xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZInstrFormats.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric//==- SystemZInstrFormats.td - SystemZ Instruction Formats --*- tablegen -*-==//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric
90b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
100b57cec5SDimitry Andric// Basic SystemZ instruction definition
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andricclass InstSystemZ<int size, dag outs, dag ins, string asmstr,
140b57cec5SDimitry Andric                  list<dag> pattern> : Instruction {
150b57cec5SDimitry Andric  let Namespace = "SystemZ";
160b57cec5SDimitry Andric
170b57cec5SDimitry Andric  dag OutOperandList = outs;
180b57cec5SDimitry Andric  dag InOperandList = ins;
190b57cec5SDimitry Andric  let Size = size;
200b57cec5SDimitry Andric  let Pattern = pattern;
210b57cec5SDimitry Andric  let AsmString = asmstr;
220b57cec5SDimitry Andric
230b57cec5SDimitry Andric  let hasSideEffects = 0;
240b57cec5SDimitry Andric  let mayLoad = 0;
250b57cec5SDimitry Andric  let mayStore = 0;
260b57cec5SDimitry Andric
270b57cec5SDimitry Andric  // Some instructions come in pairs, one having a 12-bit displacement
280b57cec5SDimitry Andric  // and the other having a 20-bit displacement.  Both instructions in
290b57cec5SDimitry Andric  // the pair have the same DispKey and their DispSizes are "12" and "20"
300b57cec5SDimitry Andric  // respectively.
310b57cec5SDimitry Andric  string DispKey = "";
320b57cec5SDimitry Andric  string DispSize = "none";
330b57cec5SDimitry Andric
340b57cec5SDimitry Andric  // Many register-based <INSN>R instructions have a memory-based <INSN>
350b57cec5SDimitry Andric  // counterpart.  OpKey uniquely identifies <INSN>R, while OpType is
360b57cec5SDimitry Andric  // "reg" for <INSN>R and "mem" for <INSN>.
370b57cec5SDimitry Andric  string OpKey = "";
380b57cec5SDimitry Andric  string OpType = "none";
390b57cec5SDimitry Andric
400b57cec5SDimitry Andric  // MemKey identifies a targe reg-mem opcode, while MemType can be either
410b57cec5SDimitry Andric  // "pseudo" or "target". This is used to map a pseduo memory instruction to
420b57cec5SDimitry Andric  // its corresponding target opcode. See comment at MemFoldPseudo.
430b57cec5SDimitry Andric  string MemKey = "";
440b57cec5SDimitry Andric  string MemType = "none";
450b57cec5SDimitry Andric
460b57cec5SDimitry Andric  // Many distinct-operands instructions have older 2-operand equivalents.
470b57cec5SDimitry Andric  // NumOpsKey uniquely identifies one of these 2-operand and 3-operand pairs,
480b57cec5SDimitry Andric  // with NumOpsValue being "2" or "3" as appropriate.
490b57cec5SDimitry Andric  string NumOpsKey = "";
500b57cec5SDimitry Andric  string NumOpsValue = "none";
510b57cec5SDimitry Andric
520b57cec5SDimitry Andric  // True if this instruction is a simple D(X,B) load of a register
530b57cec5SDimitry Andric  // (with no sign or zero extension).
540b57cec5SDimitry Andric  bit SimpleBDXLoad = 0;
550b57cec5SDimitry Andric
560b57cec5SDimitry Andric  // True if this instruction is a simple D(X,B) store of a register
570b57cec5SDimitry Andric  // (with no truncation).
580b57cec5SDimitry Andric  bit SimpleBDXStore = 0;
590b57cec5SDimitry Andric
600b57cec5SDimitry Andric  // True if this instruction has a 20-bit displacement field.
610b57cec5SDimitry Andric  bit Has20BitOffset = 0;
620b57cec5SDimitry Andric
630b57cec5SDimitry Andric  // True if addresses in this instruction have an index register.
640b57cec5SDimitry Andric  bit HasIndex = 0;
650b57cec5SDimitry Andric
660b57cec5SDimitry Andric  // True if this is a 128-bit pseudo instruction that combines two 64-bit
670b57cec5SDimitry Andric  // operations.
680b57cec5SDimitry Andric  bit Is128Bit = 0;
690b57cec5SDimitry Andric
700b57cec5SDimitry Andric  // The access size of all memory operands in bytes, or 0 if not known.
710b57cec5SDimitry Andric  bits<5> AccessBytes = 0;
720b57cec5SDimitry Andric
730b57cec5SDimitry Andric  // If the instruction sets CC to a useful value, this gives the mask
740b57cec5SDimitry Andric  // of all possible CC results.  The mask has the same form as
750b57cec5SDimitry Andric  // SystemZ::CCMASK_*.
760b57cec5SDimitry Andric  bits<4> CCValues = 0;
770b57cec5SDimitry Andric
78480093f4SDimitry Andric  // The subset of CCValues that have the same meaning as they would after a
79480093f4SDimitry Andric  // comparison of the first operand against zero. "Logical" instructions
80480093f4SDimitry Andric  // leave this blank as they set CC in a different way.
810b57cec5SDimitry Andric  bits<4> CompareZeroCCMask = 0;
820b57cec5SDimitry Andric
830b57cec5SDimitry Andric  // True if the instruction is conditional and if the CC mask operand
840b57cec5SDimitry Andric  // comes first (as for BRC, etc.).
850b57cec5SDimitry Andric  bit CCMaskFirst = 0;
860b57cec5SDimitry Andric
870b57cec5SDimitry Andric  // Similar, but true if the CC mask operand comes last (as for LOC, etc.).
880b57cec5SDimitry Andric  bit CCMaskLast = 0;
890b57cec5SDimitry Andric
900b57cec5SDimitry Andric  // True if the instruction is the "logical" rather than "arithmetic" form,
91480093f4SDimitry Andric  // in cases where a distinction exists. Except for logical compares, if the
92480093f4SDimitry Andric  // instruction sets this flag along with a non-zero CCValues field, it is
93480093f4SDimitry Andric  // assumed to set CC to either CCMASK_LOGICAL_ZERO or
94480093f4SDimitry Andric  // CCMASK_LOGICAL_NONZERO.
950b57cec5SDimitry Andric  bit IsLogical = 0;
960b57cec5SDimitry Andric
97480093f4SDimitry Andric  // True if the (add or sub) instruction sets CC like a compare of the
98480093f4SDimitry Andric  // result against zero, but only if the 'nsw' flag is set.
99480093f4SDimitry Andric  bit CCIfNoSignedWrap = 0;
100480093f4SDimitry Andric
1010b57cec5SDimitry Andric  let TSFlags{0}     = SimpleBDXLoad;
1020b57cec5SDimitry Andric  let TSFlags{1}     = SimpleBDXStore;
1030b57cec5SDimitry Andric  let TSFlags{2}     = Has20BitOffset;
1040b57cec5SDimitry Andric  let TSFlags{3}     = HasIndex;
1050b57cec5SDimitry Andric  let TSFlags{4}     = Is128Bit;
1060b57cec5SDimitry Andric  let TSFlags{9-5}   = AccessBytes;
1070b57cec5SDimitry Andric  let TSFlags{13-10} = CCValues;
1080b57cec5SDimitry Andric  let TSFlags{17-14} = CompareZeroCCMask;
1090b57cec5SDimitry Andric  let TSFlags{18}    = CCMaskFirst;
1100b57cec5SDimitry Andric  let TSFlags{19}    = CCMaskLast;
1110b57cec5SDimitry Andric  let TSFlags{20}    = IsLogical;
112480093f4SDimitry Andric  let TSFlags{21}    = CCIfNoSignedWrap;
1130b57cec5SDimitry Andric}
1140b57cec5SDimitry Andric
1150b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1160b57cec5SDimitry Andric// Mappings between instructions
1170b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andric// Return the version of an instruction that has an unsigned 12-bit
1200b57cec5SDimitry Andric// displacement.
1210b57cec5SDimitry Andricdef getDisp12Opcode : InstrMapping {
1220b57cec5SDimitry Andric  let FilterClass = "InstSystemZ";
1230b57cec5SDimitry Andric  let RowFields = ["DispKey"];
1240b57cec5SDimitry Andric  let ColFields = ["DispSize"];
1250b57cec5SDimitry Andric  let KeyCol = ["20"];
1260b57cec5SDimitry Andric  let ValueCols = [["12"]];
1270b57cec5SDimitry Andric}
1280b57cec5SDimitry Andric
1290b57cec5SDimitry Andric// Return the version of an instruction that has a signed 20-bit displacement.
1300b57cec5SDimitry Andricdef getDisp20Opcode : InstrMapping {
1310b57cec5SDimitry Andric  let FilterClass = "InstSystemZ";
1320b57cec5SDimitry Andric  let RowFields = ["DispKey"];
1330b57cec5SDimitry Andric  let ColFields = ["DispSize"];
1340b57cec5SDimitry Andric  let KeyCol = ["12"];
1350b57cec5SDimitry Andric  let ValueCols = [["20"]];
1360b57cec5SDimitry Andric}
1370b57cec5SDimitry Andric
1380b57cec5SDimitry Andric// Return the memory form of a register instruction. Note that this may
1390b57cec5SDimitry Andric// return a MemFoldPseudo instruction (see below).
1400b57cec5SDimitry Andricdef getMemOpcode : InstrMapping {
1410b57cec5SDimitry Andric  let FilterClass = "InstSystemZ";
1420b57cec5SDimitry Andric  let RowFields = ["OpKey"];
1430b57cec5SDimitry Andric  let ColFields = ["OpType"];
1440b57cec5SDimitry Andric  let KeyCol = ["reg"];
1450b57cec5SDimitry Andric  let ValueCols = [["mem"]];
1460b57cec5SDimitry Andric}
1470b57cec5SDimitry Andric
1480b57cec5SDimitry Andric// Return the target memory instruction for a MemFoldPseudo.
1490b57cec5SDimitry Andricdef getTargetMemOpcode : InstrMapping {
1500b57cec5SDimitry Andric  let FilterClass = "InstSystemZ";
1510b57cec5SDimitry Andric  let RowFields = ["MemKey"];
1520b57cec5SDimitry Andric  let ColFields = ["MemType"];
1530b57cec5SDimitry Andric  let KeyCol = ["pseudo"];
1540b57cec5SDimitry Andric  let ValueCols = [["target"]];
1550b57cec5SDimitry Andric}
1560b57cec5SDimitry Andric
1570b57cec5SDimitry Andric// Return the 2-operand form of a 3-operand instruction.
1580b57cec5SDimitry Andricdef getTwoOperandOpcode : InstrMapping {
1590b57cec5SDimitry Andric  let FilterClass = "InstSystemZ";
1600b57cec5SDimitry Andric  let RowFields = ["NumOpsKey"];
1610b57cec5SDimitry Andric  let ColFields = ["NumOpsValue"];
1620b57cec5SDimitry Andric  let KeyCol = ["3"];
1630b57cec5SDimitry Andric  let ValueCols = [["2"]];
1640b57cec5SDimitry Andric}
1650b57cec5SDimitry Andric
1660b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1670b57cec5SDimitry Andric// Instruction formats
1680b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1690b57cec5SDimitry Andric//
1700b57cec5SDimitry Andric// Formats are specified using operand field declarations of the form:
1710b57cec5SDimitry Andric//
1720b57cec5SDimitry Andric//   bits<4> Rn   : register input or output for operand n
1730b57cec5SDimitry Andric//   bits<5> Vn   : vector register input or output for operand n
1740b57cec5SDimitry Andric//   bits<m> In   : immediate value of width m for operand n
17506c3fb27SDimitry Andric//   bits<4> Bn   : base register for address operand n
17606c3fb27SDimitry Andric//   bits<m> Dn   : displacement for address operand n
17706c3fb27SDimitry Andric//   bits<5> Vn   : vector index for address operand n
1780b57cec5SDimitry Andric//   bits<4> Xn   : index register for address operand n
1790b57cec5SDimitry Andric//   bits<4> Mn   : mode value for operand n
1800b57cec5SDimitry Andric//
1810b57cec5SDimitry Andric// The operand numbers ("n" in the list above) follow the architecture manual.
1820b57cec5SDimitry Andric// Assembly operands sometimes have a different order; in particular, R3 often
1830b57cec5SDimitry Andric// is often written between operands 1 and 2.
1840b57cec5SDimitry Andric//
1850b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1860b57cec5SDimitry Andric
1870b57cec5SDimitry Andricclass InstE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1880b57cec5SDimitry Andric  : InstSystemZ<2, outs, ins, asmstr, pattern> {
1890b57cec5SDimitry Andric  field bits<16> Inst;
1900b57cec5SDimitry Andric  field bits<16> SoftFail = 0;
1910b57cec5SDimitry Andric
1920b57cec5SDimitry Andric  let Inst = op;
1930b57cec5SDimitry Andric}
1940b57cec5SDimitry Andric
1950b57cec5SDimitry Andricclass InstI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1960b57cec5SDimitry Andric  : InstSystemZ<2, outs, ins, asmstr, pattern> {
1970b57cec5SDimitry Andric  field bits<16> Inst;
1980b57cec5SDimitry Andric  field bits<16> SoftFail = 0;
1990b57cec5SDimitry Andric
2000b57cec5SDimitry Andric  bits<8> I1;
2010b57cec5SDimitry Andric
2020b57cec5SDimitry Andric  let Inst{15-8} = op;
2030b57cec5SDimitry Andric  let Inst{7-0}  = I1;
2040b57cec5SDimitry Andric}
2050b57cec5SDimitry Andric
2060b57cec5SDimitry Andricclass InstIE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
2070b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
2080b57cec5SDimitry Andric  field bits<32> Inst;
2090b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
2100b57cec5SDimitry Andric
2110b57cec5SDimitry Andric  bits<4> I1;
2120b57cec5SDimitry Andric  bits<4> I2;
2130b57cec5SDimitry Andric
2140b57cec5SDimitry Andric  let Inst{31-16} = op;
2150b57cec5SDimitry Andric  let Inst{15-8}  = 0;
2160b57cec5SDimitry Andric  let Inst{7-4}   = I1;
2170b57cec5SDimitry Andric  let Inst{3-0}   = I2;
2180b57cec5SDimitry Andric}
2190b57cec5SDimitry Andric
2200b57cec5SDimitry Andricclass InstMII<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
2210b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
2220b57cec5SDimitry Andric  field bits<48> Inst;
2230b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
2240b57cec5SDimitry Andric
2250b57cec5SDimitry Andric  bits<4> M1;
2260b57cec5SDimitry Andric  bits<12> RI2;
2270b57cec5SDimitry Andric  bits<24> RI3;
2280b57cec5SDimitry Andric
2290b57cec5SDimitry Andric  let Inst{47-40} = op;
2300b57cec5SDimitry Andric  let Inst{39-36} = M1;
2310b57cec5SDimitry Andric  let Inst{35-24} = RI2;
2320b57cec5SDimitry Andric  let Inst{23-0}  = RI3;
2330b57cec5SDimitry Andric}
2340b57cec5SDimitry Andric
2350b57cec5SDimitry Andricclass InstRIa<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
2360b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
2370b57cec5SDimitry Andric  field bits<32> Inst;
2380b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
2390b57cec5SDimitry Andric
2400b57cec5SDimitry Andric  bits<4> R1;
2410b57cec5SDimitry Andric  bits<16> I2;
2420b57cec5SDimitry Andric
2430b57cec5SDimitry Andric  let Inst{31-24} = op{11-4};
2440b57cec5SDimitry Andric  let Inst{23-20} = R1;
2450b57cec5SDimitry Andric  let Inst{19-16} = op{3-0};
2460b57cec5SDimitry Andric  let Inst{15-0}  = I2;
2470b57cec5SDimitry Andric}
2480b57cec5SDimitry Andric
2490b57cec5SDimitry Andricclass InstRIb<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
2500b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
2510b57cec5SDimitry Andric  field bits<32> Inst;
2520b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
2530b57cec5SDimitry Andric
2540b57cec5SDimitry Andric  bits<4> R1;
2550b57cec5SDimitry Andric  bits<16> RI2;
2560b57cec5SDimitry Andric
2570b57cec5SDimitry Andric  let Inst{31-24} = op{11-4};
2580b57cec5SDimitry Andric  let Inst{23-20} = R1;
2590b57cec5SDimitry Andric  let Inst{19-16} = op{3-0};
2600b57cec5SDimitry Andric  let Inst{15-0}  = RI2;
2610b57cec5SDimitry Andric}
2620b57cec5SDimitry Andric
2630b57cec5SDimitry Andricclass InstRIc<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
2640b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
2650b57cec5SDimitry Andric  field bits<32> Inst;
2660b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
2670b57cec5SDimitry Andric
2680b57cec5SDimitry Andric  bits<4> M1;
2690b57cec5SDimitry Andric  bits<16> RI2;
2700b57cec5SDimitry Andric
2710b57cec5SDimitry Andric  let Inst{31-24} = op{11-4};
2720b57cec5SDimitry Andric  let Inst{23-20} = M1;
2730b57cec5SDimitry Andric  let Inst{19-16} = op{3-0};
2740b57cec5SDimitry Andric  let Inst{15-0}  = RI2;
2750b57cec5SDimitry Andric}
2760b57cec5SDimitry Andric
2770b57cec5SDimitry Andricclass InstRIEa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
2780b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
2790b57cec5SDimitry Andric  field bits<48> Inst;
2800b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
2810b57cec5SDimitry Andric
2820b57cec5SDimitry Andric  bits<4> R1;
2830b57cec5SDimitry Andric  bits<16> I2;
2840b57cec5SDimitry Andric  bits<4> M3;
2850b57cec5SDimitry Andric
2860b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
2870b57cec5SDimitry Andric  let Inst{39-36} = R1;
2880b57cec5SDimitry Andric  let Inst{35-32} = 0;
2890b57cec5SDimitry Andric  let Inst{31-16} = I2;
2900b57cec5SDimitry Andric  let Inst{15-12} = M3;
2910b57cec5SDimitry Andric  let Inst{11-8}  = 0;
2920b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
2930b57cec5SDimitry Andric}
2940b57cec5SDimitry Andric
2950b57cec5SDimitry Andricclass InstRIEb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
2960b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
2970b57cec5SDimitry Andric  field bits<48> Inst;
2980b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
2990b57cec5SDimitry Andric
3000b57cec5SDimitry Andric  bits<4> R1;
3010b57cec5SDimitry Andric  bits<4> R2;
3020b57cec5SDimitry Andric  bits<4> M3;
3030b57cec5SDimitry Andric  bits<16> RI4;
3040b57cec5SDimitry Andric
3050b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
3060b57cec5SDimitry Andric  let Inst{39-36} = R1;
3070b57cec5SDimitry Andric  let Inst{35-32} = R2;
3080b57cec5SDimitry Andric  let Inst{31-16} = RI4;
3090b57cec5SDimitry Andric  let Inst{15-12} = M3;
3100b57cec5SDimitry Andric  let Inst{11-8}  = 0;
3110b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
3120b57cec5SDimitry Andric}
3130b57cec5SDimitry Andric
3140b57cec5SDimitry Andricclass InstRIEc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
3150b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
3160b57cec5SDimitry Andric  field bits<48> Inst;
3170b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
3180b57cec5SDimitry Andric
3190b57cec5SDimitry Andric  bits<4> R1;
3200b57cec5SDimitry Andric  bits<8> I2;
3210b57cec5SDimitry Andric  bits<4> M3;
3220b57cec5SDimitry Andric  bits<16> RI4;
3230b57cec5SDimitry Andric
3240b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
3250b57cec5SDimitry Andric  let Inst{39-36} = R1;
3260b57cec5SDimitry Andric  let Inst{35-32} = M3;
3270b57cec5SDimitry Andric  let Inst{31-16} = RI4;
3280b57cec5SDimitry Andric  let Inst{15-8}  = I2;
3290b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
3300b57cec5SDimitry Andric}
3310b57cec5SDimitry Andric
3320b57cec5SDimitry Andricclass InstRIEd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
3330b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
3340b57cec5SDimitry Andric  field bits<48> Inst;
3350b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
3360b57cec5SDimitry Andric
3370b57cec5SDimitry Andric  bits<4> R1;
3380b57cec5SDimitry Andric  bits<4> R3;
3390b57cec5SDimitry Andric  bits<16> I2;
3400b57cec5SDimitry Andric
3410b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
3420b57cec5SDimitry Andric  let Inst{39-36} = R1;
3430b57cec5SDimitry Andric  let Inst{35-32} = R3;
3440b57cec5SDimitry Andric  let Inst{31-16} = I2;
3450b57cec5SDimitry Andric  let Inst{15-8}  = 0;
3460b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
3470b57cec5SDimitry Andric}
3480b57cec5SDimitry Andric
3490b57cec5SDimitry Andricclass InstRIEe<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
3500b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
3510b57cec5SDimitry Andric  field bits<48> Inst;
3520b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
3530b57cec5SDimitry Andric
3540b57cec5SDimitry Andric  bits<4> R1;
3550b57cec5SDimitry Andric  bits<4> R3;
3560b57cec5SDimitry Andric  bits<16> RI2;
3570b57cec5SDimitry Andric
3580b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
3590b57cec5SDimitry Andric  let Inst{39-36} = R1;
3600b57cec5SDimitry Andric  let Inst{35-32} = R3;
3610b57cec5SDimitry Andric  let Inst{31-16} = RI2;
3620b57cec5SDimitry Andric  let Inst{15-8}  = 0;
3630b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
3640b57cec5SDimitry Andric}
3650b57cec5SDimitry Andric
366*0fca6ea1SDimitry Andricclass InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern,
367*0fca6ea1SDimitry Andric               bits<8> I3Or = 0, bits<8> I4Or = 0>
3680b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
3690b57cec5SDimitry Andric  field bits<48> Inst;
3700b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
3710b57cec5SDimitry Andric
3720b57cec5SDimitry Andric  bits<4> R1;
3730b57cec5SDimitry Andric  bits<4> R2;
3740b57cec5SDimitry Andric  bits<8> I3;
3750b57cec5SDimitry Andric  bits<8> I4;
3760b57cec5SDimitry Andric  bits<8> I5;
3770b57cec5SDimitry Andric
3780b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
3790b57cec5SDimitry Andric  let Inst{39-36} = R1;
3800b57cec5SDimitry Andric  let Inst{35-32} = R2;
381*0fca6ea1SDimitry Andric  let Inst{31} = !if(I3Or{7}, 1, I3{7});
382*0fca6ea1SDimitry Andric  let Inst{30} = !if(I3Or{6}, 1, I3{6});
383*0fca6ea1SDimitry Andric  let Inst{29} = !if(I3Or{5}, 1, I3{5});
384*0fca6ea1SDimitry Andric  let Inst{28} = !if(I3Or{4}, 1, I3{4});
385*0fca6ea1SDimitry Andric  let Inst{27} = !if(I3Or{3}, 1, I3{3});
386*0fca6ea1SDimitry Andric  let Inst{26} = !if(I3Or{2}, 1, I3{2});
387*0fca6ea1SDimitry Andric  let Inst{25} = !if(I3Or{1}, 1, I3{1});
388*0fca6ea1SDimitry Andric  let Inst{24} = !if(I3Or{0}, 1, I3{0});
389*0fca6ea1SDimitry Andric  let Inst{23} = !if(I4Or{7}, 1, I4{7});
390*0fca6ea1SDimitry Andric  let Inst{22} = !if(I4Or{6}, 1, I4{6});
391*0fca6ea1SDimitry Andric  let Inst{21} = !if(I4Or{5}, 1, I4{5});
392*0fca6ea1SDimitry Andric  let Inst{20} = !if(I4Or{4}, 1, I4{4});
393*0fca6ea1SDimitry Andric  let Inst{19} = !if(I4Or{3}, 1, I4{3});
394*0fca6ea1SDimitry Andric  let Inst{18} = !if(I4Or{2}, 1, I4{2});
395*0fca6ea1SDimitry Andric  let Inst{17} = !if(I4Or{1}, 1, I4{1});
396*0fca6ea1SDimitry Andric  let Inst{16} = !if(I4Or{0}, 1, I4{0});
3970b57cec5SDimitry Andric  let Inst{15-8}  = I5;
3980b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
3990b57cec5SDimitry Andric}
4000b57cec5SDimitry Andric
4010b57cec5SDimitry Andricclass InstRIEg<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
4020b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
4030b57cec5SDimitry Andric  field bits<48> Inst;
4040b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
4050b57cec5SDimitry Andric
4060b57cec5SDimitry Andric  bits<4> R1;
4070b57cec5SDimitry Andric  bits<4> M3;
4080b57cec5SDimitry Andric  bits<16> I2;
4090b57cec5SDimitry Andric
4100b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
4110b57cec5SDimitry Andric  let Inst{39-36} = R1;
4120b57cec5SDimitry Andric  let Inst{35-32} = M3;
4130b57cec5SDimitry Andric  let Inst{31-16} = I2;
4140b57cec5SDimitry Andric  let Inst{15-8}  = 0;
4150b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
4160b57cec5SDimitry Andric}
4170b57cec5SDimitry Andric
4180b57cec5SDimitry Andricclass InstRILa<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
4190b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
4200b57cec5SDimitry Andric  field bits<48> Inst;
4210b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
4220b57cec5SDimitry Andric
4230b57cec5SDimitry Andric  bits<4> R1;
4240b57cec5SDimitry Andric  bits<32> I2;
4250b57cec5SDimitry Andric
4260b57cec5SDimitry Andric  let Inst{47-40} = op{11-4};
4270b57cec5SDimitry Andric  let Inst{39-36} = R1;
4280b57cec5SDimitry Andric  let Inst{35-32} = op{3-0};
4290b57cec5SDimitry Andric  let Inst{31-0}  = I2;
4300b57cec5SDimitry Andric}
4310b57cec5SDimitry Andric
4320b57cec5SDimitry Andricclass InstRILb<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
4330b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
4340b57cec5SDimitry Andric  field bits<48> Inst;
4350b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
4360b57cec5SDimitry Andric
4370b57cec5SDimitry Andric  bits<4> R1;
4380b57cec5SDimitry Andric  bits<32> RI2;
4390b57cec5SDimitry Andric
4400b57cec5SDimitry Andric  let Inst{47-40} = op{11-4};
4410b57cec5SDimitry Andric  let Inst{39-36} = R1;
4420b57cec5SDimitry Andric  let Inst{35-32} = op{3-0};
4430b57cec5SDimitry Andric  let Inst{31-0}  = RI2;
4440b57cec5SDimitry Andric}
4450b57cec5SDimitry Andric
4460b57cec5SDimitry Andricclass InstRILc<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
4470b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
4480b57cec5SDimitry Andric  field bits<48> Inst;
4490b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
4500b57cec5SDimitry Andric
4510b57cec5SDimitry Andric  bits<4> M1;
4520b57cec5SDimitry Andric  bits<32> RI2;
4530b57cec5SDimitry Andric
4540b57cec5SDimitry Andric  let Inst{47-40} = op{11-4};
4550b57cec5SDimitry Andric  let Inst{39-36} = M1;
4560b57cec5SDimitry Andric  let Inst{35-32} = op{3-0};
4570b57cec5SDimitry Andric  let Inst{31-0}  = RI2;
4580b57cec5SDimitry Andric}
4590b57cec5SDimitry Andric
4600b57cec5SDimitry Andricclass InstRIS<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
4610b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
4620b57cec5SDimitry Andric  field bits<48> Inst;
4630b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
4640b57cec5SDimitry Andric
4650b57cec5SDimitry Andric  bits<4> R1;
4660b57cec5SDimitry Andric  bits<8> I2;
4670b57cec5SDimitry Andric  bits<4> M3;
46806c3fb27SDimitry Andric  bits<4> B4;
46906c3fb27SDimitry Andric  bits<12> D4;
4700b57cec5SDimitry Andric
4710b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
4720b57cec5SDimitry Andric  let Inst{39-36} = R1;
4730b57cec5SDimitry Andric  let Inst{35-32} = M3;
47406c3fb27SDimitry Andric  let Inst{31-28} = B4;
47506c3fb27SDimitry Andric  let Inst{27-16} = D4;
4760b57cec5SDimitry Andric  let Inst{15-8}  = I2;
4770b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
4780b57cec5SDimitry Andric}
4790b57cec5SDimitry Andric
4800b57cec5SDimitry Andricclass InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
4810b57cec5SDimitry Andric  : InstSystemZ<2, outs, ins, asmstr, pattern> {
4820b57cec5SDimitry Andric  field bits<16> Inst;
4830b57cec5SDimitry Andric  field bits<16> SoftFail = 0;
4840b57cec5SDimitry Andric
4850b57cec5SDimitry Andric  bits<4> R1;
4860b57cec5SDimitry Andric  bits<4> R2;
4870b57cec5SDimitry Andric
4880b57cec5SDimitry Andric  let Inst{15-8} = op;
4890b57cec5SDimitry Andric  let Inst{7-4}  = R1;
4900b57cec5SDimitry Andric  let Inst{3-0}  = R2;
4910b57cec5SDimitry Andric}
4920b57cec5SDimitry Andric
4930b57cec5SDimitry Andricclass InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
4940b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
4950b57cec5SDimitry Andric  field bits<32> Inst;
4960b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
4970b57cec5SDimitry Andric
4980b57cec5SDimitry Andric  bits<4> R1;
4990b57cec5SDimitry Andric  bits<4> R3;
5000b57cec5SDimitry Andric  bits<4> R2;
5010b57cec5SDimitry Andric
5020b57cec5SDimitry Andric  let Inst{31-16} = op;
5030b57cec5SDimitry Andric  let Inst{15-12} = R1;
5040b57cec5SDimitry Andric  let Inst{11-8}  = 0;
5050b57cec5SDimitry Andric  let Inst{7-4}   = R3;
5060b57cec5SDimitry Andric  let Inst{3-0}   = R2;
5070b57cec5SDimitry Andric}
5080b57cec5SDimitry Andric
5090b57cec5SDimitry Andricclass InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
5100b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
5110b57cec5SDimitry Andric  field bits<32> Inst;
5120b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
5130b57cec5SDimitry Andric
5140b57cec5SDimitry Andric  bits<4> R1;
5150b57cec5SDimitry Andric  bits<4> R2;
5160b57cec5SDimitry Andric
5170b57cec5SDimitry Andric  let Inst{31-16} = op;
5180b57cec5SDimitry Andric  let Inst{15-8}  = 0;
5190b57cec5SDimitry Andric  let Inst{7-4}   = R1;
5200b57cec5SDimitry Andric  let Inst{3-0}   = R2;
5210b57cec5SDimitry Andric}
5220b57cec5SDimitry Andric
5230b57cec5SDimitry Andricclass InstRRFa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
5240b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
5250b57cec5SDimitry Andric  field bits<32> Inst;
5260b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
5270b57cec5SDimitry Andric
5280b57cec5SDimitry Andric  bits<4> R1;
5290b57cec5SDimitry Andric  bits<4> R2;
5300b57cec5SDimitry Andric  bits<4> R3;
5310b57cec5SDimitry Andric  bits<4> M4;
5320b57cec5SDimitry Andric
5330b57cec5SDimitry Andric  let Inst{31-16} = op;
5340b57cec5SDimitry Andric  let Inst{15-12} = R3;
5350b57cec5SDimitry Andric  let Inst{11-8}  = M4;
5360b57cec5SDimitry Andric  let Inst{7-4}   = R1;
5370b57cec5SDimitry Andric  let Inst{3-0}   = R2;
5380b57cec5SDimitry Andric}
5390b57cec5SDimitry Andric
5400b57cec5SDimitry Andricclass InstRRFb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
5410b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
5420b57cec5SDimitry Andric  field bits<32> Inst;
5430b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
5440b57cec5SDimitry Andric
5450b57cec5SDimitry Andric  bits<4> R1;
5460b57cec5SDimitry Andric  bits<4> R2;
5470b57cec5SDimitry Andric  bits<4> R3;
5480b57cec5SDimitry Andric  bits<4> M4;
5490b57cec5SDimitry Andric
5500b57cec5SDimitry Andric  let Inst{31-16} = op;
5510b57cec5SDimitry Andric  let Inst{15-12} = R3;
5520b57cec5SDimitry Andric  let Inst{11-8}  = M4;
5530b57cec5SDimitry Andric  let Inst{7-4}   = R1;
5540b57cec5SDimitry Andric  let Inst{3-0}   = R2;
5550b57cec5SDimitry Andric}
5560b57cec5SDimitry Andric
5570b57cec5SDimitry Andricclass InstRRFc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
5580b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
5590b57cec5SDimitry Andric  field bits<32> Inst;
5600b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
5610b57cec5SDimitry Andric
5620b57cec5SDimitry Andric  bits<4> R1;
5630b57cec5SDimitry Andric  bits<4> R2;
5640b57cec5SDimitry Andric  bits<4> M3;
5650b57cec5SDimitry Andric
5660b57cec5SDimitry Andric  let Inst{31-16} = op;
5670b57cec5SDimitry Andric  let Inst{15-12} = M3;
5680b57cec5SDimitry Andric  let Inst{11-8}  = 0;
5690b57cec5SDimitry Andric  let Inst{7-4}   = R1;
5700b57cec5SDimitry Andric  let Inst{3-0}   = R2;
5710b57cec5SDimitry Andric}
5720b57cec5SDimitry Andric
5730b57cec5SDimitry Andricclass InstRRFd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
5740b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
5750b57cec5SDimitry Andric  field bits<32> Inst;
5760b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
5770b57cec5SDimitry Andric
5780b57cec5SDimitry Andric  bits<4> R1;
5790b57cec5SDimitry Andric  bits<4> R2;
5800b57cec5SDimitry Andric  bits<4> M4;
5810b57cec5SDimitry Andric
5820b57cec5SDimitry Andric  let Inst{31-16} = op;
5830b57cec5SDimitry Andric  let Inst{15-12} = 0;
5840b57cec5SDimitry Andric  let Inst{11-8}  = M4;
5850b57cec5SDimitry Andric  let Inst{7-4}   = R1;
5860b57cec5SDimitry Andric  let Inst{3-0}   = R2;
5870b57cec5SDimitry Andric}
5880b57cec5SDimitry Andric
5890b57cec5SDimitry Andricclass InstRRFe<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
5900b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
5910b57cec5SDimitry Andric  field bits<32> Inst;
5920b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
5930b57cec5SDimitry Andric
5940b57cec5SDimitry Andric  bits<4> R1;
5950b57cec5SDimitry Andric  bits<4> R2;
5960b57cec5SDimitry Andric  bits<4> M3;
5970b57cec5SDimitry Andric  bits<4> M4;
5980b57cec5SDimitry Andric
5990b57cec5SDimitry Andric  let Inst{31-16} = op;
6000b57cec5SDimitry Andric  let Inst{15-12} = M3;
6010b57cec5SDimitry Andric  let Inst{11-8}  = M4;
6020b57cec5SDimitry Andric  let Inst{7-4}   = R1;
6030b57cec5SDimitry Andric  let Inst{3-0}   = R2;
6040b57cec5SDimitry Andric}
6050b57cec5SDimitry Andric
6060b57cec5SDimitry Andricclass InstRRS<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
6070b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
6080b57cec5SDimitry Andric  field bits<48> Inst;
6090b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
6100b57cec5SDimitry Andric
6110b57cec5SDimitry Andric  bits<4> R1;
6120b57cec5SDimitry Andric  bits<4> R2;
6130b57cec5SDimitry Andric  bits<4> M3;
61406c3fb27SDimitry Andric  bits<4> B4;
61506c3fb27SDimitry Andric  bits<12> D4;
6160b57cec5SDimitry Andric
6170b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
6180b57cec5SDimitry Andric  let Inst{39-36} = R1;
6190b57cec5SDimitry Andric  let Inst{35-32} = R2;
62006c3fb27SDimitry Andric  let Inst{31-28} = B4;
62106c3fb27SDimitry Andric  let Inst{27-16} = D4;
6220b57cec5SDimitry Andric  let Inst{15-12} = M3;
6230b57cec5SDimitry Andric  let Inst{11-8}  = 0;
6240b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
6250b57cec5SDimitry Andric}
6260b57cec5SDimitry Andric
6270b57cec5SDimitry Andricclass InstRXa<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
6280b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
6290b57cec5SDimitry Andric  field bits<32> Inst;
6300b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
6310b57cec5SDimitry Andric
6320b57cec5SDimitry Andric  bits<4> R1;
63306c3fb27SDimitry Andric  bits<4> X2;
63406c3fb27SDimitry Andric  bits<4> B2;
63506c3fb27SDimitry Andric  bits<12> D2;
6360b57cec5SDimitry Andric
6370b57cec5SDimitry Andric  let Inst{31-24} = op;
6380b57cec5SDimitry Andric  let Inst{23-20} = R1;
63906c3fb27SDimitry Andric  let Inst{19-16} = X2;
64006c3fb27SDimitry Andric  let Inst{15-12} = B2;
64106c3fb27SDimitry Andric  let Inst{11-0}  = D2;
6420b57cec5SDimitry Andric
6430b57cec5SDimitry Andric  let HasIndex = 1;
6440b57cec5SDimitry Andric}
6450b57cec5SDimitry Andric
6460b57cec5SDimitry Andricclass InstRXb<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
6470b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
6480b57cec5SDimitry Andric  field bits<32> Inst;
6490b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
6500b57cec5SDimitry Andric
6510b57cec5SDimitry Andric  bits<4> M1;
65206c3fb27SDimitry Andric  bits<4> X2;
65306c3fb27SDimitry Andric  bits<4> B2;
65406c3fb27SDimitry Andric  bits<12> D2;
6550b57cec5SDimitry Andric
6560b57cec5SDimitry Andric  let Inst{31-24} = op;
6570b57cec5SDimitry Andric  let Inst{23-20} = M1;
65806c3fb27SDimitry Andric  let Inst{19-16} = X2;
65906c3fb27SDimitry Andric  let Inst{15-12} = B2;
66006c3fb27SDimitry Andric  let Inst{11-0}  = D2;
6610b57cec5SDimitry Andric
6620b57cec5SDimitry Andric  let HasIndex = 1;
6630b57cec5SDimitry Andric}
6640b57cec5SDimitry Andric
6650b57cec5SDimitry Andricclass InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
6660b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
6670b57cec5SDimitry Andric  field bits<48> Inst;
6680b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
6690b57cec5SDimitry Andric
6700b57cec5SDimitry Andric  bits<4> R1;
67106c3fb27SDimitry Andric  bits<4> X2;
67206c3fb27SDimitry Andric  bits<4> B2;
67306c3fb27SDimitry Andric  bits<12> D2;
6740b57cec5SDimitry Andric  bits<4> M3;
6750b57cec5SDimitry Andric
6760b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
6770b57cec5SDimitry Andric  let Inst{39-36} = R1;
67806c3fb27SDimitry Andric  let Inst{35-32} = X2;
67906c3fb27SDimitry Andric  let Inst{31-28} = B2;
68006c3fb27SDimitry Andric  let Inst{27-16} = D2;
6810b57cec5SDimitry Andric  let Inst{15-12} = M3;
6820b57cec5SDimitry Andric  let Inst{11-8}  = 0;
6830b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
6840b57cec5SDimitry Andric
6850b57cec5SDimitry Andric  let HasIndex = 1;
6860b57cec5SDimitry Andric}
6870b57cec5SDimitry Andric
6880b57cec5SDimitry Andricclass InstRXF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
6890b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
6900b57cec5SDimitry Andric  field bits<48> Inst;
6910b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
6920b57cec5SDimitry Andric
6930b57cec5SDimitry Andric  bits<4> R1;
6940b57cec5SDimitry Andric  bits<4> R3;
69506c3fb27SDimitry Andric  bits<4> X2;
69606c3fb27SDimitry Andric  bits<4> B2;
69706c3fb27SDimitry Andric  bits<12> D2;
6980b57cec5SDimitry Andric
6990b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
7000b57cec5SDimitry Andric  let Inst{39-36} = R3;
70106c3fb27SDimitry Andric  let Inst{35-32} = X2;
70206c3fb27SDimitry Andric  let Inst{31-28} = B2;
70306c3fb27SDimitry Andric  let Inst{27-16} = D2;
7040b57cec5SDimitry Andric  let Inst{15-12} = R1;
7050b57cec5SDimitry Andric  let Inst{11-8}  = 0;
7060b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
7070b57cec5SDimitry Andric
7080b57cec5SDimitry Andric  let HasIndex = 1;
7090b57cec5SDimitry Andric}
7100b57cec5SDimitry Andric
7110b57cec5SDimitry Andricclass InstRXYa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
7120b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
7130b57cec5SDimitry Andric  field bits<48> Inst;
7140b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
7150b57cec5SDimitry Andric
7160b57cec5SDimitry Andric  bits<4> R1;
71706c3fb27SDimitry Andric  bits<4> X2;
71806c3fb27SDimitry Andric  bits<4> B2;
71906c3fb27SDimitry Andric  bits<20> D2;
7200b57cec5SDimitry Andric
7210b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
7220b57cec5SDimitry Andric  let Inst{39-36} = R1;
72306c3fb27SDimitry Andric  let Inst{35-32} = X2;
72406c3fb27SDimitry Andric  let Inst{31-28} = B2;
72506c3fb27SDimitry Andric  let Inst{27-16} = D2{11-0};
72606c3fb27SDimitry Andric  let Inst{15-8}  = D2{19-12};
7270b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
7280b57cec5SDimitry Andric
7290b57cec5SDimitry Andric  let Has20BitOffset = 1;
7300b57cec5SDimitry Andric  let HasIndex = 1;
7310b57cec5SDimitry Andric}
7320b57cec5SDimitry Andric
7330b57cec5SDimitry Andricclass InstRXYb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
7340b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
7350b57cec5SDimitry Andric  field bits<48> Inst;
7360b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
7370b57cec5SDimitry Andric
7380b57cec5SDimitry Andric  bits<4> M1;
73906c3fb27SDimitry Andric  bits<4> X2;
74006c3fb27SDimitry Andric  bits<4> B2;
74106c3fb27SDimitry Andric  bits<20> D2;
7420b57cec5SDimitry Andric
7430b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
7440b57cec5SDimitry Andric  let Inst{39-36} = M1;
74506c3fb27SDimitry Andric  let Inst{35-32} = X2;
74606c3fb27SDimitry Andric  let Inst{31-28} = B2;
74706c3fb27SDimitry Andric  let Inst{27-16} = D2{11-0};
74806c3fb27SDimitry Andric  let Inst{15-8}  = D2{19-12};
7490b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
7500b57cec5SDimitry Andric
7510b57cec5SDimitry Andric  let Has20BitOffset = 1;
7520b57cec5SDimitry Andric  let HasIndex = 1;
7530b57cec5SDimitry Andric}
7540b57cec5SDimitry Andric
7550b57cec5SDimitry Andricclass InstRSa<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
7560b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
7570b57cec5SDimitry Andric  field bits<32> Inst;
7580b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
7590b57cec5SDimitry Andric
7600b57cec5SDimitry Andric  bits<4> R1;
7610b57cec5SDimitry Andric  bits<4> R3;
76206c3fb27SDimitry Andric  bits<4> B2;
76306c3fb27SDimitry Andric  bits<12> D2;
7640b57cec5SDimitry Andric
7650b57cec5SDimitry Andric  let Inst{31-24} = op;
7660b57cec5SDimitry Andric  let Inst{23-20} = R1;
7670b57cec5SDimitry Andric  let Inst{19-16} = R3;
76806c3fb27SDimitry Andric  let Inst{15-12} = B2;
76906c3fb27SDimitry Andric  let Inst{11-0}  = D2;
7700b57cec5SDimitry Andric}
7710b57cec5SDimitry Andric
7720b57cec5SDimitry Andricclass InstRSb<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
7730b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
7740b57cec5SDimitry Andric  field bits<32> Inst;
7750b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
7760b57cec5SDimitry Andric
7770b57cec5SDimitry Andric  bits<4> R1;
7780b57cec5SDimitry Andric  bits<4> M3;
77906c3fb27SDimitry Andric  bits<4> B2;
78006c3fb27SDimitry Andric  bits<12> D2;
7810b57cec5SDimitry Andric
7820b57cec5SDimitry Andric  let Inst{31-24} = op;
7830b57cec5SDimitry Andric  let Inst{23-20} = R1;
7840b57cec5SDimitry Andric  let Inst{19-16} = M3;
78506c3fb27SDimitry Andric  let Inst{15-12} = B2;
78606c3fb27SDimitry Andric  let Inst{11-0}  = D2;
78706c3fb27SDimitry Andric}
78806c3fb27SDimitry Andric
78906c3fb27SDimitry Andricclass InstRSEa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
79006c3fb27SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
79106c3fb27SDimitry Andric  field bits<48> Inst;
79206c3fb27SDimitry Andric  field bits<48> SoftFail = 0;
79306c3fb27SDimitry Andric
79406c3fb27SDimitry Andric  bits<4> R1;
79506c3fb27SDimitry Andric  bits<4> R3;
79606c3fb27SDimitry Andric  bits<4> B2;
79706c3fb27SDimitry Andric  bits<12> D2;
79806c3fb27SDimitry Andric
79906c3fb27SDimitry Andric  let Inst{47-40} = op{15-8};
80006c3fb27SDimitry Andric  let Inst{39-36} = R1;
80106c3fb27SDimitry Andric  let Inst{35-32} = R3;
80206c3fb27SDimitry Andric  let Inst{31-28} = B2;
80306c3fb27SDimitry Andric  let Inst{27-16} = D2;
80406c3fb27SDimitry Andric  let Inst{15-8}  = 0;
80506c3fb27SDimitry Andric  let Inst{7-0}   = op{7-0};
8060b57cec5SDimitry Andric}
8070b57cec5SDimitry Andric
8080b57cec5SDimitry Andricclass InstRSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
8090b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
8100b57cec5SDimitry Andric  field bits<32> Inst;
8110b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
8120b57cec5SDimitry Andric
8130b57cec5SDimitry Andric  bits<4> R1;
8140b57cec5SDimitry Andric  bits<4> R3;
8150b57cec5SDimitry Andric  bits<16> RI2;
8160b57cec5SDimitry Andric
8170b57cec5SDimitry Andric  let Inst{31-24} = op;
8180b57cec5SDimitry Andric  let Inst{23-20} = R1;
8190b57cec5SDimitry Andric  let Inst{19-16} = R3;
8200b57cec5SDimitry Andric  let Inst{15-0}  = RI2;
8210b57cec5SDimitry Andric}
8220b57cec5SDimitry Andric
8230b57cec5SDimitry Andricclass InstRSLa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
8240b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
8250b57cec5SDimitry Andric  field bits<48> Inst;
8260b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
8270b57cec5SDimitry Andric
82806c3fb27SDimitry Andric  bits<4> B1;
82906c3fb27SDimitry Andric  bits<12> D1;
83006c3fb27SDimitry Andric  bits<4> L1;
8310b57cec5SDimitry Andric
8320b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
83306c3fb27SDimitry Andric  let Inst{39-36} = L1;
8340b57cec5SDimitry Andric  let Inst{35-32} = 0;
83506c3fb27SDimitry Andric  let Inst{31-28} = B1;
83606c3fb27SDimitry Andric  let Inst{27-16} = D1;
8370b57cec5SDimitry Andric  let Inst{15-8}  = 0;
8380b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
8390b57cec5SDimitry Andric}
8400b57cec5SDimitry Andric
8410b57cec5SDimitry Andricclass InstRSLb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
8420b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
8430b57cec5SDimitry Andric  field bits<48> Inst;
8440b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
8450b57cec5SDimitry Andric
8460b57cec5SDimitry Andric  bits<4> R1;
84706c3fb27SDimitry Andric  bits<4> B2;
84806c3fb27SDimitry Andric  bits<12> D2;
84906c3fb27SDimitry Andric  bits<8> L2;
8500b57cec5SDimitry Andric  bits<4> M3;
8510b57cec5SDimitry Andric
8520b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
85306c3fb27SDimitry Andric  let Inst{39-32} = L2;
85406c3fb27SDimitry Andric  let Inst{31-28} = B2;
85506c3fb27SDimitry Andric  let Inst{27-16} = D2;
8560b57cec5SDimitry Andric  let Inst{15-12} = R1;
8570b57cec5SDimitry Andric  let Inst{11-8}  = M3;
8580b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
8590b57cec5SDimitry Andric}
8600b57cec5SDimitry Andric
8610b57cec5SDimitry Andricclass InstRSYa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
8620b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
8630b57cec5SDimitry Andric  field bits<48> Inst;
8640b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
8650b57cec5SDimitry Andric
8660b57cec5SDimitry Andric  bits<4> R1;
8670b57cec5SDimitry Andric  bits<4> R3;
86806c3fb27SDimitry Andric  bits<4> B2;
86906c3fb27SDimitry Andric  bits<20> D2;
8700b57cec5SDimitry Andric
8710b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
8720b57cec5SDimitry Andric  let Inst{39-36} = R1;
8730b57cec5SDimitry Andric  let Inst{35-32} = R3;
87406c3fb27SDimitry Andric  let Inst{31-28} = B2;
87506c3fb27SDimitry Andric  let Inst{27-16} = D2{11-0};
87606c3fb27SDimitry Andric  let Inst{15-8}  = D2{19-12};
8770b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
8780b57cec5SDimitry Andric
8790b57cec5SDimitry Andric  let Has20BitOffset = 1;
8800b57cec5SDimitry Andric}
8810b57cec5SDimitry Andric
8820b57cec5SDimitry Andricclass InstRSYb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
8830b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
8840b57cec5SDimitry Andric  field bits<48> Inst;
8850b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
8860b57cec5SDimitry Andric
8870b57cec5SDimitry Andric  bits<4> R1;
8880b57cec5SDimitry Andric  bits<4> M3;
88906c3fb27SDimitry Andric  bits<4> B2;
89006c3fb27SDimitry Andric  bits<20> D2;
8910b57cec5SDimitry Andric
8920b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
8930b57cec5SDimitry Andric  let Inst{39-36} = R1;
8940b57cec5SDimitry Andric  let Inst{35-32} = M3;
89506c3fb27SDimitry Andric  let Inst{31-28} = B2;
89606c3fb27SDimitry Andric  let Inst{27-16} = D2{11-0};
89706c3fb27SDimitry Andric  let Inst{15-8}  = D2{19-12};
8980b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
8990b57cec5SDimitry Andric
9000b57cec5SDimitry Andric  let Has20BitOffset = 1;
9010b57cec5SDimitry Andric}
9020b57cec5SDimitry Andric
9030b57cec5SDimitry Andricclass InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
9040b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
9050b57cec5SDimitry Andric  field bits<32> Inst;
9060b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
9070b57cec5SDimitry Andric
90806c3fb27SDimitry Andric  bits<4> B1;
90906c3fb27SDimitry Andric  bits<12> D1;
9100b57cec5SDimitry Andric  bits<8> I2;
9110b57cec5SDimitry Andric
9120b57cec5SDimitry Andric  let Inst{31-24} = op;
9130b57cec5SDimitry Andric  let Inst{23-16} = I2;
91406c3fb27SDimitry Andric  let Inst{15-12} = B1;
91506c3fb27SDimitry Andric  let Inst{11-0}  = D1;
9160b57cec5SDimitry Andric}
9170b57cec5SDimitry Andric
9180b57cec5SDimitry Andricclass InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
9190b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
9200b57cec5SDimitry Andric  field bits<48> Inst;
9210b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
9220b57cec5SDimitry Andric
92306c3fb27SDimitry Andric  bits<4> B1;
92406c3fb27SDimitry Andric  bits<12> D1;
9250b57cec5SDimitry Andric  bits<16> I2;
9260b57cec5SDimitry Andric
9270b57cec5SDimitry Andric  let Inst{47-32} = op;
92806c3fb27SDimitry Andric  let Inst{31-28} = B1;
92906c3fb27SDimitry Andric  let Inst{27-16} = D1;
9300b57cec5SDimitry Andric  let Inst{15-0}  = I2;
9310b57cec5SDimitry Andric}
9320b57cec5SDimitry Andric
9330b57cec5SDimitry Andricclass InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
9340b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
9350b57cec5SDimitry Andric  field bits<48> Inst;
9360b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
9370b57cec5SDimitry Andric
93806c3fb27SDimitry Andric  bits<4> B1;
93906c3fb27SDimitry Andric  bits<20> D1;
9400b57cec5SDimitry Andric  bits<8> I2;
9410b57cec5SDimitry Andric
9420b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
9430b57cec5SDimitry Andric  let Inst{39-32} = I2;
94406c3fb27SDimitry Andric  let Inst{31-28} = B1;
94506c3fb27SDimitry Andric  let Inst{27-16} = D1{11-0};
94606c3fb27SDimitry Andric  let Inst{15-8}  = D1{19-12};
9470b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
9480b57cec5SDimitry Andric
9490b57cec5SDimitry Andric  let Has20BitOffset = 1;
9500b57cec5SDimitry Andric}
9510b57cec5SDimitry Andric
9520b57cec5SDimitry Andricclass InstSMI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
9530b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
9540b57cec5SDimitry Andric  field bits<48> Inst;
9550b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
9560b57cec5SDimitry Andric
9570b57cec5SDimitry Andric  bits<4> M1;
9580b57cec5SDimitry Andric  bits<16> RI2;
95906c3fb27SDimitry Andric  bits<4> B3;
96006c3fb27SDimitry Andric  bits<12> D3;
9610b57cec5SDimitry Andric
9620b57cec5SDimitry Andric  let Inst{47-40} = op;
9630b57cec5SDimitry Andric  let Inst{39-36} = M1;
9640b57cec5SDimitry Andric  let Inst{35-32} = 0;
96506c3fb27SDimitry Andric  let Inst{31-28} = B3;
96606c3fb27SDimitry Andric  let Inst{27-16} = D3;
9670b57cec5SDimitry Andric  let Inst{15-0}  = RI2;
9680b57cec5SDimitry Andric}
9690b57cec5SDimitry Andric
9700b57cec5SDimitry Andricclass InstSSa<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
9710b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
9720b57cec5SDimitry Andric  field bits<48> Inst;
9730b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
9740b57cec5SDimitry Andric
97506c3fb27SDimitry Andric  bits<4> B1;
97606c3fb27SDimitry Andric  bits<12> D1;
97706c3fb27SDimitry Andric  bits<8> L1;
97806c3fb27SDimitry Andric  bits<4> B2;
97906c3fb27SDimitry Andric  bits<12> D2;
9800b57cec5SDimitry Andric
9810b57cec5SDimitry Andric  let Inst{47-40} = op;
98206c3fb27SDimitry Andric  let Inst{39-32} = L1;
98306c3fb27SDimitry Andric  let Inst{31-28} = B1;
98406c3fb27SDimitry Andric  let Inst{27-16} = D1;
98506c3fb27SDimitry Andric  let Inst{15-12} = B2;
98606c3fb27SDimitry Andric  let Inst{11-0}  = D2;
9870b57cec5SDimitry Andric}
9880b57cec5SDimitry Andric
9890b57cec5SDimitry Andricclass InstSSb<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
9900b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
9910b57cec5SDimitry Andric  field bits<48> Inst;
9920b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
9930b57cec5SDimitry Andric
99406c3fb27SDimitry Andric  bits<4> B1;
99506c3fb27SDimitry Andric  bits<12> D1;
99606c3fb27SDimitry Andric  bits<4> L1;
99706c3fb27SDimitry Andric  bits<4> B2;
99806c3fb27SDimitry Andric  bits<12> D2;
99906c3fb27SDimitry Andric  bits<4> L2;
10000b57cec5SDimitry Andric
10010b57cec5SDimitry Andric  let Inst{47-40} = op;
100206c3fb27SDimitry Andric  let Inst{39-36} = L1;
100306c3fb27SDimitry Andric  let Inst{35-32} = L2;
100406c3fb27SDimitry Andric  let Inst{31-28} = B1;
100506c3fb27SDimitry Andric  let Inst{27-16} = D1;
100606c3fb27SDimitry Andric  let Inst{15-12} = B2;
100706c3fb27SDimitry Andric  let Inst{11-0} = D2;
10080b57cec5SDimitry Andric}
10090b57cec5SDimitry Andric
10100b57cec5SDimitry Andricclass InstSSc<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
10110b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
10120b57cec5SDimitry Andric  field bits<48> Inst;
10130b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
10140b57cec5SDimitry Andric
101506c3fb27SDimitry Andric  bits<4> B1;
101606c3fb27SDimitry Andric  bits<12> D1;
101706c3fb27SDimitry Andric  bits<4> L1;
101806c3fb27SDimitry Andric  bits<4> B2;
101906c3fb27SDimitry Andric  bits<12> D2;
10200b57cec5SDimitry Andric  bits<4> I3;
10210b57cec5SDimitry Andric
10220b57cec5SDimitry Andric  let Inst{47-40} = op;
102306c3fb27SDimitry Andric  let Inst{39-36} = L1;
10240b57cec5SDimitry Andric  let Inst{35-32} = I3;
102506c3fb27SDimitry Andric  let Inst{31-28} = B1;
102606c3fb27SDimitry Andric  let Inst{27-16} = D1;
102706c3fb27SDimitry Andric  let Inst{15-12} = B2;
102806c3fb27SDimitry Andric  let Inst{11-0}  = D2;
10290b57cec5SDimitry Andric}
10300b57cec5SDimitry Andric
10310b57cec5SDimitry Andricclass InstSSd<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
10320b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
10330b57cec5SDimitry Andric  field bits<48> Inst;
10340b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
10350b57cec5SDimitry Andric
103606c3fb27SDimitry Andric  bits<4> R1;
103706c3fb27SDimitry Andric  bits<4> B1;
103806c3fb27SDimitry Andric  bits<12> D1;
103906c3fb27SDimitry Andric  bits<4> B2;
104006c3fb27SDimitry Andric  bits<12> D2;
10410b57cec5SDimitry Andric  bits<4> R3;
10420b57cec5SDimitry Andric
10430b57cec5SDimitry Andric  let Inst{47-40} = op;
104406c3fb27SDimitry Andric  let Inst{39-36} = R1;
10450b57cec5SDimitry Andric  let Inst{35-32} = R3;
104606c3fb27SDimitry Andric  let Inst{31-28} = B1;
104706c3fb27SDimitry Andric  let Inst{27-16} = D1;
104806c3fb27SDimitry Andric  let Inst{15-12} = B2;
104906c3fb27SDimitry Andric  let Inst{11-0}  = D2;
10500b57cec5SDimitry Andric}
10510b57cec5SDimitry Andric
10520b57cec5SDimitry Andricclass InstSSe<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
10530b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
10540b57cec5SDimitry Andric  field bits<48> Inst;
10550b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
10560b57cec5SDimitry Andric
10570b57cec5SDimitry Andric  bits<4> R1;
105806c3fb27SDimitry Andric  bits<4> B2;
105906c3fb27SDimitry Andric  bits<12> D2;
10600b57cec5SDimitry Andric  bits<4> R3;
106106c3fb27SDimitry Andric  bits<4> B4;
106206c3fb27SDimitry Andric  bits<12> D4;
10630b57cec5SDimitry Andric
10640b57cec5SDimitry Andric  let Inst{47-40} = op;
10650b57cec5SDimitry Andric  let Inst{39-36} = R1;
10660b57cec5SDimitry Andric  let Inst{35-32} = R3;
106706c3fb27SDimitry Andric  let Inst{31-28} = B2;
106806c3fb27SDimitry Andric  let Inst{27-16} = D2;
106906c3fb27SDimitry Andric  let Inst{15-12} = B4;
107006c3fb27SDimitry Andric  let Inst{11-0}  = D4;
10710b57cec5SDimitry Andric}
10720b57cec5SDimitry Andric
10730b57cec5SDimitry Andricclass InstSSf<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
10740b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
10750b57cec5SDimitry Andric  field bits<48> Inst;
10760b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
10770b57cec5SDimitry Andric
107806c3fb27SDimitry Andric  bits<4> B1;
107906c3fb27SDimitry Andric  bits<12> D1;
108006c3fb27SDimitry Andric  bits<4> B2;
108106c3fb27SDimitry Andric  bits<12> D2;
108206c3fb27SDimitry Andric  bits<8> L2;
10830b57cec5SDimitry Andric
10840b57cec5SDimitry Andric  let Inst{47-40} = op;
108506c3fb27SDimitry Andric  let Inst{39-32} = L2;
108606c3fb27SDimitry Andric  let Inst{31-28} = B1;
108706c3fb27SDimitry Andric  let Inst{27-16} = D1;
108806c3fb27SDimitry Andric  let Inst{15-12} = B2;
108906c3fb27SDimitry Andric  let Inst{11-0}  = D2;
10900b57cec5SDimitry Andric}
10910b57cec5SDimitry Andric
10920b57cec5SDimitry Andricclass InstSSE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
10930b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
10940b57cec5SDimitry Andric  field bits<48> Inst;
10950b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
10960b57cec5SDimitry Andric
109706c3fb27SDimitry Andric  bits<4> B1;
109806c3fb27SDimitry Andric  bits<12> D1;
109906c3fb27SDimitry Andric  bits<4> B2;
110006c3fb27SDimitry Andric  bits<12> D2;
11010b57cec5SDimitry Andric
11020b57cec5SDimitry Andric  let Inst{47-32} = op;
110306c3fb27SDimitry Andric  let Inst{31-28} = B1;
110406c3fb27SDimitry Andric  let Inst{27-16} = D1;
110506c3fb27SDimitry Andric  let Inst{15-12} = B2;
110606c3fb27SDimitry Andric  let Inst{11-0}  = D2;
11070b57cec5SDimitry Andric}
11080b57cec5SDimitry Andric
11090b57cec5SDimitry Andricclass InstSSF<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
11100b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
11110b57cec5SDimitry Andric  field bits<48> Inst;
11120b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
11130b57cec5SDimitry Andric
111406c3fb27SDimitry Andric  bits<4> B1;
111506c3fb27SDimitry Andric  bits<12> D1;
111606c3fb27SDimitry Andric  bits<4> B2;
111706c3fb27SDimitry Andric  bits<12> D2;
11180b57cec5SDimitry Andric  bits<4>  R3;
11190b57cec5SDimitry Andric
11200b57cec5SDimitry Andric  let Inst{47-40} = op{11-4};
11210b57cec5SDimitry Andric  let Inst{39-36} = R3;
11220b57cec5SDimitry Andric  let Inst{35-32} = op{3-0};
112306c3fb27SDimitry Andric  let Inst{31-28} = B1;
112406c3fb27SDimitry Andric  let Inst{27-16} = D1;
112506c3fb27SDimitry Andric  let Inst{15-12} = B2;
112606c3fb27SDimitry Andric  let Inst{11-0}  = D2;
11270b57cec5SDimitry Andric}
11280b57cec5SDimitry Andric
11290b57cec5SDimitry Andricclass InstS<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
11300b57cec5SDimitry Andric  : InstSystemZ<4, outs, ins, asmstr, pattern> {
11310b57cec5SDimitry Andric  field bits<32> Inst;
11320b57cec5SDimitry Andric  field bits<32> SoftFail = 0;
11330b57cec5SDimitry Andric
113406c3fb27SDimitry Andric  bits<4> B2;
113506c3fb27SDimitry Andric  bits<12> D2;
11360b57cec5SDimitry Andric
11370b57cec5SDimitry Andric  let Inst{31-16} = op;
113806c3fb27SDimitry Andric  let Inst{15-12} = B2;
113906c3fb27SDimitry Andric  let Inst{11-0}  = D2;
11400b57cec5SDimitry Andric}
11410b57cec5SDimitry Andric
11420b57cec5SDimitry Andricclass InstVRIa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
11430b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
11440b57cec5SDimitry Andric  field bits<48> Inst;
11450b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
11460b57cec5SDimitry Andric
11470b57cec5SDimitry Andric  bits<5> V1;
11480b57cec5SDimitry Andric  bits<16> I2;
11490b57cec5SDimitry Andric  bits<4> M3;
11500b57cec5SDimitry Andric
11510b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
11520b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
11530b57cec5SDimitry Andric  let Inst{35-32} = 0;
11540b57cec5SDimitry Andric  let Inst{31-16} = I2;
11550b57cec5SDimitry Andric  let Inst{15-12} = M3;
11560b57cec5SDimitry Andric  let Inst{11}    = V1{4};
11570b57cec5SDimitry Andric  let Inst{10-8}  = 0;
11580b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
11590b57cec5SDimitry Andric}
11600b57cec5SDimitry Andric
11610b57cec5SDimitry Andricclass InstVRIb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
11620b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
11630b57cec5SDimitry Andric  field bits<48> Inst;
11640b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
11650b57cec5SDimitry Andric
11660b57cec5SDimitry Andric  bits<5> V1;
11670b57cec5SDimitry Andric  bits<8> I2;
11680b57cec5SDimitry Andric  bits<8> I3;
11690b57cec5SDimitry Andric  bits<4> M4;
11700b57cec5SDimitry Andric
11710b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
11720b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
11730b57cec5SDimitry Andric  let Inst{35-32} = 0;
11740b57cec5SDimitry Andric  let Inst{31-24} = I2;
11750b57cec5SDimitry Andric  let Inst{23-16} = I3;
11760b57cec5SDimitry Andric  let Inst{15-12} = M4;
11770b57cec5SDimitry Andric  let Inst{11}    = V1{4};
11780b57cec5SDimitry Andric  let Inst{10-8}  = 0;
11790b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
11800b57cec5SDimitry Andric}
11810b57cec5SDimitry Andric
11820b57cec5SDimitry Andricclass InstVRIc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
11830b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
11840b57cec5SDimitry Andric  field bits<48> Inst;
11850b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
11860b57cec5SDimitry Andric
11870b57cec5SDimitry Andric  bits<5> V1;
11880b57cec5SDimitry Andric  bits<5> V3;
11890b57cec5SDimitry Andric  bits<16> I2;
11900b57cec5SDimitry Andric  bits<4> M4;
11910b57cec5SDimitry Andric
11920b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
11930b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
11940b57cec5SDimitry Andric  let Inst{35-32} = V3{3-0};
11950b57cec5SDimitry Andric  let Inst{31-16} = I2;
11960b57cec5SDimitry Andric  let Inst{15-12} = M4;
11970b57cec5SDimitry Andric  let Inst{11}    = V1{4};
11980b57cec5SDimitry Andric  let Inst{10}    = V3{4};
11990b57cec5SDimitry Andric  let Inst{9-8}   = 0;
12000b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
12010b57cec5SDimitry Andric}
12020b57cec5SDimitry Andric
12030b57cec5SDimitry Andricclass InstVRId<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
12040b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
12050b57cec5SDimitry Andric  field bits<48> Inst;
12060b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
12070b57cec5SDimitry Andric
12080b57cec5SDimitry Andric  bits<5> V1;
12090b57cec5SDimitry Andric  bits<5> V2;
12100b57cec5SDimitry Andric  bits<5> V3;
12110b57cec5SDimitry Andric  bits<8> I4;
12120b57cec5SDimitry Andric  bits<4> M5;
12130b57cec5SDimitry Andric
12140b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
12150b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
12160b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
12170b57cec5SDimitry Andric  let Inst{31-28} = V3{3-0};
12180b57cec5SDimitry Andric  let Inst{27-24} = 0;
12190b57cec5SDimitry Andric  let Inst{23-16} = I4;
12200b57cec5SDimitry Andric  let Inst{15-12} = M5;
12210b57cec5SDimitry Andric  let Inst{11}    = V1{4};
12220b57cec5SDimitry Andric  let Inst{10}    = V2{4};
12230b57cec5SDimitry Andric  let Inst{9}     = V3{4};
12240b57cec5SDimitry Andric  let Inst{8}     = 0;
12250b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
12260b57cec5SDimitry Andric}
12270b57cec5SDimitry Andric
12280b57cec5SDimitry Andricclass InstVRIe<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
12290b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
12300b57cec5SDimitry Andric  field bits<48> Inst;
12310b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
12320b57cec5SDimitry Andric
12330b57cec5SDimitry Andric  bits<5> V1;
12340b57cec5SDimitry Andric  bits<5> V2;
12350b57cec5SDimitry Andric  bits<12> I3;
12360b57cec5SDimitry Andric  bits<4> M4;
12370b57cec5SDimitry Andric  bits<4> M5;
12380b57cec5SDimitry Andric
12390b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
12400b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
12410b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
12420b57cec5SDimitry Andric  let Inst{31-20} = I3;
12430b57cec5SDimitry Andric  let Inst{19-16} = M5;
12440b57cec5SDimitry Andric  let Inst{15-12} = M4;
12450b57cec5SDimitry Andric  let Inst{11}    = V1{4};
12460b57cec5SDimitry Andric  let Inst{10}    = V2{4};
12470b57cec5SDimitry Andric  let Inst{9-8}   = 0;
12480b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
12490b57cec5SDimitry Andric}
12500b57cec5SDimitry Andric
12510b57cec5SDimitry Andricclass InstVRIf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
12520b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
12530b57cec5SDimitry Andric  field bits<48> Inst;
12540b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
12550b57cec5SDimitry Andric
12560b57cec5SDimitry Andric  bits<5> V1;
12570b57cec5SDimitry Andric  bits<5> V2;
12580b57cec5SDimitry Andric  bits<5> V3;
12590b57cec5SDimitry Andric  bits<8> I4;
12600b57cec5SDimitry Andric  bits<4> M5;
12610b57cec5SDimitry Andric
12620b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
12630b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
12640b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
12650b57cec5SDimitry Andric  let Inst{31-28} = V3{3-0};
12660b57cec5SDimitry Andric  let Inst{27-24} = 0;
12670b57cec5SDimitry Andric  let Inst{23-20} = M5;
12680b57cec5SDimitry Andric  let Inst{19-12} = I4;
12690b57cec5SDimitry Andric  let Inst{11}    = V1{4};
12700b57cec5SDimitry Andric  let Inst{10}    = V2{4};
12710b57cec5SDimitry Andric  let Inst{9}     = V3{4};
12720b57cec5SDimitry Andric  let Inst{8}     = 0;
12730b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
12740b57cec5SDimitry Andric}
12750b57cec5SDimitry Andric
12760b57cec5SDimitry Andricclass InstVRIg<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
12770b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
12780b57cec5SDimitry Andric  field bits<48> Inst;
12790b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
12800b57cec5SDimitry Andric
12810b57cec5SDimitry Andric  bits<5> V1;
12820b57cec5SDimitry Andric  bits<5> V2;
12830b57cec5SDimitry Andric  bits<8> I3;
12840b57cec5SDimitry Andric  bits<8> I4;
12850b57cec5SDimitry Andric  bits<4> M5;
12860b57cec5SDimitry Andric
12870b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
12880b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
12890b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
12900b57cec5SDimitry Andric  let Inst{31-24} = I4;
12910b57cec5SDimitry Andric  let Inst{23-20} = M5;
12920b57cec5SDimitry Andric  let Inst{19-12} = I3;
12930b57cec5SDimitry Andric  let Inst{11}    = V1{4};
12940b57cec5SDimitry Andric  let Inst{10}    = V2{4};
12950b57cec5SDimitry Andric  let Inst{9-8}   = 0;
12960b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
12970b57cec5SDimitry Andric}
12980b57cec5SDimitry Andric
12990b57cec5SDimitry Andricclass InstVRIh<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
13000b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
13010b57cec5SDimitry Andric  field bits<48> Inst;
13020b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
13030b57cec5SDimitry Andric
13040b57cec5SDimitry Andric  bits<5> V1;
13050b57cec5SDimitry Andric  bits<16> I2;
13060b57cec5SDimitry Andric  bits<4> I3;
13070b57cec5SDimitry Andric
13080b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
13090b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
13100b57cec5SDimitry Andric  let Inst{35-32} = 0;
13110b57cec5SDimitry Andric  let Inst{31-16} = I2;
13120b57cec5SDimitry Andric  let Inst{15-12} = I3;
13130b57cec5SDimitry Andric  let Inst{11}    = V1{4};
13140b57cec5SDimitry Andric  let Inst{10-8}  = 0;
13150b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
13160b57cec5SDimitry Andric}
13170b57cec5SDimitry Andric
13180b57cec5SDimitry Andricclass InstVRIi<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
13190b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
13200b57cec5SDimitry Andric  field bits<48> Inst;
13210b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
13220b57cec5SDimitry Andric
13230b57cec5SDimitry Andric  bits<5> V1;
13240b57cec5SDimitry Andric  bits<4> R2;
13250b57cec5SDimitry Andric  bits<8> I3;
13260b57cec5SDimitry Andric  bits<4> M4;
13270b57cec5SDimitry Andric
13280b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
13290b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
13300b57cec5SDimitry Andric  let Inst{35-32} = R2;
13310b57cec5SDimitry Andric  let Inst{31-24} = 0;
13320b57cec5SDimitry Andric  let Inst{23-20} = M4;
13330b57cec5SDimitry Andric  let Inst{19-12} = I3;
13340b57cec5SDimitry Andric  let Inst{11}    = V1{4};
13350b57cec5SDimitry Andric  let Inst{10-8}  = 0;
13360b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
13370b57cec5SDimitry Andric}
13380b57cec5SDimitry Andric
13390b57cec5SDimitry Andric// Depending on the instruction mnemonic, certain bits may be or-ed into
13400b57cec5SDimitry Andric// the M4 value provided as explicit operand.  These are passed as m4or.
13410b57cec5SDimitry Andricclass InstVRRa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern,
13420b57cec5SDimitry Andric               bits<4> m4or = 0>
13430b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
13440b57cec5SDimitry Andric  field bits<48> Inst;
13450b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
13460b57cec5SDimitry Andric
13470b57cec5SDimitry Andric  bits<5> V1;
13480b57cec5SDimitry Andric  bits<5> V2;
13490b57cec5SDimitry Andric  bits<4> M3;
13500b57cec5SDimitry Andric  bits<4> M4;
13510b57cec5SDimitry Andric  bits<4> M5;
13520b57cec5SDimitry Andric
13530b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
13540b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
13550b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
13560b57cec5SDimitry Andric  let Inst{31-24} = 0;
13570b57cec5SDimitry Andric  let Inst{23-20} = M5;
13580b57cec5SDimitry Andric  let Inst{19}    = !if (!eq (m4or{3}, 1), 1, M4{3});
13590b57cec5SDimitry Andric  let Inst{18}    = !if (!eq (m4or{2}, 1), 1, M4{2});
13600b57cec5SDimitry Andric  let Inst{17}    = !if (!eq (m4or{1}, 1), 1, M4{1});
13610b57cec5SDimitry Andric  let Inst{16}    = !if (!eq (m4or{0}, 1), 1, M4{0});
13620b57cec5SDimitry Andric  let Inst{15-12} = M3;
13630b57cec5SDimitry Andric  let Inst{11}    = V1{4};
13640b57cec5SDimitry Andric  let Inst{10}    = V2{4};
13650b57cec5SDimitry Andric  let Inst{9-8}   = 0;
13660b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
13670b57cec5SDimitry Andric}
13680b57cec5SDimitry Andric
13690b57cec5SDimitry Andric// Depending on the instruction mnemonic, certain bits may be or-ed into
13700b57cec5SDimitry Andric// the M5 value provided as explicit operand.  These are passed as m5or.
13710b57cec5SDimitry Andricclass InstVRRb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern,
13720b57cec5SDimitry Andric               bits<4> m5or = 0>
13730b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
13740b57cec5SDimitry Andric  field bits<48> Inst;
13750b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
13760b57cec5SDimitry Andric
13770b57cec5SDimitry Andric  bits<5> V1;
13780b57cec5SDimitry Andric  bits<5> V2;
13790b57cec5SDimitry Andric  bits<5> V3;
13800b57cec5SDimitry Andric  bits<4> M4;
13810b57cec5SDimitry Andric  bits<4> M5;
13820b57cec5SDimitry Andric
13830b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
13840b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
13850b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
13860b57cec5SDimitry Andric  let Inst{31-28} = V3{3-0};
13870b57cec5SDimitry Andric  let Inst{27-24} = 0;
13880b57cec5SDimitry Andric  let Inst{23}    = !if (!eq (m5or{3}, 1), 1, M5{3});
13890b57cec5SDimitry Andric  let Inst{22}    = !if (!eq (m5or{2}, 1), 1, M5{2});
13900b57cec5SDimitry Andric  let Inst{21}    = !if (!eq (m5or{1}, 1), 1, M5{1});
13910b57cec5SDimitry Andric  let Inst{20}    = !if (!eq (m5or{0}, 1), 1, M5{0});
13920b57cec5SDimitry Andric  let Inst{19-16} = 0;
13930b57cec5SDimitry Andric  let Inst{15-12} = M4;
13940b57cec5SDimitry Andric  let Inst{11}    = V1{4};
13950b57cec5SDimitry Andric  let Inst{10}    = V2{4};
13960b57cec5SDimitry Andric  let Inst{9}     = V3{4};
13970b57cec5SDimitry Andric  let Inst{8}     = 0;
13980b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
13990b57cec5SDimitry Andric}
14000b57cec5SDimitry Andric
14010b57cec5SDimitry Andricclass InstVRRc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
14020b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
14030b57cec5SDimitry Andric  field bits<48> Inst;
14040b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
14050b57cec5SDimitry Andric
14060b57cec5SDimitry Andric  bits<5> V1;
14070b57cec5SDimitry Andric  bits<5> V2;
14080b57cec5SDimitry Andric  bits<5> V3;
14090b57cec5SDimitry Andric  bits<4> M4;
14100b57cec5SDimitry Andric  bits<4> M5;
14110b57cec5SDimitry Andric  bits<4> M6;
14120b57cec5SDimitry Andric
14130b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
14140b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
14150b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
14160b57cec5SDimitry Andric  let Inst{31-28} = V3{3-0};
14170b57cec5SDimitry Andric  let Inst{27-24} = 0;
14180b57cec5SDimitry Andric  let Inst{23-20} = M6;
14190b57cec5SDimitry Andric  let Inst{19-16} = M5;
14200b57cec5SDimitry Andric  let Inst{15-12} = M4;
14210b57cec5SDimitry Andric  let Inst{11}    = V1{4};
14220b57cec5SDimitry Andric  let Inst{10}    = V2{4};
14230b57cec5SDimitry Andric  let Inst{9}     = V3{4};
14240b57cec5SDimitry Andric  let Inst{8}     = 0;
14250b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
14260b57cec5SDimitry Andric}
14270b57cec5SDimitry Andric
14280b57cec5SDimitry Andric// Depending on the instruction mnemonic, certain bits may be or-ed into
14290b57cec5SDimitry Andric// the M6 value provided as explicit operand.  These are passed as m6or.
14300b57cec5SDimitry Andricclass InstVRRd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern,
14310b57cec5SDimitry Andric               bits<4> m6or = 0>
14320b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
14330b57cec5SDimitry Andric  field bits<48> Inst;
14340b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
14350b57cec5SDimitry Andric
14360b57cec5SDimitry Andric  bits<5> V1;
14370b57cec5SDimitry Andric  bits<5> V2;
14380b57cec5SDimitry Andric  bits<5> V3;
14390b57cec5SDimitry Andric  bits<5> V4;
14400b57cec5SDimitry Andric  bits<4> M5;
14410b57cec5SDimitry Andric  bits<4> M6;
14420b57cec5SDimitry Andric
14430b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
14440b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
14450b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
14460b57cec5SDimitry Andric  let Inst{31-28} = V3{3-0};
14470b57cec5SDimitry Andric  let Inst{27-24} = M5;
14480b57cec5SDimitry Andric  let Inst{23}    = !if (!eq (m6or{3}, 1), 1, M6{3});
14490b57cec5SDimitry Andric  let Inst{22}    = !if (!eq (m6or{2}, 1), 1, M6{2});
14500b57cec5SDimitry Andric  let Inst{21}    = !if (!eq (m6or{1}, 1), 1, M6{1});
14510b57cec5SDimitry Andric  let Inst{20}    = !if (!eq (m6or{0}, 1), 1, M6{0});
14520b57cec5SDimitry Andric  let Inst{19-16} = 0;
14530b57cec5SDimitry Andric  let Inst{15-12} = V4{3-0};
14540b57cec5SDimitry Andric  let Inst{11}    = V1{4};
14550b57cec5SDimitry Andric  let Inst{10}    = V2{4};
14560b57cec5SDimitry Andric  let Inst{9}     = V3{4};
14570b57cec5SDimitry Andric  let Inst{8}     = V4{4};
14580b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
14590b57cec5SDimitry Andric}
14600b57cec5SDimitry Andric
14610b57cec5SDimitry Andricclass InstVRRe<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
14620b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
14630b57cec5SDimitry Andric  field bits<48> Inst;
14640b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
14650b57cec5SDimitry Andric
14660b57cec5SDimitry Andric  bits<5> V1;
14670b57cec5SDimitry Andric  bits<5> V2;
14680b57cec5SDimitry Andric  bits<5> V3;
14690b57cec5SDimitry Andric  bits<5> V4;
14700b57cec5SDimitry Andric  bits<4> M5;
14710b57cec5SDimitry Andric  bits<4> M6;
14720b57cec5SDimitry Andric
14730b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
14740b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
14750b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
14760b57cec5SDimitry Andric  let Inst{31-28} = V3{3-0};
14770b57cec5SDimitry Andric  let Inst{27-24} = M6;
14780b57cec5SDimitry Andric  let Inst{23-20} = 0;
14790b57cec5SDimitry Andric  let Inst{19-16} = M5;
14800b57cec5SDimitry Andric  let Inst{15-12} = V4{3-0};
14810b57cec5SDimitry Andric  let Inst{11}    = V1{4};
14820b57cec5SDimitry Andric  let Inst{10}    = V2{4};
14830b57cec5SDimitry Andric  let Inst{9}     = V3{4};
14840b57cec5SDimitry Andric  let Inst{8}     = V4{4};
14850b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
14860b57cec5SDimitry Andric}
14870b57cec5SDimitry Andric
14880b57cec5SDimitry Andricclass InstVRRf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
14890b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
14900b57cec5SDimitry Andric  field bits<48> Inst;
14910b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
14920b57cec5SDimitry Andric
14930b57cec5SDimitry Andric  bits<5> V1;
14940b57cec5SDimitry Andric  bits<4> R2;
14950b57cec5SDimitry Andric  bits<4> R3;
14960b57cec5SDimitry Andric
14970b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
14980b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
14990b57cec5SDimitry Andric  let Inst{35-32} = R2;
15000b57cec5SDimitry Andric  let Inst{31-28} = R3;
15010b57cec5SDimitry Andric  let Inst{27-12} = 0;
15020b57cec5SDimitry Andric  let Inst{11}    = V1{4};
15030b57cec5SDimitry Andric  let Inst{10-8}  = 0;
15040b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
15050b57cec5SDimitry Andric}
15060b57cec5SDimitry Andric
15070b57cec5SDimitry Andricclass InstVRRg<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
15080b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
15090b57cec5SDimitry Andric  field bits<48> Inst;
15100b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
15110b57cec5SDimitry Andric
15120b57cec5SDimitry Andric  bits<5> V1;
15130b57cec5SDimitry Andric
15140b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
15150b57cec5SDimitry Andric  let Inst{39-36} = 0;
15160b57cec5SDimitry Andric  let Inst{35-32} = V1{3-0};
15170b57cec5SDimitry Andric  let Inst{31-12} = 0;
15180b57cec5SDimitry Andric  let Inst{11}    = 0;
15190b57cec5SDimitry Andric  let Inst{10}    = V1{4};
15200b57cec5SDimitry Andric  let Inst{9-8}   = 0;
15210b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
15220b57cec5SDimitry Andric}
15230b57cec5SDimitry Andric
15240b57cec5SDimitry Andricclass InstVRRh<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
15250b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
15260b57cec5SDimitry Andric  field bits<48> Inst;
15270b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
15280b57cec5SDimitry Andric
15290b57cec5SDimitry Andric  bits<5> V1;
15300b57cec5SDimitry Andric  bits<5> V2;
15310b57cec5SDimitry Andric  bits<4> M3;
15320b57cec5SDimitry Andric
15330b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
15340b57cec5SDimitry Andric  let Inst{39-36} = 0;
15350b57cec5SDimitry Andric  let Inst{35-32} = V1{3-0};
15360b57cec5SDimitry Andric  let Inst{31-28} = V2{3-0};
15370b57cec5SDimitry Andric  let Inst{27-24} = 0;
15380b57cec5SDimitry Andric  let Inst{23-20} = M3;
15390b57cec5SDimitry Andric  let Inst{19-12} = 0;
15400b57cec5SDimitry Andric  let Inst{11}    = 0;
15410b57cec5SDimitry Andric  let Inst{10}    = V1{4};
15420b57cec5SDimitry Andric  let Inst{9}     = V2{4};
15430b57cec5SDimitry Andric  let Inst{8}     = 0;
15440b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
15450b57cec5SDimitry Andric}
15460b57cec5SDimitry Andric
15470b57cec5SDimitry Andricclass InstVRRi<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
15480b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
15490b57cec5SDimitry Andric  field bits<48> Inst;
15500b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
15510b57cec5SDimitry Andric
15520b57cec5SDimitry Andric  bits<4> R1;
15530b57cec5SDimitry Andric  bits<5> V2;
15540b57cec5SDimitry Andric  bits<4> M3;
15550b57cec5SDimitry Andric  bits<4> M4;
15560b57cec5SDimitry Andric
15570b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
15580b57cec5SDimitry Andric  let Inst{39-36} = R1;
15590b57cec5SDimitry Andric  let Inst{35-32} = V2{3-0};
15600b57cec5SDimitry Andric  let Inst{31-24} = 0;
15610b57cec5SDimitry Andric  let Inst{23-20} = M3;
15620b57cec5SDimitry Andric  let Inst{19-16} = M4;
15630b57cec5SDimitry Andric  let Inst{15-12} = 0;
15640b57cec5SDimitry Andric  let Inst{11}    = 0;
15650b57cec5SDimitry Andric  let Inst{10}    = V2{4};
15660b57cec5SDimitry Andric  let Inst{9-8}   = 0;
15670b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
15680b57cec5SDimitry Andric}
15690b57cec5SDimitry Andric
1570fe6060f1SDimitry Andricclass InstVRRj<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1571fe6060f1SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
1572fe6060f1SDimitry Andric  field bits<48> Inst;
1573fe6060f1SDimitry Andric  field bits<48> SoftFail = 0;
1574fe6060f1SDimitry Andric
1575fe6060f1SDimitry Andric  bits<5> V1;
1576fe6060f1SDimitry Andric  bits<5> V2;
1577fe6060f1SDimitry Andric  bits<5> V3;
1578fe6060f1SDimitry Andric  bits<4> M4;
1579fe6060f1SDimitry Andric
1580fe6060f1SDimitry Andric  let Inst{47-40} = op{15-8};
1581fe6060f1SDimitry Andric  let Inst{39-36} = V1{3-0};
1582fe6060f1SDimitry Andric  let Inst{35-32} = V2{3-0};
1583fe6060f1SDimitry Andric  let Inst{31-28} = V3{3-0};
1584fe6060f1SDimitry Andric  let Inst{27-24} = 0;
1585fe6060f1SDimitry Andric  let Inst{23-20} = M4;
1586fe6060f1SDimitry Andric  let Inst{19-16} = 0;
1587fe6060f1SDimitry Andric  let Inst{15-12} = 0;
1588fe6060f1SDimitry Andric  let Inst{11}    = V1{4};
1589fe6060f1SDimitry Andric  let Inst{10}    = V2{4};
1590fe6060f1SDimitry Andric  let Inst{9}     = V3{4};
1591fe6060f1SDimitry Andric  let Inst{8}     = 0;
1592fe6060f1SDimitry Andric  let Inst{7-0}   = op{7-0};
1593fe6060f1SDimitry Andric}
1594fe6060f1SDimitry Andric
1595fe6060f1SDimitry Andricclass InstVRRk<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1596fe6060f1SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
1597fe6060f1SDimitry Andric  field bits<48> Inst;
1598fe6060f1SDimitry Andric  field bits<48> SoftFail = 0;
1599fe6060f1SDimitry Andric
1600fe6060f1SDimitry Andric  bits<5> V1;
1601fe6060f1SDimitry Andric  bits<5> V2;
1602fe6060f1SDimitry Andric  bits<4> M3;
1603fe6060f1SDimitry Andric
1604fe6060f1SDimitry Andric  let Inst{47-40} = op{15-8};
1605fe6060f1SDimitry Andric  let Inst{39-36} = V1{3-0};
1606fe6060f1SDimitry Andric  let Inst{35-32} = V2{3-0};
1607fe6060f1SDimitry Andric  let Inst{31-28} = 0;
1608fe6060f1SDimitry Andric  let Inst{27-24} = 0;
1609fe6060f1SDimitry Andric  let Inst{23-20} = M3;
1610fe6060f1SDimitry Andric  let Inst{19-16} = 0;
1611fe6060f1SDimitry Andric  let Inst{15-12} = 0;
1612fe6060f1SDimitry Andric  let Inst{11}    = V1{4};
1613fe6060f1SDimitry Andric  let Inst{10}    = V2{4};
1614fe6060f1SDimitry Andric  let Inst{9}     = 0;
1615fe6060f1SDimitry Andric  let Inst{8}     = 0;
1616fe6060f1SDimitry Andric  let Inst{7-0}   = op{7-0};
1617fe6060f1SDimitry Andric}
1618fe6060f1SDimitry Andric
16190b57cec5SDimitry Andricclass InstVRSa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
16200b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
16210b57cec5SDimitry Andric  field bits<48> Inst;
16220b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
16230b57cec5SDimitry Andric
16240b57cec5SDimitry Andric  bits<5> V1;
162506c3fb27SDimitry Andric  bits<4> B2;
162606c3fb27SDimitry Andric  bits<12> D2;
16270b57cec5SDimitry Andric  bits<5> V3;
16280b57cec5SDimitry Andric  bits<4> M4;
16290b57cec5SDimitry Andric
16300b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
16310b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
16320b57cec5SDimitry Andric  let Inst{35-32} = V3{3-0};
163306c3fb27SDimitry Andric  let Inst{31-28} = B2;
163406c3fb27SDimitry Andric  let Inst{27-16} = D2;
16350b57cec5SDimitry Andric  let Inst{15-12} = M4;
16360b57cec5SDimitry Andric  let Inst{11}    = V1{4};
16370b57cec5SDimitry Andric  let Inst{10}    = V3{4};
16380b57cec5SDimitry Andric  let Inst{9-8}   = 0;
16390b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
16400b57cec5SDimitry Andric}
16410b57cec5SDimitry Andric
16420b57cec5SDimitry Andricclass InstVRSb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
16430b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
16440b57cec5SDimitry Andric  field bits<48> Inst;
16450b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
16460b57cec5SDimitry Andric
16470b57cec5SDimitry Andric  bits<5> V1;
164806c3fb27SDimitry Andric  bits<4> B2;
164906c3fb27SDimitry Andric  bits<12> D2;
16500b57cec5SDimitry Andric  bits<4> R3;
16510b57cec5SDimitry Andric  bits<4> M4;
16520b57cec5SDimitry Andric
16530b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
16540b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
16550b57cec5SDimitry Andric  let Inst{35-32} = R3;
165606c3fb27SDimitry Andric  let Inst{31-28} = B2;
165706c3fb27SDimitry Andric  let Inst{27-16} = D2;
16580b57cec5SDimitry Andric  let Inst{15-12} = M4;
16590b57cec5SDimitry Andric  let Inst{11}    = V1{4};
16600b57cec5SDimitry Andric  let Inst{10-8}  = 0;
16610b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
16620b57cec5SDimitry Andric}
16630b57cec5SDimitry Andric
16640b57cec5SDimitry Andricclass InstVRSc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
16650b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
16660b57cec5SDimitry Andric  field bits<48> Inst;
16670b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
16680b57cec5SDimitry Andric
16690b57cec5SDimitry Andric  bits<4> R1;
167006c3fb27SDimitry Andric  bits<4> B2;
167106c3fb27SDimitry Andric  bits<12> D2;
16720b57cec5SDimitry Andric  bits<5> V3;
16730b57cec5SDimitry Andric  bits<4> M4;
16740b57cec5SDimitry Andric
16750b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
16760b57cec5SDimitry Andric  let Inst{39-36} = R1;
16770b57cec5SDimitry Andric  let Inst{35-32} = V3{3-0};
167806c3fb27SDimitry Andric  let Inst{31-28} = B2;
167906c3fb27SDimitry Andric  let Inst{27-16} = D2;
16800b57cec5SDimitry Andric  let Inst{15-12} = M4;
16810b57cec5SDimitry Andric  let Inst{11}    = 0;
16820b57cec5SDimitry Andric  let Inst{10}    = V3{4};
16830b57cec5SDimitry Andric  let Inst{9-8}   = 0;
16840b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
16850b57cec5SDimitry Andric}
16860b57cec5SDimitry Andric
16870b57cec5SDimitry Andricclass InstVRSd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
16880b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
16890b57cec5SDimitry Andric  field bits<48> Inst;
16900b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
16910b57cec5SDimitry Andric
16920b57cec5SDimitry Andric  bits<5> V1;
169306c3fb27SDimitry Andric  bits<4> B2;
169406c3fb27SDimitry Andric  bits<12> D2;
16950b57cec5SDimitry Andric  bits<4> R3;
16960b57cec5SDimitry Andric
16970b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
16980b57cec5SDimitry Andric  let Inst{39-36} = 0;
16990b57cec5SDimitry Andric  let Inst{35-32} = R3;
170006c3fb27SDimitry Andric  let Inst{31-28} = B2;
170106c3fb27SDimitry Andric  let Inst{27-16} = D2;
17020b57cec5SDimitry Andric  let Inst{15-12} = V1{3-0};
17030b57cec5SDimitry Andric  let Inst{11-9}  = 0;
17040b57cec5SDimitry Andric  let Inst{8}     = V1{4};
17050b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
17060b57cec5SDimitry Andric}
17070b57cec5SDimitry Andric
17080b57cec5SDimitry Andricclass InstVRV<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
17090b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
17100b57cec5SDimitry Andric  field bits<48> Inst;
17110b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
17120b57cec5SDimitry Andric
17130b57cec5SDimitry Andric  bits<5> V1;
171406c3fb27SDimitry Andric  bits<5> V2;
171506c3fb27SDimitry Andric  bits<4> B2;
171606c3fb27SDimitry Andric  bits<12> D2;
17170b57cec5SDimitry Andric  bits<4> M3;
17180b57cec5SDimitry Andric
17190b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
17200b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
172106c3fb27SDimitry Andric  let Inst{35-32} = V2{3-0};
172206c3fb27SDimitry Andric  let Inst{31-28} = B2;
172306c3fb27SDimitry Andric  let Inst{27-16} = D2;
17240b57cec5SDimitry Andric  let Inst{15-12} = M3;
17250b57cec5SDimitry Andric  let Inst{11}    = V1{4};
172606c3fb27SDimitry Andric  let Inst{10}    = V2{4};
17270b57cec5SDimitry Andric  let Inst{9-8}   = 0;
17280b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
17290b57cec5SDimitry Andric}
17300b57cec5SDimitry Andric
17310b57cec5SDimitry Andricclass InstVRX<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
17320b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
17330b57cec5SDimitry Andric  field bits<48> Inst;
17340b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
17350b57cec5SDimitry Andric
17360b57cec5SDimitry Andric  bits<5> V1;
173706c3fb27SDimitry Andric  bits<4> X2;
173806c3fb27SDimitry Andric  bits<4> B2;
173906c3fb27SDimitry Andric  bits<12> D2;
17400b57cec5SDimitry Andric  bits<4> M3;
17410b57cec5SDimitry Andric
17420b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
17430b57cec5SDimitry Andric  let Inst{39-36} = V1{3-0};
174406c3fb27SDimitry Andric  let Inst{35-32} = X2;
174506c3fb27SDimitry Andric  let Inst{31-28} = B2;
174606c3fb27SDimitry Andric  let Inst{27-16} = D2;
17470b57cec5SDimitry Andric  let Inst{15-12} = M3;
17480b57cec5SDimitry Andric  let Inst{11}    = V1{4};
17490b57cec5SDimitry Andric  let Inst{10-8}  = 0;
17500b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
17510b57cec5SDimitry Andric}
17520b57cec5SDimitry Andric
17530b57cec5SDimitry Andricclass InstVSI<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
17540b57cec5SDimitry Andric  : InstSystemZ<6, outs, ins, asmstr, pattern> {
17550b57cec5SDimitry Andric  field bits<48> Inst;
17560b57cec5SDimitry Andric  field bits<48> SoftFail = 0;
17570b57cec5SDimitry Andric
17580b57cec5SDimitry Andric  bits<5> V1;
175906c3fb27SDimitry Andric  bits<4> B2;
176006c3fb27SDimitry Andric  bits<12> D2;
17610b57cec5SDimitry Andric  bits<8> I3;
17620b57cec5SDimitry Andric
17630b57cec5SDimitry Andric  let Inst{47-40} = op{15-8};
17640b57cec5SDimitry Andric  let Inst{39-32} = I3;
176506c3fb27SDimitry Andric  let Inst{31-28} = B2;
176606c3fb27SDimitry Andric  let Inst{27-16} = D2;
17670b57cec5SDimitry Andric  let Inst{15-12} = V1{3-0};
17680b57cec5SDimitry Andric  let Inst{11-9}  = 0;
17690b57cec5SDimitry Andric  let Inst{8}     = V1{4};
17700b57cec5SDimitry Andric  let Inst{7-0}   = op{7-0};
17710b57cec5SDimitry Andric}
17720b57cec5SDimitry Andric
17730b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
17740b57cec5SDimitry Andric// Instruction classes for .insn directives
17750b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
17760b57cec5SDimitry Andric
17770b57cec5SDimitry Andricclass DirectiveInsnE<dag outs, dag ins, string asmstr, list<dag> pattern>
17780b57cec5SDimitry Andric  : InstE<0, outs, ins, asmstr, pattern> {
17790b57cec5SDimitry Andric  bits<16> enc;
17800b57cec5SDimitry Andric
17810b57cec5SDimitry Andric  let Inst = enc;
17820b57cec5SDimitry Andric}
17830b57cec5SDimitry Andric
17840b57cec5SDimitry Andricclass DirectiveInsnRI<dag outs, dag ins, string asmstr, list<dag> pattern>
17850b57cec5SDimitry Andric  : InstRIa<0, outs, ins, asmstr, pattern> {
17860b57cec5SDimitry Andric  bits<32> enc;
17870b57cec5SDimitry Andric
17880b57cec5SDimitry Andric  let Inst{31-24} = enc{31-24};
17890b57cec5SDimitry Andric  let Inst{19-16} = enc{19-16};
17900b57cec5SDimitry Andric}
17910b57cec5SDimitry Andric
17920b57cec5SDimitry Andricclass DirectiveInsnRIE<dag outs, dag ins, string asmstr, list<dag> pattern>
17930b57cec5SDimitry Andric  : InstRIEd<0, outs, ins, asmstr, pattern> {
17940b57cec5SDimitry Andric  bits<48> enc;
17950b57cec5SDimitry Andric
17960b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
17970b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
17980b57cec5SDimitry Andric}
17990b57cec5SDimitry Andric
18000b57cec5SDimitry Andricclass DirectiveInsnRIL<dag outs, dag ins, string asmstr, list<dag> pattern>
18010b57cec5SDimitry Andric  : InstRILa<0, outs, ins, asmstr, pattern> {
18020b57cec5SDimitry Andric  bits<48> enc;
18030b57cec5SDimitry Andric  string type;
18040b57cec5SDimitry Andric
18050b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
18060b57cec5SDimitry Andric  let Inst{35-32} = enc{35-32};
18070b57cec5SDimitry Andric}
18080b57cec5SDimitry Andric
18090b57cec5SDimitry Andricclass DirectiveInsnRIS<dag outs, dag ins, string asmstr, list<dag> pattern>
18100b57cec5SDimitry Andric  : InstRIS<0, outs, ins, asmstr, pattern> {
18110b57cec5SDimitry Andric  bits<48> enc;
18120b57cec5SDimitry Andric
18130b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
18140b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
18150b57cec5SDimitry Andric}
18160b57cec5SDimitry Andric
18170b57cec5SDimitry Andricclass DirectiveInsnRR<dag outs, dag ins, string asmstr, list<dag> pattern>
18180b57cec5SDimitry Andric  : InstRR<0, outs, ins, asmstr, pattern> {
18190b57cec5SDimitry Andric  bits<16> enc;
18200b57cec5SDimitry Andric
18210b57cec5SDimitry Andric  let Inst{15-8} = enc{15-8};
18220b57cec5SDimitry Andric}
18230b57cec5SDimitry Andric
18240b57cec5SDimitry Andricclass DirectiveInsnRRE<dag outs, dag ins, string asmstr, list<dag> pattern>
18250b57cec5SDimitry Andric  : InstRRE<0, outs, ins, asmstr, pattern> {
18260b57cec5SDimitry Andric  bits<32> enc;
18270b57cec5SDimitry Andric
18280b57cec5SDimitry Andric  let Inst{31-16} = enc{31-16};
18290b57cec5SDimitry Andric}
18300b57cec5SDimitry Andric
18310b57cec5SDimitry Andricclass DirectiveInsnRRF<dag outs, dag ins, string asmstr, list<dag> pattern>
18320b57cec5SDimitry Andric  : InstRRFa<0, outs, ins, asmstr, pattern> {
18330b57cec5SDimitry Andric  bits<32> enc;
18340b57cec5SDimitry Andric
18350b57cec5SDimitry Andric  let Inst{31-16} = enc{31-16};
18360b57cec5SDimitry Andric}
18370b57cec5SDimitry Andric
18380b57cec5SDimitry Andricclass DirectiveInsnRRS<dag outs, dag ins, string asmstr, list<dag> pattern>
18390b57cec5SDimitry Andric  : InstRRS<0, outs, ins, asmstr, pattern> {
18400b57cec5SDimitry Andric  bits<48> enc;
18410b57cec5SDimitry Andric
18420b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
18430b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
18440b57cec5SDimitry Andric}
18450b57cec5SDimitry Andric
18460b57cec5SDimitry Andricclass DirectiveInsnRS<dag outs, dag ins, string asmstr, list<dag> pattern>
18470b57cec5SDimitry Andric  : InstRSa<0, outs, ins, asmstr, pattern> {
18480b57cec5SDimitry Andric  bits<32> enc;
18490b57cec5SDimitry Andric
18500b57cec5SDimitry Andric  let Inst{31-24} = enc{31-24};
18510b57cec5SDimitry Andric}
18520b57cec5SDimitry Andric
18530b57cec5SDimitry Andricclass DirectiveInsnRSE<dag outs, dag ins, string asmstr, list<dag> pattern>
185406c3fb27SDimitry Andric  : InstRSEa<6, outs, ins, asmstr, pattern> {
18550b57cec5SDimitry Andric  bits <48> enc;
18560b57cec5SDimitry Andric
18570b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
18580b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
18590b57cec5SDimitry Andric}
18600b57cec5SDimitry Andric
18610b57cec5SDimitry Andricclass DirectiveInsnRSI<dag outs, dag ins, string asmstr, list<dag> pattern>
18620b57cec5SDimitry Andric  : InstRSI<0, outs, ins, asmstr, pattern> {
18630b57cec5SDimitry Andric  bits<32> enc;
18640b57cec5SDimitry Andric
18650b57cec5SDimitry Andric  let Inst{31-24} = enc{31-24};
18660b57cec5SDimitry Andric}
18670b57cec5SDimitry Andric
18680b57cec5SDimitry Andricclass DirectiveInsnRSY<dag outs, dag ins, string asmstr, list<dag> pattern>
18690b57cec5SDimitry Andric  : InstRSYa<0, outs, ins, asmstr, pattern> {
18700b57cec5SDimitry Andric  bits<48> enc;
18710b57cec5SDimitry Andric
18720b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
18730b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
18740b57cec5SDimitry Andric}
18750b57cec5SDimitry Andric
18760b57cec5SDimitry Andricclass DirectiveInsnRX<dag outs, dag ins, string asmstr, list<dag> pattern>
18770b57cec5SDimitry Andric  : InstRXa<0, outs, ins, asmstr, pattern> {
18780b57cec5SDimitry Andric  bits<32> enc;
18790b57cec5SDimitry Andric
18800b57cec5SDimitry Andric  let Inst{31-24} = enc{31-24};
18810b57cec5SDimitry Andric}
18820b57cec5SDimitry Andric
18830b57cec5SDimitry Andricclass DirectiveInsnRXE<dag outs, dag ins, string asmstr, list<dag> pattern>
18840b57cec5SDimitry Andric  : InstRXE<0, outs, ins, asmstr, pattern> {
18850b57cec5SDimitry Andric  bits<48> enc;
18860b57cec5SDimitry Andric
18870b57cec5SDimitry Andric  let M3 = 0;
18880b57cec5SDimitry Andric
18890b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
18900b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
18910b57cec5SDimitry Andric}
18920b57cec5SDimitry Andric
18930b57cec5SDimitry Andricclass DirectiveInsnRXF<dag outs, dag ins, string asmstr, list<dag> pattern>
18940b57cec5SDimitry Andric  : InstRXF<0, outs, ins, asmstr, pattern> {
18950b57cec5SDimitry Andric  bits<48> enc;
18960b57cec5SDimitry Andric
18970b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
18980b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
18990b57cec5SDimitry Andric}
19000b57cec5SDimitry Andric
19010b57cec5SDimitry Andricclass DirectiveInsnRXY<dag outs, dag ins, string asmstr, list<dag> pattern>
19020b57cec5SDimitry Andric  : InstRXYa<0, outs, ins, asmstr, pattern> {
19030b57cec5SDimitry Andric  bits<48> enc;
19040b57cec5SDimitry Andric
19050b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
19060b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
19070b57cec5SDimitry Andric}
19080b57cec5SDimitry Andric
19090b57cec5SDimitry Andricclass DirectiveInsnS<dag outs, dag ins, string asmstr, list<dag> pattern>
19100b57cec5SDimitry Andric  : InstS<0, outs, ins, asmstr, pattern> {
19110b57cec5SDimitry Andric  bits<32> enc;
19120b57cec5SDimitry Andric
19130b57cec5SDimitry Andric  let Inst{31-16} = enc{31-16};
19140b57cec5SDimitry Andric}
19150b57cec5SDimitry Andric
19160b57cec5SDimitry Andricclass DirectiveInsnSI<dag outs, dag ins, string asmstr, list<dag> pattern>
19170b57cec5SDimitry Andric  : InstSI<0, outs, ins, asmstr, pattern> {
19180b57cec5SDimitry Andric  bits<32> enc;
19190b57cec5SDimitry Andric
19200b57cec5SDimitry Andric  let Inst{31-24} = enc{31-24};
19210b57cec5SDimitry Andric}
19220b57cec5SDimitry Andric
19230b57cec5SDimitry Andricclass DirectiveInsnSIY<dag outs, dag ins, string asmstr, list<dag> pattern>
19240b57cec5SDimitry Andric  : InstSIY<0, outs, ins, asmstr, pattern> {
19250b57cec5SDimitry Andric  bits<48> enc;
19260b57cec5SDimitry Andric
19270b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
19280b57cec5SDimitry Andric  let Inst{7-0}   = enc{7-0};
19290b57cec5SDimitry Andric}
19300b57cec5SDimitry Andric
19310b57cec5SDimitry Andricclass DirectiveInsnSIL<dag outs, dag ins, string asmstr, list<dag> pattern>
19320b57cec5SDimitry Andric  : InstSIL<0, outs, ins, asmstr, pattern> {
19330b57cec5SDimitry Andric  bits<48> enc;
19340b57cec5SDimitry Andric
19350b57cec5SDimitry Andric  let Inst{47-32} = enc{47-32};
19360b57cec5SDimitry Andric}
19370b57cec5SDimitry Andric
19380b57cec5SDimitry Andricclass DirectiveInsnSS<dag outs, dag ins, string asmstr, list<dag> pattern>
19390b57cec5SDimitry Andric  : InstSSd<0, outs, ins, asmstr, pattern> {
19400b57cec5SDimitry Andric  bits<48> enc;
19410b57cec5SDimitry Andric
19420b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
19430b57cec5SDimitry Andric}
19440b57cec5SDimitry Andric
19450b57cec5SDimitry Andricclass DirectiveInsnSSE<dag outs, dag ins, string asmstr, list<dag> pattern>
19460b57cec5SDimitry Andric  : InstSSE<0, outs, ins, asmstr, pattern> {
19470b57cec5SDimitry Andric  bits<48> enc;
19480b57cec5SDimitry Andric
19490b57cec5SDimitry Andric  let Inst{47-32} = enc{47-32};
19500b57cec5SDimitry Andric}
19510b57cec5SDimitry Andric
19520b57cec5SDimitry Andricclass DirectiveInsnSSF<dag outs, dag ins, string asmstr, list<dag> pattern>
19530b57cec5SDimitry Andric  : InstSSF<0, outs, ins, asmstr, pattern> {
19540b57cec5SDimitry Andric  bits<48> enc;
19550b57cec5SDimitry Andric
19560b57cec5SDimitry Andric  let Inst{47-40} = enc{47-40};
19570b57cec5SDimitry Andric  let Inst{35-32} = enc{35-32};
19580b57cec5SDimitry Andric}
19590b57cec5SDimitry Andric
1960e8d8bef9SDimitry Andricclass DirectiveInsnVRI<dag outs, dag ins, string asmstr, list<dag> pattern>
1961e8d8bef9SDimitry Andric  : InstVRIe<0, outs, ins, asmstr, pattern> {
1962e8d8bef9SDimitry Andric  bits<48> enc;
1963e8d8bef9SDimitry Andric
1964e8d8bef9SDimitry Andric  let Inst{47-40} = enc{47-40};
1965e8d8bef9SDimitry Andric  let Inst{7-0}   = enc{7-0};
1966e8d8bef9SDimitry Andric}
1967e8d8bef9SDimitry Andric
1968e8d8bef9SDimitry Andricclass DirectiveInsnVRR<dag outs, dag ins, string asmstr, list<dag> pattern>
1969e8d8bef9SDimitry Andric  : InstVRRc<0, outs, ins, asmstr, pattern> {
1970e8d8bef9SDimitry Andric  bits<48> enc;
1971e8d8bef9SDimitry Andric
1972e8d8bef9SDimitry Andric  let Inst{47-40} = enc{47-40};
1973e8d8bef9SDimitry Andric  let Inst{7-0}   = enc{7-0};
1974e8d8bef9SDimitry Andric}
1975e8d8bef9SDimitry Andric
1976e8d8bef9SDimitry Andricclass DirectiveInsnVRS<dag outs, dag ins, string asmstr, list<dag> pattern>
1977e8d8bef9SDimitry Andric  : InstVRSc<0, outs, ins, asmstr, pattern> {
1978e8d8bef9SDimitry Andric  bits<48> enc;
1979e8d8bef9SDimitry Andric
1980e8d8bef9SDimitry Andric  let Inst{47-40} = enc{47-40};
1981e8d8bef9SDimitry Andric  let Inst{7-0}   = enc{7-0};
1982e8d8bef9SDimitry Andric}
1983e8d8bef9SDimitry Andric
1984e8d8bef9SDimitry Andricclass DirectiveInsnVRV<dag outs, dag ins, string asmstr, list<dag> pattern>
1985e8d8bef9SDimitry Andric  : InstVRV<0, outs, ins, asmstr, pattern> {
1986e8d8bef9SDimitry Andric  bits<48> enc;
1987e8d8bef9SDimitry Andric
1988e8d8bef9SDimitry Andric  let Inst{47-40} = enc{47-40};
1989e8d8bef9SDimitry Andric  let Inst{7-0}   = enc{7-0};
1990e8d8bef9SDimitry Andric}
1991e8d8bef9SDimitry Andric
1992e8d8bef9SDimitry Andricclass DirectiveInsnVRX<dag outs, dag ins, string asmstr, list<dag> pattern>
1993e8d8bef9SDimitry Andric  : InstVRX<0, outs, ins, asmstr, pattern> {
1994e8d8bef9SDimitry Andric  bits<48> enc;
1995e8d8bef9SDimitry Andric
1996e8d8bef9SDimitry Andric  let Inst{47-40} = enc{47-40};
1997e8d8bef9SDimitry Andric  let Inst{7-0}   = enc{7-0};
1998e8d8bef9SDimitry Andric}
1999e8d8bef9SDimitry Andric
2000e8d8bef9SDimitry Andricclass DirectiveInsnVSI<dag outs, dag ins, string asmstr, list<dag> pattern>
2001e8d8bef9SDimitry Andric  : InstVSI<0, outs, ins, asmstr, pattern> {
2002e8d8bef9SDimitry Andric  bits<48> enc;
2003e8d8bef9SDimitry Andric
2004e8d8bef9SDimitry Andric  let Inst{47-40} = enc{47-40};
2005e8d8bef9SDimitry Andric  let Inst{7-0}   = enc{7-0};
2006e8d8bef9SDimitry Andric}
2007e8d8bef9SDimitry Andric
2008e8d8bef9SDimitry Andric
20090b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20100b57cec5SDimitry Andric// Variants of instructions with condition mask
20110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20120b57cec5SDimitry Andric//
20130b57cec5SDimitry Andric// For instructions using a condition mask (e.g. conditional branches,
20140b57cec5SDimitry Andric// compare-and-branch instructions, or conditional move instructions),
20150b57cec5SDimitry Andric// we generally need to create multiple instruction patterns:
20160b57cec5SDimitry Andric//
20170b57cec5SDimitry Andric// - One used for code generation, which encodes the condition mask as an
20180b57cec5SDimitry Andric//   MI operand, but writes out an extended mnemonic for better readability.
20190b57cec5SDimitry Andric// - One pattern for the base form of the instruction with an explicit
20200b57cec5SDimitry Andric//   condition mask (encoded as a plain integer MI operand).
20210b57cec5SDimitry Andric// - Specific patterns for each extended mnemonic, where the condition mask
20220b57cec5SDimitry Andric//   is implied by the pattern name and not otherwise encoded at all.
20230b57cec5SDimitry Andric//
20240b57cec5SDimitry Andric// We need the latter primarily for the assembler and disassembler, since the
20250b57cec5SDimitry Andric// assembler parser is not able to decode part of an instruction mnemonic
20260b57cec5SDimitry Andric// into an operand.  Thus we provide separate patterns for each mnemonic.
20270b57cec5SDimitry Andric//
20280b57cec5SDimitry Andric// Note that in some cases there are two different mnemonics for the same
20290b57cec5SDimitry Andric// condition mask.  In this case we cannot have both instructions available
20300b57cec5SDimitry Andric// to the disassembler at the same time since the encodings are not distinct.
20310b57cec5SDimitry Andric// Therefore the alternate forms are marked isAsmParserOnly.
20320b57cec5SDimitry Andric//
20330b57cec5SDimitry Andric// We don't make one of the two names an alias of the other because
20340b57cec5SDimitry Andric// we need the custom parsing routines to select the correct register class.
20350b57cec5SDimitry Andric//
20360b57cec5SDimitry Andric// This section provides helpers for generating the specific forms.
20370b57cec5SDimitry Andric//
20380b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20390b57cec5SDimitry Andric
20400b57cec5SDimitry Andric// A class to describe a variant of an instruction with condition mask.
2041fe6060f1SDimitry Andricclass CondVariant<bits<4> ccmaskin, string suffixin, bit alternatein,
2042fe6060f1SDimitry Andric                  string asmvariantin = ""> {
20430b57cec5SDimitry Andric  // The fixed condition mask to use.
20440b57cec5SDimitry Andric  bits<4> ccmask = ccmaskin;
20450b57cec5SDimitry Andric
20460b57cec5SDimitry Andric  // The suffix to use for the extended assembler mnemonic.
20470b57cec5SDimitry Andric  string suffix = suffixin;
20480b57cec5SDimitry Andric
20490b57cec5SDimitry Andric  // Whether this is an alternate that needs to be marked isAsmParserOnly.
20500b57cec5SDimitry Andric  bit alternate = alternatein;
2051fe6060f1SDimitry Andric
2052fe6060f1SDimitry Andric  // Whether this needs be to restricted to a specific dialect.
2053fe6060f1SDimitry Andric  // Valid values are "att" and "hlasm", which when passed in
2054fe6060f1SDimitry Andric  // will set AsmVariantName.
2055fe6060f1SDimitry Andric  string asmvariant = asmvariantin;
20560b57cec5SDimitry Andric}
20570b57cec5SDimitry Andric
20580b57cec5SDimitry Andric// Condition mask 15 means "always true", which is used to define
20590b57cec5SDimitry Andric// unconditional branches as a variant of conditional branches.
20600b57cec5SDimitry Andricdef CondAlways : CondVariant<15, "", 0>;
20610b57cec5SDimitry Andric
20620b57cec5SDimitry Andric// Condition masks for general instructions that can set all 4 bits.
20630b57cec5SDimitry Andricdef CondVariantO   : CondVariant<1,  "o",   0>;
20640b57cec5SDimitry Andricdef CondVariantH   : CondVariant<2,  "h",   0>;
20650b57cec5SDimitry Andricdef CondVariantP   : CondVariant<2,  "p",   1>;
2066fe6060f1SDimitry Andricdef CondVariantNLE : CondVariant<3,  "nle", 0, "att">;
20670b57cec5SDimitry Andricdef CondVariantL   : CondVariant<4,  "l",   0>;
20680b57cec5SDimitry Andricdef CondVariantM   : CondVariant<4,  "m",   1>;
2069fe6060f1SDimitry Andricdef CondVariantNHE : CondVariant<5,  "nhe", 0, "att">;
2070fe6060f1SDimitry Andricdef CondVariantLH  : CondVariant<6,  "lh",  0, "att">;
20710b57cec5SDimitry Andricdef CondVariantNE  : CondVariant<7,  "ne",  0>;
20720b57cec5SDimitry Andricdef CondVariantNZ  : CondVariant<7,  "nz",  1>;
20730b57cec5SDimitry Andricdef CondVariantE   : CondVariant<8,  "e",   0>;
20740b57cec5SDimitry Andricdef CondVariantZ   : CondVariant<8,  "z",   1>;
2075fe6060f1SDimitry Andricdef CondVariantNLH : CondVariant<9,  "nlh", 0, "att">;
2076fe6060f1SDimitry Andricdef CondVariantHE  : CondVariant<10, "he",  0, "att">;
20770b57cec5SDimitry Andricdef CondVariantNL  : CondVariant<11, "nl",  0>;
20780b57cec5SDimitry Andricdef CondVariantNM  : CondVariant<11, "nm",  1>;
2079fe6060f1SDimitry Andricdef CondVariantLE  : CondVariant<12, "le",  0, "att">;
20800b57cec5SDimitry Andricdef CondVariantNH  : CondVariant<13, "nh",  0>;
20810b57cec5SDimitry Andricdef CondVariantNP  : CondVariant<13, "np",  1>;
20820b57cec5SDimitry Andricdef CondVariantNO  : CondVariant<14, "no",  0>;
20830b57cec5SDimitry Andric
20840b57cec5SDimitry Andric// A helper class to look up one of the above by name.
20850b57cec5SDimitry Andricclass CV<string name>
20860b57cec5SDimitry Andric  : CondVariant<!cast<CondVariant>("CondVariant"#name).ccmask,
20870b57cec5SDimitry Andric                !cast<CondVariant>("CondVariant"#name).suffix,
2088fe6060f1SDimitry Andric                !cast<CondVariant>("CondVariant"#name).alternate,
2089fe6060f1SDimitry Andric                !cast<CondVariant>("CondVariant"#name).asmvariant>;
20900b57cec5SDimitry Andric
20910b57cec5SDimitry Andric// Condition masks for integer instructions (e.g. compare-and-branch).
20920b57cec5SDimitry Andric// This is like the list above, except that condition 3 is not possible
20930b57cec5SDimitry Andric// and that the low bit of the mask is therefore always 0.  This means
20940b57cec5SDimitry Andric// that each condition has two names.  Conditions "o" and "no" are not used.
20950b57cec5SDimitry Andricdef IntCondVariantH   : CondVariant<2,  "h",   0>;
2096fe6060f1SDimitry Andricdef IntCondVariantNLE : CondVariant<2,  "nle", 1, "att">;
20970b57cec5SDimitry Andricdef IntCondVariantL   : CondVariant<4,  "l",   0>;
2098fe6060f1SDimitry Andricdef IntCondVariantNHE : CondVariant<4,  "nhe", 1, "att">;
2099fe6060f1SDimitry Andricdef IntCondVariantLH  : CondVariant<6,  "lh",  0, "att">;
21000b57cec5SDimitry Andricdef IntCondVariantNE  : CondVariant<6,  "ne",  1>;
21010b57cec5SDimitry Andricdef IntCondVariantE   : CondVariant<8,  "e",   0>;
2102fe6060f1SDimitry Andricdef IntCondVariantNLH : CondVariant<8,  "nlh", 1, "att">;
2103fe6060f1SDimitry Andricdef IntCondVariantHE  : CondVariant<10, "he",  0, "att">;
21040b57cec5SDimitry Andricdef IntCondVariantNL  : CondVariant<10, "nl",  1>;
2105fe6060f1SDimitry Andricdef IntCondVariantLE  : CondVariant<12, "le",  0, "att">;
21060b57cec5SDimitry Andricdef IntCondVariantNH  : CondVariant<12, "nh",  1>;
21070b57cec5SDimitry Andric
21080b57cec5SDimitry Andric// A helper class to look up one of the above by name.
21090b57cec5SDimitry Andricclass ICV<string name>
21100b57cec5SDimitry Andric  : CondVariant<!cast<CondVariant>("IntCondVariant"#name).ccmask,
21110b57cec5SDimitry Andric                !cast<CondVariant>("IntCondVariant"#name).suffix,
2112fe6060f1SDimitry Andric                !cast<CondVariant>("IntCondVariant"#name).alternate,
2113fe6060f1SDimitry Andric                !cast<CondVariant>("IntCondVariant"#name).asmvariant>;
21140b57cec5SDimitry Andric
2115e8d8bef9SDimitry Andric// Defines a class that makes it easier to define
2116e8d8bef9SDimitry Andric// a MnemonicAlias when CondVariant's are involved.
2117fe6060f1SDimitry Andricmulticlass MnemonicCondBranchAlias<CondVariant V, string from, string to,
2118fe6060f1SDimitry Andric                                   string asmvariant = V.asmvariant> {
2119fe6060f1SDimitry Andric  if !or(!eq(V.asmvariant, ""), !eq(V.asmvariant, asmvariant)) then
2120fe6060f1SDimitry Andric    def "" : MnemonicAlias<!subst("#", V.suffix, from),
2121fe6060f1SDimitry Andric                           !subst("#", V.suffix, to),
2122fe6060f1SDimitry Andric                           asmvariant>;
2123fe6060f1SDimitry Andric}
2124e8d8bef9SDimitry Andric
21250b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
21260b57cec5SDimitry Andric// Instruction definitions with semantics
21270b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
21280b57cec5SDimitry Andric//
21290b57cec5SDimitry Andric// These classes have the form [Cond]<Category><Format>, where <Format> is one
21300b57cec5SDimitry Andric// of the formats defined above and where <Category> describes the inputs
21310b57cec5SDimitry Andric// and outputs.  "Cond" is used if the instruction is conditional,
21320b57cec5SDimitry Andric// in which case the 4-bit condition-code mask is added as a final operand.
21330b57cec5SDimitry Andric// <Category> can be one of:
21340b57cec5SDimitry Andric//
21350b57cec5SDimitry Andric//   Inherent:
21360b57cec5SDimitry Andric//     One register output operand and no input operands.
21370b57cec5SDimitry Andric//
21380b57cec5SDimitry Andric//   InherentDual:
21390b57cec5SDimitry Andric//     Two register output operands and no input operands.
21400b57cec5SDimitry Andric//
21410b57cec5SDimitry Andric//   StoreInherent:
21420b57cec5SDimitry Andric//     One address operand.  The instruction stores to the address.
21430b57cec5SDimitry Andric//
21440b57cec5SDimitry Andric//   SideEffectInherent:
21450b57cec5SDimitry Andric//     No input or output operands, but causes some side effect.
21460b57cec5SDimitry Andric//
21470b57cec5SDimitry Andric//   Branch:
21480b57cec5SDimitry Andric//     One branch target.  The instruction branches to the target.
21490b57cec5SDimitry Andric//
21500b57cec5SDimitry Andric//   Call:
21510b57cec5SDimitry Andric//     One output operand and one branch target.  The instruction stores
21520b57cec5SDimitry Andric//     the return address to the output operand and branches to the target.
21530b57cec5SDimitry Andric//
21540b57cec5SDimitry Andric//   CmpBranch:
21550b57cec5SDimitry Andric//     Two input operands and one optional branch target.  The instruction
21560b57cec5SDimitry Andric//     compares the two input operands and branches or traps on the result.
21570b57cec5SDimitry Andric//
21580b57cec5SDimitry Andric//   BranchUnary:
21590b57cec5SDimitry Andric//     One register output operand, one register input operand and one branch
21600b57cec5SDimitry Andric//     target.  The instructions stores a modified form of the source register
21610b57cec5SDimitry Andric//     in the destination register and branches on the result.
21620b57cec5SDimitry Andric//
21630b57cec5SDimitry Andric//   BranchBinary:
21640b57cec5SDimitry Andric//     One register output operand, two register input operands and one branch
21650b57cec5SDimitry Andric//     target. The instructions stores a modified form of one of the source
21660b57cec5SDimitry Andric//     registers in the destination register and branches on the result.
21670b57cec5SDimitry Andric//
21680b57cec5SDimitry Andric//   LoadMultiple:
21690b57cec5SDimitry Andric//     One address input operand and two explicit output operands.
21700b57cec5SDimitry Andric//     The instruction loads a range of registers from the address,
21710b57cec5SDimitry Andric//     with the explicit operands giving the first and last register
21720b57cec5SDimitry Andric//     to load.  Other loaded registers are added as implicit definitions.
21730b57cec5SDimitry Andric//
21740b57cec5SDimitry Andric//   StoreMultiple:
21750b57cec5SDimitry Andric//     Two explicit input register operands and an address operand.
21760b57cec5SDimitry Andric//     The instruction stores a range of registers to the address,
21770b57cec5SDimitry Andric//     with the explicit operands giving the first and last register
21780b57cec5SDimitry Andric//     to store.  Other stored registers are added as implicit uses.
21790b57cec5SDimitry Andric//
21800b57cec5SDimitry Andric//   StoreLength:
21810b57cec5SDimitry Andric//     One value operand, one length operand and one address operand.
21820b57cec5SDimitry Andric//     The instruction stores the value operand to the address but
21830b57cec5SDimitry Andric//     doesn't write more than the number of bytes specified by the
21840b57cec5SDimitry Andric//     length operand.
21850b57cec5SDimitry Andric//
21860b57cec5SDimitry Andric//   LoadAddress:
21870b57cec5SDimitry Andric//     One register output operand and one address operand.
21880b57cec5SDimitry Andric//
21890b57cec5SDimitry Andric//   SideEffectAddress:
21900b57cec5SDimitry Andric//     One address operand.  No output operands, but causes some side effect.
21910b57cec5SDimitry Andric//
21920b57cec5SDimitry Andric//   Unary:
21930b57cec5SDimitry Andric//     One register output operand and one input operand.
21940b57cec5SDimitry Andric//
21950b57cec5SDimitry Andric//   Store:
21960b57cec5SDimitry Andric//     One address operand and one other input operand.  The instruction
21970b57cec5SDimitry Andric//     stores to the address.
21980b57cec5SDimitry Andric//
21990b57cec5SDimitry Andric//   SideEffectUnary:
22000b57cec5SDimitry Andric//     One input operand.  No output operands, but causes some side effect.
22010b57cec5SDimitry Andric//
22020b57cec5SDimitry Andric//   Binary:
22030b57cec5SDimitry Andric//     One register output operand and two input operands.
22040b57cec5SDimitry Andric//
22050b57cec5SDimitry Andric//   StoreBinary:
22060b57cec5SDimitry Andric//     One address operand and two other input operands.  The instruction
22070b57cec5SDimitry Andric//     stores to the address.
22080b57cec5SDimitry Andric//
22090b57cec5SDimitry Andric//   SideEffectBinary:
22100b57cec5SDimitry Andric//     Two input operands.  No output operands, but causes some side effect.
22110b57cec5SDimitry Andric//
22120b57cec5SDimitry Andric//   Compare:
22130b57cec5SDimitry Andric//     Two input operands and an implicit CC output operand.
22140b57cec5SDimitry Andric//
22150b57cec5SDimitry Andric//   Test:
22160b57cec5SDimitry Andric//     One or two input operands and an implicit CC output operand.  If
22170b57cec5SDimitry Andric//     present, the second input operand is an "address" operand used as
22180b57cec5SDimitry Andric//     a test class mask.
22190b57cec5SDimitry Andric//
22200b57cec5SDimitry Andric//   Ternary:
22210b57cec5SDimitry Andric//     One register output operand and three input operands.
22220b57cec5SDimitry Andric//
22230b57cec5SDimitry Andric//   SideEffectTernary:
22240b57cec5SDimitry Andric//     Three input operands.  No output operands, but causes some side effect.
22250b57cec5SDimitry Andric//
22260b57cec5SDimitry Andric//   Quaternary:
22270b57cec5SDimitry Andric//     One register output operand and four input operands.
22280b57cec5SDimitry Andric//
22290b57cec5SDimitry Andric//   LoadAndOp:
22300b57cec5SDimitry Andric//     One output operand and two input operands, one of which is an address.
22310b57cec5SDimitry Andric//     The instruction both reads from and writes to the address.
22320b57cec5SDimitry Andric//
22330b57cec5SDimitry Andric//   CmpSwap:
22340b57cec5SDimitry Andric//     One output operand and three input operands, one of which is an address.
22350b57cec5SDimitry Andric//     The instruction both reads from and writes to the address.
22360b57cec5SDimitry Andric//
22370b57cec5SDimitry Andric//   RotateSelect:
22380b57cec5SDimitry Andric//     One output operand and five input operands.  The first two operands
22390b57cec5SDimitry Andric//     are registers and the other three are immediates.
22400b57cec5SDimitry Andric//
22410b57cec5SDimitry Andric//   Prefetch:
22420b57cec5SDimitry Andric//     One 4-bit immediate operand and one address operand.  The immediate
22430b57cec5SDimitry Andric//     operand is 1 for a load prefetch and 2 for a store prefetch.
22440b57cec5SDimitry Andric//
22450b57cec5SDimitry Andric//   BranchPreload:
22460b57cec5SDimitry Andric//     One 4-bit immediate operand and two address operands.
22470b57cec5SDimitry Andric//
22480b57cec5SDimitry Andric// The format determines which input operands are tied to output operands,
22490b57cec5SDimitry Andric// and also determines the shape of any address operand.
22500b57cec5SDimitry Andric//
22510b57cec5SDimitry Andric// Multiclasses of the form <Category><Format>Pair define two instructions,
22520b57cec5SDimitry Andric// one with <Category><Format> and one with <Category><Format>Y.  The name
22530b57cec5SDimitry Andric// of the first instruction has no suffix, the name of the second has
22540b57cec5SDimitry Andric// an extra "y".
22550b57cec5SDimitry Andric//
22560b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
22570b57cec5SDimitry Andric
22580b57cec5SDimitry Andricclass InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
22590b57cec5SDimitry Andric                  SDPatternOperator operator>
22600b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls:$R1), (ins),
22610b57cec5SDimitry Andric            mnemonic#"\t$R1",
22620b57cec5SDimitry Andric            [(set cls:$R1, (operator))]> {
22630b57cec5SDimitry Andric  let R2 = 0;
22640b57cec5SDimitry Andric}
22650b57cec5SDimitry Andric
22660b57cec5SDimitry Andricclass InherentDualRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
22670b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls:$R1, cls:$R2), (ins),
22680b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2", []>;
22690b57cec5SDimitry Andric
22700b57cec5SDimitry Andricclass InherentVRIa<string mnemonic, bits<16> opcode, bits<16> value>
22710b57cec5SDimitry Andric  : InstVRIa<opcode, (outs VR128:$V1), (ins), mnemonic#"\t$V1", []> {
22720b57cec5SDimitry Andric  let I2 = value;
22730b57cec5SDimitry Andric  let M3 = 0;
22740b57cec5SDimitry Andric}
22750b57cec5SDimitry Andric
22760b57cec5SDimitry Andricclass StoreInherentS<string mnemonic, bits<16> opcode,
22770b57cec5SDimitry Andric                     SDPatternOperator operator, bits<5> bytes>
227806c3fb27SDimitry Andric  : InstS<opcode, (outs), (ins (bdaddr12only $B2, $D2):$BD2),
22790b57cec5SDimitry Andric          mnemonic#"\t$BD2", [(operator bdaddr12only:$BD2)]> {
22800b57cec5SDimitry Andric  let mayStore = 1;
22810b57cec5SDimitry Andric  let AccessBytes = bytes;
22820b57cec5SDimitry Andric}
22830b57cec5SDimitry Andric
22840b57cec5SDimitry Andricclass SideEffectInherentE<string mnemonic, bits<16>opcode>
22850b57cec5SDimitry Andric  : InstE<opcode, (outs), (ins), mnemonic, []>;
22860b57cec5SDimitry Andric
22870b57cec5SDimitry Andricclass SideEffectInherentS<string mnemonic, bits<16> opcode,
22880b57cec5SDimitry Andric                          SDPatternOperator operator>
22890b57cec5SDimitry Andric  : InstS<opcode, (outs), (ins), mnemonic, [(operator)]> {
229006c3fb27SDimitry Andric  let B2 = 0;
229106c3fb27SDimitry Andric  let D2 = 0;
22920b57cec5SDimitry Andric}
22930b57cec5SDimitry Andric
22940b57cec5SDimitry Andricclass SideEffectInherentRRE<string mnemonic, bits<16> opcode>
22950b57cec5SDimitry Andric  : InstRRE<opcode, (outs), (ins), mnemonic, []> {
22960b57cec5SDimitry Andric  let R1 = 0;
22970b57cec5SDimitry Andric  let R2 = 0;
22980b57cec5SDimitry Andric}
22990b57cec5SDimitry Andric
23000b57cec5SDimitry Andric// Allow an optional TLS marker symbol to generate TLS call relocations.
23010b57cec5SDimitry Andricclass CallRI<string mnemonic, bits<12> opcode>
23020b57cec5SDimitry Andric  : InstRIb<opcode, (outs), (ins GR64:$R1, brtarget16tls:$RI2),
23030b57cec5SDimitry Andric            mnemonic#"\t$R1, $RI2", []>;
23040b57cec5SDimitry Andric
23050b57cec5SDimitry Andric// Allow an optional TLS marker symbol to generate TLS call relocations.
23060b57cec5SDimitry Andricclass CallRIL<string mnemonic, bits<12> opcode>
23070b57cec5SDimitry Andric  : InstRILb<opcode, (outs), (ins GR64:$R1, brtarget32tls:$RI2),
23080b57cec5SDimitry Andric             mnemonic#"\t$R1, $RI2", []>;
23090b57cec5SDimitry Andric
23100b57cec5SDimitry Andricclass CallRR<string mnemonic, bits<8> opcode>
23110b57cec5SDimitry Andric  : InstRR<opcode, (outs), (ins GR64:$R1, ADDR64:$R2),
23120b57cec5SDimitry Andric           mnemonic#"\t$R1, $R2", []>;
23130b57cec5SDimitry Andric
23140b57cec5SDimitry Andricclass CallRX<string mnemonic, bits<8> opcode>
231506c3fb27SDimitry Andric  : InstRXa<opcode, (outs), (ins GR64:$R1, (bdxaddr12only $B2, $D2, $X2):$XBD2),
23160b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2", []>;
23170b57cec5SDimitry Andric
23180b57cec5SDimitry Andricclass CondBranchRI<string mnemonic, bits<12> opcode,
23190b57cec5SDimitry Andric                   SDPatternOperator operator = null_frag>
23200b57cec5SDimitry Andric  : InstRIc<opcode, (outs), (ins cond4:$valid, cond4:$M1, brtarget16:$RI2),
23210b57cec5SDimitry Andric            !subst("#", "${M1}", mnemonic)#"\t$RI2",
23220b57cec5SDimitry Andric            [(operator cond4:$valid, cond4:$M1, bb:$RI2)]> {
23230b57cec5SDimitry Andric  let CCMaskFirst = 1;
23240b57cec5SDimitry Andric}
23250b57cec5SDimitry Andric
23260b57cec5SDimitry Andricclass AsmCondBranchRI<string mnemonic, bits<12> opcode>
23270b57cec5SDimitry Andric  : InstRIc<opcode, (outs), (ins imm32zx4:$M1, brtarget16:$RI2),
23280b57cec5SDimitry Andric            mnemonic#"\t$M1, $RI2", []>;
23290b57cec5SDimitry Andric
23300b57cec5SDimitry Andricclass FixedCondBranchRI<CondVariant V, string mnemonic, bits<12> opcode,
23310b57cec5SDimitry Andric                        SDPatternOperator operator = null_frag>
23320b57cec5SDimitry Andric  : InstRIc<opcode, (outs), (ins brtarget16:$RI2),
23330b57cec5SDimitry Andric            !subst("#", V.suffix, mnemonic)#"\t$RI2", [(operator bb:$RI2)]> {
23340b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2335fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
23360b57cec5SDimitry Andric  let M1 = V.ccmask;
23370b57cec5SDimitry Andric}
23380b57cec5SDimitry Andric
23390b57cec5SDimitry Andricclass CondBranchRIL<string mnemonic, bits<12> opcode>
23400b57cec5SDimitry Andric  : InstRILc<opcode, (outs), (ins cond4:$valid, cond4:$M1, brtarget32:$RI2),
23410b57cec5SDimitry Andric             !subst("#", "${M1}", mnemonic)#"\t$RI2", []> {
23420b57cec5SDimitry Andric  let CCMaskFirst = 1;
23430b57cec5SDimitry Andric}
23440b57cec5SDimitry Andric
23450b57cec5SDimitry Andricclass AsmCondBranchRIL<string mnemonic, bits<12> opcode>
23460b57cec5SDimitry Andric  : InstRILc<opcode, (outs), (ins imm32zx4:$M1, brtarget32:$RI2),
23470b57cec5SDimitry Andric             mnemonic#"\t$M1, $RI2", []>;
23480b57cec5SDimitry Andric
23490b57cec5SDimitry Andricclass FixedCondBranchRIL<CondVariant V, string mnemonic, bits<12> opcode>
23500b57cec5SDimitry Andric  : InstRILc<opcode, (outs), (ins brtarget32:$RI2),
23510b57cec5SDimitry Andric             !subst("#", V.suffix, mnemonic)#"\t$RI2", []> {
23520b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2353fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
23540b57cec5SDimitry Andric  let M1 = V.ccmask;
23550b57cec5SDimitry Andric}
23560b57cec5SDimitry Andric
23570b57cec5SDimitry Andricclass CondBranchRR<string mnemonic, bits<8> opcode>
23580b57cec5SDimitry Andric  : InstRR<opcode, (outs), (ins cond4:$valid, cond4:$R1, GR64:$R2),
23590b57cec5SDimitry Andric           !subst("#", "${R1}", mnemonic)#"\t$R2", []> {
23600b57cec5SDimitry Andric  let CCMaskFirst = 1;
23610b57cec5SDimitry Andric}
23620b57cec5SDimitry Andric
23630b57cec5SDimitry Andricclass AsmCondBranchRR<string mnemonic, bits<8> opcode>
23640b57cec5SDimitry Andric  : InstRR<opcode, (outs), (ins imm32zx4:$R1, GR64:$R2),
23650b57cec5SDimitry Andric           mnemonic#"\t$R1, $R2", []>;
23660b57cec5SDimitry Andric
2367*0fca6ea1SDimitry Andricclass NeverCondBranchRR<string mnemonic, bits<8> opcode>
2368*0fca6ea1SDimitry Andric  : InstRR<opcode, (outs), (ins GR64:$R2),
2369*0fca6ea1SDimitry Andric           mnemonic#"\t$R2", []> {
2370*0fca6ea1SDimitry Andric  let R1 = 0;
2371*0fca6ea1SDimitry Andric}
2372*0fca6ea1SDimitry Andric
23730b57cec5SDimitry Andricclass FixedCondBranchRR<CondVariant V, string mnemonic, bits<8> opcode,
23740b57cec5SDimitry Andric                      SDPatternOperator operator = null_frag>
23750b57cec5SDimitry Andric  : InstRR<opcode, (outs), (ins ADDR64:$R2),
23760b57cec5SDimitry Andric           !subst("#", V.suffix, mnemonic)#"\t$R2", [(operator ADDR64:$R2)]> {
23770b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2378fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
23790b57cec5SDimitry Andric  let R1 = V.ccmask;
23800b57cec5SDimitry Andric}
23810b57cec5SDimitry Andric
23820b57cec5SDimitry Andricclass CondBranchRX<string mnemonic, bits<8> opcode>
238306c3fb27SDimitry Andric  : InstRXb<opcode, (outs),
238406c3fb27SDimitry Andric            (ins cond4:$valid, cond4:$M1, (bdxaddr12only $B2, $D2, $X2):$XBD2),
23850b57cec5SDimitry Andric            !subst("#", "${M1}", mnemonic)#"\t$XBD2", []> {
23860b57cec5SDimitry Andric  let CCMaskFirst = 1;
23870b57cec5SDimitry Andric}
23880b57cec5SDimitry Andric
23890b57cec5SDimitry Andricclass AsmCondBranchRX<string mnemonic, bits<8> opcode>
239006c3fb27SDimitry Andric  : InstRXb<opcode, (outs),
239106c3fb27SDimitry Andric            (ins imm32zx4:$M1, (bdxaddr12only $B2, $D2, $X2):$XBD2),
23920b57cec5SDimitry Andric            mnemonic#"\t$M1, $XBD2", []>;
23930b57cec5SDimitry Andric
2394*0fca6ea1SDimitry Andricclass NeverCondBranchRX<string mnemonic, bits<8> opcode>
2395*0fca6ea1SDimitry Andric  : InstRXb<opcode, (outs),
2396*0fca6ea1SDimitry Andric            (ins (bdxaddr12only $B2, $D2, $X2):$XBD2),
2397*0fca6ea1SDimitry Andric            mnemonic#"\t$XBD2", []> {
2398*0fca6ea1SDimitry Andric  let M1 = 0;
2399*0fca6ea1SDimitry Andric}
2400*0fca6ea1SDimitry Andric
24010b57cec5SDimitry Andricclass FixedCondBranchRX<CondVariant V, string mnemonic, bits<8> opcode>
240206c3fb27SDimitry Andric  : InstRXb<opcode, (outs), (ins (bdxaddr12only $B2, $D2, $X2):$XBD2),
24030b57cec5SDimitry Andric            !subst("#", V.suffix, mnemonic)#"\t$XBD2", []> {
24040b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2405fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
24060b57cec5SDimitry Andric  let M1 = V.ccmask;
24070b57cec5SDimitry Andric}
24080b57cec5SDimitry Andric
24090b57cec5SDimitry Andricclass CondBranchRXY<string mnemonic, bits<16> opcode>
241006c3fb27SDimitry Andric  : InstRXYb<opcode, (outs), (ins cond4:$valid, cond4:$M1,
241106c3fb27SDimitry Andric             (bdxaddr20only $B2, $D2, $X2):$XBD2),
24120b57cec5SDimitry Andric             !subst("#", "${M1}", mnemonic)#"\t$XBD2", []> {
24130b57cec5SDimitry Andric  let CCMaskFirst = 1;
24140b57cec5SDimitry Andric  let mayLoad = 1;
24150b57cec5SDimitry Andric}
24160b57cec5SDimitry Andric
24170b57cec5SDimitry Andricclass AsmCondBranchRXY<string mnemonic, bits<16> opcode>
241806c3fb27SDimitry Andric  : InstRXYb<opcode, (outs),
241906c3fb27SDimitry Andric             (ins imm32zx4:$M1, (bdxaddr20only $B2, $D2, $X2):$XBD2),
24200b57cec5SDimitry Andric             mnemonic#"\t$M1, $XBD2", []> {
24210b57cec5SDimitry Andric  let mayLoad = 1;
24220b57cec5SDimitry Andric}
24230b57cec5SDimitry Andric
24240b57cec5SDimitry Andricclass FixedCondBranchRXY<CondVariant V, string mnemonic, bits<16> opcode,
24250b57cec5SDimitry Andric                         SDPatternOperator operator = null_frag>
242606c3fb27SDimitry Andric  : InstRXYb<opcode, (outs), (ins (bdxaddr20only $B2, $D2, $X2):$XBD2),
24270b57cec5SDimitry Andric             !subst("#", V.suffix, mnemonic)#"\t$XBD2",
24280b57cec5SDimitry Andric             [(operator (load bdxaddr20only:$XBD2))]> {
24290b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2430fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
24310b57cec5SDimitry Andric  let M1 = V.ccmask;
24320b57cec5SDimitry Andric  let mayLoad = 1;
24330b57cec5SDimitry Andric}
24340b57cec5SDimitry Andric
24350b57cec5SDimitry Andricclass CmpBranchRIEa<string mnemonic, bits<16> opcode,
24368bcb0991SDimitry Andric                    RegisterOperand cls, ImmOpWithPattern imm>
24370b57cec5SDimitry Andric  : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2, cond4:$M3),
24380b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $I2", []>;
24390b57cec5SDimitry Andric
24400b57cec5SDimitry Andricclass AsmCmpBranchRIEa<string mnemonic, bits<16> opcode,
24418bcb0991SDimitry Andric                       RegisterOperand cls, ImmOpWithPattern imm>
24420b57cec5SDimitry Andric  : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2, imm32zx4:$M3),
24430b57cec5SDimitry Andric             mnemonic#"\t$R1, $I2, $M3", []>;
24440b57cec5SDimitry Andric
24450b57cec5SDimitry Andricclass FixedCmpBranchRIEa<CondVariant V, string mnemonic, bits<16> opcode,
24468bcb0991SDimitry Andric                          RegisterOperand cls, ImmOpWithPattern imm>
24470b57cec5SDimitry Andric  : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2),
24480b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $I2", []> {
24490b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2450fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
24510b57cec5SDimitry Andric  let M3 = V.ccmask;
24520b57cec5SDimitry Andric}
24530b57cec5SDimitry Andric
24540b57cec5SDimitry Andricmulticlass CmpBranchRIEaPair<string mnemonic, bits<16> opcode,
24558bcb0991SDimitry Andric                             RegisterOperand cls, ImmOpWithPattern imm> {
24560b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
24570b57cec5SDimitry Andric    def "" : CmpBranchRIEa<mnemonic, opcode, cls, imm>;
24580b57cec5SDimitry Andric  def Asm : AsmCmpBranchRIEa<mnemonic, opcode, cls, imm>;
24590b57cec5SDimitry Andric}
24600b57cec5SDimitry Andric
24610b57cec5SDimitry Andricclass CmpBranchRIEb<string mnemonic, bits<16> opcode,
24620b57cec5SDimitry Andric                    RegisterOperand cls>
24630b57cec5SDimitry Andric  : InstRIEb<opcode, (outs),
24640b57cec5SDimitry Andric             (ins cls:$R1, cls:$R2, cond4:$M3, brtarget16:$RI4),
24650b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $R2, $RI4", []>;
24660b57cec5SDimitry Andric
24670b57cec5SDimitry Andricclass AsmCmpBranchRIEb<string mnemonic, bits<16> opcode,
24680b57cec5SDimitry Andric                       RegisterOperand cls>
24690b57cec5SDimitry Andric  : InstRIEb<opcode, (outs),
24700b57cec5SDimitry Andric             (ins cls:$R1, cls:$R2, imm32zx4:$M3, brtarget16:$RI4),
24710b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $M3, $RI4", []>;
24720b57cec5SDimitry Andric
24730b57cec5SDimitry Andricclass FixedCmpBranchRIEb<CondVariant V, string mnemonic, bits<16> opcode,
24740b57cec5SDimitry Andric                         RegisterOperand cls>
24750b57cec5SDimitry Andric  : InstRIEb<opcode, (outs), (ins cls:$R1, cls:$R2, brtarget16:$RI4),
24760b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $R2, $RI4", []> {
24770b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2478fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
24790b57cec5SDimitry Andric  let M3 = V.ccmask;
24800b57cec5SDimitry Andric}
24810b57cec5SDimitry Andric
24820b57cec5SDimitry Andricmulticlass CmpBranchRIEbPair<string mnemonic, bits<16> opcode,
24830b57cec5SDimitry Andric                             RegisterOperand cls> {
24840b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
24850b57cec5SDimitry Andric    def "" : CmpBranchRIEb<mnemonic, opcode, cls>;
24860b57cec5SDimitry Andric  def Asm : AsmCmpBranchRIEb<mnemonic, opcode, cls>;
24870b57cec5SDimitry Andric}
24880b57cec5SDimitry Andric
24890b57cec5SDimitry Andricclass CmpBranchRIEc<string mnemonic, bits<16> opcode,
24908bcb0991SDimitry Andric                    RegisterOperand cls, ImmOpWithPattern imm>
24910b57cec5SDimitry Andric  : InstRIEc<opcode, (outs),
24920b57cec5SDimitry Andric             (ins cls:$R1, imm:$I2, cond4:$M3, brtarget16:$RI4),
24930b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $I2, $RI4", []>;
24940b57cec5SDimitry Andric
24950b57cec5SDimitry Andricclass AsmCmpBranchRIEc<string mnemonic, bits<16> opcode,
24968bcb0991SDimitry Andric                       RegisterOperand cls, ImmOpWithPattern imm>
24970b57cec5SDimitry Andric  : InstRIEc<opcode, (outs),
24980b57cec5SDimitry Andric             (ins cls:$R1, imm:$I2, imm32zx4:$M3, brtarget16:$RI4),
24990b57cec5SDimitry Andric             mnemonic#"\t$R1, $I2, $M3, $RI4", []>;
25000b57cec5SDimitry Andric
25010b57cec5SDimitry Andricclass FixedCmpBranchRIEc<CondVariant V, string mnemonic, bits<16> opcode,
25028bcb0991SDimitry Andric                         RegisterOperand cls, ImmOpWithPattern imm>
25030b57cec5SDimitry Andric  : InstRIEc<opcode, (outs), (ins cls:$R1, imm:$I2, brtarget16:$RI4),
25040b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $I2, $RI4", []> {
25050b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2506fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
25070b57cec5SDimitry Andric  let M3 = V.ccmask;
25080b57cec5SDimitry Andric}
25090b57cec5SDimitry Andric
25100b57cec5SDimitry Andricmulticlass CmpBranchRIEcPair<string mnemonic, bits<16> opcode,
25118bcb0991SDimitry Andric                            RegisterOperand cls, ImmOpWithPattern imm> {
25120b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
25130b57cec5SDimitry Andric    def "" : CmpBranchRIEc<mnemonic, opcode, cls, imm>;
25140b57cec5SDimitry Andric  def Asm : AsmCmpBranchRIEc<mnemonic, opcode, cls, imm>;
25150b57cec5SDimitry Andric}
25160b57cec5SDimitry Andric
25170b57cec5SDimitry Andricclass CmpBranchRRFc<string mnemonic, bits<16> opcode,
25180b57cec5SDimitry Andric                    RegisterOperand cls>
25190b57cec5SDimitry Andric  : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2, cond4:$M3),
25200b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $R2", []>;
25210b57cec5SDimitry Andric
25220b57cec5SDimitry Andricclass AsmCmpBranchRRFc<string mnemonic, bits<16> opcode,
25230b57cec5SDimitry Andric                       RegisterOperand cls>
25240b57cec5SDimitry Andric  : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2, imm32zx4:$M3),
25250b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $M3", []>;
25260b57cec5SDimitry Andric
25270b57cec5SDimitry Andricmulticlass CmpBranchRRFcPair<string mnemonic, bits<16> opcode,
25280b57cec5SDimitry Andric                             RegisterOperand cls> {
25290b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
25300b57cec5SDimitry Andric    def "" : CmpBranchRRFc<mnemonic, opcode, cls>;
25310b57cec5SDimitry Andric  def Asm : AsmCmpBranchRRFc<mnemonic, opcode, cls>;
25320b57cec5SDimitry Andric}
25330b57cec5SDimitry Andric
25340b57cec5SDimitry Andricclass FixedCmpBranchRRFc<CondVariant V, string mnemonic, bits<16> opcode,
25350b57cec5SDimitry Andric                          RegisterOperand cls>
25360b57cec5SDimitry Andric  : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2),
25370b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $R2", []> {
25380b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2539fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
25400b57cec5SDimitry Andric  let M3 = V.ccmask;
25410b57cec5SDimitry Andric}
25420b57cec5SDimitry Andric
25430b57cec5SDimitry Andricclass CmpBranchRRS<string mnemonic, bits<16> opcode,
25440b57cec5SDimitry Andric                   RegisterOperand cls>
25450b57cec5SDimitry Andric  : InstRRS<opcode, (outs),
254606c3fb27SDimitry Andric            (ins cls:$R1, cls:$R2, cond4:$M3, (bdaddr12only $B4, $D4):$BD4),
25470b57cec5SDimitry Andric            mnemonic#"$M3\t$R1, $R2, $BD4", []>;
25480b57cec5SDimitry Andric
25490b57cec5SDimitry Andricclass AsmCmpBranchRRS<string mnemonic, bits<16> opcode,
25500b57cec5SDimitry Andric                      RegisterOperand cls>
25510b57cec5SDimitry Andric  : InstRRS<opcode, (outs),
255206c3fb27SDimitry Andric            (ins cls:$R1, cls:$R2, imm32zx4:$M3, (bdaddr12only $B4, $D4):$BD4),
25530b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2, $M3, $BD4", []>;
25540b57cec5SDimitry Andric
25550b57cec5SDimitry Andricclass FixedCmpBranchRRS<CondVariant V, string mnemonic, bits<16> opcode,
25560b57cec5SDimitry Andric                        RegisterOperand cls>
255706c3fb27SDimitry Andric  : InstRRS<opcode, (outs),
255806c3fb27SDimitry Andric            (ins cls:$R1, cls:$R2, (bdaddr12only $B4, $D4):$BD4),
25590b57cec5SDimitry Andric            mnemonic#V.suffix#"\t$R1, $R2, $BD4", []> {
25600b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2561fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
25620b57cec5SDimitry Andric  let M3 = V.ccmask;
25630b57cec5SDimitry Andric}
25640b57cec5SDimitry Andric
25650b57cec5SDimitry Andricmulticlass CmpBranchRRSPair<string mnemonic, bits<16> opcode,
25660b57cec5SDimitry Andric                            RegisterOperand cls> {
25670b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
25680b57cec5SDimitry Andric    def "" : CmpBranchRRS<mnemonic, opcode, cls>;
25690b57cec5SDimitry Andric  def Asm : AsmCmpBranchRRS<mnemonic, opcode, cls>;
25700b57cec5SDimitry Andric}
25710b57cec5SDimitry Andric
25720b57cec5SDimitry Andricclass CmpBranchRIS<string mnemonic, bits<16> opcode,
25738bcb0991SDimitry Andric                   RegisterOperand cls, ImmOpWithPattern imm>
25740b57cec5SDimitry Andric  : InstRIS<opcode, (outs),
257506c3fb27SDimitry Andric            (ins cls:$R1, imm:$I2, cond4:$M3, (bdaddr12only $B4, $D4):$BD4),
25760b57cec5SDimitry Andric            mnemonic#"$M3\t$R1, $I2, $BD4", []>;
25770b57cec5SDimitry Andric
25780b57cec5SDimitry Andricclass AsmCmpBranchRIS<string mnemonic, bits<16> opcode,
25798bcb0991SDimitry Andric                      RegisterOperand cls, ImmOpWithPattern imm>
25800b57cec5SDimitry Andric  : InstRIS<opcode, (outs),
258106c3fb27SDimitry Andric            (ins cls:$R1, imm:$I2, imm32zx4:$M3, (bdaddr12only $B4, $D4):$BD4),
25820b57cec5SDimitry Andric            mnemonic#"\t$R1, $I2, $M3, $BD4", []>;
25830b57cec5SDimitry Andric
25840b57cec5SDimitry Andricclass FixedCmpBranchRIS<CondVariant V, string mnemonic, bits<16> opcode,
25858bcb0991SDimitry Andric                        RegisterOperand cls, ImmOpWithPattern imm>
258606c3fb27SDimitry Andric  : InstRIS<opcode, (outs),
258706c3fb27SDimitry Andric            (ins cls:$R1, imm:$I2, (bdaddr12only $B4, $D4):$BD4),
25880b57cec5SDimitry Andric            mnemonic#V.suffix#"\t$R1, $I2, $BD4", []> {
25890b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2590fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
25910b57cec5SDimitry Andric  let M3 = V.ccmask;
25920b57cec5SDimitry Andric}
25930b57cec5SDimitry Andric
25940b57cec5SDimitry Andricmulticlass CmpBranchRISPair<string mnemonic, bits<16> opcode,
25958bcb0991SDimitry Andric                            RegisterOperand cls, ImmOpWithPattern imm> {
25960b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
25970b57cec5SDimitry Andric    def "" : CmpBranchRIS<mnemonic, opcode, cls, imm>;
25980b57cec5SDimitry Andric  def Asm : AsmCmpBranchRIS<mnemonic, opcode, cls, imm>;
25990b57cec5SDimitry Andric}
26000b57cec5SDimitry Andric
26010b57cec5SDimitry Andricclass CmpBranchRSYb<string mnemonic, bits<16> opcode,
26020b57cec5SDimitry Andric                    RegisterOperand cls>
260306c3fb27SDimitry Andric  : InstRSYb<opcode, (outs),
260406c3fb27SDimitry Andric             (ins cls:$R1, (bdaddr20only $B2, $D2):$BD2, cond4:$M3),
26050b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $BD2", []>;
26060b57cec5SDimitry Andric
26070b57cec5SDimitry Andricclass AsmCmpBranchRSYb<string mnemonic, bits<16> opcode,
26080b57cec5SDimitry Andric                       RegisterOperand cls>
260906c3fb27SDimitry Andric  : InstRSYb<opcode, (outs),
261006c3fb27SDimitry Andric             (ins cls:$R1, (bdaddr20only $B2, $D2):$BD2, imm32zx4:$M3),
26110b57cec5SDimitry Andric             mnemonic#"\t$R1, $M3, $BD2", []>;
26120b57cec5SDimitry Andric
26130b57cec5SDimitry Andricmulticlass CmpBranchRSYbPair<string mnemonic, bits<16> opcode,
26140b57cec5SDimitry Andric                             RegisterOperand cls> {
26150b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
26160b57cec5SDimitry Andric    def "" : CmpBranchRSYb<mnemonic, opcode, cls>;
26170b57cec5SDimitry Andric  def Asm : AsmCmpBranchRSYb<mnemonic, opcode, cls>;
26180b57cec5SDimitry Andric}
26190b57cec5SDimitry Andric
26200b57cec5SDimitry Andricclass FixedCmpBranchRSYb<CondVariant V, string mnemonic, bits<16> opcode,
26210b57cec5SDimitry Andric                          RegisterOperand cls>
262206c3fb27SDimitry Andric  : InstRSYb<opcode, (outs), (ins cls:$R1, (bdaddr20only $B2, $D2):$BD2),
26230b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $BD2", []> {
26240b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2625fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
26260b57cec5SDimitry Andric  let M3 = V.ccmask;
26270b57cec5SDimitry Andric}
26280b57cec5SDimitry Andric
26290b57cec5SDimitry Andricclass BranchUnaryRI<string mnemonic, bits<12> opcode, RegisterOperand cls>
26300b57cec5SDimitry Andric  : InstRIb<opcode, (outs cls:$R1), (ins cls:$R1src, brtarget16:$RI2),
26315ffd83dbSDimitry Andric            mnemonic#"\t$R1, $RI2", []> {
26320b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26330b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26340b57cec5SDimitry Andric}
26350b57cec5SDimitry Andric
26360b57cec5SDimitry Andricclass BranchUnaryRIL<string mnemonic, bits<12> opcode, RegisterOperand cls>
26370b57cec5SDimitry Andric  : InstRILb<opcode, (outs cls:$R1), (ins cls:$R1src, brtarget32:$RI2),
26385ffd83dbSDimitry Andric             mnemonic#"\t$R1, $RI2", []> {
26390b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26400b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26410b57cec5SDimitry Andric}
26420b57cec5SDimitry Andric
26430b57cec5SDimitry Andricclass BranchUnaryRR<string mnemonic, bits<8> opcode, RegisterOperand cls>
26440b57cec5SDimitry Andric  : InstRR<opcode, (outs cls:$R1), (ins cls:$R1src, GR64:$R2),
26455ffd83dbSDimitry Andric           mnemonic#"\t$R1, $R2", []> {
26460b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26470b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26480b57cec5SDimitry Andric}
26490b57cec5SDimitry Andric
26500b57cec5SDimitry Andricclass BranchUnaryRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
26510b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls:$R1), (ins cls:$R1src, GR64:$R2),
26525ffd83dbSDimitry Andric            mnemonic#"\t$R1, $R2", []> {
26530b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26540b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26550b57cec5SDimitry Andric}
26560b57cec5SDimitry Andric
26570b57cec5SDimitry Andricclass BranchUnaryRX<string mnemonic, bits<8> opcode, RegisterOperand cls>
265806c3fb27SDimitry Andric  : InstRXa<opcode, (outs cls:$R1),
265906c3fb27SDimitry Andric            (ins cls:$R1src, (bdxaddr12only $B2, $D2, $X2):$XBD2),
26605ffd83dbSDimitry Andric            mnemonic#"\t$R1, $XBD2", []> {
26610b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26620b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26630b57cec5SDimitry Andric}
26640b57cec5SDimitry Andric
26650b57cec5SDimitry Andricclass BranchUnaryRXY<string mnemonic, bits<16> opcode, RegisterOperand cls>
266606c3fb27SDimitry Andric  : InstRXYa<opcode, (outs cls:$R1),
266706c3fb27SDimitry Andric             (ins cls:$R1src, (bdxaddr20only $B2, $D2, $X2):$XBD2),
26685ffd83dbSDimitry Andric             mnemonic#"\t$R1, $XBD2", []> {
26690b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26700b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26710b57cec5SDimitry Andric}
26720b57cec5SDimitry Andric
26730b57cec5SDimitry Andricclass BranchBinaryRSI<string mnemonic, bits<8> opcode, RegisterOperand cls>
26740b57cec5SDimitry Andric  : InstRSI<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, brtarget16:$RI2),
26755ffd83dbSDimitry Andric            mnemonic#"\t$R1, $R3, $RI2", []> {
26760b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26770b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26780b57cec5SDimitry Andric}
26790b57cec5SDimitry Andric
26800b57cec5SDimitry Andricclass BranchBinaryRIEe<string mnemonic, bits<16> opcode, RegisterOperand cls>
26810b57cec5SDimitry Andric  : InstRIEe<opcode, (outs cls:$R1),
26820b57cec5SDimitry Andric             (ins cls:$R1src, cls:$R3, brtarget16:$RI2),
26835ffd83dbSDimitry Andric             mnemonic#"\t$R1, $R3, $RI2", []> {
26840b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26850b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26860b57cec5SDimitry Andric}
26870b57cec5SDimitry Andric
26880b57cec5SDimitry Andricclass BranchBinaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls>
26890b57cec5SDimitry Andric  : InstRSa<opcode, (outs cls:$R1),
269006c3fb27SDimitry Andric            (ins cls:$R1src, cls:$R3, (bdaddr12only $B2, $D2):$BD2),
26915ffd83dbSDimitry Andric            mnemonic#"\t$R1, $R3, $BD2", []> {
26920b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
26930b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
26940b57cec5SDimitry Andric}
26950b57cec5SDimitry Andric
26960b57cec5SDimitry Andricclass BranchBinaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
26970b57cec5SDimitry Andric  : InstRSYa<opcode,
269806c3fb27SDimitry Andric             (outs cls:$R1),
269906c3fb27SDimitry Andric             (ins cls:$R1src, cls:$R3, (bdaddr20only $B2, $D2):$BD2),
27005ffd83dbSDimitry Andric             mnemonic#"\t$R1, $R3, $BD2", []> {
27010b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
27020b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
27030b57cec5SDimitry Andric}
27040b57cec5SDimitry Andric
27050b57cec5SDimitry Andricclass LoadMultipleRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
27060b57cec5SDimitry Andric                     AddressingMode mode = bdaddr12only>
270706c3fb27SDimitry Andric  : InstRSa<opcode, (outs cls:$R1, cls:$R3), (ins (mode $B2, $D2):$BD2),
27080b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $BD2", []> {
27090b57cec5SDimitry Andric  let mayLoad = 1;
27100b57cec5SDimitry Andric}
27110b57cec5SDimitry Andric
27120b57cec5SDimitry Andricclass LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
27130b57cec5SDimitry Andric                      AddressingMode mode = bdaddr20only>
271406c3fb27SDimitry Andric  : InstRSYa<opcode, (outs cls:$R1, cls:$R3), (ins (mode $B2, $D2):$BD2),
27150b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $BD2", []> {
27160b57cec5SDimitry Andric  let mayLoad = 1;
27170b57cec5SDimitry Andric}
27180b57cec5SDimitry Andric
27190b57cec5SDimitry Andricmulticlass LoadMultipleRSPair<string mnemonic, bits<8> rsOpcode,
27200b57cec5SDimitry Andric                              bits<16> rsyOpcode, RegisterOperand cls> {
27215ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
27220b57cec5SDimitry Andric    let DispSize = "12" in
27230b57cec5SDimitry Andric      def "" : LoadMultipleRS<mnemonic, rsOpcode, cls, bdaddr12pair>;
27240b57cec5SDimitry Andric    let DispSize = "20" in
27250b57cec5SDimitry Andric      def Y  : LoadMultipleRSY<mnemonic#"y", rsyOpcode, cls, bdaddr20pair>;
27260b57cec5SDimitry Andric  }
27270b57cec5SDimitry Andric}
27280b57cec5SDimitry Andric
27290b57cec5SDimitry Andricclass LoadMultipleSSe<string mnemonic, bits<8> opcode, RegisterOperand cls>
27300b57cec5SDimitry Andric  : InstSSe<opcode, (outs cls:$R1, cls:$R3),
273106c3fb27SDimitry Andric            (ins (bdaddr12only $B2, $D2):$BD2, (bdaddr12only $B4, $D4):$BD4),
27320b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $BD2, $BD4", []> {
27330b57cec5SDimitry Andric  let mayLoad = 1;
27340b57cec5SDimitry Andric}
27350b57cec5SDimitry Andric
27360b57cec5SDimitry Andricmulticlass LoadMultipleVRSaAlign<string mnemonic, bits<16> opcode> {
27370b57cec5SDimitry Andric  let mayLoad = 1 in {
27380b57cec5SDimitry Andric    def Align : InstVRSa<opcode, (outs VR128:$V1, VR128:$V3),
273906c3fb27SDimitry Andric                        (ins (bdaddr12only $B2, $D2):$BD2, imm32zx4:$M4),
27400b57cec5SDimitry Andric                        mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
27410b57cec5SDimitry Andric    let M4 = 0 in
27420b57cec5SDimitry Andric      def "" : InstVRSa<opcode, (outs VR128:$V1, VR128:$V3),
274306c3fb27SDimitry Andric                        (ins (bdaddr12only $B2, $D2):$BD2),
27440b57cec5SDimitry Andric                        mnemonic#"\t$V1, $V3, $BD2", []>;
27450b57cec5SDimitry Andric  }
27460b57cec5SDimitry Andric}
27470b57cec5SDimitry Andric
27480b57cec5SDimitry Andricclass StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
27490b57cec5SDimitry Andric                 RegisterOperand cls>
27500b57cec5SDimitry Andric  : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
27510b57cec5SDimitry Andric             mnemonic#"\t$R1, $RI2",
27520b57cec5SDimitry Andric             [(operator cls:$R1, pcrel32:$RI2)]> {
27530b57cec5SDimitry Andric  let mayStore = 1;
27540b57cec5SDimitry Andric  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
27550b57cec5SDimitry Andric  // However, BDXs have two extra operands and are therefore 6 units more
27560b57cec5SDimitry Andric  // complex.
27570b57cec5SDimitry Andric  let AddedComplexity = 7;
27580b57cec5SDimitry Andric}
27590b57cec5SDimitry Andric
27600b57cec5SDimitry Andricclass StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
27610b57cec5SDimitry Andric              RegisterOperand cls, bits<5> bytes,
27620b57cec5SDimitry Andric              AddressingMode mode = bdxaddr12only>
276306c3fb27SDimitry Andric  : InstRXa<opcode, (outs), (ins cls:$R1, (mode $B2, $D2, $X2):$XBD2),
27640b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
27650b57cec5SDimitry Andric            [(operator cls:$R1, mode:$XBD2)]> {
27660b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
27670b57cec5SDimitry Andric  let OpType = "mem";
27680b57cec5SDimitry Andric  let mayStore = 1;
27690b57cec5SDimitry Andric  let AccessBytes = bytes;
27700b57cec5SDimitry Andric}
27710b57cec5SDimitry Andric
27720b57cec5SDimitry Andricclass StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
27730b57cec5SDimitry Andric               RegisterOperand cls, bits<5> bytes,
27740b57cec5SDimitry Andric               AddressingMode mode = bdxaddr20only>
277506c3fb27SDimitry Andric  : InstRXYa<opcode, (outs), (ins cls:$R1, (mode $B2, $D2, $X2):$XBD2),
27760b57cec5SDimitry Andric             mnemonic#"\t$R1, $XBD2",
27770b57cec5SDimitry Andric             [(operator cls:$R1, mode:$XBD2)]> {
27780b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
27790b57cec5SDimitry Andric  let OpType = "mem";
27800b57cec5SDimitry Andric  let mayStore = 1;
27810b57cec5SDimitry Andric  let AccessBytes = bytes;
27820b57cec5SDimitry Andric}
27830b57cec5SDimitry Andric
27840b57cec5SDimitry Andricmulticlass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
27850b57cec5SDimitry Andric                       SDPatternOperator operator, RegisterOperand cls,
27860b57cec5SDimitry Andric                       bits<5> bytes> {
27875ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
27880b57cec5SDimitry Andric    let DispSize = "12" in
27890b57cec5SDimitry Andric      def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
27900b57cec5SDimitry Andric    let DispSize = "20" in
27910b57cec5SDimitry Andric      def Y  : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
27920b57cec5SDimitry Andric                        bdxaddr20pair>;
27930b57cec5SDimitry Andric  }
27940b57cec5SDimitry Andric}
27950b57cec5SDimitry Andric
27960b57cec5SDimitry Andricclass StoreVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
27970b57cec5SDimitry Andric               TypedReg tr, bits<5> bytes, bits<4> type = 0>
279806c3fb27SDimitry Andric  : InstVRX<opcode, (outs),
279906c3fb27SDimitry Andric            (ins tr.op:$V1, (bdxaddr12only $B2, $D2, $X2):$XBD2),
28000b57cec5SDimitry Andric            mnemonic#"\t$V1, $XBD2",
28010b57cec5SDimitry Andric            [(operator (tr.vt tr.op:$V1), bdxaddr12only:$XBD2)]> {
28020b57cec5SDimitry Andric  let M3 = type;
28030b57cec5SDimitry Andric  let mayStore = 1;
28040b57cec5SDimitry Andric  let AccessBytes = bytes;
28050b57cec5SDimitry Andric}
28060b57cec5SDimitry Andric
28070b57cec5SDimitry Andricclass StoreVRXGeneric<string mnemonic, bits<16> opcode>
280806c3fb27SDimitry Andric  : InstVRX<opcode, (outs),
280906c3fb27SDimitry Andric            (ins VR128:$V1, (bdxaddr12only $B2, $D2, $X2):$XBD2, imm32zx4:$M3),
28100b57cec5SDimitry Andric            mnemonic#"\t$V1, $XBD2, $M3", []> {
28110b57cec5SDimitry Andric  let mayStore = 1;
28120b57cec5SDimitry Andric}
28130b57cec5SDimitry Andric
28140b57cec5SDimitry Andricmulticlass StoreVRXAlign<string mnemonic, bits<16> opcode> {
28150b57cec5SDimitry Andric  let mayStore = 1, AccessBytes = 16 in {
28160b57cec5SDimitry Andric    def Align : InstVRX<opcode, (outs),
281706c3fb27SDimitry Andric                        (ins VR128:$V1, (bdxaddr12only $B2, $D2, $X2):$XBD2,
281806c3fb27SDimitry Andric                             imm32zx4:$M3),
28190b57cec5SDimitry Andric                        mnemonic#"\t$V1, $XBD2, $M3", []>;
28200b57cec5SDimitry Andric    let M3 = 0 in
282106c3fb27SDimitry Andric      def "" : InstVRX<opcode, (outs),
282206c3fb27SDimitry Andric                       (ins VR128:$V1, (bdxaddr12only $B2, $D2, $X2):$XBD2),
28230b57cec5SDimitry Andric                       mnemonic#"\t$V1, $XBD2", []>;
28240b57cec5SDimitry Andric  }
28250b57cec5SDimitry Andric}
28260b57cec5SDimitry Andric
28270b57cec5SDimitry Andricclass StoreLengthVRSb<string mnemonic, bits<16> opcode,
28280b57cec5SDimitry Andric                      SDPatternOperator operator, bits<5> bytes>
282906c3fb27SDimitry Andric  : InstVRSb<opcode, (outs),
283006c3fb27SDimitry Andric             (ins VR128:$V1, GR32:$R3, (bdaddr12only $B2, $D2):$BD2),
28310b57cec5SDimitry Andric             mnemonic#"\t$V1, $R3, $BD2",
28320b57cec5SDimitry Andric             [(operator VR128:$V1, GR32:$R3, bdaddr12only:$BD2)]> {
28330b57cec5SDimitry Andric  let M4 = 0;
28340b57cec5SDimitry Andric  let mayStore = 1;
28350b57cec5SDimitry Andric  let AccessBytes = bytes;
28360b57cec5SDimitry Andric}
28370b57cec5SDimitry Andric
28380b57cec5SDimitry Andricclass StoreLengthVRSd<string mnemonic, bits<16> opcode,
28390b57cec5SDimitry Andric                      SDPatternOperator operator, bits<5> bytes>
284006c3fb27SDimitry Andric  : InstVRSd<opcode, (outs),
284106c3fb27SDimitry Andric             (ins VR128:$V1, GR32:$R3, (bdaddr12only $B2, $D2):$BD2),
28420b57cec5SDimitry Andric             mnemonic#"\t$V1, $R3, $BD2",
28430b57cec5SDimitry Andric             [(operator VR128:$V1, GR32:$R3, bdaddr12only:$BD2)]> {
28440b57cec5SDimitry Andric  let mayStore = 1;
28450b57cec5SDimitry Andric  let AccessBytes = bytes;
28460b57cec5SDimitry Andric}
28470b57cec5SDimitry Andric
28480b57cec5SDimitry Andricclass StoreLengthVSI<string mnemonic, bits<16> opcode,
28490b57cec5SDimitry Andric                     SDPatternOperator operator, bits<5> bytes>
285006c3fb27SDimitry Andric  : InstVSI<opcode, (outs),
285106c3fb27SDimitry Andric            (ins VR128:$V1, (bdaddr12only $B2, $D2):$BD2, imm32zx8:$I3),
28520b57cec5SDimitry Andric            mnemonic#"\t$V1, $BD2, $I3",
28530b57cec5SDimitry Andric            [(operator VR128:$V1, imm32zx8:$I3, bdaddr12only:$BD2)]> {
28540b57cec5SDimitry Andric  let mayStore = 1;
28550b57cec5SDimitry Andric  let AccessBytes = bytes;
28560b57cec5SDimitry Andric}
28570b57cec5SDimitry Andric
28580b57cec5SDimitry Andricclass StoreMultipleRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
28590b57cec5SDimitry Andric                      AddressingMode mode = bdaddr12only>
286006c3fb27SDimitry Andric  : InstRSa<opcode, (outs), (ins cls:$R1, cls:$R3, (mode $B2, $D2):$BD2),
28610b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $BD2", []> {
28620b57cec5SDimitry Andric  let mayStore = 1;
28630b57cec5SDimitry Andric}
28640b57cec5SDimitry Andric
28650b57cec5SDimitry Andricclass StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
28660b57cec5SDimitry Andric                       AddressingMode mode = bdaddr20only>
286706c3fb27SDimitry Andric  : InstRSYa<opcode, (outs), (ins cls:$R1, cls:$R3, (mode $B2, $D2):$BD2),
28680b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $BD2", []> {
28690b57cec5SDimitry Andric  let mayStore = 1;
28700b57cec5SDimitry Andric}
28710b57cec5SDimitry Andric
28720b57cec5SDimitry Andricmulticlass StoreMultipleRSPair<string mnemonic, bits<8> rsOpcode,
28730b57cec5SDimitry Andric                               bits<16> rsyOpcode, RegisterOperand cls> {
28745ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
28750b57cec5SDimitry Andric    let DispSize = "12" in
28760b57cec5SDimitry Andric      def "" : StoreMultipleRS<mnemonic, rsOpcode, cls, bdaddr12pair>;
28770b57cec5SDimitry Andric    let DispSize = "20" in
28780b57cec5SDimitry Andric      def Y  : StoreMultipleRSY<mnemonic#"y", rsyOpcode, cls, bdaddr20pair>;
28790b57cec5SDimitry Andric  }
28800b57cec5SDimitry Andric}
28810b57cec5SDimitry Andric
28820b57cec5SDimitry Andricmulticlass StoreMultipleVRSaAlign<string mnemonic, bits<16> opcode> {
28830b57cec5SDimitry Andric  let mayStore = 1 in {
28840b57cec5SDimitry Andric    def Align : InstVRSa<opcode, (outs), (ins VR128:$V1, VR128:$V3,
288506c3fb27SDimitry Andric                                              (bdaddr12only $B2, $D2):$BD2,
288606c3fb27SDimitry Andric                                              imm32zx4:$M4),
28870b57cec5SDimitry Andric                         mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
28880b57cec5SDimitry Andric    let M4 = 0 in
28890b57cec5SDimitry Andric      def "" : InstVRSa<opcode, (outs), (ins VR128:$V1, VR128:$V3,
289006c3fb27SDimitry Andric                                             (bdaddr12only $B2, $D2):$BD2),
28910b57cec5SDimitry Andric                        mnemonic#"\t$V1, $V3, $BD2", []>;
28920b57cec5SDimitry Andric  }
28930b57cec5SDimitry Andric}
28940b57cec5SDimitry Andric
28950b57cec5SDimitry Andric// StoreSI* instructions are used to store an integer to memory, but the
28960b57cec5SDimitry Andric// addresses are more restricted than for normal stores.  If we are in the
28970b57cec5SDimitry Andric// situation of having to force either the address into a register or the
28980b57cec5SDimitry Andric// constant into a register, it's usually better to do the latter.
28990b57cec5SDimitry Andric// We therefore match the address in the same way as a normal store and
29000b57cec5SDimitry Andric// only use the StoreSI* instruction if the matched address is suitable.
29010b57cec5SDimitry Andricclass StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
29028bcb0991SDimitry Andric              ImmOpWithPattern imm>
290306c3fb27SDimitry Andric  : InstSI<opcode, (outs), (ins (mviaddr12pair $B1, $D1):$BD1, imm:$I2),
29040b57cec5SDimitry Andric           mnemonic#"\t$BD1, $I2",
29050b57cec5SDimitry Andric           [(operator imm:$I2, mviaddr12pair:$BD1)]> {
29060b57cec5SDimitry Andric  let mayStore = 1;
29070b57cec5SDimitry Andric}
29080b57cec5SDimitry Andric
29090b57cec5SDimitry Andricclass StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
29108bcb0991SDimitry Andric               ImmOpWithPattern imm>
291106c3fb27SDimitry Andric  : InstSIY<opcode, (outs), (ins (mviaddr20pair $B1, $D1):$BD1, imm:$I2),
29120b57cec5SDimitry Andric            mnemonic#"\t$BD1, $I2",
29130b57cec5SDimitry Andric            [(operator imm:$I2, mviaddr20pair:$BD1)]> {
29140b57cec5SDimitry Andric  let mayStore = 1;
29150b57cec5SDimitry Andric}
29160b57cec5SDimitry Andric
29170b57cec5SDimitry Andricclass StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
29188bcb0991SDimitry Andric               ImmOpWithPattern imm>
291906c3fb27SDimitry Andric  : InstSIL<opcode, (outs), (ins (mviaddr12pair $B1, $D1):$BD1, imm:$I2),
29200b57cec5SDimitry Andric            mnemonic#"\t$BD1, $I2",
29210b57cec5SDimitry Andric            [(operator imm:$I2, mviaddr12pair:$BD1)]> {
29220b57cec5SDimitry Andric  let mayStore = 1;
29230b57cec5SDimitry Andric}
29240b57cec5SDimitry Andric
29250b57cec5SDimitry Andricmulticlass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
29268bcb0991SDimitry Andric                       SDPatternOperator operator, ImmOpWithPattern imm> {
29270b57cec5SDimitry Andric  let DispKey = mnemonic in {
29280b57cec5SDimitry Andric    let DispSize = "12" in
29290b57cec5SDimitry Andric      def "" : StoreSI<mnemonic, siOpcode, operator, imm>;
29300b57cec5SDimitry Andric    let DispSize = "20" in
29310b57cec5SDimitry Andric      def Y  : StoreSIY<mnemonic#"y", siyOpcode, operator, imm>;
29320b57cec5SDimitry Andric  }
29330b57cec5SDimitry Andric}
29340b57cec5SDimitry Andric
29350b57cec5SDimitry Andricclass StoreSSE<string mnemonic, bits<16> opcode>
293606c3fb27SDimitry Andric  : InstSSE<opcode, (outs),
293706c3fb27SDimitry Andric            (ins (bdaddr12only $B1, $D1):$BD1, (bdaddr12only $B2, $D2):$BD2),
29380b57cec5SDimitry Andric            mnemonic#"\t$BD1, $BD2", []> {
29390b57cec5SDimitry Andric  let mayStore = 1;
29400b57cec5SDimitry Andric}
29410b57cec5SDimitry Andric
29420b57cec5SDimitry Andricclass CondStoreRSY<string mnemonic, bits<16> opcode,
29430b57cec5SDimitry Andric                   RegisterOperand cls, bits<5> bytes,
29440b57cec5SDimitry Andric                   AddressingMode mode = bdaddr20only>
294506c3fb27SDimitry Andric  : InstRSYb<opcode, (outs),
294606c3fb27SDimitry Andric             (ins cls:$R1, (mode $B2, $D2):$BD2, cond4:$valid, cond4:$M3),
29470b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $BD2", []> {
29480b57cec5SDimitry Andric  let mayStore = 1;
29490b57cec5SDimitry Andric  let AccessBytes = bytes;
29500b57cec5SDimitry Andric  let CCMaskLast = 1;
29510b57cec5SDimitry Andric}
29520b57cec5SDimitry Andric
29530b57cec5SDimitry Andric// Like CondStoreRSY, but used for the raw assembly form.  The condition-code
29540b57cec5SDimitry Andric// mask is the third operand rather than being part of the mnemonic.
29550b57cec5SDimitry Andricclass AsmCondStoreRSY<string mnemonic, bits<16> opcode,
29560b57cec5SDimitry Andric                      RegisterOperand cls, bits<5> bytes,
29570b57cec5SDimitry Andric                      AddressingMode mode = bdaddr20only>
295806c3fb27SDimitry Andric  : InstRSYb<opcode, (outs), (ins cls:$R1, (mode $B2, $D2):$BD2, imm32zx4:$M3),
29590b57cec5SDimitry Andric             mnemonic#"\t$R1, $BD2, $M3", []> {
29600b57cec5SDimitry Andric  let mayStore = 1;
29610b57cec5SDimitry Andric  let AccessBytes = bytes;
29620b57cec5SDimitry Andric}
29630b57cec5SDimitry Andric
29640b57cec5SDimitry Andric// Like CondStoreRSY, but with a fixed CC mask.
29650b57cec5SDimitry Andricclass FixedCondStoreRSY<CondVariant V, string mnemonic, bits<16> opcode,
29660b57cec5SDimitry Andric                        RegisterOperand cls, bits<5> bytes,
29670b57cec5SDimitry Andric                        AddressingMode mode = bdaddr20only>
296806c3fb27SDimitry Andric  : InstRSYb<opcode, (outs), (ins cls:$R1, (mode $B2, $D2):$BD2),
29690b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $BD2", []> {
29700b57cec5SDimitry Andric  let mayStore = 1;
29710b57cec5SDimitry Andric  let AccessBytes = bytes;
29720b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
2973fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
29740b57cec5SDimitry Andric  let M3 = V.ccmask;
29750b57cec5SDimitry Andric}
29760b57cec5SDimitry Andric
29770b57cec5SDimitry Andricmulticlass CondStoreRSYPair<string mnemonic, bits<16> opcode,
29780b57cec5SDimitry Andric                            RegisterOperand cls, bits<5> bytes,
29790b57cec5SDimitry Andric                            AddressingMode mode = bdaddr20only> {
29800b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
29810b57cec5SDimitry Andric    def "" : CondStoreRSY<mnemonic, opcode, cls, bytes, mode>;
29820b57cec5SDimitry Andric  def Asm : AsmCondStoreRSY<mnemonic, opcode, cls, bytes, mode>;
29830b57cec5SDimitry Andric}
29840b57cec5SDimitry Andric
29858bcb0991SDimitry Andricclass SideEffectUnaryI<string mnemonic, bits<8> opcode, ImmOpWithPattern imm>
29860b57cec5SDimitry Andric  : InstI<opcode, (outs), (ins imm:$I1),
29870b57cec5SDimitry Andric          mnemonic#"\t$I1", []>;
29880b57cec5SDimitry Andric
29890b57cec5SDimitry Andricclass SideEffectUnaryRR<string mnemonic, bits<8>opcode, RegisterOperand cls>
29900b57cec5SDimitry Andric  : InstRR<opcode, (outs), (ins cls:$R1),
29910b57cec5SDimitry Andric           mnemonic#"\t$R1", []> {
29920b57cec5SDimitry Andric  let R2 = 0;
29930b57cec5SDimitry Andric}
29940b57cec5SDimitry Andric
29950b57cec5SDimitry Andricclass SideEffectUnaryRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
29960b57cec5SDimitry Andric                         SDPatternOperator operator>
29970b57cec5SDimitry Andric  : InstRRE<opcode, (outs), (ins cls:$R1),
29980b57cec5SDimitry Andric            mnemonic#"\t$R1", [(operator cls:$R1)]> {
29990b57cec5SDimitry Andric  let R2 = 0;
30000b57cec5SDimitry Andric}
30010b57cec5SDimitry Andric
30020b57cec5SDimitry Andricclass SideEffectUnaryS<string mnemonic, bits<16> opcode,
30030b57cec5SDimitry Andric                       SDPatternOperator operator, bits<5> bytes,
30040b57cec5SDimitry Andric                       AddressingMode mode = bdaddr12only>
300506c3fb27SDimitry Andric  : InstS<opcode, (outs), (ins (mode $B2, $D2):$BD2),
30060b57cec5SDimitry Andric          mnemonic#"\t$BD2", [(operator mode:$BD2)]> {
30070b57cec5SDimitry Andric  let mayLoad = 1;
30080b57cec5SDimitry Andric  let AccessBytes = bytes;
30090b57cec5SDimitry Andric}
30100b57cec5SDimitry Andric
3011fe6060f1SDimitry Andricclass SideEffectUnarySIY<string mnemonic, bits<16> opcode,
3012fe6060f1SDimitry Andric                         bits<5> bytes,
3013fe6060f1SDimitry Andric                         AddressingMode mode = bdaddr20only>
301406c3fb27SDimitry Andric  : InstSIY<opcode, (outs), (ins (mode $B1, $D1):$BD1),
3015fe6060f1SDimitry Andric            mnemonic#"\t$BD1", []> {
3016fe6060f1SDimitry Andric  let mayLoad = 1;
3017fe6060f1SDimitry Andric  let AccessBytes = bytes;
3018fe6060f1SDimitry Andric  let I2 = 0;
3019fe6060f1SDimitry Andric}
3020fe6060f1SDimitry Andric
30210b57cec5SDimitry Andricclass SideEffectAddressS<string mnemonic, bits<16> opcode,
30220b57cec5SDimitry Andric                        SDPatternOperator operator,
30230b57cec5SDimitry Andric                        AddressingMode mode = bdaddr12only>
302406c3fb27SDimitry Andric  : InstS<opcode, (outs), (ins (mode $B2, $D2):$BD2),
30250b57cec5SDimitry Andric          mnemonic#"\t$BD2", [(operator mode:$BD2)]>;
30260b57cec5SDimitry Andric
30270b57cec5SDimitry Andricclass LoadAddressRX<string mnemonic, bits<8> opcode,
30280b57cec5SDimitry Andric                    SDPatternOperator operator, AddressingMode mode>
302906c3fb27SDimitry Andric  : InstRXa<opcode, (outs GR64:$R1), (ins (mode $B2, $D2, $X2):$XBD2),
30300b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
30310b57cec5SDimitry Andric            [(set GR64:$R1, (operator mode:$XBD2))]>;
30320b57cec5SDimitry Andric
30330b57cec5SDimitry Andricclass LoadAddressRXY<string mnemonic, bits<16> opcode,
30340b57cec5SDimitry Andric                     SDPatternOperator operator, AddressingMode mode>
303506c3fb27SDimitry Andric  : InstRXYa<opcode, (outs GR64:$R1), (ins (mode $B2, $D2, $X2):$XBD2),
30360b57cec5SDimitry Andric             mnemonic#"\t$R1, $XBD2",
30370b57cec5SDimitry Andric             [(set GR64:$R1, (operator mode:$XBD2))]>;
30380b57cec5SDimitry Andric
30390b57cec5SDimitry Andricmulticlass LoadAddressRXPair<string mnemonic, bits<8> rxOpcode,
30400b57cec5SDimitry Andric                             bits<16> rxyOpcode, SDPatternOperator operator> {
30410b57cec5SDimitry Andric  let DispKey = mnemonic in {
30420b57cec5SDimitry Andric    let DispSize = "12" in
30430b57cec5SDimitry Andric      def "" : LoadAddressRX<mnemonic, rxOpcode, operator, laaddr12pair>;
30440b57cec5SDimitry Andric    let DispSize = "20" in
30450b57cec5SDimitry Andric      def Y  : LoadAddressRXY<mnemonic#"y", rxyOpcode, operator, laaddr20pair>;
30460b57cec5SDimitry Andric  }
30470b57cec5SDimitry Andric}
30480b57cec5SDimitry Andric
30490b57cec5SDimitry Andricclass LoadAddressRIL<string mnemonic, bits<12> opcode,
30500b57cec5SDimitry Andric                     SDPatternOperator operator>
30510b57cec5SDimitry Andric  : InstRILb<opcode, (outs GR64:$R1), (ins pcrel32:$RI2),
30520b57cec5SDimitry Andric             mnemonic#"\t$R1, $RI2",
30530b57cec5SDimitry Andric             [(set GR64:$R1, (operator pcrel32:$RI2))]>;
30540b57cec5SDimitry Andric
30550b57cec5SDimitry Andricclass UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
30560b57cec5SDimitry Andric              RegisterOperand cls1, RegisterOperand cls2>
30570b57cec5SDimitry Andric  : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
30580b57cec5SDimitry Andric           mnemonic#"\t$R1, $R2",
30590b57cec5SDimitry Andric           [(set cls1:$R1, (operator cls2:$R2))]> {
30600b57cec5SDimitry Andric  let OpKey = mnemonic#cls1;
30610b57cec5SDimitry Andric  let OpType = "reg";
30620b57cec5SDimitry Andric}
30630b57cec5SDimitry Andric
30640b57cec5SDimitry Andricclass UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
30650b57cec5SDimitry Andric               RegisterOperand cls1, RegisterOperand cls2>
30660b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
30670b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2",
30680b57cec5SDimitry Andric            [(set cls1:$R1, (operator cls2:$R2))]> {
30690b57cec5SDimitry Andric  let OpKey = mnemonic#cls1;
30700b57cec5SDimitry Andric  let OpType = "reg";
30710b57cec5SDimitry Andric}
30720b57cec5SDimitry Andric
30730b57cec5SDimitry Andricclass UnaryTiedRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
30740b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls:$R1), (ins cls:$R1src),
30750b57cec5SDimitry Andric            mnemonic#"\t$R1", []> {
30760b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
30770b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
30780b57cec5SDimitry Andric  let R2 = 0;
30790b57cec5SDimitry Andric}
30800b57cec5SDimitry Andric
30810b57cec5SDimitry Andricclass UnaryMemRRFc<string mnemonic, bits<16> opcode,
30820b57cec5SDimitry Andric                   RegisterOperand cls1, RegisterOperand cls2>
30830b57cec5SDimitry Andric  : InstRRFc<opcode, (outs cls2:$R2, cls1:$R1), (ins cls1:$R1src),
30840b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2", []> {
30850b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
30860b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
30870b57cec5SDimitry Andric  let M3 = 0;
30880b57cec5SDimitry Andric}
30890b57cec5SDimitry Andric
30900b57cec5SDimitry Andricclass UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
30918bcb0991SDimitry Andric              RegisterOperand cls, ImmOpWithPattern imm>
30920b57cec5SDimitry Andric  : InstRIa<opcode, (outs cls:$R1), (ins imm:$I2),
30930b57cec5SDimitry Andric            mnemonic#"\t$R1, $I2",
30940b57cec5SDimitry Andric            [(set cls:$R1, (operator imm:$I2))]>;
30950b57cec5SDimitry Andric
30960b57cec5SDimitry Andricclass UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
30978bcb0991SDimitry Andric               RegisterOperand cls, ImmOpWithPattern imm>
30980b57cec5SDimitry Andric  : InstRILa<opcode, (outs cls:$R1), (ins imm:$I2),
30990b57cec5SDimitry Andric             mnemonic#"\t$R1, $I2",
31000b57cec5SDimitry Andric             [(set cls:$R1, (operator imm:$I2))]>;
31010b57cec5SDimitry Andric
31020b57cec5SDimitry Andricclass UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
31030b57cec5SDimitry Andric                 RegisterOperand cls>
31040b57cec5SDimitry Andric  : InstRILb<opcode, (outs cls:$R1), (ins pcrel32:$RI2),
31050b57cec5SDimitry Andric             mnemonic#"\t$R1, $RI2",
31060b57cec5SDimitry Andric             [(set cls:$R1, (operator pcrel32:$RI2))]> {
31070b57cec5SDimitry Andric  let mayLoad = 1;
31080b57cec5SDimitry Andric  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
31090b57cec5SDimitry Andric  // However, BDXs have two extra operands and are therefore 6 units more
31100b57cec5SDimitry Andric  // complex.
31110b57cec5SDimitry Andric  let AddedComplexity = 7;
31120b57cec5SDimitry Andric}
31130b57cec5SDimitry Andric
31140b57cec5SDimitry Andricclass CondUnaryRSY<string mnemonic, bits<16> opcode,
31150b57cec5SDimitry Andric                   SDPatternOperator operator, RegisterOperand cls,
31160b57cec5SDimitry Andric                   bits<5> bytes, AddressingMode mode = bdaddr20only>
31170b57cec5SDimitry Andric  : InstRSYb<opcode, (outs cls:$R1),
311806c3fb27SDimitry Andric             (ins cls:$R1src, (mode $B2, $D2):$BD2, cond4:$valid, cond4:$M3),
31190b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $BD2",
31200b57cec5SDimitry Andric             [(set cls:$R1,
31210b57cec5SDimitry Andric                   (z_select_ccmask (operator bdaddr20only:$BD2), cls:$R1src,
31220b57cec5SDimitry Andric                                    cond4:$valid, cond4:$M3))]> {
31230b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
31240b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
31250b57cec5SDimitry Andric  let mayLoad = 1;
31260b57cec5SDimitry Andric  let AccessBytes = bytes;
31270b57cec5SDimitry Andric  let CCMaskLast = 1;
31285ffd83dbSDimitry Andric  let OpKey = mnemonic#"r"#cls;
31295ffd83dbSDimitry Andric  let OpType = "mem";
31305ffd83dbSDimitry Andric  let MemKey = mnemonic#cls;
31315ffd83dbSDimitry Andric  let MemType = "target";
31320b57cec5SDimitry Andric}
31330b57cec5SDimitry Andric
31340b57cec5SDimitry Andric// Like CondUnaryRSY, but used for the raw assembly form.  The condition-code
31350b57cec5SDimitry Andric// mask is the third operand rather than being part of the mnemonic.
31360b57cec5SDimitry Andricclass AsmCondUnaryRSY<string mnemonic, bits<16> opcode,
31370b57cec5SDimitry Andric                      RegisterOperand cls, bits<5> bytes,
31380b57cec5SDimitry Andric                      AddressingMode mode = bdaddr20only>
313906c3fb27SDimitry Andric  : InstRSYb<opcode, (outs cls:$R1),
314006c3fb27SDimitry Andric             (ins cls:$R1src, (mode $B2, $D2):$BD2, imm32zx4:$M3),
31410b57cec5SDimitry Andric             mnemonic#"\t$R1, $BD2, $M3", []> {
31420b57cec5SDimitry Andric  let mayLoad = 1;
31430b57cec5SDimitry Andric  let AccessBytes = bytes;
31440b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
31450b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
31460b57cec5SDimitry Andric}
31470b57cec5SDimitry Andric
31480b57cec5SDimitry Andric// Like CondUnaryRSY, but with a fixed CC mask.
31490b57cec5SDimitry Andricclass FixedCondUnaryRSY<CondVariant V, string mnemonic, bits<16> opcode,
31500b57cec5SDimitry Andric                        RegisterOperand cls, bits<5> bytes,
31510b57cec5SDimitry Andric                        AddressingMode mode = bdaddr20only>
315206c3fb27SDimitry Andric  : InstRSYb<opcode, (outs cls:$R1), (ins cls:$R1src, (mode $B2, $D2):$BD2),
31530b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $BD2", []> {
31540b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
31550b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
31560b57cec5SDimitry Andric  let mayLoad = 1;
31570b57cec5SDimitry Andric  let AccessBytes = bytes;
31580b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
3159fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
31600b57cec5SDimitry Andric  let M3 = V.ccmask;
31610b57cec5SDimitry Andric}
31620b57cec5SDimitry Andric
31630b57cec5SDimitry Andricmulticlass CondUnaryRSYPair<string mnemonic, bits<16> opcode,
31640b57cec5SDimitry Andric                            SDPatternOperator operator,
31650b57cec5SDimitry Andric                            RegisterOperand cls, bits<5> bytes,
31660b57cec5SDimitry Andric                            AddressingMode mode = bdaddr20only> {
31670b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
31680b57cec5SDimitry Andric    def "" : CondUnaryRSY<mnemonic, opcode, operator, cls, bytes, mode>;
31690b57cec5SDimitry Andric  def Asm : AsmCondUnaryRSY<mnemonic, opcode, cls, bytes, mode>;
31700b57cec5SDimitry Andric}
31710b57cec5SDimitry Andric
31720b57cec5SDimitry Andricclass UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
31730b57cec5SDimitry Andric              RegisterOperand cls, bits<5> bytes,
31740b57cec5SDimitry Andric              AddressingMode mode = bdxaddr12only>
317506c3fb27SDimitry Andric  : InstRXa<opcode, (outs cls:$R1), (ins (mode $B2, $D2, $X2):$XBD2),
31760b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
31770b57cec5SDimitry Andric            [(set cls:$R1, (operator mode:$XBD2))]> {
31780b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
31790b57cec5SDimitry Andric  let OpType = "mem";
31800b57cec5SDimitry Andric  let mayLoad = 1;
31810b57cec5SDimitry Andric  let AccessBytes = bytes;
31820b57cec5SDimitry Andric}
31830b57cec5SDimitry Andric
31840b57cec5SDimitry Andricclass UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
31850b57cec5SDimitry Andric               RegisterOperand cls, bits<5> bytes>
318606c3fb27SDimitry Andric  : InstRXE<opcode, (outs cls:$R1), (ins (bdxaddr12only $B2, $D2, $X2):$XBD2),
31870b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
31880b57cec5SDimitry Andric            [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
31890b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
31900b57cec5SDimitry Andric  let OpType = "mem";
31910b57cec5SDimitry Andric  let mayLoad = 1;
31920b57cec5SDimitry Andric  let AccessBytes = bytes;
31930b57cec5SDimitry Andric  let M3 = 0;
31940b57cec5SDimitry Andric}
31950b57cec5SDimitry Andric
31960b57cec5SDimitry Andricclass UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
31970b57cec5SDimitry Andric               RegisterOperand cls, bits<5> bytes,
31980b57cec5SDimitry Andric               AddressingMode mode = bdxaddr20only>
319906c3fb27SDimitry Andric  : InstRXYa<opcode, (outs cls:$R1), (ins (mode $B2, $D2, $X2):$XBD2),
32000b57cec5SDimitry Andric             mnemonic#"\t$R1, $XBD2",
32010b57cec5SDimitry Andric             [(set cls:$R1, (operator mode:$XBD2))]> {
32020b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
32030b57cec5SDimitry Andric  let OpType = "mem";
32040b57cec5SDimitry Andric  let mayLoad = 1;
32050b57cec5SDimitry Andric  let AccessBytes = bytes;
32060b57cec5SDimitry Andric}
32070b57cec5SDimitry Andric
32080b57cec5SDimitry Andricmulticlass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
32090b57cec5SDimitry Andric                       SDPatternOperator operator, RegisterOperand cls,
32100b57cec5SDimitry Andric                       bits<5> bytes> {
32115ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
32120b57cec5SDimitry Andric    let DispSize = "12" in
32130b57cec5SDimitry Andric      def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
32140b57cec5SDimitry Andric    let DispSize = "20" in
32150b57cec5SDimitry Andric      def Y  : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
32160b57cec5SDimitry Andric                        bdxaddr20pair>;
32170b57cec5SDimitry Andric  }
32180b57cec5SDimitry Andric}
32190b57cec5SDimitry Andric
32200b57cec5SDimitry Andricclass UnaryVRIa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
32218bcb0991SDimitry Andric                TypedReg tr, ImmOpWithPattern imm, bits<4> type = 0>
32220b57cec5SDimitry Andric  : InstVRIa<opcode, (outs tr.op:$V1), (ins imm:$I2),
32230b57cec5SDimitry Andric             mnemonic#"\t$V1, $I2",
32248bcb0991SDimitry Andric             [(set (tr.vt tr.op:$V1), (operator (i32 timm:$I2)))]> {
32250b57cec5SDimitry Andric  let M3 = type;
32260b57cec5SDimitry Andric}
32270b57cec5SDimitry Andric
32288bcb0991SDimitry Andricclass UnaryVRIaGeneric<string mnemonic, bits<16> opcode, ImmOpWithPattern imm>
32290b57cec5SDimitry Andric  : InstVRIa<opcode, (outs VR128:$V1), (ins imm:$I2, imm32zx4:$M3),
32300b57cec5SDimitry Andric             mnemonic#"\t$V1, $I2, $M3", []>;
32310b57cec5SDimitry Andric
32320b57cec5SDimitry Andricclass UnaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
32330b57cec5SDimitry Andric                TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m4 = 0,
32345ffd83dbSDimitry Andric                bits<4> m5 = 0, string fp_mnemonic = "">
32350b57cec5SDimitry Andric  : InstVRRa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2),
32360b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2",
32370b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2)))]> {
32380b57cec5SDimitry Andric  let M3 = type;
32390b57cec5SDimitry Andric  let M4 = m4;
32400b57cec5SDimitry Andric  let M5 = m5;
32415ffd83dbSDimitry Andric  let OpKey = fp_mnemonic#!subst("VR", "FP", !cast<string>(tr1.op));
32425ffd83dbSDimitry Andric  let OpType = "reg";
32430b57cec5SDimitry Andric}
32440b57cec5SDimitry Andric
32450b57cec5SDimitry Andricclass UnaryVRRaGeneric<string mnemonic, bits<16> opcode, bits<4> m4 = 0,
32460b57cec5SDimitry Andric                       bits<4> m5 = 0>
32470b57cec5SDimitry Andric  : InstVRRa<opcode, (outs VR128:$V1), (ins VR128:$V2, imm32zx4:$M3),
32480b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M3", []> {
32490b57cec5SDimitry Andric  let M4 = m4;
32500b57cec5SDimitry Andric  let M5 = m5;
32510b57cec5SDimitry Andric}
32520b57cec5SDimitry Andric
32530b57cec5SDimitry Andricclass UnaryVRRaFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0>
32540b57cec5SDimitry Andric  : InstVRRa<opcode, (outs VR128:$V1),
32550b57cec5SDimitry Andric             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4),
32560b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M3, $M4", []> {
32570b57cec5SDimitry Andric  let M5 = m5;
32580b57cec5SDimitry Andric}
32590b57cec5SDimitry Andric
32600b57cec5SDimitry Andric// Declare a pair of instructions, one which sets CC and one which doesn't.
32610b57cec5SDimitry Andric// The CC-setting form ends with "S" and sets the low bit of M5.
32620b57cec5SDimitry Andric// The form that does not set CC has an extra operand to optionally allow
32630b57cec5SDimitry Andric// specifying arbitrary M5 values in assembler.
32640b57cec5SDimitry Andricmulticlass UnaryExtraVRRaSPair<string mnemonic, bits<16> opcode,
32650b57cec5SDimitry Andric                               SDPatternOperator operator,
32660b57cec5SDimitry Andric                               SDPatternOperator operator_cc,
32670b57cec5SDimitry Andric                               TypedReg tr1, TypedReg tr2, bits<4> type> {
32680b57cec5SDimitry Andric  let M3 = type, M4 = 0 in
32690b57cec5SDimitry Andric    def "" : InstVRRa<opcode, (outs tr1.op:$V1),
32700b57cec5SDimitry Andric                      (ins tr2.op:$V2, imm32zx4:$M5),
32710b57cec5SDimitry Andric                      mnemonic#"\t$V1, $V2, $M5", []>;
32720b57cec5SDimitry Andric  def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2))),
32730b57cec5SDimitry Andric            (!cast<Instruction>(NAME) tr2.op:$V2, 0)>;
32740b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2",
32750b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2, 0)>;
32760b57cec5SDimitry Andric  let Defs = [CC] in
32775ffd83dbSDimitry Andric    def S : UnaryVRRa<mnemonic#"s", opcode, operator_cc, tr1, tr2,
32780b57cec5SDimitry Andric                      type, 0, 1>;
32790b57cec5SDimitry Andric}
32800b57cec5SDimitry Andric
32810b57cec5SDimitry Andricmulticlass UnaryExtraVRRaSPairGeneric<string mnemonic, bits<16> opcode> {
32820b57cec5SDimitry Andric  let M4 = 0, Defs = [CC] in
32830b57cec5SDimitry Andric    def "" : InstVRRa<opcode, (outs VR128:$V1),
32840b57cec5SDimitry Andric                     (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M5),
32850b57cec5SDimitry Andric                     mnemonic#"\t$V1, $V2, $M3, $M5", []>;
32860b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $M3",
32870b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2,
32880b57cec5SDimitry Andric                                            imm32zx4:$M3, 0)>;
32890b57cec5SDimitry Andric}
32900b57cec5SDimitry Andric
32910b57cec5SDimitry Andricclass UnaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
32920b57cec5SDimitry Andric               TypedReg tr, bits<5> bytes, bits<4> type = 0>
329306c3fb27SDimitry Andric  : InstVRX<opcode, (outs tr.op:$V1), (ins (bdxaddr12only $B2, $D2, $X2):$XBD2),
32940b57cec5SDimitry Andric            mnemonic#"\t$V1, $XBD2",
32950b57cec5SDimitry Andric            [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2))]> {
32960b57cec5SDimitry Andric  let M3 = type;
32970b57cec5SDimitry Andric  let mayLoad = 1;
32980b57cec5SDimitry Andric  let AccessBytes = bytes;
32990b57cec5SDimitry Andric}
33000b57cec5SDimitry Andric
33010b57cec5SDimitry Andricclass UnaryVRXGeneric<string mnemonic, bits<16> opcode>
330206c3fb27SDimitry Andric  : InstVRX<opcode, (outs VR128:$V1),
330306c3fb27SDimitry Andric            (ins (bdxaddr12only $B2, $D2, $X2):$XBD2, imm32zx4:$M3),
33040b57cec5SDimitry Andric            mnemonic#"\t$V1, $XBD2, $M3", []> {
33050b57cec5SDimitry Andric  let mayLoad = 1;
33060b57cec5SDimitry Andric}
33070b57cec5SDimitry Andric
33080b57cec5SDimitry Andricmulticlass UnaryVRXAlign<string mnemonic, bits<16> opcode> {
33090b57cec5SDimitry Andric  let mayLoad = 1, AccessBytes = 16 in {
33100b57cec5SDimitry Andric    def Align : InstVRX<opcode, (outs VR128:$V1),
331106c3fb27SDimitry Andric                        (ins (bdxaddr12only $B2, $D2, $X2):$XBD2, imm32zx4:$M3),
33120b57cec5SDimitry Andric                        mnemonic#"\t$V1, $XBD2, $M3", []>;
33130b57cec5SDimitry Andric    let M3 = 0 in
331406c3fb27SDimitry Andric      def "" : InstVRX<opcode, (outs VR128:$V1),
331506c3fb27SDimitry Andric                       (ins (bdxaddr12only $B2, $D2, $X2):$XBD2),
33160b57cec5SDimitry Andric                       mnemonic#"\t$V1, $XBD2", []>;
33170b57cec5SDimitry Andric  }
33180b57cec5SDimitry Andric}
33190b57cec5SDimitry Andric
33200b57cec5SDimitry Andricclass SideEffectBinaryRX<string mnemonic, bits<8> opcode,
33210b57cec5SDimitry Andric                         RegisterOperand cls>
332206c3fb27SDimitry Andric  : InstRXa<opcode, (outs), (ins cls:$R1, (bdxaddr12only $B2, $D2, $X2):$XBD2),
33235ffd83dbSDimitry Andric            mnemonic#"\t$R1, $XBD2", []>;
33240b57cec5SDimitry Andric
33250b57cec5SDimitry Andricclass SideEffectBinaryRXY<string mnemonic, bits<16> opcode,
33260b57cec5SDimitry Andric                          RegisterOperand cls>
332706c3fb27SDimitry Andric  : InstRXYa<opcode, (outs), (ins cls:$R1, (bdxaddr20only $B2, $D2, $X2):$XBD2),
33285ffd83dbSDimitry Andric             mnemonic#"\t$R1, $XBD2", []>;
33290b57cec5SDimitry Andric
33300b57cec5SDimitry Andricclass SideEffectBinaryRILPC<string mnemonic, bits<12> opcode,
33310b57cec5SDimitry Andric                            RegisterOperand cls>
33320b57cec5SDimitry Andric  : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
33335ffd83dbSDimitry Andric             mnemonic#"\t$R1, $RI2", []> {
33340b57cec5SDimitry Andric  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
33350b57cec5SDimitry Andric  // However, BDXs have two extra operands and are therefore 6 units more
33360b57cec5SDimitry Andric  // complex.
33370b57cec5SDimitry Andric  let AddedComplexity = 7;
33380b57cec5SDimitry Andric}
33390b57cec5SDimitry Andric
33400b57cec5SDimitry Andricclass SideEffectBinaryRRE<string mnemonic, bits<16> opcode,
33410b57cec5SDimitry Andric                          RegisterOperand cls1, RegisterOperand cls2>
33420b57cec5SDimitry Andric  : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
33430b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2", []>;
33440b57cec5SDimitry Andric
33450b57cec5SDimitry Andricclass SideEffectBinaryRRFa<string mnemonic, bits<16> opcode,
33460b57cec5SDimitry Andric                           RegisterOperand cls1, RegisterOperand cls2>
33470b57cec5SDimitry Andric  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2),
33480b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2", []> {
33490b57cec5SDimitry Andric  let R3 = 0;
33500b57cec5SDimitry Andric  let M4 = 0;
33510b57cec5SDimitry Andric}
33520b57cec5SDimitry Andric
33530b57cec5SDimitry Andricclass SideEffectBinaryRRFc<string mnemonic, bits<16> opcode,
33540b57cec5SDimitry Andric                           RegisterOperand cls1, RegisterOperand cls2>
33550b57cec5SDimitry Andric  : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2),
33560b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2", []> {
33570b57cec5SDimitry Andric  let M3 = 0;
33580b57cec5SDimitry Andric}
33590b57cec5SDimitry Andric
33600b57cec5SDimitry Andricclass SideEffectBinaryIE<string mnemonic, bits<16> opcode,
33618bcb0991SDimitry Andric                         ImmOpWithPattern imm1, ImmOpWithPattern imm2>
33620b57cec5SDimitry Andric  : InstIE<opcode, (outs), (ins imm1:$I1, imm2:$I2),
33630b57cec5SDimitry Andric           mnemonic#"\t$I1, $I2", []>;
33640b57cec5SDimitry Andric
33650b57cec5SDimitry Andricclass SideEffectBinarySI<string mnemonic, bits<8> opcode, Operand imm>
336606c3fb27SDimitry Andric  : InstSI<opcode, (outs), (ins (bdaddr12only $B1, $D1):$BD1, imm:$I2),
33670b57cec5SDimitry Andric           mnemonic#"\t$BD1, $I2", []>;
33680b57cec5SDimitry Andric
33690b57cec5SDimitry Andricclass SideEffectBinarySIL<string mnemonic, bits<16> opcode,
33708bcb0991SDimitry Andric                          SDPatternOperator operator, ImmOpWithPattern imm>
337106c3fb27SDimitry Andric  : InstSIL<opcode, (outs), (ins (bdaddr12only $B1, $D1):$BD1, imm:$I2),
33720b57cec5SDimitry Andric            mnemonic#"\t$BD1, $I2", [(operator bdaddr12only:$BD1, imm:$I2)]>;
33730b57cec5SDimitry Andric
33740b57cec5SDimitry Andricclass SideEffectBinarySSa<string mnemonic, bits<8> opcode>
337506c3fb27SDimitry Andric  : InstSSa<opcode, (outs), (ins (bdladdr12onlylen8 $B1, $D1, $L1):$BDL1,
337606c3fb27SDimitry Andric                                 (bdaddr12only $B2, $D2):$BD2),
33775ffd83dbSDimitry Andric            mnemonic#"\t$BDL1, $BD2", []>;
33780b57cec5SDimitry Andric
33790b57cec5SDimitry Andricclass SideEffectBinarySSb<string mnemonic, bits<8> opcode>
33800b57cec5SDimitry Andric  : InstSSb<opcode,
338106c3fb27SDimitry Andric            (outs), (ins (bdladdr12onlylen4 $B1, $D1, $L1):$BDL1,
338206c3fb27SDimitry Andric                         (bdladdr12onlylen4 $B2, $D2, $L2):$BDL2),
33835ffd83dbSDimitry Andric            mnemonic#"\t$BDL1, $BDL2", []>;
33840b57cec5SDimitry Andric
33850b57cec5SDimitry Andricclass SideEffectBinarySSf<string mnemonic, bits<8> opcode>
338606c3fb27SDimitry Andric  : InstSSf<opcode, (outs), (ins (bdaddr12only $B1, $D1):$BD1,
338706c3fb27SDimitry Andric                                 (bdladdr12onlylen8 $B2, $D2, $L2):$BDL2),
33885ffd83dbSDimitry Andric            mnemonic#"\t$BD1, $BDL2", []>;
33890b57cec5SDimitry Andric
33900b57cec5SDimitry Andricclass SideEffectBinarySSE<string mnemonic, bits<16> opcode>
339106c3fb27SDimitry Andric  : InstSSE<opcode, (outs),
339206c3fb27SDimitry Andric            (ins (bdaddr12only $B1, $D1):$BD1, (bdaddr12only $B2, $D2):$BD2),
33930b57cec5SDimitry Andric            mnemonic#"\t$BD1, $BD2", []>;
33940b57cec5SDimitry Andric
33950b57cec5SDimitry Andricclass SideEffectBinaryMemMemRR<string mnemonic, bits<8> opcode,
33960b57cec5SDimitry Andric                               RegisterOperand cls1, RegisterOperand cls2>
33970b57cec5SDimitry Andric  : InstRR<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
33980b57cec5SDimitry Andric           mnemonic#"\t$R1, $R2", []> {
33990b57cec5SDimitry Andric    let Constraints = "$R1 = $R1src, $R2 = $R2src";
34000b57cec5SDimitry Andric    let DisableEncoding = "$R1src, $R2src";
34010b57cec5SDimitry Andric}
34020b57cec5SDimitry Andric
34030b57cec5SDimitry Andricclass SideEffectBinaryMemRRE<string mnemonic, bits<16> opcode,
34040b57cec5SDimitry Andric                             RegisterOperand cls1, RegisterOperand cls2>
34050b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls2:$R2), (ins cls1:$R1, cls2:$R2src),
34060b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2", []> {
34070b57cec5SDimitry Andric  let Constraints = "$R2 = $R2src";
34080b57cec5SDimitry Andric  let DisableEncoding = "$R2src";
34090b57cec5SDimitry Andric}
34100b57cec5SDimitry Andric
34110b57cec5SDimitry Andricclass SideEffectBinaryMemMemRRE<string mnemonic, bits<16> opcode,
34120b57cec5SDimitry Andric                                RegisterOperand cls1, RegisterOperand cls2>
34130b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
34140b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2", []> {
34150b57cec5SDimitry Andric    let Constraints = "$R1 = $R1src, $R2 = $R2src";
34160b57cec5SDimitry Andric    let DisableEncoding = "$R1src, $R2src";
34170b57cec5SDimitry Andric}
34180b57cec5SDimitry Andric
34190b57cec5SDimitry Andricclass SideEffectBinaryMemMemRRFc<string mnemonic, bits<16> opcode,
34200b57cec5SDimitry Andric                                 RegisterOperand cls1, RegisterOperand cls2>
34210b57cec5SDimitry Andric  : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
34220b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2", []> {
34230b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src, $R2 = $R2src";
34240b57cec5SDimitry Andric  let DisableEncoding = "$R1src, $R2src";
34250b57cec5SDimitry Andric  let M3 = 0;
34260b57cec5SDimitry Andric}
34270b57cec5SDimitry Andric
34280b57cec5SDimitry Andricclass BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
34290b57cec5SDimitry Andric               RegisterOperand cls1, RegisterOperand cls2>
34300b57cec5SDimitry Andric  : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
34310b57cec5SDimitry Andric           mnemonic#"\t$R1, $R2",
34320b57cec5SDimitry Andric           [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
34330b57cec5SDimitry Andric  let OpKey = mnemonic#cls1;
34340b57cec5SDimitry Andric  let OpType = "reg";
34350b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
34360b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
34370b57cec5SDimitry Andric}
34380b57cec5SDimitry Andric
34390b57cec5SDimitry Andricclass BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
34400b57cec5SDimitry Andric                RegisterOperand cls1, RegisterOperand cls2>
34410b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
34420b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2",
34430b57cec5SDimitry Andric            [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
34440b57cec5SDimitry Andric  let OpKey = mnemonic#cls1;
34450b57cec5SDimitry Andric  let OpType = "reg";
34460b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
34470b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
34480b57cec5SDimitry Andric}
34490b57cec5SDimitry Andric
34500b57cec5SDimitry Andricclass BinaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
34510b57cec5SDimitry Andric                RegisterOperand cls1, RegisterOperand cls2>
34520b57cec5SDimitry Andric  : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R3, cls2:$R2),
34530b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $R2",
34540b57cec5SDimitry Andric            [(set cls1:$R1, (operator cls2:$R3, cls2:$R2))]> {
34550b57cec5SDimitry Andric  let OpKey = mnemonic#cls;
34560b57cec5SDimitry Andric  let OpType = "reg";
34570b57cec5SDimitry Andric}
34580b57cec5SDimitry Andric
34590b57cec5SDimitry Andricclass BinaryRRFa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
34600b57cec5SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2,
34610b57cec5SDimitry Andric                 RegisterOperand cls3>
34620b57cec5SDimitry Andric  : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3),
34630b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $R3",
34640b57cec5SDimitry Andric             [(set cls1:$R1, (operator cls2:$R2, cls3:$R3))]> {
34650b57cec5SDimitry Andric  let M4 = 0;
34660b57cec5SDimitry Andric  let OpKey = mnemonic#cls1;
34670b57cec5SDimitry Andric  let OpType = "reg";
34680b57cec5SDimitry Andric}
34690b57cec5SDimitry Andric
3470*0fca6ea1SDimitry Andric
3471*0fca6ea1SDimitry Andricclass UnaryRRFa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3472*0fca6ea1SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2>
3473*0fca6ea1SDimitry Andric  : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls2:$R3),
3474*0fca6ea1SDimitry Andric             mnemonic#"\t$R1, $R2",
3475*0fca6ea1SDimitry Andric             [(set cls1:$R1, (operator cls2:$R2, cls2:$R3))]> {
3476*0fca6ea1SDimitry Andric  let R3 = R2;
3477*0fca6ea1SDimitry Andric  let M4 = 0;
3478*0fca6ea1SDimitry Andric  let OpKey = mnemonic#cls1;
3479*0fca6ea1SDimitry Andric  let OpType = "reg";
3480*0fca6ea1SDimitry Andric}
3481*0fca6ea1SDimitry Andric
3482*0fca6ea1SDimitry Andric
34830b57cec5SDimitry Andricmulticlass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
34840b57cec5SDimitry Andric                        SDPatternOperator operator, RegisterOperand cls1,
34850b57cec5SDimitry Andric                        RegisterOperand cls2> {
34860b57cec5SDimitry Andric  let NumOpsKey = mnemonic in {
34870b57cec5SDimitry Andric    let NumOpsValue = "3" in
34880b57cec5SDimitry Andric      def K : BinaryRRFa<mnemonic#"k", opcode2, operator, cls1, cls1, cls2>,
34890b57cec5SDimitry Andric              Requires<[FeatureDistinctOps]>;
34900b57cec5SDimitry Andric    let NumOpsValue = "2" in
34910b57cec5SDimitry Andric      def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
34920b57cec5SDimitry Andric  }
34930b57cec5SDimitry Andric}
34940b57cec5SDimitry Andric
34950b57cec5SDimitry Andricmulticlass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
34960b57cec5SDimitry Andric                         SDPatternOperator operator, RegisterOperand cls1,
34970b57cec5SDimitry Andric                         RegisterOperand cls2> {
34980b57cec5SDimitry Andric  let NumOpsKey = mnemonic in {
34990b57cec5SDimitry Andric    let NumOpsValue = "3" in
35000b57cec5SDimitry Andric      def K : BinaryRRFa<mnemonic#"k", opcode2, operator, cls1, cls1, cls2>,
35010b57cec5SDimitry Andric              Requires<[FeatureDistinctOps]>;
35020b57cec5SDimitry Andric    let NumOpsValue = "2" in
35030b57cec5SDimitry Andric      def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
35040b57cec5SDimitry Andric  }
35050b57cec5SDimitry Andric}
35060b57cec5SDimitry Andric
35070b57cec5SDimitry Andricclass BinaryRRFb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
35080b57cec5SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2,
35090b57cec5SDimitry Andric                 RegisterOperand cls3>
35100b57cec5SDimitry Andric  : InstRRFb<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3),
35110b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $R2",
35120b57cec5SDimitry Andric             [(set cls1:$R1, (operator cls2:$R2, cls3:$R3))]> {
35130b57cec5SDimitry Andric  let M4 = 0;
35140b57cec5SDimitry Andric}
35150b57cec5SDimitry Andric
35160b57cec5SDimitry Andricclass BinaryRRFc<string mnemonic, bits<16> opcode,
35170b57cec5SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2>
35180b57cec5SDimitry Andric  : InstRRFc<opcode, (outs cls1:$R1), (ins cls2:$R2, imm32zx4:$M3),
35190b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $M3", []>;
35200b57cec5SDimitry Andric
35210b57cec5SDimitry Andricclass BinaryMemRRFc<string mnemonic, bits<16> opcode,
35228bcb0991SDimitry Andric                    RegisterOperand cls1, RegisterOperand cls2, ImmOpWithPattern imm>
35230b57cec5SDimitry Andric  : InstRRFc<opcode, (outs cls2:$R2, cls1:$R1), (ins cls1:$R1src, imm:$M3),
35240b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2, $M3", []> {
35250b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
35260b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
35270b57cec5SDimitry Andric}
35280b57cec5SDimitry Andric
35290b57cec5SDimitry Andricmulticlass BinaryMemRRFcOpt<string mnemonic, bits<16> opcode,
35300b57cec5SDimitry Andric                            RegisterOperand cls1, RegisterOperand cls2> {
35310b57cec5SDimitry Andric  def "" : BinaryMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
35320b57cec5SDimitry Andric  def Opt : UnaryMemRRFc<mnemonic, opcode, cls1, cls2>;
35330b57cec5SDimitry Andric}
35340b57cec5SDimitry Andric
35350b57cec5SDimitry Andricclass BinaryRRFd<string mnemonic, bits<16> opcode, RegisterOperand cls1,
35360b57cec5SDimitry Andric                RegisterOperand cls2>
35370b57cec5SDimitry Andric  : InstRRFd<opcode, (outs cls1:$R1), (ins cls2:$R2, imm32zx4:$M4),
35380b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $M4", []>;
35390b57cec5SDimitry Andric
35400b57cec5SDimitry Andricclass BinaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
35410b57cec5SDimitry Andric                RegisterOperand cls2>
35420b57cec5SDimitry Andric  : InstRRFe<opcode, (outs cls1:$R1), (ins imm32zx4:$M3, cls2:$R2),
35430b57cec5SDimitry Andric             mnemonic#"\t$R1, $M3, $R2", []> {
35440b57cec5SDimitry Andric  let M4 = 0;
35450b57cec5SDimitry Andric}
35460b57cec5SDimitry Andric
35470b57cec5SDimitry Andricclass CondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
35480b57cec5SDimitry Andric                   RegisterOperand cls2>
35490b57cec5SDimitry Andric  : InstRRFc<opcode, (outs cls1:$R1),
35500b57cec5SDimitry Andric             (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3),
35510b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $R2",
35520b57cec5SDimitry Andric             [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls1:$R1src,
35530b57cec5SDimitry Andric                                              cond4:$valid, cond4:$M3))]> {
35540b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
35550b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
35560b57cec5SDimitry Andric  let CCMaskLast = 1;
3557480093f4SDimitry Andric  let NumOpsKey = !subst("loc", "sel", mnemonic);
3558480093f4SDimitry Andric  let NumOpsValue = "2";
35595ffd83dbSDimitry Andric  let OpKey = mnemonic#cls1;
35605ffd83dbSDimitry Andric  let OpType = "reg";
35610b57cec5SDimitry Andric}
35620b57cec5SDimitry Andric
35630b57cec5SDimitry Andric// Like CondBinaryRRF, but used for the raw assembly form.  The condition-code
35640b57cec5SDimitry Andric// mask is the third operand rather than being part of the mnemonic.
35650b57cec5SDimitry Andricclass AsmCondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
35660b57cec5SDimitry Andric                       RegisterOperand cls2>
35670b57cec5SDimitry Andric  : InstRRFc<opcode, (outs cls1:$R1),
35680b57cec5SDimitry Andric             (ins cls1:$R1src, cls2:$R2, imm32zx4:$M3),
35690b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $M3", []> {
35700b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
35710b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
35720b57cec5SDimitry Andric}
35730b57cec5SDimitry Andric
35740b57cec5SDimitry Andric// Like CondBinaryRRF, but with a fixed CC mask.
35750b57cec5SDimitry Andricclass FixedCondBinaryRRF<CondVariant V, string mnemonic, bits<16> opcode,
35760b57cec5SDimitry Andric                         RegisterOperand cls1, RegisterOperand cls2>
35770b57cec5SDimitry Andric  : InstRRFc<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
35780b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $R2", []> {
35790b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
35800b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
35810b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
3582fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
35830b57cec5SDimitry Andric  let M3 = V.ccmask;
35840b57cec5SDimitry Andric}
35850b57cec5SDimitry Andric
35860b57cec5SDimitry Andricmulticlass CondBinaryRRFPair<string mnemonic, bits<16> opcode,
35870b57cec5SDimitry Andric                             RegisterOperand cls1, RegisterOperand cls2> {
35880b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
35890b57cec5SDimitry Andric    def "" : CondBinaryRRF<mnemonic, opcode, cls1, cls2>;
35900b57cec5SDimitry Andric  def Asm : AsmCondBinaryRRF<mnemonic, opcode, cls1, cls2>;
35910b57cec5SDimitry Andric}
35920b57cec5SDimitry Andric
35930b57cec5SDimitry Andricclass CondBinaryRRFa<string mnemonic, bits<16> opcode, RegisterOperand cls1,
35940b57cec5SDimitry Andric                    RegisterOperand cls2, RegisterOperand cls3>
35950b57cec5SDimitry Andric  : InstRRFa<opcode, (outs cls1:$R1),
35960b57cec5SDimitry Andric             (ins cls3:$R3, cls2:$R2, cond4:$valid, cond4:$M4),
35970b57cec5SDimitry Andric             mnemonic#"$M4\t$R1, $R2, $R3",
35980b57cec5SDimitry Andric             [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls3:$R3,
35990b57cec5SDimitry Andric                                              cond4:$valid, cond4:$M4))]> {
36000b57cec5SDimitry Andric  let CCMaskLast = 1;
3601480093f4SDimitry Andric  let NumOpsKey = mnemonic;
3602480093f4SDimitry Andric  let NumOpsValue = "3";
36035ffd83dbSDimitry Andric  let OpKey = mnemonic#cls1;
36045ffd83dbSDimitry Andric  let OpType = "reg";
36050b57cec5SDimitry Andric}
36060b57cec5SDimitry Andric
36070b57cec5SDimitry Andric// Like CondBinaryRRFa, but used for the raw assembly form.  The condition-code
36080b57cec5SDimitry Andric// mask is the third operand rather than being part of the mnemonic.
36090b57cec5SDimitry Andricclass AsmCondBinaryRRFa<string mnemonic, bits<16> opcode, RegisterOperand cls1,
36100b57cec5SDimitry Andric                        RegisterOperand cls2, RegisterOperand cls3>
36110b57cec5SDimitry Andric  : InstRRFa<opcode, (outs cls1:$R1), (ins cls3:$R3, cls2:$R2, imm32zx4:$M4),
36120b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
36130b57cec5SDimitry Andric
36140b57cec5SDimitry Andric// Like CondBinaryRRFa, but with a fixed CC mask.
36150b57cec5SDimitry Andricclass FixedCondBinaryRRFa<CondVariant V, string mnemonic, bits<16> opcode,
36160b57cec5SDimitry Andric                         RegisterOperand cls1, RegisterOperand cls2,
36170b57cec5SDimitry Andric                         RegisterOperand cls3>
36180b57cec5SDimitry Andric  : InstRRFa<opcode, (outs cls1:$R1), (ins cls3:$R3, cls2:$R2),
36190b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $R2, $R3", []> {
36200b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
3621fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
36220b57cec5SDimitry Andric  let M4 = V.ccmask;
36230b57cec5SDimitry Andric}
36240b57cec5SDimitry Andric
36250b57cec5SDimitry Andricmulticlass CondBinaryRRFaPair<string mnemonic, bits<16> opcode,
36260b57cec5SDimitry Andric                             RegisterOperand cls1, RegisterOperand cls2,
36270b57cec5SDimitry Andric                             RegisterOperand cls3> {
36280b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
36290b57cec5SDimitry Andric    def "" : CondBinaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
36300b57cec5SDimitry Andric  def Asm : AsmCondBinaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
36310b57cec5SDimitry Andric}
36320b57cec5SDimitry Andric
36330b57cec5SDimitry Andricclass BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
36348bcb0991SDimitry Andric               RegisterOperand cls, ImmOpWithPattern imm>
36350b57cec5SDimitry Andric  : InstRIa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
36360b57cec5SDimitry Andric            mnemonic#"\t$R1, $I2",
36370b57cec5SDimitry Andric            [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
36380b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
36390b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
36400b57cec5SDimitry Andric}
36410b57cec5SDimitry Andric
36420b57cec5SDimitry Andricclass BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
36438bcb0991SDimitry Andric                RegisterOperand cls, ImmOpWithPattern imm>
36440b57cec5SDimitry Andric  : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
36450b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $I2",
36460b57cec5SDimitry Andric             [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
36470b57cec5SDimitry Andric
36480b57cec5SDimitry Andricmulticlass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
36490b57cec5SDimitry Andric                        SDPatternOperator operator, RegisterOperand cls,
36508bcb0991SDimitry Andric                        ImmOpWithPattern imm> {
36510b57cec5SDimitry Andric  let NumOpsKey = mnemonic in {
36520b57cec5SDimitry Andric    let NumOpsValue = "3" in
36535ffd83dbSDimitry Andric      def K : BinaryRIE<mnemonic#"k", opcode2, operator, cls, imm>,
36540b57cec5SDimitry Andric              Requires<[FeatureDistinctOps]>;
36550b57cec5SDimitry Andric    let NumOpsValue = "2" in
36560b57cec5SDimitry Andric      def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
36570b57cec5SDimitry Andric  }
36580b57cec5SDimitry Andric}
36590b57cec5SDimitry Andric
36600b57cec5SDimitry Andricclass CondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
36618bcb0991SDimitry Andric                    ImmOpWithPattern imm>
36620b57cec5SDimitry Andric  : InstRIEg<opcode, (outs cls:$R1),
36630b57cec5SDimitry Andric             (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
36640b57cec5SDimitry Andric             mnemonic#"$M3\t$R1, $I2",
36650b57cec5SDimitry Andric             [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
36660b57cec5SDimitry Andric                                             cond4:$valid, cond4:$M3))]> {
36670b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
36680b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
36690b57cec5SDimitry Andric  let CCMaskLast = 1;
36700b57cec5SDimitry Andric}
36710b57cec5SDimitry Andric
36720b57cec5SDimitry Andric// Like CondBinaryRIE, but used for the raw assembly form.  The condition-code
36730b57cec5SDimitry Andric// mask is the third operand rather than being part of the mnemonic.
36740b57cec5SDimitry Andricclass AsmCondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
36758bcb0991SDimitry Andric                       ImmOpWithPattern imm>
36760b57cec5SDimitry Andric  : InstRIEg<opcode, (outs cls:$R1),
36770b57cec5SDimitry Andric             (ins cls:$R1src, imm:$I2, imm32zx4:$M3),
36780b57cec5SDimitry Andric             mnemonic#"\t$R1, $I2, $M3", []> {
36790b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
36800b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
36810b57cec5SDimitry Andric}
36820b57cec5SDimitry Andric
36830b57cec5SDimitry Andric// Like CondBinaryRIE, but with a fixed CC mask.
36840b57cec5SDimitry Andricclass FixedCondBinaryRIE<CondVariant V, string mnemonic, bits<16> opcode,
36858bcb0991SDimitry Andric                         RegisterOperand cls, ImmOpWithPattern imm>
36860b57cec5SDimitry Andric  : InstRIEg<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
36870b57cec5SDimitry Andric             mnemonic#V.suffix#"\t$R1, $I2", []> {
36880b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
36890b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
36900b57cec5SDimitry Andric  let isAsmParserOnly = V.alternate;
3691fe6060f1SDimitry Andric  let AsmVariantName = V.asmvariant;
36920b57cec5SDimitry Andric  let M3 = V.ccmask;
36930b57cec5SDimitry Andric}
36940b57cec5SDimitry Andric
36950b57cec5SDimitry Andricmulticlass CondBinaryRIEPair<string mnemonic, bits<16> opcode,
36968bcb0991SDimitry Andric                             RegisterOperand cls, ImmOpWithPattern imm> {
36970b57cec5SDimitry Andric  let isCodeGenOnly = 1 in
36980b57cec5SDimitry Andric    def "" : CondBinaryRIE<mnemonic, opcode, cls, imm>;
36990b57cec5SDimitry Andric  def Asm : AsmCondBinaryRIE<mnemonic, opcode, cls, imm>;
37000b57cec5SDimitry Andric}
37010b57cec5SDimitry Andric
37020b57cec5SDimitry Andricclass BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
37038bcb0991SDimitry Andric                RegisterOperand cls, ImmOpWithPattern imm>
37040b57cec5SDimitry Andric  : InstRILa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
37050b57cec5SDimitry Andric             mnemonic#"\t$R1, $I2",
37060b57cec5SDimitry Andric             [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
37070b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
37080b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
37090b57cec5SDimitry Andric}
37100b57cec5SDimitry Andric
37110b57cec5SDimitry Andricclass BinaryRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
37120b57cec5SDimitry Andric               RegisterOperand cls>
371306c3fb27SDimitry Andric  : InstRSa<opcode, (outs cls:$R1),
371406c3fb27SDimitry Andric            (ins cls:$R1src, (shift12only $B2, $D2):$BD2),
37150b57cec5SDimitry Andric            mnemonic#"\t$R1, $BD2",
37160b57cec5SDimitry Andric            [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
37170b57cec5SDimitry Andric  let R3 = 0;
37180b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
37190b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
37200b57cec5SDimitry Andric}
37210b57cec5SDimitry Andric
37220b57cec5SDimitry Andricclass BinaryRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
37230b57cec5SDimitry Andric                RegisterOperand cls>
372406c3fb27SDimitry Andric  : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, (shift20only $B2, $D2):$BD2),
37250b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $BD2",
37260b57cec5SDimitry Andric             [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
37270b57cec5SDimitry Andric
37280b57cec5SDimitry Andricmulticlass BinaryRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
37290b57cec5SDimitry Andric                        SDPatternOperator operator, RegisterOperand cls> {
37300b57cec5SDimitry Andric  let NumOpsKey = mnemonic in {
37310b57cec5SDimitry Andric    let NumOpsValue = "3" in
37325ffd83dbSDimitry Andric      def K  : BinaryRSY<mnemonic#"k", opcode2, operator, cls>,
37330b57cec5SDimitry Andric               Requires<[FeatureDistinctOps]>;
37340b57cec5SDimitry Andric    let NumOpsValue = "2" in
37350b57cec5SDimitry Andric      def "" : BinaryRS<mnemonic, opcode1, operator, cls>;
37360b57cec5SDimitry Andric  }
37370b57cec5SDimitry Andric}
37380b57cec5SDimitry Andric
37390b57cec5SDimitry Andricclass BinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
37400b57cec5SDimitry Andric  : InstRSLb<opcode, (outs cls:$R1),
374106c3fb27SDimitry Andric             (ins (bdladdr12onlylen8 $B2, $D2, $L2):$BDL2, imm32zx4:$M3),
37420b57cec5SDimitry Andric             mnemonic#"\t$R1, $BDL2, $M3", []> {
37430b57cec5SDimitry Andric  let mayLoad = 1;
37440b57cec5SDimitry Andric}
37450b57cec5SDimitry Andric
37460b57cec5SDimitry Andricclass BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
37470b57cec5SDimitry Andric               RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
37480b57cec5SDimitry Andric               AddressingMode mode = bdxaddr12only>
374906c3fb27SDimitry Andric  : InstRXa<opcode, (outs cls:$R1), (ins cls:$R1src, (mode $B2, $D2, $X2):$XBD2),
37500b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
37510b57cec5SDimitry Andric            [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
37520b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
37530b57cec5SDimitry Andric  let OpType = "mem";
37540b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
37550b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
37560b57cec5SDimitry Andric  let mayLoad = 1;
37570b57cec5SDimitry Andric  let AccessBytes = bytes;
37580b57cec5SDimitry Andric}
37590b57cec5SDimitry Andric
37600b57cec5SDimitry Andricclass BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
37610b57cec5SDimitry Andric                  RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
376206c3fb27SDimitry Andric  : InstRXE<opcode, (outs cls:$R1),
376306c3fb27SDimitry Andric            (ins cls:$R1src, (bdxaddr12only $B2, $D2, $X2):$XBD2),
37640b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
37650b57cec5SDimitry Andric            [(set cls:$R1, (operator cls:$R1src,
37660b57cec5SDimitry Andric                                     (load bdxaddr12only:$XBD2)))]> {
37670b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
37680b57cec5SDimitry Andric  let OpType = "mem";
37690b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
37700b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
37710b57cec5SDimitry Andric  let mayLoad = 1;
37720b57cec5SDimitry Andric  let AccessBytes = bytes;
37730b57cec5SDimitry Andric  let M3 = 0;
37740b57cec5SDimitry Andric}
37750b57cec5SDimitry Andric
37760b57cec5SDimitry Andricclass BinaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
37770b57cec5SDimitry Andric                RegisterOperand cls1, RegisterOperand cls2,
37780b57cec5SDimitry Andric                SDPatternOperator load, bits<5> bytes>
377906c3fb27SDimitry Andric  : InstRXF<opcode, (outs cls1:$R1),
378006c3fb27SDimitry Andric            (ins cls2:$R3, (bdxaddr12only $B2, $D2, $X2):$XBD2),
37810b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $XBD2",
37820b57cec5SDimitry Andric            [(set cls1:$R1, (operator cls2:$R3, (load bdxaddr12only:$XBD2)))]> {
37830b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
37840b57cec5SDimitry Andric  let OpType = "mem";
37850b57cec5SDimitry Andric  let mayLoad = 1;
37860b57cec5SDimitry Andric  let AccessBytes = bytes;
37870b57cec5SDimitry Andric}
37880b57cec5SDimitry Andric
37890b57cec5SDimitry Andricclass BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
37900b57cec5SDimitry Andric                RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
37910b57cec5SDimitry Andric                AddressingMode mode = bdxaddr20only>
379206c3fb27SDimitry Andric  : InstRXYa<opcode, (outs cls:$R1),
379306c3fb27SDimitry Andric             (ins cls:$R1src, (mode $B2, $D2, $X2):$XBD2),
37940b57cec5SDimitry Andric             mnemonic#"\t$R1, $XBD2",
37950b57cec5SDimitry Andric             [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
37960b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
37970b57cec5SDimitry Andric  let OpType = "mem";
37980b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
37990b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
38000b57cec5SDimitry Andric  let mayLoad = 1;
38010b57cec5SDimitry Andric  let AccessBytes = bytes;
38020b57cec5SDimitry Andric}
38030b57cec5SDimitry Andric
38040b57cec5SDimitry Andricmulticlass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
38050b57cec5SDimitry Andric                        SDPatternOperator operator, RegisterOperand cls,
38060b57cec5SDimitry Andric                        SDPatternOperator load, bits<5> bytes> {
38075ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
38080b57cec5SDimitry Andric    let DispSize = "12" in
38090b57cec5SDimitry Andric      def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
38100b57cec5SDimitry Andric                        bdxaddr12pair>;
38110b57cec5SDimitry Andric    let DispSize = "20" in
38120b57cec5SDimitry Andric      def Y  : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
38130b57cec5SDimitry Andric                         bdxaddr20pair>;
38140b57cec5SDimitry Andric  }
38150b57cec5SDimitry Andric}
38160b57cec5SDimitry Andric
38170b57cec5SDimitry Andricclass BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
38180b57cec5SDimitry Andric               Operand imm, AddressingMode mode = bdaddr12only>
381906c3fb27SDimitry Andric  : InstSI<opcode, (outs), (ins (mode $B1, $D1):$BD1, imm:$I2),
38200b57cec5SDimitry Andric           mnemonic#"\t$BD1, $I2",
3821*0fca6ea1SDimitry Andric           [(store (operator (z_load mode:$BD1), imm:$I2), mode:$BD1)]> {
38220b57cec5SDimitry Andric  let mayLoad = 1;
38230b57cec5SDimitry Andric  let mayStore = 1;
38240b57cec5SDimitry Andric}
38250b57cec5SDimitry Andric
38260b57cec5SDimitry Andricclass BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
38270b57cec5SDimitry Andric                Operand imm, AddressingMode mode = bdaddr20only>
382806c3fb27SDimitry Andric  : InstSIY<opcode, (outs), (ins (mode $B1, $D1):$BD1, imm:$I2),
38290b57cec5SDimitry Andric            mnemonic#"\t$BD1, $I2",
3830*0fca6ea1SDimitry Andric            [(store (operator (z_load mode:$BD1), imm:$I2), mode:$BD1)]> {
38310b57cec5SDimitry Andric  let mayLoad = 1;
38320b57cec5SDimitry Andric  let mayStore = 1;
38330b57cec5SDimitry Andric}
38340b57cec5SDimitry Andric
38350b57cec5SDimitry Andricmulticlass BinarySIPair<string mnemonic, bits<8> siOpcode,
38360b57cec5SDimitry Andric                        bits<16> siyOpcode, SDPatternOperator operator,
38370b57cec5SDimitry Andric                        Operand imm> {
38385ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
38390b57cec5SDimitry Andric    let DispSize = "12" in
38400b57cec5SDimitry Andric      def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
38410b57cec5SDimitry Andric    let DispSize = "20" in
38420b57cec5SDimitry Andric      def Y  : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
38430b57cec5SDimitry Andric  }
38440b57cec5SDimitry Andric}
38450b57cec5SDimitry Andric
38460b57cec5SDimitry Andricclass BinarySSF<string mnemonic, bits<12> opcode, RegisterOperand cls>
384706c3fb27SDimitry Andric  : InstSSF<opcode, (outs cls:$R3),
384806c3fb27SDimitry Andric            (ins (bdaddr12pair $B1, $D1):$BD1, (bdaddr12pair $B2, $D2):$BD2),
38490b57cec5SDimitry Andric            mnemonic#"\t$R3, $BD1, $BD2", []> {
38500b57cec5SDimitry Andric  let mayLoad = 1;
38510b57cec5SDimitry Andric}
38520b57cec5SDimitry Andric
38530b57cec5SDimitry Andricclass BinaryVRIb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
38540b57cec5SDimitry Andric                 TypedReg tr, bits<4> type>
38550b57cec5SDimitry Andric  : InstVRIb<opcode, (outs tr.op:$V1), (ins imm32zx8:$I2, imm32zx8:$I3),
38560b57cec5SDimitry Andric             mnemonic#"\t$V1, $I2, $I3",
38578bcb0991SDimitry Andric             [(set (tr.vt tr.op:$V1), (operator imm32zx8_timm:$I2, imm32zx8_timm:$I3))]> {
38580b57cec5SDimitry Andric  let M4 = type;
38590b57cec5SDimitry Andric}
38600b57cec5SDimitry Andric
38610b57cec5SDimitry Andricclass BinaryVRIbGeneric<string mnemonic, bits<16> opcode>
38620b57cec5SDimitry Andric  : InstVRIb<opcode, (outs VR128:$V1),
38630b57cec5SDimitry Andric             (ins imm32zx8:$I2, imm32zx8:$I3, imm32zx4:$M4),
38640b57cec5SDimitry Andric             mnemonic#"\t$V1, $I2, $I3, $M4", []>;
38650b57cec5SDimitry Andric
38660b57cec5SDimitry Andricclass BinaryVRIc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
38670b57cec5SDimitry Andric                 TypedReg tr1, TypedReg tr2, bits<4> type>
38680b57cec5SDimitry Andric  : InstVRIc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, imm32zx16:$I2),
38690b57cec5SDimitry Andric             mnemonic#"\t$V1, $V3, $I2",
38700b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V3),
38718bcb0991SDimitry Andric                                                  imm32zx16_timm:$I2))]> {
38720b57cec5SDimitry Andric  let M4 = type;
38730b57cec5SDimitry Andric}
38740b57cec5SDimitry Andric
38750b57cec5SDimitry Andricclass BinaryVRIcGeneric<string mnemonic, bits<16> opcode>
38760b57cec5SDimitry Andric  : InstVRIc<opcode, (outs VR128:$V1),
38770b57cec5SDimitry Andric             (ins VR128:$V3, imm32zx16:$I2, imm32zx4:$M4),
38780b57cec5SDimitry Andric             mnemonic#"\t$V1, $V3, $I2, $M4", []>;
38790b57cec5SDimitry Andric
38800b57cec5SDimitry Andricclass BinaryVRIe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
38810b57cec5SDimitry Andric                 TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m5>
38820b57cec5SDimitry Andric  : InstVRIe<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx12:$I3),
38830b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $I3",
38840b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
38858bcb0991SDimitry Andric                                                  imm32zx12_timm:$I3))]> {
38860b57cec5SDimitry Andric  let M4 = type;
38870b57cec5SDimitry Andric  let M5 = m5;
38880b57cec5SDimitry Andric}
38890b57cec5SDimitry Andric
38900b57cec5SDimitry Andricclass BinaryVRIeFloatGeneric<string mnemonic, bits<16> opcode>
38910b57cec5SDimitry Andric  : InstVRIe<opcode, (outs VR128:$V1),
38920b57cec5SDimitry Andric             (ins VR128:$V2, imm32zx12:$I3, imm32zx4:$M4, imm32zx4:$M5),
38930b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $I3, $M4, $M5", []>;
38940b57cec5SDimitry Andric
38950b57cec5SDimitry Andricclass BinaryVRIh<string mnemonic, bits<16> opcode>
38960b57cec5SDimitry Andric  : InstVRIh<opcode, (outs VR128:$V1),
38970b57cec5SDimitry Andric             (ins imm32zx16:$I2, imm32zx4:$I3),
38980b57cec5SDimitry Andric             mnemonic#"\t$V1, $I2, $I3", []>;
38990b57cec5SDimitry Andric
39000b57cec5SDimitry Andricclass BinaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
39010b57cec5SDimitry Andric                 TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m4 = 0>
39020b57cec5SDimitry Andric  : InstVRRa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx4:$M5),
39030b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M5",
39040b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
39050b57cec5SDimitry Andric                                                  imm32zx12:$M5))]> {
39060b57cec5SDimitry Andric  let M3 = type;
39070b57cec5SDimitry Andric  let M4 = m4;
39080b57cec5SDimitry Andric}
39090b57cec5SDimitry Andric
39100b57cec5SDimitry Andricclass BinaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
39110b57cec5SDimitry Andric  : InstVRRa<opcode, (outs VR128:$V1),
39120b57cec5SDimitry Andric             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
39130b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
39140b57cec5SDimitry Andric
39150b57cec5SDimitry Andricclass BinaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
39160b57cec5SDimitry Andric                 TypedReg tr1, TypedReg tr2, bits<4> type = 0,
39170b57cec5SDimitry Andric                 bits<4> modifier = 0>
39180b57cec5SDimitry Andric  : InstVRRb<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
39190b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3",
39200b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
39210b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3)))]> {
39220b57cec5SDimitry Andric  let M4 = type;
39230b57cec5SDimitry Andric  let M5 = modifier;
39240b57cec5SDimitry Andric}
39250b57cec5SDimitry Andric
3926fe6060f1SDimitry Andricclass BinaryExtraVRRb<string mnemonic, bits<16> opcode, bits<4> type = 0>
3927fe6060f1SDimitry Andric  : InstVRRb<opcode, (outs VR128:$V1), (ins VR128:$V2, VR128:$V3, imm32zx4:$M5),
3928fe6060f1SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M5", []> {
3929fe6060f1SDimitry Andric  let M4 = type;
3930fe6060f1SDimitry Andric}
3931fe6060f1SDimitry Andric
3932fe6060f1SDimitry Andricclass BinaryExtraVRRbGeneric<string mnemonic, bits<16> opcode>
3933fe6060f1SDimitry Andric  : InstVRRb<opcode, (outs VR128:$V1),
3934fe6060f1SDimitry Andric             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3935fe6060f1SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
3936fe6060f1SDimitry Andric
39370b57cec5SDimitry Andric// Declare a pair of instructions, one which sets CC and one which doesn't.
39380b57cec5SDimitry Andric// The CC-setting form ends with "S" and sets the low bit of M5.
39390b57cec5SDimitry Andricmulticlass BinaryVRRbSPair<string mnemonic, bits<16> opcode,
39400b57cec5SDimitry Andric                           SDPatternOperator operator,
39410b57cec5SDimitry Andric                           SDPatternOperator operator_cc, TypedReg tr1,
39420b57cec5SDimitry Andric                           TypedReg tr2, bits<4> type, bits<4> modifier = 0> {
39430b57cec5SDimitry Andric  def "" : BinaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
39440b57cec5SDimitry Andric                      !and (modifier, 14)>;
39450b57cec5SDimitry Andric  let Defs = [CC] in
39465ffd83dbSDimitry Andric    def S : BinaryVRRb<mnemonic#"s", opcode, operator_cc, tr1, tr2, type,
39470b57cec5SDimitry Andric                       !add (!and (modifier, 14), 1)>;
39480b57cec5SDimitry Andric}
39490b57cec5SDimitry Andric
39500b57cec5SDimitry Andricclass BinaryVRRbSPairGeneric<string mnemonic, bits<16> opcode>
39510b57cec5SDimitry Andric  : InstVRRb<opcode, (outs VR128:$V1),
39520b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
39530b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
39540b57cec5SDimitry Andric  let Defs = [CC];
39550b57cec5SDimitry Andric}
39560b57cec5SDimitry Andric
39570b57cec5SDimitry Andric// Declare a pair of instructions, one which sets CC and one which doesn't.
39580b57cec5SDimitry Andric// The CC-setting form ends with "S" and sets the low bit of M5.
39590b57cec5SDimitry Andric// The form that does not set CC has an extra operand to optionally allow
39600b57cec5SDimitry Andric// specifying arbitrary M5 values in assembler.
39610b57cec5SDimitry Andricmulticlass BinaryExtraVRRbSPair<string mnemonic, bits<16> opcode,
39620b57cec5SDimitry Andric                                SDPatternOperator operator,
39630b57cec5SDimitry Andric                                SDPatternOperator operator_cc,
39640b57cec5SDimitry Andric                                TypedReg tr1, TypedReg tr2, bits<4> type> {
39650b57cec5SDimitry Andric  let M4 = type in
39660b57cec5SDimitry Andric    def "" : InstVRRb<opcode, (outs tr1.op:$V1),
39670b57cec5SDimitry Andric                      (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M5),
39680b57cec5SDimitry Andric                      mnemonic#"\t$V1, $V2, $V3, $M5", []>;
39690b57cec5SDimitry Andric  def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2), (tr2.vt tr2.op:$V3))),
39700b57cec5SDimitry Andric            (!cast<Instruction>(NAME) tr2.op:$V2, tr2.op:$V3, 0)>;
39710b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
39720b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
39730b57cec5SDimitry Andric                                            tr2.op:$V3, 0)>;
39740b57cec5SDimitry Andric  let Defs = [CC] in
39755ffd83dbSDimitry Andric    def S : BinaryVRRb<mnemonic#"s", opcode, operator_cc, tr1, tr2, type, 1>;
39760b57cec5SDimitry Andric}
39770b57cec5SDimitry Andric
39780b57cec5SDimitry Andricmulticlass BinaryExtraVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
39790b57cec5SDimitry Andric  let Defs = [CC] in
39800b57cec5SDimitry Andric    def "" : InstVRRb<opcode, (outs VR128:$V1),
39810b57cec5SDimitry Andric                     (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
39820b57cec5SDimitry Andric                     mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
39830b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
39840b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
39850b57cec5SDimitry Andric                                            imm32zx4:$M4, 0)>;
39860b57cec5SDimitry Andric}
39870b57cec5SDimitry Andric
39880b57cec5SDimitry Andricclass BinaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
39890b57cec5SDimitry Andric                 TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m5 = 0,
39905ffd83dbSDimitry Andric                 bits<4> m6 = 0, string fp_mnemonic = "">
39910b57cec5SDimitry Andric  : InstVRRc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
39920b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3",
39930b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
39940b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3)))]> {
39950b57cec5SDimitry Andric  let M4 = type;
39960b57cec5SDimitry Andric  let M5 = m5;
39970b57cec5SDimitry Andric  let M6 = m6;
39985ffd83dbSDimitry Andric  let OpKey = fp_mnemonic#"MemFold"#!subst("VR", "FP", !cast<string>(tr1.op));
39995ffd83dbSDimitry Andric  let OpType = "reg";
40000b57cec5SDimitry Andric}
40010b57cec5SDimitry Andric
40020b57cec5SDimitry Andricclass BinaryVRRcGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0,
40030b57cec5SDimitry Andric                        bits<4> m6 = 0>
40040b57cec5SDimitry Andric  : InstVRRc<opcode, (outs VR128:$V1),
40050b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4),
40060b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M4", []> {
40070b57cec5SDimitry Andric  let M5 = m5;
40080b57cec5SDimitry Andric  let M6 = m6;
40090b57cec5SDimitry Andric}
40100b57cec5SDimitry Andric
40110b57cec5SDimitry Andricclass BinaryVRRcFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m6 = 0>
40120b57cec5SDimitry Andric  : InstVRRc<opcode, (outs VR128:$V1),
40130b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
40140b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
40150b57cec5SDimitry Andric  let M6 = m6;
40160b57cec5SDimitry Andric}
40170b57cec5SDimitry Andric
40180b57cec5SDimitry Andric// Declare a pair of instructions, one which sets CC and one which doesn't.
40190b57cec5SDimitry Andric// The CC-setting form ends with "S" and sets the low bit of M5.
40200b57cec5SDimitry Andricmulticlass BinaryVRRcSPair<string mnemonic, bits<16> opcode,
40210b57cec5SDimitry Andric                           SDPatternOperator operator,
40220b57cec5SDimitry Andric                           SDPatternOperator operator_cc, TypedReg tr1,
40230b57cec5SDimitry Andric                           TypedReg tr2, bits<4> type, bits<4> m5,
40240b57cec5SDimitry Andric                           bits<4> modifier = 0> {
40250b57cec5SDimitry Andric  def "" : BinaryVRRc<mnemonic, opcode, operator, tr1, tr2, type,
40260b57cec5SDimitry Andric                      m5, !and (modifier, 14)>;
40270b57cec5SDimitry Andric  let Defs = [CC] in
40285ffd83dbSDimitry Andric    def S : BinaryVRRc<mnemonic#"s", opcode, operator_cc, tr1, tr2, type,
40290b57cec5SDimitry Andric                       m5, !add (!and (modifier, 14), 1)>;
40300b57cec5SDimitry Andric}
40310b57cec5SDimitry Andric
40320b57cec5SDimitry Andricclass BinaryVRRcSPairFloatGeneric<string mnemonic, bits<16> opcode>
40330b57cec5SDimitry Andric  : InstVRRc<opcode, (outs VR128:$V1),
40340b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
40350b57cec5SDimitry Andric                  imm32zx4:$M6),
40360b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
40370b57cec5SDimitry Andric
40380b57cec5SDimitry Andricclass BinaryVRRf<string mnemonic, bits<16> opcode, SDPatternOperator operator,
40390b57cec5SDimitry Andric                 TypedReg tr>
40400b57cec5SDimitry Andric  : InstVRRf<opcode, (outs tr.op:$V1), (ins GR64:$R2, GR64:$R3),
40410b57cec5SDimitry Andric             mnemonic#"\t$V1, $R2, $R3",
40420b57cec5SDimitry Andric             [(set (tr.vt tr.op:$V1), (operator GR64:$R2, GR64:$R3))]>;
40430b57cec5SDimitry Andric
40440b57cec5SDimitry Andricclass BinaryVRRi<string mnemonic, bits<16> opcode, RegisterOperand cls>
40450b57cec5SDimitry Andric  : InstVRRi<opcode, (outs cls:$R1), (ins VR128:$V2, imm32zx4:$M3),
40460b57cec5SDimitry Andric             mnemonic#"\t$R1, $V2, $M3", []> {
40470b57cec5SDimitry Andric  let M4 = 0;
40480b57cec5SDimitry Andric}
40490b57cec5SDimitry Andric
4050fe6060f1SDimitry Andricclass BinaryVRRk<string mnemonic, bits<16> opcode>
4051fe6060f1SDimitry Andric  : InstVRRk<opcode, (outs VR128:$V1), (ins VR128:$V2, imm32zx4:$M3),
4052fe6060f1SDimitry Andric             mnemonic#"\t$V1, $V2, $M3", []>;
4053fe6060f1SDimitry Andric
40540b57cec5SDimitry Andricclass BinaryVRSa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
40550b57cec5SDimitry Andric                 TypedReg tr1, TypedReg tr2, bits<4> type>
405606c3fb27SDimitry Andric  : InstVRSa<opcode, (outs tr1.op:$V1),
405706c3fb27SDimitry Andric             (ins tr2.op:$V3, (shift12only $B2, $D2):$BD2),
40580b57cec5SDimitry Andric             mnemonic#"\t$V1, $V3, $BD2",
40590b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V3),
40600b57cec5SDimitry Andric                                                  shift12only:$BD2))]> {
40610b57cec5SDimitry Andric  let M4 = type;
40620b57cec5SDimitry Andric}
40630b57cec5SDimitry Andric
40640b57cec5SDimitry Andricclass BinaryVRSaGeneric<string mnemonic, bits<16> opcode>
40650b57cec5SDimitry Andric  : InstVRSa<opcode, (outs VR128:$V1),
406606c3fb27SDimitry Andric             (ins VR128:$V3, (shift12only $B2, $D2):$BD2, imm32zx4:$M4),
40670b57cec5SDimitry Andric             mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
40680b57cec5SDimitry Andric
40690b57cec5SDimitry Andricclass BinaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
40700b57cec5SDimitry Andric                 bits<5> bytes>
407106c3fb27SDimitry Andric  : InstVRSb<opcode, (outs VR128:$V1),
407206c3fb27SDimitry Andric             (ins GR32:$R3, (bdaddr12only $B2, $D2):$BD2),
40730b57cec5SDimitry Andric             mnemonic#"\t$V1, $R3, $BD2",
40740b57cec5SDimitry Andric             [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
40750b57cec5SDimitry Andric  let M4 = 0;
40760b57cec5SDimitry Andric  let mayLoad = 1;
40770b57cec5SDimitry Andric  let AccessBytes = bytes;
40780b57cec5SDimitry Andric}
40790b57cec5SDimitry Andric
40800b57cec5SDimitry Andricclass BinaryVRSc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
40810b57cec5SDimitry Andric                 TypedReg tr, bits<4> type>
408206c3fb27SDimitry Andric  : InstVRSc<opcode, (outs GR64:$R1),
408306c3fb27SDimitry Andric             (ins tr.op:$V3, (shift12only $B2, $D2):$BD2),
40840b57cec5SDimitry Andric             mnemonic#"\t$R1, $V3, $BD2",
40850b57cec5SDimitry Andric             [(set GR64:$R1, (operator (tr.vt tr.op:$V3), shift12only:$BD2))]> {
40860b57cec5SDimitry Andric  let M4 = type;
40870b57cec5SDimitry Andric}
40880b57cec5SDimitry Andric
40890b57cec5SDimitry Andricclass BinaryVRScGeneric<string mnemonic, bits<16> opcode>
40900b57cec5SDimitry Andric  : InstVRSc<opcode, (outs GR64:$R1),
409106c3fb27SDimitry Andric             (ins VR128:$V3, (shift12only $B2, $D2):$BD2, imm32zx4: $M4),
40920b57cec5SDimitry Andric             mnemonic#"\t$R1, $V3, $BD2, $M4", []>;
40930b57cec5SDimitry Andric
40940b57cec5SDimitry Andricclass BinaryVRSd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
40950b57cec5SDimitry Andric                 bits<5> bytes>
409606c3fb27SDimitry Andric  : InstVRSd<opcode, (outs VR128:$V1),
409706c3fb27SDimitry Andric             (ins GR32:$R3, (bdaddr12only $B2, $D2):$BD2),
40980b57cec5SDimitry Andric             mnemonic#"\t$V1, $R3, $BD2",
40990b57cec5SDimitry Andric             [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
41000b57cec5SDimitry Andric  let mayLoad = 1;
41010b57cec5SDimitry Andric  let AccessBytes = bytes;
41020b57cec5SDimitry Andric}
41030b57cec5SDimitry Andric
41040b57cec5SDimitry Andricclass BinaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
41050b57cec5SDimitry Andric                TypedReg tr, bits<5> bytes>
410606c3fb27SDimitry Andric  : InstVRX<opcode, (outs VR128:$V1),
410706c3fb27SDimitry Andric            (ins (bdxaddr12only $B2, $D2, $X2):$XBD2, imm32zx4:$M3),
41080b57cec5SDimitry Andric            mnemonic#"\t$V1, $XBD2, $M3",
41090b57cec5SDimitry Andric            [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2,
41108bcb0991SDimitry Andric                                               imm32zx4_timm:$M3))]> {
41110b57cec5SDimitry Andric  let mayLoad = 1;
41120b57cec5SDimitry Andric  let AccessBytes = bytes;
41130b57cec5SDimitry Andric}
41140b57cec5SDimitry Andric
41150b57cec5SDimitry Andricclass StoreBinaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
41160b57cec5SDimitry Andric                    bits<5> bytes, AddressingMode mode = bdaddr12only>
411706c3fb27SDimitry Andric  : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, (mode $B2, $D2):$BD2),
41180b57cec5SDimitry Andric            mnemonic#"\t$R1, $M3, $BD2", []> {
41190b57cec5SDimitry Andric  let mayStore = 1;
41200b57cec5SDimitry Andric  let AccessBytes = bytes;
41210b57cec5SDimitry Andric}
41220b57cec5SDimitry Andric
41230b57cec5SDimitry Andricclass StoreBinaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
41240b57cec5SDimitry Andric                     bits<5> bytes, AddressingMode mode = bdaddr20only>
412506c3fb27SDimitry Andric  : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, (mode $B2, $D2):$BD2),
41260b57cec5SDimitry Andric             mnemonic#"\t$R1, $M3, $BD2", []> {
41270b57cec5SDimitry Andric  let mayStore = 1;
41280b57cec5SDimitry Andric  let AccessBytes = bytes;
41290b57cec5SDimitry Andric}
41300b57cec5SDimitry Andric
41310b57cec5SDimitry Andricmulticlass StoreBinaryRSPair<string mnemonic, bits<8> rsOpcode,
41320b57cec5SDimitry Andric                             bits<16> rsyOpcode, RegisterOperand cls,
41330b57cec5SDimitry Andric                             bits<5> bytes> {
41345ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
41350b57cec5SDimitry Andric    let DispSize = "12" in
41360b57cec5SDimitry Andric      def "" : StoreBinaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
41370b57cec5SDimitry Andric    let DispSize = "20" in
41380b57cec5SDimitry Andric      def Y  : StoreBinaryRSY<mnemonic#"y", rsyOpcode, cls, bytes,
41390b57cec5SDimitry Andric                              bdaddr20pair>;
41400b57cec5SDimitry Andric  }
41410b57cec5SDimitry Andric}
41420b57cec5SDimitry Andric
41430b57cec5SDimitry Andricclass StoreBinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
41440b57cec5SDimitry Andric  : InstRSLb<opcode, (outs),
414506c3fb27SDimitry Andric             (ins cls:$R1, (bdladdr12onlylen8 $B2, $D2, $L2):$BDL2,
414606c3fb27SDimitry Andric                  imm32zx4:$M3),
41470b57cec5SDimitry Andric             mnemonic#"\t$R1, $BDL2, $M3", []> {
41480b57cec5SDimitry Andric  let mayStore = 1;
41490b57cec5SDimitry Andric}
41500b57cec5SDimitry Andric
41510b57cec5SDimitry Andricclass BinaryVSI<string mnemonic, bits<16> opcode, SDPatternOperator operator,
41520b57cec5SDimitry Andric                bits<5> bytes>
415306c3fb27SDimitry Andric  : InstVSI<opcode, (outs VR128:$V1),
415406c3fb27SDimitry Andric            (ins (bdaddr12only $B2, $D2):$BD2, imm32zx8:$I3),
41550b57cec5SDimitry Andric            mnemonic#"\t$V1, $BD2, $I3",
41560b57cec5SDimitry Andric            [(set VR128:$V1, (operator imm32zx8:$I3, bdaddr12only:$BD2))]> {
41570b57cec5SDimitry Andric  let mayLoad = 1;
41580b57cec5SDimitry Andric  let AccessBytes = bytes;
41590b57cec5SDimitry Andric}
41600b57cec5SDimitry Andric
41610b57cec5SDimitry Andricclass StoreBinaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
41628bcb0991SDimitry Andric                     ImmOpWithPattern index>
416306c3fb27SDimitry Andric  : InstVRV<opcode, (outs),
416406c3fb27SDimitry Andric            (ins VR128:$V1, (bdvaddr12only $B2, $D2, $V2):$VBD2, index:$M3),
41650b57cec5SDimitry Andric            mnemonic#"\t$V1, $VBD2, $M3", []> {
41660b57cec5SDimitry Andric  let mayStore = 1;
41670b57cec5SDimitry Andric  let AccessBytes = bytes;
41680b57cec5SDimitry Andric}
41690b57cec5SDimitry Andric
41700b57cec5SDimitry Andricclass StoreBinaryVRX<string mnemonic, bits<16> opcode,
41710b57cec5SDimitry Andric                     SDPatternOperator operator, TypedReg tr, bits<5> bytes,
41728bcb0991SDimitry Andric                     ImmOpWithPattern index>
417306c3fb27SDimitry Andric  : InstVRX<opcode, (outs),
417406c3fb27SDimitry Andric            (ins tr.op:$V1, (bdxaddr12only $B2, $D2, $X2):$XBD2, index:$M3),
41750b57cec5SDimitry Andric            mnemonic#"\t$V1, $XBD2, $M3",
41760b57cec5SDimitry Andric            [(operator (tr.vt tr.op:$V1), bdxaddr12only:$XBD2, index:$M3)]> {
41770b57cec5SDimitry Andric  let mayStore = 1;
41780b57cec5SDimitry Andric  let AccessBytes = bytes;
41790b57cec5SDimitry Andric}
41800b57cec5SDimitry Andric
41810b57cec5SDimitry Andricclass MemoryBinarySSd<string mnemonic, bits<8> opcode,
41820b57cec5SDimitry Andric                      RegisterOperand cls>
41830b57cec5SDimitry Andric  : InstSSd<opcode, (outs),
418406c3fb27SDimitry Andric            (ins (bdraddr12only $B1, $D1, $R1):$RBD1,
418506c3fb27SDimitry Andric                 (bdaddr12only $B2, $D2):$BD2, cls:$R3),
41860b57cec5SDimitry Andric            mnemonic#"\t$RBD1, $BD2, $R3", []>;
41870b57cec5SDimitry Andric
41880b57cec5SDimitry Andricclass CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
41890b57cec5SDimitry Andric                RegisterOperand cls1, RegisterOperand cls2>
41900b57cec5SDimitry Andric  : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
41910b57cec5SDimitry Andric           mnemonic#"\t$R1, $R2",
41920b57cec5SDimitry Andric           [(set CC, (operator cls1:$R1, cls2:$R2))]> {
41930b57cec5SDimitry Andric  let OpKey = mnemonic#cls1;
41940b57cec5SDimitry Andric  let OpType = "reg";
41950b57cec5SDimitry Andric  let isCompare = 1;
41960b57cec5SDimitry Andric}
41970b57cec5SDimitry Andric
41980b57cec5SDimitry Andricclass CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
41990b57cec5SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2>
42000b57cec5SDimitry Andric  : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
42010b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2",
42020b57cec5SDimitry Andric            [(set CC, (operator cls1:$R1, cls2:$R2))]> {
42030b57cec5SDimitry Andric  let OpKey = mnemonic#cls1;
42040b57cec5SDimitry Andric  let OpType = "reg";
42050b57cec5SDimitry Andric  let isCompare = 1;
42060b57cec5SDimitry Andric}
42070b57cec5SDimitry Andric
42080b57cec5SDimitry Andricclass CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
42098bcb0991SDimitry Andric                RegisterOperand cls, ImmOpWithPattern imm>
42100b57cec5SDimitry Andric  : InstRIa<opcode, (outs), (ins cls:$R1, imm:$I2),
42110b57cec5SDimitry Andric            mnemonic#"\t$R1, $I2",
42120b57cec5SDimitry Andric            [(set CC, (operator cls:$R1, imm:$I2))]> {
42130b57cec5SDimitry Andric  let isCompare = 1;
42140b57cec5SDimitry Andric}
42150b57cec5SDimitry Andric
42160b57cec5SDimitry Andricclass CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
42178bcb0991SDimitry Andric                 RegisterOperand cls, ImmOpWithPattern imm>
42180b57cec5SDimitry Andric  : InstRILa<opcode, (outs), (ins cls:$R1, imm:$I2),
42190b57cec5SDimitry Andric             mnemonic#"\t$R1, $I2",
42200b57cec5SDimitry Andric             [(set CC, (operator cls:$R1, imm:$I2))]> {
42210b57cec5SDimitry Andric  let isCompare = 1;
42220b57cec5SDimitry Andric}
42230b57cec5SDimitry Andric
42240b57cec5SDimitry Andricclass CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
42250b57cec5SDimitry Andric                   RegisterOperand cls, SDPatternOperator load>
42260b57cec5SDimitry Andric  : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
42270b57cec5SDimitry Andric             mnemonic#"\t$R1, $RI2",
42280b57cec5SDimitry Andric             [(set CC, (operator cls:$R1, (load pcrel32:$RI2)))]> {
42290b57cec5SDimitry Andric  let isCompare = 1;
42300b57cec5SDimitry Andric  let mayLoad = 1;
42310b57cec5SDimitry Andric  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
42320b57cec5SDimitry Andric  // However, BDXs have two extra operands and are therefore 6 units more
42330b57cec5SDimitry Andric  // complex.
42340b57cec5SDimitry Andric  let AddedComplexity = 7;
42350b57cec5SDimitry Andric}
42360b57cec5SDimitry Andric
42370b57cec5SDimitry Andricclass CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
42380b57cec5SDimitry Andric                RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
42390b57cec5SDimitry Andric                AddressingMode mode = bdxaddr12only>
424006c3fb27SDimitry Andric  : InstRXa<opcode, (outs), (ins cls:$R1, (mode $B2, $D2, $X2):$XBD2),
42410b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
42420b57cec5SDimitry Andric            [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
42430b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
42440b57cec5SDimitry Andric  let OpType = "mem";
42450b57cec5SDimitry Andric  let isCompare = 1;
42460b57cec5SDimitry Andric  let mayLoad = 1;
42470b57cec5SDimitry Andric  let AccessBytes = bytes;
42480b57cec5SDimitry Andric}
42490b57cec5SDimitry Andric
42500b57cec5SDimitry Andricclass CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
42510b57cec5SDimitry Andric                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
425206c3fb27SDimitry Andric  : InstRXE<opcode, (outs), (ins cls:$R1, (bdxaddr12only $B2, $D2, $X2):$XBD2),
42530b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
42540b57cec5SDimitry Andric            [(set CC, (operator cls:$R1, (load bdxaddr12only:$XBD2)))]> {
42550b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
42560b57cec5SDimitry Andric  let OpType = "mem";
42570b57cec5SDimitry Andric  let isCompare = 1;
42580b57cec5SDimitry Andric  let mayLoad = 1;
42590b57cec5SDimitry Andric  let AccessBytes = bytes;
42600b57cec5SDimitry Andric  let M3 = 0;
42610b57cec5SDimitry Andric}
42620b57cec5SDimitry Andric
42630b57cec5SDimitry Andricclass CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
42640b57cec5SDimitry Andric                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
42650b57cec5SDimitry Andric                 AddressingMode mode = bdxaddr20only>
426606c3fb27SDimitry Andric  : InstRXYa<opcode, (outs), (ins cls:$R1, (mode $B2, $D2, $X2):$XBD2),
42670b57cec5SDimitry Andric             mnemonic#"\t$R1, $XBD2",
42680b57cec5SDimitry Andric             [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
42690b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
42700b57cec5SDimitry Andric  let OpType = "mem";
42710b57cec5SDimitry Andric  let isCompare = 1;
42720b57cec5SDimitry Andric  let mayLoad = 1;
42730b57cec5SDimitry Andric  let AccessBytes = bytes;
42740b57cec5SDimitry Andric}
42750b57cec5SDimitry Andric
42760b57cec5SDimitry Andricmulticlass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
42770b57cec5SDimitry Andric                         SDPatternOperator operator, RegisterOperand cls,
42780b57cec5SDimitry Andric                         SDPatternOperator load, bits<5> bytes> {
42795ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
42800b57cec5SDimitry Andric    let DispSize = "12" in
42810b57cec5SDimitry Andric      def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
42820b57cec5SDimitry Andric                         load, bytes, bdxaddr12pair>;
42830b57cec5SDimitry Andric    let DispSize = "20" in
42840b57cec5SDimitry Andric      def Y  : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
42850b57cec5SDimitry Andric                          load, bytes, bdxaddr20pair>;
42860b57cec5SDimitry Andric  }
42870b57cec5SDimitry Andric}
42880b57cec5SDimitry Andric
42890b57cec5SDimitry Andricclass CompareRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
42900b57cec5SDimitry Andric                bits<5> bytes, AddressingMode mode = bdaddr12only>
429106c3fb27SDimitry Andric  : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, (mode $B2, $D2):$BD2),
42920b57cec5SDimitry Andric            mnemonic#"\t$R1, $M3, $BD2", []> {
42930b57cec5SDimitry Andric  let mayLoad = 1;
42940b57cec5SDimitry Andric  let AccessBytes = bytes;
42950b57cec5SDimitry Andric}
42960b57cec5SDimitry Andric
42970b57cec5SDimitry Andricclass CompareRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
42980b57cec5SDimitry Andric                 bits<5> bytes, AddressingMode mode = bdaddr20only>
429906c3fb27SDimitry Andric  : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, (mode $B2, $D2):$BD2),
43000b57cec5SDimitry Andric             mnemonic#"\t$R1, $M3, $BD2", []> {
43010b57cec5SDimitry Andric  let mayLoad = 1;
43020b57cec5SDimitry Andric  let AccessBytes = bytes;
43030b57cec5SDimitry Andric}
43040b57cec5SDimitry Andric
43050b57cec5SDimitry Andricmulticlass CompareRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
43060b57cec5SDimitry Andric                         RegisterOperand cls, bits<5> bytes> {
43075ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
43080b57cec5SDimitry Andric    let DispSize = "12" in
43090b57cec5SDimitry Andric      def "" : CompareRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
43100b57cec5SDimitry Andric    let DispSize = "20" in
43110b57cec5SDimitry Andric      def Y  : CompareRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
43120b57cec5SDimitry Andric  }
43130b57cec5SDimitry Andric}
43140b57cec5SDimitry Andric
43150b57cec5SDimitry Andricclass CompareSSb<string mnemonic, bits<8> opcode>
43160b57cec5SDimitry Andric  : InstSSb<opcode,
431706c3fb27SDimitry Andric            (outs), (ins (bdladdr12onlylen4 $B1, $D1, $L1):$BDL1,
431806c3fb27SDimitry Andric                         (bdladdr12onlylen4 $B2, $D2, $L2):$BDL2),
43195ffd83dbSDimitry Andric            mnemonic#"\t$BDL1, $BDL2", []> {
43200b57cec5SDimitry Andric  let isCompare = 1;
43210b57cec5SDimitry Andric  let mayLoad = 1;
43220b57cec5SDimitry Andric}
43230b57cec5SDimitry Andric
43240b57cec5SDimitry Andricclass CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
43258bcb0991SDimitry Andric                SDPatternOperator load, ImmOpWithPattern imm,
43260b57cec5SDimitry Andric                AddressingMode mode = bdaddr12only>
432706c3fb27SDimitry Andric  : InstSI<opcode, (outs), (ins (mode $B1, $D1):$BD1, imm:$I2),
43280b57cec5SDimitry Andric           mnemonic#"\t$BD1, $I2",
43290b57cec5SDimitry Andric           [(set CC, (operator (load mode:$BD1), imm:$I2))]> {
43300b57cec5SDimitry Andric  let isCompare = 1;
43310b57cec5SDimitry Andric  let mayLoad = 1;
43320b57cec5SDimitry Andric}
43330b57cec5SDimitry Andric
43340b57cec5SDimitry Andricclass CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
43358bcb0991SDimitry Andric                 SDPatternOperator load, ImmOpWithPattern imm>
433606c3fb27SDimitry Andric  : InstSIL<opcode, (outs), (ins (bdaddr12only $B1, $D1):$BD1, imm:$I2),
43370b57cec5SDimitry Andric            mnemonic#"\t$BD1, $I2",
43380b57cec5SDimitry Andric            [(set CC, (operator (load bdaddr12only:$BD1), imm:$I2))]> {
43390b57cec5SDimitry Andric  let isCompare = 1;
43400b57cec5SDimitry Andric  let mayLoad = 1;
43410b57cec5SDimitry Andric}
43420b57cec5SDimitry Andric
43430b57cec5SDimitry Andricclass CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
43448bcb0991SDimitry Andric                 SDPatternOperator load, ImmOpWithPattern imm,
43450b57cec5SDimitry Andric                 AddressingMode mode = bdaddr20only>
434606c3fb27SDimitry Andric  : InstSIY<opcode, (outs), (ins (mode $B1, $D1):$BD1, imm:$I2),
43470b57cec5SDimitry Andric            mnemonic#"\t$BD1, $I2",
43480b57cec5SDimitry Andric            [(set CC, (operator (load mode:$BD1), imm:$I2))]> {
43490b57cec5SDimitry Andric  let isCompare = 1;
43500b57cec5SDimitry Andric  let mayLoad = 1;
43510b57cec5SDimitry Andric}
43520b57cec5SDimitry Andric
43530b57cec5SDimitry Andricmulticlass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
43540b57cec5SDimitry Andric                         SDPatternOperator operator, SDPatternOperator load,
43558bcb0991SDimitry Andric                         ImmOpWithPattern imm> {
43560b57cec5SDimitry Andric  let DispKey = mnemonic in {
43570b57cec5SDimitry Andric    let DispSize = "12" in
43580b57cec5SDimitry Andric      def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
43590b57cec5SDimitry Andric    let DispSize = "20" in
43600b57cec5SDimitry Andric      def Y  : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
43610b57cec5SDimitry Andric                          bdaddr20pair>;
43620b57cec5SDimitry Andric  }
43630b57cec5SDimitry Andric}
43640b57cec5SDimitry Andric
43650b57cec5SDimitry Andricclass CompareVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
43665ffd83dbSDimitry Andric                  TypedReg tr, bits<4> type, string fp_mnemonic = "">
43670b57cec5SDimitry Andric  : InstVRRa<opcode, (outs), (ins tr.op:$V1, tr.op:$V2),
43680b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2",
43690b57cec5SDimitry Andric             [(set CC, (operator (tr.vt tr.op:$V1), (tr.vt tr.op:$V2)))]> {
43700b57cec5SDimitry Andric  let isCompare = 1;
43710b57cec5SDimitry Andric  let M3 = type;
43720b57cec5SDimitry Andric  let M4 = 0;
43730b57cec5SDimitry Andric  let M5 = 0;
43745ffd83dbSDimitry Andric  let OpKey = fp_mnemonic#!subst("VR", "FP", !cast<string>(tr.op));
43755ffd83dbSDimitry Andric  let OpType = "reg";
43760b57cec5SDimitry Andric}
43770b57cec5SDimitry Andric
43780b57cec5SDimitry Andricclass CompareVRRaGeneric<string mnemonic, bits<16> opcode>
43790b57cec5SDimitry Andric  : InstVRRa<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
43800b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M3", []> {
43810b57cec5SDimitry Andric  let isCompare = 1;
43820b57cec5SDimitry Andric  let M4 = 0;
43830b57cec5SDimitry Andric  let M5 = 0;
43840b57cec5SDimitry Andric}
43850b57cec5SDimitry Andric
43860b57cec5SDimitry Andricclass CompareVRRaFloatGeneric<string mnemonic, bits<16> opcode>
43870b57cec5SDimitry Andric  : InstVRRa<opcode, (outs),
43880b57cec5SDimitry Andric             (ins VR64:$V1, VR64:$V2, imm32zx4:$M3, imm32zx4:$M4),
43890b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M3, $M4", []> {
43900b57cec5SDimitry Andric  let isCompare = 1;
43910b57cec5SDimitry Andric  let M5 = 0;
43920b57cec5SDimitry Andric}
43930b57cec5SDimitry Andric
43940b57cec5SDimitry Andricclass CompareVRRh<string mnemonic, bits<16> opcode>
43950b57cec5SDimitry Andric  : InstVRRh<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
43960b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M3", []> {
43970b57cec5SDimitry Andric  let isCompare = 1;
43980b57cec5SDimitry Andric}
43990b57cec5SDimitry Andric
44000b57cec5SDimitry Andricclass TestInherentS<string mnemonic, bits<16> opcode,
44010b57cec5SDimitry Andric                    SDPatternOperator operator>
44020b57cec5SDimitry Andric  : InstS<opcode, (outs), (ins), mnemonic, [(set CC, (operator))]> {
440306c3fb27SDimitry Andric  let B2 = 0;
440406c3fb27SDimitry Andric  let D2 = 0;
44050b57cec5SDimitry Andric}
44060b57cec5SDimitry Andric
44070b57cec5SDimitry Andricclass TestRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
44080b57cec5SDimitry Andric              RegisterOperand cls>
440906c3fb27SDimitry Andric  : InstRXE<opcode, (outs), (ins cls:$R1, (bdxaddr12only $B2, $D2, $X2):$XBD2),
44100b57cec5SDimitry Andric            mnemonic#"\t$R1, $XBD2",
44110b57cec5SDimitry Andric            [(set CC, (operator cls:$R1, bdxaddr12only:$XBD2))]> {
44120b57cec5SDimitry Andric  let M3 = 0;
44130b57cec5SDimitry Andric}
44140b57cec5SDimitry Andric
44150b57cec5SDimitry Andricclass TestBinarySIL<string mnemonic, bits<16> opcode,
44168bcb0991SDimitry Andric                    SDPatternOperator operator, ImmOpWithPattern imm>
441706c3fb27SDimitry Andric  : InstSIL<opcode, (outs), (ins (bdaddr12only $B1, $D1):$BD1, imm:$I2),
44180b57cec5SDimitry Andric            mnemonic#"\t$BD1, $I2",
44190b57cec5SDimitry Andric            [(set CC, (operator bdaddr12only:$BD1, imm:$I2))]>;
44200b57cec5SDimitry Andric
44210b57cec5SDimitry Andricclass TestRSL<string mnemonic, bits<16> opcode>
442206c3fb27SDimitry Andric  : InstRSLa<opcode, (outs), (ins (bdladdr12onlylen4 $B1, $D1, $L1):$BDL1),
44230b57cec5SDimitry Andric             mnemonic#"\t$BDL1", []> {
44240b57cec5SDimitry Andric  let mayLoad = 1;
44250b57cec5SDimitry Andric}
44260b57cec5SDimitry Andric
44270b57cec5SDimitry Andricclass TestVRRg<string mnemonic, bits<16> opcode>
44280b57cec5SDimitry Andric  : InstVRRg<opcode, (outs), (ins VR128:$V1),
44290b57cec5SDimitry Andric             mnemonic#"\t$V1", []>;
44300b57cec5SDimitry Andric
44310b57cec5SDimitry Andricclass SideEffectTernarySSc<string mnemonic, bits<8> opcode>
443206c3fb27SDimitry Andric  : InstSSc<opcode, (outs), (ins (bdladdr12onlylen4 $B1, $D1, $L1):$BDL1,
443306c3fb27SDimitry Andric                                 (shift12only $B2, $D2):$BD2, imm32zx4:$I3),
44345ffd83dbSDimitry Andric            mnemonic#"\t$BDL1, $BD2, $I3", []>;
44350b57cec5SDimitry Andric
44360b57cec5SDimitry Andricclass SideEffectTernaryRRFa<string mnemonic, bits<16> opcode,
44370b57cec5SDimitry Andric                            RegisterOperand cls1, RegisterOperand cls2,
44380b57cec5SDimitry Andric                            RegisterOperand cls3>
44390b57cec5SDimitry Andric  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
44400b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $R3", []> {
44410b57cec5SDimitry Andric  let M4 = 0;
44420b57cec5SDimitry Andric}
44430b57cec5SDimitry Andric
44440b57cec5SDimitry Andricclass SideEffectTernaryMemMemRRFa<string mnemonic, bits<16> opcode,
44450b57cec5SDimitry Andric                                  RegisterOperand cls1, RegisterOperand cls2,
44460b57cec5SDimitry Andric                                  RegisterOperand cls3>
44470b57cec5SDimitry Andric  : InstRRFa<opcode, (outs cls1:$R1, cls2:$R2),
44480b57cec5SDimitry Andric             (ins cls1:$R1src, cls2:$R2src, cls3:$R3),
44490b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $R3", []> {
44500b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src, $R2 = $R2src";
44510b57cec5SDimitry Andric  let DisableEncoding = "$R1src, $R2src";
44520b57cec5SDimitry Andric  let M4 = 0;
44530b57cec5SDimitry Andric}
44540b57cec5SDimitry Andric
44550b57cec5SDimitry Andricclass SideEffectTernaryRRFb<string mnemonic, bits<16> opcode,
44560b57cec5SDimitry Andric                            RegisterOperand cls1, RegisterOperand cls2,
44570b57cec5SDimitry Andric                            RegisterOperand cls3>
44580b57cec5SDimitry Andric  : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
44590b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $R2", []> {
44600b57cec5SDimitry Andric  let M4 = 0;
44610b57cec5SDimitry Andric}
44620b57cec5SDimitry Andric
44630b57cec5SDimitry Andricclass SideEffectTernaryMemMemMemRRFb<string mnemonic, bits<16> opcode,
44640b57cec5SDimitry Andric                                     RegisterOperand cls1,
44650b57cec5SDimitry Andric                                     RegisterOperand cls2,
44660b57cec5SDimitry Andric                                     RegisterOperand cls3>
44670b57cec5SDimitry Andric  : InstRRFb<opcode, (outs cls1:$R1, cls2:$R2, cls3:$R3),
44680b57cec5SDimitry Andric             (ins cls1:$R1src, cls2:$R2src, cls3:$R3src),
44690b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $R2", []> {
44700b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src, $R2 = $R2src, $R3 = $R3src";
44710b57cec5SDimitry Andric  let DisableEncoding = "$R1src, $R2src, $R3src";
44720b57cec5SDimitry Andric  let M4 = 0;
44730b57cec5SDimitry Andric}
44740b57cec5SDimitry Andric
44750b57cec5SDimitry Andricclass SideEffectTernaryRRFc<string mnemonic, bits<16> opcode,
44760b57cec5SDimitry Andric                            RegisterOperand cls1, RegisterOperand cls2,
44778bcb0991SDimitry Andric                            ImmOpWithPattern imm>
44780b57cec5SDimitry Andric  : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2, imm:$M3),
44790b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $M3", []>;
44800b57cec5SDimitry Andric
44810b57cec5SDimitry Andricmulticlass SideEffectTernaryRRFcOpt<string mnemonic, bits<16> opcode,
44820b57cec5SDimitry Andric                                    RegisterOperand cls1,
44830b57cec5SDimitry Andric                                    RegisterOperand cls2> {
44840b57cec5SDimitry Andric  def "" : SideEffectTernaryRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
44850b57cec5SDimitry Andric  def Opt : SideEffectBinaryRRFc<mnemonic, opcode, cls1, cls2>;
44860b57cec5SDimitry Andric}
44870b57cec5SDimitry Andric
44880b57cec5SDimitry Andricclass SideEffectTernaryMemMemRRFc<string mnemonic, bits<16> opcode,
44890b57cec5SDimitry Andric                                  RegisterOperand cls1, RegisterOperand cls2,
44908bcb0991SDimitry Andric                                  ImmOpWithPattern imm>
44910b57cec5SDimitry Andric  : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2),
44920b57cec5SDimitry Andric             (ins cls1:$R1src, cls2:$R2src, imm:$M3),
44930b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $M3", []> {
44940b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src, $R2 = $R2src";
44950b57cec5SDimitry Andric  let DisableEncoding = "$R1src, $R2src";
44960b57cec5SDimitry Andric}
44970b57cec5SDimitry Andric
44980b57cec5SDimitry Andricmulticlass SideEffectTernaryMemMemRRFcOpt<string mnemonic, bits<16> opcode,
44990b57cec5SDimitry Andric                                          RegisterOperand cls1,
45000b57cec5SDimitry Andric                                          RegisterOperand cls2> {
45010b57cec5SDimitry Andric  def "" : SideEffectTernaryMemMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
45020b57cec5SDimitry Andric  def Opt : SideEffectBinaryMemMemRRFc<mnemonic, opcode, cls1, cls2>;
45030b57cec5SDimitry Andric}
45040b57cec5SDimitry Andric
45050b57cec5SDimitry Andricclass SideEffectTernarySSF<string mnemonic, bits<12> opcode,
45060b57cec5SDimitry Andric                           RegisterOperand cls>
45070b57cec5SDimitry Andric  : InstSSF<opcode, (outs),
450806c3fb27SDimitry Andric            (ins (bdaddr12only $B1, $D1):$BD1,
450906c3fb27SDimitry Andric                 (bdaddr12only $B2, $D2):$BD2, cls:$R3),
45100b57cec5SDimitry Andric            mnemonic#"\t$BD1, $BD2, $R3", []>;
45110b57cec5SDimitry Andric
45120b57cec5SDimitry Andricclass TernaryRRFa<string mnemonic, bits<16> opcode,
45130b57cec5SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2,
45140b57cec5SDimitry Andric                 RegisterOperand cls3>
45150b57cec5SDimitry Andric  : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3, imm32zx4:$M4),
45160b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
45170b57cec5SDimitry Andric
45180b57cec5SDimitry Andricclass TernaryRRFb<string mnemonic, bits<16> opcode,
45190b57cec5SDimitry Andric                  RegisterOperand cls1, RegisterOperand cls2,
45200b57cec5SDimitry Andric                  RegisterOperand cls3>
45210b57cec5SDimitry Andric  : InstRRFb<opcode, (outs cls1:$R1, cls3:$R3),
45220b57cec5SDimitry Andric             (ins cls1:$R1src, cls2:$R2, imm32zx4:$M4),
45230b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $R2, $M4", []> {
45240b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
45250b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
45260b57cec5SDimitry Andric}
45270b57cec5SDimitry Andric
45280b57cec5SDimitry Andricclass TernaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
45290b57cec5SDimitry Andric                  RegisterOperand cls2>
45300b57cec5SDimitry Andric  : InstRRFe<opcode, (outs cls1:$R1),
45310b57cec5SDimitry Andric             (ins imm32zx4:$M3, cls2:$R2, imm32zx4:$M4),
45320b57cec5SDimitry Andric             mnemonic#"\t$R1, $M3, $R2, $M4", []>;
45330b57cec5SDimitry Andric
45340b57cec5SDimitry Andricclass TernaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
45350b57cec5SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2>
45360b57cec5SDimitry Andric  : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R1src, cls2:$R3, cls2:$R2),
45370b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $R2",
45380b57cec5SDimitry Andric            [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3, cls2:$R2))]> {
45390b57cec5SDimitry Andric  let OpKey = mnemonic#cls;
45400b57cec5SDimitry Andric  let OpType = "reg";
45410b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
45420b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
45430b57cec5SDimitry Andric}
45440b57cec5SDimitry Andric
45450b57cec5SDimitry Andricclass TernaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
45460b57cec5SDimitry Andric                bits<5> bytes, AddressingMode mode = bdaddr12only>
45470b57cec5SDimitry Andric  : InstRSb<opcode, (outs cls:$R1),
454806c3fb27SDimitry Andric            (ins cls:$R1src, imm32zx4:$M3, (mode $B2, $D2):$BD2),
45490b57cec5SDimitry Andric            mnemonic#"\t$R1, $M3, $BD2", []> {
45500b57cec5SDimitry Andric
45510b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
45520b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
45530b57cec5SDimitry Andric  let mayLoad = 1;
45540b57cec5SDimitry Andric  let AccessBytes = bytes;
45550b57cec5SDimitry Andric}
45560b57cec5SDimitry Andric
45570b57cec5SDimitry Andricclass TernaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
45580b57cec5SDimitry Andric                bits<5> bytes, AddressingMode mode = bdaddr20only>
45590b57cec5SDimitry Andric  : InstRSYb<opcode, (outs cls:$R1),
456006c3fb27SDimitry Andric             (ins cls:$R1src, imm32zx4:$M3, (mode $B2, $D2):$BD2),
45610b57cec5SDimitry Andric             mnemonic#"\t$R1, $M3, $BD2", []> {
45620b57cec5SDimitry Andric
45630b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
45640b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
45650b57cec5SDimitry Andric  let mayLoad = 1;
45660b57cec5SDimitry Andric  let AccessBytes = bytes;
45670b57cec5SDimitry Andric}
45680b57cec5SDimitry Andric
45690b57cec5SDimitry Andricmulticlass TernaryRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
45700b57cec5SDimitry Andric                         RegisterOperand cls, bits<5> bytes> {
45715ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
45720b57cec5SDimitry Andric    let DispSize = "12" in
45730b57cec5SDimitry Andric      def "" : TernaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
45740b57cec5SDimitry Andric    let DispSize = "20" in
45750b57cec5SDimitry Andric      def Y  : TernaryRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
45760b57cec5SDimitry Andric  }
45770b57cec5SDimitry Andric}
45780b57cec5SDimitry Andric
45790b57cec5SDimitry Andricclass SideEffectTernaryRS<string mnemonic, bits<8> opcode,
45800b57cec5SDimitry Andric                          RegisterOperand cls1, RegisterOperand cls2>
45810b57cec5SDimitry Andric  : InstRSa<opcode, (outs),
458206c3fb27SDimitry Andric            (ins cls1:$R1, cls2:$R3, (bdaddr12only $B2, $D2):$BD2),
45830b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $BD2", []>;
45840b57cec5SDimitry Andric
45850b57cec5SDimitry Andricclass SideEffectTernaryRSY<string mnemonic, bits<16> opcode,
45860b57cec5SDimitry Andric                           RegisterOperand cls1, RegisterOperand cls2>
45870b57cec5SDimitry Andric  : InstRSYa<opcode, (outs),
458806c3fb27SDimitry Andric             (ins cls1:$R1, cls2:$R3, (bdaddr20only $B2, $D2):$BD2),
45890b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $BD2", []>;
45900b57cec5SDimitry Andric
45910b57cec5SDimitry Andricclass SideEffectTernaryMemMemRS<string mnemonic, bits<8> opcode,
45920b57cec5SDimitry Andric                                RegisterOperand cls1, RegisterOperand cls2>
45930b57cec5SDimitry Andric  : InstRSa<opcode, (outs cls1:$R1, cls2:$R3),
459406c3fb27SDimitry Andric            (ins cls1:$R1src, cls2:$R3src, (shift12only $B2, $D2):$BD2),
45950b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $BD2", []> {
45960b57cec5SDimitry Andric    let Constraints = "$R1 = $R1src, $R3 = $R3src";
45970b57cec5SDimitry Andric    let DisableEncoding = "$R1src, $R3src";
45980b57cec5SDimitry Andric}
45990b57cec5SDimitry Andric
46000b57cec5SDimitry Andricclass SideEffectTernaryMemMemRSY<string mnemonic, bits<16> opcode,
46010b57cec5SDimitry Andric                                 RegisterOperand cls1, RegisterOperand cls2>
46020b57cec5SDimitry Andric  : InstRSYa<opcode, (outs cls1:$R1, cls2:$R3),
460306c3fb27SDimitry Andric             (ins cls1:$R1src, cls2:$R3src, (shift20only $B2, $D2):$BD2),
46040b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $BD2", []> {
46050b57cec5SDimitry Andric    let Constraints = "$R1 = $R1src, $R3 = $R3src";
46060b57cec5SDimitry Andric    let DisableEncoding = "$R1src, $R3src";
46070b57cec5SDimitry Andric}
46080b57cec5SDimitry Andric
46090b57cec5SDimitry Andricclass TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
46100b57cec5SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2,
46110b57cec5SDimitry Andric                 SDPatternOperator load, bits<5> bytes>
46120b57cec5SDimitry Andric  : InstRXF<opcode, (outs cls1:$R1),
461306c3fb27SDimitry Andric            (ins cls2:$R1src, cls2:$R3, (bdxaddr12only $B2, $D2, $X2):$XBD2),
46140b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $XBD2",
46150b57cec5SDimitry Andric            [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3,
46160b57cec5SDimitry Andric                                      (load bdxaddr12only:$XBD2)))]> {
46170b57cec5SDimitry Andric  let OpKey = mnemonic#"r"#cls;
46180b57cec5SDimitry Andric  let OpType = "mem";
46190b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
46200b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
46210b57cec5SDimitry Andric  let mayLoad = 1;
46220b57cec5SDimitry Andric  let AccessBytes = bytes;
46230b57cec5SDimitry Andric}
46240b57cec5SDimitry Andric
46250b57cec5SDimitry Andricclass TernaryVRIa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
46268bcb0991SDimitry Andric                  TypedReg tr1, TypedReg tr2, ImmOpWithPattern imm, ImmOpWithPattern index>
46270b57cec5SDimitry Andric  : InstVRIa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V1src, imm:$I2, index:$M3),
46280b57cec5SDimitry Andric             mnemonic#"\t$V1, $I2, $M3",
46290b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
46300b57cec5SDimitry Andric                                                  imm:$I2, index:$M3))]> {
46310b57cec5SDimitry Andric  let Constraints = "$V1 = $V1src";
46320b57cec5SDimitry Andric  let DisableEncoding = "$V1src";
46330b57cec5SDimitry Andric}
46340b57cec5SDimitry Andric
46350b57cec5SDimitry Andricclass TernaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
46360b57cec5SDimitry Andric                  TypedReg tr1, TypedReg tr2, bits<4> type>
46370b57cec5SDimitry Andric  : InstVRId<opcode, (outs tr1.op:$V1),
46380b57cec5SDimitry Andric             (ins tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
46390b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $I4",
46400b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
46410b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3),
46428bcb0991SDimitry Andric                                                  imm32zx8_timm:$I4))]> {
46430b57cec5SDimitry Andric  let M5 = type;
46440b57cec5SDimitry Andric}
46450b57cec5SDimitry Andric
46460b57cec5SDimitry Andricclass TernaryVRIi<string mnemonic, bits<16> opcode, RegisterOperand cls>
46470b57cec5SDimitry Andric  : InstVRIi<opcode, (outs VR128:$V1),
46480b57cec5SDimitry Andric             (ins cls:$R2, imm32zx8:$I3, imm32zx4:$M4),
46490b57cec5SDimitry Andric             mnemonic#"\t$V1, $R2, $I3, $M4", []>;
46500b57cec5SDimitry Andric
46510b57cec5SDimitry Andricclass TernaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
46520b57cec5SDimitry Andric                  TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m4or>
46530b57cec5SDimitry Andric  : InstVRRa<opcode, (outs tr1.op:$V1),
46540b57cec5SDimitry Andric             (ins tr2.op:$V2, imm32zx4:$M4, imm32zx4:$M5),
46550b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M4, $M5",
46560b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
46578bcb0991SDimitry Andric                                                  imm32zx4_timm:$M4,
46588bcb0991SDimitry Andric                                                  imm32zx4_timm:$M5))],
46590b57cec5SDimitry Andric             m4or> {
46600b57cec5SDimitry Andric  let M3 = type;
46610b57cec5SDimitry Andric}
46620b57cec5SDimitry Andric
46630b57cec5SDimitry Andricclass TernaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
46640b57cec5SDimitry Andric  : InstVRRa<opcode, (outs VR128:$V1),
46650b57cec5SDimitry Andric             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
46660b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
46670b57cec5SDimitry Andric
46680b57cec5SDimitry Andricclass TernaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
46690b57cec5SDimitry Andric                  TypedReg tr1, TypedReg tr2, bits<4> type,
46700b57cec5SDimitry Andric                  SDPatternOperator m5mask, bits<4> m5or>
46710b57cec5SDimitry Andric  : InstVRRb<opcode, (outs tr1.op:$V1),
46720b57cec5SDimitry Andric             (ins tr2.op:$V2, tr2.op:$V3, m5mask:$M5),
46730b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M5",
46740b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
46750b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3),
46760b57cec5SDimitry Andric                                                  m5mask:$M5))],
46770b57cec5SDimitry Andric             m5or> {
46780b57cec5SDimitry Andric  let M4 = type;
46790b57cec5SDimitry Andric}
46800b57cec5SDimitry Andric
46810b57cec5SDimitry Andric// Declare a pair of instructions, one which sets CC and one which doesn't.
46820b57cec5SDimitry Andric// The CC-setting form ends with "S" and sets the low bit of M5.
46830b57cec5SDimitry Andric// Also create aliases to make use of M5 operand optional in assembler.
46840b57cec5SDimitry Andricmulticlass TernaryOptVRRbSPair<string mnemonic, bits<16> opcode,
46850b57cec5SDimitry Andric                               SDPatternOperator operator,
46860b57cec5SDimitry Andric                               SDPatternOperator operator_cc,
46870b57cec5SDimitry Andric                               TypedReg tr1, TypedReg tr2, bits<4> type,
46880b57cec5SDimitry Andric                               bits<4> modifier = 0> {
46890b57cec5SDimitry Andric  def "" : TernaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
46908bcb0991SDimitry Andric                       imm32zx4even_timm, !and (modifier, 14)>;
46910b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
46920b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
46930b57cec5SDimitry Andric                                            tr2.op:$V3, 0)>;
46940b57cec5SDimitry Andric  let Defs = [CC] in
46955ffd83dbSDimitry Andric    def S : TernaryVRRb<mnemonic#"s", opcode, operator_cc, tr1, tr2, type,
46968bcb0991SDimitry Andric                        imm32zx4even_timm, !add(!and (modifier, 14), 1)>;
46970b57cec5SDimitry Andric  def : InstAlias<mnemonic#"s\t$V1, $V2, $V3",
46980b57cec5SDimitry Andric                  (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
46990b57cec5SDimitry Andric                                                tr2.op:$V3, 0)>;
47000b57cec5SDimitry Andric}
47010b57cec5SDimitry Andric
47020b57cec5SDimitry Andricmulticlass TernaryOptVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
47030b57cec5SDimitry Andric  let Defs = [CC] in
47040b57cec5SDimitry Andric    def "" : InstVRRb<opcode, (outs VR128:$V1),
47050b57cec5SDimitry Andric                     (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
47060b57cec5SDimitry Andric                     mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
47070b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
47080b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
47090b57cec5SDimitry Andric                                            imm32zx4:$M4, 0)>;
47100b57cec5SDimitry Andric}
47110b57cec5SDimitry Andric
47120b57cec5SDimitry Andricclass TernaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
47130b57cec5SDimitry Andric                  TypedReg tr1, TypedReg tr2>
47140b57cec5SDimitry Andric  : InstVRRc<opcode, (outs tr1.op:$V1),
47150b57cec5SDimitry Andric             (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M4),
47160b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M4",
47170b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
47180b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3),
47198bcb0991SDimitry Andric                                                  imm32zx4_timm:$M4))]> {
47200b57cec5SDimitry Andric  let M5 = 0;
47210b57cec5SDimitry Andric  let M6 = 0;
47220b57cec5SDimitry Andric}
47230b57cec5SDimitry Andric
47240b57cec5SDimitry Andricclass TernaryVRRcFloat<string mnemonic, bits<16> opcode,
47250b57cec5SDimitry Andric                       SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
47260b57cec5SDimitry Andric                       bits<4> type = 0, bits<4> m5 = 0>
47270b57cec5SDimitry Andric  : InstVRRc<opcode, (outs tr1.op:$V1),
47280b57cec5SDimitry Andric             (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M6),
47290b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M6",
47300b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
47310b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3),
47328bcb0991SDimitry Andric                                                  imm32zx4_timm:$M6))]> {
47330b57cec5SDimitry Andric  let M4 = type;
47340b57cec5SDimitry Andric  let M5 = m5;
47350b57cec5SDimitry Andric}
47360b57cec5SDimitry Andric
47370b57cec5SDimitry Andricclass TernaryVRRcFloatGeneric<string mnemonic, bits<16> opcode>
47380b57cec5SDimitry Andric  : InstVRRc<opcode, (outs VR128:$V1),
47390b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
47400b57cec5SDimitry Andric                  imm32zx4:$M6),
47410b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
47420b57cec5SDimitry Andric
47430b57cec5SDimitry Andricclass TernaryVRRd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
47440b57cec5SDimitry Andric                  TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m6 = 0>
47450b57cec5SDimitry Andric  : InstVRRd<opcode, (outs tr1.op:$V1),
47460b57cec5SDimitry Andric             (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
47470b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $V4",
47480b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
47490b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3),
47500b57cec5SDimitry Andric                                                  (tr1.vt tr1.op:$V4)))]> {
47510b57cec5SDimitry Andric  let M5 = type;
47520b57cec5SDimitry Andric  let M6 = m6;
47530b57cec5SDimitry Andric}
47540b57cec5SDimitry Andric
47550b57cec5SDimitry Andricclass TernaryVRRdGeneric<string mnemonic, bits<16> opcode>
47560b57cec5SDimitry Andric  : InstVRRd<opcode, (outs VR128:$V1),
47570b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5),
47580b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $V4, $M5", []> {
47590b57cec5SDimitry Andric  let M6 = 0;
47600b57cec5SDimitry Andric}
47610b57cec5SDimitry Andric
47620b57cec5SDimitry Andric// Ternary operation where the assembler mnemonic has an extra operand to
47635ffd83dbSDimitry Andric// optionally allow specifying arbitrary M6 values.
47640b57cec5SDimitry Andricmulticlass TernaryExtraVRRd<string mnemonic, bits<16> opcode,
47650b57cec5SDimitry Andric                             SDPatternOperator operator,
47660b57cec5SDimitry Andric                             TypedReg tr1, TypedReg tr2, bits<4> type> {
47670b57cec5SDimitry Andric  let M5 = type, Defs = [CC] in
47680b57cec5SDimitry Andric    def "" : InstVRRd<opcode, (outs tr1.op:$V1),
47690b57cec5SDimitry Andric                      (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4, imm32zx4:$M6),
47700b57cec5SDimitry Andric                      mnemonic#"\t$V1, $V2, $V3, $V4, $M6", []>;
47710b57cec5SDimitry Andric  def : Pat<(operator (tr2.vt tr2.op:$V2), (tr2.vt tr2.op:$V3),
47720b57cec5SDimitry Andric                      (tr1.vt tr1.op:$V4)),
47730b57cec5SDimitry Andric            (!cast<Instruction>(NAME) tr2.op:$V2, tr2.op:$V3, tr1.op:$V4, 0)>;
47740b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4",
47750b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
47760b57cec5SDimitry Andric                                            tr2.op:$V3, tr1.op:$V4, 0)>;
47770b57cec5SDimitry Andric}
47780b57cec5SDimitry Andric
47790b57cec5SDimitry Andricmulticlass TernaryExtraVRRdGeneric<string mnemonic, bits<16> opcode> {
47800b57cec5SDimitry Andric  let Defs = [CC] in
47810b57cec5SDimitry Andric    def "" : InstVRRd<opcode, (outs VR128:$V1),
47820b57cec5SDimitry Andric                      (ins VR128:$V2, VR128:$V3, VR128:$V4,
47830b57cec5SDimitry Andric                       imm32zx4:$M5, imm32zx4:$M6),
47840b57cec5SDimitry Andric                      mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
47850b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4, $M5",
47860b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
47870b57cec5SDimitry Andric                                            VR128:$V4, imm32zx4:$M5, 0)>;
47880b57cec5SDimitry Andric}
47890b57cec5SDimitry Andric
47900b57cec5SDimitry Andricclass TernaryVRRe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
47915ffd83dbSDimitry Andric                  TypedReg tr1, TypedReg tr2, bits<4> m5 = 0, bits<4> type = 0,
47925ffd83dbSDimitry Andric                  string fp_mnemonic = "">
47930b57cec5SDimitry Andric  : InstVRRe<opcode, (outs tr1.op:$V1),
47940b57cec5SDimitry Andric             (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
47950b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $V4",
47960b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
47970b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3),
47980b57cec5SDimitry Andric                                                  (tr1.vt tr1.op:$V4)))]> {
47990b57cec5SDimitry Andric  let M5 = m5;
48000b57cec5SDimitry Andric  let M6 = type;
48015ffd83dbSDimitry Andric  let OpKey = fp_mnemonic#"MemFold"#!subst("VR", "FP", !cast<string>(tr1.op));
48025ffd83dbSDimitry Andric  let OpType = "reg";
48030b57cec5SDimitry Andric}
48040b57cec5SDimitry Andric
48050b57cec5SDimitry Andricclass TernaryVRReFloatGeneric<string mnemonic, bits<16> opcode>
48060b57cec5SDimitry Andric  : InstVRRe<opcode, (outs VR128:$V1),
48070b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
48080b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
48090b57cec5SDimitry Andric
48100b57cec5SDimitry Andricclass TernaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
48110b57cec5SDimitry Andric                  TypedReg tr1, TypedReg tr2, RegisterOperand cls, bits<4> type>
48120b57cec5SDimitry Andric  : InstVRSb<opcode, (outs tr1.op:$V1),
481306c3fb27SDimitry Andric             (ins tr2.op:$V1src, cls:$R3, (shift12only $B2, $D2):$BD2),
48140b57cec5SDimitry Andric             mnemonic#"\t$V1, $R3, $BD2",
48150b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
48160b57cec5SDimitry Andric                                                  cls:$R3,
48170b57cec5SDimitry Andric                                                  shift12only:$BD2))]> {
48180b57cec5SDimitry Andric  let Constraints = "$V1 = $V1src";
48190b57cec5SDimitry Andric  let DisableEncoding = "$V1src";
48200b57cec5SDimitry Andric  let M4 = type;
48210b57cec5SDimitry Andric}
48220b57cec5SDimitry Andric
48230b57cec5SDimitry Andricclass TernaryVRRi<string mnemonic, bits<16> opcode, RegisterOperand cls>
48240b57cec5SDimitry Andric  : InstVRRi<opcode, (outs cls:$R1), (ins VR128:$V2,
48250b57cec5SDimitry Andric                                      imm32zx4:$M3, imm32zx4:$M4),
48260b57cec5SDimitry Andric             mnemonic#"\t$R1, $V2, $M3, $M4", []>;
48270b57cec5SDimitry Andric
4828fe6060f1SDimitry Andricclass TernaryVRRj<string mnemonic, bits<16> opcode>
4829fe6060f1SDimitry Andric  : InstVRRj<opcode, (outs VR128:$V1), (ins VR128:$V2,
4830fe6060f1SDimitry Andric                                        VR128:$V3, imm32zx4:$M4),
4831fe6060f1SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $M4", []>;
4832fe6060f1SDimitry Andric
48330b57cec5SDimitry Andricclass TernaryVRSbGeneric<string mnemonic, bits<16> opcode>
48340b57cec5SDimitry Andric  : InstVRSb<opcode, (outs VR128:$V1),
483506c3fb27SDimitry Andric             (ins VR128:$V1src, GR64:$R3, (shift12only $B2, $D2):$BD2,
483606c3fb27SDimitry Andric                  imm32zx4:$M4),
48370b57cec5SDimitry Andric             mnemonic#"\t$V1, $R3, $BD2, $M4", []> {
48380b57cec5SDimitry Andric  let Constraints = "$V1 = $V1src";
48390b57cec5SDimitry Andric  let DisableEncoding = "$V1src";
48400b57cec5SDimitry Andric}
48410b57cec5SDimitry Andric
48420b57cec5SDimitry Andricclass TernaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
48438bcb0991SDimitry Andric                 ImmOpWithPattern index>
48440b57cec5SDimitry Andric  : InstVRV<opcode, (outs VR128:$V1),
484506c3fb27SDimitry Andric           (ins VR128:$V1src, (bdvaddr12only $B2, $D2, $V2):$VBD2, index:$M3),
48460b57cec5SDimitry Andric           mnemonic#"\t$V1, $VBD2, $M3", []> {
48470b57cec5SDimitry Andric  let Constraints = "$V1 = $V1src";
48480b57cec5SDimitry Andric  let DisableEncoding = "$V1src";
48490b57cec5SDimitry Andric  let mayLoad = 1;
48500b57cec5SDimitry Andric  let AccessBytes = bytes;
48510b57cec5SDimitry Andric}
48520b57cec5SDimitry Andric
48530b57cec5SDimitry Andricclass TernaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
48548bcb0991SDimitry Andric                 TypedReg tr1, TypedReg tr2, bits<5> bytes, ImmOpWithPattern index>
48550b57cec5SDimitry Andric  : InstVRX<opcode, (outs tr1.op:$V1),
485606c3fb27SDimitry Andric           (ins tr2.op:$V1src, (bdxaddr12only $B2, $D2, $X2):$XBD2, index:$M3),
48570b57cec5SDimitry Andric           mnemonic#"\t$V1, $XBD2, $M3",
48580b57cec5SDimitry Andric           [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
48590b57cec5SDimitry Andric                                                bdxaddr12only:$XBD2,
48600b57cec5SDimitry Andric                                                index:$M3))]> {
48610b57cec5SDimitry Andric  let Constraints = "$V1 = $V1src";
48620b57cec5SDimitry Andric  let DisableEncoding = "$V1src";
48630b57cec5SDimitry Andric  let mayLoad = 1;
48640b57cec5SDimitry Andric  let AccessBytes = bytes;
48650b57cec5SDimitry Andric}
48660b57cec5SDimitry Andric
48670b57cec5SDimitry Andricclass QuaternaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
48680b57cec5SDimitry Andric                     TypedReg tr1, TypedReg tr2, bits<4> type>
48690b57cec5SDimitry Andric  : InstVRId<opcode, (outs tr1.op:$V1),
48700b57cec5SDimitry Andric             (ins tr2.op:$V1src, tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
48710b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $I4",
48720b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
48730b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V2),
48740b57cec5SDimitry Andric                                                  (tr2.vt tr2.op:$V3),
48758bcb0991SDimitry Andric                                                  imm32zx8_timm:$I4))]> {
48760b57cec5SDimitry Andric  let Constraints = "$V1 = $V1src";
48770b57cec5SDimitry Andric  let DisableEncoding = "$V1src";
48780b57cec5SDimitry Andric  let M5 = type;
48790b57cec5SDimitry Andric}
48800b57cec5SDimitry Andric
48810b57cec5SDimitry Andricclass QuaternaryVRIdGeneric<string mnemonic, bits<16> opcode>
48820b57cec5SDimitry Andric  : InstVRId<opcode, (outs VR128:$V1),
48830b57cec5SDimitry Andric             (ins VR128:$V1src, VR128:$V2, VR128:$V3,
48840b57cec5SDimitry Andric                  imm32zx8:$I4, imm32zx4:$M5),
48850b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []> {
48860b57cec5SDimitry Andric  let Constraints = "$V1 = $V1src";
48870b57cec5SDimitry Andric  let DisableEncoding = "$V1src";
48880b57cec5SDimitry Andric}
48890b57cec5SDimitry Andric
48900b57cec5SDimitry Andricclass QuaternaryVRIf<string mnemonic, bits<16> opcode>
48910b57cec5SDimitry Andric  : InstVRIf<opcode, (outs VR128:$V1),
48920b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3,
48930b57cec5SDimitry Andric                  imm32zx8:$I4, imm32zx4:$M5),
48940b57cec5SDimitry Andric            mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []>;
48950b57cec5SDimitry Andric
48960b57cec5SDimitry Andricclass QuaternaryVRIg<string mnemonic, bits<16> opcode>
48970b57cec5SDimitry Andric  : InstVRIg<opcode, (outs VR128:$V1),
48980b57cec5SDimitry Andric             (ins VR128:$V2, imm32zx8:$I3,
48990b57cec5SDimitry Andric                  imm32zx8:$I4, imm32zx4:$M5),
49000b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $I3, $I4, $M5", []>;
49010b57cec5SDimitry Andric
49020b57cec5SDimitry Andricclass QuaternaryVRRd<string mnemonic, bits<16> opcode,
49030b57cec5SDimitry Andric                     SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
49040b57cec5SDimitry Andric                     TypedReg tr3, TypedReg tr4, bits<4> type,
49058bcb0991SDimitry Andric                     SDPatternOperator m6mask = imm32zx4_timm, bits<4> m6or = 0>
49060b57cec5SDimitry Andric  : InstVRRd<opcode, (outs tr1.op:$V1),
49070b57cec5SDimitry Andric             (ins tr2.op:$V2, tr3.op:$V3, tr4.op:$V4, m6mask:$M6),
49080b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $V4, $M6",
49090b57cec5SDimitry Andric             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
49100b57cec5SDimitry Andric                                                  (tr3.vt tr3.op:$V3),
49110b57cec5SDimitry Andric                                                  (tr4.vt tr4.op:$V4),
49120b57cec5SDimitry Andric                                                  m6mask:$M6))],
49130b57cec5SDimitry Andric             m6or> {
49140b57cec5SDimitry Andric  let M5 = type;
49150b57cec5SDimitry Andric}
49160b57cec5SDimitry Andric
49170b57cec5SDimitry Andricclass QuaternaryVRRdGeneric<string mnemonic, bits<16> opcode>
49180b57cec5SDimitry Andric  : InstVRRd<opcode, (outs VR128:$V1),
49190b57cec5SDimitry Andric             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
49200b57cec5SDimitry Andric             mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
49210b57cec5SDimitry Andric
49220b57cec5SDimitry Andric// Declare a pair of instructions, one which sets CC and one which doesn't.
49230b57cec5SDimitry Andric// The CC-setting form ends with "S" and sets the low bit of M6.
49240b57cec5SDimitry Andric// Also create aliases to make use of M6 operand optional in assembler.
49250b57cec5SDimitry Andricmulticlass QuaternaryOptVRRdSPair<string mnemonic, bits<16> opcode,
49260b57cec5SDimitry Andric                                  SDPatternOperator operator,
49270b57cec5SDimitry Andric                                SDPatternOperator operator_cc,
49280b57cec5SDimitry Andric                                TypedReg tr1, TypedReg tr2, bits<4> type,
49290b57cec5SDimitry Andric                                bits<4> modifier = 0> {
49300b57cec5SDimitry Andric  def "" : QuaternaryVRRd<mnemonic, opcode, operator,
49310b57cec5SDimitry Andric                          tr1, tr2, tr2, tr2, type,
49328bcb0991SDimitry Andric                          imm32zx4even_timm, !and (modifier, 14)>;
49330b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4",
49340b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
49350b57cec5SDimitry Andric                                            tr2.op:$V3, tr2.op:$V4, 0)>;
49360b57cec5SDimitry Andric  let Defs = [CC] in
49375ffd83dbSDimitry Andric    def S : QuaternaryVRRd<mnemonic#"s", opcode, operator_cc,
49380b57cec5SDimitry Andric                           tr1, tr2, tr2, tr2, type,
49398bcb0991SDimitry Andric                           imm32zx4even_timm, !add (!and (modifier, 14), 1)>;
49400b57cec5SDimitry Andric  def : InstAlias<mnemonic#"s\t$V1, $V2, $V3, $V4",
49410b57cec5SDimitry Andric                  (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
49420b57cec5SDimitry Andric                                                tr2.op:$V3, tr2.op:$V4, 0)>;
49430b57cec5SDimitry Andric}
49440b57cec5SDimitry Andric
49450b57cec5SDimitry Andricmulticlass QuaternaryOptVRRdSPairGeneric<string mnemonic, bits<16> opcode> {
49460b57cec5SDimitry Andric  let Defs = [CC] in
49470b57cec5SDimitry Andric    def "" : QuaternaryVRRdGeneric<mnemonic, opcode>;
49480b57cec5SDimitry Andric  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4, $M5",
49490b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
49508bcb0991SDimitry Andric                                            VR128:$V4, imm32zx4_timm:$M5, 0)>;
49510b57cec5SDimitry Andric}
49520b57cec5SDimitry Andric
49530b57cec5SDimitry Andricclass SideEffectQuaternaryRRFa<string mnemonic, bits<16> opcode,
49540b57cec5SDimitry Andric                               RegisterOperand cls1, RegisterOperand cls2,
49550b57cec5SDimitry Andric                               RegisterOperand cls3>
49560b57cec5SDimitry Andric  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
49570b57cec5SDimitry Andric             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
49580b57cec5SDimitry Andric
49590b57cec5SDimitry Andricmulticlass SideEffectQuaternaryRRFaOptOpt<string mnemonic, bits<16> opcode,
49600b57cec5SDimitry Andric                                          RegisterOperand cls1,
49610b57cec5SDimitry Andric                                          RegisterOperand cls2,
49620b57cec5SDimitry Andric                                          RegisterOperand cls3> {
49630b57cec5SDimitry Andric  def "" : SideEffectQuaternaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
49640b57cec5SDimitry Andric  def Opt : SideEffectTernaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
49650b57cec5SDimitry Andric  def OptOpt : SideEffectBinaryRRFa<mnemonic, opcode, cls1, cls2>;
49660b57cec5SDimitry Andric}
49670b57cec5SDimitry Andric
49680b57cec5SDimitry Andricclass SideEffectQuaternaryRRFb<string mnemonic, bits<16> opcode,
49690b57cec5SDimitry Andric                               RegisterOperand cls1, RegisterOperand cls2,
49700b57cec5SDimitry Andric                               RegisterOperand cls3>
49710b57cec5SDimitry Andric  : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
49720b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $R2, $M4", []>;
49730b57cec5SDimitry Andric
49740b57cec5SDimitry Andricmulticlass SideEffectQuaternaryRRFbOpt<string mnemonic, bits<16> opcode,
49750b57cec5SDimitry Andric                                       RegisterOperand cls1,
49760b57cec5SDimitry Andric                                       RegisterOperand cls2,
49770b57cec5SDimitry Andric                                       RegisterOperand cls3> {
49780b57cec5SDimitry Andric  def "" : SideEffectQuaternaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
49790b57cec5SDimitry Andric  def Opt : SideEffectTernaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
49800b57cec5SDimitry Andric}
49810b57cec5SDimitry Andric
49820b57cec5SDimitry Andricclass SideEffectQuaternarySSe<string mnemonic, bits<8> opcode,
49830b57cec5SDimitry Andric                              RegisterOperand cls>
49840b57cec5SDimitry Andric  : InstSSe<opcode, (outs),
498506c3fb27SDimitry Andric            (ins cls:$R1, (bdaddr12only $B2, $D2):$BD2, cls:$R3,
498606c3fb27SDimitry Andric                 (bdaddr12only $B4, $D4):$BD4),
49870b57cec5SDimitry Andric            mnemonic#"\t$R1, $BD2, $R3, $BD4", []>;
49880b57cec5SDimitry Andric
49890b57cec5SDimitry Andricclass LoadAndOpRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
49900b57cec5SDimitry Andric                  RegisterOperand cls, AddressingMode mode = bdaddr20only>
499106c3fb27SDimitry Andric  : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, (mode $B2, $D2):$BD2),
49920b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $BD2",
49930b57cec5SDimitry Andric             [(set cls:$R1, (operator mode:$BD2, cls:$R3))]> {
49940b57cec5SDimitry Andric  let mayLoad = 1;
49950b57cec5SDimitry Andric  let mayStore = 1;
49960b57cec5SDimitry Andric}
49970b57cec5SDimitry Andric
49980b57cec5SDimitry Andricclass CmpSwapRRE<string mnemonic, bits<16> opcode,
49990b57cec5SDimitry Andric                 RegisterOperand cls1, RegisterOperand cls2>
50000b57cec5SDimitry Andric  : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
50010b57cec5SDimitry Andric            mnemonic#"\t$R1, $R2", []> {
50020b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
50030b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
50040b57cec5SDimitry Andric  let mayLoad = 1;
50050b57cec5SDimitry Andric  let mayStore = 1;
50060b57cec5SDimitry Andric}
50070b57cec5SDimitry Andric
50080b57cec5SDimitry Andricclass CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
50090b57cec5SDimitry Andric                RegisterOperand cls, AddressingMode mode = bdaddr12only>
501006c3fb27SDimitry Andric  : InstRSa<opcode, (outs cls:$R1),
501106c3fb27SDimitry Andric            (ins cls:$R1src, cls:$R3, (mode $B2, $D2):$BD2),
50120b57cec5SDimitry Andric            mnemonic#"\t$R1, $R3, $BD2",
50130b57cec5SDimitry Andric            [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
50140b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
50150b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
50160b57cec5SDimitry Andric  let mayLoad = 1;
50170b57cec5SDimitry Andric  let mayStore = 1;
50180b57cec5SDimitry Andric}
50190b57cec5SDimitry Andric
50200b57cec5SDimitry Andricclass CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
50210b57cec5SDimitry Andric                 RegisterOperand cls, AddressingMode mode = bdaddr20only>
502206c3fb27SDimitry Andric  : InstRSYa<opcode, (outs cls:$R1),
502306c3fb27SDimitry Andric             (ins cls:$R1src, cls:$R3, (mode $B2, $D2):$BD2),
50240b57cec5SDimitry Andric             mnemonic#"\t$R1, $R3, $BD2",
50250b57cec5SDimitry Andric             [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
50260b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
50270b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
50280b57cec5SDimitry Andric  let mayLoad = 1;
50290b57cec5SDimitry Andric  let mayStore = 1;
50300b57cec5SDimitry Andric}
50310b57cec5SDimitry Andric
50320b57cec5SDimitry Andricmulticlass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
50330b57cec5SDimitry Andric                         SDPatternOperator operator, RegisterOperand cls> {
50345ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
50350b57cec5SDimitry Andric    let DispSize = "12" in
50360b57cec5SDimitry Andric      def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
50370b57cec5SDimitry Andric    let DispSize = "20" in
50380b57cec5SDimitry Andric      def Y  : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
50390b57cec5SDimitry Andric  }
50400b57cec5SDimitry Andric}
50410b57cec5SDimitry Andric
50420b57cec5SDimitry Andricclass RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
5043*0fca6ea1SDimitry Andric                       RegisterOperand cls2, bits<8> I3Or = 0, bits<8> I4Or = 0>
50440b57cec5SDimitry Andric  : InstRIEf<opcode, (outs cls1:$R1),
50450b57cec5SDimitry Andric             (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
504606c3fb27SDimitry Andric                  imm32zx8:$I5),
5047*0fca6ea1SDimitry Andric             mnemonic#"\t$R1, $R2, $I3, $I4, $I5", [], I3Or, I4Or> {
50480b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
50490b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
50500b57cec5SDimitry Andric}
50510b57cec5SDimitry Andric
50520b57cec5SDimitry Andricclass PrefetchRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator>
505306c3fb27SDimitry Andric  : InstRXYb<opcode, (outs),
505406c3fb27SDimitry Andric             (ins imm32zx4:$M1, (bdxaddr20only $B2, $D2, $X2):$XBD2),
50555ffd83dbSDimitry Andric             mnemonic#"\t$M1, $XBD2",
50568bcb0991SDimitry Andric             [(operator imm32zx4_timm:$M1, bdxaddr20only:$XBD2)]>;
50570b57cec5SDimitry Andric
50580b57cec5SDimitry Andricclass PrefetchRILPC<string mnemonic, bits<12> opcode,
50590b57cec5SDimitry Andric                    SDPatternOperator operator>
50608bcb0991SDimitry Andric  : InstRILc<opcode, (outs), (ins imm32zx4_timm:$M1, pcrel32:$RI2),
50615ffd83dbSDimitry Andric             mnemonic#"\t$M1, $RI2",
50628bcb0991SDimitry Andric             [(operator imm32zx4_timm:$M1, pcrel32:$RI2)]> {
50630b57cec5SDimitry Andric  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
50640b57cec5SDimitry Andric  // However, BDXs have two extra operands and are therefore 6 units more
50650b57cec5SDimitry Andric  // complex.
50660b57cec5SDimitry Andric  let AddedComplexity = 7;
50670b57cec5SDimitry Andric}
50680b57cec5SDimitry Andric
50690b57cec5SDimitry Andricclass BranchPreloadSMI<string mnemonic, bits<8> opcode>
50700b57cec5SDimitry Andric  : InstSMI<opcode, (outs),
507106c3fb27SDimitry Andric            (ins imm32zx4:$M1, brtarget16bpp:$RI2,
507206c3fb27SDimitry Andric                 (bdaddr12only $B3, $D3):$BD3),
50730b57cec5SDimitry Andric            mnemonic#"\t$M1, $RI2, $BD3", []>;
50740b57cec5SDimitry Andric
50750b57cec5SDimitry Andricclass BranchPreloadMII<string mnemonic, bits<8> opcode>
50760b57cec5SDimitry Andric  : InstMII<opcode, (outs),
50770b57cec5SDimitry Andric            (ins imm32zx4:$M1, brtarget12bpp:$RI2, brtarget24bpp:$RI3),
50780b57cec5SDimitry Andric            mnemonic#"\t$M1, $RI2, $RI3", []>;
50790b57cec5SDimitry Andric
50800b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
50810b57cec5SDimitry Andric// Pseudo instructions
50820b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
50830b57cec5SDimitry Andric//
50840b57cec5SDimitry Andric// Convenience instructions that get lowered to real instructions
50850b57cec5SDimitry Andric// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
50860b57cec5SDimitry Andric// or SystemZInstrInfo::expandPostRAPseudo().
50870b57cec5SDimitry Andric//
50880b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
50890b57cec5SDimitry Andric
50900b57cec5SDimitry Andricclass Pseudo<dag outs, dag ins, list<dag> pattern>
50910b57cec5SDimitry Andric  : InstSystemZ<0, outs, ins, "", pattern> {
50920b57cec5SDimitry Andric  let isPseudo = 1;
50930b57cec5SDimitry Andric  let isCodeGenOnly = 1;
50940b57cec5SDimitry Andric}
50950b57cec5SDimitry Andric
50960b57cec5SDimitry Andric// Like UnaryRI, but expanded after RA depending on the choice of register.
50970b57cec5SDimitry Andricclass UnaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
50988bcb0991SDimitry Andric                    ImmOpWithPattern imm>
50990b57cec5SDimitry Andric  : Pseudo<(outs cls:$R1), (ins imm:$I2),
51000b57cec5SDimitry Andric           [(set cls:$R1, (operator imm:$I2))]>;
51010b57cec5SDimitry Andric
51020b57cec5SDimitry Andric// Like UnaryRXY, but expanded after RA depending on the choice of register.
51030b57cec5SDimitry Andricclass UnaryRXYPseudo<string key, SDPatternOperator operator,
51040b57cec5SDimitry Andric                     RegisterOperand cls, bits<5> bytes,
51050b57cec5SDimitry Andric                     AddressingMode mode = bdxaddr20only>
510606c3fb27SDimitry Andric  : Pseudo<(outs cls:$R1), (ins (mode $B2, $D2, $X2):$XBD2),
51070b57cec5SDimitry Andric           [(set cls:$R1, (operator mode:$XBD2))]> {
51080b57cec5SDimitry Andric  let OpKey = key#"r"#cls;
51090b57cec5SDimitry Andric  let OpType = "mem";
51100b57cec5SDimitry Andric  let mayLoad = 1;
51110b57cec5SDimitry Andric  let Has20BitOffset = 1;
51120b57cec5SDimitry Andric  let HasIndex = 1;
51130b57cec5SDimitry Andric  let AccessBytes = bytes;
51140b57cec5SDimitry Andric}
51150b57cec5SDimitry Andric
51160b57cec5SDimitry Andric// Like UnaryRR, but expanded after RA depending on the choice of registers.
51170b57cec5SDimitry Andricclass UnaryRRPseudo<string key, SDPatternOperator operator,
51180b57cec5SDimitry Andric                    RegisterOperand cls1, RegisterOperand cls2>
51190b57cec5SDimitry Andric  : Pseudo<(outs cls1:$R1), (ins cls2:$R2),
51200b57cec5SDimitry Andric           [(set cls1:$R1, (operator cls2:$R2))]> {
51210b57cec5SDimitry Andric  let OpKey = key#cls1;
51220b57cec5SDimitry Andric  let OpType = "reg";
51230b57cec5SDimitry Andric}
51240b57cec5SDimitry Andric
51250b57cec5SDimitry Andric// Like BinaryRI, but expanded after RA depending on the choice of register.
51260b57cec5SDimitry Andricclass BinaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
51278bcb0991SDimitry Andric                     ImmOpWithPattern imm>
51280b57cec5SDimitry Andric  : Pseudo<(outs cls:$R1), (ins cls:$R1src, imm:$I2),
51290b57cec5SDimitry Andric           [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
51300b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
51310b57cec5SDimitry Andric}
51320b57cec5SDimitry Andric
51330b57cec5SDimitry Andric// Like BinaryRIE, but expanded after RA depending on the choice of register.
51340b57cec5SDimitry Andricclass BinaryRIEPseudo<SDPatternOperator operator, RegisterOperand cls,
51358bcb0991SDimitry Andric                      ImmOpWithPattern imm>
51360b57cec5SDimitry Andric  : Pseudo<(outs cls:$R1), (ins cls:$R3, imm:$I2),
51370b57cec5SDimitry Andric           [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
51380b57cec5SDimitry Andric
51390b57cec5SDimitry Andric// Like BinaryRIAndK, but expanded after RA depending on the choice of register.
51400b57cec5SDimitry Andricmulticlass BinaryRIAndKPseudo<string key, SDPatternOperator operator,
51418bcb0991SDimitry Andric                              RegisterOperand cls, ImmOpWithPattern imm> {
51420b57cec5SDimitry Andric  let NumOpsKey = key in {
51430b57cec5SDimitry Andric    let NumOpsValue = "3" in
51440b57cec5SDimitry Andric      def K : BinaryRIEPseudo<operator, cls, imm>,
51450b57cec5SDimitry Andric              Requires<[FeatureHighWord, FeatureDistinctOps]>;
51460b57cec5SDimitry Andric    let NumOpsValue = "2" in
51470b57cec5SDimitry Andric      def "" : BinaryRIPseudo<operator, cls, imm>,
51480b57cec5SDimitry Andric               Requires<[FeatureHighWord]>;
51490b57cec5SDimitry Andric  }
51500b57cec5SDimitry Andric}
51510b57cec5SDimitry Andric
51520b57cec5SDimitry Andric// A pseudo that is used during register allocation when folding a memory
51530b57cec5SDimitry Andric// operand. The 3-address register instruction with a spilled source cannot
51540b57cec5SDimitry Andric// be converted directly to a target 2-address reg/mem instruction.
51550b57cec5SDimitry Andric// Mapping:  <INSN>R  ->  MemFoldPseudo  ->  <INSN>
51560b57cec5SDimitry Andricclass MemFoldPseudo<string mnemonic, RegisterOperand cls, bits<5> bytes,
51570b57cec5SDimitry Andric                    AddressingMode mode>
515806c3fb27SDimitry Andric  : Pseudo<(outs cls:$R1), (ins cls:$R2, (mode $B2, $D2, $X2):$XBD2), []> {
51595ffd83dbSDimitry Andric    let OpKey = !subst("mscrk", "msrkc",
51605ffd83dbSDimitry Andric                !subst("msgcrk", "msgrkc",
51615ffd83dbSDimitry Andric                mnemonic#"rk"#cls));
51620b57cec5SDimitry Andric    let OpType = "mem";
51630b57cec5SDimitry Andric    let MemKey = mnemonic#cls;
51640b57cec5SDimitry Andric    let MemType = "pseudo";
51650b57cec5SDimitry Andric    let mayLoad = 1;
51660b57cec5SDimitry Andric    let AccessBytes = bytes;
51670b57cec5SDimitry Andric    let HasIndex = 1;
51680b57cec5SDimitry Andric    let hasNoSchedulingInfo = 1;
51690b57cec5SDimitry Andric}
51700b57cec5SDimitry Andric
51715ffd83dbSDimitry Andric// Same as MemFoldPseudo but for mapping a W... vector instruction
51725ffd83dbSDimitry Andricclass MemFoldPseudo_FP<string mnemonic, RegisterOperand cls, bits<5> bytes,
51735ffd83dbSDimitry Andric                    AddressingMode mode>
51745ffd83dbSDimitry Andric  : MemFoldPseudo<mnemonic, cls, bytes, mode> {
51755ffd83dbSDimitry Andric    let OpKey = mnemonic#"r"#"MemFold"#cls;
51765ffd83dbSDimitry Andric}
51775ffd83dbSDimitry Andric
51785ffd83dbSDimitry Andricclass MemFoldPseudo_FPTern<string mnemonic, RegisterOperand cls, bits<5> bytes,
51795ffd83dbSDimitry Andric                           AddressingMode mode>
518006c3fb27SDimitry Andric  : Pseudo<(outs cls:$R1),
518106c3fb27SDimitry Andric           (ins cls:$R2, cls:$R3, (mode $B2, $D2, $X2):$XBD2), []> {
51825ffd83dbSDimitry Andric    let OpKey = mnemonic#"r"#"MemFold"#cls;
51835ffd83dbSDimitry Andric    let OpType = "mem";
51845ffd83dbSDimitry Andric    let MemKey = mnemonic#cls;
51855ffd83dbSDimitry Andric    let MemType = "pseudo";
51865ffd83dbSDimitry Andric    let mayLoad = 1;
51875ffd83dbSDimitry Andric    let AccessBytes = bytes;
51885ffd83dbSDimitry Andric    let HasIndex = 1;
51895ffd83dbSDimitry Andric    let hasNoSchedulingInfo = 1;
51905ffd83dbSDimitry Andric}
51915ffd83dbSDimitry Andric
51925ffd83dbSDimitry Andric// Same as MemFoldPseudo but for Load On Condition with CC operands.
51935ffd83dbSDimitry Andricclass MemFoldPseudo_CondMove<string mnemonic, RegisterOperand cls, bits<5> bytes,
51945ffd83dbSDimitry Andric                             AddressingMode mode>
51955ffd83dbSDimitry Andric  : Pseudo<(outs cls:$R1),
519606c3fb27SDimitry Andric           (ins cls:$R2, (mode $B2, $D2):$BD2, cond4:$valid, cond4:$M3), []> {
51975ffd83dbSDimitry Andric    let OpKey = !subst("loc", "sel", mnemonic)#"r"#cls;
51985ffd83dbSDimitry Andric    let OpType = "mem";
51995ffd83dbSDimitry Andric    let MemKey = mnemonic#cls;
52005ffd83dbSDimitry Andric    let MemType = "pseudo";
52015ffd83dbSDimitry Andric    let mayLoad = 1;
52025ffd83dbSDimitry Andric    let AccessBytes = bytes;
52035ffd83dbSDimitry Andric    let hasNoSchedulingInfo = 1;
52045ffd83dbSDimitry Andric}
52055ffd83dbSDimitry Andric
52060b57cec5SDimitry Andric// Like CompareRI, but expanded after RA depending on the choice of register.
52070b57cec5SDimitry Andricclass CompareRIPseudo<SDPatternOperator operator, RegisterOperand cls,
52088bcb0991SDimitry Andric                      ImmOpWithPattern imm>
52090b57cec5SDimitry Andric  : Pseudo<(outs), (ins cls:$R1, imm:$I2),
52100b57cec5SDimitry Andric           [(set CC, (operator cls:$R1, imm:$I2))]> {
52110b57cec5SDimitry Andric  let isCompare = 1;
52120b57cec5SDimitry Andric}
52130b57cec5SDimitry Andric
52140b57cec5SDimitry Andric// Like CompareRXY, but expanded after RA depending on the choice of register.
52150b57cec5SDimitry Andricclass CompareRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
52160b57cec5SDimitry Andric                       SDPatternOperator load, bits<5> bytes,
52170b57cec5SDimitry Andric                       AddressingMode mode = bdxaddr20only>
521806c3fb27SDimitry Andric  : Pseudo<(outs), (ins cls:$R1, (mode $B2, $D2, $X2):$XBD2),
52190b57cec5SDimitry Andric           [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
52200b57cec5SDimitry Andric  let mayLoad = 1;
52210b57cec5SDimitry Andric  let Has20BitOffset = 1;
52220b57cec5SDimitry Andric  let HasIndex = 1;
52230b57cec5SDimitry Andric  let AccessBytes = bytes;
52240b57cec5SDimitry Andric}
52250b57cec5SDimitry Andric
52260b57cec5SDimitry Andric// Like TestBinarySIL, but expanded later.
52278bcb0991SDimitry Andricclass TestBinarySILPseudo<SDPatternOperator operator, ImmOpWithPattern imm>
522806c3fb27SDimitry Andric  : Pseudo<(outs), (ins (bdaddr12only $B1, $D1):$BD1, imm:$I2),
52290b57cec5SDimitry Andric           [(set CC, (operator bdaddr12only:$BD1, imm:$I2))]>;
52300b57cec5SDimitry Andric
52310b57cec5SDimitry Andric// Like CondBinaryRRF, but expanded after RA depending on the choice of
52320b57cec5SDimitry Andric// register.
5233480093f4SDimitry Andricclass CondBinaryRRFPseudo<string mnemonic, RegisterOperand cls1,
5234480093f4SDimitry Andric                          RegisterOperand cls2>
52350b57cec5SDimitry Andric  : Pseudo<(outs cls1:$R1),
52360b57cec5SDimitry Andric           (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3),
52370b57cec5SDimitry Andric           [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls1:$R1src,
52380b57cec5SDimitry Andric                                            cond4:$valid, cond4:$M3))]> {
52390b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
52400b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
52410b57cec5SDimitry Andric  let CCMaskLast = 1;
5242480093f4SDimitry Andric  let NumOpsKey = !subst("loc", "sel", mnemonic);
5243480093f4SDimitry Andric  let NumOpsValue = "2";
52445ffd83dbSDimitry Andric  let OpKey = mnemonic#cls1;
52455ffd83dbSDimitry Andric  let OpType = "reg";
52460b57cec5SDimitry Andric}
52470b57cec5SDimitry Andric
52480b57cec5SDimitry Andric// Like CondBinaryRRFa, but expanded after RA depending on the choice of
52490b57cec5SDimitry Andric// register.
5250480093f4SDimitry Andricclass CondBinaryRRFaPseudo<string mnemonic, RegisterOperand cls1,
5251480093f4SDimitry Andric                           RegisterOperand cls2, RegisterOperand cls3>
52520b57cec5SDimitry Andric  : Pseudo<(outs cls1:$R1),
52530b57cec5SDimitry Andric           (ins cls3:$R3, cls2:$R2, cond4:$valid, cond4:$M4),
52540b57cec5SDimitry Andric           [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls3:$R3,
52550b57cec5SDimitry Andric                                            cond4:$valid, cond4:$M4))]> {
52560b57cec5SDimitry Andric  let CCMaskLast = 1;
5257480093f4SDimitry Andric  let NumOpsKey = mnemonic;
5258480093f4SDimitry Andric  let NumOpsValue = "3";
52595ffd83dbSDimitry Andric  let OpKey = mnemonic#cls1;
52605ffd83dbSDimitry Andric  let OpType = "reg";
52610b57cec5SDimitry Andric}
52620b57cec5SDimitry Andric
52630b57cec5SDimitry Andric// Like CondBinaryRIE, but expanded after RA depending on the choice of
52640b57cec5SDimitry Andric// register.
52658bcb0991SDimitry Andricclass CondBinaryRIEPseudo<RegisterOperand cls, ImmOpWithPattern imm>
52660b57cec5SDimitry Andric  : Pseudo<(outs cls:$R1),
52670b57cec5SDimitry Andric           (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
52680b57cec5SDimitry Andric           [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
52690b57cec5SDimitry Andric                                           cond4:$valid, cond4:$M3))]> {
52700b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
52710b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
52720b57cec5SDimitry Andric  let CCMaskLast = 1;
52730b57cec5SDimitry Andric}
52740b57cec5SDimitry Andric
52750b57cec5SDimitry Andric// Like CondUnaryRSY, but expanded after RA depending on the choice of
52760b57cec5SDimitry Andric// register.
52775ffd83dbSDimitry Andricclass CondUnaryRSYPseudo<string mnemonic, SDPatternOperator operator,
52785ffd83dbSDimitry Andric                         RegisterOperand cls, bits<5> bytes,
52795ffd83dbSDimitry Andric                         AddressingMode mode = bdaddr20only>
52800b57cec5SDimitry Andric  : Pseudo<(outs cls:$R1),
528106c3fb27SDimitry Andric           (ins cls:$R1src, (mode $B2, $D2):$BD2, cond4:$valid, cond4:$R3),
52820b57cec5SDimitry Andric           [(set cls:$R1,
52830b57cec5SDimitry Andric                 (z_select_ccmask (operator mode:$BD2), cls:$R1src,
52840b57cec5SDimitry Andric                                  cond4:$valid, cond4:$R3))]> {
52850b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
52860b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
52870b57cec5SDimitry Andric  let mayLoad = 1;
52880b57cec5SDimitry Andric  let AccessBytes = bytes;
52890b57cec5SDimitry Andric  let CCMaskLast = 1;
52905ffd83dbSDimitry Andric  let OpKey = mnemonic#"r"#cls;
52915ffd83dbSDimitry Andric  let OpType = "mem";
52925ffd83dbSDimitry Andric  let MemKey = mnemonic#cls;
52935ffd83dbSDimitry Andric  let MemType = "target";
52940b57cec5SDimitry Andric}
52950b57cec5SDimitry Andric
52960b57cec5SDimitry Andric// Like CondStoreRSY, but expanded after RA depending on the choice of
52970b57cec5SDimitry Andric// register.
52980b57cec5SDimitry Andricclass CondStoreRSYPseudo<RegisterOperand cls, bits<5> bytes,
52990b57cec5SDimitry Andric                         AddressingMode mode = bdaddr20only>
530006c3fb27SDimitry Andric  : Pseudo<(outs),
530106c3fb27SDimitry Andric           (ins cls:$R1, (mode $B2, $D2):$BD2, cond4:$valid, cond4:$R3), []> {
53020b57cec5SDimitry Andric  let mayStore = 1;
53030b57cec5SDimitry Andric  let AccessBytes = bytes;
53040b57cec5SDimitry Andric  let CCMaskLast = 1;
53050b57cec5SDimitry Andric}
53060b57cec5SDimitry Andric
53070b57cec5SDimitry Andric// Like StoreRXY, but expanded after RA depending on the choice of register.
53080b57cec5SDimitry Andricclass StoreRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
53090b57cec5SDimitry Andric                     bits<5> bytes, AddressingMode mode = bdxaddr20only>
531006c3fb27SDimitry Andric  : Pseudo<(outs), (ins cls:$R1, (mode $B2, $D2, $X2):$XBD2),
53110b57cec5SDimitry Andric           [(operator cls:$R1, mode:$XBD2)]> {
53120b57cec5SDimitry Andric  let mayStore = 1;
53130b57cec5SDimitry Andric  let Has20BitOffset = 1;
53140b57cec5SDimitry Andric  let HasIndex = 1;
53150b57cec5SDimitry Andric  let AccessBytes = bytes;
53160b57cec5SDimitry Andric}
53170b57cec5SDimitry Andric
53180b57cec5SDimitry Andric// Like RotateSelectRIEf, but expanded after RA depending on the choice
53190b57cec5SDimitry Andric// of registers.
53200b57cec5SDimitry Andricclass RotateSelectRIEfPseudo<RegisterOperand cls1, RegisterOperand cls2>
53210b57cec5SDimitry Andric  : Pseudo<(outs cls1:$R1),
53220b57cec5SDimitry Andric           (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
532306c3fb27SDimitry Andric                imm32zx8:$I5),
53240b57cec5SDimitry Andric           []> {
53250b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
53260b57cec5SDimitry Andric  let DisableEncoding = "$R1src";
53270b57cec5SDimitry Andric}
53280b57cec5SDimitry Andric
53290b57cec5SDimitry Andric// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
53300b57cec5SDimitry Andric// the value of the PSW's 2-bit condition code field.
53310b57cec5SDimitry Andricclass SelectWrapper<ValueType vt, RegisterOperand cls>
53320b57cec5SDimitry Andric  : Pseudo<(outs cls:$dst),
53330b57cec5SDimitry Andric           (ins cls:$src1, cls:$src2, imm32zx4:$valid, imm32zx4:$cc),
53340b57cec5SDimitry Andric           [(set (vt cls:$dst), (z_select_ccmask cls:$src1, cls:$src2,
53358bcb0991SDimitry Andric                                            imm32zx4_timm:$valid, imm32zx4_timm:$cc))]> {
53360b57cec5SDimitry Andric  let usesCustomInserter = 1;
53370b57cec5SDimitry Andric  let hasNoSchedulingInfo = 1;
53380b57cec5SDimitry Andric  let Uses = [CC];
53390b57cec5SDimitry Andric}
53400b57cec5SDimitry Andric
53410b57cec5SDimitry Andric// Stores $new to $addr if $cc is true ("" case) or false (Inv case).
53420b57cec5SDimitry Andricmulticlass CondStores<RegisterOperand cls, SDPatternOperator store,
53430b57cec5SDimitry Andric                      SDPatternOperator load, AddressingMode mode> {
53440b57cec5SDimitry Andric  let Uses = [CC], usesCustomInserter = 1, hasNoSchedulingInfo = 1,
53450b57cec5SDimitry Andric      mayLoad = 1, mayStore = 1 in {
53460b57cec5SDimitry Andric    def "" : Pseudo<(outs),
53470b57cec5SDimitry Andric                    (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
53480b57cec5SDimitry Andric                    [(store (z_select_ccmask cls:$new, (load mode:$addr),
53498bcb0991SDimitry Andric                                             imm32zx4_timm:$valid, imm32zx4_timm:$cc),
53500b57cec5SDimitry Andric                            mode:$addr)]>;
53510b57cec5SDimitry Andric    def Inv : Pseudo<(outs),
53520b57cec5SDimitry Andric                     (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
53530b57cec5SDimitry Andric                     [(store (z_select_ccmask (load mode:$addr), cls:$new,
53548bcb0991SDimitry Andric                                              imm32zx4_timm:$valid, imm32zx4_timm:$cc),
53550b57cec5SDimitry Andric                              mode:$addr)]>;
53560b57cec5SDimitry Andric  }
53570b57cec5SDimitry Andric}
53580b57cec5SDimitry Andric
53590b57cec5SDimitry Andric// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation.  PAT and OPERAND
53600b57cec5SDimitry Andric// describe the second (non-memory) operand.
53610b57cec5SDimitry Andricclass AtomicLoadWBinary<SDPatternOperator operator, dag pat,
53620b57cec5SDimitry Andric                        DAGOperand operand>
53630b57cec5SDimitry Andric  : Pseudo<(outs GR32:$dst),
53640b57cec5SDimitry Andric           (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
53650b57cec5SDimitry Andric                ADDR32:$negbitshift, uimm32:$bitsize),
53660b57cec5SDimitry Andric           [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
53670b57cec5SDimitry Andric                                      ADDR32:$negbitshift, uimm32:$bitsize))]> {
53680b57cec5SDimitry Andric  let Defs = [CC];
53690b57cec5SDimitry Andric  let Has20BitOffset = 1;
53700b57cec5SDimitry Andric  let mayLoad = 1;
53710b57cec5SDimitry Andric  let mayStore = 1;
53720b57cec5SDimitry Andric  let usesCustomInserter = 1;
53730b57cec5SDimitry Andric  let hasNoSchedulingInfo = 1;
53740b57cec5SDimitry Andric}
53750b57cec5SDimitry Andric
53760b57cec5SDimitry Andric// Specializations of AtomicLoadWBinary.
53770b57cec5SDimitry Andricclass AtomicLoadWBinaryReg<SDPatternOperator operator>
53780b57cec5SDimitry Andric  : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
53798bcb0991SDimitry Andricclass AtomicLoadWBinaryImm<SDPatternOperator operator, ImmOpWithPattern imm>
53800b57cec5SDimitry Andric  : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;
53810b57cec5SDimitry Andric
53820b57cec5SDimitry Andric// A pseudo instruction that is a direct alias of a real instruction.
53830b57cec5SDimitry Andric// These aliases are used in cases where a particular register operand is
53840b57cec5SDimitry Andric// fixed or where the same instruction is used with different register sizes.
53850b57cec5SDimitry Andric// The size parameter is the size in bytes of the associated real instruction.
53860b57cec5SDimitry Andricclass Alias<int size, dag outs, dag ins, list<dag> pattern>
53870b57cec5SDimitry Andric  : InstSystemZ<size, outs, ins, "", pattern> {
53880b57cec5SDimitry Andric  let isPseudo = 1;
53890b57cec5SDimitry Andric  let isCodeGenOnly = 1;
53900b57cec5SDimitry Andric}
53910b57cec5SDimitry Andric
53920b57cec5SDimitry Andricclass UnaryAliasVRS<RegisterOperand cls1, RegisterOperand cls2>
53930b57cec5SDimitry Andric : Alias<6, (outs cls1:$src1), (ins cls2:$src2), []>;
53940b57cec5SDimitry Andric
53950b57cec5SDimitry Andric// An alias of a UnaryVRR*, but with different register sizes.
53960b57cec5SDimitry Andricclass UnaryAliasVRR<SDPatternOperator operator, TypedReg tr1, TypedReg tr2>
53970b57cec5SDimitry Andric  : Alias<6, (outs tr1.op:$V1), (ins tr2.op:$V2),
53980b57cec5SDimitry Andric          [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2)))]>;
53990b57cec5SDimitry Andric
54000b57cec5SDimitry Andric// An alias of a UnaryVRX, but with different register sizes.
54010b57cec5SDimitry Andricclass UnaryAliasVRX<SDPatternOperator operator, TypedReg tr,
54020b57cec5SDimitry Andric                    AddressingMode mode = bdxaddr12only>
540306c3fb27SDimitry Andric  : Alias<6, (outs tr.op:$V1), (ins (mode $B2, $D2, $X2):$XBD2),
54040b57cec5SDimitry Andric          [(set (tr.vt tr.op:$V1), (operator mode:$XBD2))]>;
54050b57cec5SDimitry Andric
54060b57cec5SDimitry Andric// An alias of a StoreVRX, but with different register sizes.
54070b57cec5SDimitry Andricclass StoreAliasVRX<SDPatternOperator operator, TypedReg tr,
54080b57cec5SDimitry Andric                    AddressingMode mode = bdxaddr12only>
540906c3fb27SDimitry Andric  : Alias<6, (outs), (ins tr.op:$V1, (mode $B2, $D2, $X2):$XBD2),
54100b57cec5SDimitry Andric          [(operator (tr.vt tr.op:$V1), mode:$XBD2)]>;
54110b57cec5SDimitry Andric
54120b57cec5SDimitry Andric// An alias of a BinaryRI, but with different register sizes.
54130b57cec5SDimitry Andricclass BinaryAliasRI<SDPatternOperator operator, RegisterOperand cls,
54148bcb0991SDimitry Andric                    ImmOpWithPattern imm>
54150b57cec5SDimitry Andric  : Alias<4, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
54160b57cec5SDimitry Andric          [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
54170b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
54180b57cec5SDimitry Andric}
54190b57cec5SDimitry Andric
54200b57cec5SDimitry Andric// An alias of a BinaryRIL, but with different register sizes.
54210b57cec5SDimitry Andricclass BinaryAliasRIL<SDPatternOperator operator, RegisterOperand cls,
54228bcb0991SDimitry Andric                     ImmOpWithPattern imm>
54230b57cec5SDimitry Andric  : Alias<6, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
54240b57cec5SDimitry Andric          [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
54250b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
54260b57cec5SDimitry Andric}
54270b57cec5SDimitry Andric
54280b57cec5SDimitry Andric// An alias of a BinaryVRRf, but with different register sizes.
54290b57cec5SDimitry Andricclass BinaryAliasVRRf<RegisterOperand cls>
54300b57cec5SDimitry Andric  : Alias<6, (outs VR128:$V1), (ins cls:$R2, cls:$R3), []>;
54310b57cec5SDimitry Andric
54320b57cec5SDimitry Andric// An alias of a CompareRI, but with different register sizes.
54330b57cec5SDimitry Andricclass CompareAliasRI<SDPatternOperator operator, RegisterOperand cls,
54348bcb0991SDimitry Andric                     ImmOpWithPattern imm>
54350b57cec5SDimitry Andric  : Alias<4, (outs), (ins cls:$R1, imm:$I2),
54360b57cec5SDimitry Andric          [(set CC, (operator cls:$R1, imm:$I2))]> {
54370b57cec5SDimitry Andric  let isCompare = 1;
54380b57cec5SDimitry Andric}
54390b57cec5SDimitry Andric
54400b57cec5SDimitry Andric// An alias of a RotateSelectRIEf, but with different register sizes.
54410b57cec5SDimitry Andricclass RotateSelectAliasRIEf<RegisterOperand cls1, RegisterOperand cls2>
54420b57cec5SDimitry Andric  : Alias<6, (outs cls1:$R1),
54430b57cec5SDimitry Andric          (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
544406c3fb27SDimitry Andric               imm32zx8:$I5), []> {
54450b57cec5SDimitry Andric  let Constraints = "$R1 = $R1src";
54460b57cec5SDimitry Andric}
54470b57cec5SDimitry Andric
54480eae32dcSDimitry Andricclass MemsetPseudo<DAGOperand lenop, DAGOperand byteop>
54490eae32dcSDimitry Andric  : Pseudo<(outs), (ins bdaddr12only:$dest, lenop:$length, byteop:$B),
54500eae32dcSDimitry Andric           [(z_memset_mvc bdaddr12only:$dest, lenop:$length, byteop:$B)]> {
54510eae32dcSDimitry Andric  let Defs = [CC];
54520eae32dcSDimitry Andric  let mayLoad = 1;
54530eae32dcSDimitry Andric  let mayStore = 1;
54540eae32dcSDimitry Andric  let usesCustomInserter = 1;
54550eae32dcSDimitry Andric  let hasNoSchedulingInfo = 1;
54560eae32dcSDimitry Andric}
54570eae32dcSDimitry Andric
54580b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
54590b57cec5SDimitry Andric// Multiclasses that emit both real and pseudo instructions
54600b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
54610b57cec5SDimitry Andric
54620b57cec5SDimitry Andricmulticlass BinaryRXYAndPseudo<string mnemonic, bits<16> opcode,
54630b57cec5SDimitry Andric                              SDPatternOperator operator, RegisterOperand cls,
54640b57cec5SDimitry Andric                              SDPatternOperator load, bits<5> bytes,
54650b57cec5SDimitry Andric                              AddressingMode mode = bdxaddr20only> {
54660b57cec5SDimitry Andric  def "" : BinaryRXY<mnemonic, opcode, operator, cls, load, bytes, mode> {
54670b57cec5SDimitry Andric    let MemKey = mnemonic#cls;
54680b57cec5SDimitry Andric    let MemType = "target";
54690b57cec5SDimitry Andric  }
54700b57cec5SDimitry Andric  let Has20BitOffset = 1 in
54710b57cec5SDimitry Andric    def _MemFoldPseudo : MemFoldPseudo<mnemonic, cls, bytes, mode>;
54720b57cec5SDimitry Andric}
54730b57cec5SDimitry Andric
54740b57cec5SDimitry Andricmulticlass BinaryRXPairAndPseudo<string mnemonic, bits<8> rxOpcode,
54750b57cec5SDimitry Andric                                 bits<16> rxyOpcode, SDPatternOperator operator,
54760b57cec5SDimitry Andric                                 RegisterOperand cls,
54770b57cec5SDimitry Andric                                 SDPatternOperator load, bits<5> bytes> {
54785ffd83dbSDimitry Andric  let DispKey = mnemonic # cls in {
54790b57cec5SDimitry Andric    def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
54800b57cec5SDimitry Andric                      bdxaddr12pair> {
54810b57cec5SDimitry Andric      let DispSize = "12";
54820b57cec5SDimitry Andric      let MemKey = mnemonic#cls;
54830b57cec5SDimitry Andric      let MemType = "target";
54840b57cec5SDimitry Andric    }
54850b57cec5SDimitry Andric    let DispSize = "20" in
54860b57cec5SDimitry Andric      def Y  : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load,
54870b57cec5SDimitry Andric                         bytes, bdxaddr20pair>;
54880b57cec5SDimitry Andric  }
54890b57cec5SDimitry Andric  def _MemFoldPseudo : MemFoldPseudo<mnemonic, cls, bytes, bdxaddr12pair>;
54900b57cec5SDimitry Andric}
54910b57cec5SDimitry Andric
54925ffd83dbSDimitry Andricmulticlass BinaryRXEAndPseudo<string mnemonic, bits<16> opcode,
54935ffd83dbSDimitry Andric                              SDPatternOperator operator, RegisterOperand cls,
54945ffd83dbSDimitry Andric                              SDPatternOperator load, bits<5> bytes> {
54955ffd83dbSDimitry Andric  def "" : BinaryRXE<mnemonic, opcode, operator, cls, load, bytes> {
54965ffd83dbSDimitry Andric    let MemKey = mnemonic#cls;
54975ffd83dbSDimitry Andric    let MemType = "target";
54985ffd83dbSDimitry Andric  }
54995ffd83dbSDimitry Andric  def _MemFoldPseudo : MemFoldPseudo_FP<mnemonic, cls, bytes, bdxaddr12pair>;
55005ffd83dbSDimitry Andric}
55015ffd83dbSDimitry Andric
55025ffd83dbSDimitry Andricmulticlass TernaryRXFAndPseudo<string mnemonic, bits<16> opcode,
55035ffd83dbSDimitry Andric                               SDPatternOperator operator, RegisterOperand cls1,
55045ffd83dbSDimitry Andric                               RegisterOperand cls2, SDPatternOperator load,
55055ffd83dbSDimitry Andric                               bits<5> bytes> {
55065ffd83dbSDimitry Andric  def "" : TernaryRXF<mnemonic, opcode, operator, cls1, cls2, load, bytes> {
55075ffd83dbSDimitry Andric    let MemKey = mnemonic#cls1;
55085ffd83dbSDimitry Andric    let MemType = "target";
55095ffd83dbSDimitry Andric  }
55105ffd83dbSDimitry Andric  def _MemFoldPseudo : MemFoldPseudo_FPTern<mnemonic, cls1, bytes, bdxaddr12pair>;
55115ffd83dbSDimitry Andric}
55125ffd83dbSDimitry Andric
55135ffd83dbSDimitry Andricmulticlass CondUnaryRSYPairAndMemFold<string mnemonic, bits<16> opcode,
55145ffd83dbSDimitry Andric                                      SDPatternOperator operator,
55155ffd83dbSDimitry Andric                                      RegisterOperand cls, bits<5> bytes,
55165ffd83dbSDimitry Andric                                      AddressingMode mode = bdaddr20only> {
55175ffd83dbSDimitry Andric  defm "" : CondUnaryRSYPair<mnemonic, opcode, operator, cls, bytes, mode>;
55185ffd83dbSDimitry Andric  def _MemFoldPseudo : MemFoldPseudo_CondMove<mnemonic, cls, bytes, mode>;
55195ffd83dbSDimitry Andric}
55205ffd83dbSDimitry Andric
55215ffd83dbSDimitry Andricmulticlass CondUnaryRSYPseudoAndMemFold<string mnemonic,
55225ffd83dbSDimitry Andric                                        SDPatternOperator operator,
55235ffd83dbSDimitry Andric                                        RegisterOperand cls, bits<5> bytes,
55245ffd83dbSDimitry Andric                                        AddressingMode mode = bdaddr20only> {
55255ffd83dbSDimitry Andric  def "" : CondUnaryRSYPseudo<mnemonic, operator, cls, bytes, mode>;
55265ffd83dbSDimitry Andric  def _MemFoldPseudo : MemFoldPseudo_CondMove<mnemonic, cls, bytes, mode>;
55275ffd83dbSDimitry Andric}
55285ffd83dbSDimitry Andric
55290b57cec5SDimitry Andric// Define an instruction that operates on two fixed-length blocks of memory,
55300b57cec5SDimitry Andric// and associated pseudo instructions for operating on blocks of any size.
5531349cc55cSDimitry Andric// There are two pseudos for the different cases of when the length is
5532349cc55cSDimitry Andric// constant or variable. The length operand of a pseudo is actually one less
5533349cc55cSDimitry Andric// than the intended number of bytes, since the register case needs to use an
5534349cc55cSDimitry Andric// EXRL with a target instruction that adds one to the length always.
5535349cc55cSDimitry Andricmulticlass MemorySS<string mnemonic, bits<8> opcode, SDPatternOperator memop> {
55360b57cec5SDimitry Andric  def "" : SideEffectBinarySSa<mnemonic, opcode>;
55370b57cec5SDimitry Andric  let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CC] in {
5538349cc55cSDimitry Andric    def Imm : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
55390b57cec5SDimitry Andric                                  imm64:$length),
5540349cc55cSDimitry Andric                             [(memop bdaddr12only:$dest, bdaddr12only:$src,
55410b57cec5SDimitry Andric                                     imm64:$length)]>;
5542349cc55cSDimitry Andric    def Reg : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5543349cc55cSDimitry Andric                                  ADDR64:$length),
5544349cc55cSDimitry Andric                             [(memop bdaddr12only:$dest, bdaddr12only:$src,
5545349cc55cSDimitry Andric                                     ADDR64:$length)]>;
55460b57cec5SDimitry Andric  }
55470b57cec5SDimitry Andric}
55480b57cec5SDimitry Andric
55495ffd83dbSDimitry Andric// The same, but setting a CC result as comparison operator.
55500b57cec5SDimitry Andricmulticlass CompareMemorySS<string mnemonic, bits<8> opcode,
5551349cc55cSDimitry Andric                           SDPatternOperator memop> {
55520b57cec5SDimitry Andric  def "" : SideEffectBinarySSa<mnemonic, opcode>;
55530b57cec5SDimitry Andric  let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
5554349cc55cSDimitry Andric    def Imm : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
55550b57cec5SDimitry Andric                                  imm64:$length),
5556349cc55cSDimitry Andric                          [(set CC, (memop bdaddr12only:$dest, bdaddr12only:$src,
55570b57cec5SDimitry Andric                                           imm64:$length))]>;
5558349cc55cSDimitry Andric    def Reg : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5559349cc55cSDimitry Andric                                  ADDR64:$length),
5560349cc55cSDimitry Andric                          [(set CC, (memop bdaddr12only:$dest, bdaddr12only:$src,
5561349cc55cSDimitry Andric                                           ADDR64:$length))]>;
55620b57cec5SDimitry Andric  }
55630b57cec5SDimitry Andric}
55640b57cec5SDimitry Andric
55650b57cec5SDimitry Andric// Define an instruction that operates on two strings, both terminated
55660b57cec5SDimitry Andric// by the character in R0.  The instruction processes a CPU-determinated
55670b57cec5SDimitry Andric// number of bytes at a time and sets CC to 3 if the instruction needs
55680b57cec5SDimitry Andric// to be repeated.  Also define a pseudo instruction that represents
55690b57cec5SDimitry Andric// the full loop (the main instruction plus the branch on CC==3).
55700b57cec5SDimitry Andricmulticlass StringRRE<string mnemonic, bits<16> opcode,
55710b57cec5SDimitry Andric                     SDPatternOperator operator> {
55720b57cec5SDimitry Andric  let Uses = [R0L] in
55730b57cec5SDimitry Andric    def "" : SideEffectBinaryMemMemRRE<mnemonic, opcode, GR64, GR64>;
55740b57cec5SDimitry Andric  let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in
55750b57cec5SDimitry Andric    def Loop : Pseudo<(outs GR64:$end),
55760b57cec5SDimitry Andric                      (ins GR64:$start1, GR64:$start2, GR32:$char),
55770b57cec5SDimitry Andric                      [(set GR64:$end, (operator GR64:$start1, GR64:$start2,
55780b57cec5SDimitry Andric                                                 GR32:$char))]>;
55790b57cec5SDimitry Andric}
5580