aasmcpu.pas 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. function is_nop:boolean;override;
  44. function is_move:boolean;override;
  45. end;
  46. tai_align = class(tai_align_abstract)
  47. { nothing to add }
  48. end;
  49. procedure InitAsm;
  50. procedure DoneAsm;
  51. implementation
  52. {*****************************************************************************
  53. taicpu Constructors
  54. *****************************************************************************}
  55. constructor taicpu.op_none(op : tasmop);
  56. begin
  57. inherited create(op);
  58. end;
  59. constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
  60. begin
  61. inherited create(op);
  62. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  63. internalerror(2003031207);
  64. ops:=1;
  65. loadreg(0,_op1);
  66. end;
  67. constructor taicpu.op_ref(op : tasmop;const _op1 : treference);
  68. begin
  69. inherited create(op);
  70. ops:=1;
  71. loadref(0,_op1);
  72. end;
  73. constructor taicpu.op_const(op : tasmop;_op1 : aword);
  74. begin
  75. inherited create(op);
  76. ops:=1;
  77. loadconst(0,_op1);
  78. end;
  79. constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
  80. begin
  81. inherited create(op);
  82. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  83. internalerror(2003031205);
  84. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  85. internalerror(2003031206);
  86. ops:=2;
  87. loadreg(0,_op1);
  88. loadreg(1,_op2);
  89. end;
  90. constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: aword);
  91. begin
  92. inherited create(op);
  93. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  94. internalerror(2003031208);
  95. ops:=2;
  96. loadreg(0,_op1);
  97. loadconst(1,_op2);
  98. end;
  99. constructor taicpu.op_const_reg(op:tasmop; _op1: aword; _op2: tregister);
  100. begin
  101. inherited create(op);
  102. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  103. internalerror(2003031209);
  104. ops:=2;
  105. loadconst(0,_op1);
  106. loadreg(1,_op2);
  107. end;
  108. constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
  109. begin
  110. inherited create(op);
  111. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  112. internalerror(2003031210);
  113. ops:=2;
  114. loadreg(0,_op1);
  115. loadref(1,_op2);
  116. end;
  117. constructor taicpu.op_ref_reg(op : tasmop;const _op1 : treference;_op2 : tregister);
  118. begin
  119. inherited create(op);
  120. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  121. internalerror(2003031210);
  122. ops:=2;
  123. loadref(0,_op1);
  124. loadreg(1,_op2);
  125. end;
  126. constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
  127. begin
  128. inherited create(op);
  129. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  130. internalerror(2003031211);
  131. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  132. internalerror(2003031212);
  133. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  134. internalerror(2003031213);
  135. ops:=3;
  136. loadreg(0,_op1);
  137. loadreg(1,_op2);
  138. loadreg(2,_op3);
  139. end;
  140. constructor taicpu.op_reg_ref_reg(op:tasmop;_op1:TRegister;_op2:TReference;_op3:tregister);
  141. begin
  142. inherited create(op);
  143. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  144. internalerror(2003031214);
  145. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  146. internalerror(2003031215);
  147. { only allowed to load the address }
  148. if not(_op2.symaddr in [refs_lo,refs_hi]) then
  149. internalerror(200305311);
  150. ops:=3;
  151. loadreg(0,_op1);
  152. loadref(1,_op2);
  153. loadreg(2,_op3);
  154. end;
  155. constructor taicpu.op_reg_const_reg(op:tasmop;_op1:TRegister;_op2:aword;_op3:tregister);
  156. begin
  157. inherited create(op);
  158. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  159. internalerror(2003031216);
  160. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  161. internalerror(2003031217);
  162. ops:=3;
  163. loadreg(0,_op1);
  164. loadconst(1,_op2);
  165. loadreg(2,_op3);
  166. end;
  167. constructor taicpu.op_cond_sym(op:tasmop;cond:TAsmCond;_op1:tasmsymbol);
  168. begin
  169. inherited create(op);
  170. condition:=cond;
  171. ops:=1;
  172. loadsymbol(0,_op1,0);
  173. end;
  174. constructor taicpu.op_sym(op : tasmop;_op1 : tasmsymbol);
  175. begin
  176. inherited create(op);
  177. ops:=1;
  178. loadsymbol(0,_op1,0);
  179. end;
  180. constructor taicpu.op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
  181. begin
  182. inherited create(op);
  183. ops:=1;
  184. loadsymbol(0,_op1,_op1ofs);
  185. end;
  186. function taicpu.is_nop:boolean;
  187. begin
  188. result:=(opcode=A_NOP);
  189. end;
  190. function taicpu.is_move:boolean;
  191. begin
  192. result:=(opcode=A_MOV) and
  193. (oper[0].typ=top_reg) and
  194. (oper[1].typ=top_reg);
  195. end;
  196. procedure InitAsm;
  197. begin
  198. end;
  199. procedure DoneAsm;
  200. begin
  201. end;
  202. end.
  203. {
  204. $Log$
  205. Revision 1.29 2003-06-12 16:43:07 peter
  206. * newra compiles for sparc
  207. Revision 1.28 2003/06/01 01:03:41 peter
  208. * remove unsupported combinations
  209. * reg_ref_reg only allowed for refs_lo,refs_hi
  210. Revision 1.27 2003/05/30 23:57:08 peter
  211. * more sparc cleanup
  212. * accumulator removed, splitted in function_return_reg (called) and
  213. function_result_reg (caller)
  214. }