1 //===-- SystemZOperands.td - SystemZ instruction operands ----*- tblgen-*--===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 class ImmediateAsmOperand<string name>
16 let RenderMethod = "addImmOperands";
18 class ImmediateTLSAsmOperand<string name>
21 let RenderMethod = "addImmTLSOperands";
24 class ImmediateOp<ValueType vt, string asmop> : Operand<vt> {
25 let PrintMethod = "print"#asmop#"Operand";
26 let EncoderMethod = "getImmOpValue<SystemZ::FK_390_"#asmop#">";
27 let DecoderMethod = "decode"#asmop#"Operand";
28 let ParserMatchClass = !cast<AsmOperandClass>(asmop);
29 let OperandType = "OPERAND_IMMEDIATE";
32 class ImmOpWithPattern<ValueType vt, string asmop, code pred, SDNodeXForm xform,
33 SDNode ImmNode = imm> :
34 ImmediateOp<vt, asmop>, PatLeaf<(vt ImmNode), pred, xform>;
36 // class ImmediatePatLeaf<ValueType vt, code pred,
37 // SDNodeXForm xform, SDNode ImmNode>
38 // : PatLeaf<(vt ImmNode), pred, xform>;
41 // Constructs both a DAG pattern and instruction operand for an immediate
42 // of type VT. PRED returns true if a node is acceptable and XFORM returns
43 // the operand value associated with the node. ASMOP is the name of the
44 // associated asm operand, and also forms the basis of the asm print method.
45 multiclass Immediate<ValueType vt, code pred, SDNodeXForm xform, string asmop> {
46 // def "" : ImmediateOp<vt, asmop>,
47 // PatLeaf<(vt imm), pred, xform>;
48 def "" : ImmOpWithPattern<vt, asmop, pred, xform>;
50 // def _timm : PatLeaf<(vt timm), pred, xform>;
51 def _timm : ImmOpWithPattern<vt, asmop, pred, xform, timm>;
54 // Constructs an asm operand for a PC-relative address. SIZE says how
55 // many bits there are.
56 class PCRelAsmOperand<string size> : ImmediateAsmOperand<"PCRel"#size> {
57 let PredicateMethod = "isImm";
58 let ParserMethod = "parsePCRel"#size;
60 class PCRelTLSAsmOperand<string size>
61 : ImmediateTLSAsmOperand<"PCRelTLS"#size> {
62 let PredicateMethod = "isImmTLS";
63 let ParserMethod = "parsePCRelTLS"#size;
66 // Constructs an operand for a PC-relative address with address type VT.
67 // ASMOP is the associated asm operand.
68 let OperandType = "OPERAND_PCREL" in {
69 class PCRelOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> {
70 let PrintMethod = "printPCRelOperand";
71 let ParserMatchClass = asmop;
73 class PCRelTLSOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> {
74 let PrintMethod = "printPCRelTLSOperand";
75 let ParserMatchClass = asmop;
79 // Constructs both a DAG pattern and instruction operand for a PC-relative
80 // address with address size VT. SELF is the name of the operand and
81 // ASMOP is the associated asm operand.
82 class PCRelAddress<ValueType vt, string self, AsmOperandClass asmop>
83 : ComplexPattern<vt, 1, "selectPCRelAddress",
84 [z_pcrel_wrapper, z_pcrel_offset]>,
85 PCRelOperand<vt, asmop> {
86 let MIOperandInfo = (ops !cast<Operand>(self));
89 // Constructs an AsmOperandClass for addressing mode FORMAT, treating the
90 // registers as having BITSIZE bits and displacements as having DISPSIZE bits.
91 // LENGTH is "LenN" for addresses with an N-bit length field, otherwise it
93 class AddressAsmOperand<string format, string bitsize, string dispsize,
96 let Name = format#bitsize#"Disp"#dispsize#length;
97 let ParserMethod = "parse"#format#bitsize;
98 let RenderMethod = "add"#format#"Operands";
101 // Constructs an instruction operand for an addressing mode. FORMAT,
102 // BITSIZE, DISPSIZE and LENGTH are the parameters to an associated
103 // AddressAsmOperand. OPERANDS is a list of individual operands
104 // (base register, displacement, etc.).
105 class AddressOperand<string bitsize, string dispsize, string length,
106 string format, dag operands>
107 : Operand<!cast<ValueType>("i"#bitsize)> {
108 let PrintMethod = "print"#format#"Operand";
109 let OperandType = "OPERAND_MEMORY";
110 let MIOperandInfo = operands;
111 let ParserMatchClass =
112 !cast<AddressAsmOperand>(format#bitsize#"Disp"#dispsize#length);
115 // Constructs both a DAG pattern and instruction operand for an addressing mode.
116 // FORMAT, BITSIZE, DISPSIZE and LENGTH are the parameters to an associated
117 // AddressAsmOperand. OPERANDS is a list of NUMOPS individual operands
118 // (base register, displacement, etc.). SELTYPE is the type of the memory
119 // operand for selection purposes; sometimes we want different selection
120 // choices for the same underlying addressing mode. SUFFIX is similarly
121 // a suffix appended to the displacement for selection purposes;
122 // e.g. we want to reject small 20-bit displacements if a 12-bit form
123 // also exists, but we want to accept them otherwise.
124 class AddressingMode<string seltype, string bitsize, string dispsize,
125 string suffix, string length, int numops, string format,
127 : ComplexPattern<!cast<ValueType>("i"#bitsize), numops,
128 "select"#seltype#dispsize#suffix#length,
129 [add, sub, or, frameindex, z_adjdynalloc]>,
130 AddressOperand<bitsize, dispsize, length, format, operands>;
132 // An addressing mode with a base and displacement but no index.
133 class BDMode<string type, string bitsize, string dispsize, string suffix>
134 : AddressingMode<type, bitsize, dispsize, suffix, "", 2, "BDAddr",
135 (ops !cast<RegisterOperand>("ADDR"#bitsize),
136 !cast<Operand>("disp"#dispsize#"imm"#bitsize))>;
138 // An addressing mode with a base, displacement and index.
139 class BDXMode<string type, string bitsize, string dispsize, string suffix>
140 : AddressingMode<type, bitsize, dispsize, suffix, "", 3, "BDXAddr",
141 (ops !cast<RegisterOperand>("ADDR"#bitsize),
142 !cast<Operand>("disp"#dispsize#"imm"#bitsize),
143 !cast<RegisterOperand>("ADDR"#bitsize))>;
145 // A BDMode paired with an immediate length operand of LENSIZE bits.
146 class BDLMode<string type, string bitsize, string dispsize, string suffix,
148 : AddressingMode<type, bitsize, dispsize, suffix, "Len"#lensize, 3,
150 (ops !cast<RegisterOperand>("ADDR"#bitsize),
151 !cast<Operand>("disp"#dispsize#"imm"#bitsize),
152 !cast<Operand>("len"#lensize#"imm"#bitsize))>;
154 // A BDMode paired with a register length operand.
155 class BDRMode<string type, string bitsize, string dispsize, string suffix>
156 : AddressingMode<type, bitsize, dispsize, suffix, "", 3, "BDRAddr",
157 (ops !cast<RegisterOperand>("ADDR"#bitsize),
158 !cast<Operand>("disp"#dispsize#"imm"#bitsize),
159 !cast<RegisterOperand>("GR"#bitsize))>;
161 // An addressing mode with a base, displacement and a vector index.
162 class BDVMode<string bitsize, string dispsize>
163 : AddressOperand<bitsize, dispsize, "", "BDVAddr",
164 (ops !cast<RegisterOperand>("ADDR"#bitsize),
165 !cast<Operand>("disp"#dispsize#"imm"#bitsize),
166 !cast<RegisterOperand>("VR128"))>;
168 // An addressing mode with a base, 32-bit displacement and 32-bit index.
169 class LXAMode<string bitsize, string dispsize>
170 : AddressOperand<bitsize, dispsize, "", "LXAAddr",
171 (ops !cast<RegisterOperand>("ADDR"#bitsize),
172 !cast<Operand>("disp"#dispsize#"imm32"),
173 !cast<RegisterOperand>("ADDR32"))>;
175 //===----------------------------------------------------------------------===//
176 // Extracting immediate operands from nodes
177 // These all create MVT::i64 nodes to ensure the value is not sign-extended
178 // when converted from an SDNode to a MachineOperand later on.
179 //===----------------------------------------------------------------------===//
181 // Bits 0-15 (counting from the lsb).
182 def LL16 : SDNodeXForm<imm, [{
183 uint64_t Value = N->getZExtValue() & 0x000000000000FFFFULL;
184 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
187 // Bits 16-31 (counting from the lsb).
188 def LH16 : SDNodeXForm<imm, [{
189 uint64_t Value = (N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16;
190 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
193 // Bits 32-47 (counting from the lsb).
194 def HL16 : SDNodeXForm<imm, [{
195 uint64_t Value = (N->getZExtValue() & 0x0000FFFF00000000ULL) >> 32;
196 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
199 // Bits 48-63 (counting from the lsb).
200 def HH16 : SDNodeXForm<imm, [{
201 uint64_t Value = (N->getZExtValue() & 0xFFFF000000000000ULL) >> 48;
202 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
206 def LF32 : SDNodeXForm<imm, [{
207 uint64_t Value = N->getZExtValue() & 0x00000000FFFFFFFFULL;
208 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
212 def HF32 : SDNodeXForm<imm, [{
213 uint64_t Value = N->getZExtValue() >> 32;
214 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
218 def NEGLH16 : SDNodeXForm<imm, [{
219 uint64_t Value = (-N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16;
220 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
223 def NEGLF32 : SDNodeXForm<imm, [{
224 uint64_t Value = -N->getZExtValue() & 0x00000000FFFFFFFFULL;
225 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
228 // Truncate an immediate to a 8-bit signed quantity.
229 def SIMM8 : SDNodeXForm<imm, [{
230 return CurDAG->getSignedTargetConstant(int8_t(N->getSExtValue()), SDLoc(N),
234 // Truncate an immediate to a 8-bit unsigned quantity.
235 def UIMM8 : SDNodeXForm<imm, [{
236 return CurDAG->getTargetConstant(uint8_t(N->getZExtValue()), SDLoc(N),
240 // Truncate an immediate to a 8-bit unsigned quantity and mask off low bit.
241 def UIMM8EVEN : SDNodeXForm<imm, [{
242 return CurDAG->getTargetConstant(N->getZExtValue() & 0xfe, SDLoc(N),
246 // Truncate an immediate to a 12-bit unsigned quantity.
247 def UIMM12 : SDNodeXForm<imm, [{
248 return CurDAG->getTargetConstant(N->getZExtValue() & 0xfff, SDLoc(N),
252 // Truncate an immediate to a 16-bit signed quantity.
253 def SIMM16 : SDNodeXForm<imm, [{
254 return CurDAG->getSignedTargetConstant(int16_t(N->getSExtValue()), SDLoc(N),
258 // Negate and then truncate an immediate to a 16-bit signed quantity.
259 def NEGSIMM16 : SDNodeXForm<imm, [{
260 return CurDAG->getSignedTargetConstant(int16_t(-N->getSExtValue()), SDLoc(N),
264 // Truncate an immediate to a 16-bit unsigned quantity.
265 def UIMM16 : SDNodeXForm<imm, [{
266 return CurDAG->getTargetConstant(uint16_t(N->getZExtValue()), SDLoc(N),
270 // Truncate an immediate to a 32-bit signed quantity.
271 def SIMM32 : SDNodeXForm<imm, [{
272 return CurDAG->getSignedTargetConstant(int32_t(N->getSExtValue()), SDLoc(N),
276 // Negate and then truncate an immediate to a 32-bit unsigned quantity.
277 def NEGSIMM32 : SDNodeXForm<imm, [{
278 return CurDAG->getSignedTargetConstant(int32_t(-N->getSExtValue()), SDLoc(N),
282 // Truncate an immediate to a 32-bit unsigned quantity.
283 def UIMM32 : SDNodeXForm<imm, [{
284 return CurDAG->getTargetConstant(uint32_t(N->getZExtValue()), SDLoc(N),
288 // Negate and then truncate an immediate to a 32-bit unsigned quantity.
289 def NEGUIMM32 : SDNodeXForm<imm, [{
290 return CurDAG->getTargetConstant(uint32_t(-N->getZExtValue()), SDLoc(N),
294 // Truncate an immediate to a 48-bit unsigned quantity.
295 def UIMM48 : SDNodeXForm<imm, [{
296 return CurDAG->getTargetConstant(uint64_t(N->getZExtValue()) & 0xffffffffffff,
300 //===----------------------------------------------------------------------===//
301 // Immediate asm operands.
302 //===----------------------------------------------------------------------===//
304 def U1Imm : ImmediateAsmOperand<"U1Imm">;
305 def U2Imm : ImmediateAsmOperand<"U2Imm">;
306 def U3Imm : ImmediateAsmOperand<"U3Imm">;
307 def U4Imm : ImmediateAsmOperand<"U4Imm">;
308 def S8Imm : ImmediateAsmOperand<"S8Imm">;
309 def U8Imm : ImmediateAsmOperand<"U8Imm">;
310 def U12Imm : ImmediateAsmOperand<"U12Imm">;
311 def S16Imm : ImmediateAsmOperand<"S16Imm">;
312 def U16Imm : ImmediateAsmOperand<"U16Imm">;
313 def S32Imm : ImmediateAsmOperand<"S32Imm">;
314 def U32Imm : ImmediateAsmOperand<"U32Imm">;
315 def U48Imm : ImmediateAsmOperand<"U48Imm">;
317 //===----------------------------------------------------------------------===//
319 //===----------------------------------------------------------------------===//
321 // Immediates for the lower and upper 16 bits of an i32, with the other
322 // bits of the i32 being zero.
323 defm imm32ll16 : Immediate<i32, [{
324 return N->getAPIntValue().isIntN(32) && SystemZ::isImmLL(N->getZExtValue());
327 defm imm32lh16 : Immediate<i32, [{
328 return N->getAPIntValue().isIntN(32) && SystemZ::isImmLH(N->getZExtValue());
331 // Immediates for the lower and upper 16 bits of an i32, with the other
332 // bits of the i32 being one.
333 defm imm32ll16c : Immediate<i32, [{
334 return N->getAPIntValue().isIntN(32) &&
335 SystemZ::isImmLL(uint32_t(~N->getZExtValue()));
338 defm imm32lh16c : Immediate<i32, [{
339 return N->getAPIntValue().isIntN(32) &&
340 SystemZ::isImmLH(uint32_t(~N->getZExtValue()));
344 defm imm32zx1 : Immediate<i32, [{
345 return N->getAPIntValue().isIntN(1);
346 }], NOOP_SDNodeXForm, "U1Imm">;
348 defm imm32zx2 : Immediate<i32, [{
349 return N->getAPIntValue().isIntN(2);
350 }], NOOP_SDNodeXForm, "U2Imm">;
352 defm imm32zx3 : Immediate<i32, [{
353 return N->getAPIntValue().isIntN(3);
354 }], NOOP_SDNodeXForm, "U3Imm">;
356 defm imm32zx4 : Immediate<i32, [{
357 return N->getAPIntValue().isIntN(4);
358 }], NOOP_SDNodeXForm, "U4Imm">;
360 // Note: this enforces an even value during code generation only.
361 // When used from the assembler, any 4-bit value is allowed.
362 defm imm32zx4even : Immediate<i32, [{
363 return N->getAPIntValue().isIntN(4);
364 }], UIMM8EVEN, "U4Imm">;
366 defm imm32sx8 : Immediate<i32, [{
367 return N->getAPIntValue().isSignedIntN(8);
370 defm imm32zx8 : Immediate<i32, [{
371 return N->getAPIntValue().isIntN(8);
374 defm imm32zx8trunc : Immediate<i32, [{}], UIMM8, "U8Imm">;
376 defm imm32zx12 : Immediate<i32, [{
377 return N->getAPIntValue().isIntN(12);
378 }], UIMM12, "U12Imm">;
380 defm imm32sx16 : Immediate<i32, [{
381 return N->getAPIntValue().isSignedIntN(16);
382 }], SIMM16, "S16Imm">;
384 defm imm32sx16n : Immediate<i32, [{
385 return (-N->getAPIntValue()).isSignedIntN(16);
386 }], NEGSIMM16, "S16Imm">;
388 defm imm32zx16 : Immediate<i32, [{
389 return N->getAPIntValue().isIntN(16);
390 }], UIMM16, "U16Imm">;
392 defm imm32sx16trunc : Immediate<i32, [{}], SIMM16, "S16Imm">;
393 defm imm32zx16trunc : Immediate<i32, [{}], UIMM16, "U16Imm">;
395 // Full 32-bit immediates. we need both signed and unsigned versions
396 // because the assembler is picky. E.g. AFI requires signed operands
397 // while NILF requires unsigned ones.
398 defm simm32 : Immediate<i32, [{}], SIMM32, "S32Imm">;
399 defm uimm32 : Immediate<i32, [{}], UIMM32, "U32Imm">;
401 defm simm32n : Immediate<i32, [{
402 auto SImm = N->getAPIntValue().trySExtValue();
403 return SImm.has_value() && isInt<32>(-*SImm);
404 }], NEGSIMM32, "S32Imm">;
406 def imm32 : ImmLeaf<i32, [{}]>;
408 //===----------------------------------------------------------------------===//
410 //===----------------------------------------------------------------------===//
412 // Immediates for 16-bit chunks of an i64, with the other bits of the
414 defm imm64ll16 : Immediate<i64, [{
415 return N->getAPIntValue().isIntN(64) && SystemZ::isImmLL(N->getZExtValue());
418 defm imm64lh16 : Immediate<i64, [{
419 return N->getAPIntValue().isIntN(64) && SystemZ::isImmLH(N->getZExtValue());
422 defm imm64hl16 : Immediate<i64, [{
423 return N->getAPIntValue().isIntN(64) && SystemZ::isImmHL(N->getZExtValue());
426 defm imm64hh16 : Immediate<i64, [{
427 return N->getAPIntValue().isIntN(64) && SystemZ::isImmHH(N->getZExtValue());
430 // Immediates for 16-bit chunks of an i64, with the other bits of the
432 defm imm64ll16c : Immediate<i64, [{
433 return N->getAPIntValue().isIntN(64) &&
434 SystemZ::isImmLL(uint64_t(~N->getZExtValue()));
437 defm imm64lh16c : Immediate<i64, [{
438 return N->getAPIntValue().isIntN(64) &&
439 SystemZ::isImmLH(uint64_t(~N->getZExtValue()));
442 defm imm64hl16c : Immediate<i64, [{
443 return N->getAPIntValue().isIntN(64) &&
444 SystemZ::isImmHL(uint64_t(~N->getZExtValue()));
447 defm imm64hh16c : Immediate<i64, [{
448 return N->getAPIntValue().isIntN(64) &&
449 SystemZ::isImmHH(uint64_t(~N->getZExtValue()));
452 // Immediates for the lower and upper 32 bits of an i64, with the other
453 // bits of the i32 being zero.
454 defm imm64lf32 : Immediate<i64, [{
455 return N->getAPIntValue().isIntN(64) && SystemZ::isImmLF(N->getZExtValue());
458 defm imm64hf32 : Immediate<i64, [{
459 return N->getAPIntValue().isIntN(64) && SystemZ::isImmHF(N->getZExtValue());
462 // Immediates for the lower and upper 32 bits of an i64, with the other
463 // bits of the i32 being one.
464 defm imm64lf32c : Immediate<i64, [{
465 return N->getAPIntValue().isIntN(64) &&
466 SystemZ::isImmLF(uint64_t(~N->getZExtValue()));
469 defm imm64hf32c : Immediate<i64, [{
470 return N->getAPIntValue().isIntN(64) &&
471 SystemZ::isImmHF(uint64_t(~N->getZExtValue()));
474 // Negated immediates that fit LF32 or LH16.
475 defm imm64lh16n : Immediate<i64, [{
476 return N->getAPIntValue().isIntN(64) &&
477 SystemZ::isImmLH(uint64_t(-N->getZExtValue()));
478 }], NEGLH16, "U16Imm">;
480 defm imm64lf32n : Immediate<i64, [{
481 return N->getAPIntValue().isIntN(64) &&
482 SystemZ::isImmLF(uint64_t(-N->getZExtValue()));
483 }], NEGLF32, "U32Imm">;
486 defm imm64sx8 : Immediate<i64, [{
487 return N->getAPIntValue().isSignedIntN(8);
490 defm imm64zx8 : Immediate<i64, [{
491 return N->getAPIntValue().isIntN(8);;
494 defm imm64sx16 : Immediate<i64, [{
495 return N->getAPIntValue().isSignedIntN(16);
496 }], SIMM16, "S16Imm">;
498 defm imm64sx16n : Immediate<i64, [{
499 return (-N->getAPIntValue()).isSignedIntN(16);
500 }], NEGSIMM16, "S16Imm">;
502 defm imm64zx16 : Immediate<i64, [{
503 return N->getAPIntValue().isIntN(16);
504 }], UIMM16, "U16Imm">;
506 defm imm64sx32 : Immediate<i64, [{
507 return N->getAPIntValue().isSignedIntN(32);
508 }], SIMM32, "S32Imm">;
510 defm imm64sx32n : Immediate<i64, [{
511 return (-N->getAPIntValue()).isSignedIntN(32);
512 }], NEGSIMM32, "S32Imm">;
514 defm imm64zx32 : Immediate<i64, [{
515 return N->getAPIntValue().isIntN(32);
516 }], UIMM32, "U32Imm">;
518 defm imm64zx32n : Immediate<i64, [{
519 return (-N->getAPIntValue()).isIntN(32);
520 }], NEGUIMM32, "U32Imm">;
522 defm imm64zx48 : Immediate<i64, [{
523 return N->getAPIntValue().isIntN(64);
524 }], UIMM48, "U48Imm">;
526 class Imm64 : ImmLeaf<i64, [{}]>, Operand<i64> {
527 let OperandType = "OPERAND_IMMEDIATE";
530 def len4imm64 : Imm64 {
531 let EncoderMethod = "getLenEncoding<SystemZ::FK_390_U4Imm>";
532 let DecoderMethod = "decodeLenOperand<4>";
534 def len8imm64 : Imm64 {
535 let EncoderMethod = "getLenEncoding<SystemZ::FK_390_U8Imm>";
536 let DecoderMethod = "decodeLenOperand<8>";
539 //===----------------------------------------------------------------------===//
540 // Floating-point immediates
541 //===----------------------------------------------------------------------===//
543 // Floating-point zero.
544 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
546 // Floating point negative zero.
547 def fpimmneg0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(-0.0); }]>;
549 //===----------------------------------------------------------------------===//
550 // Symbolic address operands
551 //===----------------------------------------------------------------------===//
553 // PC-relative asm operands.
554 def PCRel12 : PCRelAsmOperand<"12">;
555 def PCRel16 : PCRelAsmOperand<"16">;
556 def PCRel24 : PCRelAsmOperand<"24">;
557 def PCRel32 : PCRelAsmOperand<"32">;
558 def PCRelTLS16 : PCRelTLSAsmOperand<"16">;
559 def PCRelTLS32 : PCRelTLSAsmOperand<"32">;
561 // PC-relative offsets of a basic block. The offset is sign-extended
562 // and multiplied by 2.
563 def brtarget16 : PCRelOperand<OtherVT, PCRel16> {
564 let EncoderMethod = "getPC16DBLEncoding";
565 let DecoderMethod = "decodePC16DBLBranchOperand";
567 def brtarget32 : PCRelOperand<OtherVT, PCRel32> {
568 let EncoderMethod = "getPC32DBLEncoding";
569 let DecoderMethod = "decodePC32DBLBranchOperand";
572 // Variants of brtarget for use with branch prediction preload.
573 def brtarget12bpp : PCRelOperand<OtherVT, PCRel12> {
574 let EncoderMethod = "getPC12DBLBPPEncoding";
575 let DecoderMethod = "decodePC12DBLBranchOperand";
577 def brtarget16bpp : PCRelOperand<OtherVT, PCRel16> {
578 let EncoderMethod = "getPC16DBLBPPEncoding";
579 let DecoderMethod = "decodePC16DBLBranchOperand";
581 def brtarget24bpp : PCRelOperand<OtherVT, PCRel24> {
582 let EncoderMethod = "getPC24DBLBPPEncoding";
583 let DecoderMethod = "decodePC24DBLBranchOperand";
586 // Variants of brtarget16/32 with an optional additional TLS symbol.
587 // These are used to annotate calls to __tls_get_offset.
588 def tlssym : Operand<i64> { }
589 def brtarget16tls : PCRelTLSOperand<OtherVT, PCRelTLS16> {
590 let MIOperandInfo = (ops brtarget16:$func, tlssym:$sym);
591 let EncoderMethod = "getPC16DBLTLSEncoding";
592 let DecoderMethod = "decodePC16DBLBranchOperand";
594 def brtarget32tls : PCRelTLSOperand<OtherVT, PCRelTLS32> {
595 let MIOperandInfo = (ops brtarget32:$func, tlssym:$sym);
596 let EncoderMethod = "getPC32DBLTLSEncoding";
597 let DecoderMethod = "decodePC32DBLBranchOperand";
600 // A PC-relative offset of a global value. The offset is sign-extended
601 // and multiplied by 2.
602 def pcrel32 : PCRelAddress<i64, "pcrel32", PCRel32> {
603 let EncoderMethod = "getPC32DBLEncoding";
604 let DecoderMethod = "decodePC32DBLOperand";
607 //===----------------------------------------------------------------------===//
609 //===----------------------------------------------------------------------===//
611 class DispOp<ValueType vt, code pred> : Operand<vt>, PatLeaf<(vt imm), pred>;
613 // 12-bit displacement operands.
614 let EncoderMethod = "getImmOpValue<SystemZ::FK_390_U12Imm>",
615 DecoderMethod = "decodeU12ImmOperand" in {
616 def disp12imm32 : DispOp<i32, [{ return N->getAPIntValue().isIntN(12); }]>;
617 def disp12imm64 : DispOp<i64, [{ return N->getAPIntValue().isIntN(12); }]>;
620 // 20-bit displacement operands.
621 let EncoderMethod = "getImmOpValue<SystemZ::FK_390_S20Imm>",
622 DecoderMethod = "decodeS20ImmOperand" in {
623 def disp20imm32 : DispOp<i32, [{ return N->getAPIntValue().isSignedIntN(20); }]>;
624 def disp20imm64 : DispOp<i64, [{ return N->getAPIntValue().isSignedIntN(20); }]>;
627 def BDAddr32Disp12 : AddressAsmOperand<"BDAddr", "32", "12">;
628 def BDAddr32Disp20 : AddressAsmOperand<"BDAddr", "32", "20">;
629 def BDAddr64Disp12 : AddressAsmOperand<"BDAddr", "64", "12">;
630 def BDAddr64Disp20 : AddressAsmOperand<"BDAddr", "64", "20">;
631 def BDXAddr64Disp12 : AddressAsmOperand<"BDXAddr", "64", "12">;
632 def BDXAddr64Disp20 : AddressAsmOperand<"BDXAddr", "64", "20">;
633 def BDLAddr64Disp12Len4 : AddressAsmOperand<"BDLAddr", "64", "12", "Len4">;
634 def BDLAddr64Disp12Len8 : AddressAsmOperand<"BDLAddr", "64", "12", "Len8">;
635 def BDRAddr64Disp12 : AddressAsmOperand<"BDRAddr", "64", "12">;
636 def BDVAddr64Disp12 : AddressAsmOperand<"BDVAddr", "64", "12">;
637 def LXAAddr64Disp20 : AddressAsmOperand<"LXAAddr", "64", "20">;
639 // DAG patterns and operands for addressing modes. Each mode has
640 // the form <type><range><group>[<len>] where:
643 // shift : base + displacement (32-bit)
644 // bdaddr : base + displacement
645 // mviaddr : like bdaddr, but reject cases with a natural index
646 // bdxaddr : base + displacement + index
647 // laaddr : like bdxaddr, but used for Load Address operations
648 // lxaaddr : like bdxaddr, but used for Load (Logical) Indexed Address
649 // dynalloc : base + displacement + index + ADJDYNALLOC
650 // bdladdr : base + displacement with a length field
651 // bdvaddr : base + displacement with a vector index
653 // <range> is one of:
654 // 12 : the displacement is an unsigned 12-bit value
655 // 20 : the displacement is a signed 20-bit value
657 // <group> is one of:
658 // pair : used when there is an equivalent instruction with the opposite
659 // range value (12 or 20)
660 // only : used when there is no equivalent instruction with the opposite
665 // <empty> : there is no length field
666 // len8 : the length field is 8 bits, with a range of [1, 0x100].
667 def shift12only : BDMode <"BDAddr", "32", "12", "Only">;
668 def shift20only : BDMode <"BDAddr", "32", "20", "Only">;
669 def bdaddr12only : BDMode <"BDAddr", "64", "12", "Only">;
670 def bdaddr12pair : BDMode <"BDAddr", "64", "12", "Pair">;
671 def bdaddr20only : BDMode <"BDAddr", "64", "20", "Only">;
672 def bdaddr20pair : BDMode <"BDAddr", "64", "20", "Pair">;
673 def mviaddr12pair : BDMode <"MVIAddr", "64", "12", "Pair">;
674 def mviaddr20pair : BDMode <"MVIAddr", "64", "20", "Pair">;
675 def bdxaddr12only : BDXMode<"BDXAddr", "64", "12", "Only">;
676 def bdxaddr12pair : BDXMode<"BDXAddr", "64", "12", "Pair">;
677 def bdxaddr20only : BDXMode<"BDXAddr", "64", "20", "Only">;
678 def bdxaddr20only128 : BDXMode<"BDXAddr", "64", "20", "Only128">;
679 def bdxaddr20pair : BDXMode<"BDXAddr", "64", "20", "Pair">;
680 def dynalloc12only : BDXMode<"DynAlloc", "64", "12", "Only">;
681 def laaddr12pair : BDXMode<"LAAddr", "64", "12", "Pair">;
682 def laaddr20pair : BDXMode<"LAAddr", "64", "20", "Pair">;
683 def lxaaddr20only : LXAMode< "64", "20">;
684 def bdladdr12onlylen4 : BDLMode<"BDLAddr", "64", "12", "Only", "4">;
685 def bdladdr12onlylen8 : BDLMode<"BDLAddr", "64", "12", "Only", "8">;
686 def bdraddr12only : BDRMode<"BDRAddr", "64", "12", "Only">;
687 def bdvaddr12only : BDVMode< "64", "12">;
689 //===----------------------------------------------------------------------===//
691 //===----------------------------------------------------------------------===//
693 // A 4-bit condition-code mask.
694 def cond4 : PatLeaf<(i32 timm), [{ return (N->getZExtValue() < 16); }]>,
696 let PrintMethod = "printCond4Operand";
697 let OperandType = "OPERAND_IMMEDIATE";