ncpuinln.pas 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate SPARC inline nodes
  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 ncpuinln;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,ninl,ncginl;
  23. type
  24. tsparcinlinenode = class(tcgInlineNode)
  25. function first_abs_real: tnode; override;
  26. function first_sqr_real: tnode; override;
  27. function first_sqrt_real: tnode; override;
  28. procedure second_abs_real; override;
  29. procedure second_sqr_real; override;
  30. procedure second_sqrt_real; override;
  31. private
  32. procedure load_fpu_location;
  33. end;
  34. implementation
  35. uses
  36. systems,
  37. cutils,verbose,
  38. symconst,symdef,
  39. aasmtai,aasmcpu,
  40. cgbase,pass_2,
  41. cpubase,paramgr,
  42. nbas,ncon,ncal,ncnv,nld,
  43. ncgutil,cgobj,cgutils;
  44. {*****************************************************************************
  45. tsparcinlinenode
  46. *****************************************************************************}
  47. procedure tsparcinlinenode.load_fpu_location;
  48. begin
  49. secondpass(left);
  50. location_force_fpureg(exprasmlist,left.location,true);
  51. location_copy(location,left.location);
  52. if left.location.loc=LOC_CFPUREGISTER then
  53. begin
  54. location.register:=cg.getfpuregister(exprasmlist,location.size);
  55. location.loc := LOC_FPUREGISTER;
  56. end;
  57. end;
  58. function tsparcinlinenode.first_abs_real : tnode;
  59. begin
  60. expectloc:=LOC_FPUREGISTER;
  61. registersint:=left.registersint;
  62. registersfpu:=max(left.registersfpu,1);
  63. first_abs_real := nil;
  64. end;
  65. function tsparcinlinenode.first_sqr_real : tnode;
  66. begin
  67. expectloc:=LOC_FPUREGISTER;
  68. registersint:=left.registersint;
  69. registersfpu:=max(left.registersfpu,1);
  70. first_sqr_real:=nil;
  71. end;
  72. function tsparcinlinenode.first_sqrt_real : tnode;
  73. begin
  74. expectloc:=LOC_FPUREGISTER;
  75. registersint:=left.registersint;
  76. registersfpu:=max(left.registersfpu,1);
  77. first_sqrt_real := nil;
  78. end;
  79. procedure tsparcinlinenode.second_abs_real;
  80. begin
  81. load_fpu_location;
  82. case tfloatdef(left.resulttype.def).typ of
  83. s32real:
  84. exprasmlist.concat(taicpu.op_reg_reg(A_FABSs,left.location.register,location.register));
  85. s64real:
  86. exprasmlist.concat(taicpu.op_reg_reg(A_FABSd,left.location.register,location.register));
  87. s128real:
  88. exprasmlist.concat(taicpu.op_reg_reg(A_FABSq,left.location.register,location.register));
  89. else
  90. internalerror(200410031);
  91. end;
  92. end;
  93. procedure tsparcinlinenode.second_sqr_real;
  94. begin
  95. load_fpu_location;
  96. case tfloatdef(left.resulttype.def).typ of
  97. s32real:
  98. exprasmlist.concat(taicpu.op_reg_reg_reg(A_FMULs,left.location.register,left.location.register,location.register));
  99. s64real:
  100. exprasmlist.concat(taicpu.op_reg_reg_reg(A_FMULd,left.location.register,left.location.register,location.register));
  101. s128real:
  102. exprasmlist.concat(taicpu.op_reg_reg_reg(A_FMULq,left.location.register,left.location.register,location.register));
  103. else
  104. internalerror(200410032);
  105. end;
  106. end;
  107. procedure tsparcinlinenode.second_sqrt_real;
  108. begin
  109. load_fpu_location;
  110. case tfloatdef(left.resulttype.def).typ of
  111. s32real:
  112. exprasmlist.concat(taicpu.op_reg_reg(A_FSQRTs,left.location.register,location.register));
  113. s64real:
  114. exprasmlist.concat(taicpu.op_reg_reg(A_FSQRTd,left.location.register,location.register));
  115. s128real:
  116. exprasmlist.concat(taicpu.op_reg_reg(A_FSQRTq,left.location.register,location.register));
  117. else
  118. internalerror(200410033);
  119. end;
  120. end;
  121. begin
  122. cInlineNode:=tsparcinlinenode;
  123. end.
  124. {
  125. $Log$
  126. Revision 1.11 2004-10-31 21:45:04 peter
  127. * generic tlocation
  128. * move tlocation to cgutils
  129. Revision 1.10 2004/10/03 12:42:22 florian
  130. * made sqrt, sqr and abs internal for the sparc
  131. Revision 1.9 2004/06/20 08:55:32 florian
  132. * logs truncated
  133. Revision 1.8 2004/02/03 22:32:54 peter
  134. * renamed xNNbittype to xNNinttype
  135. * renamed registers32 to registersint
  136. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  137. }