1 //===- HexagonOperands.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 // Immediate operands.
12 let PrintMethod = "printImmOperand" in {
13 // f32Ext type is used to identify constant extended floating point immediates.
14 def f32Ext : Operand<f32>;
15 def s32Imm : Operand<i32>;
16 def s26_6Imm : Operand<i32>;
17 def s16Imm : Operand<i32>;
18 def s12Imm : Operand<i32>;
19 def s11Imm : Operand<i32>;
20 def s11_0Imm : Operand<i32>;
21 def s11_1Imm : Operand<i32>;
22 def s11_2Imm : Operand<i32>;
23 def s11_3Imm : Operand<i32>;
24 def s10Imm : Operand<i32>;
25 def s9Imm : Operand<i32>;
26 def m9Imm : Operand<i32>;
27 def s8Imm : Operand<i32>;
28 def s8Imm64 : Operand<i64>;
29 def s6Imm : Operand<i32>;
30 def s4Imm : Operand<i32>;
31 def s4_0Imm : Operand<i32>;
32 def s4_1Imm : Operand<i32>;
33 def s4_2Imm : Operand<i32>;
34 def s4_3Imm : Operand<i32>;
35 def u64Imm : Operand<i64>;
36 def u32Imm : Operand<i32>;
37 def u26_6Imm : Operand<i32>;
38 def u16Imm : Operand<i32>;
39 def u16_0Imm : Operand<i32>;
40 def u16_1Imm : Operand<i32>;
41 def u16_2Imm : Operand<i32>;
42 def u11_3Imm : Operand<i32>;
43 def u10Imm : Operand<i32>;
44 def u9Imm : Operand<i32>;
45 def u8Imm : Operand<i32>;
46 def u7Imm : Operand<i32>;
47 def u6Imm : Operand<i32>;
48 def u6_0Imm : Operand<i32>;
49 def u6_1Imm : Operand<i32>;
50 def u6_2Imm : Operand<i32>;
51 def u6_3Imm : Operand<i32>;
52 def u5Imm : Operand<i32>;
53 def u4Imm : Operand<i32>;
54 def u3Imm : Operand<i32>;
55 def u2Imm : Operand<i32>;
56 def u1Imm : Operand<i32>;
57 def n8Imm : Operand<i32>;
58 def m6Imm : Operand<i32>;
61 let PrintMethod = "printNOneImmOperand" in
62 def nOneImm : Operand<i32>;
65 // Immediate predicates
67 def s32ImmPred : PatLeaf<(i32 imm), [{
68 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
70 int64_t v = (int64_t)N->getSExtValue();
74 def s32_24ImmPred : PatLeaf<(i32 imm), [{
75 // s32_24ImmPred predicate - True if the immediate fits in a 32-bit sign
76 // extended field that is a multiple of 0x1000000.
77 int64_t v = (int64_t)N->getSExtValue();
78 return isShiftedInt<32,24>(v);
81 def s32_16s8ImmPred : PatLeaf<(i32 imm), [{
82 // s32_16s8ImmPred predicate - True if the immediate fits in a 32-bit sign
83 // extended field that is a multiple of 0x10000.
84 int64_t v = (int64_t)N->getSExtValue();
85 return isShiftedInt<24,16>(v);
88 def s16ImmPred : PatLeaf<(i32 imm), [{
89 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
91 int64_t v = (int64_t)N->getSExtValue();
96 def s13ImmPred : PatLeaf<(i32 imm), [{
97 // immS13 predicate - True if the immediate fits in a 13-bit sign extended
99 int64_t v = (int64_t)N->getSExtValue();
104 def s12ImmPred : PatLeaf<(i32 imm), [{
105 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
107 int64_t v = (int64_t)N->getSExtValue();
111 def s11_0ImmPred : PatLeaf<(i32 imm), [{
112 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
114 int64_t v = (int64_t)N->getSExtValue();
119 def s11_1ImmPred : PatLeaf<(i32 imm), [{
120 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
122 int64_t v = (int64_t)N->getSExtValue();
123 return isShiftedInt<11,1>(v);
127 def s11_2ImmPred : PatLeaf<(i32 imm), [{
128 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
130 int64_t v = (int64_t)N->getSExtValue();
131 return isShiftedInt<11,2>(v);
135 def s11_3ImmPred : PatLeaf<(i32 imm), [{
136 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
138 int64_t v = (int64_t)N->getSExtValue();
139 return isShiftedInt<11,3>(v);
143 def s10ImmPred : PatLeaf<(i32 imm), [{
144 // s10ImmPred predicate - True if the immediate fits in a 10-bit sign extended
146 int64_t v = (int64_t)N->getSExtValue();
151 def s9ImmPred : PatLeaf<(i32 imm), [{
152 // s9ImmPred predicate - True if the immediate fits in a 9-bit sign extended
154 int64_t v = (int64_t)N->getSExtValue();
159 def s8ImmPred : PatLeaf<(i32 imm), [{
160 // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended
162 int64_t v = (int64_t)N->getSExtValue();
167 def s8Imm64Pred : PatLeaf<(i64 imm), [{
168 // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended
170 int64_t v = (int64_t)N->getSExtValue();
175 def s6ImmPred : PatLeaf<(i32 imm), [{
176 // s6ImmPred predicate - True if the immediate fits in a 6-bit sign extended
178 int64_t v = (int64_t)N->getSExtValue();
183 def s4_0ImmPred : PatLeaf<(i32 imm), [{
184 // s4_0ImmPred predicate - True if the immediate fits in a 4-bit sign extended
186 int64_t v = (int64_t)N->getSExtValue();
191 def s4_1ImmPred : PatLeaf<(i32 imm), [{
192 // s4_1ImmPred predicate - True if the immediate fits in a 4-bit sign extended
194 int64_t v = (int64_t)N->getSExtValue();
195 return isShiftedInt<4,1>(v);
199 def s4_2ImmPred : PatLeaf<(i32 imm), [{
200 // s4_2ImmPred predicate - True if the immediate fits in a 4-bit sign extended
201 // field that is a multiple of 4.
202 int64_t v = (int64_t)N->getSExtValue();
203 return isShiftedInt<4,2>(v);
207 def s4_3ImmPred : PatLeaf<(i32 imm), [{
208 // s4_3ImmPred predicate - True if the immediate fits in a 4-bit sign extended
209 // field that is a multiple of 8.
210 int64_t v = (int64_t)N->getSExtValue();
211 return isShiftedInt<4,3>(v);
215 def u64ImmPred : PatLeaf<(i64 imm), [{
216 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
218 // Adding "N ||" to suppress gcc unused warning.
222 def u32ImmPred : PatLeaf<(i32 imm), [{
223 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
225 int64_t v = (int64_t)N->getSExtValue();
226 return isUInt<32>(v);
229 def u16ImmPred : PatLeaf<(i32 imm), [{
230 // u16ImmPred predicate - True if the immediate fits in a 16-bit unsigned
232 int64_t v = (int64_t)N->getSExtValue();
233 return isUInt<16>(v);
236 def u16_s8ImmPred : PatLeaf<(i32 imm), [{
237 // u16_s8ImmPred predicate - True if the immediate fits in a 16-bit sign
238 // extended s8 field.
239 int64_t v = (int64_t)N->getSExtValue();
240 return isShiftedUInt<16,8>(v);
243 def u9ImmPred : PatLeaf<(i32 imm), [{
244 // u9ImmPred predicate - True if the immediate fits in a 9-bit unsigned
246 int64_t v = (int64_t)N->getSExtValue();
251 def u8ImmPred : PatLeaf<(i32 imm), [{
252 // u8ImmPred predicate - True if the immediate fits in a 8-bit unsigned
254 int64_t v = (int64_t)N->getSExtValue();
258 def u7ImmPred : PatLeaf<(i32 imm), [{
259 // u7ImmPred predicate - True if the immediate fits in a 8-bit unsigned
261 int64_t v = (int64_t)N->getSExtValue();
266 def u6ImmPred : PatLeaf<(i32 imm), [{
267 // u6ImmPred predicate - True if the immediate fits in a 6-bit unsigned
269 int64_t v = (int64_t)N->getSExtValue();
273 def u6_0ImmPred : PatLeaf<(i32 imm), [{
274 // u6_0ImmPred predicate - True if the immediate fits in a 6-bit unsigned
275 // field. Same as u6ImmPred.
276 int64_t v = (int64_t)N->getSExtValue();
280 def u6_1ImmPred : PatLeaf<(i32 imm), [{
281 // u6_1ImmPred predicate - True if the immediate fits in a 6-bit unsigned
282 // field that is 1 bit alinged - multiple of 2.
283 int64_t v = (int64_t)N->getSExtValue();
284 return isShiftedUInt<6,1>(v);
287 def u6_2ImmPred : PatLeaf<(i32 imm), [{
288 // u6_2ImmPred predicate - True if the immediate fits in a 6-bit unsigned
289 // field that is 2 bits alinged - multiple of 4.
290 int64_t v = (int64_t)N->getSExtValue();
291 return isShiftedUInt<6,2>(v);
294 def u6_3ImmPred : PatLeaf<(i32 imm), [{
295 // u6_3ImmPred predicate - True if the immediate fits in a 6-bit unsigned
296 // field that is 3 bits alinged - multiple of 8.
297 int64_t v = (int64_t)N->getSExtValue();
298 return isShiftedUInt<6,3>(v);
301 def u5ImmPred : PatLeaf<(i32 imm), [{
302 // u5ImmPred predicate - True if the immediate fits in a 5-bit unsigned
304 int64_t v = (int64_t)N->getSExtValue();
309 def u3ImmPred : PatLeaf<(i32 imm), [{
310 // u3ImmPred predicate - True if the immediate fits in a 3-bit unsigned
312 int64_t v = (int64_t)N->getSExtValue();
317 def u2ImmPred : PatLeaf<(i32 imm), [{
318 // u2ImmPred predicate - True if the immediate fits in a 2-bit unsigned
320 int64_t v = (int64_t)N->getSExtValue();
325 def u1ImmPred : PatLeaf<(i1 imm), [{
326 // u1ImmPred predicate - True if the immediate fits in a 1-bit unsigned
328 int64_t v = (int64_t)N->getSExtValue();
332 def m6ImmPred : PatLeaf<(i32 imm), [{
333 // m6ImmPred predicate - True if the immediate is negative and fits in
334 // a 6-bit negative number.
335 int64_t v = (int64_t)N->getSExtValue();
339 //InN means negative integers in [-(2^N - 1), 0]
340 def n8ImmPred : PatLeaf<(i32 imm), [{
341 // n8ImmPred predicate - True if the immediate fits in a 8-bit signed
343 int64_t v = (int64_t)N->getSExtValue();
344 return (-255 <= v && v <= 0);
347 def nOneImmPred : PatLeaf<(i32 imm), [{
348 // nOneImmPred predicate - True if the immediate is -1.
349 int64_t v = (int64_t)N->getSExtValue();