ncgcal.pas 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787
  1. {
  2. Id: ncgcal.pas,v 1.10 2002/08/17 09:23:35 florian Exp $
  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. funcretref : treference;
  34. refcountedtemp : treference;
  35. procedure handle_return_value(inlined,extended_new:boolean);
  36. {# This routine is used to push the current frame pointer
  37. on the stack. This is used in nested routines where the
  38. value of the frame pointer is always pushed as an extra
  39. parameter.
  40. The default handling is the standard handling used on
  41. most stack based machines, where the frame pointer is
  42. the first invisible parameter.
  43. }
  44. procedure load_framepointer;virtual;
  45. procedure extra_interrupt_code;virtual;
  46. public
  47. procedure pass_2;override;
  48. end;
  49. tcgprocinlinenode = class(tprocinlinenode)
  50. procedure pass_2;override;
  51. end;
  52. implementation
  53. uses
  54. systems,
  55. cutils,verbose,globals,
  56. symconst,symbase,symsym,symtable,defutil,paramgr,
  57. {$ifdef GDB}
  58. {$ifdef delphi}
  59. sysutils,
  60. {$else}
  61. strings,
  62. {$endif}
  63. gdb,
  64. {$endif GDB}
  65. cginfo,cgbase,pass_2,
  66. cpuinfo,cpupi,aasmbase,aasmtai,aasmcpu,
  67. nmem,nld,ncnv,
  68. {$ifdef i386}
  69. cga,
  70. {$endif i386}
  71. cg64f32,ncgutil,cgobj,tgobj,regvars,rgobj,rgcpu,cgcpu;
  72. {*****************************************************************************
  73. TCGCALLPARANODE
  74. *****************************************************************************}
  75. procedure tcgcallparanode.secondcallparan(push_from_left_to_right:boolean;calloption:tproccalloption;para_alignment,para_offset : longint);
  76. {$ifndef VS_HIDDEN}
  77. { goes to pass 1 }
  78. procedure maybe_push_high;
  79. begin
  80. { open array ? }
  81. { defcoll.data can be nil for read/write }
  82. if assigned(paraitem.paratype.def) and
  83. assigned(hightree) then
  84. begin
  85. secondpass(hightree);
  86. { this is a longint anyway ! }
  87. push_value_para(hightree,calloption,para_offset,4,paraitem.paraloc);
  88. end;
  89. end;
  90. {$endif VS_HIDDEN}
  91. var
  92. otlabel,oflabel : tasmlabel;
  93. { temporary variables: }
  94. tempdeftype : tdeftype;
  95. tmpreg : tregister;
  96. href : treference;
  97. begin
  98. { push from left to right if specified }
  99. if push_from_left_to_right and assigned(right) then
  100. begin
  101. if (nf_varargs_para in flags) then
  102. tcallparanode(right).secondcallparan(push_from_left_to_right,
  103. calloption,para_alignment,para_offset)
  104. else
  105. tcallparanode(right).secondcallparan(push_from_left_to_right,
  106. calloption,para_alignment,para_offset);
  107. end;
  108. otlabel:=truelabel;
  109. oflabel:=falselabel;
  110. objectlibrary.getlabel(truelabel);
  111. objectlibrary.getlabel(falselabel);
  112. secondpass(left);
  113. { handle varargs first, because defcoll is not valid }
  114. if (nf_varargs_para in flags) then
  115. begin
  116. if paramanager.push_addr_param(left.resulttype.def,calloption) then
  117. begin
  118. inc(pushedparasize,4);
  119. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  120. location_release(exprasmlist,left.location);
  121. end
  122. else
  123. push_value_para(left,calloption,para_offset,para_alignment,paraitem.paraloc);
  124. end
  125. { filter array constructor with c styled args }
  126. else if is_array_constructor(left.resulttype.def) and (nf_cargs in left.flags) then
  127. begin
  128. { nothing, everything is already pushed }
  129. end
  130. { in codegen.handleread.. paraitem.data is set to nil }
  131. else if assigned(paraitem.paratype.def) and
  132. (paraitem.paratype.def.deftype=formaldef) then
  133. begin
  134. { allow passing of a constant to a const formaldef }
  135. if (paraitem.paratyp=vs_const) and
  136. (left.location.loc=LOC_CONSTANT) then
  137. location_force_mem(exprasmlist,left.location);
  138. { allow @var }
  139. inc(pushedparasize,4);
  140. if (left.nodetype=addrn) and
  141. (not(nf_procvarload in left.flags)) then
  142. begin
  143. if calloption=pocall_inline then
  144. begin
  145. reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
  146. cg.a_load_loc_ref(exprasmlist,left.location,href);
  147. end
  148. else
  149. cg.a_param_loc(exprasmlist,left.location,paraitem.paraloc);
  150. location_release(exprasmlist,left.location);
  151. end
  152. else
  153. begin
  154. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  155. begin
  156. CGMessage(type_e_mismatch)
  157. end
  158. else
  159. begin
  160. if calloption=pocall_inline then
  161. begin
  162. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  163. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  164. reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
  165. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  166. cg.free_scratch_reg(exprasmlist,tmpreg);
  167. end
  168. else
  169. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  170. location_release(exprasmlist,left.location);
  171. end;
  172. end;
  173. end
  174. { handle call by reference parameter }
  175. else if (paraitem.paratyp in [vs_var,vs_out]) then
  176. begin
  177. if (left.location.loc<>LOC_REFERENCE) then
  178. begin
  179. { passing self to a var parameter is allowed in
  180. TP and delphi }
  181. if not((left.location.loc=LOC_CREFERENCE) and
  182. (left.nodetype=selfn)) then
  183. internalerror(200106041);
  184. end;
  185. {$ifdef unused}
  186. if not push_from_left_to_right then
  187. {$endif unused}
  188. {$ifndef VS_HIDDEN}
  189. maybe_push_high;
  190. {$endif VS_HIDDEN}
  191. if (paraitem.paratyp=vs_out) and
  192. assigned(paraitem.paratype.def) and
  193. not is_class(paraitem.paratype.def) and
  194. paraitem.paratype.def.needs_inittable then
  195. cg.g_finalize(exprasmlist,paraitem.paratype.def,left.location.reference,false);
  196. inc(pushedparasize,4);
  197. if calloption=pocall_inline then
  198. begin
  199. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  200. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  201. reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
  202. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  203. cg.free_scratch_reg(exprasmlist,tmpreg);
  204. end
  205. else
  206. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  207. location_release(exprasmlist,left.location);
  208. {$ifdef unused}
  209. if push_from_left_to_right then
  210. maybe_push_high;
  211. {$endif unused}
  212. end
  213. else
  214. begin
  215. tempdeftype:=resulttype.def.deftype;
  216. if tempdeftype=filedef then
  217. CGMessage(cg_e_file_must_call_by_reference);
  218. { open array must always push the address, this is needed to
  219. also push addr of small open arrays and with cdecl functions (PFV) }
  220. if (
  221. assigned(paraitem.paratype.def) and
  222. (is_open_array(paraitem.paratype.def) or
  223. is_array_of_const(paraitem.paratype.def))
  224. ) or
  225. (
  226. paramanager.push_addr_param(resulttype.def,calloption)
  227. ) then
  228. begin
  229. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  230. begin
  231. { allow passing nil to a procvardef (methodpointer) }
  232. (* if (left.nodetype=typeconvn) and
  233. (left.resulttype.def.deftype=procvardef) and
  234. (ttypeconvnode(left).left.nodetype=niln) then
  235. *)
  236. if (left.location.size <> OS_NO) then
  237. begin
  238. tg.GetTemp(exprasmlist,tcgsize2size[left.location.size],tt_normal,href);
  239. if not (left.location.size in [OS_64,OS_S64]) then
  240. cg.a_load_loc_ref(exprasmlist,left.location,href)
  241. else
  242. cg64.a_load64_loc_ref(exprasmlist,left.location,href);
  243. location_reset(left.location,LOC_REFERENCE,left.location.size);
  244. left.location.reference:=href;
  245. end
  246. else
  247. internalerror(200204011);
  248. end;
  249. {$ifdef unused}
  250. if not push_from_left_to_right then
  251. {$endif unused}
  252. {$ifndef VS_HIDDEN}
  253. maybe_push_high;
  254. {$endif VS_HIDDEN}
  255. inc(pushedparasize,4);
  256. if calloption=pocall_inline then
  257. begin
  258. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  259. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
  260. reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
  261. cg.a_load_reg_ref(exprasmlist,OS_ADDR,tmpreg,href);
  262. cg.free_scratch_reg(exprasmlist,tmpreg);
  263. end
  264. else
  265. cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
  266. location_release(exprasmlist,left.location);
  267. {$ifdef unused}
  268. if push_from_left_to_right then
  269. maybe_push_high;
  270. {$endif unused}
  271. end
  272. else
  273. begin
  274. push_value_para(left,calloption,
  275. para_offset,para_alignment,paraitem.paraloc);
  276. end;
  277. end;
  278. truelabel:=otlabel;
  279. falselabel:=oflabel;
  280. { push from right to left }
  281. if not push_from_left_to_right and assigned(right) then
  282. begin
  283. if (nf_varargs_para in flags) then
  284. tcallparanode(right).secondcallparan(push_from_left_to_right,
  285. calloption,para_alignment,para_offset)
  286. else
  287. tcallparanode(right).secondcallparan(push_from_left_to_right,
  288. calloption,para_alignment,para_offset);
  289. end;
  290. end;
  291. {*****************************************************************************
  292. TCGCALLNODE
  293. *****************************************************************************}
  294. procedure tcgcallnode.extra_interrupt_code;
  295. var r:Tregister;
  296. begin
  297. {$ifdef i386}
  298. { if the i386 ever uses tcgcal, we've to move this into an overriden method }
  299. emit_none(A_PUSHF,S_L);
  300. r.enum:=R_CS;
  301. emit_reg(A_PUSH,S_L,r);
  302. {$endif i386}
  303. end;
  304. procedure tcgcallnode.load_framepointer;
  305. var href : treference;
  306. hregister : tregister;
  307. i: integer;
  308. begin
  309. { this routine is itself not nested }
  310. if lexlevel=(tprocdef(procdefinition).parast.symtablelevel) then
  311. begin
  312. reference_reset_base(href,procinfo.framepointer,procinfo.framepointer_offset);
  313. cg.a_param_ref(exprasmlist,OS_ADDR,href,paramanager.getintparaloc(1));
  314. end
  315. { one nesting level }
  316. else if (lexlevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  317. begin
  318. cg.a_param_reg(exprasmlist,OS_ADDR,procinfo.framepointer,paramanager.getintparaloc(1));
  319. end
  320. { very complex nesting level ... }
  321. else if (lexlevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  322. begin
  323. hregister:=rg.getaddressregister(exprasmlist);
  324. reference_reset_base(href,procinfo.framepointer,procinfo.framepointer_offset);
  325. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  326. for i:=(tprocdef(procdefinition).parast.symtablelevel) to lexlevel-1 do
  327. begin
  328. reference_reset_base(href,hregister,procinfo.framepointer_offset);
  329. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  330. end;
  331. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,paramanager.getintparaloc(1));
  332. rg.ungetaddressregister(exprasmlist,hregister);
  333. end;
  334. end;
  335. procedure tcgcallnode.handle_return_value(inlined,extended_new:boolean);
  336. var
  337. cgsize : tcgsize;
  338. r,hregister : tregister;
  339. begin
  340. { structured results are easy to handle.... }
  341. { needed also when result_no_used !! }
  342. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  343. begin
  344. location_reset(location,LOC_CREFERENCE,def_cgsize(resulttype.def));
  345. location.reference.symbol:=nil;
  346. location.reference:=funcretref;
  347. end
  348. else
  349. { ansi/widestrings must be registered, so we can dispose them }
  350. if is_ansistring(resulttype.def) or
  351. is_widestring(resulttype.def) then
  352. begin
  353. location_reset(location,LOC_CREFERENCE,OS_ADDR);
  354. location.reference:=refcountedtemp;
  355. r.enum:=accumulator;
  356. cg.a_reg_alloc(exprasmlist,r);
  357. cg.a_load_reg_ref(exprasmlist,OS_ADDR,r,location.reference);
  358. cg.a_reg_dealloc(exprasmlist,r);
  359. end
  360. else
  361. { we have only to handle the result if it is used }
  362. if (nf_return_value_used in flags) then
  363. begin
  364. case resulttype.def.deftype of
  365. enumdef,
  366. orddef :
  367. begin
  368. cgsize:=def_cgsize(resulttype.def);
  369. { an object constructor is a function with boolean result }
  370. if (inlined or (right=nil)) and
  371. (procdefinition.proctypeoption=potype_constructor) then
  372. begin
  373. {$ifdef x86}
  374. if extended_new then
  375. cgsize:=OS_INT
  376. else
  377. begin
  378. cgsize:=OS_NO;
  379. { this fails if popsize > 0 PM }
  380. location_reset(location,LOC_FLAGS,OS_NO);
  381. location.resflags:=F_NE;
  382. end;
  383. {$else x86}
  384. cgsize:=OS_INT
  385. {$endif x86}
  386. end;
  387. if cgsize<>OS_NO then
  388. begin
  389. location_reset(location,LOC_REGISTER,cgsize);
  390. r.enum:=accumulator;
  391. hregister.enum:=accumulatorhigh;
  392. cg.a_reg_alloc(exprasmlist,r);
  393. {$ifndef cpu64bit}
  394. if cgsize in [OS_64,OS_S64] then
  395. begin
  396. cg.a_reg_alloc(exprasmlist,hregister);
  397. location.registerhigh:=rg.getexplicitregisterint(exprasmlist,hregister.enum);
  398. location.registerlow:=rg.getexplicitregisterint(exprasmlist,r.enum);
  399. cg64.a_load64_reg_reg(exprasmlist,joinreg64(r,hregister),
  400. location.register64);
  401. end
  402. else
  403. {$endif cpu64bit}
  404. begin
  405. location.register:=rg.getexplicitregisterint(exprasmlist,r.enum);
  406. hregister:=rg.makeregsize(r,cgsize);
  407. location.register:=rg.makeregsize(location.register,cgsize);
  408. cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,hregister,location.register);
  409. end;
  410. end;
  411. end;
  412. floatdef :
  413. begin
  414. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  415. {$ifdef cpufpemu}
  416. if cs_fp_emulation in aktmoduleswitches then
  417. location.register.enum := accumulator
  418. else
  419. {$endif cpufpemu}
  420. location.register.enum:=fpu_result_reg;
  421. {$ifdef x86}
  422. inc(trgcpu(rg).fpuvaroffset);
  423. {$endif x86}
  424. end;
  425. {$ifdef TEST_WIN32_RECORDS}
  426. recorddef :
  427. begin
  428. if (target_info.system=system_i386_win32) then
  429. begin
  430. location_reset(location,LOC_REFERENCE,def_cgsize(resulttype.def));
  431. tg.GetTemp(exprasmlist,resulttype.size,tt_normal,location);
  432. {$ifndef cpu64bit}
  433. if cgsize in [OS_64,OS_S64] then
  434. cg64.a_load64_reg_loc(exprasmlist,joinreg64(accumulator,accumulatorhigh),location)
  435. else
  436. {$endif cpu64bit}
  437. cg.a_load_reg_loc(exprasmlist,accumulator,location);
  438. end
  439. else
  440. internalerror(200211141);
  441. end;
  442. {$endif TEST_WIN32_RECORDS}
  443. else
  444. begin
  445. location_reset(location,LOC_REGISTER,OS_INT);
  446. location.register:=rg.getexplicitregisterint(exprasmlist,accumulator);
  447. r.enum:=accumulator;
  448. cg.a_load_reg_reg(exprasmlist,OS_INT,OS_INT,r,location.register);
  449. end;
  450. end;
  451. end;
  452. end;
  453. procedure tcgcallnode.pass_2;
  454. var
  455. regs_to_push : tregisterset;
  456. unusedstate: pointer;
  457. pushed : tpushedsaved;
  458. tmpreg : tregister;
  459. hregister : tregister;
  460. hregister64 : tregister64;
  461. oldpushedparasize : longint;
  462. { true if ESI must be loaded again after the subroutine }
  463. loadesi : boolean;
  464. { true if a virtual method must be called directly }
  465. no_virtual_call : boolean;
  466. { true if we produce a con- or destrutor in a call }
  467. is_con_or_destructor : boolean;
  468. { true if a constructor is called again }
  469. extended_new : boolean;
  470. { adress returned from an I/O-error }
  471. iolabel : tasmlabel;
  472. { lexlevel count }
  473. i : longint;
  474. { help reference pointer }
  475. href : treference;
  476. hrefvmt : treference;
  477. hp : tnode;
  478. pp : tbinarynode;
  479. params : tnode;
  480. inlined : boolean;
  481. inlinecode : tprocinlinenode;
  482. store_parast_fixup,
  483. para_alignment,
  484. para_offset : longint;
  485. cgsize : tcgsize;
  486. { instruction for alignement correction }
  487. { corr : paicpu;}
  488. { we must pop this size also after !! }
  489. { must_pop : boolean; }
  490. pop_size : longint;
  491. {$ifdef OPTALIGN}
  492. pop_esp : boolean;
  493. push_size : longint;
  494. {$endif OPTALIGN}
  495. pop_allowed : boolean;
  496. release_tmpreg : boolean;
  497. constructorfailed : tasmlabel;
  498. resultloc : tparalocation;
  499. returnref,
  500. pararef : treference;
  501. r,r2:Tregister;
  502. label
  503. dont_call;
  504. begin
  505. extended_new:=false;
  506. iolabel:=nil;
  507. inlinecode:=nil;
  508. inlined:=false;
  509. loadesi:=true;
  510. no_virtual_call:=false;
  511. rg.saveunusedstate(unusedstate);
  512. { if we allocate the temp. location for ansi- or widestrings }
  513. { already here, we avoid later a push/pop }
  514. if is_widestring(resulttype.def) then
  515. begin
  516. tg.GetTemp(exprasmlist,pointer_size,tt_widestring,refcountedtemp);
  517. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp);
  518. end
  519. else if is_ansistring(resulttype.def) then
  520. begin
  521. tg.GetTemp(exprasmlist,pointer_size,tt_ansistring,refcountedtemp);
  522. cg.g_decrrefcount(exprasmlist,resulttype.def,refcountedtemp);
  523. end;
  524. if (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_stdcall]) then
  525. para_alignment:=4
  526. else
  527. para_alignment:=aktalignment.paraalign;
  528. if not assigned(procdefinition) then
  529. exit;
  530. { Deciding whether we may still need the parameters happens next (JM) }
  531. if assigned(left) then
  532. params:=left.getcopy
  533. else
  534. params := nil;
  535. if (procdefinition.proccalloption=pocall_inline) then
  536. begin
  537. inlined:=true;
  538. inlinecode:=tprocinlinenode(right);
  539. right:=nil;
  540. { set it to the same lexical level as the local symtable, becuase
  541. the para's are stored there }
  542. tprocdef(procdefinition).parast.symtablelevel:=aktprocdef.localst.symtablelevel;
  543. if assigned(params) then
  544. begin
  545. inlinecode.para_size:=tprocdef(procdefinition).para_size(para_alignment);
  546. tg.GetTemp(exprasmlist,inlinecode.para_size,tt_persistant,pararef);
  547. inlinecode.para_offset:=pararef.offset;
  548. end;
  549. store_parast_fixup:=tprocdef(procdefinition).parast.address_fixup;
  550. tprocdef(procdefinition).parast.address_fixup:=inlinecode.para_offset;
  551. {$ifdef extdebug}
  552. Comment(V_debug,
  553. 'inlined parasymtable is at offset '
  554. +tostr(tprocdef(procdefinition).parast.address_fixup));
  555. exprasmList.concat(tai_comment.Create(
  556. strpnew('inlined parasymtable is at offset '
  557. +tostr(tprocdef(procdefinition).parast.address_fixup))));
  558. {$endif extdebug}
  559. end;
  560. { only if no proc var }
  561. if inlined or
  562. not(assigned(right)) then
  563. is_con_or_destructor:=(procdefinition.proctypeoption in [potype_constructor,potype_destructor]);
  564. { proc variables destroy all registers }
  565. if (inlined or
  566. (right=nil)) and
  567. { virtual methods too }
  568. not(po_virtualmethod in procdefinition.procoptions) then
  569. begin
  570. if (cs_check_io in aktlocalswitches) and
  571. (po_iocheck in procdefinition.procoptions) and
  572. not(po_iocheck in aktprocdef.procoptions) then
  573. begin
  574. objectlibrary.getaddrlabel(iolabel);
  575. cg.a_label(exprasmlist,iolabel);
  576. end
  577. else
  578. iolabel:=nil;
  579. { save all used registers and possible registers
  580. used for the return value }
  581. regs_to_push := tprocdef(procdefinition).usedregisters;
  582. if (not is_void(resulttype.def)) and
  583. (not paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption)) then
  584. begin
  585. include(regs_to_push,accumulator);
  586. {$ifndef cpu64bit}
  587. if resulttype.def.size>sizeof(aword) then
  588. include(regs_to_push,accumulatorhigh);
  589. {$endif cpu64bit}
  590. end;
  591. rg.saveusedregisters(exprasmlist,pushed,regs_to_push);
  592. { give used registers through }
  593. rg.usedinproc:=rg.usedinproc + tprocdef(procdefinition).usedregisters;
  594. end
  595. else
  596. begin
  597. regs_to_push := all_registers;
  598. rg.saveusedregisters(exprasmlist,pushed,regs_to_push);
  599. rg.usedinproc:=all_registers;
  600. { no IO check for methods and procedure variables }
  601. iolabel:=nil;
  602. end;
  603. { generate the code for the parameter and push them }
  604. oldpushedparasize:=pushedparasize;
  605. pushedparasize:=0;
  606. pop_size:=0;
  607. {$ifdef dummy}
  608. { no inc esp for inlined procedure
  609. and for objects constructors PM }
  610. if inlined or
  611. ((procdefinition.proctypeoption=potype_constructor) and
  612. { quick'n'dirty check if it is a class or an object }
  613. (resulttype.def.deftype=orddef)) then
  614. pop_allowed:=false
  615. else
  616. pop_allowed:=true;
  617. if pop_allowed then
  618. begin
  619. { Old pushedsize aligned on 4 ? }
  620. i:=oldpushedparasize and 3;
  621. if i>0 then
  622. inc(pop_size,4-i);
  623. { This parasize aligned on 4 ? }
  624. i:=procdefinition.para_size(para_alignment) and 3;
  625. if i>0 then
  626. inc(pop_size,4-i);
  627. { insert the opcode and update pushedparasize }
  628. { never push 4 or more !! }
  629. pop_size:=pop_size mod 4;
  630. if pop_size>0 then
  631. begin
  632. inc(pushedparasize,pop_size);
  633. cg.a_const_reg(A_SUB,S_L,pop_size,R_ESP);
  634. {$ifdef GDB}
  635. if (cs_debuginfo in aktmoduleswitches) and
  636. (exprasmList.first=exprasmList.last) then
  637. exprasmList.concat(Tai_force_line.Create);
  638. {$endif GDB}
  639. end;
  640. end;
  641. {$endif dummy}
  642. {$ifdef OPTALIGN}
  643. if pop_allowed and (cs_align in aktglobalswitches) then
  644. begin
  645. pop_esp:=true;
  646. push_size:=procdefinition.para_size(para_alignment);
  647. { !!!! here we have to take care of return type, self
  648. and nested procedures
  649. }
  650. inc(push_size,12);
  651. r.enum:=R_ESP:
  652. r2.enum:=R_EDI;
  653. emit_reg_reg(A_MOV,S_L,r,r2);
  654. if (push_size mod 8)=0 then
  655. emit_const_reg(A_AND,S_L,$fffffff8,r)
  656. else
  657. begin
  658. emit_const_reg(A_SUB,S_L,push_size,r);
  659. emit_const_reg(A_AND,S_L,$fffffff8,r);
  660. emit_const_reg(A_SUB,S_L,push_size,r);
  661. end;
  662. emit_reg(A_PUSH,S_L,r2);
  663. end
  664. else
  665. pop_esp:=false;
  666. {$endif OPTALIGN}
  667. { Push parameters }
  668. if assigned(params) then
  669. begin
  670. { be found elsewhere }
  671. if inlined then
  672. para_offset:=tprocdef(procdefinition).parast.address_fixup+
  673. tprocdef(procdefinition).parast.datasize
  674. else
  675. para_offset:=0;
  676. if not(inlined) and
  677. assigned(right) then
  678. tcallparanode(params).secondcallparan(
  679. { TParaItem(tabstractprocdef(right.resulttype.def).Para.first), }
  680. (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
  681. para_alignment,para_offset)
  682. else
  683. tcallparanode(params).secondcallparan(
  684. { TParaItem(procdefinition.Para.first), }
  685. (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
  686. para_alignment,para_offset);
  687. end;
  688. { Allocate return value for inlined routines }
  689. if inlined and
  690. (resulttype.def.size>0) then
  691. begin
  692. tg.GetTemp(exprasmlist,Align(resulttype.def.size,aktalignment.paraalign),tt_persistant,returnref);
  693. inlinecode.retoffset:=returnref.offset;
  694. end;
  695. { Allocate return value when returned in argument }
  696. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  697. begin
  698. if assigned(funcretrefnode) then
  699. begin
  700. secondpass(funcretrefnode);
  701. if codegenerror then
  702. exit;
  703. if (funcretrefnode.location.loc<>LOC_REFERENCE) then
  704. internalerror(200204246);
  705. funcretref:=funcretrefnode.location.reference;
  706. end
  707. else
  708. begin
  709. if inlined then
  710. begin
  711. tg.GetTemp(exprasmlist,resulttype.def.size,tt_persistant,funcretref);
  712. {$ifdef extdebug}
  713. Comment(V_debug,'function return value is at offset '
  714. +tostr(funcretref.offset));
  715. exprasmlist.concat(tai_comment.create(
  716. strpnew('function return value is at offset '
  717. +tostr(funcretref.offset))));
  718. {$endif extdebug}
  719. end
  720. else
  721. tg.GetTemp(exprasmlist,resulttype.def.size,tt_normal,funcretref);
  722. end;
  723. { This must not be counted for C code
  724. complex return address is removed from stack
  725. by function itself ! }
  726. {$ifdef OLD_C_STACK}
  727. inc(pushedparasize,4); { lets try without it PM }
  728. {$endif not OLD_C_STACK}
  729. if inlined then
  730. begin
  731. hregister:=cg.get_scratch_reg_address(exprasmlist);
  732. cg.a_loadaddr_ref_reg(exprasmlist,funcretref,hregister);
  733. reference_reset_base(href,procinfo.framepointer,inlinecode.retoffset);
  734. cg.a_load_reg_ref(exprasmlist,OS_ADDR,hregister,href);
  735. cg.free_scratch_reg(exprasmlist,hregister);
  736. end
  737. else
  738. cg.a_paramaddr_ref(exprasmlist,funcretref,
  739. paramanager.getfuncretparaloc(procdefinition));
  740. end;
  741. { procedure variable or normal function call ? }
  742. if inlined or
  743. (right=nil) then
  744. begin
  745. { Normal function call }
  746. {$ifdef dummy}
  747. { overloaded operator has no symtable }
  748. { push self }
  749. if assigned(symtableproc) and
  750. (symtableproc.symtabletype=withsymtable) then
  751. begin
  752. { dirty trick to avoid the secondcall below }
  753. methodpointer:=ccallparanode.create(nil,nil);
  754. location_reset(methodpointer.location,LOC_REGISTER,OS_ADDR);
  755. rg.getexplicitregisterint(exprasmlist,R_ESI);
  756. methodpointer.location.register:=R_ESI;
  757. { ARGHHH this is wrong !!!
  758. if we can init from base class for a child
  759. class that the wrong VMT will be
  760. transfered to constructor !! }
  761. methodpointer.resulttype:=
  762. twithnode(twithsymtable(symtableproc).withnode).left.resulttype;
  763. { make a reference }
  764. href:=twithnode(twithsymtable(symtableproc).withnode).withreference;
  765. if ((not(nf_islocal in twithnode(twithsymtable(symtableproc).withnode).flags)) and
  766. (not twithsymtable(symtableproc).direct_with)) or
  767. is_class_or_interface(methodpointer.resulttype.def) then
  768. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,self_pointer_reg)
  769. else
  770. cg.a_loadaddr_ref_reg(exprasmlist,href,self_pointer_reg);
  771. end;
  772. { push self }
  773. if assigned(symtableproc) and
  774. ((symtableproc.symtabletype=objectsymtable) or
  775. (symtableproc.symtabletype=withsymtable)) then
  776. begin
  777. if assigned(methodpointer) then
  778. begin
  779. {
  780. if methodpointer^.resulttype.def=classrefdef then
  781. begin
  782. two possibilities:
  783. 1. constructor
  784. 2. class method
  785. end
  786. else }
  787. begin
  788. case methodpointer.nodetype of
  789. typen:
  790. begin
  791. { direct call to inherited method }
  792. if (po_abstractmethod in procdefinition.procoptions) then
  793. begin
  794. CGMessage(cg_e_cant_call_abstract_method);
  795. goto dont_call;
  796. end;
  797. { generate no virtual call }
  798. no_virtual_call:=true;
  799. if (sp_static in symtableprocentry.symoptions) then
  800. begin
  801. { well lets put the VMT address directly into ESI }
  802. { it is kind of dirty but that is the simplest }
  803. { way to accept virtual static functions (PM) }
  804. loadesi:=true;
  805. { if no VMT just use $0 bug0214 PM }
  806. rg.getexplicitregisterint(exprasmlist,R_ESI);
  807. if not(oo_has_vmt in tobjectdef(methodpointer.resulttype.def).objectoptions) then
  808. cg.a_load_const_reg(exprasmlist,OS_ADDR,0,self_pointer_reg)
  809. else
  810. begin
  811. reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
  812. cg.a_loadaddr_ref_reg(exprasmlist,href,self_pointer_reg);
  813. end;
  814. { emit_reg(A_PUSH,S_L,R_ESI);
  815. this is done below !! }
  816. end
  817. else
  818. { this is a member call, so ESI isn't modfied }
  819. loadesi:=false;
  820. { a class destructor needs a flag }
  821. if is_class(tobjectdef(methodpointer.resulttype.def)) and
  822. (procdefinition.proctypeoption=potype_destructor) then
  823. begin
  824. cg.a_param_const(exprasmlist,OS_ADDR,0,2);
  825. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,1);
  826. end;
  827. if not(is_con_or_destructor and
  828. is_class(methodpointer.resulttype.def) and
  829. (procdefinition.proctypeoption in [potype_constructor,potype_destructor])
  830. ) then
  831. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,1);
  832. { if an inherited con- or destructor should be }
  833. { called in a con- or destructor then a warning }
  834. { will be made }
  835. { con- and destructors need a pointer to the vmt }
  836. if is_con_or_destructor and
  837. is_object(methodpointer.resulttype.def) and
  838. assigned(aktprocdef) then
  839. begin
  840. if not(aktprocdef.proctypeoption in
  841. [potype_constructor,potype_destructor]) then
  842. CGMessage(cg_w_member_cd_call_from_method);
  843. end;
  844. { class destructors get there flag above }
  845. { constructor flags ? }
  846. if is_con_or_destructor and
  847. not(
  848. is_class(methodpointer.resulttype.def) and
  849. assigned(aktprocdef) and
  850. (aktprocdef.proctypeoption=potype_destructor)) then
  851. begin
  852. { a constructor needs also a flag }
  853. if is_class(methodpointer.resulttype.def) then
  854. cg.a_param_const(exprasmlist,OS_ADDR,0,2);
  855. cg.a_param_const(exprasmlist,OS_ADDR,0,1);
  856. end;
  857. end;
  858. hnewn:
  859. begin
  860. { extended syntax of new }
  861. { ESI must be zero }
  862. rg.getexplicitregisterint(exprasmlist,R_ESI);
  863. cg.a_load_const_reg(exprasmlist,OS_ADDR,0,self_pointer_reg);
  864. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,2);
  865. { insert the vmt }
  866. reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
  867. cg.a_paramaddr_ref(exprasmlist,href,1);
  868. extended_new:=true;
  869. end;
  870. hdisposen:
  871. begin
  872. secondpass(methodpointer);
  873. { destructor with extended syntax called from dispose }
  874. { hdisposen always deliver LOC_REFERENCE }
  875. rg.getexplicitregisterint(exprasmlist,R_ESI);
  876. emit_ref_reg(A_LEA,S_L,methodpointer.location.reference,R_ESI);
  877. reference_release(exprasmlist,methodpointer.location.reference);
  878. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,2);
  879. reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
  880. cg.a_paramaddr_ref(exprasmlist,href,1);
  881. end;
  882. else
  883. begin
  884. { call to an instance member }
  885. if (symtableproc.symtabletype<>withsymtable) then
  886. begin
  887. secondpass(methodpointer);
  888. rg.getexplicitregisterint(exprasmlist,R_ESI);
  889. case methodpointer.location.loc of
  890. LOC_CREGISTER,
  891. LOC_REGISTER:
  892. begin
  893. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,methodpointer.location.register,R_ESI);
  894. rg.ungetregisterint(exprasmlist,methodpointer.location.register);
  895. end;
  896. else
  897. begin
  898. if (methodpointer.resulttype.def.deftype=classrefdef) or
  899. is_class_or_interface(methodpointer.resulttype.def) then
  900. cg.a_load_ref_reg(exprasmlist,OS_ADDR,methodpointer.location.reference,R_ESI)
  901. else
  902. cg.a_loadaddr_ref_reg(exprasmlist,methodpointer.location.reference,R_ESI);
  903. reference_release(exprasmlist,methodpointer.location.reference);
  904. end;
  905. end;
  906. end;
  907. { when calling a class method, we have to load ESI with the VMT !
  908. But, not for a class method via self }
  909. if not(po_containsself in procdefinition.procoptions) then
  910. begin
  911. if (po_staticmethod in procdefinition.procoptions) or
  912. ((po_classmethod in procdefinition.procoptions) and
  913. not(methodpointer.resulttype.def.deftype=classrefdef)) then
  914. begin
  915. r.enum:=self_pointer_reg;
  916. rg.getexplicitregisterint(exprasmlist,r.enum);
  917. if not(oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  918. cg.a_load_const_reg(exprasmlist,OS_ADDR,0,r)
  919. else
  920. begin
  921. { class method and static methods needs current VMT }
  922. cg.g_maybe_testself(exprasmlist,r);
  923. reference_reset_base(href,r,tprocdef(procdefinition)._class.vmt_offset);
  924. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r);
  925. cg.g_maybe_testvmt(exprasmlist,r,tprocdef(procdefinition)._class);
  926. end;
  927. end;
  928. { direct call to destructor: remove data }
  929. if (procdefinition.proctypeoption=potype_destructor) and
  930. is_class(methodpointer.resulttype.def) then
  931. cg.a_param_const(exprasmlist,OS_INT,1,1);
  932. { direct call to class constructor, don't allocate memory }
  933. if (procdefinition.proctypeoption=potype_constructor) and
  934. is_class(methodpointer.resulttype.def) then
  935. begin
  936. cg.a_param_const(exprasmlist,OS_INT,0,2);
  937. cg.a_param_const(exprasmlist,OS_INT,0,1);
  938. end
  939. else
  940. begin
  941. { constructor call via classreference => allocate memory }
  942. if (procdefinition.proctypeoption=potype_constructor) and
  943. (methodpointer.resulttype.def.deftype=classrefdef) and
  944. is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
  945. cg.a_param_const(exprasmlist,OS_INT,1,1);
  946. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,1);
  947. end;
  948. end;
  949. if is_con_or_destructor then
  950. begin
  951. { classes don't get a VMT pointer pushed }
  952. if is_object(methodpointer.resulttype.def) then
  953. begin
  954. if (procdefinition.proctypeoption=potype_constructor) then
  955. begin
  956. { it's no bad idea, to insert the VMT }
  957. reference_reset_symbol(href,objectlibrary.newasmsymbol(
  958. tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
  959. cg.a_paramaddr_ref(exprasmlist,href,1);
  960. end
  961. { destructors haven't to dispose the instance, if this is }
  962. { a direct call }
  963. else
  964. cg.a_param_const(exprasmlist,OS_INT,0,1);
  965. end;
  966. end;
  967. end;
  968. end;
  969. end;
  970. end
  971. else
  972. begin
  973. if (
  974. (po_classmethod in procdefinition.procoptions) and
  975. not(assigned(aktprocdef) and
  976. (po_classmethod in aktprocdef.procoptions))
  977. ) or
  978. (
  979. (po_staticmethod in procdefinition.procoptions) and
  980. not(assigned(aktprocdef) and
  981. (po_staticmethod in aktprocdef.procoptions))
  982. ) then
  983. begin
  984. r.enum:=self_pointer_reg;
  985. rg.getexplicitregisterint(exprasmlist,r.enum);
  986. if not(oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  987. cg.a_load_const_reg(exprasmlist,OS_ADDR,0,r)
  988. else
  989. begin
  990. { class method and static methods needs current VMT }
  991. cg.g_maybe_testself(exprasmlist,r);
  992. reference_reset_base(href,r,tprocdef(procdefinition)._class.vmt_offset);
  993. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r);
  994. cg.g_maybe_testvmt(exprasmlist,r,tprocdef(procdefinition)._class);
  995. end;
  996. end
  997. else
  998. begin
  999. { member call, ESI isn't modified }
  1000. loadesi:=false;
  1001. end;
  1002. { direct call to destructor: don't remove data! }
  1003. if is_class(procinfo._class) then
  1004. begin
  1005. if (procdefinition.proctypeoption=potype_destructor) then
  1006. begin
  1007. cg.a_param_const(exprasmlist,OS_INT,0,2);
  1008. cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,1);
  1009. end
  1010. else if (procdefinition.proctypeoption=potype_constructor) then
  1011. begin
  1012. cg.a_param_const(exprasmlist,OS_INT,0,2);
  1013. cg.a_param_const(exprasmlist,OS_INT,0,1);
  1014. end
  1015. else
  1016. cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,1);
  1017. end
  1018. else if is_object(procinfo._class) then
  1019. begin
  1020. cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,1);
  1021. if is_con_or_destructor then
  1022. begin
  1023. if (procdefinition.proctypeoption=potype_constructor) then
  1024. begin
  1025. { it's no bad idea, to insert the VMT }
  1026. reference_reset_symbol(href,objectlibrary.newasmsymbol(procinfo._class.vmt_mangledname),0);
  1027. cg.a_paramaddr_ref(exprasmlist,href,1);
  1028. end
  1029. { destructors haven't to dispose the instance, if this is }
  1030. { a direct call }
  1031. else
  1032. cg.a_param_const(exprasmlist,OS_INT,0,1);
  1033. end;
  1034. end
  1035. else
  1036. Internalerror(200006165);
  1037. end;
  1038. end;
  1039. {$endif dummy}
  1040. { call to BeforeDestruction? }
  1041. if (procdefinition.proctypeoption=potype_destructor) and
  1042. assigned(methodpointer) and
  1043. (methodpointer.nodetype<>typen) and
  1044. is_class(tobjectdef(methodpointer.resulttype.def)) and
  1045. (inlined or
  1046. (right=nil)) then
  1047. begin
  1048. r.enum:=self_pointer_reg;
  1049. cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
  1050. reference_reset_base(href,r,0);
  1051. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  1052. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
  1053. reference_reset_base(href,tmpreg,72);
  1054. cg.a_call_ref(exprasmlist,href);
  1055. cg.free_scratch_reg(exprasmlist,tmpreg);
  1056. end;
  1057. {$ifndef SPARC}{We don't need that on SPARC arch!}
  1058. { push base pointer ?}
  1059. { never when inlining, since if necessary, the base pointer }
  1060. { can/will be gottten from the current procedure's symtable }
  1061. { (JM)}
  1062. if not inlined then
  1063. if (lexlevel>=normal_function_level) and assigned(tprocdef(procdefinition).parast) and
  1064. ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
  1065. load_framepointer;
  1066. {$endif SPARC}
  1067. rg.saveregvars(exprasmlist,regs_to_push);
  1068. {$ifdef dummy}
  1069. if (po_virtualmethod in procdefinition.procoptions) and
  1070. not(no_virtual_call) then
  1071. begin
  1072. { static functions contain the vmt_address in ESI }
  1073. { also class methods }
  1074. { Here it is quite tricky because it also depends }
  1075. { on the methodpointer PM }
  1076. release_tmpreg:=false;
  1077. rg.getexplicitregisterint(exprasmlist,R_ESI);
  1078. if assigned(aktprocdef) then
  1079. begin
  1080. if (((sp_static in aktprocdef.procsym.symoptions) or
  1081. (po_classmethod in aktprocdef.procoptions)) and
  1082. ((methodpointer=nil) or (methodpointer.nodetype=typen)))
  1083. or
  1084. (po_staticmethod in procdefinition.procoptions) or
  1085. ((procdefinition.proctypeoption=potype_constructor) and
  1086. { esi contains the vmt if we call a constructor via a class ref }
  1087. assigned(methodpointer) and
  1088. (methodpointer.resulttype.def.deftype=classrefdef)
  1089. ) or
  1090. { is_interface(tprocdef(procdefinition)._class) or }
  1091. { ESI is loaded earlier }
  1092. (po_classmethod in procdefinition.procoptions) then
  1093. begin
  1094. reference_reset_base(href,R_ESI,0);
  1095. end
  1096. else
  1097. begin
  1098. { this is one point where we need vmt_offset (PM) }
  1099. reference_reset_base(href,R_ESI,tprocdef(procdefinition)._class.vmt_offset);
  1100. cg.a_maybe_testself(exprasmlist);
  1101. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  1102. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
  1103. reference_reset_base(href,tmpreg,0);
  1104. release_tmpreg:=true;
  1105. end;
  1106. end
  1107. else
  1108. { aktprocdef should be assigned, also in main program }
  1109. internalerror(12345);
  1110. if tprocdef(procdefinition).extnumber=-1 then
  1111. internalerror(44584);
  1112. href.offset:=tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber);
  1113. if not(is_interface(tprocdef(procdefinition)._class)) and
  1114. not(is_cppclass(tprocdef(procdefinition)._class)) then
  1115. cg.g_maybe_testvmt(exprasmlist,href.base,tprocdef(procdefinition)._class);
  1116. cg.a_call_ref(exprasmlist,href);
  1117. if release_tmpreg then
  1118. cg.free_scratch_reg(exprasmlist,tmpreg);
  1119. end
  1120. else
  1121. {$endif dummy}
  1122. if not inlined then
  1123. begin
  1124. { We can call interrupts from within the smae code
  1125. by just pushing the flags and CS PM }
  1126. if (po_interrupt in procdefinition.procoptions) then
  1127. extra_interrupt_code;
  1128. cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname);
  1129. end
  1130. else { inlined proc }
  1131. { inlined code is in inlinecode }
  1132. begin
  1133. { process the inlinecode }
  1134. secondpass(tnode(inlinecode));
  1135. { free the args }
  1136. if tprocdef(procdefinition).parast.datasize>0 then
  1137. tg.UnGetTemp(exprasmlist,pararef);
  1138. end;
  1139. end
  1140. else
  1141. { now procedure variable case }
  1142. begin
  1143. secondpass(right);
  1144. if (po_interrupt in procdefinition.procoptions) then
  1145. extra_interrupt_code;
  1146. { procedure of object? }
  1147. if (po_methodpointer in procdefinition.procoptions) then
  1148. begin
  1149. {$ifdef dummy}
  1150. { method pointer can't be in a register }
  1151. hregister:=R_NO;
  1152. { do some hacking if we call a method pointer }
  1153. { which is a class member }
  1154. { else ESI is overwritten ! }
  1155. if (right.location.reference.base=R_ESI) or
  1156. (right.location.reference.index=R_ESI) then
  1157. begin
  1158. reference_release(exprasmlist,right.location.reference);
  1159. hregister:=cg.get_scratch_reg_address(exprasmlist);
  1160. cg.a_load_ref_reg(exprasmlist,OS_ADDR,right.location.reference,hregister);
  1161. end;
  1162. { load self, but not if it's already explicitly pushed }
  1163. if not(po_containsself in procdefinition.procoptions) then
  1164. begin
  1165. { load ESI }
  1166. href:=right.location.reference;
  1167. inc(href.offset,4);
  1168. rg.getexplicitregisterint(exprasmlist,R_ESI);
  1169. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,self_pointer_reg);
  1170. { push self pointer }
  1171. cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,-1);
  1172. end;
  1173. rg.saveregvars(exprasmlist,ALL_REGISTERS);
  1174. if hregister<>R_NO then
  1175. cg.a_call_reg(exprasmlist,hregister)
  1176. else
  1177. cg.a_call_ref(exprasmlist,right.location.reference);
  1178. if hregister<>R_NO then
  1179. cg.free_scratch_reg(exprasmlist,hregister);
  1180. reference_release(exprasmlist,right.location.reference);
  1181. tg.Ungetiftemp(exprasmlist,right.location.reference);
  1182. {$endif dummy}
  1183. end
  1184. else
  1185. begin
  1186. rg.saveregvars(exprasmlist,ALL_REGISTERS);
  1187. cg.a_call_loc(exprasmlist,right.location);
  1188. location_release(exprasmlist,right.location);
  1189. location_freetemp(exprasmlist,right.location);
  1190. end;
  1191. end;
  1192. {$ifdef dummy}
  1193. { this was only for normal functions
  1194. displaced here so we also get
  1195. it to work for procvars PM }
  1196. if (not inlined) and (po_clearstack in procdefinition.procoptions) then
  1197. begin
  1198. { we also add the pop_size which is included in pushedparasize }
  1199. pop_size:=0;
  1200. { better than an add on all processors }
  1201. if pushedparasize=4 then
  1202. begin
  1203. rg.getexplicitregisterint(exprasmlist,R_EDI);
  1204. emit_reg(A_POP,S_L,R_EDI);
  1205. rg.ungetregisterint(exprasmlist,R_EDI);
  1206. end
  1207. { the pentium has two pipes and pop reg is pairable }
  1208. { but the registers must be different! }
  1209. else if (pushedparasize=8) and
  1210. not(cs_littlesize in aktglobalswitches) and
  1211. {$ifdef i386}
  1212. (aktoptprocessor=ClassP5) and
  1213. {$endif}
  1214. (procinfo._class=nil) then
  1215. begin
  1216. rg.getexplicitregisterint(exprasmlist,R_EDI);
  1217. emit_reg(A_POP,S_L,R_EDI);
  1218. rg.ungetregisterint(exprasmlist,R_EDI);
  1219. exprasmList.concat(tai_regalloc.Alloc(R_ESI));
  1220. emit_reg(A_POP,S_L,R_ESI);
  1221. exprasmList.concat(tai_regalloc.DeAlloc(R_ESI));
  1222. end
  1223. else if pushedparasize<>0 then
  1224. emit_const_reg(A_ADD,S_L,pushedparasize,R_ESP);
  1225. end;
  1226. {$endif dummy}
  1227. {$ifdef powerpc}
  1228. { this calculation must be done in pass_1 anyway, so don't worry }
  1229. if tppcprocinfo(procinfo).maxpushedparasize<pushedparasize then
  1230. tppcprocinfo(procinfo).maxpushedparasize:=pushedparasize;
  1231. {$endif powerpc}
  1232. {$ifdef OPTALIGN}
  1233. r.enum:=R_ESP;
  1234. if pop_esp then
  1235. emit_reg(A_POP,S_L,r);
  1236. {$endif OPTALIGN}
  1237. dont_call:
  1238. pushedparasize:=oldpushedparasize;
  1239. rg.restoreunusedstate(unusedstate);
  1240. {$ifdef TEMPREGDEBUG}
  1241. testregisters32;
  1242. {$endif TEMPREGDEBUG}
  1243. { a constructor could be a function with boolean result }
  1244. { if calling constructor called fail we
  1245. must jump directly to quickexitlabel PM
  1246. but only if it is a call of an inherited constructor }
  1247. if (inlined or
  1248. (right=nil)) and
  1249. (procdefinition.proctypeoption=potype_constructor) and
  1250. assigned(methodpointer) and
  1251. (methodpointer.nodetype=typen) and
  1252. (aktprocdef.proctypeoption=potype_constructor) then
  1253. begin
  1254. r.enum:=accumulator;
  1255. cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,r,faillabel);
  1256. end;
  1257. { call to AfterConstruction? }
  1258. if is_class(resulttype.def) and
  1259. (inlined or
  1260. (right=nil)) and
  1261. (procdefinition.proctypeoption=potype_constructor) and
  1262. assigned(methodpointer) and
  1263. (methodpointer.nodetype<>typen) then
  1264. begin
  1265. objectlibrary.getlabel(constructorfailed);
  1266. r.enum:=self_pointer_reg;
  1267. r2.enum:=accumulator;
  1268. cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,r,constructorfailed);
  1269. cg.a_param_reg(exprasmlist,OS_ADDR,r2,paramanager.getintparaloc(1));
  1270. reference_reset_base(href,r,0);
  1271. tmpreg:=cg.get_scratch_reg_address(exprasmlist);
  1272. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
  1273. reference_reset_base(href,tmpreg,17*pointer_size);
  1274. cg.a_call_ref(exprasmlist,href);
  1275. cg.free_scratch_reg(exprasmlist,tmpreg);
  1276. exprasmList.concat(tai_regalloc.Alloc(r2));
  1277. cg.a_label(exprasmlist,constructorfailed);
  1278. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,r,r2);
  1279. end;
  1280. { handle function results }
  1281. if (not is_void(resulttype.def)) then
  1282. handle_return_value(inlined,extended_new);
  1283. { perhaps i/o check ? }
  1284. if iolabel<>nil then
  1285. begin
  1286. reference_reset_symbol(href,iolabel,0);
  1287. cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(1));
  1288. cg.a_call_name(exprasmlist,'FPC_IOCHECK');
  1289. end;
  1290. {$ifdef i386}
  1291. r.enum:=R_ESP;
  1292. if pop_size>0 then
  1293. emit_const_reg(A_ADD,S_L,pop_size,r);
  1294. {$endif i386}
  1295. { restore registers }
  1296. rg.restoreusedregisters(exprasmlist,pushed);
  1297. { at last, restore instance pointer (SELF) }
  1298. if loadesi then
  1299. cg.g_maybe_loadself(exprasmlist);
  1300. pp:=tbinarynode(params);
  1301. while assigned(pp) do
  1302. begin
  1303. if assigned(pp.left) then
  1304. begin
  1305. location_freetemp(exprasmlist,pp.left.location);
  1306. { process also all nodes of an array of const }
  1307. if pp.left.nodetype=arrayconstructorn then
  1308. begin
  1309. if assigned(tarrayconstructornode(pp.left).left) then
  1310. begin
  1311. hp:=pp.left;
  1312. while assigned(hp) do
  1313. begin
  1314. location_freetemp(exprasmlist,tarrayconstructornode(hp).left.location);
  1315. hp:=tarrayconstructornode(hp).right;
  1316. end;
  1317. end;
  1318. end;
  1319. end;
  1320. pp:=tbinarynode(pp.right);
  1321. end;
  1322. if inlined then
  1323. begin
  1324. if (resulttype.def.size>0) then
  1325. tg.UnGetTemp(exprasmlist,returnref);
  1326. tprocdef(procdefinition).parast.address_fixup:=store_parast_fixup;
  1327. right:=inlinecode;
  1328. end;
  1329. if assigned(params) then
  1330. params.free;
  1331. { from now on the result can be freed normally }
  1332. if inlined and paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1333. tg.ChangeTempType(exprasmlist,funcretref,tt_normal);
  1334. { if return value is not used }
  1335. if (not(nf_return_value_used in flags)) and (not is_void(resulttype.def)) then
  1336. begin
  1337. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  1338. begin
  1339. { data which must be finalized ? }
  1340. if (resulttype.def.needs_inittable) then
  1341. cg.g_finalize(exprasmlist,resulttype.def,location.reference,false);
  1342. { release unused temp }
  1343. tg.ungetiftemp(exprasmlist,location.reference)
  1344. end
  1345. else if location.loc=LOC_FPUREGISTER then
  1346. begin
  1347. {$ifdef i386}
  1348. { release FPU stack }
  1349. r.enum:=R_ST;
  1350. emit_reg(A_FSTP,S_NO,r);
  1351. {
  1352. dec(trgcpu(rg).fpuvaroffset);
  1353. do NOT decrement as the increment before
  1354. is not called for unused results PM }
  1355. {$endif i386}
  1356. end;
  1357. end;
  1358. end;
  1359. {*****************************************************************************
  1360. TCGPROCINLINENODE
  1361. *****************************************************************************}
  1362. procedure tcgprocinlinenode.pass_2;
  1363. var st : tsymtable;
  1364. oldprocdef : tprocdef;
  1365. ps, i : longint;
  1366. tmpreg: tregister;
  1367. oldprocinfo : tprocinfo;
  1368. oldinlining_procedure,
  1369. nostackframe,make_global : boolean;
  1370. inlineentrycode,inlineexitcode : TAAsmoutput;
  1371. oldexitlabel,oldexit2label,oldquickexitlabel:tasmlabel;
  1372. oldregstate: pointer;
  1373. localsref : treference;
  1374. {$ifdef GDB}
  1375. startlabel,endlabel : tasmlabel;
  1376. pp : pchar;
  1377. mangled_length : longint;
  1378. {$endif GDB}
  1379. begin
  1380. { deallocate the registers used for the current procedure's regvars }
  1381. if assigned(aktprocdef.regvarinfo) then
  1382. begin
  1383. with pregvarinfo(aktprocdef.regvarinfo)^ do
  1384. for i := 1 to maxvarregs do
  1385. if assigned(regvars[i]) then
  1386. store_regvar(exprasmlist,regvars[i].reg);
  1387. rg.saveStateForInline(oldregstate);
  1388. { make sure the register allocator knows what the regvars in the }
  1389. { inlined code block are (JM) }
  1390. rg.resetusableregisters;
  1391. rg.clearregistercount;
  1392. rg.cleartempgen;
  1393. if assigned(inlineprocdef.regvarinfo) then
  1394. with pregvarinfo(inlineprocdef.regvarinfo)^ do
  1395. for i := 1 to maxvarregs do
  1396. if assigned(regvars[i]) then
  1397. begin
  1398. tmpreg:=rg.makeregsize(regvars[i].reg,OS_INT);
  1399. rg.makeregvar(tmpreg);
  1400. end;
  1401. end;
  1402. oldinlining_procedure:=inlining_procedure;
  1403. oldexitlabel:=aktexitlabel;
  1404. oldexit2label:=aktexit2label;
  1405. oldquickexitlabel:=quickexitlabel;
  1406. oldprocdef:=aktprocdef;
  1407. oldprocinfo:=procinfo;
  1408. objectlibrary.getlabel(aktexitlabel);
  1409. objectlibrary.getlabel(aktexit2label);
  1410. { we're inlining a procedure }
  1411. inlining_procedure:=true;
  1412. aktprocdef:=inlineprocdef;
  1413. { clone procinfo, but not the asmlists }
  1414. procinfo:=tprocinfo(cprocinfo.newinstance);
  1415. move(pointer(oldprocinfo)^,pointer(procinfo)^,cprocinfo.InstanceSize);
  1416. procinfo.aktentrycode:=nil;
  1417. procinfo.aktexitcode:=nil;
  1418. procinfo.aktproccode:=nil;
  1419. procinfo.aktlocaldata:=nil;
  1420. { set new procinfo }
  1421. procinfo.return_offset:=retoffset;
  1422. procinfo.para_offset:=para_offset;
  1423. procinfo.no_fast_exit:=false;
  1424. { arg space has been filled by the parent secondcall }
  1425. st:=aktprocdef.localst;
  1426. { set it to the same lexical level }
  1427. st.symtablelevel:=oldprocdef.localst.symtablelevel;
  1428. if st.datasize>0 then
  1429. begin
  1430. tg.GetTemp(exprasmlist,st.datasize,tt_persistant,localsref);
  1431. st.address_fixup:=localsref.offset+st.datasize;
  1432. {$ifdef extdebug}
  1433. Comment(V_debug,'local symtable is at offset '+tostr(st.address_fixup));
  1434. exprasmList.concat(tai_comment.Create(strpnew(
  1435. 'local symtable is at offset '+tostr(st.address_fixup))));
  1436. {$endif extdebug}
  1437. end;
  1438. exprasmList.concat(Tai_Marker.Create(InlineStart));
  1439. {$ifdef extdebug}
  1440. exprasmList.concat(tai_comment.Create(strpnew('Start of inlined proc')));
  1441. {$endif extdebug}
  1442. {$ifdef GDB}
  1443. if (cs_debuginfo in aktmoduleswitches) then
  1444. begin
  1445. objectlibrary.getaddrlabel(startlabel);
  1446. objectlibrary.getaddrlabel(endlabel);
  1447. cg.a_label(exprasmlist,startlabel);
  1448. inlineprocdef.localst.symtabletype:=inlinelocalsymtable;
  1449. inlineprocdef.parast.symtabletype:=inlineparasymtable;
  1450. { Here we must include the para and local symtable info }
  1451. inlineprocdef.concatstabto(withdebuglist);
  1452. { set it back for safety }
  1453. inlineprocdef.localst.symtabletype:=localsymtable;
  1454. inlineprocdef.parast.symtabletype:=parasymtable;
  1455. mangled_length:=length(oldprocdef.mangledname);
  1456. getmem(pp,mangled_length+50);
  1457. strpcopy(pp,'192,0,0,'+startlabel.name);
  1458. if (target_info.use_function_relative_addresses) then
  1459. begin
  1460. strpcopy(strend(pp),'-');
  1461. strpcopy(strend(pp),oldprocdef.mangledname);
  1462. end;
  1463. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1464. end;
  1465. {$endif GDB}
  1466. { takes care of local data initialization }
  1467. inlineentrycode:=TAAsmoutput.Create;
  1468. inlineexitcode:=TAAsmoutput.Create;
  1469. ps:=para_size;
  1470. make_global:=false; { to avoid warning }
  1471. genentrycode(inlineentrycode,make_global,0,ps,nostackframe,true);
  1472. if po_assembler in aktprocdef.procoptions then
  1473. inlineentrycode.insert(Tai_marker.Create(asmblockstart));
  1474. exprasmList.concatlist(inlineentrycode);
  1475. secondpass(inlinetree);
  1476. genexitcode(inlineexitcode,0,false,true);
  1477. if po_assembler in aktprocdef.procoptions then
  1478. inlineexitcode.concat(Tai_marker.Create(asmblockend));
  1479. exprasmList.concatlist(inlineexitcode);
  1480. inlineentrycode.free;
  1481. inlineexitcode.free;
  1482. {$ifdef extdebug}
  1483. exprasmList.concat(tai_comment.Create(strpnew('End of inlined proc')));
  1484. {$endif extdebug}
  1485. exprasmList.concat(Tai_Marker.Create(InlineEnd));
  1486. {we can free the local data now, reset also the fixup address }
  1487. if st.datasize>0 then
  1488. begin
  1489. tg.UnGetTemp(exprasmlist,localsref);
  1490. st.address_fixup:=0;
  1491. end;
  1492. { restore procinfo }
  1493. procinfo.free;
  1494. procinfo:=oldprocinfo;
  1495. {$ifdef GDB}
  1496. if (cs_debuginfo in aktmoduleswitches) then
  1497. begin
  1498. cg.a_label(exprasmlist,endlabel);
  1499. strpcopy(pp,'224,0,0,'+endlabel.name);
  1500. if (target_info.use_function_relative_addresses) then
  1501. begin
  1502. strpcopy(strend(pp),'-');
  1503. strpcopy(strend(pp),oldprocdef.mangledname);
  1504. end;
  1505. withdebugList.concat(Tai_stabn.Create(strnew(pp)));
  1506. freemem(pp,mangled_length+50);
  1507. end;
  1508. {$endif GDB}
  1509. { restore }
  1510. aktprocdef:=oldprocdef;
  1511. aktexitlabel:=oldexitlabel;
  1512. aktexit2label:=oldexit2label;
  1513. quickexitlabel:=oldquickexitlabel;
  1514. inlining_procedure:=oldinlining_procedure;
  1515. { reallocate the registers used for the current procedure's regvars, }
  1516. { since they may have been used and then deallocated in the inlined }
  1517. { procedure (JM) }
  1518. if assigned(aktprocdef.regvarinfo) then
  1519. begin
  1520. rg.restoreStateAfterInline(oldregstate);
  1521. end;
  1522. end;
  1523. begin
  1524. ccallparanode:=tcgcallparanode;
  1525. ccallnode:=tcgcallnode;
  1526. cprocinlinenode:=tcgprocinlinenode;
  1527. end.
  1528. {
  1529. $Log$
  1530. Revision 1.38 2003-02-15 22:17:38 carl
  1531. * bugfix of FPU emulation code
  1532. Revision 1.37 2003/02/12 22:10:07 carl
  1533. * load_frame_pointer is now generic
  1534. * change fpu emulation routine names
  1535. Revision 1.36 2003/01/30 21:46:57 peter
  1536. * self fixes for static methods (merged)
  1537. Revision 1.35 2003/01/22 20:45:15 mazen
  1538. * making math code in RTL compiling.
  1539. *NB : This does NOT mean necessary that it will generate correct code!
  1540. Revision 1.34 2003/01/17 12:03:45 daniel
  1541. * Optalign conditional code adapted to record Tregister
  1542. Revision 1.33 2003/01/08 18:43:56 daniel
  1543. * Tregister changed into a record
  1544. Revision 1.32 2002/12/15 22:50:00 florian
  1545. + some stuff for the new hidden parameter handling added
  1546. Revision 1.31 2002/12/15 21:30:12 florian
  1547. * tcallnode.paraitem introduced, all references to defcoll removed
  1548. Revision 1.30 2002/11/27 20:04:39 peter
  1549. * cdecl array of const fixes
  1550. Revision 1.29 2002/11/25 17:43:17 peter
  1551. * splitted defbase in defutil,symutil,defcmp
  1552. * merged isconvertable and is_equal into compare_defs(_ext)
  1553. * made operator search faster by walking the list only once
  1554. Revision 1.28 2002/11/18 17:31:54 peter
  1555. * pass proccalloption to ret_in_xxx and push_xxx functions
  1556. Revision 1.27 2002/11/16 15:34:30 florian
  1557. * generic location for float results
  1558. Revision 1.26 2002/11/15 01:58:51 peter
  1559. * merged changes from 1.0.7 up to 04-11
  1560. - -V option for generating bug report tracing
  1561. - more tracing for option parsing
  1562. - errors for cdecl and high()
  1563. - win32 import stabs
  1564. - win32 records<=8 are returned in eax:edx (turned off by default)
  1565. - heaptrc update
  1566. - more info for temp management in .s file with EXTDEBUG
  1567. Revision 1.25 2002/10/05 12:43:25 carl
  1568. * fixes for Delphi 6 compilation
  1569. (warning : Some features do not work under Delphi)
  1570. Revision 1.24 2002/09/30 07:00:45 florian
  1571. * fixes to common code to get the alpha compiler compiled applied
  1572. Revision 1.23 2002/09/17 18:54:02 jonas
  1573. * a_load_reg_reg() now has two size parameters: source and dest. This
  1574. allows some optimizations on architectures that don't encode the
  1575. register size in the register name.
  1576. Revision 1.22 2002/09/07 15:25:02 peter
  1577. * old logs removed and tabs fixed
  1578. Revision 1.21 2002/09/07 11:50:02 jonas
  1579. * fixed small regalloction info bug
  1580. Revision 1.20 2002/09/02 11:25:20 florian
  1581. * fixed generic procedure variable calling
  1582. Revision 1.19 2002/09/01 21:04:48 florian
  1583. * several powerpc related stuff fixed
  1584. Revision 1.18 2002/09/01 18:43:27 peter
  1585. * include accumulator in regs_to_push list
  1586. Revision 1.17 2002/09/01 12:13:00 peter
  1587. * use a_call_reg
  1588. * ungetiftemp for procvar of object temp
  1589. Revision 1.16 2002/08/25 19:25:18 peter
  1590. * sym.insert_in_data removed
  1591. * symtable.insertvardata/insertconstdata added
  1592. * removed insert_in_data call from symtable.insert, it needs to be
  1593. called separatly. This allows to deref the address calculation
  1594. * procedures now calculate the parast addresses after the procedure
  1595. directives are parsed. This fixes the cdecl parast problem
  1596. * push_addr_param has an extra argument that specifies if cdecl is used
  1597. or not
  1598. Revision 1.15 2002/08/23 16:14:48 peter
  1599. * tempgen cleanup
  1600. * tt_noreuse temp type added that will be used in genentrycode
  1601. Revision 1.14 2002/08/20 16:55:38 peter
  1602. * don't write (stabs)line info when inlining a procedure
  1603. Revision 1.13 2002/08/19 19:36:42 peter
  1604. * More fixes for cross unit inlining, all tnodes are now implemented
  1605. * Moved pocall_internconst to po_internconst because it is not a
  1606. calling type at all and it conflicted when inlining of these small
  1607. functions was requested
  1608. Revision 1.12 2002/08/18 20:06:23 peter
  1609. * inlining is now also allowed in interface
  1610. * renamed write/load to ppuwrite/ppuload
  1611. * tnode storing in ppu
  1612. * nld,ncon,nbas are already updated for storing in ppu
  1613. Revision 1.11 2002/08/17 22:09:44 florian
  1614. * result type handling in tcgcal.pass_2 overhauled
  1615. * better tnode.dowrite
  1616. * some ppc stuff fixed
  1617. Revision 1.10 2002/08/17 09:23:35 florian
  1618. * first part of procinfo rewrite
  1619. Revision 1.9 2002/08/13 21:40:55 florian
  1620. * more fixes for ppc calling conventions
  1621. Revision 1.8 2002/08/13 18:01:51 carl
  1622. * rename swatoperands to swapoperands
  1623. + m68k first compilable version (still needs a lot of testing):
  1624. assembler generator, system information , inline
  1625. assembler reader.
  1626. Revision 1.7 2002/08/12 15:08:39 carl
  1627. + stab register indexes for powerpc (moved from gdb to cpubase)
  1628. + tprocessor enumeration moved to cpuinfo
  1629. + linker in target_info is now a class
  1630. * many many updates for m68k (will soon start to compile)
  1631. - removed some ifdef or correct them for correct cpu
  1632. Revision 1.6 2002/08/11 14:32:26 peter
  1633. * renamed current_library to objectlibrary
  1634. Revision 1.5 2002/08/11 13:24:11 peter
  1635. * saving of asmsymbols in ppu supported
  1636. * asmsymbollist global is removed and moved into a new class
  1637. tasmlibrarydata that will hold the info of a .a file which
  1638. corresponds with a single module. Added librarydata to tmodule
  1639. to keep the library info stored for the module. In the future the
  1640. objectfiles will also be stored to the tasmlibrarydata class
  1641. * all getlabel/newasmsymbol and friends are moved to the new class
  1642. Revision 1.4 2002/08/06 20:55:20 florian
  1643. * first part of ppc calling conventions fix
  1644. Revision 1.3 2002/07/20 11:57:53 florian
  1645. * types.pas renamed to defbase.pas because D6 contains a types
  1646. unit so this would conflicts if D6 programms are compiled
  1647. + Willamette/SSE2 instructions to assembler added
  1648. Revision 1.2 2002/07/13 19:38:43 florian
  1649. * some more generic calling stuff fixed
  1650. }