ncgadd.pas 29 KB

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