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