ncgcal.pas 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate i386 assembler for in call nodes
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published bymethodpointer
  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. { $define AnsiStrRef}
  22. uses
  23. cpubase,
  24. globtype,
  25. symdef,node,ncal;
  26. type
  27. tcgcallparanode = class(tcallparanode)
  28. procedure secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;
  29. para_alignment,para_offset : longint);override;
  30. end;
  31. tcgcallnode = class(tcallnode)
  32. protected
  33. refcountedtemp : treference;
  34. procedure handle_return_value(inlined:boolean);
  35. {# This routine is used to push the current frame pointer
  36. on the stack. This is used in nested routines where the
  37. value of the frame pointer is always pushed as an extra
  38. parameter.
  39. The default handling is the standard handling used on
  40. most stack based machines, where the frame pointer is
  41. the first invisible parameter.
  42. }
  43. function align_parasize(parasize,para_alignment:longint):longint;virtual;
  44. procedure pop_parasize(pop_size:longint);virtual;
  45. procedure push_framepointer;virtual;
  46. procedure extra_interrupt_code;virtual;
  47. public
  48. procedure pass_2;override;
  49. end;
  50. tcgprocinlinenode = class(tprocinlinenode)
  51. procedure pass_2;override;
  52. end;
  53. implementation
  54. uses
  55. systems,
  56. cutils,verbose,globals,
  57. symconst,symbase,symsym,symtable,defutil,paramgr,
  58. {$ifdef GDB}
  59. {$ifdef delphi}
  60. sysutils,
  61. {$else}
  62. strings,
  63. {$endif}
  64. gdb,
  65. {$endif GDB}
  66. cginfo,cgbase,pass_2,
  67. cpuinfo,aasmbase,aasmtai,aasmcpu,
  68. nbas,nmem,nld,ncnv,
  69. {$ifdef x86}
  70. cga,
  71. {$endif x86}
  72. {$ifdef cpu64bit}
  73. cg64f64,
  74. {$else cpu64bit}
  75. cg64f32,
  76. {$endif cpu64bit}
  77. {$ifdef powerpc}
  78. cpupi,
  79. {$endif powerpc}
  80. ncgutil,cgobj,tgobj,regvars,rgobj,rgcpu;
  81. var
  82. { Current callnode, this is needed for having a link
  83. between the callparanodes and the callnode they belong to }
  84. aktcallnode : tcallnode;
  85. {*****************************************************************************
  86. TCGCALLPARANODE
  87. *****************************************************************************}
  88. procedure tcgcallparanode.secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;para_alignment,para_offset : longint);
  89. var
  90. otlabel,
  91. oflabel : tasmlabel;
  92. tmpreg : tregister;
  93. href : treference;
  94. begin
  95. if not(assigned(paraitem.paratype.def) or
  96. assigned(paraitem.parasym)) then
  97. internalerror(200304242);
  98. { set default para_alignment to target_info.stackalignment }
  99. if para_alignment=0 then
  100. para_alignment:=aktalignment.paraalign;
  101. { push from left to right if specified }
  102. if push_from_left_to_right and assigned(right) then
  103. begin
  104. if (nf_varargs_para in flags) then
  105. tcallparanode(right).secondcallparan(push_from_left_to_right,
  106. calloption,para_alignment,para_offset)
  107. else
  108. tcallparanode(right).secondcallparan(push_from_left_to_right,
  109. calloption,para_alignment,para_offset);
  110. end;
  111. otlabel:=truelabel;
  112. oflabel:=falselabel;
  113. objectlibrary.getlabel(truelabel);
  114. objectlibrary.getlabel(falselabel);
  115. secondpass(left);
  116. { handle varargs first, because defcoll is not valid }
  117. if (nf_varargs_para in flags) then
  118. begin
  119. if paramanager.push_addr_param(left.resulttype.def,calloption) then
  120. begin
  121. inc(pushedparasize,POINTER_SIZE);
  122. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  123. location_release(exprasmlist,left.location);
  124. end
  125. else
  126. push_value_para(exprasmlist,left,calloption,para_offset,para_alignment,paraitem.paraloc);
  127. end
  128. { hidden parameters }
  129. else if paraitem.is_hidden then
  130. begin
  131. { don't push a node that already generated a pointer type
  132. by address for implicit hidden parameters }
  133. if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) or
  134. (not(left.resulttype.def.deftype in [pointerdef,classrefdef]) and
  135. paramanager.push_addr_param(paraitem.paratype.def,calloption)) then
  136. begin
  137. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  138. internalerror(200305071);
  139. inc(pushedparasize,POINTER_SIZE);
  140. if calloption=pocall_inline then
  141. begin
  142. {$ifdef newra}
  143. tmpreg:=rg.getaddressregister(exprasmlist);
  144. {$else}
  145. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  146. {$endif}
  147. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  148. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  149. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  150. {$ifdef newra}
  151. rg.ungetregisterint(exprasmlist,tmpreg);
  152. {$else}
  153. cg.free_scratch_reg(exprasmlist,tmpreg);
  154. {$endif}
  155. end
  156. else
  157. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  158. location_release(exprasmlist,left.location);
  159. end
  160. else
  161. begin
  162. push_value_para(exprasmlist,left,calloption,
  163. para_offset,para_alignment,paraitem.paraloc);
  164. end;
  165. end
  166. { filter array of const c styled args }
  167. else if is_array_of_const(left.resulttype.def) and (nf_cargs in left.flags) then
  168. begin
  169. { nothing, everything is already pushed }
  170. end
  171. { in codegen.handleread.. paraitem.data is set to nil }
  172. else if assigned(paraitem.paratype.def) and
  173. (paraitem.paratype.def.deftype=formaldef) then
  174. begin
  175. { allow passing of a constant to a const formaldef }
  176. if (tvarsym(paraitem.parasym).varspez=vs_const) and
  177. (left.location.loc=LOC_CONSTANT) then
  178. location_force_mem(exprasmlist,left.location);
  179. { allow @var }
  180. inc(pushedparasize,POINTER_SIZE);
  181. if (left.nodetype=addrn) and
  182. (not(nf_procvarload in left.flags)) then
  183. begin
  184. if calloption=pocall_inline then
  185. begin
  186. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  187. cg.a_load_loc_ref(exprasmlist,left.location,href);
  188. end
  189. else
  190. cg.a_param_loc(exprasmlist,left.location,paraitem.paraloc);
  191. location_release(exprasmlist,left.location);
  192. end
  193. else
  194. begin
  195. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  196. internalerror(200304235);
  197. if calloption=pocall_inline then
  198. begin
  199. {$ifdef newra}
  200. tmpreg:=rg.getaddressregister(exprasmlist);
  201. {$else}
  202. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  203. {$endif newra}
  204. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  205. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  206. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  207. {$ifdef newra}
  208. rg.ungetregisterint(exprasmlist,tmpreg);
  209. {$else}
  210. cg.free_scratch_reg(exprasmlist,tmpreg);
  211. {$endif}
  212. end
  213. else
  214. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  215. location_release(exprasmlist,left.location);
  216. end;
  217. end
  218. { handle call by reference parameter }
  219. else if (paraitem.paratyp in [vs_var,vs_out]) then
  220. begin
  221. if (left.location.loc<>LOC_REFERENCE) then
  222. begin
  223. { passing self to a var parameter is allowed in
  224. TP and delphi }
  225. if not((left.location.loc=LOC_CREFERENCE) and
  226. is_self_node(left)) then
  227. internalerror(200106041);
  228. end;
  229. if (paraitem.paratyp=vs_out) and
  230. assigned(paraitem.paratype.def) and
  231. not is_class(paraitem.paratype.def) and
  232. paraitem.paratype.def.needs_inittable then
  233. cg.g_finalize(exprasmlist,paraitem.paratype.def,left.location.reference,false);
  234. inc(pushedparasize,POINTER_SIZE);
  235. if calloption=pocall_inline then
  236. begin
  237. {$ifdef newra}
  238. tmpreg:=rg.getaddressregister(exprasmlist);
  239. {$else}
  240. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  241. {$endif}
  242. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  243. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  244. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  245. {$ifdef newra}
  246. rg.ungetregisterint(exprasmlist,tmpreg);
  247. {$else}
  248. cg.free_scratch_reg(exprasmlist,tmpreg);
  249. {$endif}
  250. end
  251. else
  252. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  253. location_release(exprasmlist,left.location);
  254. end
  255. else
  256. begin
  257. { don't push a node that already generated a pointer type
  258. by address for implicit hidden parameters }
  259. if (not(
  260. paraitem.is_hidden and
  261. (left.resulttype.def.deftype in [pointerdef,classrefdef])
  262. ) and
  263. paramanager.push_addr_param(paraitem.paratype.def,calloption)) then
  264. begin
  265. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  266. begin
  267. { allow passing nil to a procvardef (methodpointer) }
  268. if (left.nodetype=typeconvn) and
  269. (left.resulttype.def.deftype=procvardef) and
  270. (ttypeconvnode(left).left.nodetype=niln) then
  271. begin
  272. tg.GetTemp(exprasmlist,tcgsize2size[left.location.size],tt_normal,href);
  273. if not (left.location.size in [OS_64,OS_S64]) then
  274. cg.a_load_loc_ref(exprasmlist,left.location,href)
  275. else
  276. cg64.a_load64_loc_ref(exprasmlist,left.location,href);
  277. location_reset(left.location,LOC_REFERENCE,left.location.size);
  278. left.location.reference:=href;
  279. end
  280. else
  281. internalerror(200204011);
  282. end;
  283. inc(pushedparasize,POINTER_SIZE);
  284. if calloption=pocall_inline then
  285. begin
  286. {$ifdef newra}
  287. tmpreg:=rg.getaddressregister(exprasmlist);
  288. {$else}
  289. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  290. {$endif}
  291. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  292. reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
  293. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  294. {$ifdef newra}
  295. rg.ungetregisterint(exprasmlist,tmpreg);
  296. {$else}
  297. cg.free_scratch_reg(exprasmlist,tmpreg);
  298. {$endif}
  299. end
  300. else
  301. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  302. location_release(exprasmlist,left.location);
  303. end
  304. else
  305. begin
  306. push_value_para(exprasmlist,left,calloption,
  307. para_offset,para_alignment,paraitem.paraloc);
  308. end;
  309. end;
  310. truelabel:=otlabel;
  311. falselabel:=oflabel;
  312. { update return location in callnode when this is the function
  313. result }
  314. if (vo_is_funcret in tvarsym(paraitem.parasym).varoptions) then
  315. begin
  316. location_copy(aktcallnode.location,left.location);
  317. end;
  318. { push from right to left }
  319. if not push_from_left_to_right and assigned(right) then
  320. begin
  321. if (nf_varargs_para in flags) then
  322. tcallparanode(right).secondcallparan(push_from_left_to_right,
  323. calloption,para_alignment,para_offset)
  324. else
  325. tcallparanode(right).secondcallparan(push_from_left_to_right,
  326. calloption,para_alignment,para_offset);
  327. end;
  328. end;
  329. {*****************************************************************************
  330. TCGCALLNODE
  331. *****************************************************************************}
  332. procedure tcgcallnode.extra_interrupt_code;
  333. begin
  334. end;
  335. function tcgcallnode.align_parasize(parasize,para_alignment:longint):longint;
  336. begin
  337. result:=0;
  338. end;
  339. procedure tcgcallnode.pop_parasize(pop_size:longint);
  340. begin
  341. end;
  342. procedure tcgcallnode.push_framepointer;
  343. var
  344. href : treference;
  345. hregister : tregister;
  346. i : integer;
  347. begin
  348. { this routine is itself not nested }
  349. if current_procdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel) then
  350. begin
  351. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.framepointer_offset);
  352. cg.a_param_ref(exprasmlist,OS_ADDR,href,paramanager.getintparaloc(1));
  353. end
  354. { one nesting level }
  355. else if (current_procdef.parast.symtablelevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  356. begin
  357. cg.a_param_reg(exprasmlist,OS_ADDR,current_procinfo.framepointer,paramanager.getintparaloc(1));
  358. end
  359. { very complex nesting level ... }
  360. else if (current_procdef.parast.symtablelevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  361. begin
  362. hregister:=rg.getaddressregister(exprasmlist);
  363. reference_reset_base(href,current_procinfo.framepointer,current_procinfo.framepointer_offset);
  364. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  365. i:=current_procdef.parast.symtablelevel;
  366. while (i>tprocdef(procdefinition).parast.symtablelevel) do
  367. begin
  368. reference_reset_base(href,hregister,current_procinfo.framepointer_offset);
  369. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  370. dec(i);
  371. end;
  372. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,paramanager.getintparaloc(1));
  373. rg.ungetaddressregister(exprasmlist,hregister);
  374. end;
  375. end;
  376. procedure tcgcallnode.handle_return_value(inlined:boolean);
  377. var
  378. cgsize : tcgsize;
  379. r,hregister : tregister;
  380. nr:Tnewregister;
  381. begin
  382. { structured results are easy to handle.... }
  383. { needed also when result_no_used !! }
  384. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  385. begin
  386. { Location should be setup by the funcret para }
  387. if location.loc<>LOC_REFERENCE then
  388. internalerror(200304241);
  389. end
  390. else
  391. { ansi/widestrings must be registered, so we can dispose them }
  392. if is_ansistring(resulttype.def) or
  393. is_widestring(resulttype.def) then
  394. begin
  395. location_reset(location,LOC_CREFERENCE,OS_ADDR);
  396. location.reference:=refcountedtemp;
  397. r.enum:=accumulator;
  398. cg.a_reg_alloc(exprasmlist,r);
  399. cg.a_load_reg_ref(exprasmlist,OS_ADDR,r,location.reference);
  400. cg.a_reg_dealloc(exprasmlist,r);
  401. end
  402. else
  403. { we have only to handle the result if it is used }
  404. if (nf_return_value_used in flags) then
  405. begin
  406. if (resulttype.def.deftype=floatdef) then
  407. begin
  408. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  409. {$ifdef cpufpemu}
  410. if cs_fp_emulation in aktmoduleswitches then
  411. location.register.enum := accumulator
  412. else
  413. {$endif cpufpemu}
  414. location.register.enum:=FPU_RESULT_REG;
  415. {$ifdef x86}
  416. inc(trgcpu(rg).fpuvaroffset);
  417. {$else x86}
  418. hregister := rg.getregisterfpu(exprasmlist);
  419. cg.a_loadfpu_reg_reg(exprasmlist,location.register,hregister);
  420. location.register := hregister;
  421. {$endif x86}
  422. end
  423. else
  424. begin
  425. cgsize:=def_cgsize(resulttype.def);
  426. { an object constructor is a function with pointer result }
  427. if (inlined or (right=nil)) and
  428. (procdefinition.proctypeoption=potype_constructor) then
  429. cgsize:=OS_ADDR;
  430. if cgsize<>OS_NO then
  431. begin
  432. location_reset(location,LOC_REGISTER,cgsize);
  433. {$ifndef cpu64bit}
  434. if cgsize in [OS_64,OS_S64] then
  435. begin
  436. {Move the function result to free registers, preferably the
  437. accumulator/accumulatorhigh, so no move is necessary.}
  438. r.enum:=R_INTREGISTER;
  439. r.number:=NR_ACCUMULATOR;
  440. hregister.enum:=R_INTREGISTER;
  441. hregister.number:=NR_ACCUMULATORHIGH;
  442. {$ifdef newra}
  443. rg.getexplicitregisterint(exprasmlist,NR_ACCUMULATOR);
  444. rg.getexplicitregisterint(exprasmlist,NR_ACCUMULATORHIGH);
  445. rg.ungetregisterint(exprasmlist,r);
  446. rg.ungetregisterint(exprasmlist,hregister);
  447. location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
  448. location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
  449. {$else newra}
  450. if RS_ACCUMULATOR in rg.unusedregsint then
  451. location.registerlow:=rg.getexplicitregisterint(exprasmlist,NR_ACCUMULATOR)
  452. else
  453. cg.a_reg_alloc(exprasmlist,r);
  454. if RS_ACCUMULATORHIGH in rg.unusedregsint then
  455. location.registerhigh:=rg.getexplicitregisterint(exprasmlist,NR_ACCUMULATORHIGH)
  456. else
  457. cg.a_reg_alloc(exprasmlist,hregister);
  458. { do this after both low,high are allocated, else it is possible that
  459. low will be loaded in the register that still contains high }
  460. if location.registerlow.number=NR_NO then
  461. location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
  462. if location.registerhigh.number=NR_NO then
  463. location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
  464. {$endif newra}
  465. cg64.a_load64_reg_reg(exprasmlist,joinreg64(r,hregister),
  466. location.register64);
  467. end
  468. else
  469. {$endif cpu64bit}
  470. begin
  471. {Move the function result to a free register, preferably the
  472. accumulator, so no move is necessary.}
  473. nr:=RS_ACCUMULATOR shl 8 or cgsize2subreg(cgsize);
  474. r.enum:=R_INTREGISTER;
  475. r.number:=nr;
  476. {$ifdef newra}
  477. rg.getexplicitregisterint(exprasmlist,nr);
  478. rg.ungetregisterint(exprasmlist,r);
  479. location.register:=rg.getregisterint(exprasmlist,cgsize);
  480. {$else newra}
  481. cg.a_reg_alloc(exprasmlist,r);
  482. if RS_ACCUMULATOR in rg.unusedregsint then
  483. location.register:=rg.getexplicitregisterint(exprasmlist,nr)
  484. else
  485. location.register:=rg.getregisterint(exprasmlist,cgsize);
  486. {$endif newra}
  487. cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,r,location.register);
  488. end;
  489. end
  490. else
  491. begin
  492. if resulttype.def.size>0 then
  493. internalerror(200305131);
  494. end;
  495. end;
  496. end
  497. else
  498. location_reset(location,LOC_VOID,OS_NO);
  499. end;
  500. procedure tcgcallnode.pass_2;
  501. var
  502. regs_to_push_int : Tsupregset;
  503. regs_to_push_other : tregisterset;
  504. unusedstate: pointer;
  505. pushedother : tpushedsavedother;
  506. pushedint : tpushedsavedint;
  507. oldpushedparasize : longint;
  508. { adress returned from an I/O-error }
  509. iolabel : tasmlabel;
  510. { help reference pointer }
  511. href : treference;
  512. hp : tnode;
  513. pp : tcallparanode;
  514. inlined : boolean;
  515. inlinecode : tprocinlinenode;
  516. pushedregs : tmaybesave;
  517. store_parast_fixup,
  518. para_alignment,
  519. para_offset : longint;
  520. pop_size : longint;
  521. returnref,
  522. pararef : treference;
  523. accreg : tregister;
  524. oldaktcallnode : tcallnode;
  525. begin
  526. iolabel:=nil;
  527. inlinecode:=nil;
  528. inlined:=false;
  529. rg.saveunusedstate(unusedstate);
  530. { if we allocate the temp. location for ansi- or widestrings }
  531. { already here, we avoid later a push/pop }
  532. if is_widestring(resulttype.def) then
  533. begin
  534. tg.GetTemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  535. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  536. end
  537. else if is_ansistring(resulttype.def) then
  538. begin
  539. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  540. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp,false);
  541. end;
  542. if (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_stdcall]) then
  543. para_alignment:=4
  544. else
  545. para_alignment:=aktalignment.paraalign;
  546. if not assigned(procdefinition) then
  547. exit;
  548. if (procdefinition.proccalloption=pocall_inline) then
  549. begin
  550. inlined:=true;
  551. inlinecode:=tprocinlinenode(right);
  552. right:=nil;
  553. { set it to the same lexical level as the local symtable, becuase
  554. the para's are stored there }
  555. tprocdef(procdefinition).parast.symtablelevel:=current_procdef.localst.symtablelevel;
  556. if assigned(left) then
  557. begin
  558. inlinecode.para_size:=tprocdef(procdefinition).para_size(para_alignment);
  559. tg.GetTemp(exprasmlist,inlinecode.para_size,tt_persistent,pararef);
  560. inlinecode.para_offset:=pararef.offset;
  561. end;
  562. store_parast_fixup:=tprocdef(procdefinition).parast.address_fixup;
  563. tprocdef(procdefinition).parast.address_fixup:=inlinecode.para_offset;
  564. {$ifdef extdebug}
  565. Comment(V_debug,
  566. 'inlined parasymtable is at offset '
  567. +tostr(tprocdef(procdefinition).parast.address_fixup));
  568. exprasmList.concat(tai_comment.Create(
  569. strpnew('inlined parasymtable is at offset '
  570. +tostr(tprocdef(procdefinition).parast.address_fixup))));
  571. {$endif extdebug}
  572. end;
  573. { proc variables destroy all registers }
  574. if (inlined or
  575. (right=nil)) and
  576. { virtual methods too }
  577. not(po_virtualmethod in procdefinition.procoptions) then
  578. begin
  579. if (cs_check_io in aktlocalswitches) and
  580. (po_iocheck in procdefinition.procoptions) and
  581. not(po_iocheck in current_procdef.procoptions) then
  582. begin
  583. objectlibrary.getaddrlabel(iolabel);
  584. cg.a_label(exprasmlist,iolabel);
  585. end
  586. else
  587. iolabel:=nil;
  588. { save all used registers and possible registers
  589. used for the return value }
  590. regs_to_push_int := tprocdef(procdefinition).usedintregisters;
  591. regs_to_push_other := tprocdef(procdefinition).usedotherregisters;
  592. if (not is_void(resulttype.def)) and
  593. (not paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption)) then
  594. begin
  595. include(regs_to_push_int,RS_ACCUMULATOR);
  596. {$ifndef cpu64bit}
  597. if resulttype.def.size>sizeof(aword) then
  598. include(regs_to_push_int,RS_ACCUMULATORHIGH);
  599. {$endif cpu64bit}
  600. end;
  601. rg.saveusedintregisters(exprasmlist,pushedint,regs_to_push_int);
  602. rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
  603. { give used registers through }
  604. rg.usedintinproc:=rg.usedintinproc + tprocdef(procdefinition).usedintregisters;
  605. rg.usedinproc:=rg.usedinproc + tprocdef(procdefinition).usedotherregisters;
  606. end
  607. else
  608. begin
  609. regs_to_push_int := all_intregisters;
  610. regs_to_push_other := all_registers;
  611. rg.saveusedintregisters(exprasmlist,pushedint,regs_to_push_int);
  612. rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
  613. rg.usedinproc:=all_registers;
  614. { no IO check for methods and procedure variables }
  615. iolabel:=nil;
  616. end;
  617. { Initialize for pushing the parameters }
  618. oldpushedparasize:=pushedparasize;
  619. pushedparasize:=0;
  620. pop_size:=0;
  621. { Align stack if required }
  622. if not inlined then
  623. pop_size:=align_parasize(oldpushedparasize,para_alignment);
  624. { Push parameters }
  625. oldaktcallnode:=aktcallnode;
  626. aktcallnode:=self;
  627. { process procvar. Done here already, because otherwise it may }
  628. { destroy registers containing a parameter for the actual }
  629. { function call (e.g. if it's a function, its result will }
  630. { overwrite r3, which contains the first parameter) (JM) }
  631. if not(inlined) and
  632. assigned(right) then
  633. secondpass(right);
  634. if inlined or
  635. (right = nil) then
  636. begin
  637. if (po_virtualmethod in procdefinition.procoptions) and
  638. assigned(methodpointer) then
  639. begin
  640. secondpass(methodpointer);
  641. location_force_reg(exprasmlist,methodpointer.location,OS_ADDR,false);
  642. { virtual methods require an index }
  643. if tprocdef(procdefinition).extnumber=-1 then
  644. internalerror(200304021);
  645. { VMT should already be loaded in a register }
  646. if methodpointer.location.register.number=NR_NO then
  647. internalerror(200304022);
  648. { test validity of VMT }
  649. if not(is_interface(tprocdef(procdefinition)._class)) and
  650. not(is_cppclass(tprocdef(procdefinition)._class)) then
  651. cg.g_maybe_testvmt(exprasmlist,methodpointer.location.register,tprocdef(procdefinition)._class);
  652. end;
  653. end;
  654. if assigned(left) then
  655. begin
  656. {$ifndef newra}
  657. if assigned(right) then
  658. maybe_save(exprasmlist,left.registers32,right.location,pushedregs)
  659. else
  660. if assigned(methodpointer) then
  661. maybe_save(exprasmlist,left.registers32,methodpointer.location,pushedregs);
  662. {$endif}
  663. { be found elsewhere }
  664. if inlined then
  665. para_offset:=tprocdef(procdefinition).parast.address_fixup+
  666. tprocdef(procdefinition).parast.datasize
  667. else
  668. para_offset:=0;
  669. if not(inlined) and
  670. assigned(right) then
  671. tcallparanode(left).secondcallparan(
  672. (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
  673. para_alignment,para_offset)
  674. else
  675. tcallparanode(left).secondcallparan(
  676. (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
  677. para_alignment,para_offset);
  678. {$ifndef newra}
  679. if assigned(right) then
  680. maybe_restore(exprasmlist,right.location,pushedregs)
  681. else
  682. if assigned(methodpointer) then
  683. maybe_restore(exprasmlist,methodpointer.location,pushedregs);
  684. {$endif newra}
  685. end;
  686. aktcallnode:=oldaktcallnode;
  687. { Allocate return value for inlined routines }
  688. if inlined and
  689. (resulttype.def.size>0) then
  690. begin
  691. tg.GetTemp(exprasmlist,Align(resulttype.def.size,aktalignment.paraalign),tt_persistent,returnref);
  692. inlinecode.retoffset:=returnref.offset;
  693. end;
  694. { procedure variable or normal function call ? }
  695. if inlined or
  696. (right=nil) then
  697. begin
  698. { push base pointer ?}
  699. { never when inlining, since if necessary, the base pointer }
  700. { can/will be gottten from the current procedure's symtable }
  701. { (JM) }
  702. if not inlined then
  703. if (current_procdef.parast.symtablelevel>=normal_function_level) and
  704. assigned(tprocdef(procdefinition).parast) and
  705. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  706. push_framepointer;
  707. rg.saveintregvars(exprasmlist,regs_to_push_int);
  708. rg.saveotherregvars(exprasmlist,regs_to_push_other);
  709. if (po_virtualmethod in procdefinition.procoptions) and
  710. assigned(methodpointer) then
  711. begin
  712. { call method }
  713. reference_reset_base(href,methodpointer.location.register,
  714. tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber));
  715. cg.a_call_ref(exprasmlist,href);
  716. { release self }
  717. rg.ungetaddressregister(exprasmlist,methodpointer.location.register);
  718. end
  719. else
  720. begin
  721. if not inlined then
  722. begin
  723. { Calling interrupt from the same code requires some
  724. extra code }
  725. if (po_interrupt in procdefinition.procoptions) then
  726. extra_interrupt_code;
  727. cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname);
  728. end
  729. else { inlined proc }
  730. begin
  731. { process the inlinecode }
  732. secondpass(tnode(inlinecode));
  733. { free the args }
  734. if tprocdef(procdefinition).parast.datasize>0 then
  735. tg.UnGetTemp(exprasmlist,pararef);
  736. end;
  737. end;
  738. end
  739. else
  740. { now procedure variable case }
  741. begin
  742. { Calling interrupt from the same code requires some
  743. extra code }
  744. if (po_interrupt in procdefinition.procoptions) then
  745. extra_interrupt_code;
  746. rg.saveintregvars(exprasmlist,ALL_INTREGISTERS);
  747. rg.saveotherregvars(exprasmlist,ALL_REGISTERS);
  748. cg.a_call_loc(exprasmlist,right.location);
  749. location_release(exprasmlist,right.location);
  750. location_freetemp(exprasmlist,right.location);
  751. end;
  752. { Need to remove the parameters from the stack? }
  753. if (not inlined) and (po_clearstack in procdefinition.procoptions) then
  754. begin
  755. { the old pop_size was already included in pushedparasize }
  756. pop_size:=pushedparasize;
  757. { for Cdecl functions we don't need to pop the funcret when it
  758. was pushed by para }
  759. if paramanager.ret_in_param(procdefinition.rettype.def,procdefinition.proccalloption) then
  760. dec(pop_size,POINTER_SIZE);
  761. end;
  762. { Remove parameters/alignment from the stack }
  763. if pop_size>0 then
  764. pop_parasize(pop_size);
  765. {$ifdef powerpc}
  766. { this calculation must be done in pass_1 anyway, so don't worry }
  767. if tppcprocinfo(current_procinfo).maxpushedparasize<pushedparasize then
  768. tppcprocinfo(current_procinfo).maxpushedparasize:=pushedparasize;
  769. {$endif powerpc}
  770. { Restore }
  771. pushedparasize:=oldpushedparasize;
  772. rg.restoreunusedstate(unusedstate);
  773. {$ifdef TEMPREGDEBUG}
  774. testregisters32;
  775. {$endif TEMPREGDEBUG}
  776. { handle function results }
  777. if (not is_void(resulttype.def)) then
  778. handle_return_value(inlined)
  779. else
  780. location_reset(location,LOC_VOID,OS_NO);
  781. { perhaps i/o check ? }
  782. if iolabel<>nil then
  783. begin
  784. reference_reset_symbol(href,iolabel,0);
  785. cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(1));
  786. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  787. end;
  788. { restore registers }
  789. rg.restoreusedotherregisters(exprasmlist,pushedother);
  790. rg.restoreusedintregisters(exprasmlist,pushedint);
  791. { Release temps from parameters }
  792. pp:=tcallparanode(left);
  793. while assigned(pp) do
  794. begin
  795. if assigned(pp.left) then
  796. begin
  797. { don't release the funcret temp }
  798. if not(vo_is_funcret in tvarsym(pp.paraitem.parasym).varoptions) then
  799. location_freetemp(exprasmlist,pp.left.location);
  800. { process also all nodes of an array of const }
  801. if pp.left.nodetype=arrayconstructorn then
  802. begin
  803. if assigned(tarrayconstructornode(pp.left).left) then
  804. begin
  805. hp:=pp.left;
  806. while assigned(hp) do
  807. begin
  808. location_freetemp(exprasmlist,tarrayconstructornode(hp).left.location);
  809. hp:=tarrayconstructornode(hp).right;
  810. end;
  811. end;
  812. end;
  813. end;
  814. pp:=tcallparanode(pp.right);
  815. end;
  816. if inlined then
  817. begin
  818. if (resulttype.def.size>0) then
  819. tg.UnGetTemp(exprasmlist,returnref);
  820. tprocdef(procdefinition).parast.address_fixup:=store_parast_fixup;
  821. right:=inlinecode;
  822. { from now on the result can be freed normally }
  823. if assigned(funcretnode) and
  824. paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  825. tg.ChangeTempType(exprasmlist,funcretnode.location.reference,tt_normal);
  826. end;
  827. { if return value is not used }
  828. if (not(nf_return_value_used in flags)) and (not is_void(resulttype.def)) then
  829. begin
  830. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  831. begin
  832. { data which must be finalized ? }
  833. if (resulttype.def.needs_inittable) then
  834. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  835. { release unused temp }
  836. tg.ungetiftemp(exprasmlist,location.reference)
  837. end
  838. else if location.loc=LOC_FPUREGISTER then
  839. begin
  840. {$ifdef x86}
  841. { release FPU stack }
  842. accreg.enum:=FPU_RESULT_REG;
  843. emit_reg(A_FSTP,S_NO,accreg);
  844. {
  845. dec(trgcpu(rg).fpuvaroffset);
  846. do NOT decrement as the increment before
  847. is not called for unused results PM }
  848. {$endif x86}
  849. end;
  850. end;
  851. end;
  852. {*****************************************************************************
  853. TCGPROCINLINENODE
  854. *****************************************************************************}
  855. procedure tcgprocinlinenode.pass_2;
  856. var st : tsymtable;
  857. oldprocdef : tprocdef;
  858. ps, i : longint;
  859. oldprocinfo : tprocinfo;
  860. oldinlining_procedure,
  861. nostackframe : boolean;
  862. inlineentrycode,inlineexitcode : TAAsmoutput;
  863. oldexitlabel,oldexit2label:tasmlabel;
  864. oldregstate: pointer;
  865. localsref : treference;
  866. {$ifdef GDB}
  867. startlabel,endlabel : tasmlabel;
  868. pp : pchar;
  869. mangled_length : longint;
  870. {$endif GDB}
  871. begin
  872. { deallocate the registers used for the current procedure's regvars }
  873. if assigned(current_procdef.regvarinfo) then
  874. begin
  875. with pregvarinfo(current_procdef.regvarinfo)^ do
  876. for i := 1 to maxvarregs do
  877. if assigned(regvars[i]) then
  878. store_regvar(exprasmlist,regvars[i].reg);
  879. rg.saveStateForInline(oldregstate);
  880. { make sure the register allocator knows what the regvars in the }
  881. { inlined code block are (JM) }
  882. rg.resetusableregisters;
  883. rg.clearregistercount;
  884. {$ifndef newra}
  885. rg.cleartempgen;
  886. {$endif}
  887. if assigned(inlineprocdef.regvarinfo) then
  888. with pregvarinfo(inlineprocdef.regvarinfo)^ do
  889. for i := 1 to maxvarregs do
  890. if assigned(regvars[i]) then
  891. begin
  892. {Fix me!!}
  893. {tmpreg:=rg.makeregsize(regvars[i].reg,OS_INT);
  894. rg.makeregvar(tmpreg);}
  895. internalerror(200301232);
  896. end;
  897. end;
  898. oldinlining_procedure:=inlining_procedure;
  899. oldexitlabel:=aktexitlabel;
  900. oldexit2label:=aktexit2label;
  901. oldprocdef:=current_procdef;
  902. oldprocinfo:=current_procinfo;
  903. objectlibrary.getlabel(aktexitlabel);
  904. objectlibrary.getlabel(aktexit2label);
  905. { we're inlining a procedure }
  906. inlining_procedure:=true;
  907. { create temp procinfo }
  908. current_procinfo:=cprocinfo.create(nil);
  909. current_procinfo.procdef:=inlineprocdef;
  910. current_procinfo.return_offset:=retoffset;
  911. current_procdef:=current_procinfo.procdef;
  912. { arg space has been filled by the parent secondcall }
  913. st:=current_procdef.localst;
  914. { set it to the same lexical level }
  915. st.symtablelevel:=oldprocdef.localst.symtablelevel;
  916. if st.datasize>0 then
  917. begin
  918. tg.GetTemp(exprasmlist,st.datasize,tt_persistent,localsref);
  919. if tg.direction>0 then
  920. st.address_fixup:=localsref.offset
  921. else
  922. st.address_fixup:=localsref.offset+st.datasize;
  923. {$ifdef extdebug}
  924. Comment(V_debug,'local symtable is at offset '+tostr(st.address_fixup));
  925. exprasmList.concat(tai_comment.Create(strpnew(
  926. 'local symtable is at offset '+tostr(st.address_fixup))));
  927. {$endif extdebug}
  928. end;
  929. exprasmList.concat(Tai_Marker.Create(InlineStart));
  930. {$ifdef extdebug}
  931. exprasmList.concat(tai_comment.Create(strpnew('Start of inlined proc')));
  932. {$endif extdebug}
  933. {$ifdef GDB}
  934. if (cs_debuginfo in aktmoduleswitches) then
  935. begin
  936. objectlibrary.getaddrlabel(startlabel);
  937. objectlibrary.getaddrlabel(endlabel);
  938. cg.a_label(exprasmlist,startlabel);
  939. inlineprocdef.localst.symtabletype:=inlinelocalsymtable;
  940. inlineprocdef.parast.symtabletype:=inlineparasymtable;
  941. { Here we must include the para and local symtable info }
  942. inlineprocdef.concatstabto(withdebuglist);
  943. { set it back for safety }
  944. inlineprocdef.localst.symtabletype:=localsymtable;
  945. inlineprocdef.parast.symtabletype:=parasymtable;
  946. mangled_length:=length(oldprocdef.mangledname);
  947. getmem(pp,mangled_length+50);
  948. strpcopy(pp,'192,0,0,'+startlabel.name);
  949. if (target_info.use_function_relative_addresses) then
  950. begin
  951. strpcopy(strend(pp),'-');
  952. strpcopy(strend(pp),oldprocdef.mangledname);
  953. end;
  954. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  955. end;
  956. {$endif GDB}
  957. { takes care of local data initialization }
  958. inlineentrycode:=TAAsmoutput.Create;
  959. inlineexitcode:=TAAsmoutput.Create;
  960. ps:=para_size;
  961. genentrycode(inlineentrycode,0,ps,nostackframe,true);
  962. if po_assembler in current_procdef.procoptions then
  963. inlineentrycode.insert(Tai_marker.Create(asmblockstart));
  964. exprasmList.concatlist(inlineentrycode);
  965. secondpass(inlinetree);
  966. genexitcode(inlineexitcode,0,false,true);
  967. if po_assembler in current_procdef.procoptions then
  968. inlineexitcode.concat(Tai_marker.Create(asmblockend));
  969. exprasmList.concatlist(inlineexitcode);
  970. inlineentrycode.free;
  971. inlineexitcode.free;
  972. {$ifdef extdebug}
  973. exprasmList.concat(tai_comment.Create(strpnew('End of inlined proc')));
  974. {$endif extdebug}
  975. exprasmList.concat(Tai_Marker.Create(InlineEnd));
  976. {we can free the local data now, reset also the fixup address }
  977. if st.datasize>0 then
  978. begin
  979. tg.UnGetTemp(exprasmlist,localsref);
  980. st.address_fixup:=0;
  981. end;
  982. { restore procinfo }
  983. current_procinfo.free;
  984. current_procinfo:=oldprocinfo;
  985. {$ifdef GDB}
  986. if (cs_debuginfo in aktmoduleswitches) then
  987. begin
  988. cg.a_label(exprasmlist,endlabel);
  989. strpcopy(pp,'224,0,0,'+endlabel.name);
  990. if (target_info.use_function_relative_addresses) then
  991. begin
  992. strpcopy(strend(pp),'-');
  993. strpcopy(strend(pp),oldprocdef.mangledname);
  994. end;
  995. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  996. freemem(pp,mangled_length+50);
  997. end;
  998. {$endif GDB}
  999. { restore }
  1000. current_procdef:=oldprocdef;
  1001. aktexitlabel:=oldexitlabel;
  1002. aktexit2label:=oldexit2label;
  1003. inlining_procedure:=oldinlining_procedure;
  1004. { reallocate the registers used for the current procedure's regvars, }
  1005. { since they may have been used and then deallocated in the inlined }
  1006. { procedure (JM) }
  1007. if assigned(current_procdef.regvarinfo) then
  1008. begin
  1009. rg.restoreStateAfterInline(oldregstate);
  1010. end;
  1011. end;
  1012. begin
  1013. ccallparanode:=tcgcallparanode;
  1014. ccallnode:=tcgcallnode;
  1015. cprocinlinenode:=tcgprocinlinenode;
  1016. end.
  1017. {
  1018. $Log$
  1019. Revision 1.74 2003-05-25 11:34:17 peter
  1020. * methodpointer self pushing fixed
  1021. Revision 1.73 2003/05/25 08:59:16 peter
  1022. * inline fixes
  1023. Revision 1.72 2003/05/24 13:36:54 jonas
  1024. * save fpu results in a normal fpu register on non-x86 processors
  1025. Revision 1.71 2003/05/23 19:35:50 jonas
  1026. - undid previous commit, it was wrong
  1027. Revision 1.70 2003/05/23 19:11:58 jonas
  1028. * fixed tests for whether a certain int register is unused
  1029. Revision 1.69 2003/05/23 18:01:56 jonas
  1030. * fixed ppc compiler
  1031. Revision 1.68 2003/05/23 14:27:35 peter
  1032. * remove some unit dependencies
  1033. * current_procinfo changes to store more info
  1034. Revision 1.67 2003/05/17 13:30:08 jonas
  1035. * changed tt_persistant to tt_persistent :)
  1036. * tempcreatenode now doesn't accept a boolean anymore for persistent
  1037. temps, but a ttemptype, so you can also create ansistring temps etc
  1038. Revision 1.66 2003/05/16 14:33:31 peter
  1039. * regvar fixes
  1040. Revision 1.65 2003/05/15 18:58:53 peter
  1041. * removed selfpointer_offset, vmtpointer_offset
  1042. * tvarsym.adjusted_address
  1043. * address in localsymtable is now in the real direction
  1044. * removed some obsolete globals
  1045. Revision 1.64 2003/05/14 19:36:54 jonas
  1046. * patch from Peter for int64 function results
  1047. Revision 1.63 2003/05/13 19:14:41 peter
  1048. * failn removed
  1049. * inherited result code check moven to pexpr
  1050. Revision 1.62 2003/05/13 15:18:18 peter
  1051. * generate code for procvar first before pushing parameters. Made
  1052. the already existing code for powerpc available for all platforms
  1053. Revision 1.61 2003/05/12 18:17:55 jonas
  1054. * moved fpc_check_object call earlier for the ppc, so it can't destroy
  1055. already-loaded parameter registers
  1056. Revision 1.60 2003/05/11 21:48:38 jonas
  1057. * fixed procvar bug on the ppc (load procvar before loading para's,
  1058. because the procvar may otherwise destroy the already loaded paras)
  1059. Revision 1.59 2003/05/09 17:47:02 peter
  1060. * self moved to hidden parameter
  1061. * removed hdisposen,hnewn,selfn
  1062. Revision 1.58 2003/05/05 14:53:16 peter
  1063. * vs_hidden replaced by is_hidden boolean
  1064. Revision 1.57 2003/04/30 20:53:32 florian
  1065. * error when address of an abstract method is taken
  1066. * fixed some x86-64 problems
  1067. * merged some more x86-64 and i386 code
  1068. Revision 1.56 2003/04/29 07:28:52 michael
  1069. + Patch from peter to fix wrong pushing of ansistring function results in open array
  1070. Revision 1.55 2003/04/27 11:21:33 peter
  1071. * aktprocdef renamed to current_procdef
  1072. * procinfo renamed to current_procinfo
  1073. * procinfo will now be stored in current_module so it can be
  1074. cleaned up properly
  1075. * gen_main_procsym changed to create_main_proc and release_main_proc
  1076. to also generate a tprocinfo structure
  1077. * fixed unit implicit initfinal
  1078. Revision 1.54 2003/04/27 07:29:50 peter
  1079. * current_procdef cleanup, current_procdef is now always nil when parsing
  1080. a new procdef declaration
  1081. * aktprocsym removed
  1082. * lexlevel removed, use symtable.symtablelevel instead
  1083. * implicit init/final code uses the normal genentry/genexit
  1084. * funcret state checking updated for new funcret handling
  1085. Revision 1.53 2003/04/25 20:59:33 peter
  1086. * removed funcretn,funcretsym, function result is now in varsym
  1087. and aliases for result and function name are added using absolutesym
  1088. * vs_hidden parameter for funcret passed in parameter
  1089. * vs_hidden fixes
  1090. * writenode changed to printnode and released from extdebug
  1091. * -vp option added to generate a tree.log with the nodetree
  1092. * nicer printnode for statements, callnode
  1093. Revision 1.52 2003/04/25 08:25:26 daniel
  1094. * Ifdefs around a lot of calls to cleartempgen
  1095. * Fixed registers that are allocated but not freed in several nodes
  1096. * Tweak to register allocator to cause less spills
  1097. * 8-bit registers now interfere with esi,edi and ebp
  1098. Compiler can now compile rtl successfully when using new register
  1099. allocator
  1100. Revision 1.51 2003/04/22 23:50:22 peter
  1101. * firstpass uses expectloc
  1102. * checks if there are differences between the expectloc and
  1103. location.loc from secondpass in EXTDEBUG
  1104. Revision 1.50 2003/04/22 14:33:38 peter
  1105. * removed some notes/hints
  1106. Revision 1.49 2003/04/22 13:47:08 peter
  1107. * fixed C style array of const
  1108. * fixed C array passing
  1109. * fixed left to right with high parameters
  1110. Revision 1.48 2003/04/22 10:09:34 daniel
  1111. + Implemented the actual register allocator
  1112. + Scratch registers unavailable when new register allocator used
  1113. + maybe_save/maybe_restore unavailable when new register allocator used
  1114. Revision 1.47 2003/04/22 09:49:44 peter
  1115. * do not load self when calling a non-inherited class constructor
  1116. Revision 1.46 2003/04/21 20:03:32 peter
  1117. * forgot to copy vmtrefaddr to selfrefaddr when self=vmt
  1118. Revision 1.45 2003/04/21 13:53:16 jonas
  1119. - removed copying of all paras when secondpassing a callnode (this used
  1120. to be necessary for inlinign support, but currently the whole inlined
  1121. procedure is already copied in advance). Note that the compiler crashes
  1122. when compiling ucomplex with -dTEST_INLINE (also after fixing the
  1123. syntax errors), but that was also the case before this change.
  1124. Revision 1.44 2003/04/10 17:57:52 peter
  1125. * vs_hidden released
  1126. Revision 1.43 2003/04/06 21:11:23 olle
  1127. * changed newasmsymbol to newasmsymboldata for data symbols
  1128. Revision 1.42 2003/04/04 15:38:56 peter
  1129. * moved generic code from n386cal to ncgcal, i386 now also
  1130. uses the generic ncgcal
  1131. Revision 1.41 2003/03/28 19:16:56 peter
  1132. * generic constructor working for i386
  1133. * remove fixed self register
  1134. * esi added as address register for i386
  1135. Revision 1.40 2003/03/06 11:35:50 daniel
  1136. * Fixed internalerror 7843 issue
  1137. Revision 1.39 2003/02/19 22:00:14 daniel
  1138. * Code generator converted to new register notation
  1139. - Horribily outdated todo.txt removed
  1140. Revision 1.38 2003/02/15 22:17:38 carl
  1141. * bugfix of FPU emulation code
  1142. Revision 1.37 2003/02/12 22:10:07 carl
  1143. * load_frame_pointer is now generic
  1144. * change fpu emulation routine names
  1145. Revision 1.36 2003/01/30 21:46:57 peter
  1146. * self fixes for static methods (merged)
  1147. Revision 1.35 2003/01/22 20:45:15 mazen
  1148. * making math code in RTL compiling.
  1149. *NB : This does NOT mean necessary that it will generate correct code!
  1150. Revision 1.34 2003/01/17 12:03:45 daniel
  1151. * Optalign conditional code adapted to record Tregister
  1152. Revision 1.33 2003/01/08 18:43:56 daniel
  1153. * Tregister changed into a record
  1154. Revision 1.32 2002/12/15 22:50:00 florian
  1155. + some stuff for the new hidden parameter handling added
  1156. Revision 1.31 2002/12/15 21:30:12 florian
  1157. * tcallnode.paraitem introduced, all references to defcoll removed
  1158. Revision 1.30 2002/11/27 20:04:39 peter
  1159. * cdecl array of const fixes
  1160. Revision 1.29 2002/11/25 17:43:17 peter
  1161. * splitted defbase in defutil,symutil,defcmp
  1162. * merged isconvertable and is_equal into compare_defs(_ext)
  1163. * made operator search faster by walking the list only once
  1164. Revision 1.28 2002/11/18 17:31:54 peter
  1165. * pass proccalloption to ret_in_xxx and push_xxx functions
  1166. Revision 1.27 2002/11/16 15:34:30 florian
  1167. * generic location for float results
  1168. Revision 1.26 2002/11/15 01:58:51 peter
  1169. * merged changes from 1.0.7 up to 04-11
  1170. - -V option for generating bug report tracing
  1171. - more tracing for option parsing
  1172. - errors for cdecl and high()
  1173. - win32 import stabs
  1174. - win32 records<=8 are returned in eax:edx (turned off by default)
  1175. - heaptrc update
  1176. - more info for temp management in .s file with EXTDEBUG
  1177. Revision 1.25 2002/10/05 12:43:25 carl
  1178. * fixes for Delphi 6 compilation
  1179. (warning : Some features do not work under Delphi)
  1180. Revision 1.24 2002/09/30 07:00:45 florian
  1181. * fixes to common code to get the alpha compiler compiled applied
  1182. Revision 1.23 2002/09/17 18:54:02 jonas
  1183. * a_load_reg_reg() now has two size parameters: source and dest. This
  1184. allows some optimizations on architectures that don't encode the
  1185. register size in the register name.
  1186. Revision 1.22 2002/09/07 15:25:02 peter
  1187. * old logs removed and tabs fixed
  1188. Revision 1.21 2002/09/07 11:50:02 jonas
  1189. * fixed small regalloction info bug
  1190. Revision 1.20 2002/09/02 11:25:20 florian
  1191. * fixed generic procedure variable calling
  1192. Revision 1.19 2002/09/01 21:04:48 florian
  1193. * several powerpc related stuff fixed
  1194. Revision 1.18 2002/09/01 18:43:27 peter
  1195. * include accumulator in regs_to_push list
  1196. Revision 1.17 2002/09/01 12:13:00 peter
  1197. * use a_call_reg
  1198. * ungetiftemp for procvar of object temp
  1199. Revision 1.16 2002/08/25 19:25:18 peter
  1200. * sym.insert_in_data removed
  1201. * symtable.insertvardata/insertconstdata added
  1202. * removed insert_in_data call from symtable.insert, it needs to be
  1203. called separatly. This allows to deref the address calculation
  1204. * procedures now calculate the parast addresses after the procedure
  1205. directives are parsed. This fixes the cdecl parast problem
  1206. * push_addr_param has an extra argument that specifies if cdecl is used
  1207. or not
  1208. Revision 1.15 2002/08/23 16:14:48 peter
  1209. * tempgen cleanup
  1210. * tt_noreuse temp type added that will be used in genentrycode
  1211. Revision 1.14 2002/08/20 16:55:38 peter
  1212. * don't write (stabs)line info when inlining a procedure
  1213. Revision 1.13 2002/08/19 19:36:42 peter
  1214. * More fixes for cross unit inlining, all tnodes are now implemented
  1215. * Moved pocall_internconst to po_internconst because it is not a
  1216. calling type at all and it conflicted when inlining of these small
  1217. functions was requested
  1218. Revision 1.12 2002/08/18 20:06:23 peter
  1219. * inlining is now also allowed in interface
  1220. * renamed write/load to ppuwrite/ppuload
  1221. * tnode storing in ppu
  1222. * nld,ncon,nbas are already updated for storing in ppu
  1223. Revision 1.11 2002/08/17 22:09:44 florian
  1224. * result type handling in tcgcal.pass_2 overhauled
  1225. * better tnode.dowrite
  1226. * some ppc stuff fixed
  1227. Revision 1.10 2002/08/17 09:23:35 florian
  1228. * first part of procinfo rewrite
  1229. Revision 1.9 2002/08/13 21:40:55 florian
  1230. * more fixes for ppc calling conventions
  1231. Revision 1.8 2002/08/13 18:01:51 carl
  1232. * rename swatoperands to swapoperands
  1233. + m68k first compilable version (still needs a lot of testing):
  1234. assembler generator, system information , inline
  1235. assembler reader.
  1236. Revision 1.7 2002/08/12 15:08:39 carl
  1237. + stab register indexes for powerpc (moved from gdb to cpubase)
  1238. + tprocessor enumeration moved to cpuinfo
  1239. + linker in target_info is now a class
  1240. * many many updates for m68k (will soon start to compile)
  1241. - removed some ifdef or correct them for correct cpu
  1242. Revision 1.6 2002/08/11 14:32:26 peter
  1243. * renamed current_library to objectlibrary
  1244. Revision 1.5 2002/08/11 13:24:11 peter
  1245. * saving of asmsymbols in ppu supported
  1246. * asmsymbollist global is removed and moved into a new class
  1247. tasmlibrarydata that will hold the info of a .a file which
  1248. corresponds with a single module. Added librarydata to tmodule
  1249. to keep the library info stored for the module. In the future the
  1250. objectfiles will also be stored to the tasmlibrarydata class
  1251. * all getlabel/newasmsymbol and friends are moved to the new class
  1252. Revision 1.4 2002/08/06 20:55:20 florian
  1253. * first part of ppc calling conventions fix
  1254. Revision 1.3 2002/07/20 11:57:53 florian
  1255. * types.pas renamed to defbase.pas because D6 contains a types
  1256. unit so this would conflicts if D6 programms are compiled
  1257. + Willamette/SSE2 instructions to assembler added
  1258. Revision 1.2 2002/07/13 19:38:43 florian
  1259. * some more generic calling stuff fixed
  1260. }