ncgcal.pas 70 KB

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