ncpuadd.pas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 by Florian Klaempfl
  4. Code generation for add nodes on the SPARC
  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 ncpuadd;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,ncgadd,cpubase,cginfo;
  23. type
  24. tsparcaddnode = class(tcgaddnode)
  25. private
  26. function GetResFlags(unsigned:Boolean):TResFlags;
  27. protected
  28. procedure second_addfloat;override;
  29. procedure second_cmpfloat;override;
  30. procedure second_cmpboolean;override;
  31. procedure second_cmpsmallset;override;
  32. procedure second_cmp64bit;override;
  33. procedure second_cmpordinal;override;
  34. end;
  35. implementation
  36. uses
  37. globtype,systems,
  38. cutils,verbose,globals,
  39. symconst,symdef,paramgr,
  40. aasmbase,aasmtai,aasmcpu,defutil,htypechk,
  41. cgbase,cpuinfo,pass_1,pass_2,regvars,
  42. cpupara,
  43. ncon,nset,nadd,
  44. ncgutil,tgobj,rgobj,rgcpu,cgobj,cg64f32;
  45. {*****************************************************************************
  46. TSparcAddNode
  47. *****************************************************************************}
  48. function TSparcAddNode.GetResFlags(unsigned:Boolean):TResFlags;
  49. begin
  50. case NodeType of
  51. equaln:
  52. GetResFlags:=F_E;
  53. unequaln:
  54. GetResFlags:=F_NE;
  55. else
  56. if not(unsigned) then
  57. begin
  58. if nf_swaped in flags then
  59. case NodeType of
  60. ltn:
  61. GetResFlags:=F_G;
  62. lten:
  63. GetResFlags:=F_GE;
  64. gtn:
  65. GetResFlags:=F_L;
  66. gten:
  67. GetResFlags:=F_LE;
  68. end
  69. else
  70. case NodeType of
  71. ltn:
  72. GetResFlags:=F_L;
  73. lten:
  74. GetResFlags:=F_LE;
  75. gtn:
  76. GetResFlags:=F_G;
  77. gten:
  78. GetResFlags:=F_GE;
  79. end;
  80. end
  81. else
  82. begin
  83. if nf_swaped in Flags then
  84. case NodeType of
  85. ltn:
  86. GetResFlags:=F_A;
  87. lten:
  88. GetResFlags:=F_AE;
  89. gtn:
  90. GetResFlags:=F_B;
  91. gten:
  92. GetResFlags:=F_BE;
  93. end
  94. else
  95. case NodeType of
  96. ltn:
  97. GetResFlags:=F_B;
  98. lten:
  99. GetResFlags:=F_BE;
  100. gtn:
  101. GetResFlags:=F_A;
  102. gten:
  103. GetResFlags:=F_AE;
  104. end;
  105. end;
  106. end;
  107. end;
  108. procedure tsparcaddnode.second_addfloat;
  109. var
  110. op : TAsmOp;
  111. begin
  112. case nodetype of
  113. addn :
  114. op:=A_FADDs;
  115. muln :
  116. op:=A_FMULs;
  117. subn :
  118. op:=A_FSUBs;
  119. slashn :
  120. op:=A_FDIVs;
  121. else
  122. internalerror(200306014);
  123. end;
  124. { force fpureg as location, left right doesn't matter
  125. as both will be in a fpureg }
  126. if (nf_swaped in flags) then
  127. swapleftright;
  128. location_force_fpureg(exprasmlist,left.location,true);
  129. location_force_fpureg(exprasmlist,right.location,(left.location.loc<>LOC_CFPUREGISTER));
  130. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  131. if left.location.loc<>LOC_CFPUREGISTER then
  132. location.register:=left.location.register
  133. else
  134. location.register:=right.location.register;
  135. exprasmlist.concat(taicpu.op_reg_reg_reg(op,
  136. left.location.register,right.location.register,location.register))
  137. end;
  138. procedure tsparcaddnode.second_cmpfloat;
  139. begin
  140. { force fpureg as location, left right doesn't matter
  141. as both will be in a fpureg }
  142. if (nf_swaped in flags) then
  143. swapleftright;
  144. location_force_fpureg(exprasmlist,left.location,true);
  145. location_force_fpureg(exprasmlist,right.location,true);
  146. location_reset(location,LOC_FLAGS,OS_NO);
  147. location.resflags := getresflags(true);
  148. exprasmlist.concat(taicpu.op_reg_reg(A_FCMPs,
  149. left.location.register,right.location.register))
  150. end;
  151. procedure tsparcaddnode.second_cmpboolean;
  152. begin
  153. location_reset(location,LOC_FLAGS,OS_NO);
  154. location.resflags := getresflags(true);
  155. end;
  156. procedure tsparcaddnode.second_cmpsmallset;
  157. begin
  158. location_reset(location,LOC_FLAGS,OS_NO);
  159. location.resflags := getresflags(true);
  160. end;
  161. procedure tsparcaddnode.second_cmp64bit;
  162. begin
  163. location_reset(location,LOC_FLAGS,OS_NO);
  164. location.resflags := getresflags(true);
  165. end;
  166. procedure tsparcaddnode.second_cmpordinal;
  167. begin
  168. location_reset(location,LOC_FLAGS,OS_NO);
  169. location.resflags := getresflags(true);
  170. end;
  171. begin
  172. caddnode:=tsparcaddnode;
  173. end.
  174. {
  175. $Log$
  176. Revision 1.15 2003-06-01 21:38:06 peter
  177. * getregisterfpu size parameter added
  178. * op_const_reg size parameter added
  179. * sparc updates
  180. }