cpuasm.pas 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Contains the assembler object for the Alpha
  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 cpuasm;
  19. interface
  20. uses
  21. cobjects,
  22. aasm,globals,verbose,
  23. cpubase,tainst;
  24. type
  25. paiframe = ^taiframe;
  26. taiframe = object(tai)
  27. G,R : TRegister;
  28. LS,LU : longint;
  29. Constructor init (GP : Tregister; Localsize : Longint; RA : TRegister; L : longint);
  30. end;
  31. paient = ^taient;
  32. taient = object(tai)
  33. Name : string;
  34. Constructor Init (ProcName : String);
  35. end;
  36. paicpu = ^taicpu;
  37. taicpu = object(tainstruction)
  38. constructor op_none(op : tasmop);
  39. constructor op_reg(op : tasmop;_op1 : tregister);
  40. constructor op_const(op : tasmop;_op1 : longint);
  41. constructor op_ref(op : tasmop;_op1 : preference);
  42. constructor op_reg_reg(op : tasmop;_op1,_op2 : tregister);
  43. constructor op_reg_ref(op : tasmop;_op1 : tregister;_op2 : preference);
  44. constructor op_reg_const(op:tasmop; _op1: tregister; _op2: longint);
  45. constructor op_const_reg(op : tasmop;_op1 : longint;_op2 : tregister);
  46. constructor op_const_const(op : tasmop;_op1,_op2 : longint);
  47. constructor op_const_ref(op : tasmop;_op1 : longint;_op2 : preference);
  48. constructor op_ref_reg(op : tasmop;_op1 : preference;_op2 : tregister);
  49. { this is only allowed if _op1 is an int value (_op1^.isintvalue=true) }
  50. constructor op_ref_ref(op : tasmop;_op1,_op2 : preference);
  51. constructor op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
  52. constructor op_reg_const_reg(op : tasmop;_op1 : tregister;_op2 : longint;_op3 : tregister);
  53. constructor op_const_ref_reg(op : tasmop;_op1 : longint;_op2 : preference;_op3 : tregister);
  54. constructor op_reg_reg_ref(op : tasmop;_op1,_op2 : tregister; _op3 : preference);
  55. constructor op_const_reg_ref(op : tasmop;_op1 : longint;_op2 : tregister;_op3 : preference);
  56. constructor op_reg_ref_const(op : tasmop;_op1 : tregister;_op2 : preference;_op3 : longint);
  57. { this is for Jmp instructions }
  58. constructor op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : pasmsymbol);
  59. constructor op_sym(op : tasmop;_op1 : pasmsymbol);
  60. constructor op_sym_ofs(op : tasmop;_op1 : pasmsymbol;_op1ofs:longint);
  61. constructor op_sym_ofs_reg(op : tasmop;_op1 : pasmsymbol;_op1ofs:longint;_op2 : tregister);
  62. constructor op_sym_ofs_ref(op : tasmop;_op1 : pasmsymbol;_op1ofs:longint;_op2 : preference);
  63. function getcopy:plinkedlist_item;virtual;
  64. private
  65. segprefix : tregister;
  66. end;
  67. implementation
  68. {*****************************************************************************
  69. taicpu Constructors
  70. *****************************************************************************}
  71. constructor taicpu.op_none(op : tasmop);
  72. begin
  73. inherited init(op);
  74. end;
  75. constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
  76. begin
  77. inherited init(op);
  78. ops:=1;
  79. end;
  80. constructor taicpu.op_const(op : tasmop;_op1 : longint);
  81. begin
  82. inherited init(op);
  83. ops:=1;
  84. end;
  85. constructor taicpu.op_ref(op : tasmop;_op1 : preference);
  86. begin
  87. inherited init(op);
  88. ops:=1;
  89. end;
  90. constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
  91. begin
  92. inherited init(op);
  93. ops:=2;
  94. end;
  95. constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: longint);
  96. begin
  97. inherited init(op);
  98. ops:=2;
  99. end;
  100. constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;_op2 : preference);
  101. begin
  102. inherited init(op);
  103. ops:=2;
  104. end;
  105. constructor taicpu.op_const_reg(op : tasmop;_op1 : longint;_op2 : tregister);
  106. begin
  107. inherited init(op);
  108. ops:=2;
  109. end;
  110. constructor taicpu.op_const_const(op : tasmop;_op1,_op2 : longint);
  111. begin
  112. inherited init(op);
  113. ops:=2;
  114. end;
  115. constructor taicpu.op_const_ref(op : tasmop;_op1 : longint;_op2 : preference);
  116. begin
  117. inherited init(op);
  118. ops:=2;
  119. end;
  120. constructor taicpu.op_ref_reg(op : tasmop;_op1 : preference;_op2 : tregister);
  121. begin
  122. inherited init(op);
  123. ops:=2;
  124. end;
  125. constructor taicpu.op_ref_ref(op : tasmop;_op1,_op2 : preference);
  126. begin
  127. inherited init(op);
  128. ops:=2;
  129. end;
  130. constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
  131. begin
  132. inherited init(op);
  133. ops:=3;
  134. end;
  135. constructor taicpu.op_reg_const_reg(op : tasmop;_op1 : tregister;_op2 : longint;_op3 : tregister);
  136. begin
  137. inherited init(op);
  138. ops:=3;
  139. end;
  140. constructor taicpu.op_reg_reg_ref(op : tasmop;_op1,_op2 : tregister;_op3 : preference);
  141. begin
  142. inherited init(op);
  143. ops:=3;
  144. end;
  145. constructor taicpu.op_const_ref_reg(op : tasmop;_op1 : longint;_op2 : preference;_op3 : tregister);
  146. begin
  147. inherited init(op);
  148. ops:=3;
  149. end;
  150. constructor taicpu.op_const_reg_ref(op : tasmop;_op1 : longint;_op2 : tregister;_op3 : preference);
  151. begin
  152. inherited init(op);
  153. ops:=3;
  154. end;
  155. constructor taicpu.op_reg_ref_const(op : tasmop;_op1 : tregister;_op2 : preference;_op3 : longint);
  156. begin
  157. inherited init(op);
  158. ops:=3;
  159. end;
  160. constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : pasmsymbol);
  161. begin
  162. inherited init(op);
  163. condition:=cond;
  164. ops:=1;
  165. end;
  166. constructor taicpu.op_sym(op : tasmop;_op1 : pasmsymbol);
  167. begin
  168. inherited init(op);
  169. ops:=1;
  170. end;
  171. constructor taicpu.op_sym_ofs(op : tasmop;_op1 : pasmsymbol;_op1ofs:longint);
  172. begin
  173. inherited init(op);
  174. ops:=1;
  175. end;
  176. constructor taicpu.op_sym_ofs_reg(op : tasmop;_op1 : pasmsymbol;_op1ofs:longint;_op2 : tregister);
  177. begin
  178. inherited init(op);
  179. ops:=2;
  180. end;
  181. constructor taicpu.op_sym_ofs_ref(op : tasmop;_op1 : pasmsymbol;_op1ofs:longint;_op2 : preference);
  182. begin
  183. inherited init(op);
  184. ops:=2;
  185. end;
  186. function taicpu.getcopy:plinkedlist_item;
  187. var
  188. i : longint;
  189. p : plinkedlist_item;
  190. begin
  191. p:=inherited getcopy;
  192. { make a copy of the references }
  193. for i:=1 to ops do
  194. if (paicpu(p)^.oper[i-1].typ=top_ref) then
  195. begin
  196. new(paicpu(p)^.oper[i-1].ref);
  197. paicpu(p)^.oper[i-1].ref^:=oper[i-1].ref^;
  198. end;
  199. getcopy:=p;
  200. end;
  201. Constructor taiframe.init (GP : Tregister; Localsize : Longint; RA : TRegister; L : longint);
  202. begin
  203. Inherited Init;
  204. typ:=ait_frame;
  205. G:=GP;
  206. R:=RA;
  207. LS:=LocalSize;
  208. LU:=L;
  209. end;
  210. Constructor taient.Init (ProcName : String);
  211. begin
  212. Inherited init;
  213. typ:=ait_ent;
  214. Name:=ProcName;
  215. end;
  216. end.
  217. {
  218. $Log$
  219. Revision 1.2 2002-09-07 15:25:10 peter
  220. * old logs removed and tabs fixed
  221. Revision 1.1 2002/08/18 09:06:54 florian
  222. * alpha files moved compiler/alpha
  223. }