ncgcal.pas 75 KB

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