blob: e8ee091cd3de7fe9833865a8c75a001eb6e2bd5c [file] [log] [blame]
Rafael Espindola6ee1e082012-11-21 16:56:33 +00001//===- HexagonOperands.td - Hexagon immediate processing -*- tablegen -*-===//
Tony Linthicumb4b54152011-12-12 21:14:40 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illnois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// From IA64's InstrInfo file
11def s32Imm : Operand<i32> {
12 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000013 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000014}
15
16def s16Imm : Operand<i32> {
Evandro Menezese5041e62012-04-12 17:55:53 +000017 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000018}
19
20def s12Imm : Operand<i32> {
21 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000022 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000023}
24
25def s11Imm : Operand<i32> {
26 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000027 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000028}
29
30def s11_0Imm : Operand<i32> {
31 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000032 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000033}
34
35def s11_1Imm : Operand<i32> {
36 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000037 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000038}
39
40def s11_2Imm : Operand<i32> {
41 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000042 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000043}
44
45def s11_3Imm : Operand<i32> {
46 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000047 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000048}
49
50def s10Imm : Operand<i32> {
51 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000052 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000053}
54
Sirish Pandeab7955b2012-02-15 18:52:27 +000055def s9Imm : Operand<i32> {
Tony Linthicumb4b54152011-12-12 21:14:40 +000056 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000057 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000058}
59
Sirish Pandeab7955b2012-02-15 18:52:27 +000060def s8Imm : Operand<i32> {
Tony Linthicumb4b54152011-12-12 21:14:40 +000061 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000062 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000063}
64
65def s8Imm64 : Operand<i64> {
66 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000067 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000068}
69
70def s6Imm : Operand<i32> {
71 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000072 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000073}
74
75def s4Imm : Operand<i32> {
76 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000077 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000078}
79
80def s4_0Imm : Operand<i32> {
81 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000082 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000083}
84
85def s4_1Imm : Operand<i32> {
86 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000087 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000088}
89
90def s4_2Imm : Operand<i32> {
91 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000092 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000093}
94
95def s4_3Imm : Operand<i32> {
96 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +000097 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +000098}
99
100def u64Imm : Operand<i64> {
101 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000102 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000103}
104
105def u32Imm : Operand<i32> {
106 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000107 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000108}
109
110def u16Imm : Operand<i32> {
111 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000112 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000113}
114
115def u16_0Imm : Operand<i32> {
116 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000117 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000118}
119
120def u16_1Imm : Operand<i32> {
121 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000122 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000123}
124
125def u16_2Imm : Operand<i32> {
126 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000127 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000128}
129
130def u11_3Imm : Operand<i32> {
131 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000132 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000133}
134
135def u10Imm : Operand<i32> {
136 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000137 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000138}
139
140def u9Imm : Operand<i32> {
141 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000142 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000143}
144
145def u8Imm : Operand<i32> {
146 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000147 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000148}
149
150def u7Imm : Operand<i32> {
151 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000152 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000153}
154
155def u6Imm : Operand<i32> {
156 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000157 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000158}
159
160def u6_0Imm : Operand<i32> {
161 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000162 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000163}
164
165def u6_1Imm : Operand<i32> {
166 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000167 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000168}
169
170def u6_2Imm : Operand<i32> {
171 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000172 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000173}
174
175def u6_3Imm : Operand<i32> {
176 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000177 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000178}
179
180def u5Imm : Operand<i32> {
181 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000182 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000183}
184
185def u4Imm : Operand<i32> {
186 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000187 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000188}
189
190def u3Imm : Operand<i32> {
191 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000192 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000193}
194
195def u2Imm : Operand<i32> {
196 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000197 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000198}
199
Sirish Pandeab7955b2012-02-15 18:52:27 +0000200def u1Imm : Operand<i32> {
201 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000202 let PrintMethod = "printImmOperand";
Sirish Pandeab7955b2012-02-15 18:52:27 +0000203}
204
Tony Linthicumb4b54152011-12-12 21:14:40 +0000205def n8Imm : Operand<i32> {
206 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000207 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000208}
209
210def m6Imm : Operand<i32> {
211 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000212 let PrintMethod = "printImmOperand";
Tony Linthicumb4b54152011-12-12 21:14:40 +0000213}
214
Sirish Pandeab7955b2012-02-15 18:52:27 +0000215def nOneImm : Operand<i32> {
216 // For now, we use a generic print function for all operands.
Evandro Menezese5041e62012-04-12 17:55:53 +0000217 let PrintMethod = "printNOneImmOperand";
Sirish Pandeab7955b2012-02-15 18:52:27 +0000218}
219
Tony Linthicumb4b54152011-12-12 21:14:40 +0000220//
221// Immediate predicates
222//
223def s32ImmPred : PatLeaf<(i32 imm), [{
224 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
225 // field.
226 int64_t v = (int64_t)N->getSExtValue();
227 return isInt<32>(v);
228}]>;
229
230def 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);
235}]>;
236
237def 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);
242}]>;
243
244def s16ImmPred : PatLeaf<(i32 imm), [{
245 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
246 // field.
247 int64_t v = (int64_t)N->getSExtValue();
248 return isInt<16>(v);
249}]>;
250
251
252def s13ImmPred : PatLeaf<(i32 imm), [{
253 // immS13 predicate - True if the immediate fits in a 13-bit sign extended
254 // field.
255 int64_t v = (int64_t)N->getSExtValue();
256 return isInt<13>(v);
257}]>;
258
259
260def s12ImmPred : PatLeaf<(i32 imm), [{
261 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
262 // field.
263 int64_t v = (int64_t)N->getSExtValue();
264 return isInt<12>(v);
265}]>;
266
267def s11_0ImmPred : PatLeaf<(i32 imm), [{
268 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
269 // field.
270 int64_t v = (int64_t)N->getSExtValue();
271 return isInt<11>(v);
272}]>;
273
274
275def s11_1ImmPred : PatLeaf<(i32 imm), [{
276 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
277 // field.
278 int64_t v = (int64_t)N->getSExtValue();
279 return isShiftedInt<11,1>(v);
280}]>;
281
282
283def s11_2ImmPred : PatLeaf<(i32 imm), [{
284 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
285 // field.
286 int64_t v = (int64_t)N->getSExtValue();
287 return isShiftedInt<11,2>(v);
288}]>;
289
290
291def s11_3ImmPred : PatLeaf<(i32 imm), [{
292 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
293 // field.
294 int64_t v = (int64_t)N->getSExtValue();
295 return isShiftedInt<11,3>(v);
296}]>;
297
298
299def s10ImmPred : PatLeaf<(i32 imm), [{
300 // s10ImmPred predicate - True if the immediate fits in a 10-bit sign extended
301 // field.
302 int64_t v = (int64_t)N->getSExtValue();
303 return isInt<10>(v);
304}]>;
305
306
307def s9ImmPred : PatLeaf<(i32 imm), [{
308 // s9ImmPred predicate - True if the immediate fits in a 9-bit sign extended
309 // field.
310 int64_t v = (int64_t)N->getSExtValue();
311 return isInt<9>(v);
312}]>;
313
314
315def s8ImmPred : PatLeaf<(i32 imm), [{
316 // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended
317 // field.
318 int64_t v = (int64_t)N->getSExtValue();
319 return isInt<8>(v);
320}]>;
321
322
323def s8Imm64Pred : PatLeaf<(i64 imm), [{
324 // s8ImmPred predicate - True if the immediate fits in a 8-bit sign extended
325 // field.
326 int64_t v = (int64_t)N->getSExtValue();
327 return isInt<8>(v);
328}]>;
329
330
331def s6ImmPred : PatLeaf<(i32 imm), [{
332 // s6ImmPred predicate - True if the immediate fits in a 6-bit sign extended
333 // field.
334 int64_t v = (int64_t)N->getSExtValue();
335 return isInt<6>(v);
336}]>;
337
338
339def s4_0ImmPred : PatLeaf<(i32 imm), [{
340 // s4_0ImmPred predicate - True if the immediate fits in a 4-bit sign extended
341 // field.
342 int64_t v = (int64_t)N->getSExtValue();
343 return isInt<4>(v);
344}]>;
345
346
347def s4_1ImmPred : PatLeaf<(i32 imm), [{
348 // s4_1ImmPred predicate - True if the immediate fits in a 4-bit sign extended
349 // field of 2.
350 int64_t v = (int64_t)N->getSExtValue();
351 return isShiftedInt<4,1>(v);
352}]>;
353
354
355def 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);
360}]>;
361
362
363def 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);
368}]>;
369
370
371def u64ImmPred : PatLeaf<(i64 imm), [{
372 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
373 // field.
Benjamin Kramerd9b0b022012-06-02 10:20:22 +0000374 // Adding "N ||" to suppress gcc unused warning.
Tony Linthicumb4b54152011-12-12 21:14:40 +0000375 return (N || true);
376}]>;
377
378def u32ImmPred : PatLeaf<(i32 imm), [{
379 // immS16 predicate - True if the immediate fits in a 16-bit sign extended
380 // field.
381 int64_t v = (int64_t)N->getSExtValue();
382 return isUInt<32>(v);
383}]>;
384
385def u16ImmPred : PatLeaf<(i32 imm), [{
386 // u16ImmPred predicate - True if the immediate fits in a 16-bit unsigned
387 // field.
388 int64_t v = (int64_t)N->getSExtValue();
389 return isUInt<16>(v);
390}]>;
391
392def 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);
397}]>;
398
399def u9ImmPred : PatLeaf<(i32 imm), [{
400 // u9ImmPred predicate - True if the immediate fits in a 9-bit unsigned
401 // field.
402 int64_t v = (int64_t)N->getSExtValue();
403 return isUInt<9>(v);
404}]>;
405
406
407def u8ImmPred : PatLeaf<(i32 imm), [{
408 // u8ImmPred predicate - True if the immediate fits in a 8-bit unsigned
409 // field.
410 int64_t v = (int64_t)N->getSExtValue();
411 return isUInt<8>(v);
412}]>;
413
414def u7ImmPred : PatLeaf<(i32 imm), [{
415 // u7ImmPred predicate - True if the immediate fits in a 8-bit unsigned
416 // field.
417 int64_t v = (int64_t)N->getSExtValue();
418 return isUInt<7>(v);
419}]>;
420
421
422def u6ImmPred : PatLeaf<(i32 imm), [{
423 // u6ImmPred predicate - True if the immediate fits in a 6-bit unsigned
424 // field.
425 int64_t v = (int64_t)N->getSExtValue();
426 return isUInt<6>(v);
427}]>;
428
429def 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();
433 return isUInt<6>(v);
434}]>;
435
436def 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);
441}]>;
442
443def 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);
448}]>;
449
450def 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);
455}]>;
456
457def u5ImmPred : PatLeaf<(i32 imm), [{
458 // u5ImmPred predicate - True if the immediate fits in a 5-bit unsigned
459 // field.
460 int64_t v = (int64_t)N->getSExtValue();
461 return isUInt<5>(v);
462}]>;
463
464
465def u3ImmPred : PatLeaf<(i32 imm), [{
466 // u3ImmPred predicate - True if the immediate fits in a 3-bit unsigned
467 // field.
468 int64_t v = (int64_t)N->getSExtValue();
469 return isUInt<3>(v);
470}]>;
471
472
473def u2ImmPred : PatLeaf<(i32 imm), [{
474 // u2ImmPred predicate - True if the immediate fits in a 2-bit unsigned
475 // field.
476 int64_t v = (int64_t)N->getSExtValue();
477 return isUInt<2>(v);
478}]>;
479
480
481def u1ImmPred : PatLeaf<(i1 imm), [{
482 // u1ImmPred predicate - True if the immediate fits in a 1-bit unsigned
483 // field.
484 int64_t v = (int64_t)N->getSExtValue();
485 return isUInt<1>(v);
486}]>;
487
488def 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();
492 return isInt<6>(v);
493}]>;
494
495//InN means negative integers in [-(2^N - 1), 0]
496def n8ImmPred : PatLeaf<(i32 imm), [{
Evandro Menezese5041e62012-04-12 17:55:53 +0000497 // n8ImmPred predicate - True if the immediate fits in a 8-bit signed
Tony Linthicumb4b54152011-12-12 21:14:40 +0000498 // field.
499 int64_t v = (int64_t)N->getSExtValue();
500 return (-255 <= v && v <= 0);
501}]>;
Sirish Pandeab7955b2012-02-15 18:52:27 +0000502
503def nOneImmPred : PatLeaf<(i32 imm), [{
504 // nOneImmPred predicate - True if the immediate is -1.
505 int64_t v = (int64_t)N->getSExtValue();
506 return (-1 == v);
507}]>;
508