n386con.pas 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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,
  31. cpubase,
  32. cga,rgobj,rgcpu;
  33. {*****************************************************************************
  34. TI386REALCONSTNODE
  35. *****************************************************************************}
  36. function ti386realconstnode.pass_1 : tnode;
  37. begin
  38. result:=nil;
  39. if (value_real=1.0) or (value_real=0.0) then
  40. begin
  41. location.loc:=LOC_FPUREGISTER;
  42. registersfpu:=1;
  43. end
  44. else
  45. location.loc:=LOC_CREFERENCE;
  46. end;
  47. procedure ti386realconstnode.pass_2;
  48. begin
  49. if (value_real=1.0) then
  50. begin
  51. emit_none(A_FLD1,S_NO);
  52. location.loc:=LOC_FPUREGISTER;
  53. location.register:=R_ST;
  54. inc(trgcpu(rg).fpuvaroffset);
  55. end
  56. else if (value_real=0.0) then
  57. begin
  58. emit_none(A_FLDZ,S_NO);
  59. location.loc:=LOC_FPUREGISTER;
  60. location.register:=R_ST;
  61. inc(trgcpu(rg).fpuvaroffset);
  62. end
  63. else
  64. inherited pass_2;
  65. end;
  66. begin
  67. crealconstnode:=ti386realconstnode;
  68. end.
  69. {
  70. $Log$
  71. Revision 1.15 2002-05-16 19:46:51 carl
  72. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  73. + try to fix temp allocation (still in ifdef)
  74. + generic constructor calls
  75. + start of tassembler / tmodulebase class cleanup
  76. Revision 1.13 2002/04/02 17:11:36 peter
  77. * tlocation,treference update
  78. * LOC_CONSTANT added for better constant handling
  79. * secondadd splitted in multiple routines
  80. * location_force_reg added for loading a location to a register
  81. of a specified size
  82. * secondassignment parses now first the right and then the left node
  83. (this is compatible with Kylix). This saves a lot of push/pop especially
  84. with string operations
  85. * adapted some routines to use the new cg methods
  86. Revision 1.12 2002/03/31 20:26:38 jonas
  87. + a_loadfpu_* and a_loadmm_* methods in tcg
  88. * register allocation is now handled by a class and is mostly processor
  89. independent (+rgobj.pas and i386/rgcpu.pas)
  90. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  91. * some small improvements and fixes to the optimizer
  92. * some register allocation fixes
  93. * some fpuvaroffset fixes in the unary minus node
  94. * push/popusedregisters is now called rg.save/restoreusedregisters and
  95. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  96. also better optimizable)
  97. * fixed and optimized register saving/restoring for new/dispose nodes
  98. * LOC_FPU locations now also require their "register" field to be set to
  99. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  100. - list field removed of the tnode class because it's not used currently
  101. and can cause hard-to-find bugs
  102. Revision 1.10 2001/08/26 13:36:57 florian
  103. * some cg reorganisation
  104. * some PPC updates
  105. Revision 1.9 2001/07/08 21:00:18 peter
  106. * various widestring updates, it works now mostly without charset
  107. mapping supported
  108. Revision 1.8 2001/04/13 01:22:18 peter
  109. * symtable change to classes
  110. * range check generation and errors fixed, make cycle DEBUG=1 works
  111. * memory leaks fixed
  112. Revision 1.7 2001/04/02 21:20:37 peter
  113. * resulttype rewrite
  114. Revision 1.6 2000/12/25 00:07:32 peter
  115. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  116. tlinkedlist objects)
  117. Revision 1.5 2000/11/29 00:30:47 florian
  118. * unused units removed from uses clause
  119. * some changes for widestrings
  120. Revision 1.4 2000/11/20 15:31:38 jonas
  121. * longint typecast to assignment of constant to offset field
  122. Revision 1.3 2000/11/13 14:44:36 jonas
  123. * fixes so no more range errors with improved range checking code
  124. Revision 1.2 2000/10/31 22:02:56 peter
  125. * symtable splitted, no real code changes
  126. Revision 1.1 2000/10/15 09:33:31 peter
  127. * moved n386*.pas to i386/ cpu_target dir
  128. Revision 1.2 2000/10/14 10:14:48 peter
  129. * moehrendorf oct 2000 rewrite
  130. Revision 1.1 2000/09/28 20:48:52 florian
  131. *** empty log message ***
  132. }