aoptobj.pas 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  1. {
  2. $Id$
  3. Copyright (c) 1999 by Jonas Maebe, member of the Free Pascal
  4. Development Team
  5. This unit contains the processor independent assembler optimizer
  6. object.
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ****************************************************************************
  19. }
  20. Unit AoptObj;
  21. { general, processor independent objects for use by the assembler optimizer }
  22. Interface
  23. uses Cobjects, cpubase, aoptcpu;
  24. {***************** Constants *****************}
  25. Const
  26. { ait_* types which don't result in executable code or which don't influence }
  27. { the way the program runs/behaves }
  28. SkipInstr = [ait_comment, ait_align, ait_symbol
  29. {$ifdef GDB}
  30. ,ait_stabs, ait_stabn, ait_stab_function_name
  31. {$endif GDB}
  32. ,ait_regalloc, ait_tempalloc
  33. ];
  34. {Possible register content types}
  35. con_Unknown = 0;
  36. con_ref = 1;
  37. con_const = 2;
  38. {***************** Types ****************}
  39. Type
  40. TRegArray = Array[LoReg..HiReg] of TRegister;
  41. TRegSet = Set of LoReg..HiReg;
  42. PRegInfo = ^TReginfo;
  43. { info about the equivalence of registers when comparing two code sequences}
  44. TRegInfo = Object
  45. { registers encountered in the new and old sequence }
  46. NewRegsEncountered, OldRegsEncountered,
  47. { registers which only have been loaded for use as base or }
  48. { index in a reference later on }
  49. RegsLoadedForRef: TRegSet;
  50. { to which register in the old sequence corresponds every }
  51. { register in the new sequence }
  52. New2OldReg: TRegArray;
  53. Constructor init;
  54. { clear all information store in the object }
  55. Procedure Clear;
  56. { the contents of OldReg in the old sequence are now being }
  57. { loaded into NewReg in the new sequence }
  58. Procedure AddReg(OldReg, NewReg: TRegister); Virtual;
  59. { the contents of OldOp in the old sequence are now being }
  60. { loaded into NewOp in the new sequence. It is assumed that }
  61. { OldOp and NewOp are equivalent }
  62. Procedure AddOp(const OldOp, NewOp:Toper);
  63. { check if a register in the old sequence (OldReg) can be }
  64. { equivalent to a register in the new sequence (NewReg) if }
  65. { the operation OpAct is performed on it. The RegInfo is }
  66. { updated (not necessary to call AddReg afterwards }
  67. Function RegsEquivalent(OldReg, NewReg: TRegister;
  68. OpAct: TopAction): Boolean;
  69. { check if a reference in the old sequence (OldRef) can be }
  70. { equivalent to a reference in the new sequence (NewRef) if }
  71. { the operation OpAct is performed on it. The RegInfo is }
  72. { updated (not necessary to call AddOp afterwards }
  73. Function RefsEquivalent(Const OldRef, NewRef: TReference;
  74. OpAct: TOpAction): Boolean;
  75. { check if an operand in the old sequence (OldOp) can be }
  76. { equivalent to an operand in the new sequence (NewOp) if }
  77. { the operation OpAct is performed on it. The RegInfo is }
  78. { updated (not necessary to call AddOp afterwards }
  79. Function OpsEquivalent(const OldOp, NewOp: toper;
  80. OpAct: TopAction): Boolean;
  81. { check if an instruction in the old sequence (OldP) can be }
  82. { equivalent to an instruction in the new sequence (Newp) }
  83. { The RegInfo is updated }
  84. Function InstructionsEquivalent(OldP, NewP: Pai): Boolean;
  85. End;
  86. { possible actions on an operand: read, write or modify (= read & write) }
  87. TOpAction = (OpAct_Read, OpAct_Write, OpAct_Modify, OpAct_Unknown);
  88. { the properties of a cpu instruction }
  89. TAsmInstrucProp = Record
  90. { what it changes }
  91. Ch: Array[1..MaxCh] of TChange;
  92. End;
  93. { Object to hold on information on which regiters are in use and which not }
  94. TUsedRegs = Object
  95. Constructor init;
  96. Constructor InitWithValue(_RegSet: TRegSet);
  97. { update the info with the pairegalloc objects coming after }
  98. { p }
  99. Procedure Update(p: Pai);
  100. { is Reg currently in use }
  101. Function IsUsed(Reg: TRegister): Boolean;
  102. { get all the currently used registers }
  103. Function GetUsedRegs: TRegSet;
  104. Destructor Done;
  105. Private
  106. UsedRegs: TRegSet;
  107. End;
  108. { size of the integer that holds the state number of a register. Can be any }
  109. { integer type, so it can be changed to reduce the size of the TContent }
  110. { structure or to improve alignment }
  111. TStateInt = Byte;
  112. TContent = Packed Record
  113. { start and end of block instructions that defines the }
  114. { content of this register. If Typ = con_const, then }
  115. { Longint(StartMod) = value of the constant) } }
  116. StartMod: pai;
  117. { starts at 0, gets increased everytime the register is }
  118. { written to }
  119. WState: TStateInt;
  120. { starts at 0, gets increased everytime the register is read }
  121. { from }
  122. RState: TStateInt;
  123. { how many instructions starting with StarMod does the block }
  124. { consist of }
  125. NrOfMods: Byte;
  126. { the type of the content of the register: unknown, memory }
  127. { (variable) or constant }
  128. Typ: Byte;
  129. End;
  130. { Contents of the integer registers }
  131. TRegContent = Array[LoGPReg..HiGPReg] Of TContent;
  132. PPaiProp = ^TPaiProp;
  133. { information object with the contents of every register. Every Pai object }
  134. { gets one of these assigned: a pointer to it is stored in the OptInfo field }
  135. TPaiProp = Object
  136. Regs: TRegContent;
  137. { info about allocation of general purpose integer registers }
  138. UsedRegs: TUsedRegs;
  139. { info about the conditional registers }
  140. CondRegs: TCondRegs;
  141. { can this instruction be removed? }
  142. CanBeRemoved: Boolean;
  143. Constructor init;
  144. { destroy the contents of a register }
  145. Procedure DestroyReg(Reg: TRegister);
  146. { if the contents of WhichReg (can be R_NO in case of a }
  147. { constant) are written to memory at the location Ref, the }
  148. { contents of the registers that depend on Ref have to be }
  149. { destroyed }
  150. Procedure DestroyRefs(Const Ref: TReference; WhichReg: TRegister);
  151. { an instruction reads from operand o }
  152. Procedure ReadOp(const o:toper);
  153. { an instruction reads from reference Ref }
  154. Procedure ReadRef(Ref: PReference);
  155. { an instruction reads from register Reg }
  156. Procedure ReadReg(Reg: TRegister);
  157. { an instruction writes/modifies operand o and this has }
  158. { special side-effects or modifies the contents in such a }
  159. { way that we can't simply add this instruction to the }
  160. { sequence of instructions that describe the contents of the }
  161. { operand, so destroy it }
  162. Procedure DestroyOp(const o:Toper);
  163. { destroy the contetns of all registers }
  164. Procedure DestroyAllRegs;
  165. {$ifdef arithopt}
  166. { a register's contents are modified, but not destroyed }
  167. { (the new value depends on the old one) }
  168. Procedure ModifyReg(reg: TRegister);
  169. { an operand's contents are modified, but not destroyed }
  170. { (the new value depends on the old one) }
  171. Procedure ModifyOp(const oper: TOper);
  172. {$endif arithopt}
  173. { increase the write state of a register (call every time a }
  174. { register is written to) }
  175. Procedure IncWState(Reg: TRegister);
  176. { increase the read state of a register (call every time a }
  177. { register is read from }
  178. Procedure IncRState(Reg: TRegister);
  179. { get the write state of a register }
  180. Function GetWState(Reg: TRegister): TStateInt;
  181. { get the read state of a register }
  182. Function GetRState(Reg: TRegister): TStateInt;
  183. { get the type of contents of a register }
  184. Function GetRegContentKind(Reg: TRegister): Byte;
  185. Destructor Done;
  186. Private
  187. Procedure IncState(Reg: TRegister);
  188. End;
  189. { the number of instructions that we have encountered since the last }
  190. { modification of a register }
  191. TInstrSinceLastMod = Array[LoGPReg..HiGPReg] Of Byte;
  192. TLabelTableItem = Record
  193. PaiObj: Pai;
  194. {$IfDef JumpAnal}
  195. InstrNr: Longint;
  196. RefsFound: Word;
  197. JmpsProcessed: Word
  198. {$EndIf JumpAnal}
  199. End;
  200. TLabelTable = Array[0..2500000] Of TLabelTableItem;
  201. PLabelTable = ^TLabelTable;
  202. TLabelInfo = Record
  203. { the highest and lowest label number occurring in the current code }
  204. { fragment }
  205. LowLabel, HighLabel: AWord;
  206. LabelDif: AWord;
  207. { table that contains the addresses of the Pai_Label objects associated }
  208. { with each label number }
  209. LabelTable: PLableTable;
  210. End;
  211. {***** General optimizer object, used to derive others from *****}
  212. Type TAOptObj = Object
  213. { processor independent methods }
  214. { returns true if the label L is found between hp and the next }
  215. { instruction }
  216. Function FindLabel(L: PasmLabel; Var hp: Pai): Boolean;
  217. { inserts new_one between prev and foll in AsmL }
  218. Procedure InsertLLItem(AsmL: PAasmOutput; prev, foll, new_one:
  219. PLinkedList_Item);
  220. { returns true if register Reg is used by instruction p1 }
  221. Function RegInInstruction(Reg: TRegister; p1: Pai): Boolean;
  222. { returns true if register Reg is used in the reference Ref }
  223. Function RegInRef(Reg: TRegister; Const Ref: TReference): Boolean;
  224. { returns whether the reference Ref is used somewhere in the loading }
  225. { sequence Constent }
  226. Function TAOptObj.RefInSequence(Const Ref: TReference;
  227. Content: TContent): Boolean;
  228. { returns whether the instruction P reads from and/or writes to Reg }
  229. Function TAOptObj.RefInInstruction(Const Ref: TReference; p: Pai): Boolean;
  230. { returns true if the instruction p1 modifies the register Reg }
  231. Function RegModifiedByInstruction(Reg: TRegister; p1: Pai): Boolean;
  232. { gets the next Pai object after current that contains info relevant }
  233. { to the optimizer in p1. If there is none, it returns false and }
  234. { sets p1 to nil }
  235. Function GetNextInstruction(Current: Pai; Var Next: Pai): Boolean;
  236. { gets the previous Pai object after current that contains info }
  237. { relevant to the optimizer in last. If there is none, it retuns }
  238. { false and sets last to nil }
  239. Function GetLastInstruction(Current: Pai; Var Last: Pai): Boolean;
  240. { If P is a Pai object releveant to the optimizer, it is left }
  241. { unchanged. If it is not relevant tot he optimizer, the first }
  242. { object after P that is relevant is stored in P }
  243. Procedure SkipHead(var P: Pai);
  244. { returns true if the operands o1 and o2 are completely equal }
  245. Function OpsEqual(const o1,o2:toper): Boolean;
  246. { Returns true if a ait_alloc object for Reg is found in the block }
  247. { of Pai's starting with StartPai and ending with the next "real" }
  248. { instruction }
  249. Function FindRegAlloc(Reg: TRegister; StartPai: Pai): Boolean;
  250. { processor dependent methods }
  251. { returns the maximum width component of Reg. Only has to be }
  252. { overridden for the 80x86 (afaik) }
  253. Function RegMaxSize(Reg: TRegister): TRegister; Virtual;
  254. { returns true if Reg1 and Reg2 are of the samae width. Only has to }
  255. { overridden for the 80x86 (afaik) }
  256. Function RegsSameSize(Reg1, Reg2: TRegister): Boolean; Virtual;
  257. { returns whether P is a load instruction (load contents from a }
  258. { memory location or (register) variable into a register) }
  259. Function IsLoadInstr(p: pai): Boolean; Virtual;
  260. { returns whether P is a store instruction (store contents from a }
  261. { register to a memory location or to a (register) variable) }
  262. Function IsStoreInstr(p: pai): Boolean; Virtual;
  263. { returns whether the instruction P reads from register Reg }
  264. Function RegReadByInstr(Reg: TRegister; p: Pai); Virtual;
  265. { convert a TChange value into the corresponding register }
  266. Function TCh2Reg(Ch: TChange): TRegister; Virtual;
  267. End;
  268. {***************** Implementation *****************}
  269. Implementation
  270. {*********************** TReginfo ***********************}
  271. Constructor TRegInfo.Init;
  272. Begin
  273. Clear;
  274. End;
  275. Constructor TRegInfo.Init;
  276. Begin
  277. RegsLoadedForRef := [];
  278. NewRegsEncountered := [ProcInfo.FramePointer, R_ESP];
  279. OldRegsEncountered := [ProcInfo.FramePointer, R_ESP];
  280. New2OldReg[ProcInfo.FramePointer] := ProcInfo.FramePointer;
  281. New2OldReg[R_ESP] := R_ESP;
  282. End;
  283. Procedure TRegInfo.AddReg(OldReg, NewReg: TRegister);
  284. { updates the ???RegsEncountered and ???2???Reg fields of RegInfo. Assumes }
  285. { that OldReg and NewReg have the same size (has to be chcked in advance }
  286. { with RegsSameSize) and that neither equals R_NO }
  287. { has to be overridden for architectures like the 80x86 when not all GP }
  288. { regs are of the same size }
  289. Begin
  290. NewRegsEncountered := NewRegsEncountered + [NewReg];
  291. OldRegsEncountered := OldRegsEncountered + [OldReg];
  292. New2OldReg[NewReg] := OldReg;
  293. End;
  294. Procedure TRegInfo.AddOp(const OldOp, NewOp:Toper);
  295. Begin
  296. Case OldOp.typ Of
  297. Top_Reg:
  298. If (OldOp.reg <> R_NO) Then
  299. AddReg(OldOp.reg, NewOp.reg);
  300. Top_Ref:
  301. Begin
  302. If OldOp.ref^.base <> R_NO Then
  303. AddReg(OldOp.ref^.base, NewOp.ref^.base);
  304. {$ifdef RefsHaveIndexReg}
  305. If OldOp.ref^.index <> R_NO Then
  306. AddReg(OldOp.ref^.index, NewOp.ref^.index);
  307. {$endif RefsHaveIndexReg}
  308. End;
  309. End;
  310. End;
  311. Function TRegInfo.RegsEquivalent(OldReg, NewReg: TRegister;
  312. OPAct: TOpAction): Boolean;
  313. Begin
  314. If Not((OldReg = R_NO) Or (NewReg = R_NO)) Then
  315. If RegsSameSize(OldReg, NewReg) Then
  316. {here we always check for the 32 bit component, because it is possible that
  317. the 8 bit component has not been set, event though NewReg already has been
  318. processed. This happens if it has been compared with a register that doesn't
  319. have an 8 bit component (such as EDI). In that case the 8 bit component is
  320. still set to R_NO and the comparison in the Else-part will fail}
  321. If (RegMaxSize(OldReg) in OldRegsEncountered) Then
  322. If (RegMaxSize(NewReg) in NewRegsEncountered) Then
  323. RegsEquivalent := (OldReg = New2OldReg[NewReg])
  324. { If we haven't encountered the new register yet, but we have encountered the
  325. old one already, the new one can only be correct if it's being written to
  326. (and consequently the old one is also being written to), otherwise
  327. movl -8(%ebp), %eax and movl -8(%ebp), %eax
  328. movl (%eax), %eax movl (%edx), %edx
  329. are considered equivalent}
  330. Else
  331. If (OpAct = OpAct_Write) Then
  332. Begin
  333. AddReg(OldReg, NewReg);
  334. RegsEquivalent := True
  335. End
  336. Else Regsequivalent := False
  337. Else
  338. If Not(RegMaxSize(NewReg) in NewRegsEncountered) Then
  339. Begin
  340. AddReg(OldReg, NewReg);
  341. RegsEquivalent := True
  342. End
  343. Else RegsEquivalent := False
  344. Else RegsEquivalent := False
  345. Else RegsEquivalent := OldReg = NewReg
  346. End;
  347. Function TRegInfo.RefsEquivalent(Const OldRef, NewRef: TReference;
  348. OpAct: TOpAction): Boolean;
  349. Begin
  350. If OldRef.is_immediate Then
  351. RefsEquivalent := NewRef.is_immediate and (OldRef.Offset = NewRef.Offset)
  352. Else
  353. RefsEquivalent := (OldRef.Offset+OldRef.OffsetFixup =
  354. NewRef.Offset+NewRef.OffsetFixup) And
  355. RegsEquivalent(OldRef.Base, NewRef.Base, OpAct)
  356. {$ifdef RefsHaveindex}
  357. And RegsEquivalent(OldRef.Index, NewRef.Index, OpAct)
  358. {$endif RefsHaveIndex}
  359. {$ifdef RefsHaveScale}
  360. And (OldRef.ScaleFactor = NewRef.ScaleFactor)
  361. {$endif RefsHaveScale}
  362. And (OldRef.Symbol = NewRef.Symbol)
  363. {$ifdef RefsHaveSegment}
  364. And (OldRef.Segment = NewRef.Segment)
  365. {$endif RefsHaveSegment}
  366. ;
  367. End;
  368. Function TRegInfo.OpsEquivalent(const OldOp, NewOp: toper; OpAct: TopAction):
  369. Boolean;
  370. Begin {checks whether the two ops are equivalent}
  371. OpsEquivalent := False;
  372. if OldOp.typ=NewOp.typ then
  373. Case OldOp.typ Of
  374. Top_Const: OpsEquivalent := OldOp.value = NewOp.value;
  375. Top_Reg:
  376. OpsEquivalent := RegsEquivalent(OldOp.reg,NewOp.reg, OpAct);
  377. Top_Ref:
  378. OpsEquivalent := RefsEquivalent(OldOp.ref^, NewOp.ref^, OpAct);
  379. Top_None:
  380. OpsEquivalent := True
  381. End;
  382. End;
  383. Function TRegInfo.InstructionsEquivalent(OldP, NewP: Pai): Boolean;
  384. { checks whether two PInstr instructions are equal }
  385. Var Count: TNatInt;
  386. TmpResult: Boolean;
  387. Begin
  388. If Assigned(OldP) And Assigned(NewP) And
  389. (Pai(OldP)^.typ = ait_instruction) And
  390. (Pai(NewP)^.typ = ait_instruction) And
  391. (PInstr(OldP)^.opcode = PInstr(NewP)^.opcode) And
  392. (PInstr(OldP)^.oper[0].typ = PInstr(NewP)^.oper[0].typ) And
  393. (PInstr(OldP)^.oper[1].typ = PInstr(NewP)^.oper[1].typ) And
  394. (PInstr(OldP)^.oper[2].typ = PInstr(NewP)^.oper[2].typ)
  395. Then
  396. { both instructions have the same structure: }
  397. { "<operator> <operand of type1>, <operand of type 2>" }
  398. If IsLoadInstr(OldP) {then also NewP = loadinstr} Then
  399. If Not(RegInRef(PInstr(OldP)^.oper[LoadDst].reg,
  400. PInstr(OldP)^.oper[LoadSrc].ref^)) Then
  401. { the "old" instruction is a load of a register with a new value, not with }
  402. { a value based on the contents of this register (so no "mov (reg), reg") }
  403. If Not(RegInRef(PInstr(NewP)^.oper[LoadDst].reg,
  404. PInstr(NewP)^.oper[LoadSrc].ref^)) And
  405. RefsEqual(PInstr(OldP)^.oper[LoadSrc].ref^,
  406. PInstr(NewP)^.oper[LoadSrc].ref^)
  407. Then
  408. { the "new" instruction is also a load of a register with a new value, and }
  409. { this value is fetched from the same memory location }
  410. Begin
  411. With PInstr(NewP)^.oper[LoadSrc].ref^ Do
  412. Begin
  413. If Not(Base in [ProcInfo.FramePointer, R_NO, StackPtr])
  414. { it won't do any harm if the register is already in RegsLoadedForRef }
  415. Then RegsLoadedForRef := RegsLoadedForRef + [Base];
  416. {$ifdef RefsHaveIndex}
  417. If Not(Index in [ProcInfo.FramePointer, R_NO, R_StackPtr])
  418. Then RegsLoadedForRef := RegsLoadedForRef + [Index];
  419. {$endif RefsHaveIndex}
  420. End;
  421. { add the registers from the reference (.oper[Src]) to the RegInfo, all }
  422. { registers from the reference are the same in the old and in the new }
  423. { instruction sequence }
  424. AddOp(PInstr(OldP)^.oper[Src], PInstr(OldP)^.oper[Src]);
  425. { the registers from .oper[Dest] have to be equivalent, but not necessarily }
  426. { equal }
  427. InstructionsEquivalent :=
  428. RegsEquivalent(PInstr(OldP)^.oper[Dest].reg,
  429. PInstr(NewP)^.oper[Dest].reg, OpAct_Write);
  430. End
  431. { the registers are loaded with values from different memory locations. If }
  432. { this were allowed, the instructions "mov -4(%esi),%eax" and }
  433. { "mov -4(%ebp),%eax" would be considered equivalent }
  434. Else InstructionsEquivalent := False
  435. Else
  436. { load register with a value based on the current value of this register }
  437. Begin
  438. With PInstr(NewP)^.oper[0].ref^ Do
  439. { Assume the registers occurring in the reference have only been loaded with }
  440. { the value they contain now to calculate an address (so the value they have }
  441. { now, won't be stored to memory later on)}
  442. Begin
  443. If Not(Base in [ProcInfo.FramePointer,
  444. RegMaxSize(PInstr(NewP)^.oper[LoadDst].reg),
  445. R_NO,StackPtr])
  446. { It won't do any harm if the register is already in RegsLoadedForRef }
  447. Then
  448. Begin
  449. RegsLoadedForRef := RegsLoadedForRef + [Base];
  450. {$ifdef csdebug}
  451. Writeln(att_reg2str[base], ' added');
  452. {$endif csdebug}
  453. end;
  454. {$Ifdef RefsHaveIndex}
  455. If Not(Index in [ProcInfo.FramePointer,
  456. RegMaxSize(PInstr(NewP)^.oper[LoadDst].reg),
  457. R_NO,StackPtr])
  458. Then
  459. Begin
  460. RegsLoadedForRef := RegsLoadedForRef + [Index];
  461. {$ifdef csdebug}
  462. Writeln(att_reg2str[index], ' added');
  463. {$endif csdebug}
  464. end;
  465. {$endif RefsHaveIndex}
  466. End;
  467. { now, remove the destination register of the load from the }
  468. { RegsLoadedForReg, since if it's loaded with a new value, it certainly }
  469. { will still be used later on }
  470. If Not(RegMaxSize(PInstr(NewP)^.oper[LoadDst].reg) In
  471. [ProcInfo.FramePointer,R_NO,StackPtr])
  472. Then
  473. Begin
  474. RegsLoadedForRef := RegsLoadedForRef -
  475. [RegMaxSize(PInstr(NewP)^.oper[LoadDst].reg)];
  476. {$ifdef csdebug}
  477. Writeln(att_reg2str[Reg32(Pai386(NewP)^.oper[1].reg)], ' removed');
  478. {$endif csdebug}
  479. end;
  480. InstructionsEquivalent :=
  481. OpsEquivalent(PInstr(OldP)^.oper[LoadSrc],
  482. PInstr(NewP)^.oper[LoadSrc], OpAct_Read) And
  483. OpsEquivalent(PInstr(OldP)^.oper[LoadDst],
  484. PInstr(NewP)^.oper[LoadDst], OpAct_Write)
  485. End
  486. Else
  487. {an instruction that's not a load instruction}
  488. Begin
  489. Count := 0;
  490. TmpResult := true;
  491. Repeat
  492. TmpResult :=
  493. OpsEquivalent(PInstr(OldP)^.oper[Count], PInstr(NewP)^.oper[Count],
  494. OpAct_Unknown);
  495. Inc(Count)
  496. Until (Count = MaxOps) or not(TmpResult);
  497. InstructionsEquivalent := TmpResult
  498. End
  499. { the instructions haven't even got the same structure, so they're certainly }
  500. { not equivalent }
  501. Else InstructionsEquivalent := False;
  502. End;
  503. {*************************** TUsedRegs ***************************}
  504. Constructor TUsedRegs.init;
  505. Begin
  506. UsedRegs := [];
  507. End;
  508. Constructor TUsedRegisters.InitWithValue(Const _RegSet: TRegSet);
  509. Begin
  510. RegSet := _RegSet;
  511. End;
  512. Procedure TUsedRegs.Update(p: Pai);
  513. {updates UsedRegs with the RegAlloc Information coming after P}
  514. Begin
  515. Repeat
  516. While Assigned(p) And
  517. ((p^.typ in (SkipInstr - [ait_RegAlloc])) or
  518. ((p^.typ = ait_label) And
  519. Not(Pai_Label(p)^.l^.is_used))) Do
  520. p := Pai(p^.next);
  521. While Assigned(p) And
  522. (p^.typ=ait_RegAlloc) Do
  523. Begin
  524. if pairegalloc(p)^.allocation then
  525. UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg]
  526. else
  527. UsedRegs := UsedRegs - [PaiRegAlloc(p)^.Reg];
  528. p := pai(p^.next);
  529. End;
  530. Until Not(Assigned(p)) Or
  531. (Not(p^.typ in SkipInstr) And
  532. Not((p^.typ = ait_label) And
  533. Not(Pai_Label(p)^.l^.is_used)));
  534. End;
  535. Function TUsedRegs.IsUsed(Reg: TRegister): Boolean;
  536. Begin
  537. IsUsed := Reg in UsedRegs
  538. End;
  539. Function TUsedRegs.GetUsedRegs: TRegSet;
  540. Begin
  541. GetUsedRegs := UsedRegs;
  542. End;
  543. {*************************** TPaiProp ***************************}
  544. Constructor TPaiProp.Init;
  545. Begin
  546. UsedRegs.Init;
  547. CondRegs.init;
  548. { DirFlag: TFlagContents; I386 specific}
  549. End;
  550. Procedure TPaiProp.DestroyReg(Reg: TRegister);
  551. {Destroys the contents of the register Reg in the PPaiProp p1, as well as the
  552. contents of registers are loaded with a memory location based on Reg}
  553. Var TmpWState, TmpRState: Byte;
  554. Counter: TRegister;
  555. Begin
  556. Reg := Reg32(Reg);
  557. NrOfInstrSinceLastMod[Reg] := 0;
  558. If (Reg >= R_EAX) And (Reg <= R_EDI)
  559. Then
  560. Begin
  561. With Regs[Reg] Do
  562. Begin
  563. IncState(WState);
  564. TmpWState := WState;
  565. TmpRState := RState;
  566. FillChar(Regs[Reg], SizeOf(TContent), 0);
  567. WState := TmpWState;
  568. RState := TmpRState;
  569. End;
  570. For Counter := R_EAX to R_EDI Do
  571. With Regs[Counter] Do
  572. If (Typ = Con_Ref) And
  573. RegInSequence(Reg, Regs[Counter])
  574. Then
  575. Begin
  576. IncState(WState);
  577. TmpWState := WState;
  578. TmpRState := RState;
  579. FillChar(Regs[Counter], SizeOf(TContent), 0);
  580. WState := TmpWState;
  581. RState := TmpRState;
  582. End;
  583. End;
  584. End;
  585. Procedure TPaiProp.DestroyRefs(Const Ref: TReference; WhichReg: TRegister);
  586. {destroys all registers which possibly contain a reference to Ref, WhichReg
  587. is the register whose contents are being written to memory (if this proc
  588. is called because of a "mov?? %reg, (mem)" instruction)}
  589. Var Counter: TRegister;
  590. Begin
  591. WhichReg := RegMaxSize(WhichReg);
  592. If ((Ref.base = ProcInfo.FramePointer) And
  593. {$ifdef refsHaveIndex}
  594. (Ref.Index = R_NO)
  595. {$endif refsHaveIndex}
  596. ) Or
  597. Assigned(Ref.Symbol)
  598. Then
  599. {write something to a parameter, a local or global variable, so
  600. * with uncertain optimizations on:
  601. - destroy the contents of registers whose contents have somewhere a
  602. "mov?? (Ref), %reg". WhichReg (this is the register whose contents
  603. are being written to memory) is not destroyed if it's StartMod is
  604. of that form and NrOfMods = 1 (so if it holds ref, but is not a
  605. pointer or value based on Ref)
  606. * with uncertain optimizations off:
  607. - also destroy registers that contain any pointer}
  608. For Counter := LoGPReg to HiGPReg Do
  609. With Regs[Counter] Do
  610. Begin
  611. If (typ = Con_Ref) And
  612. ((Not(cs_UncertainOpts in aktglobalswitches) And
  613. (NrOfMods <> 1)
  614. ) Or
  615. (RefInSequence(Ref,Regs[Counter]) And
  616. ((Counter <> WhichReg) Or
  617. ((NrOfMods <> 1) And
  618. {StarMod is always of the type ait_instruction}
  619. (PInstr(StartMod)^.oper[0].typ = top_ref) And
  620. RefsEqual(PInstr(StartMod)^.oper[0].ref^, Ref)
  621. )
  622. )
  623. )
  624. )
  625. Then
  626. DestroyReg(Counter)
  627. End
  628. Else
  629. {write something to a pointer location, so
  630. * with uncertain optimzations on:
  631. - do not destroy registers which contain a local/global variable or a
  632. parameter, except if DestroyRefs is called because of a "movsl"
  633. * with uncertain optimzations off:
  634. - destroy every register which contains a memory location
  635. }
  636. For Counter := LoGPReg to HiGPReg Do
  637. With Regs[Counter] Do
  638. If (typ = Con_Ref) And
  639. (Not(cs_UncertainOpts in aktglobalswitches) Or
  640. {$ifdef i386}
  641. {for movsl}
  642. (Ref.Base = R_EDI) Or
  643. {$endif}
  644. {don't destroy if reg contains a parameter, local or global variable}
  645. Not((NrOfMods = 1) And
  646. (PInstr(StartMod)^.oper[0].typ = top_ref) And
  647. ((PInstr(StartMod)^.oper[0].ref^.base = ProcInfo.FramePointer) Or
  648. Assigned(PInstr(StartMod)^.oper[0].ref^.Symbol)
  649. )
  650. )
  651. )
  652. Then DestroyReg(Counter)
  653. End;
  654. Procedure TPaiProp.DestroyAllRegs;
  655. Var Counter: TRegister;
  656. Begin {initializes/desrtoys all registers}
  657. For Counter := R_EAX To R_EDI Do
  658. DestroyReg(Counter);
  659. CondRegs.Init;
  660. { FPURegs.Init; }
  661. End;
  662. Procedure TPaiProp.DestroyOp(const o:Toper);
  663. Begin
  664. Case o.typ Of
  665. top_reg: DestroyReg(o.reg);
  666. top_ref: DestroyRefs(o.ref^, R_NO);
  667. top_symbol:;
  668. End;
  669. End;
  670. Procedure TPaiProp.ReadReg(Reg: TRegister);
  671. Begin
  672. Reg := RegMaxSize(Reg);
  673. If Reg in General_Registers Then
  674. IncRState(RegMaxSize(Reg))
  675. End;
  676. Procedure TPaiProp.ReadRef(Ref: PReference);
  677. Begin
  678. If Ref^.Base <> R_NO Then
  679. ReadReg(Ref^.Base);
  680. If Ref^.Index <> R_NO Then
  681. ReadReg(Ref^.Index);
  682. End;
  683. Procedure TPaiProp.ReadOp(const o:toper);
  684. Begin
  685. Case o.typ Of
  686. top_reg: ReadReg(o.reg);
  687. top_ref: ReadRef(o.ref);
  688. top_symbol : ;
  689. End;
  690. End;
  691. {$ifdef arithopt}
  692. Procedure TPaiProp.ModifyReg(reg: TRegister);
  693. Begin
  694. With Regs[reg] Do
  695. If (Typ = Con_Ref)
  696. Then
  697. Begin
  698. IncState(WState);
  699. {also store how many instructions are part of the sequence in the first
  700. instructions PPaiProp, so it can be easily accessed from within
  701. CheckSequence}
  702. Inc(NrOfMods, NrOfInstrSinceLastMod[Reg]);
  703. PPaiProp(StartMod^.OptInfo)^.Regs[Reg].NrOfMods := NrOfMods;
  704. NrOfInstrSinceLastMod[Reg] := 0;
  705. End
  706. Else
  707. DestroyReg(Reg);
  708. End;
  709. Procedure TPaiProp.ModifyOp(const oper: TOper);
  710. Begin
  711. If oper.typ = top_reg Then
  712. ModifyReg(RegMaxSize(oper.reg))
  713. Else
  714. Begin
  715. ReadOp(oper);
  716. DestroyOp(oper);
  717. End
  718. End;
  719. {$endif arithopt}
  720. Procedure TPaiProp.IncWState(Reg: TRegister);{$ifdef fpc} inline;{$endif fpc}
  721. Begin
  722. IncState(Regs[Reg].WState);
  723. End;
  724. Procedure TPaiProp.IncRState(Reg: TRegister);{$ifdef fpc} inline;{$endif fpc}
  725. Begin
  726. IncState(Regs[Reg].RState);
  727. End;
  728. Procedure TPaiProp.IncState(Var s: TStateInt); {$ifdef fpc} inline;{$endif fpc}
  729. Begin
  730. If s <> $ff Then Inc(s)
  731. Else s := 0
  732. End;
  733. Function TPaiProp.GetWState(Reg: TRegister): TStateInt;
  734. Begin
  735. GetWState := Regs[Reg].WState
  736. End;
  737. Function TPaiProp.GetRState(Reg: TRegister): TStateInt;
  738. Begin
  739. GetRState := Regs[Reg].RState
  740. End;
  741. Function TPaiProp.GetRegContentKind(Reg: TRegister): Byte;
  742. Begin
  743. GetRegContentKind := Regs[Reg].ty
  744. End;
  745. {******************* TAOptObj *******************}
  746. Function TAOptObj.FindLabel(L: PasmLabel; Var hp: Pai): Boolean;
  747. Var TempP: Pai;
  748. Begin
  749. TempP := hp;
  750. While Assigned(TempP) and
  751. (TempP^.typ In SkipInstr + [ait_label]) Do
  752. If (TempP^.typ <> ait_Label) Or
  753. (pai_label(TempP)^.l <> L)
  754. Then GetNextInstruction(TempP, TempP)
  755. Else
  756. Begin
  757. hp := TempP;
  758. FindLabel := True;
  759. exit
  760. End;
  761. FindLabel := False;
  762. End;
  763. Procedure TAOptObj.InsertLLItem(AsmL: PAasmOutput; prev, foll, new_one:
  764. PLinkedList_Item);
  765. Begin
  766. If Assigned(prev) Then
  767. If Assigned(foll) Then
  768. Begin
  769. If Assigned(new_one) Then
  770. Begin
  771. new_one^.previous := prev;
  772. new_one^.next := foll;
  773. prev^.next := new_one;
  774. foll^.previous := new_one;
  775. new_one^.fileinfo := foll^.fileinfo
  776. End
  777. End
  778. Else AsmL^.Concat(new_one)
  779. Else If Assigned(Foll) Then AsmL^.Insert(new_one)
  780. End;
  781. Function TAOptObj.RegInInstruction(Reg: TRegister; p1: Pai): Boolean;
  782. Var Count: TNatInt;
  783. TmpResult: Boolean;
  784. Begin
  785. TmpResult := False;
  786. Count := 0;
  787. If (p1^.typ = ait_instruction) Then
  788. Repeat
  789. TmpResult := RegInOp(Reg, PInstr(p1)^.oper[Count]);
  790. Inc(Count)
  791. Until (Count = MaxOps) or TmpResult;
  792. RegInInstruction := TmpResult
  793. End;
  794. Function TAOptObj.RegInOp(Reg: TRegister; const op: toper): Boolean;
  795. Begin
  796. Case op.typ Of
  797. Top_Reg: RegInOp := Reg = op.reg;
  798. Top_Ref: RegInOp := RegInRef(Reg, op.ref^)
  799. Else RegInOp := False
  800. End
  801. End;
  802. Function TAOptObj.RegModifiedByInstruction(Reg: TRegister; p1: Pai): Boolean;
  803. Var hp: Pai;
  804. Begin
  805. If GetLastInstruction(p1, hp)
  806. Then
  807. RegModifiedByInstruction :=
  808. PPAiProp(p1^.OptInfo)^.Regs[Reg].WState <>
  809. PPAiProp(hp^.OptInfo)^.Regs[Reg].WState
  810. Else RegModifiedByInstruction := True;
  811. End;
  812. Function TAOptObj.GetNextInstruction(Current: Pai; Var Next: Pai): Boolean;
  813. Begin
  814. Repeat
  815. Current := Pai(Current^.Next);
  816. While Assigned(Current) And
  817. ((Current^.typ In SkipInstr) or
  818. ((Current^.typ = ait_label) And
  819. Not(Pai_Label(Current)^.l^.is_used))) Do
  820. Current := Pai(Current^.Next);
  821. If Assigned(Current) And
  822. (Current^.typ = ait_Marker) And
  823. (Pai_Marker(Current)^.Kind = NoPropInfoStart) Then
  824. Begin
  825. While Assigned(Current) And
  826. ((Current^.typ <> ait_Marker) Or
  827. (Pai_Marker(Current)^.Kind <> NoPropInfoEnd)) Do
  828. Current := Pai(Current^.Next);
  829. End;
  830. Until Not(Assigned(Current)) Or
  831. (Current^.typ <> ait_Marker) Or
  832. (Pai_Marker(Current)^.Kind <> NoPropInfoEnd);
  833. Next := Current;
  834. If Assigned(Current) And
  835. Not((Current^.typ In SkipInstr) or
  836. ((Current^.typ = ait_label) And
  837. Not(Pai_Label(Current)^.l^.is_used)))
  838. Then GetNextInstruction := True
  839. Else
  840. Begin
  841. Next := Nil;
  842. GetNextInstruction := False;
  843. End;
  844. End;
  845. Function TAOptObj.GetLastInstruction(Current: Pai; Var Last: Pai): Boolean;
  846. Begin
  847. Repeat
  848. Current := Pai(Current^.previous);
  849. While Assigned(Current) And
  850. (((Current^.typ = ait_Marker) And
  851. Not(Pai_Marker(Current)^.Kind in [AsmBlockEnd,NoPropInfoEnd])) or
  852. (Current^.typ In SkipInstr) or
  853. ((Current^.typ = ait_label) And
  854. Not(Pai_Label(Current)^.l^.is_used))) Do
  855. Current := Pai(Current^.previous);
  856. If Assigned(Current) And
  857. (Current^.typ = ait_Marker) And
  858. (Pai_Marker(Current)^.Kind = NoPropInfoEnd) Then
  859. Begin
  860. While Assigned(Current) And
  861. ((Current^.typ <> ait_Marker) Or
  862. (Pai_Marker(Current)^.Kind <> NoPropInfoStart)) Do
  863. Current := Pai(Current^.previous);
  864. End;
  865. Until Not(Assigned(Current)) Or
  866. (Current^.typ <> ait_Marker) Or
  867. (Pai_Marker(Current)^.Kind <> NoPropInfoStart);
  868. If Not(Assigned(Current)) or
  869. (Current^.typ In SkipInstr) or
  870. ((Current^.typ = ait_label) And
  871. Not(Pai_Label(Current)^.l^.is_used)) or
  872. ((Current^.typ = ait_Marker) And
  873. (Pai_Marker(Current)^.Kind = AsmBlockEnd))
  874. Then
  875. Begin
  876. Last := Nil;
  877. GetLastInstruction := False
  878. End
  879. Else
  880. Begin
  881. Last := Current;
  882. GetLastInstruction := True;
  883. End;
  884. End;
  885. Procedure TAOptObj.SkipHead(var P: Pai);
  886. { skips Pai objects at the start of a block that don't do anything }
  887. Var OldP: Pai;
  888. Begin
  889. Repeat
  890. OldP := P;
  891. If (P^.typ in SkipInstr) Or
  892. ((P^.typ = ait_marker) And
  893. (Pai_Marker(P)^.Kind = AsmBlockEnd)) Then
  894. GetNextInstruction(P, P)
  895. Else If ((P^.Typ = Ait_Marker) And
  896. (Pai_Marker(P)^.Kind = NoPropInfoStart)) Then
  897. { a marker of the type NoPropInfoStart can't be the first instruction of a }
  898. { paasmoutput list }
  899. GetNextInstruction(Pai(P^.Previous),P);
  900. If (P^.Typ = Ait_Marker) And
  901. (Pai_Marker(P)^.Kind = AsmBlockStart) Then
  902. Begin
  903. P := Pai(P^.Next);
  904. While (P^.typ <> Ait_Marker) Or
  905. (Pai_Marker(P)^.Kind <> AsmBlockEnd) Do
  906. P := Pai(P^.Next)
  907. End;
  908. Until P = OldP
  909. End;
  910. Function TAOptObj.OpsEqual(const o1,o2:toper): Boolean;
  911. Begin
  912. if o1.typ=o2.typ then
  913. Case o1.typ Of
  914. Top_Reg :
  915. OpsEqual:=o1.reg=o2.reg;
  916. Top_Ref :
  917. OpsEqual := RefsEqual(o1.ref^, o2.ref^);
  918. Top_Const :
  919. OpsEqual:=o1.val=o2.val;
  920. Top_Symbol :
  921. OpsEqual:=(o1.sym=o2.sym) and (o1.symofs=o2.symofs);
  922. Top_None :
  923. OpsEqual := True
  924. else OpsEqual := False
  925. End;
  926. End;
  927. Function TAOptObj.FindRegAlloc(Reg: TRegister; StartPai: Pai): Boolean;
  928. Begin
  929. FindRegAlloc:=False;
  930. Repeat
  931. While Assigned(StartPai) And
  932. ((StartPai^.typ in (SkipInstr - [ait_regAlloc])) Or
  933. ((StartPai^.typ = ait_label) and
  934. Not(Pai_Label(StartPai)^.l^.Is_Used))) Do
  935. StartPai := Pai(StartPai^.Next);
  936. If Assigned(StartPai) And
  937. (StartPai^.typ = ait_regAlloc) and (PairegAlloc(StartPai)^.allocation) Then
  938. Begin
  939. if PairegAlloc(StartPai)^.Reg = Reg then
  940. begin
  941. FindRegAlloc:=true;
  942. exit;
  943. end;
  944. StartPai := Pai(StartPai^.Next);
  945. End
  946. else
  947. exit;
  948. Until false;
  949. End;
  950. Function TAOptObj.RefsEqual(Const R1, R2: TReference): Boolean;
  951. Begin
  952. If R1.is_immediate Then
  953. RefsEqual := R2.is_immediate and (R1.Offset = R2.Offset)
  954. Else
  955. RefsEqual := (R1.Offset+R1.OffsetFixup = R2.Offset+R2.OffsetFixup)
  956. And (R1.Base = R2.Base)
  957. {$ifdef RefsHaveindex}
  958. And (R1.Index = R2.Index)
  959. {$endif RefsHaveindex}
  960. {$ifdef RefsHaveScale}
  961. And (R1.ScaleFactor = R2.ScaleFactor)
  962. {$endif RefsHaveScale}
  963. And (R1.Symbol = R2.Symbol)
  964. {$ifdef RefsHaveSegment}
  965. And (R1.Segment = R2.Segment)
  966. {$endif RefsHaveSegment}
  967. ;
  968. Function TAOptObj.RegInRef(Reg: TRegister; Const Ref: TReference): Boolean;
  969. Begin
  970. Reg := RegMaxSize(Reg);
  971. RegInRef := (Ref.Base = Reg)
  972. {$ifdef RefsHaveIndexReg}
  973. Or (Ref.Index = Reg)
  974. {$endif RefsHaveIndexReg}
  975. End;
  976. Function TAOptObj.RegModifiedByInstruction(Reg: TRegister; p1: Pai): Boolean;
  977. Var hp: Pai;
  978. Begin
  979. If GetLastInstruction(p1, hp)
  980. Then
  981. RegModifiedByInstruction :=
  982. PPAiProp(p1^.OptInfo)^.GetWState <>
  983. PPAiProp(hp^.OptInfo)^.GetWState
  984. Else RegModifiedByInstruction := True;
  985. End;
  986. Function TAOptObj.RefInInstruction(Const Ref: TReference; p: Pai): Boolean;
  987. Var Count: TNatInt;
  988. TmpResult: Boolean;
  989. Begin
  990. TmpResult := False;
  991. If (p^.typ = ait_instruction) Then
  992. Begin
  993. Count := 0;
  994. Repeat
  995. If (PInstr(p)^.oper[Count].typ = Top_Ref) Then
  996. TmpResult := RefsEqual(Ref, PInstr(p)^.oper[Count].ref^);
  997. Inc(Count);
  998. Until (Count = MaxOps) or TmpResult;
  999. End;
  1000. RefInInstruction := TmpResult;
  1001. End;
  1002. Function TAOptObj.RefInSequence(Const Ref: TReference; Content: TContent):
  1003. Boolean;
  1004. Var p: Pai;
  1005. Counter: Byte;
  1006. TmpResult: Boolean;
  1007. Begin
  1008. p := Content.StartMod;
  1009. TmpResult := False;
  1010. Counter := 1;
  1011. While Not(TmpResult) And
  1012. (Counter <= Content.NrOfMods) Do
  1013. Begin
  1014. If (p^.typ = ait_instruction) And
  1015. RefInInstruction(Ref, p)
  1016. Then TmpResult := True;
  1017. Inc(Counter);
  1018. GetNextInstruction(p,p)
  1019. End;
  1020. RefInSequence := TmpResult
  1021. End;
  1022. Function TAOptObj.RegMaxSize(Reg: TRegister): TRegister;
  1023. Begin
  1024. RegMaxSize := Reg
  1025. End;
  1026. Function TAOptObj.RegsSameSize(Reg1, Reg2: TRegister): Boolean;
  1027. Begin
  1028. RegsSameSize := True
  1029. End;
  1030. Function TAOptObj.IsLoadInstr(p: pai): Boolean;
  1031. Begin
  1032. Abstract
  1033. End;
  1034. Function TAOptObj.RegReadByInstr(Reg: TRegister; p: Pai);
  1035. Begin
  1036. Abstract
  1037. End;
  1038. Function TAOptObj.IsStoreInstr(p: pai): Boolean;
  1039. Begin
  1040. Abstract
  1041. End;
  1042. Function TAOptObj.TCh2Reg(Ch: TChange): TRegister;
  1043. Begin
  1044. Abstract
  1045. End;
  1046. End.
  1047. {
  1048. $Log$
  1049. Revision 1.1 1999-08-08 13:24:50 jonas
  1050. + added copyright header/GNU license info
  1051. * made the assembler optimizer almost completely OOP
  1052. * some code style clean up and extra comments
  1053. * moved from the new/aopt to the /new and /new/i386 dirs
  1054. }