n386con.pas 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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,
  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.16 2002-05-18 13:34:25 peter
  72. * readded missing revisions
  73. Revision 1.15 2002/05/16 19:46:51 carl
  74. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  75. + try to fix temp allocation (still in ifdef)
  76. + generic constructor calls
  77. + start of tassembler / tmodulebase class cleanup
  78. Revision 1.13 2002/04/02 17:11:36 peter
  79. * tlocation,treference update
  80. * LOC_CONSTANT added for better constant handling
  81. * secondadd splitted in multiple routines
  82. * location_force_reg added for loading a location to a register
  83. of a specified size
  84. * secondassignment parses now first the right and then the left node
  85. (this is compatible with Kylix). This saves a lot of push/pop especially
  86. with string operations
  87. * adapted some routines to use the new cg methods
  88. Revision 1.12 2002/03/31 20:26:38 jonas
  89. + a_loadfpu_* and a_loadmm_* methods in tcg
  90. * register allocation is now handled by a class and is mostly processor
  91. independent (+rgobj.pas and i386/rgcpu.pas)
  92. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  93. * some small improvements and fixes to the optimizer
  94. * some register allocation fixes
  95. * some fpuvaroffset fixes in the unary minus node
  96. * push/popusedregisters is now called rg.save/restoreusedregisters and
  97. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  98. also better optimizable)
  99. * fixed and optimized register saving/restoring for new/dispose nodes
  100. * LOC_FPU locations now also require their "register" field to be set to
  101. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  102. - list field removed of the tnode class because it's not used currently
  103. and can cause hard-to-find bugs
  104. }