1 //==- SystemZInstrFormats.td - SystemZ Instruction Formats --*- tablegen -*-==//
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 //===----------------------------------------------------------------------===//
11 // Basic SystemZ instruction definition
12 //===----------------------------------------------------------------------===//
14 class InstSystemZ<int size, dag outs, dag ins, string asmstr,
15 list<dag> pattern> : Instruction {
16 let Namespace = "SystemZ";
18 dag OutOperandList = outs;
19 dag InOperandList = ins;
21 let Pattern = pattern;
22 let AsmString = asmstr;
24 // Some instructions come in pairs, one having a 12-bit displacement
25 // and the other having a 20-bit displacement. Both instructions in
26 // the pair have the same DispKey and their DispSizes are "12" and "20"
29 string DispSize = "none";
31 // Many register-based <INSN>R instructions have a memory-based <INSN>
32 // counterpart. OpKey uniquely identifies <INSN>, while OpType is
33 // "reg" for <INSN>R and "mem" for <INSN>.
35 string OpType = "none";
37 // Many distinct-operands instructions have older 2-operand equivalents.
38 // NumOpsKey uniquely identifies one of these 2-operand and 3-operand pairs,
39 // with NumOpsValue being "2" or "3" as appropriate.
40 string NumOpsKey = "";
41 string NumOpsValue = "none";
43 // True if this instruction is a simple D(X,B) load of a register
44 // (with no sign or zero extension).
45 bit SimpleBDXLoad = 0;
47 // True if this instruction is a simple D(X,B) store of a register
48 // (with no truncation).
49 bit SimpleBDXStore = 0;
51 // True if this instruction has a 20-bit displacement field.
52 bit Has20BitOffset = 0;
54 // True if addresses in this instruction have an index register.
57 // True if this is a 128-bit pseudo instruction that combines two 64-bit
61 // The access size of all memory operands in bytes, or 0 if not known.
62 bits<5> AccessBytes = 0;
64 let TSFlags{0} = SimpleBDXLoad;
65 let TSFlags{1} = SimpleBDXStore;
66 let TSFlags{2} = Has20BitOffset;
67 let TSFlags{3} = HasIndex;
68 let TSFlags{4} = Is128Bit;
69 let TSFlags{9-5} = AccessBytes;
72 //===----------------------------------------------------------------------===//
73 // Mappings between instructions
74 //===----------------------------------------------------------------------===//
76 // Return the version of an instruction that has an unsigned 12-bit
78 def getDisp12Opcode : InstrMapping {
79 let FilterClass = "InstSystemZ";
80 let RowFields = ["DispKey"];
81 let ColFields = ["DispSize"];
83 let ValueCols = [["12"]];
86 // Return the version of an instruction that has a signed 20-bit displacement.
87 def getDisp20Opcode : InstrMapping {
88 let FilterClass = "InstSystemZ";
89 let RowFields = ["DispKey"];
90 let ColFields = ["DispSize"];
92 let ValueCols = [["20"]];
95 // Return the memory form of a register instruction.
96 def getMemOpcode : InstrMapping {
97 let FilterClass = "InstSystemZ";
98 let RowFields = ["OpKey"];
99 let ColFields = ["OpType"];
100 let KeyCol = ["reg"];
101 let ValueCols = [["mem"]];
104 // Return the 3-operand form of a 2-operand instruction.
105 def getThreeOperandOpcode : InstrMapping {
106 let FilterClass = "InstSystemZ";
107 let RowFields = ["NumOpsKey"];
108 let ColFields = ["NumOpsValue"];
110 let ValueCols = [["3"]];
113 //===----------------------------------------------------------------------===//
114 // Instruction formats
115 //===----------------------------------------------------------------------===//
117 // Formats are specified using operand field declarations of the form:
119 // bits<4> Rn : register input or output for operand n
120 // bits<m> In : immediate value of width m for operand n
121 // bits<4> BDn : address operand n, which has a base and a displacement
122 // bits<m> XBDn : address operand n, which has an index, a base and a
124 // bits<4> Xn : index register for address operand n
125 // bits<4> Mn : mode value for operand n
127 // The operand numbers ("n" in the list above) follow the architecture manual.
128 // Assembly operands sometimes have a different order; in particular, R3 often
129 // is often written between operands 1 and 2.
131 //===----------------------------------------------------------------------===//
133 class InstRI<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
134 : InstSystemZ<4, outs, ins, asmstr, pattern> {
136 field bits<32> SoftFail = 0;
141 let Inst{31-24} = op{11-4};
142 let Inst{23-20} = R1;
143 let Inst{19-16} = op{3-0};
147 class InstRIEb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
148 : InstSystemZ<6, outs, ins, asmstr, pattern> {
150 field bits<48> SoftFail = 0;
157 let Inst{47-40} = op{15-8};
158 let Inst{39-36} = R1;
159 let Inst{35-32} = R2;
160 let Inst{31-16} = RI4;
161 let Inst{15-12} = M3;
163 let Inst{7-0} = op{7-0};
166 class InstRIEc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
167 : InstSystemZ<6, outs, ins, asmstr, pattern> {
169 field bits<48> SoftFail = 0;
176 let Inst{47-40} = op{15-8};
177 let Inst{39-36} = R1;
178 let Inst{35-32} = M3;
179 let Inst{31-16} = RI4;
181 let Inst{7-0} = op{7-0};
184 class InstRIEd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
185 : InstSystemZ<6, outs, ins, asmstr, pattern> {
187 field bits<48> SoftFail = 0;
193 let Inst{47-40} = op{15-8};
194 let Inst{39-36} = R1;
195 let Inst{35-32} = R3;
196 let Inst{31-16} = I2;
198 let Inst{7-0} = op{7-0};
201 class InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
202 : InstSystemZ<6, outs, ins, asmstr, pattern> {
204 field bits<48> SoftFail = 0;
212 let Inst{47-40} = op{15-8};
213 let Inst{39-36} = R1;
214 let Inst{35-32} = R2;
215 let Inst{31-24} = I3;
216 let Inst{23-16} = I4;
218 let Inst{7-0} = op{7-0};
221 class InstRIL<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
222 : InstSystemZ<6, outs, ins, asmstr, pattern> {
224 field bits<48> SoftFail = 0;
229 let Inst{47-40} = op{11-4};
230 let Inst{39-36} = R1;
231 let Inst{35-32} = op{3-0};
235 class InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
236 : InstSystemZ<2, outs, ins, asmstr, pattern> {
238 field bits<16> SoftFail = 0;
248 class InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
249 : InstSystemZ<4, outs, ins, asmstr, pattern> {
251 field bits<32> SoftFail = 0;
257 let Inst{31-16} = op;
258 let Inst{15-12} = R1;
264 class InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
265 : InstSystemZ<4, outs, ins, asmstr, pattern> {
267 field bits<32> SoftFail = 0;
272 let Inst{31-16} = op;
278 class InstRRF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
279 : InstSystemZ<4, outs, ins, asmstr, pattern> {
281 field bits<32> SoftFail = 0;
287 let Inst{31-16} = op;
288 let Inst{15-12} = R3;
294 class InstRX<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
295 : InstSystemZ<4, outs, ins, asmstr, pattern> {
297 field bits<32> SoftFail = 0;
302 let Inst{31-24} = op;
303 let Inst{23-20} = R1;
304 let Inst{19-0} = XBD2;
309 class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
310 : InstSystemZ<6, outs, ins, asmstr, pattern> {
312 field bits<48> SoftFail = 0;
317 let Inst{47-40} = op{15-8};
318 let Inst{39-36} = R1;
319 let Inst{35-16} = XBD2;
321 let Inst{7-0} = op{7-0};
326 class InstRXF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
327 : InstSystemZ<6, outs, ins, asmstr, pattern> {
329 field bits<48> SoftFail = 0;
335 let Inst{47-40} = op{15-8};
336 let Inst{39-36} = R3;
337 let Inst{35-16} = XBD2;
338 let Inst{15-12} = R1;
340 let Inst{7-0} = op{7-0};
345 class InstRXY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
346 : InstSystemZ<6, outs, ins, asmstr, pattern> {
348 field bits<48> SoftFail = 0;
353 let Inst{47-40} = op{15-8};
354 let Inst{39-36} = R1;
355 let Inst{35-8} = XBD2;
356 let Inst{7-0} = op{7-0};
358 let Has20BitOffset = 1;
362 class InstRS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
363 : InstSystemZ<4, outs, ins, asmstr, pattern> {
365 field bits<32> SoftFail = 0;
371 let Inst{31-24} = op;
372 let Inst{23-20} = R1;
373 let Inst{19-16} = R3;
374 let Inst{15-0} = BD2;
377 class InstRSY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
378 : InstSystemZ<6, outs, ins, asmstr, pattern> {
380 field bits<48> SoftFail = 0;
386 let Inst{47-40} = op{15-8};
387 let Inst{39-36} = R1;
388 let Inst{35-32} = R3;
389 let Inst{31-8} = BD2;
390 let Inst{7-0} = op{7-0};
392 let Has20BitOffset = 1;
395 class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
396 : InstSystemZ<4, outs, ins, asmstr, pattern> {
398 field bits<32> SoftFail = 0;
403 let Inst{31-24} = op;
404 let Inst{23-16} = I2;
405 let Inst{15-0} = BD1;
408 class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
409 : InstSystemZ<6, outs, ins, asmstr, pattern> {
411 field bits<48> SoftFail = 0;
416 let Inst{47-32} = op;
417 let Inst{31-16} = BD1;
421 class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
422 : InstSystemZ<6, outs, ins, asmstr, pattern> {
424 field bits<48> SoftFail = 0;
429 let Inst{47-40} = op{15-8};
430 let Inst{39-32} = I2;
431 let Inst{31-8} = BD1;
432 let Inst{7-0} = op{7-0};
434 let Has20BitOffset = 1;
437 class InstSS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
438 : InstSystemZ<6, outs, ins, asmstr, pattern> {
440 field bits<48> SoftFail = 0;
445 let Inst{47-40} = op;
446 let Inst{39-16} = BDL1;
447 let Inst{15-0} = BD2;
450 //===----------------------------------------------------------------------===//
451 // Instruction definitions with semantics
452 //===----------------------------------------------------------------------===//
454 // These classes have the form [Cond]<Category><Format>, where <Format> is one
455 // of the formats defined above and where <Category> describes the inputs
456 // and outputs. "Cond" is used if the instruction is conditional,
457 // in which case the 4-bit condition-code mask is added as a final operand.
458 // <Category> can be one of:
461 // One register output operand and no input operands.
464 // One register or immediate input operand and one address input operand.
465 // The instruction stores the first operand to the address.
467 // This category is used for both pure and truncating stores.
470 // One address input operand and two explicit output operands.
471 // The instruction loads a range of registers from the address,
472 // with the explicit operands giving the first and last register
473 // to load. Other loaded registers are added as implicit definitions.
476 // Two explicit input register operands and an address operand.
477 // The instruction stores a range of registers to the address,
478 // with the explicit operands giving the first and last register
479 // to store. Other stored registers are added as implicit uses.
482 // One register output operand and one input operand. The input
483 // operand may be a register, immediate or memory.
486 // One register output operand and two input operands. The first
487 // input operand is always a register and he second may be a register,
488 // immediate or memory.
491 // One register output operand and two input operands. The first
492 // input operand is a register and the second has the same form as
493 // an address (although it isn't actually used to address memory).
496 // Two input operands. The first operand is always a register,
497 // the second may be a register, immediate or memory.
500 // One register output operand and three register input operands.
503 // One output operand and three input operands. The first two
504 // operands are registers and the third is an address. The instruction
505 // both reads from and writes to the address.
508 // One output operand and five input operands. The first two operands
509 // are registers and the other three are immediates.
511 // The format determines which input operands are tied to output operands,
512 // and also determines the shape of any address operand.
514 // Multiclasses of the form <Category><Format>Pair define two instructions,
515 // one with <Category><Format> and one with <Category><Format>Y. The name
516 // of the first instruction has no suffix, the name of the second has
519 //===----------------------------------------------------------------------===//
521 class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
523 : InstRRE<opcode, (outs cls:$R1), (ins),
525 [(set cls:$R1, src)]> {
529 class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
530 : InstRSY<opcode, (outs cls:$R1, cls:$R3), (ins bdaddr20only:$BD2),
531 mnemonic#"\t$R1, $R3, $BD2", []> {
535 class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
537 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
538 mnemonic#"\t$R1, $I2",
539 [(operator cls:$R1, pcrel32:$I2)]> {
541 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
542 // However, BDXs have two extra operands and are therefore 6 units more
544 let AddedComplexity = 7;
547 class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
548 RegisterOperand cls, bits<5> bytes,
549 AddressingMode mode = bdxaddr12only>
550 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
551 mnemonic#"\t$R1, $XBD2",
552 [(operator cls:$R1, mode:$XBD2)]> {
553 let OpKey = mnemonic ## cls;
556 let AccessBytes = bytes;
559 class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
560 RegisterOperand cls, bits<5> bytes,
561 AddressingMode mode = bdxaddr20only>
562 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
563 mnemonic#"\t$R1, $XBD2",
564 [(operator cls:$R1, mode:$XBD2)]> {
565 let OpKey = mnemonic ## cls;
568 let AccessBytes = bytes;
571 multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
572 SDPatternOperator operator, RegisterOperand cls,
574 let DispKey = mnemonic ## #cls in {
575 let DispSize = "12" in
576 def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
577 let DispSize = "20" in
578 def Y : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
583 class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
584 : InstRSY<opcode, (outs), (ins cls:$R1, cls:$R3, bdaddr20only:$BD2),
585 mnemonic#"\t$R1, $R3, $BD2", []> {
589 class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
590 Immediate imm, AddressingMode mode = bdaddr12only>
591 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
592 mnemonic#"\t$BD1, $I2",
593 [(operator imm:$I2, mode:$BD1)]> {
597 class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
598 Immediate imm, AddressingMode mode = bdaddr20only>
599 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
600 mnemonic#"\t$BD1, $I2",
601 [(operator imm:$I2, mode:$BD1)]> {
605 class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
607 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
608 mnemonic#"\t$BD1, $I2",
609 [(operator imm:$I2, bdaddr12only:$BD1)]> {
613 multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
614 SDPatternOperator operator, Immediate imm> {
615 let DispKey = mnemonic in {
616 let DispSize = "12" in
617 def "" : StoreSI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
618 let DispSize = "20" in
619 def Y : StoreSIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
623 class CondStoreRSY<string mnemonic, bits<16> opcode,
624 RegisterOperand cls, bits<5> bytes,
625 AddressingMode mode = bdaddr20only>
626 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, cond4:$R3),
627 mnemonic#"$R3\t$R1, $BD2", []>,
628 Requires<[FeatureLoadStoreOnCond]> {
630 let AccessBytes = bytes;
633 // Like CondStoreRSY, but used for the raw assembly form. The condition-code
634 // mask is the third operand rather than being part of the mnemonic.
635 class AsmCondStoreRSY<string mnemonic, bits<16> opcode,
636 RegisterOperand cls, bits<5> bytes,
637 AddressingMode mode = bdaddr20only>
638 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, uimm8zx4:$R3),
639 mnemonic#"\t$R1, $BD2, $R3", []>,
640 Requires<[FeatureLoadStoreOnCond]> {
642 let AccessBytes = bytes;
645 // Like CondStoreRSY, but with a fixed CC mask.
646 class FixedCondStoreRSY<string mnemonic, bits<16> opcode,
647 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
648 AddressingMode mode = bdaddr20only>
649 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2),
650 mnemonic#"\t$R1, $BD2", []>,
651 Requires<[FeatureLoadStoreOnCond]> {
653 let AccessBytes = bytes;
657 class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
658 RegisterOperand cls1, RegisterOperand cls2>
659 : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
660 mnemonic#"r\t$R1, $R2",
661 [(set cls1:$R1, (operator cls2:$R2))]> {
662 let OpKey = mnemonic ## cls1;
666 class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
667 RegisterOperand cls1, RegisterOperand cls2>
668 : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
669 mnemonic#"r\t$R1, $R2",
670 [(set cls1:$R1, (operator cls2:$R2))]> {
671 let OpKey = mnemonic ## cls1;
675 class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
676 RegisterOperand cls2>
677 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2),
678 mnemonic#"r\t$R1, $R3, $R2", []> {
679 let OpKey = mnemonic ## cls1;
683 class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
684 RegisterOperand cls, Immediate imm>
685 : InstRI<opcode, (outs cls:$R1), (ins imm:$I2),
686 mnemonic#"\t$R1, $I2",
687 [(set cls:$R1, (operator imm:$I2))]>;
689 class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
690 RegisterOperand cls, Immediate imm>
691 : InstRIL<opcode, (outs cls:$R1), (ins imm:$I2),
692 mnemonic#"\t$R1, $I2",
693 [(set cls:$R1, (operator imm:$I2))]>;
695 class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
697 : InstRIL<opcode, (outs cls:$R1), (ins pcrel32:$I2),
698 mnemonic#"\t$R1, $I2",
699 [(set cls:$R1, (operator pcrel32:$I2))]> {
701 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
702 // However, BDXs have two extra operands and are therefore 6 units more
704 let AddedComplexity = 7;
707 class CondUnaryRSY<string mnemonic, bits<16> opcode,
708 RegisterOperand cls, bits<5> bytes,
709 AddressingMode mode = bdaddr20only>
710 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, cond4:$R3),
711 mnemonic#"$R3\t$R1, $BD2", []>,
712 Requires<[FeatureLoadStoreOnCond]> {
713 let Constraints = "$R1 = $R1src";
714 let DisableEncoding = "$R1src";
716 let AccessBytes = bytes;
719 // Like CondUnaryRSY, but used for the raw assembly form. The condition-code
720 // mask is the third operand rather than being part of the mnemonic.
721 class AsmCondUnaryRSY<string mnemonic, bits<16> opcode,
722 RegisterOperand cls, bits<5> bytes,
723 AddressingMode mode = bdaddr20only>
724 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, uimm8zx4:$R3),
725 mnemonic#"\t$R1, $BD2, $R3", []>,
726 Requires<[FeatureLoadStoreOnCond]> {
728 let AccessBytes = bytes;
729 let Constraints = "$R1 = $R1src";
730 let DisableEncoding = "$R1src";
733 // Like CondUnaryRSY, but with a fixed CC mask.
734 class FixedCondUnaryRSY<string mnemonic, bits<16> opcode,
735 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
736 AddressingMode mode = bdaddr20only>
737 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
738 mnemonic#"\t$R1, $BD2", []>,
739 Requires<[FeatureLoadStoreOnCond]> {
740 let Constraints = "$R1 = $R1src";
741 let DisableEncoding = "$R1src";
744 let AccessBytes = bytes;
747 class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
748 RegisterOperand cls, bits<5> bytes,
749 AddressingMode mode = bdxaddr12only>
750 : InstRX<opcode, (outs cls:$R1), (ins mode:$XBD2),
751 mnemonic#"\t$R1, $XBD2",
752 [(set cls:$R1, (operator mode:$XBD2))]> {
753 let OpKey = mnemonic ## cls;
756 let AccessBytes = bytes;
759 class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
760 RegisterOperand cls, bits<5> bytes>
761 : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
762 mnemonic#"\t$R1, $XBD2",
763 [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
764 let OpKey = mnemonic ## cls;
767 let AccessBytes = bytes;
770 class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
771 RegisterOperand cls, bits<5> bytes,
772 AddressingMode mode = bdxaddr20only>
773 : InstRXY<opcode, (outs cls:$R1), (ins mode:$XBD2),
774 mnemonic#"\t$R1, $XBD2",
775 [(set cls:$R1, (operator mode:$XBD2))]> {
776 let OpKey = mnemonic ## cls;
779 let AccessBytes = bytes;
782 multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
783 SDPatternOperator operator, RegisterOperand cls,
785 let DispKey = mnemonic ## #cls in {
786 let DispSize = "12" in
787 def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
788 let DispSize = "20" in
789 def Y : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
794 class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
795 RegisterOperand cls1, RegisterOperand cls2>
796 : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
797 mnemonic#"r\t$R1, $R2",
798 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
799 let OpKey = mnemonic ## cls1;
801 let Constraints = "$R1 = $R1src";
802 let DisableEncoding = "$R1src";
805 class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
806 RegisterOperand cls1, RegisterOperand cls2>
807 : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
808 mnemonic#"r\t$R1, $R2",
809 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
810 let OpKey = mnemonic ## cls1;
812 let Constraints = "$R1 = $R1src";
813 let DisableEncoding = "$R1src";
816 class BinaryRRF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
817 RegisterOperand cls1, RegisterOperand cls2>
818 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R3, cls2:$R2),
819 mnemonic#"r\t$R1, $R3, $R2",
820 [(set cls1:$R1, (operator cls1:$R3, cls2:$R2))]> {
821 let OpKey = mnemonic ## cls1;
825 class BinaryRRFK<string mnemonic, bits<16> opcode, SDPatternOperator operator,
826 RegisterOperand cls1, RegisterOperand cls2>
827 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R2, cls2:$R3),
828 mnemonic#"rk\t$R1, $R2, $R3",
829 [(set cls1:$R1, (operator cls1:$R2, cls2:$R3))]>;
831 multiclass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
832 SDPatternOperator operator, RegisterOperand cls1,
833 RegisterOperand cls2> {
834 let NumOpsKey = mnemonic in {
835 let NumOpsValue = "3" in
836 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
837 Requires<[FeatureDistinctOps]>;
838 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
839 def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
843 multiclass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
844 SDPatternOperator operator, RegisterOperand cls1,
845 RegisterOperand cls2> {
846 let NumOpsKey = mnemonic in {
847 let NumOpsValue = "3" in
848 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
849 Requires<[FeatureDistinctOps]>;
850 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
851 def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
855 class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
856 RegisterOperand cls, Immediate imm>
857 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
858 mnemonic#"\t$R1, $I2",
859 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
860 let Constraints = "$R1 = $R1src";
861 let DisableEncoding = "$R1src";
864 class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
865 RegisterOperand cls, Immediate imm>
866 : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
867 mnemonic#"\t$R1, $R3, $I2",
868 [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
870 multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
871 SDPatternOperator operator, RegisterOperand cls,
873 let NumOpsKey = mnemonic in {
874 let NumOpsValue = "3" in
875 def K : BinaryRIE<mnemonic##"k", opcode2, null_frag, cls, imm>,
876 Requires<[FeatureDistinctOps]>;
877 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
878 def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
882 class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
883 RegisterOperand cls, Immediate imm>
884 : InstRIL<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
885 mnemonic#"\t$R1, $I2",
886 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
887 let Constraints = "$R1 = $R1src";
888 let DisableEncoding = "$R1src";
891 class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
892 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
893 AddressingMode mode = bdxaddr12only>
894 : InstRX<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
895 mnemonic#"\t$R1, $XBD2",
896 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
897 let OpKey = mnemonic ## cls;
899 let Constraints = "$R1 = $R1src";
900 let DisableEncoding = "$R1src";
902 let AccessBytes = bytes;
905 class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
906 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
907 : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
908 mnemonic#"\t$R1, $XBD2",
909 [(set cls:$R1, (operator cls:$R1src,
910 (load bdxaddr12only:$XBD2)))]> {
911 let OpKey = mnemonic ## cls;
913 let Constraints = "$R1 = $R1src";
914 let DisableEncoding = "$R1src";
916 let AccessBytes = bytes;
919 class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
920 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
921 AddressingMode mode = bdxaddr20only>
922 : InstRXY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
923 mnemonic#"\t$R1, $XBD2",
924 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
925 let OpKey = mnemonic ## cls;
927 let Constraints = "$R1 = $R1src";
928 let DisableEncoding = "$R1src";
930 let AccessBytes = bytes;
933 multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
934 SDPatternOperator operator, RegisterOperand cls,
935 SDPatternOperator load, bits<5> bytes> {
936 let DispKey = mnemonic ## #cls in {
937 let DispSize = "12" in
938 def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
940 let DispSize = "20" in
941 def Y : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
946 class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
947 Operand imm, AddressingMode mode = bdaddr12only>
948 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
949 mnemonic#"\t$BD1, $I2",
950 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
955 class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
956 Operand imm, AddressingMode mode = bdaddr20only>
957 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
958 mnemonic#"\t$BD1, $I2",
959 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
964 multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
965 bits<16> siyOpcode, SDPatternOperator operator,
967 let DispKey = mnemonic ## #cls in {
968 let DispSize = "12" in
969 def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
970 let DispSize = "20" in
971 def Y : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
975 class ShiftRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
977 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
978 mnemonic#"\t$R1, $BD2",
979 [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
981 let Constraints = "$R1 = $R1src";
982 let DisableEncoding = "$R1src";
985 class ShiftRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
987 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
988 mnemonic#"\t$R1, $R3, $BD2",
989 [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
991 multiclass ShiftRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
992 SDPatternOperator operator, RegisterOperand cls> {
993 let NumOpsKey = mnemonic in {
994 let NumOpsValue = "3" in
995 def K : ShiftRSY<mnemonic##"k", opcode2, null_frag, cls>,
996 Requires<[FeatureDistinctOps]>;
997 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
998 def "" : ShiftRS<mnemonic, opcode1, operator, cls>;
1002 class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1003 RegisterOperand cls1, RegisterOperand cls2>
1004 : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
1005 mnemonic#"r\t$R1, $R2",
1006 [(operator cls1:$R1, cls2:$R2)]> {
1007 let OpKey = mnemonic ## cls1;
1011 class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1012 RegisterOperand cls1, RegisterOperand cls2>
1013 : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
1014 mnemonic#"r\t$R1, $R2",
1015 [(operator cls1:$R1, cls2:$R2)]> {
1016 let OpKey = mnemonic ## cls1;
1020 class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1021 RegisterOperand cls, Immediate imm>
1022 : InstRI<opcode, (outs), (ins cls:$R1, imm:$I2),
1023 mnemonic#"\t$R1, $I2",
1024 [(operator cls:$R1, imm:$I2)]>;
1026 class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1027 RegisterOperand cls, Immediate imm>
1028 : InstRIL<opcode, (outs), (ins cls:$R1, imm:$I2),
1029 mnemonic#"\t$R1, $I2",
1030 [(operator cls:$R1, imm:$I2)]>;
1032 class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1033 RegisterOperand cls, SDPatternOperator load>
1034 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
1035 mnemonic#"\t$R1, $I2",
1036 [(operator cls:$R1, (load pcrel32:$I2))]> {
1038 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
1039 // However, BDXs have two extra operands and are therefore 6 units more
1041 let AddedComplexity = 7;
1044 class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1045 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
1046 AddressingMode mode = bdxaddr12only>
1047 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1048 mnemonic#"\t$R1, $XBD2",
1049 [(operator cls:$R1, (load mode:$XBD2))]> {
1050 let OpKey = mnemonic ## cls;
1053 let AccessBytes = bytes;
1056 class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1057 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
1058 : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
1059 mnemonic#"\t$R1, $XBD2",
1060 [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
1061 let OpKey = mnemonic ## cls;
1064 let AccessBytes = bytes;
1067 class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1068 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
1069 AddressingMode mode = bdxaddr20only>
1070 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1071 mnemonic#"\t$R1, $XBD2",
1072 [(operator cls:$R1, (load mode:$XBD2))]> {
1073 let OpKey = mnemonic ## cls;
1076 let AccessBytes = bytes;
1079 multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
1080 SDPatternOperator operator, RegisterOperand cls,
1081 SDPatternOperator load, bits<5> bytes> {
1082 let DispKey = mnemonic ## #cls in {
1083 let DispSize = "12" in
1084 def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
1085 load, bytes, bdxaddr12pair>;
1086 let DispSize = "20" in
1087 def Y : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
1088 load, bytes, bdxaddr20pair>;
1092 class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1093 SDPatternOperator load, Immediate imm,
1094 AddressingMode mode = bdaddr12only>
1095 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
1096 mnemonic#"\t$BD1, $I2",
1097 [(operator (load mode:$BD1), imm:$I2)]> {
1101 class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1102 SDPatternOperator load, Immediate imm>
1103 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
1104 mnemonic#"\t$BD1, $I2",
1105 [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
1109 class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1110 SDPatternOperator load, Immediate imm,
1111 AddressingMode mode = bdaddr20only>
1112 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
1113 mnemonic#"\t$BD1, $I2",
1114 [(operator (load mode:$BD1), imm:$I2)]> {
1118 multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
1119 SDPatternOperator operator, SDPatternOperator load,
1121 let DispKey = mnemonic in {
1122 let DispSize = "12" in
1123 def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
1124 let DispSize = "20" in
1125 def Y : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
1130 class TernaryRRD<string mnemonic, bits<16> opcode,
1131 SDPatternOperator operator, RegisterOperand cls>
1132 : InstRRD<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, cls:$R2),
1133 mnemonic#"r\t$R1, $R3, $R2",
1134 [(set cls:$R1, (operator cls:$R1src, cls:$R3, cls:$R2))]> {
1135 let OpKey = mnemonic ## cls;
1137 let Constraints = "$R1 = $R1src";
1138 let DisableEncoding = "$R1src";
1141 class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1142 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
1143 : InstRXF<opcode, (outs cls:$R1),
1144 (ins cls:$R1src, cls:$R3, bdxaddr12only:$XBD2),
1145 mnemonic#"\t$R1, $R3, $XBD2",
1146 [(set cls:$R1, (operator cls:$R1src, cls:$R3,
1147 (load bdxaddr12only:$XBD2)))]> {
1148 let OpKey = mnemonic ## cls;
1150 let Constraints = "$R1 = $R1src";
1151 let DisableEncoding = "$R1src";
1153 let AccessBytes = bytes;
1156 class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1157 RegisterOperand cls, AddressingMode mode = bdaddr12only>
1158 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1159 mnemonic#"\t$R1, $R3, $BD2",
1160 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1161 let Constraints = "$R1 = $R1src";
1162 let DisableEncoding = "$R1src";
1167 class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1168 RegisterOperand cls, AddressingMode mode = bdaddr20only>
1169 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1170 mnemonic#"\t$R1, $R3, $BD2",
1171 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1172 let Constraints = "$R1 = $R1src";
1173 let DisableEncoding = "$R1src";
1178 multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
1179 SDPatternOperator operator, RegisterOperand cls> {
1180 let DispKey = mnemonic ## #cls in {
1181 let DispSize = "12" in
1182 def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
1183 let DispSize = "20" in
1184 def Y : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
1188 class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
1189 RegisterOperand cls2>
1190 : InstRIEf<opcode, (outs cls1:$R1),
1191 (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5),
1192 mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
1193 let Constraints = "$R1 = $R1src";
1194 let DisableEncoding = "$R1src";
1197 //===----------------------------------------------------------------------===//
1198 // Pseudo instructions
1199 //===----------------------------------------------------------------------===//
1201 // Convenience instructions that get lowered to real instructions
1202 // by either SystemZTargetLowering::EmitInstrWithCustomInserter()
1203 // or SystemZInstrInfo::expandPostRAPseudo().
1205 //===----------------------------------------------------------------------===//
1207 class Pseudo<dag outs, dag ins, list<dag> pattern>
1208 : InstSystemZ<0, outs, ins, "", pattern> {
1210 let isCodeGenOnly = 1;
1213 // Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
1214 // the value of the PSW's 2-bit condition code field.
1215 class SelectWrapper<RegisterOperand cls>
1216 : Pseudo<(outs cls:$dst), (ins cls:$src1, cls:$src2, i8imm:$cc),
1217 [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2, imm:$cc))]> {
1218 let usesCustomInserter = 1;
1219 // Although the instructions used by these nodes do not in themselves
1220 // change CC, the insertion requires new blocks, and CC cannot be live
1226 // Stores $new to $addr if $cc is true ("" case) or false (Inv case).
1227 multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
1228 SDPatternOperator load, AddressingMode mode> {
1229 let Defs = [CC], Uses = [CC], usesCustomInserter = 1 in {
1230 def "" : Pseudo<(outs), (ins cls:$new, mode:$addr, uimm8zx4:$cc),
1231 [(store (z_select_ccmask cls:$new, (load mode:$addr),
1232 uimm8zx4:$cc), mode:$addr)]>;
1233 def Inv : Pseudo<(outs), (ins cls:$new, mode:$addr, uimm8zx4:$cc),
1234 [(store (z_select_ccmask (load mode:$addr), cls:$new,
1235 uimm8zx4:$cc), mode:$addr)]>;
1239 // OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation. PAT and OPERAND
1240 // describe the second (non-memory) operand.
1241 class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
1242 dag pat, DAGOperand operand>
1243 : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
1244 [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
1246 let Has20BitOffset = 1;
1249 let usesCustomInserter = 1;
1252 // Specializations of AtomicLoadWBinary.
1253 class AtomicLoadBinaryReg32<SDPatternOperator operator>
1254 : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
1255 class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
1256 : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
1257 class AtomicLoadBinaryReg64<SDPatternOperator operator>
1258 : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
1259 class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
1260 : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
1262 // OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation. PAT and OPERAND
1263 // describe the second (non-memory) operand.
1264 class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
1266 : Pseudo<(outs GR32:$dst),
1267 (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
1268 ADDR32:$negbitshift, uimm32:$bitsize),
1269 [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
1270 ADDR32:$negbitshift, uimm32:$bitsize))]> {
1272 let Has20BitOffset = 1;
1275 let usesCustomInserter = 1;
1278 // Specializations of AtomicLoadWBinary.
1279 class AtomicLoadWBinaryReg<SDPatternOperator operator>
1280 : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
1281 class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
1282 : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;