ncgadd.pas 29 KB

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