blob: 43982279b52059d30e9575bfffd619e9f2b73de0 [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, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000013 unsigned val = N->getZExtValue();
Scott Michel564427e2007-12-05 01:24:05 +000014 // Transformation function: get the low 16 bits.
15 return getI32Imm(val & 0xffff);
16}]>;
17
18def LO16_vec : SDNodeXForm<scalar_to_vector, [{
Dan Gohman475871a2008-07-27 21:46:04 +000019 SDValue OpVal(0, 0);
Scott Michel564427e2007-12-05 01:24:05 +000020
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...
Gabor Greif93c53e52008-08-31 15:37:04 +000027 for (unsigned i = 0, e = N->getNumOperands();
28 OpVal.getNode() == 0 && i != e; ++i) {
Scott Michel564427e2007-12-05 01:24:05 +000029 if (N->getOperand(i).getOpcode() == ISD::UNDEF) continue;
Gabor Greifba36cb52008-08-28 21:40:38 +000030 if (OpVal.getNode() == 0)
Scott Michel564427e2007-12-05 01:24:05 +000031 OpVal = N->getOperand(i);
32 }
33
Gabor Greifba36cb52008-08-28 21:40:38 +000034 assert(OpVal.getNode() != 0 && "LO16_vec did not locate a <defined> node");
Dan Gohmand8ed2a72008-08-20 14:50:24 +000035 ConstantSDNode *CN = cast<ConstantSDNode>(OpVal);
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000036 return getI32Imm((unsigned)CN->getZExtValue() & 0xffff);
Scott Michel564427e2007-12-05 01:24:05 +000037}]>;
38
39// Transform an immediate, returning the high 16 bits shifted down:
40def HI16 : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000041 return getI32Imm((unsigned)N->getZExtValue() >> 16);
Scott Michel564427e2007-12-05 01:24:05 +000042}]>;
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, [{
Dan Gohman475871a2008-07-27 21:46:04 +000047 SDValue OpVal(0, 0);
Scott Michel564427e2007-12-05 01:24:05 +000048
49 assert(N->getOpcode() == ISD::BUILD_VECTOR
50 && "HI16_vec got something other than a BUILD_VECTOR");
51
52 // Get first constant operand...
Gabor Greif93c53e52008-08-31 15:37:04 +000053 for (unsigned i = 0, e = N->getNumOperands();
54 OpVal.getNode() == 0 && i != e; ++i) {
Scott Michel564427e2007-12-05 01:24:05 +000055 if (N->getOperand(i).getOpcode() == ISD::UNDEF) continue;
Gabor Greifba36cb52008-08-28 21:40:38 +000056 if (OpVal.getNode() == 0)
Scott Michel564427e2007-12-05 01:24:05 +000057 OpVal = N->getOperand(i);
58 }
59
Gabor Greifba36cb52008-08-28 21:40:38 +000060 assert(OpVal.getNode() != 0 && "HI16_vec did not locate a <defined> node");
Dan Gohmand8ed2a72008-08-20 14:50:24 +000061 ConstantSDNode *CN = cast<ConstantSDNode>(OpVal);
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000062 return getI32Imm((unsigned)CN->getZExtValue() >> 16);
Scott Michel564427e2007-12-05 01:24:05 +000063}]>;
64
65// simm7 predicate - True if the immediate fits in an 7-bit signed
66// field.
67def simm7: PatLeaf<(imm), [{
Dan Gohman7810bfe2008-09-26 21:54:37 +000068 int sextVal = int(N->getSExtValue());
Scott Michel564427e2007-12-05 01:24:05 +000069 return (sextVal >= -64 && sextVal <= 63);
70}]>;
71
72// uimm7 predicate - True if the immediate fits in an 7-bit unsigned
73// field.
74def uimm7: PatLeaf<(imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000075 return (N->getZExtValue() <= 0x7f);
Scott Michel564427e2007-12-05 01:24:05 +000076}]>;
77
78// immSExt8 predicate - True if the immediate fits in an 8-bit sign extended
79// field.
80def immSExt8 : PatLeaf<(imm), [{
Dan Gohman7810bfe2008-09-26 21:54:37 +000081 int Value = int(N->getSExtValue());
Scott Michel79698f62008-03-20 00:51:36 +000082 return (Value >= -(1 << 8) && Value <= (1 << 8) - 1);
Scott Michel564427e2007-12-05 01:24:05 +000083}]>;
84
85// immU8: immediate, unsigned 8-bit quantity
86def immU8 : PatLeaf<(imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000087 return (N->getZExtValue() <= 0xff);
Scott Michel564427e2007-12-05 01:24:05 +000088}]>;
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.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000130 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
Scott Michel564427e2007-12-05 01:24:05 +0000131}], LO16>;
132
133def immU16 : PatLeaf<(imm), [{
134 // immU16 predicate- True if the immediate fits into a 16-bit unsigned field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000135 return (uint64_t)N->getZExtValue() == (N->getZExtValue() & 0xffff);
Scott Michel564427e2007-12-05 01:24:05 +0000136}]>;
137
138def imm18 : PatLeaf<(imm), [{
139 // imm18 predicate: True if the immediate fits into an 18-bit unsigned field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000140 int Value = (int) N->getZExtValue();
Scott Michel564427e2007-12-05 01:24:05 +0000141 return ((Value & ((1 << 19) - 1)) == Value);
142}]>;
143
Scott Michel9de5d0d2008-01-11 02:53:15 +0000144def lo16 : PatLeaf<(imm), [{
Scott Michelad2715e2008-03-05 23:02:02 +0000145 // lo16 predicate - returns true if the immediate has all zeros in the
Scott Michel9de5d0d2008-01-11 02:53:15 +0000146 // low order bits and is a 32-bit constant:
147 if (N->getValueType(0) == MVT::i32) {
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000148 uint32_t val = N->getZExtValue();
Scott Michel9de5d0d2008-01-11 02:53:15 +0000149 return ((val & 0x0000ffff) == val);
150 }
151
152 return false;
153}], LO16>;
154
Scott Michel564427e2007-12-05 01:24:05 +0000155def 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) {
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000159 uint32_t val = uint32_t(N->getZExtValue());
Scott Michel564427e2007-12-05 01:24:05 +0000160 return ((val & 0xffff0000) == val);
Scott Michelad2715e2008-03-05 23:02:02 +0000161 } else if (N->getValueType(0) == MVT::i64) {
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000162 uint64_t val = N->getZExtValue();
Scott Michelad2715e2008-03-05 23:02:02 +0000163 return ((val & 0xffff0000ULL) == val);
Scott Michel564427e2007-12-05 01:24:05 +0000164 }
165
166 return false;
167}], HI16>;
168
Scott Michela59d4692008-02-23 18:41:37 +0000169def bitshift : PatLeaf<(imm), [{
170 // bitshift predicate - returns true if 0 < imm <= 7 for SHLQBII
171 // (shift left quadword by bits immediate)
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000172 int64_t Val = N->getZExtValue();
Scott Michela59d4692008-02-23 18:41:37 +0000173 return (Val > 0 && Val <= 7);
174}]>;
175
Scott Michel564427e2007-12-05 01:24:05 +0000176//===----------------------------------------------------------------------===//
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:
182def HI16_f32 : SDNodeXForm<fpimm, [{
Chris Lattner10d724a2007-12-16 20:41:33 +0000183 float fval = N->getValueAPF().convertToFloat();
184 return getI32Imm(FloatToBits(fval) >> 16);
Scott Michel564427e2007-12-05 01:24:05 +0000185}]>;
186
187// Transformation function on floats: get the low 16 bits as if the float was
188// an unsigned integer.
189def LO16_f32 : SDNodeXForm<fpimm, [{
Chris Lattner10d724a2007-12-16 20:41:33 +0000190 float fval = N->getValueAPF().convertToFloat();
191 return getI32Imm(FloatToBits(fval) & 0xffff);
Scott Michel564427e2007-12-05 01:24:05 +0000192}]>;
193
194def FPimm_sext16 : SDNodeXForm<fpimm, [{
Chris Lattner10d724a2007-12-16 20:41:33 +0000195 float fval = N->getValueAPF().convertToFloat();
196 return getI32Imm((int) ((FloatToBits(fval) << 16) >> 16));
Scott Michel564427e2007-12-05 01:24:05 +0000197}]>;
198
199def FPimm_u18 : SDNodeXForm<fpimm, [{
Chris Lattner10d724a2007-12-16 20:41:33 +0000200 float fval = N->getValueAPF().convertToFloat();
201 return getI32Imm(FloatToBits(fval) & ((1 << 19) - 1));
Scott Michel564427e2007-12-05 01:24:05 +0000202}]>;
203
204def 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?
210def hi16_f32 : PatLeaf<(fpimm), [{
211 if (N->getValueType(0) == MVT::f32) {
Chris Lattner10d724a2007-12-16 20:41:33 +0000212 uint32_t val = FloatToBits(N->getValueAPF().convertToFloat());
Scott Michel564427e2007-12-05 01:24:05 +0000213 return ((val & 0xffff0000) == val);
214 }
215
216 return false;
217}], HI16_f32>;
218
219// Does the SFP constant fit into 18 bits?
220def fpimm18 : PatLeaf<(fpimm), [{
221 if (N->getValueType(0) == MVT::f32) {
Chris Lattner10d724a2007-12-16 20:41:33 +0000222 uint32_t Value = FloatToBits(N->getValueAPF().convertToFloat());
Scott Michel564427e2007-12-05 01:24:05 +0000223 return ((Value & ((1 << 19) - 1)) == Value);
224 }
225
226 return false;
227}], FPimm_u18>;
228
229//===----------------------------------------------------------------------===//
Scott Michelec2a08f2007-12-15 00:38:50 +0000230// 64-bit operands (TODO):
Scott Michel564427e2007-12-05 01:24:05 +0000231//===----------------------------------------------------------------------===//
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).
240def 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)
248def v16i8SExt8Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000249 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000250}], 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).
255def 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)
263def v16i8U8Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000264 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i8).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000265}], v16i8U8Imm_xform>;
266
267// v8i16SExt8Imm_xform function: convert build_vector to 8-bit sign extended
268// immediate constant load for v8i16 vectors.
269def 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.
275def v8i16SExt8Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000276 return SPU::get_vec_i8imm(N, *CurDAG, MVT::i16).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000277}], v8i16SExt8Imm_xform>;
278
279// v8i16SExt10Imm_xform function: convert build_vector to 16-bit sign extended
280// immediate constant load for v8i16 vectors.
281def 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.
287def v8i16SExt10Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000288 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000289}], v8i16SExt10Imm_xform>;
290
Scott Michel504c3692007-12-17 22:32:34 +0000291// v8i16Uns10Imm_xform function: convert build_vector to 16-bit unsigned
292// immediate constant load for v8i16 vectors.
293def 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.
299def v8i16Uns10Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000300 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i16).getNode() != 0;
Scott Michel504c3692007-12-17 22:32:34 +0000301}], v8i16Uns10Imm_xform>;
302
Scott Michel564427e2007-12-05 01:24:05 +0000303// v8i16SExt16Imm_xform function: convert build_vector to 16-bit sign extended
304// immediate constant load for v8i16 vectors.
Scott Michel504c3692007-12-17 22:32:34 +0000305def v8i16Uns16Imm_xform: SDNodeXForm<build_vector, [{
Scott Michel564427e2007-12-05 01:24:05 +0000306 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.
311def v8i16SExt16Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000312 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i16).getNode() != 0;
Scott Michel504c3692007-12-17 22:32:34 +0000313}], v8i16Uns16Imm_xform>;
Scott Michel564427e2007-12-05 01:24:05 +0000314
315// v4i32SExt10Imm_xform function: convert build_vector to 10-bit sign extended
316// immediate constant load for v4i32 vectors.
317def 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.
323def v4i32SExt10Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000324 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000325}], v4i32SExt10Imm_xform>;
326
Scott Michel504c3692007-12-17 22:32:34 +0000327// v4i32Uns10Imm_xform function: convert build_vector to 10-bit unsigned
328// immediate constant load for v4i32 vectors.
329def 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.
335def v4i32Uns10Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000336 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i32).getNode() != 0;
Scott Michel504c3692007-12-17 22:32:34 +0000337}], v4i32Uns10Imm_xform>;
338
Scott Michel564427e2007-12-05 01:24:05 +0000339// v4i32SExt16Imm_xform function: convert build_vector to 16-bit sign extended
340// immediate constant load for v4i32 vectors.
341def 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.
347def v4i32SExt16Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000348 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i32).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000349}], v4i32SExt16Imm_xform>;
350
351// v4i32Uns18Imm_xform function: convert build_vector to 18-bit unsigned
352// immediate constant load for v4i32 vectors.
353def 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.
359def v4i32Uns18Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000360 return SPU::get_vec_u18imm(N, *CurDAG, MVT::i32).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000361}], v4i32Uns18Imm_xform>;
362
363// ILHUvec_get_imm xform function: convert build_vector to ILHUvec imm constant
364// load.
365def 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.
370def immILHUvec: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000371 return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i32).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000372}], ILHUvec_get_imm>;
373
374// Catch-all for any other i32 vector constants
375def v4i32_get_imm: SDNodeXForm<build_vector, [{
376 return SPU::get_v4i32_imm(N, *CurDAG);
377}]>;
378
379def v4i32Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000380 return SPU::get_v4i32_imm(N, *CurDAG).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000381}], v4i32_get_imm>;
382
383// v2i64SExt10Imm_xform function: convert build_vector to 10-bit sign extended
384// immediate constant load for v2i64 vectors.
385def 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.
391def v2i64SExt10Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000392 return SPU::get_vec_i10imm(N, *CurDAG, MVT::i64).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000393}], v2i64SExt10Imm_xform>;
394
395// v2i64SExt16Imm_xform function: convert build_vector to 16-bit sign extended
396// immediate constant load for v2i64 vectors.
397def 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.
403def v2i64SExt16Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000404 return SPU::get_vec_i16imm(N, *CurDAG, MVT::i64).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000405}], v2i64SExt16Imm_xform>;
406
407// v2i64Uns18Imm_xform function: convert build_vector to 18-bit unsigned
408// immediate constant load for v2i64 vectors.
409def 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.
415def v2i64Uns18Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000416 return SPU::get_vec_u18imm(N, *CurDAG, MVT::i64).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000417}], v2i64Uns18Imm_xform>;
418
419/// immILHUvec: Predicate test for a ILHU constant vector.
420def immILHUvec_i64: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000421 return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i64).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000422}], ILHUvec_get_imm>;
423
424// Catch-all for any other i32 vector constants
425def v2i64_get_imm: SDNodeXForm<build_vector, [{
426 return SPU::get_v2i64_imm(N, *CurDAG);
427}]>;
428
429def v2i64Imm: PatLeaf<(build_vector), [{
Gabor Greifba36cb52008-08-28 21:40:38 +0000430 return SPU::get_v2i64_imm(N, *CurDAG).getNode() != 0;
Scott Michel564427e2007-12-05 01:24:05 +0000431}], v2i64_get_imm>;
432
433//===----------------------------------------------------------------------===//
434// Operand Definitions.
435
Scott Michel9de5d0d2008-01-11 02:53:15 +0000436def s7imm: Operand<i8> {
437 let PrintMethod = "printS7ImmOperand";
438}
439
440def s7imm_i8: Operand<i8> {
Scott Michel564427e2007-12-05 01:24:05 +0000441 let PrintMethod = "printS7ImmOperand";
442}
443
444def u7imm: Operand<i16> {
445 let PrintMethod = "printU7ImmOperand";
446}
447
Scott Michel504c3692007-12-17 22:32:34 +0000448def u7imm_i8: Operand<i8> {
449 let PrintMethod = "printU7ImmOperand";
450}
451
Scott Michel564427e2007-12-05 01:24:05 +0000452def u7imm_i32: Operand<i32> {
453 let PrintMethod = "printU7ImmOperand";
454}
455
456// Halfword, signed 10-bit constant
457def s10imm : Operand<i16> {
458 let PrintMethod = "printS10ImmOperand";
459}
460
Scott Michela59d4692008-02-23 18:41:37 +0000461def s10imm_i8: Operand<i8> {
462 let PrintMethod = "printS10ImmOperand";
463}
464
Scott Michel564427e2007-12-05 01:24:05 +0000465def s10imm_i32: Operand<i32> {
466 let PrintMethod = "printS10ImmOperand";
467}
468
469def s10imm_i64: Operand<i64> {
470 let PrintMethod = "printS10ImmOperand";
471}
472
473// Unsigned 10-bit integers:
474def u10imm: Operand<i16> {
475 let PrintMethod = "printU10ImmOperand";
476}
477
Scott Michel504c3692007-12-17 22:32:34 +0000478def u10imm_i8: Operand<i8> {
479 let PrintMethod = "printU10ImmOperand";
480}
481
Scott Michel564427e2007-12-05 01:24:05 +0000482def u10imm_i32: Operand<i32> {
483 let PrintMethod = "printU10ImmOperand";
484}
485
486def s16imm : Operand<i16> {
487 let PrintMethod = "printS16ImmOperand";
488}
489
Scott Michel504c3692007-12-17 22:32:34 +0000490def s16imm_i8: Operand<i8> {
491 let PrintMethod = "printS16ImmOperand";
492}
493
Scott Michel564427e2007-12-05 01:24:05 +0000494def s16imm_i32: Operand<i32> {
495 let PrintMethod = "printS16ImmOperand";
496}
497
498def s16imm_i64: Operand<i64> {
499 let PrintMethod = "printS16ImmOperand";
500}
501
502def s16imm_f32: Operand<f32> {
503 let PrintMethod = "printS16ImmOperand";
504}
505
506def s16imm_f64: Operand<f64> {
507 let PrintMethod = "printS16ImmOperand";
508}
509
Scott Michelad2715e2008-03-05 23:02:02 +0000510def u16imm_i64 : Operand<i64> {
511 let PrintMethod = "printU16ImmOperand";
512}
513
Scott Michel203b2d62008-04-30 00:30:08 +0000514def u16imm_i32 : Operand<i32> {
515 let PrintMethod = "printU16ImmOperand";
516}
517
518def u16imm : Operand<i16> {
Scott Michel564427e2007-12-05 01:24:05 +0000519 let PrintMethod = "printU16ImmOperand";
520}
521
522def f16imm : Operand<f32> {
523 let PrintMethod = "printU16ImmOperand";
524}
525
526def s18imm : Operand<i32> {
527 let PrintMethod = "printS18ImmOperand";
528}
529
530def u18imm : Operand<i32> {
531 let PrintMethod = "printU18ImmOperand";
532}
533
534def u18imm_i64 : Operand<i64> {
535 let PrintMethod = "printU18ImmOperand";
536}
537
538def f18imm : Operand<f32> {
539 let PrintMethod = "printU18ImmOperand";
540}
541
542def f18imm_f64 : Operand<f64> {
543 let PrintMethod = "printU18ImmOperand";
544}
545
546// Negated 7-bit halfword rotate immediate operands
547def rothNeg7imm : Operand<i32> {
548 let PrintMethod = "printROTHNeg7Imm";
549}
550
551def rothNeg7imm_i16 : Operand<i16> {
552 let PrintMethod = "printROTHNeg7Imm";
553}
554
555// Negated 7-bit word rotate immediate operands
556def rotNeg7imm : Operand<i32> {
557 let PrintMethod = "printROTNeg7Imm";
558}
559
560def rotNeg7imm_i16 : Operand<i16> {
561 let PrintMethod = "printROTNeg7Imm";
562}
563
Scott Michel8bf61e82008-06-02 22:18:03 +0000564def rotNeg7imm_i8 : Operand<i8> {
565 let PrintMethod = "printROTNeg7Imm";
566}
567
Scott Michel564427e2007-12-05 01:24:05 +0000568def target : Operand<OtherVT> {
569 let PrintMethod = "printBranchOperand";
570}
571
572// Absolute address call target
573def calltarget : Operand<iPTR> {
574 let PrintMethod = "printCallOperand";
575 let MIOperandInfo = (ops u18imm:$calldest);
576}
577
578// Relative call target
579def relcalltarget : Operand<iPTR> {
580 let PrintMethod = "printPCRelativeOperand";
581 let MIOperandInfo = (ops s16imm:$calldest);
582}
583
584// Branch targets:
585def brtarget : Operand<OtherVT> {
586 let PrintMethod = "printPCRelativeOperand";
587}
588
589// Indirect call target
590def indcalltarget : Operand<iPTR> {
591 let PrintMethod = "printCallOperand";
592 let MIOperandInfo = (ops ptr_rc:$calldest);
593}
594
595def symbolHi: Operand<i32> {
596 let PrintMethod = "printSymbolHi";
597}
598
599def symbolLo: Operand<i32> {
600 let PrintMethod = "printSymbolLo";
601}
602
603def symbolLSA: Operand<i32> {
604 let PrintMethod = "printSymbolLSA";
605}
606
607// memory s7imm(reg) operaand
608def memri7 : Operand<iPTR> {
609 let PrintMethod = "printMemRegImmS7";
610 let MIOperandInfo = (ops s7imm:$imm, ptr_rc:$reg);
611}
612
613// memory s10imm(reg) operand
614def 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.
622def addr256k : Operand<iPTR> {
623 let PrintMethod = "printAddr256K";
624 let MIOperandInfo = (ops s16imm:$imm, ptr_rc:$reg);
625}
626
627// memory s18imm(reg) operand
628def memri18 : Operand<iPTR> {
629 let PrintMethod = "printMemRegImmS18";
630 let MIOperandInfo = (ops s18imm:$imm, ptr_rc:$reg);
631}
632
633// memory register + register operand
634def 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
647def dform_addr : ComplexPattern<iPTR, 2, "SelectDFormAddr", [], []>;
648def xform_addr : ComplexPattern<iPTR, 2, "SelectXFormAddr", [], []>;
649def aform_addr : ComplexPattern<iPTR, 2, "SelectAFormAddr", [], []>;
650def dform2_addr : ComplexPattern<iPTR, 2, "SelectDForm2Addr", [], []>;