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