aasmcpu.pas 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. {
  2. $Id$
  3. Copyright (c) 1999-2002 by Mazen Neifer
  4. Contains the assembler object for 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 aasmcpu;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cclasses,aasmtai,
  23. aasmbase,globals,verbose,
  24. cpubase,cpuinfo;
  25. type
  26. taicpu = class(taicpu_abstract)
  27. constructor op_none(op : tasmop);
  28. constructor op_reg(op : tasmop;_op1 : tregister);
  29. constructor op_ref(op : tasmop;const _op1 : treference);
  30. constructor op_const(op : tasmop;_op1 : aword);
  31. constructor op_reg_reg(op : tasmop;_op1,_op2 : tregister);
  32. constructor op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
  33. constructor op_reg_const(op:tasmop; _op1: tregister; _op2: aword);
  34. constructor op_const_reg(op:tasmop; _op1: aword; _op2: tregister);
  35. constructor op_ref_reg(op : tasmop;const _op1 : treference;_op2 : tregister);
  36. constructor op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
  37. constructor op_reg_ref_reg(op:tasmop;_op1:TRegister;_op2:TReference;_op3:tregister);
  38. constructor op_reg_const_reg(op:tasmop;_op1:TRegister;_op2:aword;_op3:tregister);
  39. { this is for Jmp instructions }
  40. constructor op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : tasmsymbol);
  41. constructor op_sym(op : tasmop;_op1 : tasmsymbol);
  42. constructor op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
  43. end;
  44. tai_align = class(tai_align_abstract)
  45. { nothing to add }
  46. end;
  47. procedure InitAsm;
  48. procedure DoneAsm;
  49. implementation
  50. {*****************************************************************************
  51. taicpu Constructors
  52. *****************************************************************************}
  53. constructor taicpu.op_none(op : tasmop);
  54. begin
  55. inherited create(op);
  56. end;
  57. constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
  58. begin
  59. inherited create(op);
  60. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  61. internalerror(2003031207);
  62. ops:=1;
  63. loadreg(0,_op1);
  64. end;
  65. constructor taicpu.op_ref(op : tasmop;const _op1 : treference);
  66. begin
  67. inherited create(op);
  68. ops:=1;
  69. loadref(0,_op1);
  70. end;
  71. constructor taicpu.op_const(op : tasmop;_op1 : aword);
  72. begin
  73. inherited create(op);
  74. ops:=1;
  75. loadconst(0,_op1);
  76. end;
  77. constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
  78. begin
  79. inherited create(op);
  80. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  81. internalerror(2003031205);
  82. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  83. internalerror(2003031206);
  84. ops:=2;
  85. loadreg(0,_op1);
  86. loadreg(1,_op2);
  87. end;
  88. constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: aword);
  89. begin
  90. inherited create(op);
  91. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  92. internalerror(2003031208);
  93. ops:=2;
  94. loadreg(0,_op1);
  95. loadconst(1,_op2);
  96. end;
  97. constructor taicpu.op_const_reg(op:tasmop; _op1: aword; _op2: tregister);
  98. begin
  99. inherited create(op);
  100. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  101. internalerror(2003031209);
  102. ops:=2;
  103. loadconst(0,_op1);
  104. loadreg(1,_op2);
  105. end;
  106. constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
  107. begin
  108. inherited create(op);
  109. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  110. internalerror(2003031210);
  111. ops:=2;
  112. loadreg(0,_op1);
  113. loadref(1,_op2);
  114. end;
  115. constructor taicpu.op_ref_reg(op : tasmop;const _op1 : treference;_op2 : tregister);
  116. begin
  117. inherited create(op);
  118. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  119. internalerror(2003031210);
  120. ops:=2;
  121. loadref(0,_op1);
  122. loadreg(1,_op2);
  123. end;
  124. constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
  125. begin
  126. inherited create(op);
  127. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  128. internalerror(2003031211);
  129. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  130. internalerror(2003031212);
  131. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  132. internalerror(2003031213);
  133. ops:=3;
  134. loadreg(0,_op1);
  135. loadreg(1,_op2);
  136. loadreg(2,_op3);
  137. end;
  138. constructor taicpu.op_reg_ref_reg(op:tasmop;_op1:TRegister;_op2:TReference;_op3:tregister);
  139. begin
  140. inherited create(op);
  141. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  142. internalerror(2003031214);
  143. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  144. internalerror(2003031215);
  145. { only allowed to load the address }
  146. if not(_op2.symaddr in [refs_lo,refs_hi]) then
  147. internalerror(200305311);
  148. ops:=3;
  149. loadreg(0,_op1);
  150. loadref(1,_op2);
  151. loadreg(2,_op3);
  152. end;
  153. constructor taicpu.op_reg_const_reg(op:tasmop;_op1:TRegister;_op2:aword;_op3:tregister);
  154. begin
  155. inherited create(op);
  156. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  157. internalerror(2003031216);
  158. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  159. internalerror(2003031217);
  160. ops:=3;
  161. loadreg(0,_op1);
  162. loadconst(1,_op2);
  163. loadreg(2,_op3);
  164. end;
  165. constructor taicpu.op_cond_sym(op:tasmop;cond:TAsmCond;_op1:tasmsymbol);
  166. begin
  167. inherited create(op);
  168. condition:=cond;
  169. ops:=1;
  170. loadsymbol(0,_op1,0);
  171. end;
  172. constructor taicpu.op_sym(op : tasmop;_op1 : tasmsymbol);
  173. begin
  174. inherited create(op);
  175. ops:=1;
  176. loadsymbol(0,_op1,0);
  177. end;
  178. constructor taicpu.op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
  179. begin
  180. inherited create(op);
  181. ops:=1;
  182. loadsymbol(0,_op1,_op1ofs);
  183. end;
  184. procedure InitAsm;
  185. begin
  186. end;
  187. procedure DoneAsm;
  188. begin
  189. end;
  190. end.
  191. {
  192. $Log$
  193. Revision 1.28 2003-06-01 01:03:41 peter
  194. * remove unsupported combinations
  195. * reg_ref_reg only allowed for refs_lo,refs_hi
  196. Revision 1.27 2003/05/30 23:57:08 peter
  197. * more sparc cleanup
  198. * accumulator removed, splitted in function_return_reg (called) and
  199. function_result_reg (caller)
  200. }