ncgutil.pas 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295
  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,
  25. aasmbase,aasmtai,aasmcpu,
  26. cginfo,symbase,symdef,symtype,
  27. {$ifndef cpu64bit}
  28. cg64f32,
  29. {$endif cpu64bit}
  30. rgobj;
  31. type
  32. tloadregvars = (lr_dont_load_regvars, lr_load_regvars);
  33. tmaybesave = record
  34. saved : boolean;
  35. ref : treference;
  36. end;
  37. procedure firstcomplex(p : tbinarynode);
  38. procedure maketojumpbool(list:TAAsmoutput; p : tnode; loadregvars: tloadregvars);
  39. procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsupregset);
  40. procedure location_force_reg(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  41. procedure location_force_mem(list: TAAsmoutput;var l:tlocation);
  42. {$ifndef newra}
  43. procedure maybe_save(list:taasmoutput;needed:integer;var l:tlocation;var s:tmaybesave);
  44. procedure maybe_restore(list:taasmoutput;var l:tlocation;const s:tmaybesave);
  45. {$endif}
  46. function maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
  47. procedure push_value_para(list:taasmoutput;p:tnode;calloption:tproccalloption;
  48. para_offset:longint;alignment : longint;
  49. const locpara : tparalocation);
  50. procedure genentrycode(list : TAAsmoutput;stackframe:longint;inlined : boolean);
  51. procedure genexitcode(list : TAAsmoutput;inlined:boolean);
  52. procedure geninlineentrycode(list : TAAsmoutput;stackframe:longint);
  53. procedure geninlineexitcode(list : TAAsmoutput;inlined:boolean);
  54. {#
  55. Allocate the buffers for exception management and setjmp environment.
  56. Return a pointer to these buffers, send them to the utility routine
  57. so they are registered, and then call setjmp.
  58. Then compare the result of setjmp with 0, and if not equal
  59. to zero, then jump to exceptlabel.
  60. Also store the result of setjmp to a temporary space by calling g_save_exception_reason
  61. It is to note that this routine may be called *after* the stackframe of a
  62. routine has been called, therefore on machines where the stack cannot
  63. be modified, all temps should be allocated on the heap instead of the
  64. stack.
  65. }
  66. procedure new_exception(list : taasmoutput;const jmpbuf,envbuf, href : treference;
  67. a : aword; exceptlabel : tasmlabel);
  68. procedure free_exception(list : taasmoutput;const jmpbuf, envbuf, href : treference;
  69. a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
  70. implementation
  71. uses
  72. {$ifdef Delphi}
  73. Sysutils,
  74. {$else}
  75. strings,
  76. {$endif}
  77. cutils,cclasses,
  78. globals,systems,verbose,
  79. symconst,symsym,symtable,defutil,
  80. paramgr,fmodule,
  81. cgbase,regvars,
  82. {$ifdef GDB}
  83. gdb,
  84. {$endif GDB}
  85. ncon,
  86. tgobj,cgobj;
  87. const
  88. { Please leave this here, this module should NOT use
  89. exprasmlist, the lists are always passed as arguments.
  90. Declaring it as string here results in an error when compiling (PFV) }
  91. exprasmlist = 'error';
  92. {*****************************************************************************
  93. Misc Helpers
  94. *****************************************************************************}
  95. { DO NOT RELY on the fact that the tnode is not yet swaped
  96. because of inlining code PM }
  97. procedure firstcomplex(p : tbinarynode);
  98. var
  99. hp : tnode;
  100. begin
  101. { always calculate boolean AND and OR from left to right }
  102. if (p.nodetype in [orn,andn]) and
  103. is_boolean(p.left.resulttype.def) then
  104. begin
  105. if nf_swaped in p.flags then
  106. internalerror(234234);
  107. end
  108. else
  109. if (
  110. (p.location.loc=LOC_FPUREGISTER) and
  111. (p.right.registersfpu > p.left.registersfpu)
  112. ) or
  113. (
  114. (
  115. (
  116. ((p.left.registersfpu = 0) and (p.right.registersfpu = 0)) or
  117. (p.location.loc<>LOC_FPUREGISTER)
  118. ) and
  119. (p.left.registers32<p.right.registers32)
  120. ) and
  121. { the following check is appropriate, because all }
  122. { 4 registers are rarely used and it is thereby }
  123. { achieved that the extra code is being dropped }
  124. { by exchanging not commutative operators }
  125. (p.right.registers32<=c_countusableregsint)
  126. ) then
  127. begin
  128. hp:=p.left;
  129. p.left:=p.right;
  130. p.right:=hp;
  131. if nf_swaped in p.flags then
  132. exclude(p.flags,nf_swaped)
  133. else
  134. include(p.flags,nf_swaped);
  135. end;
  136. end;
  137. procedure maketojumpbool(list:TAAsmoutput; p : tnode; loadregvars: tloadregvars);
  138. {
  139. produces jumps to true respectively false labels using boolean expressions
  140. depending on whether the loading of regvars is currently being
  141. synchronized manually (such as in an if-node) or automatically (most of
  142. the other cases where this procedure is called), loadregvars can be
  143. "lr_load_regvars" or "lr_dont_load_regvars"
  144. }
  145. var
  146. opsize : tcgsize;
  147. storepos : tfileposinfo;
  148. begin
  149. if nf_error in p.flags then
  150. exit;
  151. storepos:=aktfilepos;
  152. aktfilepos:=p.fileinfo;
  153. if is_boolean(p.resulttype.def) then
  154. begin
  155. if loadregvars = lr_load_regvars then
  156. load_all_regvars(list);
  157. if is_constboolnode(p) then
  158. begin
  159. if tordconstnode(p).value<>0 then
  160. cg.a_jmp_always(list,truelabel)
  161. else
  162. cg.a_jmp_always(list,falselabel)
  163. end
  164. else
  165. begin
  166. opsize:=def_cgsize(p.resulttype.def);
  167. case p.location.loc of
  168. LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
  169. begin
  170. if (p.location.loc = LOC_CREGISTER) then
  171. load_regvar_reg(list,p.location.register);
  172. cg.a_cmp_const_loc_label(list,opsize,OC_NE,
  173. 0,p.location,truelabel);
  174. { !!! should happen right after cmp (JM) }
  175. location_release(list,p.location);
  176. cg.a_jmp_always(list,falselabel);
  177. end;
  178. {$ifdef cpuflags}
  179. LOC_FLAGS :
  180. begin
  181. cg.a_jmp_flags(list,p.location.resflags,
  182. truelabel);
  183. cg.a_jmp_always(list,falselabel);
  184. end;
  185. {$endif cpuflags}
  186. end;
  187. end;
  188. end
  189. else
  190. internalerror(200112305);
  191. aktfilepos:=storepos;
  192. end;
  193. procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsupregset);
  194. begin
  195. case t.loc of
  196. LOC_REGISTER:
  197. begin
  198. { can't be a regvar, since it would be LOC_CREGISTER then }
  199. if t.register.enum<>R_INTREGISTER then
  200. internalerror(200301154);
  201. if t.registerhigh.enum<>R_INTREGISTER then
  202. internalerror(200301154);
  203. exclude(regs,t.register.number shr 8);
  204. if t.registerhigh.enum <> R_NO then
  205. exclude(regs,t.registerhigh.number shr 8);
  206. end;
  207. LOC_CREFERENCE,LOC_REFERENCE:
  208. begin
  209. if t.reference.base.enum<>R_INTREGISTER then
  210. internalerror(200301154);
  211. if t.reference.index.enum<>R_INTREGISTER then
  212. internalerror(200301154);
  213. if not(cs_regalloc in aktglobalswitches) or
  214. ((t.reference.base.number shr 8) in rg.usableregsint) then
  215. exclude(regs,t.reference.base.number shr 8);
  216. if not(cs_regalloc in aktglobalswitches) or
  217. ((t.reference.index.number shr 8) in rg.usableregsint) then
  218. exclude(regs,t.reference.index.number shr 8);
  219. end;
  220. end;
  221. end;
  222. {*****************************************************************************
  223. EXCEPTION MANAGEMENT
  224. *****************************************************************************}
  225. procedure new_exception(list : taasmoutput;const jmpbuf,envbuf, href : treference;
  226. a : aword; exceptlabel : tasmlabel);
  227. var r:Tregister;
  228. begin
  229. cg.a_paramaddr_ref(list,envbuf,paramanager.getintparaloc(3));
  230. cg.a_paramaddr_ref(list,jmpbuf,paramanager.getintparaloc(2));
  231. { push type of exceptionframe }
  232. cg.a_param_const(list,OS_S32,1,paramanager.getintparaloc(1));
  233. cg.a_call_name(list,'FPC_PUSHEXCEPTADDR');
  234. r.enum:=R_INTREGISTER;
  235. r.number:=NR_FUNCTION_RESULT_REG;
  236. cg.a_param_reg(list,OS_ADDR,r,paramanager.getintparaloc(1));
  237. cg.a_call_name(list,'FPC_SETJMP');
  238. cg.g_exception_reason_save(list, href);
  239. cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,r,exceptlabel);
  240. end;
  241. procedure free_exception(list : taasmoutput;const jmpbuf, envbuf, href : treference;
  242. a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
  243. var r:Tregister;
  244. begin
  245. cg.a_call_name(list,'FPC_POPADDRSTACK');
  246. if not onlyfree then
  247. begin
  248. cg.g_exception_reason_load(list, href);
  249. r.enum:=R_INTREGISTER;
  250. r.number:=NR_FUNCTION_RESULT_REG;
  251. cg.a_cmp_const_reg_label(list,OS_S32,OC_EQ,a,r,endexceptlabel);
  252. end;
  253. end;
  254. {*****************************************************************************
  255. TLocation
  256. *****************************************************************************}
  257. {$ifndef cpu64bit}
  258. { 32-bit version }
  259. procedure location_force(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  260. var
  261. hregister,
  262. hregisterhi : tregister;
  263. hreg64 : tregister64;
  264. hl : tasmlabel;
  265. begin
  266. { handle transformations to 64bit separate }
  267. if dst_size in [OS_64,OS_S64] then
  268. begin
  269. if not (l.size in [OS_64,OS_S64]) then
  270. begin
  271. { load a smaller size to OS_64 }
  272. if l.loc=LOC_REGISTER then
  273. begin
  274. hregister.enum:=R_INTREGISTER;
  275. hregister.number:=(l.registerlow.number and not $ff) or R_SUBWHOLE;
  276. cg.a_load_reg_reg(list,l.size,OS_32,l.registerlow,hregister);
  277. end
  278. else
  279. hregister:=rg.getregisterint(list,OS_INT);
  280. { load value in low register }
  281. case l.loc of
  282. LOC_FLAGS :
  283. cg.g_flags2reg(list,OS_INT,l.resflags,hregister);
  284. LOC_JUMP :
  285. begin
  286. cg.a_label(list,truelabel);
  287. cg.a_load_const_reg(list,OS_INT,1,hregister);
  288. objectlibrary.getlabel(hl);
  289. cg.a_jmp_always(list,hl);
  290. cg.a_label(list,falselabel);
  291. cg.a_load_const_reg(list,OS_INT,0,hregister);
  292. cg.a_label(list,hl);
  293. end;
  294. else
  295. cg.a_load_loc_reg(list,OS_INT,l,hregister);
  296. end;
  297. { reset hi part, take care of the signed bit of the current value }
  298. hregisterhi:=rg.getregisterint(list,OS_INT);
  299. if (dst_size=OS_S64) and
  300. (l.size in [OS_S8,OS_S16,OS_S32]) then
  301. begin
  302. if l.loc=LOC_CONSTANT then
  303. begin
  304. if (longint(l.value)<0) then
  305. cg.a_load_const_reg(list,OS_32,$ffffffff,hregisterhi)
  306. else
  307. cg.a_load_const_reg(list,OS_32,0,hregisterhi);
  308. end
  309. else
  310. begin
  311. cg.a_op_const_reg_reg(list,OP_SAR,OS_32,31,hregister,
  312. hregisterhi);
  313. end;
  314. end
  315. else
  316. cg.a_load_const_reg(list,OS_32,0,hregisterhi);
  317. location_reset(l,LOC_REGISTER,dst_size);
  318. l.registerlow:=hregister;
  319. l.registerhigh:=hregisterhi;
  320. end
  321. else
  322. begin
  323. { 64bit to 64bit }
  324. if (l.loc=LOC_REGISTER) or
  325. ((l.loc=LOC_CREGISTER) and maybeconst) then
  326. begin
  327. hregister:=l.registerlow;
  328. hregisterhi:=l.registerhigh;
  329. end
  330. else
  331. begin
  332. hregister:=rg.getregisterint(list,OS_INT);
  333. hregisterhi:=rg.getregisterint(list,OS_INT);
  334. end;
  335. hreg64.reglo:=hregister;
  336. hreg64.reghi:=hregisterhi;
  337. { load value in new register }
  338. cg64.a_load64_loc_reg(list,l,hreg64);
  339. location_reset(l,LOC_REGISTER,dst_size);
  340. l.registerlow:=hregister;
  341. l.registerhigh:=hregisterhi;
  342. end;
  343. end
  344. else
  345. begin
  346. { transformations to 32bit or smaller }
  347. if l.loc=LOC_REGISTER then
  348. begin
  349. { if the previous was 64bit release the high register }
  350. if l.size in [OS_64,OS_S64] then
  351. begin
  352. rg.ungetregisterint(list,l.registerhigh);
  353. l.registerhigh.enum:=R_NO;
  354. end;
  355. hregister:=l.register;
  356. end
  357. else
  358. begin
  359. { get new register }
  360. if (l.loc=LOC_CREGISTER) and
  361. maybeconst and
  362. (TCGSize2Size[dst_size]=TCGSize2Size[l.size]) then
  363. hregister:=l.register
  364. else
  365. begin
  366. hregister.enum:=R_INTREGISTER;
  367. hregister.number:=NR_NO;
  368. end;
  369. end;
  370. if hregister.enum<>R_INTREGISTER then
  371. internalerror(200302022);
  372. { need to load into address register? }
  373. if (dst_size=OS_ADDR) then
  374. begin
  375. if (hregister.number=NR_NO) or
  376. (not rg.isaddressregister(hregister)) then
  377. hregister:=rg.getaddressregister(list);
  378. end
  379. else
  380. begin
  381. if (hregister.number=NR_NO) {or
  382. rg.isaddressregister(hregister)} then
  383. hregister:=rg.getregisterint(list,dst_size);
  384. end;
  385. hregister.number:=(hregister.number and not $ff) or cgsize2subreg(dst_size);
  386. { load value in new register }
  387. case l.loc of
  388. LOC_FLAGS :
  389. cg.g_flags2reg(list,dst_size,l.resflags,hregister);
  390. LOC_JUMP :
  391. begin
  392. cg.a_label(list,truelabel);
  393. cg.a_load_const_reg(list,dst_size,1,hregister);
  394. objectlibrary.getlabel(hl);
  395. cg.a_jmp_always(list,hl);
  396. cg.a_label(list,falselabel);
  397. cg.a_load_const_reg(list,dst_size,0,hregister);
  398. cg.a_label(list,hl);
  399. end;
  400. else
  401. begin
  402. { load_loc_reg can only handle size >= l.size, when the
  403. new size is smaller then we need to adjust the size
  404. of the orignal and maybe recalculate l.register for i386 }
  405. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  406. begin
  407. if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  408. l.register.number:=(l.register.number and not $ff) or cgsize2subreg(dst_size);
  409. { for big endian systems, the reference's offset must }
  410. { be increased in this case, since they have the }
  411. { MSB first in memory and e.g. byte(word_var) should }
  412. { return the second byte in this case (JM) }
  413. if (target_info.endian = ENDIAN_BIG) and
  414. (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  415. inc(l.reference.offset,TCGSize2Size[l.size]-TCGSize2Size[dst_size]);
  416. {$ifdef i386}
  417. l.size:=dst_size;
  418. {$endif i386}
  419. end;
  420. cg.a_load_loc_reg(list,dst_size,l,hregister);
  421. {$ifndef i386}
  422. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  423. l.size:=dst_size;
  424. {$endif not i386}
  425. { Release old register when the superregister is changed }
  426. if (l.loc=LOC_REGISTER) and
  427. (l.register.number shr 8<>hregister.number shr 8) then
  428. begin
  429. if rg.isaddressregister(l.register) then
  430. rg.ungetaddressregister(list,l.register)
  431. else
  432. rg.ungetregisterint(list,l.register);
  433. end;
  434. end;
  435. end;
  436. if (l.loc <> LOC_CREGISTER) or
  437. not maybeconst then
  438. location_reset(l,LOC_REGISTER,dst_size)
  439. else
  440. location_reset(l,LOC_CREGISTER,dst_size);
  441. l.register:=hregister;
  442. end;
  443. end;
  444. {$else cpu64bit}
  445. { 64-bit version }
  446. procedure location_force(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  447. var
  448. hregister : tregister;
  449. hl : tasmlabel;
  450. begin
  451. { handle transformations to 64bit separate }
  452. if dst_size in [OS_64,OS_S64] then
  453. begin
  454. { load a smaller size to OS_64 }
  455. if l.loc=LOC_REGISTER then
  456. hregister:=rg.makeregsize(l.register,OS_INT)
  457. else
  458. hregister:=rg.getregisterint(list,OS_INT);
  459. { load value in low register }
  460. case l.loc of
  461. {$ifdef cpuflags}
  462. LOC_FLAGS :
  463. cg.g_flags2reg(list,OS_INT,l.resflags,hregister);
  464. {$endif cpuflags}
  465. LOC_JUMP :
  466. begin
  467. cg.a_label(list,truelabel);
  468. cg.a_load_const_reg(list,OS_INT,1,hregister);
  469. objectlibrary.getlabel(hl);
  470. cg.a_jmp_always(list,hl);
  471. cg.a_label(list,falselabel);
  472. cg.a_load_const_reg(list,OS_INT,0,hregister);
  473. cg.a_label(list,hl);
  474. end;
  475. else
  476. cg.a_load_loc_reg(list,OS_INT,l,hregister);
  477. end;
  478. location_reset(l,LOC_REGISTER,dst_size);
  479. l.register:=hregister;
  480. end
  481. else
  482. begin
  483. { transformations to 32bit or smaller }
  484. if l.loc=LOC_REGISTER then
  485. begin
  486. hregister:=l.register;
  487. end
  488. else
  489. begin
  490. { get new register }
  491. if (l.loc=LOC_CREGISTER) and
  492. maybeconst and
  493. (TCGSize2Size[dst_size]=TCGSize2Size[l.size]) then
  494. hregister:=l.register
  495. else
  496. hregister:=rg.getregisterint(list,OS_INT);
  497. end;
  498. hregister:=rg.makeregsize(hregister,dst_size);
  499. { load value in new register }
  500. case l.loc of
  501. {$ifdef cpuflags}
  502. LOC_FLAGS :
  503. cg.g_flags2reg(list,dst_size,l.resflags,hregister);
  504. {$endif cpuflags}
  505. LOC_JUMP :
  506. begin
  507. cg.a_label(list,truelabel);
  508. cg.a_load_const_reg(list,dst_size,1,hregister);
  509. objectlibrary.getlabel(hl);
  510. cg.a_jmp_always(list,hl);
  511. cg.a_label(list,falselabel);
  512. cg.a_load_const_reg(list,dst_size,0,hregister);
  513. cg.a_label(list,hl);
  514. end;
  515. else
  516. begin
  517. { load_loc_reg can only handle size >= l.size, when the
  518. new size is smaller then we need to adjust the size
  519. of the orignal and maybe recalculate l.register for i386 }
  520. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  521. begin
  522. if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  523. l.register:=rg.makeregsize(l.register,dst_size);
  524. { for big endian systems, the reference's offset must }
  525. { be increased in this case, since they have the }
  526. { MSB first in memory and e.g. byte(word_var) should }
  527. { return the second byte in this case (JM) }
  528. if (target_info.endian = ENDIAN_BIG) and
  529. (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  530. inc(l.reference.offset,TCGSize2Size[l.size]-TCGSize2Size[dst_size]);
  531. {$ifdef i386}
  532. l.size:=dst_size;
  533. {$endif i386}
  534. end;
  535. cg.a_load_loc_reg(list,dst_size,l,hregister);
  536. {$ifndef i386}
  537. if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
  538. l.size:=dst_size;
  539. {$endif not i386}
  540. end;
  541. end;
  542. location_reset(l,LOC_REGISTER,dst_size);
  543. l.register:=hregister;
  544. end;
  545. end;
  546. {$endif cpu64bit}
  547. procedure location_force_reg(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
  548. begin
  549. { release previous location before demanding a new register }
  550. if (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  551. begin
  552. location_freetemp(list,l);
  553. location_release(list,l);
  554. end;
  555. location_force(list, l, dst_size, maybeconst)
  556. end;
  557. procedure location_force_mem(list: TAAsmoutput;var l:tlocation);
  558. var
  559. r : treference;
  560. begin
  561. case l.loc of
  562. LOC_FPUREGISTER,
  563. LOC_CFPUREGISTER :
  564. begin
  565. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
  566. cg.a_loadfpu_reg_ref(list,l.size,l.register,r);
  567. location_release(list,l);
  568. location_reset(l,LOC_REFERENCE,l.size);
  569. l.reference:=r;
  570. end;
  571. LOC_CONSTANT,
  572. LOC_REGISTER,
  573. LOC_CREGISTER :
  574. begin
  575. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
  576. if l.size in [OS_64,OS_S64] then
  577. cg64.a_load64_loc_ref(list,l,r)
  578. else
  579. cg.a_load_loc_ref(list,l,r);
  580. location_release(list,l);
  581. location_reset(l,LOC_REFERENCE,l.size);
  582. l.reference:=r;
  583. end;
  584. LOC_CREFERENCE,
  585. LOC_REFERENCE : ;
  586. else
  587. internalerror(200203219);
  588. end;
  589. end;
  590. {*****************************************************************************
  591. Maybe_Save
  592. *****************************************************************************}
  593. {$ifndef newra}
  594. procedure maybe_save(list:taasmoutput;needed:integer;var l:tlocation;var s:tmaybesave);
  595. begin
  596. s.saved:=false;
  597. if l.loc=LOC_CREGISTER then
  598. begin
  599. s.saved:=true;
  600. exit;
  601. end;
  602. if needed>rg.countunusedregsint then
  603. begin
  604. case l.loc of
  605. LOC_REGISTER :
  606. begin
  607. {$ifndef cpu64bit}
  608. if l.size in [OS_64,OS_S64] then
  609. begin
  610. tg.GetTemp(list,8,tt_normal,s.ref);
  611. cg64.a_load64_reg_ref(list,joinreg64(l.registerlow,l.registerhigh),s.ref);
  612. end
  613. else
  614. {$endif cpu64bit}
  615. begin
  616. tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,s.ref);
  617. cg.a_load_reg_ref(list,l.size,l.register,s.ref);
  618. end;
  619. location_release(list,l);
  620. s.saved:=true;
  621. end;
  622. LOC_REFERENCE,
  623. LOC_CREFERENCE :
  624. begin
  625. if l.reference.base.enum<>R_INTREGISTER then
  626. internalerror(200302101);
  627. if l.reference.index.enum<>R_INTREGISTER then
  628. internalerror(200302101);
  629. if ((l.reference.base.number<>NR_NO) or
  630. (l.reference.index.number<>NR_NO)) then
  631. begin
  632. { load address into a single base register }
  633. if l.reference.index.number<>NR_NO then
  634. begin
  635. cg.a_loadaddr_ref_reg(list,l.reference,l.reference.index);
  636. rg.ungetregisterint(list,l.reference.base);
  637. reference_reset_base(l.reference,l.reference.index,0);
  638. end
  639. else
  640. begin
  641. cg.a_loadaddr_ref_reg(list,l.reference,l.reference.base);
  642. rg.ungetregisterint(list,l.reference.index);
  643. reference_reset_base(l.reference,l.reference.base,0);
  644. end;
  645. { save base register }
  646. tg.GetTemp(list,TCGSize2Size[OS_ADDR],tt_normal,s.ref);
  647. cg.a_load_reg_ref(list,OS_ADDR,l.reference.base,s.ref);
  648. { release }
  649. location_release(list,l);
  650. s.saved:=true;
  651. end;
  652. end;
  653. end;
  654. end;
  655. end;
  656. procedure maybe_restore(list:taasmoutput;var l:tlocation;const s:tmaybesave);
  657. begin
  658. if not s.saved then
  659. exit;
  660. if l.loc=LOC_CREGISTER then
  661. begin
  662. load_regvar_reg(list,l.register);
  663. exit;
  664. end;
  665. case l.loc of
  666. LOC_REGISTER :
  667. begin
  668. {$ifndef cpu64bit}
  669. if l.size in [OS_64,OS_S64] then
  670. begin
  671. l.registerlow:=rg.getregisterint(list,OS_INT);
  672. l.registerhigh:=rg.getregisterint(list,OS_INT);
  673. cg64.a_load64_ref_reg(list,s.ref,joinreg64(l.registerlow,l.registerhigh));
  674. end
  675. else
  676. {$endif cpu64bit}
  677. begin
  678. l.register:=rg.getregisterint(list,OS_INT);
  679. cg.a_load_ref_reg(list,OS_INT,s.ref,l.register);
  680. end;
  681. end;
  682. LOC_CREFERENCE,
  683. LOC_REFERENCE :
  684. begin
  685. reference_reset(l.reference);
  686. l.reference.base:=rg.getaddressregister(list);
  687. cg.a_load_ref_reg(list,OS_ADDR,s.ref,l.reference.base);
  688. end;
  689. end;
  690. tg.ungetiftemp(list,s.ref);
  691. end;
  692. {$endif newra}
  693. function maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
  694. begin
  695. if (needed>=maxfpuregs) and
  696. (l.loc = LOC_FPUREGISTER) then
  697. begin
  698. location_force_mem(list,l);
  699. maybe_pushfpu:=true;
  700. end
  701. else
  702. maybe_pushfpu:=false;
  703. end;
  704. {*****************************************************************************
  705. Push Value Para
  706. *****************************************************************************}
  707. procedure push_value_para(list:taasmoutput;p:tnode;calloption:tproccalloption;
  708. para_offset:longint;alignment : longint;
  709. const locpara : tparalocation);
  710. var
  711. tempreference : treference;
  712. href : treference;
  713. hreg : tregister;
  714. sizetopush,
  715. size : longint;
  716. cgsize : tcgsize;
  717. r:Tregister;
  718. begin
  719. { we've nothing to push when the size of the parameter is 0 }
  720. if p.resulttype.def.size=0 then
  721. exit;
  722. { Move flags and jump in register to make it less complex }
  723. if p.location.loc in [LOC_FLAGS,LOC_JUMP] then
  724. location_force_reg(list,p.location,def_cgsize(p.resulttype.def),false);
  725. { Handle Floating point types differently }
  726. if p.resulttype.def.deftype=floatdef then
  727. begin
  728. case p.location.loc of
  729. LOC_FPUREGISTER,
  730. LOC_CFPUREGISTER:
  731. begin
  732. {$ifdef i386}
  733. size:=align(tfloatdef(p.resulttype.def).size,alignment);
  734. inc(pushedparasize,size);
  735. if calloption<>pocall_inline then
  736. cg.g_stackpointer_alloc(list,size);
  737. {$ifdef GDB}
  738. if (cs_debuginfo in aktmoduleswitches) and
  739. (list.first=list.last) then
  740. list.concat(Tai_force_line.Create);
  741. {$endif GDB}
  742. { this is the easiest case for inlined !! }
  743. r.enum:=R_INTREGISTER;
  744. r.number:=NR_STACK_POINTER_REG;
  745. if calloption=pocall_inline then
  746. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize)
  747. else
  748. reference_reset_base(href,r,0);
  749. cg.a_loadfpu_reg_ref(list,
  750. def_cgsize(p.resulttype.def),p.location.register,href);
  751. {$else i386}
  752. cg.a_paramfpu_reg(list,def_cgsize(p.resulttype.def),p.location.register,locpara);
  753. {$endif i386}
  754. end;
  755. LOC_REFERENCE,
  756. LOC_CREFERENCE :
  757. begin
  758. if locpara.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER] then
  759. cg.a_paramfpu_ref(list,def_cgsize(p.resulttype.def),p.location.reference,locpara)
  760. else
  761. begin
  762. sizetopush:=align(p.resulttype.def.size,alignment);
  763. tempreference:=p.location.reference;
  764. inc(tempreference.offset,sizetopush);
  765. while (sizetopush>0) do
  766. begin
  767. if sizetopush>=4 then
  768. begin
  769. cgsize:=OS_32;
  770. inc(pushedparasize,4);
  771. dec(tempreference.offset,4);
  772. dec(sizetopush,4);
  773. end
  774. else
  775. begin
  776. cgsize:=OS_16;
  777. inc(pushedparasize,2);
  778. dec(tempreference.offset,2);
  779. dec(sizetopush,2);
  780. end;
  781. if calloption=pocall_inline then
  782. begin
  783. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  784. cg.a_load_ref_ref(list,cgsize,tempreference,href);
  785. end
  786. else
  787. cg.a_param_ref(list,cgsize,tempreference,locpara);
  788. end;
  789. end;
  790. end;
  791. else
  792. internalerror(200204243);
  793. end;
  794. location_release(list,p.location);
  795. end
  796. else
  797. begin
  798. { copy the value on the stack or use normal parameter push? }
  799. if paramanager.copy_value_on_stack(p.resulttype.def,calloption) then
  800. begin
  801. {$ifdef i386}
  802. if not (p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  803. internalerror(200204241);
  804. { push on stack }
  805. size:=align(p.resulttype.def.size,alignment);
  806. inc(pushedparasize,size);
  807. cg.g_stackpointer_alloc(list,size);
  808. r.enum:=R_INTREGISTER;
  809. r.number:=NR_STACK_POINTER_REG;
  810. reference_reset_base(href,r,0);
  811. cg.g_concatcopy(list,p.location.reference,href,size,false,false);
  812. {$else i386}
  813. cg.a_param_copy_ref(list,p.resulttype.def.size,p.location.reference,locpara);
  814. {$endif i386}
  815. end
  816. else
  817. begin
  818. case p.location.loc of
  819. LOC_CONSTANT,
  820. LOC_REGISTER,
  821. LOC_CREGISTER,
  822. LOC_REFERENCE,
  823. LOC_CREFERENCE :
  824. begin
  825. cgsize:=def_cgsize(p.resulttype.def);
  826. if cgsize in [OS_64,OS_S64] then
  827. begin
  828. inc(pushedparasize,8);
  829. if calloption=pocall_inline then
  830. begin
  831. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  832. if p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  833. begin
  834. size:=align(p.resulttype.def.size,alignment);
  835. cg.g_concatcopy(list,p.location.reference,href,size,false,false)
  836. end
  837. else
  838. cg64.a_load64_loc_ref(list,p.location,href);
  839. end
  840. else
  841. cg64.a_param64_loc(list,p.location,locpara);
  842. end
  843. else
  844. begin
  845. case cgsize of
  846. OS_8,OS_S8 :
  847. begin
  848. if alignment=4 then
  849. cgsize:=OS_32
  850. else
  851. cgsize:=OS_16;
  852. end;
  853. OS_16,OS_S16 :
  854. begin
  855. if alignment=4 then
  856. cgsize:=OS_32;
  857. end;
  858. end;
  859. { update register to use to match alignment }
  860. if p.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
  861. begin
  862. if p.location.register.enum<>R_INTREGISTER then
  863. internalerror(200302024);
  864. hreg:=p.location.register;
  865. p.location.register.number:=(p.location.register.number and not $ff) or cgsize2subreg(cgsize);
  866. end;
  867. inc(pushedparasize,alignment);
  868. if calloption=pocall_inline then
  869. begin
  870. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  871. if p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  872. begin
  873. size:=align(p.resulttype.def.size,alignment);
  874. cg.g_concatcopy(list,p.location.reference,href,size,false,false)
  875. end
  876. else
  877. cg.a_load_loc_ref(list,p.location,href);
  878. end
  879. else
  880. cg.a_param_loc(list,p.location,locpara);
  881. { restore old register }
  882. if p.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
  883. p.location.register:=hreg;
  884. end;
  885. location_release(list,p.location);
  886. end;
  887. {$ifdef SUPPORT_MMX}
  888. LOC_MMXREGISTER,
  889. LOC_CMMXREGISTER:
  890. begin
  891. inc(pushedparasize,8);
  892. if calloption=pocall_inline then
  893. begin
  894. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  895. cg.a_loadmm_reg_ref(list,p.location.register,href);
  896. end
  897. else
  898. cg.a_parammm_reg(list,p.location.register);
  899. end;
  900. {$endif SUPPORT_MMX}
  901. else
  902. internalerror(200204241);
  903. end;
  904. end;
  905. end;
  906. end;
  907. {****************************************************************************
  908. Entry/Exit Code
  909. ****************************************************************************}
  910. procedure copyvalueparas(p : tnamedindexitem;arg:pointer);
  911. var
  912. href1,href2 : treference;
  913. list : taasmoutput;
  914. begin
  915. list:=taasmoutput(arg);
  916. if (tsym(p).typ=varsym) and
  917. (tvarsym(p).varspez=vs_value) and
  918. (paramanager.push_addr_param(tvarsym(p).vartype.def,current_procinfo.procdef.proccalloption)) then
  919. begin
  920. reference_reset_base(href1,current_procinfo.framepointer,tvarsym(p).adjusted_address);
  921. if is_open_array(tvarsym(p).vartype.def) or
  922. is_array_of_const(tvarsym(p).vartype.def) then
  923. cg.g_copyvaluepara_openarray(list,href1,tarraydef(tvarsym(p).vartype.def).elesize)
  924. else
  925. begin
  926. reference_reset_base(href2,current_procinfo.framepointer,tvarsym(p).localvarsym.adjusted_address);
  927. if is_shortstring(tvarsym(p).vartype.def) then
  928. cg.g_copyshortstring(list,href1,href2,tstringdef(tvarsym(p).vartype.def).len,false,true)
  929. else
  930. cg.g_concatcopy(list,href1,href2,tvarsym(p).vartype.def.size,true,true);
  931. end;
  932. end;
  933. end;
  934. { generates the code for initialisation of local data }
  935. procedure initialize_data(p : tnamedindexitem;arg:pointer);
  936. var
  937. href : treference;
  938. list : taasmoutput;
  939. begin
  940. list:=taasmoutput(arg);
  941. if (tsym(p).typ=varsym) and
  942. not(vo_is_local_copy in tvarsym(p).varoptions) and
  943. assigned(tvarsym(p).vartype.def) and
  944. not(is_class(tvarsym(p).vartype.def)) and
  945. tvarsym(p).vartype.def.needs_inittable then
  946. begin
  947. if (cs_implicit_exceptions in aktmoduleswitches) then
  948. include(current_procinfo.flags,pi_needs_implicit_finally);
  949. if tsym(p).owner.symtabletype in [localsymtable,inlinelocalsymtable] then
  950. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address)
  951. else
  952. reference_reset_symbol(href,objectlibrary.newasmsymboldata(tvarsym(p).mangledname),0);
  953. cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
  954. end;
  955. end;
  956. { generates the code for finalisation of local data }
  957. procedure finalize_data(p : tnamedindexitem;arg:pointer);
  958. var
  959. href : treference;
  960. list : taasmoutput;
  961. begin
  962. list:=taasmoutput(arg);
  963. case tsym(p).typ of
  964. varsym :
  965. begin
  966. if not(vo_is_local_copy in tvarsym(p).varoptions) and
  967. not(vo_is_funcret in tvarsym(p).varoptions) and
  968. assigned(tvarsym(p).vartype.def) and
  969. not(is_class(tvarsym(p).vartype.def)) and
  970. tvarsym(p).vartype.def.needs_inittable then
  971. begin
  972. if tsym(p).owner.symtabletype in [localsymtable,inlinelocalsymtable] then
  973. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address)
  974. else
  975. reference_reset_symbol(href,objectlibrary.newasmsymboldata(tvarsym(p).mangledname),0);
  976. cg.g_finalize(list,tvarsym(p).vartype.def,href,false);
  977. end;
  978. end;
  979. typedconstsym :
  980. begin
  981. if ttypedconstsym(p).is_writable and
  982. ttypedconstsym(p).typedconsttype.def.needs_inittable then
  983. begin
  984. reference_reset_symbol(href,objectlibrary.newasmsymboldata(ttypedconstsym(p).mangledname),0);
  985. cg.g_finalize(list,ttypedconstsym(p).typedconsttype.def,href,false);
  986. end;
  987. end;
  988. end;
  989. end;
  990. { generates the code for incrementing the reference count of parameters and
  991. initialize out parameters }
  992. procedure init_paras(p : tnamedindexitem;arg:pointer);
  993. var
  994. href : treference;
  995. tmpreg : tregister;
  996. list : taasmoutput;
  997. begin
  998. list:=taasmoutput(arg);
  999. if (tsym(p).typ=varsym) and
  1000. not is_class(tvarsym(p).vartype.def) and
  1001. tvarsym(p).vartype.def.needs_inittable then
  1002. begin
  1003. case tvarsym(p).varspez of
  1004. vs_value :
  1005. begin
  1006. if (cs_implicit_exceptions in aktmoduleswitches) then
  1007. include(current_procinfo.flags,pi_needs_implicit_finally);
  1008. if assigned(tvarsym(p).localvarsym) then
  1009. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).localvarsym.adjusted_address)
  1010. else
  1011. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
  1012. cg.g_incrrefcount(list,tvarsym(p).vartype.def,href,is_open_array(tvarsym(p).vartype.def));
  1013. end;
  1014. vs_out :
  1015. begin
  1016. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
  1017. {$ifdef newra}
  1018. tmpreg:=rg.getaddressregister(list);
  1019. {$else}
  1020. tmpreg:=cg.get_scratch_reg_address(list);
  1021. {$endif}
  1022. cg.a_load_ref_reg(list,OS_ADDR,href,tmpreg);
  1023. reference_reset_base(href,tmpreg,0);
  1024. cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
  1025. {$ifdef newra}
  1026. rg.ungetregisterint(list,tmpreg);
  1027. {$else}
  1028. cg.free_scratch_reg(list,tmpreg);
  1029. {$endif newra}
  1030. end;
  1031. end;
  1032. end;
  1033. end;
  1034. { generates the code for decrementing the reference count of parameters }
  1035. procedure final_paras(p : tnamedindexitem;arg:pointer);
  1036. var
  1037. href : treference;
  1038. list : taasmoutput;
  1039. begin
  1040. list:=taasmoutput(arg);
  1041. if (tsym(p).typ=varsym) and
  1042. not is_class(tvarsym(p).vartype.def) and
  1043. tvarsym(p).vartype.def.needs_inittable then
  1044. begin
  1045. if (tvarsym(p).varspez=vs_value) then
  1046. begin
  1047. if assigned(tvarsym(p).localvarsym) then
  1048. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).localvarsym.adjusted_address)
  1049. else
  1050. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
  1051. cg.g_decrrefcount(list,tvarsym(p).vartype.def,href,is_open_array(tvarsym(p).vartype.def));
  1052. end;
  1053. end;
  1054. end;
  1055. { Initialize temp ansi/widestrings,interfaces }
  1056. procedure inittempvariables(list:taasmoutput);
  1057. var
  1058. hp : ptemprecord;
  1059. href : treference;
  1060. begin
  1061. hp:=tg.templist;
  1062. while assigned(hp) do
  1063. begin
  1064. if hp^.temptype in [tt_ansistring,tt_freeansistring,
  1065. tt_widestring,tt_freewidestring,
  1066. tt_interfacecom,tt_freeinterfacecom] then
  1067. begin
  1068. if (cs_implicit_exceptions in aktmoduleswitches) then
  1069. include(current_procinfo.flags,pi_needs_implicit_finally);
  1070. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  1071. cg.a_load_const_ref(list,OS_ADDR,0,href);
  1072. end;
  1073. hp:=hp^.next;
  1074. end;
  1075. end;
  1076. procedure finalizetempvariables(list:taasmoutput);
  1077. var
  1078. hp : ptemprecord;
  1079. href : treference;
  1080. begin
  1081. hp:=tg.templist;
  1082. while assigned(hp) do
  1083. begin
  1084. case hp^.temptype of
  1085. tt_ansistring,
  1086. tt_freeansistring :
  1087. begin
  1088. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  1089. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(1));
  1090. cg.a_call_name(list,'FPC_ANSISTR_DECR_REF');
  1091. end;
  1092. tt_widestring,
  1093. tt_freewidestring :
  1094. begin
  1095. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  1096. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(1));
  1097. cg.a_call_name(list,'FPC_WIDESTR_DECR_REF');
  1098. end;
  1099. tt_interfacecom :
  1100. begin
  1101. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  1102. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(1));
  1103. cg.a_call_name(list,'FPC_INTF_DECR_REF');
  1104. end;
  1105. end;
  1106. hp:=hp^.next;
  1107. end;
  1108. end;
  1109. procedure initretvalue(list:taasmoutput);
  1110. var
  1111. paraloc : tparalocation;
  1112. href : treference;
  1113. begin
  1114. if not is_void(current_procdef.rettype.def) then
  1115. begin
  1116. { for now the pointer to the result can't be a register }
  1117. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1118. begin
  1119. {$ifdef powerpc}
  1120. { no stack space is allocated in this case -> can't save the result reg on the stack }
  1121. if not(po_assembler in current_procdef.procoptions) then
  1122. {$endif powerpc}
  1123. begin
  1124. paraloc:=paramanager.getfuncretparaloc(current_procdef);
  1125. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.return_offset);
  1126. case paraloc.loc of
  1127. LOC_CREGISTER,
  1128. LOC_REGISTER:
  1129. if not(paraloc.size in [OS_64,OS_S64]) then
  1130. cg.a_load_reg_ref(list,paraloc.size,paraloc.register,href)
  1131. else
  1132. cg64.a_load64_reg_ref(list,paraloc.register64,href);
  1133. LOC_CFPUREGISTER,
  1134. LOC_FPUREGISTER:
  1135. cg.a_load_reg_ref(list,paraloc.size,paraloc.register,href);
  1136. LOC_CMMREGISTER,
  1137. LOC_MMREGISTER:
  1138. cg.a_loadmm_reg_ref(list,paraloc.register,href);
  1139. end;
  1140. end;
  1141. end;
  1142. { initialize return value }
  1143. if (current_procdef.rettype.def.needs_inittable) then
  1144. begin
  1145. {$ifdef powerpc}
  1146. if (po_assembler in current_procdef.procoptions) then
  1147. internalerror(200304161);
  1148. {$endif powerpc}
  1149. if (cs_implicit_exceptions in aktmoduleswitches) then
  1150. include(current_procinfo.flags,pi_needs_implicit_finally);
  1151. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.return_offset);
  1152. cg.g_initialize(list,current_procdef.rettype.def,href,paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption));
  1153. end;
  1154. end;
  1155. end;
  1156. procedure load_return_value(list:TAAsmoutput; var uses_acc,uses_acchi,uses_fpu : boolean);
  1157. var
  1158. href : treference;
  1159. hreg,r,r2 : tregister;
  1160. cgsize : TCGSize;
  1161. begin
  1162. if not is_void(current_procdef.rettype.def) then
  1163. begin
  1164. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.return_offset);
  1165. cgsize:=def_cgsize(current_procdef.rettype.def);
  1166. { Here, we return the function result. In most architectures, the value is
  1167. passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
  1168. function returns in a register and the caller receives it in an other one }
  1169. case current_procdef.rettype.def.deftype of
  1170. orddef,
  1171. enumdef :
  1172. begin
  1173. uses_acc:=true;
  1174. {$ifndef cpu64bit}
  1175. if cgsize in [OS_64,OS_S64] then
  1176. begin
  1177. uses_acchi:=true;
  1178. r.enum:=R_INTREGISTER;
  1179. r.number:=NR_FUNCTION_RETURN64_LOW_REG;
  1180. cg.a_reg_alloc(list,r);
  1181. r2.enum:=R_INTREGISTER;
  1182. r2.number:=NR_FUNCTION_RETURN64_HIGH_REG;
  1183. cg.a_reg_alloc(list,r2);
  1184. cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
  1185. end
  1186. else
  1187. {$endif cpu64bit}
  1188. begin
  1189. hreg.enum:=R_INTREGISTER;
  1190. hreg.number:=(RS_FUNCTION_RETURN_REG shl 8) or cgsize2subreg(cgsize);
  1191. cg.a_load_ref_reg(list,cgsize,href,hreg);
  1192. end;
  1193. end;
  1194. floatdef :
  1195. begin
  1196. uses_fpu := true;
  1197. {$ifdef cpufpemu}
  1198. if cs_fp_emulation in aktmoduleswitches then
  1199. r.enum := FUNCTION_RETURN_REG
  1200. else
  1201. {$endif cpufpemu}
  1202. r.enum:=FPU_RESULT_REG;
  1203. cg.a_loadfpu_ref_reg(list,cgsize,href,r);
  1204. end;
  1205. else
  1206. begin
  1207. if not paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1208. begin
  1209. uses_acc:=true;
  1210. {$ifndef cpu64bit}
  1211. { Win32 can return records in EAX:EDX }
  1212. if cgsize in [OS_64,OS_S64] then
  1213. begin
  1214. uses_acchi:=true;
  1215. r.enum:=R_INTREGISTER;
  1216. r.number:=NR_FUNCTION_RETURN64_LOW_REG;
  1217. cg.a_reg_alloc(list,r);
  1218. r2.enum:=R_INTREGISTER;
  1219. r2.number:=NR_FUNCTION_RETURN64_HIGH_REG;
  1220. cg.a_reg_alloc(list,r2);
  1221. cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
  1222. end
  1223. else
  1224. {$endif cpu64bit}
  1225. begin
  1226. hreg.enum:=R_INTREGISTER;
  1227. hreg.number:=(RS_FUNCTION_RETURN_REG shl 8) or cgsize2subreg(cgsize);
  1228. cg.a_load_ref_reg(list,cgsize,href,hreg);
  1229. end;
  1230. end
  1231. end;
  1232. end;
  1233. end;
  1234. end;
  1235. procedure genentrycode(list : TAAsmoutput;stackframe:longint;inlined : boolean);
  1236. var
  1237. hs : string;
  1238. href : treference;
  1239. stackalloclist : taasmoutput;
  1240. hp : tparaitem;
  1241. rsp : tregister;
  1242. begin
  1243. if not inlined then
  1244. stackalloclist:=taasmoutput.Create;
  1245. { the actual stack allocation code, symbol entry point and
  1246. gdb stabs information is generated AFTER the rest of this
  1247. code, since temp. allocation might occur before - carl
  1248. }
  1249. if assigned(current_procdef.parast) then
  1250. begin
  1251. if not (po_assembler in current_procdef.procoptions) then
  1252. begin
  1253. { move register parameters which aren't regable into memory }
  1254. { we do this before init_paras because that one calls routines which may overwrite these }
  1255. { registers and it also expects the values to be in memory }
  1256. hp:=tparaitem(current_procdef.para.first);
  1257. while assigned(hp) do
  1258. begin
  1259. if Tvarsym(hp.parasym).reg.enum>R_INTREGISTER then
  1260. internalerror(200301081);
  1261. if (tvarsym(hp.parasym).reg.enum<>R_NO) then
  1262. case hp.paraloc.loc of
  1263. LOC_CREGISTER,
  1264. LOC_REGISTER:
  1265. if not(hp.paraloc.size in [OS_S64,OS_64]) then
  1266. cg.a_load_reg_reg(list,hp.paraloc.size,hp.paraloc.size,hp.paraloc.register,tvarsym(hp.parasym).reg)
  1267. else
  1268. internalerror(2003053011);
  1269. // cg64.a_load64_reg_reg(list,hp.paraloc.register64,tvarsym(hp.parasym).reg);
  1270. LOC_CFPUREGISTER,
  1271. LOC_FPUREGISTER:
  1272. cg.a_loadfpu_reg_reg(list,hp.paraloc.register,tvarsym(hp.parasym).reg);
  1273. LOC_REFERENCE,
  1274. LOC_CREFERENCE:
  1275. begin
  1276. reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
  1277. cg.a_load_ref_reg(list,hp.paraloc.size,href,tvarsym(hp.parasym).reg);
  1278. end;
  1279. else
  1280. internalerror(2003053010);
  1281. end
  1282. else if (hp.paraloc.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
  1283. LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
  1284. (tvarsym(hp.parasym).reg.enum=R_NO) then
  1285. begin
  1286. reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
  1287. case hp.paraloc.loc of
  1288. LOC_CREGISTER,
  1289. LOC_REGISTER:
  1290. if not(hp.paraloc.size in [OS_S64,OS_64]) then
  1291. cg.a_load_reg_ref(list,hp.paraloc.size,hp.paraloc.register,href)
  1292. else
  1293. cg64.a_load64_reg_ref(list,hp.paraloc.register64,href);
  1294. LOC_FPUREGISTER,
  1295. LOC_CFPUREGISTER:
  1296. cg.a_loadfpu_reg_ref(list,hp.paraloc.size,hp.paraloc.register,href);
  1297. else
  1298. internalerror(2002081302);
  1299. end;
  1300. end;
  1301. hp:=tparaitem(hp.next);
  1302. end;
  1303. end;
  1304. end;
  1305. { for the save all registers we can simply use a pusha,popa which
  1306. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1307. if (po_saveregisters in current_procdef.procoptions) then
  1308. cg.g_save_all_registers(list)
  1309. else
  1310. { should we save edi,esi,ebx like C ? }
  1311. if (po_savestdregs in current_procdef.procoptions) then
  1312. cg.g_save_standard_registers(list,current_procdef.usedintregisters);
  1313. { Save stackpointer value }
  1314. if not inlined and
  1315. (current_procinfo.framepointer.number<>NR_STACK_POINTER_REG) and
  1316. ((po_savestdregs in current_procdef.procoptions) or
  1317. (po_saveregisters in current_procdef.procoptions)) then
  1318. begin
  1319. tg.GetTemp(list,POINTER_SIZE,tt_noreuse,current_procinfo.save_stackptr_ref);
  1320. rsp.enum:=R_INTREGISTER;
  1321. rsp.number:=NR_STACK_POINTER_REG;
  1322. cg.a_load_reg_ref(list,OS_ADDR,rsp,current_procinfo.save_stackptr_ref);
  1323. end;
  1324. { the actual profile code can clobber some registers,
  1325. therefore if the context must be saved, do it before
  1326. the actual call to the profile code
  1327. }
  1328. if (cs_profile in aktmoduleswitches) and
  1329. not(po_assembler in current_procdef.procoptions) and
  1330. not(inlined) then
  1331. begin
  1332. { non-win32 can call mcout even in main }
  1333. if not (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  1334. cg.g_profilecode(list)
  1335. else
  1336. { wdosx, and win32 should not call mcount before monstartup has been called }
  1337. if not (current_procdef.proctypeoption=potype_proginit) then
  1338. cg.g_profilecode(list);
  1339. end;
  1340. { initialize return value }
  1341. initretvalue(list);
  1342. { initialize local data like ansistrings }
  1343. case current_procdef.proctypeoption of
  1344. potype_unitinit:
  1345. begin
  1346. { this is also used for initialization of variables in a
  1347. program which does not have a globalsymtable }
  1348. if assigned(current_module.globalsymtable) then
  1349. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1350. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1351. end;
  1352. { units have seperate code for initilization and finalization }
  1353. potype_unitfinalize: ;
  1354. { program init/final is generated in separate procedure }
  1355. potype_proginit: ;
  1356. else
  1357. current_procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1358. end;
  1359. { initialisizes temp. ansi/wide string data }
  1360. inittempvariables(list);
  1361. { initialize ansi/widesstring para's }
  1362. if assigned(current_procdef.parast) then
  1363. begin
  1364. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1365. end;
  1366. { generate copies of call by value parameters }
  1367. if not(po_assembler in current_procdef.procoptions) then
  1368. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1369. if (not inlined) then
  1370. begin
  1371. { call startup helpers from main program }
  1372. if (current_procdef.proctypeoption=potype_proginit) then
  1373. begin
  1374. { initialize profiling for win32 }
  1375. if (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1376. (cs_profile in aktmoduleswitches) then
  1377. begin
  1378. reference_reset_symbol(href,objectlibrary.newasmsymboldata('etext'),0);
  1379. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(2));
  1380. reference_reset_symbol(href,objectlibrary.newasmsymboldata('__image_base__'),0);
  1381. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(2));
  1382. cg.a_call_name(list,'_monstartup');
  1383. end;
  1384. { initialize units }
  1385. cg.a_call_name(list,'FPC_INITIALIZEUNITS');
  1386. end;
  1387. {$ifdef GDB}
  1388. if (cs_debuginfo in aktmoduleswitches) then
  1389. list.concat(Tai_force_line.Create);
  1390. {$endif GDB}
  1391. end;
  1392. if inlined then
  1393. load_regvars(list,nil);
  1394. {************************* Stack allocation **************************}
  1395. { and symbol entry point as well as debug information }
  1396. { will be inserted in front of the rest of this list. }
  1397. { Insert alignment and assembler names }
  1398. if not inlined then
  1399. begin
  1400. { Align, gprof uses 16 byte granularity }
  1401. if (cs_profile in aktmoduleswitches) then
  1402. stackalloclist.concat(Tai_align.Create(16))
  1403. else
  1404. stackalloclist.concat(Tai_align.Create(aktalignment.procalign));
  1405. {$ifdef GDB}
  1406. if (cs_debuginfo in aktmoduleswitches) then
  1407. begin
  1408. if (po_public in current_procdef.procoptions) then
  1409. tprocsym(current_procdef.procsym).is_global:=true;
  1410. current_procdef.concatstabto(stackalloclist);
  1411. tprocsym(current_procdef.procsym).isstabwritten:=true;
  1412. end;
  1413. {$endif GDB}
  1414. repeat
  1415. hs:=current_procdef.aliasnames.getfirst;
  1416. if hs='' then
  1417. break;
  1418. {$ifdef GDB}
  1419. if (cs_debuginfo in aktmoduleswitches) and
  1420. target_info.use_function_relative_addresses then
  1421. stackalloclist.concat(Tai_stab_function_name.Create(strpnew(hs)));
  1422. {$endif GDB}
  1423. if (cs_profile in aktmoduleswitches) or
  1424. (po_public in current_procdef.procoptions) then
  1425. stackalloclist.concat(Tai_symbol.Createname_global(hs,0))
  1426. else
  1427. stackalloclist.concat(Tai_symbol.Createname(hs,0));
  1428. until false;
  1429. stackframe:=stackframe+tg.gettempsize;
  1430. {$ifndef m68k}
  1431. { give a warning if the limit of local variables is reached }
  1432. if stackframe > maxlocalsize then
  1433. Message(cg_w_localsize_too_big);
  1434. {$endif}
  1435. {$ifndef powerpc}
  1436. { at least for the ppc this applies always, so this code isn't usable (FK) }
  1437. { omit stack frame ? }
  1438. if (current_procinfo.framepointer.number=NR_STACK_POINTER_REG) then
  1439. begin
  1440. CGMessage(cg_d_stackframe_omited);
  1441. if stackframe<>0 then
  1442. cg.g_stackpointer_alloc(stackalloclist,stackframe);
  1443. end
  1444. else
  1445. {$endif powerpc}
  1446. begin
  1447. if (po_interrupt in current_procdef.procoptions) then
  1448. cg.g_interrupt_stackframe_entry(stackalloclist);
  1449. cg.g_stackframe_entry(stackalloclist,stackframe);
  1450. { never call stack checking before the standard system unit
  1451. has not been initialized
  1452. }
  1453. if (cs_check_stack in aktlocalswitches) and (current_procdef.proctypeoption<>potype_proginit) then
  1454. cg.g_stackcheck(stackalloclist,stackframe);
  1455. end;
  1456. list.insertlist(stackalloclist);
  1457. stackalloclist.free;
  1458. end;
  1459. {************************* End Stack allocation **************************}
  1460. end;
  1461. procedure genexitcode(list : TAAsmoutput;inlined:boolean);
  1462. var
  1463. {$ifdef GDB}
  1464. stabsendlabel : tasmlabel;
  1465. mangled_length : longint;
  1466. p : pchar;
  1467. {$endif GDB}
  1468. okexitlabel : tasmlabel;
  1469. href : treference;
  1470. srsym : tsym;
  1471. usesacc,
  1472. usesacchi,
  1473. usesfpu : boolean;
  1474. rsp,r : Tregister;
  1475. retsize : longint;
  1476. begin
  1477. if aktexitlabel.is_used then
  1478. cg.a_label(list,aktexitlabel);
  1479. cleanup_regvars(list);
  1480. { finalize temporary data }
  1481. finalizetempvariables(list);
  1482. { finalize local data like ansistrings}
  1483. case current_procdef.proctypeoption of
  1484. potype_unitfinalize:
  1485. begin
  1486. { this is also used for initialization of variables in a
  1487. program which does not have a globalsymtable }
  1488. if assigned(current_module.globalsymtable) then
  1489. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1490. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1491. end;
  1492. { units/progs have separate code for initialization and finalization }
  1493. potype_unitinit: ;
  1494. { program init/final is generated in separate procedure }
  1495. potype_proginit: ;
  1496. else
  1497. current_procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1498. end;
  1499. { finalize paras data }
  1500. if assigned(current_procdef.parast) then
  1501. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1502. { call __EXIT for main program }
  1503. if (not DLLsource) and
  1504. (not inlined) and
  1505. (current_procdef.proctypeoption=potype_proginit) then
  1506. begin
  1507. cg.a_call_name(list,'FPC_DO_EXIT');
  1508. end;
  1509. { handle return value, this is not done for assembler routines when
  1510. they didn't reference the result variable }
  1511. usesacc:=false;
  1512. usesacchi:=false;
  1513. if not(po_assembler in current_procdef.procoptions) or
  1514. (assigned(current_procdef.funcretsym) and
  1515. (tvarsym(current_procdef.funcretsym).refcount>1)) then
  1516. begin
  1517. if (current_procdef.proctypeoption=potype_constructor) then
  1518. begin
  1519. objectlibrary.getlabel(okexitlabel);
  1520. cg.a_jmp_always(list,okexitlabel);
  1521. { Success exit }
  1522. cg.a_label(list,okexitlabel);
  1523. r.enum:=R_INTREGISTER;
  1524. r.number:=NR_FUNCTION_RETURN_REG;
  1525. cg.a_reg_alloc(list,r);
  1526. { return the self pointer }
  1527. srsym:=tvarsym(current_procdef.parast.search('self'));
  1528. if not assigned(srsym) then
  1529. internalerror(200305058);
  1530. reference_reset_base(href,current_procinfo.framepointer,tvarsym(srsym).adjusted_address);
  1531. cg.a_load_ref_reg(list,OS_ADDR,href,r);
  1532. cg.a_reg_dealloc(list,r);
  1533. usesacc:=true;
  1534. end
  1535. else
  1536. load_return_value(list,usesacc,usesacchi,usesfpu)
  1537. end;
  1538. {$ifdef GDB}
  1539. if ((cs_debuginfo in aktmoduleswitches) and not inlined) then
  1540. begin
  1541. objectlibrary.getlabel(stabsendlabel);
  1542. cg.a_label(list,stabsendlabel);
  1543. end;
  1544. {$endif GDB}
  1545. { Restore stackpointer if it was saved }
  1546. if not inlined and
  1547. (current_procinfo.framepointer.number<>NR_STACK_POINTER_REG) and
  1548. ((po_savestdregs in current_procdef.procoptions) or
  1549. (po_saveregisters in current_procdef.procoptions)) then
  1550. begin
  1551. rsp.enum:=R_INTREGISTER;
  1552. rsp.number:=NR_STACK_POINTER_REG;
  1553. cg.a_load_ref_reg(list,OS_ADDR,current_procinfo.save_stackptr_ref,rsp);
  1554. tg.UngetTemp(list,current_procinfo.save_stackptr_ref);
  1555. end;
  1556. { for the save all registers we can simply use a pusha,popa which
  1557. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1558. if (po_saveregisters in current_procdef.procoptions) then
  1559. cg.g_restore_all_registers(list,usesacc,usesacchi)
  1560. else
  1561. { should we restore edi ? }
  1562. if (po_savestdregs in current_procdef.procoptions) then
  1563. cg.g_restore_standard_registers(list,current_procdef.usedintregisters);
  1564. {$ifndef powerpc}
  1565. { remove stackframe }
  1566. if not inlined then
  1567. begin
  1568. if (current_procinfo.framepointer.number=NR_STACK_POINTER_REG) then
  1569. begin
  1570. if (tg.gettempsize<>0) then
  1571. cg.a_op_const_reg(list,OP_ADD,tg.gettempsize,current_procinfo.framepointer);
  1572. end
  1573. else
  1574. cg.g_restore_frame_pointer(list);
  1575. if not (po_assembler in current_procdef.procoptions) then
  1576. end;
  1577. {$endif}
  1578. { at last, the return is generated }
  1579. if not inlined then
  1580. begin
  1581. if (po_interrupt in current_procdef.procoptions) then
  1582. cg.g_interrupt_stackframe_exit(list,usesacc,usesacchi)
  1583. else
  1584. begin
  1585. if (po_clearstack in current_procdef.procoptions) then
  1586. begin
  1587. retsize:=0;
  1588. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1589. inc(retsize,POINTER_SIZE);
  1590. end
  1591. else
  1592. begin
  1593. retsize:=current_procdef.parast.datasize;
  1594. if current_procdef.parast.address_fixup>target_info.first_parm_offset then
  1595. inc(retsize,current_procdef.parast.address_fixup-target_info.first_parm_offset);
  1596. end;
  1597. cg.g_return_from_proc(list,retsize);
  1598. end;
  1599. end;
  1600. if not inlined then
  1601. list.concat(Tai_symbol_end.Createname(current_procdef.mangledname));
  1602. {$ifdef GDB}
  1603. if (cs_debuginfo in aktmoduleswitches) and not inlined then
  1604. begin
  1605. { define calling EBP as pseudo local var PM }
  1606. { this enables test if the function is a local one !! }
  1607. if assigned(current_procinfo.parent) and
  1608. (current_procdef.parast.symtablelevel>normal_function_level) then
  1609. list.concat(Tai_stabs.Create(strpnew(
  1610. '"parent_ebp:'+tstoreddef(voidpointertype.def).numberstring+'",'+
  1611. tostr(N_LSYM)+',0,0,'+tostr(current_procinfo.framepointer_offset))));
  1612. if (not is_void(current_procdef.rettype.def)) then
  1613. begin
  1614. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1615. list.concat(Tai_stabs.Create(strpnew(
  1616. '"'+current_procdef.procsym.name+':X*'+tstoreddef(current_procdef.rettype.def).numberstring+'",'+
  1617. tostr(N_tsym)+',0,0,'+tostr(current_procinfo.return_offset))))
  1618. else
  1619. list.concat(Tai_stabs.Create(strpnew(
  1620. '"'+current_procdef.procsym.name+':X'+tstoreddef(current_procdef.rettype.def).numberstring+'",'+
  1621. tostr(N_tsym)+',0,0,'+tostr(current_procinfo.return_offset))));
  1622. if (m_result in aktmodeswitches) then
  1623. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1624. list.concat(Tai_stabs.Create(strpnew(
  1625. '"RESULT:X*'+tstoreddef(current_procdef.rettype.def).numberstring+'",'+
  1626. tostr(N_tsym)+',0,0,'+tostr(current_procinfo.return_offset))))
  1627. else
  1628. list.concat(Tai_stabs.Create(strpnew(
  1629. '"RESULT:X'+tstoreddef(current_procdef.rettype.def).numberstring+'",'+
  1630. tostr(N_tsym)+',0,0,'+tostr(current_procinfo.return_offset))));
  1631. end;
  1632. mangled_length:=length(current_procdef.mangledname);
  1633. getmem(p,2*mangled_length+50);
  1634. strpcopy(p,'192,0,0,');
  1635. strpcopy(strend(p),current_procdef.mangledname);
  1636. if (target_info.use_function_relative_addresses) then
  1637. begin
  1638. strpcopy(strend(p),'-');
  1639. strpcopy(strend(p),current_procdef.mangledname);
  1640. end;
  1641. list.concat(Tai_stabn.Create(strnew(p)));
  1642. {List.concat(Tai_stabn.Create(strpnew('192,0,0,'
  1643. +current_procdef.mangledname))));
  1644. p[0]:='2';p[1]:='2';p[2]:='4';
  1645. strpcopy(strend(p),'_end');}
  1646. strpcopy(p,'224,0,0,'+stabsendlabel.name);
  1647. if (target_info.use_function_relative_addresses) then
  1648. begin
  1649. strpcopy(strend(p),'-');
  1650. strpcopy(strend(p),current_procdef.mangledname);
  1651. end;
  1652. list.concatlist(withdebuglist);
  1653. list.concat(Tai_stabn.Create(strnew(p)));
  1654. { strpnew('224,0,0,'
  1655. +current_procdef.mangledname+'_end'))));}
  1656. freemem(p,2*mangled_length+50);
  1657. end;
  1658. {$endif GDB}
  1659. if inlined then
  1660. cleanup_regvars(list);
  1661. end;
  1662. {****************************************************************************
  1663. Inlining
  1664. ****************************************************************************}
  1665. procedure load_inlined_return_value(list:TAAsmoutput);
  1666. var
  1667. href : treference;
  1668. r,r2 : tregister;
  1669. cgsize : TCGSize;
  1670. begin
  1671. if not is_void(current_procdef.rettype.def) then
  1672. begin
  1673. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.return_offset);
  1674. cgsize:=def_cgsize(current_procdef.rettype.def);
  1675. { Here, we return the function result. In most architectures, the value is
  1676. passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
  1677. function returns in a register and the caller receives it in an other one }
  1678. case current_procdef.rettype.def.deftype of
  1679. orddef,
  1680. enumdef :
  1681. begin
  1682. {$ifndef cpu64bit}
  1683. if cgsize in [OS_64,OS_S64] then
  1684. begin
  1685. r:=rg.getregisterint(list,OS_INT);
  1686. r2:=rg.getregisterint(list,OS_INT);
  1687. cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
  1688. end
  1689. else
  1690. {$endif cpu64bit}
  1691. begin
  1692. r:=rg.getregisterint(list,cgsize);
  1693. cg.a_load_ref_reg(list,cgsize,href,r);
  1694. end;
  1695. end;
  1696. floatdef :
  1697. begin
  1698. {$ifdef cpufpemu}
  1699. if cs_fp_emulation in aktmoduleswitches then
  1700. r.enum := FUNCTION_RETURN_REG
  1701. else
  1702. {$endif cpufpemu}
  1703. r.enum:=FPU_RESULT_REG;
  1704. cg.a_loadfpu_ref_reg(list,cgsize,href,r);
  1705. end;
  1706. else
  1707. begin
  1708. if not paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1709. begin
  1710. {$ifndef cpu64bit}
  1711. { Win32 can return records in EAX:EDX }
  1712. if cgsize in [OS_64,OS_S64] then
  1713. begin
  1714. r:=rg.getregisterint(list,OS_INT);
  1715. r2:=rg.getregisterint(list,OS_INT);
  1716. cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
  1717. end
  1718. else
  1719. {$endif cpu64bit}
  1720. begin
  1721. r:=rg.getregisterint(list,cgsize);
  1722. cg.a_load_ref_reg(list,cgsize,href,r);
  1723. end;
  1724. end
  1725. end;
  1726. end;
  1727. end;
  1728. end;
  1729. procedure geninlineentrycode(list : TAAsmoutput;stackframe:longint);
  1730. begin
  1731. { initialize return value }
  1732. initretvalue(list);
  1733. current_procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1734. { initialisizes temp. ansi/wide string data }
  1735. inittempvariables(list);
  1736. { initialize ansi/widesstring para's }
  1737. if assigned(current_procdef.parast) then
  1738. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1739. { generate copies of call by value parameters }
  1740. if not(po_assembler in current_procdef.procoptions) then
  1741. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1742. load_regvars(list,nil);
  1743. end;
  1744. procedure geninlineexitcode(list : TAAsmoutput;inlined:boolean);
  1745. var
  1746. usesacc,
  1747. usesacchi,
  1748. usesfpu : boolean;
  1749. begin
  1750. if aktexitlabel.is_used then
  1751. cg.a_label(list,aktexitlabel);
  1752. cleanup_regvars(list);
  1753. { finalize temporary data }
  1754. finalizetempvariables(list);
  1755. current_procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1756. { finalize paras data }
  1757. if assigned(current_procdef.parast) then
  1758. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1759. { handle return value, this is not done for assembler routines when
  1760. they didn't reference the result variable }
  1761. if not(po_assembler in current_procdef.procoptions) or
  1762. (assigned(current_procdef.funcretsym) and
  1763. (tvarsym(current_procdef.funcretsym).refcount>1)) then
  1764. begin
  1765. if (current_procdef.proctypeoption=potype_constructor) then
  1766. internalerror(200305263);
  1767. // load_inlined_return_value(list);
  1768. load_return_value(list,usesacc,usesacchi,usesfpu)
  1769. end;
  1770. cleanup_regvars(list);
  1771. end;
  1772. end.
  1773. {
  1774. $Log$
  1775. Revision 1.114 2003-05-31 15:05:28 peter
  1776. * FUNCTION_RESULT64_LOW/HIGH_REG added for int64 results
  1777. Revision 1.113 2003/05/31 00:48:15 jonas
  1778. * fixed my previous commit
  1779. Revision 1.112 2003/05/30 23:57:08 peter
  1780. * more sparc cleanup
  1781. * accumulator removed, splitted in function_return_reg (called) and
  1782. function_result_reg (caller)
  1783. Revision 1.111 2003/05/30 23:49:18 jonas
  1784. * a_load_loc_reg now has an extra size parameter for the destination
  1785. register (properly fixes what I worked around in revision 1.106 of
  1786. ncgutil.pas)
  1787. Revision 1.110 2003/05/30 18:52:10 jonas
  1788. * fixed bug with intregvars
  1789. * locapara.loc can also be LOC_CFPUREGISTER -> also fixed
  1790. rcgppc.a_param_ref, which previously got bogus size values
  1791. Revision 1.109 2003/05/27 21:19:08 jonas
  1792. * fixed ppc cycle
  1793. Revision 1.108 2003/05/27 14:28:14 jonas
  1794. * patch from Peter for nested procedures
  1795. Revision 1.107 2003/05/26 21:17:17 peter
  1796. * procinlinenode removed
  1797. * aktexit2label removed, fast exit removed
  1798. + tcallnode.inlined_pass_2 added
  1799. Revision 1.106 2003/05/24 11:59:42 jonas
  1800. * fixed integer typeconversion problems
  1801. Revision 1.105 2003/05/23 14:27:35 peter
  1802. * remove some unit dependencies
  1803. * current_procinfo changes to store more info
  1804. Revision 1.104 2003/05/15 18:58:53 peter
  1805. * removed selfpointer_offset, vmtpointer_offset
  1806. * tvarsym.adjusted_address
  1807. * address in localsymtable is now in the real direction
  1808. * removed some obsolete globals
  1809. Revision 1.103 2003/05/14 19:37:25 jonas
  1810. * patch from Peter for int64 function results
  1811. Revision 1.102 2003/05/13 19:14:41 peter
  1812. * failn removed
  1813. * inherited result code check moven to pexpr
  1814. Revision 1.101 2003/05/13 15:16:13 peter
  1815. * removed ret_in_acc, it's the reverse of ret_in_param
  1816. * fixed ret_in_param for win32 cdecl array
  1817. Revision 1.100 2003/05/12 08:08:27 jonas
  1818. * fixed several initialization and finalization related bugs (missing
  1819. tg.direction's, wrong paralocation for decreasing refcount of
  1820. everything but ansistrings)
  1821. Revision 1.99 2003/05/11 21:37:03 peter
  1822. * moved implicit exception frame from ncgutil to psub
  1823. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1824. Revision 1.98 2003/05/11 14:45:12 peter
  1825. * tloadnode does not support objectsymtable,withsymtable anymore
  1826. * withnode cleanup
  1827. * direct with rewritten to use temprefnode
  1828. Revision 1.97 2003/05/10 13:20:23 jonas
  1829. * moved storing of register parameters to memory even earlier in the
  1830. entry code to fix problems with constructors
  1831. Revision 1.96 2003/05/09 17:47:02 peter
  1832. * self moved to hidden parameter
  1833. * removed hdisposen,hnewn,selfn
  1834. Revision 1.95 2003/04/29 07:28:52 michael
  1835. + Patch from peter to fix wrong pushing of ansistring function results in open array
  1836. Revision 1.94 2003/04/28 21:17:38 peter
  1837. * do not finalize function results
  1838. Revision 1.93 2003/04/27 16:30:34 jonas
  1839. * store register para's to memory before copying the valuepara's, because
  1840. that one requires them to be there already (and it calls subroutines ->
  1841. could overwrite those registers)
  1842. Revision 1.92 2003/04/27 11:21:33 peter
  1843. * aktprocdef renamed to current_procdef
  1844. * procinfo renamed to current_procinfo
  1845. * procinfo will now be stored in current_module so it can be
  1846. cleaned up properly
  1847. * gen_main_procsym changed to create_main_proc and release_main_proc
  1848. to also generate a tprocinfo structure
  1849. * fixed unit implicit initfinal
  1850. Revision 1.91 2003/04/27 07:29:50 peter
  1851. * current_procdef cleanup, current_procdef is now always nil when parsing
  1852. a new procdef declaration
  1853. * aktprocsym removed
  1854. * lexlevel removed, use symtable.symtablelevel instead
  1855. * implicit init/final code uses the normal genentry/genexit
  1856. * funcret state checking updated for new funcret handling
  1857. Revision 1.90 2003/04/26 17:21:08 florian
  1858. * fixed passing of fpu values by fpu register
  1859. Revision 1.89 2003/04/25 20:59:33 peter
  1860. * removed funcretn,funcretsym, function result is now in varsym
  1861. and aliases for result and function name are added using absolutesym
  1862. * vs_hidden parameter for funcret passed in parameter
  1863. * vs_hidden fixes
  1864. * writenode changed to printnode and released from extdebug
  1865. * -vp option added to generate a tree.log with the nodetree
  1866. * nicer printnode for statements, callnode
  1867. Revision 1.88 2003/04/23 12:35:34 florian
  1868. * fixed several issues with powerpc
  1869. + applied a patch from Jonas for nested function calls (PowerPC only)
  1870. * ...
  1871. Revision 1.87 2003/04/22 14:33:38 peter
  1872. * removed some notes/hints
  1873. Revision 1.86 2003/04/22 13:47:08 peter
  1874. * fixed C style array of const
  1875. * fixed C array passing
  1876. * fixed left to right with high parameters
  1877. Revision 1.85 2003/04/22 10:09:35 daniel
  1878. + Implemented the actual register allocator
  1879. + Scratch registers unavailable when new register allocator used
  1880. + maybe_save/maybe_restore unavailable when new register allocator used
  1881. Revision 1.84 2003/04/16 09:26:55 jonas
  1882. * assembler procedures now again get a stackframe if they have local
  1883. variables. No space is reserved for a function result however.
  1884. Also, the register parameters aren't automatically saved on the stack
  1885. anymore in assembler procedures.
  1886. Revision 1.83 2003/04/06 21:11:23 olle
  1887. * changed newasmsymbol to newasmsymboldata for data symbols
  1888. Revision 1.82 2003/03/30 20:59:07 peter
  1889. * fix classmethod from classmethod call
  1890. * move BeforeDestruction/AfterConstruction calls to
  1891. genentrycode/genexitcode instead of generating them on the fly
  1892. after a call to a constructor
  1893. Revision 1.81 2003/03/28 19:16:56 peter
  1894. * generic constructor working for i386
  1895. * remove fixed self register
  1896. * esi added as address register for i386
  1897. Revision 1.80 2003/03/17 15:52:20 peter
  1898. * fix range error
  1899. Revision 1.79 2003/03/11 21:46:24 jonas
  1900. * lots of new regallocator fixes, both in generic and ppc-specific code
  1901. (ppc compiler still can't compile the linux system unit though)
  1902. Revision 1.78 2003/02/26 21:15:43 daniel
  1903. * Fixed the optimizer
  1904. Revision 1.77 2003/02/19 22:00:14 daniel
  1905. * Code generator converted to new register notation
  1906. - Horribily outdated todo.txt removed
  1907. Revision 1.76 2003/02/15 22:17:38 carl
  1908. * bugfix of FPU emulation code
  1909. Revision 1.75 2003/01/09 22:00:53 florian
  1910. * fixed some PowerPC issues
  1911. Revision 1.74 2003/01/09 20:41:10 florian
  1912. * fixed broken PowerPC compiler
  1913. Revision 1.73 2003/01/08 18:43:56 daniel
  1914. * Tregister changed into a record
  1915. Revision 1.72 2002/12/29 23:51:43 florian
  1916. * web bug 2214 fixed: ie 10 in const array constructors
  1917. Revision 1.71 2002/12/24 15:56:50 peter
  1918. * stackpointer_alloc added for adjusting ESP. Win32 needs
  1919. this for the pageprotection
  1920. Revision 1.70 2002/12/05 14:39:21 florian
  1921. * added missing then, Carl did you really a make fullcycle :) ?
  1922. Revision 1.69 2002/12/03 22:13:39 carl
  1923. * bugfix of problems with profile code which clobbers some registers
  1924. Revision 1.68 2002/12/01 22:06:59 carl
  1925. * warning of portabilitiy problems with parasize / localsize
  1926. Revision 1.67 2002/11/30 18:44:57 carl
  1927. + profiling support for Win32
  1928. Revision 1.66 2002/11/30 14:39:15 carl
  1929. * try to fix profiling for win32
  1930. Revision 1.65 2002/11/28 23:28:14 florian
  1931. * push_value_para didn't release floatdef locations, fixes tw2045
  1932. Revision 1.64 2002/11/27 02:33:19 peter
  1933. * copy_value_on_stack method added for cdecl record passing
  1934. Revision 1.63 2002/11/25 17:43:18 peter
  1935. * splitted defbase in defutil,symutil,defcmp
  1936. * merged isconvertable and is_equal into compare_defs(_ext)
  1937. * made operator search faster by walking the list only once
  1938. Revision 1.62 2002/11/18 17:31:55 peter
  1939. * pass proccalloption to ret_in_xxx and push_xxx functions
  1940. Revision 1.61 2002/11/17 17:49:08 mazen
  1941. + 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
  1942. Revision 1.60 2002/11/17 16:31:56 carl
  1943. * memory optimization (3-4%) : cleanup of tai fields,
  1944. cleanup of tdef and tsym fields.
  1945. * make it work for m68k
  1946. Revision 1.59 2002/11/15 01:58:51 peter
  1947. * merged changes from 1.0.7 up to 04-11
  1948. - -V option for generating bug report tracing
  1949. - more tracing for option parsing
  1950. - errors for cdecl and high()
  1951. - win32 import stabs
  1952. - win32 records<=8 are returned in eax:edx (turned off by default)
  1953. - heaptrc update
  1954. - more info for temp management in .s file with EXTDEBUG
  1955. Revision 1.58 2002/11/10 19:07:45 mazen
  1956. * SPARC calling mechanism almost OK (as in GCC./mppcsparc )
  1957. Revision 1.57 2002/11/03 20:22:40 mazen
  1958. * parameter handling updated
  1959. Revision 1.56 2002/10/16 19:01:43 peter
  1960. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  1961. implicit exception frames for procedures with initialized variables
  1962. and for constructors. The default is on for compatibility
  1963. Revision 1.55 2002/10/14 19:42:33 peter
  1964. * only use init tables for threadvars
  1965. Revision 1.54 2002/10/06 19:41:30 peter
  1966. * Add finalization of typed consts
  1967. * Finalization of globals in the main program
  1968. Revision 1.53 2002/10/05 15:18:42 carl
  1969. * fix heap leaks
  1970. Revision 1.52 2002/09/30 07:00:46 florian
  1971. * fixes to common code to get the alpha compiler compiled applied
  1972. Revision 1.51 2002/09/22 14:02:35 carl
  1973. * stack checking cannot be called before system unit is initialized
  1974. * MC68020 define
  1975. Revision 1.50 2002/09/17 18:54:03 jonas
  1976. * a_load_reg_reg() now has two size parameters: source and dest. This
  1977. allows some optimizations on architectures that don't encode the
  1978. register size in the register name.
  1979. Revision 1.49 2002/09/10 21:48:30 florian
  1980. * improved handling of procedures with register calling conventions
  1981. Revision 1.48 2002/09/07 15:25:03 peter
  1982. * old logs removed and tabs fixed
  1983. Revision 1.47 2002/09/02 18:44:48 peter
  1984. * fixed (not) pushing of empty parameters
  1985. * fixed implicit initialization/finalization generation
  1986. * fixed/optimized local copy of value arguments init/final
  1987. Revision 1.46 2002/09/01 19:27:34 peter
  1988. * use index register when available for generating a reference with
  1989. only a signle register. Using the base register could possibly
  1990. destroy the framepointer
  1991. Revision 1.45 2002/09/01 18:50:20 peter
  1992. * fixed maybe_save that did not support a reference with only
  1993. a index register. It now also updates the location with the new
  1994. base register only
  1995. Revision 1.44 2002/09/01 14:42:41 peter
  1996. * removevaluepara added to fix the stackpointer so restoring of
  1997. saved registers works
  1998. Revision 1.43 2002/08/25 19:25:18 peter
  1999. * sym.insert_in_data removed
  2000. * symtable.insertvardata/insertconstdata added
  2001. * removed insert_in_data call from symtable.insert, it needs to be
  2002. called separatly. This allows to deref the address calculation
  2003. * procedures now calculate the parast addresses after the procedure
  2004. directives are parsed. This fixes the cdecl parast problem
  2005. * push_addr_param has an extra argument that specifies if cdecl is used
  2006. or not
  2007. Revision 1.42 2002/08/24 18:38:26 peter
  2008. * really use tt_noreuse for exception frame buffers
  2009. Revision 1.41 2002/08/23 16:14:49 peter
  2010. * tempgen cleanup
  2011. * tt_noreuse temp type added that will be used in genentrycode
  2012. Revision 1.40 2002/08/18 10:42:37 florian
  2013. * remaining assembler writer bugs fixed, the errors in the
  2014. system unit are inline assembler problems
  2015. Revision 1.39 2002/08/17 09:23:36 florian
  2016. * first part of procinfo rewrite
  2017. Revision 1.38 2002/08/16 14:24:57 carl
  2018. * issameref() to test if two references are the same (then emit no opcodes)
  2019. + ret_in_reg to replace ret_in_acc
  2020. (fix some register allocation bugs at the same time)
  2021. + save_std_register now has an extra parameter which is the
  2022. usedinproc registers
  2023. Revision 1.37 2002/08/15 15:15:55 carl
  2024. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  2025. * more generic nodes for maths
  2026. * several fixes for better m68k support
  2027. Revision 1.36 2002/08/14 19:25:09 carl
  2028. * fix Florian's last commit for m68k compilation
  2029. Revision 1.35 2002/08/13 21:40:56 florian
  2030. * more fixes for ppc calling conventions
  2031. Revision 1.34 2002/08/12 15:08:39 carl
  2032. + stab register indexes for powerpc (moved from gdb to cpubase)
  2033. + tprocessor enumeration moved to cpuinfo
  2034. + linker in target_info is now a class
  2035. * many many updates for m68k (will soon start to compile)
  2036. - removed some ifdef or correct them for correct cpu
  2037. Revision 1.33 2002/08/11 14:32:27 peter
  2038. * renamed current_library to objectlibrary
  2039. Revision 1.32 2002/08/11 13:24:12 peter
  2040. * saving of asmsymbols in ppu supported
  2041. * asmsymbollist global is removed and moved into a new class
  2042. tasmlibrarydata that will hold the info of a .a file which
  2043. corresponds with a single module. Added librarydata to tmodule
  2044. to keep the library info stored for the module. In the future the
  2045. objectfiles will also be stored to the tasmlibrarydata class
  2046. * all getlabel/newasmsymbol and friends are moved to the new class
  2047. Revision 1.31 2002/08/09 19:16:57 carl
  2048. * stack allocation is now done separately (at the end) of genentrycode
  2049. so temps. can be allocated before.
  2050. * fix generic exception handling
  2051. Revision 1.30 2002/08/06 20:55:21 florian
  2052. * first part of ppc calling conventions fix
  2053. Revision 1.29 2002/08/04 19:09:22 carl
  2054. + added generic exception support (still does not work!)
  2055. + more documentation
  2056. Revision 1.28 2002/07/29 21:23:42 florian
  2057. * more fixes for the ppc
  2058. + wrappers for the tcnvnode.first_* stuff introduced
  2059. }