Rename ConstantSDNode::getValue to getZExtValue, for consistency
[oota-llvm.git] / lib / Target / CellSPU / SPUOperands.td
1 //===- SPUOperands.td - Cell SPU Instruction Operands ------*- 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 // Cell SPU Instruction Operands:
10 //===----------------------------------------------------------------------===//
11
12 def LO16 : SDNodeXForm<imm, [{
13   unsigned val = N->getZExtValue();
14   // Transformation function: get the low 16 bits.
15   return getI32Imm(val & 0xffff);
16 }]>;
17
18 def LO16_vec : SDNodeXForm<scalar_to_vector, [{
19   SDValue OpVal(0, 0);
20
21   // Transformation function: get the low 16 bit immediate from a build_vector
22   // node.
23   assert(N->getOpcode() == ISD::BUILD_VECTOR
24          && "LO16_vec got something other than a BUILD_VECTOR");
25
26   // Get first constant operand...
27   for (unsigned i = 0, e = N->getNumOperands();
28        OpVal.getNode() == 0 && i != e; ++i) {
29     if (N->getOperand(i).getOpcode() == ISD::UNDEF) continue;
30     if (OpVal.getNode() == 0)
31       OpVal = N->getOperand(i);
32   }
33   
34   assert(OpVal.getNode() != 0 && "LO16_vec did not locate a <defined> node");
35   ConstantSDNode *CN = cast<ConstantSDNode>(OpVal);
36   return getI32Imm((unsigned)CN->getZExtValue() & 0xffff);
37 }]>;
38
39 // Transform an immediate, returning the high 16 bits shifted down:
40 def HI16 : SDNodeXForm<imm, [{
41   return getI32Imm((unsigned)N->getZExtValue() >> 16);
42 }]>;
43
44 // Transformation function: shift the high 16 bit immediate from a build_vector
45 // node into the low 16 bits, and return a 16-bit constant.
46 def HI16_vec : SDNodeXForm<scalar_to_vector, [{
47   SDValue OpVal(0, 0);
48
49   assert(N->getOpcode() == ISD::BUILD_VECTOR
50          && "HI16_vec got something other than a BUILD_VECTOR");
51   
52   // Get first constant operand...
53   for (unsigned i = 0, e = N->getNumOperands();
54        OpVal.getNode() == 0 && i != e; ++i) {
55     if (N->getOperand(i).getOpcode() == ISD::UNDEF) continue;
56     if (OpVal.getNode() == 0)
57       OpVal = N->getOperand(i);
58   }
59   
60   assert(OpVal.getNode() != 0 && "HI16_vec did not locate a <defined> node");
61   ConstantSDNode *CN = cast<ConstantSDNode>(OpVal);
62   return getI32Imm((unsigned)CN->getZExtValue() >> 16);
63 }]>;
64
65 // simm7 predicate - True if the immediate fits in an 7-bit signed
66 // field.
67 def simm7: PatLeaf<(imm), [{
68   int sextVal = int(N->getSignExtended());
69   return (sextVal >= -64 && sextVal <= 63);
70 }]>;
71
72 // uimm7 predicate - True if the immediate fits in an 7-bit unsigned
73 // field.
74 def uimm7: PatLeaf<(imm), [{
75   return (N->getZExtValue() <= 0x7f);
76 }]>;
77
78 // immSExt8 predicate - True if the immediate fits in an 8-bit sign extended
79 // field.
80 def immSExt8  : PatLeaf<(imm), [{
81   int Value = int(N->getSignExtended());
82   return (Value >= -(1 << 8) && Value <= (1 << 8) - 1);
83 }]>;
84
85 // immU8: immediate, unsigned 8-bit quantity
86 def immU8 : PatLeaf<(imm), [{
87   return (N->getZExtValue() <= 0xff);
88 }]>;
89
90 // i64ImmSExt10 predicate - True if the i64 immediate fits in a 10-bit sign
91 // extended field.  Used by RI10Form instructions like 'ldq'.
92 def i64ImmSExt10  : PatLeaf<(imm), [{
93   return isI64IntS10Immediate(N);
94 }]>;
95
96 // i32ImmSExt10 predicate - True if the i32 immediate fits in a 10-bit sign
97 // extended field.  Used by RI10Form instructions like 'ldq'.
98 def i32ImmSExt10  : PatLeaf<(imm), [{
99   return isI32IntS10Immediate(N);
100 }]>;
101
102 // i32ImmUns10 predicate - True if the i32 immediate fits in a 10-bit unsigned
103 // field.  Used by RI10Form instructions like 'ldq'.
104 def i32ImmUns10  : PatLeaf<(imm), [{
105   return isI32IntU10Immediate(N);
106 }]>;
107
108 // i16ImmSExt10 predicate - True if the i16 immediate fits in a 10-bit sign
109 // extended field.  Used by RI10Form instructions like 'ldq'.
110 def i16ImmSExt10  : PatLeaf<(imm), [{
111   return isI16IntS10Immediate(N);
112 }]>;
113
114 // i16ImmUns10 predicate - True if the i16 immediate fits into a 10-bit unsigned
115 // value. Used by RI10Form instructions.
116 def i16ImmUns10 : PatLeaf<(imm), [{
117   return isI16IntU10Immediate(N);
118 }]>;
119
120 def immSExt16  : PatLeaf<(imm), [{
121   // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
122   // field.
123   short Ignored;
124   return isIntS16Immediate(N, Ignored);
125 }]>;
126
127 def immZExt16  : PatLeaf<(imm), [{
128   // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
129   // field.
130   return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
131 }], LO16>;
132
133 def immU16 : PatLeaf<(imm), [{
134   // immU16 predicate- True if the immediate fits into a 16-bit unsigned field.
135   return (uint64_t)N->getZExtValue() == (N->getZExtValue() & 0xffff);
136 }]>;
137
138 def imm18  : PatLeaf<(imm), [{
139   // imm18 predicate: True if the immediate fits into an 18-bit unsigned field.
140   int Value = (int) N->getZExtValue();
141   return ((Value & ((1 << 19) - 1)) == Value);
142 }]>;
143
144 def lo16 : PatLeaf<(imm), [{
145   // lo16 predicate - returns true if the immediate has all zeros in the
146   // low order bits and is a 32-bit constant:
147   if (N->getValueType(0) == MVT::i32) {
148     uint32_t val = N->getZExtValue();
149     return ((val & 0x0000ffff) == val);
150   }
151
152   return false;
153 }], LO16>;
154
155 def hi16 : PatLeaf<(imm), [{
156   // hi16 predicate - returns true if the immediate has all zeros in the
157   // low order bits and is a 32-bit constant:
158   if (N->getValueType(0) == MVT::i32) {
159     uint32_t val = uint32_t(N->getZExtValue());
160     return ((val & 0xffff0000) == val);
161   } else if (N->getValueType(0) == MVT::i64) {
162     uint64_t val = N->getZExtValue();
163     return ((val & 0xffff0000ULL) == val);
164   }
165
166   return false;
167 }], HI16>;
168
169 def bitshift : PatLeaf<(imm), [{
170   // bitshift predicate - returns true if 0 < imm <= 7 for SHLQBII
171   // (shift left quadword by bits immediate)
172   int64_t Val = N->getZExtValue();
173   return (Val > 0 && Val <= 7);
174 }]>;
175
176 //===----------------------------------------------------------------------===//
177 // Floating point operands:
178 //===----------------------------------------------------------------------===//
179
180 // Transform a float, returning the high 16 bits shifted down, as if
181 // the float was really an unsigned integer:
182 def HI16_f32 : SDNodeXForm<fpimm, [{
183   float fval = N->getValueAPF().convertToFloat();
184   return getI32Imm(FloatToBits(fval) >> 16);
185 }]>;
186
187 // Transformation function on floats: get the low 16 bits as if the float was
188 // an unsigned integer.
189 def LO16_f32 : SDNodeXForm<fpimm, [{
190   float fval = N->getValueAPF().convertToFloat();
191   return getI32Imm(FloatToBits(fval) & 0xffff);
192 }]>;
193
194 def FPimm_sext16 : SDNodeXForm<fpimm, [{
195   float fval = N->getValueAPF().convertToFloat();
196   return getI32Imm((int) ((FloatToBits(fval) << 16) >> 16));
197 }]>;
198
199 def FPimm_u18 : SDNodeXForm<fpimm, [{
200   float fval = N->getValueAPF().convertToFloat();
201   return getI32Imm(FloatToBits(fval) & ((1 << 19) - 1));
202 }]>;
203
204 def fpimmSExt16 : PatLeaf<(fpimm), [{
205   short Ignored;
206   return isFPS16Immediate(N, Ignored);  
207 }], FPimm_sext16>;
208
209 // Does the SFP constant only have upp 16 bits set?
210 def hi16_f32 : PatLeaf<(fpimm), [{
211   if (N->getValueType(0) == MVT::f32) {
212     uint32_t val = FloatToBits(N->getValueAPF().convertToFloat());
213     return ((val & 0xffff0000) == val);
214   }
215
216   return false;
217 }], HI16_f32>;
218
219 // Does the SFP constant fit into 18 bits?
220 def fpimm18  : PatLeaf<(fpimm), [{
221   if (N->getValueType(0) == MVT::f32) {
222     uint32_t Value = FloatToBits(N->getValueAPF().convertToFloat());
223     return ((Value & ((1 << 19) - 1)) == Value);
224   }
225
226   return false;
227 }], FPimm_u18>;
228
229 //===----------------------------------------------------------------------===//
230 // 64-bit operands (TODO):
231 //===----------------------------------------------------------------------===//
232
233 //===----------------------------------------------------------------------===//
234 // build_vector operands:
235 //===----------------------------------------------------------------------===//
236
237 // v16i8SExt8Imm_xform function: convert build_vector to 8-bit sign extended
238 // immediate constant load for v16i8 vectors. N.B.: The incoming constant has
239 // to be a 16-bit quantity with the upper and lower bytes equal (e.g., 0x2a2a).
240 def v16i8SExt8Imm_xform: SDNodeXForm<build_vector, [{
241   return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8);
242 }]>;
243
244 // v16i8SExt8Imm: Predicate test for 8-bit sign extended immediate constant
245 // load, works in conjunction with its transform function. N.B.: This relies the
246 // incoming constant being a 16-bit quantity, where the upper and lower bytes
247 // are EXACTLY the same (e.g., 0x2a2a)
248 def v16i8SExt8Imm: PatLeaf<(build_vector), [{
249   return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8).getNode() != 0;
250 }], v16i8SExt8Imm_xform>;
251
252 // v16i8U8Imm_xform function: convert build_vector to unsigned 8-bit
253 // immediate constant load for v16i8 vectors. N.B.: The incoming constant has
254 // to be a 16-bit quantity with the upper and lower bytes equal (e.g., 0x2a2a).
255 def v16i8U8Imm_xform: SDNodeXForm<build_vector, [{
256   return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8);
257 }]>;
258
259 // v16i8U8Imm: Predicate test for unsigned 8-bit immediate constant
260 // load, works in conjunction with its transform function. N.B.: This relies the
261 // incoming constant being a 16-bit quantity, where the upper and lower bytes
262 // are EXACTLY the same (e.g., 0x2a2a)
263 def v16i8U8Imm: PatLeaf<(build_vector), [{
264   return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8).getNode() != 0;
265 }], v16i8U8Imm_xform>;
266
267 // v8i16SExt8Imm_xform function: convert build_vector to 8-bit sign extended
268 // immediate constant load for v8i16 vectors.
269 def v8i16SExt8Imm_xform: SDNodeXForm<build_vector, [{
270   return SPU::get_vec_i8imm(N, *CurDAG, MVT::i16);
271 }]>;
272
273 // v8i16SExt8Imm: Predicate test for 8-bit sign extended immediate constant
274 // load, works in conjunction with its transform function.
275 def v8i16SExt8Imm: PatLeaf<(build_vector), [{
276   return SPU::get_vec_i8imm(N, *CurDAG, MVT::i16).getNode() != 0;
277 }], v8i16SExt8Imm_xform>;
278
279 // v8i16SExt10Imm_xform function: convert build_vector to 16-bit sign extended
280 // immediate constant load for v8i16 vectors.
281 def v8i16SExt10Imm_xform: SDNodeXForm<build_vector, [{
282   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16);
283 }]>;
284
285 // v8i16SExt10Imm: Predicate test for 16-bit sign extended immediate constant
286 // load, works in conjunction with its transform function.
287 def v8i16SExt10Imm: PatLeaf<(build_vector), [{
288   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16).getNode() != 0;
289 }], v8i16SExt10Imm_xform>;
290
291 // v8i16Uns10Imm_xform function: convert build_vector to 16-bit unsigned
292 // immediate constant load for v8i16 vectors.
293 def v8i16Uns10Imm_xform: SDNodeXForm<build_vector, [{
294   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16);
295 }]>;
296
297 // v8i16Uns10Imm: Predicate test for 16-bit unsigned immediate constant
298 // load, works in conjunction with its transform function.
299 def v8i16Uns10Imm: PatLeaf<(build_vector), [{
300   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16).getNode() != 0;
301 }], v8i16Uns10Imm_xform>;
302
303 // v8i16SExt16Imm_xform function: convert build_vector to 16-bit sign extended
304 // immediate constant load for v8i16 vectors.
305 def v8i16Uns16Imm_xform: SDNodeXForm<build_vector, [{
306   return SPU::get_vec_i16imm(N, *CurDAG, MVT::i16);
307 }]>;
308
309 // v8i16SExt16Imm: Predicate test for 16-bit sign extended immediate constant
310 // load, works in conjunction with its transform function.
311 def v8i16SExt16Imm: PatLeaf<(build_vector), [{
312   return SPU::get_vec_i16imm(N, *CurDAG, MVT::i16).getNode() != 0;
313 }], v8i16Uns16Imm_xform>;
314
315 // v4i32SExt10Imm_xform function: convert build_vector to 10-bit sign extended
316 // immediate constant load for v4i32 vectors.
317 def v4i32SExt10Imm_xform: SDNodeXForm<build_vector, [{
318   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32);
319 }]>;
320
321 // v4i32SExt10Imm: Predicate test for 10-bit sign extended immediate constant
322 // load, works in conjunction with its transform function.
323 def v4i32SExt10Imm: PatLeaf<(build_vector), [{
324   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32).getNode() != 0;
325 }], v4i32SExt10Imm_xform>;
326
327 // v4i32Uns10Imm_xform function: convert build_vector to 10-bit unsigned
328 // immediate constant load for v4i32 vectors.
329 def v4i32Uns10Imm_xform: SDNodeXForm<build_vector, [{
330   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32);
331 }]>;
332
333 // v4i32Uns10Imm: Predicate test for 10-bit unsigned immediate constant
334 // load, works in conjunction with its transform function.
335 def v4i32Uns10Imm: PatLeaf<(build_vector), [{
336   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32).getNode() != 0;
337 }], v4i32Uns10Imm_xform>;
338
339 // v4i32SExt16Imm_xform function: convert build_vector to 16-bit sign extended
340 // immediate constant load for v4i32 vectors.
341 def v4i32SExt16Imm_xform: SDNodeXForm<build_vector, [{
342   return SPU::get_vec_i16imm(N, *CurDAG, MVT::i32);
343 }]>;
344
345 // v4i32SExt16Imm: Predicate test for 16-bit sign extended immediate constant
346 // load, works in conjunction with its transform function.
347 def v4i32SExt16Imm: PatLeaf<(build_vector), [{
348   return SPU::get_vec_i16imm(N, *CurDAG, MVT::i32).getNode() != 0;
349 }], v4i32SExt16Imm_xform>;
350
351 // v4i32Uns18Imm_xform function: convert build_vector to 18-bit unsigned
352 // immediate constant load for v4i32 vectors.
353 def v4i32Uns18Imm_xform: SDNodeXForm<build_vector, [{
354   return SPU::get_vec_u18imm(N, *CurDAG, MVT::i32);
355 }]>;
356
357 // v4i32Uns18Imm: Predicate test for 18-bit unsigned immediate constant load,
358 // works in conjunction with its transform function.
359 def v4i32Uns18Imm: PatLeaf<(build_vector), [{
360   return SPU::get_vec_u18imm(N, *CurDAG, MVT::i32).getNode() != 0;
361 }], v4i32Uns18Imm_xform>;
362
363 // ILHUvec_get_imm xform function: convert build_vector to ILHUvec imm constant
364 // load.
365 def ILHUvec_get_imm: SDNodeXForm<build_vector, [{
366   return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i32);
367 }]>;
368
369 /// immILHUvec: Predicate test for a ILHU constant vector.
370 def immILHUvec: PatLeaf<(build_vector), [{
371   return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i32).getNode() != 0;
372 }], ILHUvec_get_imm>;
373
374 // Catch-all for any other i32 vector constants
375 def v4i32_get_imm: SDNodeXForm<build_vector, [{
376   return SPU::get_v4i32_imm(N, *CurDAG);
377 }]>;
378
379 def v4i32Imm: PatLeaf<(build_vector), [{
380   return SPU::get_v4i32_imm(N, *CurDAG).getNode() != 0;
381 }], v4i32_get_imm>;
382
383 // v2i64SExt10Imm_xform function: convert build_vector to 10-bit sign extended
384 // immediate constant load for v2i64 vectors.
385 def v2i64SExt10Imm_xform: SDNodeXForm<build_vector, [{
386   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i64);
387 }]>;
388
389 // v2i64SExt10Imm: Predicate test for 10-bit sign extended immediate constant
390 // load, works in conjunction with its transform function.
391 def v2i64SExt10Imm: PatLeaf<(build_vector), [{
392   return SPU::get_vec_i10imm(N, *CurDAG, MVT::i64).getNode() != 0;
393 }], v2i64SExt10Imm_xform>;
394
395 // v2i64SExt16Imm_xform function: convert build_vector to 16-bit sign extended
396 // immediate constant load for v2i64 vectors.
397 def v2i64SExt16Imm_xform: SDNodeXForm<build_vector, [{
398   return SPU::get_vec_i16imm(N, *CurDAG, MVT::i64);
399 }]>;
400
401 // v2i64SExt16Imm: Predicate test for 16-bit sign extended immediate constant
402 // load, works in conjunction with its transform function.
403 def v2i64SExt16Imm: PatLeaf<(build_vector), [{
404   return SPU::get_vec_i16imm(N, *CurDAG, MVT::i64).getNode() != 0;
405 }], v2i64SExt16Imm_xform>;
406
407 // v2i64Uns18Imm_xform function: convert build_vector to 18-bit unsigned
408 // immediate constant load for v2i64 vectors.
409 def v2i64Uns18Imm_xform: SDNodeXForm<build_vector, [{
410   return SPU::get_vec_u18imm(N, *CurDAG, MVT::i64);
411 }]>;
412
413 // v2i64Uns18Imm: Predicate test for 18-bit unsigned immediate constant load,
414 // works in conjunction with its transform function.
415 def v2i64Uns18Imm: PatLeaf<(build_vector), [{
416   return SPU::get_vec_u18imm(N, *CurDAG, MVT::i64).getNode() != 0;
417 }], v2i64Uns18Imm_xform>;
418
419 /// immILHUvec: Predicate test for a ILHU constant vector.
420 def immILHUvec_i64: PatLeaf<(build_vector), [{
421   return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i64).getNode() != 0;
422 }], ILHUvec_get_imm>;
423
424 // Catch-all for any other i32 vector constants
425 def v2i64_get_imm: SDNodeXForm<build_vector, [{
426   return SPU::get_v2i64_imm(N, *CurDAG);
427 }]>;
428
429 def v2i64Imm: PatLeaf<(build_vector), [{
430   return SPU::get_v2i64_imm(N, *CurDAG).getNode() != 0;
431 }], v2i64_get_imm>;
432
433 //===----------------------------------------------------------------------===//
434 // Operand Definitions.
435
436 def s7imm: Operand<i8> {
437   let PrintMethod = "printS7ImmOperand";
438 }
439
440 def s7imm_i8: Operand<i8> {
441   let PrintMethod = "printS7ImmOperand";
442 }
443
444 def u7imm: Operand<i16> {
445   let PrintMethod = "printU7ImmOperand";
446 }
447
448 def u7imm_i8: Operand<i8> {
449   let PrintMethod = "printU7ImmOperand";
450 }
451
452 def u7imm_i32: Operand<i32> {
453   let PrintMethod = "printU7ImmOperand";
454 }
455
456 // Halfword, signed 10-bit constant
457 def s10imm : Operand<i16> {
458   let PrintMethod = "printS10ImmOperand";
459 }
460
461 def s10imm_i8: Operand<i8> {
462   let PrintMethod = "printS10ImmOperand";
463 }
464
465 def s10imm_i32: Operand<i32> {
466   let PrintMethod = "printS10ImmOperand";
467 }
468
469 def s10imm_i64: Operand<i64> {
470   let PrintMethod = "printS10ImmOperand";
471 }
472
473 // Unsigned 10-bit integers:
474 def u10imm: Operand<i16> {
475   let PrintMethod = "printU10ImmOperand";
476 }
477
478 def u10imm_i8: Operand<i8> {
479   let PrintMethod = "printU10ImmOperand";
480 }
481
482 def u10imm_i32: Operand<i32> {
483   let PrintMethod = "printU10ImmOperand";
484 }
485
486 def s16imm  : Operand<i16> {
487   let PrintMethod = "printS16ImmOperand";
488 }
489
490 def s16imm_i8: Operand<i8> {
491   let PrintMethod = "printS16ImmOperand";
492 }
493
494 def s16imm_i32: Operand<i32> {
495   let PrintMethod = "printS16ImmOperand";
496 }
497
498 def s16imm_i64: Operand<i64> {
499   let PrintMethod = "printS16ImmOperand";
500 }
501
502 def s16imm_f32: Operand<f32> {
503   let PrintMethod = "printS16ImmOperand";
504 }
505
506 def s16imm_f64: Operand<f64> {
507   let PrintMethod = "printS16ImmOperand";
508 }
509
510 def u16imm_i64 : Operand<i64> {
511   let PrintMethod = "printU16ImmOperand";
512 }
513
514 def u16imm_i32 : Operand<i32> {
515   let PrintMethod = "printU16ImmOperand";
516 }
517
518 def u16imm : Operand<i16> {
519   let PrintMethod = "printU16ImmOperand";
520 }
521
522 def f16imm : Operand<f32> {
523   let PrintMethod = "printU16ImmOperand";
524 }
525
526 def s18imm  : Operand<i32> {
527   let PrintMethod = "printS18ImmOperand";
528 }
529
530 def u18imm : Operand<i32> {
531   let PrintMethod = "printU18ImmOperand";
532 }
533
534 def u18imm_i64 : Operand<i64> {
535   let PrintMethod = "printU18ImmOperand";
536 }
537
538 def f18imm : Operand<f32> {
539   let PrintMethod = "printU18ImmOperand";
540 }
541
542 def f18imm_f64 : Operand<f64> {
543   let PrintMethod = "printU18ImmOperand";
544 }
545
546 // Negated 7-bit halfword rotate immediate operands
547 def rothNeg7imm : Operand<i32> {
548   let PrintMethod = "printROTHNeg7Imm";
549 }
550
551 def rothNeg7imm_i16 : Operand<i16> {
552   let PrintMethod = "printROTHNeg7Imm";
553 }
554
555 // Negated 7-bit word rotate immediate operands
556 def rotNeg7imm : Operand<i32> {
557   let PrintMethod = "printROTNeg7Imm";
558 }
559
560 def rotNeg7imm_i16 : Operand<i16> {
561   let PrintMethod = "printROTNeg7Imm";
562 }
563
564 def rotNeg7imm_i8 : Operand<i8> {
565   let PrintMethod = "printROTNeg7Imm";
566 }
567
568 def target : Operand<OtherVT> {
569   let PrintMethod = "printBranchOperand";
570 }
571
572 // Absolute address call target
573 def calltarget : Operand<iPTR> {
574   let PrintMethod = "printCallOperand";
575   let MIOperandInfo = (ops u18imm:$calldest);
576 }
577
578 // Relative call target
579 def relcalltarget : Operand<iPTR> {
580   let PrintMethod = "printPCRelativeOperand";
581   let MIOperandInfo = (ops s16imm:$calldest);
582 }
583
584 // Branch targets:
585 def brtarget : Operand<OtherVT> {
586   let PrintMethod = "printPCRelativeOperand";
587 }
588
589 // Indirect call target
590 def indcalltarget : Operand<iPTR> {
591   let PrintMethod = "printCallOperand";
592   let MIOperandInfo = (ops ptr_rc:$calldest);
593 }
594
595 def symbolHi: Operand<i32> {
596   let PrintMethod = "printSymbolHi";
597 }
598
599 def symbolLo: Operand<i32> {
600   let PrintMethod = "printSymbolLo";
601 }
602
603 def symbolLSA: Operand<i32> {
604   let PrintMethod = "printSymbolLSA";
605 }
606
607 // memory s7imm(reg) operaand
608 def memri7 : Operand<iPTR> {
609   let PrintMethod = "printMemRegImmS7";
610   let MIOperandInfo = (ops s7imm:$imm, ptr_rc:$reg);
611 }
612
613 // memory s10imm(reg) operand
614 def memri10 : Operand<iPTR> {
615   let PrintMethod = "printMemRegImmS10";
616   let MIOperandInfo = (ops s10imm:$imm, ptr_rc:$reg);
617 }
618
619 // 256K local store address
620 // N.B.: The tblgen code generator expects to have two operands, an offset
621 // and a pointer. Of these, only the immediate is actually used.
622 def addr256k : Operand<iPTR> {
623   let PrintMethod = "printAddr256K";
624   let MIOperandInfo = (ops s16imm:$imm, ptr_rc:$reg);
625 }
626
627 // memory s18imm(reg) operand
628 def memri18 : Operand<iPTR> {
629   let PrintMethod = "printMemRegImmS18";
630   let MIOperandInfo = (ops s18imm:$imm, ptr_rc:$reg);
631 }
632
633 // memory register + register operand
634 def memrr : Operand<iPTR> {
635   let PrintMethod = "printMemRegReg";
636   let MIOperandInfo = (ops ptr_rc:$reg_a, ptr_rc:$reg_b);
637 }
638
639 // Define SPU-specific addressing modes: These come in three basic
640 // flavors:
641 //
642 // D-form   : [r+I10] (10-bit signed offset + reg)
643 // X-form   : [r+r]   (reg+reg)
644 // A-form   : abs     (256K LSA offset)
645 // D-form(2): [r+I7]  (7-bit signed offset + reg)
646
647 def dform_addr   : ComplexPattern<iPTR, 2, "SelectDFormAddr",     [], []>;
648 def xform_addr   : ComplexPattern<iPTR, 2, "SelectXFormAddr",     [], []>;
649 def aform_addr   : ComplexPattern<iPTR, 2, "SelectAFormAddr",     [], []>;
650 def dform2_addr  : ComplexPattern<iPTR, 2, "SelectDForm2Addr",    [], []>;