ncgadd.pas 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 by the FPC development team
  4. Code generation for add nodes (generic version)
  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 ncgadd;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,nadd,cpubase;
  23. type
  24. tcgaddnode = class(taddnode)
  25. { function pass_1: tnode; override;}
  26. procedure pass_2;override;
  27. protected
  28. { call secondpass for both left and right }
  29. procedure pass_left_right;
  30. { set the register of the result location }
  31. procedure set_result_location_reg;
  32. { load left and right nodes into registers }
  33. procedure force_reg_left_right(allow_swap,allow_constant:boolean);
  34. { free used registers, except result location }
  35. procedure release_reg_left_right;
  36. procedure second_opfloat;
  37. procedure second_opboolean;
  38. procedure second_opsmallset;
  39. procedure second_op64bit;
  40. procedure second_opordinal;
  41. procedure second_addfloat;virtual;abstract;
  42. procedure second_addboolean;virtual;
  43. procedure second_addsmallset;virtual;
  44. {$ifdef i386}
  45. procedure second_addmmxset;virtual;abstract;
  46. {$endif}
  47. procedure second_add64bit;virtual;
  48. procedure second_addordinal;virtual;
  49. procedure second_cmpfloat;virtual;abstract;
  50. procedure second_cmpboolean;virtual;
  51. procedure second_cmpsmallset;virtual;abstract;
  52. procedure second_cmp64bit;virtual;abstract;
  53. procedure second_cmpordinal;virtual;abstract;
  54. end;
  55. implementation
  56. uses
  57. globtype,systems,
  58. cutils,verbose,globals,
  59. symconst,symdef,paramgr,
  60. aasmbase,aasmtai,aasmcpu,defutil,htypechk,
  61. cgbase,cpuinfo,pass_1,pass_2,regvars,
  62. ncon,nset,ncgutil,tgobj,cgobj,
  63. {$ifdef cpu64bit}
  64. cg64f64
  65. {$else cpu64bit}
  66. cg64f32
  67. {$endif cpu64bit}
  68. ;
  69. {*****************************************************************************
  70. Helpers
  71. *****************************************************************************}
  72. procedure tcgaddnode.pass_left_right;
  73. var
  74. tmpreg : tregister;
  75. isjump,
  76. pushedfpu : boolean;
  77. otl,ofl : tasmlabel;
  78. begin
  79. { calculate the operator which is more difficult }
  80. firstcomplex(self);
  81. { in case of constant put it to the left }
  82. if (left.nodetype=ordconstn) then
  83. swapleftright;
  84. isjump:=(left.expectloc=LOC_JUMP);
  85. if isjump then
  86. begin
  87. otl:=truelabel;
  88. objectlibrary.getlabel(truelabel);
  89. ofl:=falselabel;
  90. objectlibrary.getlabel(falselabel);
  91. end;
  92. secondpass(left);
  93. if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
  94. location_force_reg(exprasmlist,left.location,def_cgsize(resulttype.def),false);
  95. if isjump then
  96. begin
  97. truelabel:=otl;
  98. falselabel:=ofl;
  99. end
  100. else
  101. internalerror(2003122901);
  102. { are too few registers free? }
  103. if left.location.loc=LOC_FPUREGISTER then
  104. pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
  105. else
  106. pushedfpu:=false;
  107. isjump:=(right.expectloc=LOC_JUMP);
  108. if isjump then
  109. begin
  110. otl:=truelabel;
  111. objectlibrary.getlabel(truelabel);
  112. ofl:=falselabel;
  113. objectlibrary.getlabel(falselabel);
  114. end;
  115. secondpass(right);
  116. if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
  117. location_force_reg(exprasmlist,right.location,def_cgsize(resulttype.def),false);
  118. if isjump then
  119. begin
  120. truelabel:=otl;
  121. falselabel:=ofl;
  122. end
  123. else
  124. internalerror(2003122902);
  125. if pushedfpu then
  126. begin
  127. tmpreg := cg.getfpuregister(exprasmlist,left.location.size);
  128. cg.a_loadfpu_loc_reg(exprasmlist,left.location,tmpreg);
  129. location_reset(left.location,LOC_FPUREGISTER,left.location.size);
  130. left.location.register := tmpreg;
  131. end;
  132. end;
  133. procedure tcgaddnode.set_result_location_reg;
  134. begin
  135. location_reset(location,LOC_REGISTER,def_cgsize(resulttype.def));
  136. if left.location.loc=LOC_REGISTER then
  137. begin
  138. if TCGSize2Size[left.location.size]<>TCGSize2Size[location.size] then
  139. internalerror(200307041);
  140. {$ifndef cpu64bit}
  141. if location.size in [OS_64,OS_S64] then
  142. begin
  143. location.registerlow := left.location.registerlow;
  144. location.registerhigh := left.location.registerhigh;
  145. end
  146. else
  147. {$endif}
  148. location.register := left.location.register;
  149. end
  150. else
  151. if right.location.loc=LOC_REGISTER then
  152. begin
  153. if TCGSize2Size[right.location.size]<>TCGSize2Size[location.size] then
  154. internalerror(200307042);
  155. {$ifndef cpu64bit}
  156. if location.size in [OS_64,OS_S64] then
  157. begin
  158. location.registerlow := right.location.registerlow;
  159. location.registerhigh := right.location.registerhigh;
  160. end
  161. else
  162. {$endif}
  163. location.register := right.location.register;
  164. end
  165. else
  166. begin
  167. {$ifndef cpu64bit}
  168. if location.size in [OS_64,OS_S64] then
  169. begin
  170. location.registerlow := cg.getintregister(exprasmlist,OS_INT);
  171. location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
  172. end
  173. else
  174. {$endif}
  175. location.register := cg.getintregister(exprasmlist,location.size);
  176. end;
  177. end;
  178. procedure tcgaddnode.force_reg_left_right(allow_swap,allow_constant:boolean);
  179. begin
  180. if (left.location.loc<>LOC_REGISTER) and
  181. not(
  182. allow_constant and
  183. (left.location.loc=LOC_CONSTANT)
  184. ) then
  185. location_force_reg(exprasmlist,left.location,left.location.size,false);
  186. if (right.location.loc<>LOC_REGISTER) and
  187. not(
  188. allow_constant and
  189. (right.location.loc=LOC_CONSTANT) and
  190. (left.location.loc<>LOC_CONSTANT)
  191. ) then
  192. location_force_reg(exprasmlist,right.location,right.location.size,false);
  193. { Left is always a register, right can be register or constant }
  194. if left.location.loc<>LOC_REGISTER then
  195. begin
  196. { when it is not allowed to swap we have a constant on
  197. left, that will give problems }
  198. if not allow_swap then
  199. internalerror(200307041);
  200. swapleftright;
  201. end;
  202. end;
  203. procedure tcgaddnode.release_reg_left_right;
  204. begin
  205. if (right.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
  206. not(
  207. (location.loc = right.location.loc) and
  208. (location.register=right.location.register)
  209. ) then
  210. location_release(exprasmlist,right.location);
  211. if (left.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
  212. not(
  213. (location.loc = left.location.loc) and
  214. (location.register=left.location.register)
  215. ) then
  216. location_release(exprasmlist,left.location);
  217. end;
  218. {*****************************************************************************
  219. Smallsets
  220. *****************************************************************************}
  221. procedure tcgaddnode.second_opsmallset;
  222. begin
  223. { when a setdef is passed, it has to be a smallset }
  224. if ((left.resulttype.def.deftype=setdef) and
  225. (tsetdef(left.resulttype.def).settype<>smallset)) or
  226. ((right.resulttype.def.deftype=setdef) and
  227. (tsetdef(right.resulttype.def).settype<>smallset)) then
  228. internalerror(200203301);
  229. if nodetype in [equaln,unequaln,gtn,gten,lten,ltn] then
  230. second_cmpsmallset
  231. else
  232. second_addsmallset;
  233. end;
  234. procedure tcgaddnode.second_addsmallset;
  235. var
  236. cgop : TOpCg;
  237. tmpreg : tregister;
  238. opdone : boolean;
  239. begin
  240. opdone := false;
  241. pass_left_right;
  242. force_reg_left_right(true,true);
  243. { setelementn is a special case, it must be on right.
  244. We need an extra check if left is a register because the
  245. default case can skip the register loading when the
  246. setelementn is in a register (PFV) }
  247. if (nf_swaped in flags) and
  248. (left.nodetype=setelementn) then
  249. swapleftright;
  250. if (right.nodetype=setelementn) and
  251. (left.location.loc<>LOC_REGISTER) then
  252. location_force_reg(exprasmlist,left.location,left.location.size,false);
  253. set_result_location_reg;
  254. case nodetype of
  255. addn :
  256. begin
  257. { are we adding set elements ? }
  258. if right.nodetype=setelementn then
  259. begin
  260. { no range support for smallsets! }
  261. if assigned(tsetelementnode(right).right) then
  262. internalerror(43244);
  263. if (right.location.loc = LOC_CONSTANT) then
  264. cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
  265. aword(1 shl aword(right.location.value)),
  266. left.location.register,location.register)
  267. else
  268. begin
  269. tmpreg := cg.getintregister(exprasmlist,location.size);
  270. cg.a_load_const_reg(exprasmlist,location.size,1,tmpreg);
  271. cg.a_op_reg_reg(exprasmlist,OP_SHL,location.size,
  272. right.location.register,tmpreg);
  273. if left.location.loc <> LOC_CONSTANT then
  274. cg.a_op_reg_reg_reg(exprasmlist,OP_OR,location.size,tmpreg,
  275. left.location.register,location.register)
  276. else
  277. cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
  278. aword(left.location.value),tmpreg,location.register);
  279. cg.ungetregister(exprasmlist,tmpreg);
  280. end;
  281. opdone := true;
  282. end
  283. else
  284. cgop := OP_OR;
  285. end;
  286. symdifn :
  287. cgop:=OP_XOR;
  288. muln :
  289. cgop:=OP_AND;
  290. subn :
  291. begin
  292. cgop:=OP_AND;
  293. if (not(nf_swaped in flags)) then
  294. if (right.location.loc=LOC_CONSTANT) then
  295. right.location.value := not(right.location.value)
  296. else
  297. opdone := true
  298. else if (left.location.loc=LOC_CONSTANT) then
  299. left.location.value := not(left.location.value)
  300. else
  301. begin
  302. swapleftright;
  303. opdone := true;
  304. end;
  305. if opdone then
  306. begin
  307. if left.location.loc = LOC_CONSTANT then
  308. begin
  309. tmpreg := cg.getintregister(exprasmlist,location.size);
  310. cg.a_load_const_reg(exprasmlist,location.size,
  311. aword(left.location.value),tmpreg);
  312. cg.a_op_reg_reg(exprasmlist,OP_NOT,location.size,right.location.register,right.location.register);
  313. cg.a_op_reg_reg(exprasmlist,OP_AND,location.size,right.location.register,tmpreg);
  314. cg.a_load_reg_reg(exprasmlist,OS_INT,location.size,tmpreg,location.register);
  315. cg.ungetregister(exprasmlist,tmpreg);
  316. end
  317. else
  318. begin
  319. cg.a_op_reg_reg(exprasmlist,OP_NOT,right.location.size,right.location.register,right.location.register);
  320. cg.a_op_reg_reg(exprasmlist,OP_AND,left.location.size,right.location.register,left.location.register);
  321. cg.a_load_reg_reg(exprasmlist,left.location.size,location.size,left.location.register,location.register);
  322. end;
  323. end;
  324. end;
  325. else
  326. internalerror(2002072701);
  327. end;
  328. if not opdone then
  329. begin
  330. // these are all commutative operations
  331. if (left.location.loc = LOC_CONSTANT) then
  332. swapleftright;
  333. if (right.location.loc = LOC_CONSTANT) then
  334. cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
  335. aword(right.location.value),left.location.register,
  336. location.register)
  337. else
  338. cg.a_op_reg_reg_reg(exprasmlist,cgop,location.size,
  339. right.location.register,left.location.register,
  340. location.register);
  341. end;
  342. release_reg_left_right;
  343. end;
  344. {*****************************************************************************
  345. Boolean
  346. *****************************************************************************}
  347. procedure tcgaddnode.second_opboolean;
  348. begin
  349. if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
  350. second_cmpboolean
  351. else
  352. second_addboolean;
  353. end;
  354. procedure tcgaddnode.second_addboolean;
  355. var
  356. cgop : TOpCg;
  357. otl,ofl : tasmlabel;
  358. begin
  359. { And,Or will only evaluate from left to right only the
  360. needed nodes unless full boolean evaluation is enabled }
  361. if (nodetype in [orn,andn]) and
  362. not(cs_full_boolean_eval in aktlocalswitches) then
  363. begin
  364. location_reset(location,LOC_JUMP,OS_NO);
  365. case nodetype of
  366. andn :
  367. begin
  368. otl:=truelabel;
  369. objectlibrary.getlabel(truelabel);
  370. secondpass(left);
  371. maketojumpbool(exprasmlist,left,lr_load_regvars);
  372. cg.a_label(exprasmlist,truelabel);
  373. truelabel:=otl;
  374. end;
  375. orn :
  376. begin
  377. ofl:=falselabel;
  378. objectlibrary.getlabel(falselabel);
  379. secondpass(left);
  380. maketojumpbool(exprasmlist,left,lr_load_regvars);
  381. cg.a_label(exprasmlist,falselabel);
  382. falselabel:=ofl;
  383. end;
  384. else
  385. internalerror(200307044);
  386. end;
  387. secondpass(right);
  388. maketojumpbool(exprasmlist,right,lr_load_regvars);
  389. end
  390. else
  391. begin
  392. pass_left_right;
  393. force_reg_left_right(false,true);
  394. set_result_location_reg;
  395. case nodetype of
  396. xorn :
  397. cgop:=OP_XOR;
  398. orn :
  399. cgop:=OP_OR;
  400. andn :
  401. cgop:=OP_AND;
  402. else
  403. internalerror(200203247);
  404. end;
  405. if right.location.loc <> LOC_CONSTANT then
  406. cg.a_op_reg_reg_reg(exprasmlist,cgop,location.size,
  407. left.location.register,right.location.register,
  408. location.register)
  409. else
  410. cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
  411. aword(right.location.value),left.location.register,
  412. location.register);
  413. end;
  414. release_reg_left_right;
  415. end;
  416. {*****************************************************************************
  417. 64-bit
  418. *****************************************************************************}
  419. procedure tcgaddnode.second_op64bit;
  420. begin
  421. if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
  422. second_cmp64bit
  423. else
  424. second_add64bit;
  425. end;
  426. procedure tcgaddnode.second_add64bit;
  427. var
  428. op : TOpCG;
  429. checkoverflow : boolean;
  430. begin
  431. pass_left_right;
  432. force_reg_left_right(false,(cs_check_overflow in aktlocalswitches) and
  433. (nodetype in [addn,subn]));
  434. set_result_location_reg;
  435. { assume no overflow checking is required }
  436. checkoverflow := false;
  437. case nodetype of
  438. addn :
  439. begin
  440. op:=OP_ADD;
  441. checkoverflow := true;
  442. end;
  443. subn :
  444. begin
  445. op:=OP_SUB;
  446. checkoverflow := true;
  447. end;
  448. xorn:
  449. op:=OP_XOR;
  450. orn:
  451. op:=OP_OR;
  452. andn:
  453. op:=OP_AND;
  454. muln:
  455. begin
  456. { should be handled in pass_1 (JM) }
  457. internalerror(200109051);
  458. end;
  459. else
  460. internalerror(2002072705);
  461. end;
  462. case nodetype of
  463. xorn,orn,andn,addn:
  464. begin
  465. if (right.location.loc = LOC_CONSTANT) then
  466. cg64.a_op64_const_reg_reg(exprasmlist,op,right.location.valueqword,
  467. left.location.register64,location.register64)
  468. else
  469. cg64.a_op64_reg_reg_reg(exprasmlist,op,right.location.register64,
  470. left.location.register64,location.register64);
  471. end;
  472. subn:
  473. begin
  474. if (nf_swaped in flags) then
  475. swapleftright;
  476. if left.location.loc <> LOC_CONSTANT then
  477. begin
  478. if right.location.loc <> LOC_CONSTANT then
  479. // reg64 - reg64
  480. cg64.a_op64_reg_reg_reg(exprasmlist,OP_SUB,
  481. right.location.register64,left.location.register64,
  482. location.register64)
  483. else
  484. // reg64 - const64
  485. cg64.a_op64_const_reg_reg(exprasmlist,OP_SUB,
  486. right.location.valueqword,left.location.register64,
  487. location.register64)
  488. end
  489. else
  490. begin
  491. // const64 - reg64
  492. location_force_reg(exprasmlist,left.location,left.location.size,true);
  493. cg64.a_op64_reg_reg_reg(exprasmlist,OP_SUB,
  494. right.location.register64,left.location.register64,
  495. location.register64);
  496. end;
  497. end;
  498. else
  499. internalerror(2002072803);
  500. end;
  501. { emit overflow check if enabled }
  502. if checkoverflow then
  503. cg.g_overflowcheck(exprasmlist,Location,ResultType.Def);
  504. release_reg_left_right;
  505. end;
  506. {*****************************************************************************
  507. Floats
  508. *****************************************************************************}
  509. procedure tcgaddnode.second_opfloat;
  510. begin
  511. if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
  512. second_cmpfloat
  513. else
  514. second_addfloat;
  515. end;
  516. {*****************************************************************************
  517. Ordinals
  518. *****************************************************************************}
  519. procedure tcgaddnode.second_opordinal;
  520. begin
  521. if (nodetype in [ltn,lten,gtn,gten,equaln,unequaln]) then
  522. second_cmpordinal
  523. else
  524. second_addordinal;
  525. end;
  526. procedure tcgaddnode.second_addordinal;
  527. var
  528. unsigned,
  529. checkoverflow : boolean;
  530. cgop : topcg;
  531. tmpreg : tregister;
  532. begin
  533. pass_left_right;
  534. force_reg_left_right(false,(cs_check_overflow in aktlocalswitches) and
  535. (nodetype in [addn,subn,muln]));
  536. set_result_location_reg;
  537. { determine if the comparison will be unsigned }
  538. unsigned:=not(is_signed(left.resulttype.def)) or
  539. not(is_signed(right.resulttype.def));
  540. { assume no overflow checking is require }
  541. checkoverflow := false;
  542. case nodetype of
  543. addn:
  544. begin
  545. cgop := OP_ADD;
  546. checkoverflow := true;
  547. end;
  548. xorn :
  549. begin
  550. cgop := OP_XOR;
  551. end;
  552. orn :
  553. begin
  554. cgop := OP_OR;
  555. end;
  556. andn:
  557. begin
  558. cgop := OP_AND;
  559. end;
  560. muln:
  561. begin
  562. checkoverflow := true;
  563. if unsigned then
  564. cgop := OP_MUL
  565. else
  566. cgop := OP_IMUL;
  567. end;
  568. subn :
  569. begin
  570. checkoverflow := true;
  571. cgop := OP_SUB;
  572. end;
  573. end;
  574. if nodetype <> subn then
  575. begin
  576. if (right.location.loc <> LOC_CONSTANT) then
  577. cg.a_op_reg_reg_reg(exprasmlist,cgop,location.size,
  578. left.location.register,right.location.register,
  579. location.register)
  580. else
  581. cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
  582. aword(right.location.value),left.location.register,
  583. location.register);
  584. end
  585. else { subtract is a special case since its not commutative }
  586. begin
  587. if (nf_swaped in flags) then
  588. swapleftright;
  589. if left.location.loc <> LOC_CONSTANT then
  590. begin
  591. if right.location.loc <> LOC_CONSTANT then
  592. cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,location.size,
  593. right.location.register,left.location.register,
  594. location.register)
  595. else
  596. cg.a_op_const_reg_reg(exprasmlist,OP_SUB,location.size,
  597. aword(right.location.value),left.location.register,
  598. location.register);
  599. end
  600. else
  601. begin
  602. tmpreg := cg.getintregister(exprasmlist,location.size);
  603. cg.a_load_const_reg(exprasmlist,location.size,
  604. aword(left.location.value),tmpreg);
  605. cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,location.size,
  606. right.location.register,tmpreg,location.register);
  607. cg.ungetregister(exprasmlist,tmpreg);
  608. end;
  609. end;
  610. { emit overflow check if required }
  611. if checkoverflow then
  612. cg.g_overflowcheck(exprasmlist,Location,ResultType.Def);
  613. release_reg_left_right;
  614. end;
  615. procedure tcgaddnode.second_cmpboolean;
  616. begin
  617. second_cmpordinal;
  618. end;
  619. {*****************************************************************************
  620. pass_2
  621. *****************************************************************************}
  622. procedure tcgaddnode.pass_2;
  623. begin
  624. case left.resulttype.def.deftype of
  625. orddef :
  626. begin
  627. { handling boolean expressions }
  628. if is_boolean(left.resulttype.def) and
  629. is_boolean(right.resulttype.def) then
  630. second_opboolean
  631. { 64bit operations }
  632. else if is_64bit(left.resulttype.def) then
  633. second_op64bit
  634. else
  635. second_opordinal;
  636. end;
  637. stringdef :
  638. begin
  639. { this should already be handled in pass1 }
  640. internalerror(2002072402);
  641. end;
  642. setdef :
  643. begin
  644. {Normalsets are already handled in pass1 if mmx
  645. should not be used.}
  646. if (tsetdef(left.resulttype.def).settype<>smallset) then
  647. begin
  648. {$ifdef SUPPORT_MMX}
  649. {$ifdef i386}
  650. if cs_mmx in aktlocalswitches then
  651. second_opmmxset
  652. else
  653. {$endif SUPPORT_MMX}
  654. {$endif}
  655. internalerror(200109041);
  656. end
  657. else
  658. second_opsmallset;
  659. end;
  660. arraydef :
  661. begin
  662. {$ifdef SUPPORT_MMX}
  663. if is_mmx_able_array(left.resulttype.def) then
  664. second_opmmx;
  665. {$endif SUPPORT_MMX}
  666. { only mmx arrays are possible }
  667. internalerror(200306016);
  668. end;
  669. floatdef :
  670. second_opfloat;
  671. else
  672. second_opordinal;
  673. end;
  674. end;
  675. begin
  676. caddnode:=tcgaddnode;
  677. end.
  678. {
  679. $Log$
  680. Revision 1.25 2003-12-29 11:37:52 jonas
  681. * hopefully fixed bug tb0454 (merged from nppcadd)
  682. Revision 1.24 2003/12/23 14:38:07 florian
  683. + second_floataddsse implemented
  684. Revision 1.23 2003/12/21 11:28:41 daniel
  685. * Some work to allow mmx instructions to be used for 32 byte sets
  686. Revision 1.22 2003/10/17 01:22:08 florian
  687. * compilation of the powerpc compiler fixed
  688. Revision 1.21 2003/10/10 17:48:13 peter
  689. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  690. * tregisteralloctor renamed to trgobj
  691. * removed rgobj from a lot of units
  692. * moved location_* and reference_* to cgobj
  693. * first things for mmx register allocation
  694. Revision 1.20 2003/10/01 20:34:48 peter
  695. * procinfo unit contains tprocinfo
  696. * cginfo renamed to cgbase
  697. * moved cgmessage to verbose
  698. * fixed ppc and sparc compiles
  699. Revision 1.19 2003/09/14 21:57:08 jonas
  700. * fixed release_reg_left_right for fpu registers
  701. Revision 1.18 2003/09/14 21:34:16 peter
  702. * fix setelementn support
  703. * fix loading of flags
  704. Revision 1.17 2003/09/03 15:55:00 peter
  705. * NEWRA branch merged
  706. Revision 1.16 2003/09/03 11:18:36 florian
  707. * fixed arm concatcopy
  708. + arm support in the common compiler sources added
  709. * moved some generic cg code around
  710. + tfputype added
  711. * ...
  712. Revision 1.15.2.2 2003/09/01 21:02:55 peter
  713. * sparc updates for new tregister
  714. Revision 1.15.2.1 2003/08/27 20:23:55 peter
  715. * remove old ra code
  716. Revision 1.15 2003/07/08 21:24:59 peter
  717. * sparc fixes
  718. Revision 1.14 2003/07/06 17:44:12 peter
  719. * cleanup and first sparc implementation
  720. Revision 1.13 2003/06/12 16:43:07 peter
  721. * newra compiles for sparc
  722. Revision 1.12 2003/06/10 20:46:17 mazen
  723. * fixing a general compile problem related to
  724. cg.g_overflowcheck declaration that has
  725. changed
  726. Revision 1.11 2003/06/01 21:38:06 peter
  727. * getregisterfpu size parameter added
  728. * op_const_reg size parameter added
  729. * sparc updates
  730. Revision 1.10 2003/05/23 14:27:35 peter
  731. * remove some unit dependencies
  732. * current_procinfo changes to store more info
  733. Revision 1.9 2003/04/30 22:15:59 florian
  734. * some 64 bit adaptions in ncgadd
  735. * x86-64 now uses ncgadd
  736. * tparamanager.ret_in_acc doesn't return true anymore for a void-def
  737. Revision 1.8 2003/04/23 20:16:04 peter
  738. + added currency support based on int64
  739. + is_64bit for use in cg units instead of is_64bitint
  740. * removed cgmessage from n386add, replace with internalerrors
  741. Revision 1.7 2003/04/22 23:50:22 peter
  742. * firstpass uses expectloc
  743. * checks if there are differences between the expectloc and
  744. location.loc from secondpass in EXTDEBUG
  745. Revision 1.6 2003/02/19 22:00:14 daniel
  746. * Code generator converted to new register notation
  747. - Horribily outdated todo.txt removed
  748. Revision 1.5 2003/02/02 19:25:54 carl
  749. * Several bugfixes for m68k target (register alloc., opcode emission)
  750. + VIS target
  751. + Generic add more complete (still not verified)
  752. Revision 1.4 2003/01/08 18:43:56 daniel
  753. * Tregister changed into a record
  754. Revision 1.3 2002/12/14 15:02:03 carl
  755. * maxoperands -> max_operands (for portability in rautils.pas)
  756. * fix some range-check errors with loadconst
  757. + add ncgadd unit to m68k
  758. * some bugfix of a_param_reg with LOC_CREFERENCE
  759. Revision 1.2 2002/12/08 15:02:17 carl
  760. + more fixes
  761. Revision 1.1 2002/12/07 19:51:35 carl
  762. + first version (uncompilable!)
  763. }