ncgcal.pas 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate i386 assembler for in call nodes
  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 ncgcal;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cpubase,
  23. globtype,
  24. symdef,node,ncal;
  25. type
  26. tcgcallparanode = class(tcallparanode)
  27. private
  28. tempparaloc : tparalocation;
  29. public
  30. procedure secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;
  31. para_alignment,para_offset : longint);override;
  32. end;
  33. tcgcallnode = class(tcallnode)
  34. private
  35. procedure release_para_temps;
  36. procedure normal_pass_2;
  37. procedure inlined_pass_2;
  38. protected
  39. framepointer_paraloc : tparalocation;
  40. refcountedtemp : treference;
  41. procedure handle_return_value;
  42. {# This routine is used to push the current frame pointer
  43. on the stack. This is used in nested routines where the
  44. value of the frame pointer is always pushed as an extra
  45. parameter.
  46. The default handling is the standard handling used on
  47. most stack based machines, where the frame pointer is
  48. the first invisible parameter.
  49. }
  50. function align_parasize:longint;virtual;
  51. procedure pop_parasize(pop_size:longint);virtual;
  52. procedure push_framepointer;virtual;
  53. procedure free_pushed_framepointer;virtual;
  54. procedure extra_interrupt_code;virtual;
  55. public
  56. procedure pass_2;override;
  57. end;
  58. implementation
  59. uses
  60. systems,
  61. cutils,verbose,globals,
  62. symconst,symbase,symsym,symtable,defutil,paramgr,
  63. {$ifdef GDB}
  64. {$ifdef delphi}
  65. sysutils,
  66. {$else}
  67. strings,
  68. {$endif}
  69. gdb,
  70. {$endif GDB}
  71. cginfo,cgbase,pass_2,
  72. cpuinfo,aasmbase,aasmtai,aasmcpu,
  73. nbas,nmem,nld,ncnv,
  74. {$ifdef x86}
  75. cga,
  76. {$endif x86}
  77. {$ifdef cpu64bit}
  78. cg64f64,
  79. {$else cpu64bit}
  80. cg64f32,
  81. {$endif cpu64bit}
  82. ncgutil,cgobj,tgobj,regvars,rgobj,rgcpu;
  83. {*****************************************************************************
  84. TCGCALLPARANODE
  85. *****************************************************************************}
  86. procedure tcgcallparanode.secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;para_alignment,para_offset : longint);
  87. var
  88. otlabel,
  89. oflabel : tasmlabel;
  90. tmpreg : tregister;
  91. href : treference;
  92. begin
  93. if not(assigned(paraitem.paratype.def) or
  94. assigned(paraitem.parasym)) then
  95. internalerror(200304242);
  96. { set default para_alignment to target_info.stackalignment }
  97. if para_alignment=0 then
  98. para_alignment:=aktalignment.paraalign;
  99. { push from left to right if specified }
  100. if push_from_left_to_right and assigned(right) then
  101. begin
  102. tcallparanode(right).secondcallparan(push_from_left_to_right,
  103. calloption,para_alignment,para_offset);
  104. end;
  105. otlabel:=truelabel;
  106. oflabel:=falselabel;
  107. objectlibrary.getlabel(truelabel);
  108. objectlibrary.getlabel(falselabel);
  109. secondpass(left);
  110. { Allocate (temporary) paralocation }
  111. tempparaloc:=paraitem.paraloc[callerside];
  112. if tempparaloc.loc=LOC_REGISTER then
  113. paramanager.alloctempregs(exprasmlist,tempparaloc)
  114. else
  115. paramanager.allocparaloc(exprasmlist,tempparaloc);
  116. { handle varargs first, because defcoll is not valid }
  117. if (nf_varargs_para in flags) then
  118. begin
  119. if paramanager.push_addr_param(vs_value,left.resulttype.def,calloption) then
  120. begin
  121. inc(pushedparasize,POINTER_SIZE);
  122. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  123. location_release(exprasmlist,left.location);
  124. end
  125. else
  126. push_value_para(exprasmlist,left,vs_value,calloption,para_offset,para_alignment,tempparaloc);
  127. end
  128. { hidden parameters }
  129. else if paraitem.is_hidden then
  130. begin
  131. { don't push a node that already generated a pointer type
  132. by address for implicit hidden parameters }
  133. if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) or
  134. (not(left.resulttype.def.deftype in [pointerdef,classrefdef]) and
  135. paramanager.push_addr_param(paraitem.paratyp,paraitem.paratype.def,calloption)) then
  136. begin
  137. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  138. internalerror(200305071);
  139. inc(pushedparasize,POINTER_SIZE);
  140. if calloption=pocall_inline then
  141. begin
  142. tmpreg:=rg.getaddressregister(exprasmlist);
  143. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  144. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  145. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  146. rg.ungetregisterint(exprasmlist,tmpreg);
  147. end
  148. else
  149. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  150. location_release(exprasmlist,left.location);
  151. end
  152. else
  153. begin
  154. push_value_para(exprasmlist,left,paraitem.paratyp,calloption,
  155. para_offset,para_alignment,tempparaloc);
  156. end;
  157. end
  158. { filter array of const c styled args }
  159. else if is_array_of_const(left.resulttype.def) and (nf_cargs in left.flags) then
  160. begin
  161. { nothing, everything is already pushed }
  162. end
  163. { in codegen.handleread.. paraitem.data is set to nil }
  164. else if assigned(paraitem.paratype.def) and
  165. (paraitem.paratype.def.deftype=formaldef) then
  166. begin
  167. { allow passing of a constant to a const formaldef }
  168. if (tvarsym(paraitem.parasym).varspez=vs_const) and
  169. (left.location.loc=LOC_CONSTANT) then
  170. location_force_mem(exprasmlist,left.location);
  171. { allow @var }
  172. inc(pushedparasize,POINTER_SIZE);
  173. if (left.nodetype=addrn) and
  174. (not(nf_procvarload in left.flags)) then
  175. begin
  176. if calloption=pocall_inline then
  177. begin
  178. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  179. cg.a_load_loc_ref(exprasmlist,OS_ADDR,left.location,href);
  180. end
  181. else
  182. cg.a_param_loc(exprasmlist,left.location,tempparaloc);
  183. location_release(exprasmlist,left.location);
  184. end
  185. else
  186. begin
  187. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  188. internalerror(200304235);
  189. if calloption=pocall_inline then
  190. begin
  191. tmpreg:=rg.getaddressregister(exprasmlist);
  192. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  193. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  194. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  195. rg.ungetregisterint(exprasmlist,tmpreg);
  196. end
  197. else
  198. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  199. location_release(exprasmlist,left.location);
  200. end;
  201. end
  202. (*
  203. { handle call by reference parameter }
  204. else if (paraitem.paratyp in [vs_var,vs_out]) or
  205. { win32 stdcall const parameters are also
  206. call by reference, Delphi compatible }
  207. (paraitem.paratyp=vs_const) and
  208. (calloption=pocall_stdcall) and
  209. (target_info.target=target_i386_win32) then
  210. begin
  211. if (left.location.loc<>LOC_REFERENCE) then
  212. begin
  213. { passing self to a var parameter is allowed in
  214. TP and delphi }
  215. if not((left.location.loc=LOC_CREFERENCE) and
  216. is_self_node(left)) then
  217. internalerror(200106041);
  218. end;
  219. if (paraitem.paratyp=vs_out) and
  220. assigned(paraitem.paratype.def) and
  221. not is_class(paraitem.paratype.def) and
  222. paraitem.paratype.def.needs_inittable then
  223. cg.g_finalize(exprasmlist,paraitem.paratype.def,left.location.reference,false);
  224. inc(pushedparasize,POINTER_SIZE);
  225. if calloption=pocall_inline then
  226. begin
  227. tmpreg:=rg.getaddressregister(exprasmlist);
  228. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  229. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  230. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  231. rg.ungetregisterint(exprasmlist,tmpreg);
  232. end
  233. else
  234. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  235. location_release(exprasmlist,left.location);
  236. end
  237. *)
  238. else
  239. { don't push a node that already generated a pointer type
  240. by address for implicit hidden parameters }
  241. if (not(
  242. paraitem.is_hidden and
  243. (left.resulttype.def.deftype in [pointerdef,classrefdef])
  244. ) and
  245. paramanager.push_addr_param(paraitem.paratyp,paraitem.paratype.def,calloption)) then
  246. begin
  247. { Check for passing a constant to var,out parameter }
  248. if (paraitem.paratyp in [vs_var,vs_out]) and
  249. (left.location.loc<>LOC_REFERENCE) then
  250. begin
  251. { passing self to a var parameter is allowed in
  252. TP and delphi }
  253. if not((left.location.loc=LOC_CREFERENCE) and
  254. is_self_node(left)) then
  255. internalerror(200106041);
  256. end;
  257. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  258. begin
  259. { allow passing nil to a procvardef (methodpointer) }
  260. if (left.nodetype=typeconvn) and
  261. (left.resulttype.def.deftype=procvardef) and
  262. (ttypeconvnode(left).left.nodetype=niln) then
  263. begin
  264. tg.GetTemp(exprasmlist,tcgsize2size[left.location.size],tt_normal,href);
  265. if not (left.location.size in [OS_64,OS_S64]) then
  266. cg.a_load_loc_ref(exprasmlist,left.location.size,left.location,href)
  267. else
  268. cg64.a_load64_loc_ref(exprasmlist,left.location,href);
  269. location_reset(left.location,LOC_REFERENCE,left.location.size);
  270. left.location.reference:=href;
  271. end
  272. else
  273. internalerror(200204011);
  274. end;
  275. inc(pushedparasize,POINTER_SIZE);
  276. if calloption=pocall_inline then
  277. begin
  278. tmpreg:=rg.getaddressregister(exprasmlist);
  279. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  280. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  281. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  282. rg.ungetregisterint(exprasmlist,tmpreg);
  283. end
  284. else
  285. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  286. location_release(exprasmlist,left.location);
  287. end
  288. else
  289. begin
  290. push_value_para(exprasmlist,left,paraitem.paratyp,calloption,
  291. para_offset,para_alignment,tempparaloc);
  292. end;
  293. truelabel:=otlabel;
  294. falselabel:=oflabel;
  295. { update return location in callnode when this is the function
  296. result }
  297. if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) then
  298. begin
  299. location_copy(aktcallnode.location,left.location);
  300. end;
  301. { push from right to left }
  302. if not push_from_left_to_right and assigned(right) then
  303. begin
  304. tcallparanode(right).secondcallparan(push_from_left_to_right,
  305. calloption,para_alignment,para_offset);
  306. end;
  307. end;
  308. {*****************************************************************************
  309. TCGCALLNODE
  310. *****************************************************************************}
  311. procedure tcgcallnode.extra_interrupt_code;
  312. begin
  313. end;
  314. function tcgcallnode.align_parasize:longint;
  315. begin
  316. result:=0;
  317. end;
  318. procedure tcgcallnode.pop_parasize(pop_size:longint);
  319. begin
  320. end;
  321. procedure tcgcallnode.push_framepointer;
  322. var
  323. href : treference;
  324. hregister : tregister;
  325. begin
  326. framepointer_paraloc:=paramanager.getintparaloc(procdefinition.proccalloption,1);
  327. paramanager.allocparaloc(exprasmlist,framepointer_paraloc);
  328. { this routine is itself not nested }
  329. if current_procinfo.procdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel) then
  330. begin
  331. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.parent_framepointer_offset);
  332. cg.a_param_ref(exprasmlist,OS_ADDR,href,framepointer_paraloc);
  333. end
  334. { one nesting level }
  335. else if (current_procinfo.procdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  336. begin
  337. cg.a_param_reg(exprasmlist,OS_ADDR,current_procinfo.framepointer,framepointer_paraloc);
  338. end
  339. { very complex nesting level ... }
  340. else if (current_procinfo.procdef.parast.symtablelevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  341. begin
  342. hregister:=rg.getaddressregister(exprasmlist);
  343. cg.g_load_parent_framepointer(exprasmlist,tprocdef(procdefinition).parast,hregister);
  344. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,framepointer_paraloc);
  345. rg.ungetaddressregister(exprasmlist,hregister);
  346. end;
  347. end;
  348. procedure tcgcallnode.free_pushed_framepointer;
  349. begin
  350. paramanager.freeparaloc(exprasmlist,framepointer_paraloc);
  351. end;
  352. procedure tcgcallnode.handle_return_value;
  353. var
  354. cgsize : tcgsize;
  355. hregister : tregister;
  356. tempnode: tnode;
  357. begin
  358. { structured results are easy to handle.... }
  359. { needed also when result_no_used !! }
  360. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  361. begin
  362. { Location should be setup by the funcret para }
  363. if location.loc<>LOC_REFERENCE then
  364. internalerror(200304241);
  365. end
  366. else
  367. { ansi/widestrings must be registered, so we can dispose them }
  368. if is_ansistring(resulttype.def) or
  369. is_widestring(resulttype.def) then
  370. begin
  371. { the FUNCTION_RESULT_REG is already allocated }
  372. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  373. if not assigned(funcretnode) then
  374. begin
  375. location_reset(location,LOC_CREFERENCE,OS_ADDR);
  376. location.reference:=refcountedtemp;
  377. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,location.reference);
  378. end
  379. else
  380. begin
  381. hregister := rg.getaddressregister(exprasmlist);
  382. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,hregister);
  383. { in case of a regular funcretnode with ret_in_param, the }
  384. { original funcretnode isn't touched -> make sure it's }
  385. { the same here (not sure if it's necessary) }
  386. tempnode := funcretnode.getcopy;
  387. tempnode.pass_2;
  388. location := tempnode.location;
  389. tempnode.free;
  390. cg.g_decrrefcount(exprasmlist,resulttype.def,location.reference, false);
  391. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
  392. rg.ungetregisterint(exprasmlist,hregister);
  393. end;
  394. end
  395. else
  396. { we have only to handle the result if it is used }
  397. if (nf_return_value_used in flags) then
  398. begin
  399. if (resulttype.def.deftype=floatdef) then
  400. begin
  401. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  402. {$ifdef cpufpemu}
  403. if cs_fp_emulation in aktmoduleswitches then
  404. location.register:=NR_FUNCTION_RESULT_REG
  405. else
  406. {$endif cpufpemu}
  407. location.register:=NR_FPU_RESULT_REG;
  408. {$ifdef x86}
  409. inc(trgcpu(rg).fpuvaroffset);
  410. {$else x86}
  411. hregister := rg.getregisterfpu(exprasmlist,location.size);
  412. cg.a_loadfpu_reg_reg(exprasmlist,location.size,location.register,hregister);
  413. location.register := hregister;
  414. {$endif x86}
  415. end
  416. else
  417. begin
  418. cgsize:=def_cgsize(resulttype.def);
  419. { an object constructor is a function with pointer result }
  420. if (procdefinition.proctypeoption=potype_constructor) then
  421. cgsize:=OS_ADDR;
  422. if cgsize<>OS_NO then
  423. begin
  424. location_reset(location,LOC_REGISTER,cgsize);
  425. {$ifndef cpu64bit}
  426. if cgsize in [OS_64,OS_S64] then
  427. begin
  428. { Move the function result to free registers, preferably the
  429. FUNCTION_RESULT_REG/FUNCTION_RESULTHIGH_REG, so no move is necessary.}
  430. { the FUNCTION_RESULT_LOW_REG/FUNCTION_RESULT_HIGH_REG
  431. are already allocated }
  432. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
  433. location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
  434. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_LOW_REG,location.registerlow);
  435. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
  436. location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
  437. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_HIGH_REG,location.registerhigh);
  438. end
  439. else
  440. {$endif cpu64bit}
  441. begin
  442. {Move the function result to a free register, preferably the
  443. FUNCTION_RESULT_REG, so no move is necessary.}
  444. { the FUNCTION_RESULT_REG is already allocated }
  445. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  446. { change register size after the unget because the
  447. getregister was done for the full register }
  448. location.register:=rg.getregisterint(exprasmlist,cgsize);
  449. cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,rg.makeregsize(NR_FUNCTION_RESULT_REG,cgsize),location.register);
  450. end;
  451. end
  452. else
  453. begin
  454. if resulttype.def.size>0 then
  455. internalerror(200305131);
  456. end;
  457. end;
  458. end
  459. else
  460. begin
  461. cgsize:=def_cgsize(resulttype.def);
  462. { an object constructor is a function with pointer result }
  463. if (procdefinition.proctypeoption=potype_constructor) then
  464. cgsize:=OS_ADDR;
  465. if cgsize<>OS_NO then
  466. {$ifndef cpu64bit}
  467. if cgsize in [OS_64,OS_S64] then
  468. begin
  469. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
  470. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
  471. end
  472. else
  473. {$endif cpu64bit}
  474. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  475. location_reset(location,LOC_VOID,OS_NO);
  476. end;
  477. end;
  478. procedure tcgcallnode.release_para_temps;
  479. var
  480. hp : tnode;
  481. ppn : tcallparanode;
  482. begin
  483. { Release temps from parameters }
  484. ppn:=tcallparanode(left);
  485. while assigned(ppn) do
  486. begin
  487. if assigned(ppn.left) then
  488. begin
  489. { don't release the funcret temp }
  490. if not(vo_is_funcret in tvarsym(ppn.paraitem.parasym).varoptions) then
  491. location_freetemp(exprasmlist,ppn.left.location);
  492. { process also all nodes of an array of const }
  493. if ppn.left.nodetype=arrayconstructorn then
  494. begin
  495. if assigned(tarrayconstructornode(ppn.left).left) then
  496. begin
  497. hp:=ppn.left;
  498. while assigned(hp) do
  499. begin
  500. location_freetemp(exprasmlist,tarrayconstructornode(hp).left.location);
  501. hp:=tarrayconstructornode(hp).right;
  502. end;
  503. end;
  504. end;
  505. end;
  506. ppn:=tcallparanode(ppn.right);
  507. end;
  508. end;
  509. procedure tcgcallnode.normal_pass_2;
  510. var
  511. regs_to_push_other : totherregisterset;
  512. unusedstate: pointer;
  513. regs_to_alloc,regs_to_free:Tsuperregisterset;
  514. pushedother : tpushedsavedother;
  515. oldpushedparasize : longint;
  516. { adress returned from an I/O-error }
  517. iolabel : tasmlabel;
  518. { help reference pointer }
  519. href,helpref : treference;
  520. para_alignment,
  521. pop_size : longint;
  522. {$ifndef usecallref}
  523. pvreg,
  524. {$endif usecallref}
  525. vmtreg,vmtreg2 : tregister;
  526. oldaktcallnode : tcallnode;
  527. procedure pushparas;
  528. var
  529. ppn : tcgcallparanode;
  530. begin
  531. { copy all resources to the allocated registers }
  532. ppn:=tcgcallparanode(left);
  533. while assigned(ppn) do
  534. begin
  535. if ppn.tempparaloc.loc=LOC_REGISTER then
  536. begin
  537. paramanager.freeparaloc(exprasmlist,ppn.tempparaloc);
  538. paramanager.allocparaloc(exprasmlist,ppn.paraitem.paraloc[callerside]);
  539. {$ifdef sparc}
  540. case ppn.tempparaloc.size of
  541. OS_F32 :
  542. ppn.tempparaloc.size:=OS_32;
  543. OS_F64 :
  544. ppn.tempparaloc.size:=OS_64;
  545. end;
  546. {$endif sparc}
  547. {$ifndef cpu64bit}
  548. if ppn.tempparaloc.size in [OS_64,OS_S64] then
  549. begin
  550. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,ppn.tempparaloc.registerlow,
  551. ppn.paraitem.paraloc[callerside].registerlow);
  552. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,ppn.tempparaloc.registerhigh,
  553. ppn.paraitem.paraloc[callerside].registerhigh);
  554. end
  555. else
  556. {$endif cpu64bit}
  557. cg.a_load_reg_reg(exprasmlist,ppn.tempparaloc.size,ppn.tempparaloc.size,
  558. ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside].register);
  559. end;
  560. ppn:=tcgcallparanode(ppn.right);
  561. end;
  562. end;
  563. procedure freeparas;
  564. var
  565. ppn : tcgcallparanode;
  566. begin
  567. { free the resources allocated for the parameters }
  568. ppn:=tcgcallparanode(left);
  569. while assigned(ppn) do
  570. begin
  571. if ppn.tempparaloc.loc=LOC_REGISTER then
  572. paramanager.freeparaloc(exprasmlist,ppn.tempparaloc);
  573. paramanager.freeparaloc(exprasmlist,ppn.paraitem.paraloc[callerside]);
  574. ppn:=tcgcallparanode(ppn.right);
  575. end;
  576. { free pushed base pointer }
  577. if (right=nil) and
  578. (current_procinfo.procdef.parast.symtablelevel>=normal_function_level) and
  579. assigned(tprocdef(procdefinition).parast) and
  580. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  581. free_pushed_framepointer;
  582. end;
  583. begin
  584. if not assigned(procdefinition) then
  585. internalerror(200305264);
  586. { calculate the parameter info for the procdef }
  587. if not procdefinition.has_paraloc_info then
  588. begin
  589. paramanager.create_paraloc_info(procdefinition,callerside);
  590. procdefinition.has_paraloc_info:=true;
  591. end;
  592. iolabel:=nil;
  593. rg.saveunusedstate(unusedstate);
  594. if not assigned(funcretnode) then
  595. begin
  596. { if we allocate the temp. location for ansi- or widestrings }
  597. { already here, we avoid later a push/pop }
  598. if is_widestring(resulttype.def) then
  599. begin
  600. tg.gettemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  601. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  602. end
  603. else if is_ansistring(resulttype.def) then
  604. begin
  605. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  606. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  607. end;
  608. end;
  609. if (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_stdcall]) then
  610. para_alignment:=4
  611. else
  612. para_alignment:=aktalignment.paraalign;
  613. regs_to_alloc:=paramanager.get_volatile_registers_int(procdefinition.proccalloption);
  614. regs_to_push_other:=paramanager.get_volatile_registers_fpu(procdefinition.proccalloption);
  615. { Include Function result registers }
  616. if (not is_void(resulttype.def)) then
  617. begin
  618. case procdefinition.funcret_paraloc[callerside].loc of
  619. LOC_REGISTER,LOC_CREGISTER:
  620. begin
  621. {$ifndef cpu64bit}
  622. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  623. begin
  624. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  625. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  626. end
  627. else
  628. {$endif cpu64bit}
  629. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  630. end;
  631. end;
  632. end;
  633. { Save registers destroyed by the call }
  634. rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
  635. { Initialize for pushing the parameters }
  636. oldpushedparasize:=pushedparasize;
  637. pushedparasize:=0;
  638. { Align stack if required }
  639. pop_size:=align_parasize;
  640. { Push parameters }
  641. oldaktcallnode:=aktcallnode;
  642. aktcallnode:=self;
  643. {$ifndef i386}
  644. { process procvar. Done here already, because otherwise it may }
  645. { destroy registers containing a parameter for the actual }
  646. { function call (e.g. if it's a function, its result will }
  647. { overwrite r3, which contains the first parameter) (JM) }
  648. if assigned(right) then
  649. secondpass(right);
  650. if (po_virtualmethod in procdefinition.procoptions) and
  651. assigned(methodpointer) then
  652. begin
  653. secondpass(methodpointer);
  654. location_force_reg(exprasmlist,methodpointer.location,OS_ADDR,false);
  655. { virtual methods require an index }
  656. if tprocdef(procdefinition).extnumber=-1 then
  657. internalerror(200304021);
  658. { VMT should already be loaded in a register }
  659. if methodpointer.location.register=NR_NO then
  660. internalerror(200304022);
  661. { test validity of VMT }
  662. if not(is_interface(tprocdef(procdefinition)._class)) and
  663. not(is_cppclass(tprocdef(procdefinition)._class)) then
  664. cg.g_maybe_testvmt(exprasmlist,methodpointer.location.register,tprocdef(procdefinition)._class);
  665. end;
  666. {$endif not i386}
  667. { Process parameters }
  668. if assigned(left) then
  669. begin
  670. tcallparanode(left).secondcallparan(
  671. (procdefinition.proccalloption in pushleftright_pocalls),procdefinition.proccalloption,
  672. para_alignment,0);
  673. pushparas;
  674. end;
  675. aktcallnode:=oldaktcallnode;
  676. { procedure variable or normal function call ? }
  677. if (right=nil) then
  678. begin
  679. { push base pointer ?}
  680. if (current_procinfo.procdef.parast.symtablelevel>=normal_function_level) and
  681. assigned(tprocdef(procdefinition).parast) and
  682. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  683. push_framepointer;
  684. rg.saveotherregvars(exprasmlist,regs_to_push_other);
  685. if (po_virtualmethod in procdefinition.procoptions) and
  686. assigned(methodpointer) then
  687. begin
  688. {$ifdef i386}
  689. secondpass(methodpointer);
  690. location_force_reg(exprasmlist,methodpointer.location,OS_ADDR,false);
  691. vmtreg:=methodpointer.location.register;
  692. { virtual methods require an index }
  693. if tprocdef(procdefinition).extnumber=-1 then
  694. internalerror(200304021);
  695. { VMT should already be loaded in a register }
  696. if vmtreg=NR_NO then
  697. internalerror(200304022);
  698. { test validity of VMT }
  699. if not(is_interface(tprocdef(procdefinition)._class)) and
  700. not(is_cppclass(tprocdef(procdefinition)._class)) then
  701. cg.g_maybe_testvmt(exprasmlist,vmtreg,tprocdef(procdefinition)._class);
  702. {$else}
  703. vmtreg:=methodpointer.location.register;
  704. {$endif}
  705. { release self }
  706. rg.ungetaddressregister(exprasmlist,vmtreg);
  707. vmtreg2:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  708. rg.ungetregisterint(exprasmlist,vmtreg2);
  709. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
  710. {$ifndef usecallref}
  711. pvreg:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  712. reference_reset_base(href,vmtreg2,
  713. tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber));
  714. rg.ungetregisterint(exprasmlist,pvreg);
  715. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,href,pvreg);
  716. {$endif usecallref}
  717. { free the resources allocated for the parameters }
  718. freeparas;
  719. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  720. { call method }
  721. {$ifdef usecallref}
  722. reference_reset_base(href,vmtreg2,
  723. tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber));
  724. cg.a_call_ref(exprasmlist,href);
  725. {$else usecallref}
  726. cg.a_call_reg(exprasmlist,pvreg);
  727. {$endif usecallref}
  728. end
  729. else
  730. begin
  731. { free the resources allocated for the parameters }
  732. freeparas;
  733. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  734. { Calling interrupt from the same code requires some
  735. extra code }
  736. if (po_interrupt in procdefinition.procoptions) then
  737. extra_interrupt_code;
  738. cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname);
  739. end;
  740. end
  741. else
  742. { now procedure variable case }
  743. begin
  744. {$ifdef i386}
  745. secondpass(right);
  746. {$endif i386}
  747. {$ifdef usecallref}
  748. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  749. begin
  750. helpref:=right.location.reference;
  751. if (helpref.index<>NR_NO) and (helpref.index<>NR_FRAME_POINTER_REG) then
  752. begin
  753. rg.ungetregisterint(exprasmlist,helpref.index);
  754. helpref.index:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  755. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
  756. right.location.reference.index,helpref.index);
  757. end;
  758. if (helpref.base<>NR_NO) and (helpref.base<>NR_FRAME_POINTER_REG) then
  759. begin
  760. rg.ungetregisterint(exprasmlist,helpref.base);
  761. helpref.base:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  762. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
  763. right.location.reference.base,helpref.base);
  764. end;
  765. reference_release(exprasmlist,helpref);
  766. end
  767. else
  768. rg.ungetregisterint(exprasmlist,right.location.register);
  769. location_freetemp(exprasmlist,right.location);
  770. {$else usecallref}
  771. pvreg:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  772. rg.ungetregisterint(exprasmlist,pvreg);
  773. { Only load OS_ADDR from the reference }
  774. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  775. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,right.location.reference,pvreg)
  776. else
  777. cg.a_load_loc_reg(exprasmlist,OS_ADDR,right.location,pvreg);
  778. location_release(exprasmlist,right.location);
  779. location_freetemp(exprasmlist,right.location);
  780. {$endif usecallref}
  781. { free the resources allocated for the parameters }
  782. freeparas;
  783. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  784. { Calling interrupt from the same code requires some
  785. extra code }
  786. if (po_interrupt in procdefinition.procoptions) then
  787. extra_interrupt_code;
  788. rg.saveotherregvars(exprasmlist,ALL_OTHERREGISTERS);
  789. {$ifdef usecallref}
  790. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  791. cg.a_call_ref(exprasmlist,helpref)
  792. else
  793. cg.a_call_reg(exprasmlist,right.location.register);
  794. {$else usecallref}
  795. cg.a_call_reg(exprasmlist,pvreg);
  796. {$endif usecallref}
  797. end;
  798. { Need to remove the parameters from the stack? }
  799. if (procdefinition.proccalloption in clearstack_pocalls) then
  800. begin
  801. { the old pop_size was already included in pushedparasize }
  802. pop_size:=pushedparasize;
  803. { for Cdecl functions we don't need to pop the funcret when it
  804. was pushed by para }
  805. if paramanager.ret_in_param(procdefinition.rettype.def,procdefinition.proccalloption) then
  806. dec(pop_size,POINTER_SIZE);
  807. end;
  808. { Remove parameters/alignment from the stack }
  809. if pop_size>0 then
  810. pop_parasize(pop_size);
  811. { Reserve space for storing parameters that will be pushed }
  812. current_procinfo.allocate_push_parasize(pushedparasize);
  813. { Restore }
  814. pushedparasize:=oldpushedparasize;
  815. rg.restoreunusedstate(unusedstate);
  816. {$ifdef TEMPREGDEBUG}
  817. testregisters32;
  818. {$endif TEMPREGDEBUG}
  819. { Release registers, but not the registers that contain the
  820. function result }
  821. regs_to_free:=regs_to_alloc;
  822. if (not is_void(resulttype.def)) then
  823. begin
  824. case procdefinition.funcret_paraloc[callerside].loc of
  825. LOC_REGISTER,LOC_CREGISTER:
  826. begin
  827. {$ifndef cpu64bit}
  828. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  829. begin
  830. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  831. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  832. end
  833. else
  834. {$endif cpu64bit}
  835. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  836. end;
  837. end;
  838. end;
  839. rg.deallocexplicitregistersint(exprasmlist,regs_to_free);
  840. { handle function results }
  841. if (not is_void(resulttype.def)) then
  842. handle_return_value
  843. else
  844. location_reset(location,LOC_VOID,OS_NO);
  845. { perhaps i/o check ? }
  846. if (cs_check_io in aktlocalswitches) and
  847. (po_iocheck in procdefinition.procoptions) and
  848. not(po_iocheck in current_procinfo.procdef.procoptions) and
  849. { no IO check for methods and procedure variables }
  850. (right=nil) and
  851. not(po_virtualmethod in procdefinition.procoptions) then
  852. begin
  853. rg.allocexplicitregistersint(exprasmlist,paramanager.get_volatile_registers_int(pocall_default));
  854. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  855. rg.deallocexplicitregistersint(exprasmlist,paramanager.get_volatile_registers_int(pocall_default));
  856. end;
  857. { restore registers }
  858. rg.restoreusedotherregisters(exprasmlist,pushedother);
  859. { release temps of paras }
  860. release_para_temps;
  861. { if return value is not used }
  862. if (not(nf_return_value_used in flags)) and (not is_void(resulttype.def)) then
  863. begin
  864. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  865. begin
  866. { data which must be finalized ? }
  867. if (resulttype.def.needs_inittable) then
  868. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  869. { release unused temp }
  870. tg.ungetiftemp(exprasmlist,location.reference)
  871. end
  872. else if location.loc=LOC_FPUREGISTER then
  873. begin
  874. {$ifdef x86}
  875. { release FPU stack }
  876. emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
  877. {
  878. dec(trgcpu(rg).fpuvaroffset);
  879. do NOT decrement as the increment before
  880. is not called for unused results PM }
  881. {$endif x86}
  882. end;
  883. end;
  884. end;
  885. procedure tcgcallnode.inlined_pass_2;
  886. var
  887. regs_to_push_int : Tsuperregisterset;
  888. regs_to_push_other : totherregisterset;
  889. unusedstate: pointer;
  890. pushedother : tpushedsavedother;
  891. oldpushedparasize : longint;
  892. oldaktcallnode : tcallnode;
  893. oldprocdef : tprocdef;
  894. i : longint;
  895. oldprocinfo : tprocinfo;
  896. oldinlining_procedure : boolean;
  897. inlineentrycode,inlineexitcode : TAAsmoutput;
  898. oldregstate: pointer;
  899. old_local_fixup,
  900. old_para_fixup : longint;
  901. usesacc,usesacchi,usesfpu : boolean;
  902. pararef,
  903. localsref : treference;
  904. {$ifdef GDB}
  905. startlabel,endlabel : tasmlabel;
  906. pp : pchar;
  907. mangled_length : longint;
  908. {$endif GDB}
  909. begin
  910. {$warning TODO Fix inlining}
  911. internalerror(200309211);
  912. (*
  913. if not(assigned(procdefinition) and (procdefinition.deftype=procdef)) then
  914. internalerror(200305262);
  915. oldinlining_procedure:=inlining_procedure;
  916. oldprocdef:=current_procinfo.procdef;
  917. oldprocinfo:=current_procinfo;
  918. { we're inlining a procedure }
  919. inlining_procedure:=true;
  920. { calculate the parameter info for the procdef }
  921. if not procdefinition.has_paraloc_info then
  922. begin
  923. paramanager.create_paraloc_info(procdefinition,callerside);
  924. procdefinition.has_paraloc_info:=true;
  925. end;
  926. { deallocate the registers used for the current procedure's regvars }
  927. if assigned(current_procinfo.procdef.regvarinfo) then
  928. begin
  929. with pregvarinfo(current_procinfo.procdef.regvarinfo)^ do
  930. for i := 1 to maxvarregs do
  931. if assigned(regvars[i]) then
  932. store_regvar(exprasmlist,regvars[i].localloc.register);
  933. rg.saveStateForInline(oldregstate);
  934. { make sure the register allocator knows what the regvars in the }
  935. { inlined code block are (JM) }
  936. rg.resetusableregisters;
  937. rg.clearregistercount;
  938. if assigned(tprocdef(procdefinition).regvarinfo) then
  939. with pregvarinfo(tprocdef(procdefinition).regvarinfo)^ do
  940. for i := 1 to maxvarregs do
  941. if assigned(regvars[i]) then
  942. begin
  943. {Fix me!!}
  944. {tmpreg:=rg.makeregsize(regvars[i].reg,OS_INT);
  945. rg.makeregvar(tmpreg);}
  946. internalerror(200301232);
  947. end;
  948. end;
  949. { create temp procinfo }
  950. current_procinfo:=cprocinfo.create(nil);
  951. current_procinfo.procdef:=tprocdef(procdefinition);
  952. { Localsymtable }
  953. current_procinfo.procdef.localst.symtablelevel:=oldprocdef.localst.symtablelevel;
  954. if current_procinfo.procdef.localst.datasize>0 then
  955. begin
  956. old_local_fixup:=current_procinfo.procdef.localst.address_fixup;
  957. tg.GetTemp(exprasmlist,current_procinfo.procdef.localst.datasize,tt_persistent,localsref);
  958. if tg.direction>0 then
  959. current_procinfo.procdef.localst.address_fixup:=localsref.offset
  960. else
  961. current_procinfo.procdef.localst.address_fixup:=localsref.offset+current_procinfo.procdef.localst.datasize;
  962. {$ifdef extdebug}
  963. Comment(V_debug,'inlined local symtable ('+tostr(current_procinfo.procdef.localst.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.localst.address_fixup));
  964. exprasmList.concat(tai_comment.Create(strpnew(
  965. 'inlined local symtable ('+tostr(current_procinfo.procdef.localst.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.localst.address_fixup))));
  966. {$endif extdebug}
  967. end;
  968. { Parasymtable }
  969. current_procinfo.procdef.parast.symtablelevel:=oldprocdef.localst.symtablelevel;
  970. if current_procinfo.procdef.parast.datasize>0 then
  971. begin
  972. old_para_fixup:=current_procinfo.procdef.parast.address_fixup;
  973. tg.GetTemp(exprasmlist,current_procinfo.procdef.parast.datasize,tt_persistent,pararef);
  974. current_procinfo.procdef.parast.address_fixup:=pararef.offset;
  975. {$ifdef extdebug}
  976. Comment(V_debug,'inlined para symtable ('+tostr(current_procinfo.procdef.parast.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.parast.address_fixup));
  977. exprasmList.concat(tai_comment.Create(strpnew(
  978. 'inlined para symtable ('+tostr(current_procinfo.procdef.parast.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.parast.address_fixup))));
  979. {$endif extdebug}
  980. end;
  981. exprasmList.concat(Tai_Marker.Create(InlineStart));
  982. {$ifdef extdebug}
  983. exprasmList.concat(tai_comment.Create(strpnew('Start of inlined proc')));
  984. {$endif extdebug}
  985. {$ifdef GDB}
  986. if (cs_debuginfo in aktmoduleswitches) then
  987. begin
  988. objectlibrary.getaddrlabel(startlabel);
  989. objectlibrary.getaddrlabel(endlabel);
  990. cg.a_label(exprasmlist,startlabel);
  991. tprocdef(procdefinition).localst.symtabletype:=inlinelocalsymtable;
  992. procdefinition.parast.symtabletype:=inlineparasymtable;
  993. { Here we must include the para and local symtable info }
  994. procdefinition.concatstabto(withdebuglist);
  995. { set it back for safety }
  996. tprocdef(procdefinition).localst.symtabletype:=localsymtable;
  997. procdefinition.parast.symtabletype:=parasymtable;
  998. mangled_length:=length(oldprocdef.mangledname);
  999. getmem(pp,mangled_length+50);
  1000. strpcopy(pp,'192,0,0,'+startlabel.name);
  1001. if (target_info.use_function_relative_addresses) then
  1002. begin
  1003. strpcopy(strend(pp),'-');
  1004. strpcopy(strend(pp),oldprocdef.mangledname);
  1005. end;
  1006. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1007. end;
  1008. {$endif GDB}
  1009. rg.saveunusedstate(unusedstate);
  1010. { if we allocate the temp. location for ansi- or widestrings }
  1011. { already here, we avoid later a push/pop }
  1012. if is_widestring(resulttype.def) then
  1013. begin
  1014. tg.GetTemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  1015. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  1016. end
  1017. else if is_ansistring(resulttype.def) then
  1018. begin
  1019. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  1020. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  1021. end;
  1022. { save all used registers and possible registers
  1023. used for the return value }
  1024. regs_to_push_int:=paramanager.get_volatile_registers_int(procdefinition.proccalloption);
  1025. regs_to_push_other:=paramanager.get_volatile_registers_fpu(procdefinition.proccalloption);
  1026. if (not is_void(resulttype.def)) then
  1027. begin
  1028. case procdefinition.funcret_paraloc[callerside].loc of
  1029. LOC_REGISTER,LOC_CREGISTER:
  1030. begin
  1031. {$ifndef cpu64bit}
  1032. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  1033. begin
  1034. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  1035. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  1036. end
  1037. else
  1038. {$endif cpu64bit}
  1039. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  1040. end;
  1041. end;
  1042. end;
  1043. rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
  1044. { Initialize for pushing the parameters }
  1045. oldpushedparasize:=pushedparasize;
  1046. pushedparasize:=0;
  1047. { Push parameters }
  1048. oldaktcallnode:=aktcallnode;
  1049. aktcallnode:=self;
  1050. if assigned(left) then
  1051. begin
  1052. { we push from right to left, so start with parameters at the end of
  1053. the parameter block }
  1054. tcallparanode(left).secondcallparan(
  1055. (procdefinition.proccalloption in pushleftright_pocalls),procdefinition.proccalloption,
  1056. 0,procdefinition.parast.address_fixup+procdefinition.parast.datasize);
  1057. end;
  1058. aktcallnode:=oldaktcallnode;
  1059. rg.saveotherregvars(exprasmlist,regs_to_push_other);
  1060. { takes care of local data initialization }
  1061. inlineentrycode:=TAAsmoutput.Create;
  1062. inlineexitcode:=TAAsmoutput.Create;
  1063. gen_initialize_code(inlineentrycode,true);
  1064. if po_assembler in current_procinfo.procdef.procoptions then
  1065. inlineentrycode.insert(Tai_marker.Create(asmblockstart));
  1066. exprasmList.concatlist(inlineentrycode);
  1067. { process the inline code }
  1068. secondpass(inlinecode);
  1069. { Reserve space for storing parameters that will be pushed }
  1070. current_procinfo.allocate_push_parasize(pushedparasize);
  1071. { Restore }
  1072. pushedparasize:=oldpushedparasize;
  1073. rg.restoreunusedstate(unusedstate);
  1074. {$ifdef TEMPREGDEBUG}
  1075. testregisters32;
  1076. {$endif TEMPREGDEBUG}
  1077. gen_finalize_code(inlineexitcode,true);
  1078. gen_load_return_value(inlineexitcode,usesacc,usesacchi,usesfpu);
  1079. if po_assembler in current_procinfo.procdef.procoptions then
  1080. inlineexitcode.concat(Tai_marker.Create(asmblockend));
  1081. exprasmList.concatlist(inlineexitcode);
  1082. inlineentrycode.free;
  1083. inlineexitcode.free;
  1084. {$ifdef extdebug}
  1085. exprasmList.concat(tai_comment.Create(strpnew('End of inlined proc')));
  1086. {$endif extdebug}
  1087. exprasmList.concat(Tai_Marker.Create(InlineEnd));
  1088. {we can free the local data now, reset also the fixup address }
  1089. if current_procinfo.procdef.localst.datasize>0 then
  1090. begin
  1091. tg.UnGetTemp(exprasmlist,localsref);
  1092. current_procinfo.procdef.localst.address_fixup:=old_local_fixup;
  1093. end;
  1094. {we can free the para data now, reset also the fixup address }
  1095. if current_procinfo.procdef.parast.datasize>0 then
  1096. begin
  1097. tg.UnGetTemp(exprasmlist,pararef);
  1098. current_procinfo.procdef.parast.address_fixup:=old_para_fixup;
  1099. end;
  1100. { handle function results }
  1101. if (not is_void(resulttype.def)) then
  1102. handle_return_value
  1103. else
  1104. location_reset(location,LOC_VOID,OS_NO);
  1105. { perhaps i/o check ? }
  1106. if (cs_check_io in aktlocalswitches) and
  1107. (po_iocheck in procdefinition.procoptions) and
  1108. not(po_iocheck in current_procinfo.procdef.procoptions) and
  1109. { no IO check for methods and procedure variables }
  1110. (right=nil) and
  1111. not(po_virtualmethod in procdefinition.procoptions) then
  1112. begin
  1113. rg.allocexplicitregistersint(exprasmlist,paramanager.get_volatile_registers_int(pocall_default));
  1114. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  1115. rg.deallocexplicitregistersint(exprasmlist,paramanager.get_volatile_registers_int(pocall_default));
  1116. end;
  1117. { restore registers }
  1118. rg.restoreusedotherregisters(exprasmlist,pushedother);
  1119. { release temps of paras }
  1120. release_para_temps;
  1121. { if return value is not used }
  1122. if (not is_void(resulttype.def)) and
  1123. (not(nf_return_value_used in flags)) then
  1124. begin
  1125. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  1126. begin
  1127. { data which must be finalized ? }
  1128. if (resulttype.def.needs_inittable) then
  1129. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  1130. { release unused temp }
  1131. tg.ungetiftemp(exprasmlist,location.reference)
  1132. end
  1133. else if location.loc=LOC_FPUREGISTER then
  1134. begin
  1135. {$ifdef x86}
  1136. { release FPU stack }
  1137. emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
  1138. {
  1139. dec(trgcpu(rg).fpuvaroffset);
  1140. do NOT decrement as the increment before
  1141. is not called for unused results PM }
  1142. {$endif x86}
  1143. end;
  1144. end;
  1145. { release procinfo }
  1146. current_procinfo.free;
  1147. current_procinfo:=oldprocinfo;
  1148. {$ifdef GDB}
  1149. if (cs_debuginfo in aktmoduleswitches) then
  1150. begin
  1151. cg.a_label(exprasmlist,endlabel);
  1152. strpcopy(pp,'224,0,0,'+endlabel.name);
  1153. if (target_info.use_function_relative_addresses) then
  1154. begin
  1155. strpcopy(strend(pp),'-');
  1156. strpcopy(strend(pp),oldprocdef.mangledname);
  1157. end;
  1158. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1159. freemem(pp,mangled_length+50);
  1160. end;
  1161. {$endif GDB}
  1162. { restore }
  1163. current_procinfo.procdef:=oldprocdef;
  1164. inlining_procedure:=oldinlining_procedure;
  1165. { reallocate the registers used for the current procedure's regvars, }
  1166. { since they may have been used and then deallocated in the inlined }
  1167. { procedure (JM) }
  1168. if assigned(current_procinfo.procdef.regvarinfo) then
  1169. rg.restoreStateAfterInline(oldregstate);
  1170. *)
  1171. end;
  1172. procedure tcgcallnode.pass_2;
  1173. begin
  1174. if assigned(inlinecode) then
  1175. inlined_pass_2
  1176. else
  1177. normal_pass_2;
  1178. end;
  1179. begin
  1180. ccallparanode:=tcgcallparanode;
  1181. ccallnode:=tcgcallnode;
  1182. end.
  1183. {
  1184. $Log$
  1185. Revision 1.116 2003-09-23 17:56:05 peter
  1186. * locals and paras are allocated in the code generation
  1187. * tvarsym.localloc contains the location of para/local when
  1188. generating code for the current procedure
  1189. Revision 1.115 2003/09/16 16:17:01 peter
  1190. * varspez in calls to push_addr_param
  1191. Revision 1.114 2003/09/14 19:17:39 peter
  1192. * don't use a_call_ref because it can use a parameter register
  1193. as temp
  1194. Revision 1.113 2003/09/11 11:54:59 florian
  1195. * improved arm code generation
  1196. * move some protected and private field around
  1197. * the temp. register for register parameters/arguments are now released
  1198. before the move to the parameter register is done. This improves
  1199. the code in a lot of cases.
  1200. Revision 1.112 2003/09/10 08:31:47 marco
  1201. * Patch from Peter for paraloc
  1202. Revision 1.111 2003/09/07 22:09:35 peter
  1203. * preparations for different default calling conventions
  1204. * various RA fixes
  1205. Revision 1.110 2003/09/04 15:39:58 peter
  1206. * released useparatemp
  1207. Revision 1.109 2003/09/03 15:55:00 peter
  1208. * NEWRA branch merged
  1209. Revision 1.108.2.4 2003/09/01 21:02:55 peter
  1210. * sparc updates for new tregister
  1211. Revision 1.108.2.3 2003/08/31 21:07:44 daniel
  1212. * callparatemp ripped
  1213. Revision 1.108.2.2 2003/08/29 17:28:59 peter
  1214. * next batch of updates
  1215. Revision 1.108.2.1 2003/08/27 20:23:55 peter
  1216. * remove old ra code
  1217. Revision 1.108 2003/08/21 22:14:16 olle
  1218. - removed parameter from fpc_iocheck
  1219. Revision 1.107 2003/08/17 16:59:20 jonas
  1220. * fixed regvars so they work with newra (at least for ppc)
  1221. * fixed some volatile register bugs
  1222. + -dnotranslation option for -dnewra, which causes the registers not to
  1223. be translated from virtual to normal registers. Requires support in
  1224. the assembler writer as well, which is only implemented in aggas/
  1225. agppcgas currently
  1226. Revision 1.106 2003/08/16 18:56:40 marco
  1227. * fix from Jonas.
  1228. Revision 1.105 2003/08/11 21:18:20 peter
  1229. * start of sparc support for newra
  1230. Revision 1.104 2003/08/11 14:22:06 mazen
  1231. - dupplicated code removed
  1232. Revision 1.103 2003/07/23 11:01:14 jonas
  1233. * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
  1234. pairs round calls to helpers
  1235. Revision 1.102 2003/07/21 13:51:50 jonas
  1236. * fixed 64bit int results with -dnewra (you can't free both registers and
  1237. then allocate two new ones, because then the registers could be reversed
  1238. afterwards -> you get something like "movl %eax, %edx; movl %edx,%eax")
  1239. Revision 1.101 2003/07/08 21:24:59 peter
  1240. * sparc fixes
  1241. Revision 1.100 2003/07/06 21:50:33 jonas
  1242. * fixed ppc compilation problems and changed VOLATILE_REGISTERS for x86
  1243. so that it doesn't include ebp and esp anymore
  1244. Revision 1.99 2003/07/06 17:58:22 peter
  1245. * framepointer fixes for sparc
  1246. * parent framepointer code more generic
  1247. Revision 1.98 2003/07/06 15:31:20 daniel
  1248. * Fixed register allocator. *Lots* of fixes.
  1249. Revision 1.97 2003/07/05 20:21:26 jonas
  1250. * create_paraloc_info() is now called separately for the caller and
  1251. callee info
  1252. * fixed ppc cycle
  1253. Revision 1.96 2003/07/02 22:18:04 peter
  1254. * paraloc splitted in paraloc[callerside],calleeparaloc
  1255. * sparc calling convention updates
  1256. Revision 1.95 2003/06/17 16:34:44 jonas
  1257. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  1258. * renamed all_intregisters to paramanager.get_volatile_registers_int(pocall_default) and made it
  1259. processor dependent
  1260. Revision 1.94 2003/06/15 16:52:02 jonas
  1261. * release function result registers if the functino result isn't used
  1262. * don't allocate function result register with -dnewra if there is none
  1263. * some optimizations for non-x86 processor (don't save any registers
  1264. before a call)
  1265. Revision 1.93 2003/06/13 21:19:30 peter
  1266. * current_procdef removed, use current_procinfo.procdef instead
  1267. Revision 1.92 2003/06/12 21:10:50 peter
  1268. * newra fixes
  1269. Revision 1.91 2003/06/12 18:38:45 jonas
  1270. * deallocate parameter registers in time for newra
  1271. * for non-i386, procvars and methodpointers always have to be processed
  1272. in advance, whether or not newra is defined
  1273. Revision 1.90 2003/06/09 14:54:26 jonas
  1274. * (de)allocation of registers for parameters is now performed properly
  1275. (and checked on the ppc)
  1276. - removed obsolete allocation of all parameter registers at the start
  1277. of a procedure (and deallocation at the end)
  1278. Revision 1.89 2003/06/09 12:23:29 peter
  1279. * init/final of procedure data splitted from genentrycode
  1280. * use asmnode getposition to insert final at the correct position
  1281. als for the implicit try...finally
  1282. Revision 1.88 2003/06/08 20:01:53 jonas
  1283. * optimized assignments with on the right side a function that returns
  1284. an ansi- or widestring
  1285. Revision 1.87 2003/06/08 18:21:47 jonas
  1286. * fixed weird error in the copyleft statement :)
  1287. Revision 1.86 2003/06/07 18:57:04 jonas
  1288. + added freeintparaloc
  1289. * ppc get/freeintparaloc now check whether the parameter regs are
  1290. properly allocated/deallocated (and get an extra list para)
  1291. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  1292. * fixed lot of missing pi_do_call's
  1293. Revision 1.85 2003/06/04 06:43:36 jonas
  1294. * fixed double secondpassing of procvar loads
  1295. Revision 1.84 2003/06/03 21:11:09 peter
  1296. * cg.a_load_* get a from and to size specifier
  1297. * makeregsize only accepts newregister
  1298. * i386 uses generic tcgnotnode,tcgunaryminus
  1299. Revision 1.83 2003/06/03 20:27:02 daniel
  1300. * Restored original methodpointer code for non newra case
  1301. Revision 1.82 2003/06/03 13:01:59 daniel
  1302. * Register allocator finished
  1303. Revision 1.81 2003/06/01 21:38:06 peter
  1304. * getregisterfpu size parameter added
  1305. * op_const_reg size parameter added
  1306. * sparc updates
  1307. Revision 1.80 2003/05/31 15:05:28 peter
  1308. * FUNCTION_RESULT64_LOW/HIGH_REG added for int64 results
  1309. Revision 1.79 2003/05/31 00:59:44 peter
  1310. * typo in FUNCTION_RESULT_REG
  1311. Revision 1.78 2003/05/30 23:57:08 peter
  1312. * more sparc cleanup
  1313. * accumulator removed, splitted in function_return_reg (called) and
  1314. function_result_reg (caller)
  1315. Revision 1.77 2003/05/29 10:05:40 jonas
  1316. * free callparatemps created for call-by-reference parameters
  1317. Revision 1.76 2003/05/28 23:58:18 jonas
  1318. * added missing initialization of rg.usedintin,byproc
  1319. * ppc now also saves/restores used fpu registers
  1320. * ncgcal doesn't add used registers to usedby/inproc anymore, except for
  1321. i386
  1322. Revision 1.75 2003/05/26 21:17:17 peter
  1323. * procinlinenode removed
  1324. * aktexit2label removed, fast exit removed
  1325. + tcallnode.inlined_pass_2 added
  1326. Revision 1.74 2003/05/25 11:34:17 peter
  1327. * methodpointer self pushing fixed
  1328. Revision 1.73 2003/05/25 08:59:16 peter
  1329. * inline fixes
  1330. Revision 1.72 2003/05/24 13:36:54 jonas
  1331. * save fpu results in a normal fpu register on non-x86 processors
  1332. Revision 1.71 2003/05/23 19:35:50 jonas
  1333. - undid previous commit, it was wrong
  1334. Revision 1.70 2003/05/23 19:11:58 jonas
  1335. * fixed tests for whether a certain int register is unused
  1336. Revision 1.69 2003/05/23 18:01:56 jonas
  1337. * fixed ppc compiler
  1338. Revision 1.68 2003/05/23 14:27:35 peter
  1339. * remove some unit dependencies
  1340. * current_procinfo changes to store more info
  1341. Revision 1.67 2003/05/17 13:30:08 jonas
  1342. * changed tt_persistant to tt_persistent :)
  1343. * tempcreatenode now doesn't accept a boolean anymore for persistent
  1344. temps, but a ttemptype, so you can also create ansistring temps etc
  1345. Revision 1.66 2003/05/16 14:33:31 peter
  1346. * regvar fixes
  1347. Revision 1.65 2003/05/15 18:58:53 peter
  1348. * removed selfpointer_offset, vmtpointer_offset
  1349. * tvarsym.adjusted_address
  1350. * address in localsymtable is now in the real direction
  1351. * removed some obsolete globals
  1352. Revision 1.64 2003/05/14 19:36:54 jonas
  1353. * patch from Peter for int64 function results
  1354. Revision 1.63 2003/05/13 19:14:41 peter
  1355. * failn removed
  1356. * inherited result code check moven to pexpr
  1357. Revision 1.62 2003/05/13 15:18:18 peter
  1358. * generate code for procvar first before pushing parameters. Made
  1359. the already existing code for powerpc available for all platforms
  1360. Revision 1.61 2003/05/12 18:17:55 jonas
  1361. * moved fpc_check_object call earlier for the ppc, so it can't destroy
  1362. already-loaded parameter registers
  1363. Revision 1.60 2003/05/11 21:48:38 jonas
  1364. * fixed procvar bug on the ppc (load procvar before loading para's,
  1365. because the procvar may otherwise destroy the already loaded paras)
  1366. Revision 1.59 2003/05/09 17:47:02 peter
  1367. * self moved to hidden parameter
  1368. * removed hdisposen,hnewn,selfn
  1369. Revision 1.58 2003/05/05 14:53:16 peter
  1370. * vs_hidden replaced by is_hidden boolean
  1371. Revision 1.57 2003/04/30 20:53:32 florian
  1372. * error when address of an abstract method is taken
  1373. * fixed some x86-64 problems
  1374. * merged some more x86-64 and i386 code
  1375. Revision 1.56 2003/04/29 07:28:52 michael
  1376. + Patch from peter to fix wrong pushing of ansistring function results in open array
  1377. Revision 1.55 2003/04/27 11:21:33 peter
  1378. * aktprocdef renamed to current_procinfo.procdef
  1379. * procinfo renamed to current_procinfo
  1380. * procinfo will now be stored in current_module so it can be
  1381. cleaned up properly
  1382. * gen_main_procsym changed to create_main_proc and release_main_proc
  1383. to also generate a tprocinfo structure
  1384. * fixed unit implicit initfinal
  1385. Revision 1.54 2003/04/27 07:29:50 peter
  1386. * current_procinfo.procdef cleanup, current_procinfo.procdef is now always nil when parsing
  1387. a new procdef declaration
  1388. * aktprocsym removed
  1389. * lexlevel removed, use symtable.symtablelevel instead
  1390. * implicit init/final code uses the normal genentry/genexit
  1391. * funcret state checking updated for new funcret handling
  1392. Revision 1.53 2003/04/25 20:59:33 peter
  1393. * removed funcretn,funcretsym, function result is now in varsym
  1394. and aliases for result and function name are added using absolutesym
  1395. * vs_hidden parameter for funcret passed in parameter
  1396. * vs_hidden fixes
  1397. * writenode changed to printnode and released from extdebug
  1398. * -vp option added to generate a tree.log with the nodetree
  1399. * nicer printnode for statements, callnode
  1400. Revision 1.52 2003/04/25 08:25:26 daniel
  1401. * Ifdefs around a lot of calls to cleartempgen
  1402. * Fixed registers that are allocated but not freed in several nodes
  1403. * Tweak to register allocator to cause less spills
  1404. * 8-bit registers now interfere with esi,edi and ebp
  1405. Compiler can now compile rtl successfully when using new register
  1406. allocator
  1407. Revision 1.51 2003/04/22 23:50:22 peter
  1408. * firstpass uses expectloc
  1409. * checks if there are differences between the expectloc and
  1410. location.loc from secondpass in EXTDEBUG
  1411. Revision 1.50 2003/04/22 14:33:38 peter
  1412. * removed some notes/hints
  1413. Revision 1.49 2003/04/22 13:47:08 peter
  1414. * fixed C style array of const
  1415. * fixed C array passing
  1416. * fixed left to right with high parameters
  1417. Revision 1.48 2003/04/22 10:09:34 daniel
  1418. + Implemented the actual register allocator
  1419. + Scratch registers unavailable when new register allocator used
  1420. + maybe_save/maybe_restore unavailable when new register allocator used
  1421. Revision 1.47 2003/04/22 09:49:44 peter
  1422. * do not load self when calling a non-inherited class constructor
  1423. Revision 1.46 2003/04/21 20:03:32 peter
  1424. * forgot to copy vmtrefaddr to selfrefaddr when self=vmt
  1425. Revision 1.45 2003/04/21 13:53:16 jonas
  1426. - removed copying of all paras when secondpassing a callnode (this used
  1427. to be necessary for inlinign support, but currently the whole inlined
  1428. procedure is already copied in advance). Note that the compiler crashes
  1429. when compiling ucomplex with -dTEST_INLINE (also after fixing the
  1430. syntax errors), but that was also the case before this change.
  1431. Revision 1.44 2003/04/10 17:57:52 peter
  1432. * vs_hidden released
  1433. Revision 1.43 2003/04/06 21:11:23 olle
  1434. * changed newasmsymbol to newasmsymboldata for data symbols
  1435. Revision 1.42 2003/04/04 15:38:56 peter
  1436. * moved generic code from n386cal to ncgcal, i386 now also
  1437. uses the generic ncgcal
  1438. Revision 1.41 2003/03/28 19:16:56 peter
  1439. * generic constructor working for i386
  1440. * remove fixed self register
  1441. * esi added as address register for i386
  1442. Revision 1.40 2003/03/06 11:35:50 daniel
  1443. * Fixed internalerror 7843 issue
  1444. Revision 1.39 2003/02/19 22:00:14 daniel
  1445. * Code generator converted to new register notation
  1446. - Horribily outdated todo.txt removed
  1447. Revision 1.38 2003/02/15 22:17:38 carl
  1448. * bugfix of FPU emulation code
  1449. Revision 1.37 2003/02/12 22:10:07 carl
  1450. * load_frame_pointer is now generic
  1451. * change fpu emulation routine names
  1452. Revision 1.36 2003/01/30 21:46:57 peter
  1453. * self fixes for static methods (merged)
  1454. Revision 1.35 2003/01/22 20:45:15 mazen
  1455. * making math code in RTL compiling.
  1456. *NB : This does NOT mean necessary that it will generate correct code!
  1457. Revision 1.34 2003/01/17 12:03:45 daniel
  1458. * Optalign conditional code adapted to record Tregister
  1459. Revision 1.33 2003/01/08 18:43:56 daniel
  1460. * Tregister changed into a record
  1461. Revision 1.32 2002/12/15 22:50:00 florian
  1462. + some stuff for the new hidden parameter handling added
  1463. Revision 1.31 2002/12/15 21:30:12 florian
  1464. * tcallnode.paraitem introduced, all references to defcoll removed
  1465. Revision 1.30 2002/11/27 20:04:39 peter
  1466. * cdecl array of const fixes
  1467. Revision 1.29 2002/11/25 17:43:17 peter
  1468. * splitted defbase in defutil,symutil,defcmp
  1469. * merged isconvertable and is_equal into compare_defs(_ext)
  1470. * made operator search faster by walking the list only once
  1471. Revision 1.28 2002/11/18 17:31:54 peter
  1472. * pass proccalloption to ret_in_xxx and push_xxx functions
  1473. Revision 1.27 2002/11/16 15:34:30 florian
  1474. * generic location for float results
  1475. Revision 1.26 2002/11/15 01:58:51 peter
  1476. * merged changes from 1.0.7 up to 04-11
  1477. - -V option for generating bug report tracing
  1478. - more tracing for option parsing
  1479. - errors for cdecl and high()
  1480. - win32 import stabs
  1481. - win32 records<=8 are returned in eax:edx (turned off by default)
  1482. - heaptrc update
  1483. - more info for temp management in .s file with EXTDEBUG
  1484. Revision 1.25 2002/10/05 12:43:25 carl
  1485. * fixes for Delphi 6 compilation
  1486. (warning : Some features do not work under Delphi)
  1487. Revision 1.24 2002/09/30 07:00:45 florian
  1488. * fixes to common code to get the alpha compiler compiled applied
  1489. Revision 1.23 2002/09/17 18:54:02 jonas
  1490. * a_load_reg_reg() now has two size parameters: source and dest. This
  1491. allows some optimizations on architectures that don't encode the
  1492. register size in the register name.
  1493. Revision 1.22 2002/09/07 15:25:02 peter
  1494. * old logs removed and tabs fixed
  1495. Revision 1.21 2002/09/07 11:50:02 jonas
  1496. * fixed small regalloction info bug
  1497. Revision 1.20 2002/09/02 11:25:20 florian
  1498. * fixed generic procedure variable calling
  1499. Revision 1.19 2002/09/01 21:04:48 florian
  1500. * several powerpc related stuff fixed
  1501. Revision 1.18 2002/09/01 18:43:27 peter
  1502. * include FUNCTION_RETURN_REG in regs_to_push list
  1503. Revision 1.17 2002/09/01 12:13:00 peter
  1504. * use a_call_reg
  1505. * ungetiftemp for procvar of object temp
  1506. Revision 1.16 2002/08/25 19:25:18 peter
  1507. * sym.insert_in_data removed
  1508. * symtable.insertvardata/insertconstdata added
  1509. * removed insert_in_data call from symtable.insert, it needs to be
  1510. called separatly. This allows to deref the address calculation
  1511. * procedures now calculate the parast addresses after the procedure
  1512. directives are parsed. This fixes the cdecl parast problem
  1513. * push_addr_param has an extra argument that specifies if cdecl is used
  1514. or not
  1515. Revision 1.15 2002/08/23 16:14:48 peter
  1516. * tempgen cleanup
  1517. * tt_noreuse temp type added that will be used in genentrycode
  1518. Revision 1.14 2002/08/20 16:55:38 peter
  1519. * don't write (stabs)line info when inlining a procedure
  1520. Revision 1.13 2002/08/19 19:36:42 peter
  1521. * More fixes for cross unit inlining, all tnodes are now implemented
  1522. * Moved pocall_internconst to po_internconst because it is not a
  1523. calling type at all and it conflicted when inlining of these small
  1524. functions was requested
  1525. Revision 1.12 2002/08/18 20:06:23 peter
  1526. * inlining is now also allowed in interface
  1527. * renamed write/load to ppuwrite/ppuload
  1528. * tnode storing in ppu
  1529. * nld,ncon,nbas are already updated for storing in ppu
  1530. Revision 1.11 2002/08/17 22:09:44 florian
  1531. * result type handling in tcgcal.pass_2 overhauled
  1532. * better tnode.dowrite
  1533. * some ppc stuff fixed
  1534. Revision 1.10 2002/08/17 09:23:35 florian
  1535. * first part of procinfo rewrite
  1536. Revision 1.9 2002/08/13 21:40:55 florian
  1537. * more fixes for ppc calling conventions
  1538. Revision 1.8 2002/08/13 18:01:51 carl
  1539. * rename swatoperands to swapoperands
  1540. + m68k first compilable version (still needs a lot of testing):
  1541. assembler generator, system information , inline
  1542. assembler reader.
  1543. Revision 1.7 2002/08/12 15:08:39 carl
  1544. + stab register indexes for powerpc (moved from gdb to cpubase)
  1545. + tprocessor enumeration moved to cpuinfo
  1546. + linker in target_info is now a class
  1547. * many many updates for m68k (will soon start to compile)
  1548. - removed some ifdef or correct them for correct cpu
  1549. Revision 1.6 2002/08/11 14:32:26 peter
  1550. * renamed current_library to objectlibrary
  1551. Revision 1.5 2002/08/11 13:24:11 peter
  1552. * saving of asmsymbols in ppu supported
  1553. * asmsymbollist global is removed and moved into a new class
  1554. tasmlibrarydata that will hold the info of a .a file which
  1555. corresponds with a single module. Added librarydata to tmodule
  1556. to keep the library info stored for the module. In the future the
  1557. objectfiles will also be stored to the tasmlibrarydata class
  1558. * all getlabel/newasmsymbol and friends are moved to the new class
  1559. Revision 1.4 2002/08/06 20:55:20 florian
  1560. * first part of ppc calling conventions fix
  1561. Revision 1.3 2002/07/20 11:57:53 florian
  1562. * types.pas renamed to defbase.pas because D6 contains a types
  1563. unit so this would conflicts if D6 programms are compiled
  1564. + Willamette/SSE2 instructions to assembler added
  1565. Revision 1.2 2002/07/13 19:38:43 florian
  1566. * some more generic calling stuff fixed
  1567. }