ncginl.pas 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl and Carl Eric Codere
  4. Generate generic inline nodes
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ncginl;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,ninl;
  23. type
  24. tcginlinenode = class(tinlinenode)
  25. procedure pass_2;override;
  26. procedure second_assert;virtual;
  27. procedure second_sizeoftypeof;virtual;
  28. procedure second_length;virtual;
  29. procedure second_predsucc;virtual;
  30. procedure second_incdec;virtual;
  31. procedure second_typeinfo;virtual;
  32. procedure second_includeexclude;virtual;
  33. procedure second_pi; virtual;
  34. procedure second_arctan_real; virtual;
  35. procedure second_abs_real; virtual;
  36. procedure second_sqr_real; virtual;
  37. procedure second_sqrt_real; virtual;
  38. procedure second_ln_real; virtual;
  39. procedure second_cos_real; virtual;
  40. procedure second_sin_real; virtual;
  41. procedure second_assigned; virtual;
  42. end;
  43. implementation
  44. uses
  45. globtype,systems,
  46. cutils,verbose,globals,fmodule,
  47. symconst,symdef,defutil,symsym,
  48. aasmbase,aasmtai,aasmcpu,
  49. cgbase,pass_1,pass_2,
  50. cpuinfo,cpubase,paramgr,procinfo,
  51. nbas,ncon,ncal,ncnv,nld,
  52. tgobj,ncgutil,cgobj
  53. {$ifndef cpu64bit}
  54. ,cg64f32
  55. {$endif cpu64bit}
  56. ;
  57. {*****************************************************************************
  58. TCGINLINENODE
  59. *****************************************************************************}
  60. procedure tcginlinenode.pass_2;
  61. begin
  62. location_reset(location,LOC_VOID,OS_NO);
  63. case inlinenumber of
  64. in_assert_x_y:
  65. begin
  66. second_Assert;
  67. end;
  68. in_sizeof_x,
  69. in_typeof_x :
  70. begin
  71. second_SizeofTypeOf;
  72. end;
  73. in_length_x :
  74. begin
  75. second_Length;
  76. end;
  77. in_pred_x,
  78. in_succ_x:
  79. begin
  80. second_PredSucc;
  81. end;
  82. in_dec_x,
  83. in_inc_x :
  84. begin
  85. second_IncDec;
  86. end;
  87. in_typeinfo_x:
  88. begin
  89. second_TypeInfo;
  90. end;
  91. in_include_x_y,
  92. in_exclude_x_y:
  93. begin
  94. second_IncludeExclude;
  95. end;
  96. in_pi:
  97. begin
  98. second_pi;
  99. end;
  100. in_sin_extended:
  101. begin
  102. second_sin_real;
  103. end;
  104. in_arctan_extended:
  105. begin
  106. second_arctan_real;
  107. end;
  108. in_abs_extended:
  109. begin
  110. second_abs_real;
  111. end;
  112. in_sqr_extended:
  113. begin
  114. second_sqr_real;
  115. end;
  116. in_sqrt_extended:
  117. begin
  118. second_sqrt_real;
  119. end;
  120. in_ln_extended:
  121. begin
  122. second_ln_real;
  123. end;
  124. in_cos_extended:
  125. begin
  126. second_cos_real;
  127. end;
  128. in_assigned_x:
  129. begin
  130. second_assigned;
  131. end;
  132. {$ifdef SUPPORT_MMX}
  133. in_mmx_pcmpeqb..in_mmx_pcmpgtw:
  134. begin
  135. location_reset(location,LOC_MMXREGISTER,OS_NO);
  136. if left.location.loc=LOC_REGISTER then
  137. begin
  138. {!!!!!!!}
  139. end
  140. else if tcallparanode(left).left.location.loc=LOC_REGISTER then
  141. begin
  142. {!!!!!!!}
  143. end
  144. else
  145. begin
  146. {!!!!!!!}
  147. end;
  148. end;
  149. {$endif SUPPORT_MMX}
  150. else internalerror(9);
  151. end;
  152. end;
  153. {*****************************************************************************
  154. ASSERT GENERIC HANDLING
  155. *****************************************************************************}
  156. procedure tcginlinenode.second_Assert;
  157. var
  158. hp2 : tstringconstnode;
  159. otlabel,oflabel : tasmlabel;
  160. paraloc1,paraloc2,
  161. paraloc3,paraloc4 : tparalocation;
  162. begin
  163. { the node should be removed in the firstpass }
  164. if not (cs_do_assertion in aktlocalswitches) then
  165. internalerror(7123458);
  166. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  167. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  168. paraloc3:=paramanager.getintparaloc(pocall_default,3);
  169. paraloc4:=paramanager.getintparaloc(pocall_default,4);
  170. otlabel:=truelabel;
  171. oflabel:=falselabel;
  172. objectlibrary.getlabel(truelabel);
  173. objectlibrary.getlabel(falselabel);
  174. secondpass(tcallparanode(left).left);
  175. maketojumpbool(exprasmlist,tcallparanode(left).left,lr_load_regvars);
  176. cg.a_label(exprasmlist,falselabel);
  177. { erroraddr }
  178. paramanager.allocparaloc(exprasmlist,paraloc4);
  179. cg.a_param_reg(exprasmlist,OS_ADDR,NR_FRAME_POINTER_REG,paraloc4);
  180. { lineno }
  181. paramanager.allocparaloc(exprasmlist,paraloc3);
  182. cg.a_param_const(exprasmlist,OS_INT,aktfilepos.line,paraloc3);
  183. { filename string }
  184. hp2:=cstringconstnode.createstr(current_module.sourcefiles.get_file_name(aktfilepos.fileindex),st_shortstring);
  185. firstpass(tnode(hp2));
  186. secondpass(tnode(hp2));
  187. if codegenerror then
  188. exit;
  189. paramanager.allocparaloc(exprasmlist,paraloc2);
  190. cg.a_paramaddr_ref(exprasmlist,hp2.location.reference,paraloc2);
  191. hp2.free;
  192. { push msg }
  193. secondpass(tcallparanode(tcallparanode(left).right).left);
  194. paramanager.allocparaloc(exprasmlist,paraloc1);
  195. cg.a_paramaddr_ref(exprasmlist,tcallparanode(tcallparanode(left).right).left.location.reference,paraloc1);
  196. { call }
  197. paramanager.freeparaloc(exprasmlist,paraloc1);
  198. paramanager.freeparaloc(exprasmlist,paraloc2);
  199. paramanager.freeparaloc(exprasmlist,paraloc3);
  200. paramanager.freeparaloc(exprasmlist,paraloc4);
  201. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  202. cg.a_call_name(exprasmlist,'FPC_ASSERT');
  203. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  204. cg.a_label(exprasmlist,truelabel);
  205. truelabel:=otlabel;
  206. falselabel:=oflabel;
  207. end;
  208. {*****************************************************************************
  209. SIZEOF / TYPEOF GENERIC HANDLING
  210. *****************************************************************************}
  211. { second_handle_ the sizeof and typeof routines }
  212. procedure tcginlinenode.second_SizeOfTypeOf;
  213. var
  214. href,
  215. hrefvmt : treference;
  216. hregister : tregister;
  217. begin
  218. location_reset(location,LOC_REGISTER,OS_ADDR);
  219. { for both cases load vmt }
  220. if left.nodetype=typen then
  221. begin
  222. hregister:=cg.getaddressregister(exprasmlist);
  223. reference_reset_symbol(href,objectlibrary.newasmsymboldata(tobjectdef(left.resulttype.def).vmt_mangledname),0);
  224. cg.a_loadaddr_ref_reg(exprasmlist,href,hregister);
  225. end
  226. else
  227. begin
  228. secondpass(left);
  229. location_release(exprasmlist,left.location);
  230. hregister:=cg.getaddressregister(exprasmlist);
  231. { handle self inside a method of a class }
  232. case left.location.loc of
  233. LOC_CREGISTER,
  234. LOC_REGISTER :
  235. begin
  236. if (left.resulttype.def.deftype=classrefdef) or
  237. (po_staticmethod in current_procinfo.procdef.procoptions) then
  238. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,left.location.register,hregister)
  239. else
  240. begin
  241. { load VMT pointer }
  242. reference_reset_base(hrefvmt,left.location.register,tobjectdef(left.resulttype.def).vmt_offset);
  243. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,hrefvmt,hregister);
  244. end
  245. end;
  246. LOC_REFERENCE,
  247. LOC_CREFERENCE :
  248. begin
  249. if is_class(left.resulttype.def) then
  250. begin
  251. { deref class }
  252. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,left.location.reference,hregister);
  253. cg.g_maybe_testself(exprasmlist,hregister);
  254. { load VMT pointer }
  255. reference_reset_base(hrefvmt,hregister,tobjectdef(left.resulttype.def).vmt_offset);
  256. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,hrefvmt,hregister);
  257. end
  258. else
  259. begin
  260. { load VMT pointer, but not for classrefdefs }
  261. if (left.resulttype.def.deftype=objectdef) then
  262. inc(left.location.reference.offset,tobjectdef(left.resulttype.def).vmt_offset);
  263. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,left.location.reference,hregister);
  264. end;
  265. end;
  266. else
  267. internalerror(200301301);
  268. end;
  269. end;
  270. { in sizeof load size }
  271. if inlinenumber=in_sizeof_x then
  272. begin
  273. reference_reset_base(href,hregister,0);
  274. cg.ungetregister(exprasmlist,hregister);
  275. hregister:=cg.getintregister(exprasmlist,OS_INT);
  276. cg.a_load_ref_reg(exprasmlist,OS_INT,OS_INT,href,hregister);
  277. end;
  278. location.register:=hregister;
  279. end;
  280. {*****************************************************************************
  281. LENGTH GENERIC HANDLING
  282. *****************************************************************************}
  283. procedure tcginlinenode.second_Length;
  284. var
  285. lengthlab : tasmlabel;
  286. hregister : tregister;
  287. href : treference;
  288. begin
  289. secondpass(left);
  290. if is_shortstring(left.resulttype.def) then
  291. begin
  292. location_copy(location,left.location);
  293. location.size:=OS_8;
  294. end
  295. else
  296. begin
  297. { length in ansi strings is at offset -8 }
  298. location_force_reg(exprasmlist,left.location,OS_ADDR,false);
  299. hregister:=left.location.register;
  300. objectlibrary.getlabel(lengthlab);
  301. cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,hregister,lengthlab);
  302. reference_reset_base(href,hregister,-8);
  303. cg.a_load_ref_reg(exprasmlist,OS_32,OS_32,href,hregister);
  304. cg.a_label(exprasmlist,lengthlab);
  305. location_reset(location,LOC_REGISTER,OS_32);
  306. location.register:=hregister;
  307. end;
  308. end;
  309. {*****************************************************************************
  310. PRED/SUCC GENERIC HANDLING
  311. *****************************************************************************}
  312. procedure tcginlinenode.second_PredSucc;
  313. var
  314. cgsize : TCGSize;
  315. cgop : topcg;
  316. begin
  317. secondpass(left);
  318. if inlinenumber=in_pred_x then
  319. cgop:=OP_SUB
  320. else
  321. cgop:=OP_ADD;
  322. cgsize:=def_cgsize(resulttype.def);
  323. { we need a value in a register }
  324. location_copy(location,left.location);
  325. location_force_reg(exprasmlist,location,cgsize,false);
  326. if cgsize in [OS_64,OS_S64] then
  327. cg64.a_op64_const_reg(exprasmlist,cgop,1,
  328. location.register64)
  329. else
  330. cg.a_op_const_reg(exprasmlist,cgop,location.size,1,location.register);
  331. cg.g_rangecheck(exprasmlist,location,resulttype.def,resulttype.def);
  332. end;
  333. {*****************************************************************************
  334. INC/DEC GENERIC HANDLING
  335. *****************************************************************************}
  336. procedure tcginlinenode.second_IncDec;
  337. const
  338. addsubop:array[in_inc_x..in_dec_x] of TOpCG=(OP_ADD,OP_SUB);
  339. var
  340. addvalue : TConstExprInt;
  341. addconstant : boolean;
  342. {$ifndef cpu64bit}
  343. hregisterhi,
  344. {$endif cpu64bit}
  345. hregister : tregister;
  346. cgsize : tcgsize;
  347. begin
  348. { set defaults }
  349. addconstant:=true;
  350. { load first parameter, must be a reference }
  351. secondpass(tcallparanode(left).left);
  352. cgsize:=def_cgsize(tcallparanode(left).left.resulttype.def);
  353. { get addvalue }
  354. case tcallparanode(left).left.resulttype.def.deftype of
  355. orddef,
  356. enumdef :
  357. addvalue:=1;
  358. pointerdef :
  359. begin
  360. if is_void(tpointerdef(tcallparanode(left).left.resulttype.def).pointertype.def) then
  361. addvalue:=1
  362. else
  363. addvalue:=tpointerdef(tcallparanode(left).left.resulttype.def).pointertype.def.size;
  364. end;
  365. else
  366. internalerror(10081);
  367. end;
  368. { second_ argument specified?, must be a s32bit in register }
  369. if assigned(tcallparanode(left).right) then
  370. begin
  371. secondpass(tcallparanode(tcallparanode(left).right).left);
  372. { when constant, just multiply the addvalue }
  373. if is_constintnode(tcallparanode(tcallparanode(left).right).left) then
  374. addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
  375. else
  376. begin
  377. location_force_reg(exprasmlist,tcallparanode(tcallparanode(left).right).left.location,cgsize,false);
  378. hregister:=tcallparanode(tcallparanode(left).right).left.location.register;
  379. {$ifndef cpu64bit}
  380. hregisterhi:=tcallparanode(tcallparanode(left).right).left.location.registerhigh;
  381. {$endif cpu64bit}
  382. { insert multiply with addvalue if its >1 }
  383. if addvalue>1 then
  384. cg.a_op_const_reg(exprasmlist,OP_IMUL,cgsize,addvalue,hregister);
  385. addconstant:=false;
  386. end;
  387. end;
  388. { write the add instruction }
  389. if addconstant then
  390. begin
  391. if cgsize in [OS_64,OS_S64] then
  392. cg64.a_op64_const_loc(exprasmlist,addsubop[inlinenumber],
  393. addvalue,tcallparanode(left).left.location)
  394. else
  395. cg.a_op_const_loc(exprasmlist,addsubop[inlinenumber],
  396. aword(addvalue),tcallparanode(left).left.location);
  397. end
  398. else
  399. begin
  400. {$ifndef cpu64bit}
  401. if cgsize in [OS_64,OS_S64] then
  402. cg64.a_op64_reg_loc(exprasmlist,addsubop[inlinenumber],
  403. joinreg64(hregister,hregisterhi),tcallparanode(left).left.location)
  404. else
  405. {$endif cpu64bit}
  406. cg.a_op_reg_loc(exprasmlist,addsubop[inlinenumber],
  407. hregister,tcallparanode(left).left.location);
  408. location_release(exprasmlist,tcallparanode(tcallparanode(left).right).left.location);
  409. end;
  410. location_release(exprasmlist,tcallparanode(left).left.location);
  411. cg.g_overflowcheck(exprasmlist,tcallparanode(left).left.location,tcallparanode(left).resulttype.def);
  412. cg.g_rangecheck(exprasmlist,tcallparanode(left).left.location,tcallparanode(left).left.resulttype.def,
  413. tcallparanode(left).left.resulttype.def);
  414. end;
  415. {*****************************************************************************
  416. TYPEINFO GENERIC HANDLING
  417. *****************************************************************************}
  418. procedure tcginlinenode.second_typeinfo;
  419. var
  420. href : treference;
  421. begin
  422. location_reset(location,LOC_REGISTER,OS_ADDR);
  423. location.register:=cg.getaddressregister(exprasmlist);
  424. reference_reset_symbol(href,tstoreddef(left.resulttype.def).get_rtti_label(fullrtti),0);
  425. cg.a_loadaddr_ref_reg(exprasmlist,href,location.register);
  426. end;
  427. {*****************************************************************************
  428. INCLUDE/EXCLUDE GENERIC HANDLING
  429. *****************************************************************************}
  430. procedure tcginlinenode.second_IncludeExclude;
  431. var
  432. L : longint;
  433. cgop : topcg;
  434. addrreg2,addrreg,
  435. hregister,hregister2: tregister;
  436. use_small : boolean;
  437. cgsize : tcgsize;
  438. href : treference;
  439. begin
  440. secondpass(tcallparanode(left).left);
  441. if tcallparanode(tcallparanode(left).right).left.nodetype=ordconstn then
  442. begin
  443. { calculate bit position }
  444. l:=1 shl (tordconstnode(tcallparanode(tcallparanode(left).right).left).value mod 32);
  445. { determine operator }
  446. if inlinenumber=in_include_x_y then
  447. cgop:=OP_OR
  448. else
  449. begin
  450. cgop:=OP_AND;
  451. l:=not(l);
  452. end;
  453. if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
  454. begin
  455. inc(tcallparanode(left).left.location.reference.offset,
  456. (tordconstnode(tcallparanode(tcallparanode(left).right).left).value div 32)*4);
  457. cg.a_op_const_ref(exprasmlist,cgop,OS_INT,aword(l),tcallparanode(left).left.location.reference);
  458. location_release(exprasmlist,tcallparanode(left).left.location);
  459. end
  460. else
  461. { LOC_CREGISTER }
  462. begin
  463. cg.a_op_const_reg(exprasmlist,cgop,tcallparanode(left).left.location.size,aword(l),tcallparanode(left).left.location.register);
  464. end;
  465. end
  466. else
  467. begin
  468. use_small:=
  469. { set type }
  470. (tsetdef(tcallparanode(left).left.resulttype.def).settype=smallset)
  471. and
  472. { elemenut number between 1 and 32 }
  473. ((tcallparanode(tcallparanode(left).right).left.resulttype.def.deftype=orddef) and
  474. (torddef(tcallparanode(tcallparanode(left).right).left.resulttype.def).high<=32) or
  475. (tcallparanode(tcallparanode(left).right).left.resulttype.def.deftype=enumdef) and
  476. (tenumdef(tcallparanode(tcallparanode(left).right).left.resulttype.def).max<=32));
  477. { generate code for the element to set }
  478. secondpass(tcallparanode(tcallparanode(left).right).left);
  479. { bitnumber - which must be loaded into register }
  480. hregister:=cg.getintregister(exprasmlist,OS_32);
  481. hregister2:=cg.getintregister(exprasmlist,OS_32);
  482. cg.a_load_loc_reg(exprasmlist,OS_32,
  483. tcallparanode(tcallparanode(left).right).left.location,hregister);
  484. if use_small then
  485. begin
  486. { hregister contains the bitnumber to add }
  487. cg.a_load_const_reg(exprasmlist, OS_32, 1, hregister2);
  488. cg.a_op_reg_reg(exprasmlist, OP_SHL, OS_32, hregister, hregister2);
  489. { possiblities :
  490. bitnumber : LOC_REFERENCE, LOC_REGISTER, LOC_CREGISTER
  491. set value : LOC_REFERENCE, LOC_REGISTER
  492. }
  493. { location of set }
  494. if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
  495. begin
  496. if inlinenumber=in_include_x_y then
  497. begin
  498. cg.a_op_reg_ref(exprasmlist, OP_OR, OS_32, hregister2,
  499. tcallparanode(left).left.location.reference);
  500. end
  501. else
  502. begin
  503. cg.a_op_reg_reg(exprasmlist, OP_NOT, OS_32, hregister2,hregister2);
  504. cg.a_op_reg_ref(exprasmlist, OP_AND, OS_32, hregister2,
  505. tcallparanode(left).left.location.reference);
  506. end;
  507. end
  508. else
  509. internalerror(20020728);
  510. end
  511. else
  512. begin
  513. { possiblities :
  514. bitnumber : LOC_REFERENCE, LOC_REGISTER, LOC_CREGISTER
  515. set value : LOC_REFERENCE
  516. }
  517. { hregister contains the bitnumber (div 32 to get the correct offset) }
  518. { hregister contains the bitnumber to add }
  519. cg.a_op_const_reg_reg(exprasmlist, OP_SHR, OS_32, 5, hregister,hregister2);
  520. cg.a_op_const_reg(exprasmlist, OP_SHL, OS_32, 2, hregister2);
  521. addrreg:=cg.getaddressregister(exprasmlist);
  522. { we need an extra address register to be able to do an ADD operation }
  523. addrreg2:=cg.getaddressregister(exprasmlist);
  524. cg.a_load_reg_reg(exprasmlist,OS_32,OS_ADDR,hregister2,addrreg2);
  525. { calculate the correct address of the operand }
  526. cg.a_loadaddr_ref_reg(exprasmlist, tcallparanode(left).left.location.reference,addrreg);
  527. cg.a_op_reg_reg(exprasmlist, OP_ADD, OS_32, addrreg2, addrreg);
  528. cg.ungetregister(exprasmlist,addrreg2);
  529. { hregister contains the bitnumber to add }
  530. cg.a_load_const_reg(exprasmlist, OS_32, 1, hregister2);
  531. cg.a_op_const_reg(exprasmlist, OP_AND, OS_32, 31, hregister);
  532. cg.a_op_reg_reg(exprasmlist, OP_SHL, OS_32, hregister, hregister2);
  533. reference_reset_base(href,addrreg,0);
  534. if inlinenumber=in_include_x_y then
  535. cg.a_op_reg_ref(exprasmlist, OP_OR, OS_32, hregister2, href)
  536. else
  537. begin
  538. cg.a_op_reg_reg(exprasmlist, OP_NOT, OS_32, hregister2, hregister2);
  539. cg.a_op_reg_ref(exprasmlist, OP_AND, OS_32, hregister2, href);
  540. end;
  541. cg.ungetregister(exprasmlist,addrreg);
  542. end;
  543. cg.ungetregister(exprasmlist,hregister);
  544. cg.ungetregister(exprasmlist,hregister2);
  545. end;
  546. end;
  547. {*****************************************************************************
  548. FLOAT GENERIC HANDLING
  549. *****************************************************************************}
  550. {
  551. These routines all call internal RTL routines, so if they are
  552. called here, they give an internal error
  553. }
  554. procedure tcginlinenode.second_pi;
  555. begin
  556. internalerror(20020718);
  557. end;
  558. procedure tcginlinenode.second_arctan_real;
  559. begin
  560. internalerror(20020718);
  561. end;
  562. procedure tcginlinenode.second_abs_real;
  563. begin
  564. internalerror(20020718);
  565. end;
  566. procedure tcginlinenode.second_sqr_real;
  567. begin
  568. internalerror(20020718);
  569. end;
  570. procedure tcginlinenode.second_sqrt_real;
  571. begin
  572. internalerror(20020718);
  573. end;
  574. procedure tcginlinenode.second_ln_real;
  575. begin
  576. internalerror(20020718);
  577. end;
  578. procedure tcginlinenode.second_cos_real;
  579. begin
  580. internalerror(20020718);
  581. end;
  582. procedure tcginlinenode.second_sin_real;
  583. begin
  584. internalerror(20020718);
  585. end;
  586. {*****************************************************************************
  587. ASSIGNED GENERIC HANDLING
  588. *****************************************************************************}
  589. procedure tcginlinenode.second_assigned;
  590. begin
  591. secondpass(tcallparanode(left).left);
  592. { force left to be an OS_ADDR, since in case of method procvars }
  593. { the size is 2*OS_ADDR (JM) }
  594. cg.a_cmp_const_loc_label(exprasmlist,OS_ADDR,OC_NE,0,tcallparanode(left).left.location,truelabel);
  595. cg.a_jmp_always(exprasmlist,falselabel);
  596. location_reset(location,LOC_JUMP,OS_NO);
  597. end;
  598. begin
  599. cinlinenode:=tcginlinenode;
  600. end.
  601. {
  602. $Log$
  603. Revision 1.51 2004-01-31 17:45:17 peter
  604. * Change several $ifdef i386 to x86
  605. * Change several OS_32 to OS_INT/OS_ADDR
  606. Revision 1.50 2003/12/31 20:47:02 jonas
  607. * properly fixed assigned() mess (by handling it separately in ncginl)
  608. -> all assigned()-related tests in the test suite work again
  609. Revision 1.49 2003/12/06 01:15:22 florian
  610. * reverted Peter's alloctemp patch; hopefully properly
  611. Revision 1.48 2003/12/03 23:13:20 peter
  612. * delayed paraloc allocation, a_param_*() gets extra parameter
  613. if it needs to allocate temp or real paralocation
  614. * optimized/simplified int-real loading
  615. Revision 1.47 2003/10/10 17:48:13 peter
  616. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  617. * tregisteralloctor renamed to trgobj
  618. * removed rgobj from a lot of units
  619. * moved location_* and reference_* to cgobj
  620. * first things for mmx register allocation
  621. Revision 1.46 2003/10/09 21:31:37 daniel
  622. * Register allocator splitted, ans abstract now
  623. Revision 1.45 2003/10/08 19:19:45 peter
  624. * set_varstate cleanup
  625. Revision 1.44 2003/10/05 21:21:52 peter
  626. * c style array of const generates callparanodes
  627. * varargs paraloc fixes
  628. Revision 1.43 2003/10/01 20:34:48 peter
  629. * procinfo unit contains tprocinfo
  630. * cginfo renamed to cgbase
  631. * moved cgmessage to verbose
  632. * fixed ppc and sparc compiles
  633. Revision 1.42 2003/09/10 08:31:47 marco
  634. * Patch from Peter for paraloc
  635. Revision 1.41 2003/09/07 22:09:35 peter
  636. * preparations for different default calling conventions
  637. * various RA fixes
  638. Revision 1.40 2003/09/03 15:55:00 peter
  639. * NEWRA branch merged
  640. Revision 1.39.2.1 2003/08/29 17:28:59 peter
  641. * next batch of updates
  642. Revision 1.39 2003/07/23 11:01:14 jonas
  643. * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
  644. pairs round calls to helpers
  645. Revision 1.38 2003/07/05 20:07:24 jonas
  646. * fixed range check errors
  647. Revision 1.37 2003/06/13 21:19:30 peter
  648. * current_procdef removed, use current_procinfo.procdef instead
  649. Revision 1.36 2003/06/07 18:57:04 jonas
  650. + added freeintparaloc
  651. * ppc get/freeintparaloc now check whether the parameter regs are
  652. properly allocated/deallocated (and get an extra list para)
  653. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  654. * fixed lot of missing pi_do_call's
  655. Revision 1.35 2003/06/03 21:11:09 peter
  656. * cg.a_load_* get a from and to size specifier
  657. * makeregsize only accepts newregister
  658. * i386 uses generic tcgnotnode,tcgunaryminus
  659. Revision 1.34 2003/06/01 21:38:06 peter
  660. * getregisterfpu size parameter added
  661. * op_const_reg size parameter added
  662. * sparc updates
  663. Revision 1.33 2003/05/24 17:15:59 jonas
  664. - removed bogus location_copy for include/exclude
  665. Revision 1.32 2003/05/23 21:10:38 jonas
  666. * fixed exclude
  667. Revision 1.31 2003/05/23 14:27:35 peter
  668. * remove some unit dependencies
  669. * current_procinfo changes to store more info
  670. Revision 1.30 2003/05/09 17:47:02 peter
  671. * self moved to hidden parameter
  672. * removed hdisposen,hnewn,selfn
  673. Revision 1.29 2003/05/01 12:27:08 jonas
  674. * fixed include/exclude for normalsets
  675. Revision 1.28 2003/04/27 11:21:33 peter
  676. * aktprocdef renamed to current_procinfo.procdef
  677. * procinfo renamed to current_procinfo
  678. * procinfo will now be stored in current_module so it can be
  679. cleaned up properly
  680. * gen_main_procsym changed to create_main_proc and release_main_proc
  681. to also generate a tprocinfo structure
  682. * fixed unit implicit initfinal
  683. Revision 1.27 2003/04/25 08:25:26 daniel
  684. * Ifdefs around a lot of calls to cleartempgen
  685. * Fixed registers that are allocated but not freed in several nodes
  686. * Tweak to register allocator to cause less spills
  687. * 8-bit registers now interfere with esi,edi and ebp
  688. Compiler can now compile rtl successfully when using new register
  689. allocator
  690. Revision 1.26 2003/04/24 22:29:57 florian
  691. * fixed a lot of PowerPC related stuff
  692. Revision 1.25 2003/04/22 23:50:22 peter
  693. * firstpass uses expectloc
  694. * checks if there are differences between the expectloc and
  695. location.loc from secondpass in EXTDEBUG
  696. Revision 1.24 2003/04/22 10:09:35 daniel
  697. + Implemented the actual register allocator
  698. + Scratch registers unavailable when new register allocator used
  699. + maybe_save/maybe_restore unavailable when new register allocator used
  700. Revision 1.23 2003/04/06 21:11:23 olle
  701. * changed newasmsymbol to newasmsymboldata for data symbols
  702. Revision 1.22 2003/03/28 19:16:56 peter
  703. * generic constructor working for i386
  704. * remove fixed self register
  705. * esi added as address register for i386
  706. Revision 1.21 2003/02/19 22:00:14 daniel
  707. * Code generator converted to new register notation
  708. - Horribily outdated todo.txt removed
  709. Revision 1.20 2003/01/31 22:47:27 peter
  710. * fix previous typeof change
  711. Revision 1.19 2003/01/30 21:46:57 peter
  712. * self fixes for static methods (merged)
  713. Revision 1.18 2003/01/08 18:43:56 daniel
  714. * Tregister changed into a record
  715. Revision 1.17 2002/11/25 17:43:18 peter
  716. * splitted defbase in defutil,symutil,defcmp
  717. * merged isconvertable and is_equal into compare_defs(_ext)
  718. * made operator search faster by walking the list only once
  719. Revision 1.16 2002/10/05 12:43:25 carl
  720. * fixes for Delphi 6 compilation
  721. (warning : Some features do not work under Delphi)
  722. Revision 1.15 2002/09/30 07:00:46 florian
  723. * fixes to common code to get the alpha compiler compiled applied
  724. Revision 1.14 2002/09/17 18:54:02 jonas
  725. * a_load_reg_reg() now has two size parameters: source and dest. This
  726. allows some optimizations on architectures that don't encode the
  727. register size in the register name.
  728. Revision 1.13 2002/08/13 18:01:52 carl
  729. * rename swatoperands to swapoperands
  730. + m68k first compilable version (still needs a lot of testing):
  731. assembler generator, system information , inline
  732. assembler reader.
  733. Revision 1.12 2002/08/11 14:32:26 peter
  734. * renamed current_library to objectlibrary
  735. Revision 1.11 2002/08/11 13:24:11 peter
  736. * saving of asmsymbols in ppu supported
  737. * asmsymbollist global is removed and moved into a new class
  738. tasmlibrarydata that will hold the info of a .a file which
  739. corresponds with a single module. Added librarydata to tmodule
  740. to keep the library info stored for the module. In the future the
  741. objectfiles will also be stored to the tasmlibrarydata class
  742. * all getlabel/newasmsymbol and friends are moved to the new class
  743. Revision 1.10 2002/08/05 18:27:48 carl
  744. + more more more documentation
  745. + first version include/exclude (can't test though, not enough scratch for i386 :()...
  746. Revision 1.9 2002/08/04 19:06:41 carl
  747. + added generic exception support (still does not work!)
  748. + more documentation
  749. Revision 1.8 2002/07/31 07:54:59 jonas
  750. * re-enabled second_assigned()
  751. Revision 1.7 2002/07/30 20:50:43 florian
  752. * the code generator knows now if parameters are in registers
  753. Revision 1.6 2002/07/29 21:23:42 florian
  754. * more fixes for the ppc
  755. + wrappers for the tcnvnode.first_* stuff introduced
  756. Revision 1.5 2002/07/28 20:45:22 florian
  757. + added direct assembler reader for PowerPC
  758. Revision 1.4 2002/07/26 09:45:20 florian
  759. * fixed a mistake in yesterday's commit, forgot to commit it
  760. Revision 1.3 2002/07/25 22:58:30 florian
  761. no message
  762. Revision 1.2 2002/07/25 17:55:41 carl
  763. + First working revision
  764. Revision 1.1 2002/07/24 04:07:49 carl
  765. + first revision (incomplete)
  766. }