1 //===- HexagonImmediates.td - Hexagon immediate processing -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illnois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 def s32_0ImmOperand : AsmOperandClass { let Name = "s32_0Imm"; }
11 def s23_2ImmOperand : AsmOperandClass { let Name = "s23_2Imm"; }
12 def s8_0ImmOperand : AsmOperandClass { let Name = "s8_0Imm"; }
13 def s8_0Imm64Operand : AsmOperandClass { let Name = "s8_0Imm64"; }
14 def s6_0ImmOperand : AsmOperandClass { let Name = "s6_0Imm"; }
15 def s4_0ImmOperand : AsmOperandClass { let Name = "s4_0Imm"; }
16 def s4_1ImmOperand : AsmOperandClass { let Name = "s4_1Imm"; }
17 def s4_2ImmOperand : AsmOperandClass { let Name = "s4_2Imm"; }
18 def s4_3ImmOperand : AsmOperandClass { let Name = "s4_3Imm"; }
19 def s4_6ImmOperand : AsmOperandClass { let Name = "s4_6Imm"; }
20 def s3_6ImmOperand : AsmOperandClass { let Name = "s3_6Imm"; }
21 def u64_0ImmOperand : AsmOperandClass { let Name = "u64_0Imm"; }
22 def u32_0ImmOperand : AsmOperandClass { let Name = "u32_0Imm"; }
23 def u26_6ImmOperand : AsmOperandClass { let Name = "u26_6Imm"; }
24 def u16_0ImmOperand : AsmOperandClass { let Name = "u16_0Imm"; }
25 def u16_1ImmOperand : AsmOperandClass { let Name = "u16_1Imm"; }
26 def u16_2ImmOperand : AsmOperandClass { let Name = "u16_2Imm"; }
27 def u16_3ImmOperand : AsmOperandClass { let Name = "u16_3Imm"; }
28 def u11_3ImmOperand : AsmOperandClass { let Name = "u11_3Imm"; }
29 def u10_0ImmOperand : AsmOperandClass { let Name = "u10_0Imm"; }
30 def u9_0ImmOperand : AsmOperandClass { let Name = "u9_0Imm"; }
31 def u8_0ImmOperand : AsmOperandClass { let Name = "u8_0Imm"; }
32 def u7_0ImmOperand : AsmOperandClass { let Name = "u7_0Imm"; }
33 def u6_0ImmOperand : AsmOperandClass { let Name = "u6_0Imm"; }
34 def u6_1ImmOperand : AsmOperandClass { let Name = "u6_1Imm"; }
35 def u6_2ImmOperand : AsmOperandClass { let Name = "u6_2Imm"; }
36 def u6_3ImmOperand : AsmOperandClass { let Name = "u6_3Imm"; }
37 def u5_0ImmOperand : AsmOperandClass { let Name = "u5_0Imm"; }
38 def u4_0ImmOperand : AsmOperandClass { let Name = "u4_0Imm"; }
39 def u3_0ImmOperand : AsmOperandClass { let Name = "u3_0Imm"; }
40 def u2_0ImmOperand : AsmOperandClass { let Name = "u2_0Imm"; }
41 def u1_0ImmOperand : AsmOperandClass { let Name = "u1_0Imm"; }
42 def n8_0ImmOperand : AsmOperandClass { let Name = "n8_0Imm"; }
43 // Immediate operands.
45 let OperandType = "OPERAND_IMMEDIATE",
46 DecoderMethod = "unsignedImmDecoder" in {
47 def s32_0Imm : Operand<i32> { let ParserMatchClass = s32_0ImmOperand;
48 let DecoderMethod = "s32_0ImmDecoder"; }
49 def s23_2Imm : Operand<i32> { let ParserMatchClass = s23_2ImmOperand; }
50 def s8_0Imm : Operand<i32> { let ParserMatchClass = s8_0ImmOperand;
51 let DecoderMethod = "s8_0ImmDecoder"; }
52 def s8_0Imm64 : Operand<i64> { let ParserMatchClass = s8_0Imm64Operand;
53 let DecoderMethod = "s8_0ImmDecoder"; }
54 def s6_0Imm : Operand<i32> { let ParserMatchClass = s6_0ImmOperand;
55 let DecoderMethod = "s6_0ImmDecoder"; }
56 def s6_3Imm : Operand<i32>;
57 def s4_0Imm : Operand<i32> { let ParserMatchClass = s4_0ImmOperand;
58 let DecoderMethod = "s4_0ImmDecoder"; }
59 def s4_1Imm : Operand<i32> { let ParserMatchClass = s4_1ImmOperand;
60 let DecoderMethod = "s4_1ImmDecoder"; }
61 def s4_2Imm : Operand<i32> { let ParserMatchClass = s4_2ImmOperand;
62 let DecoderMethod = "s4_2ImmDecoder"; }
63 def s4_3Imm : Operand<i32> { let ParserMatchClass = s4_3ImmOperand;
64 let DecoderMethod = "s4_3ImmDecoder"; }
65 def u64_0Imm : Operand<i64> { let ParserMatchClass = u64_0ImmOperand; }
66 def u32_0Imm : Operand<i32> { let ParserMatchClass = u32_0ImmOperand; }
67 def u26_6Imm : Operand<i32> { let ParserMatchClass = u26_6ImmOperand; }
68 def u16_0Imm : Operand<i32> { let ParserMatchClass = u16_0ImmOperand; }
69 def u16_1Imm : Operand<i32> { let ParserMatchClass = u16_1ImmOperand; }
70 def u16_2Imm : Operand<i32> { let ParserMatchClass = u16_2ImmOperand; }
71 def u16_3Imm : Operand<i32> { let ParserMatchClass = u16_3ImmOperand; }
72 def u11_3Imm : Operand<i32> { let ParserMatchClass = u11_3ImmOperand; }
73 def u10_0Imm : Operand<i32> { let ParserMatchClass = u10_0ImmOperand; }
74 def u9_0Imm : Operand<i32> { let ParserMatchClass = u9_0ImmOperand; }
75 def u8_0Imm : Operand<i32> { let ParserMatchClass = u8_0ImmOperand; }
76 def u7_0Imm : Operand<i32> { let ParserMatchClass = u7_0ImmOperand; }
77 def u6_0Imm : Operand<i32> { let ParserMatchClass = u6_0ImmOperand; }
78 def u6_1Imm : Operand<i32> { let ParserMatchClass = u6_1ImmOperand; }
79 def u6_2Imm : Operand<i32> { let ParserMatchClass = u6_2ImmOperand; }
80 def u6_3Imm : Operand<i32> { let ParserMatchClass = u6_3ImmOperand; }
81 def u5_0Imm : Operand<i32> { let ParserMatchClass = u5_0ImmOperand; }
82 def u5_1Imm : Operand<i32>;
83 def u5_2Imm : Operand<i32>;
84 def u5_3Imm : Operand<i32>;
85 def u4_0Imm : Operand<i32> { let ParserMatchClass = u4_0ImmOperand; }
86 def u4_1Imm : Operand<i32>;
87 def u4_2Imm : Operand<i32>;
88 def u4_3Imm : Operand<i32>;
89 def u3_0Imm : Operand<i32> { let ParserMatchClass = u3_0ImmOperand; }
90 def u3_1Imm : Operand<i32>;
91 def u3_2Imm : Operand<i32>;
92 def u3_3Imm : Operand<i32>;
93 def u2_0Imm : Operand<i32> { let ParserMatchClass = u2_0ImmOperand; }
94 def u1_0Imm : Operand<i32> { let ParserMatchClass = u1_0ImmOperand; }
95 def n8_0Imm : Operand<i32> { let ParserMatchClass = n8_0ImmOperand; }
98 let OperandType = "OPERAND_IMMEDIATE" in {
99 def s4_6Imm : Operand<i32> { let ParserMatchClass = s4_6ImmOperand;
100 let PrintMethod = "prints4_6ImmOperand";
101 let DecoderMethod = "s4_6ImmDecoder";}
102 def s4_7Imm : Operand<i32> { let PrintMethod = "prints4_7ImmOperand";
103 let DecoderMethod = "s4_6ImmDecoder";}
104 def s3_6Imm : Operand<i32> { let ParserMatchClass = s3_6ImmOperand;
105 let PrintMethod = "prints3_6ImmOperand";
106 let DecoderMethod = "s3_6ImmDecoder";}
107 def s3_7Imm : Operand<i32> { let PrintMethod = "prints3_7ImmOperand";
108 let DecoderMethod = "s3_6ImmDecoder";}
110 def n1ConstOperand : AsmOperandClass { let Name = "n1Const"; }
111 def n1Const : Operand<i32> { let ParserMatchClass = n1ConstOperand; }
114 // Immediate predicates
116 def s32_0ImmPred : PatLeaf<(i32 imm), [{
117 int64_t v = (int64_t)N->getSExtValue();
121 def s31_1ImmPred : PatLeaf<(i32 imm), [{
122 int64_t v = (int64_t)N->getSExtValue();
123 return isShiftedInt<31,1>(v);
126 def s30_2ImmPred : PatLeaf<(i32 imm), [{
127 int64_t v = (int64_t)N->getSExtValue();
128 return isShiftedInt<30,2>(v);
131 def s29_3ImmPred : PatLeaf<(i32 imm), [{
132 int64_t v = (int64_t)N->getSExtValue();
133 return isShiftedInt<29,3>(v);
136 def s10_0ImmPred : PatLeaf<(i32 imm), [{
137 int64_t v = (int64_t)N->getSExtValue();
141 def s8_0ImmPred : PatLeaf<(i32 imm), [{
142 int64_t v = (int64_t)N->getSExtValue();
146 def s8_0Imm64Pred : PatLeaf<(i64 imm), [{
147 int64_t v = (int64_t)N->getSExtValue();
151 def s6_0ImmPred : PatLeaf<(i32 imm), [{
152 int64_t v = (int64_t)N->getSExtValue();
156 def s4_0ImmPred : PatLeaf<(i32 imm), [{
157 int64_t v = (int64_t)N->getSExtValue();
161 def s4_1ImmPred : PatLeaf<(i32 imm), [{
162 int64_t v = (int64_t)N->getSExtValue();
163 return isShiftedInt<4,1>(v);
166 def s4_2ImmPred : PatLeaf<(i32 imm), [{
167 int64_t v = (int64_t)N->getSExtValue();
168 return isShiftedInt<4,2>(v);
171 def s4_3ImmPred : PatLeaf<(i32 imm), [{
172 int64_t v = (int64_t)N->getSExtValue();
173 return isShiftedInt<4,3>(v);
176 def u32_0ImmPred : PatLeaf<(i32 imm), [{
177 int64_t v = (int64_t)N->getSExtValue();
178 return isUInt<32>(v);
181 def u16_0ImmPred : PatLeaf<(i32 imm), [{
182 int64_t v = (int64_t)N->getSExtValue();
183 return isUInt<16>(v);
186 def u11_3ImmPred : PatLeaf<(i32 imm), [{
187 int64_t v = (int64_t)N->getSExtValue();
188 return isShiftedUInt<11,3>(v);
191 def u9_0ImmPred : PatLeaf<(i32 imm), [{
192 int64_t v = (int64_t)N->getSExtValue();
196 def u8_0ImmPred : PatLeaf<(i32 imm), [{
197 int64_t v = (int64_t)N->getSExtValue();
201 def u6_0ImmPred : PatLeaf<(i32 imm), [{
202 int64_t v = (int64_t)N->getSExtValue();
206 def u6_1ImmPred : PatLeaf<(i32 imm), [{
207 int64_t v = (int64_t)N->getSExtValue();
208 return isShiftedUInt<6,1>(v);
211 def u6_2ImmPred : PatLeaf<(i32 imm), [{
212 int64_t v = (int64_t)N->getSExtValue();
213 return isShiftedUInt<6,2>(v);
216 def u5_0ImmPred : PatLeaf<(i32 imm), [{
217 int64_t v = (int64_t)N->getSExtValue();
221 def u4_0ImmPred : PatLeaf<(i32 imm), [{
222 int64_t v = (int64_t)N->getSExtValue();
226 def u3_0ImmPred : PatLeaf<(i32 imm), [{
227 int64_t v = (int64_t)N->getSExtValue();
231 def u2_0ImmPred : PatLeaf<(i32 imm), [{
232 int64_t v = (int64_t)N->getSExtValue();
236 // Extendable immediate operands.
237 def f32ExtOperand : AsmOperandClass { let Name = "f32Ext"; }
238 def s16_0ExtOperand : AsmOperandClass { let Name = "s16_0Ext"; }
239 def s12_0ExtOperand : AsmOperandClass { let Name = "s12_0Ext"; }
240 def s10_0ExtOperand : AsmOperandClass { let Name = "s10_0Ext"; }
241 def s9_0ExtOperand : AsmOperandClass { let Name = "s9_0Ext"; }
242 def s8_0ExtOperand : AsmOperandClass { let Name = "s8_0Ext"; }
243 def s7_0ExtOperand : AsmOperandClass { let Name = "s7_0Ext"; }
244 def s6_0ExtOperand : AsmOperandClass { let Name = "s6_0Ext"; }
245 def s11_0ExtOperand : AsmOperandClass { let Name = "s11_0Ext"; }
246 def s11_1ExtOperand : AsmOperandClass { let Name = "s11_1Ext"; }
247 def s11_2ExtOperand : AsmOperandClass { let Name = "s11_2Ext"; }
248 def s11_3ExtOperand : AsmOperandClass { let Name = "s11_3Ext"; }
249 def u6_0ExtOperand : AsmOperandClass { let Name = "u6_0Ext"; }
250 def u7_0ExtOperand : AsmOperandClass { let Name = "u7_0Ext"; }
251 def u8_0ExtOperand : AsmOperandClass { let Name = "u8_0Ext"; }
252 def u9_0ExtOperand : AsmOperandClass { let Name = "u9_0Ext"; }
253 def u10_0ExtOperand : AsmOperandClass { let Name = "u10_0Ext"; }
254 def u6_1ExtOperand : AsmOperandClass { let Name = "u6_1Ext"; }
255 def u6_2ExtOperand : AsmOperandClass { let Name = "u6_2Ext"; }
256 def u6_3ExtOperand : AsmOperandClass { let Name = "u6_3Ext"; }
257 def u32_0MustExtOperand : AsmOperandClass { let Name = "u32_0MustExt"; }
261 let OperandType = "OPERAND_IMMEDIATE", PrintMethod = "printExtOperand",
262 DecoderMethod = "unsignedImmDecoder" in {
263 def f32Ext : Operand<f32> { let ParserMatchClass = f32ExtOperand; }
264 def s16_0Ext : Operand<i32> { let ParserMatchClass = s16_0ExtOperand;
265 let DecoderMethod = "s16_0ImmDecoder"; }
266 def s12_0Ext : Operand<i32> { let ParserMatchClass = s12_0ExtOperand;
267 let DecoderMethod = "s12_0ImmDecoder"; }
268 def s11_0Ext : Operand<i32> { let ParserMatchClass = s11_0ExtOperand;
269 let DecoderMethod = "s11_0ImmDecoder"; }
270 def s11_1Ext : Operand<i32> { let ParserMatchClass = s11_1ExtOperand;
271 let DecoderMethod = "s11_1ImmDecoder"; }
272 def s11_2Ext : Operand<i32> { let ParserMatchClass = s11_2ExtOperand;
273 let DecoderMethod = "s11_2ImmDecoder"; }
274 def s11_3Ext : Operand<i32> { let ParserMatchClass = s11_3ExtOperand;
275 let DecoderMethod = "s11_3ImmDecoder"; }
276 def s10_0Ext : Operand<i32> { let ParserMatchClass = s10_0ExtOperand;
277 let DecoderMethod = "s10_0ImmDecoder"; }
278 def s9_0Ext : Operand<i32> { let ParserMatchClass = s9_0ExtOperand;
279 let DecoderMethod = "s9_0ImmDecoder"; }
280 def s8_0Ext : Operand<i32> { let ParserMatchClass = s8_0ExtOperand;
281 let DecoderMethod = "s8_0ImmDecoder"; }
282 def s7_0Ext : Operand<i32> { let ParserMatchClass = s7_0ExtOperand; }
283 def s6_0Ext : Operand<i32> { let ParserMatchClass = s6_0ExtOperand;
284 let DecoderMethod = "s6_0ImmDecoder"; }
285 def u7_0Ext : Operand<i32> { let ParserMatchClass = u7_0ExtOperand; }
286 def u8_0Ext : Operand<i32> { let ParserMatchClass = u8_0ExtOperand; }
287 def u9_0Ext : Operand<i32> { let ParserMatchClass = u9_0ExtOperand; }
288 def u10_0Ext : Operand<i32> { let ParserMatchClass = u10_0ExtOperand; }
289 def u6_0Ext : Operand<i32> { let ParserMatchClass = u6_0ExtOperand; }
290 def u6_1Ext : Operand<i32> { let ParserMatchClass = u6_1ExtOperand; }
291 def u6_2Ext : Operand<i32> { let ParserMatchClass = u6_2ExtOperand; }
292 def u6_3Ext : Operand<i32> { let ParserMatchClass = u6_3ExtOperand; }
293 def u32_0MustExt : Operand<i32> { let ParserMatchClass = u32_0MustExtOperand; }
297 // This complex pattern exists only to create a machine instruction operand
298 // of type "frame index". There doesn't seem to be a way to do that directly
300 def AddrFI : ComplexPattern<i32, 1, "SelectAddrFI", [frameindex], []>;
302 // These complex patterns are not strictly necessary, since global address
303 // folding will happen during DAG combining. For distinguishing between GA
304 // and GP, pat frags with HexagonCONST32 and HexagonCONST32_GP can be used.
305 def AddrGA : ComplexPattern<i32, 1, "SelectAddrGA", [], []>;
306 def AddrGP : ComplexPattern<i32, 1, "SelectAddrGP", [], []>;
310 let PrintMethod = "printGlobalOperand" in {
311 def globaladdress : Operand<i32>;
312 def globaladdressExt : Operand<i32>;
315 let PrintMethod = "printJumpTable" in
316 def jumptablebase : Operand<i32>;
318 def brtarget : Operand<OtherVT> {
319 let DecoderMethod = "brtargetDecoder";
320 let PrintMethod = "printBrtarget";
322 def brtargetExt : Operand<OtherVT> {
323 let DecoderMethod = "brtargetDecoder";
324 let PrintMethod = "printBrtarget";
326 def calltarget : Operand<i32> {
327 let DecoderMethod = "brtargetDecoder";
328 let PrintMethod = "printBrtarget";
331 def bblabel : Operand<i32>;
332 def bbl : SDNode<"ISD::BasicBlock", SDTPtrLeaf, [], "BasicBlockSDNode">;