Hexagon backend 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 class InstHexagon<dag outs, dag ins, string asmstr, list<dag> pattern,
11                   string cstr,
12                 InstrItinClass itin> : Instruction {
13   field bits<32> Inst;
14
15   let Namespace = "Hexagon";
16
17 /* Commented out for Hexagon
18   bits<2> op;
19   let Inst{31-30} = op; */              // Top two bits are the 'op' field
20
21   dag OutOperandList = outs;
22   dag InOperandList = ins;
23   let AsmString   = asmstr;
24   let Pattern = pattern;
25   let Constraints = cstr;
26   let Itinerary   = itin;
27 }
28
29 //----------------------------------------------------------------------------//
30 //                         Intruction Classes Definitions +
31 //----------------------------------------------------------------------------//
32
33 // LD Instruction Class in V2/V3/V4.
34 // Definition of the instruction class NOT CHANGED.
35 class LDInst<dag outs, dag ins, string asmstr, list<dag> pattern>
36   : InstHexagon<outs, ins, asmstr, pattern, "", LD> {
37   bits<5> rd;
38   bits<5> rs;
39   bits<13> imm13;
40 }
41
42 // LD Instruction Class in V2/V3/V4.
43 // Definition of the instruction class NOT CHANGED.
44 class LDInstPost<dag outs, dag ins, string asmstr, list<dag> pattern,
45                  string cstr>
46   : InstHexagon<outs, ins, asmstr, pattern, cstr,  LD> {
47   bits<5> rd;
48   bits<5> rs;
49   bits<5> rt;
50   bits<13> imm13;
51 }
52
53 // ST Instruction Class in V2/V3 can take SLOT0 only.
54 // ST Instruction Class in V4    can take SLOT0 & SLOT1.
55 // Definition of the instruction class CHANGED from V2/V3 to V4.
56 class STInst<dag outs, dag ins, string asmstr, list<dag> pattern>
57   : InstHexagon<outs, ins, asmstr, pattern, "",  ST> {
58   bits<5> rd;
59   bits<5> rs;
60   bits<13> imm13;
61 }
62
63 // ST Instruction Class in V2/V3 can take SLOT0 only.
64 // ST Instruction Class in V4    can take SLOT0 & SLOT1.
65 // Definition of the instruction class CHANGED from V2/V3 to V4.
66 class STInstPost<dag outs, dag ins, string asmstr, list<dag> pattern,
67                  string cstr>
68   : InstHexagon<outs, ins, asmstr, pattern, cstr,  ST> {
69   bits<5> rd;
70   bits<5> rs;
71   bits<5> rt;
72   bits<13> imm13;
73 }
74
75 // ALU32 Instruction Class in V2/V3/V4.
76 // Definition of the instruction class NOT CHANGED.
77 class ALU32Type<dag outs, dag ins, string asmstr, list<dag> pattern>
78    : InstHexagon<outs, ins, asmstr, pattern, "",  ALU32> {
79   bits<5>  rd;
80   bits<5>  rs;
81   bits<5>  rt;
82   bits<16> imm16;
83   bits<16> imm16_2;
84 }
85
86 // ALU64 Instruction Class in V2/V3.
87 // XTYPE Instruction Class in V4.
88 // Definition of the instruction class NOT CHANGED.
89 // Name of the Instruction Class changed from ALU64 to XTYPE from V2/V3 to V4.
90 class ALU64Type<dag outs, dag ins, string asmstr, list<dag> pattern>
91    : InstHexagon<outs, ins, asmstr, pattern, "",  ALU64> {
92   bits<5>  rd;
93   bits<5>  rs;
94   bits<5>  rt;
95   bits<16> imm16;
96   bits<16> imm16_2;
97 }
98
99 // M Instruction Class in V2/V3.
100 // XTYPE Instruction Class in V4.
101 // Definition of the instruction class NOT CHANGED.
102 // Name of the Instruction Class changed from M to XTYPE from V2/V3 to V4.
103 class MInst<dag outs, dag ins, string asmstr, list<dag> pattern>
104   : InstHexagon<outs, ins, asmstr, pattern, "",  M> {
105   bits<5> rd;
106   bits<5> rs;
107   bits<5> rt;
108 }
109
110 // M Instruction Class in V2/V3.
111 // XTYPE Instruction Class in V4.
112 // Definition of the instruction class NOT CHANGED.
113 // Name of the Instruction Class changed from M to XTYPE from V2/V3 to V4.
114 class MInst_acc<dag outs, dag ins, string asmstr, list<dag> pattern,
115                 string cstr>
116     : InstHexagon<outs, ins, asmstr, pattern, cstr,  M> {
117   bits<5> rd;
118   bits<5> rs;
119   bits<5> rt;
120 }
121
122 // S Instruction Class in V2/V3.
123 // XTYPE Instruction Class in V4.
124 // Definition of the instruction class NOT CHANGED.
125 // Name of the Instruction Class changed from S to XTYPE from V2/V3 to V4.
126 class SInst<dag outs, dag ins, string asmstr, list<dag> pattern>
127 //: InstHexagon<outs, ins, asmstr, pattern, cstr, !if(V4T, XTYPE_V4, M)> {
128   : InstHexagon<outs, ins, asmstr, pattern, "",  S> {
129 //  : InstHexagon<outs, ins, asmstr, pattern, "", S> {
130   bits<5> rd;
131   bits<5> rs;
132   bits<5> rt;
133 }
134
135 // S Instruction Class in V2/V3.
136 // XTYPE Instruction Class in V4.
137 // Definition of the instruction class NOT CHANGED.
138 // Name of the Instruction Class changed from S to XTYPE from V2/V3 to V4.
139 class SInst_acc<dag outs, dag ins, string asmstr, list<dag> pattern,
140                 string cstr>
141   : InstHexagon<outs, ins, asmstr, pattern, cstr,  S> {
142 //  : InstHexagon<outs, ins, asmstr, pattern, cstr,  S> {
143 //  : InstHexagon<outs, ins, asmstr, pattern, cstr, !if(V4T, XTYPE_V4, S)> {
144   bits<5> rd;
145   bits<5> rs;
146   bits<5> rt;
147 }
148
149 // J Instruction Class in V2/V3/V4.
150 // Definition of the instruction class NOT CHANGED.
151 class JType<dag outs, dag ins, string asmstr, list<dag> pattern>
152   : InstHexagon<outs, ins, asmstr, pattern, "",  J> {
153   bits<16> imm16;
154 }
155
156 // JR Instruction Class in V2/V3/V4.
157 // Definition of the instruction class NOT CHANGED.
158 class JRType<dag outs, dag ins, string asmstr, list<dag> pattern>
159   : InstHexagon<outs, ins, asmstr, pattern, "", JR> {
160   bits<5>  rs;
161   bits<5>  pu; // Predicate register
162 }
163
164 // CR Instruction Class in V2/V3/V4.
165 // Definition of the instruction class NOT CHANGED.
166 class CRInst<dag outs, dag ins, string asmstr, list<dag> pattern>
167   : InstHexagon<outs, ins, asmstr, pattern, "", CR> {
168   bits<5> rs;
169   bits<10> imm10;
170 }
171
172
173 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
174  : InstHexagon<outs, ins, asmstr, pattern, "", PSEUDO>;
175
176
177 //----------------------------------------------------------------------------//
178 //                         Intruction Classes Definitions -
179 //----------------------------------------------------------------------------//
180
181
182 //
183 // ALU32 patterns
184 //.
185 class ALU32_rr<dag outs, dag ins, string asmstr, list<dag> pattern>
186    : ALU32Type<outs, ins, asmstr, pattern> {
187 }
188
189 class ALU32_ir<dag outs, dag ins, string asmstr, list<dag> pattern>
190    : ALU32Type<outs, ins, asmstr, pattern> {
191    let rt{0-4} = 0;
192 }
193
194 class ALU32_ri<dag outs, dag ins, string asmstr, list<dag> pattern>
195    : ALU32Type<outs, ins, asmstr, pattern> {
196   let rt{0-4} = 0;
197 }
198
199 class ALU32_ii<dag outs, dag ins, string asmstr, list<dag> pattern>
200    : ALU32Type<outs, ins, asmstr, pattern> {
201   let rt{0-4} = 0;
202 }
203
204 //
205 // ALU64 patterns.
206 //
207 class ALU64_rr<dag outs, dag ins, string asmstr, list<dag> pattern>
208    : ALU64Type<outs, ins, asmstr, pattern> {
209 }
210
211 // J Type Instructions.
212 class JInst<dag outs, dag ins, string asmstr, list<dag> pattern>
213   : JType<outs, ins, asmstr, pattern> {
214 }
215
216 // JR type Instructions.
217 class JRInst<dag outs, dag ins, string asmstr, list<dag> pattern>
218   : JRType<outs, ins, asmstr, pattern> {
219 }
220
221
222 // Post increment ST Instruction.
223 class STInstPI<dag outs, dag ins, string asmstr, list<dag> pattern, string cstr>
224   : STInstPost<outs, ins, asmstr, pattern, cstr> {
225   let rt{0-4} = 0;
226 }
227
228 // Post increment LD Instruction.
229 class LDInstPI<dag outs, dag ins, string asmstr, list<dag> pattern, string cstr>
230   : LDInstPost<outs, ins, asmstr, pattern, cstr> {
231   let rt{0-4} = 0;
232 }
233
234 //===----------------------------------------------------------------------===//
235 // V4 Instruction Format Definitions +
236 //===----------------------------------------------------------------------===//
237
238 include "HexagonInstrFormatsV4.td"
239
240 //===----------------------------------------------------------------------===//
241 // V4 Instruction Format Definitions +
242 //===----------------------------------------------------------------------===//