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 // From IA64's InstrInfo file
11 def s32Imm : Operand<i32> {
12 // For now, we use a generic print function for all operands.
13 let PrintMethod = "printImmOperand";
16 def s16Imm : Operand<i32> {
17 let PrintMethod = "printImmOperand";
20 def s12Imm : Operand<i32> {
21 // For now, we use a generic print function for all operands.
22 let PrintMethod = "printImmOperand";
25 def s11Imm : Operand<i32> {
26 // For now, we use a generic print function for all operands.
27 let PrintMethod = "printImmOperand";
30 def s11_0Imm : Operand<i32> {
31 // For now, we use a generic print function for all operands.
32 let PrintMethod = "printImmOperand";
35 def s11_1Imm : Operand<i32> {
36 // For now, we use a generic print function for all operands.
37 let PrintMethod = "printImmOperand";
40 def s11_2Imm : Operand<i32> {
41 // For now, we use a generic print function for all operands.
42 let PrintMethod = "printImmOperand";
45 def s11_3Imm : Operand<i32> {
46 // For now, we use a generic print function for all operands.
47 let PrintMethod = "printImmOperand";
50 def s10Imm : Operand<i32> {
51 // For now, we use a generic print function for all operands.
52 let PrintMethod = "printImmOperand";
55 def s9Imm : Operand<i32> {
56 // For now, we use a generic print function for all operands.
57 let PrintMethod = "printImmOperand";
60 def s8Imm : Operand<i32> {
61 // For now, we use a generic print function for all operands.
62 let PrintMethod = "printImmOperand";
65 def s8Imm64 : Operand<i64> {
66 // For now, we use a generic print function for all operands.
67 let PrintMethod = "printImmOperand";
70 def s6Imm : Operand<i32> {
71 // For now, we use a generic print function for all operands.
72 let PrintMethod = "printImmOperand";
75 def s4Imm : Operand<i32> {
76 // For now, we use a generic print function for all operands.
77 let PrintMethod = "printImmOperand";
80 def s4_0Imm : Operand<i32> {
81 // For now, we use a generic print function for all operands.
82 let PrintMethod = "printImmOperand";
85 def s4_1Imm : Operand<i32> {
86 // For now, we use a generic print function for all operands.
87 let PrintMethod = "printImmOperand";
90 def s4_2Imm : Operand<i32> {
91 // For now, we use a generic print function for all operands.
92 let PrintMethod = "printImmOperand";
95 def s4_3Imm : Operand<i32> {
96 // For now, we use a generic print function for all operands.
97 let PrintMethod = "printImmOperand";
100 def u64Imm : Operand<i64> {
101 // For now, we use a generic print function for all operands.
102 let PrintMethod = "printImmOperand";
105 def u32Imm : Operand<i32> {
106 // For now, we use a generic print function for all operands.
107 let PrintMethod = "printImmOperand";
110 def u16Imm : Operand<i32> {
111 // For now, we use a generic print function for all operands.
112 let PrintMethod = "printImmOperand";
115 def u16_0Imm : Operand<i32> {
116 // For now, we use a generic print function for all operands.
117 let PrintMethod = "printImmOperand";
120 def u16_1Imm : Operand<i32> {
121 // For now, we use a generic print function for all operands.
122 let PrintMethod = "printImmOperand";
125 def u16_2Imm : Operand<i32> {
126 // For now, we use a generic print function for all operands.
127 let PrintMethod = "printImmOperand";
130 def u11_3Imm : Operand<i32> {
131 // For now, we use a generic print function for all operands.
132 let PrintMethod = "printImmOperand";
135 def u10Imm : Operand<i32> {
136 // For now, we use a generic print function for all operands.
137 let PrintMethod = "printImmOperand";
140 def u9Imm : Operand<i32> {
141 // For now, we use a generic print function for all operands.
142 let PrintMethod = "printImmOperand";
145 def u8Imm : Operand<i32> {
146 // For now, we use a generic print function for all operands.
147 let PrintMethod = "printImmOperand";
150 def u7Imm : Operand<i32> {
151 // For now, we use a generic print function for all operands.
152 let PrintMethod = "printImmOperand";
155 def u6Imm : Operand<i32> {
156 // For now, we use a generic print function for all operands.
157 let PrintMethod = "printImmOperand";
160 def u6_0Imm : Operand<i32> {
161 // For now, we use a generic print function for all operands.
162 let PrintMethod = "printImmOperand";
165 def u6_1Imm : Operand<i32> {
166 // For now, we use a generic print function for all operands.
167 let PrintMethod = "printImmOperand";
170 def u6_2Imm : Operand<i32> {
171 // For now, we use a generic print function for all operands.
172 let PrintMethod = "printImmOperand";
175 def u6_3Imm : Operand<i32> {
176 // For now, we use a generic print function for all operands.
177 let PrintMethod = "printImmOperand";
180 def u5Imm : Operand<i32> {
181 // For now, we use a generic print function for all operands.
182 let PrintMethod = "printImmOperand";
185 def u4Imm : Operand<i32> {
186 // For now, we use a generic print function for all operands.
187 let PrintMethod = "printImmOperand";
190 def u3Imm : Operand<i32> {
191 // For now, we use a generic print function for all operands.
192 let PrintMethod = "printImmOperand";
195 def u2Imm : Operand<i32> {
196 // For now, we use a generic print function for all operands.
197 let PrintMethod = "printImmOperand";
200 def u1Imm : Operand<i32> {
201 // For now, we use a generic print function for all operands.
202 let PrintMethod = "printImmOperand";
205 def n8Imm : Operand<i32> {
206 // For now, we use a generic print function for all operands.
207 let PrintMethod = "printImmOperand";
210 def m6Imm : Operand<i32> {
211 // For now, we use a generic print function for all operands.
212 let PrintMethod = "printImmOperand";
215 def nOneImm : Operand<i32> {
216 // For now, we use a generic print function for all operands.
217 let PrintMethod = "printNOneImmOperand";
221 // Immediate predicates
223 def s32ImmPred : PatLeaf<(i32 imm), [{
224 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
226 int64_t v = (int64_t)N->getSExtValue();
230 def s32_24ImmPred : PatLeaf<(i32 imm), [{
231 // s32_24ImmPred predicate - True if the immediate fits in a 32-bit sign
232 // extended field that is a multiple of 0x1000000.
233 int64_t v = (int64_t)N->getSExtValue();
234 return isShiftedInt<32,24>(v);
237 def s32_16s8ImmPred : PatLeaf<(i32 imm), [{
238 // s32_16s8ImmPred predicate - True if the immediate fits in a 32-bit sign
239 // extended field that is a multiple of 0x10000.
240 int64_t v = (int64_t)N->getSExtValue();
241 return isShiftedInt<24,16>(v);
244 def s16ImmPred : PatLeaf<(i32 imm), [{
245 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
247 int64_t v = (int64_t)N->getSExtValue();
252 def s13ImmPred : PatLeaf<(i32 imm), [{
253 // immS13 predicate - True if the immediate fits in a 13-bit sign extended
255 int64_t v = (int64_t)N->getSExtValue();
260 def s12ImmPred : PatLeaf<(i32 imm), [{
261 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
263 int64_t v = (int64_t)N->getSExtValue();
267 def s11_0ImmPred : PatLeaf<(i32 imm), [{
268 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
270 int64_t v = (int64_t)N->getSExtValue();
275 def s11_1ImmPred : PatLeaf<(i32 imm), [{
276 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
278 int64_t v = (int64_t)N->getSExtValue();
279 return isShiftedInt<11,1>(v);
283 def s11_2ImmPred : PatLeaf<(i32 imm), [{
284 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
286 int64_t v = (int64_t)N->getSExtValue();
287 return isShiftedInt<11,2>(v);
291 def s11_3ImmPred : PatLeaf<(i32 imm), [{
292 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
294 int64_t v = (int64_t)N->getSExtValue();
295 return isShiftedInt<11,3>(v);
299 def s10ImmPred : PatLeaf<(i32 imm), [{
300 // s10ImmPred predicate - True if the immediate fits in a 10-bit sign extended
302 int64_t v = (int64_t)N->getSExtValue();
307 def s9ImmPred : PatLeaf<(i32 imm), [{
308 // s9ImmPred predicate - True if the immediate fits in a 9-bit sign extended
310 int64_t v = (int64_t)N->getSExtValue();
315 def s8ImmPred : PatLeaf<(i32 imm), [{
316 // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended
318 int64_t v = (int64_t)N->getSExtValue();
323 def s8Imm64Pred : PatLeaf<(i64 imm), [{
324 // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended
326 int64_t v = (int64_t)N->getSExtValue();
331 def s6ImmPred : PatLeaf<(i32 imm), [{
332 // s6ImmPred predicate - True if the immediate fits in a 6-bit sign extended
334 int64_t v = (int64_t)N->getSExtValue();
339 def s4_0ImmPred : PatLeaf<(i32 imm), [{
340 // s4_0ImmPred predicate - True if the immediate fits in a 4-bit sign extended
342 int64_t v = (int64_t)N->getSExtValue();
347 def s4_1ImmPred : PatLeaf<(i32 imm), [{
348 // s4_1ImmPred predicate - True if the immediate fits in a 4-bit sign extended
350 int64_t v = (int64_t)N->getSExtValue();
351 return isShiftedInt<4,1>(v);
355 def s4_2ImmPred : PatLeaf<(i32 imm), [{
356 // s4_2ImmPred predicate - True if the immediate fits in a 4-bit sign extended
357 // field that is a multiple of 4.
358 int64_t v = (int64_t)N->getSExtValue();
359 return isShiftedInt<4,2>(v);
363 def s4_3ImmPred : PatLeaf<(i32 imm), [{
364 // s4_3ImmPred predicate - True if the immediate fits in a 4-bit sign extended
365 // field that is a multiple of 8.
366 int64_t v = (int64_t)N->getSExtValue();
367 return isShiftedInt<4,3>(v);
371 def u64ImmPred : PatLeaf<(i64 imm), [{
372 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
374 // Adding "N ||" to suppress gcc unused warning.
378 def u32ImmPred : PatLeaf<(i32 imm), [{
379 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
381 int64_t v = (int64_t)N->getSExtValue();
382 return isUInt<32>(v);
385 def u16ImmPred : PatLeaf<(i32 imm), [{
386 // u16ImmPred predicate - True if the immediate fits in a 16-bit unsigned
388 int64_t v = (int64_t)N->getSExtValue();
389 return isUInt<16>(v);
392 def u16_s8ImmPred : PatLeaf<(i32 imm), [{
393 // u16_s8ImmPred predicate - True if the immediate fits in a 16-bit sign
394 // extended s8 field.
395 int64_t v = (int64_t)N->getSExtValue();
396 return isShiftedUInt<16,8>(v);
399 def u9ImmPred : PatLeaf<(i32 imm), [{
400 // u9ImmPred predicate - True if the immediate fits in a 9-bit unsigned
402 int64_t v = (int64_t)N->getSExtValue();
407 def u8ImmPred : PatLeaf<(i32 imm), [{
408 // u8ImmPred predicate - True if the immediate fits in a 8-bit unsigned
410 int64_t v = (int64_t)N->getSExtValue();
414 def u7ImmPred : PatLeaf<(i32 imm), [{
415 // u7ImmPred predicate - True if the immediate fits in a 8-bit unsigned
417 int64_t v = (int64_t)N->getSExtValue();
422 def u6ImmPred : PatLeaf<(i32 imm), [{
423 // u6ImmPred predicate - True if the immediate fits in a 6-bit unsigned
425 int64_t v = (int64_t)N->getSExtValue();
429 def u6_0ImmPred : PatLeaf<(i32 imm), [{
430 // u6_0ImmPred predicate - True if the immediate fits in a 6-bit unsigned
431 // field. Same as u6ImmPred.
432 int64_t v = (int64_t)N->getSExtValue();
436 def u6_1ImmPred : PatLeaf<(i32 imm), [{
437 // u6_1ImmPred predicate - True if the immediate fits in a 6-bit unsigned
438 // field that is 1 bit alinged - multiple of 2.
439 int64_t v = (int64_t)N->getSExtValue();
440 return isShiftedUInt<6,1>(v);
443 def u6_2ImmPred : PatLeaf<(i32 imm), [{
444 // u6_2ImmPred predicate - True if the immediate fits in a 6-bit unsigned
445 // field that is 2 bits alinged - multiple of 4.
446 int64_t v = (int64_t)N->getSExtValue();
447 return isShiftedUInt<6,2>(v);
450 def u6_3ImmPred : PatLeaf<(i32 imm), [{
451 // u6_3ImmPred predicate - True if the immediate fits in a 6-bit unsigned
452 // field that is 3 bits alinged - multiple of 8.
453 int64_t v = (int64_t)N->getSExtValue();
454 return isShiftedUInt<6,3>(v);
457 def u5ImmPred : PatLeaf<(i32 imm), [{
458 // u5ImmPred predicate - True if the immediate fits in a 5-bit unsigned
460 int64_t v = (int64_t)N->getSExtValue();
465 def u3ImmPred : PatLeaf<(i32 imm), [{
466 // u3ImmPred predicate - True if the immediate fits in a 3-bit unsigned
468 int64_t v = (int64_t)N->getSExtValue();
473 def u2ImmPred : PatLeaf<(i32 imm), [{
474 // u2ImmPred predicate - True if the immediate fits in a 2-bit unsigned
476 int64_t v = (int64_t)N->getSExtValue();
481 def u1ImmPred : PatLeaf<(i1 imm), [{
482 // u1ImmPred predicate - True if the immediate fits in a 1-bit unsigned
484 int64_t v = (int64_t)N->getSExtValue();
488 def m6ImmPred : PatLeaf<(i32 imm), [{
489 // m6ImmPred predicate - True if the immediate is negative and fits in
490 // a 6-bit negative number.
491 int64_t v = (int64_t)N->getSExtValue();
495 //InN means negative integers in [-(2^N - 1), 0]
496 def n8ImmPred : PatLeaf<(i32 imm), [{
497 // n8ImmPred predicate - True if the immediate fits in a 8-bit signed
499 int64_t v = (int64_t)N->getSExtValue();
500 return (-255 <= v && v <= 0);
503 def nOneImmPred : PatLeaf<(i32 imm), [{
504 // nOneImmPred predicate - True if the immediate is -1.
505 int64_t v = (int64_t)N->getSExtValue();