ncgutil.pas 109 KB

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