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 i32ll16 : PatLeaf<(i32 imm), [{
71 // i32ll16 predicate - true if the 32-bit immediate has only rightmost 16
73 return ((N->getZExtValue() & 0x000000000000FFFFULL) == N->getZExtValue());
76 def i32lh16 : PatLeaf<(i32 imm), [{
77 // i32lh16 predicate - true if the 32-bit immediate has only bits 16-31 set.
78 return ((N->getZExtValue() & 0x00000000FFFF0000ULL) == N->getZExtValue());
81 def i32ll16c : PatLeaf<(i32 imm), [{
82 // i32ll16c predicate - true if the 32-bit immediate has all bits 16-31 set.
83 return ((N->getZExtValue() | 0x00000000FFFF0000ULL) == N->getZExtValue());
86 def i32lh16c : PatLeaf<(i32 imm), [{
87 // i32lh16c predicate - true if the 32-bit immediate has all rightmost 16
89 return ((N->getZExtValue() | 0x000000000000FFFFULL) == N->getZExtValue());
92 def i64ll16 : PatLeaf<(i64 imm), [{
93 // i64ll16 predicate - true if the 64-bit immediate has only rightmost 16
95 return ((N->getZExtValue() & 0x000000000000FFFFULL) == N->getZExtValue());
98 def i64lh16 : PatLeaf<(i64 imm), [{
99 // i64lh16 predicate - true if the 64-bit immediate has only bits 16-31 set.
100 return ((N->getZExtValue() & 0x00000000FFFF0000ULL) == N->getZExtValue());
103 def i64hl16 : PatLeaf<(i64 imm), [{
104 // i64hl16 predicate - true if the 64-bit immediate has only bits 32-47 set.
105 return ((N->getZExtValue() & 0x0000FFFF00000000ULL) == N->getZExtValue());
108 def i64hh16 : PatLeaf<(i64 imm), [{
109 // i64hh16 predicate - true if the 64-bit immediate has only bits 48-63 set.
110 return ((N->getZExtValue() & 0xFFFF000000000000ULL) == N->getZExtValue());
113 def i64ll16c : PatLeaf<(i64 imm), [{
114 // i64ll16c predicate - true if the 64-bit immediate has only rightmost 16
116 return ((N->getZExtValue() | 0xFFFFFFFFFFFF0000ULL) == N->getZExtValue());
119 def i64lh16c : PatLeaf<(i64 imm), [{
120 // i64lh16c predicate - true if the 64-bit immediate has only bits 16-31 set.
121 return ((N->getZExtValue() | 0xFFFFFFFF0000FFFFULL) == N->getZExtValue());
124 def i64hl16c : PatLeaf<(i64 imm), [{
125 // i64hl16c predicate - true if the 64-bit immediate has only bits 32-47 set.
126 return ((N->getZExtValue() | 0xFFFF0000FFFFFFFFULL) == N->getZExtValue());
129 def i64hh16c : PatLeaf<(i64 imm), [{
130 // i64hh16c predicate - true if the 64-bit immediate has only bits 48-63 set.
131 return ((N->getZExtValue() | 0x0000FFFFFFFFFFFFULL) == N->getZExtValue());
134 def immSExt16 : PatLeaf<(imm), [{
135 // immSExt16 predicate - true if the immediate fits in a 16-bit sign extended
137 if (N->getValueType(0) == MVT::i64) {
138 uint64_t val = N->getZExtValue();
139 return ((int64_t)val == (int16_t)val);
140 } else if (N->getValueType(0) == MVT::i32) {
141 uint32_t val = N->getZExtValue();
142 return ((int32_t)val == (int16_t)val);
148 def immSExt32 : PatLeaf<(i64 imm), [{
149 // immSExt32 predicate - true if the immediate fits in a 32-bit sign extended
151 uint64_t val = N->getZExtValue();
152 return ((int64_t)val == (int32_t)val);
155 def i64lo32 : PatLeaf<(i64 imm), [{
156 // i64lo32 predicate - true if the 64-bit immediate has only rightmost 32
158 return ((N->getZExtValue() & 0x00000000FFFFFFFFULL) == N->getZExtValue());
161 def i64hi32 : PatLeaf<(i64 imm), [{
162 // i64hi32 predicate - true if the 64-bit immediate has only bits 32-63 set.
163 return ((N->getZExtValue() & 0xFFFFFFFF00000000ULL) == N->getZExtValue());
166 def i64lo32c : PatLeaf<(i64 imm), [{
167 // i64lo32 predicate - true if the 64-bit immediate has only rightmost 32
169 return ((N->getZExtValue() | 0xFFFFFFFF00000000ULL) == N->getZExtValue());
172 def i64hi32c : PatLeaf<(i64 imm), [{
173 // i64hi32 predicate - true if the 64-bit immediate has only bits 32-63 set.
174 return ((N->getZExtValue() | 0x00000000FFFFFFFFULL) == N->getZExtValue());
177 def i32immSExt8 : PatLeaf<(i32 imm), [{
178 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
179 // sign extended field.
180 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
183 def i32immSExt16 : PatLeaf<(i32 imm), [{
184 // i32immSExt16 predicate - True if the 32-bit immediate fits in a 16-bit
185 // sign extended field.
186 return (int32_t)N->getZExtValue() == (int16_t)N->getZExtValue();
189 def i64immSExt32 : PatLeaf<(i64 imm), [{
190 // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit
191 // sign extended field.
192 return (int64_t)N->getZExtValue() == (int32_t)N->getZExtValue();
195 def i64immZExt32 : PatLeaf<(i64 imm), [{
196 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
197 // zero extended field.
198 return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue();
202 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
203 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
204 def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
205 def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
206 def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
208 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
209 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
210 def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
211 def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
212 def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
214 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
215 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
216 def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
217 def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
218 def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
220 // A couple of more descriptive operand definitions.
221 // 32-bits but only 8 bits are significant.
222 def i32i8imm : Operand<i32>;
223 // 32-bits but only 16 bits are significant.
224 def i32i16imm : Operand<i32>;
225 // 64-bits but only 32 bits are significant.
226 def i64i32imm : Operand<i64>;
227 // Branch targets have OtherVT type.
228 def brtarget : Operand<OtherVT>;
231 def u12imm : Operand<i32> {
232 let PrintMethod = "printU12ImmOperand";
234 def u12imm64 : Operand<i64> {
235 let PrintMethod = "printU12ImmOperand";
239 def s16imm : Operand<i32> {
240 let PrintMethod = "printS16ImmOperand";
242 def s16imm64 : Operand<i64> {
243 let PrintMethod = "printS16ImmOperand";
246 def s20imm : Operand<i32> {
247 let PrintMethod = "printS20ImmOperand";
249 def s20imm64 : Operand<i64> {
250 let PrintMethod = "printS20ImmOperand";
253 def s32imm : Operand<i32> {
254 let PrintMethod = "printS32ImmOperand";
256 def s32imm64 : Operand<i64> {
257 let PrintMethod = "printS32ImmOperand";
260 def imm_pcrel : Operand<i64> {
261 let PrintMethod = "printPCRelImmOperand";
264 //===----------------------------------------------------------------------===//
265 // SystemZ Operand Definitions.
266 //===----------------------------------------------------------------------===//
270 // riaddr := reg + imm
271 def riaddr32 : Operand<i64>,
272 ComplexPattern<i64, 2, "SelectAddrRI12Only", []> {
273 let PrintMethod = "printRIAddrOperand";
274 let MIOperandInfo = (ops ADDR64:$base, u12imm:$disp);
277 def riaddr12 : Operand<i64>,
278 ComplexPattern<i64, 2, "SelectAddrRI12", []> {
279 let PrintMethod = "printRIAddrOperand";
280 let MIOperandInfo = (ops ADDR64:$base, u12imm64:$disp);
283 def riaddr : Operand<i64>,
284 ComplexPattern<i64, 2, "SelectAddrRI", []> {
285 let PrintMethod = "printRIAddrOperand";
286 let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp);
289 //===----------------------------------------------------------------------===//
291 // rriaddr := reg + reg + imm
292 def rriaddr12 : Operand<i64>,
293 ComplexPattern<i64, 3, "SelectAddrRRI12", [], []> {
294 let PrintMethod = "printRRIAddrOperand";
295 let MIOperandInfo = (ops ADDR64:$base, u12imm64:$disp, ADDR64:$index);
297 def rriaddr : Operand<i64>,
298 ComplexPattern<i64, 3, "SelectAddrRRI20", [], []> {
299 let PrintMethod = "printRRIAddrOperand";
300 let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp, ADDR64:$index);
302 def laaddr : Operand<i64>,
303 ComplexPattern<i64, 3, "SelectLAAddr", [add, sub, or, frameindex], []> {
304 let PrintMethod = "printRRIAddrOperand";
305 let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp, ADDR64:$index);