ncgutil.pas 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310
  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. loadref: boolean;
  915. begin
  916. list:=taasmoutput(arg);
  917. if (tsym(p).typ=varsym) and
  918. (tvarsym(p).varspez=vs_value) and
  919. (paramanager.push_addr_param(tvarsym(p).vartype.def,current_procinfo.procdef.proccalloption)) then
  920. begin
  921. loadref := tvarsym(p).reg.enum = R_NO;
  922. if (loadref) then
  923. reference_reset_base(href1,current_procinfo.framepointer,tvarsym(p).adjusted_address)
  924. else
  925. reference_reset_base(href1,tvarsym(p).reg,0);
  926. if is_open_array(tvarsym(p).vartype.def) or
  927. is_array_of_const(tvarsym(p).vartype.def) then
  928. if loadref then
  929. cg.g_copyvaluepara_openarray(list,href1,tarraydef(tvarsym(p).vartype.def).elesize)
  930. else
  931. internalerror(2003053101)
  932. else
  933. begin
  934. reference_reset_base(href2,current_procinfo.framepointer,tvarsym(p).localvarsym.adjusted_address);
  935. if is_shortstring(tvarsym(p).vartype.def) then
  936. cg.g_copyshortstring(list,href1,href2,tstringdef(tvarsym(p).vartype.def).len,false,loadref)
  937. else
  938. cg.g_concatcopy(list,href1,href2,tvarsym(p).vartype.def.size,true,loadref);
  939. end;
  940. end;
  941. end;
  942. { generates the code for initialisation of local data }
  943. procedure initialize_data(p : tnamedindexitem;arg:pointer);
  944. var
  945. href : treference;
  946. list : taasmoutput;
  947. begin
  948. list:=taasmoutput(arg);
  949. if (tsym(p).typ=varsym) and
  950. not(vo_is_local_copy in tvarsym(p).varoptions) and
  951. assigned(tvarsym(p).vartype.def) and
  952. not(is_class(tvarsym(p).vartype.def)) and
  953. tvarsym(p).vartype.def.needs_inittable then
  954. begin
  955. if (cs_implicit_exceptions in aktmoduleswitches) then
  956. include(current_procinfo.flags,pi_needs_implicit_finally);
  957. if tsym(p).owner.symtabletype in [localsymtable,inlinelocalsymtable] then
  958. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address)
  959. else
  960. reference_reset_symbol(href,objectlibrary.newasmsymboldata(tvarsym(p).mangledname),0);
  961. cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
  962. end;
  963. end;
  964. { generates the code for finalisation of local data }
  965. procedure finalize_data(p : tnamedindexitem;arg:pointer);
  966. var
  967. href : treference;
  968. list : taasmoutput;
  969. begin
  970. list:=taasmoutput(arg);
  971. case tsym(p).typ of
  972. varsym :
  973. begin
  974. if not(vo_is_local_copy in tvarsym(p).varoptions) and
  975. not(vo_is_funcret in tvarsym(p).varoptions) and
  976. assigned(tvarsym(p).vartype.def) and
  977. not(is_class(tvarsym(p).vartype.def)) and
  978. tvarsym(p).vartype.def.needs_inittable then
  979. begin
  980. if tsym(p).owner.symtabletype in [localsymtable,inlinelocalsymtable] then
  981. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address)
  982. else
  983. reference_reset_symbol(href,objectlibrary.newasmsymboldata(tvarsym(p).mangledname),0);
  984. cg.g_finalize(list,tvarsym(p).vartype.def,href,false);
  985. end;
  986. end;
  987. typedconstsym :
  988. begin
  989. if ttypedconstsym(p).is_writable and
  990. ttypedconstsym(p).typedconsttype.def.needs_inittable then
  991. begin
  992. reference_reset_symbol(href,objectlibrary.newasmsymboldata(ttypedconstsym(p).mangledname),0);
  993. cg.g_finalize(list,ttypedconstsym(p).typedconsttype.def,href,false);
  994. end;
  995. end;
  996. end;
  997. end;
  998. { generates the code for incrementing the reference count of parameters and
  999. initialize out parameters }
  1000. procedure init_paras(p : tnamedindexitem;arg:pointer);
  1001. var
  1002. href : treference;
  1003. tmpreg : tregister;
  1004. list : taasmoutput;
  1005. begin
  1006. list:=taasmoutput(arg);
  1007. if (tsym(p).typ=varsym) and
  1008. not is_class(tvarsym(p).vartype.def) and
  1009. tvarsym(p).vartype.def.needs_inittable then
  1010. begin
  1011. case tvarsym(p).varspez of
  1012. vs_value :
  1013. begin
  1014. if (cs_implicit_exceptions in aktmoduleswitches) then
  1015. include(current_procinfo.flags,pi_needs_implicit_finally);
  1016. if assigned(tvarsym(p).localvarsym) then
  1017. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).localvarsym.adjusted_address)
  1018. else
  1019. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
  1020. cg.g_incrrefcount(list,tvarsym(p).vartype.def,href,is_open_array(tvarsym(p).vartype.def));
  1021. end;
  1022. vs_out :
  1023. begin
  1024. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
  1025. {$ifdef newra}
  1026. tmpreg:=rg.getaddressregister(list);
  1027. {$else}
  1028. tmpreg:=cg.get_scratch_reg_address(list);
  1029. {$endif}
  1030. cg.a_load_ref_reg(list,OS_ADDR,href,tmpreg);
  1031. reference_reset_base(href,tmpreg,0);
  1032. cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
  1033. {$ifdef newra}
  1034. rg.ungetregisterint(list,tmpreg);
  1035. {$else}
  1036. cg.free_scratch_reg(list,tmpreg);
  1037. {$endif newra}
  1038. end;
  1039. end;
  1040. end;
  1041. end;
  1042. { generates the code for decrementing the reference count of parameters }
  1043. procedure final_paras(p : tnamedindexitem;arg:pointer);
  1044. var
  1045. href : treference;
  1046. list : taasmoutput;
  1047. begin
  1048. list:=taasmoutput(arg);
  1049. if (tsym(p).typ=varsym) and
  1050. not is_class(tvarsym(p).vartype.def) and
  1051. tvarsym(p).vartype.def.needs_inittable then
  1052. begin
  1053. if (tvarsym(p).varspez=vs_value) then
  1054. begin
  1055. if assigned(tvarsym(p).localvarsym) then
  1056. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).localvarsym.adjusted_address)
  1057. else
  1058. reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
  1059. cg.g_decrrefcount(list,tvarsym(p).vartype.def,href,is_open_array(tvarsym(p).vartype.def));
  1060. end;
  1061. end;
  1062. end;
  1063. { Initialize temp ansi/widestrings,interfaces }
  1064. procedure inittempvariables(list:taasmoutput);
  1065. var
  1066. hp : ptemprecord;
  1067. href : treference;
  1068. begin
  1069. hp:=tg.templist;
  1070. while assigned(hp) do
  1071. begin
  1072. if hp^.temptype in [tt_ansistring,tt_freeansistring,
  1073. tt_widestring,tt_freewidestring,
  1074. tt_interfacecom,tt_freeinterfacecom] then
  1075. begin
  1076. if (cs_implicit_exceptions in aktmoduleswitches) then
  1077. include(current_procinfo.flags,pi_needs_implicit_finally);
  1078. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  1079. cg.a_load_const_ref(list,OS_ADDR,0,href);
  1080. end;
  1081. hp:=hp^.next;
  1082. end;
  1083. end;
  1084. procedure finalizetempvariables(list:taasmoutput);
  1085. var
  1086. hp : ptemprecord;
  1087. href : treference;
  1088. begin
  1089. hp:=tg.templist;
  1090. while assigned(hp) do
  1091. begin
  1092. case hp^.temptype of
  1093. tt_ansistring,
  1094. tt_freeansistring :
  1095. begin
  1096. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  1097. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(1));
  1098. cg.a_call_name(list,'FPC_ANSISTR_DECR_REF');
  1099. end;
  1100. tt_widestring,
  1101. tt_freewidestring :
  1102. begin
  1103. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  1104. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(1));
  1105. cg.a_call_name(list,'FPC_WIDESTR_DECR_REF');
  1106. end;
  1107. tt_interfacecom :
  1108. begin
  1109. reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
  1110. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(1));
  1111. cg.a_call_name(list,'FPC_INTF_DECR_REF');
  1112. end;
  1113. end;
  1114. hp:=hp^.next;
  1115. end;
  1116. end;
  1117. procedure initretvalue(list:taasmoutput);
  1118. var
  1119. paraloc : tparalocation;
  1120. href : treference;
  1121. begin
  1122. if not is_void(current_procdef.rettype.def) then
  1123. begin
  1124. { for now the pointer to the result can't be a register }
  1125. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1126. begin
  1127. {$ifdef powerpc}
  1128. { no stack space is allocated in this case -> can't save the result reg on the stack }
  1129. if not(po_assembler in current_procdef.procoptions) then
  1130. {$endif powerpc}
  1131. begin
  1132. paraloc:=paramanager.getfuncretparaloc(current_procdef);
  1133. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.return_offset);
  1134. case paraloc.loc of
  1135. LOC_CREGISTER,
  1136. LOC_REGISTER:
  1137. if not(paraloc.size in [OS_64,OS_S64]) then
  1138. cg.a_load_reg_ref(list,paraloc.size,paraloc.register,href)
  1139. else
  1140. cg64.a_load64_reg_ref(list,paraloc.register64,href);
  1141. LOC_CFPUREGISTER,
  1142. LOC_FPUREGISTER:
  1143. cg.a_load_reg_ref(list,paraloc.size,paraloc.register,href);
  1144. LOC_CMMREGISTER,
  1145. LOC_MMREGISTER:
  1146. cg.a_loadmm_reg_ref(list,paraloc.register,href);
  1147. end;
  1148. end;
  1149. end;
  1150. { initialize return value }
  1151. if (current_procdef.rettype.def.needs_inittable) then
  1152. begin
  1153. {$ifdef powerpc}
  1154. if (po_assembler in current_procdef.procoptions) then
  1155. internalerror(200304161);
  1156. {$endif powerpc}
  1157. if (cs_implicit_exceptions in aktmoduleswitches) then
  1158. include(current_procinfo.flags,pi_needs_implicit_finally);
  1159. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.return_offset);
  1160. cg.g_initialize(list,current_procdef.rettype.def,href,paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption));
  1161. end;
  1162. end;
  1163. end;
  1164. procedure load_return_value(list:TAAsmoutput; var uses_acc,uses_acchi,uses_fpu : boolean);
  1165. var
  1166. href : treference;
  1167. hreg,r,r2 : tregister;
  1168. cgsize : TCGSize;
  1169. begin
  1170. if not is_void(current_procdef.rettype.def) then
  1171. begin
  1172. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.return_offset);
  1173. cgsize:=def_cgsize(current_procdef.rettype.def);
  1174. { Here, we return the function result. In most architectures, the value is
  1175. passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
  1176. function returns in a register and the caller receives it in an other one }
  1177. case current_procdef.rettype.def.deftype of
  1178. orddef,
  1179. enumdef :
  1180. begin
  1181. uses_acc:=true;
  1182. {$ifndef cpu64bit}
  1183. if cgsize in [OS_64,OS_S64] then
  1184. begin
  1185. uses_acchi:=true;
  1186. r.enum:=R_INTREGISTER;
  1187. r.number:=NR_FUNCTION_RETURN64_LOW_REG;
  1188. cg.a_reg_alloc(list,r);
  1189. r2.enum:=R_INTREGISTER;
  1190. r2.number:=NR_FUNCTION_RETURN64_HIGH_REG;
  1191. cg.a_reg_alloc(list,r2);
  1192. cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
  1193. end
  1194. else
  1195. {$endif cpu64bit}
  1196. begin
  1197. hreg.enum:=R_INTREGISTER;
  1198. hreg.number:=(RS_FUNCTION_RETURN_REG shl 8) or cgsize2subreg(cgsize);
  1199. cg.a_load_ref_reg(list,cgsize,href,hreg);
  1200. end;
  1201. end;
  1202. floatdef :
  1203. begin
  1204. uses_fpu := true;
  1205. {$ifdef cpufpemu}
  1206. if cs_fp_emulation in aktmoduleswitches then
  1207. r.enum := FUNCTION_RETURN_REG
  1208. else
  1209. {$endif cpufpemu}
  1210. r.enum:=FPU_RESULT_REG;
  1211. cg.a_loadfpu_ref_reg(list,cgsize,href,r);
  1212. end;
  1213. else
  1214. begin
  1215. if not paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1216. begin
  1217. uses_acc:=true;
  1218. {$ifndef cpu64bit}
  1219. { Win32 can return records in EAX:EDX }
  1220. if cgsize in [OS_64,OS_S64] then
  1221. begin
  1222. uses_acchi:=true;
  1223. r.enum:=R_INTREGISTER;
  1224. r.number:=NR_FUNCTION_RETURN64_LOW_REG;
  1225. cg.a_reg_alloc(list,r);
  1226. r2.enum:=R_INTREGISTER;
  1227. r2.number:=NR_FUNCTION_RETURN64_HIGH_REG;
  1228. cg.a_reg_alloc(list,r2);
  1229. cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
  1230. end
  1231. else
  1232. {$endif cpu64bit}
  1233. begin
  1234. hreg.enum:=R_INTREGISTER;
  1235. hreg.number:=(RS_FUNCTION_RETURN_REG shl 8) or cgsize2subreg(cgsize);
  1236. cg.a_load_ref_reg(list,cgsize,href,hreg);
  1237. end;
  1238. end
  1239. end;
  1240. end;
  1241. end;
  1242. end;
  1243. procedure genentrycode(list : TAAsmoutput;stackframe:longint;inlined : boolean);
  1244. var
  1245. hs : string;
  1246. href : treference;
  1247. stackalloclist : taasmoutput;
  1248. hp : tparaitem;
  1249. rsp : tregister;
  1250. begin
  1251. if not inlined then
  1252. stackalloclist:=taasmoutput.Create;
  1253. { the actual stack allocation code, symbol entry point and
  1254. gdb stabs information is generated AFTER the rest of this
  1255. code, since temp. allocation might occur before - carl
  1256. }
  1257. if assigned(current_procdef.parast) then
  1258. begin
  1259. if not (po_assembler in current_procdef.procoptions) then
  1260. begin
  1261. { move register parameters which aren't regable into memory }
  1262. { we do this before init_paras because that one calls routines which may overwrite these }
  1263. { registers and it also expects the values to be in memory }
  1264. hp:=tparaitem(current_procdef.para.first);
  1265. while assigned(hp) do
  1266. begin
  1267. if Tvarsym(hp.parasym).reg.enum>R_INTREGISTER then
  1268. internalerror(200301081);
  1269. if (tvarsym(hp.parasym).reg.enum<>R_NO) then
  1270. case hp.paraloc.loc of
  1271. LOC_CREGISTER,
  1272. LOC_REGISTER:
  1273. if not(hp.paraloc.size in [OS_S64,OS_64]) then
  1274. cg.a_load_reg_reg(list,hp.paraloc.size,hp.paraloc.size,hp.paraloc.register,tvarsym(hp.parasym).reg)
  1275. else
  1276. internalerror(2003053011);
  1277. // cg64.a_load64_reg_reg(list,hp.paraloc.register64,tvarsym(hp.parasym).reg);
  1278. LOC_CFPUREGISTER,
  1279. LOC_FPUREGISTER:
  1280. cg.a_loadfpu_reg_reg(list,hp.paraloc.register,tvarsym(hp.parasym).reg);
  1281. LOC_REFERENCE,
  1282. LOC_CREFERENCE:
  1283. begin
  1284. reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
  1285. cg.a_load_ref_reg(list,hp.paraloc.size,href,tvarsym(hp.parasym).reg);
  1286. end;
  1287. else
  1288. internalerror(2003053010);
  1289. end
  1290. else if (hp.paraloc.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
  1291. LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
  1292. (tvarsym(hp.parasym).reg.enum=R_NO) then
  1293. begin
  1294. reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
  1295. case hp.paraloc.loc of
  1296. LOC_CREGISTER,
  1297. LOC_REGISTER:
  1298. if not(hp.paraloc.size in [OS_S64,OS_64]) then
  1299. cg.a_load_reg_ref(list,hp.paraloc.size,hp.paraloc.register,href)
  1300. else
  1301. cg64.a_load64_reg_ref(list,hp.paraloc.register64,href);
  1302. LOC_FPUREGISTER,
  1303. LOC_CFPUREGISTER:
  1304. cg.a_loadfpu_reg_ref(list,hp.paraloc.size,hp.paraloc.register,href);
  1305. else
  1306. internalerror(2002081302);
  1307. end;
  1308. end;
  1309. hp:=tparaitem(hp.next);
  1310. end;
  1311. end;
  1312. end;
  1313. { for the save all registers we can simply use a pusha,popa which
  1314. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1315. if (po_saveregisters in current_procdef.procoptions) then
  1316. cg.g_save_all_registers(list)
  1317. else
  1318. { should we save edi,esi,ebx like C ? }
  1319. if (po_savestdregs in current_procdef.procoptions) then
  1320. cg.g_save_standard_registers(list,current_procdef.usedintregisters);
  1321. { Save stackpointer value }
  1322. if not inlined and
  1323. (current_procinfo.framepointer.number<>NR_STACK_POINTER_REG) and
  1324. ((po_savestdregs in current_procdef.procoptions) or
  1325. (po_saveregisters in current_procdef.procoptions)) then
  1326. begin
  1327. tg.GetTemp(list,POINTER_SIZE,tt_noreuse,current_procinfo.save_stackptr_ref);
  1328. rsp.enum:=R_INTREGISTER;
  1329. rsp.number:=NR_STACK_POINTER_REG;
  1330. cg.a_load_reg_ref(list,OS_ADDR,rsp,current_procinfo.save_stackptr_ref);
  1331. end;
  1332. { the actual profile code can clobber some registers,
  1333. therefore if the context must be saved, do it before
  1334. the actual call to the profile code
  1335. }
  1336. if (cs_profile in aktmoduleswitches) and
  1337. not(po_assembler in current_procdef.procoptions) and
  1338. not(inlined) then
  1339. begin
  1340. { non-win32 can call mcout even in main }
  1341. if not (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  1342. cg.g_profilecode(list)
  1343. else
  1344. { wdosx, and win32 should not call mcount before monstartup has been called }
  1345. if not (current_procdef.proctypeoption=potype_proginit) then
  1346. cg.g_profilecode(list);
  1347. end;
  1348. { initialize return value }
  1349. initretvalue(list);
  1350. { initialize local data like ansistrings }
  1351. case current_procdef.proctypeoption of
  1352. potype_unitinit:
  1353. begin
  1354. { this is also used for initialization of variables in a
  1355. program which does not have a globalsymtable }
  1356. if assigned(current_module.globalsymtable) then
  1357. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1358. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1359. end;
  1360. { units have seperate code for initilization and finalization }
  1361. potype_unitfinalize: ;
  1362. { program init/final is generated in separate procedure }
  1363. potype_proginit: ;
  1364. else
  1365. current_procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1366. end;
  1367. { initialisizes temp. ansi/wide string data }
  1368. inittempvariables(list);
  1369. { initialize ansi/widesstring para's }
  1370. if assigned(current_procdef.parast) then
  1371. begin
  1372. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1373. end;
  1374. { generate copies of call by value parameters }
  1375. if not(po_assembler in current_procdef.procoptions) then
  1376. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1377. if (not inlined) then
  1378. begin
  1379. { call startup helpers from main program }
  1380. if (current_procdef.proctypeoption=potype_proginit) then
  1381. begin
  1382. { initialize profiling for win32 }
  1383. if (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1384. (cs_profile in aktmoduleswitches) then
  1385. begin
  1386. reference_reset_symbol(href,objectlibrary.newasmsymboldata('etext'),0);
  1387. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(2));
  1388. reference_reset_symbol(href,objectlibrary.newasmsymboldata('__image_base__'),0);
  1389. cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(2));
  1390. cg.a_call_name(list,'_monstartup');
  1391. end;
  1392. { initialize units }
  1393. cg.a_call_name(list,'FPC_INITIALIZEUNITS');
  1394. end;
  1395. {$ifdef GDB}
  1396. if (cs_debuginfo in aktmoduleswitches) then
  1397. list.concat(Tai_force_line.Create);
  1398. {$endif GDB}
  1399. end;
  1400. if inlined then
  1401. load_regvars(list,nil);
  1402. {************************* Stack allocation **************************}
  1403. { and symbol entry point as well as debug information }
  1404. { will be inserted in front of the rest of this list. }
  1405. { Insert alignment and assembler names }
  1406. if not inlined then
  1407. begin
  1408. { Align, gprof uses 16 byte granularity }
  1409. if (cs_profile in aktmoduleswitches) then
  1410. stackalloclist.concat(Tai_align.Create(16))
  1411. else
  1412. stackalloclist.concat(Tai_align.Create(aktalignment.procalign));
  1413. {$ifdef GDB}
  1414. if (cs_debuginfo in aktmoduleswitches) then
  1415. begin
  1416. if (po_public in current_procdef.procoptions) then
  1417. tprocsym(current_procdef.procsym).is_global:=true;
  1418. current_procdef.concatstabto(stackalloclist);
  1419. tprocsym(current_procdef.procsym).isstabwritten:=true;
  1420. end;
  1421. {$endif GDB}
  1422. repeat
  1423. hs:=current_procdef.aliasnames.getfirst;
  1424. if hs='' then
  1425. break;
  1426. {$ifdef GDB}
  1427. if (cs_debuginfo in aktmoduleswitches) and
  1428. target_info.use_function_relative_addresses then
  1429. stackalloclist.concat(Tai_stab_function_name.Create(strpnew(hs)));
  1430. {$endif GDB}
  1431. if (cs_profile in aktmoduleswitches) or
  1432. (po_public in current_procdef.procoptions) then
  1433. stackalloclist.concat(Tai_symbol.Createname_global(hs,0))
  1434. else
  1435. stackalloclist.concat(Tai_symbol.Createname(hs,0));
  1436. until false;
  1437. stackframe:=stackframe+tg.gettempsize;
  1438. {$ifndef m68k}
  1439. { give a warning if the limit of local variables is reached }
  1440. if stackframe > maxlocalsize then
  1441. Message(cg_w_localsize_too_big);
  1442. {$endif}
  1443. {$ifndef powerpc}
  1444. { at least for the ppc this applies always, so this code isn't usable (FK) }
  1445. { omit stack frame ? }
  1446. if (current_procinfo.framepointer.number=NR_STACK_POINTER_REG) then
  1447. begin
  1448. CGMessage(cg_d_stackframe_omited);
  1449. if stackframe<>0 then
  1450. cg.g_stackpointer_alloc(stackalloclist,stackframe);
  1451. end
  1452. else
  1453. {$endif powerpc}
  1454. begin
  1455. if (po_interrupt in current_procdef.procoptions) then
  1456. cg.g_interrupt_stackframe_entry(stackalloclist);
  1457. cg.g_stackframe_entry(stackalloclist,stackframe);
  1458. { never call stack checking before the standard system unit
  1459. has not been initialized
  1460. }
  1461. if (cs_check_stack in aktlocalswitches) and (current_procdef.proctypeoption<>potype_proginit) then
  1462. cg.g_stackcheck(stackalloclist,stackframe);
  1463. end;
  1464. list.insertlist(stackalloclist);
  1465. stackalloclist.free;
  1466. end;
  1467. {************************* End Stack allocation **************************}
  1468. end;
  1469. procedure genexitcode(list : TAAsmoutput;inlined:boolean);
  1470. var
  1471. {$ifdef GDB}
  1472. stabsendlabel : tasmlabel;
  1473. mangled_length : longint;
  1474. p : pchar;
  1475. {$endif GDB}
  1476. okexitlabel : tasmlabel;
  1477. href : treference;
  1478. srsym : tsym;
  1479. usesacc,
  1480. usesacchi,
  1481. usesfpu : boolean;
  1482. rsp,r : Tregister;
  1483. retsize : longint;
  1484. begin
  1485. if aktexitlabel.is_used then
  1486. cg.a_label(list,aktexitlabel);
  1487. cleanup_regvars(list);
  1488. { finalize temporary data }
  1489. finalizetempvariables(list);
  1490. { finalize local data like ansistrings}
  1491. case current_procdef.proctypeoption of
  1492. potype_unitfinalize:
  1493. begin
  1494. { this is also used for initialization of variables in a
  1495. program which does not have a globalsymtable }
  1496. if assigned(current_module.globalsymtable) then
  1497. tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1498. tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1499. end;
  1500. { units/progs have separate code for initialization and finalization }
  1501. potype_unitinit: ;
  1502. { program init/final is generated in separate procedure }
  1503. potype_proginit: ;
  1504. else
  1505. current_procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1506. end;
  1507. { finalize paras data }
  1508. if assigned(current_procdef.parast) then
  1509. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1510. { call __EXIT for main program }
  1511. if (not DLLsource) and
  1512. (not inlined) and
  1513. (current_procdef.proctypeoption=potype_proginit) then
  1514. begin
  1515. cg.a_call_name(list,'FPC_DO_EXIT');
  1516. end;
  1517. { handle return value, this is not done for assembler routines when
  1518. they didn't reference the result variable }
  1519. usesacc:=false;
  1520. usesacchi:=false;
  1521. if not(po_assembler in current_procdef.procoptions) or
  1522. (assigned(current_procdef.funcretsym) and
  1523. (tvarsym(current_procdef.funcretsym).refcount>1)) then
  1524. begin
  1525. if (current_procdef.proctypeoption=potype_constructor) then
  1526. begin
  1527. objectlibrary.getlabel(okexitlabel);
  1528. cg.a_jmp_always(list,okexitlabel);
  1529. { Success exit }
  1530. cg.a_label(list,okexitlabel);
  1531. r.enum:=R_INTREGISTER;
  1532. r.number:=NR_FUNCTION_RETURN_REG;
  1533. cg.a_reg_alloc(list,r);
  1534. { return the self pointer }
  1535. srsym:=tvarsym(current_procdef.parast.search('self'));
  1536. if not assigned(srsym) then
  1537. internalerror(200305058);
  1538. reference_reset_base(href,current_procinfo.framepointer,tvarsym(srsym).adjusted_address);
  1539. cg.a_load_ref_reg(list,OS_ADDR,href,r);
  1540. cg.a_reg_dealloc(list,r);
  1541. usesacc:=true;
  1542. end
  1543. else
  1544. load_return_value(list,usesacc,usesacchi,usesfpu)
  1545. end;
  1546. {$ifdef GDB}
  1547. if ((cs_debuginfo in aktmoduleswitches) and not inlined) then
  1548. begin
  1549. objectlibrary.getlabel(stabsendlabel);
  1550. cg.a_label(list,stabsendlabel);
  1551. end;
  1552. {$endif GDB}
  1553. { Restore stackpointer if it was saved }
  1554. if not inlined and
  1555. (current_procinfo.framepointer.number<>NR_STACK_POINTER_REG) and
  1556. ((po_savestdregs in current_procdef.procoptions) or
  1557. (po_saveregisters in current_procdef.procoptions)) then
  1558. begin
  1559. rsp.enum:=R_INTREGISTER;
  1560. rsp.number:=NR_STACK_POINTER_REG;
  1561. cg.a_load_ref_reg(list,OS_ADDR,current_procinfo.save_stackptr_ref,rsp);
  1562. tg.UngetTemp(list,current_procinfo.save_stackptr_ref);
  1563. end;
  1564. { for the save all registers we can simply use a pusha,popa which
  1565. push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
  1566. if (po_saveregisters in current_procdef.procoptions) then
  1567. cg.g_restore_all_registers(list,usesacc,usesacchi)
  1568. else
  1569. { should we restore edi ? }
  1570. if (po_savestdregs in current_procdef.procoptions) then
  1571. cg.g_restore_standard_registers(list,current_procdef.usedintregisters);
  1572. {$ifndef powerpc}
  1573. { remove stackframe }
  1574. if not inlined then
  1575. begin
  1576. if (current_procinfo.framepointer.number=NR_STACK_POINTER_REG) then
  1577. begin
  1578. if (tg.gettempsize<>0) then
  1579. cg.a_op_const_reg(list,OP_ADD,tg.gettempsize,current_procinfo.framepointer);
  1580. end
  1581. else
  1582. cg.g_restore_frame_pointer(list);
  1583. if not (po_assembler in current_procdef.procoptions) then
  1584. end;
  1585. {$endif}
  1586. { at last, the return is generated }
  1587. if not inlined then
  1588. begin
  1589. if (po_interrupt in current_procdef.procoptions) then
  1590. cg.g_interrupt_stackframe_exit(list,usesacc,usesacchi)
  1591. else
  1592. begin
  1593. if (po_clearstack in current_procdef.procoptions) then
  1594. begin
  1595. retsize:=0;
  1596. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1597. inc(retsize,POINTER_SIZE);
  1598. end
  1599. else
  1600. begin
  1601. retsize:=current_procdef.parast.datasize;
  1602. if current_procdef.parast.address_fixup>target_info.first_parm_offset then
  1603. inc(retsize,current_procdef.parast.address_fixup-target_info.first_parm_offset);
  1604. end;
  1605. cg.g_return_from_proc(list,retsize);
  1606. end;
  1607. end;
  1608. if not inlined then
  1609. list.concat(Tai_symbol_end.Createname(current_procdef.mangledname));
  1610. {$ifdef GDB}
  1611. if (cs_debuginfo in aktmoduleswitches) and not inlined then
  1612. begin
  1613. { define calling EBP as pseudo local var PM }
  1614. { this enables test if the function is a local one !! }
  1615. if assigned(current_procinfo.parent) and
  1616. (current_procdef.parast.symtablelevel>normal_function_level) then
  1617. list.concat(Tai_stabs.Create(strpnew(
  1618. '"parent_ebp:'+tstoreddef(voidpointertype.def).numberstring+'",'+
  1619. tostr(N_LSYM)+',0,0,'+tostr(current_procinfo.framepointer_offset))));
  1620. if (not is_void(current_procdef.rettype.def)) then
  1621. begin
  1622. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1623. list.concat(Tai_stabs.Create(strpnew(
  1624. '"'+current_procdef.procsym.name+':X*'+tstoreddef(current_procdef.rettype.def).numberstring+'",'+
  1625. tostr(N_tsym)+',0,0,'+tostr(current_procinfo.return_offset))))
  1626. else
  1627. list.concat(Tai_stabs.Create(strpnew(
  1628. '"'+current_procdef.procsym.name+':X'+tstoreddef(current_procdef.rettype.def).numberstring+'",'+
  1629. tostr(N_tsym)+',0,0,'+tostr(current_procinfo.return_offset))));
  1630. if (m_result in aktmodeswitches) then
  1631. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1632. list.concat(Tai_stabs.Create(strpnew(
  1633. '"RESULT:X*'+tstoreddef(current_procdef.rettype.def).numberstring+'",'+
  1634. tostr(N_tsym)+',0,0,'+tostr(current_procinfo.return_offset))))
  1635. else
  1636. list.concat(Tai_stabs.Create(strpnew(
  1637. '"RESULT:X'+tstoreddef(current_procdef.rettype.def).numberstring+'",'+
  1638. tostr(N_tsym)+',0,0,'+tostr(current_procinfo.return_offset))));
  1639. end;
  1640. mangled_length:=length(current_procdef.mangledname);
  1641. getmem(p,2*mangled_length+50);
  1642. strpcopy(p,'192,0,0,');
  1643. strpcopy(strend(p),current_procdef.mangledname);
  1644. if (target_info.use_function_relative_addresses) then
  1645. begin
  1646. strpcopy(strend(p),'-');
  1647. strpcopy(strend(p),current_procdef.mangledname);
  1648. end;
  1649. list.concat(Tai_stabn.Create(strnew(p)));
  1650. {List.concat(Tai_stabn.Create(strpnew('192,0,0,'
  1651. +current_procdef.mangledname))));
  1652. p[0]:='2';p[1]:='2';p[2]:='4';
  1653. strpcopy(strend(p),'_end');}
  1654. strpcopy(p,'224,0,0,'+stabsendlabel.name);
  1655. if (target_info.use_function_relative_addresses) then
  1656. begin
  1657. strpcopy(strend(p),'-');
  1658. strpcopy(strend(p),current_procdef.mangledname);
  1659. end;
  1660. list.concatlist(withdebuglist);
  1661. list.concat(Tai_stabn.Create(strnew(p)));
  1662. { strpnew('224,0,0,'
  1663. +current_procdef.mangledname+'_end'))));}
  1664. freemem(p,2*mangled_length+50);
  1665. end;
  1666. {$endif GDB}
  1667. if inlined then
  1668. cleanup_regvars(list);
  1669. end;
  1670. {****************************************************************************
  1671. Inlining
  1672. ****************************************************************************}
  1673. procedure load_inlined_return_value(list:TAAsmoutput);
  1674. var
  1675. href : treference;
  1676. r,r2 : tregister;
  1677. cgsize : TCGSize;
  1678. begin
  1679. if not is_void(current_procdef.rettype.def) then
  1680. begin
  1681. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.return_offset);
  1682. cgsize:=def_cgsize(current_procdef.rettype.def);
  1683. { Here, we return the function result. In most architectures, the value is
  1684. passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
  1685. function returns in a register and the caller receives it in an other one }
  1686. case current_procdef.rettype.def.deftype of
  1687. orddef,
  1688. enumdef :
  1689. begin
  1690. {$ifndef cpu64bit}
  1691. if cgsize in [OS_64,OS_S64] then
  1692. begin
  1693. r:=rg.getregisterint(list,OS_INT);
  1694. r2:=rg.getregisterint(list,OS_INT);
  1695. cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
  1696. end
  1697. else
  1698. {$endif cpu64bit}
  1699. begin
  1700. r:=rg.getregisterint(list,cgsize);
  1701. cg.a_load_ref_reg(list,cgsize,href,r);
  1702. end;
  1703. end;
  1704. floatdef :
  1705. begin
  1706. {$ifdef cpufpemu}
  1707. if cs_fp_emulation in aktmoduleswitches then
  1708. r.enum := FUNCTION_RETURN_REG
  1709. else
  1710. {$endif cpufpemu}
  1711. r.enum:=FPU_RESULT_REG;
  1712. cg.a_loadfpu_ref_reg(list,cgsize,href,r);
  1713. end;
  1714. else
  1715. begin
  1716. if not paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) then
  1717. begin
  1718. {$ifndef cpu64bit}
  1719. { Win32 can return records in EAX:EDX }
  1720. if cgsize in [OS_64,OS_S64] then
  1721. begin
  1722. r:=rg.getregisterint(list,OS_INT);
  1723. r2:=rg.getregisterint(list,OS_INT);
  1724. cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
  1725. end
  1726. else
  1727. {$endif cpu64bit}
  1728. begin
  1729. r:=rg.getregisterint(list,cgsize);
  1730. cg.a_load_ref_reg(list,cgsize,href,r);
  1731. end;
  1732. end
  1733. end;
  1734. end;
  1735. end;
  1736. end;
  1737. procedure geninlineentrycode(list : TAAsmoutput;stackframe:longint);
  1738. begin
  1739. { initialize return value }
  1740. initretvalue(list);
  1741. current_procdef.localst.foreach_static({$ifndef TP}@{$endif}initialize_data,list);
  1742. { initialisizes temp. ansi/wide string data }
  1743. inittempvariables(list);
  1744. { initialize ansi/widesstring para's }
  1745. if assigned(current_procdef.parast) then
  1746. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}init_paras,list);
  1747. { generate copies of call by value parameters }
  1748. if not(po_assembler in current_procdef.procoptions) then
  1749. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
  1750. load_regvars(list,nil);
  1751. end;
  1752. procedure geninlineexitcode(list : TAAsmoutput;inlined:boolean);
  1753. var
  1754. usesacc,
  1755. usesacchi,
  1756. usesfpu : boolean;
  1757. begin
  1758. if aktexitlabel.is_used then
  1759. cg.a_label(list,aktexitlabel);
  1760. cleanup_regvars(list);
  1761. { finalize temporary data }
  1762. finalizetempvariables(list);
  1763. current_procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_data,list);
  1764. { finalize paras data }
  1765. if assigned(current_procdef.parast) then
  1766. current_procdef.parast.foreach_static({$ifndef TP}@{$endif}final_paras,list);
  1767. { handle return value, this is not done for assembler routines when
  1768. they didn't reference the result variable }
  1769. if not(po_assembler in current_procdef.procoptions) or
  1770. (assigned(current_procdef.funcretsym) and
  1771. (tvarsym(current_procdef.funcretsym).refcount>1)) then
  1772. begin
  1773. if (current_procdef.proctypeoption=potype_constructor) then
  1774. internalerror(200305263);
  1775. // load_inlined_return_value(list);
  1776. load_return_value(list,usesacc,usesacchi,usesfpu)
  1777. end;
  1778. cleanup_regvars(list);
  1779. end;
  1780. end.
  1781. {
  1782. $Log$
  1783. Revision 1.115 2003-05-31 20:28:17 jonas
  1784. * changed copyvalueparas so it also supports register parameters
  1785. (except for copy_value_openarray, but that one is seriously broken
  1786. anyway, since it expects that the high parameter will always be in
  1787. memory right after the pointer to the array, while it could just as
  1788. will be in a register)
  1789. Revision 1.114 2003/05/31 15:05:28 peter
  1790. * FUNCTION_RESULT64_LOW/HIGH_REG added for int64 results
  1791. Revision 1.113 2003/05/31 00:48:15 jonas
  1792. * fixed my previous commit
  1793. Revision 1.112 2003/05/30 23:57:08 peter
  1794. * more sparc cleanup
  1795. * accumulator removed, splitted in function_return_reg (called) and
  1796. function_result_reg (caller)
  1797. Revision 1.111 2003/05/30 23:49:18 jonas
  1798. * a_load_loc_reg now has an extra size parameter for the destination
  1799. register (properly fixes what I worked around in revision 1.106 of
  1800. ncgutil.pas)
  1801. Revision 1.110 2003/05/30 18:52:10 jonas
  1802. * fixed bug with intregvars
  1803. * locapara.loc can also be LOC_CFPUREGISTER -> also fixed
  1804. rcgppc.a_param_ref, which previously got bogus size values
  1805. Revision 1.109 2003/05/27 21:19:08 jonas
  1806. * fixed ppc cycle
  1807. Revision 1.108 2003/05/27 14:28:14 jonas
  1808. * patch from Peter for nested procedures
  1809. Revision 1.107 2003/05/26 21:17:17 peter
  1810. * procinlinenode removed
  1811. * aktexit2label removed, fast exit removed
  1812. + tcallnode.inlined_pass_2 added
  1813. Revision 1.106 2003/05/24 11:59:42 jonas
  1814. * fixed integer typeconversion problems
  1815. Revision 1.105 2003/05/23 14:27:35 peter
  1816. * remove some unit dependencies
  1817. * current_procinfo changes to store more info
  1818. Revision 1.104 2003/05/15 18:58:53 peter
  1819. * removed selfpointer_offset, vmtpointer_offset
  1820. * tvarsym.adjusted_address
  1821. * address in localsymtable is now in the real direction
  1822. * removed some obsolete globals
  1823. Revision 1.103 2003/05/14 19:37:25 jonas
  1824. * patch from Peter for int64 function results
  1825. Revision 1.102 2003/05/13 19:14:41 peter
  1826. * failn removed
  1827. * inherited result code check moven to pexpr
  1828. Revision 1.101 2003/05/13 15:16:13 peter
  1829. * removed ret_in_acc, it's the reverse of ret_in_param
  1830. * fixed ret_in_param for win32 cdecl array
  1831. Revision 1.100 2003/05/12 08:08:27 jonas
  1832. * fixed several initialization and finalization related bugs (missing
  1833. tg.direction's, wrong paralocation for decreasing refcount of
  1834. everything but ansistrings)
  1835. Revision 1.99 2003/05/11 21:37:03 peter
  1836. * moved implicit exception frame from ncgutil to psub
  1837. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1838. Revision 1.98 2003/05/11 14:45:12 peter
  1839. * tloadnode does not support objectsymtable,withsymtable anymore
  1840. * withnode cleanup
  1841. * direct with rewritten to use temprefnode
  1842. Revision 1.97 2003/05/10 13:20:23 jonas
  1843. * moved storing of register parameters to memory even earlier in the
  1844. entry code to fix problems with constructors
  1845. Revision 1.96 2003/05/09 17:47:02 peter
  1846. * self moved to hidden parameter
  1847. * removed hdisposen,hnewn,selfn
  1848. Revision 1.95 2003/04/29 07:28:52 michael
  1849. + Patch from peter to fix wrong pushing of ansistring function results in open array
  1850. Revision 1.94 2003/04/28 21:17:38 peter
  1851. * do not finalize function results
  1852. Revision 1.93 2003/04/27 16:30:34 jonas
  1853. * store register para's to memory before copying the valuepara's, because
  1854. that one requires them to be there already (and it calls subroutines ->
  1855. could overwrite those registers)
  1856. Revision 1.92 2003/04/27 11:21:33 peter
  1857. * aktprocdef renamed to current_procdef
  1858. * procinfo renamed to current_procinfo
  1859. * procinfo will now be stored in current_module so it can be
  1860. cleaned up properly
  1861. * gen_main_procsym changed to create_main_proc and release_main_proc
  1862. to also generate a tprocinfo structure
  1863. * fixed unit implicit initfinal
  1864. Revision 1.91 2003/04/27 07:29:50 peter
  1865. * current_procdef cleanup, current_procdef is now always nil when parsing
  1866. a new procdef declaration
  1867. * aktprocsym removed
  1868. * lexlevel removed, use symtable.symtablelevel instead
  1869. * implicit init/final code uses the normal genentry/genexit
  1870. * funcret state checking updated for new funcret handling
  1871. Revision 1.90 2003/04/26 17:21:08 florian
  1872. * fixed passing of fpu values by fpu register
  1873. Revision 1.89 2003/04/25 20:59:33 peter
  1874. * removed funcretn,funcretsym, function result is now in varsym
  1875. and aliases for result and function name are added using absolutesym
  1876. * vs_hidden parameter for funcret passed in parameter
  1877. * vs_hidden fixes
  1878. * writenode changed to printnode and released from extdebug
  1879. * -vp option added to generate a tree.log with the nodetree
  1880. * nicer printnode for statements, callnode
  1881. Revision 1.88 2003/04/23 12:35:34 florian
  1882. * fixed several issues with powerpc
  1883. + applied a patch from Jonas for nested function calls (PowerPC only)
  1884. * ...
  1885. Revision 1.87 2003/04/22 14:33:38 peter
  1886. * removed some notes/hints
  1887. Revision 1.86 2003/04/22 13:47:08 peter
  1888. * fixed C style array of const
  1889. * fixed C array passing
  1890. * fixed left to right with high parameters
  1891. Revision 1.85 2003/04/22 10:09:35 daniel
  1892. + Implemented the actual register allocator
  1893. + Scratch registers unavailable when new register allocator used
  1894. + maybe_save/maybe_restore unavailable when new register allocator used
  1895. Revision 1.84 2003/04/16 09:26:55 jonas
  1896. * assembler procedures now again get a stackframe if they have local
  1897. variables. No space is reserved for a function result however.
  1898. Also, the register parameters aren't automatically saved on the stack
  1899. anymore in assembler procedures.
  1900. Revision 1.83 2003/04/06 21:11:23 olle
  1901. * changed newasmsymbol to newasmsymboldata for data symbols
  1902. Revision 1.82 2003/03/30 20:59:07 peter
  1903. * fix classmethod from classmethod call
  1904. * move BeforeDestruction/AfterConstruction calls to
  1905. genentrycode/genexitcode instead of generating them on the fly
  1906. after a call to a constructor
  1907. Revision 1.81 2003/03/28 19:16:56 peter
  1908. * generic constructor working for i386
  1909. * remove fixed self register
  1910. * esi added as address register for i386
  1911. Revision 1.80 2003/03/17 15:52:20 peter
  1912. * fix range error
  1913. Revision 1.79 2003/03/11 21:46:24 jonas
  1914. * lots of new regallocator fixes, both in generic and ppc-specific code
  1915. (ppc compiler still can't compile the linux system unit though)
  1916. Revision 1.78 2003/02/26 21:15:43 daniel
  1917. * Fixed the optimizer
  1918. Revision 1.77 2003/02/19 22:00:14 daniel
  1919. * Code generator converted to new register notation
  1920. - Horribily outdated todo.txt removed
  1921. Revision 1.76 2003/02/15 22:17:38 carl
  1922. * bugfix of FPU emulation code
  1923. Revision 1.75 2003/01/09 22:00:53 florian
  1924. * fixed some PowerPC issues
  1925. Revision 1.74 2003/01/09 20:41:10 florian
  1926. * fixed broken PowerPC compiler
  1927. Revision 1.73 2003/01/08 18:43:56 daniel
  1928. * Tregister changed into a record
  1929. Revision 1.72 2002/12/29 23:51:43 florian
  1930. * web bug 2214 fixed: ie 10 in const array constructors
  1931. Revision 1.71 2002/12/24 15:56:50 peter
  1932. * stackpointer_alloc added for adjusting ESP. Win32 needs
  1933. this for the pageprotection
  1934. Revision 1.70 2002/12/05 14:39:21 florian
  1935. * added missing then, Carl did you really a make fullcycle :) ?
  1936. Revision 1.69 2002/12/03 22:13:39 carl
  1937. * bugfix of problems with profile code which clobbers some registers
  1938. Revision 1.68 2002/12/01 22:06:59 carl
  1939. * warning of portabilitiy problems with parasize / localsize
  1940. Revision 1.67 2002/11/30 18:44:57 carl
  1941. + profiling support for Win32
  1942. Revision 1.66 2002/11/30 14:39:15 carl
  1943. * try to fix profiling for win32
  1944. Revision 1.65 2002/11/28 23:28:14 florian
  1945. * push_value_para didn't release floatdef locations, fixes tw2045
  1946. Revision 1.64 2002/11/27 02:33:19 peter
  1947. * copy_value_on_stack method added for cdecl record passing
  1948. Revision 1.63 2002/11/25 17:43:18 peter
  1949. * splitted defbase in defutil,symutil,defcmp
  1950. * merged isconvertable and is_equal into compare_defs(_ext)
  1951. * made operator search faster by walking the list only once
  1952. Revision 1.62 2002/11/18 17:31:55 peter
  1953. * pass proccalloption to ret_in_xxx and push_xxx functions
  1954. Revision 1.61 2002/11/17 17:49:08 mazen
  1955. + 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
  1956. Revision 1.60 2002/11/17 16:31:56 carl
  1957. * memory optimization (3-4%) : cleanup of tai fields,
  1958. cleanup of tdef and tsym fields.
  1959. * make it work for m68k
  1960. Revision 1.59 2002/11/15 01:58:51 peter
  1961. * merged changes from 1.0.7 up to 04-11
  1962. - -V option for generating bug report tracing
  1963. - more tracing for option parsing
  1964. - errors for cdecl and high()
  1965. - win32 import stabs
  1966. - win32 records<=8 are returned in eax:edx (turned off by default)
  1967. - heaptrc update
  1968. - more info for temp management in .s file with EXTDEBUG
  1969. Revision 1.58 2002/11/10 19:07:45 mazen
  1970. * SPARC calling mechanism almost OK (as in GCC./mppcsparc )
  1971. Revision 1.57 2002/11/03 20:22:40 mazen
  1972. * parameter handling updated
  1973. Revision 1.56 2002/10/16 19:01:43 peter
  1974. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  1975. implicit exception frames for procedures with initialized variables
  1976. and for constructors. The default is on for compatibility
  1977. Revision 1.55 2002/10/14 19:42:33 peter
  1978. * only use init tables for threadvars
  1979. Revision 1.54 2002/10/06 19:41:30 peter
  1980. * Add finalization of typed consts
  1981. * Finalization of globals in the main program
  1982. Revision 1.53 2002/10/05 15:18:42 carl
  1983. * fix heap leaks
  1984. Revision 1.52 2002/09/30 07:00:46 florian
  1985. * fixes to common code to get the alpha compiler compiled applied
  1986. Revision 1.51 2002/09/22 14:02:35 carl
  1987. * stack checking cannot be called before system unit is initialized
  1988. * MC68020 define
  1989. Revision 1.50 2002/09/17 18:54:03 jonas
  1990. * a_load_reg_reg() now has two size parameters: source and dest. This
  1991. allows some optimizations on architectures that don't encode the
  1992. register size in the register name.
  1993. Revision 1.49 2002/09/10 21:48:30 florian
  1994. * improved handling of procedures with register calling conventions
  1995. Revision 1.48 2002/09/07 15:25:03 peter
  1996. * old logs removed and tabs fixed
  1997. Revision 1.47 2002/09/02 18:44:48 peter
  1998. * fixed (not) pushing of empty parameters
  1999. * fixed implicit initialization/finalization generation
  2000. * fixed/optimized local copy of value arguments init/final
  2001. Revision 1.46 2002/09/01 19:27:34 peter
  2002. * use index register when available for generating a reference with
  2003. only a signle register. Using the base register could possibly
  2004. destroy the framepointer
  2005. Revision 1.45 2002/09/01 18:50:20 peter
  2006. * fixed maybe_save that did not support a reference with only
  2007. a index register. It now also updates the location with the new
  2008. base register only
  2009. Revision 1.44 2002/09/01 14:42:41 peter
  2010. * removevaluepara added to fix the stackpointer so restoring of
  2011. saved registers works
  2012. Revision 1.43 2002/08/25 19:25:18 peter
  2013. * sym.insert_in_data removed
  2014. * symtable.insertvardata/insertconstdata added
  2015. * removed insert_in_data call from symtable.insert, it needs to be
  2016. called separatly. This allows to deref the address calculation
  2017. * procedures now calculate the parast addresses after the procedure
  2018. directives are parsed. This fixes the cdecl parast problem
  2019. * push_addr_param has an extra argument that specifies if cdecl is used
  2020. or not
  2021. Revision 1.42 2002/08/24 18:38:26 peter
  2022. * really use tt_noreuse for exception frame buffers
  2023. Revision 1.41 2002/08/23 16:14:49 peter
  2024. * tempgen cleanup
  2025. * tt_noreuse temp type added that will be used in genentrycode
  2026. Revision 1.40 2002/08/18 10:42:37 florian
  2027. * remaining assembler writer bugs fixed, the errors in the
  2028. system unit are inline assembler problems
  2029. Revision 1.39 2002/08/17 09:23:36 florian
  2030. * first part of procinfo rewrite
  2031. Revision 1.38 2002/08/16 14:24:57 carl
  2032. * issameref() to test if two references are the same (then emit no opcodes)
  2033. + ret_in_reg to replace ret_in_acc
  2034. (fix some register allocation bugs at the same time)
  2035. + save_std_register now has an extra parameter which is the
  2036. usedinproc registers
  2037. Revision 1.37 2002/08/15 15:15:55 carl
  2038. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  2039. * more generic nodes for maths
  2040. * several fixes for better m68k support
  2041. Revision 1.36 2002/08/14 19:25:09 carl
  2042. * fix Florian's last commit for m68k compilation
  2043. Revision 1.35 2002/08/13 21:40:56 florian
  2044. * more fixes for ppc calling conventions
  2045. Revision 1.34 2002/08/12 15:08:39 carl
  2046. + stab register indexes for powerpc (moved from gdb to cpubase)
  2047. + tprocessor enumeration moved to cpuinfo
  2048. + linker in target_info is now a class
  2049. * many many updates for m68k (will soon start to compile)
  2050. - removed some ifdef or correct them for correct cpu
  2051. Revision 1.33 2002/08/11 14:32:27 peter
  2052. * renamed current_library to objectlibrary
  2053. Revision 1.32 2002/08/11 13:24:12 peter
  2054. * saving of asmsymbols in ppu supported
  2055. * asmsymbollist global is removed and moved into a new class
  2056. tasmlibrarydata that will hold the info of a .a file which
  2057. corresponds with a single module. Added librarydata to tmodule
  2058. to keep the library info stored for the module. In the future the
  2059. objectfiles will also be stored to the tasmlibrarydata class
  2060. * all getlabel/newasmsymbol and friends are moved to the new class
  2061. Revision 1.31 2002/08/09 19:16:57 carl
  2062. * stack allocation is now done separately (at the end) of genentrycode
  2063. so temps. can be allocated before.
  2064. * fix generic exception handling
  2065. Revision 1.30 2002/08/06 20:55:21 florian
  2066. * first part of ppc calling conventions fix
  2067. Revision 1.29 2002/08/04 19:09:22 carl
  2068. + added generic exception support (still does not work!)
  2069. + more documentation
  2070. Revision 1.28 2002/07/29 21:23:42 florian
  2071. * more fixes for the ppc
  2072. + wrappers for the tcnvnode.first_* stuff introduced
  2073. }