ncpuinln.pas 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate SPARC inline nodes
  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. }
  17. unit ncpuinln;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,ninl,ncginl;
  22. type
  23. tsparcinlinenode = class(tcgInlineNode)
  24. function first_abs_real: tnode; override;
  25. function first_sqr_real: tnode; override;
  26. function first_sqrt_real: tnode; override;
  27. procedure second_abs_real; override;
  28. procedure second_sqr_real; override;
  29. procedure second_sqrt_real; override;
  30. private
  31. procedure load_fpu_location;
  32. end;
  33. implementation
  34. uses
  35. systems,globtype,
  36. cutils,verbose,
  37. symconst,symdef,
  38. aasmtai,aasmdata,aasmcpu,
  39. cgbase,pass_2,
  40. cpubase,paramgr,
  41. nbas,ncon,ncal,ncnv,nld,
  42. hlcgobj,ncgutil,cgobj,cgutils;
  43. {*****************************************************************************
  44. tsparcinlinenode
  45. *****************************************************************************}
  46. procedure tsparcinlinenode.load_fpu_location;
  47. begin
  48. secondpass(left);
  49. hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  50. location_copy(location,left.location);
  51. if left.location.loc=LOC_CFPUREGISTER then
  52. begin
  53. location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  54. location.loc := LOC_FPUREGISTER;
  55. end;
  56. end;
  57. function tsparcinlinenode.first_abs_real : tnode;
  58. begin
  59. expectloc:=LOC_FPUREGISTER;
  60. first_abs_real := nil;
  61. end;
  62. function tsparcinlinenode.first_sqr_real : tnode;
  63. begin
  64. expectloc:=LOC_FPUREGISTER;
  65. first_sqr_real:=nil;
  66. end;
  67. function tsparcinlinenode.first_sqrt_real : tnode;
  68. begin
  69. expectloc:=LOC_FPUREGISTER;
  70. first_sqrt_real := nil;
  71. end;
  72. procedure tsparcinlinenode.second_abs_real;
  73. begin
  74. load_fpu_location;
  75. case tfloatdef(left.resultdef).floattype of
  76. s32real:
  77. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FABSs,left.location.register,location.register));
  78. s64real:
  79. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FABSd,left.location.register,location.register));
  80. s128real:
  81. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FABSq,left.location.register,location.register));
  82. else
  83. internalerror(200410031);
  84. end;
  85. end;
  86. procedure tsparcinlinenode.second_sqr_real;
  87. begin
  88. load_fpu_location;
  89. case tfloatdef(left.resultdef).floattype of
  90. s32real:
  91. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_FMULs,left.location.register,left.location.register,location.register));
  92. s64real:
  93. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_FMULd,left.location.register,left.location.register,location.register));
  94. s128real:
  95. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_FMULq,left.location.register,left.location.register,location.register));
  96. else
  97. internalerror(200410032);
  98. end;
  99. end;
  100. procedure tsparcinlinenode.second_sqrt_real;
  101. begin
  102. load_fpu_location;
  103. case tfloatdef(left.resultdef).floattype of
  104. s32real:
  105. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRTs,left.location.register,location.register));
  106. s64real:
  107. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRTd,left.location.register,location.register));
  108. s128real:
  109. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRTq,left.location.register,location.register));
  110. else
  111. internalerror(200410033);
  112. end;
  113. end;
  114. begin
  115. cInlineNode:=tsparcinlinenode;
  116. end.