ncginl.pas 27 KB

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