ncgcal.pas 49 KB

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