narminl.pas 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generates ARM 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 narminl;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,ninl,ncginl;
  23. type
  24. tarminlinenode = class(tcgInlineNode)
  25. function first_abs_real: tnode; override;
  26. function first_sqr_real: tnode; override;
  27. function first_sqrt_real: tnode; override;
  28. function first_arctan_real: tnode; override;
  29. { lgn isn't supported by the linux fpe
  30. function first_ln_real: tnode; override;
  31. }
  32. function first_cos_real: tnode; override;
  33. function first_sin_real: tnode; override;
  34. procedure second_abs_real; override;
  35. procedure second_sqr_real; override;
  36. procedure second_sqrt_real; override;
  37. procedure second_arctan_real; override;
  38. { lgn isn't supported by the linux fpe
  39. procedure second_ln_real; override;
  40. }
  41. procedure second_cos_real; override;
  42. procedure second_sin_real; override;
  43. private
  44. procedure load_fpu_location;
  45. end;
  46. implementation
  47. uses
  48. globtype,systems,
  49. cutils,verbose,globals,fmodule,
  50. symconst,symdef,
  51. aasmbase,aasmtai,aasmcpu,
  52. cgbase,cgutils,
  53. pass_1,pass_2,
  54. cpubase,paramgr,
  55. nbas,ncon,ncal,ncnv,nld,
  56. tgobj,ncgutil,cgobj,cg64f32,rgobj,rgcpu,cgcpu;
  57. {*****************************************************************************
  58. tarminlinenode
  59. *****************************************************************************}
  60. procedure tarminlinenode.load_fpu_location;
  61. begin
  62. secondpass(left);
  63. location_force_fpureg(exprasmlist,left.location,true);
  64. location_copy(location,left.location);
  65. if left.location.loc=LOC_CFPUREGISTER then
  66. begin
  67. location.register:=cg.getfpuregister(exprasmlist,location.size);
  68. location.loc := LOC_FPUREGISTER;
  69. end;
  70. end;
  71. function tarminlinenode.first_abs_real : tnode;
  72. begin
  73. expectloc:=LOC_FPUREGISTER;
  74. registersint:=left.registersint;
  75. registersfpu:=max(left.registersfpu,1);
  76. first_abs_real := nil;
  77. end;
  78. function tarminlinenode.first_sqr_real : tnode;
  79. begin
  80. expectloc:=LOC_FPUREGISTER;
  81. registersint:=left.registersint;
  82. registersfpu:=max(left.registersfpu,1);
  83. first_sqr_real:=nil;
  84. end;
  85. function tarminlinenode.first_sqrt_real : tnode;
  86. begin
  87. expectloc:=LOC_FPUREGISTER;
  88. registersint:=left.registersint;
  89. registersfpu:=max(left.registersfpu,1);
  90. first_sqrt_real := nil;
  91. end;
  92. function tarminlinenode.first_arctan_real: tnode;
  93. begin
  94. expectloc:=LOC_FPUREGISTER;
  95. registersint:=left.registersint;
  96. registersfpu:=max(left.registersfpu,1);
  97. result:=nil;
  98. end;
  99. { lgn isn't supported by the linux fpe
  100. function tarminlinenode.first_ln_real: tnode;
  101. begin
  102. expectloc:=LOC_FPUREGISTER;
  103. registersint:=left.registersint;
  104. registersfpu:=max(left.registersfpu,1);
  105. result:=nil;
  106. end;
  107. }
  108. function tarminlinenode.first_cos_real: tnode;
  109. begin
  110. expectloc:=LOC_FPUREGISTER;
  111. registersint:=left.registersint;
  112. registersfpu:=max(left.registersfpu,1);
  113. result:=nil;
  114. end;
  115. function tarminlinenode.first_sin_real: tnode;
  116. begin
  117. expectloc:=LOC_FPUREGISTER;
  118. registersint:=left.registersint;
  119. registersfpu:=max(left.registersfpu,1);
  120. result:=nil;
  121. end;
  122. procedure tarminlinenode.second_abs_real;
  123. begin
  124. load_fpu_location;
  125. exprasmlist.concat(setoppostfix(taicpu.op_reg_reg(A_ABS,location.register,location.register),get_fpu_postfix(resulttype.def)));
  126. end;
  127. procedure tarminlinenode.second_sqr_real;
  128. begin
  129. load_fpu_location;
  130. exprasmlist.concat(setoppostfix(taicpu.op_reg_reg_reg(A_MUF,location.register,left.location.register,left.location.register),get_fpu_postfix(resulttype.def)));
  131. end;
  132. procedure tarminlinenode.second_sqrt_real;
  133. begin
  134. load_fpu_location;
  135. exprasmlist.concat(setoppostfix(taicpu.op_reg_reg(A_SQT,location.register,location.register),get_fpu_postfix(resulttype.def)));
  136. end;
  137. procedure tarminlinenode.second_arctan_real;
  138. begin
  139. load_fpu_location;
  140. exprasmlist.concat(setoppostfix(taicpu.op_reg_reg(A_ATN,location.register,location.register),get_fpu_postfix(resulttype.def)));
  141. end;
  142. { lgn isn't supported by the linux fpe
  143. procedure tarminlinenode.second_ln_real;
  144. begin
  145. load_fpu_location;
  146. exprasmlist.concat(setoppostfix(taicpu.op_reg_reg(A_LGN,location.register,location.register),get_fpu_postfix(resulttype.def)));
  147. end;
  148. }
  149. procedure tarminlinenode.second_cos_real;
  150. begin
  151. load_fpu_location;
  152. exprasmlist.concat(setoppostfix(taicpu.op_reg_reg(A_COS,location.register,location.register),get_fpu_postfix(resulttype.def)));
  153. end;
  154. procedure tarminlinenode.second_sin_real;
  155. begin
  156. load_fpu_location;
  157. exprasmlist.concat(setoppostfix(taicpu.op_reg_reg(A_SIN,location.register,location.register),get_fpu_postfix(resulttype.def)));
  158. end;
  159. begin
  160. cinlinenode:=tarminlinenode;
  161. end.
  162. {
  163. $Log$
  164. Revision 1.8 2004-11-01 17:41:28 florian
  165. * fixed arm compilation with cgutils
  166. * ...
  167. Revision 1.7 2004/06/20 08:55:31 florian
  168. * logs truncated
  169. Revision 1.6 2004/03/16 22:12:10 florian
  170. * some alignment issues resolved
  171. * compiler doesn't generate anymore instructions not supported by the linux fpe
  172. Revision 1.5 2004/02/03 22:32:54 peter
  173. * renamed xNNbittype to xNNinttype
  174. * renamed registers32 to registersint
  175. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  176. Revision 1.4 2004/01/27 15:04:06 florian
  177. * fixed code generation for math inl. nodes
  178. * more code generator improvements
  179. Revision 1.3 2004/01/20 21:02:56 florian
  180. * fixed symbol type writing for arm-linux
  181. * fixed assembler generation for abs
  182. }