nx86add.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 by Florian Klaempfl
  4. Common code generation for add nodes on the i386 and x86
  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. {
  19. Common code generation for add nodes on the i386 and x86
  20. }
  21. unit nx86add;
  22. {$i fpcdefs.inc}
  23. interface
  24. uses
  25. node,nadd,ncgadd,cpubase;
  26. type
  27. tx86addnode = class(tcgaddnode)
  28. procedure second_floataddsse;
  29. end;
  30. implementation
  31. uses
  32. verbose,
  33. aasmtai,
  34. cgbase,cgobj,
  35. ncgutil,
  36. defutil;
  37. procedure tx86addnode.second_floataddsse;
  38. var
  39. op : topcg;
  40. begin
  41. pass_left_right;
  42. if (nf_swaped in flags) then
  43. swapleftright;
  44. case nodetype of
  45. addn :
  46. op:=OP_ADD;
  47. muln :
  48. op:=OP_MUL;
  49. subn :
  50. op:=OP_SUB;
  51. slashn :
  52. op:=OP_DIV;
  53. else
  54. internalerror(200312231);
  55. end;
  56. location_reset(location,LOC_MMREGISTER,def_cgsize(resulttype.def));
  57. { we can use only right as left operand if the operation is commutative }
  58. if (right.location.loc=LOC_MMREGISTER) and (op in [OP_ADD,OP_MUL]) then
  59. begin
  60. location.register:=right.location.register;
  61. cg.a_opmm_loc_reg(exprasmlist,op,location.size,left.location,location.register,mms_movescalar);
  62. location_release(exprasmlist,left.location);
  63. end
  64. else
  65. begin
  66. location_force_mmregscalar(exprasmlist,left.location,false);
  67. location.register:=left.location.register;
  68. cg.a_opmm_loc_reg(exprasmlist,op,location.size,right.location,location.register,mms_movescalar);
  69. location_release(exprasmlist,right.location);
  70. end;
  71. end;
  72. end.
  73. {
  74. $Log$
  75. Revision 1.2 2003-12-23 14:38:07 florian
  76. + second_floataddsse implemented
  77. Revision 1.1 2003/10/13 01:58:04 florian
  78. * some ideas for mm support implemented
  79. }