ncgutil.pas 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830
  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,
  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_stackalloc_code(list:Taasmoutput);
  44. procedure gen_stackfree_code(list:Taasmoutput;usesacc,usesacchi:boolean);
  45. procedure gen_save_used_regs(list:TAAsmoutput);
  46. procedure gen_restore_used_regs(list:TAAsmoutput;const funcretparaloc:tparalocation);
  47. procedure gen_initialize_code(list:TAAsmoutput;inlined:boolean);
  48. procedure gen_finalize_code(list:TAAsmoutput;inlined:boolean);
  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; var uses_acc,uses_acchi,uses_fpu : boolean);
  53. (*
  54. procedure geninlineentrycode(list:TAAsmoutput;stackframe:longint);
  55. procedure geninlineexitcode(list:TAAsmoutput;inlined:boolean);
  56. *)
  57. {#
  58. Allocate the buffers for exception management and setjmp environment.
  59. Return a pointer to these buffers, send them to the utility routine
  60. so they are registered, and then call setjmp.
  61. Then compare the result of setjmp with 0, and if not equal
  62. to zero, then jump to exceptlabel.
  63. Also store the result of setjmp to a temporary space by calling g_save_exception_reason
  64. It is to note that this routine may be called *after* the stackframe of a
  65. routine has been called, therefore on machines where the stack cannot
  66. be modified, all temps should be allocated on the heap instead of the
  67. stack.
  68. }
  69. procedure new_exception(list:TAAsmoutput;const jmpbuf,envbuf, href : treference;
  70. a : aword; exceptlabel : tasmlabel);
  71. procedure free_exception(list:TAAsmoutput;const jmpbuf, envbuf, href : treference;
  72. a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
  73. procedure insertconstdata(sym : ttypedconstsym);
  74. procedure insertbssdata(sym : tvarsym);
  75. procedure gen_alloc_localst(list:TAAsmoutput;st:tlocalsymtable);
  76. procedure gen_free_localst(list:TAAsmoutput;st:tlocalsymtable);
  77. procedure gen_alloc_parast(list:TAAsmoutput;st:tparasymtable);
  78. procedure gen_alloc_inline_parast(list:TAAsmoutput;st:tparasymtable);
  79. procedure gen_free_parast(list:TAAsmoutput;st:tparasymtable);
  80. { rtti and init/final }
  81. procedure generate_rtti(p:Ttypesym);
  82. procedure generate_inittable(p:tsym);
  83. implementation
  84. uses
  85. {$ifdef Delphi}
  86. Sysutils,
  87. {$else}
  88. strings,
  89. {$endif}
  90. cutils,cclasses,
  91. globals,systems,verbose,
  92. defutil,
  93. procinfo,paramgr,fmodule,
  94. regvars,
  95. {$ifdef GDB}
  96. gdb,
  97. {$endif GDB}
  98. ncon,
  99. tgobj,cgobj;
  100. const
  101. { Please leave this here, this module should NOT use
  102. exprasmlist, the lists are always passed as arguments.
  103. Declaring it as string here results in an error when compiling (PFV) }
  104. exprasmlist = 'error';
  105. {*****************************************************************************
  106. Misc Helpers
  107. *****************************************************************************}
  108. { DO NOT RELY on the fact that the tnode is not yet swaped
  109. because of inlining code PM }
  110. procedure firstcomplex(p : tbinarynode);
  111. var
  112. hp : tnode;
  113. begin
  114. { always calculate boolean AND and OR from left to right }
  115. if (p.nodetype in [orn,andn]) and
  116. is_boolean(p.left.resulttype.def) then
  117. begin
  118. if nf_swaped in p.flags then
  119. internalerror(234234);
  120. end
  121. else
  122. if (
  123. (p.location.loc=LOC_FPUREGISTER) and
  124. (p.right.registersfpu > p.left.registersfpu)
  125. ) or
  126. (
  127. (
  128. (
  129. ((p.left.registersfpu = 0) and (p.right.registersfpu = 0)) or
  130. (p.location.loc<>LOC_FPUREGISTER)
  131. ) and
  132. (p.left.registersint<p.right.registersint)
  133. )
  134. ) then
  135. begin
  136. hp:=p.left;
  137. p.left:=p.right;
  138. p.right:=hp;
  139. if nf_swaped in p.flags then
  140. exclude(p.flags,nf_swaped)
  141. else
  142. include(p.flags,nf_swaped);
  143. end;
  144. end;
  145. procedure maketojumpbool(list:TAAsmoutput; p : tnode; loadregvars: tloadregvars);
  146. {
  147. produces jumps to true respectively false labels using boolean expressions
  148. depending on whether the loading of regvars is currently being
  149. synchronized manually (such as in an if-node) or automatically (most of
  150. the other cases where this procedure is called), loadregvars can be
  151. "lr_load_regvars" or "lr_dont_load_regvars"
  152. }
  153. var
  154. opsize : tcgsize;
  155. storepos : tfileposinfo;
  156. begin
  157. if nf_error in p.flags then
  158. exit;
  159. storepos:=aktfilepos;
  160. aktfilepos:=p.fileinfo;
  161. if is_boolean(p.resulttype.def) then
  162. begin
  163. {$ifdef OLDREGVARS}
  164. if loadregvars = lr_load_regvars then
  165. load_all_regvars(list);
  166. {$endif OLDREGVARS}
  167. if is_constboolnode(p) then
  168. begin
  169. if tordconstnode(p).value<>0 then
  170. cg.a_jmp_always(list,truelabel)
  171. else
  172. cg.a_jmp_always(list,falselabel)
  173. end
  174. else
  175. begin
  176. opsize:=def_cgsize(p.resulttype.def);
  177. case p.location.loc of
  178. LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
  179. begin
  180. {$ifdef OLDREGVARS}
  181. if (p.location.loc = LOC_CREGISTER) then
  182. load_regvar_reg(list,p.location.register);
  183. {$endif OLDREGVARS}
  184. cg.a_cmp_const_loc_label(list,opsize,OC_NE,
  185. 0,p.location,truelabel);
  186. { !!! should happen right after cmp (JM) }
  187. location_release(list,p.location);
  188. cg.a_jmp_always(list,falselabel);
  189. end;
  190. LOC_JUMP:
  191. ;
  192. {$ifdef cpuflags}
  193. LOC_FLAGS :
  194. begin
  195. cg.a_jmp_flags(list,p.location.resflags,
  196. truelabel);
  197. cg.a_jmp_always(list,falselabel);
  198. end;
  199. {$endif cpuflags}
  200. else
  201. begin
  202. printnode(output,p);
  203. internalerror(200308241);
  204. end;
  205. end;
  206. end;
  207. end
  208. else
  209. internalerror(200112305);
  210. aktfilepos:=storepos;
  211. end;
  212. (*
  213. This code needs fixing. It is not safe to use rgint; on the m68000 it
  214. would be rgaddr.
  215. procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsuperregisterset);
  216. begin
  217. case t.loc of
  218. LOC_REGISTER:
  219. begin
  220. { can't be a regvar, since it would be LOC_CREGISTER then }
  221. exclude(regs,getsupreg(t.register));
  222. if t.registerhigh<>NR_NO then
  223. exclude(regs,getsupreg(t.registerhigh));
  224. end;
  225. LOC_CREFERENCE,LOC_REFERENCE:
  226. begin
  227. if not(cs_regvars in aktglobalswitches) or
  228. (getsupreg(t.reference.base) in cg.rgint.usableregs) then
  229. exclude(regs,getsupreg(t.reference.base));
  230. if not(cs_regvars in aktglobalswitches) or
  231. (getsupreg(t.reference.index) in cg.rgint.usableregs) then
  232. exclude(regs,getsupreg(t.reference.index));
  233. end;
  234. end;
  235. end;
  236. *)
  237. {*****************************************************************************
  238. EXCEPTION MANAGEMENT
  239. *****************************************************************************}
  240. procedure new_exception(list:TAAsmoutput;const jmpbuf,envbuf, href : treference;
  241. a : aword; exceptlabel : tasmlabel);
  242. var
  243. paraloc1,paraloc2,paraloc3 : tparalocation;
  244. begin
  245. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  246. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  247. paraloc3:=paramanager.getintparaloc(pocall_default,3);
  248. paramanager.allocparaloc(list,paraloc3);
  249. cg.a_paramaddr_ref(list,envbuf,paraloc3);
  250. paramanager.allocparaloc(list,paraloc2);
  251. cg.a_paramaddr_ref(list,jmpbuf,paraloc2);
  252. { push type of exceptionframe }
  253. paramanager.allocparaloc(list,paraloc1);
  254. cg.a_param_const(list,OS_S32,1,paraloc1);
  255. paramanager.freeparaloc(list,paraloc3);
  256. paramanager.freeparaloc(list,paraloc2);
  257. paramanager.freeparaloc(list,paraloc1);
  258. cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  259. cg.a_call_name(list,'FPC_PUSHEXCEPTADDR');
  260. cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  261. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  262. paramanager.allocparaloc(list,paraloc1);
  263. cg.a_param_reg(list,OS_ADDR,NR_FUNCTION_RESULT_REG,paraloc1);
  264. paramanager.freeparaloc(list,paraloc1);
  265. cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  266. cg.a_call_name(list,'FPC_SETJMP');
  267. cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  268. cg.g_exception_reason_save(list, href);
  269. cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,cg.makeregsize(NR_FUNCTION_RESULT_REG,OS_S32),exceptlabel);
  270. end;
  271. procedure free_exception(list:TAAsmoutput;const jmpbuf, envbuf, href : treference;
  272. a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
  273. begin
  274. cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  275. cg.a_call_name(list,'FPC_POPADDRSTACK');
  276. cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  277. if not onlyfree then
  278. begin
  279. cg.g_exception_reason_load(list, href);
  280. cg.a_cmp_const_reg_label(list,OS_S32,OC_EQ,a,NR_FUNCTION_RESULT_REG,endexceptlabel);
  281. end;
  282. end;
  283. {*****************************************************************************
  284. TLocation
  285. *****************************************************************************}
  286. {$ifndef cpu64bit}
  287. { 32-bit version }
  288. procedure location_force_reg(list:TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  289. var
  290. hregister,
  291. hregisterhi : tregister;
  292. hreg64 : tregister64;
  293. hl : tasmlabel;
  294. oldloc : tlocation;
  295. begin
  296. oldloc:=l;
  297. if dst_size=OS_NO then
  298. internalerror(200309144);
  299. { handle transformations to 64bit separate }
  300. if dst_size in [OS_64,OS_S64] then
  301. begin
  302. if not (l.size in [OS_64,OS_S64]) then
  303. begin
  304. { load a smaller size to OS_64 }
  305. if l.loc=LOC_REGISTER then
  306. begin
  307. hregister:=cg.makeregsize(l.registerlow,OS_32);
  308. cg.a_load_reg_reg(list,l.size,OS_32,l.registerlow,hregister);
  309. end
  310. else
  311. begin
  312. location_release(list,l);
  313. hregister:=cg.getintregister(list,OS_INT);
  314. end;
  315. { load value in low register }
  316. case l.loc of
  317. LOC_FLAGS :
  318. cg.g_flags2reg(list,OS_INT,l.resflags,hregister);
  319. LOC_JUMP :
  320. begin
  321. cg.a_label(list,truelabel);
  322. cg.a_load_const_reg(list,OS_INT,1,hregister);
  323. objectlibrary.getlabel(hl);
  324. cg.a_jmp_always(list,hl);
  325. cg.a_label(list,falselabel);
  326. cg.a_load_const_reg(list,OS_INT,0,hregister);
  327. cg.a_label(list,hl);
  328. end;
  329. else
  330. cg.a_load_loc_reg(list,OS_INT,l,hregister);
  331. end;
  332. { reset hi part, take care of the signed bit of the current value }
  333. hregisterhi:=cg.getintregister(list,OS_INT);
  334. if (dst_size=OS_S64) and
  335. (l.size in [OS_S8,OS_S16,OS_S32]) then
  336. begin
  337. if l.loc=LOC_CONSTANT then
  338. begin
  339. if (longint(l.value)<0) then
  340. cg.a_load_const_reg(list,OS_32,$ffffffff,hregisterhi)
  341. else
  342. cg.a_load_const_reg(list,OS_32,0,hregisterhi);
  343. end
  344. else
  345. begin
  346. cg.a_op_const_reg_reg(list,OP_SAR,OS_32,31,hregister,
  347. hregisterhi);
  348. end;
  349. end
  350. else
  351. cg.a_load_const_reg(list,OS_32,0,hregisterhi);
  352. location_reset(l,LOC_REGISTER,dst_size);
  353. l.registerlow:=hregister;
  354. l.registerhigh:=hregisterhi;
  355. end
  356. else
  357. begin
  358. { 64bit to 64bit }
  359. if (l.loc=LOC_REGISTER) or
  360. ((l.loc=LOC_CREGISTER) and maybeconst) then
  361. begin
  362. hregister:=l.registerlow;
  363. hregisterhi:=l.registerhigh;
  364. end
  365. else
  366. begin
  367. hregister:=cg.getintregister(list,OS_INT);
  368. hregisterhi:=cg.getintregister(list,OS_INT);
  369. location_release(list,l);
  370. end;
  371. hreg64.reglo:=hregister;
  372. hreg64.reghi:=hregisterhi;
  373. { load value in new register }
  374. cg64.a_load64_loc_reg(list,l,hreg64);
  375. location_reset(l,LOC_REGISTER,dst_size);
  376. l.registerlow:=hregister;
  377. l.registerhigh:=hregisterhi;
  378. end;
  379. end
  380. else
  381. begin
  382. {Do not bother to recycle the existing register. The register
  383. allocator eliminates unnecessary moves, so it's not needed
  384. and trying to recycle registers can cause problems because
  385. the registers changes size and may need aditional constraints.}
  386. location_release(list,l);
  387. hregister:=cg.getintregister(list,dst_size);
  388. { load value in new register }
  389. case l.loc of
  390. LOC_FLAGS :
  391. cg.g_flags2reg(list,dst_size,l.resflags,hregister);
  392. LOC_JUMP :
  393. begin
  394. cg.a_label(list,truelabel);
  395. cg.a_load_const_reg(list,dst_size,1,hregister);
  396. objectlibrary.getlabel(hl);
  397. cg.a_jmp_always(list,hl);
  398. cg.a_label(list,falselabel);
  399. cg.a_load_const_reg(list,dst_size,0,hregister);
  400. cg.a_label(list,hl);
  401. end;
  402. else
  403. begin
  404. { load_loc_reg can only handle size >= l.size, when the
  405. new size is smaller then we need to adjust the size
  406. of the orignal and maybe recalculate l.register for i386 }
  407. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  408. begin
  409. if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  410. l.register:=cg.makeregsize(l.register,dst_size);
  411. { for big endian systems, the reference's offset must }
  412. { be increased in this case, since they have the }
  413. { MSB first in memory and e.g. byte(word_var) should }
  414. { return the second byte in this case (JM) }
  415. if (target_info.endian = ENDIAN_BIG) and
  416. (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  417. inc(l.reference.offset,TCGSize2Size[l.size]-TCGSize2Size[dst_size]);
  418. {$ifdef x86}
  419. l.size:=dst_size;
  420. {$endif x86}
  421. end;
  422. cg.a_load_loc_reg(list,dst_size,l,hregister);
  423. {$ifndef x86}
  424. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  425. l.size:=dst_size;
  426. {$endif not x86}
  427. end;
  428. end;
  429. if (l.loc <> LOC_CREGISTER) or
  430. not maybeconst then
  431. location_reset(l,LOC_REGISTER,dst_size)
  432. else
  433. location_reset(l,LOC_CREGISTER,dst_size);
  434. l.register:=hregister;
  435. end;
  436. { Release temp when it was a reference }
  437. if oldloc.loc=LOC_REFERENCE then
  438. location_freetemp(list,oldloc);
  439. end;
  440. {$else cpu64bit}
  441. { 64-bit version }
  442. procedure location_force_reg(list:TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  443. var
  444. hregister : tregister;
  445. hl : tasmlabel;
  446. oldloc : tlocation;
  447. begin
  448. {Do not bother to recycle the existing register. The register
  449. allocator eliminates unnecessary moves, so it's not needed
  450. and trying to recycle registers can cause problems because
  451. the registers changes size and may need aditional constraints.}
  452. location_release(list,l);
  453. hregister:=cg.getintregister(list,dst_size);
  454. { load value in new register }
  455. case l.loc of
  456. LOC_FLAGS :
  457. cg.g_flags2reg(list,dst_size,l.resflags,hregister);
  458. LOC_JUMP :
  459. begin
  460. cg.a_label(list,truelabel);
  461. cg.a_load_const_reg(list,dst_size,1,hregister);
  462. objectlibrary.getlabel(hl);
  463. cg.a_jmp_always(list,hl);
  464. cg.a_label(list,falselabel);
  465. cg.a_load_const_reg(list,dst_size,0,hregister);
  466. cg.a_label(list,hl);
  467. end;
  468. else
  469. begin
  470. { load_loc_reg can only handle size >= l.size, when the
  471. new size is smaller then we need to adjust the size
  472. of the orignal and maybe recalculate l.register for i386 }
  473. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  474. begin
  475. if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  476. l.register:=cg.makeregsize(l.register,dst_size);
  477. { for big endian systems, the reference's offset must }
  478. { be increased in this case, since they have the }
  479. { MSB first in memory and e.g. byte(word_var) should }
  480. { return the second byte in this case (JM) }
  481. if (target_info.endian = ENDIAN_BIG) and
  482. (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  483. inc(l.reference.offset,TCGSize2Size[l.size]-TCGSize2Size[dst_size]);
  484. {$ifdef x86}
  485. l.size:=dst_size;
  486. {$endif x86}
  487. end;
  488. cg.a_load_loc_reg(list,dst_size,l,hregister);
  489. {$ifndef x86}
  490. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  491. l.size:=dst_size;
  492. {$endif not x86}
  493. end;
  494. end;
  495. if (l.loc <> LOC_CREGISTER) or
  496. not maybeconst then
  497. location_reset(l,LOC_REGISTER,dst_size)
  498. else
  499. location_reset(l,LOC_CREGISTER,dst_size);
  500. l.register:=hregister;
  501. { Release temp when it was a reference }
  502. if oldloc.loc=LOC_REFERENCE then
  503. location_freetemp(list,oldloc);
  504. end;
  505. {$endif cpu64bit}
  506. procedure location_force_fpureg(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
  507. var
  508. reg : tregister;
  509. href : treference;
  510. begin
  511. if (l.loc<>LOC_FPUREGISTER) and
  512. ((l.loc<>LOC_CFPUREGISTER) or (not maybeconst)) then
  513. begin
  514. { if it's in an mm register, store to memory first }
  515. if (l.loc in [LOC_MMREGISTER,LOC_CMMREGISTER]) then
  516. begin
  517. tg.GetTemp(list,tcgsize2size[l.size],tt_normal,href);
  518. cg.a_loadmm_reg_ref(list,l.size,l.size,l.register,href,mms_movescalar);
  519. location_release(list,l);
  520. location_reset(l,LOC_REFERENCE,l.size);
  521. l.reference:=href;
  522. end;
  523. reg:=cg.getfpuregister(list,l.size);
  524. cg.a_loadfpu_loc_reg(list,l,reg);
  525. location_freetemp(list,l);
  526. location_release(list,l);
  527. location_reset(l,LOC_FPUREGISTER,l.size);
  528. l.register:=reg;
  529. end;
  530. end;
  531. procedure location_force_mmregscalar(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
  532. var
  533. reg : tregister;
  534. href : treference;
  535. begin
  536. if (l.loc<>LOC_MMREGISTER) and
  537. ((l.loc<>LOC_CMMREGISTER) or (not maybeconst)) then
  538. begin
  539. { if it's in an fpu register, store to memory first }
  540. if (l.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then
  541. begin
  542. tg.GetTemp(list,tcgsize2size[l.size],tt_normal,href);
  543. cg.a_loadfpu_reg_ref(list,l.size,l.register,href);
  544. location_release(list,l);
  545. location_reset(l,LOC_REFERENCE,l.size);
  546. l.reference:=href;
  547. end;
  548. reg:=cg.getmmregister(list,l.size);
  549. cg.a_loadmm_loc_reg(list,l.size,l,reg,mms_movescalar);
  550. location_freetemp(list,l);
  551. location_release(list,l);
  552. location_reset(l,LOC_MMREGISTER,l.size);
  553. l.register:=reg;
  554. end;
  555. end;
  556. procedure location_force_mem(list:TAAsmoutput;var l:tlocation);
  557. var
  558. r : treference;
  559. begin
  560. case l.loc of
  561. LOC_FPUREGISTER,
  562. LOC_CFPUREGISTER :
  563. begin
  564. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
  565. cg.a_loadfpu_reg_ref(list,l.size,l.register,r);
  566. location_release(list,l);
  567. location_reset(l,LOC_REFERENCE,l.size);
  568. l.reference:=r;
  569. end;
  570. LOC_MMREGISTER,
  571. LOC_CMMREGISTER:
  572. begin
  573. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
  574. cg.a_loadmm_reg_ref(list,l.size,l.size,l.register,r,mms_movescalar);
  575. location_release(list,l);
  576. location_reset(l,LOC_REFERENCE,l.size);
  577. l.reference:=r;
  578. end;
  579. LOC_CONSTANT,
  580. LOC_REGISTER,
  581. LOC_CREGISTER :
  582. begin
  583. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
  584. if l.size in [OS_64,OS_S64] then
  585. begin
  586. cg64.a_load64_loc_ref(list,l,r);
  587. location_release(list,l);
  588. end
  589. else
  590. begin
  591. location_release(list,l);
  592. cg.a_load_loc_ref(list,l.size,l,r);
  593. end;
  594. location_reset(l,LOC_REFERENCE,l.size);
  595. l.reference:=r;
  596. end;
  597. LOC_CREFERENCE,
  598. LOC_REFERENCE : ;
  599. else
  600. internalerror(200203219);
  601. end;
  602. end;
  603. {*****************************************************************************
  604. Maybe_Save
  605. *****************************************************************************}
  606. function maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
  607. begin
  608. {$ifdef i386}
  609. if (needed>=maxfpuregs) and
  610. (l.loc = LOC_FPUREGISTER) then
  611. begin
  612. location_force_mem(list,l);
  613. maybe_pushfpu:=true;
  614. end
  615. else
  616. maybe_pushfpu:=false;
  617. {$endif i386}
  618. end;
  619. {****************************************************************************
  620. Init/Finalize Code
  621. ****************************************************************************}
  622. procedure copyvalueparas(p : tnamedindexitem;arg:pointer);
  623. var
  624. href1,href2 : treference;
  625. list:TAAsmoutput;
  626. hsym : tvarsym;
  627. l : longint;
  628. loadref : boolean;
  629. localcopyloc : tparalocation;
  630. begin
  631. list:=taasmoutput(arg);
  632. if (tsym(p).typ=varsym) and
  633. (tvarsym(p).varspez=vs_value) and
  634. (paramanager.push_addr_param(tvarsym(p).varspez,tvarsym(p).vartype.def,current_procinfo.procdef.proccalloption)) then
  635. begin
  636. loadref:=true;
  637. case tvarsym(p).localloc.loc of
  638. LOC_REGISTER :
  639. begin
  640. reference_reset_base(href1,tvarsym(p).localloc.register,0);
  641. loadref:=false;
  642. end;
  643. LOC_REFERENCE :
  644. reference_reset_base(href1,tvarsym(p).localloc.reference.index,
  645. tvarsym(p).localloc.reference.offset);
  646. else
  647. internalerror(200309181);
  648. end;
  649. if is_open_array(tvarsym(p).vartype.def) or
  650. is_array_of_const(tvarsym(p).vartype.def) then
  651. begin
  652. { cdecl functions don't have a high pointer so it is not possible to generate
  653. a local copy }
  654. if not(current_procinfo.procdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  655. begin
  656. hsym:=tvarsym(tsym(p).owner.search('high'+p.name));
  657. if not assigned(hsym) then
  658. internalerror(200306061);
  659. case hsym.localloc.loc of
  660. LOC_REFERENCE :
  661. begin
  662. { this code is only executed before the code for the body and the entry/exit code is generated
  663. so we're allowed to include pi_do_call here; after pass1 is run, this isn't allowed anymore
  664. }
  665. include(current_procinfo.flags,pi_do_call);
  666. reference_reset_base(href2,hsym.localloc.reference.index,hsym.localloc.reference.offset);
  667. cg.g_copyvaluepara_openarray(list,href1,href2,tarraydef(tvarsym(p).vartype.def).elesize)
  668. end
  669. else
  670. internalerror(200309182);
  671. end;
  672. end;
  673. end
  674. else
  675. begin
  676. if tvarsym(p).localloc.loc<>LOC_REFERENCE then
  677. internalerror(200309183);
  678. { Allocate space for the local copy }
  679. l:=tvarsym(p).getvaluesize;
  680. localcopyloc.loc:=LOC_REFERENCE;
  681. localcopyloc.size:=int_cgsize(l);
  682. tg.GetLocal(list,l,tvarsym(p).vartype.def,localcopyloc.reference);
  683. { Copy data }
  684. reference_reset_base(href2,localcopyloc.reference.index,localcopyloc.reference.offset);
  685. if is_shortstring(tvarsym(p).vartype.def) then
  686. begin
  687. { this code is only executed before the code for the body and the entry/exit code is generated
  688. so we're allowed to include pi_do_call here; after pass1 is run, this isn't allowed anymore
  689. }
  690. include(current_procinfo.flags,pi_do_call);
  691. cg.g_copyshortstring(list,href1,href2,tstringdef(tvarsym(p).vartype.def).len,false,loadref)
  692. end
  693. else
  694. cg.g_concatcopy(list,href1,href2,tvarsym(p).vartype.def.size,true,loadref);
  695. { update localloc of varsym }
  696. tg.Ungetlocal(list,tvarsym(p).localloc.reference);
  697. tvarsym(p).localloc:=localcopyloc;
  698. end;
  699. end;
  700. end;
  701. { generates the code for initialisation of local data }
  702. procedure initialize_data(p : tnamedindexitem;arg:pointer);
  703. var
  704. href : treference;
  705. list:TAAsmoutput;
  706. begin
  707. list:=taasmoutput(arg);
  708. if (tsym(p).typ=varsym) and
  709. (tvarsym(p).refs>0) and
  710. assigned(tvarsym(p).vartype.def) and
  711. not(is_class(tvarsym(p).vartype.def)) and
  712. tvarsym(p).vartype.def.needs_inittable then
  713. begin
  714. if (cs_implicit_exceptions in aktmoduleswitches) then
  715. include(current_procinfo.flags,pi_needs_implicit_finally);
  716. if tvarsym(p).owner.symtabletype=localsymtable then
  717. begin
  718. case tvarsym(p).localloc.loc of
  719. LOC_REFERENCE :
  720. reference_reset_base(href,tvarsym(p).localloc.reference.index,tvarsym(p).localloc.reference.offset);
  721. else
  722. internalerror(2003091810);
  723. end;
  724. end
  725. else
  726. reference_reset_symbol(href,objectlibrary.newasmsymboldata(tvarsym(p).mangledname),0);
  727. cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
  728. end;
  729. end;
  730. { generates the code for finalisation of local data }
  731. procedure finalize_data(p : tnamedindexitem;arg:pointer);
  732. var
  733. href : treference;
  734. list:TAAsmoutput;
  735. begin
  736. list:=taasmoutput(arg);
  737. case tsym(p).typ of
  738. varsym :
  739. begin
  740. if (tvarsym(p).refs>0) and
  741. not(vo_is_funcret in tvarsym(p).varoptions) and
  742. assigned(tvarsym(p).vartype.def) and
  743. not(is_class(tvarsym(p).vartype.def)) and
  744. tvarsym(p).vartype.def.needs_inittable then
  745. begin
  746. if tvarsym(p).owner.symtabletype=localsymtable then
  747. begin
  748. case tvarsym(p).localloc.loc of
  749. LOC_REFERENCE :
  750. reference_reset_base(href,tvarsym(p).localloc.reference.index,tvarsym(p).localloc.reference.offset);
  751. else
  752. internalerror(2003091811);
  753. end;
  754. end
  755. else
  756. reference_reset_symbol(href,objectlibrary.newasmsymboldata(tvarsym(p).mangledname),0);
  757. cg.g_finalize(list,tvarsym(p).vartype.def,href,false);
  758. end;
  759. end;
  760. typedconstsym :
  761. begin
  762. if ttypedconstsym(p).is_writable and
  763. ttypedconstsym(p).typedconsttype.def.needs_inittable then
  764. begin
  765. reference_reset_symbol(href,objectlibrary.newasmsymboldata(ttypedconstsym(p).mangledname),0);
  766. cg.g_finalize(list,ttypedconstsym(p).typedconsttype.def,href,false);
  767. end;
  768. end;
  769. end;
  770. end;
  771. { generates the code for incrementing the reference count of parameters and
  772. initialize out parameters }
  773. procedure init_paras(p : tnamedindexitem;arg:pointer);
  774. var
  775. href : treference;
  776. tmpreg : tregister;
  777. list:TAAsmoutput;
  778. begin
  779. list:=taasmoutput(arg);
  780. if (tsym(p).typ=varsym) and
  781. not is_class(tvarsym(p).vartype.def) and
  782. tvarsym(p).vartype.def.needs_inittable then
  783. begin
  784. case tvarsym(p).varspez of
  785. vs_value :
  786. begin
  787. if (cs_implicit_exceptions in aktmoduleswitches) then
  788. include(current_procinfo.flags,pi_needs_implicit_finally);
  789. if tvarsym(p).localloc.loc<>LOC_REFERENCE then
  790. internalerror(200309187);
  791. reference_reset_base(href,tvarsym(p).localloc.reference.index,tvarsym(p).localloc.reference.offset);
  792. cg.g_incrrefcount(list,tvarsym(p).vartype.def,href,is_open_array(tvarsym(p).vartype.def));
  793. end;
  794. vs_out :
  795. begin
  796. case tvarsym(p).localloc.loc of
  797. LOC_REFERENCE :
  798. reference_reset_base(href,tvarsym(p).localloc.reference.index,tvarsym(p).localloc.reference.offset);
  799. else
  800. internalerror(2003091810);
  801. end;
  802. tmpreg:=cg.getaddressregister(list);
  803. cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,tmpreg);
  804. reference_reset_base(href,tmpreg,0);
  805. cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
  806. cg.ungetregister(list,tmpreg);
  807. end;
  808. end;
  809. end;
  810. end;
  811. { generates the code for decrementing the reference count of parameters }
  812. procedure final_paras(p : tnamedindexitem;arg:pointer);
  813. var
  814. href : treference;
  815. list:TAAsmoutput;
  816. begin
  817. list:=taasmoutput(arg);
  818. if (tsym(p).typ=varsym) and
  819. not is_class(tvarsym(p).vartype.def) and
  820. tvarsym(p).vartype.def.needs_inittable then
  821. begin
  822. if (tvarsym(p).varspez=vs_value) then
  823. begin
  824. if tvarsym(p).localloc.loc<>LOC_REFERENCE then
  825. internalerror(200309188);
  826. reference_reset_base(href,tvarsym(p).localloc.reference.index,tvarsym(p).localloc.reference.offset);
  827. cg.g_decrrefcount(list,tvarsym(p).vartype.def,href,is_open_array(tvarsym(p).vartype.def));
  828. end;
  829. end
  830. else if (tsym(p).typ=varsym) and
  831. (tvarsym(p).varspez=vs_value) and
  832. (is_open_array(tvarsym(p).vartype.def) or
  833. is_array_of_const(tvarsym(p).vartype.def)) then
  834. begin
  835. { cdecl functions don't have a high pointer so it is not possible to generate
  836. a local copy }
  837. if not(current_procinfo.procdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  838. begin
  839. reference_reset_base(href,tvarsym(p).localloc.reference.index,tvarsym(p).localloc.reference.offset);
  840. cg.g_releasevaluepara_openarray(list,href);
  841. end;
  842. end;
  843. end;
  844. { Initialize temp ansi/widestrings,interfaces }
  845. procedure inittempvariables(list:taasmoutput);
  846. var
  847. hp : ptemprecord;
  848. href : treference;
  849. begin
  850. hp:=tg.templist;
  851. while assigned(hp) do
  852. begin
  853. if assigned(hp^.def) and
  854. hp^.def.needs_inittable then
  855. begin
  856. if (cs_implicit_exceptions in aktmoduleswitches) then
  857. include(current_procinfo.flags,pi_needs_implicit_finally);
  858. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  859. cg.g_initialize(list,hp^.def,href,false);
  860. end;
  861. hp:=hp^.next;
  862. end;
  863. end;
  864. procedure finalizetempvariables(list:taasmoutput);
  865. var
  866. hp : ptemprecord;
  867. href : treference;
  868. paraloc1 : tparalocation;
  869. begin
  870. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  871. hp:=tg.templist;
  872. while assigned(hp) do
  873. begin
  874. if assigned(hp^.def) and
  875. hp^.def.needs_inittable then
  876. begin
  877. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  878. cg.g_finalize(list,hp^.def,href,false);
  879. end;
  880. hp:=hp^.next;
  881. end;
  882. end;
  883. procedure gen_load_return_value(list:TAAsmoutput; var uses_acc,uses_acchi,uses_fpu : boolean);
  884. var
  885. ressym : tvarsym;
  886. resloc : tlocation;
  887. href : treference;
  888. hreg : tregister;
  889. begin
  890. { Is the loading needed? }
  891. if is_void(current_procinfo.procdef.rettype.def) or
  892. (
  893. (po_assembler in current_procinfo.procdef.procoptions) and
  894. (not(assigned(current_procinfo.procdef.funcretsym)) or
  895. (tvarsym(current_procinfo.procdef.funcretsym).refs=0))
  896. ) then
  897. exit;
  898. { Constructors need to return self }
  899. if (current_procinfo.procdef.proctypeoption=potype_constructor) then
  900. begin
  901. cg.getexplicitregister(list,NR_FUNCTION_RETURN_REG);
  902. { return the self pointer }
  903. ressym:=tvarsym(current_procinfo.procdef.parast.search('self'));
  904. if not assigned(ressym) then
  905. internalerror(200305058);
  906. case ressym.localloc.loc of
  907. LOC_REFERENCE :
  908. reference_reset_base(href,ressym.localloc.reference.index,ressym.localloc.reference.offset);
  909. else
  910. internalerror(2003091810);
  911. end;
  912. cg.ungetregister(list,NR_FUNCTION_RETURN_REG);
  913. // for the optimizer
  914. cg.a_reg_alloc(list,NR_FUNCTION_RETURN_REG);
  915. cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,NR_FUNCTION_RETURN_REG);
  916. uses_acc:=true;
  917. exit;
  918. end;
  919. ressym := tvarsym(current_procinfo.procdef.funcretsym);
  920. if (ressym.refs>0) then
  921. begin
  922. case ressym.localloc.loc of
  923. LOC_FPUREGISTER,
  924. LOC_REGISTER :
  925. begin
  926. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  927. location_reset(resloc,LOC_CREGISTER,OS_ADDR)
  928. else
  929. if ressym.vartype.def.deftype = floatdef then
  930. location_reset(resloc,LOC_CFPUREGISTER,def_cgsize(current_procinfo.procdef.rettype.def))
  931. else
  932. location_reset(resloc,LOC_CREGISTER,def_cgsize(current_procinfo.procdef.rettype.def));
  933. resloc.register:=ressym.localloc.register;
  934. end;
  935. LOC_REFERENCE :
  936. begin
  937. location_reset(resloc,LOC_REFERENCE,def_cgsize(current_procinfo.procdef.rettype.def));
  938. reference_reset_base(resloc.reference,ressym.localloc.reference.index,ressym.localloc.reference.offset);
  939. end;
  940. else
  941. internalerror(200309184);
  942. end;
  943. { Here, we return the function result. In most architectures, the value is
  944. passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
  945. function returns in a register and the caller receives it in an other one }
  946. case current_procinfo.procdef.rettype.def.deftype of
  947. orddef,
  948. enumdef :
  949. begin
  950. uses_acc:=true;
  951. {$ifndef cpu64bit}
  952. if resloc.size in [OS_64,OS_S64] then
  953. begin
  954. uses_acchi:=true;
  955. cg.getexplicitregister(list,NR_FUNCTION_RETURN64_LOW_REG);
  956. cg.getexplicitregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
  957. cg.ungetregister(list,NR_FUNCTION_RETURN64_LOW_REG);
  958. cg.ungetregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
  959. // for the optimizer
  960. cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_LOW_REG);
  961. cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_HIGH_REG);
  962. cg64.a_load64_loc_reg(list,resloc,joinreg64(NR_FUNCTION_RETURN64_LOW_REG,
  963. NR_FUNCTION_RETURN64_HIGH_REG));
  964. end
  965. else
  966. {$endif cpu64bit}
  967. begin
  968. cg.getexplicitregister(list,NR_FUNCTION_RETURN_REG);
  969. hreg:=cg.makeregsize(NR_FUNCTION_RETURN_REG,resloc.size);
  970. cg.ungetregister(list,hreg);
  971. // for the optimizer
  972. cg.a_reg_alloc(list,NR_FUNCTION_RETURN_REG);
  973. cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
  974. end;
  975. end;
  976. floatdef :
  977. begin
  978. uses_fpu := true;
  979. {$ifdef cpufpemu}
  980. if cs_fp_emulation in aktmoduleswitches then
  981. cg.a_loadfpu_loc_reg(list,resloc,NR_FUNCTION_RETURN_REG)
  982. else
  983. {$endif cpufpemu}
  984. cg.a_loadfpu_loc_reg(list,resloc,NR_FPU_RESULT_REG);
  985. end;
  986. else
  987. begin
  988. if not paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  989. begin
  990. uses_acc:=true;
  991. {$ifndef cpu64bit}
  992. { Win32 can return records in EAX:EDX }
  993. if resloc.size in [OS_64,OS_S64] then
  994. begin
  995. uses_acchi:=true;
  996. cg.getexplicitregister(list,NR_FUNCTION_RETURN64_LOW_REG);
  997. cg.getexplicitregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
  998. cg.ungetregister(list,NR_FUNCTION_RETURN64_LOW_REG);
  999. cg.ungetregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
  1000. // for the optimizer
  1001. cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_LOW_REG);
  1002. cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_HIGH_REG);
  1003. cg64.a_load64_loc_reg(list,resloc,joinreg64(NR_FUNCTION_RETURN64_LOW_REG,
  1004. NR_FUNCTION_RETURN64_HIGH_REG));
  1005. end
  1006. else
  1007. {$endif cpu64bit}
  1008. begin
  1009. cg.getexplicitregister(list,NR_FUNCTION_RETURN_REG);
  1010. hreg:=cg.makeregsize(NR_FUNCTION_RETURN_REG,resloc.size);
  1011. cg.ungetregister(list,hreg);
  1012. // for the optimizer
  1013. cg.a_reg_alloc(list,NR_FUNCTION_RETURN_REG);
  1014. cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
  1015. end;
  1016. end
  1017. end;
  1018. end;
  1019. end;
  1020. end;
  1021. procedure gen_load_para_value(list:TAAsmoutput);
  1022. var
  1023. hp : tparaitem;
  1024. href : treference;
  1025. gotregvarparas : boolean;
  1026. begin
  1027. { Store register parameters in reference or in register variable }
  1028. if assigned(current_procinfo.procdef.parast) and
  1029. not (po_assembler in current_procinfo.procdef.procoptions) then
  1030. begin
  1031. { move register parameters which aren't regable into memory }
  1032. { we do this before init_paras because that one calls routines which may overwrite these }
  1033. { registers and it also expects the values to be in memory }
  1034. hp:=tparaitem(current_procinfo.procdef.para.first);
  1035. gotregvarparas := false;
  1036. while assigned(hp) do
  1037. begin
  1038. case tvarsym(hp.parasym).localloc.loc of
  1039. LOC_REGISTER,
  1040. LOC_MMREGISTER,
  1041. LOC_FPUREGISTER:
  1042. begin
  1043. gotregvarparas := true;
  1044. { cg.a_load_param_reg will first allocate and then deallocate paraloc }
  1045. { register (if the parameter resides in a register) and then allocate }
  1046. { the regvar (which is currently not allocated) }
  1047. cg.a_loadany_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).localloc.register,nil);
  1048. end;
  1049. LOC_REFERENCE :
  1050. begin
  1051. if hp.paraloc[calleeside].loc<>LOC_REFERENCE then
  1052. begin
  1053. if getsupreg(hp.paraloc[calleeside].register)<first_int_imreg then
  1054. begin
  1055. {$ifndef cpu64bit}
  1056. if (hp.paraloc[calleeside].size in [OS_S64,OS_64]) then
  1057. begin
  1058. cg.getexplicitregister(list,hp.paraloc[calleeside].registerlow);
  1059. cg.getexplicitregister(list,hp.paraloc[calleeside].registerhigh);
  1060. end
  1061. else
  1062. {$endif cpu64bit}
  1063. cg.getexplicitregister(list,hp.paraloc[calleeside].register);
  1064. end;
  1065. { Release parameter register }
  1066. {$ifndef cpu64bit}
  1067. if (hp.paraloc[calleeside].size in [OS_S64,OS_64]) then
  1068. begin
  1069. cg.ungetregister(list,hp.paraloc[calleeside].registerlow);
  1070. cg.ungetregister(list,hp.paraloc[calleeside].registerhigh);
  1071. end
  1072. else
  1073. {$endif cpu64bit}
  1074. cg.ungetregister(list,hp.paraloc[calleeside].register);
  1075. reference_reset_base(href,tvarsym(hp.parasym).localloc.reference.index,tvarsym(hp.parasym).localloc.reference.offset);
  1076. cg.a_loadany_param_ref(list,hp.paraloc[calleeside],href,nil);
  1077. end;
  1078. end;
  1079. else
  1080. internalerror(200309185);
  1081. end;
  1082. hp:=tparaitem(hp.next);
  1083. end;
  1084. if gotregvarparas then
  1085. begin
  1086. { deallocate all register variables again }
  1087. hp:=tparaitem(current_procinfo.procdef.para.first);
  1088. while assigned(hp) do
  1089. begin
  1090. if (tvarsym(hp.parasym).localloc.loc=LOC_REGISTER) then
  1091. cg.ungetregister(list,tvarsym(hp.parasym).localloc.register);
  1092. hp:=tparaitem(hp.next);
  1093. end;
  1094. end;
  1095. end;
  1096. { generate copies of call by value parameters, must be done before
  1097. the initialization and body is parsed because the refcounts are
  1098. incremented using the local copies }
  1099. if not(po_assembler in current_procinfo.procdef.procoptions) then
  1100. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1101. end;
  1102. procedure gen_initialize_code(list:TAAsmoutput;inlined:boolean);
  1103. begin
  1104. { initialize local data like ansistrings }
  1105. case current_procinfo.procdef.proctypeoption of
  1106. potype_unitinit:
  1107. begin
  1108. { this is also used for initialization of variables in a
  1109. program which does not have a globalsymtable }
  1110. if assigned(current_module.globalsymtable) then
  1111. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1112. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1113. end;
  1114. { units have seperate code for initilization and finalization }
  1115. potype_unitfinalize: ;
  1116. { program init/final is generated in separate procedure }
  1117. potype_proginit: ;
  1118. else
  1119. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1120. end;
  1121. { initialisizes temp. ansi/wide string data }
  1122. inittempvariables(list);
  1123. { initialize ansi/widesstring para's }
  1124. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1125. {$ifdef OLDREGVARS}
  1126. load_regvars(list,nil);
  1127. {$endif OLDREGVARS}
  1128. end;
  1129. procedure gen_finalize_code(list:TAAsmoutput;inlined:boolean);
  1130. begin
  1131. {$ifdef OLDREGVARS}
  1132. cleanup_regvars(list);
  1133. {$endif OLDREGVARS}
  1134. { finalize temporary data }
  1135. finalizetempvariables(list);
  1136. { finalize local data like ansistrings}
  1137. case current_procinfo.procdef.proctypeoption of
  1138. potype_unitfinalize:
  1139. begin
  1140. { this is also used for initialization of variables in a
  1141. program which does not have a globalsymtable }
  1142. if assigned(current_module.globalsymtable) then
  1143. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1144. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1145. end;
  1146. { units/progs have separate code for initialization and finalization }
  1147. potype_unitinit: ;
  1148. { program init/final is generated in separate procedure }
  1149. potype_proginit: ;
  1150. else
  1151. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1152. end;
  1153. { finalize paras data }
  1154. if assigned(current_procinfo.procdef.parast) then
  1155. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1156. end;
  1157. procedure gen_entry_code(list:TAAsmoutput);
  1158. var
  1159. href : treference;
  1160. paraloc1,
  1161. paraloc2 : tparalocation;
  1162. begin
  1163. { the actual profile code can clobber some registers,
  1164. therefore if the context must be saved, do it before
  1165. the actual call to the profile code
  1166. }
  1167. if (cs_profile in aktmoduleswitches) and
  1168. not(po_assembler in current_procinfo.procdef.procoptions) then
  1169. begin
  1170. { non-win32 can call mcout even in main }
  1171. if not (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  1172. cg.g_profilecode(list)
  1173. else
  1174. { wdosx, and win32 should not call mcount before monstartup has been called }
  1175. if not (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1176. cg.g_profilecode(list);
  1177. end;
  1178. { call startup helpers from main program }
  1179. if (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1180. begin
  1181. { initialize profiling for win32 }
  1182. if (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1183. (cs_profile in aktmoduleswitches) then
  1184. begin
  1185. reference_reset_symbol(href,objectlibrary.newasmsymboldata('etext'),0);
  1186. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1187. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  1188. paramanager.allocparaloc(list,paraloc2);
  1189. cg.a_paramaddr_ref(list,href,paraloc2);
  1190. reference_reset_symbol(href,objectlibrary.newasmsymboldata('__image_base__'),0);
  1191. paramanager.allocparaloc(list,paraloc1);
  1192. cg.a_paramaddr_ref(list,href,paraloc1);
  1193. paramanager.freeparaloc(list,paraloc2);
  1194. paramanager.freeparaloc(list,paraloc1);
  1195. cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1196. cg.a_call_name(list,'_monstartup');
  1197. cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
  1198. end;
  1199. { initialize units }
  1200. cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1201. cg.a_call_name(list,'FPC_INITIALIZEUNITS');
  1202. cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1203. end;
  1204. {$ifdef GDB}
  1205. if (cs_debuginfo in aktmoduleswitches) then
  1206. list.concat(Tai_force_line.Create);
  1207. {$endif GDB}
  1208. {$ifdef OLDREGVARS}
  1209. load_regvars(list,nil);
  1210. {$endif OLDREGVARS}
  1211. end;
  1212. procedure gen_exit_code(list:TAAsmoutput);
  1213. begin
  1214. { call __EXIT for main program }
  1215. if (not DLLsource) and
  1216. (current_procinfo.procdef.proctypeoption=potype_proginit) then
  1217. cg.a_call_name(list,'FPC_DO_EXIT');
  1218. end;
  1219. {****************************************************************************
  1220. Entry/Exit
  1221. ****************************************************************************}
  1222. procedure gen_proc_symbol(list:Taasmoutput);
  1223. var
  1224. hs : string;
  1225. begin
  1226. { add symbol entry point as well as debug information }
  1227. { will be inserted in front of the rest of this list. }
  1228. { Insert alignment and assembler names }
  1229. { Align, gprof uses 16 byte granularity }
  1230. if (cs_profile in aktmoduleswitches) then
  1231. list.concat(Tai_align.create(16))
  1232. else
  1233. list.concat(Tai_align.create(aktalignment.procalign));
  1234. {$ifdef GDB}
  1235. if (cs_debuginfo in aktmoduleswitches) then
  1236. begin
  1237. if (po_public in current_procinfo.procdef.procoptions) then
  1238. Tprocsym(current_procinfo.procdef.procsym).is_global:=true;
  1239. current_procinfo.procdef.concatstabto(list);
  1240. Tprocsym(current_procinfo.procdef.procsym).isstabwritten:=true;
  1241. end;
  1242. {$endif GDB}
  1243. repeat
  1244. hs:=current_procinfo.procdef.aliasnames.getfirst;
  1245. if hs='' then
  1246. break;
  1247. {$ifdef GDB}
  1248. if (cs_debuginfo in aktmoduleswitches) and
  1249. target_info.use_function_relative_addresses then
  1250. list.concat(Tai_stab_function_name.create(strpnew(hs)));
  1251. {$endif GDB}
  1252. if (cs_profile in aktmoduleswitches) or
  1253. (po_public in current_procinfo.procdef.procoptions) then
  1254. list.concat(Tai_symbol.createname_global(hs,0))
  1255. else
  1256. list.concat(Tai_symbol.createname(hs,0));
  1257. until false;
  1258. end;
  1259. procedure gen_proc_symbol_end(list:Taasmoutput);
  1260. {$ifdef GDB}
  1261. var
  1262. stabsendlabel : tasmlabel;
  1263. mangled_length : longint;
  1264. p : pchar;
  1265. {$endif GDB}
  1266. begin
  1267. list.concat(Tai_symbol_end.Createname(current_procinfo.procdef.mangledname));
  1268. {$ifdef GDB}
  1269. if (cs_debuginfo in aktmoduleswitches) then
  1270. begin
  1271. objectlibrary.getlabel(stabsendlabel);
  1272. cg.a_label(list,stabsendlabel);
  1273. { define calling EBP as pseudo local var PM }
  1274. { this enables test if the function is a local one !! }
  1275. {if assigned(current_procinfo.parent) and
  1276. (current_procinfo.procdef.parast.symtablelevel>normal_function_level) then
  1277. list.concat(Tai_stabs.Create(strpnew(
  1278. '"parent_ebp:'+tstoreddef(voidpointertype.def).numberstring+'",'+
  1279. tostr(N_LSYM)+',0,0,'+tostr(current_procinfo.parent_framepointer_offset)))); }
  1280. if (not is_void(current_procinfo.procdef.rettype.def)) and
  1281. (tvarsym(current_procinfo.procdef.funcretsym).refs>0) then
  1282. begin
  1283. if tvarsym(current_procinfo.procdef.funcretsym).localloc.loc=LOC_REFERENCE then
  1284. begin
  1285. {$warning Need to add gdb support for ret in param register calling}
  1286. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1287. begin
  1288. list.concat(Tai_stabs.Create(strpnew(
  1289. '"'+current_procinfo.procdef.procsym.name+':X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1290. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1291. if (m_result in aktmodeswitches) then
  1292. list.concat(Tai_stabs.Create(strpnew(
  1293. '"RESULT:X*'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1294. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))))
  1295. end
  1296. else
  1297. begin
  1298. list.concat(Tai_stabs.Create(strpnew(
  1299. '"'+current_procinfo.procdef.procsym.name+':X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1300. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1301. if (m_result in aktmodeswitches) then
  1302. list.concat(Tai_stabs.Create(strpnew(
  1303. '"RESULT:X'+tstoreddef(current_procinfo.procdef.rettype.def).numberstring+'",'+
  1304. tostr(N_tsym)+',0,0,'+tostr(tvarsym(current_procinfo.procdef.funcretsym).localloc.reference.offset))));
  1305. end;
  1306. end;
  1307. end;
  1308. mangled_length:=length(current_procinfo.procdef.mangledname);
  1309. getmem(p,2*mangled_length+50);
  1310. strpcopy(p,'192,0,0,');
  1311. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1312. if (target_info.use_function_relative_addresses) then
  1313. begin
  1314. strpcopy(strend(p),'-');
  1315. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1316. end;
  1317. list.concat(Tai_stabn.Create(strnew(p)));
  1318. {List.concat(Tai_stabn.Create(strpnew('192,0,0,'
  1319. +current_procinfo.procdef.mangledname))));
  1320. p[0]:='2';p[1]:='2';p[2]:='4';
  1321. strpcopy(strend(p),'_end');}
  1322. strpcopy(p,'224,0,0,'+stabsendlabel.name);
  1323. if (target_info.use_function_relative_addresses) then
  1324. begin
  1325. strpcopy(strend(p),'-');
  1326. strpcopy(strend(p),current_procinfo.procdef.mangledname);
  1327. end;
  1328. list.concatlist(withdebuglist);
  1329. list.concat(Tai_stabn.Create(strnew(p)));
  1330. { strpnew('224,0,0,'
  1331. +current_procinfo.procdef.mangledname+'_end'))));}
  1332. freemem(p,2*mangled_length+50);
  1333. end;
  1334. {$endif GDB}
  1335. end;
  1336. procedure gen_stackalloc_code(list:Taasmoutput);
  1337. var
  1338. hitemp,
  1339. lotemp,
  1340. stackframe : longint;
  1341. check : boolean;
  1342. paraloc1 : tparalocation;
  1343. href : treference;
  1344. begin
  1345. check:=(cs_check_stack in aktlocalswitches) and (current_procinfo.procdef.proctypeoption<>potype_proginit);
  1346. if check then
  1347. begin
  1348. { Allocate tempspace to store register parameter than
  1349. is destroyed when calling stackchecking code }
  1350. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1351. if paraloc1.loc=LOC_REGISTER then
  1352. tg.GetTemp(list,POINTER_SIZE,tt_normal,href);
  1353. end;
  1354. { Calculate size of stackframe }
  1355. stackframe:=current_procinfo.calc_stackframe_size;
  1356. { All temps are know, write offsets used for information }
  1357. if (cs_asm_source in aktglobalswitches) then
  1358. begin
  1359. if tg.direction>0 then
  1360. begin
  1361. lotemp:=current_procinfo.tempstart;
  1362. hitemp:=tg.lasttemp;
  1363. end
  1364. else
  1365. begin
  1366. lotemp:=tg.lasttemp;
  1367. hitemp:=current_procinfo.tempstart;
  1368. end;
  1369. list.concat(Tai_comment.Create(strpnew('Temps allocated between '+std_regname(current_procinfo.framepointer)+
  1370. tostr_with_plus(lotemp)+' and '+std_regname(current_procinfo.framepointer)+tostr_with_plus(hitemp))));
  1371. end;
  1372. {$ifndef powerpc}
  1373. { at least for the ppc this applies always, so this code isn't usable (FK) }
  1374. { omit stack frame ? }
  1375. if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
  1376. begin
  1377. CGmessage(cg_d_stackframe_omited);
  1378. if stackframe<>0 then
  1379. cg.g_stackpointer_alloc(list,stackframe);
  1380. end
  1381. else
  1382. {$endif powerpc}
  1383. begin
  1384. if (po_interrupt in current_procinfo.procdef.procoptions) then
  1385. cg.g_interrupt_stackframe_entry(list);
  1386. cg.g_stackframe_entry(list,stackframe);
  1387. { Add stack checking code? }
  1388. if check then
  1389. begin
  1390. { The tempspace to store original register is already
  1391. allocated above before the stackframe size is calculated. }
  1392. if paraloc1.loc=LOC_REGISTER then
  1393. cg.a_load_reg_ref(list,OS_INT,OS_INT,paraloc1.register,href);
  1394. paramanager.allocparaloc(list,paraloc1);
  1395. cg.a_param_const(list,OS_INT,stackframe,paraloc1);
  1396. paramanager.freeparaloc(list,paraloc1);
  1397. { No register saving needed, saveregisters is used }
  1398. {$ifndef x86}
  1399. cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1400. {$endif x86}
  1401. cg.a_call_name(list,'FPC_STACKCHECK');
  1402. {$ifndef x86}
  1403. cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1404. {$endif x86}
  1405. if paraloc1.loc=LOC_REGISTER then
  1406. begin
  1407. cg.a_load_ref_reg(list,OS_INT,OS_INT,href,paraloc1.register);
  1408. tg.UnGetTemp(list,href);
  1409. end;
  1410. end;
  1411. end;
  1412. end;
  1413. procedure gen_stackfree_code(list:Taasmoutput;usesacc,usesacchi:boolean);
  1414. var
  1415. stacksize,
  1416. retsize : longint;
  1417. begin
  1418. {$ifndef powerpc}
  1419. { remove stackframe }
  1420. if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
  1421. begin
  1422. stacksize:=current_procinfo.calc_stackframe_size;
  1423. if (stacksize<>0) then
  1424. cg.a_op_const_reg(list,OP_ADD,OS_ADDR,stacksize,current_procinfo.framepointer);
  1425. end
  1426. else
  1427. cg.g_restore_frame_pointer(list);
  1428. {$endif}
  1429. {$ifdef x86}
  1430. { at last, the return is generated }
  1431. if (po_interrupt in current_procinfo.procdef.procoptions) then
  1432. cg.g_interrupt_stackframe_exit(list,usesacc,usesacchi)
  1433. else
  1434. {$endif x86}
  1435. begin
  1436. if current_procinfo.procdef.proccalloption in clearstack_pocalls then
  1437. begin
  1438. retsize:=0;
  1439. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1440. inc(retsize,POINTER_SIZE);
  1441. end
  1442. else
  1443. retsize:=current_procinfo.para_stack_size;
  1444. cg.g_return_from_proc(list,retsize);
  1445. end;
  1446. {$ifndef cpu64bit}
  1447. if usesacchi then
  1448. begin
  1449. cg.a_reg_dealloc(list,NR_FUNCTION_RETURN64_LOW_REG);
  1450. cg.a_reg_dealloc(list,NR_FUNCTION_RETURN64_HIGH_REG);
  1451. end
  1452. else
  1453. {$endif cpu64bit}
  1454. if usesacc then
  1455. cg.a_reg_dealloc(list,NR_FUNCTION_RETURN_REG);
  1456. end;
  1457. procedure gen_save_used_regs(list:TAAsmoutput);
  1458. begin
  1459. { Pure assembler routines need to save the registers themselves }
  1460. if (po_assembler in current_procinfo.procdef.procoptions) then
  1461. exit;
  1462. { for the save all registers we can simply use a pusha,popa which
  1463. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1464. if (po_saveregisters in current_procinfo.procdef.procoptions) then
  1465. cg.g_save_all_registers(list)
  1466. else
  1467. if current_procinfo.procdef.proccalloption in savestdregs_pocalls then
  1468. cg.g_save_standard_registers(list);
  1469. end;
  1470. procedure gen_restore_used_regs(list:TAAsmoutput;const funcretparaloc:tparalocation);
  1471. begin
  1472. { Pure assembler routines need to save the registers themselves }
  1473. if (po_assembler in current_procinfo.procdef.procoptions) then
  1474. exit;
  1475. { for the save all registers we can simply use a pusha,popa which
  1476. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1477. if (po_saveregisters in current_procinfo.procdef.procoptions) then
  1478. cg.g_restore_all_registers(list,funcretparaloc)
  1479. else
  1480. if current_procinfo.procdef.proccalloption in savestdregs_pocalls then
  1481. cg.g_restore_standard_registers(list);
  1482. end;
  1483. {****************************************************************************
  1484. Inlining
  1485. ****************************************************************************}
  1486. (*
  1487. procedure load_inlined_return_value(list:TAAsmoutput);
  1488. var
  1489. ressym: tvarsym;
  1490. resloc: tlocation;
  1491. r,r2 : tregister;
  1492. begin
  1493. if not is_void(current_procinfo.procdef.rettype.def) then
  1494. begin
  1495. ressym := tvarsym(current_procinfo.procdef.funcretsym);
  1496. if ressym.reg.enum <> R_NO then
  1497. begin
  1498. if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1499. location_reset(resloc,LOC_CREGISTER,OS_ADDR)
  1500. else
  1501. if ressym.vartype.def.deftype = floatdef then
  1502. location_reset(resloc,LOC_CFPUREGISTER,def_cgsize(current_procinfo.procdef.rettype.def))
  1503. else
  1504. location_reset(resloc,LOC_CREGISTER,def_cgsize(current_procinfo.procdef.rettype.def));
  1505. resloc.register := ressym.reg;
  1506. end
  1507. else
  1508. begin
  1509. location_reset(resloc,LOC_CREGISTER,def_cgsize(current_procinfo.procdef.rettype.def));
  1510. reference_reset_base(resloc.reference,current_procinfo.framepointer,tvarsym(current_procinfo.procdef.funcretsym).adjusted_address);
  1511. end;
  1512. { Here, we return the function result. In most architectures, the value is
  1513. passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
  1514. function returns in a register and the caller receives it in an other one }
  1515. case current_procinfo.procdef.rettype.def.deftype of
  1516. orddef,
  1517. enumdef :
  1518. begin
  1519. {$ifndef cpu64bit}
  1520. if resloc.size in [OS_64,OS_S64] then
  1521. begin
  1522. r:=cg.getregisterint(list,OS_INT);
  1523. r2:=cg.getregisterint(list,OS_INT);
  1524. cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2));
  1525. end
  1526. else
  1527. {$endif cpu64bit}
  1528. begin
  1529. r:=cg.getregisterint(list,resloc.size);
  1530. cg.a_load_loc_reg(list,resloc.size,resloc,r);
  1531. end;
  1532. end;
  1533. floatdef :
  1534. begin
  1535. {$ifdef cpufpemu}
  1536. if cs_fp_emulation in aktmoduleswitches then
  1537. r.enum := FUNCTION_RETURN_REG
  1538. else
  1539. {$endif cpufpemu}
  1540. r.enum:=FPU_RESULT_REG;
  1541. cg.a_loadfpu_loc_reg(list,resloc,r);
  1542. end;
  1543. else
  1544. begin
  1545. if not paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
  1546. begin
  1547. {$ifndef cpu64bit}
  1548. { Win32 can return records in EAX:EDX }
  1549. if resloc.size in [OS_64,OS_S64] then
  1550. begin
  1551. r:=cg.getregisterint(list,OS_INT);
  1552. r2:=cg.getregisterint(list,OS_INT);
  1553. cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2));
  1554. end
  1555. else
  1556. {$endif cpu64bit}
  1557. begin
  1558. r:=cg.getregisterint(list,resloc.size);
  1559. cg.a_load_loc_reg(list,resloc.size,resloc,r);
  1560. end;
  1561. end
  1562. end;
  1563. end;
  1564. end;
  1565. end;
  1566. procedure geninlineentrycode(list:TAAsmoutput;stackframe:longint);
  1567. begin
  1568. { initialize return value }
  1569. initretvalue(list);
  1570. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1571. { initialisizes temp. ansi/wide string data }
  1572. inittempvariables(list);
  1573. { initialize ansi/widesstring para's }
  1574. if assigned(current_procinfo.procdef.parast) then
  1575. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1576. { generate copies of call by value parameters }
  1577. if not(po_assembler in current_procinfo.procdef.procoptions) then
  1578. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1579. load_regvars(list,nil);
  1580. end;
  1581. procedure geninlineexitcode(list:TAAsmoutput;inlined:boolean);
  1582. var
  1583. usesacc,
  1584. usesacchi,
  1585. usesfpu : boolean;
  1586. begin
  1587. if aktexitlabel.is_used then
  1588. cg.a_label(list,aktexitlabel);
  1589. cleanup_regvars(list);
  1590. { finalize temporary data }
  1591. finalizetempvariables(list);
  1592. current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1593. { finalize paras data }
  1594. if assigned(current_procinfo.procdef.parast) then
  1595. current_procinfo.procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1596. { handle return value, this is not done for assembler routines when
  1597. they didn't reference the result variable }
  1598. if not(po_assembler in current_procinfo.procdef.procoptions) or
  1599. (assigned(current_procinfo.procdef.funcretsym) and
  1600. (tvarsym(current_procinfo.procdef.funcretsym).refcount>1)) then
  1601. begin
  1602. if (current_procinfo.procdef.proctypeoption=potype_constructor) then
  1603. internalerror(200305263);
  1604. // load_inlined_return_value(list);
  1605. load_return_value(list,usesacc,usesacchi,usesfpu)
  1606. end;
  1607. cleanup_regvars(list);
  1608. end;
  1609. *)
  1610. {****************************************************************************
  1611. Const Data
  1612. ****************************************************************************}
  1613. procedure insertconstdata(sym : ttypedconstsym);
  1614. { this does not affect the local stack space, since all
  1615. typed constansts and initialized variables are always
  1616. put in the .data / .rodata section
  1617. }
  1618. var
  1619. storefilepos : tfileposinfo;
  1620. curconstsegment : taasmoutput;
  1621. l : longint;
  1622. stabstr:Pchar;
  1623. begin
  1624. storefilepos:=aktfilepos;
  1625. aktfilepos:=sym.fileinfo;
  1626. if sym.is_writable then
  1627. curconstsegment:=datasegment
  1628. else
  1629. curconstsegment:=consts;
  1630. l:=sym.getsize;
  1631. { insert cut for smartlinking or alignment }
  1632. if (cs_create_smart in aktmoduleswitches) then
  1633. curconstSegment.concat(Tai_cut.Create);
  1634. curconstSegment.concat(Tai_align.create(const_align(l)));
  1635. {$ifdef GDB}
  1636. if cs_debuginfo in aktmoduleswitches then
  1637. begin
  1638. if not sym.isstabwritten then
  1639. begin
  1640. stabstr:=sym.stabstring;
  1641. if stabstr<>nil then
  1642. curconstsegment.concat(Tai_stabs.create(stabstr));
  1643. sym.isstabwritten:=true;
  1644. end;
  1645. end;
  1646. {$endif GDB}
  1647. if (sym.owner.symtabletype=globalsymtable) or
  1648. (cs_create_smart in aktmoduleswitches) or
  1649. (assigned(current_procinfo) and
  1650. (current_procinfo.procdef.proccalloption=pocall_inline)) or
  1651. DLLSource then
  1652. curconstSegment.concat(Tai_symbol.Createdataname_global(sym.mangledname,l))
  1653. else
  1654. curconstSegment.concat(Tai_symbol.Createdataname(sym.mangledname,l));
  1655. aktfilepos:=storefilepos;
  1656. end;
  1657. procedure insertbssdata(sym : tvarsym);
  1658. var
  1659. l,varalign : longint;
  1660. storefilepos : tfileposinfo;
  1661. stabstr:Pchar;
  1662. begin
  1663. storefilepos:=aktfilepos;
  1664. aktfilepos:=sym.fileinfo;
  1665. l:=sym.getvaluesize;
  1666. if (vo_is_thread_var in sym.varoptions) then
  1667. inc(l,pointer_size);
  1668. varalign:=var_align(l);
  1669. {
  1670. sym.address:=align(datasize,varalign);
  1671. datasize:=tvarsym(sym).address+l;
  1672. }
  1673. { insert cut for smartlinking or alignment }
  1674. if (cs_create_smart in aktmoduleswitches) then
  1675. bssSegment.concat(Tai_cut.Create);
  1676. bssSegment.concat(Tai_align.create(varalign));
  1677. {$ifdef GDB}
  1678. if cs_debuginfo in aktmoduleswitches then
  1679. begin
  1680. if not sym.isstabwritten then
  1681. begin
  1682. stabstr:=sym.stabstring;
  1683. if stabstr<>nil then
  1684. bsssegment.concat(Tai_stabs.create(stabstr));
  1685. sym.isstabwritten:=true;
  1686. end;
  1687. end;
  1688. {$endif GDB}
  1689. if (sym.owner.symtabletype=globalsymtable) or
  1690. (cs_create_smart in aktmoduleswitches) or
  1691. DLLSource or
  1692. (assigned(current_procinfo) and
  1693. (current_procinfo.procdef.proccalloption=pocall_inline)) or
  1694. (vo_is_exported in sym.varoptions) or
  1695. (vo_is_C_var in sym.varoptions) then
  1696. bssSegment.concat(Tai_datablock.Create_global(sym.mangledname,l))
  1697. else
  1698. bssSegment.concat(Tai_datablock.Create(sym.mangledname,l));
  1699. aktfilepos:=storefilepos;
  1700. end;
  1701. procedure gen_alloc_localst(list:TAAsmoutput;st:tlocalsymtable);
  1702. var
  1703. sym : tsym;
  1704. begin
  1705. sym:=tsym(st.symindex.first);
  1706. while assigned(sym) do
  1707. begin
  1708. { Only allocate space for referenced locals }
  1709. if (sym.typ=varsym) and
  1710. (tvarsym(sym).refs>0) then
  1711. begin
  1712. with tvarsym(sym) do
  1713. begin
  1714. {$warning TODO Add support for register variables}
  1715. localloc.loc:=LOC_REFERENCE;
  1716. tg.GetLocal(list,getvaluesize,vartype.def,localloc.reference);
  1717. if cs_asm_source in aktglobalswitches then
  1718. list.concat(Tai_comment.Create(strpnew('Local '+realname+' located at '+
  1719. std_regname(localloc.reference.index)+tostr_with_plus(localloc.reference.offset))));
  1720. end;
  1721. end;
  1722. sym:=tsym(sym.indexnext);
  1723. end;
  1724. end;
  1725. procedure gen_free_localst(list:TAAsmoutput;st:tlocalsymtable);
  1726. var
  1727. sym : tsym;
  1728. begin
  1729. sym:=tsym(st.symindex.first);
  1730. while assigned(sym) do
  1731. begin
  1732. if (sym.typ=varsym) and
  1733. (tvarsym(sym).refs>0) then
  1734. begin
  1735. with tvarsym(sym) do
  1736. begin
  1737. { Note: We need to keep the data available in memory
  1738. for the sub procedures that can access local data
  1739. in the parent procedures }
  1740. case localloc.loc of
  1741. LOC_REFERENCE :
  1742. tg.Ungetlocal(list,localloc.reference);
  1743. LOC_REGISTER :
  1744. begin
  1745. {$ifndef cpu64bit}
  1746. if localloc.size in [OS_64,OS_S64] then
  1747. begin
  1748. cg.ungetregister(list,localloc.registerlow);
  1749. cg.ungetregister(list,localloc.registerhigh);
  1750. end
  1751. else
  1752. {$endif cpu64bit}
  1753. cg.ungetregister(list,localloc.register);
  1754. end;
  1755. end;
  1756. end;
  1757. end;
  1758. sym:=tsym(sym.indexnext);
  1759. end;
  1760. end;
  1761. procedure gen_alloc_parast(list:TAAsmoutput;st:tparasymtable);
  1762. var
  1763. sym : tsym;
  1764. begin
  1765. sym:=tsym(st.symindex.first);
  1766. while assigned(sym) do
  1767. begin
  1768. if sym.typ=varsym then
  1769. begin
  1770. with tvarsym(sym) do
  1771. begin
  1772. if not(po_assembler in current_procinfo.procdef.procoptions) then
  1773. begin
  1774. case paraitem.paraloc[calleeside].loc of
  1775. LOC_MMREGISTER,
  1776. LOC_FPUREGISTER,
  1777. LOC_REGISTER:
  1778. begin
  1779. (*
  1780. if paraitem.paraloc[calleeside].register=NR_NO then
  1781. begin
  1782. paraitem.paraloc[calleeside].loc:=LOC_REGISTER;
  1783. paraitem.paraloc[calleeside].size:=paraitem.paraloc[calleeside].size;
  1784. {$ifndef cpu64bit}
  1785. if paraitem.paraloc[calleeside].size in [OS_64,OS_S64] then
  1786. begin
  1787. paraitem.paraloc[calleeside].registerlow:=cg.getregisterint(list,OS_32);
  1788. paraitem.paraloc[calleeside].registerhigh:=cg.getregisterint(list,OS_32);
  1789. end
  1790. else
  1791. {$endif cpu64bit}
  1792. paraitem.paraloc[calleeside].register:=cg.getregisterint(list,localloc.size);
  1793. end;
  1794. *)
  1795. (*
  1796. {$warning TODO Allocate register paras}
  1797. localloc.loc:=LOC_REGISTER;
  1798. localloc.size:=paraitem.paraloc[calleeside].size;
  1799. {$ifndef cpu64bit}
  1800. if localloc.size in [OS_64,OS_S64] then
  1801. begin
  1802. localloc.registerlow:=cg.getregisterint(list,OS_32);
  1803. localloc.registerhigh:=cg.getregisterint(list,OS_32);
  1804. end
  1805. else
  1806. {$endif cpu64bit}
  1807. localloc.register:=cg.getregisterint(list,localloc.size);
  1808. *)
  1809. localloc.loc:=LOC_REFERENCE;
  1810. localloc.size:=paraitem.paraloc[calleeside].size;
  1811. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1812. end
  1813. else
  1814. localloc:=paraitem.paraloc[calleeside];
  1815. end;
  1816. end
  1817. else
  1818. localloc:=paraitem.paraloc[calleeside];
  1819. if cs_asm_source in aktglobalswitches then
  1820. begin
  1821. case localloc.loc of
  1822. LOC_REFERENCE :
  1823. begin
  1824. list.concat(Tai_comment.Create(strpnew('Para '+realname+' located at '+
  1825. std_regname(localloc.reference.index)+tostr_with_plus(localloc.reference.offset))));
  1826. {$ifdef powerpc}
  1827. localloc.size:=paraitem.paraloc[calleeside].size;
  1828. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1829. {$endif powerpc}
  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;st:tparasymtable);
  1839. var
  1840. sym : tsym;
  1841. begin
  1842. sym:=tsym(st.symindex.first);
  1843. while assigned(sym) do
  1844. begin
  1845. if sym.typ=varsym then
  1846. begin
  1847. with tvarsym(sym) do
  1848. begin
  1849. {$warning TODO Allocate register paras}
  1850. localloc.loc:=LOC_REFERENCE;
  1851. localloc.size:=int_cgsize(paramanager.push_size(vs_value,vartype.def,pocall_inline));
  1852. tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
  1853. if cs_asm_source in aktglobalswitches then
  1854. begin
  1855. case localloc.loc of
  1856. LOC_REFERENCE :
  1857. list.concat(Tai_comment.Create(strpnew('Para '+realname+' allocated at '+
  1858. std_regname(localloc.reference.index)+tostr_with_plus(localloc.reference.offset))));
  1859. end;
  1860. end;
  1861. paraitem.paraloc[callerside]:=localloc;
  1862. paraitem.paraloc[calleeside]:=localloc;
  1863. end;
  1864. end;
  1865. sym:=tsym(sym.indexnext);
  1866. end;
  1867. end;
  1868. procedure gen_free_parast(list:TAAsmoutput;st:tparasymtable);
  1869. var
  1870. sym : tsym;
  1871. begin
  1872. sym:=tsym(st.symindex.first);
  1873. while assigned(sym) do
  1874. begin
  1875. if sym.typ=varsym then
  1876. begin
  1877. with tvarsym(sym) do
  1878. begin
  1879. { Note: We need to keep the data available in memory
  1880. for the sub procedures that can access local data
  1881. in the parent procedures }
  1882. case localloc.loc of
  1883. LOC_REFERENCE :
  1884. tg.UngetLocal(list,localloc.reference);
  1885. LOC_REGISTER :
  1886. begin
  1887. if localloc.register<>paraitem.paraloc[calleeside].register then
  1888. begin
  1889. {$ifndef cpu64bit}
  1890. if localloc.size in [OS_64,OS_S64] then
  1891. begin
  1892. cg.ungetregister(list,localloc.registerlow);
  1893. cg.ungetregister(list,localloc.registerhigh);
  1894. end
  1895. else
  1896. {$endif cpu64bit}
  1897. cg.ungetregister(list,localloc.register);
  1898. end;
  1899. end;
  1900. end;
  1901. end;
  1902. end;
  1903. sym:=tsym(sym.indexnext);
  1904. end;
  1905. end;
  1906. { persistent rtti generation }
  1907. procedure generate_rtti(p:Ttypesym);
  1908. var
  1909. rsym : trttisym;
  1910. def : tstoreddef;
  1911. begin
  1912. { rtti can only be generated for classes that are always typesyms }
  1913. def:=tstoreddef(ttypesym(p).restype.def);
  1914. { there is an error, skip rtti info }
  1915. if def.deftype=errordef then
  1916. exit;
  1917. { only create rtti once for each definition }
  1918. if not(df_has_rttitable in def.defoptions) then
  1919. begin
  1920. { definition should be in the same symtable as the symbol }
  1921. if p.owner<>def.owner then
  1922. internalerror(200108262);
  1923. { create rttisym }
  1924. rsym:=trttisym.create(p.name,fullrtti);
  1925. p.owner.insert(rsym);
  1926. { register rttisym in definition }
  1927. include(def.defoptions,df_has_rttitable);
  1928. def.rttitablesym:=rsym;
  1929. { write rtti data }
  1930. def.write_child_rtti_data(fullrtti);
  1931. if (cs_create_smart in aktmoduleswitches) then
  1932. rttiList.concat(Tai_cut.Create);
  1933. rttilist.concat(tai_align.create(const_align(pointer_size)));
  1934. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  1935. def.write_rtti_data(fullrtti);
  1936. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  1937. end;
  1938. end;
  1939. { persistent init table generation }
  1940. procedure generate_inittable(p:tsym);
  1941. var
  1942. rsym : trttisym;
  1943. def : tstoreddef;
  1944. begin
  1945. { anonymous types are also allowed for records that can be varsym }
  1946. case p.typ of
  1947. typesym :
  1948. def:=tstoreddef(ttypesym(p).restype.def);
  1949. varsym :
  1950. def:=tstoreddef(tvarsym(p).vartype.def);
  1951. else
  1952. internalerror(200108263);
  1953. end;
  1954. { only create inittable once for each definition }
  1955. if not(df_has_inittable in def.defoptions) then
  1956. begin
  1957. { definition should be in the same symtable as the symbol }
  1958. if p.owner<>def.owner then
  1959. internalerror(200108264);
  1960. { create rttisym }
  1961. rsym:=trttisym.create(p.name,initrtti);
  1962. p.owner.insert(rsym);
  1963. { register rttisym in definition }
  1964. include(def.defoptions,df_has_inittable);
  1965. def.inittablesym:=rsym;
  1966. { write inittable data }
  1967. def.write_child_rtti_data(initrtti);
  1968. if (cs_create_smart in aktmoduleswitches) then
  1969. rttiList.concat(Tai_cut.Create);
  1970. rttilist.concat(tai_align.create(const_align(pointer_size)));
  1971. rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
  1972. def.write_rtti_data(initrtti);
  1973. rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
  1974. end;
  1975. end;
  1976. end.
  1977. {
  1978. $Log$
  1979. Revision 1.191 2004-02-05 19:35:27 florian
  1980. * more x86-64 fixes
  1981. Revision 1.190 2004/02/05 01:24:08 florian
  1982. * several fixes to compile x86-64 system
  1983. Revision 1.189 2004/02/04 22:15:15 daniel
  1984. * Rtti generation moved to ncgutil
  1985. * Assmtai usage of symsym removed
  1986. * operator overloading cleanup up
  1987. Revision 1.188 2004/02/04 22:01:13 peter
  1988. * first try to get cpupara working for x86_64
  1989. Revision 1.187 2004/02/03 22:32:54 peter
  1990. * renamed xNNbittype to xNNinttype
  1991. * renamed registers32 to registersint
  1992. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  1993. Revision 1.186 2004/01/31 18:40:15 daniel
  1994. * Last steps before removal of aasmtai dependency in symsym can be
  1995. accomplished.
  1996. Revision 1.185 2004/01/31 17:45:17 peter
  1997. * Change several $ifdef i386 to x86
  1998. * Change several OS_32 to OS_INT/OS_ADDR
  1999. Revision 1.184 2004/01/21 21:01:34 peter
  2000. * fixed stackchecking for register calling
  2001. Revision 1.183 2004/01/17 15:55:10 jonas
  2002. * fixed allocation of parameters passed by reference for powerpc in
  2003. callee
  2004. Revision 1.182 2004/01/13 18:08:58 florian
  2005. * x86-64 compilation fixed
  2006. Revision 1.181 2004/01/12 22:11:38 peter
  2007. * use localalign info for alignment for locals and temps
  2008. * sparc fpu flags branching added
  2009. * moved powerpc copy_valye_openarray to generic
  2010. Revision 1.180 2003/12/28 21:57:43 jonas
  2011. * fixed procedures declared as "interrupt" for non-x86
  2012. Revision 1.179 2003/12/26 13:19:16 florian
  2013. * rtl and compiler compile with -Cfsse2
  2014. Revision 1.178 2003/12/26 00:32:21 florian
  2015. + fpu<->mm register conversion
  2016. Revision 1.177 2003/12/24 00:10:02 florian
  2017. - delete parameter in cg64 methods removed
  2018. Revision 1.176 2003/12/23 14:38:07 florian
  2019. + second_floataddsse implemented
  2020. Revision 1.175 2003/12/22 19:00:17 florian
  2021. * fixed some x86-64 issues
  2022. Revision 1.174 2003/12/07 16:28:30 jonas
  2023. * fixed typo found by Charlie
  2024. Revision 1.173 2003/12/06 01:15:22 florian
  2025. * reverted Peter's alloctemp patch; hopefully properly
  2026. Revision 1.172 2003/12/03 23:13:20 peter
  2027. * delayed paraloc allocation, a_param_*() gets extra parameter
  2028. if it needs to allocate temp or real paralocation
  2029. * optimized/simplified int-real loading
  2030. Revision 1.171 2003/11/30 19:35:29 florian
  2031. * fixed several arm related problems
  2032. Revision 1.170 2003/11/29 20:13:25 florian
  2033. * fixed several pi_do_call problems
  2034. Revision 1.169 2003/11/23 17:05:15 peter
  2035. * register calling is left-right
  2036. * parameter ordering
  2037. * left-right calling inserts result parameter last
  2038. Revision 1.168 2003/11/22 00:31:25 jonas
  2039. + extra allocations of function result regs for the optimiser
  2040. Revision 1.167 2003/11/11 21:10:12 peter
  2041. * remove temporary stdcall hack
  2042. Revision 1.166 2003/11/10 22:02:52 peter
  2043. * cross unit inlining fixed
  2044. Revision 1.165 2003/11/07 15:58:32 florian
  2045. * Florian's culmutative nr. 1; contains:
  2046. - invalid calling conventions for a certain cpu are rejected
  2047. - arm softfloat calling conventions
  2048. - -Sp for cpu dependend code generation
  2049. - several arm fixes
  2050. - remaining code for value open array paras on heap
  2051. Revision 1.164 2003/11/04 19:03:50 peter
  2052. * fixes for temp type patch
  2053. Revision 1.163 2003/11/04 15:35:13 peter
  2054. * fix for referencecounted temps
  2055. Revision 1.162 2003/10/25 11:34:02 florian
  2056. * fixed compilation of ppc system unit
  2057. Revision 1.161 2003/10/19 01:34:30 florian
  2058. * some ppc stuff fixed
  2059. * memory leak fixed
  2060. Revision 1.160 2003/10/17 15:08:34 peter
  2061. * commented out more obsolete constants
  2062. Revision 1.159 2003/10/17 14:38:32 peter
  2063. * 64k registers supported
  2064. * fixed some memory leaks
  2065. Revision 1.158 2003/10/10 17:48:13 peter
  2066. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  2067. * tregisteralloctor renamed to trgobj
  2068. * removed rgobj from a lot of units
  2069. * moved location_* and reference_* to cgobj
  2070. * first things for mmx register allocation
  2071. Revision 1.157 2003/10/09 21:31:37 daniel
  2072. * Register allocator splitted, ans abstract now
  2073. Revision 1.156 2003/10/07 18:18:16 peter
  2074. * fix register calling for assembler procedures
  2075. * fix result loading for assembler procedures
  2076. Revision 1.155 2003/10/07 15:17:07 peter
  2077. * inline supported again, LOC_REFERENCEs are used to pass the
  2078. parameters
  2079. * inlineparasymtable,inlinelocalsymtable removed
  2080. * exitlabel inserting fixed
  2081. Revision 1.154 2003/10/01 20:34:48 peter
  2082. * procinfo unit contains tprocinfo
  2083. * cginfo renamed to cgbase
  2084. * moved cgmessage to verbose
  2085. * fixed ppc and sparc compiles
  2086. Revision 1.153 2003/09/30 21:02:37 peter
  2087. * updates for inlining
  2088. Revision 1.152 2003/09/29 20:58:56 peter
  2089. * optimized releasing of registers
  2090. Revision 1.151 2003/09/28 21:47:18 peter
  2091. * register paras and local copies updates
  2092. Revision 1.150 2003/09/28 17:55:03 peter
  2093. * parent framepointer changed to hidden parameter
  2094. * tloadparentfpnode added
  2095. Revision 1.149 2003/09/28 13:39:38 peter
  2096. * optimized releasing of registers
  2097. Revision 1.148 2003/09/25 21:28:00 peter
  2098. * parameter fixes
  2099. Revision 1.147 2003/09/23 21:03:59 peter
  2100. * check for refs>0 in init/final local data
  2101. Revision 1.146 2003/09/23 17:56:05 peter
  2102. * locals and paras are allocated in the code generation
  2103. * tvarsym.localloc contains the location of para/local when
  2104. generating code for the current procedure
  2105. Revision 1.145 2003/09/16 16:17:01 peter
  2106. * varspez in calls to push_addr_param
  2107. Revision 1.144 2003/09/14 21:33:37 peter
  2108. * location_force_reg gives IE when size=OS_NO
  2109. Revision 1.143 2003/09/14 19:18:10 peter
  2110. * remove obsolete code already in comments
  2111. Revision 1.142 2003/09/11 11:54:59 florian
  2112. * improved arm code generation
  2113. * move some protected and private field around
  2114. * the temp. register for register parameters/arguments are now released
  2115. before the move to the parameter register is done. This improves
  2116. the code in a lot of cases.
  2117. Revision 1.141 2003/09/10 08:31:47 marco
  2118. * Patch from Peter for paraloc
  2119. Revision 1.140 2003/09/07 22:09:35 peter
  2120. * preparations for different default calling conventions
  2121. * various RA fixes
  2122. Revision 1.139 2003/09/03 15:55:01 peter
  2123. * NEWRA branch merged
  2124. Revision 1.138 2003/09/03 11:18:37 florian
  2125. * fixed arm concatcopy
  2126. + arm support in the common compiler sources added
  2127. * moved some generic cg code around
  2128. + tfputype added
  2129. * ...
  2130. Revision 1.137.2.4 2003/08/31 15:46:26 peter
  2131. * more updates for tregister
  2132. Revision 1.137.2.3 2003/08/29 17:28:59 peter
  2133. * next batch of updates
  2134. Revision 1.137.2.2 2003/08/28 18:35:08 peter
  2135. * tregister changed to cardinal
  2136. Revision 1.137.2.1 2003/08/27 19:55:54 peter
  2137. * first tregister patch
  2138. Revision 1.137 2003/08/20 20:29:06 daniel
  2139. * Some more R_NO changes
  2140. * Preventive code to loadref added
  2141. Revision 1.136 2003/08/20 17:48:49 peter
  2142. * fixed stackalloc to not allocate localst.datasize twice
  2143. * order of stackalloc code fixed for implicit init/final
  2144. Revision 1.135 2003/08/17 16:59:20 jonas
  2145. * fixed regvars so they work with newra (at least for ppc)
  2146. * fixed some volatile register bugs
  2147. + -dnotranslation option for -dnewra, which causes the registers not to
  2148. be translated from virtual to normal registers. Requires support in
  2149. the assembler writer as well, which is only implemented in aggas/
  2150. agppcgas currently
  2151. Revision 1.134 2003/08/11 21:18:20 peter
  2152. * start of sparc support for newra
  2153. Revision 1.133 2003/08/09 18:56:54 daniel
  2154. * cs_regalloc renamed to cs_regvars to avoid confusion with register
  2155. allocator
  2156. * Some preventive changes to i386 spillinh code
  2157. Revision 1.132 2003/08/03 14:09:50 daniel
  2158. * Fixed a register allocator bug
  2159. * Figured out why -dnewra generates superfluous "mov reg1,reg2"
  2160. statements: changes in location_force. These moves are now no longer
  2161. constrained so they are optimized away.
  2162. Revision 1.131 2003/07/23 11:04:15 jonas
  2163. * split en_exit_code into a part that may allocate a register and a part
  2164. that doesn't, so the former can be done before the register colouring
  2165. has been performed
  2166. Revision 1.130 2003/07/06 17:58:22 peter
  2167. * framepointer fixes for sparc
  2168. * parent framepointer code more generic
  2169. Revision 1.129 2003/07/06 15:31:20 daniel
  2170. * Fixed register allocator. *Lots* of fixes.
  2171. Revision 1.128 2003/07/02 22:18:04 peter
  2172. * paraloc splitted in callerparaloc,calleeparaloc
  2173. * sparc calling convention updates
  2174. Revision 1.127 2003/06/17 18:13:51 jonas
  2175. * fixed -dnewra compilation problems
  2176. Revision 1.126 2003/06/17 16:32:44 peter
  2177. * alloc register for function result
  2178. Revision 1.125 2003/06/13 21:19:30 peter
  2179. * current_procdef removed, use current_procinfo.procdef instead
  2180. Revision 1.124 2003/06/09 12:23:30 peter
  2181. * init/final of procedure data splitted from genentrycode
  2182. * use asmnode getposition to insert final at the correct position
  2183. als for the implicit try...finally
  2184. Revision 1.123 2003/06/07 18:57:04 jonas
  2185. + added freeintparaloc
  2186. * ppc get/freeintparaloc now check whether the parameter regs are
  2187. properly allocated/deallocated (and get an extra list para)
  2188. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  2189. * fixed lot of missing pi_do_call's
  2190. Revision 1.122 2003/06/06 14:43:02 peter
  2191. * g_copyopenarrayvalue gets length reference
  2192. * don't copy open arrays for cdecl
  2193. Revision 1.121 2003/06/03 21:11:09 peter
  2194. * cg.a_load_* get a from and to size specifier
  2195. * makeregsize only accepts newregister
  2196. * i386 uses generic tcgnotnode,tcgunaryminus
  2197. Revision 1.120 2003/06/03 15:49:49 jonas
  2198. * fixed ref/loc problems
  2199. Revision 1.119 2003/06/03 15:06:37 daniel
  2200. * fixed conflict marks
  2201. Revision 1.118 2003/06/03 13:01:59 daniel
  2202. * Register allocator finished
  2203. Revision 1.117 2003/06/02 21:42:05 jonas
  2204. * function results can now also be regvars
  2205. - removed tprocinfo.return_offset, never use it again since it's invalid
  2206. if the result is a regvar
  2207. Revision 1.116 2003/06/01 21:38:06 peter
  2208. * getregisterfpu size parameter added
  2209. * op_const_reg size parameter added
  2210. * sparc updates
  2211. Revision 1.115 2003/05/31 20:28:17 jonas
  2212. * changed copyvalueparas so it also supports register parameters
  2213. (except for copy_value_openarray, but that one is seriously broken
  2214. anyway, since it expects that the high parameter will always be in
  2215. memory right after the pointer to the array, while it could just as
  2216. will be in a register)
  2217. Revision 1.114 2003/05/31 15:05:28 peter
  2218. * FUNCTION_RESULT64_LOW/HIGH_REG added for int64 results
  2219. Revision 1.113 2003/05/31 00:48:15 jonas
  2220. * fixed my previous commit
  2221. Revision 1.112 2003/05/30 23:57:08 peter
  2222. * more sparc cleanup
  2223. * accumulator removed, splitted in function_return_reg (called) and
  2224. function_result_reg (caller)
  2225. Revision 1.111 2003/05/30 23:49:18 jonas
  2226. * a_load_loc_reg now has an extra size parameter for the destination
  2227. register (properly fixes what I worked around in revision 1.106 of
  2228. ncgutil.pas)
  2229. Revision 1.110 2003/05/30 18:52:10 jonas
  2230. * fixed bug with intregvars
  2231. * locapara.loc can also be LOC_CFPUREGISTER -> also fixed
  2232. rcgppc.a_param_ref, which previously got bogus size values
  2233. Revision 1.109 2003/05/27 21:19:08 jonas
  2234. * fixed ppc cycle
  2235. Revision 1.108 2003/05/27 14:28:14 jonas
  2236. * patch from Peter for nested procedures
  2237. Revision 1.107 2003/05/26 21:17:17 peter
  2238. * procinlinenode removed
  2239. * aktexit2label removed, fast exit removed
  2240. + tcallnode.inlined_pass_2 added
  2241. Revision 1.106 2003/05/24 11:59:42 jonas
  2242. * fixed integer typeconversion problems
  2243. Revision 1.105 2003/05/23 14:27:35 peter
  2244. * remove some unit dependencies
  2245. * current_procinfo changes to store more info
  2246. Revision 1.104 2003/05/15 18:58:53 peter
  2247. * removed selfpointer_offset, vmtpointer_offset
  2248. * tvarsym.adjusted_address
  2249. * address in localsymtable is now in the real direction
  2250. * removed some obsolete globals
  2251. Revision 1.103 2003/05/14 19:37:25 jonas
  2252. * patch from Peter for int64 function results
  2253. Revision 1.102 2003/05/13 19:14:41 peter
  2254. * failn removed
  2255. * inherited result code check moven to pexpr
  2256. Revision 1.101 2003/05/13 15:16:13 peter
  2257. * removed ret_in_acc, it's the reverse of ret_in_param
  2258. * fixed ret_in_param for win32 cdecl array
  2259. Revision 1.100 2003/05/12 08:08:27 jonas
  2260. * fixed several initialization and finalization related bugs (missing
  2261. tg.direction's, wrong paralocation for decreasing refcount of
  2262. everything but ansistrings)
  2263. Revision 1.99 2003/05/11 21:37:03 peter
  2264. * moved implicit exception frame from ncgutil to psub
  2265. * constructor/destructor helpers moved from cobj/ncgutil to psub
  2266. Revision 1.98 2003/05/11 14:45:12 peter
  2267. * tloadnode does not support objectsymtable,withsymtable anymore
  2268. * withnode cleanup
  2269. * direct with rewritten to use temprefnode
  2270. Revision 1.97 2003/05/10 13:20:23 jonas
  2271. * moved storing of register parameters to memory even earlier in the
  2272. entry code to fix problems with constructors
  2273. Revision 1.96 2003/05/09 17:47:02 peter
  2274. * self moved to hidden parameter
  2275. * removed hdisposen,hnewn,selfn
  2276. Revision 1.95 2003/04/29 07:28:52 michael
  2277. + Patch from peter to fix wrong pushing of ansistring function results in open array
  2278. Revision 1.94 2003/04/28 21:17:38 peter
  2279. * do not finalize function results
  2280. Revision 1.93 2003/04/27 16:30:34 jonas
  2281. * store register para's to memory before copying the valuepara's, because
  2282. that one requires them to be there already (and it calls subroutines ->
  2283. could overwrite those registers)
  2284. Revision 1.92 2003/04/27 11:21:33 peter
  2285. * aktprocdef renamed to current_procinfo.procdef
  2286. * procinfo renamed to current_procinfo
  2287. * procinfo will now be stored in current_module so it can be
  2288. cleaned up properly
  2289. * gen_main_procsym changed to create_main_proc and release_main_proc
  2290. to also generate a tprocinfo structure
  2291. * fixed unit implicit initfinal
  2292. Revision 1.91 2003/04/27 07:29:50 peter
  2293. * current_procinfo.procdef cleanup, current_procinfo.procdef is now always nil when parsing
  2294. a new procdef declaration
  2295. * aktprocsym removed
  2296. * lexlevel removed, use symtable.symtablelevel instead
  2297. * implicit init/final code uses the normal genentry/genexit
  2298. * funcret state checking updated for new funcret handling
  2299. Revision 1.90 2003/04/26 17:21:08 florian
  2300. * fixed passing of fpu values by fpu register
  2301. Revision 1.89 2003/04/25 20:59:33 peter
  2302. * removed funcretn,funcretsym, function result is now in varsym
  2303. and aliases for result and function name are added using absolutesym
  2304. * vs_hidden parameter for funcret passed in parameter
  2305. * vs_hidden fixes
  2306. * writenode changed to printnode and released from extdebug
  2307. * -vp option added to generate a tree.log with the nodetree
  2308. * nicer printnode for statements, callnode
  2309. Revision 1.88 2003/04/23 12:35:34 florian
  2310. * fixed several issues with powerpc
  2311. + applied a patch from Jonas for nested function calls (PowerPC only)
  2312. * ...
  2313. Revision 1.87 2003/04/22 14:33:38 peter
  2314. * removed some notes/hints
  2315. Revision 1.86 2003/04/22 13:47:08 peter
  2316. * fixed C style array of const
  2317. * fixed C array passing
  2318. * fixed left to right with high parameters
  2319. Revision 1.85 2003/04/22 10:09:35 daniel
  2320. + Implemented the actual register allocator
  2321. + Scratch registers unavailable when new register allocator used
  2322. + maybe_save/maybe_restore unavailable when new register allocator used
  2323. Revision 1.84 2003/04/16 09:26:55 jonas
  2324. * assembler procedures now again get a stackframe if they have local
  2325. variables. No space is reserved for a function result however.
  2326. Also, the register parameters aren't automatically saved on the stack
  2327. anymore in assembler procedures.
  2328. Revision 1.83 2003/04/06 21:11:23 olle
  2329. * changed newasmsymbol to newasmsymboldata for data symbols
  2330. Revision 1.82 2003/03/30 20:59:07 peter
  2331. * fix classmethod from classmethod call
  2332. * move BeforeDestruction/AfterConstruction calls to
  2333. genentrycode/genexitcode instead of generating them on the fly
  2334. after a call to a constructor
  2335. Revision 1.81 2003/03/28 19:16:56 peter
  2336. * generic constructor working for i386
  2337. * remove fixed self register
  2338. * esi added as address register for i386
  2339. Revision 1.80 2003/03/17 15:52:20 peter
  2340. * fix range error
  2341. Revision 1.79 2003/03/11 21:46:24 jonas
  2342. * lots of new regallocator fixes, both in generic and ppc-specific code
  2343. (ppc compiler still can't compile the linux system unit though)
  2344. Revision 1.78 2003/02/26 21:15:43 daniel
  2345. * Fixed the optimizer
  2346. Revision 1.77 2003/02/19 22:00:14 daniel
  2347. * Code generator converted to new register notation
  2348. - Horribily outdated todo.txt removed
  2349. Revision 1.76 2003/02/15 22:17:38 carl
  2350. * bugfix of FPU emulation code
  2351. Revision 1.75 2003/01/09 22:00:53 florian
  2352. * fixed some PowerPC issues
  2353. Revision 1.74 2003/01/09 20:41:10 florian
  2354. * fixed broken PowerPC compiler
  2355. Revision 1.73 2003/01/08 18:43:56 daniel
  2356. * Tregister changed into a record
  2357. Revision 1.72 2002/12/29 23:51:43 florian
  2358. * web bug 2214 fixed: ie 10 in const array constructors
  2359. Revision 1.71 2002/12/24 15:56:50 peter
  2360. * stackpointer_alloc added for adjusting ESP. Win32 needs
  2361. this for the pageprotection
  2362. Revision 1.70 2002/12/05 14:39:21 florian
  2363. * added missing then, Carl did you really a make fullcycle :) ?
  2364. Revision 1.69 2002/12/03 22:13:39 carl
  2365. * bugfix of problems with profile code which clobbers some registers
  2366. Revision 1.68 2002/12/01 22:06:59 carl
  2367. * warning of portabilitiy problems with parasize / localsize
  2368. Revision 1.67 2002/11/30 18:44:57 carl
  2369. + profiling support for Win32
  2370. Revision 1.66 2002/11/30 14:39:15 carl
  2371. * try to fix profiling for win32
  2372. Revision 1.65 2002/11/28 23:28:14 florian
  2373. * push_value_para didn't release floatdef locations, fixes tw2045
  2374. Revision 1.64 2002/11/27 02:33:19 peter
  2375. * copy_value_on_stack method added for cdecl record passing
  2376. Revision 1.63 2002/11/25 17:43:18 peter
  2377. * splitted defbase in defutil,symutil,defcmp
  2378. * merged isconvertable and is_equal into compare_defs(_ext)
  2379. * made operator search faster by walking the list only once
  2380. Revision 1.62 2002/11/18 17:31:55 peter
  2381. * pass proccalloption to ret_in_xxx and push_xxx functions
  2382. Revision 1.61 2002/11/17 17:49:08 mazen
  2383. + return_result_reg and FUNCTION_RESULT_REG are now used, in all plateforms, to pass functions result between called function and its caller. See the explanation of each one
  2384. Revision 1.60 2002/11/17 16:31:56 carl
  2385. * memory optimization (3-4%) : cleanup of tai fields,
  2386. cleanup of tdef and tsym fields.
  2387. * make it work for m68k
  2388. Revision 1.59 2002/11/15 01:58:51 peter
  2389. * merged changes from 1.0.7 up to 04-11
  2390. - -V option for generating bug report tracing
  2391. - more tracing for option parsing
  2392. - errors for cdecl and high()
  2393. - win32 import stabs
  2394. - win32 records<=8 are returned in eax:edx (turned off by default)
  2395. - heaptrc update
  2396. - more info for temp management in .s file with EXTDEBUG
  2397. Revision 1.58 2002/11/10 19:07:45 mazen
  2398. * SPARC calling mechanism almost OK (as in GCC./mppcsparc )
  2399. Revision 1.57 2002/11/03 20:22:40 mazen
  2400. * parameter handling updated
  2401. Revision 1.56 2002/10/16 19:01:43 peter
  2402. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  2403. implicit exception frames for procedures with initialized variables
  2404. and for constructors. The default is on for compatibility
  2405. Revision 1.55 2002/10/14 19:42:33 peter
  2406. * only use init tables for threadvars
  2407. Revision 1.54 2002/10/06 19:41:30 peter
  2408. * Add finalization of typed consts
  2409. * Finalization of globals in the main program
  2410. Revision 1.53 2002/10/05 15:18:42 carl
  2411. * fix heap leaks
  2412. Revision 1.52 2002/09/30 07:00:46 florian
  2413. * fixes to common code to get the alpha compiler compiled applied
  2414. Revision 1.51 2002/09/22 14:02:35 carl
  2415. * stack checking cannot be called before system unit is initialized
  2416. * MC68020 define
  2417. Revision 1.50 2002/09/17 18:54:03 jonas
  2418. * a_load_reg_reg() now has two size parameters: source and dest. This
  2419. allows some optimizations on architectures that don't encode the
  2420. register size in the register name.
  2421. Revision 1.49 2002/09/10 21:48:30 florian
  2422. * improved handling of procedures with register calling conventions
  2423. Revision 1.48 2002/09/07 15:25:03 peter
  2424. * old logs removed and tabs fixed
  2425. Revision 1.47 2002/09/02 18:44:48 peter
  2426. * fixed (not) pushing of empty parameters
  2427. * fixed implicit initialization/finalization generation
  2428. * fixed/optimized local copy of value arguments init/final
  2429. Revision 1.46 2002/09/01 19:27:34 peter
  2430. * use index register when available for generating a reference with
  2431. only a signle register. Using the base register could possibly
  2432. destroy the framepointer
  2433. Revision 1.45 2002/09/01 18:50:20 peter
  2434. * fixed maybe_save that did not support a reference with only
  2435. a index register. It now also updates the location with the new
  2436. base register only
  2437. Revision 1.44 2002/09/01 14:42:41 peter
  2438. * removevaluepara added to fix the stackpointer so restoring of
  2439. saved registers works
  2440. Revision 1.43 2002/08/25 19:25:18 peter
  2441. * sym.insert_in_data removed
  2442. * symtable.insertvardata/insertconstdata added
  2443. * removed insert_in_data call from symtable.insert, it needs to be
  2444. called separatly. This allows to deref the address calculation
  2445. * procedures now calculate the parast addresses after the procedure
  2446. directives are parsed. This fixes the cdecl parast problem
  2447. * push_addr_param has an extra argument that specifies if cdecl is used
  2448. or not
  2449. Revision 1.42 2002/08/24 18:38:26 peter
  2450. * really use tt_noreuse for exception frame buffers
  2451. Revision 1.41 2002/08/23 16:14:49 peter
  2452. * tempgen cleanup
  2453. * tt_noreuse temp type added that will be used in genentrycode
  2454. Revision 1.40 2002/08/18 10:42:37 florian
  2455. * remaining assembler writer bugs fixed, the errors in the
  2456. system unit are inline assembler problems
  2457. Revision 1.39 2002/08/17 09:23:36 florian
  2458. * first part of procinfo rewrite
  2459. Revision 1.38 2002/08/16 14:24:57 carl
  2460. * issameref() to test if two references are the same (then emit no opcodes)
  2461. + ret_in_reg to replace ret_in_acc
  2462. (fix some register allocation bugs at the same time)
  2463. + save_std_register now has an extra parameter which is the
  2464. usedinproc registers
  2465. Revision 1.37 2002/08/15 15:15:55 carl
  2466. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  2467. * more generic nodes for maths
  2468. * several fixes for better m68k support
  2469. Revision 1.36 2002/08/14 19:25:09 carl
  2470. * fix Florian's last commit for m68k compilation
  2471. Revision 1.35 2002/08/13 21:40:56 florian
  2472. * more fixes for ppc calling conventions
  2473. Revision 1.34 2002/08/12 15:08:39 carl
  2474. + stab register indexes for powerpc (moved from gdb to cpubase)
  2475. + tprocessor enumeration moved to cpuinfo
  2476. + linker in target_info is now a class
  2477. * many many updates for m68k (will soon start to compile)
  2478. - removed some ifdef or correct them for correct cpu
  2479. Revision 1.33 2002/08/11 14:32:27 peter
  2480. * renamed current_library to objectlibrary
  2481. Revision 1.32 2002/08/11 13:24:12 peter
  2482. * saving of asmsymbols in ppu supported
  2483. * asmsymbollist global is removed and moved into a new class
  2484. tasmlibrarydata that will hold the info of a .a file which
  2485. corresponds with a single module. Added librarydata to tmodule
  2486. to keep the library info stored for the module. In the future the
  2487. objectfiles will also be stored to the tasmlibrarydata class
  2488. * all getlabel/newasmsymbol and friends are moved to the new class
  2489. Revision 1.31 2002/08/09 19:16:57 carl
  2490. * stack allocation is now done separately (at the end) of genentrycode
  2491. so temps. can be allocated before.
  2492. * fix generic exception handling
  2493. Revision 1.30 2002/08/06 20:55:21 florian
  2494. * first part of ppc calling conventions fix
  2495. Revision 1.29 2002/08/04 19:09:22 carl
  2496. + added generic exception support (still does not work!)
  2497. + more documentation
  2498. Revision 1.28 2002/07/29 21:23:42 florian
  2499. * more fixes for the ppc
  2500. + wrappers for the tcnvnode.first_* stuff introduced
  2501. }