ncpuinln.pas 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. {******************************************************************************
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. *****************************************************************************}
  16. unit nCpuInln;
  17. {Generate SPARC inline nodes}
  18. {$INCLUDE fpcdefs.inc}
  19. interface
  20. uses
  21. node,ninl,ncginl;
  22. type
  23. tSparcInlineNode = class(tcgInlineNode)
  24. {first pass override, so that the code generator will actually generate
  25. these nodes.}
  26. function first_abs_real: tnode; override;
  27. function first_sqr_real: tnode; override;
  28. function first_sqrt_real: tnode; override;
  29. procedure second_abs_real; override;
  30. procedure second_sqr_real; override;
  31. procedure second_sqrt_real; override;
  32. private
  33. procedure load_fpu_location;
  34. end;
  35. implementation
  36. uses
  37. globtype,systems,
  38. cutils,verbose,globals,fmodule,
  39. symconst,symdef,
  40. aasmbase,aasmtai,aasmcpu,
  41. cginfo,cgbase,pass_1,pass_2,
  42. cpubase,paramgr,
  43. nbas,ncon,ncal,ncnv,nld,
  44. tgobj,ncgutil,cgobj,cg64f32,rgobj,rgcpu;
  45. {*****************************************************************************
  46. TSparcInlineNode
  47. *****************************************************************************}
  48. function tSparcInlineNode.first_abs_real : tnode;
  49. begin
  50. location.loc:=LOC_FPUREGISTER;
  51. registers32:=left.registers32;
  52. registersfpu:=max(left.registersfpu,1);
  53. first_abs_real := nil;
  54. end;
  55. function tSparcInlineNode.first_sqr_real : tnode;
  56. begin
  57. location.loc:=LOC_FPUREGISTER;
  58. registers32:=left.registers32;
  59. registersfpu:=max(left.registersfpu,1);
  60. first_sqr_real:=nil;
  61. end;
  62. function tSparcInlineNode.first_sqrt_real : tnode;
  63. begin
  64. location.loc:=LOC_FPUREGISTER;
  65. registers32:=left.registers32;
  66. registersfpu:=max(left.registersfpu,1);
  67. first_sqrt_real := nil;
  68. end;
  69. { load the FPU into the an fpu register }
  70. procedure tSparcInlineNode.load_fpu_location;
  71. begin
  72. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  73. secondpass(left);
  74. case left.location.loc of
  75. LOC_FPUREGISTER:
  76. location.register := left.location.register;
  77. LOC_CFPUREGISTER:
  78. begin
  79. location.register := rg.getregisterfpu(exprasmlist);
  80. end;
  81. LOC_REFERENCE,LOC_CREFERENCE:
  82. begin
  83. location.register := rg.getregisterfpu(exprasmlist);
  84. cg.a_loadfpu_ref_reg(exprasmlist,
  85. def_cgsize(left.resulttype.def),
  86. left.location.reference,location.register);
  87. location_release(exprasmlist,left.location);
  88. location_reset(left.location,LOC_FPUREGISTER,
  89. left.location.size);
  90. left.location.register := location.register;
  91. end
  92. else
  93. internalerror(309991);
  94. end;
  95. end;
  96. procedure tSparcInlineNode.second_abs_real;
  97. begin
  98. load_fpu_location;
  99. exprasmlist.concat(taicpu.op_reg_reg(A_NONE,location.register,
  100. left.location.register));
  101. end;
  102. procedure tSparcInlineNode.second_sqr_real;
  103. begin
  104. load_fpu_location;
  105. exprasmlist.concat(taicpu.op_reg_reg_reg(A_FMULS,location.register,
  106. left.location.register,left.location.register));
  107. end;
  108. procedure tSparcInlineNode.second_sqrt_real;
  109. begin
  110. load_fpu_location;
  111. exprasmlist.concat(taicpu.op_reg_reg(A_NONE,location.register,
  112. left.location.register));
  113. end;
  114. begin
  115. cInlineNode:=tSparcInlineNode;
  116. end.
  117. {
  118. $Log$
  119. Revision 1.3 2003-01-05 21:32:35 mazen
  120. * fixing several bugs compiling the RTL
  121. Revision 1.2 2002/12/30 21:17:22 mazen
  122. - unit cga no more used in sparc compiler.
  123. Revision 1.1 2002/11/30 20:03:49 mazen
  124. + ncpuinln node
  125. Revision 1.3 2002/09/18 09:19:37 jonas
  126. * fixed LOC_REFERENCE/LOC_CREFERENCE problems
  127. Revision 1.2 2002/08/19 17:35:42 jonas
  128. * fixes
  129. Revision 1.1 2002/08/10 17:15:00 jonas
  130. + abs, sqr, sqrt implementations
  131. }