aasmtai.pas 66 KB

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