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 //===----------------------------------------------------------------------===//
169 // Extracting immediate operands from nodes
170 // These all create MVT::i64 nodes to ensure the value is not sign-extended
171 // when converted from an SDNode to a MachineOperand later on.
172 //===----------------------------------------------------------------------===//
174 // Bits 0-15 (counting from the lsb).
175 def LL16 : SDNodeXForm<imm, [{
176 uint64_t Value = N->getZExtValue() & 0x000000000000FFFFULL;
177 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
180 // Bits 16-31 (counting from the lsb).
181 def LH16 : SDNodeXForm<imm, [{
182 uint64_t Value = (N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16;
183 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
186 // Bits 32-47 (counting from the lsb).
187 def HL16 : SDNodeXForm<imm, [{
188 uint64_t Value = (N->getZExtValue() & 0x0000FFFF00000000ULL) >> 32;
189 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
192 // Bits 48-63 (counting from the lsb).
193 def HH16 : SDNodeXForm<imm, [{
194 uint64_t Value = (N->getZExtValue() & 0xFFFF000000000000ULL) >> 48;
195 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
199 def LF32 : SDNodeXForm<imm, [{
200 uint64_t Value = N->getZExtValue() & 0x00000000FFFFFFFFULL;
201 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
205 def HF32 : SDNodeXForm<imm, [{
206 uint64_t Value = N->getZExtValue() >> 32;
207 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
211 def NEGLH16 : SDNodeXForm<imm, [{
212 uint64_t Value = (-N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16;
213 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
216 def NEGLF32 : SDNodeXForm<imm, [{
217 uint64_t Value = -N->getZExtValue() & 0x00000000FFFFFFFFULL;
218 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
221 // Truncate an immediate to a 8-bit signed quantity.
222 def SIMM8 : SDNodeXForm<imm, [{
223 return CurDAG->getTargetConstant(int8_t(N->getZExtValue()), SDLoc(N),
227 // Truncate an immediate to a 8-bit unsigned quantity.
228 def UIMM8 : SDNodeXForm<imm, [{
229 return CurDAG->getTargetConstant(uint8_t(N->getZExtValue()), SDLoc(N),
233 // Truncate an immediate to a 8-bit unsigned quantity and mask off low bit.
234 def UIMM8EVEN : SDNodeXForm<imm, [{
235 return CurDAG->getTargetConstant(N->getZExtValue() & 0xfe, SDLoc(N),
239 // Truncate an immediate to a 12-bit unsigned quantity.
240 def UIMM12 : SDNodeXForm<imm, [{
241 return CurDAG->getTargetConstant(N->getZExtValue() & 0xfff, SDLoc(N),
245 // Truncate an immediate to a 16-bit signed quantity.
246 def SIMM16 : SDNodeXForm<imm, [{
247 return CurDAG->getTargetConstant(int16_t(N->getZExtValue()), SDLoc(N),
251 // Negate and then truncate an immediate to a 16-bit signed quantity.
252 def NEGSIMM16 : SDNodeXForm<imm, [{
253 return CurDAG->getTargetConstant(int16_t(-N->getZExtValue()), SDLoc(N),
257 // Truncate an immediate to a 16-bit unsigned quantity.
258 def UIMM16 : SDNodeXForm<imm, [{
259 return CurDAG->getTargetConstant(uint16_t(N->getZExtValue()), SDLoc(N),
263 // Truncate an immediate to a 32-bit signed quantity.
264 def SIMM32 : SDNodeXForm<imm, [{
265 return CurDAG->getTargetConstant(int32_t(N->getZExtValue()), SDLoc(N),
269 // Negate and then truncate an immediate to a 32-bit unsigned quantity.
270 def NEGSIMM32 : SDNodeXForm<imm, [{
271 return CurDAG->getTargetConstant(int32_t(-N->getZExtValue()), SDLoc(N),
275 // Truncate an immediate to a 32-bit unsigned quantity.
276 def UIMM32 : SDNodeXForm<imm, [{
277 return CurDAG->getTargetConstant(uint32_t(N->getZExtValue()), SDLoc(N),
281 // Negate and then truncate an immediate to a 32-bit unsigned quantity.
282 def NEGUIMM32 : SDNodeXForm<imm, [{
283 return CurDAG->getTargetConstant(uint32_t(-N->getZExtValue()), SDLoc(N),
287 // Truncate an immediate to a 48-bit unsigned quantity.
288 def UIMM48 : SDNodeXForm<imm, [{
289 return CurDAG->getTargetConstant(uint64_t(N->getZExtValue()) & 0xffffffffffff,
293 //===----------------------------------------------------------------------===//
294 // Immediate asm operands.
295 //===----------------------------------------------------------------------===//
297 def U1Imm : ImmediateAsmOperand<"U1Imm">;
298 def U2Imm : ImmediateAsmOperand<"U2Imm">;
299 def U3Imm : ImmediateAsmOperand<"U3Imm">;
300 def U4Imm : ImmediateAsmOperand<"U4Imm">;
301 def S8Imm : ImmediateAsmOperand<"S8Imm">;
302 def U8Imm : ImmediateAsmOperand<"U8Imm">;
303 def U12Imm : ImmediateAsmOperand<"U12Imm">;
304 def S16Imm : ImmediateAsmOperand<"S16Imm">;
305 def U16Imm : ImmediateAsmOperand<"U16Imm">;
306 def S32Imm : ImmediateAsmOperand<"S32Imm">;
307 def U32Imm : ImmediateAsmOperand<"U32Imm">;
308 def U48Imm : ImmediateAsmOperand<"U48Imm">;
310 //===----------------------------------------------------------------------===//
312 //===----------------------------------------------------------------------===//
314 // Immediates for the lower and upper 16 bits of an i32, with the other
315 // bits of the i32 being zero.
316 defm imm32ll16 : Immediate<i32, [{
317 return N->getAPIntValue().isIntN(32) && SystemZ::isImmLL(N->getZExtValue());
320 defm imm32lh16 : Immediate<i32, [{
321 return N->getAPIntValue().isIntN(32) && SystemZ::isImmLH(N->getZExtValue());
324 // Immediates for the lower and upper 16 bits of an i32, with the other
325 // bits of the i32 being one.
326 defm imm32ll16c : Immediate<i32, [{
327 return N->getAPIntValue().isIntN(32) &&
328 SystemZ::isImmLL(uint32_t(~N->getZExtValue()));
331 defm imm32lh16c : Immediate<i32, [{
332 return N->getAPIntValue().isIntN(32) &&
333 SystemZ::isImmLH(uint32_t(~N->getZExtValue()));
337 defm imm32zx1 : Immediate<i32, [{
338 return N->getAPIntValue().isIntN(1);
339 }], NOOP_SDNodeXForm, "U1Imm">;
341 defm imm32zx2 : Immediate<i32, [{
342 return N->getAPIntValue().isIntN(2);
343 }], NOOP_SDNodeXForm, "U2Imm">;
345 defm imm32zx3 : Immediate<i32, [{
346 return N->getAPIntValue().isIntN(3);
347 }], NOOP_SDNodeXForm, "U3Imm">;
349 defm imm32zx4 : Immediate<i32, [{
350 return N->getAPIntValue().isIntN(4);
351 }], NOOP_SDNodeXForm, "U4Imm">;
353 // Note: this enforces an even value during code generation only.
354 // When used from the assembler, any 4-bit value is allowed.
355 defm imm32zx4even : Immediate<i32, [{
356 return N->getAPIntValue().isIntN(4);
357 }], UIMM8EVEN, "U4Imm">;
359 defm imm32sx8 : Immediate<i32, [{
360 return N->getAPIntValue().isSignedIntN(8);
363 defm imm32zx8 : Immediate<i32, [{
364 return N->getAPIntValue().isIntN(8);
367 defm imm32zx8trunc : Immediate<i32, [{}], UIMM8, "U8Imm">;
369 defm imm32zx12 : Immediate<i32, [{
370 return N->getAPIntValue().isIntN(12);
371 }], UIMM12, "U12Imm">;
373 defm imm32sx16 : Immediate<i32, [{
374 return N->getAPIntValue().isSignedIntN(16);
375 }], SIMM16, "S16Imm">;
377 defm imm32sx16n : Immediate<i32, [{
378 return (-N->getAPIntValue()).isSignedIntN(16);
379 }], NEGSIMM16, "S16Imm">;
381 defm imm32zx16 : Immediate<i32, [{
382 return N->getAPIntValue().isIntN(16);
383 }], UIMM16, "U16Imm">;
385 defm imm32sx16trunc : Immediate<i32, [{}], SIMM16, "S16Imm">;
386 defm imm32zx16trunc : Immediate<i32, [{}], UIMM16, "U16Imm">;
388 // Full 32-bit immediates. we need both signed and unsigned versions
389 // because the assembler is picky. E.g. AFI requires signed operands
390 // while NILF requires unsigned ones.
391 defm simm32 : Immediate<i32, [{}], SIMM32, "S32Imm">;
392 defm uimm32 : Immediate<i32, [{}], UIMM32, "U32Imm">;
394 defm simm32n : Immediate<i32, [{
395 auto SImm = N->getAPIntValue().trySExtValue();
396 return SImm.has_value() && isInt<32>(-*SImm);
397 }], NEGSIMM32, "S32Imm">;
399 def imm32 : ImmLeaf<i32, [{}]>;
401 //===----------------------------------------------------------------------===//
403 //===----------------------------------------------------------------------===//
405 // Immediates for 16-bit chunks of an i64, with the other bits of the
407 defm imm64ll16 : Immediate<i64, [{
408 return N->getAPIntValue().isIntN(64) && SystemZ::isImmLL(N->getZExtValue());
411 defm imm64lh16 : Immediate<i64, [{
412 return N->getAPIntValue().isIntN(64) && SystemZ::isImmLH(N->getZExtValue());
415 defm imm64hl16 : Immediate<i64, [{
416 return N->getAPIntValue().isIntN(64) && SystemZ::isImmHL(N->getZExtValue());
419 defm imm64hh16 : Immediate<i64, [{
420 return N->getAPIntValue().isIntN(64) && SystemZ::isImmHH(N->getZExtValue());
423 // Immediates for 16-bit chunks of an i64, with the other bits of the
425 defm imm64ll16c : Immediate<i64, [{
426 return N->getAPIntValue().isIntN(64) &&
427 SystemZ::isImmLL(uint64_t(~N->getZExtValue()));
430 defm imm64lh16c : Immediate<i64, [{
431 return N->getAPIntValue().isIntN(64) &&
432 SystemZ::isImmLH(uint64_t(~N->getZExtValue()));
435 defm imm64hl16c : Immediate<i64, [{
436 return N->getAPIntValue().isIntN(64) &&
437 SystemZ::isImmHL(uint64_t(~N->getZExtValue()));
440 defm imm64hh16c : Immediate<i64, [{
441 return N->getAPIntValue().isIntN(64) &&
442 SystemZ::isImmHH(uint64_t(~N->getZExtValue()));
445 // Immediates for the lower and upper 32 bits of an i64, with the other
446 // bits of the i32 being zero.
447 defm imm64lf32 : Immediate<i64, [{
448 return N->getAPIntValue().isIntN(64) && SystemZ::isImmLF(N->getZExtValue());
451 defm imm64hf32 : Immediate<i64, [{
452 return N->getAPIntValue().isIntN(64) && SystemZ::isImmHF(N->getZExtValue());
455 // Immediates for the lower and upper 32 bits of an i64, with the other
456 // bits of the i32 being one.
457 defm imm64lf32c : Immediate<i64, [{
458 return N->getAPIntValue().isIntN(64) &&
459 SystemZ::isImmLF(uint64_t(~N->getZExtValue()));
462 defm imm64hf32c : Immediate<i64, [{
463 return N->getAPIntValue().isIntN(64) &&
464 SystemZ::isImmHF(uint64_t(~N->getZExtValue()));
467 // Negated immediates that fit LF32 or LH16.
468 defm imm64lh16n : Immediate<i64, [{
469 return N->getAPIntValue().isIntN(64) &&
470 SystemZ::isImmLH(uint64_t(-N->getZExtValue()));
471 }], NEGLH16, "U16Imm">;
473 defm imm64lf32n : Immediate<i64, [{
474 return N->getAPIntValue().isIntN(64) &&
475 SystemZ::isImmLF(uint64_t(-N->getZExtValue()));
476 }], NEGLF32, "U32Imm">;
479 defm imm64sx8 : Immediate<i64, [{
480 return N->getAPIntValue().isSignedIntN(8);
483 defm imm64zx8 : Immediate<i64, [{
484 return N->getAPIntValue().isIntN(8);;
487 defm imm64sx16 : Immediate<i64, [{
488 return N->getAPIntValue().isSignedIntN(16);
489 }], SIMM16, "S16Imm">;
491 defm imm64sx16n : Immediate<i64, [{
492 return (-N->getAPIntValue()).isSignedIntN(16);
493 }], NEGSIMM16, "S16Imm">;
495 defm imm64zx16 : Immediate<i64, [{
496 return N->getAPIntValue().isIntN(16);
497 }], UIMM16, "U16Imm">;
499 defm imm64sx32 : Immediate<i64, [{
500 return N->getAPIntValue().isSignedIntN(32);
501 }], SIMM32, "S32Imm">;
503 defm imm64sx32n : Immediate<i64, [{
504 return (-N->getAPIntValue()).isSignedIntN(32);
505 }], NEGSIMM32, "S32Imm">;
507 defm imm64zx32 : Immediate<i64, [{
508 return N->getAPIntValue().isIntN(32);
509 }], UIMM32, "U32Imm">;
511 defm imm64zx32n : Immediate<i64, [{
512 return (-N->getAPIntValue()).isIntN(32);
513 }], NEGUIMM32, "U32Imm">;
515 defm imm64zx48 : Immediate<i64, [{
516 return N->getAPIntValue().isIntN(64);
517 }], UIMM48, "U48Imm">;
519 class Imm64 : ImmLeaf<i64, [{}]>, Operand<i64> {
520 let OperandType = "OPERAND_IMMEDIATE";
523 def len4imm64 : Imm64 {
524 let EncoderMethod = "getLenEncoding<SystemZ::FK_390_U4Imm>";
525 let DecoderMethod = "decodeLenOperand<4>";
527 def len8imm64 : Imm64 {
528 let EncoderMethod = "getLenEncoding<SystemZ::FK_390_U8Imm>";
529 let DecoderMethod = "decodeLenOperand<8>";
532 //===----------------------------------------------------------------------===//
533 // Floating-point immediates
534 //===----------------------------------------------------------------------===//
536 // Floating-point zero.
537 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
539 // Floating point negative zero.
540 def fpimmneg0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(-0.0); }]>;
542 //===----------------------------------------------------------------------===//
543 // Symbolic address operands
544 //===----------------------------------------------------------------------===//
546 // PC-relative asm operands.
547 def PCRel12 : PCRelAsmOperand<"12">;
548 def PCRel16 : PCRelAsmOperand<"16">;
549 def PCRel24 : PCRelAsmOperand<"24">;
550 def PCRel32 : PCRelAsmOperand<"32">;
551 def PCRelTLS16 : PCRelTLSAsmOperand<"16">;
552 def PCRelTLS32 : PCRelTLSAsmOperand<"32">;
554 // PC-relative offsets of a basic block. The offset is sign-extended
555 // and multiplied by 2.
556 def brtarget16 : PCRelOperand<OtherVT, PCRel16> {
557 let EncoderMethod = "getPC16DBLEncoding";
558 let DecoderMethod = "decodePC16DBLBranchOperand";
560 def brtarget32 : PCRelOperand<OtherVT, PCRel32> {
561 let EncoderMethod = "getPC32DBLEncoding";
562 let DecoderMethod = "decodePC32DBLBranchOperand";
565 // Variants of brtarget for use with branch prediction preload.
566 def brtarget12bpp : PCRelOperand<OtherVT, PCRel12> {
567 let EncoderMethod = "getPC12DBLBPPEncoding";
568 let DecoderMethod = "decodePC12DBLBranchOperand";
570 def brtarget16bpp : PCRelOperand<OtherVT, PCRel16> {
571 let EncoderMethod = "getPC16DBLBPPEncoding";
572 let DecoderMethod = "decodePC16DBLBranchOperand";
574 def brtarget24bpp : PCRelOperand<OtherVT, PCRel24> {
575 let EncoderMethod = "getPC24DBLBPPEncoding";
576 let DecoderMethod = "decodePC24DBLBranchOperand";
579 // Variants of brtarget16/32 with an optional additional TLS symbol.
580 // These are used to annotate calls to __tls_get_offset.
581 def tlssym : Operand<i64> { }
582 def brtarget16tls : PCRelTLSOperand<OtherVT, PCRelTLS16> {
583 let MIOperandInfo = (ops brtarget16:$func, tlssym:$sym);
584 let EncoderMethod = "getPC16DBLTLSEncoding";
585 let DecoderMethod = "decodePC16DBLBranchOperand";
587 def brtarget32tls : PCRelTLSOperand<OtherVT, PCRelTLS32> {
588 let MIOperandInfo = (ops brtarget32:$func, tlssym:$sym);
589 let EncoderMethod = "getPC32DBLTLSEncoding";
590 let DecoderMethod = "decodePC32DBLBranchOperand";
593 // A PC-relative offset of a global value. The offset is sign-extended
594 // and multiplied by 2.
595 def pcrel32 : PCRelAddress<i64, "pcrel32", PCRel32> {
596 let EncoderMethod = "getPC32DBLEncoding";
597 let DecoderMethod = "decodePC32DBLOperand";
600 //===----------------------------------------------------------------------===//
602 //===----------------------------------------------------------------------===//
604 // 12-bit displacement operands.
605 let EncoderMethod = "getImmOpValue<SystemZ::FK_390_U12Imm>",
606 DecoderMethod = "decodeU12ImmOperand" in {
607 def disp12imm32 : Operand<i32>;
608 def disp12imm64 : Operand<i64>;
611 // 20-bit displacement operands.
612 let EncoderMethod = "getImmOpValue<SystemZ::FK_390_S20Imm>",
613 DecoderMethod = "decodeS20ImmOperand" in {
614 def disp20imm32 : Operand<i32>;
615 def disp20imm64 : Operand<i64>;
618 def BDAddr32Disp12 : AddressAsmOperand<"BDAddr", "32", "12">;
619 def BDAddr32Disp20 : AddressAsmOperand<"BDAddr", "32", "20">;
620 def BDAddr64Disp12 : AddressAsmOperand<"BDAddr", "64", "12">;
621 def BDAddr64Disp20 : AddressAsmOperand<"BDAddr", "64", "20">;
622 def BDXAddr64Disp12 : AddressAsmOperand<"BDXAddr", "64", "12">;
623 def BDXAddr64Disp20 : AddressAsmOperand<"BDXAddr", "64", "20">;
624 def BDLAddr64Disp12Len4 : AddressAsmOperand<"BDLAddr", "64", "12", "Len4">;
625 def BDLAddr64Disp12Len8 : AddressAsmOperand<"BDLAddr", "64", "12", "Len8">;
626 def BDRAddr64Disp12 : AddressAsmOperand<"BDRAddr", "64", "12">;
627 def BDVAddr64Disp12 : AddressAsmOperand<"BDVAddr", "64", "12">;
629 // DAG patterns and operands for addressing modes. Each mode has
630 // the form <type><range><group>[<len>] where:
633 // shift : base + displacement (32-bit)
634 // bdaddr : base + displacement
635 // mviaddr : like bdaddr, but reject cases with a natural index
636 // bdxaddr : base + displacement + index
637 // laaddr : like bdxaddr, but used for Load Address operations
638 // dynalloc : base + displacement + index + ADJDYNALLOC
639 // bdladdr : base + displacement with a length field
640 // bdvaddr : base + displacement with a vector index
642 // <range> is one of:
643 // 12 : the displacement is an unsigned 12-bit value
644 // 20 : the displacement is a signed 20-bit value
646 // <group> is one of:
647 // pair : used when there is an equivalent instruction with the opposite
648 // range value (12 or 20)
649 // only : used when there is no equivalent instruction with the opposite
654 // <empty> : there is no length field
655 // len8 : the length field is 8 bits, with a range of [1, 0x100].
656 def shift12only : BDMode <"BDAddr", "32", "12", "Only">;
657 def shift20only : BDMode <"BDAddr", "32", "20", "Only">;
658 def bdaddr12only : BDMode <"BDAddr", "64", "12", "Only">;
659 def bdaddr12pair : BDMode <"BDAddr", "64", "12", "Pair">;
660 def bdaddr20only : BDMode <"BDAddr", "64", "20", "Only">;
661 def bdaddr20pair : BDMode <"BDAddr", "64", "20", "Pair">;
662 def mviaddr12pair : BDMode <"MVIAddr", "64", "12", "Pair">;
663 def mviaddr20pair : BDMode <"MVIAddr", "64", "20", "Pair">;
664 def bdxaddr12only : BDXMode<"BDXAddr", "64", "12", "Only">;
665 def bdxaddr12pair : BDXMode<"BDXAddr", "64", "12", "Pair">;
666 def bdxaddr20only : BDXMode<"BDXAddr", "64", "20", "Only">;
667 def bdxaddr20only128 : BDXMode<"BDXAddr", "64", "20", "Only128">;
668 def bdxaddr20pair : BDXMode<"BDXAddr", "64", "20", "Pair">;
669 def dynalloc12only : BDXMode<"DynAlloc", "64", "12", "Only">;
670 def laaddr12pair : BDXMode<"LAAddr", "64", "12", "Pair">;
671 def laaddr20pair : BDXMode<"LAAddr", "64", "20", "Pair">;
672 def bdladdr12onlylen4 : BDLMode<"BDLAddr", "64", "12", "Only", "4">;
673 def bdladdr12onlylen8 : BDLMode<"BDLAddr", "64", "12", "Only", "8">;
674 def bdraddr12only : BDRMode<"BDRAddr", "64", "12", "Only">;
675 def bdvaddr12only : BDVMode< "64", "12">;
677 //===----------------------------------------------------------------------===//
679 //===----------------------------------------------------------------------===//
681 // A 4-bit condition-code mask.
682 def cond4 : PatLeaf<(i32 timm), [{ return (N->getZExtValue() < 16); }]>,
684 let PrintMethod = "printCond4Operand";
685 let OperandType = "OPERAND_IMMEDIATE";