ncpuinln.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. {
  2. Copyright (c) 1998-2009 by Florian Klaempfl and David Zhang
  3. Generate MIPSEL 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. tMIPSELinlinenode = 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,
  36. globtype,
  37. cutils, verbose,
  38. symconst, symdef,
  39. aasmtai, aasmcpu, aasmdata,
  40. cgbase, pass_2,
  41. cpubase, paramgr,
  42. nbas, ncon, ncal, ncnv, nld,
  43. ncgutil, cgobj, cgutils;
  44. {*****************************************************************************
  45. tMIPSELinlinenode
  46. *****************************************************************************}
  47. procedure tMIPSELinlinenode.load_fpu_location;
  48. begin
  49. secondpass(left);
  50. location_force_fpureg(current_asmdata.CurrAsmList, left.location, True);
  51. location_copy(location, left.location);
  52. if left.location.loc = LOC_CFPUREGISTER then
  53. begin
  54. location.Register := cg.getfpuregister(current_asmdata.CurrAsmList, location.size);
  55. location.loc := LOC_FPUREGISTER;
  56. end;
  57. end;
  58. function tMIPSELinlinenode.first_abs_real: tnode;
  59. begin
  60. expectloc := LOC_FPUREGISTER;
  61. first_abs_real := nil;
  62. end;
  63. function tMIPSELinlinenode.first_sqr_real: tnode;
  64. begin
  65. expectloc := LOC_FPUREGISTER;
  66. first_sqr_real := nil;
  67. end;
  68. function tMIPSELinlinenode.first_sqrt_real: tnode;
  69. begin
  70. expectloc := LOC_FPUREGISTER;
  71. first_sqrt_real := nil;
  72. end;
  73. procedure tMIPSELinlinenode.second_abs_real;
  74. begin
  75. load_fpu_location;
  76. case tfloatdef(left.resultdef).floattype of
  77. s32real:
  78. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_ABS_s, location.Register, left.location.Register));
  79. s64real:
  80. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_ABS_d, location.Register, left.location.Register));
  81. else
  82. internalerror(200410031);
  83. end;
  84. end;
  85. procedure tMIPSELinlinenode.second_sqr_real;
  86. begin
  87. load_fpu_location;
  88. case tfloatdef(left.resultdef).floattype of
  89. s32real:
  90. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_MUL_s, location.Register, left.location.Register, left.location.Register));
  91. s64real:
  92. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_MUL_d, location.Register, left.location.Register, left.location.Register));
  93. else
  94. internalerror(200410032);
  95. end;
  96. end;
  97. procedure tMIPSELinlinenode.second_sqrt_real;
  98. begin
  99. load_fpu_location;
  100. case tfloatdef(left.resultdef).floattype of
  101. s32real:
  102. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_SQRT_s, location.Register, left.location.Register));
  103. s64real:
  104. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_SQRT_d, location.Register, left.location.Register));
  105. else
  106. internalerror(200410033);
  107. end;
  108. end;
  109. begin
  110. cInlineNode := tMIPSELinlinenode;
  111. end.