n386con.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate i386 assembler for constants
  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 n386con;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,ncon,ncgcon;
  23. type
  24. ti386realconstnode = class(tcgrealconstnode)
  25. function pass_1 : tnode;override;
  26. procedure pass_2;override;
  27. end;
  28. implementation
  29. uses
  30. systems,globals,
  31. defutil,
  32. cpubase,
  33. cga,cgx86,cgobj,cgbase,cgutils;
  34. {*****************************************************************************
  35. TI386REALCONSTNODE
  36. *****************************************************************************}
  37. function ti386realconstnode.pass_1 : tnode;
  38. begin
  39. result:=nil;
  40. if is_number_float(value_real) and (value_real=1.0) or (value_real=0.0) then
  41. begin
  42. expectloc:=LOC_FPUREGISTER;
  43. registersfpu:=1;
  44. end
  45. else
  46. expectloc:=LOC_CREFERENCE;
  47. end;
  48. procedure ti386realconstnode.pass_2;
  49. begin
  50. if is_number_float(value_real) then
  51. begin
  52. if (value_real=1.0) then
  53. begin
  54. emit_none(A_FLD1,S_NO);
  55. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  56. location.register:=NR_ST;
  57. tcgx86(cg).inc_fpu_stack;
  58. end
  59. else if (value_real=0.0) then
  60. begin
  61. emit_none(A_FLDZ,S_NO);
  62. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  63. location.register:=NR_ST;
  64. tcgx86(cg).inc_fpu_stack;
  65. end
  66. else
  67. inherited pass_2;
  68. end
  69. else
  70. inherited pass_2;
  71. end;
  72. begin
  73. crealconstnode:=ti386realconstnode;
  74. end.
  75. {
  76. $Log$
  77. Revision 1.26 2004-10-31 21:45:03 peter
  78. * generic tlocation
  79. * move tlocation to cgutils
  80. Revision 1.25 2004/06/20 08:55:31 florian
  81. * logs truncated
  82. }