blob: 2a3551d4f64383c4e09955278943d0fdc82ab4c0 [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), [{
66 int sextVal = ((((int) N->getValue()) << 25) >> 25);
67 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), [{
144 // hi16 predicate - returns true if the immediate has all zeros in the
145 // 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) {
158 uint32_t val = N->getValue();
159 return ((val & 0xffff0000) == val);
160 }
161
162 return false;
163}], HI16>;
164
165//===----------------------------------------------------------------------===//
166// Floating point operands:
167//===----------------------------------------------------------------------===//
168
169// Transform a float, returning the high 16 bits shifted down, as if
170// the float was really an unsigned integer:
171def HI16_f32 : SDNodeXForm<fpimm, [{
Chris Lattner10d724a2007-12-16 20:41:33 +0000172 float fval = N->getValueAPF().convertToFloat();
173 return getI32Imm(FloatToBits(fval) >> 16);
Scott Michel564427e2007-12-05 01:24:05 +0000174}]>;
175
176// Transformation function on floats: get the low 16 bits as if the float was
177// an unsigned integer.
178def LO16_f32 : SDNodeXForm<fpimm, [{
Chris Lattner10d724a2007-12-16 20:41:33 +0000179 float fval = N->getValueAPF().convertToFloat();
180 return getI32Imm(FloatToBits(fval) & 0xffff);
Scott Michel564427e2007-12-05 01:24:05 +0000181}]>;
182
183def FPimm_sext16 : SDNodeXForm<fpimm, [{
Chris Lattner10d724a2007-12-16 20:41:33 +0000184 float fval = N->getValueAPF().convertToFloat();
185 return getI32Imm((int) ((FloatToBits(fval) << 16) >> 16));
Scott Michel564427e2007-12-05 01:24:05 +0000186}]>;
187
188def FPimm_u18 : SDNodeXForm<fpimm, [{
Chris Lattner10d724a2007-12-16 20:41:33 +0000189 float fval = N->getValueAPF().convertToFloat();
190 return getI32Imm(FloatToBits(fval) & ((1 << 19) - 1));
Scott Michel564427e2007-12-05 01:24:05 +0000191}]>;
192
193def fpimmSExt16 : PatLeaf<(fpimm), [{
194 short Ignored;
195 return isFPS16Immediate(N, Ignored);
196}], FPimm_sext16>;
197
198// Does the SFP constant only have upp 16 bits set?
199def hi16_f32 : PatLeaf<(fpimm), [{
200 if (N->getValueType(0) == MVT::f32) {
Chris Lattner10d724a2007-12-16 20:41:33 +0000201 uint32_t val = FloatToBits(N->getValueAPF().convertToFloat());
Scott Michel564427e2007-12-05 01:24:05 +0000202 return ((val & 0xffff0000) == val);
203 }
204
205 return false;
206}], HI16_f32>;
207
208// Does the SFP constant fit into 18 bits?
209def fpimm18 : PatLeaf<(fpimm), [{
210 if (N->getValueType(0) == MVT::f32) {
Chris Lattner10d724a2007-12-16 20:41:33 +0000211 uint32_t Value = FloatToBits(N->getValueAPF().convertToFloat());
Scott Michel564427e2007-12-05 01:24:05 +0000212 return ((Value & ((1 << 19) - 1)) == Value);
213 }
214
215 return false;
216}], FPimm_u18>;
217
218//===----------------------------------------------------------------------===//
Scott Michelec2a08f2007-12-15 00:38:50 +0000219// 64-bit operands (TODO):
Scott Michel564427e2007-12-05 01:24:05 +0000220//===----------------------------------------------------------------------===//
221
222//===----------------------------------------------------------------------===//
223// build_vector operands:
224//===----------------------------------------------------------------------===//
225
226// v16i8SExt8Imm_xform function: convert build_vector to 8-bit sign extended
227// immediate constant load for v16i8 vectors. N.B.: The incoming constant has
228// to be a 16-bit quantity with the upper and lower bytes equal (e.g., 0x2a2a).
229def v16i8SExt8Imm_xform: SDNodeXForm<build_vector, [{
230 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8);
231}]>;
232
233// v16i8SExt8Imm: Predicate test for 8-bit sign extended immediate constant
234// load, works in conjunction with its transform function. N.B.: This relies the
235// incoming constant being a 16-bit quantity, where the upper and lower bytes
236// are EXACTLY the same (e.g., 0x2a2a)
237def v16i8SExt8Imm: PatLeaf<(build_vector), [{
238 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8).Val != 0;
239}], v16i8SExt8Imm_xform>;
240
241// v16i8U8Imm_xform function: convert build_vector to unsigned 8-bit
242// immediate constant load for v16i8 vectors. N.B.: The incoming constant has
243// to be a 16-bit quantity with the upper and lower bytes equal (e.g., 0x2a2a).
244def v16i8U8Imm_xform: SDNodeXForm<build_vector, [{
245 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8);
246}]>;
247
248// v16i8U8Imm: Predicate test for unsigned 8-bit immediate constant
249// load, works in conjunction with its transform function. N.B.: This relies the
250// incoming constant being a 16-bit quantity, where the upper and lower bytes
251// are EXACTLY the same (e.g., 0x2a2a)
252def v16i8U8Imm: PatLeaf<(build_vector), [{
253 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8).Val != 0;
254}], v16i8U8Imm_xform>;
255
256// v8i16SExt8Imm_xform function: convert build_vector to 8-bit sign extended
257// immediate constant load for v8i16 vectors.
258def v8i16SExt8Imm_xform: SDNodeXForm<build_vector, [{
259 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i16);
260}]>;
261
262// v8i16SExt8Imm: Predicate test for 8-bit sign extended immediate constant
263// load, works in conjunction with its transform function.
264def v8i16SExt8Imm: PatLeaf<(build_vector), [{
265 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i16).Val != 0;
266}], v8i16SExt8Imm_xform>;
267
268// v8i16SExt10Imm_xform function: convert build_vector to 16-bit sign extended
269// immediate constant load for v8i16 vectors.
270def v8i16SExt10Imm_xform: SDNodeXForm<build_vector, [{
271 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16);
272}]>;
273
274// v8i16SExt10Imm: Predicate test for 16-bit sign extended immediate constant
275// load, works in conjunction with its transform function.
276def v8i16SExt10Imm: PatLeaf<(build_vector), [{
277 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16).Val != 0;
278}], v8i16SExt10Imm_xform>;
279
Scott Michel504c3692007-12-17 22:32:34 +0000280// v8i16Uns10Imm_xform function: convert build_vector to 16-bit unsigned
281// immediate constant load for v8i16 vectors.
282def v8i16Uns10Imm_xform: SDNodeXForm<build_vector, [{
283 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16);
284}]>;
285
286// v8i16Uns10Imm: Predicate test for 16-bit unsigned immediate constant
287// load, works in conjunction with its transform function.
288def v8i16Uns10Imm: PatLeaf<(build_vector), [{
289 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16).Val != 0;
290}], v8i16Uns10Imm_xform>;
291
Scott Michel564427e2007-12-05 01:24:05 +0000292// v8i16SExt16Imm_xform function: convert build_vector to 16-bit sign extended
293// immediate constant load for v8i16 vectors.
Scott Michel504c3692007-12-17 22:32:34 +0000294def v8i16Uns16Imm_xform: SDNodeXForm<build_vector, [{
Scott Michel564427e2007-12-05 01:24:05 +0000295 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i16);
296}]>;
297
298// v8i16SExt16Imm: Predicate test for 16-bit sign extended immediate constant
299// load, works in conjunction with its transform function.
300def v8i16SExt16Imm: PatLeaf<(build_vector), [{
301 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i16).Val != 0;
Scott Michel504c3692007-12-17 22:32:34 +0000302}], v8i16Uns16Imm_xform>;
Scott Michel564427e2007-12-05 01:24:05 +0000303
304// v4i32SExt10Imm_xform function: convert build_vector to 10-bit sign extended
305// immediate constant load for v4i32 vectors.
306def v4i32SExt10Imm_xform: SDNodeXForm<build_vector, [{
307 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32);
308}]>;
309
310// v4i32SExt10Imm: Predicate test for 10-bit sign extended immediate constant
311// load, works in conjunction with its transform function.
312def v4i32SExt10Imm: PatLeaf<(build_vector), [{
313 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32).Val != 0;
314}], v4i32SExt10Imm_xform>;
315
Scott Michel504c3692007-12-17 22:32:34 +0000316// v4i32Uns10Imm_xform function: convert build_vector to 10-bit unsigned
317// immediate constant load for v4i32 vectors.
318def v4i32Uns10Imm_xform: SDNodeXForm<build_vector, [{
319 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32);
320}]>;
321
322// v4i32Uns10Imm: Predicate test for 10-bit unsigned immediate constant
323// load, works in conjunction with its transform function.
324def v4i32Uns10Imm: PatLeaf<(build_vector), [{
325 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32).Val != 0;
326}], v4i32Uns10Imm_xform>;
327
Scott Michel564427e2007-12-05 01:24:05 +0000328// v4i32SExt16Imm_xform function: convert build_vector to 16-bit sign extended
329// immediate constant load for v4i32 vectors.
330def v4i32SExt16Imm_xform: SDNodeXForm<build_vector, [{
331 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i32);
332}]>;
333
334// v4i32SExt16Imm: Predicate test for 16-bit sign extended immediate constant
335// load, works in conjunction with its transform function.
336def v4i32SExt16Imm: PatLeaf<(build_vector), [{
337 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i32).Val != 0;
338}], v4i32SExt16Imm_xform>;
339
340// v4i32Uns18Imm_xform function: convert build_vector to 18-bit unsigned
341// immediate constant load for v4i32 vectors.
342def v4i32Uns18Imm_xform: SDNodeXForm<build_vector, [{
343 return SPU::get_vec_u18imm(N, *CurDAG, MVT::i32);
344}]>;
345
346// v4i32Uns18Imm: Predicate test for 18-bit unsigned immediate constant load,
347// works in conjunction with its transform function.
348def v4i32Uns18Imm: PatLeaf<(build_vector), [{
349 return SPU::get_vec_u18imm(N, *CurDAG, MVT::i32).Val != 0;
350}], v4i32Uns18Imm_xform>;
351
352// ILHUvec_get_imm xform function: convert build_vector to ILHUvec imm constant
353// load.
354def ILHUvec_get_imm: SDNodeXForm<build_vector, [{
355 return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i32);
356}]>;
357
358/// immILHUvec: Predicate test for a ILHU constant vector.
359def immILHUvec: PatLeaf<(build_vector), [{
360 return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i32).Val != 0;
361}], ILHUvec_get_imm>;
362
363// Catch-all for any other i32 vector constants
364def v4i32_get_imm: SDNodeXForm<build_vector, [{
365 return SPU::get_v4i32_imm(N, *CurDAG);
366}]>;
367
368def v4i32Imm: PatLeaf<(build_vector), [{
369 return SPU::get_v4i32_imm(N, *CurDAG).Val != 0;
370}], v4i32_get_imm>;
371
372// v2i64SExt10Imm_xform function: convert build_vector to 10-bit sign extended
373// immediate constant load for v2i64 vectors.
374def v2i64SExt10Imm_xform: SDNodeXForm<build_vector, [{
375 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i64);
376}]>;
377
378// v2i64SExt10Imm: Predicate test for 10-bit sign extended immediate constant
379// load, works in conjunction with its transform function.
380def v2i64SExt10Imm: PatLeaf<(build_vector), [{
381 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i64).Val != 0;
382}], v2i64SExt10Imm_xform>;
383
384// v2i64SExt16Imm_xform function: convert build_vector to 16-bit sign extended
385// immediate constant load for v2i64 vectors.
386def v2i64SExt16Imm_xform: SDNodeXForm<build_vector, [{
387 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i64);
388}]>;
389
390// v2i64SExt16Imm: Predicate test for 16-bit sign extended immediate constant
391// load, works in conjunction with its transform function.
392def v2i64SExt16Imm: PatLeaf<(build_vector), [{
393 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i64).Val != 0;
394}], v2i64SExt16Imm_xform>;
395
396// v2i64Uns18Imm_xform function: convert build_vector to 18-bit unsigned
397// immediate constant load for v2i64 vectors.
398def v2i64Uns18Imm_xform: SDNodeXForm<build_vector, [{
399 return SPU::get_vec_u18imm(N, *CurDAG, MVT::i64);
400}]>;
401
402// v2i64Uns18Imm: Predicate test for 18-bit unsigned immediate constant load,
403// works in conjunction with its transform function.
404def v2i64Uns18Imm: PatLeaf<(build_vector), [{
405 return SPU::get_vec_u18imm(N, *CurDAG, MVT::i64).Val != 0;
406}], v2i64Uns18Imm_xform>;
407
408/// immILHUvec: Predicate test for a ILHU constant vector.
409def immILHUvec_i64: PatLeaf<(build_vector), [{
410 return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i64).Val != 0;
411}], ILHUvec_get_imm>;
412
413// Catch-all for any other i32 vector constants
414def v2i64_get_imm: SDNodeXForm<build_vector, [{
415 return SPU::get_v2i64_imm(N, *CurDAG);
416}]>;
417
418def v2i64Imm: PatLeaf<(build_vector), [{
419 return SPU::get_v2i64_imm(N, *CurDAG).Val != 0;
420}], v2i64_get_imm>;
421
422//===----------------------------------------------------------------------===//
423// Operand Definitions.
424
Scott Michel9de5d0d2008-01-11 02:53:15 +0000425def s7imm: Operand<i8> {
426 let PrintMethod = "printS7ImmOperand";
427}
428
429def s7imm_i8: Operand<i8> {
Scott Michel564427e2007-12-05 01:24:05 +0000430 let PrintMethod = "printS7ImmOperand";
431}
432
433def u7imm: Operand<i16> {
434 let PrintMethod = "printU7ImmOperand";
435}
436
Scott Michel504c3692007-12-17 22:32:34 +0000437def u7imm_i8: Operand<i8> {
438 let PrintMethod = "printU7ImmOperand";
439}
440
Scott Michel564427e2007-12-05 01:24:05 +0000441def u7imm_i32: Operand<i32> {
442 let PrintMethod = "printU7ImmOperand";
443}
444
445// Halfword, signed 10-bit constant
446def s10imm : Operand<i16> {
447 let PrintMethod = "printS10ImmOperand";
448}
449
450def s10imm_i32: Operand<i32> {
451 let PrintMethod = "printS10ImmOperand";
452}
453
454def s10imm_i64: Operand<i64> {
455 let PrintMethod = "printS10ImmOperand";
456}
457
458// Unsigned 10-bit integers:
459def u10imm: Operand<i16> {
460 let PrintMethod = "printU10ImmOperand";
461}
462
Scott Michel504c3692007-12-17 22:32:34 +0000463def u10imm_i8: Operand<i8> {
464 let PrintMethod = "printU10ImmOperand";
465}
466
Scott Michel564427e2007-12-05 01:24:05 +0000467def u10imm_i32: Operand<i32> {
468 let PrintMethod = "printU10ImmOperand";
469}
470
471def s16imm : Operand<i16> {
472 let PrintMethod = "printS16ImmOperand";
473}
474
Scott Michel504c3692007-12-17 22:32:34 +0000475def s16imm_i8: Operand<i8> {
476 let PrintMethod = "printS16ImmOperand";
477}
478
Scott Michel564427e2007-12-05 01:24:05 +0000479def s16imm_i32: Operand<i32> {
480 let PrintMethod = "printS16ImmOperand";
481}
482
483def s16imm_i64: Operand<i64> {
484 let PrintMethod = "printS16ImmOperand";
485}
486
487def s16imm_f32: Operand<f32> {
488 let PrintMethod = "printS16ImmOperand";
489}
490
491def s16imm_f64: Operand<f64> {
492 let PrintMethod = "printS16ImmOperand";
493}
494
495def u16imm : Operand<i32> {
496 let PrintMethod = "printU16ImmOperand";
497}
498
499def f16imm : Operand<f32> {
500 let PrintMethod = "printU16ImmOperand";
501}
502
503def s18imm : Operand<i32> {
504 let PrintMethod = "printS18ImmOperand";
505}
506
507def u18imm : Operand<i32> {
508 let PrintMethod = "printU18ImmOperand";
509}
510
511def u18imm_i64 : Operand<i64> {
512 let PrintMethod = "printU18ImmOperand";
513}
514
515def f18imm : Operand<f32> {
516 let PrintMethod = "printU18ImmOperand";
517}
518
519def f18imm_f64 : Operand<f64> {
520 let PrintMethod = "printU18ImmOperand";
521}
522
523// Negated 7-bit halfword rotate immediate operands
524def rothNeg7imm : Operand<i32> {
525 let PrintMethod = "printROTHNeg7Imm";
526}
527
528def rothNeg7imm_i16 : Operand<i16> {
529 let PrintMethod = "printROTHNeg7Imm";
530}
531
532// Negated 7-bit word rotate immediate operands
533def rotNeg7imm : Operand<i32> {
534 let PrintMethod = "printROTNeg7Imm";
535}
536
537def rotNeg7imm_i16 : Operand<i16> {
538 let PrintMethod = "printROTNeg7Imm";
539}
540
541// Floating point immediate operands
542def f32imm : Operand<f32>;
543
544def target : Operand<OtherVT> {
545 let PrintMethod = "printBranchOperand";
546}
547
548// Absolute address call target
549def calltarget : Operand<iPTR> {
550 let PrintMethod = "printCallOperand";
551 let MIOperandInfo = (ops u18imm:$calldest);
552}
553
554// Relative call target
555def relcalltarget : Operand<iPTR> {
556 let PrintMethod = "printPCRelativeOperand";
557 let MIOperandInfo = (ops s16imm:$calldest);
558}
559
560// Branch targets:
561def brtarget : Operand<OtherVT> {
562 let PrintMethod = "printPCRelativeOperand";
563}
564
565// Indirect call target
566def indcalltarget : Operand<iPTR> {
567 let PrintMethod = "printCallOperand";
568 let MIOperandInfo = (ops ptr_rc:$calldest);
569}
570
571def symbolHi: Operand<i32> {
572 let PrintMethod = "printSymbolHi";
573}
574
575def symbolLo: Operand<i32> {
576 let PrintMethod = "printSymbolLo";
577}
578
579def symbolLSA: Operand<i32> {
580 let PrintMethod = "printSymbolLSA";
581}
582
583// memory s7imm(reg) operaand
584def memri7 : Operand<iPTR> {
585 let PrintMethod = "printMemRegImmS7";
586 let MIOperandInfo = (ops s7imm:$imm, ptr_rc:$reg);
587}
588
589// memory s10imm(reg) operand
590def memri10 : Operand<iPTR> {
591 let PrintMethod = "printMemRegImmS10";
592 let MIOperandInfo = (ops s10imm:$imm, ptr_rc:$reg);
593}
594
595// 256K local store address
596// N.B.: The tblgen code generator expects to have two operands, an offset
597// and a pointer. Of these, only the immediate is actually used.
598def addr256k : Operand<iPTR> {
599 let PrintMethod = "printAddr256K";
600 let MIOperandInfo = (ops s16imm:$imm, ptr_rc:$reg);
601}
602
603// memory s18imm(reg) operand
604def memri18 : Operand<iPTR> {
605 let PrintMethod = "printMemRegImmS18";
606 let MIOperandInfo = (ops s18imm:$imm, ptr_rc:$reg);
607}
608
609// memory register + register operand
610def memrr : Operand<iPTR> {
611 let PrintMethod = "printMemRegReg";
612 let MIOperandInfo = (ops ptr_rc:$reg_a, ptr_rc:$reg_b);
613}
614
615// Define SPU-specific addressing modes: These come in three basic
616// flavors:
617//
618// D-form : [r+I10] (10-bit signed offset + reg)
619// X-form : [r+r] (reg+reg)
620// A-form : abs (256K LSA offset)
621// D-form(2): [r+I7] (7-bit signed offset + reg)
622
623def dform_addr : ComplexPattern<iPTR, 2, "SelectDFormAddr", [], []>;
624def xform_addr : ComplexPattern<iPTR, 2, "SelectXFormAddr", [], []>;
625def aform_addr : ComplexPattern<iPTR, 2, "SelectAFormAddr", [], []>;
626def dform2_addr : ComplexPattern<iPTR, 2, "SelectDForm2Addr", [], []>;