aasmtai.pas 68 KB

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