ncgutil.pas 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263
  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. href : treference;
  1154. begin
  1155. if (po_assembler in current_procinfo.procdef.procoptions) then
  1156. exit;
  1157. { Allocate registers used by parameters }
  1158. hp:=tparaitem(current_procinfo.procdef.para.first);
  1159. while assigned(hp) do
  1160. begin
  1161. paraloc:=hp.paraloc[calleeside].location;
  1162. while assigned(paraloc) do
  1163. begin
  1164. if paraloc^.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER] then
  1165. get_para(paraloc^);
  1166. paraloc:=paraloc^.next;
  1167. end;
  1168. hp:=tparaitem(hp.next);
  1169. end;
  1170. { Copy parameters to local references/registers }
  1171. hp:=tparaitem(current_procinfo.procdef.para.first);
  1172. while assigned(hp) do
  1173. begin
  1174. paraloc:=hp.paraloc[calleeside].location;
  1175. if not assigned(paraloc) then
  1176. internalerror(200408203);
  1177. case tvarsym(hp.parasym).localloc.loc of
  1178. LOC_REFERENCE :
  1179. begin
  1180. href:=tvarsym(hp.parasym).localloc.reference;
  1181. while assigned(paraloc) do
  1182. begin
  1183. unget_para(paraloc^);
  1184. gen_load_ref(paraloc^,href);
  1185. inc(href.offset,TCGSize2Size[paraloc^.size]);
  1186. paraloc:=paraloc^.next;
  1187. end;
  1188. end;
  1189. LOC_CREGISTER,
  1190. LOC_CMMREGISTER,
  1191. LOC_CFPUREGISTER :
  1192. begin
  1193. href:=tvarsym(hp.parasym).localloc.reference;
  1194. {$ifndef cpu64bit}
  1195. if tvarsym(hp.parasym).localloc.size in [OS_64,OS_S64] then
  1196. begin
  1197. { First 32bits }
  1198. unget_para(paraloc^);
  1199. if (target_info.endian=ENDIAN_BIG) then
  1200. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerhigh)
  1201. else
  1202. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerlow);
  1203. { Second 32bits }
  1204. if not assigned(paraloc^.next) then
  1205. internalerror(200410104);
  1206. unget_para(paraloc^);
  1207. if (target_info.endian=ENDIAN_BIG) then
  1208. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerlow)
  1209. else
  1210. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerhigh);
  1211. end
  1212. else
  1213. {$endif cpu64bit}
  1214. begin
  1215. unget_para(paraloc^);
  1216. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register);
  1217. if assigned(paraloc^.next) then
  1218. internalerror(200410105);
  1219. end;
  1220. end;
  1221. end;
  1222. hp:=tparaitem(hp.next);
  1223. end;
  1224. { generate copies of call by value parameters, must be done before
  1225. the initialization and body is parsed because the refcounts are
  1226. incremented using the local copies }
  1227. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1228. end;
  1229. procedure gen_initialize_code(list:TAAsmoutput);
  1230. begin
  1231. { initialize local data like ansistrings }
  1232. case current_procinfo.procdef.proctypeoption of
  1233. potype_unitinit:
  1234. begin
  1235. { this is also used for initialization of variables in a
  1236. program which does not have a globalsymtable }
  1237. if assigned(current_module.globalsymtable) then
  1238. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1239. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1240. end;
  1241. { units have seperate code for initilization and finalization }
  1242. potype_unitfinalize: ;
  1243. { program init/final is generated in separate procedure }
  1244. potype_proginit: ;
  1245. else
  1246. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1247. end;
  1248. { initialisizes temp. ansi/wide string data }
  1249. inittempvariables(list);
  1250. { initialize ansi/widesstring para's }
  1251. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1252. {$ifdef OLDREGVARS}
  1253. load_regvars(list,nil);
  1254. {$endif OLDREGVARS}
  1255. end;
  1256. procedure gen_finalize_code(list:TAAsmoutput);
  1257. begin
  1258. {$ifdef OLDREGVARS}
  1259. cleanup_regvars(list);
  1260. {$endif OLDREGVARS}
  1261. { finalize temporary data }
  1262. finalizetempvariables(list);
  1263. { finalize local data like ansistrings}
  1264. case current_procinfo.procdef.proctypeoption of
  1265. potype_unitfinalize:
  1266. begin
  1267. { this is also used for initialization of variables in a
  1268. program which does not have a globalsymtable }
  1269. if assigned(current_module.globalsymtable) then
  1270. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}finalize_static_data,list);
  1271. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}finalize_static_data,list);
  1272. end;
  1273. { units/progs have separate code for initialization and finalization }
  1274. potype_unitinit: ;
  1275. { program init/final is generated in separate procedure }
  1276. potype_proginit: ;
  1277. else
  1278. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_local_vars,list);
  1279. end;
  1280. { finalize paras data }
  1281. if assigned(current_procinfo.procdef.parast) then
  1282. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1283. end;
  1284. procedure gen_entry_code(list:TAAsmoutput);
  1285. var
  1286. href : treference;
  1287. paraloc1,
  1288. paraloc2 : tcgpara;
  1289. hp : tused_unit;
  1290. begin
  1291. paraloc1.init;
  1292. paraloc2.init;
  1293. { the actual profile code can clobber some registers,
  1294. therefore if the context must be saved, do it before
  1295. the actual call to the profile code
  1296. }
  1297. if (cs_profile in aktmoduleswitches) and
  1298. not(po_assembler in current_procinfo.procdef.procoptions) then
  1299. begin
  1300. { non-win32 can call mcout even in main }
  1301. if not (target_info.system in [system_i386_win32,system_i386_wdosx]) or
  1302. not (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1303. begin
  1304. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1305. cg.g_profilecode(list);
  1306. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1307. end;
  1308. end;
  1309. { call startup helpers from main program }
  1310. if (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1311. begin
  1312. { initialize profiling for win32 }
  1313. if (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1314. (cs_profile in aktmoduleswitches) then
  1315. begin
  1316. reference_reset_symbol(href,objectlibrary.newasmsymbol('etext',AB_EXTERNAL,AT_DATA),0);
  1317. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1318. paramanager.getintparaloc(pocall_default,2,paraloc2);
  1319. paramanager.allocparaloc(list,paraloc2);
  1320. cg.a_paramaddr_ref(list,href,paraloc2);
  1321. reference_reset_symbol(href,objectlibrary.newasmsymbol('__image_base__',AB_EXTERNAL,AT_DATA),0);
  1322. paramanager.allocparaloc(list,paraloc1);
  1323. cg.a_paramaddr_ref(list,href,paraloc1);
  1324. paramanager.freeparaloc(list,paraloc2);
  1325. paramanager.freeparaloc(list,paraloc1);
  1326. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1327. cg.a_call_name(list,'_monstartup');
  1328. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1329. end;
  1330. { initialize units }
  1331. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1332. cg.a_call_name(list,'FPC_INITIALIZEUNITS');
  1333. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1334. {$ifdef GDB}
  1335. if (cs_debuginfo in aktmoduleswitches) then
  1336. if target_info.system <> system_powerpc_macos then
  1337. begin
  1338. { include reference to all debuginfo sections of used units }
  1339. hp:=tused_unit(usedunits.first);
  1340. while assigned(hp) do
  1341. begin
  1342. If (hp.u.flags and uf_has_debuginfo)=uf_has_debuginfo then
  1343. current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.u.globalsymtable,''),AT_DATA,0));
  1344. hp:=tused_unit(hp.next);
  1345. end;
  1346. { include reference to debuginfo for this program }
  1347. current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
  1348. end;
  1349. {$endif GDB}
  1350. end;
  1351. {$ifdef GDB}
  1352. if (cs_debuginfo in aktmoduleswitches) then
  1353. list.concat(Tai_force_line.Create);
  1354. {$endif GDB}
  1355. {$ifdef OLDREGVARS}
  1356. load_regvars(list,nil);
  1357. {$endif OLDREGVARS}
  1358. paraloc1.done;
  1359. paraloc2.done;
  1360. end;
  1361. procedure gen_exit_code(list:TAAsmoutput);
  1362. begin
  1363. { call __EXIT for main program }
  1364. if (not DLLsource) and
  1365. (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1366. cg.a_call_name(list,'FPC_DO_EXIT');
  1367. end;
  1368. {****************************************************************************
  1369. Entry/Exit
  1370. ****************************************************************************}
  1371. procedure gen_proc_symbol(list:Taasmoutput);
  1372. var
  1373. hs : string;
  1374. begin
  1375. { add symbol entry point as well as debug information }
  1376. { will be inserted in front of the rest of this list. }
  1377. { Insert alignment and assembler names }
  1378. { Align, gprof uses 16 byte granularity }
  1379. if (cs_profile in aktmoduleswitches) then
  1380. list.concat(Tai_align.create(16))
  1381. else
  1382. list.concat(Tai_align.create(aktalignment.procalign));
  1383. {$ifdef GDB}
  1384. if (cs_debuginfo in aktmoduleswitches) then
  1385. begin
  1386. if (po_public in current_procinfo.procdef.procoptions) then
  1387. Tprocsym(current_procinfo.procdef.procsym).is_global:=true;
  1388. current_procinfo.procdef.concatstabto(list);
  1389. Tprocsym(current_procinfo.procdef.procsym).isstabwritten:=true;
  1390. end;
  1391. {$endif GDB}
  1392. repeat
  1393. hs:=current_procinfo.procdef.aliasnames.getfirst;
  1394. if hs='' then
  1395. break;
  1396. {$ifdef GDB}
  1397. if (cs_debuginfo in aktmoduleswitches) and
  1398. target_info.use_function_relative_addresses then
  1399. list.concat(Tai_stab_function_name.create(strpnew(hs)));
  1400. {$endif GDB}
  1401. if (cs_profile in aktmoduleswitches) or
  1402. (po_public in current_procinfo.procdef.procoptions) then
  1403. list.concat(Tai_symbol.createname_global(hs,AT_FUNCTION,0))
  1404. else
  1405. list.concat(Tai_symbol.createname(hs,AT_FUNCTION,0));
  1406. until false;
  1407. end;
  1408. procedure gen_proc_symbol_end(list:Taasmoutput);
  1409. {$ifdef GDB}
  1410. var
  1411. stabsendlabel : tasmlabel;
  1412. mangled_length : longint;
  1413. p : pchar;
  1414. {$endif GDB}
  1415. begin
  1416. list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname));
  1417. {$ifdef GDB}
  1418. if (cs_debuginfo in aktmoduleswitches) then
  1419. begin
  1420. objectlibrary.getlabel(stabsendlabel);
  1421. cg.a_label(list,stabsendlabel);
  1422. { define calling EBP as pseudo local var PM }
  1423. { this enables test if the function is a local one !! }
  1424. {if assigned(current_procinfo.parent) and
  1425. (current_procinfo.procdef.parast.symtablelevel>normal_function_level) then
  1426. list.concat(Tai_stabs.Create(strpnew(
  1427. '"parent_ebp:'+tstoreddef(voidpointertype.def).numberstring+'",'+
  1428. tostr(N_LSYM)+',0,0,'+tostr(current_procinfo.parent_framepointer_offset)))); }
  1429. if assigned(current_procinfo.procdef.funcretsym) and
  1430. (tvarsym(current_procinfo.procdef.funcretsym).refs>0) then
  1431. begin
  1432. if tvarsym(current_procinfo.procdef.funcretsym).localloc.loc=LOC_REFERENCE then
  1433. begin
  1434. {$warning Need to add gdb support for ret in param register calling}
  1435. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1436. begin
  1437. list.concat(Tai_stabs.Create(strpnew(
  1438. '"'+current_procinfo.procdef.procsym.name+':X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1439. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1440. if (m_result in aktmodeswitches) then
  1441. list.concat(Tai_stabs.Create(strpnew(
  1442. '"RESULT:X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1443. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))))
  1444. end
  1445. else
  1446. begin
  1447. list.concat(Tai_stabs.Create(strpnew(
  1448. '"'+current_procinfo.procdef.procsym.name+':X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1449. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1450. if (m_result in aktmodeswitches) then
  1451. list.concat(Tai_stabs.Create(strpnew(
  1452. '"RESULT:X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1453. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1454. end;
  1455. end;
  1456. end;
  1457. mangled_length:=length(current_procinfo.procdef.mangledname);
  1458. getmem(p,2*mangled_length+50);
  1459. strpcopy(p,'192,0,0,');
  1460. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1461. if (target_info.use_function_relative_addresses) then
  1462. begin
  1463. strpcopy(strend(p),'-');
  1464. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1465. end;
  1466. list.concat(Tai_stabn.Create(strnew(p)));
  1467. {List.concat(Tai_stabn.Create(strpnew('192,0,0,'
  1468. +current_procinfo.procdef.mangledname))));
  1469. p[0]:='2';p[1]:='2';p[2]:='4';
  1470. strpcopy(strend(p),'_end');}
  1471. strpcopy(p,'224,0,0,'+stabsendlabel.name);
  1472. if (target_info.use_function_relative_addresses) then
  1473. begin
  1474. strpcopy(strend(p),'-');
  1475. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1476. end;
  1477. list.concatlist(withdebuglist);
  1478. list.concat(Tai_stabn.Create(strnew(p)));
  1479. { strpnew('224,0,0,'
  1480. +current_procinfo.procdef.mangledname+'_end'))));}
  1481. freemem(p,2*mangled_length+50);
  1482. end;
  1483. {$endif GDB}
  1484. end;
  1485. procedure gen_proc_entry_code(list:Taasmoutput);
  1486. var
  1487. hitemp,
  1488. lotemp,
  1489. stackframe : longint;
  1490. check : boolean;
  1491. paraloc1 : tcgpara;
  1492. href : treference;
  1493. begin
  1494. paraloc1.init;
  1495. { generate call frame marker for dwarf call frame info }
  1496. dwarfcfi.start_frame(list);
  1497. { allocate temp for saving the argument used when
  1498. stack checking uses a register for pushing the stackframe size }
  1499. check:=(cs_check_stack in aktlocalswitches) and (current_procinfo.procdef.proctypeoption<>potype_proginit);
  1500. if check then
  1501. begin
  1502. { Allocate tempspace to store register parameter than
  1503. is destroyed when calling stackchecking code }
  1504. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1505. if paraloc1.location^.loc=LOC_REGISTER then
  1506. tg.GetTemp(list,sizeof(aint),tt_normal,href);
  1507. end;
  1508. { Calculate size of stackframe }
  1509. stackframe:=current_procinfo.calc_stackframe_size;
  1510. { All temps are know, write offsets used for information }
  1511. if (cs_asm_source in aktglobalswitches) then
  1512. begin
  1513. if tg.direction>0 then
  1514. begin
  1515. lotemp:=current_procinfo.tempstart;
  1516. hitemp:=tg.lasttemp;
  1517. end
  1518. else
  1519. begin
  1520. lotemp:=tg.lasttemp;
  1521. hitemp:=current_procinfo.tempstart;
  1522. end;
  1523. list.concat(Tai_comment.Create(strpnew('Temps allocated between '+std_regname(current_procinfo.framepointer)+
  1524. tostr_with_plus(lotemp)+' and '+std_regname(current_procinfo.framepointer)+tostr_with_plus(hitemp))));
  1525. end;
  1526. { generate target specific proc entry code }
  1527. cg.g_proc_entry(list,stackframe,(po_nostackframe in current_procinfo.procdef.procoptions));
  1528. { Add stack checking code? }
  1529. if check then
  1530. begin
  1531. { The tempspace to store original register is already
  1532. allocated above before the stackframe size is calculated. }
  1533. if paraloc1.location^.loc=LOC_REGISTER then
  1534. cg.a_load_reg_ref(list,OS_INT,OS_INT,paraloc1.location^.register,href);
  1535. paramanager.allocparaloc(list,paraloc1);
  1536. cg.a_param_const(list,OS_INT,stackframe,paraloc1);
  1537. paramanager.freeparaloc(list,paraloc1);
  1538. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1539. cg.a_call_name(list,'FPC_STACKCHECK');
  1540. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1541. if paraloc1.location^.loc=LOC_REGISTER then
  1542. begin
  1543. cg.a_load_ref_reg(list,OS_INT,OS_INT,href,paraloc1.location^.register);
  1544. tg.UnGetTemp(list,href);
  1545. end;
  1546. end;
  1547. paraloc1.done;
  1548. end;
  1549. procedure gen_proc_exit_code(list:Taasmoutput);
  1550. var
  1551. parasize : longint;
  1552. begin
  1553. { c style clearstack does not need to remove parameters from the stack, only the
  1554. return value when it was pushed by arguments }
  1555. if current_procinfo.procdef.proccalloption in clearstack_pocalls then
  1556. begin
  1557. parasize:=0;
  1558. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1559. inc(parasize,sizeof(aint));
  1560. end
  1561. else
  1562. parasize:=current_procinfo.para_stack_size;
  1563. { generate target specific proc exit code }
  1564. cg.g_proc_exit(list,parasize,(po_nostackframe in current_procinfo.procdef.procoptions));
  1565. { release return registers, needed for optimizer }
  1566. paramanager.freeparaloc(list,current_procinfo.procdef.funcret_paraloc[calleeside]);
  1567. { end of frame marker for call frame info }
  1568. dwarfcfi.end_frame(list);
  1569. end;
  1570. procedure gen_save_used_regs(list:TAAsmoutput);
  1571. begin
  1572. { Pure assembler routines need to save the registers themselves }
  1573. if (po_assembler in current_procinfo.procdef.procoptions) then
  1574. exit;
  1575. { for the save all registers we can simply use a pusha,popa which
  1576. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1577. if (po_saveregisters in current_procinfo.procdef.procoptions) then
  1578. cg.g_save_all_registers(list)
  1579. else
  1580. if current_procinfo.procdef.proccalloption in savestdregs_pocalls then
  1581. cg.g_save_standard_registers(list);
  1582. end;
  1583. procedure gen_restore_used_regs(list:TAAsmoutput;const funcretparaloc:tcgpara);
  1584. begin
  1585. { Pure assembler routines need to save the registers themselves }
  1586. if (po_assembler in current_procinfo.procdef.procoptions) then
  1587. exit;
  1588. { for the save all registers we can simply use a pusha,popa which
  1589. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1590. if (po_saveregisters in current_procinfo.procdef.procoptions) then
  1591. cg.g_restore_all_registers(list,funcretparaloc)
  1592. else
  1593. if current_procinfo.procdef.proccalloption in savestdregs_pocalls then
  1594. cg.g_restore_standard_registers(list);
  1595. end;
  1596. {****************************************************************************
  1597. Const Data
  1598. ****************************************************************************}
  1599. procedure insertconstdata(sym : ttypedconstsym);
  1600. { this does not affect the local stack space, since all
  1601. typed constansts and initialized variables are always
  1602. put in the .data / .rodata section
  1603. }
  1604. var
  1605. storefilepos : tfileposinfo;
  1606. curconstsegment : taasmoutput;
  1607. l : longint;
  1608. begin
  1609. storefilepos:=aktfilepos;
  1610. aktfilepos:=sym.fileinfo;
  1611. if sym.is_writable then
  1612. curconstsegment:=datasegment
  1613. else
  1614. curconstsegment:=consts;
  1615. l:=sym.getsize;
  1616. { insert cut for smartlinking or alignment }
  1617. maybe_new_object_file(curconstSegment);
  1618. new_section(curconstSegment,sec_rodata,lower(sym.mangledname),const_align(l));
  1619. if (sym.owner.symtabletype=globalsymtable) or
  1620. maybe_smartlink_symbol or
  1621. (assigned(current_procinfo) and
  1622. (current_procinfo.procdef.proccalloption=pocall_inline)) or
  1623. DLLSource then
  1624. curconstSegment.concat(Tai_symbol.Createname_global(sym.mangledname,AT_DATA,l))
  1625. else
  1626. curconstSegment.concat(Tai_symbol.Createname(sym.mangledname,AT_DATA,l));
  1627. aktfilepos:=storefilepos;
  1628. end;
  1629. procedure insertbssdata(sym : tvarsym);
  1630. var
  1631. l,varalign : longint;
  1632. storefilepos : tfileposinfo;
  1633. begin
  1634. storefilepos:=aktfilepos;
  1635. aktfilepos:=sym.fileinfo;
  1636. l:=sym.getvaluesize;
  1637. if (vo_is_thread_var in sym.varoptions) then
  1638. inc(l,sizeof(aint));
  1639. varalign:=var_align(l);
  1640. maybe_new_object_file(bssSegment);
  1641. new_section(bssSegment,sec_bss,lower(sym.mangledname),varalign);
  1642. if (sym.owner.symtabletype=globalsymtable) or
  1643. maybe_smartlink_symbol or
  1644. DLLSource or
  1645. (assigned(current_procinfo) and
  1646. (current_procinfo.procdef.proccalloption=pocall_inline)) or
  1647. (vo_is_exported in sym.varoptions) or
  1648. (vo_is_C_var in sym.varoptions) then
  1649. bssSegment.concat(Tai_datablock.Create_global(sym.mangledname,l))
  1650. else
  1651. bssSegment.concat(Tai_datablock.Create(sym.mangledname,l));
  1652. aktfilepos:=storefilepos;
  1653. end;
  1654. procedure gen_alloc_symtable(list:TAAsmoutput;st:tsymtable);
  1655. function getregvar(v:tvarregable;size:tcgsize):tregister;
  1656. begin
  1657. case v of
  1658. vr_intreg :
  1659. result:=cg.getintregister(list,size);
  1660. vr_fpureg :
  1661. result:=cg.getfpuregister(list,size);
  1662. vr_mmreg :
  1663. result:=cg.getmmregister(list,size);
  1664. end;
  1665. end;
  1666. var
  1667. sym : tsym;
  1668. isaddr : boolean;
  1669. cgsize : tcgsize;
  1670. begin
  1671. sym:=tsym(st.symindex.first);
  1672. while assigned(sym) do
  1673. begin
  1674. if (sym.typ=varsym) then
  1675. begin
  1676. with tvarsym(sym) do
  1677. begin
  1678. { Parameters passed to assembler procedures need to be kept
  1679. in the original location }
  1680. if (st.symtabletype=parasymtable) and
  1681. (po_assembler in current_procinfo.procdef.procoptions) then
  1682. begin
  1683. paraitem.paraloc[calleeside].get_location(localloc);
  1684. end
  1685. else
  1686. begin
  1687. isaddr:=(st.symtabletype=parasymtable) and
  1688. paramanager.push_addr_param(varspez,vartype.def,current_procinfo.procdef.proccalloption);
  1689. if isaddr then
  1690. cgsize:=OS_ADDR
  1691. else
  1692. cgsize:=def_cgsize(vartype.def);
  1693. {$ifndef OLDREGVARS}
  1694. { When there is assembler code we can't use regvars }
  1695. if (cs_regvars in aktglobalswitches) and
  1696. not(pi_has_assembler_block in current_procinfo.flags) and
  1697. not(pi_uses_exceptions in current_procinfo.flags) and
  1698. (varregable<>vr_none) then
  1699. begin
  1700. localloc.loc:=LOC_CREGISTER;
  1701. localloc.size:=cgsize;
  1702. {$ifndef cpu64bit}
  1703. if cgsize in [OS_64,OS_S64] then
  1704. begin
  1705. localloc.registerlow:=getregvar(varregable,OS_32);
  1706. localloc.registerhigh:=getregvar(varregable,OS_32);
  1707. end
  1708. else
  1709. {$endif cpu64bit}
  1710. localloc.register:=getregvar(varregable,cgsize);
  1711. end
  1712. else
  1713. {$endif NOT OLDREGVARS}
  1714. begin
  1715. localloc.loc:=LOC_REFERENCE;
  1716. localloc.size:=cgsize;
  1717. case st.symtabletype of
  1718. parasymtable :
  1719. begin
  1720. { Reuse the parameter location for values to are at a single location on the stack }
  1721. if (paraitem.paraloc[calleeside].is_simple_reference) then
  1722. begin
  1723. reference_reset_base(localloc.reference,paraitem.paraloc[calleeside].location^.reference.index,
  1724. paraitem.paraloc[calleeside].location^.reference.offset);
  1725. end
  1726. else
  1727. begin
  1728. if isaddr then
  1729. tg.GetLocal(list,sizeof(aint),voidpointertype.def,localloc.reference)
  1730. else
  1731. tg.GetLocal(list,getvaluesize,vartype.def,localloc.reference);
  1732. end;
  1733. end;
  1734. localsymtable,
  1735. stt_exceptsymtable :
  1736. begin
  1737. tg.GetLocal(list,getvaluesize,vartype.def,localloc.reference);
  1738. end;
  1739. staticsymtable :
  1740. begin
  1741. { PIC, DLL and Threadvar need extra code and are handled in ncgld }
  1742. if not(cs_create_pic in aktmoduleswitches) and
  1743. not(vo_is_dll_var in varoptions) and
  1744. not(vo_is_thread_var in varoptions) then
  1745. reference_reset_symbol(localloc.reference,objectlibrary.newasmsymbol(mangledname,AB_EXTERNAL,AT_DATA),0);
  1746. end;
  1747. else
  1748. internalerror(200410103);
  1749. end;
  1750. end;
  1751. end;
  1752. if cs_asm_source in aktglobalswitches then
  1753. begin
  1754. case localloc.loc of
  1755. LOC_REGISTER,
  1756. LOC_CREGISTER :
  1757. begin
  1758. if (cs_no_regalloc in aktglobalswitches) then
  1759. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located in register '+
  1760. std_regname(localloc.register))))
  1761. else
  1762. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located in register')));
  1763. end;
  1764. LOC_REFERENCE :
  1765. begin
  1766. if not assigned(localloc.reference.symbol) then
  1767. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located at '+
  1768. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1769. end;
  1770. end;
  1771. end;
  1772. end;
  1773. end;
  1774. sym:=tsym(sym.indexnext);
  1775. end;
  1776. end;
  1777. procedure gen_free_symtable(list:TAAsmoutput;st:tsymtable);
  1778. var
  1779. sym : tsym;
  1780. begin
  1781. sym:=tsym(st.symindex.first);
  1782. while assigned(sym) do
  1783. begin
  1784. if (sym.typ=varsym) then
  1785. begin
  1786. with tvarsym(sym) do
  1787. begin
  1788. { Note: We need to keep the data available in memory
  1789. for the sub procedures that can access local data
  1790. in the parent procedures }
  1791. case localloc.loc of
  1792. LOC_CREGISTER :
  1793. cg.a_reg_sync(list,localloc.register);
  1794. LOC_REFERENCE :
  1795. begin
  1796. case st.symtabletype of
  1797. localsymtable,
  1798. parasymtable,
  1799. stt_exceptsymtable :
  1800. tg.Ungetlocal(list,localloc.reference);
  1801. end;
  1802. end;
  1803. end;
  1804. end;
  1805. end;
  1806. sym:=tsym(sym.indexnext);
  1807. end;
  1808. end;
  1809. procedure gen_alloc_inline_parast(list:TAAsmoutput;pd:tprocdef);
  1810. var
  1811. sym : tsym;
  1812. calleeparaloc,
  1813. callerparaloc : pcgparalocation;
  1814. begin
  1815. if (po_assembler in pd.procoptions) then
  1816. exit;
  1817. sym:=tsym(pd.parast.symindex.first);
  1818. while assigned(sym) do
  1819. begin
  1820. if sym.typ=varsym then
  1821. begin
  1822. with tvarsym(sym) do
  1823. begin
  1824. { for localloc <> LOC_REFERENCE, we need regvar support inside inlined procedures }
  1825. localloc.loc:=LOC_REFERENCE;
  1826. localloc.size:=int_cgsize(paramanager.push_size(varspez,vartype.def,pocall_inline));
  1827. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1828. calleeparaloc:=paraitem.paraloc[calleeside].location;
  1829. callerparaloc:=paraitem.paraloc[callerside].location;
  1830. while assigned(calleeparaloc) do
  1831. begin
  1832. if not assigned(callerparaloc) then
  1833. internalerror(200408281);
  1834. if calleeparaloc^.loc<>callerparaloc^.loc then
  1835. internalerror(200408282);
  1836. case calleeparaloc^.loc of
  1837. LOC_FPUREGISTER:
  1838. begin
  1839. calleeparaloc^.register:=cg.getfpuregister(list,calleeparaloc^.size);
  1840. callerparaloc^.register:=calleeparaloc^.register;
  1841. end;
  1842. LOC_REGISTER:
  1843. begin
  1844. calleeparaloc^.register:=cg.getintregister(list,calleeparaloc^.size);
  1845. callerparaloc^.register:=calleeparaloc^.register;
  1846. end;
  1847. LOC_MMREGISTER:
  1848. begin
  1849. calleeparaloc^.register:=cg.getmmregister(list,calleeparaloc^.size);
  1850. callerparaloc^.register:=calleeparaloc^.register;
  1851. end;
  1852. LOC_REFERENCE:
  1853. begin
  1854. calleeparaloc^.reference.offset := localloc.reference.offset;
  1855. calleeparaloc^.reference.index := localloc.reference.base;
  1856. callerparaloc^.reference.offset := localloc.reference.offset;
  1857. callerparaloc^.reference.index := localloc.reference.base;
  1858. end;
  1859. end;
  1860. calleeparaloc:=calleeparaloc^.next;
  1861. callerparaloc:=callerparaloc^.next;
  1862. end;
  1863. if cs_asm_source in aktglobalswitches then
  1864. begin
  1865. case localloc.loc of
  1866. LOC_REFERENCE :
  1867. list.concat(Tai_comment.Create(strpnew('Para '+realname+' allocated at '+
  1868. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1869. end;
  1870. end;
  1871. end;
  1872. end;
  1873. sym:=tsym(sym.indexnext);
  1874. end;
  1875. end;
  1876. procedure gen_alloc_inline_funcret(list:TAAsmoutput;pd:tprocdef);
  1877. var
  1878. calleeparaloc,
  1879. callerparaloc : pcgparalocation;
  1880. begin
  1881. if not assigned(pd.funcretsym) or
  1882. (po_assembler in pd.procoptions) then
  1883. exit;
  1884. { for localloc <> LOC_REFERENCE, we need regvar support inside inlined procedures }
  1885. with tvarsym(pd.funcretsym) do
  1886. begin
  1887. localloc.loc:=LOC_REFERENCE;
  1888. localloc.size:=int_cgsize(paramanager.push_size(varspez,vartype.def,pocall_inline));
  1889. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1890. calleeparaloc:=pd.funcret_paraloc[calleeside].location;
  1891. callerparaloc:=pd.funcret_paraloc[callerside].location;
  1892. while assigned(calleeparaloc) do
  1893. begin
  1894. if not assigned(callerparaloc) then
  1895. internalerror(200408281);
  1896. if calleeparaloc^.loc<>callerparaloc^.loc then
  1897. internalerror(200408282);
  1898. case calleeparaloc^.loc of
  1899. LOC_FPUREGISTER:
  1900. begin
  1901. calleeparaloc^.register:=cg.getfpuregister(list,calleeparaloc^.size);
  1902. callerparaloc^.register:=calleeparaloc^.register;
  1903. end;
  1904. LOC_REGISTER:
  1905. begin
  1906. calleeparaloc^.register:=cg.getintregister(list,calleeparaloc^.size);
  1907. callerparaloc^.register:=calleeparaloc^.register;
  1908. end;
  1909. LOC_MMREGISTER:
  1910. begin
  1911. calleeparaloc^.register:=cg.getmmregister(list,calleeparaloc^.size);
  1912. callerparaloc^.register:=calleeparaloc^.register;
  1913. end;
  1914. LOC_REFERENCE:
  1915. begin
  1916. calleeparaloc^.reference.offset := localloc.reference.offset;
  1917. calleeparaloc^.reference.index := localloc.reference.base;
  1918. callerparaloc^.reference.offset := localloc.reference.offset;
  1919. callerparaloc^.reference.index := localloc.reference.base;
  1920. end;
  1921. end;
  1922. calleeparaloc:=calleeparaloc^.next;
  1923. callerparaloc:=callerparaloc^.next;
  1924. end;
  1925. if cs_asm_source in aktglobalswitches then
  1926. begin
  1927. case localloc.loc of
  1928. LOC_REFERENCE :
  1929. list.concat(Tai_comment.Create(strpnew('Funcret '+realname+' allocated at '+
  1930. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1931. end;
  1932. end;
  1933. end;
  1934. end;
  1935. { persistent rtti generation }
  1936. procedure generate_rtti(p:Ttypesym);
  1937. var
  1938. rsym : trttisym;
  1939. def : tstoreddef;
  1940. begin
  1941. { rtti can only be generated for classes that are always typesyms }
  1942. def:=tstoreddef(ttypesym(p).restype.def);
  1943. { there is an error, skip rtti info }
  1944. if (def.deftype=errordef) or (Errorcount>0) then
  1945. exit;
  1946. { only create rtti once for each definition }
  1947. if not(df_has_rttitable in def.defoptions) then
  1948. begin
  1949. { definition should be in the same symtable as the symbol }
  1950. if p.owner<>def.owner then
  1951. internalerror(200108262);
  1952. { create rttisym }
  1953. rsym:=trttisym.create(p.name,fullrtti);
  1954. p.owner.insert(rsym);
  1955. { register rttisym in definition }
  1956. include(def.defoptions,df_has_rttitable);
  1957. def.rttitablesym:=rsym;
  1958. { write rtti data }
  1959. def.write_child_rtti_data(fullrtti);
  1960. maybe_new_object_file(rttilist);
  1961. new_section(rttilist,sec_rodata,rsym.get_label.name,const_align(sizeof(aint)));
  1962. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  1963. def.write_rtti_data(fullrtti);
  1964. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  1965. end;
  1966. end;
  1967. { persistent init table generation }
  1968. procedure generate_inittable(p:tsym);
  1969. var
  1970. rsym : trttisym;
  1971. def : tstoreddef;
  1972. begin
  1973. { anonymous types are also allowed for records that can be varsym }
  1974. case p.typ of
  1975. typesym :
  1976. def:=tstoreddef(ttypesym(p).restype.def);
  1977. varsym :
  1978. def:=tstoreddef(tvarsym(p).vartype.def);
  1979. else
  1980. internalerror(200108263);
  1981. end;
  1982. { only create inittable once for each definition }
  1983. if not(df_has_inittable in def.defoptions) then
  1984. begin
  1985. { definition should be in the same symtable as the symbol }
  1986. if p.owner<>def.owner then
  1987. internalerror(200108264);
  1988. { create rttisym }
  1989. rsym:=trttisym.create(p.name,initrtti);
  1990. p.owner.insert(rsym);
  1991. { register rttisym in definition }
  1992. include(def.defoptions,df_has_inittable);
  1993. def.inittablesym:=rsym;
  1994. { write inittable data }
  1995. def.write_child_rtti_data(initrtti);
  1996. maybe_new_object_file(rttilist);
  1997. new_section(rttilist,sec_rodata,rsym.get_label.name,const_align(sizeof(aint)));
  1998. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  1999. def.write_rtti_data(initrtti);
  2000. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2001. end;
  2002. end;
  2003. end.
  2004. {
  2005. $Log$
  2006. Revision 1.223 2004-10-10 20:22:53 peter
  2007. * symtable allocation rewritten
  2008. * loading of parameters to local temps/regs cleanup
  2009. * regvar support for parameters
  2010. * regvar support for staticsymtable (main body)
  2011. Revision 1.222 2004/10/09 10:51:13 olle
  2012. * Refs to DEBUGINFO_<x> is now not inserted for target MacOS
  2013. Revision 1.221 2004/10/08 20:52:07 florian
  2014. * fixed storage of parameters passed by ref.
  2015. Revision 1.220 2004/10/08 17:09:43 peter
  2016. * tvarsym.varregable added, split vo_regable from varoptions
  2017. Revision 1.219 2004/09/27 15:14:08 peter
  2018. * fix compile for oldregvars
  2019. Revision 1.218 2004/09/26 17:45:30 peter
  2020. * simple regvar support, not yet finished
  2021. Revision 1.217 2004/09/25 14:23:54 peter
  2022. * ungetregister is now only used for cpuregisters, renamed to
  2023. ungetcpuregister
  2024. * renamed (get|unget)explicitregister(s) to ..cpuregister
  2025. * removed location-release/reference_release
  2026. Revision 1.216 2004/09/21 17:25:12 peter
  2027. * paraloc branch merged
  2028. Revision 1.215 2004/09/14 16:33:46 peter
  2029. * release localsymtables when module is compiled
  2030. Revision 1.214 2004/09/13 20:30:05 peter
  2031. * finalize all (also procedure local) typedconst at unit finalization
  2032. Revision 1.213.4.3 2004/09/20 20:46:34 peter
  2033. * register allocation optimized for 64bit loading of parameters
  2034. and return values
  2035. Revision 1.213.4.2 2004/09/17 17:19:26 peter
  2036. * fixed 64 bit unaryminus for sparc
  2037. * fixed 64 bit inlining
  2038. * signness of not operation
  2039. Revision 1.213.4.1 2004/08/31 20:43:06 peter
  2040. * paraloc patch
  2041. Revision 1.213 2004/08/23 11:00:06 michael
  2042. + Patch from Peter to fix debuginfo in constructor.
  2043. Revision 1.212 2004/07/17 13:14:17 jonas
  2044. * don't finalize typed consts (fixes bug3212, but causes memory leak;
  2045. they should be finalized at the end of the module)
  2046. Revision 1.211 2004/07/09 23:41:04 jonas
  2047. * support register parameters for inlined procedures + some inline
  2048. cleanups
  2049. Revision 1.210 2004/07/04 12:24:59 jonas
  2050. * fixed one regvar problem, but regvars are still broken since the dwarf
  2051. merge...
  2052. Revision 1.209 2004/06/29 20:57:21 peter
  2053. * fixed size of exceptbuf
  2054. Revision 1.208 2004/06/20 08:55:29 florian
  2055. * logs truncated
  2056. Revision 1.207 2004/06/16 20:07:08 florian
  2057. * dwarf branch merged
  2058. Revision 1.206 2004/06/01 20:39:33 jonas
  2059. * fixed bug regarding parameters on the ppc (they were allocated twice
  2060. under some circumstances and not at all in others)
  2061. Revision 1.205 2004/05/30 21:41:15 jonas
  2062. * more regvar optimizations in location_force_reg
  2063. Revision 1.204 2004/05/30 21:18:22 jonas
  2064. * some optimizations and associated fixes for better regvar code
  2065. Revision 1.203 2004/05/28 21:14:13 peter
  2066. * first load para's to temps before calling entry code (profile
  2067. }