ncgcal.pas 73 KB

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