ncginl.pas 27 KB

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