a64c7a18164f09dbbd804b185a09df3cc169c758
[oota-llvm.git] / lib / Target / Hexagon / HexagonInstrFormats.td
1 //==- HexagonInstrFormats.td - Hexagon Instruction Formats --*- tablegen -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 //===----------------------------------------------------------------------===//
11 //                         Hexagon Intruction Flags +
12 //
13 //                    *** Must match HexagonBaseInfo.h ***
14 //===----------------------------------------------------------------------===//
15
16 class Type<bits<5> t> {
17   bits<5> Value = t;
18 }
19 def TypePSEUDO : Type<0>;
20 def TypeALU32  : Type<1>;
21 def TypeCR     : Type<2>;
22 def TypeJR     : Type<3>;
23 def TypeJ      : Type<4>;
24 def TypeLD     : Type<5>;
25 def TypeST     : Type<6>;
26 def TypeSYSTEM : Type<7>;
27 def TypeXTYPE  : Type<8>;
28 def TypeMARKER : Type<31>;
29
30 //===----------------------------------------------------------------------===//
31 //                         Intruction Class Declaration +
32 //===----------------------------------------------------------------------===//
33
34 class InstHexagon<dag outs, dag ins, string asmstr, list<dag> pattern,
35                   string cstr, InstrItinClass itin, Type type> : Instruction {
36   field bits<32> Inst;
37
38   let Namespace = "Hexagon";
39
40   dag OutOperandList = outs;
41   dag InOperandList = ins;
42   let AsmString = asmstr;
43   let Pattern = pattern;
44   let Constraints = cstr;
45   let Itinerary = itin;
46   let Size = 4;
47
48   // *** Must match HexagonBaseInfo.h ***
49   // Instruction type according to the ISA.
50   Type HexagonType = type;
51   let TSFlags{4-0} = HexagonType.Value;
52   // Solo instructions, i.e., those that cannot be in a packet with others.
53   bits<1> isHexagonSolo = 0;
54   let TSFlags{5} = isHexagonSolo;
55   // Predicated instructions.
56   bits<1> isPredicated = 0;
57   let TSFlags{6} = isPredicated;
58
59   // Dot new value store instructions.
60   bits<1> isNVStore = 0;
61   let TSFlags{8} = isNVStore;
62
63   // Fields used for relation models.
64   string BaseOpcode = "";
65   string CextOpcode = "";
66   string PredSense = "";
67   string PNewValue = "";
68   string InputType = "";    // Input is "imm" or "reg" type.
69   // *** The code above must match HexagonBaseInfo.h ***
70 }
71
72 //===----------------------------------------------------------------------===//
73 //                         Intruction Classes Definitions +
74 //===----------------------------------------------------------------------===//
75
76 // LD Instruction Class in V2/V3/V4.
77 // Definition of the instruction class NOT CHANGED.
78 class LDInst<dag outs, dag ins, string asmstr, list<dag> pattern>
79   : InstHexagon<outs, ins, asmstr, pattern, "", LD, TypeLD> {
80   bits<5> rd;
81   bits<5> rs;
82   bits<13> imm13;
83 }
84
85 class LDInst2<dag outs, dag ins, string asmstr, list<dag> pattern>
86   : InstHexagon<outs, ins, asmstr, pattern, "", LD, TypeLD> {
87   bits<5> rd;
88   bits<5> rs;
89   bits<13> imm13;
90   let mayLoad = 1;
91 }
92
93 // LD Instruction Class in V2/V3/V4.
94 // Definition of the instruction class NOT CHANGED.
95 class LDInstPost<dag outs, dag ins, string asmstr, list<dag> pattern,
96                  string cstr>
97   : InstHexagon<outs, ins, asmstr, pattern, cstr, LD, TypeLD> {
98   bits<5> rd;
99   bits<5> rs;
100   bits<5> rt;
101   bits<13> imm13;
102 }
103
104 // ST Instruction Class in V2/V3 can take SLOT0 only.
105 // ST Instruction Class in V4    can take SLOT0 & SLOT1.
106 // Definition of the instruction class CHANGED from V2/V3 to V4.
107 class STInst<dag outs, dag ins, string asmstr, list<dag> pattern>
108   : InstHexagon<outs, ins, asmstr, pattern, "", ST, TypeST> {
109   bits<5> rd;
110   bits<5> rs;
111   bits<13> imm13;
112 }
113
114 class STInst2<dag outs, dag ins, string asmstr, list<dag> pattern>
115   : InstHexagon<outs, ins, asmstr, pattern, "", ST, TypeST> {
116   bits<5> rd;
117   bits<5> rs;
118   bits<13> imm13;
119   let mayStore = 1;
120 }
121
122 // SYSTEM Instruction Class in V4 can take SLOT0 only
123 // In V2/V3 we used ST for this but in v4 ST can take SLOT0 or SLOT1.
124 class SYSInst<dag outs, dag ins, string asmstr, list<dag> pattern>
125   : InstHexagon<outs, ins, asmstr, pattern, "", SYS, TypeSYSTEM> {
126   bits<5> rd;
127   bits<5> rs;
128   bits<13> imm13;
129 }
130
131 // ST Instruction Class in V2/V3 can take SLOT0 only.
132 // ST Instruction Class in V4    can take SLOT0 & SLOT1.
133 // Definition of the instruction class CHANGED from V2/V3 to V4.
134 class STInstPost<dag outs, dag ins, string asmstr, list<dag> pattern,
135                  string cstr>
136   : InstHexagon<outs, ins, asmstr, pattern, cstr, ST, TypeST> {
137   bits<5> rd;
138   bits<5> rs;
139   bits<5> rt;
140   bits<13> imm13;
141 }
142
143 // ALU32 Instruction Class in V2/V3/V4.
144 // Definition of the instruction class NOT CHANGED.
145 class ALU32Type<dag outs, dag ins, string asmstr, list<dag> pattern>
146    : InstHexagon<outs, ins, asmstr, pattern, "", ALU32, TypeALU32> {
147   bits<5>  rd;
148   bits<5>  rs;
149   bits<5>  rt;
150   bits<16> imm16;
151   bits<16> imm16_2;
152 }
153
154 // ALU64 Instruction Class in V2/V3.
155 // XTYPE Instruction Class in V4.
156 // Definition of the instruction class NOT CHANGED.
157 // Name of the Instruction Class changed from ALU64 to XTYPE from V2/V3 to V4.
158 class ALU64Type<dag outs, dag ins, string asmstr, list<dag> pattern>
159    : InstHexagon<outs, ins, asmstr, pattern, "", ALU64, TypeXTYPE> {
160   bits<5>  rd;
161   bits<5>  rs;
162   bits<5>  rt;
163   bits<16> imm16;
164   bits<16> imm16_2;
165 }
166
167 class ALU64_acc<dag outs, dag ins, string asmstr, list<dag> pattern,
168    string cstr>
169    : InstHexagon<outs, ins, asmstr, pattern, cstr, ALU64, TypeXTYPE> {
170   bits<5>  rd;
171   bits<5>  rs;
172   bits<5>  rt;
173   bits<16> imm16;
174   bits<16> imm16_2;
175 }
176
177 // M Instruction Class in V2/V3.
178 // XTYPE Instruction Class in V4.
179 // Definition of the instruction class NOT CHANGED.
180 // Name of the Instruction Class changed from M to XTYPE from V2/V3 to V4.
181 class MInst<dag outs, dag ins, string asmstr, list<dag> pattern>
182   : InstHexagon<outs, ins, asmstr, pattern, "", M, TypeXTYPE> {
183   bits<5> rd;
184   bits<5> rs;
185   bits<5> rt;
186 }
187
188 // M Instruction Class in V2/V3.
189 // XTYPE Instruction Class in V4.
190 // Definition of the instruction class NOT CHANGED.
191 // Name of the Instruction Class changed from M to XTYPE from V2/V3 to V4.
192 class MInst_acc<dag outs, dag ins, string asmstr, list<dag> pattern,
193     string cstr>
194     : InstHexagon<outs, ins, asmstr, pattern, cstr, M, TypeXTYPE> {
195   bits<5> rd;
196   bits<5> rs;
197   bits<5> rt;
198 }
199
200 // S Instruction Class in V2/V3.
201 // XTYPE Instruction Class in V4.
202 // Definition of the instruction class NOT CHANGED.
203 // Name of the Instruction Class changed from S to XTYPE from V2/V3 to V4.
204 class SInst<dag outs, dag ins, string asmstr, list<dag> pattern>
205   : InstHexagon<outs, ins, asmstr, pattern, "", S, TypeXTYPE> {
206   bits<5> rd;
207   bits<5> rs;
208   bits<5> rt;
209 }
210
211 // S Instruction Class in V2/V3.
212 // XTYPE Instruction Class in V4.
213 // Definition of the instruction class NOT CHANGED.
214 // Name of the Instruction Class changed from S to XTYPE from V2/V3 to V4.
215 class SInst_acc<dag outs, dag ins, string asmstr, list<dag> pattern,
216    string cstr>
217   : InstHexagon<outs, ins, asmstr, pattern, cstr, S, TypeXTYPE> {
218 //  : InstHexagon<outs, ins, asmstr, pattern, cstr,  S> {
219 //  : InstHexagon<outs, ins, asmstr, pattern, cstr, !if(V4T, XTYPE_V4, S)> {
220   bits<5> rd;
221   bits<5> rs;
222   bits<5> rt;
223 }
224
225 // J Instruction Class in V2/V3/V4.
226 // Definition of the instruction class NOT CHANGED.
227 class JType<dag outs, dag ins, string asmstr, list<dag> pattern>
228   : InstHexagon<outs, ins, asmstr, pattern, "", J, TypeJ> {
229   bits<16> imm16;
230 }
231
232 // JR Instruction Class in V2/V3/V4.
233 // Definition of the instruction class NOT CHANGED.
234 class JRType<dag outs, dag ins, string asmstr, list<dag> pattern>
235   : InstHexagon<outs, ins, asmstr, pattern, "", JR, TypeJR> {
236   bits<5>  rs;
237   bits<5>  pu; // Predicate register
238 }
239
240 // CR Instruction Class in V2/V3/V4.
241 // Definition of the instruction class NOT CHANGED.
242 class CRInst<dag outs, dag ins, string asmstr, list<dag> pattern>
243   : InstHexagon<outs, ins, asmstr, pattern, "", CR, TypeCR> {
244   bits<5> rs;
245   bits<10> imm10;
246 }
247
248 class Marker<dag outs, dag ins, string asmstr, list<dag> pattern>
249   : InstHexagon<outs, ins, asmstr, pattern, "", MARKER, TypeMARKER> {
250   let isCodeGenOnly = 1;
251   let isPseudo = 1;
252 }
253
254 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
255   : InstHexagon<outs, ins, asmstr, pattern, "", PSEUDO, TypePSEUDO> {
256   let isCodeGenOnly = 1;
257   let isPseudo = 1;
258 }
259
260 //===----------------------------------------------------------------------===//
261 //                         Intruction Classes Definitions -
262 //===----------------------------------------------------------------------===//
263
264
265 //
266 // ALU32 patterns
267 //.
268 class ALU32_rr<dag outs, dag ins, string asmstr, list<dag> pattern>
269    : ALU32Type<outs, ins, asmstr, pattern> {
270 }
271
272 class ALU32_ir<dag outs, dag ins, string asmstr, list<dag> pattern>
273    : ALU32Type<outs, ins, asmstr, pattern> {
274    let rt{0-4} = 0;
275 }
276
277 class ALU32_ri<dag outs, dag ins, string asmstr, list<dag> pattern>
278    : ALU32Type<outs, ins, asmstr, pattern> {
279   let rt{0-4} = 0;
280 }
281
282 class ALU32_ii<dag outs, dag ins, string asmstr, list<dag> pattern>
283    : ALU32Type<outs, ins, asmstr, pattern> {
284   let rt{0-4} = 0;
285 }
286
287 //
288 // ALU64 patterns.
289 //
290 class ALU64_rr<dag outs, dag ins, string asmstr, list<dag> pattern>
291    : ALU64Type<outs, ins, asmstr, pattern> {
292 }
293
294 class ALU64_ri<dag outs, dag ins, string asmstr, list<dag> pattern>
295    : ALU64Type<outs, ins, asmstr, pattern> {
296   let rt{0-4} = 0;
297 }
298
299 // J Type Instructions.
300 class JInst<dag outs, dag ins, string asmstr, list<dag> pattern>
301   : JType<outs, ins, asmstr, pattern> {
302 }
303
304 // JR type Instructions.
305 class JRInst<dag outs, dag ins, string asmstr, list<dag> pattern>
306   : JRType<outs, ins, asmstr, pattern> {
307 }
308
309
310 // Post increment ST Instruction.
311 class STInstPI<dag outs, dag ins, string asmstr, list<dag> pattern,
312                string cstr>
313   : STInstPost<outs, ins, asmstr, pattern, cstr> {
314   let rt{0-4} = 0;
315 }
316
317 class STInst2PI<dag outs, dag ins, string asmstr, list<dag> pattern,
318                 string cstr>
319   : STInstPost<outs, ins, asmstr, pattern, cstr> {
320   let rt{0-4} = 0;
321   let mayStore = 1;
322 }
323
324 // Post increment LD Instruction.
325 class LDInstPI<dag outs, dag ins, string asmstr, list<dag> pattern,
326                string cstr>
327   : LDInstPost<outs, ins, asmstr, pattern, cstr> {
328   let rt{0-4} = 0;
329 }
330
331 class LDInst2PI<dag outs, dag ins, string asmstr, list<dag> pattern,
332                 string cstr>
333   : LDInstPost<outs, ins, asmstr, pattern, cstr> {
334   let rt{0-4} = 0;
335   let mayLoad = 1;
336 }
337
338 //===----------------------------------------------------------------------===//
339 // V4 Instruction Format Definitions +
340 //===----------------------------------------------------------------------===//
341
342 include "HexagonInstrFormatsV4.td"
343
344 //===----------------------------------------------------------------------===//
345 // V4 Instruction Format Definitions +
346 //===----------------------------------------------------------------------===//