Hexagon V5 (floating point) support.
[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
47   // *** Must match HexagonBaseInfo.h ***
48   Type HexagonType = type;
49   let TSFlags{4-0} = HexagonType.Value;
50   bits<1> isHexagonSolo = 0;
51   let TSFlags{5} = isHexagonSolo;
52
53   // Predicated instructions.
54   bits<1> isPredicated = 0;
55   let TSFlags{6} = isPredicated;
56
57   // *** The code above must match HexagonBaseInfo.h ***
58 }
59
60 //===----------------------------------------------------------------------===//
61 //                         Intruction Classes Definitions +
62 //===----------------------------------------------------------------------===//
63
64 // LD Instruction Class in V2/V3/V4.
65 // Definition of the instruction class NOT CHANGED.
66 class LDInst<dag outs, dag ins, string asmstr, list<dag> pattern>
67   : InstHexagon<outs, ins, asmstr, pattern, "", LD, TypeLD> {
68   bits<5> rd;
69   bits<5> rs;
70   bits<13> imm13;
71 }
72
73 class LDInst2<dag outs, dag ins, string asmstr, list<dag> pattern>
74   : InstHexagon<outs, ins, asmstr, pattern, "", LD, TypeLD> {
75   bits<5> rd;
76   bits<5> rs;
77   bits<13> imm13;
78   let mayLoad = 1;
79 }
80
81 // LD Instruction Class in V2/V3/V4.
82 // Definition of the instruction class NOT CHANGED.
83 class LDInstPost<dag outs, dag ins, string asmstr, list<dag> pattern,
84                  string cstr>
85   : InstHexagon<outs, ins, asmstr, pattern, cstr, LD, TypeLD> {
86   bits<5> rd;
87   bits<5> rs;
88   bits<5> rt;
89   bits<13> imm13;
90 }
91
92 // ST Instruction Class in V2/V3 can take SLOT0 only.
93 // ST Instruction Class in V4    can take SLOT0 & SLOT1.
94 // Definition of the instruction class CHANGED from V2/V3 to V4.
95 class STInst<dag outs, dag ins, string asmstr, list<dag> pattern>
96   : InstHexagon<outs, ins, asmstr, pattern, "", ST, TypeST> {
97   bits<5> rd;
98   bits<5> rs;
99   bits<13> imm13;
100 }
101
102 class STInst2<dag outs, dag ins, string asmstr, list<dag> pattern>
103   : InstHexagon<outs, ins, asmstr, pattern, "", ST, TypeST> {
104   bits<5> rd;
105   bits<5> rs;
106   bits<13> imm13;
107   let mayStore = 1;
108 }
109
110 // SYSTEM Instruction Class in V4 can take SLOT0 only
111 // In V2/V3 we used ST for this but in v4 ST can take SLOT0 or SLOT1.
112 class SYSInst<dag outs, dag ins, string asmstr, list<dag> pattern>
113   : InstHexagon<outs, ins, asmstr, pattern, "", SYS, TypeSYSTEM> {
114   bits<5> rd;
115   bits<5> rs;
116   bits<13> imm13;
117 }
118
119 // ST Instruction Class in V2/V3 can take SLOT0 only.
120 // ST Instruction Class in V4    can take SLOT0 & SLOT1.
121 // Definition of the instruction class CHANGED from V2/V3 to V4.
122 class STInstPost<dag outs, dag ins, string asmstr, list<dag> pattern,
123                  string cstr>
124   : InstHexagon<outs, ins, asmstr, pattern, cstr, ST, TypeST> {
125   bits<5> rd;
126   bits<5> rs;
127   bits<5> rt;
128   bits<13> imm13;
129 }
130
131 // ALU32 Instruction Class in V2/V3/V4.
132 // Definition of the instruction class NOT CHANGED.
133 class ALU32Type<dag outs, dag ins, string asmstr, list<dag> pattern>
134    : InstHexagon<outs, ins, asmstr, pattern, "", ALU32, TypeALU32> {
135   bits<5>  rd;
136   bits<5>  rs;
137   bits<5>  rt;
138   bits<16> imm16;
139   bits<16> imm16_2;
140 }
141
142 // ALU64 Instruction Class in V2/V3.
143 // XTYPE Instruction Class in V4.
144 // Definition of the instruction class NOT CHANGED.
145 // Name of the Instruction Class changed from ALU64 to XTYPE from V2/V3 to V4.
146 class ALU64Type<dag outs, dag ins, string asmstr, list<dag> pattern>
147    : InstHexagon<outs, ins, asmstr, pattern, "", ALU64, TypeXTYPE> {
148   bits<5>  rd;
149   bits<5>  rs;
150   bits<5>  rt;
151   bits<16> imm16;
152   bits<16> imm16_2;
153 }
154
155 class ALU64_acc<dag outs, dag ins, string asmstr, list<dag> pattern,
156    string cstr>
157    : InstHexagon<outs, ins, asmstr, pattern, cstr, ALU64, TypeXTYPE> {
158   bits<5>  rd;
159   bits<5>  rs;
160   bits<5>  rt;
161   bits<16> imm16;
162   bits<16> imm16_2;
163 }
164
165 // M Instruction Class in V2/V3.
166 // XTYPE Instruction Class in V4.
167 // Definition of the instruction class NOT CHANGED.
168 // Name of the Instruction Class changed from M to XTYPE from V2/V3 to V4.
169 class MInst<dag outs, dag ins, string asmstr, list<dag> pattern>
170   : InstHexagon<outs, ins, asmstr, pattern, "", M, TypeXTYPE> {
171   bits<5> rd;
172   bits<5> rs;
173   bits<5> rt;
174 }
175
176 // M Instruction Class in V2/V3.
177 // XTYPE Instruction Class in V4.
178 // Definition of the instruction class NOT CHANGED.
179 // Name of the Instruction Class changed from M to XTYPE from V2/V3 to V4.
180 class MInst_acc<dag outs, dag ins, string asmstr, list<dag> pattern,
181     string cstr>
182     : InstHexagon<outs, ins, asmstr, pattern, cstr, M, TypeXTYPE> {
183   bits<5> rd;
184   bits<5> rs;
185   bits<5> rt;
186 }
187
188 // S 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 S to XTYPE from V2/V3 to V4.
192 class SInst<dag outs, dag ins, string asmstr, list<dag> pattern>
193   : InstHexagon<outs, ins, asmstr, pattern, "", S, TypeXTYPE> {
194   bits<5> rd;
195   bits<5> rs;
196   bits<5> rt;
197 }
198
199 // S Instruction Class in V2/V3.
200 // XTYPE Instruction Class in V4.
201 // Definition of the instruction class NOT CHANGED.
202 // Name of the Instruction Class changed from S to XTYPE from V2/V3 to V4.
203 class SInst_acc<dag outs, dag ins, string asmstr, list<dag> pattern,
204    string cstr>
205   : InstHexagon<outs, ins, asmstr, pattern, cstr, S, TypeXTYPE> {
206 //  : InstHexagon<outs, ins, asmstr, pattern, cstr,  S> {
207 //  : InstHexagon<outs, ins, asmstr, pattern, cstr, !if(V4T, XTYPE_V4, S)> {
208   bits<5> rd;
209   bits<5> rs;
210   bits<5> rt;
211 }
212
213 // J Instruction Class in V2/V3/V4.
214 // Definition of the instruction class NOT CHANGED.
215 class JType<dag outs, dag ins, string asmstr, list<dag> pattern>
216   : InstHexagon<outs, ins, asmstr, pattern, "", J, TypeJ> {
217   bits<16> imm16;
218 }
219
220 // JR Instruction Class in V2/V3/V4.
221 // Definition of the instruction class NOT CHANGED.
222 class JRType<dag outs, dag ins, string asmstr, list<dag> pattern>
223   : InstHexagon<outs, ins, asmstr, pattern, "", JR, TypeJR> {
224   bits<5>  rs;
225   bits<5>  pu; // Predicate register
226 }
227
228 // CR Instruction Class in V2/V3/V4.
229 // Definition of the instruction class NOT CHANGED.
230 class CRInst<dag outs, dag ins, string asmstr, list<dag> pattern>
231   : InstHexagon<outs, ins, asmstr, pattern, "", CR, TypeCR> {
232   bits<5> rs;
233   bits<10> imm10;
234 }
235
236 class Marker<dag outs, dag ins, string asmstr, list<dag> pattern>
237   : InstHexagon<outs, ins, asmstr, pattern, "", MARKER, TypeMARKER> {
238   let isCodeGenOnly = 1;
239   let isPseudo = 1;
240 }
241
242 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
243   : InstHexagon<outs, ins, asmstr, pattern, "", PSEUDO, TypePSEUDO> {
244   let isCodeGenOnly = 1;
245   let isPseudo = 1;
246 }
247
248 //===----------------------------------------------------------------------===//
249 //                         Intruction Classes Definitions -
250 //===----------------------------------------------------------------------===//
251
252
253 //
254 // ALU32 patterns
255 //.
256 class ALU32_rr<dag outs, dag ins, string asmstr, list<dag> pattern>
257    : ALU32Type<outs, ins, asmstr, pattern> {
258 }
259
260 class ALU32_ir<dag outs, dag ins, string asmstr, list<dag> pattern>
261    : ALU32Type<outs, ins, asmstr, pattern> {
262    let rt{0-4} = 0;
263 }
264
265 class ALU32_ri<dag outs, dag ins, string asmstr, list<dag> pattern>
266    : ALU32Type<outs, ins, asmstr, pattern> {
267   let rt{0-4} = 0;
268 }
269
270 class ALU32_ii<dag outs, dag ins, string asmstr, list<dag> pattern>
271    : ALU32Type<outs, ins, asmstr, pattern> {
272   let rt{0-4} = 0;
273 }
274
275 //
276 // ALU64 patterns.
277 //
278 class ALU64_rr<dag outs, dag ins, string asmstr, list<dag> pattern>
279    : ALU64Type<outs, ins, asmstr, pattern> {
280 }
281
282 class ALU64_ri<dag outs, dag ins, string asmstr, list<dag> pattern>
283    : ALU64Type<outs, ins, asmstr, pattern> {
284   let rt{0-4} = 0;
285 }
286
287 // J Type Instructions.
288 class JInst<dag outs, dag ins, string asmstr, list<dag> pattern>
289   : JType<outs, ins, asmstr, pattern> {
290 }
291
292 // JR type Instructions.
293 class JRInst<dag outs, dag ins, string asmstr, list<dag> pattern>
294   : JRType<outs, ins, asmstr, pattern> {
295 }
296
297
298 // Post increment ST Instruction.
299 class STInstPI<dag outs, dag ins, string asmstr, list<dag> pattern, string cstr>
300   : STInstPost<outs, ins, asmstr, pattern, cstr> {
301   let rt{0-4} = 0;
302 }
303
304 class STInst2PI<dag outs, dag ins, string asmstr, list<dag> pattern, string cstr>
305   : STInstPost<outs, ins, asmstr, pattern, cstr> {
306   let rt{0-4} = 0;
307   let mayStore = 1;
308 }
309
310
311
312 // Post increment LD Instruction.
313 class LDInstPI<dag outs, dag ins, string asmstr, list<dag> pattern, string cstr>
314   : LDInstPost<outs, ins, asmstr, pattern, cstr> {
315   let rt{0-4} = 0;
316 }
317
318 class LDInst2PI<dag outs, dag ins, string asmstr, list<dag> pattern, string cstr>
319   : LDInstPost<outs, ins, asmstr, pattern, cstr> {
320   let rt{0-4} = 0;
321   let mayLoad = 1;
322 }
323
324
325 //===----------------------------------------------------------------------===//
326 // V4 Instruction Format Definitions +
327 //===----------------------------------------------------------------------===//
328
329 include "HexagonInstrFormatsV4.td"
330
331 //===----------------------------------------------------------------------===//
332 // V4 Instruction Format Definitions +
333 //===----------------------------------------------------------------------===//