ncgcal.pas 71 KB

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