aasmcpu.pas 8.2 KB

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