2
0

ncgcal.pas 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate assembler for call nodes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit ncgcal;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cpubase,
  22. globtype,
  23. parabase,cgutils,
  24. symdef,node,ncal;
  25. type
  26. tcgcallparanode = class(tcallparanode)
  27. private
  28. tempcgpara : tcgpara;
  29. procedure push_addr_para;
  30. procedure push_value_para;
  31. public
  32. constructor create(expr,next : tnode);override;
  33. destructor destroy;override;
  34. procedure secondcallparan;override;
  35. end;
  36. tcgcallnode = class(tcallnode)
  37. private
  38. procedure release_para_temps;
  39. procedure pushparas;
  40. procedure freeparas;
  41. protected
  42. framepointer_paraloc : tcgpara;
  43. refcountedtemp : treference;
  44. procedure handle_return_value;
  45. {# This routine is used to push the current frame pointer
  46. on the stack. This is used in nested routines where the
  47. value of the frame pointer is always pushed as an extra
  48. parameter.
  49. The default handling is the standard handling used on
  50. most stack based machines, where the frame pointer is
  51. the first invisible parameter.
  52. }
  53. procedure pop_parasize(pop_size:longint);virtual;
  54. procedure extra_interrupt_code;virtual;
  55. procedure extra_call_code;virtual;
  56. procedure extra_post_call_code;virtual;
  57. procedure do_syscall;virtual;abstract;
  58. public
  59. procedure pass_generate_code;override;
  60. end;
  61. implementation
  62. uses
  63. systems,
  64. cutils,verbose,globals,
  65. cpuinfo,
  66. symconst,symtable,defutil,paramgr,
  67. cgbase,pass_2,
  68. aasmbase,aasmtai,aasmdata,
  69. nbas,nmem,nld,ncnv,nutils,
  70. {$ifdef x86}
  71. cga,cgx86,
  72. {$endif x86}
  73. ncgutil,
  74. cgobj,tgobj,
  75. procinfo;
  76. {*****************************************************************************
  77. TCGCALLPARANODE
  78. *****************************************************************************}
  79. constructor tcgcallparanode.create(expr,next : tnode);
  80. begin
  81. inherited create(expr,next);
  82. tempcgpara.init;
  83. end;
  84. destructor tcgcallparanode.destroy;
  85. begin
  86. tempcgpara.done;
  87. inherited destroy;
  88. end;
  89. procedure tcgcallparanode.push_addr_para;
  90. begin
  91. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  92. internalerror(200304235);
  93. cg.a_paramaddr_ref(current_asmdata.CurrAsmList,left.location.reference,tempcgpara);
  94. end;
  95. procedure tcgcallparanode.push_value_para;
  96. {$ifdef i386}
  97. var
  98. href : treference;
  99. size : longint;
  100. {$endif i386}
  101. begin
  102. { we've nothing to push when the size of the parameter is 0 }
  103. if left.resultdef.size=0 then
  104. exit;
  105. { Move flags and jump in register to make it less complex }
  106. if left.location.loc in [LOC_FLAGS,LOC_JUMP,LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF] then
  107. location_force_reg(current_asmdata.CurrAsmList,left.location,def_cgsize(left.resultdef),false);
  108. { Handle Floating point types differently
  109. This doesn't depend on emulator settings, emulator settings should
  110. be handled by cpupara }
  111. if left.resultdef.typ=floatdef then
  112. begin
  113. {$ifdef i386}
  114. if tempcgpara.location^.loc<>LOC_REFERENCE then
  115. internalerror(200309291);
  116. case left.location.loc of
  117. LOC_FPUREGISTER,
  118. LOC_CFPUREGISTER:
  119. begin
  120. size:=align(TCGSize2Size[left.location.size],tempcgpara.alignment);
  121. if tempcgpara.location^.reference.index=NR_STACK_POINTER_REG then
  122. begin
  123. cg.g_stackpointer_alloc(current_asmdata.CurrAsmList,size);
  124. reference_reset_base(href,NR_STACK_POINTER_REG,0);
  125. end
  126. else
  127. reference_reset_base(href,tempcgpara.location^.reference.index,tempcgpara.location^.reference.offset);
  128. cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,left.location.size,left.location.register,href);
  129. end;
  130. LOC_MMREGISTER,
  131. LOC_CMMREGISTER:
  132. begin
  133. size:=align(tfloatdef(left.resultdef).size,tempcgpara.alignment);
  134. if tempcgpara.location^.reference.index=NR_STACK_POINTER_REG then
  135. begin
  136. cg.g_stackpointer_alloc(current_asmdata.CurrAsmList,size);
  137. reference_reset_base(href,NR_STACK_POINTER_REG,0);
  138. end
  139. else
  140. reference_reset_base(href,tempcgpara.location^.reference.index,tempcgpara.location^.reference.offset);
  141. cg.a_loadmm_reg_ref(current_asmdata.CurrAsmList,left.location.size,left.location.size,left.location.register,href,mms_movescalar);
  142. end;
  143. LOC_REFERENCE,
  144. LOC_CREFERENCE :
  145. begin
  146. size:=align(left.resultdef.size,tempcgpara.alignment);
  147. if (not use_fixed_stack) and
  148. (tempcgpara.location^.reference.index=NR_STACK_POINTER_REG) then
  149. cg.a_param_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara)
  150. else
  151. begin
  152. reference_reset_base(href,tempcgpara.location^.reference.index,tempcgpara.location^.reference.offset);
  153. cg.g_concatcopy(current_asmdata.CurrAsmList,left.location.reference,href,size);
  154. end;
  155. end;
  156. else
  157. internalerror(2002042430);
  158. end;
  159. {$else i386}
  160. case left.location.loc of
  161. LOC_MMREGISTER,
  162. LOC_CMMREGISTER:
  163. case tempcgpara.location^.loc of
  164. LOC_REFERENCE,
  165. LOC_CREFERENCE,
  166. LOC_MMREGISTER,
  167. LOC_CMMREGISTER:
  168. cg.a_parammm_reg(current_asmdata.CurrAsmList,left.location.size,left.location.register,tempcgpara,mms_movescalar);
  169. LOC_FPUREGISTER,
  170. LOC_CFPUREGISTER:
  171. begin
  172. location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
  173. cg.a_paramfpu_reg(current_asmdata.CurrAsmList,left.location.size,left.location.register,tempcgpara);
  174. end;
  175. else
  176. internalerror(200204249);
  177. end;
  178. LOC_FPUREGISTER,
  179. LOC_CFPUREGISTER:
  180. case tempcgpara.location^.loc of
  181. LOC_MMREGISTER,
  182. LOC_CMMREGISTER:
  183. begin
  184. location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,false);
  185. cg.a_parammm_reg(current_asmdata.CurrAsmList,left.location.size,left.location.register,tempcgpara,mms_movescalar);
  186. end;
  187. {$ifdef x86_64}
  188. { x86_64 pushes s64comp in normal register }
  189. LOC_REGISTER,
  190. LOC_CREGISTER :
  191. begin
  192. location_force_mem(current_asmdata.CurrAsmList,left.location);
  193. { force integer size }
  194. left.location.size:=int_cgsize(tcgsize2size[left.location.size]);
  195. cg.a_param_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara);
  196. end;
  197. {$endif x86_64}
  198. {$ifdef powerpc}
  199. LOC_REGISTER,
  200. LOC_CREGISTER :
  201. begin
  202. { aix abi passes floats of varargs in both fpu and }
  203. { integer registers }
  204. location_force_mem(current_asmdata.CurrAsmList,left.location);
  205. { force integer size }
  206. left.location.size:=int_cgsize(tcgsize2size[left.location.size]);
  207. if (left.location.size in [OS_32,OS_S32]) then
  208. cg.a_param_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara)
  209. else
  210. cg64.a_param64_ref(current_asmdata.CurrAsmList,left.location.reference,tempcgpara);
  211. end;
  212. {$endif powerpc}
  213. {$ifdef powerpc64}
  214. LOC_REGISTER,
  215. LOC_CREGISTER :
  216. begin
  217. { ppc64 abi passes floats of varargs in integer registers, so force a store }
  218. location_force_mem(current_asmdata.CurrAsmList,left.location);
  219. { force integer size }
  220. left.location.size:=int_cgsize(tcgsize2size[tempcgpara.location^.size]);
  221. cg.a_param_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara)
  222. end;
  223. {$endif powerpc64}
  224. {$if defined(sparc) or defined(arm)}
  225. { sparc and arm pass floats in normal registers }
  226. LOC_REGISTER,
  227. LOC_CREGISTER,
  228. {$endif sparc}
  229. LOC_REFERENCE,
  230. LOC_CREFERENCE,
  231. LOC_FPUREGISTER,
  232. LOC_CFPUREGISTER:
  233. cg.a_paramfpu_reg(current_asmdata.CurrAsmList,left.location.size,left.location.register,tempcgpara);
  234. else
  235. internalerror(2002042433);
  236. end;
  237. LOC_REFERENCE,
  238. LOC_CREFERENCE:
  239. case tempcgpara.location^.loc of
  240. LOC_MMREGISTER,
  241. LOC_CMMREGISTER:
  242. cg.a_parammm_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara,mms_movescalar);
  243. {$ifdef x86_64}
  244. { x86_64 pushes s64comp in normal register }
  245. LOC_REGISTER,
  246. LOC_CREGISTER :
  247. begin
  248. { force integer size }
  249. left.location.size:=int_cgsize(tcgsize2size[left.location.size]);
  250. cg.a_param_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara);
  251. end;
  252. {$endif x86_64}
  253. {$ifdef powerpc}
  254. { x86_64 pushes s64comp in normal register }
  255. LOC_REGISTER,
  256. LOC_CREGISTER :
  257. begin
  258. { force integer size }
  259. left.location.size:=int_cgsize(tcgsize2size[left.location.size]);
  260. if (left.location.size in [OS_32,OS_S32]) then
  261. cg.a_param_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara)
  262. else
  263. cg64.a_param64_ref(current_asmdata.CurrAsmList,left.location.reference,tempcgpara);
  264. end;
  265. {$endif powerpc}
  266. {$ifdef powerpc64}
  267. LOC_REGISTER,
  268. LOC_CREGISTER :
  269. begin
  270. { force integer size }
  271. left.location.size:=int_cgsize(tcgsize2size[tempcgpara.location^.size]);
  272. cg.a_param_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara)
  273. end;
  274. {$endif powerpc64}
  275. {$if defined(sparc) or defined(arm) }
  276. { sparc and arm pass floats in normal registers }
  277. LOC_REGISTER,
  278. LOC_CREGISTER,
  279. {$endif sparc}
  280. LOC_REFERENCE,
  281. LOC_CREFERENCE,
  282. LOC_FPUREGISTER,
  283. LOC_CFPUREGISTER:
  284. cg.a_paramfpu_ref(current_asmdata.CurrAsmList,left.location.size,left.location.reference,tempcgpara);
  285. else
  286. internalerror(2002042431);
  287. end;
  288. else
  289. internalerror(2002042432);
  290. end;
  291. {$endif i386}
  292. end
  293. else
  294. begin
  295. case left.location.loc of
  296. LOC_CONSTANT,
  297. LOC_REGISTER,
  298. LOC_CREGISTER,
  299. LOC_REFERENCE,
  300. LOC_CREFERENCE :
  301. begin
  302. {$ifndef cpu64bit}
  303. { use cg64 only for int64, not for 8 byte records }
  304. if is_64bit(left.resultdef) then
  305. cg64.a_param64_loc(current_asmdata.CurrAsmList,left.location,tempcgpara)
  306. else
  307. {$endif cpu64bit}
  308. begin
  309. {$ifndef cpu64bit}
  310. { Only a_param_ref supports multiple locations, when the
  311. value is still a const or in a register then write it
  312. to a reference first. This situation can be triggered
  313. by typecasting an int64 constant to a record of 8 bytes }
  314. if left.location.size in [OS_64,OS_S64] then
  315. location_force_mem(current_asmdata.CurrAsmList,left.location);
  316. {$endif cpu64bit}
  317. cg.a_param_loc(current_asmdata.CurrAsmList,left.location,tempcgpara);
  318. end;
  319. end;
  320. {$ifdef SUPPORT_MMX}
  321. LOC_MMXREGISTER,
  322. LOC_CMMXREGISTER:
  323. cg.a_parammm_reg(current_asmdata.CurrAsmList,OS_M64,left.location.register,tempcgpara,nil);
  324. {$endif SUPPORT_MMX}
  325. else
  326. internalerror(200204241);
  327. end;
  328. end;
  329. end;
  330. procedure tcgcallparanode.secondcallparan;
  331. var
  332. href : treference;
  333. otlabel,
  334. oflabel : tasmlabel;
  335. begin
  336. if not(assigned(parasym)) then
  337. internalerror(200304242);
  338. { Skip nothingn nodes which are used after disabling
  339. a parameter }
  340. if (left.nodetype<>nothingn) then
  341. begin
  342. otlabel:=current_procinfo.CurrTrueLabel;
  343. oflabel:=current_procinfo.CurrFalseLabel;
  344. current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
  345. current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
  346. secondpass(left);
  347. maybechangeloadnodereg(current_asmdata.CurrAsmList,left,true);
  348. { release memory for refcnt out parameters }
  349. if (parasym.varspez=vs_out) and
  350. (left.resultdef.needs_inittable) then
  351. begin
  352. location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false);
  353. cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);
  354. end;
  355. paramanager.createtempparaloc(current_asmdata.CurrAsmList,aktcallnode.procdefinition.proccalloption,parasym,tempcgpara);
  356. { handle varargs first, because parasym is not valid }
  357. if (cpf_varargs_para in callparaflags) then
  358. begin
  359. if paramanager.push_addr_param(vs_value,left.resultdef,
  360. aktcallnode.procdefinition.proccalloption) then
  361. push_addr_para
  362. else
  363. push_value_para;
  364. end
  365. { hidden parameters }
  366. else if (vo_is_hidden_para in parasym.varoptions) then
  367. begin
  368. { don't push a node that already generated a pointer type
  369. by address for implicit hidden parameters }
  370. if (vo_is_funcret in parasym.varoptions) or
  371. (not(left.resultdef.typ in [pointerdef,classrefdef]) and
  372. paramanager.push_addr_param(parasym.varspez,parasym.vardef,
  373. aktcallnode.procdefinition.proccalloption)) then
  374. push_addr_para
  375. else
  376. push_value_para;
  377. end
  378. { formal def }
  379. else if (parasym.vardef.typ=formaldef) then
  380. begin
  381. { allow passing of a constant to a const formaldef }
  382. if (parasym.varspez=vs_const) and
  383. (left.location.loc in [LOC_CONSTANT,LOC_REGISTER]) then
  384. location_force_mem(current_asmdata.CurrAsmList,left.location);
  385. push_addr_para;
  386. end
  387. { Normal parameter }
  388. else
  389. begin
  390. { don't push a node that already generated a pointer type
  391. by address for implicit hidden parameters }
  392. if (not(
  393. (vo_is_hidden_para in parasym.varoptions) and
  394. (left.resultdef.typ in [pointerdef,classrefdef])
  395. ) and
  396. paramanager.push_addr_param(parasym.varspez,parasym.vardef,
  397. aktcallnode.procdefinition.proccalloption)) and
  398. { dyn. arrays passed to an array of const must be passed by value, see tests/webtbs/tw4219.pp }
  399. not(
  400. is_array_of_const(parasym.vardef) and
  401. is_dynamic_array(left.resultdef)
  402. ) then
  403. begin
  404. { Passing a var parameter to a var parameter, we can
  405. just push the address transparently }
  406. if (left.nodetype=loadn) and
  407. (tloadnode(left).is_addr_param_load) then
  408. begin
  409. if (left.location.reference.index<>NR_NO) or
  410. (left.location.reference.offset<>0) then
  411. internalerror(200410107);
  412. cg.a_param_reg(current_asmdata.CurrAsmList,OS_ADDR,left.location.reference.base,tempcgpara)
  413. end
  414. else
  415. begin
  416. { Force to be in memory }
  417. if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  418. location_force_mem(current_asmdata.CurrAsmList,left.location);
  419. push_addr_para;
  420. end;
  421. end
  422. else
  423. push_value_para;
  424. end;
  425. current_procinfo.CurrTrueLabel:=otlabel;
  426. current_procinfo.CurrFalseLabel:=oflabel;
  427. { update return location in callnode when this is the function
  428. result }
  429. if assigned(parasym) and
  430. (vo_is_funcret in parasym.varoptions) then
  431. location_copy(aktcallnode.location,left.location);
  432. end;
  433. { next parameter }
  434. if assigned(right) then
  435. tcallparanode(right).secondcallparan;
  436. end;
  437. {*****************************************************************************
  438. TCGCALLNODE
  439. *****************************************************************************}
  440. procedure tcgcallnode.extra_interrupt_code;
  441. begin
  442. end;
  443. procedure tcgcallnode.extra_call_code;
  444. begin
  445. end;
  446. procedure tcgcallnode.extra_post_call_code;
  447. begin
  448. end;
  449. procedure tcgcallnode.pop_parasize(pop_size:longint);
  450. begin
  451. end;
  452. procedure tcgcallnode.handle_return_value;
  453. var
  454. cgsize : tcgsize;
  455. retloc : tlocation;
  456. hregister : tregister;
  457. tempnode : tnode;
  458. begin
  459. cgsize:=procdefinition.funcretloc[callerside].size;
  460. { structured results are easy to handle....
  461. needed also when result_no_used !! }
  462. if (procdefinition.proctypeoption<>potype_constructor) and
  463. paramanager.ret_in_param(resultdef,procdefinition.proccalloption) then
  464. begin
  465. { Location should be setup by the funcret para }
  466. if location.loc<>LOC_REFERENCE then
  467. internalerror(200304241);
  468. end
  469. else
  470. { ansi/widestrings must be registered, so we can dispose them }
  471. if resultdef.needs_inittable then
  472. begin
  473. if procdefinition.funcretloc[callerside].loc<>LOC_REGISTER then
  474. internalerror(200409261);
  475. { the FUNCTION_RESULT_REG is already allocated }
  476. if getsupreg(procdefinition.funcretloc[callerside].register)<first_int_imreg then
  477. cg.ungetcpuregister(current_asmdata.CurrAsmList,procdefinition.funcretloc[callerside].register);
  478. if not assigned(funcretnode) then
  479. begin
  480. { reg_ref could generate two instrcutions and allocate a register so we've to
  481. save the result first before releasing it }
  482. hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
  483. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,procdefinition.funcretloc[callerside].register,hregister);
  484. location_reset(location,LOC_REFERENCE,OS_ADDR);
  485. location.reference:=refcountedtemp;
  486. cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,hregister,location.reference);
  487. end
  488. else
  489. begin
  490. hregister := cg.getaddressregister(current_asmdata.CurrAsmList);
  491. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,procdefinition.funcretloc[callerside].register,hregister);
  492. { in case of a regular funcretnode with ret_in_param, the }
  493. { original funcretnode isn't touched -> make sure it's }
  494. { the same here (not sure if it's necessary) }
  495. tempnode := funcretnode.getcopy;
  496. tempnode.pass_generate_code;
  497. location := tempnode.location;
  498. tempnode.free;
  499. cg.g_decrrefcount(current_asmdata.CurrAsmList,resultdef,location.reference);
  500. cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,hregister,location.reference);
  501. end;
  502. end
  503. else
  504. { normal (ordinal,float,pointer) result value }
  505. begin
  506. { we have only to handle the result if it is used }
  507. if (cnf_return_value_used in callnodeflags) then
  508. begin
  509. location.loc:=procdefinition.funcretloc[callerside].loc;
  510. case procdefinition.funcretloc[callerside].loc of
  511. LOC_FPUREGISTER:
  512. begin
  513. location_reset(location,LOC_FPUREGISTER,cgsize);
  514. location.register:=procdefinition.funcretloc[callerside].register;
  515. {$ifdef x86}
  516. tcgx86(cg).inc_fpu_stack;
  517. {$else x86}
  518. if getsupreg(procdefinition.funcretloc[callerside].register)<first_fpu_imreg then
  519. cg.ungetcpuregister(current_asmdata.CurrAsmList,procdefinition.funcretloc[callerside].register);
  520. hregister:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  521. cg.a_loadfpu_reg_reg(current_asmdata.CurrAsmList,location.size,location.register,hregister);
  522. location.register:=hregister;
  523. {$endif x86}
  524. end;
  525. LOC_REGISTER:
  526. begin
  527. if cgsize<>OS_NO then
  528. begin
  529. location_reset(location,LOC_REGISTER,cgsize);
  530. {$ifndef cpu64bit}
  531. if cgsize in [OS_64,OS_S64] then
  532. begin
  533. retloc:=procdefinition.funcretloc[callerside];
  534. if retloc.loc<>LOC_REGISTER then
  535. internalerror(200409141);
  536. { the function result registers are already allocated }
  537. if getsupreg(retloc.register64.reglo)<first_int_imreg then
  538. cg.ungetcpuregister(current_asmdata.CurrAsmList,retloc.register64.reglo);
  539. location.register64.reglo:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
  540. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,retloc.register64.reglo,location.register64.reglo);
  541. if getsupreg(retloc.register64.reghi)<first_int_imreg then
  542. cg.ungetcpuregister(current_asmdata.CurrAsmList,retloc.register64.reghi);
  543. location.register64.reghi:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
  544. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,retloc.register64.reghi,location.register64.reghi);
  545. end
  546. else
  547. {$endif cpu64bit}
  548. begin
  549. { change register size after the unget because the
  550. getregister was done for the full register
  551. def_cgsize(resultdef) is used here because
  552. it could be a constructor call }
  553. if getsupreg(procdefinition.funcretloc[callerside].register)<first_int_imreg then
  554. cg.ungetcpuregister(current_asmdata.CurrAsmList,procdefinition.funcretloc[callerside].register);
  555. location.register:=cg.getintregister(current_asmdata.CurrAsmList,def_cgsize(resultdef));
  556. cg.a_load_reg_reg(current_asmdata.CurrAsmList,cgsize,def_cgsize(resultdef),procdefinition.funcretloc[callerside].register,location.register);
  557. end;
  558. {$ifdef arm}
  559. if (resultdef.typ=floatdef) and (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) then
  560. begin
  561. location_force_mem(current_asmdata.CurrAsmList,location);
  562. end;
  563. {$endif arm}
  564. end
  565. else
  566. begin
  567. if resultdef.size>0 then
  568. internalerror(200305131);
  569. end;
  570. end;
  571. LOC_MMREGISTER:
  572. begin
  573. location_reset(location,LOC_MMREGISTER,cgsize);
  574. if getsupreg(procdefinition.funcretloc[callerside].register)<first_mm_imreg then
  575. cg.ungetcpuregister(current_asmdata.CurrAsmList,procdefinition.funcretloc[callerside].register);
  576. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,cgsize);
  577. cg.a_loadmm_reg_reg(current_asmdata.CurrAsmList,cgsize,cgsize,procdefinition.funcretloc[callerside].register,location.register,mms_movescalar);
  578. end;
  579. else
  580. internalerror(200405023);
  581. end;
  582. end
  583. else
  584. begin
  585. {$ifdef x86}
  586. { release FPU stack }
  587. if procdefinition.funcretloc[callerside].loc=LOC_FPUREGISTER then
  588. emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
  589. {$endif x86}
  590. if cgsize<>OS_NO then
  591. location_free(current_asmdata.CurrAsmList,procdefinition.funcretloc[callerside]);
  592. location_reset(location,LOC_VOID,OS_NO);
  593. end;
  594. end;
  595. { When the result is not used we need to finalize the result and
  596. can release the temp }
  597. if not(cnf_return_value_used in callnodeflags) then
  598. begin
  599. if location.loc=LOC_REFERENCE then
  600. begin
  601. if resultdef.needs_inittable then
  602. cg.g_finalize(current_asmdata.CurrAsmList,resultdef,location.reference);
  603. tg.ungetiftemp(current_asmdata.CurrAsmList,location.reference)
  604. end;
  605. end;
  606. end;
  607. procedure tcgcallnode.release_para_temps;
  608. var
  609. hp : tnode;
  610. ppn : tcallparanode;
  611. begin
  612. { Release temps from parameters }
  613. ppn:=tcallparanode(left);
  614. while assigned(ppn) do
  615. begin
  616. if assigned(ppn.left) then
  617. begin
  618. { don't release the funcret temp }
  619. if not(assigned(ppn.parasym)) or
  620. not(vo_is_funcret in ppn.parasym.varoptions) then
  621. location_freetemp(current_asmdata.CurrAsmList,ppn.left.location);
  622. { process also all nodes of an array of const }
  623. hp:=ppn.left;
  624. while (hp.nodetype=typeconvn) do
  625. hp:=ttypeconvnode(hp).left;
  626. if (hp.nodetype=arrayconstructorn) and
  627. assigned(tarrayconstructornode(hp).left) then
  628. begin
  629. while assigned(hp) do
  630. begin
  631. location_freetemp(current_asmdata.CurrAsmList,tarrayconstructornode(hp).left.location);
  632. hp:=tarrayconstructornode(hp).right;
  633. end;
  634. end;
  635. end;
  636. ppn:=tcallparanode(ppn.right);
  637. end;
  638. end;
  639. procedure tcgcallnode.pushparas;
  640. var
  641. ppn : tcgcallparanode;
  642. callerparaloc,
  643. tmpparaloc : pcgparalocation;
  644. sizeleft: aint;
  645. htempref,
  646. href : treference;
  647. begin
  648. { copy all resources to the allocated registers }
  649. ppn:=tcgcallparanode(left);
  650. while assigned(ppn) do
  651. begin
  652. if (ppn.left.nodetype<>nothingn) then
  653. begin
  654. { better check for the real location of the parameter here, when stack passed parameters
  655. are saved temporary in registers, checking for the tmpparaloc.loc is wrong
  656. }
  657. paramanager.freeparaloc(current_asmdata.CurrAsmList,ppn.tempcgpara);
  658. tmpparaloc:=ppn.tempcgpara.location;
  659. sizeleft:=ppn.tempcgpara.intsize;
  660. callerparaloc:=ppn.parasym.paraloc[callerside].location;
  661. while assigned(callerparaloc) do
  662. begin
  663. { Every paraloc must have a matching tmpparaloc }
  664. if not assigned(tmpparaloc) then
  665. internalerror(200408224);
  666. if callerparaloc^.size<>tmpparaloc^.size then
  667. internalerror(200408225);
  668. case callerparaloc^.loc of
  669. LOC_REGISTER:
  670. begin
  671. if tmpparaloc^.loc<>LOC_REGISTER then
  672. internalerror(200408221);
  673. if getsupreg(callerparaloc^.register)<first_int_imreg then
  674. cg.getcpuregister(current_asmdata.CurrAsmList,callerparaloc^.register);
  675. cg.a_load_reg_reg(current_asmdata.CurrAsmList,tmpparaloc^.size,tmpparaloc^.size,
  676. tmpparaloc^.register,callerparaloc^.register);
  677. end;
  678. LOC_FPUREGISTER:
  679. begin
  680. if tmpparaloc^.loc<>LOC_FPUREGISTER then
  681. internalerror(200408222);
  682. if getsupreg(callerparaloc^.register)<first_fpu_imreg then
  683. cg.getcpuregister(current_asmdata.CurrAsmList,callerparaloc^.register);
  684. cg.a_loadfpu_reg_reg(current_asmdata.CurrAsmList,ppn.tempcgpara.size,tmpparaloc^.register,callerparaloc^.register);
  685. end;
  686. LOC_MMREGISTER:
  687. begin
  688. if tmpparaloc^.loc<>LOC_MMREGISTER then
  689. internalerror(200408223);
  690. if getsupreg(callerparaloc^.register)<first_mm_imreg then
  691. cg.getcpuregister(current_asmdata.CurrAsmList,callerparaloc^.register);
  692. cg.a_loadmm_reg_reg(current_asmdata.CurrAsmList,tmpparaloc^.size,tmpparaloc^.size,
  693. tmpparaloc^.register,callerparaloc^.register,mms_movescalar);
  694. end;
  695. LOC_REFERENCE:
  696. begin
  697. if use_fixed_stack then
  698. begin
  699. { Can't have a data copied to the stack, every location
  700. must contain a valid size field }
  701. if (ppn.tempcgpara.size=OS_NO) and
  702. ((tmpparaloc^.loc<>LOC_REFERENCE) or
  703. assigned(tmpparaloc^.next)) then
  704. internalerror(200501281);
  705. reference_reset_base(href,callerparaloc^.reference.index,callerparaloc^.reference.offset);
  706. { copy parameters in case they were moved to a temp. location because we've a fixed stack }
  707. case tmpparaloc^.loc of
  708. LOC_REFERENCE:
  709. begin
  710. reference_reset_base(htempref,tmpparaloc^.reference.index,tmpparaloc^.reference.offset);
  711. { use concatcopy, because it can also be a float which fails when
  712. load_ref_ref is used }
  713. if (ppn.tempcgpara.size <> OS_NO) then
  714. cg.g_concatcopy(current_asmdata.CurrAsmList,htempref,href,tcgsize2size[tmpparaloc^.size])
  715. else
  716. cg.g_concatcopy(current_asmdata.CurrAsmList,htempref,href,sizeleft)
  717. end;
  718. LOC_REGISTER:
  719. cg.a_load_reg_ref(current_asmdata.CurrAsmList,tmpparaloc^.size,tmpparaloc^.size,tmpparaloc^.register,href);
  720. LOC_FPUREGISTER:
  721. cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,tmpparaloc^.size,tmpparaloc^.register,href);
  722. LOC_MMREGISTER:
  723. cg.a_loadmm_reg_ref(current_asmdata.CurrAsmList,tmpparaloc^.size,tmpparaloc^.size,tmpparaloc^.register,href,mms_movescalar);
  724. else
  725. internalerror(200402081);
  726. end;
  727. end;
  728. end;
  729. end;
  730. dec(sizeleft,tcgsize2size[tmpparaloc^.size]);
  731. callerparaloc:=callerparaloc^.next;
  732. tmpparaloc:=tmpparaloc^.next;
  733. end;
  734. end;
  735. ppn:=tcgcallparanode(ppn.right);
  736. end;
  737. end;
  738. procedure tcgcallnode.freeparas;
  739. var
  740. ppn : tcgcallparanode;
  741. begin
  742. { free the resources allocated for the parameters }
  743. ppn:=tcgcallparanode(left);
  744. while assigned(ppn) do
  745. begin
  746. if (ppn.left.nodetype<>nothingn) then
  747. begin
  748. if (ppn.parasym.paraloc[callerside].location^.loc <> LOC_REFERENCE) then
  749. paramanager.freeparaloc(current_asmdata.CurrAsmList,ppn.parasym.paraloc[callerside]);
  750. end;
  751. ppn:=tcgcallparanode(ppn.right);
  752. end;
  753. end;
  754. procedure tcgcallnode.pass_generate_code;
  755. var
  756. regs_to_save_int,
  757. regs_to_save_fpu,
  758. regs_to_save_mm : Tcpuregisterset;
  759. href : treference;
  760. pop_size : longint;
  761. vmtoffset : aint;
  762. pvreg,
  763. vmtreg : tregister;
  764. oldaktcallnode : tcallnode;
  765. {$ifdef vtentry}
  766. sym : tasmsymbol;
  767. {$endif vtentry}
  768. begin
  769. if not assigned(procdefinition) or
  770. not procdefinition.has_paraloc_info then
  771. internalerror(200305264);
  772. if assigned(methodpointerinit) then
  773. secondpass(methodpointerinit);
  774. if resultdef.needs_inittable and
  775. not paramanager.ret_in_param(resultdef,procdefinition.proccalloption) and
  776. not assigned(funcretnode) then
  777. begin
  778. tg.gettemptyped(current_asmdata.CurrAsmList,resultdef,tt_normal,refcountedtemp);
  779. { finalize instead of only decrref, because if the called }
  780. { function throws an exception this temp will be decrref'd }
  781. { again (tw7100) }
  782. cg.g_finalize(current_asmdata.CurrAsmList,resultdef,refcountedtemp);
  783. end;
  784. regs_to_save_int:=paramanager.get_volatile_registers_int(procdefinition.proccalloption);
  785. regs_to_save_fpu:=paramanager.get_volatile_registers_fpu(procdefinition.proccalloption);
  786. regs_to_save_mm:=paramanager.get_volatile_registers_mm(procdefinition.proccalloption);
  787. { Include Function result registers }
  788. if (not is_void(resultdef)) then
  789. begin
  790. case procdefinition.funcretloc[callerside].loc of
  791. LOC_REGISTER,
  792. LOC_CREGISTER:
  793. include(regs_to_save_int,getsupreg(procdefinition.funcretloc[callerside].register));
  794. LOC_FPUREGISTER,
  795. LOC_CFPUREGISTER:
  796. include(regs_to_save_fpu,getsupreg(procdefinition.funcretloc[callerside].register));
  797. LOC_MMREGISTER,
  798. LOC_CMMREGISTER:
  799. include(regs_to_save_mm,getsupreg(procdefinition.funcretloc[callerside].register));
  800. LOC_REFERENCE,
  801. LOC_VOID:
  802. ;
  803. else
  804. internalerror(2004110213);
  805. end;
  806. end;
  807. { Process parameters, register parameters will be loaded
  808. in imaginary registers. The actual load to the correct
  809. register is done just before the call }
  810. oldaktcallnode:=aktcallnode;
  811. aktcallnode:=self;
  812. if assigned(left) then
  813. tcallparanode(left).secondcallparan;
  814. aktcallnode:=oldaktcallnode;
  815. { procedure variable or normal function call ? }
  816. if (right=nil) then
  817. begin
  818. { When methodpointer is typen we don't need (and can't) load
  819. a pointer. We can directly call the correct procdef (PFV) }
  820. if (po_virtualmethod in procdefinition.procoptions) and
  821. assigned(methodpointer) and
  822. (methodpointer.nodetype<>typen) then
  823. begin
  824. { virtual methods require an index }
  825. if tprocdef(procdefinition).extnumber=$ffff then
  826. internalerror(200304021);
  827. secondpass(methodpointer);
  828. { Load VMT from self }
  829. if methodpointer.resultdef.typ=objectdef then
  830. gen_load_vmt_register(current_asmdata.CurrAsmList,tobjectdef(methodpointer.resultdef),methodpointer.location,vmtreg)
  831. else
  832. begin
  833. { Load VMT value in register }
  834. location_force_reg(current_asmdata.CurrAsmList,methodpointer.location,OS_ADDR,false);
  835. vmtreg:=methodpointer.location.register;
  836. end;
  837. { test validity of VMT }
  838. if not(is_interface(tprocdef(procdefinition)._class)) and
  839. not(is_cppclass(tprocdef(procdefinition)._class)) then
  840. cg.g_maybe_testvmt(current_asmdata.CurrAsmList,vmtreg,tprocdef(procdefinition)._class);
  841. { Call through VMT, generate a VTREF symbol to notify the linker }
  842. vmtoffset:=tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber);
  843. {$ifdef vtentry}
  844. if not is_interface(tprocdef(procdefinition)._class) then
  845. begin
  846. inc(current_asmdata.NextVTEntryNr);
  847. current_asmdata.CurrAsmList.Concat(tai_symbol.CreateName('VTREF'+tostr(current_asmdata.NextVTEntryNr)+'_'+tprocdef(procdefinition)._class.vmt_mangledname+'$$'+tostr(vmtoffset div sizeof(aint)),AT_FUNCTION,0));
  848. end;
  849. {$endif vtentry}
  850. {$ifndef x86}
  851. pvreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_ADDR);
  852. {$endif not x86}
  853. reference_reset_base(href,vmtreg,vmtoffset);
  854. {$ifndef x86}
  855. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,href,pvreg);
  856. {$endif not x86}
  857. { Load parameters that are in temporary registers in the
  858. correct parameter register }
  859. if assigned(left) then
  860. begin
  861. pushparas;
  862. { free the resources allocated for the parameters }
  863. freeparas;
  864. end;
  865. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_INTREGISTER,regs_to_save_int);
  866. if cg.uses_registers(R_FPUREGISTER) then
  867. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_FPUREGISTER,regs_to_save_fpu);
  868. if cg.uses_registers(R_MMREGISTER) then
  869. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_MMREGISTER,regs_to_save_mm);
  870. { call method }
  871. extra_call_code;
  872. {$ifdef x86}
  873. cg.a_call_ref(current_asmdata.CurrAsmList,href);
  874. {$else x86}
  875. cg.a_call_reg(current_asmdata.CurrAsmList,pvreg);
  876. {$endif x86}
  877. extra_post_call_code;
  878. end
  879. else
  880. begin
  881. { Load parameters that are in temporary registers in the
  882. correct parameter register }
  883. if assigned(left) then
  884. begin
  885. pushparas;
  886. { free the resources allocated for the parameters }
  887. freeparas;
  888. end;
  889. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_INTREGISTER,regs_to_save_int);
  890. if cg.uses_registers(R_FPUREGISTER) then
  891. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_FPUREGISTER,regs_to_save_fpu);
  892. if cg.uses_registers(R_MMREGISTER) then
  893. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_MMREGISTER,regs_to_save_mm);
  894. if procdefinition.proccalloption=pocall_syscall then
  895. do_syscall
  896. else
  897. begin
  898. { Calling interrupt from the same code requires some
  899. extra code }
  900. if (po_interrupt in procdefinition.procoptions) then
  901. extra_interrupt_code;
  902. extra_call_code;
  903. cg.a_call_name(current_asmdata.CurrAsmList,tprocdef(procdefinition).mangledname);
  904. extra_post_call_code;
  905. end;
  906. end;
  907. end
  908. else
  909. { now procedure variable case }
  910. begin
  911. secondpass(right);
  912. pvreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_ADDR);
  913. { Only load OS_ADDR from the reference }
  914. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  915. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,right.location.reference,pvreg)
  916. else
  917. cg.a_load_loc_reg(current_asmdata.CurrAsmList,OS_ADDR,right.location,pvreg);
  918. location_freetemp(current_asmdata.CurrAsmList,right.location);
  919. { Load parameters that are in temporary registers in the
  920. correct parameter register }
  921. if assigned(left) then
  922. begin
  923. pushparas;
  924. { free the resources allocated for the parameters }
  925. freeparas;
  926. end;
  927. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_INTREGISTER,regs_to_save_int);
  928. if cg.uses_registers(R_FPUREGISTER) then
  929. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_FPUREGISTER,regs_to_save_fpu);
  930. if cg.uses_registers(R_MMREGISTER) then
  931. cg.alloccpuregisters(current_asmdata.CurrAsmList,R_MMREGISTER,regs_to_save_mm);
  932. { Calling interrupt from the same code requires some
  933. extra code }
  934. if (po_interrupt in procdefinition.procoptions) then
  935. extra_interrupt_code;
  936. extra_call_code;
  937. cg.a_call_reg(current_asmdata.CurrAsmList,pvreg);
  938. extra_post_call_code;
  939. end;
  940. { Need to remove the parameters from the stack? }
  941. if (procdefinition.proccalloption in clearstack_pocalls) then
  942. begin
  943. pop_size:=pushedparasize;
  944. { for Cdecl functions we don't need to pop the funcret when it
  945. was pushed by para }
  946. if paramanager.ret_in_param(procdefinition.returndef,procdefinition.proccalloption) then
  947. dec(pop_size,sizeof(aint));
  948. { Remove parameters/alignment from the stack }
  949. pop_parasize(pop_size);
  950. end;
  951. { Release registers, but not the registers that contain the
  952. function result }
  953. if (not is_void(resultdef)) then
  954. begin
  955. case procdefinition.funcretloc[callerside].loc of
  956. LOC_REGISTER,
  957. LOC_CREGISTER:
  958. begin
  959. {$ifndef cpu64bit}
  960. if procdefinition.funcretloc[callerside].size in [OS_64,OS_S64] then
  961. begin
  962. exclude(regs_to_save_int,getsupreg(procdefinition.funcretloc[callerside].register64.reghi));
  963. exclude(regs_to_save_int,getsupreg(procdefinition.funcretloc[callerside].register64.reglo));
  964. end
  965. else
  966. {$endif cpu64bit}
  967. exclude(regs_to_save_int,getsupreg(procdefinition.funcretloc[callerside].register));
  968. end;
  969. LOC_FPUREGISTER,
  970. LOC_CFPUREGISTER:
  971. exclude(regs_to_save_fpu,getsupreg(procdefinition.funcretloc[callerside].register));
  972. LOC_MMREGISTER,
  973. LOC_CMMREGISTER:
  974. exclude(regs_to_save_mm,getsupreg(procdefinition.funcretloc[callerside].register));
  975. LOC_REFERENCE,
  976. LOC_VOID:
  977. ;
  978. else
  979. internalerror(2004110214);
  980. end;
  981. end;
  982. {$if defined(x86) or defined(arm)}
  983. if procdefinition.proccalloption=pocall_safecall then
  984. begin
  985. {$ifdef x86_64}
  986. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,NR_RAX,NR_RCX);
  987. {$endif x86_64}
  988. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  989. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_SAFECALLCHECK');
  990. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  991. end;
  992. {$endif}
  993. if cg.uses_registers(R_MMREGISTER) then
  994. cg.dealloccpuregisters(current_asmdata.CurrAsmList,R_MMREGISTER,regs_to_save_mm);
  995. if cg.uses_registers(R_FPUREGISTER) then
  996. cg.dealloccpuregisters(current_asmdata.CurrAsmList,R_FPUREGISTER,regs_to_save_fpu);
  997. cg.dealloccpuregisters(current_asmdata.CurrAsmList,R_INTREGISTER,regs_to_save_int);
  998. { handle function results }
  999. if (not is_void(resultdef)) then
  1000. handle_return_value
  1001. else
  1002. location_reset(location,LOC_VOID,OS_NO);
  1003. { perhaps i/o check ? }
  1004. if (cs_check_io in current_settings.localswitches) and
  1005. (po_iocheck in procdefinition.procoptions) and
  1006. not(po_iocheck in current_procinfo.procdef.procoptions) and
  1007. { no IO check for methods and procedure variables }
  1008. (right=nil) and
  1009. not(po_virtualmethod in procdefinition.procoptions) then
  1010. begin
  1011. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1012. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_IOCHECK');
  1013. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1014. end;
  1015. { release temps of paras }
  1016. release_para_temps;
  1017. if assigned(methodpointerdone) then
  1018. secondpass(methodpointerdone);
  1019. end;
  1020. begin
  1021. ccallparanode:=tcgcallparanode;
  1022. ccallnode:=tcgcallnode;
  1023. end.