ncpuinln.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. procedure second_get_frame; override;
  31. private
  32. procedure load_fpu_location;
  33. end;
  34. implementation
  35. uses
  36. systems,
  37. globtype,
  38. cutils, verbose,
  39. symconst, symdef,
  40. aasmtai, aasmcpu, aasmdata,
  41. cgbase, pass_2,
  42. cpubase, paramgr,
  43. nbas, ncon, ncal, ncnv, nld,
  44. hlcgobj, ncgutil, cgobj, cgutils;
  45. {*****************************************************************************
  46. tMIPSELinlinenode
  47. *****************************************************************************}
  48. procedure tMIPSELinlinenode.load_fpu_location;
  49. begin
  50. secondpass(left);
  51. hlcg.location_force_fpureg(current_asmdata.CurrAsmList, left.location, left.resultdef, True);
  52. location_copy(location, left.location);
  53. if left.location.loc = LOC_CFPUREGISTER then
  54. begin
  55. location.Register := cg.getfpuregister(current_asmdata.CurrAsmList, location.size);
  56. location.loc := LOC_FPUREGISTER;
  57. end;
  58. end;
  59. function tMIPSELinlinenode.first_abs_real: tnode;
  60. begin
  61. expectloc := LOC_FPUREGISTER;
  62. first_abs_real := nil;
  63. end;
  64. function tMIPSELinlinenode.first_sqr_real: tnode;
  65. begin
  66. expectloc := LOC_FPUREGISTER;
  67. first_sqr_real := nil;
  68. end;
  69. function tMIPSELinlinenode.first_sqrt_real: tnode;
  70. begin
  71. expectloc := LOC_FPUREGISTER;
  72. first_sqrt_real := nil;
  73. end;
  74. procedure tMIPSELinlinenode.second_abs_real;
  75. begin
  76. load_fpu_location;
  77. case tfloatdef(left.resultdef).floattype of
  78. s32real:
  79. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_ABS_s, location.Register, left.location.Register));
  80. s64real:
  81. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_ABS_d, location.Register, left.location.Register));
  82. else
  83. internalerror(200410031);
  84. end;
  85. end;
  86. procedure tMIPSELinlinenode.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_MUL_s, location.Register, left.location.Register, left.location.Register));
  92. s64real:
  93. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_MUL_d, location.Register, left.location.Register, left.location.Register));
  94. else
  95. internalerror(200410032);
  96. end;
  97. end;
  98. procedure tMIPSELinlinenode.second_sqrt_real;
  99. begin
  100. load_fpu_location;
  101. case tfloatdef(left.resultdef).floattype of
  102. s32real:
  103. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_SQRT_s, location.Register, left.location.Register));
  104. s64real:
  105. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_SQRT_d, location.Register, left.location.Register));
  106. else
  107. internalerror(200410033);
  108. end;
  109. end;
  110. procedure tMIPSELinlinenode.second_get_frame;
  111. begin
  112. location_reset(location,LOC_CREGISTER,OS_ADDR);
  113. location.register:=NR_FRAME_POINTER_REG;
  114. end;
  115. begin
  116. cInlineNode := tMIPSELinlinenode;
  117. end.