ncginl.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl and Carl Eric Codere
  3. Generate generic inline 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 ncginl;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,ninl;
  22. type
  23. tcginlinenode = class(tinlinenode)
  24. procedure pass_generate_code;override;
  25. procedure second_assert;virtual;
  26. procedure second_sizeoftypeof;virtual;
  27. procedure second_length;virtual;
  28. procedure second_predsucc;virtual;
  29. procedure second_incdec;virtual;
  30. procedure second_typeinfo;virtual;
  31. procedure second_includeexclude;virtual;
  32. procedure second_pi; virtual;
  33. procedure second_arctan_real; virtual;
  34. procedure second_abs_real; virtual;
  35. procedure second_sqr_real; virtual;
  36. procedure second_sqrt_real; virtual;
  37. procedure second_ln_real; virtual;
  38. procedure second_cos_real; virtual;
  39. procedure second_sin_real; virtual;
  40. procedure second_assigned; virtual;
  41. procedure second_get_frame;virtual;
  42. procedure second_get_caller_frame;virtual;
  43. procedure second_get_caller_addr;virtual;
  44. procedure second_prefetch; virtual;
  45. procedure second_round_real; virtual;
  46. procedure second_trunc_real; virtual;
  47. end;
  48. implementation
  49. uses
  50. globtype,systems,constexp,
  51. cutils,verbose,globals,fmodule,
  52. symconst,symdef,defutil,symsym,
  53. aasmbase,aasmtai,aasmdata,aasmcpu,parabase,
  54. cgbase,pass_1,pass_2,
  55. cpuinfo,cpubase,paramgr,procinfo,
  56. nbas,ncon,ncal,ncnv,nld,ncgrtti,
  57. tgobj,ncgutil,
  58. cgutils,cgobj
  59. {$ifndef cpu64bit}
  60. ,cg64f32
  61. {$endif cpu64bit}
  62. ;
  63. {*****************************************************************************
  64. TCGINLINENODE
  65. *****************************************************************************}
  66. procedure tcginlinenode.pass_generate_code;
  67. begin
  68. location_reset(location,LOC_VOID,OS_NO);
  69. case inlinenumber of
  70. in_assert_x_y:
  71. second_Assert;
  72. in_sizeof_x,
  73. in_typeof_x :
  74. second_SizeofTypeOf;
  75. in_length_x :
  76. second_Length;
  77. in_pred_x,
  78. in_succ_x:
  79. second_PredSucc;
  80. in_dec_x,
  81. in_inc_x :
  82. second_IncDec;
  83. in_typeinfo_x:
  84. second_TypeInfo;
  85. in_include_x_y,
  86. in_exclude_x_y:
  87. second_IncludeExclude;
  88. in_pi_real:
  89. second_pi;
  90. in_sin_real:
  91. second_sin_real;
  92. in_arctan_real:
  93. second_arctan_real;
  94. in_abs_real:
  95. second_abs_real;
  96. in_round_real:
  97. second_round_real;
  98. in_trunc_real:
  99. second_trunc_real;
  100. in_sqr_real:
  101. second_sqr_real;
  102. in_sqrt_real:
  103. second_sqrt_real;
  104. in_ln_real:
  105. second_ln_real;
  106. in_cos_real:
  107. second_cos_real;
  108. in_prefetch_var:
  109. second_prefetch;
  110. in_assigned_x:
  111. second_assigned;
  112. in_get_frame:
  113. second_get_frame;
  114. in_get_caller_frame:
  115. second_get_caller_frame;
  116. in_get_caller_addr:
  117. second_get_caller_addr;
  118. {$ifdef SUPPORT_UNALIGNED}
  119. in_unaligned_x:
  120. begin
  121. secondpass(tcallparanode(left).left);
  122. location:=tcallparanode(left).left.location;
  123. if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  124. location.reference.alignment:=1;
  125. end;
  126. {$endif SUPPORT_UNALIGNED}
  127. {$ifdef SUPPORT_MMX}
  128. in_mmx_pcmpeqb..in_mmx_pcmpgtw:
  129. begin
  130. location_reset(location,LOC_MMXREGISTER,OS_NO);
  131. if left.location.loc=LOC_REGISTER then
  132. begin
  133. {!!!!!!!}
  134. end
  135. else if tcallparanode(left).left.location.loc=LOC_REGISTER then
  136. begin
  137. {!!!!!!!}
  138. end
  139. else
  140. begin
  141. {!!!!!!!}
  142. end;
  143. end;
  144. {$endif SUPPORT_MMX}
  145. else internalerror(9);
  146. end;
  147. end;
  148. {*****************************************************************************
  149. ASSERT GENERIC HANDLING
  150. *****************************************************************************}
  151. procedure tcginlinenode.second_Assert;
  152. var
  153. hp2,hp3 : tnode;
  154. otlabel,oflabel : tasmlabel;
  155. paraloc1,paraloc2,
  156. paraloc3,paraloc4 : tcgpara;
  157. begin
  158. { the node should be removed in the firstpass }
  159. if not (cs_do_assertion in current_settings.localswitches) then
  160. internalerror(7123458);
  161. paraloc1.init;
  162. paraloc2.init;
  163. paraloc3.init;
  164. paraloc4.init;
  165. paramanager.getintparaloc(pocall_default,1,paraloc1);
  166. paramanager.getintparaloc(pocall_default,2,paraloc2);
  167. paramanager.getintparaloc(pocall_default,3,paraloc3);
  168. paramanager.getintparaloc(pocall_default,4,paraloc4);
  169. otlabel:=current_procinfo.CurrTrueLabel;
  170. oflabel:=current_procinfo.CurrFalseLabel;
  171. current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
  172. current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
  173. secondpass(tcallparanode(left).left);
  174. maketojumpbool(current_asmdata.CurrAsmList,tcallparanode(left).left,lr_load_regvars);
  175. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  176. { First call secondpass() before we can push the parameters, otherwise
  177. parameters allocated in the registers can be destroyed }
  178. { generate filename string parameter }
  179. hp2:=ctypeconvnode.create(cstringconstnode.createstr(current_module.sourcefiles.get_file_name(current_filepos.fileindex)),cshortstringtype);
  180. firstpass(hp2);
  181. secondpass(hp2);
  182. if codegenerror then
  183. exit;
  184. { message parameter }
  185. hp3:=tcallparanode(tcallparanode(left).right).left;
  186. secondpass(hp3);
  187. if codegenerror then
  188. exit;
  189. { push erroraddr }
  190. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc4);
  191. cg.a_param_reg(current_asmdata.CurrAsmList,OS_ADDR,NR_FRAME_POINTER_REG,paraloc4);
  192. { push lineno }
  193. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc3);
  194. cg.a_param_const(current_asmdata.CurrAsmList,OS_INT,current_filepos.line,paraloc3);
  195. { push filename }
  196. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc2);
  197. cg.a_paramaddr_ref(current_asmdata.CurrAsmList,hp2.location.reference,paraloc2);
  198. { push msg }
  199. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
  200. cg.a_paramaddr_ref(current_asmdata.CurrAsmList,hp3.location.reference,paraloc1);
  201. { call }
  202. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
  203. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc2);
  204. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc3);
  205. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc4);
  206. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  207. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_ASSERT');
  208. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  209. location_freetemp(current_asmdata.CurrAsmList,hp3.location);
  210. location_freetemp(current_asmdata.CurrAsmList,hp2.location);
  211. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
  212. current_procinfo.CurrTrueLabel:=otlabel;
  213. current_procinfo.CurrFalseLabel:=oflabel;
  214. paraloc1.done;
  215. paraloc2.done;
  216. paraloc3.done;
  217. paraloc4.done;
  218. hp2.free;
  219. end;
  220. {*****************************************************************************
  221. SIZEOF / TYPEOF GENERIC HANDLING
  222. *****************************************************************************}
  223. { second_handle_ the sizeof and typeof routines }
  224. procedure tcginlinenode.second_SizeOfTypeOf;
  225. var
  226. href,
  227. hrefvmt : treference;
  228. hregister : tregister;
  229. begin
  230. if inlinenumber=in_sizeof_x then
  231. location_reset(location,LOC_REGISTER,OS_INT)
  232. else
  233. location_reset(location,LOC_REGISTER,OS_ADDR);
  234. { for both cases load vmt }
  235. if left.nodetype=typen then
  236. begin
  237. hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
  238. reference_reset_symbol(href,current_asmdata.RefAsmSymbol(tobjectdef(left.resultdef).vmt_mangledname),0);
  239. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,href,hregister);
  240. end
  241. else
  242. begin
  243. secondpass(left);
  244. hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
  245. { handle self inside a method of a class }
  246. case left.location.loc of
  247. LOC_CREGISTER,
  248. LOC_REGISTER :
  249. begin
  250. if (left.resultdef.typ=classrefdef) or
  251. (po_staticmethod in current_procinfo.procdef.procoptions) then
  252. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.register,hregister)
  253. else
  254. begin
  255. { load VMT pointer }
  256. reference_reset_base(hrefvmt,left.location.register,tobjectdef(left.resultdef).vmt_offset);
  257. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,hrefvmt,hregister);
  258. end
  259. end;
  260. LOC_REFERENCE,
  261. LOC_CREFERENCE :
  262. begin
  263. if is_class(left.resultdef) then
  264. begin
  265. { deref class }
  266. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.reference,hregister);
  267. cg.g_maybe_testself(current_asmdata.CurrAsmList,hregister);
  268. { load VMT pointer }
  269. reference_reset_base(hrefvmt,hregister,tobjectdef(left.resultdef).vmt_offset);
  270. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,hrefvmt,hregister);
  271. end
  272. else
  273. begin
  274. { load VMT pointer, but not for classrefdefs }
  275. if (left.resultdef.typ=objectdef) then
  276. inc(left.location.reference.offset,tobjectdef(left.resultdef).vmt_offset);
  277. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.reference,hregister);
  278. end;
  279. end;
  280. else
  281. internalerror(200301301);
  282. end;
  283. end;
  284. { in sizeof load size }
  285. if inlinenumber=in_sizeof_x then
  286. begin
  287. reference_reset_base(href,hregister,0);
  288. hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  289. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_INT,OS_INT,href,hregister);
  290. end;
  291. location.register:=hregister;
  292. end;
  293. {*****************************************************************************
  294. LENGTH GENERIC HANDLING
  295. *****************************************************************************}
  296. procedure tcginlinenode.second_Length;
  297. var
  298. lengthlab : tasmlabel;
  299. hregister : tregister;
  300. href : treference;
  301. begin
  302. secondpass(left);
  303. if is_shortstring(left.resultdef) then
  304. begin
  305. location_copy(location,left.location);
  306. location.size:=OS_8;
  307. end
  308. else
  309. begin
  310. { length in ansi/wide strings is at offset -sizeof(aint) }
  311. location_force_reg(current_asmdata.CurrAsmList,left.location,OS_ADDR,false);
  312. current_asmdata.getjumplabel(lengthlab);
  313. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_ADDR,OC_EQ,0,left.location.register,lengthlab);
  314. if is_widestring(left.resultdef) and (tf_winlikewidestring in target_info.flags) then
  315. begin
  316. reference_reset_base(href,left.location.register,-sizeof(dword));
  317. hregister:=cg.makeregsize(current_asmdata.CurrAsmList,left.location.register,OS_INT);
  318. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_INT,href,hregister);
  319. end
  320. else
  321. begin
  322. reference_reset_base(href,left.location.register,-sizeof(aint));
  323. hregister:=cg.makeregsize(current_asmdata.CurrAsmList,left.location.register,OS_INT);
  324. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_INT,OS_INT,href,hregister);
  325. end;
  326. if is_widestring(left.resultdef) then
  327. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SHR,OS_INT,1,hregister);
  328. cg.a_label(current_asmdata.CurrAsmList,lengthlab);
  329. location_reset(location,LOC_REGISTER,OS_INT);
  330. location.register:=hregister;
  331. end;
  332. end;
  333. {*****************************************************************************
  334. PRED/SUCC GENERIC HANDLING
  335. *****************************************************************************}
  336. procedure tcginlinenode.second_PredSucc;
  337. var
  338. cgsize : TCGSize;
  339. cgop : topcg;
  340. begin
  341. secondpass(left);
  342. if inlinenumber=in_pred_x then
  343. cgop:=OP_SUB
  344. else
  345. cgop:=OP_ADD;
  346. cgsize:=def_cgsize(resultdef);
  347. { we need a value in a register }
  348. location_copy(location,left.location);
  349. location_force_reg(current_asmdata.CurrAsmList,location,cgsize,false);
  350. {$ifndef cpu64bit}
  351. if cgsize in [OS_64,OS_S64] then
  352. cg64.a_op64_const_reg(current_asmdata.CurrAsmList,cgop,cgsize,1,location.register64)
  353. else
  354. {$endif cpu64bit}
  355. cg.a_op_const_reg(current_asmdata.CurrAsmList,cgop,location.size,1,location.register);
  356. cg.g_rangecheck(current_asmdata.CurrAsmList,location,resultdef,resultdef);
  357. end;
  358. {*****************************************************************************
  359. INC/DEC GENERIC HANDLING
  360. *****************************************************************************}
  361. procedure tcginlinenode.second_IncDec;
  362. const
  363. addsubop:array[in_inc_x..in_dec_x] of TOpCG=(OP_ADD,OP_SUB);
  364. var
  365. addvalue : TConstExprInt;
  366. addconstant : boolean;
  367. {$ifndef cpu64bit}
  368. hregisterhi,
  369. {$endif cpu64bit}
  370. hregister : tregister;
  371. cgsize : tcgsize;
  372. begin
  373. { set defaults }
  374. addconstant:=true;
  375. { first secondpass second argument, because if the first arg }
  376. { is used in that expression then SSL may move it to another }
  377. { register }
  378. if assigned(tcallparanode(left).right) then
  379. secondpass(tcallparanode(tcallparanode(left).right).left);
  380. { load first parameter, must be a reference }
  381. secondpass(tcallparanode(left).left);
  382. cgsize:=def_cgsize(tcallparanode(left).left.resultdef);
  383. { get addvalue }
  384. case tcallparanode(left).left.resultdef.typ of
  385. orddef,
  386. enumdef :
  387. addvalue:=1;
  388. pointerdef :
  389. begin
  390. if is_void(tpointerdef(tcallparanode(left).left.resultdef).pointeddef) then
  391. addvalue:=1
  392. else
  393. addvalue:=tpointerdef(tcallparanode(left).left.resultdef).pointeddef.size;
  394. end;
  395. else
  396. internalerror(10081);
  397. end;
  398. { second_ argument specified?, must be a s32bit in register }
  399. if assigned(tcallparanode(left).right) then
  400. begin
  401. { when constant, just multiply the addvalue }
  402. if is_constintnode(tcallparanode(tcallparanode(left).right).left) then
  403. addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
  404. else
  405. begin
  406. location_force_reg(current_asmdata.CurrAsmList,tcallparanode(tcallparanode(left).right).left.location,cgsize,addvalue<=1);
  407. hregister:=tcallparanode(tcallparanode(left).right).left.location.register;
  408. {$ifndef cpu64bit}
  409. hregisterhi:=tcallparanode(tcallparanode(left).right).left.location.register64.reghi;
  410. {$endif cpu64bit}
  411. { insert multiply with addvalue if its >1 }
  412. if addvalue>1 then
  413. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_IMUL,cgsize,addvalue.svalue,hregister);
  414. addconstant:=false;
  415. end;
  416. end;
  417. { write the add instruction }
  418. if addconstant then
  419. begin
  420. {$ifndef cpu64bit}
  421. if cgsize in [OS_64,OS_S64] then
  422. cg64.a_op64_const_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],cgsize,addvalue,tcallparanode(left).left.location)
  423. else
  424. {$endif cpu64bit}
  425. cg.a_op_const_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],
  426. aint(addvalue.svalue),tcallparanode(left).left.location);
  427. end
  428. else
  429. begin
  430. {$ifndef cpu64bit}
  431. if cgsize in [OS_64,OS_S64] then
  432. cg64.a_op64_reg_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],cgsize,
  433. joinreg64(hregister,hregisterhi),tcallparanode(left).left.location)
  434. else
  435. {$endif cpu64bit}
  436. cg.a_op_reg_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],
  437. hregister,tcallparanode(left).left.location);
  438. end;
  439. { no overflow checking for pointers (see ninl), and range checking }
  440. { is not applicable for them }
  441. if (tcallparanode(left).left.resultdef.typ <> pointerdef) then
  442. begin
  443. { things which can overflow must NOT pass via here, but have to be }
  444. { handled via a regular add node (conversion in tinlinenode.pass_1) }
  445. { Or someone has to rewrite the above to use a_op_const_reg_reg_ov }
  446. { and friends in case of overflow checking, and ask everyone to }
  447. { implement these methods since they don't exist for all cpus (JM) }
  448. if (cs_check_overflow in current_settings.localswitches) then
  449. internalerror(2006111010);
  450. // cg.g_overflowcheck(current_asmdata.CurrAsmList,tcallparanode(left).left.location,tcallparanode(left).resultdef);
  451. cg.g_rangecheck(current_asmdata.CurrAsmList,tcallparanode(left).left.location,tcallparanode(left).left.resultdef,
  452. tcallparanode(left).left.resultdef);
  453. end;
  454. end;
  455. {*****************************************************************************
  456. TYPEINFO GENERIC HANDLING
  457. *****************************************************************************}
  458. procedure tcginlinenode.second_typeinfo;
  459. var
  460. href : treference;
  461. begin
  462. location_reset(location,LOC_REGISTER,OS_ADDR);
  463. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  464. reference_reset_symbol(href,RTTIWriter.get_rtti_label(left.resultdef,fullrtti),0);
  465. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,href,location.register);
  466. end;
  467. {*****************************************************************************
  468. INCLUDE/EXCLUDE GENERIC HANDLING
  469. *****************************************************************************}
  470. procedure tcginlinenode.second_IncludeExclude;
  471. var
  472. setpara, elepara: tnode;
  473. begin
  474. { the set }
  475. secondpass(tcallparanode(left).left);
  476. { the element to set }
  477. secondpass(tcallparanode(tcallparanode(left).right).left);
  478. setpara:=tcallparanode(left).left;
  479. elepara:=tcallparanode(tcallparanode(left).right).left;
  480. if elepara.location.loc=LOC_CONSTANT then
  481. begin
  482. cg.a_bit_set_const_loc(current_asmdata.CurrAsmList,(inlinenumber=in_include_x_y),
  483. elepara.location.value,setpara.location);
  484. end
  485. else
  486. begin
  487. location_force_reg(current_asmdata.CurrAsmList,elepara.location,OS_INT,true);
  488. cg.a_bit_set_reg_loc(current_asmdata.CurrAsmList,(inlinenumber=in_include_x_y),
  489. elepara.location.size,elepara.location.register,setpara.location);
  490. end;
  491. end;
  492. {*****************************************************************************
  493. FLOAT GENERIC HANDLING
  494. *****************************************************************************}
  495. {
  496. These routines all call internal RTL routines, so if they are
  497. called here, they give an internal error
  498. }
  499. procedure tcginlinenode.second_pi;
  500. begin
  501. internalerror(20020718);
  502. end;
  503. procedure tcginlinenode.second_arctan_real;
  504. begin
  505. internalerror(20020718);
  506. end;
  507. procedure tcginlinenode.second_abs_real;
  508. begin
  509. internalerror(20020718);
  510. end;
  511. procedure tcginlinenode.second_round_real;
  512. begin
  513. internalerror(20020718);
  514. end;
  515. procedure tcginlinenode.second_trunc_real;
  516. begin
  517. internalerror(20020718);
  518. end;
  519. procedure tcginlinenode.second_sqr_real;
  520. begin
  521. internalerror(20020718);
  522. end;
  523. procedure tcginlinenode.second_sqrt_real;
  524. begin
  525. internalerror(20020718);
  526. end;
  527. procedure tcginlinenode.second_ln_real;
  528. begin
  529. internalerror(20020718);
  530. end;
  531. procedure tcginlinenode.second_cos_real;
  532. begin
  533. internalerror(20020718);
  534. end;
  535. procedure tcginlinenode.second_sin_real;
  536. begin
  537. internalerror(20020718);
  538. end;
  539. procedure tcginlinenode.second_prefetch;
  540. begin
  541. end;
  542. {*****************************************************************************
  543. ASSIGNED GENERIC HANDLING
  544. *****************************************************************************}
  545. procedure tcginlinenode.second_assigned;
  546. begin
  547. secondpass(tcallparanode(left).left);
  548. { force left to be an OS_ADDR, since in case of method procvars }
  549. { the size is 2*OS_ADDR (JM) }
  550. cg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,OS_ADDR,OC_NE,0,tcallparanode(left).left.location,current_procinfo.CurrTrueLabel);
  551. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  552. location_reset(location,LOC_JUMP,OS_NO);
  553. end;
  554. procedure Tcginlinenode.second_get_frame;
  555. begin
  556. {$if defined(x86) or defined(arm)}
  557. if current_procinfo.framepointer=NR_STACK_POINTER_REG then
  558. begin
  559. location_reset(location,LOC_CONSTANT,OS_ADDR);
  560. location.value:=0;
  561. end
  562. else
  563. {$endif defined(x86) or defined(arm)}
  564. begin
  565. location_reset(location,LOC_CREGISTER,OS_ADDR);
  566. location.register:=current_procinfo.framepointer;
  567. end;
  568. end;
  569. procedure Tcginlinenode.second_get_caller_frame;
  570. var frame_ref:Treference;
  571. frame_reg:Tregister;
  572. use_frame_pointer:boolean;
  573. begin
  574. if left<>nil then
  575. begin
  576. secondpass(left);
  577. if left.location.loc=LOC_CONSTANT then
  578. use_frame_pointer:=true
  579. else
  580. begin
  581. location_force_reg(current_asmdata.currasmlist,left.location,OS_ADDR,false);
  582. frame_reg:=left.location.register;
  583. use_frame_pointer:=false;
  584. end
  585. end
  586. else
  587. begin
  588. use_frame_pointer:=current_procinfo.framepointer=NR_STACK_POINTER_REG;
  589. frame_reg:=current_procinfo.framepointer;
  590. end;
  591. if use_frame_pointer then
  592. begin
  593. location_reset(location,LOC_CREGISTER,OS_ADDR);
  594. location.register:=NR_FRAME_POINTER_REG;
  595. end
  596. else
  597. begin
  598. location_reset(location,LOC_REFERENCE,OS_ADDR);
  599. location.reference.base:=frame_reg;
  600. end;
  601. end;
  602. procedure Tcginlinenode.second_get_caller_addr;
  603. var frame_ref:Treference;
  604. begin
  605. if current_procinfo.framepointer=NR_STACK_POINTER_REG then
  606. begin
  607. location_reset(location,LOC_REGISTER,OS_ADDR);
  608. location.register:=cg.getaddressregister(current_asmdata.currasmlist);
  609. reference_reset_base(frame_ref,NR_STACK_POINTER_REG,{current_procinfo.calc_stackframe_size}tg.lasttemp);
  610. cg.a_load_ref_reg(current_asmdata.currasmlist,OS_ADDR,OS_ADDR,frame_ref,location.register);
  611. end
  612. else
  613. begin
  614. location_reset(location,LOC_REGISTER,OS_ADDR);
  615. location.register:=cg.getaddressregister(current_asmdata.currasmlist);
  616. {$ifdef cpu64bit}
  617. reference_reset_base(frame_ref,current_procinfo.framepointer,8);
  618. {$else}
  619. reference_reset_base(frame_ref,current_procinfo.framepointer,4);
  620. {$endif}
  621. cg.a_load_ref_reg(current_asmdata.currasmlist,OS_ADDR,OS_ADDR,frame_ref,location.register);
  622. end;
  623. end;
  624. begin
  625. cinlinenode:=tcginlinenode;
  626. end.