narminl.pas 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generates ARM 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 narminl;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,ninl,ncginl;
  22. type
  23. tarminlinenode = class(tcgInlineNode)
  24. function first_abs_real: tnode; override;
  25. function first_sqr_real: tnode; override;
  26. function first_sqrt_real: tnode; override;
  27. { atn,sin,cos,lgn isn't supported by the linux fpe
  28. function first_arctan_real: tnode; override;
  29. function first_ln_real: tnode; override;
  30. function first_cos_real: tnode; override;
  31. function first_sin_real: tnode; override;
  32. }
  33. procedure second_abs_real; override;
  34. procedure second_sqr_real; override;
  35. procedure second_sqrt_real; override;
  36. { atn,sin,cos,lgn isn't supported by the linux fpe
  37. procedure second_arctan_real; override;
  38. procedure second_ln_real; override;
  39. procedure second_cos_real; override;
  40. procedure second_sin_real; override;
  41. }
  42. private
  43. procedure load_fpu_location;
  44. end;
  45. implementation
  46. uses
  47. globtype,systems,
  48. cutils,verbose,globals,fmodule,
  49. symconst,symdef,
  50. aasmbase,aasmtai,aasmdata,aasmcpu,
  51. cgbase,cgutils,
  52. pass_1,pass_2,
  53. cpubase,paramgr,
  54. nbas,ncon,ncal,ncnv,nld,
  55. tgobj,ncgutil,cgobj,cg64f32,rgobj,rgcpu,cgcpu;
  56. {*****************************************************************************
  57. tarminlinenode
  58. *****************************************************************************}
  59. procedure tarminlinenode.load_fpu_location;
  60. begin
  61. secondpass(left);
  62. location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
  63. location_copy(location,left.location);
  64. if left.location.loc=LOC_CFPUREGISTER then
  65. begin
  66. location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  67. location.loc := LOC_FPUREGISTER;
  68. end;
  69. end;
  70. function tarminlinenode.first_abs_real : tnode;
  71. begin
  72. if cs_fp_emulation in aktmoduleswitches then
  73. result:=inherited first_abs_real
  74. else
  75. begin
  76. expectloc:=LOC_FPUREGISTER;
  77. registersint:=left.registersint;
  78. registersfpu:=max(left.registersfpu,1);
  79. first_abs_real:=nil;
  80. end;
  81. end;
  82. function tarminlinenode.first_sqr_real : tnode;
  83. begin
  84. if cs_fp_emulation in aktmoduleswitches then
  85. result:=inherited first_sqr_real
  86. else
  87. begin
  88. expectloc:=LOC_FPUREGISTER;
  89. registersint:=left.registersint;
  90. registersfpu:=max(left.registersfpu,1);
  91. first_sqr_real:=nil;
  92. end;
  93. end;
  94. function tarminlinenode.first_sqrt_real : tnode;
  95. begin
  96. if cs_fp_emulation in aktmoduleswitches then
  97. result:=inherited first_sqrt_real
  98. else
  99. begin
  100. expectloc:=LOC_FPUREGISTER;
  101. registersint:=left.registersint;
  102. registersfpu:=max(left.registersfpu,1);
  103. first_sqrt_real := nil;
  104. end;
  105. end;
  106. { atn,sin,cos,lgn isn't supported by the linux fpe
  107. function tarminlinenode.first_arctan_real: tnode;
  108. begin
  109. expectloc:=LOC_FPUREGISTER;
  110. registersint:=left.registersint;
  111. registersfpu:=max(left.registersfpu,1);
  112. result:=nil;
  113. end;
  114. function tarminlinenode.first_ln_real: tnode;
  115. begin
  116. expectloc:=LOC_FPUREGISTER;
  117. registersint:=left.registersint;
  118. registersfpu:=max(left.registersfpu,1);
  119. result:=nil;
  120. end;
  121. function tarminlinenode.first_cos_real: tnode;
  122. begin
  123. expectloc:=LOC_FPUREGISTER;
  124. registersint:=left.registersint;
  125. registersfpu:=max(left.registersfpu,1);
  126. result:=nil;
  127. end;
  128. function tarminlinenode.first_sin_real: tnode;
  129. begin
  130. expectloc:=LOC_FPUREGISTER;
  131. registersint:=left.registersint;
  132. registersfpu:=max(left.registersfpu,1);
  133. result:=nil;
  134. end;
  135. }
  136. procedure tarminlinenode.second_abs_real;
  137. begin
  138. load_fpu_location;
  139. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_ABS,location.register,location.register),get_fpu_postfix(resultdef)));
  140. end;
  141. procedure tarminlinenode.second_sqr_real;
  142. begin
  143. load_fpu_location;
  144. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_MUF,location.register,left.location.register,left.location.register),get_fpu_postfix(resultdef)));
  145. end;
  146. procedure tarminlinenode.second_sqrt_real;
  147. begin
  148. load_fpu_location;
  149. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_SQT,location.register,location.register),get_fpu_postfix(resultdef)));
  150. end;
  151. { atn, sin, cos, lgn isn't supported by the linux fpe
  152. procedure tarminlinenode.second_arctan_real;
  153. begin
  154. load_fpu_location;
  155. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_ATN,location.register,location.register),get_fpu_postfix(resultdef)));
  156. end;
  157. procedure tarminlinenode.second_ln_real;
  158. begin
  159. load_fpu_location;
  160. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_LGN,location.register,location.register),get_fpu_postfix(resultdef)));
  161. end;
  162. procedure tarminlinenode.second_cos_real;
  163. begin
  164. load_fpu_location;
  165. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_COS,location.register,location.register),get_fpu_postfix(resultdef)));
  166. end;
  167. procedure tarminlinenode.second_sin_real;
  168. begin
  169. load_fpu_location;
  170. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_SIN,location.register,location.register),get_fpu_postfix(resultdef)));
  171. end;
  172. }
  173. begin
  174. cinlinenode:=tarminlinenode;
  175. end.