ncginl.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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. if is_widestring(left.resulttype.def) and (tf_winlikewidestring in target_info.flags) then
  334. begin
  335. reference_reset_base(href,left.location.register,-sizeof(dword));
  336. hregister:=cg.makeregsize(current_asmdata.CurrAsmList,left.location.register,OS_INT);
  337. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_INT,href,hregister);
  338. end
  339. else
  340. begin
  341. reference_reset_base(href,left.location.register,-sizeof(aint));
  342. hregister:=cg.makeregsize(current_asmdata.CurrAsmList,left.location.register,OS_INT);
  343. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_INT,OS_INT,href,hregister);
  344. end;
  345. if is_widestring(left.resulttype.def) then
  346. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SHR,OS_INT,1,hregister);
  347. cg.a_label(current_asmdata.CurrAsmList,lengthlab);
  348. location_reset(location,LOC_REGISTER,OS_INT);
  349. location.register:=hregister;
  350. end;
  351. end;
  352. {*****************************************************************************
  353. PRED/SUCC GENERIC HANDLING
  354. *****************************************************************************}
  355. procedure tcginlinenode.second_PredSucc;
  356. var
  357. cgsize : TCGSize;
  358. cgop : topcg;
  359. begin
  360. secondpass(left);
  361. if inlinenumber=in_pred_x then
  362. cgop:=OP_SUB
  363. else
  364. cgop:=OP_ADD;
  365. cgsize:=def_cgsize(resulttype.def);
  366. { we need a value in a register }
  367. location_copy(location,left.location);
  368. location_force_reg(current_asmdata.CurrAsmList,location,cgsize,false);
  369. {$ifndef cpu64bit}
  370. if cgsize in [OS_64,OS_S64] then
  371. cg64.a_op64_const_reg(current_asmdata.CurrAsmList,cgop,cgsize,1,location.register64)
  372. else
  373. {$endif cpu64bit}
  374. cg.a_op_const_reg(current_asmdata.CurrAsmList,cgop,location.size,1,location.register);
  375. cg.g_rangecheck(current_asmdata.CurrAsmList,location,resulttype.def,resulttype.def);
  376. end;
  377. {*****************************************************************************
  378. INC/DEC GENERIC HANDLING
  379. *****************************************************************************}
  380. procedure tcginlinenode.second_IncDec;
  381. const
  382. addsubop:array[in_inc_x..in_dec_x] of TOpCG=(OP_ADD,OP_SUB);
  383. var
  384. addvalue : TConstExprInt;
  385. addconstant : boolean;
  386. {$ifndef cpu64bit}
  387. hregisterhi,
  388. {$endif cpu64bit}
  389. hregister : tregister;
  390. cgsize : tcgsize;
  391. begin
  392. { set defaults }
  393. addconstant:=true;
  394. { load first parameter, must be a reference }
  395. secondpass(tcallparanode(left).left);
  396. cgsize:=def_cgsize(tcallparanode(left).left.resulttype.def);
  397. { get addvalue }
  398. case tcallparanode(left).left.resulttype.def.deftype of
  399. orddef,
  400. enumdef :
  401. addvalue:=1;
  402. pointerdef :
  403. begin
  404. if is_void(tpointerdef(tcallparanode(left).left.resulttype.def).pointertype.def) then
  405. addvalue:=1
  406. else
  407. addvalue:=tpointerdef(tcallparanode(left).left.resulttype.def).pointertype.def.size;
  408. end;
  409. else
  410. internalerror(10081);
  411. end;
  412. { second_ argument specified?, must be a s32bit in register }
  413. if assigned(tcallparanode(left).right) then
  414. begin
  415. secondpass(tcallparanode(tcallparanode(left).right).left);
  416. { when constant, just multiply the addvalue }
  417. if is_constintnode(tcallparanode(tcallparanode(left).right).left) then
  418. addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
  419. else
  420. begin
  421. location_force_reg(current_asmdata.CurrAsmList,tcallparanode(tcallparanode(left).right).left.location,cgsize,addvalue<=1);
  422. hregister:=tcallparanode(tcallparanode(left).right).left.location.register;
  423. {$ifndef cpu64bit}
  424. hregisterhi:=tcallparanode(tcallparanode(left).right).left.location.register64.reghi;
  425. {$endif cpu64bit}
  426. { insert multiply with addvalue if its >1 }
  427. if addvalue>1 then
  428. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_IMUL,cgsize,addvalue,hregister);
  429. addconstant:=false;
  430. end;
  431. end;
  432. { write the add instruction }
  433. if addconstant then
  434. begin
  435. {$ifndef cpu64bit}
  436. if cgsize in [OS_64,OS_S64] then
  437. cg64.a_op64_const_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],cgsize,addvalue,tcallparanode(left).left.location)
  438. else
  439. {$endif cpu64bit}
  440. cg.a_op_const_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],
  441. aint(addvalue),tcallparanode(left).left.location);
  442. end
  443. else
  444. begin
  445. {$ifndef cpu64bit}
  446. if cgsize in [OS_64,OS_S64] then
  447. cg64.a_op64_reg_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],cgsize,
  448. joinreg64(hregister,hregisterhi),tcallparanode(left).left.location)
  449. else
  450. {$endif cpu64bit}
  451. cg.a_op_reg_loc(current_asmdata.CurrAsmList,addsubop[inlinenumber],
  452. hregister,tcallparanode(left).left.location);
  453. end;
  454. cg.g_overflowcheck(current_asmdata.CurrAsmList,tcallparanode(left).left.location,tcallparanode(left).resulttype.def);
  455. cg.g_rangecheck(current_asmdata.CurrAsmList,tcallparanode(left).left.location,tcallparanode(left).left.resulttype.def,
  456. tcallparanode(left).left.resulttype.def);
  457. end;
  458. {*****************************************************************************
  459. TYPEINFO GENERIC HANDLING
  460. *****************************************************************************}
  461. procedure tcginlinenode.second_typeinfo;
  462. var
  463. href : treference;
  464. begin
  465. location_reset(location,LOC_REGISTER,OS_ADDR);
  466. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  467. reference_reset_symbol(href,tstoreddef(left.resulttype.def).get_rtti_label(fullrtti),0);
  468. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,href,location.register);
  469. end;
  470. {*****************************************************************************
  471. INCLUDE/EXCLUDE GENERIC HANDLING
  472. *****************************************************************************}
  473. procedure tcginlinenode.second_IncludeExclude;
  474. var
  475. bitsperop,l : longint;
  476. opsize : tcgsize;
  477. cgop : topcg;
  478. addrreg2,addrreg,
  479. hregister,hregister2: tregister;
  480. use_small : boolean;
  481. href : treference;
  482. begin
  483. opsize:=OS_32;
  484. bitsperop:=(8*tcgsize2size[opsize]);
  485. secondpass(tcallparanode(left).left);
  486. if tcallparanode(tcallparanode(left).right).left.nodetype=ordconstn then
  487. begin
  488. { calculate bit position }
  489. l:=1 shl (tordconstnode(tcallparanode(tcallparanode(left).right).left).value mod bitsperop);
  490. { determine operator }
  491. if inlinenumber=in_include_x_y then
  492. cgop:=OP_OR
  493. else
  494. begin
  495. cgop:=OP_AND;
  496. l:=not(l);
  497. end;
  498. case tcallparanode(left).left.location.loc of
  499. LOC_REFERENCE :
  500. begin
  501. inc(tcallparanode(left).left.location.reference.offset,
  502. (tordconstnode(tcallparanode(tcallparanode(left).right).left).value div bitsperop)*tcgsize2size[opsize]);
  503. cg.a_op_const_ref(current_asmdata.CurrAsmList,cgop,opsize,l,tcallparanode(left).left.location.reference);
  504. end;
  505. LOC_CREGISTER :
  506. cg.a_op_const_reg(current_asmdata.CurrAsmList,cgop,tcallparanode(left).left.location.size,l,tcallparanode(left).left.location.register);
  507. else
  508. internalerror(200405021);
  509. end;
  510. end
  511. else
  512. begin
  513. use_small:=
  514. { set type }
  515. (tsetdef(tcallparanode(left).left.resulttype.def).settype=smallset)
  516. and
  517. { elemenut number between 1 and 32 }
  518. ((tcallparanode(tcallparanode(left).right).left.resulttype.def.deftype=orddef) and
  519. (torddef(tcallparanode(tcallparanode(left).right).left.resulttype.def).high<=32) or
  520. (tcallparanode(tcallparanode(left).right).left.resulttype.def.deftype=enumdef) and
  521. (tenumdef(tcallparanode(tcallparanode(left).right).left.resulttype.def).max<=32));
  522. { generate code for the element to set }
  523. secondpass(tcallparanode(tcallparanode(left).right).left);
  524. { bitnumber - which must be loaded into register }
  525. hregister:=cg.getintregister(current_asmdata.CurrAsmList,opsize);
  526. hregister2:=cg.getintregister(current_asmdata.CurrAsmList,opsize);
  527. cg.a_load_loc_reg(current_asmdata.CurrAsmList,opsize,
  528. tcallparanode(tcallparanode(left).right).left.location,hregister);
  529. if use_small then
  530. begin
  531. { hregister contains the bitnumber to add }
  532. cg.a_load_const_reg(current_asmdata.CurrAsmList, opsize, 1, hregister2);
  533. cg.a_op_reg_reg(current_asmdata.CurrAsmList, OP_SHL, opsize, hregister, hregister2);
  534. { possiblities :
  535. bitnumber : LOC_REFERENCE, LOC_REGISTER, LOC_CREGISTER
  536. set value : LOC_REFERENCE, LOC_REGISTER
  537. }
  538. { location of set }
  539. if inlinenumber=in_include_x_y then
  540. begin
  541. cg.a_op_reg_loc(current_asmdata.CurrAsmList, OP_OR, hregister2,
  542. tcallparanode(left).left.location);
  543. end
  544. else
  545. begin
  546. cg.a_op_reg_reg(current_asmdata.CurrAsmList, OP_NOT, opsize, hregister2,hregister2);
  547. cg.a_op_reg_loc(current_asmdata.CurrAsmList, OP_AND, hregister2,
  548. tcallparanode(left).left.location);
  549. end;
  550. end
  551. else
  552. begin
  553. { possiblities :
  554. bitnumber : LOC_REFERENCE, LOC_REGISTER, LOC_CREGISTER
  555. set value : LOC_REFERENCE
  556. }
  557. { hregister contains the bitnumber (div 32 to get the correct offset) }
  558. { hregister contains the bitnumber to add }
  559. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SHR, opsize, 5, hregister,hregister2);
  560. cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SHL, opsize, 2, hregister2);
  561. addrreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
  562. { we need an extra address register to be able to do an ADD operation }
  563. addrreg2:=cg.getaddressregister(current_asmdata.CurrAsmList);
  564. cg.a_load_reg_reg(current_asmdata.CurrAsmList,opsize,OS_ADDR,hregister2,addrreg2);
  565. { calculate the correct address of the operand }
  566. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList, tcallparanode(left).left.location.reference,addrreg);
  567. cg.a_op_reg_reg(current_asmdata.CurrAsmList, OP_ADD, OS_ADDR, addrreg2, addrreg);
  568. { hregister contains the bitnumber to add }
  569. cg.a_load_const_reg(current_asmdata.CurrAsmList, opsize, 1, hregister2);
  570. cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_AND, opsize, 31, hregister);
  571. cg.a_op_reg_reg(current_asmdata.CurrAsmList, OP_SHL, opsize, hregister, hregister2);
  572. reference_reset_base(href,addrreg,0);
  573. if inlinenumber=in_include_x_y then
  574. cg.a_op_reg_ref(current_asmdata.CurrAsmList, OP_OR, opsize, hregister2, href)
  575. else
  576. begin
  577. cg.a_op_reg_reg(current_asmdata.CurrAsmList, OP_NOT, opsize, hregister2, hregister2);
  578. cg.a_op_reg_ref(current_asmdata.CurrAsmList, OP_AND, opsize, hregister2, href);
  579. end;
  580. end;
  581. end;
  582. end;
  583. {*****************************************************************************
  584. FLOAT GENERIC HANDLING
  585. *****************************************************************************}
  586. {
  587. These routines all call internal RTL routines, so if they are
  588. called here, they give an internal error
  589. }
  590. procedure tcginlinenode.second_pi;
  591. begin
  592. internalerror(20020718);
  593. end;
  594. procedure tcginlinenode.second_arctan_real;
  595. begin
  596. internalerror(20020718);
  597. end;
  598. procedure tcginlinenode.second_abs_real;
  599. begin
  600. internalerror(20020718);
  601. end;
  602. procedure tcginlinenode.second_sqr_real;
  603. begin
  604. internalerror(20020718);
  605. end;
  606. procedure tcginlinenode.second_sqrt_real;
  607. begin
  608. internalerror(20020718);
  609. end;
  610. procedure tcginlinenode.second_ln_real;
  611. begin
  612. internalerror(20020718);
  613. end;
  614. procedure tcginlinenode.second_cos_real;
  615. begin
  616. internalerror(20020718);
  617. end;
  618. procedure tcginlinenode.second_sin_real;
  619. begin
  620. internalerror(20020718);
  621. end;
  622. procedure tcginlinenode.second_prefetch;
  623. begin
  624. end;
  625. {*****************************************************************************
  626. ASSIGNED GENERIC HANDLING
  627. *****************************************************************************}
  628. procedure tcginlinenode.second_assigned;
  629. begin
  630. secondpass(tcallparanode(left).left);
  631. { force left to be an OS_ADDR, since in case of method procvars }
  632. { the size is 2*OS_ADDR (JM) }
  633. cg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,OS_ADDR,OC_NE,0,tcallparanode(left).left.location,current_procinfo.CurrTrueLabel);
  634. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  635. location_reset(location,LOC_JUMP,OS_NO);
  636. end;
  637. begin
  638. cinlinenode:=tcginlinenode;
  639. end.