aasmtai.pas 68 KB

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