c29a7cebceb4ffd1a312e9dcfeec18e960fa92a8
[oota-llvm.git] / lib / Target / Alpha / AlphaInstrFormats.td
1 //===- AlphaInstrFormats.td - Alpha Instruction Formats ----*- tablegen -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12
13 //3.3:
14 //Memory
15 //Branch
16 //Operate
17 //Floating-point
18 //PALcode
19
20 def u8imm   : Operand<i64>;
21 def s14imm  : Operand<i64>;
22 def s16imm  : Operand<i64>;
23 def s21imm  : Operand<i64>;
24 def s64imm  : Operand<i64>;
25
26 //===----------------------------------------------------------------------===//
27 // Instruction format superclass
28 //===----------------------------------------------------------------------===//
29 // Alpha instruction baseline
30 class InstAlphaAlt<bits<6> op, string asmstr> : Instruction {
31   field bits<32> Inst;
32   let Namespace = "Alpha";
33   let AsmString = asmstr;
34   let Inst{31-26} = op;
35 }
36
37 class InstAlpha<bits<6> op, dag OL, string asmstr> 
38 : InstAlphaAlt<op, asmstr> { // Alpha instruction baseline
39   let OperandList = OL;
40 }
41
42 //3.3.1
43 class MForm<bits<6> opcode, bit store, bit load, string asmstr, list<dag> pattern> 
44         : InstAlphaAlt<opcode, asmstr> {
45   let Pattern = pattern;
46   let isStore = store;
47   let isLoad = load;
48   let Defs = [R28]; //We may use this for frame index calculations, so reserve it here
49
50   bits<5> Ra;
51   bits<16> disp;
52   bits<5> Rb;
53
54   let Inst{25-21} = Ra;
55   let Inst{20-16} = Rb;
56   let Inst{15-0} = disp;
57 }
58
59 class MfcForm<bits<6> opcode, bits<16> fc, string asmstr> 
60         : InstAlpha<opcode, (ops GPRC:$RA), asmstr> {
61   bits<5> Ra;
62
63   let Inst{25-21} = Ra;
64   let Inst{20-16} = 0;
65   let Inst{15-0} = fc;
66 }
67
68 class MbrForm<bits<6> opcode, bits<2> TB, dag OL, string asmstr> : InstAlpha<opcode, OL, asmstr> {
69   bits<5> Ra;
70   bits<5> Rb;
71   bits<14> disp;
72
73   let Inst{25-21} = Ra;
74   let Inst{20-16} = Rb;
75   let Inst{15-14} = TB;
76   let Inst{13-0} = disp;
77 }
78
79 //3.3.2
80 def target : Operand<OtherVT> {}
81 let isBranch = 1, isTerminator = 1 in
82 class BFormD<bits<6> opcode, string asmstr, list<dag> pattern> 
83     : InstAlpha<opcode, (ops target:$DISP), asmstr> {
84   let Pattern = pattern;
85
86   bits<5> Ra;
87   bits<21> disp;
88
89   let Inst{25-21} = Ra;
90   let Inst{20-0} = disp;
91 }
92 let isBranch = 1, isTerminator = 1 in
93 class BForm<bits<6> opcode, string asmstr, list<dag> pattern> 
94     : InstAlpha<opcode, (ops GPRC:$RA, target:$DISP), asmstr> {
95   let Pattern = pattern;
96
97   bits<5> Ra;
98   bits<21> disp;
99
100   let Inst{25-21} = Ra;
101   let Inst{20-0} = disp;
102 }
103
104 let isBranch = 1, isTerminator = 1 in
105 class FBForm<bits<6> opcode, string asmstr, list<dag> pattern> 
106     : InstAlpha<opcode, (ops F8RC:$RA, target:$DISP), asmstr> {
107   let Pattern = pattern;
108
109   bits<5> Ra;
110   bits<21> disp;
111
112   let Inst{25-21} = Ra;
113   let Inst{20-0} = disp;
114 }
115
116 //3.3.3
117 class OForm<bits<6> opcode, bits<7> fun, string asmstr, list<dag> pattern> 
118         : InstAlpha<opcode, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), asmstr> {
119   let Pattern = pattern;
120
121   bits<5> Rc;
122   bits<5> Ra;
123   bits<5> Rb;
124   bits<7> Function = fun;
125
126   let Inst{25-21} = Ra;
127   let Inst{20-16} = Rb;
128   let Inst{15-13} = 0;
129   let Inst{12} = 0;
130   let Inst{11-5} = Function;
131   let Inst{4-0} = Rc;
132 }
133
134 class OForm2<bits<6> opcode, bits<7> fun, string asmstr, list<dag> pattern> 
135         : InstAlpha<opcode, (ops GPRC:$RC, GPRC:$RB), asmstr> {
136   let Pattern = pattern;
137
138   bits<5> Rc;
139   bits<5> Rb;
140   bits<7> Function = fun;
141
142   let Inst{25-21} = 31;
143   let Inst{20-16} = Rb;
144   let Inst{15-13} = 0;
145   let Inst{12} = 0;
146   let Inst{11-5} = Function;
147   let Inst{4-0} = Rc;
148 }
149
150 class OForm4<bits<6> opcode, bits<7> fun, string asmstr, list<dag> pattern> 
151         : InstAlpha<opcode, (ops GPRC:$RDEST, GPRC:$RFALSE, GPRC:$RTRUE, GPRC:$RCOND), asmstr> {
152   let Pattern = pattern;
153
154   bits<5> Rc;
155   bits<5> Rb;
156   bits<5> Ra;
157   bits<7> Function = fun;
158
159   let isTwoAddress = 1;
160   let Inst{25-21} = Ra;
161   let Inst{20-16} = Rb;
162   let Inst{15-13} = 0;
163   let Inst{12} = 0;
164   let Inst{11-5} = Function;
165   let Inst{4-0} = Rc;
166 }
167
168
169 class OFormL<bits<6> opcode, bits<7> fun, string asmstr, list<dag> pattern> 
170         : InstAlpha<opcode, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), asmstr> {
171   let Pattern = pattern;
172
173   bits<5> Rc;
174   bits<5> Ra;
175   bits<8> LIT;
176   bits<7> Function = fun;
177
178   let Inst{25-21} = Ra;
179   let Inst{20-13} = LIT;
180   let Inst{12} = 1;
181   let Inst{11-5} = Function;
182   let Inst{4-0} = Rc;
183 }
184
185 class OForm4L<bits<6> opcode, bits<7> fun, string asmstr, list<dag> pattern> 
186         : InstAlpha<opcode, (ops GPRC:$RDEST, GPRC:$RFALSE, s64imm:$RTRUE, GPRC:$RCOND), asmstr> {
187   let Pattern = pattern;
188
189   bits<5> Rc;
190   bits<8> LIT;
191   bits<5> Ra;
192   bits<7> Function = fun;
193
194   let isTwoAddress = 1;
195   let Inst{25-21} = Ra;
196   let Inst{20-13} = LIT;
197   let Inst{12} = 1;
198   let Inst{11-5} = Function;
199   let Inst{4-0} = Rc;
200 }
201
202 //3.3.4
203 class FPForm<bits<6> opcode, bits<11> fun, string asmstr, list<dag> pattern> 
204         : InstAlphaAlt<opcode, asmstr> {
205   let Pattern = pattern;
206
207   bits<5> Fc;
208   bits<5> Fa;
209   bits<5> Fb;
210   bits<11> Function = fun;
211
212   let Inst{25-21} = Fa;
213   let Inst{20-16} = Fb;
214   let Inst{15-5} = Function;
215   let Inst{4-0} = Fc;
216 }
217
218 //3.3.5
219 class PALForm<bits<6> opcode, dag OL, string asmstr> : InstAlpha<opcode, OL, asmstr> {
220   bits<26> Function;
221
222   let Inst{25-0} = Function;
223 }
224
225
226 // Pseudo instructions.
227 class PseudoInstAlpha<dag OL, string nm, list<dag> pattern> : InstAlpha<0, OL, nm>  {
228   let Pattern = pattern;
229
230 }