1 //=====- SystemZOperands.td - SystemZ Operands defs ---------*- tblgen-*-=====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the various SystemZ instruction operands.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // Instruction Pattern Stuff.
16 //===----------------------------------------------------------------------===//
18 // SystemZ specific condition code. These correspond to CondCode in
19 // SystemZ.h. They must be kept in synch.
20 def SYSTEMZ_COND_O : PatLeaf<(i8 0)>;
21 def SYSTEMZ_COND_H : PatLeaf<(i8 1)>;
22 def SYSTEMZ_COND_NLE : PatLeaf<(i8 2)>;
23 def SYSTEMZ_COND_L : PatLeaf<(i8 3)>;
24 def SYSTEMZ_COND_NHE : PatLeaf<(i8 4)>;
25 def SYSTEMZ_COND_LH : PatLeaf<(i8 5)>;
26 def SYSTEMZ_COND_NE : PatLeaf<(i8 6)>;
27 def SYSTEMZ_COND_E : PatLeaf<(i8 7)>;
28 def SYSTEMZ_COND_NLH : PatLeaf<(i8 8)>;
29 def SYSTEMZ_COND_HE : PatLeaf<(i8 9)>;
30 def SYSTEMZ_COND_NL : PatLeaf<(i8 10)>;
31 def SYSTEMZ_COND_LE : PatLeaf<(i8 11)>;
32 def SYSTEMZ_COND_NH : PatLeaf<(i8 12)>;
33 def SYSTEMZ_COND_NO : PatLeaf<(i8 13)>;
35 def LO8 : SDNodeXForm<imm, [{
36 // Transformation function: return low 8 bits.
37 return getI8Imm(N->getZExtValue() & 0x00000000000000FFULL);
40 def LL16 : SDNodeXForm<imm, [{
41 // Transformation function: return low 16 bits.
42 return getI16Imm(N->getZExtValue() & 0x000000000000FFFFULL);
45 def LH16 : SDNodeXForm<imm, [{
46 // Transformation function: return bits 16-31.
47 return getI16Imm((N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16);
50 def HL16 : SDNodeXForm<imm, [{
51 // Transformation function: return bits 32-47.
52 return getI16Imm((N->getZExtValue() & 0x0000FFFF00000000ULL) >> 32);
55 def HH16 : SDNodeXForm<imm, [{
56 // Transformation function: return bits 48-63.
57 return getI16Imm((N->getZExtValue() & 0xFFFF000000000000ULL) >> 48);
60 def LO32 : SDNodeXForm<imm, [{
61 // Transformation function: return low 32 bits.
62 return getI32Imm(N->getZExtValue() & 0x00000000FFFFFFFFULL);
65 def HI32 : SDNodeXForm<imm, [{
66 // Transformation function: return bits 32-63.
67 return getI32Imm(N->getZExtValue() >> 32);
70 def GetI64FromI32 : SDNodeXForm<imm, [{
71 return CurDAG->getTargetConstant(N->getSExtValue(), MVT::i64);
74 def i32ll16 : PatLeaf<(i32 imm), [{
75 // i32ll16 predicate - true if the 32-bit immediate has only rightmost 16
77 return ((N->getZExtValue() & 0x000000000000FFFFULL) == N->getZExtValue());
80 def i32lh16 : PatLeaf<(i32 imm), [{
81 // i32lh16 predicate - true if the 32-bit immediate has only bits 16-31 set.
82 return ((N->getZExtValue() & 0x00000000FFFF0000ULL) == N->getZExtValue());
85 def i32ll16c : PatLeaf<(i32 imm), [{
86 // i32ll16c predicate - true if the 32-bit immediate has all bits 16-31 set.
87 return ((N->getZExtValue() | 0x00000000FFFF0000ULL) == N->getZExtValue());
90 def i32lh16c : PatLeaf<(i32 imm), [{
91 // i32lh16c predicate - true if the 32-bit immediate has all rightmost 16
93 return ((N->getZExtValue() | 0x000000000000FFFFULL) == N->getZExtValue());
96 def i64ll16 : PatLeaf<(i64 imm), [{
97 // i64ll16 predicate - true if the 64-bit immediate has only rightmost 16
99 return ((N->getZExtValue() & 0x000000000000FFFFULL) == N->getZExtValue());
102 def i64lh16 : PatLeaf<(i64 imm), [{
103 // i64lh16 predicate - true if the 64-bit immediate has only bits 16-31 set.
104 return ((N->getZExtValue() & 0x00000000FFFF0000ULL) == N->getZExtValue());
107 def i64hl16 : PatLeaf<(i64 imm), [{
108 // i64hl16 predicate - true if the 64-bit immediate has only bits 32-47 set.
109 return ((N->getZExtValue() & 0x0000FFFF00000000ULL) == N->getZExtValue());
112 def i64hh16 : PatLeaf<(i64 imm), [{
113 // i64hh16 predicate - true if the 64-bit immediate has only bits 48-63 set.
114 return ((N->getZExtValue() & 0xFFFF000000000000ULL) == N->getZExtValue());
117 def i64ll16c : PatLeaf<(i64 imm), [{
118 // i64ll16c predicate - true if the 64-bit immediate has only rightmost 16
120 return ((N->getZExtValue() | 0xFFFFFFFFFFFF0000ULL) == N->getZExtValue());
123 def i64lh16c : PatLeaf<(i64 imm), [{
124 // i64lh16c predicate - true if the 64-bit immediate has only bits 16-31 set.
125 return ((N->getZExtValue() | 0xFFFFFFFF0000FFFFULL) == N->getZExtValue());
128 def i64hl16c : PatLeaf<(i64 imm), [{
129 // i64hl16c predicate - true if the 64-bit immediate has only bits 32-47 set.
130 return ((N->getZExtValue() | 0xFFFF0000FFFFFFFFULL) == N->getZExtValue());
133 def i64hh16c : PatLeaf<(i64 imm), [{
134 // i64hh16c predicate - true if the 64-bit immediate has only bits 48-63 set.
135 return ((N->getZExtValue() | 0x0000FFFFFFFFFFFFULL) == N->getZExtValue());
138 def immSExt16 : PatLeaf<(imm), [{
139 // immSExt16 predicate - true if the immediate fits in a 16-bit sign extended
141 if (N->getValueType(0) == MVT::i64) {
142 uint64_t val = N->getZExtValue();
143 return ((int64_t)val == (int16_t)val);
144 } else if (N->getValueType(0) == MVT::i32) {
145 uint32_t val = N->getZExtValue();
146 return ((int32_t)val == (int16_t)val);
152 def immSExt32 : PatLeaf<(i64 imm), [{
153 // immSExt32 predicate - true if the immediate fits in a 32-bit sign extended
155 uint64_t val = N->getZExtValue();
156 return ((int64_t)val == (int32_t)val);
159 def i64lo32 : PatLeaf<(i64 imm), [{
160 // i64lo32 predicate - true if the 64-bit immediate has only rightmost 32
162 return ((N->getZExtValue() & 0x00000000FFFFFFFFULL) == N->getZExtValue());
165 def i64hi32 : PatLeaf<(i64 imm), [{
166 // i64hi32 predicate - true if the 64-bit immediate has only bits 32-63 set.
167 return ((N->getZExtValue() & 0xFFFFFFFF00000000ULL) == N->getZExtValue());
170 def i64lo32c : PatLeaf<(i64 imm), [{
171 // i64lo32 predicate - true if the 64-bit immediate has only rightmost 32
173 return ((N->getZExtValue() | 0xFFFFFFFF00000000ULL) == N->getZExtValue());
176 def i64hi32c : PatLeaf<(i64 imm), [{
177 // i64hi32 predicate - true if the 64-bit immediate has only bits 32-63 set.
178 return ((N->getZExtValue() | 0x00000000FFFFFFFFULL) == N->getZExtValue());
181 def i32immSExt8 : PatLeaf<(i32 imm), [{
182 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
183 // sign extended field.
184 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
187 def i32immSExt16 : PatLeaf<(i32 imm), [{
188 // i32immSExt16 predicate - True if the 32-bit immediate fits in a 16-bit
189 // sign extended field.
190 return (int32_t)N->getZExtValue() == (int16_t)N->getZExtValue();
193 def i64immSExt32 : PatLeaf<(i64 imm), [{
194 // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit
195 // sign extended field.
196 return (int64_t)N->getZExtValue() == (int32_t)N->getZExtValue();
199 def i64immZExt32 : PatLeaf<(i64 imm), [{
200 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
201 // zero extended field.
202 return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue();
206 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
207 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
208 def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
209 def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
210 def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
212 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
213 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
214 def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
215 def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
216 def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
218 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
219 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
220 def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
221 def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
222 def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
224 // A couple of more descriptive operand definitions.
225 // 32-bits but only 8 bits are significant.
226 def i32i8imm : Operand<i32>;
227 // 32-bits but only 16 bits are significant.
228 def i32i16imm : Operand<i32>;
229 // 64-bits but only 32 bits are significant.
230 def i64i32imm : Operand<i64>;
231 // Branch targets have OtherVT type.
232 def brtarget : Operand<OtherVT>;
235 def u12imm : Operand<i32> {
236 let PrintMethod = "printU12ImmOperand";
238 def u12imm64 : Operand<i64> {
239 let PrintMethod = "printU12ImmOperand";
243 def s16imm : Operand<i32> {
244 let PrintMethod = "printS16ImmOperand";
246 def s16imm64 : Operand<i64> {
247 let PrintMethod = "printS16ImmOperand";
250 def u16imm : Operand<i32> {
251 let PrintMethod = "printU16ImmOperand";
253 def u16imm64 : Operand<i64> {
254 let PrintMethod = "printU16ImmOperand";
258 def s20imm : Operand<i32> {
259 let PrintMethod = "printS20ImmOperand";
261 def s20imm64 : Operand<i64> {
262 let PrintMethod = "printS20ImmOperand";
265 def s32imm : Operand<i32> {
266 let PrintMethod = "printS32ImmOperand";
268 def s32imm64 : Operand<i64> {
269 let PrintMethod = "printS32ImmOperand";
272 def u32imm : Operand<i32> {
273 let PrintMethod = "printU32ImmOperand";
275 def u32imm64 : Operand<i64> {
276 let PrintMethod = "printU32ImmOperand";
279 def imm_pcrel : Operand<i64> {
280 let PrintMethod = "printPCRelImmOperand";
283 //===----------------------------------------------------------------------===//
284 // SystemZ Operand Definitions.
285 //===----------------------------------------------------------------------===//
289 // riaddr := reg + imm
290 def riaddr32 : Operand<i64>,
291 ComplexPattern<i64, 2, "SelectAddrRI12Only", []> {
292 let PrintMethod = "printRIAddrOperand";
293 let MIOperandInfo = (ops ADDR64:$base, u12imm:$disp);
296 def riaddr12 : Operand<i64>,
297 ComplexPattern<i64, 2, "SelectAddrRI12", []> {
298 let PrintMethod = "printRIAddrOperand";
299 let MIOperandInfo = (ops ADDR64:$base, u12imm64:$disp);
302 def riaddr : Operand<i64>,
303 ComplexPattern<i64, 2, "SelectAddrRI", []> {
304 let PrintMethod = "printRIAddrOperand";
305 let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp);
308 //===----------------------------------------------------------------------===//
310 // rriaddr := reg + reg + imm
311 def rriaddr12 : Operand<i64>,
312 ComplexPattern<i64, 3, "SelectAddrRRI12", [], []> {
313 let PrintMethod = "printRRIAddrOperand";
314 let MIOperandInfo = (ops ADDR64:$base, u12imm64:$disp, ADDR64:$index);
316 def rriaddr : Operand<i64>,
317 ComplexPattern<i64, 3, "SelectAddrRRI20", [], []> {
318 let PrintMethod = "printRRIAddrOperand";
319 let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp, ADDR64:$index);
321 def laaddr : Operand<i64>,
322 ComplexPattern<i64, 3, "SelectLAAddr", [add, sub, or, frameindex], []> {
323 let PrintMethod = "printRRIAddrOperand";
324 let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp, ADDR64:$index);