ncgcal.pas 72 KB

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