ncgutil.pas 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Helper routines for all code generators
  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. unit ncgutil;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,cpuinfo,
  23. globtype,
  24. cpubase,cgbase,parabase,
  25. aasmbase,aasmtai,aasmcpu,
  26. symconst,symbase,symdef,symsym,symtype,symtable
  27. {$ifndef cpu64bit}
  28. ,cg64f32
  29. {$endif cpu64bit}
  30. ;
  31. type
  32. tloadregvars = (lr_dont_load_regvars, lr_load_regvars);
  33. procedure firstcomplex(p : tbinarynode);
  34. procedure maketojumpbool(list:TAAsmoutput; p : tnode; loadregvars: tloadregvars);
  35. // procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsuperregisterset);
  36. procedure location_force_reg(list:TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  37. procedure location_force_fpureg(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
  38. procedure location_force_mem(list:TAAsmoutput;var l:tlocation);
  39. procedure location_force_mmregscalar(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
  40. function maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
  41. procedure gen_proc_symbol(list:Taasmoutput);
  42. procedure gen_proc_symbol_end(list:Taasmoutput);
  43. procedure gen_proc_entry_code(list:Taasmoutput);
  44. procedure gen_proc_exit_code(list:Taasmoutput);
  45. procedure gen_save_used_regs(list:TAAsmoutput);
  46. procedure gen_restore_used_regs(list:TAAsmoutput;const funcretparaloc:tcgpara);
  47. procedure gen_initialize_code(list:TAAsmoutput);
  48. procedure gen_finalize_code(list:TAAsmoutput);
  49. procedure gen_entry_code(list:TAAsmoutput);
  50. procedure gen_exit_code(list:TAAsmoutput);
  51. procedure gen_load_para_value(list:TAAsmoutput);
  52. procedure gen_load_return_value(list:TAAsmoutput);
  53. {#
  54. Allocate the buffers for exception management and setjmp environment.
  55. Return a pointer to these buffers, send them to the utility routine
  56. so they are registered, and then call setjmp.
  57. Then compare the result of setjmp with 0, and if not equal
  58. to zero, then jump to exceptlabel.
  59. Also store the result of setjmp to a temporary space by calling g_save_exception_reason
  60. It is to note that this routine may be called *after* the stackframe of a
  61. routine has been called, therefore on machines where the stack cannot
  62. be modified, all temps should be allocated on the heap instead of the
  63. stack.
  64. }
  65. const
  66. EXCEPT_BUF_SIZE = 3*sizeof(aint);
  67. type
  68. texceptiontemps=record
  69. jmpbuf,
  70. envbuf,
  71. reasonbuf : treference;
  72. end;
  73. procedure get_exception_temps(list:taasmoutput;var t:texceptiontemps);
  74. procedure unget_exception_temps(list:taasmoutput;const t:texceptiontemps);
  75. procedure new_exception(list:TAAsmoutput;const t:texceptiontemps;a:aint;exceptlabel:tasmlabel);
  76. procedure free_exception(list:TAAsmoutput;const t:texceptiontemps;a:aint;endexceptlabel:tasmlabel;onlyfree:boolean);
  77. procedure insertconstdata(sym : ttypedconstsym);
  78. procedure insertbssdata(sym : tvarsym);
  79. procedure gen_alloc_symtable(list:TAAsmoutput;st:tsymtable);
  80. procedure gen_free_symtable(list:TAAsmoutput;st:tsymtable);
  81. procedure gen_alloc_inline_parast(list:TAAsmoutput;pd:tprocdef);
  82. procedure gen_alloc_inline_funcret(list:TAAsmoutput;pd:tprocdef);
  83. { rtti and init/final }
  84. procedure generate_rtti(p:Ttypesym);
  85. procedure generate_inittable(p:tsym);
  86. implementation
  87. uses
  88. {$ifdef Delphi}
  89. Sysutils,
  90. {$else}
  91. strings,
  92. {$endif}
  93. cutils,cclasses,
  94. globals,systems,verbose,
  95. ppu,defutil,
  96. procinfo,paramgr,fmodule,
  97. regvars,dwarf,
  98. {$ifdef GDB}
  99. gdb,
  100. {$endif GDB}
  101. pass_1,pass_2,
  102. ncon,nld,nutils,
  103. tgobj,cgutils,cgobj;
  104. {*****************************************************************************
  105. Misc Helpers
  106. *****************************************************************************}
  107. { DO NOT RELY on the fact that the tnode is not yet swaped
  108. because of inlining code PM }
  109. procedure firstcomplex(p : tbinarynode);
  110. var
  111. hp : tnode;
  112. begin
  113. { always calculate boolean AND and OR from left to right }
  114. if (p.nodetype in [orn,andn]) and
  115. is_boolean(p.left.resulttype.def) then
  116. begin
  117. if nf_swaped in p.flags then
  118. internalerror(234234);
  119. end
  120. else
  121. if (
  122. (p.location.loc=LOC_FPUREGISTER) and
  123. (p.right.registersfpu > p.left.registersfpu)
  124. ) or
  125. (
  126. (
  127. (
  128. ((p.left.registersfpu = 0) and (p.right.registersfpu = 0)) or
  129. (p.location.loc<>LOC_FPUREGISTER)
  130. ) and
  131. (p.left.registersint<p.right.registersint)
  132. )
  133. ) then
  134. begin
  135. hp:=p.left;
  136. p.left:=p.right;
  137. p.right:=hp;
  138. if nf_swaped in p.flags then
  139. exclude(p.flags,nf_swaped)
  140. else
  141. include(p.flags,nf_swaped);
  142. end;
  143. end;
  144. procedure maketojumpbool(list:TAAsmoutput; p : tnode; loadregvars: tloadregvars);
  145. {
  146. produces jumps to true respectively false labels using boolean expressions
  147. depending on whether the loading of regvars is currently being
  148. synchronized manually (such as in an if-node) or automatically (most of
  149. the other cases where this procedure is called), loadregvars can be
  150. "lr_load_regvars" or "lr_dont_load_regvars"
  151. }
  152. var
  153. opsize : tcgsize;
  154. storepos : tfileposinfo;
  155. begin
  156. if nf_error in p.flags then
  157. exit;
  158. storepos:=aktfilepos;
  159. aktfilepos:=p.fileinfo;
  160. if is_boolean(p.resulttype.def) then
  161. begin
  162. {$ifdef OLDREGVARS}
  163. if loadregvars = lr_load_regvars then
  164. load_all_regvars(list);
  165. {$endif OLDREGVARS}
  166. if is_constboolnode(p) then
  167. begin
  168. if tordconstnode(p).value<>0 then
  169. cg.a_jmp_always(list,truelabel)
  170. else
  171. cg.a_jmp_always(list,falselabel)
  172. end
  173. else
  174. begin
  175. opsize:=def_cgsize(p.resulttype.def);
  176. case p.location.loc of
  177. LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
  178. begin
  179. {$ifdef OLDREGVARS}
  180. if (p.location.loc = LOC_CREGISTER) then
  181. load_regvar_reg(list,p.location.register);
  182. {$endif OLDREGVARS}
  183. cg.a_cmp_const_loc_label(list,opsize,OC_NE,0,p.location,truelabel);
  184. cg.a_jmp_always(list,falselabel);
  185. end;
  186. LOC_JUMP:
  187. ;
  188. {$ifdef cpuflags}
  189. LOC_FLAGS :
  190. begin
  191. cg.a_jmp_flags(list,p.location.resflags,truelabel);
  192. cg.a_jmp_always(list,falselabel);
  193. end;
  194. {$endif cpuflags}
  195. else
  196. begin
  197. printnode(output,p);
  198. internalerror(200308241);
  199. end;
  200. end;
  201. end;
  202. end
  203. else
  204. internalerror(200112305);
  205. aktfilepos:=storepos;
  206. end;
  207. (*
  208. This code needs fixing. It is not safe to use rgint; on the m68000 it
  209. would be rgaddr.
  210. procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsuperregisterset);
  211. begin
  212. case t.loc of
  213. LOC_REGISTER:
  214. begin
  215. { can't be a regvar, since it would be LOC_CREGISTER then }
  216. exclude(regs,getsupreg(t.register));
  217. if t.registerhigh<>NR_NO then
  218. exclude(regs,getsupreg(t.registerhigh));
  219. end;
  220. LOC_CREFERENCE,LOC_REFERENCE:
  221. begin
  222. if not(cs_regvars in aktglobalswitches) or
  223. (getsupreg(t.reference.base) in cg.rgint.usableregs) then
  224. exclude(regs,getsupreg(t.reference.base));
  225. if not(cs_regvars in aktglobalswitches) or
  226. (getsupreg(t.reference.index) in cg.rgint.usableregs) then
  227. exclude(regs,getsupreg(t.reference.index));
  228. end;
  229. end;
  230. end;
  231. *)
  232. {*****************************************************************************
  233. EXCEPTION MANAGEMENT
  234. *****************************************************************************}
  235. procedure get_exception_temps(list:taasmoutput;var t:texceptiontemps);
  236. begin
  237. tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistent,t.envbuf);
  238. tg.GetTemp(list,JMP_BUF_SIZE,tt_persistent,t.jmpbuf);
  239. tg.GetTemp(list,sizeof(aint),tt_persistent,t.reasonbuf);
  240. end;
  241. procedure unget_exception_temps(list:taasmoutput;const t:texceptiontemps);
  242. begin
  243. tg.Ungettemp(list,t.jmpbuf);
  244. tg.ungettemp(list,t.envbuf);
  245. tg.ungettemp(list,t.reasonbuf);
  246. end;
  247. procedure new_exception(list:TAAsmoutput;const t:texceptiontemps;a:aint;exceptlabel:tasmlabel);
  248. var
  249. paraloc1,paraloc2,paraloc3 : tcgpara;
  250. begin
  251. paraloc1.init;
  252. paraloc2.init;
  253. paraloc3.init;
  254. paramanager.getintparaloc(pocall_default,1,paraloc1);
  255. paramanager.getintparaloc(pocall_default,2,paraloc2);
  256. paramanager.getintparaloc(pocall_default,3,paraloc3);
  257. paramanager.allocparaloc(list,paraloc3);
  258. cg.a_paramaddr_ref(list,t.envbuf,paraloc3);
  259. paramanager.allocparaloc(list,paraloc2);
  260. cg.a_paramaddr_ref(list,t.jmpbuf,paraloc2);
  261. { push type of exceptionframe }
  262. paramanager.allocparaloc(list,paraloc1);
  263. cg.a_param_const(list,OS_S32,1,paraloc1);
  264. paramanager.freeparaloc(list,paraloc3);
  265. paramanager.freeparaloc(list,paraloc2);
  266. paramanager.freeparaloc(list,paraloc1);
  267. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  268. cg.a_call_name(list,'FPC_PUSHEXCEPTADDR');
  269. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  270. paramanager.getintparaloc(pocall_default,1,paraloc1);
  271. paramanager.allocparaloc(list,paraloc1);
  272. cg.a_param_reg(list,OS_ADDR,NR_FUNCTION_RESULT_REG,paraloc1);
  273. paramanager.freeparaloc(list,paraloc1);
  274. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  275. cg.a_call_name(list,'FPC_SETJMP');
  276. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  277. cg.g_exception_reason_save(list, t.reasonbuf);
  278. cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,cg.makeregsize(list,NR_FUNCTION_RESULT_REG,OS_S32),exceptlabel);
  279. paraloc1.done;
  280. paraloc2.done;
  281. paraloc3.done;
  282. end;
  283. procedure free_exception(list:TAAsmoutput;const t:texceptiontemps;a:aint;endexceptlabel:tasmlabel;onlyfree:boolean);
  284. begin
  285. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  286. cg.a_call_name(list,'FPC_POPADDRSTACK');
  287. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  288. if not onlyfree then
  289. begin
  290. cg.g_exception_reason_load(list, t.reasonbuf);
  291. cg.a_cmp_const_reg_label(list,OS_INT,OC_EQ,a,NR_FUNCTION_RESULT_REG,endexceptlabel);
  292. end;
  293. end;
  294. {*****************************************************************************
  295. TLocation
  296. *****************************************************************************}
  297. {$ifndef cpu64bit}
  298. { 32-bit version }
  299. procedure location_force_reg(list:TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  300. var
  301. hregister,
  302. hregisterhi : tregister;
  303. hreg64 : tregister64;
  304. hl : tasmlabel;
  305. oldloc : tlocation;
  306. const_location: boolean;
  307. begin
  308. oldloc:=l;
  309. if dst_size=OS_NO then
  310. internalerror(200309144);
  311. { handle transformations to 64bit separate }
  312. if dst_size in [OS_64,OS_S64] then
  313. begin
  314. if not (l.size in [OS_64,OS_S64]) then
  315. begin
  316. { load a smaller size to OS_64 }
  317. if l.loc=LOC_REGISTER then
  318. begin
  319. hregister:=cg.makeregsize(list,l.registerlow,OS_32);
  320. cg.a_load_reg_reg(list,l.size,OS_32,l.registerlow,hregister);
  321. end
  322. else
  323. hregister:=cg.getintregister(list,OS_INT);
  324. { load value in low register }
  325. case l.loc of
  326. LOC_FLAGS :
  327. cg.g_flags2reg(list,OS_INT,l.resflags,hregister);
  328. LOC_JUMP :
  329. begin
  330. cg.a_label(list,truelabel);
  331. cg.a_load_const_reg(list,OS_INT,1,hregister);
  332. objectlibrary.getlabel(hl);
  333. cg.a_jmp_always(list,hl);
  334. cg.a_label(list,falselabel);
  335. cg.a_load_const_reg(list,OS_INT,0,hregister);
  336. cg.a_label(list,hl);
  337. end;
  338. else
  339. cg.a_load_loc_reg(list,OS_INT,l,hregister);
  340. end;
  341. { reset hi part, take care of the signed bit of the current value }
  342. hregisterhi:=cg.getintregister(list,OS_INT);
  343. if (l.size in [OS_S8,OS_S16,OS_S32]) then
  344. begin
  345. if l.loc=LOC_CONSTANT then
  346. begin
  347. if (longint(l.value)<0) then
  348. cg.a_load_const_reg(list,OS_32,aint($ffffffff),hregisterhi)
  349. else
  350. cg.a_load_const_reg(list,OS_32,0,hregisterhi);
  351. end
  352. else
  353. begin
  354. cg.a_op_const_reg_reg(list,OP_SAR,OS_32,31,hregister,
  355. hregisterhi);
  356. end;
  357. end
  358. else
  359. cg.a_load_const_reg(list,OS_32,0,hregisterhi);
  360. location_reset(l,LOC_REGISTER,dst_size);
  361. l.registerlow:=hregister;
  362. l.registerhigh:=hregisterhi;
  363. end
  364. else
  365. begin
  366. { 64bit to 64bit }
  367. if (l.loc=LOC_REGISTER) or
  368. ((l.loc=LOC_CREGISTER) and maybeconst) then
  369. begin
  370. hregister:=l.registerlow;
  371. hregisterhi:=l.registerhigh;
  372. end
  373. else
  374. begin
  375. hregister:=cg.getintregister(list,OS_INT);
  376. hregisterhi:=cg.getintregister(list,OS_INT);
  377. end;
  378. hreg64.reglo:=hregister;
  379. hreg64.reghi:=hregisterhi;
  380. { load value in new register }
  381. cg64.a_load64_loc_reg(list,l,hreg64);
  382. location_reset(l,LOC_REGISTER,dst_size);
  383. l.registerlow:=hregister;
  384. l.registerhigh:=hregisterhi;
  385. end;
  386. end
  387. else
  388. begin
  389. {Do not bother to recycle the existing register. The register
  390. allocator eliminates unnecessary moves, so it's not needed
  391. and trying to recycle registers can cause problems because
  392. the registers changes size and may need aditional constraints.
  393. Not if it's about LOC_CREGISTER's (JM)
  394. }
  395. const_location :=
  396. (maybeconst) and
  397. (l.loc = LOC_CREGISTER) and
  398. (TCGSize2Size[l.size] = TCGSize2Size[dst_size]) and
  399. ((l.size = dst_size) or
  400. (TCGSize2Size[l.size] = TCGSize2Size[OS_INT]));
  401. if not const_location then
  402. hregister:=cg.getintregister(list,dst_size)
  403. else
  404. hregister := l.register;
  405. { load value in new register }
  406. case l.loc of
  407. LOC_FLAGS :
  408. cg.g_flags2reg(list,dst_size,l.resflags,hregister);
  409. LOC_JUMP :
  410. begin
  411. cg.a_label(list,truelabel);
  412. cg.a_load_const_reg(list,dst_size,1,hregister);
  413. objectlibrary.getlabel(hl);
  414. cg.a_jmp_always(list,hl);
  415. cg.a_label(list,falselabel);
  416. cg.a_load_const_reg(list,dst_size,0,hregister);
  417. cg.a_label(list,hl);
  418. end;
  419. else
  420. begin
  421. { load_loc_reg can only handle size >= l.size, when the
  422. new size is smaller then we need to adjust the size
  423. of the orignal and maybe recalculate l.register for i386 }
  424. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  425. begin
  426. if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  427. l.register:=cg.makeregsize(list,l.register,dst_size);
  428. { for big endian systems, the reference's offset must }
  429. { be increased in this case, since they have the }
  430. { MSB first in memory and e.g. byte(word_var) should }
  431. { return the second byte in this case (JM) }
  432. if (target_info.endian = ENDIAN_BIG) and
  433. (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  434. inc(l.reference.offset,TCGSize2Size[l.size]-TCGSize2Size[dst_size]);
  435. {$ifdef x86}
  436. l.size:=dst_size;
  437. {$endif x86}
  438. end;
  439. cg.a_load_loc_reg(list,dst_size,l,hregister);
  440. {$ifndef x86}
  441. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  442. l.size:=dst_size;
  443. {$endif not x86}
  444. end;
  445. end;
  446. if not const_location then
  447. location_reset(l,LOC_REGISTER,dst_size)
  448. else
  449. location_reset(l,LOC_CREGISTER,dst_size);
  450. l.register:=hregister;
  451. end;
  452. { Release temp when it was a reference }
  453. if oldloc.loc=LOC_REFERENCE then
  454. location_freetemp(list,oldloc);
  455. end;
  456. {$else cpu64bit}
  457. { 64-bit version }
  458. procedure location_force_reg(list:TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  459. var
  460. hregister : tregister;
  461. hl : tasmlabel;
  462. oldloc : tlocation;
  463. begin
  464. oldloc:=l;
  465. hregister:=cg.getintregister(list,dst_size);
  466. { load value in new register }
  467. case l.loc of
  468. LOC_FLAGS :
  469. cg.g_flags2reg(list,dst_size,l.resflags,hregister);
  470. LOC_JUMP :
  471. begin
  472. cg.a_label(list,truelabel);
  473. cg.a_load_const_reg(list,dst_size,1,hregister);
  474. objectlibrary.getlabel(hl);
  475. cg.a_jmp_always(list,hl);
  476. cg.a_label(list,falselabel);
  477. cg.a_load_const_reg(list,dst_size,0,hregister);
  478. cg.a_label(list,hl);
  479. end;
  480. else
  481. begin
  482. { load_loc_reg can only handle size >= l.size, when the
  483. new size is smaller then we need to adjust the size
  484. of the orignal and maybe recalculate l.register for i386 }
  485. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  486. begin
  487. if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  488. l.register:=cg.makeregsize(list,l.register,dst_size);
  489. { for big endian systems, the reference's offset must }
  490. { be increased in this case, since they have the }
  491. { MSB first in memory and e.g. byte(word_var) should }
  492. { return the second byte in this case (JM) }
  493. if (target_info.endian = ENDIAN_BIG) and
  494. (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  495. inc(l.reference.offset,TCGSize2Size[l.size]-TCGSize2Size[dst_size]);
  496. {$ifdef x86}
  497. l.size:=dst_size;
  498. {$endif x86}
  499. end;
  500. cg.a_load_loc_reg(list,dst_size,l,hregister);
  501. {$ifndef x86}
  502. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  503. l.size:=dst_size;
  504. {$endif not x86}
  505. end;
  506. end;
  507. if (l.loc <> LOC_CREGISTER) or
  508. not maybeconst then
  509. location_reset(l,LOC_REGISTER,dst_size)
  510. else
  511. location_reset(l,LOC_CREGISTER,dst_size);
  512. l.register:=hregister;
  513. { Release temp when it was a reference }
  514. if oldloc.loc=LOC_REFERENCE then
  515. location_freetemp(list,oldloc);
  516. end;
  517. {$endif cpu64bit}
  518. procedure location_force_fpureg(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
  519. var
  520. reg : tregister;
  521. href : treference;
  522. begin
  523. if (l.loc<>LOC_FPUREGISTER) and
  524. ((l.loc<>LOC_CFPUREGISTER) or (not maybeconst)) then
  525. begin
  526. { if it's in an mm register, store to memory first }
  527. if (l.loc in [LOC_MMREGISTER,LOC_CMMREGISTER]) then
  528. begin
  529. tg.GetTemp(list,tcgsize2size[l.size],tt_normal,href);
  530. cg.a_loadmm_reg_ref(list,l.size,l.size,l.register,href,mms_movescalar);
  531. location_reset(l,LOC_REFERENCE,l.size);
  532. l.reference:=href;
  533. end;
  534. reg:=cg.getfpuregister(list,l.size);
  535. cg.a_loadfpu_loc_reg(list,l,reg);
  536. location_freetemp(list,l);
  537. location_reset(l,LOC_FPUREGISTER,l.size);
  538. l.register:=reg;
  539. end;
  540. end;
  541. procedure location_force_mmregscalar(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
  542. var
  543. reg : tregister;
  544. href : treference;
  545. begin
  546. if (l.loc<>LOC_MMREGISTER) and
  547. ((l.loc<>LOC_CMMREGISTER) or (not maybeconst)) then
  548. begin
  549. { if it's in an fpu register, store to memory first }
  550. if (l.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then
  551. begin
  552. tg.GetTemp(list,tcgsize2size[l.size],tt_normal,href);
  553. cg.a_loadfpu_reg_ref(list,l.size,l.register,href);
  554. location_reset(l,LOC_REFERENCE,l.size);
  555. l.reference:=href;
  556. end;
  557. reg:=cg.getmmregister(list,l.size);
  558. cg.a_loadmm_loc_reg(list,l.size,l,reg,mms_movescalar);
  559. location_freetemp(list,l);
  560. location_reset(l,LOC_MMREGISTER,l.size);
  561. l.register:=reg;
  562. end;
  563. end;
  564. procedure location_force_mem(list:TAAsmoutput;var l:tlocation);
  565. var
  566. r : treference;
  567. begin
  568. case l.loc of
  569. LOC_FPUREGISTER,
  570. LOC_CFPUREGISTER :
  571. begin
  572. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
  573. cg.a_loadfpu_reg_ref(list,l.size,l.register,r);
  574. location_reset(l,LOC_REFERENCE,l.size);
  575. l.reference:=r;
  576. end;
  577. LOC_MMREGISTER,
  578. LOC_CMMREGISTER:
  579. begin
  580. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
  581. cg.a_loadmm_reg_ref(list,l.size,l.size,l.register,r,mms_movescalar);
  582. location_reset(l,LOC_REFERENCE,l.size);
  583. l.reference:=r;
  584. end;
  585. LOC_CONSTANT,
  586. LOC_REGISTER,
  587. LOC_CREGISTER :
  588. begin
  589. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
  590. {$ifndef cpu64bit}
  591. if l.size in [OS_64,OS_S64] then
  592. cg64.a_load64_loc_ref(list,l,r)
  593. else
  594. {$endif cpu64bit}
  595. cg.a_load_loc_ref(list,l.size,l,r);
  596. location_reset(l,LOC_REFERENCE,l.size);
  597. l.reference:=r;
  598. end;
  599. LOC_CREFERENCE,
  600. LOC_REFERENCE : ;
  601. else
  602. internalerror(200203219);
  603. end;
  604. end;
  605. {*****************************************************************************
  606. Maybe_Save
  607. *****************************************************************************}
  608. function maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
  609. begin
  610. {$ifdef i386}
  611. if (needed>=maxfpuregs) and
  612. (l.loc = LOC_FPUREGISTER) then
  613. begin
  614. location_force_mem(list,l);
  615. maybe_pushfpu:=true;
  616. end
  617. else
  618. maybe_pushfpu:=false;
  619. {$else i386}
  620. maybe_pushfpu:=false;
  621. {$endif i386}
  622. end;
  623. {****************************************************************************
  624. Init/Finalize Code
  625. ****************************************************************************}
  626. procedure copyvalueparas(p : tnamedindexitem;arg:pointer);
  627. var
  628. href1 : treference;
  629. list:TAAsmoutput;
  630. hsym : tvarsym;
  631. l : longint;
  632. loadref : boolean;
  633. localcopyloc : tlocation;
  634. begin
  635. list:=taasmoutput(arg);
  636. if (tsym(p).typ=varsym) and
  637. (tvarsym(p).varspez=vs_value) and
  638. (paramanager.push_addr_param(tvarsym(p).varspez,tvarsym(p).vartype.def,current_procinfo.procdef.proccalloption)) then
  639. begin
  640. loadref:=true;
  641. case tvarsym(p).localloc.loc of
  642. LOC_REGISTER :
  643. begin
  644. reference_reset_base(href1,tvarsym(p).localloc.register,0);
  645. loadref:=false;
  646. end;
  647. LOC_REFERENCE :
  648. href1:=tvarsym(p).localloc.reference;
  649. else
  650. internalerror(200309181);
  651. end;
  652. if is_open_array(tvarsym(p).vartype.def) or
  653. is_array_of_const(tvarsym(p).vartype.def) then
  654. begin
  655. { cdecl functions don't have a high pointer so it is not possible to generate
  656. a local copy }
  657. if not(current_procinfo.procdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  658. begin
  659. hsym:=tvarsym(tsym(p).owner.search('high'+p.name));
  660. if not assigned(hsym) then
  661. internalerror(200306061);
  662. case hsym.localloc.loc of
  663. LOC_REFERENCE :
  664. begin
  665. { this code is only executed before the code for the body and the entry/exit code is generated
  666. so we're allowed to include pi_do_call here; after pass1 is run, this isn't allowed anymore
  667. }
  668. include(current_procinfo.flags,pi_do_call);
  669. cg.g_copyvaluepara_openarray(list,href1,hsym.localloc.reference,tarraydef(tvarsym(p).vartype.def).elesize)
  670. end
  671. else
  672. internalerror(200309182);
  673. end;
  674. end;
  675. end
  676. else
  677. begin
  678. if tvarsym(p).localloc.loc<>LOC_REFERENCE then
  679. internalerror(200309183);
  680. { Allocate space for the local copy }
  681. l:=tvarsym(p).getvaluesize;
  682. localcopyloc.loc:=LOC_REFERENCE;
  683. localcopyloc.size:=int_cgsize(l);
  684. tg.GetLocal(list,l,tvarsym(p).vartype.def,localcopyloc.reference);
  685. { Copy data }
  686. if is_shortstring(tvarsym(p).vartype.def) then
  687. begin
  688. { this code is only executed before the code for the body and the entry/exit code is generated
  689. so we're allowed to include pi_do_call here; after pass1 is run, this isn't allowed anymore
  690. }
  691. include(current_procinfo.flags,pi_do_call);
  692. cg.g_copyshortstring(list,href1,localcopyloc.reference,tstringdef(tvarsym(p).vartype.def).len,loadref)
  693. end
  694. else
  695. cg.g_concatcopy(list,href1,localcopyloc.reference,tvarsym(p).vartype.def.size,loadref);
  696. { update localloc of varsym }
  697. tg.Ungetlocal(list,tvarsym(p).localloc.reference);
  698. tvarsym(p).localloc:=localcopyloc;
  699. end;
  700. end;
  701. end;
  702. { generates the code for initialisation of local data }
  703. procedure initialize_data(p : tnamedindexitem;arg:pointer);
  704. var
  705. oldexprasmlist : TAAsmoutput;
  706. hp : tnode;
  707. begin
  708. if (tsym(p).typ=varsym) and
  709. (tvarsym(p).refs>0) and
  710. not(is_class(tvarsym(p).vartype.def)) and
  711. tvarsym(p).vartype.def.needs_inittable then
  712. begin
  713. oldexprasmlist:=exprasmlist;
  714. exprasmlist:=taasmoutput(arg);
  715. hp:=initialize_data_node(cloadnode.create(tsym(p),tsym(p).owner));
  716. firstpass(hp);
  717. secondpass(hp);
  718. hp.free;
  719. exprasmlist:=oldexprasmlist;
  720. end;
  721. end;
  722. procedure finalize_sym(asmlist:taasmoutput;sym:tsym);
  723. var
  724. hp : tnode;
  725. oldexprasmlist : TAAsmoutput;
  726. begin
  727. include(current_procinfo.flags,pi_needs_implicit_finally);
  728. oldexprasmlist:=exprasmlist;
  729. exprasmlist:=asmlist;
  730. hp:=finalize_data_node(cloadnode.create(sym,sym.owner));
  731. firstpass(hp);
  732. secondpass(hp);
  733. hp.free;
  734. exprasmlist:=oldexprasmlist;
  735. end;
  736. { generates the code for finalisation of local variables }
  737. procedure finalize_local_vars(p : tnamedindexitem;arg:pointer);
  738. begin
  739. case tsym(p).typ of
  740. varsym :
  741. begin
  742. if (tvarsym(p).refs>0) and
  743. not(vo_is_funcret in tvarsym(p).varoptions) and
  744. not(is_class(tvarsym(p).vartype.def)) and
  745. tvarsym(p).vartype.def.needs_inittable then
  746. finalize_sym(taasmoutput(arg),tsym(p));
  747. end;
  748. end;
  749. end;
  750. { generates the code for finalisation of local typedconsts }
  751. procedure finalize_local_typedconst(p : tnamedindexitem;arg:pointer);
  752. var
  753. i : longint;
  754. pd : tprocdef;
  755. begin
  756. case tsym(p).typ of
  757. typedconstsym :
  758. begin
  759. if ttypedconstsym(p).is_writable and
  760. ttypedconstsym(p).typedconsttype.def.needs_inittable then
  761. finalize_sym(taasmoutput(arg),tsym(p));
  762. end;
  763. procsym :
  764. begin
  765. for i:=1 to tprocsym(p).procdef_count do
  766. begin
  767. pd:=tprocsym(p).procdef[i];
  768. if assigned(pd.localst) and
  769. (pd.procsym=tprocsym(p)) and
  770. (pd.localst.symtabletype<>staticsymtable) then
  771. pd.localst.foreach_static(@finalize_local_typedconst,arg);
  772. end;
  773. end;
  774. end;
  775. end;
  776. { generates the code for finalization of static symtable and
  777. all local (static) typedconsts }
  778. procedure finalize_static_data(p : tnamedindexitem;arg:pointer);
  779. var
  780. i : longint;
  781. pd : tprocdef;
  782. begin
  783. case tsym(p).typ of
  784. varsym :
  785. begin
  786. if (tvarsym(p).refs>0) and
  787. not(vo_is_funcret in tvarsym(p).varoptions) and
  788. not(is_class(tvarsym(p).vartype.def)) and
  789. tvarsym(p).vartype.def.needs_inittable then
  790. finalize_sym(taasmoutput(arg),tsym(p));
  791. end;
  792. typedconstsym :
  793. begin
  794. if ttypedconstsym(p).is_writable and
  795. ttypedconstsym(p).typedconsttype.def.needs_inittable then
  796. finalize_sym(taasmoutput(arg),tsym(p));
  797. end;
  798. procsym :
  799. begin
  800. for i:=1 to tprocsym(p).procdef_count do
  801. begin
  802. pd:=tprocsym(p).procdef[i];
  803. if assigned(pd.localst) and
  804. (pd.procsym=tprocsym(p)) and
  805. (pd.localst.symtabletype<>staticsymtable) then
  806. pd.localst.foreach_static(@finalize_local_typedconst,arg);
  807. end;
  808. end;
  809. end;
  810. end;
  811. { generates the code for incrementing the reference count of parameters and
  812. initialize out parameters }
  813. procedure init_paras(p : tnamedindexitem;arg:pointer);
  814. var
  815. href : treference;
  816. tmpreg : tregister;
  817. list:TAAsmoutput;
  818. begin
  819. list:=taasmoutput(arg);
  820. if (tsym(p).typ=varsym) and
  821. not is_class(tvarsym(p).vartype.def) and
  822. tvarsym(p).vartype.def.needs_inittable then
  823. begin
  824. case tvarsym(p).varspez of
  825. vs_value :
  826. begin
  827. if tvarsym(p).localloc.loc<>LOC_REFERENCE then
  828. internalerror(200309187);
  829. cg.g_incrrefcount(list,tvarsym(p).vartype.def,tvarsym(p).localloc.reference,is_open_array(tvarsym(p).vartype.def));
  830. end;
  831. vs_out :
  832. begin
  833. case tvarsym(p).localloc.loc of
  834. LOC_REFERENCE :
  835. href:=tvarsym(p).localloc.reference;
  836. else
  837. internalerror(2003091810);
  838. end;
  839. tmpreg:=cg.getaddressregister(list);
  840. cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,tmpreg);
  841. reference_reset_base(href,tmpreg,0);
  842. cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
  843. end;
  844. end;
  845. end;
  846. end;
  847. { generates the code for decrementing the reference count of parameters }
  848. procedure final_paras(p : tnamedindexitem;arg:pointer);
  849. var
  850. list:TAAsmoutput;
  851. begin
  852. list:=taasmoutput(arg);
  853. if (tsym(p).typ=varsym) and
  854. not is_class(tvarsym(p).vartype.def) and
  855. tvarsym(p).vartype.def.needs_inittable then
  856. begin
  857. if (tvarsym(p).varspez=vs_value) then
  858. begin
  859. include(current_procinfo.flags,pi_needs_implicit_finally);
  860. if tvarsym(p).localloc.loc<>LOC_REFERENCE then
  861. internalerror(200309188);
  862. cg.g_decrrefcount(list,tvarsym(p).vartype.def,tvarsym(p).localloc.reference,is_open_array(tvarsym(p).vartype.def));
  863. end;
  864. end
  865. else if (tsym(p).typ=varsym) and
  866. (tvarsym(p).varspez=vs_value) and
  867. (is_open_array(tvarsym(p).vartype.def) or
  868. is_array_of_const(tvarsym(p).vartype.def)) then
  869. begin
  870. { cdecl functions don't have a high pointer so it is not possible to generate
  871. a local copy }
  872. if not(current_procinfo.procdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  873. cg.g_releasevaluepara_openarray(list,tvarsym(p).localloc.reference);
  874. end;
  875. end;
  876. { Initialize temp ansi/widestrings,interfaces }
  877. procedure inittempvariables(list:taasmoutput);
  878. var
  879. hp : ptemprecord;
  880. href : treference;
  881. begin
  882. hp:=tg.templist;
  883. while assigned(hp) do
  884. begin
  885. if assigned(hp^.def) and
  886. hp^.def.needs_inittable then
  887. begin
  888. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  889. cg.g_initialize(list,hp^.def,href,false);
  890. end;
  891. hp:=hp^.next;
  892. end;
  893. end;
  894. procedure finalizetempvariables(list:taasmoutput);
  895. var
  896. hp : ptemprecord;
  897. href : treference;
  898. begin
  899. hp:=tg.templist;
  900. while assigned(hp) do
  901. begin
  902. if assigned(hp^.def) and
  903. hp^.def.needs_inittable then
  904. begin
  905. include(current_procinfo.flags,pi_needs_implicit_finally);
  906. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  907. cg.g_finalize(list,hp^.def,href,false);
  908. end;
  909. hp:=hp^.next;
  910. end;
  911. end;
  912. procedure gen_load_return_value(list:TAAsmoutput);
  913. var
  914. {$ifndef cpu64bit}
  915. href : treference;
  916. {$endif cpu64bit}
  917. ressym : tvarsym;
  918. resloc,
  919. restmploc : tlocation;
  920. hreg : tregister;
  921. funcretloc : pcgparalocation;
  922. begin
  923. { Is the loading needed? }
  924. if is_void(current_procinfo.procdef.rettype.def) or
  925. (
  926. (po_assembler in current_procinfo.procdef.procoptions) and
  927. (not(assigned(current_procinfo.procdef.funcretsym)) or
  928. (tvarsym(current_procinfo.procdef.funcretsym).refs=0))
  929. ) then
  930. exit;
  931. funcretloc:=current_procinfo.procdef.funcret_paraloc[calleeside].location;
  932. if not assigned(funcretloc) then
  933. internalerror(200408202);
  934. { constructors return self }
  935. if (current_procinfo.procdef.proctypeoption=potype_constructor) then
  936. ressym:=tvarsym(current_procinfo.procdef.parast.search('self'))
  937. else
  938. ressym:=tvarsym(current_procinfo.procdef.funcretsym);
  939. if (ressym.refs>0) then
  940. begin
  941. {$ifdef OLDREGVARS}
  942. case ressym.localloc.loc of
  943. LOC_CFPUREGISTER,
  944. LOC_FPUREGISTER:
  945. begin
  946. location_reset(restmploc,LOC_CFPUREGISTER,funcretloc^.size);
  947. restmploc.register:=ressym.localloc.register;
  948. end;
  949. LOC_CREGISTER,
  950. LOC_REGISTER:
  951. begin
  952. location_reset(restmploc,LOC_CREGISTER,funcretloc^.size);
  953. restmploc.register:=ressym.localloc.register;
  954. end;
  955. LOC_MMREGISTER:
  956. begin
  957. location_reset(restmploc,LOC_CMMREGISTER,funcretloc^.size);
  958. restmploc.register:=ressym.localloc.register;
  959. end;
  960. LOC_REFERENCE:
  961. begin
  962. location_reset(restmploc,LOC_REFERENCE,funcretloc^.size);
  963. restmploc.reference:=ressym.localloc.reference;
  964. end;
  965. else
  966. internalerror(200309184);
  967. end;
  968. {$else}
  969. restmploc:=ressym.localloc;
  970. {$endif}
  971. { Here, we return the function result. In most architectures, the value is
  972. passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
  973. function returns in a register and the caller receives it in an other one }
  974. case funcretloc^.loc of
  975. LOC_REGISTER:
  976. begin
  977. {$ifndef cpu64bit}
  978. if current_procinfo.procdef.funcret_paraloc[calleeside].size in [OS_64,OS_S64] then
  979. begin
  980. current_procinfo.procdef.funcret_paraloc[calleeside].get_location(resloc);
  981. if resloc.loc<>LOC_REGISTER then
  982. internalerror(200409141);
  983. { Load low and high register separate to generate better register
  984. allocation info }
  985. if getsupreg(resloc.registerlow)<first_int_imreg then
  986. begin
  987. cg.getcpuregister(list,resloc.registerlow);
  988. cg.ungetcpuregister(list,resloc.registerlow);
  989. { for the optimizer }
  990. cg.a_reg_alloc(list,resloc.registerlow);
  991. end;
  992. case restmploc.loc of
  993. LOC_REFERENCE :
  994. begin
  995. href:=restmploc.reference;
  996. if target_info.endian=ENDIAN_BIG then
  997. inc(href.offset,4);
  998. cg.a_load_ref_reg(list,OS_32,OS_32,href,resloc.registerlow);
  999. end;
  1000. LOC_CREGISTER :
  1001. cg.a_load_reg_reg(list,OS_32,OS_32,restmploc.registerlow,resloc.registerlow);
  1002. else
  1003. internalerror(200409203);
  1004. end;
  1005. if getsupreg(resloc.registerhigh)<first_int_imreg then
  1006. begin
  1007. cg.getcpuregister(list,resloc.registerhigh);
  1008. cg.ungetcpuregister(list,resloc.registerhigh);
  1009. { for the optimizer }
  1010. cg.a_reg_alloc(list,resloc.registerhigh);
  1011. end;
  1012. case restmploc.loc of
  1013. LOC_REFERENCE :
  1014. begin
  1015. href:=restmploc.reference;
  1016. if target_info.endian=ENDIAN_LITTLE then
  1017. inc(href.offset,4);
  1018. cg.a_load_ref_reg(list,OS_32,OS_32,href,resloc.registerhigh);
  1019. end;
  1020. LOC_CREGISTER :
  1021. cg.a_load_reg_reg(list,OS_32,OS_32,restmploc.registerhigh,resloc.registerhigh);
  1022. else
  1023. internalerror(200409204);
  1024. end;
  1025. end
  1026. else
  1027. {$endif cpu64bit}
  1028. begin
  1029. hreg:=cg.makeregsize(list,funcretloc^.register,restmploc.size);
  1030. if getsupreg(funcretloc^.register)<first_int_imreg then
  1031. begin
  1032. cg.getcpuregister(list,funcretloc^.register);
  1033. cg.ungetcpuregister(list,hreg);
  1034. { for the optimizer }
  1035. cg.a_reg_alloc(list,funcretloc^.register);
  1036. end;
  1037. cg.a_load_loc_reg(list,restmploc.size,restmploc,hreg);
  1038. end;
  1039. end;
  1040. LOC_FPUREGISTER:
  1041. begin
  1042. if getsupreg(funcretloc^.register)<first_fpu_imreg then
  1043. begin
  1044. cg.getcpuregister(list,funcretloc^.register);
  1045. cg.ungetcpuregister(list,funcretloc^.register);
  1046. end;
  1047. cg.a_loadfpu_loc_reg(list,restmploc,funcretloc^.register);
  1048. end;
  1049. LOC_MMREGISTER:
  1050. begin
  1051. if getsupreg(funcretloc^.register)<first_mm_imreg then
  1052. begin
  1053. cg.getcpuregister(list,funcretloc^.register);
  1054. cg.ungetcpuregister(list,funcretloc^.register);
  1055. end;
  1056. cg.a_loadmm_loc_reg(list,restmploc.size,restmploc,funcretloc^.register,mms_movescalar);
  1057. end;
  1058. LOC_INVALID,
  1059. LOC_REFERENCE:
  1060. ;
  1061. else
  1062. internalerror(200405025);
  1063. end;
  1064. end;
  1065. end;
  1066. procedure gen_load_para_value(list:TAAsmoutput);
  1067. procedure get_para(const paraloc:TCGParaLocation);
  1068. begin
  1069. case paraloc.loc of
  1070. LOC_REGISTER :
  1071. begin
  1072. if getsupreg(paraloc.register)<first_int_imreg then
  1073. cg.getcpuregister(list,paraloc.register);
  1074. end;
  1075. LOC_MMREGISTER :
  1076. begin
  1077. if getsupreg(paraloc.register)<first_mm_imreg then
  1078. cg.getcpuregister(list,paraloc.register);
  1079. end;
  1080. LOC_FPUREGISTER :
  1081. begin
  1082. if getsupreg(paraloc.register)<first_fpu_imreg then
  1083. cg.getcpuregister(list,paraloc.register);
  1084. end;
  1085. end;
  1086. end;
  1087. procedure unget_para(const paraloc:TCGParaLocation);
  1088. begin
  1089. case paraloc.loc of
  1090. LOC_REGISTER :
  1091. begin
  1092. if getsupreg(paraloc.register)<first_int_imreg then
  1093. cg.ungetcpuregister(list,paraloc.register);
  1094. end;
  1095. LOC_MMREGISTER :
  1096. begin
  1097. if getsupreg(paraloc.register)<first_mm_imreg then
  1098. cg.ungetcpuregister(list,paraloc.register);
  1099. end;
  1100. LOC_FPUREGISTER :
  1101. begin
  1102. if getsupreg(paraloc.register)<first_fpu_imreg then
  1103. cg.ungetcpuregister(list,paraloc.register);
  1104. end;
  1105. end;
  1106. end;
  1107. procedure gen_load_ref(const paraloc:TCGParaLocation;const ref:treference);
  1108. var
  1109. href : treference;
  1110. begin
  1111. case paraloc.loc of
  1112. LOC_REGISTER :
  1113. cg.a_load_reg_ref(list,paraloc.size,paraloc.size,paraloc.register,ref);
  1114. LOC_MMREGISTER :
  1115. cg.a_loadmm_reg_ref(list,paraloc.size,paraloc.size,paraloc.register,ref,mms_movescalar);
  1116. LOC_FPUREGISTER :
  1117. cg.a_loadfpu_reg_ref(list,paraloc.size,paraloc.register,ref);
  1118. LOC_REFERENCE :
  1119. begin
  1120. reference_reset_base(href,paraloc.reference.index,paraloc.reference.offset);
  1121. { use concatcopy, because it can also be a float which fails when
  1122. load_ref_ref is used. Don't copy data when the references are equal }
  1123. if not((href.base=ref.base) and (href.offset=ref.offset)) then
  1124. cg.g_concatcopy(list,href,ref,tcgsize2size[paraloc.size],false);
  1125. end;
  1126. else
  1127. internalerror(2002081302);
  1128. end;
  1129. end;
  1130. procedure gen_load_reg(const paraloc:TCGParaLocation;reg:tregister);
  1131. var
  1132. href : treference;
  1133. begin
  1134. case paraloc.loc of
  1135. LOC_REGISTER :
  1136. cg.a_load_reg_reg(list,paraloc.size,paraloc.size,paraloc.register,reg);
  1137. LOC_MMREGISTER :
  1138. cg.a_loadmm_reg_reg(list,paraloc.size,paraloc.size,paraloc.register,reg,mms_movescalar);
  1139. LOC_FPUREGISTER :
  1140. cg.a_loadfpu_reg_reg(list,paraloc.size,paraloc.register,reg);
  1141. LOC_REFERENCE :
  1142. begin
  1143. reference_reset_base(href,paraloc.reference.index,paraloc.reference.offset);
  1144. cg.a_load_ref_reg(list,paraloc.size,paraloc.size,href,reg);
  1145. end;
  1146. else
  1147. internalerror(2002081302);
  1148. end;
  1149. end;
  1150. var
  1151. hp : tparaitem;
  1152. paraloc : pcgparalocation;
  1153. tempref,
  1154. href : treference;
  1155. begin
  1156. if (po_assembler in current_procinfo.procdef.procoptions) then
  1157. exit;
  1158. { Allocate registers used by parameters }
  1159. hp:=tparaitem(current_procinfo.procdef.para.first);
  1160. while assigned(hp) do
  1161. begin
  1162. paraloc:=hp.paraloc[calleeside].location;
  1163. while assigned(paraloc) do
  1164. begin
  1165. if paraloc^.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER] then
  1166. get_para(paraloc^);
  1167. paraloc:=paraloc^.next;
  1168. end;
  1169. hp:=tparaitem(hp.next);
  1170. end;
  1171. { Copy parameters to local references/registers }
  1172. hp:=tparaitem(current_procinfo.procdef.para.first);
  1173. while assigned(hp) do
  1174. begin
  1175. paraloc:=hp.paraloc[calleeside].location;
  1176. if not assigned(paraloc) then
  1177. internalerror(200408203);
  1178. case tvarsym(hp.parasym).localloc.loc of
  1179. LOC_REFERENCE :
  1180. begin
  1181. href:=tvarsym(hp.parasym).localloc.reference;
  1182. while assigned(paraloc) do
  1183. begin
  1184. unget_para(paraloc^);
  1185. gen_load_ref(paraloc^,href);
  1186. inc(href.offset,TCGSize2Size[paraloc^.size]);
  1187. paraloc:=paraloc^.next;
  1188. end;
  1189. end;
  1190. LOC_CREGISTER :
  1191. begin
  1192. {$ifndef cpu64bit}
  1193. if tvarsym(hp.parasym).localloc.size in [OS_64,OS_S64] then
  1194. begin
  1195. { First 32bits }
  1196. unget_para(paraloc^);
  1197. if (target_info.endian=ENDIAN_BIG) then
  1198. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerhigh)
  1199. else
  1200. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerlow);
  1201. { Second 32bits }
  1202. if not assigned(paraloc^.next) then
  1203. internalerror(200410104);
  1204. unget_para(paraloc^);
  1205. if (target_info.endian=ENDIAN_BIG) then
  1206. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerlow)
  1207. else
  1208. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerhigh);
  1209. end
  1210. else
  1211. {$endif cpu64bit}
  1212. begin
  1213. unget_para(paraloc^);
  1214. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register);
  1215. if assigned(paraloc^.next) then
  1216. internalerror(200410105);
  1217. end;
  1218. end;
  1219. LOC_CFPUREGISTER :
  1220. begin
  1221. {$ifdef sparc}
  1222. { Sparc passes floats in int registers, when loading to fpu register
  1223. we need a temp }
  1224. tg.GetTemp(list,TCGSize2Size[tvarsym(hp.parasym).localloc.size],tt_normal,tempref);
  1225. href:=tempref;
  1226. while assigned(paraloc) do
  1227. begin
  1228. unget_para(paraloc^);
  1229. gen_load_ref(paraloc^,href);
  1230. inc(href.offset,TCGSize2Size[paraloc^.size]);
  1231. paraloc:=paraloc^.next;
  1232. end;
  1233. cg.a_loadfpu_ref_reg(list,tvarsym(hp.parasym).localloc.size,tempref,tvarsym(hp.parasym).localloc.register);
  1234. tg.UnGetTemp(list,tempref);
  1235. {$else sparc}
  1236. unget_para(paraloc^);
  1237. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register);
  1238. if assigned(paraloc^.next) then
  1239. internalerror(200410109);
  1240. {$endif sparc}
  1241. end;
  1242. LOC_CMMREGISTER :
  1243. begin
  1244. unget_para(paraloc^);
  1245. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register);
  1246. if assigned(paraloc^.next) then
  1247. internalerror(200410108);
  1248. end;
  1249. end;
  1250. hp:=tparaitem(hp.next);
  1251. end;
  1252. { generate copies of call by value parameters, must be done before
  1253. the initialization and body is parsed because the refcounts are
  1254. incremented using the local copies }
  1255. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1256. end;
  1257. procedure gen_initialize_code(list:TAAsmoutput);
  1258. begin
  1259. { initialize local data like ansistrings }
  1260. case current_procinfo.procdef.proctypeoption of
  1261. potype_unitinit:
  1262. begin
  1263. { this is also used for initialization of variables in a
  1264. program which does not have a globalsymtable }
  1265. if assigned(current_module.globalsymtable) then
  1266. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1267. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1268. end;
  1269. { units have seperate code for initilization and finalization }
  1270. potype_unitfinalize: ;
  1271. { program init/final is generated in separate procedure }
  1272. potype_proginit: ;
  1273. else
  1274. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1275. end;
  1276. { initialisizes temp. ansi/wide string data }
  1277. inittempvariables(list);
  1278. { initialize ansi/widesstring para's }
  1279. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1280. {$ifdef OLDREGVARS}
  1281. load_regvars(list,nil);
  1282. {$endif OLDREGVARS}
  1283. end;
  1284. procedure gen_finalize_code(list:TAAsmoutput);
  1285. begin
  1286. {$ifdef OLDREGVARS}
  1287. cleanup_regvars(list);
  1288. {$endif OLDREGVARS}
  1289. { finalize temporary data }
  1290. finalizetempvariables(list);
  1291. { finalize local data like ansistrings}
  1292. case current_procinfo.procdef.proctypeoption of
  1293. potype_unitfinalize:
  1294. begin
  1295. { this is also used for initialization of variables in a
  1296. program which does not have a globalsymtable }
  1297. if assigned(current_module.globalsymtable) then
  1298. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}finalize_static_data,list);
  1299. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}finalize_static_data,list);
  1300. end;
  1301. { units/progs have separate code for initialization and finalization }
  1302. potype_unitinit: ;
  1303. { program init/final is generated in separate procedure }
  1304. potype_proginit: ;
  1305. else
  1306. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_local_vars,list);
  1307. end;
  1308. { finalize paras data }
  1309. if assigned(current_procinfo.procdef.parast) then
  1310. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1311. end;
  1312. procedure gen_entry_code(list:TAAsmoutput);
  1313. var
  1314. href : treference;
  1315. paraloc1,
  1316. paraloc2 : tcgpara;
  1317. hp : tused_unit;
  1318. begin
  1319. paraloc1.init;
  1320. paraloc2.init;
  1321. { the actual profile code can clobber some registers,
  1322. therefore if the context must be saved, do it before
  1323. the actual call to the profile code
  1324. }
  1325. if (cs_profile in aktmoduleswitches) and
  1326. not(po_assembler in current_procinfo.procdef.procoptions) then
  1327. begin
  1328. { non-win32 can call mcout even in main }
  1329. if not (target_info.system in [system_i386_win32,system_i386_wdosx]) or
  1330. not (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1331. begin
  1332. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1333. cg.g_profilecode(list);
  1334. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1335. end;
  1336. end;
  1337. { call startup helpers from main program }
  1338. if (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1339. begin
  1340. { initialize profiling for win32 }
  1341. if (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1342. (cs_profile in aktmoduleswitches) then
  1343. begin
  1344. reference_reset_symbol(href,objectlibrary.newasmsymbol('etext',AB_EXTERNAL,AT_DATA),0);
  1345. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1346. paramanager.getintparaloc(pocall_default,2,paraloc2);
  1347. paramanager.allocparaloc(list,paraloc2);
  1348. cg.a_paramaddr_ref(list,href,paraloc2);
  1349. reference_reset_symbol(href,objectlibrary.newasmsymbol('__image_base__',AB_EXTERNAL,AT_DATA),0);
  1350. paramanager.allocparaloc(list,paraloc1);
  1351. cg.a_paramaddr_ref(list,href,paraloc1);
  1352. paramanager.freeparaloc(list,paraloc2);
  1353. paramanager.freeparaloc(list,paraloc1);
  1354. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1355. cg.a_call_name(list,'_monstartup');
  1356. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1357. end;
  1358. { initialize units }
  1359. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1360. cg.a_call_name(list,'FPC_INITIALIZEUNITS');
  1361. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1362. {$ifdef GDB}
  1363. if (cs_debuginfo in aktmoduleswitches) then
  1364. if target_info.system <> system_powerpc_macos then
  1365. begin
  1366. { include reference to all debuginfo sections of used units }
  1367. hp:=tused_unit(usedunits.first);
  1368. while assigned(hp) do
  1369. begin
  1370. If (hp.u.flags and uf_has_debuginfo)=uf_has_debuginfo then
  1371. current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.u.globalsymtable,''),AT_DATA,0));
  1372. hp:=tused_unit(hp.next);
  1373. end;
  1374. { include reference to debuginfo for this program }
  1375. current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
  1376. end;
  1377. {$endif GDB}
  1378. end;
  1379. {$ifdef GDB}
  1380. if (cs_debuginfo in aktmoduleswitches) then
  1381. list.concat(Tai_force_line.Create);
  1382. {$endif GDB}
  1383. {$ifdef OLDREGVARS}
  1384. load_regvars(list,nil);
  1385. {$endif OLDREGVARS}
  1386. paraloc1.done;
  1387. paraloc2.done;
  1388. end;
  1389. procedure gen_exit_code(list:TAAsmoutput);
  1390. begin
  1391. { call __EXIT for main program }
  1392. if (not DLLsource) and
  1393. (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1394. cg.a_call_name(list,'FPC_DO_EXIT');
  1395. end;
  1396. {****************************************************************************
  1397. Entry/Exit
  1398. ****************************************************************************}
  1399. procedure gen_proc_symbol(list:Taasmoutput);
  1400. var
  1401. hs : string;
  1402. begin
  1403. { add symbol entry point as well as debug information }
  1404. { will be inserted in front of the rest of this list. }
  1405. { Insert alignment and assembler names }
  1406. { Align, gprof uses 16 byte granularity }
  1407. if (cs_profile in aktmoduleswitches) then
  1408. list.concat(Tai_align.create(16))
  1409. else
  1410. list.concat(Tai_align.create(aktalignment.procalign));
  1411. {$ifdef GDB}
  1412. if (cs_debuginfo in aktmoduleswitches) then
  1413. begin
  1414. if (po_public in current_procinfo.procdef.procoptions) then
  1415. Tprocsym(current_procinfo.procdef.procsym).is_global:=true;
  1416. current_procinfo.procdef.concatstabto(list);
  1417. Tprocsym(current_procinfo.procdef.procsym).isstabwritten:=true;
  1418. end;
  1419. {$endif GDB}
  1420. repeat
  1421. hs:=current_procinfo.procdef.aliasnames.getfirst;
  1422. if hs='' then
  1423. break;
  1424. {$ifdef GDB}
  1425. if (cs_debuginfo in aktmoduleswitches) and
  1426. target_info.use_function_relative_addresses then
  1427. list.concat(Tai_stab_function_name.create(strpnew(hs)));
  1428. {$endif GDB}
  1429. if (cs_profile in aktmoduleswitches) or
  1430. (po_public in current_procinfo.procdef.procoptions) then
  1431. list.concat(Tai_symbol.createname_global(hs,AT_FUNCTION,0))
  1432. else
  1433. list.concat(Tai_symbol.createname(hs,AT_FUNCTION,0));
  1434. until false;
  1435. end;
  1436. procedure gen_proc_symbol_end(list:Taasmoutput);
  1437. {$ifdef GDB}
  1438. var
  1439. stabsendlabel : tasmlabel;
  1440. mangled_length : longint;
  1441. p : pchar;
  1442. {$endif GDB}
  1443. begin
  1444. list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname));
  1445. {$ifdef GDB}
  1446. if (cs_debuginfo in aktmoduleswitches) then
  1447. begin
  1448. objectlibrary.getlabel(stabsendlabel);
  1449. cg.a_label(list,stabsendlabel);
  1450. { define calling EBP as pseudo local var PM }
  1451. { this enables test if the function is a local one !! }
  1452. {if assigned(current_procinfo.parent) and
  1453. (current_procinfo.procdef.parast.symtablelevel>normal_function_level) then
  1454. list.concat(Tai_stabs.Create(strpnew(
  1455. '"parent_ebp:'+tstoreddef(voidpointertype.def).numberstring+'",'+
  1456. tostr(N_LSYM)+',0,0,'+tostr(current_procinfo.parent_framepointer_offset)))); }
  1457. if assigned(current_procinfo.procdef.funcretsym) and
  1458. (tvarsym(current_procinfo.procdef.funcretsym).refs>0) then
  1459. begin
  1460. if tvarsym(current_procinfo.procdef.funcretsym).localloc.loc=LOC_REFERENCE then
  1461. begin
  1462. {$warning Need to add gdb support for ret in param register calling}
  1463. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1464. begin
  1465. list.concat(Tai_stabs.Create(strpnew(
  1466. '"'+current_procinfo.procdef.procsym.name+':X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1467. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1468. if (m_result in aktmodeswitches) then
  1469. list.concat(Tai_stabs.Create(strpnew(
  1470. '"RESULT:X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1471. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))))
  1472. end
  1473. else
  1474. begin
  1475. list.concat(Tai_stabs.Create(strpnew(
  1476. '"'+current_procinfo.procdef.procsym.name+':X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1477. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1478. if (m_result in aktmodeswitches) then
  1479. list.concat(Tai_stabs.Create(strpnew(
  1480. '"RESULT:X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1481. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1482. end;
  1483. end;
  1484. end;
  1485. mangled_length:=length(current_procinfo.procdef.mangledname);
  1486. getmem(p,2*mangled_length+50);
  1487. strpcopy(p,'192,0,0,');
  1488. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1489. if (target_info.use_function_relative_addresses) then
  1490. begin
  1491. strpcopy(strend(p),'-');
  1492. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1493. end;
  1494. list.concat(Tai_stabn.Create(strnew(p)));
  1495. {List.concat(Tai_stabn.Create(strpnew('192,0,0,'
  1496. +current_procinfo.procdef.mangledname))));
  1497. p[0]:='2';p[1]:='2';p[2]:='4';
  1498. strpcopy(strend(p),'_end');}
  1499. strpcopy(p,'224,0,0,'+stabsendlabel.name);
  1500. if (target_info.use_function_relative_addresses) then
  1501. begin
  1502. strpcopy(strend(p),'-');
  1503. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1504. end;
  1505. list.concatlist(withdebuglist);
  1506. list.concat(Tai_stabn.Create(strnew(p)));
  1507. { strpnew('224,0,0,'
  1508. +current_procinfo.procdef.mangledname+'_end'))));}
  1509. freemem(p,2*mangled_length+50);
  1510. end;
  1511. {$endif GDB}
  1512. end;
  1513. procedure gen_proc_entry_code(list:Taasmoutput);
  1514. var
  1515. hitemp,
  1516. lotemp,
  1517. stackframe : longint;
  1518. check : boolean;
  1519. paraloc1 : tcgpara;
  1520. href : treference;
  1521. begin
  1522. paraloc1.init;
  1523. { generate call frame marker for dwarf call frame info }
  1524. dwarfcfi.start_frame(list);
  1525. { allocate temp for saving the argument used when
  1526. stack checking uses a register for pushing the stackframe size }
  1527. check:=(cs_check_stack in aktlocalswitches) and (current_procinfo.procdef.proctypeoption<>potype_proginit);
  1528. if check then
  1529. begin
  1530. { Allocate tempspace to store register parameter than
  1531. is destroyed when calling stackchecking code }
  1532. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1533. if paraloc1.location^.loc=LOC_REGISTER then
  1534. tg.GetTemp(list,sizeof(aint),tt_normal,href);
  1535. end;
  1536. { Calculate size of stackframe }
  1537. stackframe:=current_procinfo.calc_stackframe_size;
  1538. { All temps are know, write offsets used for information }
  1539. if (cs_asm_source in aktglobalswitches) then
  1540. begin
  1541. if tg.direction>0 then
  1542. begin
  1543. lotemp:=current_procinfo.tempstart;
  1544. hitemp:=tg.lasttemp;
  1545. end
  1546. else
  1547. begin
  1548. lotemp:=tg.lasttemp;
  1549. hitemp:=current_procinfo.tempstart;
  1550. end;
  1551. list.concat(Tai_comment.Create(strpnew('Temps allocated between '+std_regname(current_procinfo.framepointer)+
  1552. tostr_with_plus(lotemp)+' and '+std_regname(current_procinfo.framepointer)+tostr_with_plus(hitemp))));
  1553. end;
  1554. { generate target specific proc entry code }
  1555. cg.g_proc_entry(list,stackframe,(po_nostackframe in current_procinfo.procdef.procoptions));
  1556. { Add stack checking code? }
  1557. if check then
  1558. begin
  1559. { The tempspace to store original register is already
  1560. allocated above before the stackframe size is calculated. }
  1561. if paraloc1.location^.loc=LOC_REGISTER then
  1562. cg.a_load_reg_ref(list,OS_INT,OS_INT,paraloc1.location^.register,href);
  1563. paramanager.allocparaloc(list,paraloc1);
  1564. cg.a_param_const(list,OS_INT,stackframe,paraloc1);
  1565. paramanager.freeparaloc(list,paraloc1);
  1566. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1567. cg.a_call_name(list,'FPC_STACKCHECK');
  1568. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1569. if paraloc1.location^.loc=LOC_REGISTER then
  1570. begin
  1571. cg.a_load_ref_reg(list,OS_INT,OS_INT,href,paraloc1.location^.register);
  1572. tg.UnGetTemp(list,href);
  1573. end;
  1574. end;
  1575. paraloc1.done;
  1576. end;
  1577. procedure gen_proc_exit_code(list:Taasmoutput);
  1578. var
  1579. parasize : longint;
  1580. begin
  1581. { c style clearstack does not need to remove parameters from the stack, only the
  1582. return value when it was pushed by arguments }
  1583. if current_procinfo.procdef.proccalloption in clearstack_pocalls then
  1584. begin
  1585. parasize:=0;
  1586. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1587. inc(parasize,sizeof(aint));
  1588. end
  1589. else
  1590. parasize:=current_procinfo.para_stack_size;
  1591. { generate target specific proc exit code }
  1592. cg.g_proc_exit(list,parasize,(po_nostackframe in current_procinfo.procdef.procoptions));
  1593. { release return registers, needed for optimizer }
  1594. paramanager.freeparaloc(list,current_procinfo.procdef.funcret_paraloc[calleeside]);
  1595. { end of frame marker for call frame info }
  1596. dwarfcfi.end_frame(list);
  1597. end;
  1598. procedure gen_save_used_regs(list:TAAsmoutput);
  1599. begin
  1600. { Pure assembler routines need to save the registers themselves }
  1601. if (po_assembler in current_procinfo.procdef.procoptions) then
  1602. exit;
  1603. { for the save all registers we can simply use a pusha,popa which
  1604. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1605. if (po_saveregisters in current_procinfo.procdef.procoptions) then
  1606. cg.g_save_all_registers(list)
  1607. else
  1608. if current_procinfo.procdef.proccalloption in savestdregs_pocalls then
  1609. cg.g_save_standard_registers(list);
  1610. end;
  1611. procedure gen_restore_used_regs(list:TAAsmoutput;const funcretparaloc:tcgpara);
  1612. begin
  1613. { Pure assembler routines need to save the registers themselves }
  1614. if (po_assembler in current_procinfo.procdef.procoptions) then
  1615. exit;
  1616. { for the save all registers we can simply use a pusha,popa which
  1617. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1618. if (po_saveregisters in current_procinfo.procdef.procoptions) then
  1619. cg.g_restore_all_registers(list,funcretparaloc)
  1620. else
  1621. if current_procinfo.procdef.proccalloption in savestdregs_pocalls then
  1622. cg.g_restore_standard_registers(list);
  1623. end;
  1624. {****************************************************************************
  1625. Const Data
  1626. ****************************************************************************}
  1627. procedure insertconstdata(sym : ttypedconstsym);
  1628. { this does not affect the local stack space, since all
  1629. typed constansts and initialized variables are always
  1630. put in the .data / .rodata section
  1631. }
  1632. var
  1633. storefilepos : tfileposinfo;
  1634. curconstsegment : taasmoutput;
  1635. l : longint;
  1636. begin
  1637. storefilepos:=aktfilepos;
  1638. aktfilepos:=sym.fileinfo;
  1639. if sym.is_writable then
  1640. curconstsegment:=datasegment
  1641. else
  1642. curconstsegment:=consts;
  1643. l:=sym.getsize;
  1644. { insert cut for smartlinking or alignment }
  1645. maybe_new_object_file(curconstSegment);
  1646. new_section(curconstSegment,sec_rodata,lower(sym.mangledname),const_align(l));
  1647. if (sym.owner.symtabletype=globalsymtable) or
  1648. maybe_smartlink_symbol or
  1649. (assigned(current_procinfo) and
  1650. (current_procinfo.procdef.proccalloption=pocall_inline)) or
  1651. DLLSource then
  1652. curconstSegment.concat(Tai_symbol.Createname_global(sym.mangledname,AT_DATA,l))
  1653. else
  1654. curconstSegment.concat(Tai_symbol.Createname(sym.mangledname,AT_DATA,l));
  1655. aktfilepos:=storefilepos;
  1656. end;
  1657. procedure insertbssdata(sym : tvarsym);
  1658. var
  1659. l,varalign : longint;
  1660. storefilepos : tfileposinfo;
  1661. begin
  1662. storefilepos:=aktfilepos;
  1663. aktfilepos:=sym.fileinfo;
  1664. l:=sym.getvaluesize;
  1665. if (vo_is_thread_var in sym.varoptions) then
  1666. inc(l,sizeof(aint));
  1667. varalign:=var_align(l);
  1668. maybe_new_object_file(bssSegment);
  1669. new_section(bssSegment,sec_bss,lower(sym.mangledname),varalign);
  1670. if (sym.owner.symtabletype=globalsymtable) or
  1671. maybe_smartlink_symbol or
  1672. DLLSource or
  1673. (assigned(current_procinfo) and
  1674. (current_procinfo.procdef.proccalloption=pocall_inline)) or
  1675. (vo_is_exported in sym.varoptions) or
  1676. (vo_is_C_var in sym.varoptions) then
  1677. bssSegment.concat(Tai_datablock.Create_global(sym.mangledname,l))
  1678. else
  1679. bssSegment.concat(Tai_datablock.Create(sym.mangledname,l));
  1680. aktfilepos:=storefilepos;
  1681. end;
  1682. procedure gen_alloc_symtable(list:TAAsmoutput;st:tsymtable);
  1683. var
  1684. sym : tsym;
  1685. isaddr : boolean;
  1686. cgsize : tcgsize;
  1687. begin
  1688. sym:=tsym(st.symindex.first);
  1689. while assigned(sym) do
  1690. begin
  1691. if (sym.typ=varsym) then
  1692. begin
  1693. with tvarsym(sym) do
  1694. begin
  1695. { Parameters passed to assembler procedures need to be kept
  1696. in the original location }
  1697. if (st.symtabletype=parasymtable) and
  1698. (po_assembler in current_procinfo.procdef.procoptions) then
  1699. begin
  1700. paraitem.paraloc[calleeside].get_location(localloc);
  1701. end
  1702. else
  1703. begin
  1704. isaddr:=(st.symtabletype=parasymtable) and
  1705. paramanager.push_addr_param(varspez,vartype.def,current_procinfo.procdef.proccalloption);
  1706. if isaddr then
  1707. cgsize:=OS_ADDR
  1708. else
  1709. cgsize:=def_cgsize(vartype.def);
  1710. {$ifndef OLDREGVARS}
  1711. { When there is assembler code we can't use regvars }
  1712. if (cs_regvars in aktglobalswitches) and
  1713. not(pi_has_assembler_block in current_procinfo.flags) and
  1714. not(pi_uses_exceptions in current_procinfo.flags) and
  1715. (varregable<>vr_none) then
  1716. begin
  1717. localloc.size:=cgsize;
  1718. case varregable of
  1719. vr_intreg :
  1720. begin
  1721. localloc.loc:=LOC_CREGISTER;
  1722. {$ifndef cpu64bit}
  1723. if cgsize in [OS_64,OS_S64] then
  1724. begin
  1725. localloc.registerlow:=cg.getintregister(list,OS_32);
  1726. localloc.registerhigh:=cg.getintregister(list,OS_32);
  1727. end
  1728. else
  1729. {$endif cpu64bit}
  1730. localloc.register:=cg.getintregister(list,cgsize);
  1731. end;
  1732. vr_fpureg :
  1733. begin
  1734. localloc.loc:=LOC_CFPUREGISTER;
  1735. localloc.register:=cg.getfpuregister(list,cgsize);
  1736. end;
  1737. vr_mmreg :
  1738. begin
  1739. localloc.loc:=LOC_CMMREGISTER;
  1740. localloc.register:=cg.getmmregister(list,cgsize);
  1741. end;
  1742. else
  1743. internalerror(2004101010);
  1744. end;
  1745. end
  1746. else
  1747. {$endif NOT OLDREGVARS}
  1748. begin
  1749. localloc.loc:=LOC_REFERENCE;
  1750. localloc.size:=cgsize;
  1751. case st.symtabletype of
  1752. parasymtable :
  1753. begin
  1754. { Reuse the parameter location for values to are at a single location on the stack }
  1755. if (paraitem.paraloc[calleeside].is_simple_reference) then
  1756. begin
  1757. reference_reset_base(localloc.reference,paraitem.paraloc[calleeside].location^.reference.index,
  1758. paraitem.paraloc[calleeside].location^.reference.offset);
  1759. end
  1760. else
  1761. begin
  1762. if isaddr then
  1763. tg.GetLocal(list,sizeof(aint),voidpointertype.def,localloc.reference)
  1764. else
  1765. tg.GetLocal(list,getvaluesize,vartype.def,localloc.reference);
  1766. end;
  1767. end;
  1768. localsymtable,
  1769. stt_exceptsymtable :
  1770. begin
  1771. tg.GetLocal(list,getvaluesize,vartype.def,localloc.reference);
  1772. end;
  1773. staticsymtable :
  1774. begin
  1775. { PIC, DLL and Threadvar need extra code and are handled in ncgld }
  1776. if not(cs_create_pic in aktmoduleswitches) and
  1777. not(vo_is_dll_var in varoptions) and
  1778. not(vo_is_thread_var in varoptions) then
  1779. reference_reset_symbol(localloc.reference,objectlibrary.newasmsymbol(mangledname,AB_EXTERNAL,AT_DATA),0);
  1780. end;
  1781. else
  1782. internalerror(200410103);
  1783. end;
  1784. end;
  1785. end;
  1786. if cs_asm_source in aktglobalswitches then
  1787. begin
  1788. case localloc.loc of
  1789. LOC_REGISTER,
  1790. LOC_CREGISTER :
  1791. begin
  1792. if (cs_no_regalloc in aktglobalswitches) then
  1793. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located in register '+
  1794. std_regname(localloc.register))))
  1795. else
  1796. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located in register')));
  1797. end;
  1798. LOC_REFERENCE :
  1799. begin
  1800. if not assigned(localloc.reference.symbol) then
  1801. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located at '+
  1802. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1803. end;
  1804. end;
  1805. end;
  1806. end;
  1807. end;
  1808. sym:=tsym(sym.indexnext);
  1809. end;
  1810. end;
  1811. procedure gen_free_symtable(list:TAAsmoutput;st:tsymtable);
  1812. var
  1813. sym : tsym;
  1814. begin
  1815. sym:=tsym(st.symindex.first);
  1816. while assigned(sym) do
  1817. begin
  1818. if (sym.typ=varsym) then
  1819. begin
  1820. with tvarsym(sym) do
  1821. begin
  1822. { Note: We need to keep the data available in memory
  1823. for the sub procedures that can access local data
  1824. in the parent procedures }
  1825. case localloc.loc of
  1826. LOC_CREGISTER :
  1827. cg.a_reg_sync(list,localloc.register);
  1828. LOC_REFERENCE :
  1829. begin
  1830. case st.symtabletype of
  1831. localsymtable,
  1832. parasymtable,
  1833. stt_exceptsymtable :
  1834. tg.Ungetlocal(list,localloc.reference);
  1835. end;
  1836. end;
  1837. end;
  1838. end;
  1839. end;
  1840. sym:=tsym(sym.indexnext);
  1841. end;
  1842. end;
  1843. procedure gen_alloc_inline_parast(list:TAAsmoutput;pd:tprocdef);
  1844. var
  1845. sym : tsym;
  1846. calleeparaloc,
  1847. callerparaloc : pcgparalocation;
  1848. begin
  1849. if (po_assembler in pd.procoptions) then
  1850. exit;
  1851. sym:=tsym(pd.parast.symindex.first);
  1852. while assigned(sym) do
  1853. begin
  1854. if sym.typ=varsym then
  1855. begin
  1856. with tvarsym(sym) do
  1857. begin
  1858. { for localloc <> LOC_REFERENCE, we need regvar support inside inlined procedures }
  1859. localloc.loc:=LOC_REFERENCE;
  1860. localloc.size:=int_cgsize(paramanager.push_size(varspez,vartype.def,pocall_inline));
  1861. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1862. calleeparaloc:=paraitem.paraloc[calleeside].location;
  1863. callerparaloc:=paraitem.paraloc[callerside].location;
  1864. while assigned(calleeparaloc) do
  1865. begin
  1866. if not assigned(callerparaloc) then
  1867. internalerror(200408281);
  1868. if calleeparaloc^.loc<>callerparaloc^.loc then
  1869. internalerror(200408282);
  1870. case calleeparaloc^.loc of
  1871. LOC_FPUREGISTER:
  1872. begin
  1873. calleeparaloc^.register:=cg.getfpuregister(list,calleeparaloc^.size);
  1874. callerparaloc^.register:=calleeparaloc^.register;
  1875. end;
  1876. LOC_REGISTER:
  1877. begin
  1878. calleeparaloc^.register:=cg.getintregister(list,calleeparaloc^.size);
  1879. callerparaloc^.register:=calleeparaloc^.register;
  1880. end;
  1881. LOC_MMREGISTER:
  1882. begin
  1883. calleeparaloc^.register:=cg.getmmregister(list,calleeparaloc^.size);
  1884. callerparaloc^.register:=calleeparaloc^.register;
  1885. end;
  1886. LOC_REFERENCE:
  1887. begin
  1888. calleeparaloc^.reference.offset := localloc.reference.offset;
  1889. calleeparaloc^.reference.index := localloc.reference.base;
  1890. callerparaloc^.reference.offset := localloc.reference.offset;
  1891. callerparaloc^.reference.index := localloc.reference.base;
  1892. end;
  1893. end;
  1894. calleeparaloc:=calleeparaloc^.next;
  1895. callerparaloc:=callerparaloc^.next;
  1896. end;
  1897. if cs_asm_source in aktglobalswitches then
  1898. begin
  1899. case localloc.loc of
  1900. LOC_REFERENCE :
  1901. list.concat(Tai_comment.Create(strpnew('Para '+realname+' allocated at '+
  1902. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1903. end;
  1904. end;
  1905. end;
  1906. end;
  1907. sym:=tsym(sym.indexnext);
  1908. end;
  1909. end;
  1910. procedure gen_alloc_inline_funcret(list:TAAsmoutput;pd:tprocdef);
  1911. var
  1912. calleeparaloc,
  1913. callerparaloc : pcgparalocation;
  1914. begin
  1915. if not assigned(pd.funcretsym) or
  1916. (po_assembler in pd.procoptions) then
  1917. exit;
  1918. { for localloc <> LOC_REFERENCE, we need regvar support inside inlined procedures }
  1919. with tvarsym(pd.funcretsym) do
  1920. begin
  1921. localloc.loc:=LOC_REFERENCE;
  1922. localloc.size:=int_cgsize(paramanager.push_size(varspez,vartype.def,pocall_inline));
  1923. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1924. calleeparaloc:=pd.funcret_paraloc[calleeside].location;
  1925. callerparaloc:=pd.funcret_paraloc[callerside].location;
  1926. while assigned(calleeparaloc) do
  1927. begin
  1928. if not assigned(callerparaloc) then
  1929. internalerror(200408281);
  1930. if calleeparaloc^.loc<>callerparaloc^.loc then
  1931. internalerror(200408282);
  1932. case calleeparaloc^.loc of
  1933. LOC_FPUREGISTER:
  1934. begin
  1935. calleeparaloc^.register:=cg.getfpuregister(list,calleeparaloc^.size);
  1936. callerparaloc^.register:=calleeparaloc^.register;
  1937. end;
  1938. LOC_REGISTER:
  1939. begin
  1940. calleeparaloc^.register:=cg.getintregister(list,calleeparaloc^.size);
  1941. callerparaloc^.register:=calleeparaloc^.register;
  1942. end;
  1943. LOC_MMREGISTER:
  1944. begin
  1945. calleeparaloc^.register:=cg.getmmregister(list,calleeparaloc^.size);
  1946. callerparaloc^.register:=calleeparaloc^.register;
  1947. end;
  1948. LOC_REFERENCE:
  1949. begin
  1950. calleeparaloc^.reference.offset := localloc.reference.offset;
  1951. calleeparaloc^.reference.index := localloc.reference.base;
  1952. callerparaloc^.reference.offset := localloc.reference.offset;
  1953. callerparaloc^.reference.index := localloc.reference.base;
  1954. end;
  1955. end;
  1956. calleeparaloc:=calleeparaloc^.next;
  1957. callerparaloc:=callerparaloc^.next;
  1958. end;
  1959. if cs_asm_source in aktglobalswitches then
  1960. begin
  1961. case localloc.loc of
  1962. LOC_REFERENCE :
  1963. list.concat(Tai_comment.Create(strpnew('Funcret '+realname+' allocated at '+
  1964. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1965. end;
  1966. end;
  1967. end;
  1968. end;
  1969. { persistent rtti generation }
  1970. procedure generate_rtti(p:Ttypesym);
  1971. var
  1972. rsym : trttisym;
  1973. def : tstoreddef;
  1974. begin
  1975. { rtti can only be generated for classes that are always typesyms }
  1976. def:=tstoreddef(ttypesym(p).restype.def);
  1977. { there is an error, skip rtti info }
  1978. if (def.deftype=errordef) or (Errorcount>0) then
  1979. exit;
  1980. { only create rtti once for each definition }
  1981. if not(df_has_rttitable in def.defoptions) then
  1982. begin
  1983. { definition should be in the same symtable as the symbol }
  1984. if p.owner<>def.owner then
  1985. internalerror(200108262);
  1986. { create rttisym }
  1987. rsym:=trttisym.create(p.name,fullrtti);
  1988. p.owner.insert(rsym);
  1989. { register rttisym in definition }
  1990. include(def.defoptions,df_has_rttitable);
  1991. def.rttitablesym:=rsym;
  1992. { write rtti data }
  1993. def.write_child_rtti_data(fullrtti);
  1994. maybe_new_object_file(rttilist);
  1995. new_section(rttilist,sec_rodata,rsym.get_label.name,const_align(sizeof(aint)));
  1996. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  1997. def.write_rtti_data(fullrtti);
  1998. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  1999. end;
  2000. end;
  2001. { persistent init table generation }
  2002. procedure generate_inittable(p:tsym);
  2003. var
  2004. rsym : trttisym;
  2005. def : tstoreddef;
  2006. begin
  2007. { anonymous types are also allowed for records that can be varsym }
  2008. case p.typ of
  2009. typesym :
  2010. def:=tstoreddef(ttypesym(p).restype.def);
  2011. varsym :
  2012. def:=tstoreddef(tvarsym(p).vartype.def);
  2013. else
  2014. internalerror(200108263);
  2015. end;
  2016. { only create inittable once for each definition }
  2017. if not(df_has_inittable in def.defoptions) then
  2018. begin
  2019. { definition should be in the same symtable as the symbol }
  2020. if p.owner<>def.owner then
  2021. internalerror(200108264);
  2022. { create rttisym }
  2023. rsym:=trttisym.create(p.name,initrtti);
  2024. p.owner.insert(rsym);
  2025. { register rttisym in definition }
  2026. include(def.defoptions,df_has_inittable);
  2027. def.inittablesym:=rsym;
  2028. { write inittable data }
  2029. def.write_child_rtti_data(initrtti);
  2030. maybe_new_object_file(rttilist);
  2031. new_section(rttilist,sec_rodata,rsym.get_label.name,const_align(sizeof(aint)));
  2032. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  2033. def.write_rtti_data(initrtti);
  2034. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2035. end;
  2036. end;
  2037. end.
  2038. {
  2039. $Log$
  2040. Revision 1.224 2004-10-10 20:51:46 peter
  2041. * fixed sparc compile
  2042. * fixed float regvar loading
  2043. Revision 1.223 2004/10/10 20:22:53 peter
  2044. * symtable allocation rewritten
  2045. * loading of parameters to local temps/regs cleanup
  2046. * regvar support for parameters
  2047. * regvar support for staticsymtable (main body)
  2048. Revision 1.222 2004/10/09 10:51:13 olle
  2049. * Refs to DEBUGINFO_<x> is now not inserted for target MacOS
  2050. Revision 1.221 2004/10/08 20:52:07 florian
  2051. * fixed storage of parameters passed by ref.
  2052. Revision 1.220 2004/10/08 17:09:43 peter
  2053. * tvarsym.varregable added, split vo_regable from varoptions
  2054. Revision 1.219 2004/09/27 15:14:08 peter
  2055. * fix compile for oldregvars
  2056. Revision 1.218 2004/09/26 17:45:30 peter
  2057. * simple regvar support, not yet finished
  2058. Revision 1.217 2004/09/25 14:23:54 peter
  2059. * ungetregister is now only used for cpuregisters, renamed to
  2060. ungetcpuregister
  2061. * renamed (get|unget)explicitregister(s) to ..cpuregister
  2062. * removed location-release/reference_release
  2063. Revision 1.216 2004/09/21 17:25:12 peter
  2064. * paraloc branch merged
  2065. Revision 1.215 2004/09/14 16:33:46 peter
  2066. * release localsymtables when module is compiled
  2067. Revision 1.214 2004/09/13 20:30:05 peter
  2068. * finalize all (also procedure local) typedconst at unit finalization
  2069. Revision 1.213.4.3 2004/09/20 20:46:34 peter
  2070. * register allocation optimized for 64bit loading of parameters
  2071. and return values
  2072. Revision 1.213.4.2 2004/09/17 17:19:26 peter
  2073. * fixed 64 bit unaryminus for sparc
  2074. * fixed 64 bit inlining
  2075. * signness of not operation
  2076. Revision 1.213.4.1 2004/08/31 20:43:06 peter
  2077. * paraloc patch
  2078. Revision 1.213 2004/08/23 11:00:06 michael
  2079. + Patch from Peter to fix debuginfo in constructor.
  2080. Revision 1.212 2004/07/17 13:14:17 jonas
  2081. * don't finalize typed consts (fixes bug3212, but causes memory leak;
  2082. they should be finalized at the end of the module)
  2083. Revision 1.211 2004/07/09 23:41:04 jonas
  2084. * support register parameters for inlined procedures + some inline
  2085. cleanups
  2086. Revision 1.210 2004/07/04 12:24:59 jonas
  2087. * fixed one regvar problem, but regvars are still broken since the dwarf
  2088. merge...
  2089. Revision 1.209 2004/06/29 20:57:21 peter
  2090. * fixed size of exceptbuf
  2091. Revision 1.208 2004/06/20 08:55:29 florian
  2092. * logs truncated
  2093. Revision 1.207 2004/06/16 20:07:08 florian
  2094. * dwarf branch merged
  2095. Revision 1.206 2004/06/01 20:39:33 jonas
  2096. * fixed bug regarding parameters on the ppc (they were allocated twice
  2097. under some circumstances and not at all in others)
  2098. Revision 1.205 2004/05/30 21:41:15 jonas
  2099. * more regvar optimizations in location_force_reg
  2100. Revision 1.204 2004/05/30 21:18:22 jonas
  2101. * some optimizations and associated fixes for better regvar code
  2102. Revision 1.203 2004/05/28 21:14:13 peter
  2103. * first load para's to temps before calling entry code (profile
  2104. }