aasmtai.pas 67 KB

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