ncgcal.pas 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819
  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. framepointer_paraloc : tparalocation;
  36. procedure release_para_temps;
  37. procedure normal_pass_2;
  38. procedure inlined_pass_2;
  39. protected
  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(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,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.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,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. { handle call by reference parameter }
  203. else if (paraitem.paratyp in [vs_var,vs_out]) then
  204. begin
  205. if (left.location.loc<>LOC_REFERENCE) then
  206. begin
  207. { passing self to a var parameter is allowed in
  208. TP and delphi }
  209. if not((left.location.loc=LOC_CREFERENCE) and
  210. is_self_node(left)) then
  211. internalerror(200106041);
  212. end;
  213. if (paraitem.paratyp=vs_out) and
  214. assigned(paraitem.paratype.def) and
  215. not is_class(paraitem.paratype.def) and
  216. paraitem.paratype.def.needs_inittable then
  217. cg.g_finalize(exprasmlist,paraitem.paratype.def,left.location.reference,false);
  218. inc(pushedparasize,POINTER_SIZE);
  219. if calloption=pocall_inline then
  220. begin
  221. tmpreg:=rg.getaddressregister(exprasmlist);
  222. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  223. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  224. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  225. rg.ungetregisterint(exprasmlist,tmpreg);
  226. end
  227. else
  228. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  229. location_release(exprasmlist,left.location);
  230. end
  231. else
  232. begin
  233. { don't push a node that already generated a pointer type
  234. by address for implicit hidden parameters }
  235. if (not(
  236. paraitem.is_hidden and
  237. (left.resulttype.def.deftype in [pointerdef,classrefdef])
  238. ) and
  239. paramanager.push_addr_param(paraitem.paratype.def,calloption)) then
  240. begin
  241. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  242. begin
  243. { allow passing nil to a procvardef (methodpointer) }
  244. if (left.nodetype=typeconvn) and
  245. (left.resulttype.def.deftype=procvardef) and
  246. (ttypeconvnode(left).left.nodetype=niln) then
  247. begin
  248. tg.GetTemp(exprasmlist,tcgsize2size[left.location.size],tt_normal,href);
  249. if not (left.location.size in [OS_64,OS_S64]) then
  250. cg.a_load_loc_ref(exprasmlist,left.location.size,left.location,href)
  251. else
  252. cg64.a_load64_loc_ref(exprasmlist,left.location,href);
  253. location_reset(left.location,LOC_REFERENCE,left.location.size);
  254. left.location.reference:=href;
  255. end
  256. else
  257. internalerror(200204011);
  258. end;
  259. inc(pushedparasize,POINTER_SIZE);
  260. if calloption=pocall_inline then
  261. begin
  262. tmpreg:=rg.getaddressregister(exprasmlist);
  263. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  264. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  265. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  266. rg.ungetregisterint(exprasmlist,tmpreg);
  267. end
  268. else
  269. cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
  270. location_release(exprasmlist,left.location);
  271. end
  272. else
  273. begin
  274. push_value_para(exprasmlist,left,calloption,
  275. para_offset,para_alignment,tempparaloc);
  276. end;
  277. end;
  278. truelabel:=otlabel;
  279. falselabel:=oflabel;
  280. { update return location in callnode when this is the function
  281. result }
  282. if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) then
  283. begin
  284. location_copy(aktcallnode.location,left.location);
  285. end;
  286. { push from right to left }
  287. if not push_from_left_to_right and assigned(right) then
  288. begin
  289. tcallparanode(right).secondcallparan(push_from_left_to_right,
  290. calloption,para_alignment,para_offset);
  291. end;
  292. end;
  293. {*****************************************************************************
  294. TCGCALLNODE
  295. *****************************************************************************}
  296. procedure tcgcallnode.extra_interrupt_code;
  297. begin
  298. end;
  299. function tcgcallnode.align_parasize:longint;
  300. begin
  301. result:=0;
  302. end;
  303. procedure tcgcallnode.pop_parasize(pop_size:longint);
  304. begin
  305. end;
  306. procedure tcgcallnode.push_framepointer;
  307. var
  308. href : treference;
  309. hregister : tregister;
  310. begin
  311. framepointer_paraloc:=paramanager.getintparaloc(procdefinition.proccalloption,1);
  312. paramanager.allocparaloc(exprasmlist,framepointer_paraloc);
  313. { this routine is itself not nested }
  314. if current_procinfo.procdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel) then
  315. begin
  316. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.parent_framepointer_offset);
  317. cg.a_param_ref(exprasmlist,OS_ADDR,href,framepointer_paraloc);
  318. end
  319. { one nesting level }
  320. else if (current_procinfo.procdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  321. begin
  322. cg.a_param_reg(exprasmlist,OS_ADDR,current_procinfo.framepointer,framepointer_paraloc);
  323. end
  324. { very complex nesting level ... }
  325. else if (current_procinfo.procdef.parast.symtablelevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  326. begin
  327. hregister:=rg.getaddressregister(exprasmlist);
  328. cg.g_load_parent_framepointer(exprasmlist,tprocdef(procdefinition).parast,hregister);
  329. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,framepointer_paraloc);
  330. rg.ungetaddressregister(exprasmlist,hregister);
  331. end;
  332. end;
  333. procedure tcgcallnode.free_pushed_framepointer;
  334. begin
  335. paramanager.freeparaloc(exprasmlist,framepointer_paraloc);
  336. end;
  337. procedure tcgcallnode.handle_return_value;
  338. var
  339. cgsize : tcgsize;
  340. hregister : tregister;
  341. tempnode: tnode;
  342. begin
  343. { structured results are easy to handle.... }
  344. { needed also when result_no_used !! }
  345. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  346. begin
  347. { Location should be setup by the funcret para }
  348. if location.loc<>LOC_REFERENCE then
  349. internalerror(200304241);
  350. end
  351. else
  352. { ansi/widestrings must be registered, so we can dispose them }
  353. if is_ansistring(resulttype.def) or
  354. is_widestring(resulttype.def) then
  355. begin
  356. { the FUNCTION_RESULT_REG is already allocated }
  357. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  358. if not assigned(funcretnode) then
  359. begin
  360. location_reset(location,LOC_CREFERENCE,OS_ADDR);
  361. location.reference:=refcountedtemp;
  362. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,location.reference);
  363. end
  364. else
  365. begin
  366. hregister := rg.getaddressregister(exprasmlist);
  367. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,hregister);
  368. { in case of a regular funcretnode with ret_in_param, the }
  369. { original funcretnode isn't touched -> make sure it's }
  370. { the same here (not sure if it's necessary) }
  371. tempnode := funcretnode.getcopy;
  372. tempnode.pass_2;
  373. location := tempnode.location;
  374. tempnode.free;
  375. cg.g_decrrefcount(exprasmlist,resulttype.def,location.reference, false);
  376. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
  377. rg.ungetregisterint(exprasmlist,hregister);
  378. end;
  379. end
  380. else
  381. { we have only to handle the result if it is used }
  382. if (nf_return_value_used in flags) then
  383. begin
  384. if (resulttype.def.deftype=floatdef) then
  385. begin
  386. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  387. {$ifdef cpufpemu}
  388. if cs_fp_emulation in aktmoduleswitches then
  389. location.register:=NR_FUNCTION_RESULT_REG
  390. else
  391. {$endif cpufpemu}
  392. location.register:=NR_FPU_RESULT_REG;
  393. {$ifdef x86}
  394. inc(trgcpu(rg).fpuvaroffset);
  395. {$else x86}
  396. hregister := rg.getregisterfpu(exprasmlist,location.size);
  397. cg.a_loadfpu_reg_reg(exprasmlist,location.size,location.register,hregister);
  398. location.register := hregister;
  399. {$endif x86}
  400. end
  401. else
  402. begin
  403. cgsize:=def_cgsize(resulttype.def);
  404. { an object constructor is a function with pointer result }
  405. if (procdefinition.proctypeoption=potype_constructor) then
  406. cgsize:=OS_ADDR;
  407. if cgsize<>OS_NO then
  408. begin
  409. location_reset(location,LOC_REGISTER,cgsize);
  410. {$ifndef cpu64bit}
  411. if cgsize in [OS_64,OS_S64] then
  412. begin
  413. { Move the function result to free registers, preferably the
  414. FUNCTION_RESULT_REG/FUNCTION_RESULTHIGH_REG, so no move is necessary.}
  415. { the FUNCTION_RESULT_LOW_REG/FUNCTION_RESULT_HIGH_REG
  416. are already allocated }
  417. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
  418. location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
  419. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_LOW_REG,location.registerlow);
  420. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
  421. location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
  422. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_HIGH_REG,location.registerhigh);
  423. end
  424. else
  425. {$endif cpu64bit}
  426. begin
  427. {Move the function result to a free register, preferably the
  428. FUNCTION_RESULT_REG, so no move is necessary.}
  429. { the FUNCTION_RESULT_REG is already allocated }
  430. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  431. { change register size after the unget because the
  432. getregister was done for the full register }
  433. location.register:=rg.getregisterint(exprasmlist,cgsize);
  434. cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,rg.makeregsize(NR_FUNCTION_RESULT_REG,cgsize),location.register);
  435. end;
  436. end
  437. else
  438. begin
  439. if resulttype.def.size>0 then
  440. internalerror(200305131);
  441. end;
  442. end;
  443. end
  444. else
  445. begin
  446. cgsize:=def_cgsize(resulttype.def);
  447. { an object constructor is a function with pointer result }
  448. if (procdefinition.proctypeoption=potype_constructor) then
  449. cgsize:=OS_ADDR;
  450. if cgsize<>OS_NO then
  451. {$ifndef cpu64bit}
  452. if cgsize in [OS_64,OS_S64] then
  453. begin
  454. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
  455. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
  456. end
  457. else
  458. {$endif cpu64bit}
  459. rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
  460. location_reset(location,LOC_VOID,OS_NO);
  461. end;
  462. end;
  463. procedure tcgcallnode.release_para_temps;
  464. var
  465. hp : tnode;
  466. ppn : tcallparanode;
  467. begin
  468. { Release temps from parameters }
  469. ppn:=tcallparanode(left);
  470. while assigned(ppn) do
  471. begin
  472. if assigned(ppn.left) then
  473. begin
  474. { don't release the funcret temp }
  475. if not(vo_is_funcret in tvarsym(ppn.paraitem.parasym).varoptions) then
  476. location_freetemp(exprasmlist,ppn.left.location);
  477. { process also all nodes of an array of const }
  478. if ppn.left.nodetype=arrayconstructorn then
  479. begin
  480. if assigned(tarrayconstructornode(ppn.left).left) then
  481. begin
  482. hp:=ppn.left;
  483. while assigned(hp) do
  484. begin
  485. location_freetemp(exprasmlist,tarrayconstructornode(hp).left.location);
  486. hp:=tarrayconstructornode(hp).right;
  487. end;
  488. end;
  489. end;
  490. end;
  491. ppn:=tcallparanode(ppn.right);
  492. end;
  493. end;
  494. procedure tcgcallnode.normal_pass_2;
  495. var
  496. regs_to_push_other : totherregisterset;
  497. unusedstate: pointer;
  498. regs_to_alloc,regs_to_free:Tsuperregisterset;
  499. pushedother : tpushedsavedother;
  500. oldpushedparasize : longint;
  501. { adress returned from an I/O-error }
  502. iolabel : tasmlabel;
  503. { help reference pointer }
  504. href,helpref : treference;
  505. para_alignment,
  506. pop_size : longint;
  507. vmtreg,vmtreg2 : tregister;
  508. oldaktcallnode : tcallnode;
  509. procedure pushparas;
  510. var
  511. ppn : tcgcallparanode;
  512. begin
  513. { copy all resources to the allocated registers }
  514. ppn:=tcgcallparanode(left);
  515. while assigned(ppn) do
  516. begin
  517. if ppn.tempparaloc.loc=LOC_REGISTER then
  518. begin
  519. paramanager.allocparaloc(exprasmlist,ppn.paraitem.paraloc[callerside]);
  520. {$ifdef sparc}
  521. case ppn.tempparaloc.size of
  522. OS_F32 :
  523. ppn.tempparaloc.size:=OS_32;
  524. OS_F64 :
  525. ppn.tempparaloc.size:=OS_64;
  526. end;
  527. {$endif sparc}
  528. {$ifndef cpu64bit}
  529. if ppn.tempparaloc.size in [OS_64,OS_S64] then
  530. begin
  531. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,ppn.tempparaloc.registerlow,
  532. ppn.paraitem.paraloc[callerside].registerlow);
  533. cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,ppn.tempparaloc.registerhigh,
  534. ppn.paraitem.paraloc[callerside].registerhigh);
  535. end
  536. else
  537. {$endif cpu64bit}
  538. cg.a_load_reg_reg(exprasmlist,ppn.tempparaloc.size,ppn.tempparaloc.size,
  539. ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside].register);
  540. end;
  541. ppn:=tcgcallparanode(ppn.right);
  542. end;
  543. end;
  544. procedure freeparas;
  545. var
  546. ppn : tcgcallparanode;
  547. begin
  548. { free the resources allocated for the parameters }
  549. ppn:=tcgcallparanode(left);
  550. while assigned(ppn) do
  551. begin
  552. if ppn.tempparaloc.loc=LOC_REGISTER then
  553. paramanager.freeparaloc(exprasmlist,ppn.tempparaloc);
  554. paramanager.freeparaloc(exprasmlist,ppn.paraitem.paraloc[callerside]);
  555. ppn:=tcgcallparanode(ppn.right);
  556. end;
  557. { free pushed base pointer }
  558. if (right=nil) and
  559. (current_procinfo.procdef.parast.symtablelevel>=normal_function_level) and
  560. assigned(tprocdef(procdefinition).parast) and
  561. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  562. free_pushed_framepointer;
  563. end;
  564. begin
  565. if not assigned(procdefinition) then
  566. internalerror(200305264);
  567. { calculate the parameter info for the procdef }
  568. if not procdefinition.has_paraloc_info then
  569. begin
  570. paramanager.create_paraloc_info(procdefinition,callerside);
  571. procdefinition.has_paraloc_info:=true;
  572. end;
  573. iolabel:=nil;
  574. rg.saveunusedstate(unusedstate);
  575. if not assigned(funcretnode) then
  576. begin
  577. { if we allocate the temp. location for ansi- or widestrings }
  578. { already here, we avoid later a push/pop }
  579. if is_widestring(resulttype.def) then
  580. begin
  581. tg.gettemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  582. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  583. end
  584. else if is_ansistring(resulttype.def) then
  585. begin
  586. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  587. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  588. end;
  589. end;
  590. if (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_stdcall]) then
  591. para_alignment:=4
  592. else
  593. para_alignment:=aktalignment.paraalign;
  594. { proc variables destroy all registers }
  595. if (right=nil) and
  596. { virtual methods too }
  597. not(po_virtualmethod in procdefinition.procoptions) then
  598. begin
  599. if (cs_check_io in aktlocalswitches) and
  600. (po_iocheck in procdefinition.procoptions) and
  601. not(po_iocheck in current_procinfo.procdef.procoptions) then
  602. begin
  603. objectlibrary.getaddrlabel(iolabel);
  604. cg.a_label(exprasmlist,iolabel);
  605. end
  606. else
  607. iolabel:=nil;
  608. (*
  609. regs_to_alloc:=Tprocdef(procdefinition).usedintregisters;
  610. {$ifdef i386}
  611. regs_to_push_other := tprocdef(procdefinition).usedotherregisters;
  612. {$else i386}
  613. regs_to_push_other := VOLATILE_FPUREGISTERS;
  614. {$endif i386}
  615. { on the ppc, ever procedure saves the non-volatile registers it uses itself }
  616. { and must make sure it saves its volatile registers before doing a call }
  617. {$ifdef i386}
  618. { give used registers through }
  619. rg.used_in_proc_int:=rg.used_in_proc_int + tprocdef(procdefinition).usedintregisters;
  620. rg.used_in_proc_other:=rg.used_in_proc_other + tprocdef(procdefinition).usedotherregisters;
  621. {$endif i386}
  622. *)
  623. end
  624. else
  625. begin
  626. { no IO check for methods and procedure variables }
  627. iolabel:=nil;
  628. end;
  629. regs_to_alloc:=paramanager.get_volatile_registers_int(procdefinition.proccalloption);
  630. regs_to_push_other:=paramanager.get_volatile_registers_fpu(procdefinition.proccalloption);
  631. { Include Function result registers }
  632. if (not is_void(resulttype.def)) then
  633. begin
  634. case procdefinition.funcret_paraloc[callerside].loc of
  635. LOC_REGISTER,LOC_CREGISTER:
  636. begin
  637. {$ifndef cpu64bit}
  638. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  639. begin
  640. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  641. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  642. end
  643. else
  644. {$endif cpu64bit}
  645. include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  646. end;
  647. end;
  648. end;
  649. { Save registers destroyed by the call }
  650. rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
  651. { Initialize for pushing the parameters }
  652. oldpushedparasize:=pushedparasize;
  653. pushedparasize:=0;
  654. { Align stack if required }
  655. pop_size:=align_parasize;
  656. { Push parameters }
  657. oldaktcallnode:=aktcallnode;
  658. aktcallnode:=self;
  659. {$ifndef i386}
  660. { process procvar. Done here already, because otherwise it may }
  661. { destroy registers containing a parameter for the actual }
  662. { function call (e.g. if it's a function, its result will }
  663. { overwrite r3, which contains the first parameter) (JM) }
  664. if assigned(right) then
  665. secondpass(right);
  666. if (po_virtualmethod in procdefinition.procoptions) and
  667. assigned(methodpointer) then
  668. begin
  669. secondpass(methodpointer);
  670. location_force_reg(exprasmlist,methodpointer.location,OS_ADDR,false);
  671. { virtual methods require an index }
  672. if tprocdef(procdefinition).extnumber=-1 then
  673. internalerror(200304021);
  674. { VMT should already be loaded in a register }
  675. if methodpointer.location.register=NR_NO then
  676. internalerror(200304022);
  677. { test validity of VMT }
  678. if not(is_interface(tprocdef(procdefinition)._class)) and
  679. not(is_cppclass(tprocdef(procdefinition)._class)) then
  680. cg.g_maybe_testvmt(exprasmlist,methodpointer.location.register,tprocdef(procdefinition)._class);
  681. end;
  682. {$endif not i386}
  683. { Process parameters }
  684. if assigned(left) then
  685. begin
  686. tcallparanode(left).secondcallparan(
  687. (procdefinition.proccalloption in pushleftright_pocalls),procdefinition.proccalloption,
  688. para_alignment,0);
  689. pushparas;
  690. end;
  691. aktcallnode:=oldaktcallnode;
  692. { procedure variable or normal function call ? }
  693. if (right=nil) then
  694. begin
  695. { push base pointer ?}
  696. if (current_procinfo.procdef.parast.symtablelevel>=normal_function_level) and
  697. assigned(tprocdef(procdefinition).parast) and
  698. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  699. push_framepointer;
  700. rg.saveotherregvars(exprasmlist,regs_to_push_other);
  701. if (po_virtualmethod in procdefinition.procoptions) and
  702. assigned(methodpointer) then
  703. begin
  704. {$ifdef i386}
  705. secondpass(methodpointer);
  706. location_force_reg(exprasmlist,methodpointer.location,OS_ADDR,false);
  707. vmtreg:=methodpointer.location.register;
  708. { virtual methods require an index }
  709. if tprocdef(procdefinition).extnumber=-1 then
  710. internalerror(200304021);
  711. { VMT should already be loaded in a register }
  712. if vmtreg=NR_NO then
  713. internalerror(200304022);
  714. { test validity of VMT }
  715. if not(is_interface(tprocdef(procdefinition)._class)) and
  716. not(is_cppclass(tprocdef(procdefinition)._class)) then
  717. cg.g_maybe_testvmt(exprasmlist,vmtreg,tprocdef(procdefinition)._class);
  718. {$else}
  719. vmtreg:=methodpointer.location.register;
  720. {$endif}
  721. { release self }
  722. rg.ungetaddressregister(exprasmlist,vmtreg);
  723. vmtreg2:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  724. rg.ungetregisterint(exprasmlist,vmtreg2);
  725. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
  726. { free the resources allocated for the parameters }
  727. freeparas;
  728. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  729. { call method }
  730. reference_reset_base(href,vmtreg2,
  731. tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber));
  732. cg.a_call_ref(exprasmlist,href);
  733. end
  734. else
  735. begin
  736. { free the resources allocated for the parameters }
  737. freeparas;
  738. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  739. { Calling interrupt from the same code requires some
  740. extra code }
  741. if (po_interrupt in procdefinition.procoptions) then
  742. extra_interrupt_code;
  743. cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname);
  744. end;
  745. end
  746. else
  747. { now procedure variable case }
  748. begin
  749. {$ifdef i386}
  750. secondpass(right);
  751. {$endif i386}
  752. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  753. begin
  754. helpref:=right.location.reference;
  755. if (helpref.index<>NR_NO) and (helpref.index<>NR_FRAME_POINTER_REG) then
  756. begin
  757. rg.ungetregisterint(exprasmlist,helpref.index);
  758. helpref.index:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  759. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
  760. right.location.reference.index,helpref.index);
  761. end;
  762. if (helpref.base<>NR_NO) and (helpref.base<>NR_FRAME_POINTER_REG) then
  763. begin
  764. rg.ungetregisterint(exprasmlist,helpref.base);
  765. helpref.base:=rg.getabtregisterint(exprasmlist,OS_ADDR);
  766. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
  767. right.location.reference.base,helpref.base);
  768. end;
  769. reference_release(exprasmlist,helpref);
  770. end
  771. else
  772. rg.ungetregisterint(exprasmlist,right.location.register);
  773. location_freetemp(exprasmlist,right.location);
  774. { free the resources allocated for the parameters }
  775. freeparas;
  776. rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
  777. { Calling interrupt from the same code requires some
  778. extra code }
  779. if (po_interrupt in procdefinition.procoptions) then
  780. extra_interrupt_code;
  781. rg.saveotherregvars(exprasmlist,ALL_OTHERREGISTERS);
  782. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  783. cg.a_call_ref(exprasmlist,helpref)
  784. else
  785. cg.a_call_reg(exprasmlist,right.location.register);
  786. { cg.a_call_loc(exprasmlist,right.location);}
  787. location_release(exprasmlist,right.location);
  788. location_freetemp(exprasmlist,right.location);
  789. end;
  790. { Need to remove the parameters from the stack? }
  791. if (procdefinition.proccalloption in clearstack_pocalls) then
  792. begin
  793. { the old pop_size was already included in pushedparasize }
  794. pop_size:=pushedparasize;
  795. { for Cdecl functions we don't need to pop the funcret when it
  796. was pushed by para }
  797. if paramanager.ret_in_param(procdefinition.rettype.def,procdefinition.proccalloption) then
  798. dec(pop_size,POINTER_SIZE);
  799. end;
  800. { Remove parameters/alignment from the stack }
  801. if pop_size>0 then
  802. pop_parasize(pop_size);
  803. { Reserve space for storing parameters that will be pushed }
  804. current_procinfo.allocate_push_parasize(pushedparasize);
  805. { Restore }
  806. pushedparasize:=oldpushedparasize;
  807. rg.restoreunusedstate(unusedstate);
  808. {$ifdef TEMPREGDEBUG}
  809. testregisters32;
  810. {$endif TEMPREGDEBUG}
  811. { Release registers, but not the registers that contain the
  812. function result }
  813. regs_to_free:=regs_to_alloc;
  814. if (not is_void(resulttype.def)) then
  815. begin
  816. case procdefinition.funcret_paraloc[callerside].loc of
  817. LOC_REGISTER,LOC_CREGISTER:
  818. begin
  819. {$ifndef cpu64bit}
  820. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  821. begin
  822. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  823. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  824. end
  825. else
  826. {$endif cpu64bit}
  827. exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  828. end;
  829. end;
  830. end;
  831. rg.deallocexplicitregistersint(exprasmlist,regs_to_free);
  832. { handle function results }
  833. if (not is_void(resulttype.def)) then
  834. handle_return_value
  835. else
  836. location_reset(location,LOC_VOID,OS_NO);
  837. { perhaps i/o check ? }
  838. if iolabel<>nil then
  839. begin
  840. //reference_reset_symbol(href,iolabel,0);
  841. //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
  842. //paramanager.freeintparaloc(exprasmlist,1);
  843. rg.allocexplicitregistersint(exprasmlist,paramanager.get_volatile_registers_int(pocall_default));
  844. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  845. rg.deallocexplicitregistersint(exprasmlist,paramanager.get_volatile_registers_int(pocall_default));
  846. end;
  847. { restore registers }
  848. rg.restoreusedotherregisters(exprasmlist,pushedother);
  849. { release temps of paras }
  850. release_para_temps;
  851. { if return value is not used }
  852. if (not(nf_return_value_used in flags)) and (not is_void(resulttype.def)) then
  853. begin
  854. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  855. begin
  856. { data which must be finalized ? }
  857. if (resulttype.def.needs_inittable) then
  858. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  859. { release unused temp }
  860. tg.ungetiftemp(exprasmlist,location.reference)
  861. end
  862. else if location.loc=LOC_FPUREGISTER then
  863. begin
  864. {$ifdef x86}
  865. { release FPU stack }
  866. emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
  867. {
  868. dec(trgcpu(rg).fpuvaroffset);
  869. do NOT decrement as the increment before
  870. is not called for unused results PM }
  871. {$endif x86}
  872. end;
  873. end;
  874. end;
  875. procedure tcgcallnode.inlined_pass_2;
  876. var
  877. regs_to_push_int : Tsuperregisterset;
  878. regs_to_push_other : totherregisterset;
  879. unusedstate: pointer;
  880. pushedother : tpushedsavedother;
  881. oldpushedparasize : longint;
  882. { adress returned from an I/O-error }
  883. iolabel : tasmlabel;
  884. oldaktcallnode : tcallnode;
  885. oldprocdef : tprocdef;
  886. i : longint;
  887. oldprocinfo : tprocinfo;
  888. oldinlining_procedure : boolean;
  889. inlineentrycode,inlineexitcode : TAAsmoutput;
  890. oldregstate: pointer;
  891. old_local_fixup,
  892. old_para_fixup : longint;
  893. usesacc,usesacchi,usesfpu : boolean;
  894. pararef,
  895. localsref : treference;
  896. {$ifdef GDB}
  897. startlabel,endlabel : tasmlabel;
  898. pp : pchar;
  899. mangled_length : longint;
  900. {$endif GDB}
  901. begin
  902. if not(assigned(procdefinition) and (procdefinition.deftype=procdef)) then
  903. internalerror(200305262);
  904. oldinlining_procedure:=inlining_procedure;
  905. oldprocdef:=current_procinfo.procdef;
  906. oldprocinfo:=current_procinfo;
  907. { we're inlining a procedure }
  908. inlining_procedure:=true;
  909. { calculate the parameter info for the procdef }
  910. if not procdefinition.has_paraloc_info then
  911. begin
  912. paramanager.create_paraloc_info(procdefinition,callerside);
  913. procdefinition.has_paraloc_info:=true;
  914. end;
  915. { deallocate the registers used for the current procedure's regvars }
  916. if assigned(current_procinfo.procdef.regvarinfo) then
  917. begin
  918. with pregvarinfo(current_procinfo.procdef.regvarinfo)^ do
  919. for i := 1 to maxvarregs do
  920. if assigned(regvars[i]) then
  921. store_regvar(exprasmlist,regvars[i].reg);
  922. rg.saveStateForInline(oldregstate);
  923. { make sure the register allocator knows what the regvars in the }
  924. { inlined code block are (JM) }
  925. rg.resetusableregisters;
  926. rg.clearregistercount;
  927. if assigned(tprocdef(procdefinition).regvarinfo) then
  928. with pregvarinfo(tprocdef(procdefinition).regvarinfo)^ do
  929. for i := 1 to maxvarregs do
  930. if assigned(regvars[i]) then
  931. begin
  932. {Fix me!!}
  933. {tmpreg:=rg.makeregsize(regvars[i].reg,OS_INT);
  934. rg.makeregvar(tmpreg);}
  935. internalerror(200301232);
  936. end;
  937. end;
  938. { create temp procinfo }
  939. current_procinfo:=cprocinfo.create(nil);
  940. current_procinfo.procdef:=tprocdef(procdefinition);
  941. { Localsymtable }
  942. current_procinfo.procdef.localst.symtablelevel:=oldprocdef.localst.symtablelevel;
  943. if current_procinfo.procdef.localst.datasize>0 then
  944. begin
  945. old_local_fixup:=current_procinfo.procdef.localst.address_fixup;
  946. tg.GetTemp(exprasmlist,current_procinfo.procdef.localst.datasize,tt_persistent,localsref);
  947. if tg.direction>0 then
  948. current_procinfo.procdef.localst.address_fixup:=localsref.offset
  949. else
  950. current_procinfo.procdef.localst.address_fixup:=localsref.offset+current_procinfo.procdef.localst.datasize;
  951. {$ifdef extdebug}
  952. Comment(V_debug,'inlined local symtable ('+tostr(current_procinfo.procdef.localst.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.localst.address_fixup));
  953. exprasmList.concat(tai_comment.Create(strpnew(
  954. 'inlined local symtable ('+tostr(current_procinfo.procdef.localst.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.localst.address_fixup))));
  955. {$endif extdebug}
  956. end;
  957. { Parasymtable }
  958. current_procinfo.procdef.parast.symtablelevel:=oldprocdef.localst.symtablelevel;
  959. if current_procinfo.procdef.parast.datasize>0 then
  960. begin
  961. old_para_fixup:=current_procinfo.procdef.parast.address_fixup;
  962. tg.GetTemp(exprasmlist,current_procinfo.procdef.parast.datasize,tt_persistent,pararef);
  963. current_procinfo.procdef.parast.address_fixup:=pararef.offset;
  964. {$ifdef extdebug}
  965. Comment(V_debug,'inlined para symtable ('+tostr(current_procinfo.procdef.parast.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.parast.address_fixup));
  966. exprasmList.concat(tai_comment.Create(strpnew(
  967. 'inlined para symtable ('+tostr(current_procinfo.procdef.parast.datasize)+' bytes) is at offset '+tostr(current_procinfo.procdef.parast.address_fixup))));
  968. {$endif extdebug}
  969. end;
  970. exprasmList.concat(Tai_Marker.Create(InlineStart));
  971. {$ifdef extdebug}
  972. exprasmList.concat(tai_comment.Create(strpnew('Start of inlined proc')));
  973. {$endif extdebug}
  974. {$ifdef GDB}
  975. if (cs_debuginfo in aktmoduleswitches) then
  976. begin
  977. objectlibrary.getaddrlabel(startlabel);
  978. objectlibrary.getaddrlabel(endlabel);
  979. cg.a_label(exprasmlist,startlabel);
  980. tprocdef(procdefinition).localst.symtabletype:=inlinelocalsymtable;
  981. procdefinition.parast.symtabletype:=inlineparasymtable;
  982. { Here we must include the para and local symtable info }
  983. procdefinition.concatstabto(withdebuglist);
  984. { set it back for safety }
  985. tprocdef(procdefinition).localst.symtabletype:=localsymtable;
  986. procdefinition.parast.symtabletype:=parasymtable;
  987. mangled_length:=length(oldprocdef.mangledname);
  988. getmem(pp,mangled_length+50);
  989. strpcopy(pp,'192,0,0,'+startlabel.name);
  990. if (target_info.use_function_relative_addresses) then
  991. begin
  992. strpcopy(strend(pp),'-');
  993. strpcopy(strend(pp),oldprocdef.mangledname);
  994. end;
  995. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  996. end;
  997. {$endif GDB}
  998. iolabel:=nil;
  999. rg.saveunusedstate(unusedstate);
  1000. { if we allocate the temp. location for ansi- or widestrings }
  1001. { already here, we avoid later a push/pop }
  1002. if is_widestring(resulttype.def) then
  1003. begin
  1004. tg.GetTemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  1005. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  1006. end
  1007. else if is_ansistring(resulttype.def) then
  1008. begin
  1009. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  1010. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  1011. end;
  1012. if (cs_check_io in aktlocalswitches) and
  1013. (po_iocheck in procdefinition.procoptions) and
  1014. not(po_iocheck in current_procinfo.procdef.procoptions) then
  1015. begin
  1016. objectlibrary.getaddrlabel(iolabel);
  1017. cg.a_label(exprasmlist,iolabel);
  1018. end
  1019. else
  1020. iolabel:=nil;
  1021. { save all used registers and possible registers
  1022. used for the return value }
  1023. (*
  1024. regs_to_push_int := tprocdef(procdefinition).usedintregisters;
  1025. regs_to_push_other := tprocdef(procdefinition).usedotherregisters;
  1026. *)
  1027. regs_to_push_int:=paramanager.get_volatile_registers_int(procdefinition.proccalloption);
  1028. regs_to_push_other:=paramanager.get_volatile_registers_fpu(procdefinition.proccalloption);
  1029. if (not is_void(resulttype.def)) then
  1030. begin
  1031. case procdefinition.funcret_paraloc[callerside].loc of
  1032. LOC_REGISTER,LOC_CREGISTER:
  1033. begin
  1034. {$ifndef cpu64bit}
  1035. if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
  1036. begin
  1037. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
  1038. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
  1039. end
  1040. else
  1041. {$endif cpu64bit}
  1042. include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].register));
  1043. end;
  1044. end;
  1045. end;
  1046. rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
  1047. (*
  1048. {$ifdef i386}
  1049. { give used registers through }
  1050. rg.used_in_proc_int:=rg.used_in_proc_int + tprocdef(procdefinition).usedintregisters;
  1051. rg.used_in_proc_other:=rg.used_in_proc_other + tprocdef(procdefinition).usedotherregisters;
  1052. {$endif i386}
  1053. *)
  1054. { Initialize for pushing the parameters }
  1055. oldpushedparasize:=pushedparasize;
  1056. pushedparasize:=0;
  1057. { Push parameters }
  1058. oldaktcallnode:=aktcallnode;
  1059. aktcallnode:=self;
  1060. if assigned(left) then
  1061. begin
  1062. { we push from right to left, so start with parameters at the end of
  1063. the parameter block }
  1064. tcallparanode(left).secondcallparan(
  1065. (procdefinition.proccalloption in pushleftright_pocalls),procdefinition.proccalloption,
  1066. 0,procdefinition.parast.address_fixup+procdefinition.parast.datasize);
  1067. end;
  1068. aktcallnode:=oldaktcallnode;
  1069. rg.saveotherregvars(exprasmlist,regs_to_push_other);
  1070. { takes care of local data initialization }
  1071. inlineentrycode:=TAAsmoutput.Create;
  1072. inlineexitcode:=TAAsmoutput.Create;
  1073. gen_initialize_code(inlineentrycode,true);
  1074. if po_assembler in current_procinfo.procdef.procoptions then
  1075. inlineentrycode.insert(Tai_marker.Create(asmblockstart));
  1076. exprasmList.concatlist(inlineentrycode);
  1077. { process the inline code }
  1078. secondpass(inlinecode);
  1079. { Reserve space for storing parameters that will be pushed }
  1080. current_procinfo.allocate_push_parasize(pushedparasize);
  1081. { Restore }
  1082. pushedparasize:=oldpushedparasize;
  1083. rg.restoreunusedstate(unusedstate);
  1084. {$ifdef TEMPREGDEBUG}
  1085. testregisters32;
  1086. {$endif TEMPREGDEBUG}
  1087. gen_finalize_code(inlineexitcode,true);
  1088. gen_load_return_value(inlineexitcode,usesacc,usesacchi,usesfpu);
  1089. if po_assembler in current_procinfo.procdef.procoptions then
  1090. inlineexitcode.concat(Tai_marker.Create(asmblockend));
  1091. exprasmList.concatlist(inlineexitcode);
  1092. inlineentrycode.free;
  1093. inlineexitcode.free;
  1094. {$ifdef extdebug}
  1095. exprasmList.concat(tai_comment.Create(strpnew('End of inlined proc')));
  1096. {$endif extdebug}
  1097. exprasmList.concat(Tai_Marker.Create(InlineEnd));
  1098. {we can free the local data now, reset also the fixup address }
  1099. if current_procinfo.procdef.localst.datasize>0 then
  1100. begin
  1101. tg.UnGetTemp(exprasmlist,localsref);
  1102. current_procinfo.procdef.localst.address_fixup:=old_local_fixup;
  1103. end;
  1104. {we can free the para data now, reset also the fixup address }
  1105. if current_procinfo.procdef.parast.datasize>0 then
  1106. begin
  1107. tg.UnGetTemp(exprasmlist,pararef);
  1108. current_procinfo.procdef.parast.address_fixup:=old_para_fixup;
  1109. end;
  1110. { free return reference }
  1111. if (resulttype.def.size>0) then
  1112. begin
  1113. { from now on the result can be freed normally }
  1114. // if assigned(funcretnode) and
  1115. // paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1116. // tg.ChangeTempType(exprasmlist,funcretnode.location.reference,tt_normal);
  1117. end;
  1118. { handle function results }
  1119. if (not is_void(resulttype.def)) then
  1120. handle_return_value
  1121. else
  1122. location_reset(location,LOC_VOID,OS_NO);
  1123. { perhaps i/o check ? }
  1124. if iolabel<>nil then
  1125. begin
  1126. //reference_reset_symbol(href,iolabel,0);
  1127. //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
  1128. //paramanager.freeintparaloc(exprasmlist,1);
  1129. rg.allocexplicitregistersint(exprasmlist,paramanager.get_volatile_registers_int(pocall_default));
  1130. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  1131. rg.deallocexplicitregistersint(exprasmlist,paramanager.get_volatile_registers_int(pocall_default));
  1132. end;
  1133. { restore registers }
  1134. rg.restoreusedotherregisters(exprasmlist,pushedother);
  1135. { release temps of paras }
  1136. release_para_temps;
  1137. { if return value is not used }
  1138. if (not is_void(resulttype.def)) and
  1139. (not(nf_return_value_used in flags)) then
  1140. begin
  1141. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  1142. begin
  1143. { data which must be finalized ? }
  1144. if (resulttype.def.needs_inittable) then
  1145. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  1146. { release unused temp }
  1147. tg.ungetiftemp(exprasmlist,location.reference)
  1148. end
  1149. else if location.loc=LOC_FPUREGISTER then
  1150. begin
  1151. {$ifdef x86}
  1152. { release FPU stack }
  1153. emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
  1154. {
  1155. dec(trgcpu(rg).fpuvaroffset);
  1156. do NOT decrement as the increment before
  1157. is not called for unused results PM }
  1158. {$endif x86}
  1159. end;
  1160. end;
  1161. { release procinfo }
  1162. current_procinfo.free;
  1163. current_procinfo:=oldprocinfo;
  1164. {$ifdef GDB}
  1165. if (cs_debuginfo in aktmoduleswitches) then
  1166. begin
  1167. cg.a_label(exprasmlist,endlabel);
  1168. strpcopy(pp,'224,0,0,'+endlabel.name);
  1169. if (target_info.use_function_relative_addresses) then
  1170. begin
  1171. strpcopy(strend(pp),'-');
  1172. strpcopy(strend(pp),oldprocdef.mangledname);
  1173. end;
  1174. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1175. freemem(pp,mangled_length+50);
  1176. end;
  1177. {$endif GDB}
  1178. { restore }
  1179. current_procinfo.procdef:=oldprocdef;
  1180. inlining_procedure:=oldinlining_procedure;
  1181. { reallocate the registers used for the current procedure's regvars, }
  1182. { since they may have been used and then deallocated in the inlined }
  1183. { procedure (JM) }
  1184. if assigned(current_procinfo.procdef.regvarinfo) then
  1185. rg.restoreStateAfterInline(oldregstate);
  1186. end;
  1187. procedure tcgcallnode.pass_2;
  1188. begin
  1189. if assigned(inlinecode) then
  1190. inlined_pass_2
  1191. else
  1192. normal_pass_2;
  1193. end;
  1194. begin
  1195. ccallparanode:=tcgcallparanode;
  1196. ccallnode:=tcgcallnode;
  1197. end.
  1198. {
  1199. $Log$
  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. }