aasmtai.pas 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements an abstract asmoutput class for all processor types
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. { @abstract(This unit implements an abstract asm output class for all processor types)
  19. This unit implements an abstract assembler output class for all processors, these
  20. are then overriden for each assembler writer to actually write the data in these
  21. classes to an assembler file.
  22. }
  23. unit aasmtai;
  24. {$i fpcdefs.inc}
  25. interface
  26. uses
  27. cutils,cclasses,
  28. globtype,globals,systems,
  29. cpuinfo,cpubase,
  30. cgbase,cgutils,
  31. symtype,
  32. aasmbase;
  33. type
  34. taitype = (
  35. ait_none,
  36. ait_align,
  37. ait_section,
  38. ait_comment,
  39. ait_direct,
  40. ait_string,
  41. ait_instruction,
  42. ait_datablock,
  43. ait_symbol,
  44. ait_symbol_end, { needed to calc the size of a symbol }
  45. ait_label,
  46. ait_const_64bit,
  47. ait_const_32bit,
  48. ait_const_16bit,
  49. ait_const_8bit,
  50. ait_const_symbol,
  51. { the following is only used by the win32 version of the compiler }
  52. { and only the GNU AS Win32 is able to write it }
  53. ait_const_rva,
  54. ait_real_32bit,
  55. ait_real_64bit,
  56. ait_real_80bit,
  57. ait_comp_64bit,
  58. ait_real_128bit,
  59. {$ifdef GDB}
  60. ait_stabn,
  61. ait_stabs,
  62. ait_force_line,
  63. ait_stab_function_name,
  64. {$endif GDB}
  65. {$ifdef alpha}
  66. { the follow is for the DEC Alpha }
  67. ait_frame,
  68. ait_ent,
  69. {$endif alpha}
  70. {$ifdef ia64}
  71. ait_bundle,
  72. ait_stop,
  73. {$endif ia64}
  74. {$ifdef m68k}
  75. ait_labeled_instruction,
  76. {$endif m68k}
  77. { used to split into tiny assembler files }
  78. ait_cut,
  79. ait_regalloc,
  80. ait_tempalloc,
  81. { used to mark assembler blocks and inlined functions }
  82. ait_marker,
  83. { special symbols for darwin pic code }
  84. ait_indirect_symbol,
  85. ait_non_lazy_symbol_pointer
  86. );
  87. const
  88. taitypestr : array[taitype] of string[24] = (
  89. '<none>',
  90. 'align',
  91. 'section',
  92. 'comment',
  93. 'direct',
  94. 'string',
  95. 'instruction',
  96. 'datablock',
  97. 'symbol',
  98. 'symbol_end',
  99. 'label',
  100. 'const_64bit',
  101. 'const_32bit',
  102. 'const_16bit',
  103. 'const_8bit',
  104. 'const_symbol',
  105. 'const_rva',
  106. 'real_32bit',
  107. 'real_64bit',
  108. 'real_80bit',
  109. 'comp_64bit',
  110. 'real_128bit',
  111. {$ifdef GDB}
  112. 'stabn',
  113. 'stabs',
  114. 'force_line',
  115. 'stab_funcname',
  116. {$endif GDB}
  117. {$ifdef alpha}
  118. { the follow is for the DEC Alpha }
  119. 'frame',
  120. 'ent',
  121. {$endif alpha}
  122. {$ifdef ia64}
  123. 'bundle',
  124. 'stop',
  125. {$endif ia64}
  126. {$ifdef m68k}
  127. 'labeled_instr',
  128. {$endif m68k}
  129. 'cut',
  130. 'regalloc',
  131. 'tempalloc',
  132. 'marker',
  133. 'indirect_symbol',
  134. 'non_lazy_symbol_pointer'
  135. );
  136. type
  137. { Types of operand }
  138. toptype=(top_none,top_reg,top_ref,top_const,top_bool,top_local,
  139. { ARM only }
  140. top_regset,
  141. top_shifterop,
  142. { m68k only }
  143. top_reglist);
  144. { kinds of operations that an instruction can perform on an operand }
  145. topertype = (operand_read,operand_write,operand_readwrite);
  146. tlocaloper = record
  147. localsym : pointer;
  148. localsymderef : tderef;
  149. localsymofs : longint;
  150. localindexreg : tregister;
  151. localscale : byte;
  152. localgetoffset : boolean
  153. end;
  154. plocaloper = ^tlocaloper;
  155. { please keep the size of this record <=12 bytes and keep it properly aligned }
  156. toper = record
  157. ot : longint;
  158. case typ : toptype of
  159. top_none : ();
  160. top_reg : (reg:tregister);
  161. top_ref : (ref:preference);
  162. top_const : (val:aword);
  163. top_bool : (b:boolean);
  164. { local varsym that will be inserted in pass_2 }
  165. top_local : (localoper:plocaloper);
  166. {$ifdef arm}
  167. top_regset : (regset:^tcpuregisterset);
  168. top_shifterop : (shifterop : pshifterop);
  169. {$endif arm}
  170. {$ifdef m68k}
  171. top_regset : (regset:^tcpuregisterset);
  172. {$endif m68k}
  173. end;
  174. poper=^toper;
  175. { ait_* types which don't result in executable code or which don't influence }
  176. { the way the program runs/behaves, but which may be encountered by the }
  177. { optimizer (= if it's sometimes added to the exprasm list). Update if you add }
  178. { a new ait type! }
  179. const
  180. SkipInstr = [ait_comment, ait_symbol,ait_section
  181. {$ifdef GDB}
  182. ,ait_stabs, ait_stabn, ait_stab_function_name, ait_force_line
  183. {$endif GDB}
  184. ,ait_regalloc, ait_tempalloc, ait_symbol_end];
  185. { ait_* types which do not have line information (and hence which are of type
  186. tai, otherwise, they are of type tailineinfo }
  187. SkipLineInfo =[ait_label,
  188. ait_regalloc,ait_tempalloc,
  189. {$ifdef GDB}
  190. ait_stabn,ait_stabs,ait_stab_function_name,
  191. {$endif GDB}
  192. ait_cut,ait_marker,ait_align,ait_section,ait_comment,
  193. ait_const_8bit,ait_const_16bit,ait_const_32bit,
  194. ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit,
  195. ait_non_lazy_symbol_pointer
  196. ];
  197. type
  198. { cut type, required for alphanumeric ordering of the assembler filenames }
  199. TCutPlace=(cut_normal,cut_begin,cut_end);
  200. TMarker = (NoPropInfoStart,NoPropInfoEnd,
  201. AsmBlockStart,AsmBlockEnd,
  202. InlineStart,InlineEnd,marker_blockstart,
  203. marker_position);
  204. { Buffer type used for alignment }
  205. tfillbuffer = array[0..63] of char;
  206. Tspill_temp_list=array[tsuperregister] of Treference;
  207. { abstract assembler item }
  208. tai = class(TLinkedListItem)
  209. {$ifndef NOOPT}
  210. { pointer to record with optimizer info about this tai object }
  211. optinfo : pointer;
  212. {$endif NOOPT}
  213. typ : taitype;
  214. constructor Create;
  215. constructor ppuload(t:taitype;ppufile:tcompilerppufile);virtual;
  216. procedure ppuwrite(ppufile:tcompilerppufile);virtual;
  217. procedure buildderefimpl;virtual;
  218. procedure derefimpl;virtual;
  219. end;
  220. { abstract assembler item with line information }
  221. tailineinfo = class(tai)
  222. fileinfo : tfileposinfo;
  223. constructor Create;
  224. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  225. procedure ppuwrite(ppufile:tcompilerppufile);override;
  226. end;
  227. tai_simple = class(tai)
  228. constructor create(_typ : taitype);
  229. end;
  230. taiclass = class of tai;
  231. taiclassarray = array[taitype] of taiclass;
  232. { Generates an assembler string }
  233. tai_string = class(tailineinfo)
  234. str : pchar;
  235. { extra len so the string can contain an \0 }
  236. len : longint;
  237. constructor Create(const _str : string);
  238. constructor Create_pchar(_str : pchar);
  239. constructor Create_length_pchar(_str : pchar;length : longint);
  240. destructor Destroy;override;
  241. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  242. procedure ppuwrite(ppufile:tcompilerppufile);override;
  243. function getcopy:tlinkedlistitem;override;
  244. end;
  245. { Generates a common label }
  246. tai_symbol = class(tailineinfo)
  247. is_global : boolean;
  248. sym : tasmsymbol;
  249. size : longint;
  250. constructor Create(_sym:tasmsymbol;siz:longint);
  251. constructor Create_Global(_sym:tasmsymbol;siz:longint);
  252. constructor Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint);
  253. constructor Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint);
  254. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  255. procedure ppuwrite(ppufile:tcompilerppufile);override;
  256. procedure derefimpl;override;
  257. end;
  258. tai_symbol_end = class(tailineinfo)
  259. sym : tasmsymbol;
  260. constructor Create(_sym:tasmsymbol);
  261. constructor Createname(const _name : string);
  262. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  263. procedure ppuwrite(ppufile:tcompilerppufile);override;
  264. procedure derefimpl;override;
  265. end;
  266. { Generates an assembler label }
  267. tai_label = class(tai)
  268. is_global : boolean;
  269. l : tasmlabel;
  270. constructor Create(_l : tasmlabel);
  271. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  272. procedure ppuwrite(ppufile:tcompilerppufile);override;
  273. procedure derefimpl;override;
  274. end;
  275. { Directly output data to final assembler file }
  276. tai_direct = class(tailineinfo)
  277. str : pchar;
  278. constructor Create(_str : pchar);
  279. destructor Destroy; override;
  280. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  281. procedure ppuwrite(ppufile:tcompilerppufile);override;
  282. function getcopy:tlinkedlistitem;override;
  283. end;
  284. { Generates an assembler comment }
  285. tai_comment = class(tai)
  286. str : pchar;
  287. constructor Create(_str : pchar);
  288. destructor Destroy; override;
  289. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  290. procedure ppuwrite(ppufile:tcompilerppufile);override;
  291. function getcopy:tlinkedlistitem;override;
  292. end;
  293. { Generates a section / segment directive }
  294. tai_section = class(tai)
  295. sec : TSection;
  296. constructor Create(s : TSection);
  297. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  298. procedure ppuwrite(ppufile:tcompilerppufile);override;
  299. end;
  300. { Generates an uninitializised data block }
  301. tai_datablock = class(tailineinfo)
  302. is_global : boolean;
  303. sym : tasmsymbol;
  304. size : longint;
  305. constructor Create(const _name : string;_size : longint);
  306. constructor Create_global(const _name : string;_size : longint);
  307. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  308. procedure ppuwrite(ppufile:tcompilerppufile);override;
  309. procedure derefimpl;override;
  310. end;
  311. { Generates an integer const }
  312. tai_const = class(tai)
  313. value : qword;
  314. constructor Create_ptr(_value : TConstPtrUInt);
  315. constructor Create_64bit(_value : qword);
  316. constructor Create_32bit(_value : cardinal);
  317. constructor Create_16bit(_value : word);
  318. constructor Create_8bit(_value : byte);
  319. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  320. procedure ppuwrite(ppufile:tcompilerppufile);override;
  321. end;
  322. tai_const_symbol = class(tailineinfo)
  323. sym : tasmsymbol;
  324. offset : aint;
  325. constructor Create(_sym:tasmsymbol);
  326. constructor Create_offset(_sym:tasmsymbol;ofs:aint);
  327. constructor Create_rva(_sym:tasmsymbol);
  328. constructor Create_indirect(_sym:tasmsymbol);
  329. constructor Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
  330. constructor Createname_rva(const name:string);
  331. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  332. procedure ppuwrite(ppufile:tcompilerppufile);override;
  333. procedure derefimpl;override;
  334. function getcopy:tlinkedlistitem;override;
  335. end;
  336. { Generates a single float (32 bit real) }
  337. tai_real_32bit = class(tai)
  338. value : ts32real;
  339. constructor Create(_value : ts32real);
  340. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  341. procedure ppuwrite(ppufile:tcompilerppufile);override;
  342. end;
  343. tformatoptions = (fo_none,fo_hiloswapped);
  344. { Generates a double float (64 bit real) }
  345. tai_real_64bit = class(tai)
  346. value : ts64real;
  347. {$ifdef ARM}
  348. formatoptions : tformatoptions;
  349. constructor Create_hiloswapped(_value : ts64real);
  350. {$endif ARM}
  351. constructor Create(_value : ts64real);
  352. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  353. procedure ppuwrite(ppufile:tcompilerppufile);override;
  354. end;
  355. { Generates an extended float (80 bit real) }
  356. tai_real_80bit = class(tai)
  357. value : ts80real;
  358. constructor Create(_value : ts80real);
  359. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  360. procedure ppuwrite(ppufile:tcompilerppufile);override;
  361. end;
  362. { Generates an float128 (128 bit real) }
  363. tai_real_128bit = class(tai)
  364. value : ts128real;
  365. constructor Create(_value : ts128real);
  366. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  367. procedure ppuwrite(ppufile:tcompilerppufile);override;
  368. end;
  369. { Generates a comp int (integer over 64 bits)
  370. This is Intel 80x86 specific, and is not
  371. really supported on other processors.
  372. }
  373. tai_comp_64bit = class(tai)
  374. value : ts64comp;
  375. constructor Create(_value : ts64comp);
  376. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  377. procedure ppuwrite(ppufile:tcompilerppufile);override;
  378. end;
  379. { Insert a cut to split assembler into several smaller files }
  380. tai_cut = class(tai)
  381. place : tcutplace;
  382. constructor Create;
  383. constructor Create_begin;
  384. constructor Create_end;
  385. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  386. procedure ppuwrite(ppufile:tcompilerppufile);override;
  387. end;
  388. { Insert a marker for assembler and inline blocks }
  389. tai_marker = class(tai)
  390. Kind: TMarker;
  391. Constructor Create(_Kind: TMarker);
  392. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  393. procedure ppuwrite(ppufile:tcompilerppufile);override;
  394. end;
  395. tai_tempalloc = class(tai)
  396. allocation : boolean;
  397. {$ifdef EXTDEBUG}
  398. problem : pstring;
  399. {$endif EXTDEBUG}
  400. temppos,
  401. tempsize : longint;
  402. constructor alloc(pos,size:longint);
  403. constructor dealloc(pos,size:longint);
  404. {$ifdef EXTDEBUG}
  405. constructor allocinfo(pos,size:longint;const st:string);
  406. {$endif EXTDEBUG}
  407. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  408. destructor destroy;override;
  409. procedure ppuwrite(ppufile:tcompilerppufile);override;
  410. end;
  411. tai_regalloc = class(tai)
  412. allocation : boolean;
  413. reg : tregister;
  414. constructor alloc(r : tregister);
  415. constructor dealloc(r : tregister);
  416. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  417. procedure ppuwrite(ppufile:tcompilerppufile);override;
  418. end;
  419. Taasmoutput=class;
  420. tadd_reg_instruction_proc=procedure(instr:Tai;r:tregister) of object;
  421. Trggetproc=procedure(list:Taasmoutput;position:Tai;subreg:Tsubregister;var result:Tregister) of object;
  422. Trgungetproc=procedure(list:Taasmoutput;position:Tai;r:Tregister) of object;
  423. { Class template for assembler instructions
  424. }
  425. taicpu_abstract = class(tailineinfo)
  426. protected
  427. procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);virtual;abstract;
  428. procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);virtual;abstract;
  429. procedure ppubuildderefimploper(var o:toper);virtual;abstract;
  430. procedure ppuderefoper(var o:toper);virtual;abstract;
  431. public
  432. { Condition flags for instruction }
  433. condition : TAsmCond;
  434. { Number of operands to instruction }
  435. ops : byte;
  436. { Number of allocate oper structures }
  437. opercnt : byte;
  438. { Operands of instruction }
  439. oper : array[0..max_operands-1] of poper;
  440. { Actual opcode of instruction }
  441. opcode : tasmop;
  442. {$ifdef x86}
  443. segprefix : tregister;
  444. {$endif x86}
  445. { true if instruction is a jmp }
  446. is_jmp : boolean; { is this instruction a jump? (needed for optimizer) }
  447. Constructor Create(op : tasmop);
  448. Destructor Destroy;override;
  449. function getcopy:TLinkedListItem;override;
  450. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  451. procedure ppuwrite(ppufile:tcompilerppufile);override;
  452. procedure buildderefimpl;override;
  453. procedure derefimpl;override;
  454. procedure SetCondition(const c:TAsmCond);
  455. procedure allocate_oper(opers:longint);
  456. procedure loadconst(opidx:longint;l:aword);
  457. procedure loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
  458. procedure loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset:boolean);
  459. procedure loadref(opidx:longint;const r:treference);
  460. procedure loadreg(opidx:longint;r:tregister);
  461. procedure loadoper(opidx:longint;o:toper);
  462. procedure clearop(opidx:longint);
  463. function is_same_reg_move(regtype: Tregistertype):boolean;virtual;abstract;
  464. { register allocator }
  465. function spilling_create_load(const ref:treference;r:tregister): tai;virtual;abstract;
  466. function spilling_create_store(r:tregister; const ref:treference): tai;virtual;abstract;
  467. function spilling_get_operation_type(opnr: longint): topertype;virtual;abstract;
  468. end;
  469. { alignment for operator }
  470. tai_align_abstract = class(tai)
  471. aligntype : byte; { 1 = no align, 2 = word align, 4 = dword align }
  472. fillsize : byte; { real size to fill }
  473. fillop : byte; { value to fill with - optional }
  474. use_op : boolean;
  475. constructor Create(b:byte);
  476. constructor Create_op(b: byte; _op: byte);
  477. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  478. procedure ppuwrite(ppufile:tcompilerppufile);override;
  479. function calculatefillbuf(var buf : tfillbuffer):pchar;virtual;
  480. end;
  481. taasmoutput = class(tlinkedlist)
  482. constructor create;
  483. function getlasttaifilepos : pfileposinfo;
  484. procedure InsertAfter(Item,Loc : TLinkedListItem);override;
  485. end;
  486. var
  487. { array with all class types for tais }
  488. aiclass : taiclassarray;
  489. { Current expression list }
  490. exprasmlist : taasmoutput;
  491. { labels for BREAK and CONTINUE }
  492. aktbreaklabel,aktcontinuelabel : tasmlabel;
  493. { label when the result is true or false }
  494. truelabel,falselabel : tasmlabel;
  495. { hook to notify uses of registers }
  496. add_reg_instruction_hook : tadd_reg_instruction_proc;
  497. { default lists }
  498. datasegment,codesegment,bsssegment,
  499. debuglist,withdebuglist,consts,
  500. importssection,exportssection,
  501. resourcesection,rttilist,
  502. { data used by pic code }
  503. picdata,
  504. resourcestringlist : taasmoutput;
  505. function ppuloadai(ppufile:tcompilerppufile):tai;
  506. procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
  507. implementation
  508. uses
  509. {$ifdef delphi}
  510. sysutils,
  511. {$else}
  512. strings,
  513. {$endif}
  514. verbose;
  515. const
  516. pputaimarker = 254;
  517. {****************************************************************************
  518. Helpers
  519. ****************************************************************************}
  520. function ppuloadai(ppufile:tcompilerppufile):tai;
  521. var
  522. b : byte;
  523. t : taitype;
  524. begin
  525. { marker }
  526. b:=ppufile.getbyte;
  527. if b<>pputaimarker then
  528. internalerror(200208181);
  529. { load nodetype }
  530. t:=taitype(ppufile.getbyte);
  531. if t<>ait_none then
  532. begin
  533. if t>high(taitype) then
  534. internalerror(200208182);
  535. if not assigned(aiclass[t]) then
  536. internalerror(200208183);
  537. {writeln('taiload: ',taitypestr[t]);}
  538. { generate tai of the correct class }
  539. ppuloadai:=aiclass[t].ppuload(t,ppufile);
  540. end
  541. else
  542. ppuloadai:=nil;
  543. end;
  544. procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
  545. begin
  546. { marker, read by ppuloadnode }
  547. ppufile.putbyte(pputaimarker);
  548. if assigned(n) then
  549. begin
  550. { type, read by ppuloadnode }
  551. ppufile.putbyte(byte(n.typ));
  552. {writeln('taiwrite: ',taitypestr[n.typ]);}
  553. n.ppuwrite(ppufile);
  554. end
  555. else
  556. ppufile.putbyte(byte(ait_none));
  557. end;
  558. {****************************************************************************
  559. TAI
  560. ****************************************************************************}
  561. constructor tai.Create;
  562. begin
  563. {$ifndef NOOPT}
  564. optinfo:=nil;
  565. {$endif NOOPT}
  566. end;
  567. constructor tai.ppuload(t:taitype;ppufile:tcompilerppufile);
  568. begin
  569. typ:=t;
  570. {$ifndef NOOPT}
  571. optinfo:=nil;
  572. {$endif}
  573. end;
  574. procedure tai.ppuwrite(ppufile:tcompilerppufile);
  575. begin
  576. end;
  577. procedure tai.buildderefimpl;
  578. begin
  579. end;
  580. procedure tai.derefimpl;
  581. begin
  582. end;
  583. {****************************************************************************
  584. TAILINEINFO
  585. ****************************************************************************}
  586. constructor tailineinfo.create;
  587. begin
  588. inherited create;
  589. if (not inlining_procedure) and
  590. (cs_gdb_valgrind in aktglobalswitches) then
  591. fileinfo:=aktfilepos;
  592. end;
  593. constructor tailineinfo.ppuload(t:taitype;ppufile:tcompilerppufile);
  594. begin
  595. inherited ppuload(t,ppufile);
  596. ppufile.getposinfo(fileinfo);
  597. end;
  598. procedure tailineinfo.ppuwrite(ppufile:tcompilerppufile);
  599. begin
  600. inherited ppuwrite(ppufile);
  601. ppufile.putposinfo(fileinfo);
  602. end;
  603. {****************************************************************************
  604. TAI_SIMPLE
  605. ****************************************************************************}
  606. constructor tai_simple.create(_typ : taitype);
  607. begin
  608. inherited create;
  609. typ:=_typ;
  610. end;
  611. {****************************************************************************
  612. TAI_SECTION
  613. ****************************************************************************}
  614. constructor tai_section.Create(s : TSection);
  615. begin
  616. inherited Create;
  617. typ:=ait_section;
  618. sec:=s;
  619. end;
  620. constructor tai_section.ppuload(t:taitype;ppufile:tcompilerppufile);
  621. begin
  622. inherited ppuload(t,ppufile);
  623. sec:=tsection(ppufile.getbyte);
  624. end;
  625. procedure tai_section.ppuwrite(ppufile:tcompilerppufile);
  626. begin
  627. inherited ppuwrite(ppufile);
  628. ppufile.putbyte(byte(sec));
  629. end;
  630. {****************************************************************************
  631. TAI_DATABLOCK
  632. ****************************************************************************}
  633. constructor tai_datablock.Create(const _name : string;_size : longint);
  634. begin
  635. inherited Create;
  636. typ:=ait_datablock;
  637. sym:=objectlibrary.newasmsymbol(_name,AB_LOCAL,AT_DATA);
  638. { keep things aligned }
  639. if _size<=0 then
  640. _size:=4;
  641. size:=_size;
  642. is_global:=false;
  643. end;
  644. constructor tai_datablock.Create_global(const _name : string;_size : longint);
  645. begin
  646. inherited Create;
  647. typ:=ait_datablock;
  648. sym:=objectlibrary.newasmsymbol(_name,AB_GLOBAL,AT_DATA);
  649. { keep things aligned }
  650. if _size<=0 then
  651. _size:=4;
  652. size:=_size;
  653. is_global:=true;
  654. end;
  655. constructor tai_datablock.ppuload(t:taitype;ppufile:tcompilerppufile);
  656. begin
  657. inherited Create;
  658. sym:=ppufile.getasmsymbol;
  659. size:=ppufile.getlongint;
  660. is_global:=boolean(ppufile.getbyte);
  661. end;
  662. procedure tai_datablock.ppuwrite(ppufile:tcompilerppufile);
  663. begin
  664. inherited ppuwrite(ppufile);
  665. ppufile.putasmsymbol(sym);
  666. ppufile.putlongint(size);
  667. ppufile.putbyte(byte(is_global));
  668. end;
  669. procedure tai_datablock.derefimpl;
  670. begin
  671. objectlibrary.DerefAsmsymbol(sym);
  672. end;
  673. {****************************************************************************
  674. TAI_SYMBOL
  675. ****************************************************************************}
  676. constructor tai_symbol.Create(_sym:tasmsymbol;siz:longint);
  677. begin
  678. inherited Create;
  679. typ:=ait_symbol;
  680. sym:=_sym;
  681. size:=siz;
  682. sym.defbind:=AB_LOCAL;
  683. is_global:=false;
  684. end;
  685. constructor tai_symbol.Create_global(_sym:tasmsymbol;siz:longint);
  686. begin
  687. inherited Create;
  688. typ:=ait_symbol;
  689. sym:=_sym;
  690. size:=siz;
  691. sym.defbind:=AB_GLOBAL;
  692. is_global:=true;
  693. end;
  694. constructor tai_symbol.Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint);
  695. begin
  696. inherited Create;
  697. typ:=ait_symbol;
  698. sym:=objectlibrary.newasmsymbol(_name,AB_LOCAL,_symtyp);
  699. size:=siz;
  700. is_global:=false;
  701. end;
  702. constructor tai_symbol.Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint);
  703. begin
  704. inherited Create;
  705. typ:=ait_symbol;
  706. sym:=objectlibrary.newasmsymbol(_name,AB_GLOBAL,_symtyp);
  707. size:=siz;
  708. is_global:=true;
  709. end;
  710. constructor tai_symbol.ppuload(t:taitype;ppufile:tcompilerppufile);
  711. begin
  712. inherited ppuload(t,ppufile);
  713. sym:=ppufile.getasmsymbol;
  714. size:=ppufile.getlongint;
  715. is_global:=boolean(ppufile.getbyte);
  716. end;
  717. procedure tai_symbol.ppuwrite(ppufile:tcompilerppufile);
  718. begin
  719. inherited ppuwrite(ppufile);
  720. ppufile.putasmsymbol(sym);
  721. ppufile.putlongint(size);
  722. ppufile.putbyte(byte(is_global));
  723. end;
  724. procedure tai_symbol.derefimpl;
  725. begin
  726. objectlibrary.DerefAsmsymbol(sym);
  727. end;
  728. {****************************************************************************
  729. TAI_SYMBOL_END
  730. ****************************************************************************}
  731. constructor tai_symbol_end.Create(_sym:tasmsymbol);
  732. begin
  733. inherited Create;
  734. typ:=ait_symbol_end;
  735. sym:=_sym;
  736. end;
  737. constructor tai_symbol_end.Createname(const _name : string);
  738. begin
  739. inherited Create;
  740. typ:=ait_symbol_end;
  741. sym:=objectlibrary.newasmsymbol(_name,AB_GLOBAL,AT_NONE);
  742. end;
  743. constructor tai_symbol_end.ppuload(t:taitype;ppufile:tcompilerppufile);
  744. begin
  745. inherited ppuload(t,ppufile);
  746. sym:=ppufile.getasmsymbol;
  747. end;
  748. procedure tai_symbol_end.ppuwrite(ppufile:tcompilerppufile);
  749. begin
  750. inherited ppuwrite(ppufile);
  751. ppufile.putasmsymbol(sym);
  752. end;
  753. procedure tai_symbol_end.derefimpl;
  754. begin
  755. objectlibrary.DerefAsmsymbol(sym);
  756. end;
  757. {****************************************************************************
  758. TAI_CONST
  759. ****************************************************************************}
  760. constructor tai_const.Create_ptr(_value : TConstPtrUInt);
  761. begin
  762. {$ifdef cpu64bit}
  763. self.create_64bit(_value);
  764. {$else cpu64bit}
  765. self.create_32bit(_value);
  766. {$endif cpu64bit}
  767. end;
  768. constructor tai_const.Create_64bit(_value : qword);
  769. begin
  770. inherited Create;
  771. typ:=ait_const_64bit;
  772. value:=_value;
  773. end;
  774. constructor tai_const.Create_32bit(_value : cardinal);
  775. begin
  776. inherited Create;
  777. typ:=ait_const_32bit;
  778. value:=_value;
  779. end;
  780. constructor tai_const.Create_16bit(_value : word);
  781. begin
  782. inherited Create;
  783. typ:=ait_const_16bit;
  784. value:=_value;
  785. end;
  786. constructor tai_const.Create_8bit(_value : byte);
  787. begin
  788. inherited Create;
  789. typ:=ait_const_8bit;
  790. value:=_value;
  791. end;
  792. constructor tai_const.ppuload(t:taitype;ppufile:tcompilerppufile);
  793. begin
  794. inherited ppuload(t,ppufile);
  795. value:=ppufile.getlongint;
  796. end;
  797. procedure tai_const.ppuwrite(ppufile:tcompilerppufile);
  798. begin
  799. inherited ppuwrite(ppufile);
  800. ppufile.putlongint(value);
  801. end;
  802. {****************************************************************************
  803. TAI_CONST_SYMBOL
  804. ****************************************************************************}
  805. constructor tai_const_symbol.Create(_sym:tasmsymbol);
  806. begin
  807. inherited Create;
  808. typ:=ait_const_symbol;
  809. sym:=_sym;
  810. offset:=0;
  811. { update sym info }
  812. sym.increfs;
  813. end;
  814. constructor tai_const_symbol.Create_offset(_sym:tasmsymbol;ofs:aint);
  815. begin
  816. inherited Create;
  817. typ:=ait_const_symbol;
  818. sym:=_sym;
  819. offset:=ofs;
  820. { update sym info }
  821. sym.increfs;
  822. end;
  823. constructor tai_const_symbol.Create_rva(_sym:tasmsymbol);
  824. begin
  825. inherited Create;
  826. typ:=ait_const_rva;
  827. sym:=_sym;
  828. offset:=0;
  829. { update sym info }
  830. sym.increfs;
  831. end;
  832. constructor tai_const_symbol.Create_indirect(_sym:tasmsymbol);
  833. begin
  834. inherited Create;
  835. typ:=ait_indirect_symbol;
  836. sym:=_sym;
  837. offset:=0;
  838. { update sym info }
  839. sym.increfs;
  840. end;
  841. constructor tai_const_symbol.Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
  842. begin
  843. inherited Create;
  844. typ:=ait_const_symbol;
  845. sym:=objectlibrary.newasmsymbol(name,AB_EXTERNAL,_symtyp);
  846. offset:=ofs;
  847. { update sym info }
  848. sym.increfs;
  849. end;
  850. constructor tai_const_symbol.Createname_rva(const name:string);
  851. begin
  852. inherited Create;
  853. typ:=ait_const_rva;
  854. sym:=objectlibrary.newasmsymbol(name,AB_EXTERNAL,AT_FUNCTION);
  855. offset:=0;
  856. { update sym info }
  857. sym.increfs;
  858. end;
  859. constructor tai_const_symbol.ppuload(t:taitype;ppufile:tcompilerppufile);
  860. begin
  861. inherited ppuload(t,ppufile);
  862. sym:=ppufile.getasmsymbol;
  863. offset:=ppufile.getlongint;
  864. end;
  865. procedure tai_const_symbol.ppuwrite(ppufile:tcompilerppufile);
  866. begin
  867. inherited ppuwrite(ppufile);
  868. ppufile.putasmsymbol(sym);
  869. ppufile.putlongint(offset);
  870. end;
  871. procedure tai_const_symbol.derefimpl;
  872. begin
  873. objectlibrary.DerefAsmsymbol(sym);
  874. end;
  875. function tai_const_symbol.getcopy:tlinkedlistitem;
  876. begin
  877. getcopy:=inherited getcopy;
  878. { we need to increase the reference number }
  879. sym.increfs;
  880. end;
  881. {****************************************************************************
  882. TAI_real_32bit
  883. ****************************************************************************}
  884. constructor tai_real_32bit.Create(_value : ts32real);
  885. begin
  886. inherited Create;
  887. typ:=ait_real_32bit;
  888. value:=_value;
  889. end;
  890. constructor tai_real_32bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  891. begin
  892. inherited ppuload(t,ppufile);
  893. value:=ppufile.getreal;
  894. end;
  895. procedure tai_real_32bit.ppuwrite(ppufile:tcompilerppufile);
  896. begin
  897. inherited ppuwrite(ppufile);
  898. ppufile.putreal(value);
  899. end;
  900. {****************************************************************************
  901. TAI_real_64bit
  902. ****************************************************************************}
  903. constructor tai_real_64bit.Create(_value : ts64real);
  904. begin
  905. inherited Create;
  906. typ:=ait_real_64bit;
  907. value:=_value;
  908. end;
  909. {$ifdef ARM}
  910. constructor tai_real_64bit.Create_hiloswapped(_value : ts64real);
  911. begin
  912. inherited Create;
  913. typ:=ait_real_64bit;
  914. value:=_value;
  915. formatoptions:=fo_hiloswapped;
  916. end;
  917. {$endif ARM}
  918. constructor tai_real_64bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  919. begin
  920. inherited ppuload(t,ppufile);
  921. value:=ppufile.getreal;
  922. {$ifdef ARM}
  923. formatoptions:=tformatoptions(ppufile.getbyte);
  924. {$endif ARM}
  925. end;
  926. procedure tai_real_64bit.ppuwrite(ppufile:tcompilerppufile);
  927. begin
  928. inherited ppuwrite(ppufile);
  929. ppufile.putreal(value);
  930. {$ifdef ARM}
  931. ppufile.putbyte(byte(formatoptions));
  932. {$endif ARM}
  933. end;
  934. {****************************************************************************
  935. TAI_real_80bit
  936. ****************************************************************************}
  937. constructor tai_real_80bit.Create(_value : ts80real);
  938. begin
  939. inherited Create;
  940. typ:=ait_real_80bit;
  941. value:=_value;
  942. end;
  943. constructor tai_real_80bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  944. begin
  945. inherited ppuload(t,ppufile);
  946. value:=ppufile.getreal;
  947. end;
  948. procedure tai_real_80bit.ppuwrite(ppufile:tcompilerppufile);
  949. begin
  950. inherited ppuwrite(ppufile);
  951. ppufile.putreal(value);
  952. end;
  953. {****************************************************************************
  954. TAI_real_80bit
  955. ****************************************************************************}
  956. constructor tai_real_128bit.Create(_value : ts128real);
  957. begin
  958. inherited Create;
  959. typ:=ait_real_128bit;
  960. value:=_value;
  961. end;
  962. constructor tai_real_128bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  963. begin
  964. inherited ppuload(t,ppufile);
  965. value:=ppufile.getreal;
  966. end;
  967. procedure tai_real_128bit.ppuwrite(ppufile:tcompilerppufile);
  968. begin
  969. inherited ppuwrite(ppufile);
  970. ppufile.putreal(value);
  971. end;
  972. {****************************************************************************
  973. Tai_comp_64bit
  974. ****************************************************************************}
  975. constructor tai_comp_64bit.Create(_value : ts64comp);
  976. begin
  977. inherited Create;
  978. typ:=ait_comp_64bit;
  979. value:=_value;
  980. end;
  981. constructor tai_comp_64bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  982. begin
  983. inherited ppuload(t,ppufile);
  984. ppufile.putdata(value,sizeof(value));
  985. end;
  986. procedure tai_comp_64bit.ppuwrite(ppufile:tcompilerppufile);
  987. begin
  988. inherited ppuwrite(ppufile);
  989. ppufile.getdata(value,sizeof(value));
  990. end;
  991. {****************************************************************************
  992. TAI_STRING
  993. ****************************************************************************}
  994. constructor tai_string.Create(const _str : string);
  995. begin
  996. inherited Create;
  997. typ:=ait_string;
  998. len:=length(_str);
  999. getmem(str,len+1);
  1000. strpcopy(str,_str);
  1001. end;
  1002. constructor tai_string.Create_pchar(_str : pchar);
  1003. begin
  1004. inherited Create;
  1005. typ:=ait_string;
  1006. str:=_str;
  1007. len:=strlen(_str);
  1008. end;
  1009. constructor tai_string.Create_length_pchar(_str : pchar;length : longint);
  1010. begin
  1011. inherited Create;
  1012. typ:=ait_string;
  1013. str:=_str;
  1014. len:=length;
  1015. end;
  1016. destructor tai_string.destroy;
  1017. begin
  1018. { you can have #0 inside the strings so }
  1019. if str<>nil then
  1020. freemem(str,len+1);
  1021. inherited Destroy;
  1022. end;
  1023. constructor tai_string.ppuload(t:taitype;ppufile:tcompilerppufile);
  1024. begin
  1025. inherited ppuload(t,ppufile);
  1026. len:=ppufile.getlongint;
  1027. getmem(str,len+1);
  1028. ppufile.getdata(str^,len);
  1029. str[len]:=#0;
  1030. end;
  1031. procedure tai_string.ppuwrite(ppufile:tcompilerppufile);
  1032. begin
  1033. inherited ppuwrite(ppufile);
  1034. ppufile.putlongint(len);
  1035. ppufile.putdata(str^,len);
  1036. end;
  1037. function tai_string.getcopy : tlinkedlistitem;
  1038. var
  1039. p : tlinkedlistitem;
  1040. begin
  1041. p:=inherited getcopy;
  1042. getmem(tai_string(p).str,len+1);
  1043. move(str^,tai_string(p).str^,len+1);
  1044. getcopy:=p;
  1045. end;
  1046. {****************************************************************************
  1047. TAI_LABEL
  1048. ****************************************************************************}
  1049. constructor tai_label.create(_l : tasmlabel);
  1050. begin
  1051. inherited Create;
  1052. typ:=ait_label;
  1053. l:=_l;
  1054. l.is_set:=true;
  1055. is_global:=(l.defbind=AB_GLOBAL);
  1056. end;
  1057. constructor tai_label.ppuload(t:taitype;ppufile:tcompilerppufile);
  1058. begin
  1059. inherited ppuload(t,ppufile);
  1060. l:=tasmlabel(ppufile.getasmsymbol);
  1061. is_global:=boolean(ppufile.getbyte);
  1062. end;
  1063. procedure tai_label.ppuwrite(ppufile:tcompilerppufile);
  1064. begin
  1065. inherited ppuwrite(ppufile);
  1066. ppufile.putasmsymbol(l);
  1067. ppufile.putbyte(byte(is_global));
  1068. end;
  1069. procedure tai_label.derefimpl;
  1070. begin
  1071. objectlibrary.DerefAsmsymbol(tasmsymbol(l));
  1072. l.is_set:=true;
  1073. end;
  1074. {****************************************************************************
  1075. TAI_DIRECT
  1076. ****************************************************************************}
  1077. constructor tai_direct.Create(_str : pchar);
  1078. begin
  1079. inherited Create;
  1080. typ:=ait_direct;
  1081. str:=_str;
  1082. end;
  1083. destructor tai_direct.destroy;
  1084. begin
  1085. strdispose(str);
  1086. inherited Destroy;
  1087. end;
  1088. constructor tai_direct.ppuload(t:taitype;ppufile:tcompilerppufile);
  1089. var
  1090. len : longint;
  1091. begin
  1092. inherited ppuload(t,ppufile);
  1093. len:=ppufile.getlongint;
  1094. getmem(str,len+1);
  1095. ppufile.getdata(str^,len);
  1096. str[len]:=#0;
  1097. end;
  1098. procedure tai_direct.ppuwrite(ppufile:tcompilerppufile);
  1099. var
  1100. len : longint;
  1101. begin
  1102. inherited ppuwrite(ppufile);
  1103. len:=strlen(str);
  1104. ppufile.putlongint(len);
  1105. ppufile.putdata(str^,len);
  1106. end;
  1107. function tai_direct.getcopy : tlinkedlistitem;
  1108. var
  1109. p : tlinkedlistitem;
  1110. begin
  1111. p:=inherited getcopy;
  1112. getmem(tai_direct(p).str,strlen(str)+1);
  1113. move(str^,tai_direct(p).str^,strlen(str)+1);
  1114. getcopy:=p;
  1115. end;
  1116. {****************************************************************************
  1117. tai_comment comment to be inserted in the assembler file
  1118. ****************************************************************************}
  1119. constructor tai_comment.Create(_str : pchar);
  1120. begin
  1121. inherited Create;
  1122. typ:=ait_comment;
  1123. str:=_str;
  1124. end;
  1125. destructor tai_comment.destroy;
  1126. begin
  1127. strdispose(str);
  1128. inherited Destroy;
  1129. end;
  1130. constructor tai_comment.ppuload(t:taitype;ppufile:tcompilerppufile);
  1131. var
  1132. len : longint;
  1133. begin
  1134. inherited ppuload(t,ppufile);
  1135. len:=ppufile.getlongint;
  1136. getmem(str,len+1);
  1137. ppufile.getdata(str^,len);
  1138. str[len]:=#0;
  1139. end;
  1140. procedure tai_comment.ppuwrite(ppufile:tcompilerppufile);
  1141. var
  1142. len : longint;
  1143. begin
  1144. inherited ppuwrite(ppufile);
  1145. len:=strlen(str);
  1146. ppufile.putlongint(len);
  1147. ppufile.putdata(str^,len);
  1148. end;
  1149. function tai_comment.getcopy : tlinkedlistitem;
  1150. var
  1151. p : tlinkedlistitem;
  1152. begin
  1153. p:=inherited getcopy;
  1154. getmem(tai_comment(p).str,strlen(str)+1);
  1155. move(str^,tai_comment(p).str^,strlen(str)+1);
  1156. getcopy:=p;
  1157. end;
  1158. {****************************************************************************
  1159. TAI_CUT
  1160. ****************************************************************************}
  1161. constructor tai_cut.Create;
  1162. begin
  1163. inherited Create;
  1164. typ:=ait_cut;
  1165. place:=cut_normal;
  1166. end;
  1167. constructor tai_cut.Create_begin;
  1168. begin
  1169. inherited Create;
  1170. typ:=ait_cut;
  1171. place:=cut_begin;
  1172. end;
  1173. constructor tai_cut.Create_end;
  1174. begin
  1175. inherited Create;
  1176. typ:=ait_cut;
  1177. place:=cut_end;
  1178. end;
  1179. constructor tai_cut.ppuload(t:taitype;ppufile:tcompilerppufile);
  1180. begin
  1181. inherited ppuload(t,ppufile);
  1182. place:=TCutPlace(ppufile.getbyte);
  1183. end;
  1184. procedure tai_cut.ppuwrite(ppufile:tcompilerppufile);
  1185. begin
  1186. inherited ppuwrite(ppufile);
  1187. ppufile.putbyte(byte(place));
  1188. end;
  1189. {****************************************************************************
  1190. Tai_Marker
  1191. ****************************************************************************}
  1192. constructor Tai_Marker.Create(_Kind: TMarker);
  1193. begin
  1194. Inherited Create;
  1195. typ := ait_marker;
  1196. Kind := _Kind;
  1197. end;
  1198. constructor Tai_Marker.ppuload(t:taitype;ppufile:tcompilerppufile);
  1199. begin
  1200. inherited ppuload(t,ppufile);
  1201. kind:=TMarker(ppufile.getbyte);
  1202. end;
  1203. procedure Tai_Marker.ppuwrite(ppufile:tcompilerppufile);
  1204. begin
  1205. inherited ppuwrite(ppufile);
  1206. ppufile.putbyte(byte(kind));
  1207. end;
  1208. {*****************************************************************************
  1209. tai_tempalloc
  1210. *****************************************************************************}
  1211. constructor tai_tempalloc.alloc(pos,size:longint);
  1212. begin
  1213. inherited Create;
  1214. typ:=ait_tempalloc;
  1215. allocation:=true;
  1216. temppos:=pos;
  1217. tempsize:=size;
  1218. {$ifdef EXTDEBUG}
  1219. problem:=nil;
  1220. {$endif EXTDEBUG}
  1221. end;
  1222. destructor tai_tempalloc.destroy;
  1223. begin
  1224. {$ifdef EXTDEBUG}
  1225. stringdispose(problem);
  1226. {$endif EXTDEBUG}
  1227. inherited destroy;
  1228. end;
  1229. constructor tai_tempalloc.dealloc(pos,size:longint);
  1230. begin
  1231. inherited Create;
  1232. typ:=ait_tempalloc;
  1233. allocation:=false;
  1234. temppos:=pos;
  1235. tempsize:=size;
  1236. {$ifdef EXTDEBUG}
  1237. problem:=nil;
  1238. {$endif EXTDEBUG}
  1239. end;
  1240. {$ifdef EXTDEBUG}
  1241. constructor tai_tempalloc.allocinfo(pos,size:longint;const st:string);
  1242. begin
  1243. inherited Create;
  1244. typ:=ait_tempalloc;
  1245. allocation:=false;
  1246. temppos:=pos;
  1247. tempsize:=size;
  1248. problem:=stringdup(st);
  1249. end;
  1250. {$endif EXTDEBUG}
  1251. constructor tai_tempalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
  1252. begin
  1253. inherited ppuload(t,ppufile);
  1254. temppos:=ppufile.getlongint;
  1255. tempsize:=ppufile.getlongint;
  1256. allocation:=boolean(ppufile.getbyte);
  1257. {$ifdef EXTDEBUG}
  1258. problem:=nil;
  1259. {$endif EXTDEBUG}
  1260. end;
  1261. procedure tai_tempalloc.ppuwrite(ppufile:tcompilerppufile);
  1262. begin
  1263. inherited ppuwrite(ppufile);
  1264. ppufile.putlongint(temppos);
  1265. ppufile.putlongint(tempsize);
  1266. ppufile.putbyte(byte(allocation));
  1267. end;
  1268. {*****************************************************************************
  1269. tai_regalloc
  1270. *****************************************************************************}
  1271. constructor tai_regalloc.alloc(r : tregister);
  1272. begin
  1273. inherited create;
  1274. typ:=ait_regalloc;
  1275. allocation:=true;
  1276. reg:=r;
  1277. end;
  1278. constructor tai_regalloc.dealloc(r : tregister);
  1279. begin
  1280. inherited create;
  1281. typ:=ait_regalloc;
  1282. allocation:=false;
  1283. reg:=r;
  1284. end;
  1285. constructor tai_regalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
  1286. begin
  1287. inherited ppuload(t,ppufile);
  1288. ppufile.getdata(reg,sizeof(Tregister));
  1289. allocation:=boolean(ppufile.getbyte);
  1290. end;
  1291. procedure tai_regalloc.ppuwrite(ppufile:tcompilerppufile);
  1292. begin
  1293. inherited ppuwrite(ppufile);
  1294. ppufile.putdata(reg,sizeof(Tregister));
  1295. ppufile.putbyte(byte(allocation));
  1296. end;
  1297. {*****************************************************************************
  1298. TaiInstruction
  1299. *****************************************************************************}
  1300. constructor taicpu_abstract.Create(op : tasmop);
  1301. begin
  1302. inherited create;
  1303. typ:=ait_instruction;
  1304. is_jmp:=false;
  1305. opcode:=op;
  1306. ops:=0;
  1307. fillchar(condition,sizeof(condition),0);
  1308. fillchar(oper,sizeof(oper),0);
  1309. end;
  1310. destructor taicpu_abstract.Destroy;
  1311. var
  1312. i : integer;
  1313. begin
  1314. for i:=0 to opercnt-1 do
  1315. begin
  1316. clearop(i);
  1317. dispose(oper[i]);
  1318. end;
  1319. inherited destroy;
  1320. end;
  1321. { ---------------------------------------------------------------------
  1322. Loading of operands.
  1323. ---------------------------------------------------------------------}
  1324. procedure taicpu_abstract.allocate_oper(opers:longint);
  1325. begin
  1326. while (opers>opercnt) do
  1327. begin
  1328. new(oper[opercnt]);
  1329. fillchar(oper[opercnt]^,sizeof(toper),0);
  1330. inc(opercnt);
  1331. end;
  1332. end;
  1333. procedure taicpu_abstract.loadconst(opidx:longint;l:aword);
  1334. begin
  1335. allocate_oper(opidx+1);
  1336. with oper[opidx]^ do
  1337. begin
  1338. if typ<>top_const then
  1339. clearop(opidx);
  1340. val:=l;
  1341. typ:=top_const;
  1342. end;
  1343. end;
  1344. procedure taicpu_abstract.loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
  1345. var
  1346. r : treference;
  1347. begin
  1348. reference_reset_symbol(r,s,sofs);
  1349. r.refaddr:=addr_full;
  1350. loadref(opidx,r);
  1351. end;
  1352. procedure taicpu_abstract.loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset:boolean);
  1353. begin
  1354. if not assigned(s) then
  1355. internalerror(200204251);
  1356. allocate_oper(opidx+1);
  1357. with oper[opidx]^ do
  1358. begin
  1359. if typ<>top_local then
  1360. begin
  1361. clearop(opidx);
  1362. new(localoper);
  1363. end;
  1364. with oper[opidx]^.localoper^ do
  1365. begin
  1366. localsym:=s;
  1367. localsymofs:=sofs;
  1368. localindexreg:=indexreg;
  1369. localscale:=scale;
  1370. localgetoffset:=getoffset;
  1371. end;
  1372. typ:=top_local;
  1373. end;
  1374. end;
  1375. procedure taicpu_abstract.loadref(opidx:longint;const r:treference);
  1376. begin
  1377. allocate_oper(opidx+1);
  1378. with oper[opidx]^ do
  1379. begin
  1380. if typ<>top_ref then
  1381. begin
  1382. clearop(opidx);
  1383. new(ref);
  1384. end;
  1385. ref^:=r;
  1386. {$ifdef x86}
  1387. { We allow this exception for x86, since overloading this would be
  1388. too much of a a speed penalty}
  1389. if (ref^.segment<>NR_NO) and (ref^.segment<>NR_DS) then
  1390. segprefix:=ref^.segment;
  1391. {$endif}
  1392. typ:=top_ref;
  1393. if assigned(add_reg_instruction_hook) then
  1394. begin
  1395. add_reg_instruction_hook(self,ref^.base);
  1396. add_reg_instruction_hook(self,ref^.index);
  1397. end;
  1398. { mark symbol as used }
  1399. if assigned(ref^.symbol) then
  1400. ref^.symbol.increfs;
  1401. end;
  1402. end;
  1403. procedure taicpu_abstract.loadreg(opidx:longint;r:tregister);
  1404. begin
  1405. allocate_oper(opidx+1);
  1406. with oper[opidx]^ do
  1407. begin
  1408. if typ<>top_reg then
  1409. clearop(opidx);
  1410. reg:=r;
  1411. typ:=top_reg;
  1412. end;
  1413. if assigned(add_reg_instruction_hook) then
  1414. add_reg_instruction_hook(self,r);
  1415. {$ifdef ARM}
  1416. { R15 is the PC on the ARM thus moves to R15 are jumps.
  1417. Due to speed considerations we don't use a virtual overridden method here.
  1418. Because the pc/r15 isn't handled by the reg. allocator this should never cause
  1419. problems with iregs getting r15.
  1420. }
  1421. is_jmp:=(opcode=A_MOV) and (opidx=0) and (r=NR_R15);
  1422. {$endif ARM}
  1423. end;
  1424. procedure taicpu_abstract.loadoper(opidx:longint;o:toper);
  1425. begin
  1426. allocate_oper(opidx+1);
  1427. clearop(opidx);
  1428. oper[opidx]^:=o;
  1429. { copy also the reference }
  1430. with oper[opidx]^ do
  1431. begin
  1432. case typ of
  1433. top_reg:
  1434. begin
  1435. if assigned(add_reg_instruction_hook) then
  1436. add_reg_instruction_hook(self,reg);
  1437. end;
  1438. top_ref:
  1439. begin
  1440. new(ref);
  1441. ref^:=o.ref^;
  1442. if assigned(add_reg_instruction_hook) then
  1443. begin
  1444. add_reg_instruction_hook(self,ref^.base);
  1445. add_reg_instruction_hook(self,ref^.index);
  1446. end;
  1447. end;
  1448. {$ifdef ARM}
  1449. top_shifterop:
  1450. begin
  1451. new(shifterop);
  1452. shifterop^:=o.shifterop^;
  1453. if assigned(add_reg_instruction_hook) then
  1454. add_reg_instruction_hook(self,shifterop^.rs);
  1455. end;
  1456. {$endif ARM}
  1457. end;
  1458. end;
  1459. end;
  1460. procedure taicpu_abstract.clearop(opidx:longint);
  1461. begin
  1462. with oper[opidx]^ do
  1463. begin
  1464. case typ of
  1465. top_ref:
  1466. dispose(ref);
  1467. top_local:
  1468. dispose(localoper);
  1469. {$ifdef ARM}
  1470. top_shifterop:
  1471. dispose(shifterop);
  1472. top_regset:
  1473. dispose(regset);
  1474. {$endif ARM}
  1475. end;
  1476. typ:=top_none;
  1477. end;
  1478. end;
  1479. { ---------------------------------------------------------------------
  1480. Miscellaneous methods.
  1481. ---------------------------------------------------------------------}
  1482. procedure taicpu_abstract.SetCondition(const c:TAsmCond);
  1483. begin
  1484. condition:=c;
  1485. end;
  1486. Function taicpu_abstract.getcopy:TLinkedListItem;
  1487. var
  1488. i : longint;
  1489. p : taicpu_abstract;
  1490. begin
  1491. p:=taicpu_abstract(inherited getcopy);
  1492. { make a copy of the references }
  1493. p.opercnt:=0;
  1494. p.allocate_oper(ops);
  1495. for i:=0 to ops-1 do
  1496. begin
  1497. p.oper[i]^:=oper[i]^;
  1498. case oper[i]^.typ of
  1499. top_local :
  1500. begin
  1501. new(p.oper[i]^.localoper);
  1502. p.oper[i]^.localoper^:=oper[i]^.localoper^;
  1503. end;
  1504. top_ref :
  1505. begin
  1506. new(p.oper[i]^.ref);
  1507. p.oper[i]^.ref^:=oper[i]^.ref^;
  1508. end;
  1509. {$ifdef ARM}
  1510. top_shifterop:
  1511. begin
  1512. new(p.oper[i]^.shifterop);
  1513. p.oper[i]^.shifterop^:=oper[i]^.shifterop^;
  1514. end;
  1515. {$endif ARM}
  1516. end;
  1517. end;
  1518. getcopy:=p;
  1519. end;
  1520. constructor taicpu_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
  1521. var
  1522. i : integer;
  1523. begin
  1524. inherited ppuload(t,ppufile);
  1525. { hopefully, we don't get problems with big/litte endian here when cross compiling :/ }
  1526. ppufile.getdata(condition,sizeof(tasmcond));
  1527. allocate_oper(ppufile.getbyte);
  1528. for i:=0 to ops-1 do
  1529. ppuloadoper(ppufile,oper[i]^);
  1530. opcode:=tasmop(ppufile.getword);
  1531. {$ifdef x86}
  1532. ppufile.getdata(segprefix,sizeof(Tregister));
  1533. {$endif x86}
  1534. is_jmp:=boolean(ppufile.getbyte);
  1535. end;
  1536. procedure taicpu_abstract.ppuwrite(ppufile:tcompilerppufile);
  1537. var
  1538. i : integer;
  1539. begin
  1540. inherited ppuwrite(ppufile);
  1541. ppufile.putdata(condition,sizeof(tasmcond));
  1542. ppufile.putbyte(ops);
  1543. for i:=0 to ops-1 do
  1544. ppuwriteoper(ppufile,oper[i]^);
  1545. ppufile.putword(word(opcode));
  1546. {$ifdef x86}
  1547. ppufile.putdata(segprefix,sizeof(Tregister));
  1548. {$endif x86}
  1549. ppufile.putbyte(byte(is_jmp));
  1550. end;
  1551. procedure taicpu_abstract.buildderefimpl;
  1552. var
  1553. i : integer;
  1554. begin
  1555. for i:=0 to ops-1 do
  1556. ppubuildderefimploper(oper[i]^);
  1557. end;
  1558. procedure taicpu_abstract.derefimpl;
  1559. var
  1560. i : integer;
  1561. begin
  1562. for i:=0 to ops-1 do
  1563. ppuderefoper(oper[i]^);
  1564. end;
  1565. {****************************************************************************
  1566. tai_align_abstract
  1567. ****************************************************************************}
  1568. constructor tai_align_abstract.Create(b: byte);
  1569. begin
  1570. inherited Create;
  1571. typ:=ait_align;
  1572. if b in [1,2,4,8,16,32] then
  1573. aligntype := b
  1574. else
  1575. aligntype := 1;
  1576. fillsize:=0;
  1577. fillop:=0;
  1578. use_op:=false;
  1579. end;
  1580. constructor tai_align_abstract.Create_op(b: byte; _op: byte);
  1581. begin
  1582. inherited Create;
  1583. typ:=ait_align;
  1584. if b in [1,2,4,8,16,32] then
  1585. aligntype := b
  1586. else
  1587. aligntype := 1;
  1588. fillsize:=0;
  1589. fillop:=_op;
  1590. use_op:=true;
  1591. end;
  1592. function tai_align_abstract.calculatefillbuf(var buf : tfillbuffer):pchar;
  1593. begin
  1594. fillchar(buf,high(buf),fillop);
  1595. calculatefillbuf:=pchar(@buf);
  1596. end;
  1597. constructor tai_align_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
  1598. begin
  1599. inherited ppuload(t,ppufile);
  1600. aligntype:=ppufile.getbyte;
  1601. fillsize:=0;
  1602. fillop:=ppufile.getbyte;
  1603. use_op:=boolean(ppufile.getbyte);
  1604. end;
  1605. procedure tai_align_abstract.ppuwrite(ppufile:tcompilerppufile);
  1606. begin
  1607. inherited ppuwrite(ppufile);
  1608. ppufile.putbyte(aligntype);
  1609. ppufile.putbyte(fillop);
  1610. ppufile.putbyte(byte(use_op));
  1611. end;
  1612. {*****************************************************************************
  1613. TAAsmOutput
  1614. *****************************************************************************}
  1615. constructor taasmoutput.create;
  1616. begin
  1617. inherited create;
  1618. { make sure the optimizer won't remove the first tai of this list}
  1619. insert(tai_marker.create(marker_blockstart));
  1620. end;
  1621. function taasmoutput.getlasttaifilepos : pfileposinfo;
  1622. var
  1623. hp : tlinkedlistitem;
  1624. begin
  1625. getlasttaifilepos := nil;
  1626. if assigned(last) then
  1627. begin
  1628. { find the last file information record }
  1629. if not (tai(last).typ in SkipLineInfo) then
  1630. getlasttaifilepos:=@tailineinfo(last).fileinfo
  1631. else
  1632. { go through list backwards to find the first entry
  1633. with line information
  1634. }
  1635. begin
  1636. hp:=tai(last);
  1637. while assigned(hp) and (tai(hp).typ in SkipLineInfo) do
  1638. hp:=hp.Previous;
  1639. { found entry }
  1640. if assigned(hp) then
  1641. getlasttaifilepos:=@tailineinfo(hp).fileinfo
  1642. end;
  1643. end;
  1644. end;
  1645. procedure Taasmoutput.InsertAfter(Item,Loc : TLinkedListItem);
  1646. begin
  1647. { This is not possible because it is not sure that the
  1648. tai at Loc has taifileinfo as parent }
  1649. {if assigned(Loc) then
  1650. tailineinfo(Item).fileinfo:=tailineinfo(Loc).fileinfo;}
  1651. inherited InsertAfter(Item,Loc);
  1652. end;
  1653. end.
  1654. {
  1655. $Log$
  1656. Revision 1.79 2004-03-15 08:44:51 michael
  1657. + Fix from peter: fixes crash when inlining assembler code referencing local vars
  1658. Revision 1.78 2004/03/14 22:47:56 peter
  1659. * fix memleak with top_local
  1660. Revision 1.77 2004/03/14 20:10:56 peter
  1661. * disable some debuginfo info when valgrind support is used
  1662. Revision 1.76 2004/03/02 17:32:12 florian
  1663. * make cycle fixed
  1664. + pic support for darwin
  1665. + support of importing vars from shared libs on darwin implemented
  1666. Revision 1.75 2004/03/02 00:36:32 olle
  1667. * big transformation of Tai_[const_]Symbol.Create[data]name*
  1668. Revision 1.74 2004/02/27 12:13:15 daniel
  1669. - Removed troublesome writeln statement
  1670. Revision 1.73 2004/02/27 10:21:04 florian
  1671. * top_symbol killed
  1672. + refaddr to treference added
  1673. + refsymbol to treference added
  1674. * top_local stuff moved to an extra record to save memory
  1675. + aint introduced
  1676. * tppufile.get/putint64/aint implemented
  1677. Revision 1.72 2004/02/26 16:16:38 peter
  1678. * tai_const.create_ptr added
  1679. Revision 1.71 2004/02/08 23:10:21 jonas
  1680. * taicpu.is_same_reg_move() now gets a regtype parameter so it only
  1681. removes moves of that particular register type. This is necessary so
  1682. we don't remove the live_start instruction of a register before it
  1683. has been processed
  1684. Revision 1.70 2004/02/08 20:15:42 jonas
  1685. - removed taicpu.is_reg_move because it's not used anymore
  1686. + support tracking fpu register moves by rgobj for the ppc
  1687. Revision 1.69 2004/01/31 17:45:16 peter
  1688. * Change several $ifdef i386 to x86
  1689. * Change several OS_32 to OS_INT/OS_ADDR
  1690. Revision 1.68 2004/01/30 13:42:03 florian
  1691. * fixed more alignment issues
  1692. Revision 1.67 2004/01/26 16:12:27 daniel
  1693. * reginfo now also only allocated during register allocation
  1694. * third round of gdb cleanups: kick out most of concatstabto
  1695. Revision 1.66 2004/01/24 18:12:40 florian
  1696. * fixed several arm floating point issues
  1697. Revision 1.65 2004/01/23 15:12:49 florian
  1698. * fixed generic shl/shr operations
  1699. + added register allocation hook calls for arm specific operand types:
  1700. register set and shifter op
  1701. Revision 1.64 2004/01/12 16:37:59 peter
  1702. * moved spilling code from taicpu to rg
  1703. Revision 1.63 2003/12/28 16:20:09 jonas
  1704. - removed unused methods from old generic spilling code
  1705. Revision 1.62 2003/12/26 14:02:30 peter
  1706. * sparc updates
  1707. * use registertype in spill_register
  1708. Revision 1.61 2003/12/15 21:25:48 peter
  1709. * reg allocations for imaginary register are now inserted just
  1710. before reg allocation
  1711. * tregister changed to enum to allow compile time check
  1712. * fixed several tregister-tsuperregister errors
  1713. Revision 1.60 2003/12/14 20:24:28 daniel
  1714. * Register allocator speed optimizations
  1715. - Worklist no longer a ringbuffer
  1716. - No find operations are left
  1717. - Simplify now done in constant time
  1718. - unusedregs is now a Tsuperregisterworklist
  1719. - Microoptimizations
  1720. Revision 1.59 2003/12/08 22:34:24 peter
  1721. * tai_const.create_32bit changed to cardinal
  1722. Revision 1.58 2003/12/06 22:16:12 jonas
  1723. * completely overhauled and fixed generic spilling code. New method:
  1724. spilling_get_operation_type(operand_number): returns the operation
  1725. performed by the instruction on the operand: read/write/read+write.
  1726. See powerpc/aasmcpu.pas for an example
  1727. Revision 1.57 2003/12/03 17:39:04 florian
  1728. * fixed several arm calling conventions issues
  1729. * fixed reference reading in the assembler reader
  1730. * fixed a_loadaddr_ref_reg
  1731. Revision 1.55 2003/11/12 16:05:39 florian
  1732. * assembler readers OOPed
  1733. + typed currency constants
  1734. + typed 128 bit float constants if the CPU supports it
  1735. Revision 1.54 2003/11/07 15:58:32 florian
  1736. * Florian's culmutative nr. 1; contains:
  1737. - invalid calling conventions for a certain cpu are rejected
  1738. - arm softfloat calling conventions
  1739. - -Sp for cpu dependend code generation
  1740. - several arm fixes
  1741. - remaining code for value open array paras on heap
  1742. Revision 1.53 2003/10/30 19:59:00 peter
  1743. * support scalefactor for opr_local
  1744. * support reference with opr_local set, fixes tw2631
  1745. Revision 1.52 2003/10/29 21:06:39 jonas
  1746. * allow more than 3 args in the spilling routine
  1747. Revision 1.51 2003/10/29 15:40:20 peter
  1748. * support indexing and offset retrieval for locals
  1749. Revision 1.50 2003/10/29 14:42:14 mazen
  1750. * code reformatted
  1751. Revision 1.49 2003/10/29 14:05:45 mazen
  1752. * Splling function devided to sub functions to make it easy to understand.
  1753. This commit is just to allow easy diffs to validate the migration (hint use -w)
  1754. Revision 1.48 2003/10/24 17:39:41 peter
  1755. * asmnode.get_position now inserts a marker
  1756. Revision 1.47 2003/10/23 14:44:07 peter
  1757. * splitted buildderef and buildderefimpl to fix interface crc
  1758. calculation
  1759. Revision 1.46 2003/10/22 20:39:59 peter
  1760. * write derefdata in a separate ppu entry
  1761. Revision 1.45 2003/10/21 15:15:35 peter
  1762. * taicpu_abstract.oper[] changed to pointers
  1763. Revision 1.44 2003/10/17 14:38:32 peter
  1764. * 64k registers supported
  1765. * fixed some memory leaks
  1766. Revision 1.43 2003/10/11 16:06:42 florian
  1767. * fixed some MMX<->SSE
  1768. * started to fix ppc, needs an overhaul
  1769. + stabs info improve for spilling, not sure if it works correctly/completly
  1770. - MMX_SUPPORT removed from Makefile.fpc
  1771. Revision 1.42 2003/10/10 17:48:13 peter
  1772. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  1773. * tregisteralloctor renamed to trgobj
  1774. * removed rgobj from a lot of units
  1775. * moved location_* and reference_* to cgobj
  1776. * first things for mmx register allocation
  1777. Revision 1.41 2003/10/01 20:34:48 peter
  1778. * procinfo unit contains tprocinfo
  1779. * cginfo renamed to cgbase
  1780. * moved cgmessage to verbose
  1781. * fixed ppc and sparc compiles
  1782. Revision 1.40 2003/09/23 17:56:05 peter
  1783. * locals and paras are allocated in the code generation
  1784. * tvarsym.localloc contains the location of para/local when
  1785. generating code for the current procedure
  1786. Revision 1.39 2003/09/07 22:09:34 peter
  1787. * preparations for different default calling conventions
  1788. * various RA fixes
  1789. Revision 1.38 2003/09/04 00:15:28 florian
  1790. * first bunch of adaptions of arm compiler for new register type
  1791. Revision 1.37 2003/09/03 15:55:00 peter
  1792. * NEWRA branch merged
  1793. Revision 1.36 2003/09/03 11:18:36 florian
  1794. * fixed arm concatcopy
  1795. + arm support in the common compiler sources added
  1796. * moved some generic cg code around
  1797. + tfputype added
  1798. * ...
  1799. Revision 1.35.2.5 2003/08/31 21:08:16 peter
  1800. * first batch of sparc fixes
  1801. Revision 1.35.2.4 2003/08/29 17:28:59 peter
  1802. * next batch of updates
  1803. Revision 1.35.2.3 2003/08/28 18:35:07 peter
  1804. * tregister changed to cardinal
  1805. Revision 1.35.2.2 2003/08/27 20:23:55 peter
  1806. * remove old ra code
  1807. Revision 1.35.2.1 2003/08/27 19:55:54 peter
  1808. * first tregister patch
  1809. Revision 1.35 2003/08/21 14:47:41 peter
  1810. * remove convert_registers
  1811. Revision 1.34 2003/08/20 20:29:06 daniel
  1812. * Some more R_NO changes
  1813. * Preventive code to loadref added
  1814. Revision 1.33 2003/08/17 20:47:47 daniel
  1815. * Notranslation changed into -sr functionality
  1816. Revision 1.32 2003/08/17 16:59:20 jonas
  1817. * fixed regvars so they work with newra (at least for ppc)
  1818. * fixed some volatile register bugs
  1819. + -dnotranslation option for -dnewra, which causes the registers not to
  1820. be translated from virtual to normal registers. Requires support in
  1821. the assembler writer as well, which is only implemented in aggas/
  1822. agppcgas currently
  1823. Revision 1.31 2003/08/11 21:18:20 peter
  1824. * start of sparc support for newra
  1825. Revision 1.30 2003/07/02 16:43:48 jonas
  1826. * always add dummy marker object at the start of an assembler list, so
  1827. the optimizer can't remove the first object
  1828. Revision 1.29 2003/06/03 13:01:59 daniel
  1829. * Register allocator finished
  1830. Revision 1.28 2003/05/12 18:13:57 peter
  1831. * create rtti label using newasmsymboldata and update binding
  1832. only when calling tai_symbol.create
  1833. * tai_symbol.create_global added
  1834. Revision 1.27 2003/04/25 20:59:33 peter
  1835. * removed funcretn,funcretsym, function result is now in varsym
  1836. and aliases for result and function name are added using absolutesym
  1837. * vs_hidden parameter for funcret passed in parameter
  1838. * vs_hidden fixes
  1839. * writenode changed to printnode and released from extdebug
  1840. * -vp option added to generate a tree.log with the nodetree
  1841. * nicer printnode for statements, callnode
  1842. Revision 1.26 2002/04/25 16:12:09 florian
  1843. * fixed more problems with cpubase and x86-64
  1844. Revision 1.25 2003/04/25 08:25:26 daniel
  1845. * Ifdefs around a lot of calls to cleartempgen
  1846. * Fixed registers that are allocated but not freed in several nodes
  1847. * Tweak to register allocator to cause less spills
  1848. * 8-bit registers now interfere with esi,edi and ebp
  1849. Compiler can now compile rtl successfully when using new register
  1850. allocator
  1851. Revision 1.24 2003/04/24 13:03:01 florian
  1852. * comp is now written with its bit pattern to the ppu instead as an extended
  1853. Revision 1.23 2003/04/22 14:33:38 peter
  1854. * removed some notes/hints
  1855. Revision 1.22 2003/04/22 10:09:34 daniel
  1856. + Implemented the actual register allocator
  1857. + Scratch registers unavailable when new register allocator used
  1858. + maybe_save/maybe_restore unavailable when new register allocator used
  1859. Revision 1.21 2003/02/19 22:00:14 daniel
  1860. * Code generator converted to new register notation
  1861. - Horribily outdated todo.txt removed
  1862. Revision 1.20 2003/01/30 21:46:20 peter
  1863. * tai_const_symbol.createdataname added
  1864. Revision 1.19 2003/01/21 08:48:08 daniel
  1865. * Another 200301081 fixed
  1866. Revision 1.18 2003/01/09 20:40:59 daniel
  1867. * Converted some code in cgx86.pas to new register numbering
  1868. Revision 1.17 2003/01/09 15:49:56 daniel
  1869. * Added register conversion
  1870. Revision 1.16 2003/01/08 18:43:56 daniel
  1871. * Tregister changed into a record
  1872. Revision 1.15 2003/01/05 13:36:53 florian
  1873. * x86-64 compiles
  1874. + very basic support for float128 type (x86-64 only)
  1875. Revision 1.14 2002/12/06 17:50:21 peter
  1876. * symbol count fix merged
  1877. Revision 1.13 2002/11/17 16:31:55 carl
  1878. * memory optimization (3-4%) : cleanup of tai fields,
  1879. cleanup of tdef and tsym fields.
  1880. * make it work for m68k
  1881. Revision 1.12 2002/11/15 16:29:30 peter
  1882. * made tasmsymbol.refs private (merged)
  1883. Revision 1.11 2002/11/15 01:58:45 peter
  1884. * merged changes from 1.0.7 up to 04-11
  1885. - -V option for generating bug report tracing
  1886. - more tracing for option parsing
  1887. - errors for cdecl and high()
  1888. - win32 import stabs
  1889. - win32 records<=8 are returned in eax:edx (turned off by default)
  1890. - heaptrc update
  1891. - more info for temp management in .s file with EXTDEBUG
  1892. Revision 1.10 2002/11/09 15:38:03 carl
  1893. + NOOPT removed the optinfo field
  1894. Revision 1.9 2002/10/05 12:43:23 carl
  1895. * fixes for Delphi 6 compilation
  1896. (warning : Some features do not work under Delphi)
  1897. Revision 1.8 2002/08/19 19:36:42 peter
  1898. * More fixes for cross unit inlining, all tnodes are now implemented
  1899. * Moved pocall_internconst to po_internconst because it is not a
  1900. calling type at all and it conflicted when inlining of these small
  1901. functions was requested
  1902. Revision 1.7 2002/08/18 20:06:23 peter
  1903. * inlining is now also allowed in interface
  1904. * renamed write/load to ppuwrite/ppuload
  1905. * tnode storing in ppu
  1906. * nld,ncon,nbas are already updated for storing in ppu
  1907. Revision 1.6 2002/08/16 05:21:09 florian
  1908. * powerpc compilation fix
  1909. Revision 1.5 2002/08/15 19:10:35 peter
  1910. * first things tai,tnode storing in ppu
  1911. Revision 1.4 2002/08/11 14:32:25 peter
  1912. * renamed current_library to objectlibrary
  1913. Revision 1.3 2002/08/11 13:24:10 peter
  1914. * saving of asmsymbols in ppu supported
  1915. * asmsymbollist global is removed and moved into a new class
  1916. tasmlibrarydata that will hold the info of a .a file which
  1917. corresponds with a single module. Added librarydata to tmodule
  1918. to keep the library info stored for the module. In the future the
  1919. objectfiles will also be stored to the tasmlibrarydata class
  1920. * all getlabel/newasmsymbol and friends are moved to the new class
  1921. Revision 1.2 2002/08/05 18:27:48 carl
  1922. + more more more documentation
  1923. + first version include/exclude (can't test though, not enough scratch for i386 :()...
  1924. Revision 1.1 2002/07/01 18:46:20 peter
  1925. * internal linker
  1926. * reorganized aasm layer
  1927. Revision 1.27 2002/05/18 13:34:04 peter
  1928. * readded missing revisions
  1929. Revision 1.25 2002/05/14 19:34:38 peter
  1930. * removed old logs and updated copyright year
  1931. Revision 1.24 2002/05/14 17:28:08 peter
  1932. * synchronized cpubase between powerpc and i386
  1933. * moved more tables from cpubase to cpuasm
  1934. * tai_align_abstract moved to tainst, cpuasm must define
  1935. the tai_align class now, which may be empty
  1936. Revision 1.23 2002/04/15 18:54:34 carl
  1937. - removed tcpuflags
  1938. Revision 1.22 2002/04/07 13:18:19 carl
  1939. + more documentation
  1940. Revision 1.21 2002/04/07 10:17:40 carl
  1941. - remove packenumfixed (requires version 1.0.2 or later to compile now!)
  1942. + changing some comments so its commented automatically
  1943. Revision 1.20 2002/03/24 19:04:31 carl
  1944. + patch for SPARC from Mazen NEIFER
  1945. }