ncgcal.pas 48 KB

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