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