ncgutil.pas 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302
  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_CREGISTER :
  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. cg.g_copyvaluepara_openarray(list,href1,hsym.localloc,tarraydef(tvarsym(p).vartype.def).elesize);
  663. end;
  664. end
  665. else
  666. begin
  667. { Allocate space for the local copy }
  668. l:=tvarsym(p).getsize;
  669. localcopyloc.loc:=LOC_REFERENCE;
  670. localcopyloc.size:=int_cgsize(l);
  671. tg.GetLocal(list,l,tvarsym(p).vartype.def,localcopyloc.reference);
  672. { Copy data }
  673. if is_shortstring(tvarsym(p).vartype.def) then
  674. begin
  675. { this code is only executed before the code for the body and the entry/exit code is generated
  676. so we're allowed to include pi_do_call here; after pass1 is run, this isn't allowed anymore
  677. }
  678. include(current_procinfo.flags,pi_do_call);
  679. cg.g_copyshortstring(list,href1,localcopyloc.reference,tstringdef(tvarsym(p).vartype.def).len,loadref)
  680. end
  681. else
  682. cg.g_concatcopy(list,href1,localcopyloc.reference,tvarsym(p).vartype.def.size,loadref);
  683. { update localloc of varsym }
  684. tg.Ungetlocal(list,tvarsym(p).localloc.reference);
  685. tvarsym(p).localloc:=localcopyloc;
  686. end;
  687. end;
  688. end;
  689. { generates the code for initialisation of local data }
  690. procedure initialize_data(p : tnamedindexitem;arg:pointer);
  691. var
  692. oldexprasmlist : TAAsmoutput;
  693. hp : tnode;
  694. begin
  695. if (tsym(p).typ=varsym) and
  696. (tvarsym(p).refs>0) and
  697. not(is_class(tvarsym(p).vartype.def)) and
  698. tvarsym(p).vartype.def.needs_inittable then
  699. begin
  700. oldexprasmlist:=exprasmlist;
  701. exprasmlist:=taasmoutput(arg);
  702. hp:=initialize_data_node(cloadnode.create(tsym(p),tsym(p).owner));
  703. firstpass(hp);
  704. secondpass(hp);
  705. hp.free;
  706. exprasmlist:=oldexprasmlist;
  707. end;
  708. end;
  709. procedure finalize_sym(asmlist:taasmoutput;sym:tsym);
  710. var
  711. hp : tnode;
  712. oldexprasmlist : TAAsmoutput;
  713. begin
  714. include(current_procinfo.flags,pi_needs_implicit_finally);
  715. oldexprasmlist:=exprasmlist;
  716. exprasmlist:=asmlist;
  717. hp:=finalize_data_node(cloadnode.create(sym,sym.owner));
  718. firstpass(hp);
  719. secondpass(hp);
  720. hp.free;
  721. exprasmlist:=oldexprasmlist;
  722. end;
  723. { generates the code for finalisation of local variables }
  724. procedure finalize_local_vars(p : tnamedindexitem;arg:pointer);
  725. begin
  726. case tsym(p).typ of
  727. varsym :
  728. begin
  729. if (tvarsym(p).refs>0) and
  730. not(vo_is_funcret in tvarsym(p).varoptions) and
  731. not(is_class(tvarsym(p).vartype.def)) and
  732. tvarsym(p).vartype.def.needs_inittable then
  733. finalize_sym(taasmoutput(arg),tsym(p));
  734. end;
  735. end;
  736. end;
  737. { generates the code for finalisation of local typedconsts }
  738. procedure finalize_local_typedconst(p : tnamedindexitem;arg:pointer);
  739. var
  740. i : longint;
  741. pd : tprocdef;
  742. begin
  743. case tsym(p).typ of
  744. typedconstsym :
  745. begin
  746. if ttypedconstsym(p).is_writable and
  747. ttypedconstsym(p).typedconsttype.def.needs_inittable then
  748. finalize_sym(taasmoutput(arg),tsym(p));
  749. end;
  750. procsym :
  751. begin
  752. for i:=1 to tprocsym(p).procdef_count do
  753. begin
  754. pd:=tprocsym(p).procdef[i];
  755. if assigned(pd.localst) and
  756. (pd.procsym=tprocsym(p)) and
  757. (pd.localst.symtabletype<>staticsymtable) then
  758. pd.localst.foreach_static(@finalize_local_typedconst,arg);
  759. end;
  760. end;
  761. end;
  762. end;
  763. { generates the code for finalization of static symtable and
  764. all local (static) typedconsts }
  765. procedure finalize_static_data(p : tnamedindexitem;arg:pointer);
  766. var
  767. i : longint;
  768. pd : tprocdef;
  769. begin
  770. case tsym(p).typ of
  771. varsym :
  772. begin
  773. if (tvarsym(p).refs>0) and
  774. not(vo_is_funcret in tvarsym(p).varoptions) and
  775. not(is_class(tvarsym(p).vartype.def)) and
  776. tvarsym(p).vartype.def.needs_inittable then
  777. finalize_sym(taasmoutput(arg),tsym(p));
  778. end;
  779. typedconstsym :
  780. begin
  781. if ttypedconstsym(p).is_writable and
  782. ttypedconstsym(p).typedconsttype.def.needs_inittable then
  783. finalize_sym(taasmoutput(arg),tsym(p));
  784. end;
  785. procsym :
  786. begin
  787. for i:=1 to tprocsym(p).procdef_count do
  788. begin
  789. pd:=tprocsym(p).procdef[i];
  790. if assigned(pd.localst) and
  791. (pd.procsym=tprocsym(p)) and
  792. (pd.localst.symtabletype<>staticsymtable) then
  793. pd.localst.foreach_static(@finalize_local_typedconst,arg);
  794. end;
  795. end;
  796. end;
  797. end;
  798. { generates the code for incrementing the reference count of parameters and
  799. initialize out parameters }
  800. procedure init_paras(p : tnamedindexitem;arg:pointer);
  801. var
  802. href : treference;
  803. tmpreg : tregister;
  804. list:TAAsmoutput;
  805. begin
  806. list:=taasmoutput(arg);
  807. if (tsym(p).typ=varsym) and
  808. not is_class_or_interface(tvarsym(p).vartype.def) and
  809. tvarsym(p).vartype.def.needs_inittable then
  810. begin
  811. case tvarsym(p).varspez of
  812. vs_value :
  813. begin
  814. if tvarsym(p).localloc.loc<>LOC_REFERENCE then
  815. internalerror(200309187);
  816. cg.g_incrrefcount(list,tvarsym(p).vartype.def,tvarsym(p).localloc.reference,is_open_array(tvarsym(p).vartype.def));
  817. end;
  818. vs_out :
  819. begin
  820. case tvarsym(p).localloc.loc of
  821. LOC_REFERENCE :
  822. href:=tvarsym(p).localloc.reference;
  823. else
  824. internalerror(2003091810);
  825. end;
  826. tmpreg:=cg.getaddressregister(list);
  827. cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,tmpreg);
  828. reference_reset_base(href,tmpreg,0);
  829. cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
  830. end;
  831. end;
  832. end;
  833. end;
  834. { generates the code for decrementing the reference count of parameters }
  835. procedure final_paras(p : tnamedindexitem;arg:pointer);
  836. var
  837. list:TAAsmoutput;
  838. begin
  839. list:=taasmoutput(arg);
  840. if (tsym(p).typ=varsym) and
  841. not is_class_or_interface(tvarsym(p).vartype.def) and
  842. tvarsym(p).vartype.def.needs_inittable then
  843. begin
  844. if (tvarsym(p).varspez=vs_value) then
  845. begin
  846. include(current_procinfo.flags,pi_needs_implicit_finally);
  847. if tvarsym(p).localloc.loc<>LOC_REFERENCE then
  848. internalerror(200309188);
  849. cg.g_decrrefcount(list,tvarsym(p).vartype.def,tvarsym(p).localloc.reference,is_open_array(tvarsym(p).vartype.def));
  850. end;
  851. end
  852. else if (tsym(p).typ=varsym) and
  853. (tvarsym(p).varspez=vs_value) and
  854. (is_open_array(tvarsym(p).vartype.def) or
  855. is_array_of_const(tvarsym(p).vartype.def)) then
  856. begin
  857. { cdecl functions don't have a high pointer so it is not possible to generate
  858. a local copy }
  859. if not(current_procinfo.procdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  860. cg.g_releasevaluepara_openarray(list,tvarsym(p).localloc.reference);
  861. end;
  862. end;
  863. { Initialize temp ansi/widestrings,interfaces }
  864. procedure inittempvariables(list:taasmoutput);
  865. var
  866. hp : ptemprecord;
  867. href : treference;
  868. begin
  869. hp:=tg.templist;
  870. while assigned(hp) do
  871. begin
  872. if assigned(hp^.def) and
  873. hp^.def.needs_inittable then
  874. begin
  875. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  876. cg.g_initialize(list,hp^.def,href,false);
  877. end;
  878. hp:=hp^.next;
  879. end;
  880. end;
  881. procedure finalizetempvariables(list:taasmoutput);
  882. var
  883. hp : ptemprecord;
  884. href : treference;
  885. begin
  886. hp:=tg.templist;
  887. while assigned(hp) do
  888. begin
  889. if assigned(hp^.def) and
  890. hp^.def.needs_inittable then
  891. begin
  892. include(current_procinfo.flags,pi_needs_implicit_finally);
  893. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  894. cg.g_finalize(list,hp^.def,href,false);
  895. end;
  896. hp:=hp^.next;
  897. end;
  898. end;
  899. procedure gen_load_return_value(list:TAAsmoutput);
  900. var
  901. {$ifndef cpu64bit}
  902. href : treference;
  903. {$endif cpu64bit}
  904. ressym : tvarsym;
  905. resloc,
  906. restmploc : tlocation;
  907. hreg : tregister;
  908. funcretloc : pcgparalocation;
  909. begin
  910. { Is the loading needed? }
  911. if is_void(current_procinfo.procdef.rettype.def) or
  912. (
  913. (po_assembler in current_procinfo.procdef.procoptions) and
  914. (not(assigned(current_procinfo.procdef.funcretsym)) or
  915. (tvarsym(current_procinfo.procdef.funcretsym).refs=0))
  916. ) then
  917. exit;
  918. funcretloc:=current_procinfo.procdef.funcret_paraloc[calleeside].location;
  919. if not assigned(funcretloc) then
  920. internalerror(200408202);
  921. { constructors return self }
  922. if (current_procinfo.procdef.proctypeoption=potype_constructor) then
  923. ressym:=tvarsym(current_procinfo.procdef.parast.search('self'))
  924. else
  925. ressym:=tvarsym(current_procinfo.procdef.funcretsym);
  926. if (ressym.refs>0) then
  927. begin
  928. {$ifdef OLDREGVARS}
  929. case ressym.localloc.loc of
  930. LOC_CFPUREGISTER,
  931. LOC_FPUREGISTER:
  932. begin
  933. location_reset(restmploc,LOC_CFPUREGISTER,funcretloc^.size);
  934. restmploc.register:=ressym.localloc.register;
  935. end;
  936. LOC_CREGISTER,
  937. LOC_REGISTER:
  938. begin
  939. location_reset(restmploc,LOC_CREGISTER,funcretloc^.size);
  940. restmploc.register:=ressym.localloc.register;
  941. end;
  942. LOC_MMREGISTER:
  943. begin
  944. location_reset(restmploc,LOC_CMMREGISTER,funcretloc^.size);
  945. restmploc.register:=ressym.localloc.register;
  946. end;
  947. LOC_REFERENCE:
  948. begin
  949. location_reset(restmploc,LOC_REFERENCE,funcretloc^.size);
  950. restmploc.reference:=ressym.localloc.reference;
  951. end;
  952. else
  953. internalerror(200309184);
  954. end;
  955. {$else}
  956. restmploc:=ressym.localloc;
  957. {$endif}
  958. { Here, we return the function result. In most architectures, the value is
  959. passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
  960. function returns in a register and the caller receives it in an other one }
  961. case funcretloc^.loc of
  962. LOC_REGISTER:
  963. begin
  964. {$ifndef cpu64bit}
  965. if current_procinfo.procdef.funcret_paraloc[calleeside].size in [OS_64,OS_S64] then
  966. begin
  967. current_procinfo.procdef.funcret_paraloc[calleeside].get_location(resloc);
  968. if resloc.loc<>LOC_REGISTER then
  969. internalerror(200409141);
  970. { Load low and high register separate to generate better register
  971. allocation info }
  972. if getsupreg(resloc.registerlow)<first_int_imreg then
  973. begin
  974. cg.getcpuregister(list,resloc.registerlow);
  975. cg.ungetcpuregister(list,resloc.registerlow);
  976. { for the optimizer }
  977. cg.a_reg_alloc(list,resloc.registerlow);
  978. end;
  979. case restmploc.loc of
  980. LOC_REFERENCE :
  981. begin
  982. href:=restmploc.reference;
  983. if target_info.endian=ENDIAN_BIG then
  984. inc(href.offset,4);
  985. cg.a_load_ref_reg(list,OS_32,OS_32,href,resloc.registerlow);
  986. end;
  987. LOC_CREGISTER :
  988. cg.a_load_reg_reg(list,OS_32,OS_32,restmploc.registerlow,resloc.registerlow);
  989. else
  990. internalerror(200409203);
  991. end;
  992. if getsupreg(resloc.registerhigh)<first_int_imreg then
  993. begin
  994. cg.getcpuregister(list,resloc.registerhigh);
  995. cg.ungetcpuregister(list,resloc.registerhigh);
  996. { for the optimizer }
  997. cg.a_reg_alloc(list,resloc.registerhigh);
  998. end;
  999. case restmploc.loc of
  1000. LOC_REFERENCE :
  1001. begin
  1002. href:=restmploc.reference;
  1003. if target_info.endian=ENDIAN_LITTLE then
  1004. inc(href.offset,4);
  1005. cg.a_load_ref_reg(list,OS_32,OS_32,href,resloc.registerhigh);
  1006. end;
  1007. LOC_CREGISTER :
  1008. cg.a_load_reg_reg(list,OS_32,OS_32,restmploc.registerhigh,resloc.registerhigh);
  1009. else
  1010. internalerror(200409204);
  1011. end;
  1012. end
  1013. else
  1014. {$endif cpu64bit}
  1015. begin
  1016. hreg:=cg.makeregsize(list,funcretloc^.register,restmploc.size);
  1017. if getsupreg(funcretloc^.register)<first_int_imreg then
  1018. begin
  1019. cg.getcpuregister(list,funcretloc^.register);
  1020. cg.ungetcpuregister(list,hreg);
  1021. { for the optimizer }
  1022. cg.a_reg_alloc(list,funcretloc^.register);
  1023. end;
  1024. cg.a_load_loc_reg(list,restmploc.size,restmploc,hreg);
  1025. end;
  1026. end;
  1027. LOC_FPUREGISTER:
  1028. begin
  1029. if getsupreg(funcretloc^.register)<first_fpu_imreg then
  1030. begin
  1031. cg.getcpuregister(list,funcretloc^.register);
  1032. cg.ungetcpuregister(list,funcretloc^.register);
  1033. end;
  1034. cg.a_loadfpu_loc_reg(list,restmploc,funcretloc^.register);
  1035. end;
  1036. LOC_MMREGISTER:
  1037. begin
  1038. if getsupreg(funcretloc^.register)<first_mm_imreg then
  1039. begin
  1040. cg.getcpuregister(list,funcretloc^.register);
  1041. cg.ungetcpuregister(list,funcretloc^.register);
  1042. end;
  1043. cg.a_loadmm_loc_reg(list,restmploc.size,restmploc,funcretloc^.register,mms_movescalar);
  1044. end;
  1045. LOC_INVALID,
  1046. LOC_REFERENCE:
  1047. ;
  1048. else
  1049. internalerror(200405025);
  1050. end;
  1051. end;
  1052. end;
  1053. procedure gen_load_para_value(list:TAAsmoutput);
  1054. procedure get_para(const paraloc:TCGParaLocation);
  1055. begin
  1056. case paraloc.loc of
  1057. LOC_REGISTER :
  1058. begin
  1059. if getsupreg(paraloc.register)<first_int_imreg then
  1060. cg.getcpuregister(list,paraloc.register);
  1061. end;
  1062. LOC_MMREGISTER :
  1063. begin
  1064. if getsupreg(paraloc.register)<first_mm_imreg then
  1065. cg.getcpuregister(list,paraloc.register);
  1066. end;
  1067. LOC_FPUREGISTER :
  1068. begin
  1069. if getsupreg(paraloc.register)<first_fpu_imreg then
  1070. cg.getcpuregister(list,paraloc.register);
  1071. end;
  1072. end;
  1073. end;
  1074. procedure unget_para(const paraloc:TCGParaLocation);
  1075. begin
  1076. case paraloc.loc of
  1077. LOC_REGISTER :
  1078. begin
  1079. if getsupreg(paraloc.register)<first_int_imreg then
  1080. cg.ungetcpuregister(list,paraloc.register);
  1081. end;
  1082. LOC_MMREGISTER :
  1083. begin
  1084. if getsupreg(paraloc.register)<first_mm_imreg then
  1085. cg.ungetcpuregister(list,paraloc.register);
  1086. end;
  1087. LOC_FPUREGISTER :
  1088. begin
  1089. if getsupreg(paraloc.register)<first_fpu_imreg then
  1090. cg.ungetcpuregister(list,paraloc.register);
  1091. end;
  1092. end;
  1093. end;
  1094. procedure gen_load_ref(const paraloc:TCGParaLocation;const ref:treference);
  1095. var
  1096. href : treference;
  1097. begin
  1098. case paraloc.loc of
  1099. LOC_REGISTER :
  1100. cg.a_load_reg_ref(list,paraloc.size,paraloc.size,paraloc.register,ref);
  1101. LOC_MMREGISTER :
  1102. cg.a_loadmm_reg_ref(list,paraloc.size,paraloc.size,paraloc.register,ref,mms_movescalar);
  1103. LOC_FPUREGISTER :
  1104. cg.a_loadfpu_reg_ref(list,paraloc.size,paraloc.register,ref);
  1105. LOC_REFERENCE :
  1106. begin
  1107. reference_reset_base(href,paraloc.reference.index,paraloc.reference.offset);
  1108. { use concatcopy, because it can also be a float which fails when
  1109. load_ref_ref is used. Don't copy data when the references are equal }
  1110. if not((href.base=ref.base) and (href.offset=ref.offset)) then
  1111. cg.g_concatcopy(list,href,ref,tcgsize2size[paraloc.size],false);
  1112. end;
  1113. else
  1114. internalerror(2002081302);
  1115. end;
  1116. end;
  1117. procedure gen_load_reg(const paraloc:TCGParaLocation;reg:tregister);
  1118. var
  1119. href : treference;
  1120. begin
  1121. case paraloc.loc of
  1122. LOC_REGISTER :
  1123. cg.a_load_reg_reg(list,paraloc.size,paraloc.size,paraloc.register,reg);
  1124. LOC_MMREGISTER :
  1125. cg.a_loadmm_reg_reg(list,paraloc.size,paraloc.size,paraloc.register,reg,mms_movescalar);
  1126. LOC_FPUREGISTER :
  1127. cg.a_loadfpu_reg_reg(list,paraloc.size,paraloc.register,reg);
  1128. LOC_REFERENCE :
  1129. begin
  1130. reference_reset_base(href,paraloc.reference.index,paraloc.reference.offset);
  1131. case getregtype(reg) of
  1132. R_INTREGISTER :
  1133. cg.a_load_ref_reg(list,paraloc.size,paraloc.size,href,reg);
  1134. R_FPUREGISTER :
  1135. cg.a_loadfpu_ref_reg(list,paraloc.size,href,reg);
  1136. R_MMREGISTER :
  1137. cg.a_loadmm_ref_reg(list,paraloc.size,paraloc.size,href,reg,mms_movescalar);
  1138. else
  1139. internalerror(2004101012);
  1140. end;
  1141. end;
  1142. else
  1143. internalerror(2002081302);
  1144. end;
  1145. end;
  1146. var
  1147. hp : tparaitem;
  1148. paraloc : pcgparalocation;
  1149. {$ifdef sparc}
  1150. tempref,
  1151. {$endif sparc}
  1152. href : treference;
  1153. begin
  1154. if (po_assembler in current_procinfo.procdef.procoptions) then
  1155. exit;
  1156. { Allocate registers used by parameters }
  1157. hp:=tparaitem(current_procinfo.procdef.para.first);
  1158. while assigned(hp) do
  1159. begin
  1160. paraloc:=hp.paraloc[calleeside].location;
  1161. while assigned(paraloc) do
  1162. begin
  1163. if paraloc^.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER] then
  1164. get_para(paraloc^);
  1165. paraloc:=paraloc^.next;
  1166. end;
  1167. hp:=tparaitem(hp.next);
  1168. end;
  1169. { Copy parameters to local references/registers }
  1170. hp:=tparaitem(current_procinfo.procdef.para.first);
  1171. while assigned(hp) do
  1172. begin
  1173. paraloc:=hp.paraloc[calleeside].location;
  1174. if not assigned(paraloc) then
  1175. internalerror(200408203);
  1176. case tvarsym(hp.parasym).localloc.loc of
  1177. LOC_REFERENCE :
  1178. begin
  1179. href:=tvarsym(hp.parasym).localloc.reference;
  1180. while assigned(paraloc) do
  1181. begin
  1182. unget_para(paraloc^);
  1183. gen_load_ref(paraloc^,href);
  1184. inc(href.offset,TCGSize2Size[paraloc^.size]);
  1185. paraloc:=paraloc^.next;
  1186. end;
  1187. end;
  1188. LOC_CREGISTER :
  1189. begin
  1190. {$ifndef cpu64bit}
  1191. if tvarsym(hp.parasym).localloc.size in [OS_64,OS_S64] then
  1192. begin
  1193. { First 32bits }
  1194. unget_para(paraloc^);
  1195. if (target_info.endian=ENDIAN_BIG) then
  1196. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerhigh)
  1197. else
  1198. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerlow);
  1199. { Second 32bits }
  1200. if not assigned(paraloc^.next) then
  1201. internalerror(200410104);
  1202. unget_para(paraloc^);
  1203. if (target_info.endian=ENDIAN_BIG) then
  1204. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerlow)
  1205. else
  1206. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerhigh);
  1207. end
  1208. else
  1209. {$endif cpu64bit}
  1210. begin
  1211. unget_para(paraloc^);
  1212. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register);
  1213. if assigned(paraloc^.next) then
  1214. internalerror(200410105);
  1215. end;
  1216. end;
  1217. LOC_CFPUREGISTER :
  1218. begin
  1219. {$ifdef sparc}
  1220. { Sparc passes floats in int registers, when loading to fpu register
  1221. we need a temp }
  1222. tg.GetTemp(list,TCGSize2Size[tvarsym(hp.parasym).localloc.size],tt_normal,tempref);
  1223. href:=tempref;
  1224. while assigned(paraloc) do
  1225. begin
  1226. unget_para(paraloc^);
  1227. gen_load_ref(paraloc^,href);
  1228. inc(href.offset,TCGSize2Size[paraloc^.size]);
  1229. paraloc:=paraloc^.next;
  1230. end;
  1231. cg.a_loadfpu_ref_reg(list,tvarsym(hp.parasym).localloc.size,tempref,tvarsym(hp.parasym).localloc.register);
  1232. tg.UnGetTemp(list,tempref);
  1233. {$else sparc}
  1234. unget_para(paraloc^);
  1235. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register);
  1236. if assigned(paraloc^.next) then
  1237. internalerror(200410109);
  1238. {$endif sparc}
  1239. end;
  1240. LOC_CMMREGISTER :
  1241. begin
  1242. unget_para(paraloc^);
  1243. gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register);
  1244. if assigned(paraloc^.next) then
  1245. internalerror(200410108);
  1246. end;
  1247. end;
  1248. hp:=tparaitem(hp.next);
  1249. end;
  1250. { generate copies of call by value parameters, must be done before
  1251. the initialization and body is parsed because the refcounts are
  1252. incremented using the local copies }
  1253. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1254. end;
  1255. procedure gen_initialize_code(list:TAAsmoutput);
  1256. begin
  1257. { initialize local data like ansistrings }
  1258. case current_procinfo.procdef.proctypeoption of
  1259. potype_unitinit:
  1260. begin
  1261. { this is also used for initialization of variables in a
  1262. program which does not have a globalsymtable }
  1263. if assigned(current_module.globalsymtable) then
  1264. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1265. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1266. end;
  1267. { units have seperate code for initilization and finalization }
  1268. potype_unitfinalize: ;
  1269. { program init/final is generated in separate procedure }
  1270. potype_proginit: ;
  1271. else
  1272. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1273. end;
  1274. { initialisizes temp. ansi/wide string data }
  1275. inittempvariables(list);
  1276. { initialize ansi/widesstring para's }
  1277. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1278. {$ifdef OLDREGVARS}
  1279. load_regvars(list,nil);
  1280. {$endif OLDREGVARS}
  1281. end;
  1282. procedure gen_finalize_code(list:TAAsmoutput);
  1283. begin
  1284. {$ifdef OLDREGVARS}
  1285. cleanup_regvars(list);
  1286. {$endif OLDREGVARS}
  1287. { finalize temporary data }
  1288. finalizetempvariables(list);
  1289. { finalize local data like ansistrings}
  1290. case current_procinfo.procdef.proctypeoption of
  1291. potype_unitfinalize:
  1292. begin
  1293. { this is also used for initialization of variables in a
  1294. program which does not have a globalsymtable }
  1295. if assigned(current_module.globalsymtable) then
  1296. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}finalize_static_data,list);
  1297. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}finalize_static_data,list);
  1298. end;
  1299. { units/progs have separate code for initialization and finalization }
  1300. potype_unitinit: ;
  1301. { program init/final is generated in separate procedure }
  1302. potype_proginit: ;
  1303. else
  1304. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_local_vars,list);
  1305. end;
  1306. { finalize paras data }
  1307. if assigned(current_procinfo.procdef.parast) then
  1308. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1309. end;
  1310. procedure gen_entry_code(list:TAAsmoutput);
  1311. var
  1312. href : treference;
  1313. paraloc1,
  1314. paraloc2 : tcgpara;
  1315. hp : tused_unit;
  1316. begin
  1317. paraloc1.init;
  1318. paraloc2.init;
  1319. { the actual profile code can clobber some registers,
  1320. therefore if the context must be saved, do it before
  1321. the actual call to the profile code
  1322. }
  1323. if (cs_profile in aktmoduleswitches) and
  1324. not(po_assembler in current_procinfo.procdef.procoptions) then
  1325. begin
  1326. { non-win32 can call mcout even in main }
  1327. if not (target_info.system in [system_i386_win32,system_i386_wdosx]) or
  1328. not (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1329. begin
  1330. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1331. cg.g_profilecode(list);
  1332. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1333. end;
  1334. end;
  1335. { call startup helpers from main program }
  1336. if (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1337. begin
  1338. { initialize profiling for win32 }
  1339. if (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1340. (cs_profile in aktmoduleswitches) then
  1341. begin
  1342. reference_reset_symbol(href,objectlibrary.newasmsymbol('etext',AB_EXTERNAL,AT_DATA),0);
  1343. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1344. paramanager.getintparaloc(pocall_default,2,paraloc2);
  1345. paramanager.allocparaloc(list,paraloc2);
  1346. cg.a_paramaddr_ref(list,href,paraloc2);
  1347. reference_reset_symbol(href,objectlibrary.newasmsymbol('__image_base__',AB_EXTERNAL,AT_DATA),0);
  1348. paramanager.allocparaloc(list,paraloc1);
  1349. cg.a_paramaddr_ref(list,href,paraloc1);
  1350. paramanager.freeparaloc(list,paraloc2);
  1351. paramanager.freeparaloc(list,paraloc1);
  1352. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1353. cg.a_call_name(list,'_monstartup');
  1354. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1355. end;
  1356. { initialize units }
  1357. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1358. cg.a_call_name(list,'FPC_INITIALIZEUNITS');
  1359. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1360. {$ifdef GDB}
  1361. if (cs_debuginfo in aktmoduleswitches) then
  1362. if target_info.system <> system_powerpc_macos then
  1363. begin
  1364. { include reference to all debuginfo sections of used units }
  1365. hp:=tused_unit(usedunits.first);
  1366. while assigned(hp) do
  1367. begin
  1368. If (hp.u.flags and uf_has_debuginfo)=uf_has_debuginfo then
  1369. current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.u.globalsymtable,''),AT_DATA,0));
  1370. hp:=tused_unit(hp.next);
  1371. end;
  1372. { include reference to debuginfo for this program }
  1373. current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
  1374. end;
  1375. {$endif GDB}
  1376. end;
  1377. {$ifdef GDB}
  1378. if (cs_debuginfo in aktmoduleswitches) then
  1379. list.concat(Tai_force_line.Create);
  1380. {$endif GDB}
  1381. {$ifdef OLDREGVARS}
  1382. load_regvars(list,nil);
  1383. {$endif OLDREGVARS}
  1384. paraloc1.done;
  1385. paraloc2.done;
  1386. end;
  1387. procedure gen_exit_code(list:TAAsmoutput);
  1388. begin
  1389. { call __EXIT for main program }
  1390. if (not DLLsource) and
  1391. (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1392. cg.a_call_name(list,'FPC_DO_EXIT');
  1393. end;
  1394. {****************************************************************************
  1395. Entry/Exit
  1396. ****************************************************************************}
  1397. procedure gen_proc_symbol(list:Taasmoutput);
  1398. var
  1399. hs : string;
  1400. begin
  1401. { add symbol entry point as well as debug information }
  1402. { will be inserted in front of the rest of this list. }
  1403. { Insert alignment and assembler names }
  1404. { Align, gprof uses 16 byte granularity }
  1405. if (cs_profile in aktmoduleswitches) then
  1406. list.concat(Tai_align.create(16))
  1407. else
  1408. list.concat(Tai_align.create(aktalignment.procalign));
  1409. {$ifdef GDB}
  1410. if (cs_debuginfo in aktmoduleswitches) then
  1411. begin
  1412. if (po_public in current_procinfo.procdef.procoptions) then
  1413. Tprocsym(current_procinfo.procdef.procsym).is_global:=true;
  1414. current_procinfo.procdef.concatstabto(list);
  1415. Tprocsym(current_procinfo.procdef.procsym).isstabwritten:=true;
  1416. end;
  1417. {$endif GDB}
  1418. repeat
  1419. hs:=current_procinfo.procdef.aliasnames.getfirst;
  1420. if hs='' then
  1421. break;
  1422. {$ifdef GDB}
  1423. if (cs_debuginfo in aktmoduleswitches) and
  1424. target_info.use_function_relative_addresses then
  1425. list.concat(Tai_stab_function_name.create(strpnew(hs)));
  1426. {$endif GDB}
  1427. if (cs_profile in aktmoduleswitches) or
  1428. (po_public in current_procinfo.procdef.procoptions) then
  1429. list.concat(Tai_symbol.createname_global(hs,AT_FUNCTION,0))
  1430. else
  1431. list.concat(Tai_symbol.createname(hs,AT_FUNCTION,0));
  1432. until false;
  1433. end;
  1434. procedure gen_proc_symbol_end(list:Taasmoutput);
  1435. {$ifdef GDB}
  1436. var
  1437. stabsendlabel : tasmlabel;
  1438. mangled_length : longint;
  1439. p : pchar;
  1440. {$endif GDB}
  1441. begin
  1442. list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname));
  1443. {$ifdef GDB}
  1444. if (cs_debuginfo in aktmoduleswitches) then
  1445. begin
  1446. objectlibrary.getlabel(stabsendlabel);
  1447. cg.a_label(list,stabsendlabel);
  1448. { define calling EBP as pseudo local var PM }
  1449. { this enables test if the function is a local one !! }
  1450. {if assigned(current_procinfo.parent) and
  1451. (current_procinfo.procdef.parast.symtablelevel>normal_function_level) then
  1452. list.concat(Tai_stabs.Create(strpnew(
  1453. '"parent_ebp:'+tstoreddef(voidpointertype.def).numberstring+'",'+
  1454. tostr(N_LSYM)+',0,0,'+tostr(current_procinfo.parent_framepointer_offset)))); }
  1455. if assigned(current_procinfo.procdef.funcretsym) and
  1456. (tvarsym(current_procinfo.procdef.funcretsym).refs>0) then
  1457. begin
  1458. if tvarsym(current_procinfo.procdef.funcretsym).localloc.loc=LOC_REFERENCE then
  1459. begin
  1460. {$warning Need to add gdb support for ret in param register calling}
  1461. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1462. begin
  1463. list.concat(Tai_stabs.Create(strpnew(
  1464. '"'+current_procinfo.procdef.procsym.name+':X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1465. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1466. if (m_result in aktmodeswitches) then
  1467. list.concat(Tai_stabs.Create(strpnew(
  1468. '"RESULT:X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1469. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))))
  1470. end
  1471. else
  1472. begin
  1473. list.concat(Tai_stabs.Create(strpnew(
  1474. '"'+current_procinfo.procdef.procsym.name+':X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1475. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1476. if (m_result in aktmodeswitches) then
  1477. list.concat(Tai_stabs.Create(strpnew(
  1478. '"RESULT:X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1479. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1480. end;
  1481. end;
  1482. end;
  1483. mangled_length:=length(current_procinfo.procdef.mangledname);
  1484. getmem(p,2*mangled_length+50);
  1485. strpcopy(p,'192,0,0,');
  1486. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1487. if (target_info.use_function_relative_addresses) then
  1488. begin
  1489. strpcopy(strend(p),'-');
  1490. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1491. end;
  1492. list.concat(Tai_stabn.Create(strnew(p)));
  1493. {List.concat(Tai_stabn.Create(strpnew('192,0,0,'
  1494. +current_procinfo.procdef.mangledname))));
  1495. p[0]:='2';p[1]:='2';p[2]:='4';
  1496. strpcopy(strend(p),'_end');}
  1497. strpcopy(p,'224,0,0,'+stabsendlabel.name);
  1498. if (target_info.use_function_relative_addresses) then
  1499. begin
  1500. strpcopy(strend(p),'-');
  1501. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1502. end;
  1503. list.concatlist(withdebuglist);
  1504. list.concat(Tai_stabn.Create(strnew(p)));
  1505. { strpnew('224,0,0,'
  1506. +current_procinfo.procdef.mangledname+'_end'))));}
  1507. freemem(p,2*mangled_length+50);
  1508. end;
  1509. {$endif GDB}
  1510. end;
  1511. procedure gen_proc_entry_code(list:Taasmoutput);
  1512. var
  1513. hitemp,
  1514. lotemp,
  1515. stackframe : longint;
  1516. check : boolean;
  1517. paraloc1 : tcgpara;
  1518. href : treference;
  1519. begin
  1520. paraloc1.init;
  1521. { generate call frame marker for dwarf call frame info }
  1522. dwarfcfi.start_frame(list);
  1523. { allocate temp for saving the argument used when
  1524. stack checking uses a register for pushing the stackframe size }
  1525. check:=(cs_check_stack in aktlocalswitches) and (current_procinfo.procdef.proctypeoption<>potype_proginit);
  1526. if check then
  1527. begin
  1528. { Allocate tempspace to store register parameter than
  1529. is destroyed when calling stackchecking code }
  1530. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1531. if paraloc1.location^.loc=LOC_REGISTER then
  1532. tg.GetTemp(list,sizeof(aint),tt_normal,href);
  1533. end;
  1534. { Calculate size of stackframe }
  1535. stackframe:=current_procinfo.calc_stackframe_size;
  1536. { All temps are know, write offsets used for information }
  1537. if (cs_asm_source in aktglobalswitches) then
  1538. begin
  1539. if tg.direction>0 then
  1540. begin
  1541. lotemp:=current_procinfo.tempstart;
  1542. hitemp:=tg.lasttemp;
  1543. end
  1544. else
  1545. begin
  1546. lotemp:=tg.lasttemp;
  1547. hitemp:=current_procinfo.tempstart;
  1548. end;
  1549. list.concat(Tai_comment.Create(strpnew('Temps allocated between '+std_regname(current_procinfo.framepointer)+
  1550. tostr_with_plus(lotemp)+' and '+std_regname(current_procinfo.framepointer)+tostr_with_plus(hitemp))));
  1551. end;
  1552. { generate target specific proc entry code }
  1553. cg.g_proc_entry(list,stackframe,(po_nostackframe in current_procinfo.procdef.procoptions));
  1554. { Add stack checking code? }
  1555. if check then
  1556. begin
  1557. { The tempspace to store original register is already
  1558. allocated above before the stackframe size is calculated. }
  1559. if paraloc1.location^.loc=LOC_REGISTER then
  1560. cg.a_load_reg_ref(list,OS_INT,OS_INT,paraloc1.location^.register,href);
  1561. paramanager.allocparaloc(list,paraloc1);
  1562. cg.a_param_const(list,OS_INT,stackframe,paraloc1);
  1563. paramanager.freeparaloc(list,paraloc1);
  1564. cg.alloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1565. cg.a_call_name(list,'FPC_STACKCHECK');
  1566. cg.dealloccpuregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1567. if paraloc1.location^.loc=LOC_REGISTER then
  1568. begin
  1569. cg.a_load_ref_reg(list,OS_INT,OS_INT,href,paraloc1.location^.register);
  1570. tg.UnGetTemp(list,href);
  1571. end;
  1572. end;
  1573. paraloc1.done;
  1574. end;
  1575. procedure gen_proc_exit_code(list:Taasmoutput);
  1576. var
  1577. parasize : longint;
  1578. begin
  1579. { c style clearstack does not need to remove parameters from the stack, only the
  1580. return value when it was pushed by arguments }
  1581. if current_procinfo.procdef.proccalloption in clearstack_pocalls then
  1582. begin
  1583. parasize:=0;
  1584. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1585. inc(parasize,sizeof(aint));
  1586. end
  1587. else
  1588. parasize:=current_procinfo.para_stack_size;
  1589. { generate target specific proc exit code }
  1590. cg.g_proc_exit(list,parasize,(po_nostackframe in current_procinfo.procdef.procoptions));
  1591. { release return registers, needed for optimizer }
  1592. paramanager.freeparaloc(list,current_procinfo.procdef.funcret_paraloc[calleeside]);
  1593. { end of frame marker for call frame info }
  1594. dwarfcfi.end_frame(list);
  1595. end;
  1596. procedure gen_save_used_regs(list:TAAsmoutput);
  1597. begin
  1598. { Pure assembler routines need to save the registers themselves }
  1599. if (po_assembler in current_procinfo.procdef.procoptions) then
  1600. exit;
  1601. { for the save all registers we can simply use a pusha,popa which
  1602. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1603. if (po_saveregisters in current_procinfo.procdef.procoptions) then
  1604. cg.g_save_all_registers(list)
  1605. else
  1606. if current_procinfo.procdef.proccalloption in savestdregs_pocalls then
  1607. cg.g_save_standard_registers(list);
  1608. end;
  1609. procedure gen_restore_used_regs(list:TAAsmoutput;const funcretparaloc:tcgpara);
  1610. begin
  1611. { Pure assembler routines need to save the registers themselves }
  1612. if (po_assembler in current_procinfo.procdef.procoptions) then
  1613. exit;
  1614. { for the save all registers we can simply use a pusha,popa which
  1615. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1616. if (po_saveregisters in current_procinfo.procdef.procoptions) then
  1617. cg.g_restore_all_registers(list,funcretparaloc)
  1618. else
  1619. if current_procinfo.procdef.proccalloption in savestdregs_pocalls then
  1620. cg.g_restore_standard_registers(list);
  1621. end;
  1622. {****************************************************************************
  1623. Const Data
  1624. ****************************************************************************}
  1625. procedure insertconstdata(sym : ttypedconstsym);
  1626. { this does not affect the local stack space, since all
  1627. typed constansts and initialized variables are always
  1628. put in the .data / .rodata section
  1629. }
  1630. var
  1631. storefilepos : tfileposinfo;
  1632. curconstsegment : taasmoutput;
  1633. l : longint;
  1634. begin
  1635. storefilepos:=aktfilepos;
  1636. aktfilepos:=sym.fileinfo;
  1637. if sym.is_writable then
  1638. curconstsegment:=datasegment
  1639. else
  1640. curconstsegment:=consts;
  1641. l:=sym.getsize;
  1642. { insert cut for smartlinking or alignment }
  1643. maybe_new_object_file(curconstSegment);
  1644. new_section(curconstSegment,sec_rodata,lower(sym.mangledname),const_align(l));
  1645. if (sym.owner.symtabletype=globalsymtable) or
  1646. maybe_smartlink_symbol or
  1647. (assigned(current_procinfo) and
  1648. (current_procinfo.procdef.proccalloption=pocall_inline)) or
  1649. DLLSource then
  1650. curconstSegment.concat(Tai_symbol.Createname_global(sym.mangledname,AT_DATA,l))
  1651. else
  1652. curconstSegment.concat(Tai_symbol.Createname(sym.mangledname,AT_DATA,l));
  1653. aktfilepos:=storefilepos;
  1654. end;
  1655. procedure insertbssdata(sym : tvarsym);
  1656. var
  1657. l,varalign : longint;
  1658. storefilepos : tfileposinfo;
  1659. begin
  1660. storefilepos:=aktfilepos;
  1661. aktfilepos:=sym.fileinfo;
  1662. l:=sym.getsize;
  1663. if (vo_is_thread_var in sym.varoptions) then
  1664. inc(l,sizeof(aint));
  1665. varalign:=var_align(l);
  1666. maybe_new_object_file(bssSegment);
  1667. new_section(bssSegment,sec_bss,lower(sym.mangledname),varalign);
  1668. if (sym.owner.symtabletype=globalsymtable) or
  1669. maybe_smartlink_symbol or
  1670. DLLSource or
  1671. (assigned(current_procinfo) and
  1672. (current_procinfo.procdef.proccalloption=pocall_inline)) or
  1673. (vo_is_exported in sym.varoptions) or
  1674. (vo_is_C_var in sym.varoptions) then
  1675. bssSegment.concat(Tai_datablock.Create_global(sym.mangledname,l))
  1676. else
  1677. bssSegment.concat(Tai_datablock.Create(sym.mangledname,l));
  1678. aktfilepos:=storefilepos;
  1679. end;
  1680. procedure gen_alloc_symtable(list:TAAsmoutput;st:tsymtable);
  1681. var
  1682. sym : tsym;
  1683. isaddr : boolean;
  1684. cgsize : tcgsize;
  1685. begin
  1686. sym:=tsym(st.symindex.first);
  1687. while assigned(sym) do
  1688. begin
  1689. if (sym.typ=varsym) then
  1690. begin
  1691. with tvarsym(sym) do
  1692. begin
  1693. { Parameters passed to assembler procedures need to be kept
  1694. in the original location }
  1695. if (st.symtabletype=parasymtable) and
  1696. (po_assembler in current_procinfo.procdef.procoptions) then
  1697. begin
  1698. paraitem.paraloc[calleeside].get_location(localloc);
  1699. end
  1700. else
  1701. begin
  1702. isaddr:=(st.symtabletype=parasymtable) and
  1703. paramanager.push_addr_param(varspez,vartype.def,current_procinfo.procdef.proccalloption);
  1704. if isaddr then
  1705. cgsize:=OS_ADDR
  1706. else
  1707. cgsize:=def_cgsize(vartype.def);
  1708. {$ifndef OLDREGVARS}
  1709. { When there is assembler code we can't use regvars }
  1710. if is_regvar then
  1711. begin
  1712. localloc.size:=cgsize;
  1713. case varregable of
  1714. vr_intreg :
  1715. begin
  1716. localloc.loc:=LOC_CREGISTER;
  1717. {$ifndef cpu64bit}
  1718. if cgsize in [OS_64,OS_S64] then
  1719. begin
  1720. localloc.registerlow:=cg.getintregister(list,OS_32);
  1721. localloc.registerhigh:=cg.getintregister(list,OS_32);
  1722. end
  1723. else
  1724. {$endif cpu64bit}
  1725. localloc.register:=cg.getintregister(list,cgsize);
  1726. end;
  1727. vr_fpureg :
  1728. begin
  1729. localloc.loc:=LOC_CFPUREGISTER;
  1730. localloc.register:=cg.getfpuregister(list,cgsize);
  1731. end;
  1732. vr_mmreg :
  1733. begin
  1734. localloc.loc:=LOC_CMMREGISTER;
  1735. localloc.register:=cg.getmmregister(list,cgsize);
  1736. end;
  1737. else
  1738. internalerror(2004101010);
  1739. end;
  1740. end
  1741. else
  1742. {$endif NOT OLDREGVARS}
  1743. begin
  1744. localloc.loc:=LOC_REFERENCE;
  1745. localloc.size:=cgsize;
  1746. case st.symtabletype of
  1747. parasymtable :
  1748. begin
  1749. { Reuse the parameter location for values to are at a single location on the stack }
  1750. if (paraitem.paraloc[calleeside].is_simple_reference) then
  1751. begin
  1752. reference_reset_base(localloc.reference,paraitem.paraloc[calleeside].location^.reference.index,
  1753. paraitem.paraloc[calleeside].location^.reference.offset);
  1754. end
  1755. else
  1756. begin
  1757. if isaddr then
  1758. tg.GetLocal(list,sizeof(aint),voidpointertype.def,localloc.reference)
  1759. else
  1760. tg.GetLocal(list,getsize,vartype.def,localloc.reference);
  1761. end;
  1762. end;
  1763. localsymtable,
  1764. stt_exceptsymtable :
  1765. begin
  1766. tg.GetLocal(list,getsize,vartype.def,localloc.reference);
  1767. end;
  1768. staticsymtable :
  1769. begin
  1770. { PIC, DLL and Threadvar need extra code and are handled in ncgld }
  1771. if not(cs_create_pic in aktmoduleswitches) and
  1772. not(vo_is_dll_var in varoptions) and
  1773. not(vo_is_thread_var in varoptions) then
  1774. reference_reset_symbol(localloc.reference,objectlibrary.newasmsymbol(mangledname,AB_EXTERNAL,AT_DATA),0);
  1775. end;
  1776. else
  1777. internalerror(200410103);
  1778. end;
  1779. end;
  1780. end;
  1781. if cs_asm_source in aktglobalswitches then
  1782. begin
  1783. case localloc.loc of
  1784. LOC_REGISTER,
  1785. LOC_CREGISTER :
  1786. begin
  1787. if (cs_no_regalloc in aktglobalswitches) then
  1788. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located in register '+
  1789. std_regname(localloc.register))))
  1790. else
  1791. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located in register')));
  1792. end;
  1793. LOC_REFERENCE :
  1794. begin
  1795. if not assigned(localloc.reference.symbol) then
  1796. list.concat(Tai_comment.Create(strpnew('Var '+realname+' located at '+
  1797. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1798. end;
  1799. end;
  1800. end;
  1801. end;
  1802. end;
  1803. sym:=tsym(sym.indexnext);
  1804. end;
  1805. end;
  1806. procedure gen_free_symtable(list:TAAsmoutput;st:tsymtable);
  1807. var
  1808. sym : tsym;
  1809. begin
  1810. sym:=tsym(st.symindex.first);
  1811. while assigned(sym) do
  1812. begin
  1813. if (sym.typ=varsym) then
  1814. begin
  1815. with tvarsym(sym) do
  1816. begin
  1817. { Note: We need to keep the data available in memory
  1818. for the sub procedures that can access local data
  1819. in the parent procedures }
  1820. case localloc.loc of
  1821. LOC_CREGISTER :
  1822. cg.a_reg_sync(list,localloc.register);
  1823. LOC_REFERENCE :
  1824. begin
  1825. case st.symtabletype of
  1826. localsymtable,
  1827. parasymtable,
  1828. stt_exceptsymtable :
  1829. tg.Ungetlocal(list,localloc.reference);
  1830. end;
  1831. end;
  1832. end;
  1833. end;
  1834. end;
  1835. sym:=tsym(sym.indexnext);
  1836. end;
  1837. end;
  1838. procedure gen_alloc_inline_parast(list:TAAsmoutput;pd:tprocdef);
  1839. var
  1840. sym : tsym;
  1841. calleeparaloc,
  1842. callerparaloc : pcgparalocation;
  1843. begin
  1844. if (po_assembler in pd.procoptions) then
  1845. exit;
  1846. sym:=tsym(pd.parast.symindex.first);
  1847. while assigned(sym) do
  1848. begin
  1849. if sym.typ=varsym then
  1850. begin
  1851. with tvarsym(sym) do
  1852. begin
  1853. { for localloc <> LOC_REFERENCE, we need regvar support inside inlined procedures }
  1854. localloc.loc:=LOC_REFERENCE;
  1855. localloc.size:=int_cgsize(paramanager.push_size(varspez,vartype.def,pocall_inline));
  1856. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1857. calleeparaloc:=paraitem.paraloc[calleeside].location;
  1858. callerparaloc:=paraitem.paraloc[callerside].location;
  1859. while assigned(calleeparaloc) do
  1860. begin
  1861. if not assigned(callerparaloc) then
  1862. internalerror(200408281);
  1863. if calleeparaloc^.loc<>callerparaloc^.loc then
  1864. internalerror(200408282);
  1865. case calleeparaloc^.loc of
  1866. LOC_FPUREGISTER:
  1867. begin
  1868. calleeparaloc^.register:=cg.getfpuregister(list,calleeparaloc^.size);
  1869. callerparaloc^.register:=calleeparaloc^.register;
  1870. end;
  1871. LOC_REGISTER:
  1872. begin
  1873. calleeparaloc^.register:=cg.getintregister(list,calleeparaloc^.size);
  1874. callerparaloc^.register:=calleeparaloc^.register;
  1875. end;
  1876. LOC_MMREGISTER:
  1877. begin
  1878. calleeparaloc^.register:=cg.getmmregister(list,calleeparaloc^.size);
  1879. callerparaloc^.register:=calleeparaloc^.register;
  1880. end;
  1881. LOC_REFERENCE:
  1882. begin
  1883. calleeparaloc^.reference.offset := localloc.reference.offset;
  1884. calleeparaloc^.reference.index := localloc.reference.base;
  1885. callerparaloc^.reference.offset := localloc.reference.offset;
  1886. callerparaloc^.reference.index := localloc.reference.base;
  1887. end;
  1888. end;
  1889. calleeparaloc:=calleeparaloc^.next;
  1890. callerparaloc:=callerparaloc^.next;
  1891. end;
  1892. if cs_asm_source in aktglobalswitches then
  1893. begin
  1894. case localloc.loc of
  1895. LOC_REFERENCE :
  1896. list.concat(Tai_comment.Create(strpnew('Para '+realname+' allocated at '+
  1897. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1898. end;
  1899. end;
  1900. end;
  1901. end;
  1902. sym:=tsym(sym.indexnext);
  1903. end;
  1904. end;
  1905. procedure gen_alloc_inline_funcret(list:TAAsmoutput;pd:tprocdef);
  1906. var
  1907. calleeparaloc,
  1908. callerparaloc : pcgparalocation;
  1909. begin
  1910. if not assigned(pd.funcretsym) or
  1911. (po_assembler in pd.procoptions) then
  1912. exit;
  1913. { for localloc <> LOC_REFERENCE, we need regvar support inside inlined procedures }
  1914. with tvarsym(pd.funcretsym) do
  1915. begin
  1916. localloc.loc:=LOC_REFERENCE;
  1917. localloc.size:=int_cgsize(paramanager.push_size(varspez,vartype.def,pocall_inline));
  1918. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1919. calleeparaloc:=pd.funcret_paraloc[calleeside].location;
  1920. callerparaloc:=pd.funcret_paraloc[callerside].location;
  1921. while assigned(calleeparaloc) do
  1922. begin
  1923. if not assigned(callerparaloc) then
  1924. internalerror(200408281);
  1925. if calleeparaloc^.loc<>callerparaloc^.loc then
  1926. internalerror(200408282);
  1927. case calleeparaloc^.loc of
  1928. LOC_FPUREGISTER:
  1929. begin
  1930. calleeparaloc^.register:=cg.getfpuregister(list,calleeparaloc^.size);
  1931. callerparaloc^.register:=calleeparaloc^.register;
  1932. end;
  1933. LOC_REGISTER:
  1934. begin
  1935. calleeparaloc^.register:=cg.getintregister(list,calleeparaloc^.size);
  1936. callerparaloc^.register:=calleeparaloc^.register;
  1937. end;
  1938. LOC_MMREGISTER:
  1939. begin
  1940. calleeparaloc^.register:=cg.getmmregister(list,calleeparaloc^.size);
  1941. callerparaloc^.register:=calleeparaloc^.register;
  1942. end;
  1943. LOC_REFERENCE:
  1944. begin
  1945. calleeparaloc^.reference.offset := localloc.reference.offset;
  1946. calleeparaloc^.reference.index := localloc.reference.base;
  1947. callerparaloc^.reference.offset := localloc.reference.offset;
  1948. callerparaloc^.reference.index := localloc.reference.base;
  1949. end;
  1950. end;
  1951. calleeparaloc:=calleeparaloc^.next;
  1952. callerparaloc:=callerparaloc^.next;
  1953. end;
  1954. if cs_asm_source in aktglobalswitches then
  1955. begin
  1956. case localloc.loc of
  1957. LOC_REFERENCE :
  1958. list.concat(Tai_comment.Create(strpnew('Funcret '+realname+' allocated at '+
  1959. std_regname(localloc.reference.base)+tostr_with_plus(localloc.reference.offset))));
  1960. end;
  1961. end;
  1962. end;
  1963. end;
  1964. { persistent rtti generation }
  1965. procedure generate_rtti(p:Ttypesym);
  1966. var
  1967. rsym : trttisym;
  1968. def : tstoreddef;
  1969. begin
  1970. { rtti can only be generated for classes that are always typesyms }
  1971. def:=tstoreddef(ttypesym(p).restype.def);
  1972. { there is an error, skip rtti info }
  1973. if (def.deftype=errordef) or (Errorcount>0) then
  1974. exit;
  1975. { only create rtti once for each definition }
  1976. if not(df_has_rttitable in def.defoptions) then
  1977. begin
  1978. { definition should be in the same symtable as the symbol }
  1979. if p.owner<>def.owner then
  1980. internalerror(200108262);
  1981. { create rttisym }
  1982. rsym:=trttisym.create(p.name,fullrtti);
  1983. p.owner.insert(rsym);
  1984. { register rttisym in definition }
  1985. include(def.defoptions,df_has_rttitable);
  1986. def.rttitablesym:=rsym;
  1987. { write rtti data }
  1988. def.write_child_rtti_data(fullrtti);
  1989. maybe_new_object_file(rttilist);
  1990. new_section(rttilist,sec_rodata,rsym.get_label.name,const_align(sizeof(aint)));
  1991. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  1992. def.write_rtti_data(fullrtti);
  1993. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  1994. end;
  1995. end;
  1996. { persistent init table generation }
  1997. procedure generate_inittable(p:tsym);
  1998. var
  1999. rsym : trttisym;
  2000. def : tstoreddef;
  2001. begin
  2002. { anonymous types are also allowed for records that can be varsym }
  2003. case p.typ of
  2004. typesym :
  2005. def:=tstoreddef(ttypesym(p).restype.def);
  2006. varsym :
  2007. def:=tstoreddef(tvarsym(p).vartype.def);
  2008. else
  2009. internalerror(200108263);
  2010. end;
  2011. { only create inittable once for each definition }
  2012. if not(df_has_inittable in def.defoptions) then
  2013. begin
  2014. { definition should be in the same symtable as the symbol }
  2015. if p.owner<>def.owner then
  2016. internalerror(200108264);
  2017. { create rttisym }
  2018. rsym:=trttisym.create(p.name,initrtti);
  2019. p.owner.insert(rsym);
  2020. { register rttisym in definition }
  2021. include(def.defoptions,df_has_inittable);
  2022. def.inittablesym:=rsym;
  2023. { write inittable data }
  2024. def.write_child_rtti_data(initrtti);
  2025. maybe_new_object_file(rttilist);
  2026. new_section(rttilist,sec_rodata,rsym.get_label.name,const_align(sizeof(aint)));
  2027. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  2028. def.write_rtti_data(initrtti);
  2029. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  2030. end;
  2031. end;
  2032. end.
  2033. {
  2034. $Log$
  2035. Revision 1.226 2004-10-11 15:48:15 peter
  2036. * small regvar for para fixes
  2037. * function tvarsym.is_regvar added
  2038. * tvarsym.getvaluesize removed, use getsize instead
  2039. Revision 1.225 2004/10/10 21:08:55 peter
  2040. * parameter regvar fixes
  2041. Revision 1.224 2004/10/10 20:51:46 peter
  2042. * fixed sparc compile
  2043. * fixed float regvar loading
  2044. Revision 1.223 2004/10/10 20:22:53 peter
  2045. * symtable allocation rewritten
  2046. * loading of parameters to local temps/regs cleanup
  2047. * regvar support for parameters
  2048. * regvar support for staticsymtable (main body)
  2049. Revision 1.222 2004/10/09 10:51:13 olle
  2050. * Refs to DEBUGINFO_<x> is now not inserted for target MacOS
  2051. Revision 1.221 2004/10/08 20:52:07 florian
  2052. * fixed storage of parameters passed by ref.
  2053. Revision 1.220 2004/10/08 17:09:43 peter
  2054. * tvarsym.varregable added, split vo_regable from varoptions
  2055. Revision 1.219 2004/09/27 15:14:08 peter
  2056. * fix compile for oldregvars
  2057. Revision 1.218 2004/09/26 17:45:30 peter
  2058. * simple regvar support, not yet finished
  2059. Revision 1.217 2004/09/25 14:23:54 peter
  2060. * ungetregister is now only used for cpuregisters, renamed to
  2061. ungetcpuregister
  2062. * renamed (get|unget)explicitregister(s) to ..cpuregister
  2063. * removed location-release/reference_release
  2064. Revision 1.216 2004/09/21 17:25:12 peter
  2065. * paraloc branch merged
  2066. Revision 1.215 2004/09/14 16:33:46 peter
  2067. * release localsymtables when module is compiled
  2068. Revision 1.214 2004/09/13 20:30:05 peter
  2069. * finalize all (also procedure local) typedconst at unit finalization
  2070. Revision 1.213.4.3 2004/09/20 20:46:34 peter
  2071. * register allocation optimized for 64bit loading of parameters
  2072. and return values
  2073. Revision 1.213.4.2 2004/09/17 17:19:26 peter
  2074. * fixed 64 bit unaryminus for sparc
  2075. * fixed 64 bit inlining
  2076. * signness of not operation
  2077. Revision 1.213.4.1 2004/08/31 20:43:06 peter
  2078. * paraloc patch
  2079. Revision 1.213 2004/08/23 11:00:06 michael
  2080. + Patch from Peter to fix debuginfo in constructor.
  2081. Revision 1.212 2004/07/17 13:14:17 jonas
  2082. * don't finalize typed consts (fixes bug3212, but causes memory leak;
  2083. they should be finalized at the end of the module)
  2084. Revision 1.211 2004/07/09 23:41:04 jonas
  2085. * support register parameters for inlined procedures + some inline
  2086. cleanups
  2087. Revision 1.210 2004/07/04 12:24:59 jonas
  2088. * fixed one regvar problem, but regvars are still broken since the dwarf
  2089. merge...
  2090. Revision 1.209 2004/06/29 20:57:21 peter
  2091. * fixed size of exceptbuf
  2092. Revision 1.208 2004/06/20 08:55:29 florian
  2093. * logs truncated
  2094. Revision 1.207 2004/06/16 20:07:08 florian
  2095. * dwarf branch merged
  2096. Revision 1.206 2004/06/01 20:39:33 jonas
  2097. * fixed bug regarding parameters on the ppc (they were allocated twice
  2098. under some circumstances and not at all in others)
  2099. Revision 1.205 2004/05/30 21:41:15 jonas
  2100. * more regvar optimizations in location_force_reg
  2101. Revision 1.204 2004/05/30 21:18:22 jonas
  2102. * some optimizations and associated fixes for better regvar code
  2103. Revision 1.203 2004/05/28 21:14:13 peter
  2104. * first load para's to temps before calling entry code (profile
  2105. }