xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AArch64/SVEInstrFormats.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric//=-- SVEInstrFormats.td -  AArch64 SVE Instruction classes -*- 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// AArch64 Scalable Vector Extension (SVE) Instruction Class Definitions.
100b57cec5SDimitry Andric//
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
1306c3fb27SDimitry Andric// Helper class to find the largest legal scalable vector type that can hold VT.
1406c3fb27SDimitry Andric// Non-matches return VT, which often means VT is the container type.
1506c3fb27SDimitry Andricclass SVEContainerVT<ValueType VT> {
1606c3fb27SDimitry Andric  ValueType Value = !cond(
1706c3fb27SDimitry Andric    // fixed length vectors
1806c3fb27SDimitry Andric    !eq(VT, v8i8): nxv16i8,
1906c3fb27SDimitry Andric    !eq(VT, v16i8): nxv16i8,
2006c3fb27SDimitry Andric    !eq(VT, v4i16): nxv8i16,
2106c3fb27SDimitry Andric    !eq(VT, v8i16): nxv8i16,
2206c3fb27SDimitry Andric    !eq(VT, v2i32): nxv4i32,
2306c3fb27SDimitry Andric    !eq(VT, v4i32): nxv4i32,
2406c3fb27SDimitry Andric    !eq(VT, v1i64): nxv2i64,
2506c3fb27SDimitry Andric    !eq(VT, v2i64): nxv2i64,
2606c3fb27SDimitry Andric    !eq(VT, v4f16): nxv8f16,
2706c3fb27SDimitry Andric    !eq(VT, v8f16): nxv8f16,
2806c3fb27SDimitry Andric    !eq(VT, v2f32): nxv4f32,
2906c3fb27SDimitry Andric    !eq(VT, v4f32): nxv4f32,
3006c3fb27SDimitry Andric    !eq(VT, v1f64): nxv2f64,
3106c3fb27SDimitry Andric    !eq(VT, v2f64): nxv2f64,
3206c3fb27SDimitry Andric    !eq(VT, v4bf16): nxv8bf16,
3306c3fb27SDimitry Andric    !eq(VT, v8bf16): nxv8bf16,
3406c3fb27SDimitry Andric    // unpacked scalable vectors
3506c3fb27SDimitry Andric    !eq(VT, nxv2f16): nxv8f16,
3606c3fb27SDimitry Andric    !eq(VT, nxv4f16): nxv8f16,
3706c3fb27SDimitry Andric    !eq(VT, nxv2f32): nxv4f32,
3806c3fb27SDimitry Andric    !eq(VT, nxv2bf16): nxv8bf16,
3906c3fb27SDimitry Andric    !eq(VT, nxv4bf16): nxv8bf16,
4006c3fb27SDimitry Andric    true : VT);
4106c3fb27SDimitry Andric}
4206c3fb27SDimitry Andric
435ffd83dbSDimitry Andricdef SDT_AArch64Setcc : SDTypeProfile<1, 4, [
445ffd83dbSDimitry Andric  SDTCisVec<0>, SDTCisVec<1>, SDTCisVec<2>, SDTCisVec<3>,
455ffd83dbSDimitry Andric  SDTCVecEltisVT<0, i1>, SDTCVecEltisVT<1, i1>, SDTCisSameAs<2, 3>,
465ffd83dbSDimitry Andric  SDTCisVT<4, OtherVT>
475ffd83dbSDimitry Andric]>;
485ffd83dbSDimitry Andric
495ffd83dbSDimitry Andricdef AArch64setcc_z : SDNode<"AArch64ISD::SETCC_MERGE_ZERO", SDT_AArch64Setcc>;
5006c3fb27SDimitry Andricdef AArch64setcc_z_oneuse : PatFrag<(ops node:$pg, node:$op1, node:$op2, node:$cc),
5106c3fb27SDimitry Andric                                    (AArch64setcc_z node:$pg, node:$op1, node:$op2, node:$cc), [{
5206c3fb27SDimitry Andric  return N->hasOneUse();
5306c3fb27SDimitry Andric}]>;
545ffd83dbSDimitry Andric
550b57cec5SDimitry Andricdef SVEPatternOperand : AsmOperandClass {
560b57cec5SDimitry Andric  let Name = "SVEPattern";
570b57cec5SDimitry Andric  let ParserMethod = "tryParseSVEPattern";
580b57cec5SDimitry Andric  let PredicateMethod = "isSVEPattern";
590b57cec5SDimitry Andric  let RenderMethod = "addImmOperands";
600b57cec5SDimitry Andric  let DiagnosticType = "InvalidSVEPattern";
610b57cec5SDimitry Andric}
620b57cec5SDimitry Andric
63480093f4SDimitry Andricdef sve_pred_enum : Operand<i32>, TImmLeaf<i32, [{
640b57cec5SDimitry Andric  return (((uint32_t)Imm) < 32);
650b57cec5SDimitry Andric  }]> {
660b57cec5SDimitry Andric
670b57cec5SDimitry Andric  let PrintMethod = "printSVEPattern";
680b57cec5SDimitry Andric  let ParserMatchClass = SVEPatternOperand;
690b57cec5SDimitry Andric}
700b57cec5SDimitry Andric
71bdd1243dSDimitry Andricdef SVEVecLenSpecifierOperand : AsmOperandClass {
72bdd1243dSDimitry Andric  let Name = "SVEVecLenSpecifier";
73bdd1243dSDimitry Andric  let ParserMethod = "tryParseSVEVecLenSpecifier";
74bdd1243dSDimitry Andric  let PredicateMethod = "isSVEVecLenSpecifier";
75bdd1243dSDimitry Andric  let RenderMethod = "addImmOperands";
76bdd1243dSDimitry Andric  let DiagnosticType = "InvalidSVEVecLenSpecifier";
77bdd1243dSDimitry Andric}
78bdd1243dSDimitry Andric
79bdd1243dSDimitry Andricdef sve_vec_len_specifier_enum : Operand<i32>, TImmLeaf<i32, [{
80bdd1243dSDimitry Andric  return (((uint32_t)Imm) < 2);
81bdd1243dSDimitry Andric  }]> {
82bdd1243dSDimitry Andric
83bdd1243dSDimitry Andric  let PrintMethod = "printSVEVecLenSpecifier";
84bdd1243dSDimitry Andric  let ParserMatchClass = SVEVecLenSpecifierOperand;
85bdd1243dSDimitry Andric}
86bdd1243dSDimitry Andric
870b57cec5SDimitry Andricdef SVEPrefetchOperand : AsmOperandClass {
880b57cec5SDimitry Andric  let Name = "SVEPrefetch";
890b57cec5SDimitry Andric  let ParserMethod = "tryParsePrefetch<true>";
900b57cec5SDimitry Andric  let PredicateMethod = "isPrefetch";
910b57cec5SDimitry Andric  let RenderMethod = "addPrefetchOperands";
920b57cec5SDimitry Andric}
930b57cec5SDimitry Andric
945ffd83dbSDimitry Andricdef sve_prfop : Operand<i32>, TImmLeaf<i32, [{
950b57cec5SDimitry Andric    return (((uint32_t)Imm) <= 15);
960b57cec5SDimitry Andric  }]> {
970b57cec5SDimitry Andric  let PrintMethod = "printPrefetchOp<true>";
980b57cec5SDimitry Andric  let ParserMatchClass = SVEPrefetchOperand;
990b57cec5SDimitry Andric}
1000b57cec5SDimitry Andric
1010b57cec5SDimitry Andricclass SVELogicalImmOperand<int Width> : AsmOperandClass {
1020b57cec5SDimitry Andric  let Name = "SVELogicalImm" # Width;
1030b57cec5SDimitry Andric  let DiagnosticType = "LogicalSecondSource";
1040b57cec5SDimitry Andric  let PredicateMethod = "isLogicalImm<int" # Width # "_t>";
1050b57cec5SDimitry Andric  let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>";
1060b57cec5SDimitry Andric}
1070b57cec5SDimitry Andric
1080b57cec5SDimitry Andricdef sve_logical_imm8 : Operand<i64> {
1090b57cec5SDimitry Andric  let ParserMatchClass = SVELogicalImmOperand<8>;
1100b57cec5SDimitry Andric  let PrintMethod = "printLogicalImm<int8_t>";
1110b57cec5SDimitry Andric
1120b57cec5SDimitry Andric  let MCOperandPredicate = [{
1130b57cec5SDimitry Andric    if (!MCOp.isImm())
1140b57cec5SDimitry Andric      return false;
1150b57cec5SDimitry Andric    int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
1160b57cec5SDimitry Andric    return AArch64_AM::isSVEMaskOfIdenticalElements<int8_t>(Val);
1170b57cec5SDimitry Andric  }];
1180b57cec5SDimitry Andric}
1190b57cec5SDimitry Andric
1200b57cec5SDimitry Andricdef sve_logical_imm16 : Operand<i64> {
1210b57cec5SDimitry Andric  let ParserMatchClass = SVELogicalImmOperand<16>;
1220b57cec5SDimitry Andric  let PrintMethod = "printLogicalImm<int16_t>";
1230b57cec5SDimitry Andric
1240b57cec5SDimitry Andric  let MCOperandPredicate = [{
1250b57cec5SDimitry Andric    if (!MCOp.isImm())
1260b57cec5SDimitry Andric      return false;
1270b57cec5SDimitry Andric    int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
1280b57cec5SDimitry Andric    return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val);
1290b57cec5SDimitry Andric  }];
1300b57cec5SDimitry Andric}
1310b57cec5SDimitry Andric
1320b57cec5SDimitry Andricdef sve_logical_imm32 : Operand<i64> {
1330b57cec5SDimitry Andric  let ParserMatchClass = SVELogicalImmOperand<32>;
1340b57cec5SDimitry Andric  let PrintMethod = "printLogicalImm<int32_t>";
1350b57cec5SDimitry Andric
1360b57cec5SDimitry Andric  let MCOperandPredicate = [{
1370b57cec5SDimitry Andric    if (!MCOp.isImm())
1380b57cec5SDimitry Andric      return false;
1390b57cec5SDimitry Andric    int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
1400b57cec5SDimitry Andric    return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val);
1410b57cec5SDimitry Andric  }];
1420b57cec5SDimitry Andric}
1430b57cec5SDimitry Andric
1440b57cec5SDimitry Andricclass SVEPreferredLogicalImmOperand<int Width> : AsmOperandClass {
1450b57cec5SDimitry Andric  let Name = "SVEPreferredLogicalImm" # Width;
1460b57cec5SDimitry Andric  let PredicateMethod = "isSVEPreferredLogicalImm<int" # Width # "_t>";
1470b57cec5SDimitry Andric  let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>";
1480b57cec5SDimitry Andric}
1490b57cec5SDimitry Andric
1500b57cec5SDimitry Andricdef sve_preferred_logical_imm16 : Operand<i64> {
1510b57cec5SDimitry Andric  let ParserMatchClass = SVEPreferredLogicalImmOperand<16>;
1520b57cec5SDimitry Andric  let PrintMethod = "printSVELogicalImm<int16_t>";
1530b57cec5SDimitry Andric
1540b57cec5SDimitry Andric  let MCOperandPredicate = [{
1550b57cec5SDimitry Andric    if (!MCOp.isImm())
1560b57cec5SDimitry Andric      return false;
1570b57cec5SDimitry Andric    int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
1580b57cec5SDimitry Andric    return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val) &&
1590b57cec5SDimitry Andric           AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
1600b57cec5SDimitry Andric  }];
1610b57cec5SDimitry Andric}
1620b57cec5SDimitry Andric
1630b57cec5SDimitry Andricdef sve_preferred_logical_imm32 : Operand<i64> {
1640b57cec5SDimitry Andric  let ParserMatchClass =  SVEPreferredLogicalImmOperand<32>;
1650b57cec5SDimitry Andric  let PrintMethod = "printSVELogicalImm<int32_t>";
1660b57cec5SDimitry Andric
1670b57cec5SDimitry Andric  let MCOperandPredicate = [{
1680b57cec5SDimitry Andric    if (!MCOp.isImm())
1690b57cec5SDimitry Andric      return false;
1700b57cec5SDimitry Andric    int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
1710b57cec5SDimitry Andric    return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val) &&
1720b57cec5SDimitry Andric           AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
1730b57cec5SDimitry Andric  }];
1740b57cec5SDimitry Andric}
1750b57cec5SDimitry Andric
1760b57cec5SDimitry Andricdef sve_preferred_logical_imm64 : Operand<i64> {
1770b57cec5SDimitry Andric  let ParserMatchClass = SVEPreferredLogicalImmOperand<64>;
1780b57cec5SDimitry Andric  let PrintMethod = "printSVELogicalImm<int64_t>";
1790b57cec5SDimitry Andric
1800b57cec5SDimitry Andric  let MCOperandPredicate = [{
1810b57cec5SDimitry Andric    if (!MCOp.isImm())
1820b57cec5SDimitry Andric      return false;
1830b57cec5SDimitry Andric    int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
1840b57cec5SDimitry Andric    return AArch64_AM::isSVEMaskOfIdenticalElements<int64_t>(Val) &&
1850b57cec5SDimitry Andric           AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
1860b57cec5SDimitry Andric  }];
1870b57cec5SDimitry Andric}
1880b57cec5SDimitry Andric
1890b57cec5SDimitry Andricclass SVELogicalImmNotOperand<int Width> : AsmOperandClass {
1900b57cec5SDimitry Andric  let Name = "SVELogicalImm" # Width # "Not";
1910b57cec5SDimitry Andric  let DiagnosticType = "LogicalSecondSource";
1920b57cec5SDimitry Andric  let PredicateMethod = "isLogicalImm<int" # Width # "_t>";
1930b57cec5SDimitry Andric  let RenderMethod = "addLogicalImmNotOperands<int" # Width # "_t>";
1940b57cec5SDimitry Andric}
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andricdef sve_logical_imm8_not : Operand<i64> {
1970b57cec5SDimitry Andric  let ParserMatchClass = SVELogicalImmNotOperand<8>;
1980b57cec5SDimitry Andric}
1990b57cec5SDimitry Andric
2000b57cec5SDimitry Andricdef sve_logical_imm16_not : Operand<i64> {
2010b57cec5SDimitry Andric  let ParserMatchClass = SVELogicalImmNotOperand<16>;
2020b57cec5SDimitry Andric}
2030b57cec5SDimitry Andric
2040b57cec5SDimitry Andricdef sve_logical_imm32_not : Operand<i64> {
2050b57cec5SDimitry Andric  let ParserMatchClass = SVELogicalImmNotOperand<32>;
2060b57cec5SDimitry Andric}
2070b57cec5SDimitry Andric
2080b57cec5SDimitry Andricclass SVEShiftedImmOperand<int ElementWidth, string Infix, string Predicate>
2090b57cec5SDimitry Andric    : AsmOperandClass {
2100b57cec5SDimitry Andric  let Name = "SVE" # Infix # "Imm" # ElementWidth;
2110b57cec5SDimitry Andric  let DiagnosticType = "Invalid" # Name;
2120b57cec5SDimitry Andric  let RenderMethod = "addImmWithOptionalShiftOperands<8>";
2130b57cec5SDimitry Andric  let ParserMethod = "tryParseImmWithOptionalShift";
2140b57cec5SDimitry Andric  let PredicateMethod = Predicate;
2150b57cec5SDimitry Andric}
2160b57cec5SDimitry Andric
2170b57cec5SDimitry Andricdef SVECpyImmOperand8  : SVEShiftedImmOperand<8,  "Cpy", "isSVECpyImm<int8_t>">;
2180b57cec5SDimitry Andricdef SVECpyImmOperand16 : SVEShiftedImmOperand<16, "Cpy", "isSVECpyImm<int16_t>">;
2190b57cec5SDimitry Andricdef SVECpyImmOperand32 : SVEShiftedImmOperand<32, "Cpy", "isSVECpyImm<int32_t>">;
2200b57cec5SDimitry Andricdef SVECpyImmOperand64 : SVEShiftedImmOperand<64, "Cpy", "isSVECpyImm<int64_t>">;
2210b57cec5SDimitry Andric
2220b57cec5SDimitry Andricdef SVEAddSubImmOperand8  : SVEShiftedImmOperand<8,  "AddSub", "isSVEAddSubImm<int8_t>">;
2230b57cec5SDimitry Andricdef SVEAddSubImmOperand16 : SVEShiftedImmOperand<16, "AddSub", "isSVEAddSubImm<int16_t>">;
2240b57cec5SDimitry Andricdef SVEAddSubImmOperand32 : SVEShiftedImmOperand<32, "AddSub", "isSVEAddSubImm<int32_t>">;
2250b57cec5SDimitry Andricdef SVEAddSubImmOperand64 : SVEShiftedImmOperand<64, "AddSub", "isSVEAddSubImm<int64_t>">;
2260b57cec5SDimitry Andric
2270b57cec5SDimitry Andricclass imm8_opt_lsl<int ElementWidth, string printType,
2285ffd83dbSDimitry Andric                   AsmOperandClass OpndClass>
2295ffd83dbSDimitry Andric    : Operand<i32> {
2300b57cec5SDimitry Andric  let EncoderMethod = "getImm8OptLsl";
2310b57cec5SDimitry Andric  let DecoderMethod = "DecodeImm8OptLsl<" # ElementWidth # ">";
2320b57cec5SDimitry Andric  let PrintMethod = "printImm8OptLsl<" # printType # ">";
2330b57cec5SDimitry Andric  let ParserMatchClass = OpndClass;
2340b57cec5SDimitry Andric  let MIOperandInfo = (ops i32imm, i32imm);
2350b57cec5SDimitry Andric}
2360b57cec5SDimitry Andric
2375ffd83dbSDimitry Andricdef cpy_imm8_opt_lsl_i8  : imm8_opt_lsl<8,  "int8_t",  SVECpyImmOperand8>;
2385ffd83dbSDimitry Andricdef cpy_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "int16_t", SVECpyImmOperand16>;
2395ffd83dbSDimitry Andricdef cpy_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "int32_t", SVECpyImmOperand32>;
2405ffd83dbSDimitry Andricdef cpy_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "int64_t", SVECpyImmOperand64>;
2410b57cec5SDimitry Andric
2425ffd83dbSDimitry Andricdef addsub_imm8_opt_lsl_i8  : imm8_opt_lsl<8,  "uint8_t",  SVEAddSubImmOperand8>;
2435ffd83dbSDimitry Andricdef addsub_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "uint16_t", SVEAddSubImmOperand16>;
2445ffd83dbSDimitry Andricdef addsub_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "uint32_t", SVEAddSubImmOperand32>;
2455ffd83dbSDimitry Andricdef addsub_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "uint64_t", SVEAddSubImmOperand64>;
2460b57cec5SDimitry Andric
247480093f4SDimitry Andricdef SVEAddSubImm8Pat  : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i8>", []>;
248480093f4SDimitry Andricdef SVEAddSubImm16Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i16>", []>;
249480093f4SDimitry Andricdef SVEAddSubImm32Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i32>", []>;
2500eae32dcSDimitry Andricdef SVEAddSubImm64Pat : ComplexPattern<i64, 2, "SelectSVEAddSubImm<MVT::i64>", []>;
251480093f4SDimitry Andric
252*0fca6ea1SDimitry Andricdef SVEAddSubSSatNegImm8Pat  : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i8, true>", []>;
253*0fca6ea1SDimitry Andricdef SVEAddSubSSatNegImm16Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i16, true>", []>;
254*0fca6ea1SDimitry Andricdef SVEAddSubSSatNegImm32Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i32, true>", []>;
255*0fca6ea1SDimitry Andricdef SVEAddSubSSatNegImm64Pat : ComplexPattern<i64, 2, "SelectSVEAddSubSSatImm<MVT::i64, true>", []>;
256*0fca6ea1SDimitry Andric
257*0fca6ea1SDimitry Andricdef SVEAddSubSSatPosImm8Pat  : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i8, false>", []>;
258*0fca6ea1SDimitry Andricdef SVEAddSubSSatPosImm16Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i16, false>", []>;
259*0fca6ea1SDimitry Andricdef SVEAddSubSSatPosImm32Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i32, false>", []>;
260*0fca6ea1SDimitry Andricdef SVEAddSubSSatPosImm64Pat : ComplexPattern<i64, 2, "SelectSVEAddSubSSatImm<MVT::i64, false>", []>;
261*0fca6ea1SDimitry Andric
26281ad6265SDimitry Andricdef SVECpyDupImm8Pat  : ComplexPattern<i32, 2, "SelectSVECpyDupImm<MVT::i8>", []>;
26381ad6265SDimitry Andricdef SVECpyDupImm16Pat : ComplexPattern<i32, 2, "SelectSVECpyDupImm<MVT::i16>", []>;
26481ad6265SDimitry Andricdef SVECpyDupImm32Pat : ComplexPattern<i32, 2, "SelectSVECpyDupImm<MVT::i32>", []>;
26581ad6265SDimitry Andricdef SVECpyDupImm64Pat : ComplexPattern<i64, 2, "SelectSVECpyDupImm<MVT::i64>", []>;
26681ad6265SDimitry Andric
2670eae32dcSDimitry Andricdef SVELogicalImm8Pat  : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i8>", []>;
2680eae32dcSDimitry Andricdef SVELogicalImm16Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i16>", []>;
2690eae32dcSDimitry Andricdef SVELogicalImm32Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i32>", []>;
270480093f4SDimitry Andricdef SVELogicalImm64Pat : ComplexPattern<i64, 1, "SelectSVELogicalImm<MVT::i64>", []>;
271480093f4SDimitry Andric
2720eae32dcSDimitry Andricdef SVELogicalImm8NotPat  : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i8, true>", []>;
2730eae32dcSDimitry Andricdef SVELogicalImm16NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i16, true>", []>;
2740eae32dcSDimitry Andricdef SVELogicalImm32NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i32, true>", []>;
275fe6060f1SDimitry Andricdef SVELogicalImm64NotPat : ComplexPattern<i64, 1, "SelectSVELogicalImm<MVT::i64, true>", []>;
276fe6060f1SDimitry Andric
277e8d8bef9SDimitry Andricdef SVEArithUImm8Pat  : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i8>", []>;
278e8d8bef9SDimitry Andricdef SVEArithUImm16Pat  : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i16>", []>;
279e8d8bef9SDimitry Andricdef SVEArithUImm32Pat  : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i32>", []>;
2800eae32dcSDimitry Andricdef SVEArithUImm64Pat  : ComplexPattern<i64, 1, "SelectSVEArithImm<MVT::i64>", []>;
2810eae32dcSDimitry Andric
2820eae32dcSDimitry Andricdef SVEArithSImmPat32 : ComplexPattern<i32, 1, "SelectSVESignedArithImm", []>;
2830eae32dcSDimitry Andricdef SVEArithSImmPat64 : ComplexPattern<i64, 1, "SelectSVESignedArithImm", []>;
284480093f4SDimitry Andric
285e8d8bef9SDimitry Andricdef SVEShiftImmL8  : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 7>",  []>;
286e8d8bef9SDimitry Andricdef SVEShiftImmL16 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 15>", []>;
287e8d8bef9SDimitry Andricdef SVEShiftImmL32 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 31>", []>;
2880eae32dcSDimitry Andricdef SVEShiftImmL64 : ComplexPattern<i64, 1, "SelectSVEShiftImm<0, 63>", []>;
289e8d8bef9SDimitry Andricdef SVEShiftImmR8  : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 8,  true>", []>;
290e8d8bef9SDimitry Andricdef SVEShiftImmR16 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 16, true>", []>;
291e8d8bef9SDimitry Andricdef SVEShiftImmR32 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 32, true>", []>;
2920eae32dcSDimitry Andricdef SVEShiftImmR64 : ComplexPattern<i64, 1, "SelectSVEShiftImm<1, 64, true>", []>;
2935ffd83dbSDimitry Andric
29481ad6265SDimitry Andricdef SVEShiftSplatImmR : ComplexPattern<iAny, 1, "SelectSVEShiftSplatImmR", []>;
29581ad6265SDimitry Andric
296fe6060f1SDimitry Andricdef SVEAllActive : ComplexPattern<untyped, 0, "SelectAllActivePredicate", []>;
29706c3fb27SDimitry Andricdef SVEAnyPredicate : ComplexPattern<untyped, 0, "SelectAnyPredicate", []>;
298fe6060f1SDimitry Andric
2990b57cec5SDimitry Andricclass SVEExactFPImm<string Suffix, string ValA, string ValB> : AsmOperandClass {
3000b57cec5SDimitry Andric  let Name = "SVEExactFPImmOperand" # Suffix;
3010b57cec5SDimitry Andric  let DiagnosticType = "Invalid" # Name;
3020b57cec5SDimitry Andric  let ParserMethod = "tryParseFPImm<false>";
3030b57cec5SDimitry Andric  let PredicateMethod = "isExactFPImm<" # ValA # ", " # ValB # ">";
3040b57cec5SDimitry Andric  let RenderMethod = "addExactFPImmOperands<" # ValA # ", " # ValB # ">";
3050b57cec5SDimitry Andric}
3060b57cec5SDimitry Andric
3070b57cec5SDimitry Andricclass SVEExactFPImmOperand<string Suffix, string ValA, string ValB> : Operand<i32> {
3080b57cec5SDimitry Andric  let PrintMethod = "printExactFPImm<" # ValA # ", " # ValB # ">";
3090b57cec5SDimitry Andric  let ParserMatchClass = SVEExactFPImm<Suffix, ValA, ValB>;
3100b57cec5SDimitry Andric}
3110b57cec5SDimitry Andric
3120b57cec5SDimitry Andricdef sve_fpimm_half_one
3130b57cec5SDimitry Andric    : SVEExactFPImmOperand<"HalfOne", "AArch64ExactFPImm::half",
3140b57cec5SDimitry Andric                           "AArch64ExactFPImm::one">;
3150b57cec5SDimitry Andricdef sve_fpimm_half_two
3160b57cec5SDimitry Andric    : SVEExactFPImmOperand<"HalfTwo", "AArch64ExactFPImm::half",
3170b57cec5SDimitry Andric                           "AArch64ExactFPImm::two">;
3180b57cec5SDimitry Andricdef sve_fpimm_zero_one
3190b57cec5SDimitry Andric    : SVEExactFPImmOperand<"ZeroOne", "AArch64ExactFPImm::zero",
3200b57cec5SDimitry Andric                           "AArch64ExactFPImm::one">;
3210b57cec5SDimitry Andric
322480093f4SDimitry Andricdef sve_incdec_imm : Operand<i32>, TImmLeaf<i32, [{
3230b57cec5SDimitry Andric  return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17);
3240b57cec5SDimitry Andric}]> {
3250b57cec5SDimitry Andric  let ParserMatchClass = Imm1_16Operand;
3260b57cec5SDimitry Andric  let EncoderMethod = "getSVEIncDecImm";
3270b57cec5SDimitry Andric  let DecoderMethod = "DecodeSVEIncDecImm";
3280b57cec5SDimitry Andric}
3290b57cec5SDimitry Andric
330480093f4SDimitry Andric// This allows i32 immediate extraction from i64 based arithmetic.
3310eae32dcSDimitry Andricdef sve_cnt_mul_imm_i32 : ComplexPattern<i32, 1, "SelectCntImm<1, 16, 1, false>">;
3320eae32dcSDimitry Andricdef sve_cnt_mul_imm_i64 : ComplexPattern<i64, 1, "SelectCntImm<1, 16, 1, false>">;
3330eae32dcSDimitry Andricdef sve_cnt_shl_imm     : ComplexPattern<i64, 1, "SelectCntImm<1, 16, 1, true>">;
334480093f4SDimitry Andric
3350eae32dcSDimitry Andricdef sve_ext_imm_0_31  : ComplexPattern<i64, 1, "SelectEXTImm<31, 8>">;
3360eae32dcSDimitry Andricdef sve_ext_imm_0_63  : ComplexPattern<i64, 1, "SelectEXTImm<63, 4>">;
3370eae32dcSDimitry Andricdef sve_ext_imm_0_127 : ComplexPattern<i64, 1, "SelectEXTImm<127, 2>">;
3380eae32dcSDimitry Andricdef sve_ext_imm_0_255 : ComplexPattern<i64, 1, "SelectEXTImm<255, 1>">;
339fe6060f1SDimitry Andric
340fe6060f1SDimitry Andricdef int_aarch64_sve_cntp_oneuse : PatFrag<(ops node:$pred, node:$src2),
341fe6060f1SDimitry Andric                                          (int_aarch64_sve_cntp node:$pred, node:$src2), [{
342fe6060f1SDimitry Andric  return N->hasOneUse();
343fe6060f1SDimitry Andric}]>;
344fe6060f1SDimitry Andric
345349cc55cSDimitry Andricdef step_vector_oneuse : PatFrag<(ops node:$idx),
346349cc55cSDimitry Andric                                 (step_vector node:$idx), [{
347349cc55cSDimitry Andric  return N->hasOneUse();
348349cc55cSDimitry Andric}]>;
349349cc55cSDimitry Andric
350349cc55cSDimitry Andric
3510b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
3520b57cec5SDimitry Andric// SVE PTrue - These are used extensively throughout the pattern matching so
3530b57cec5SDimitry Andric//             it's important we define them first.
3540b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
3550b57cec5SDimitry Andric
356480093f4SDimitry Andricclass sve_int_ptrue<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty,
357480093f4SDimitry Andric                    ValueType vt, SDPatternOperator op>
3580b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins sve_pred_enum:$pattern),
3590b57cec5SDimitry Andric  asm, "\t$Pd, $pattern",
3600b57cec5SDimitry Andric  "",
361480093f4SDimitry Andric  [(set (vt pprty:$Pd), (op sve_pred_enum:$pattern))]>, Sched<[]> {
3620b57cec5SDimitry Andric  bits<4> Pd;
3630b57cec5SDimitry Andric  bits<5> pattern;
3640b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
3650b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
3660b57cec5SDimitry Andric  let Inst{21-19} = 0b011;
3670b57cec5SDimitry Andric  let Inst{18-17} = opc{2-1};
3680b57cec5SDimitry Andric  let Inst{16}    = opc{0};
3690b57cec5SDimitry Andric  let Inst{15-10} = 0b111000;
3700b57cec5SDimitry Andric  let Inst{9-5}   = pattern;
3710b57cec5SDimitry Andric  let Inst{4}     = 0b0;
3720b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
3730b57cec5SDimitry Andric
3740b57cec5SDimitry Andric  let Defs = !if(!eq (opc{0}, 1), [NZCV], []);
375e8d8bef9SDimitry Andric  let ElementSize = pprty.ElementSize;
37606c3fb27SDimitry Andric  let hasSideEffects = 0;
377e8d8bef9SDimitry Andric  let isReMaterializable = 1;
378*0fca6ea1SDimitry Andric  let Uses = [VG];
3790b57cec5SDimitry Andric}
3800b57cec5SDimitry Andric
381480093f4SDimitry Andricmulticlass sve_int_ptrue<bits<3> opc, string asm, SDPatternOperator op> {
382480093f4SDimitry Andric  def _B : sve_int_ptrue<0b00, opc, asm, PPR8, nxv16i1, op>;
383480093f4SDimitry Andric  def _H : sve_int_ptrue<0b01, opc, asm, PPR16, nxv8i1, op>;
384480093f4SDimitry Andric  def _S : sve_int_ptrue<0b10, opc, asm, PPR32, nxv4i1, op>;
385480093f4SDimitry Andric  def _D : sve_int_ptrue<0b11, opc, asm, PPR64, nxv2i1, op>;
3860b57cec5SDimitry Andric
3870b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Pd",
3880b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _B) PPR8:$Pd, 0b11111), 1>;
3890b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Pd",
3900b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) PPR16:$Pd, 0b11111), 1>;
3910b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Pd",
3920b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) PPR32:$Pd, 0b11111), 1>;
3930b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Pd",
3940b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) PPR64:$Pd, 0b11111), 1>;
3950b57cec5SDimitry Andric}
3960b57cec5SDimitry Andric
397480093f4SDimitry Andricdef SDT_AArch64PTrue : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
398480093f4SDimitry Andricdef AArch64ptrue : SDNode<"AArch64ISD::PTRUE", SDT_AArch64PTrue>;
399480093f4SDimitry Andric
40081ad6265SDimitry Andriclet Predicates = [HasSVEorSME] in {
401480093f4SDimitry Andric  defm PTRUE  : sve_int_ptrue<0b000, "ptrue", AArch64ptrue>;
402480093f4SDimitry Andric  defm PTRUES : sve_int_ptrue<0b001, "ptrues", null_frag>;
40381ad6265SDimitry Andric
40481ad6265SDimitry Andric  def : Pat<(nxv16i1 immAllOnesV), (PTRUE_B 31)>;
40581ad6265SDimitry Andric  def : Pat<(nxv8i1 immAllOnesV), (PTRUE_H 31)>;
40681ad6265SDimitry Andric  def : Pat<(nxv4i1 immAllOnesV), (PTRUE_S 31)>;
40781ad6265SDimitry Andric  def : Pat<(nxv2i1 immAllOnesV), (PTRUE_D 31)>;
4080b57cec5SDimitry Andric}
4090b57cec5SDimitry Andric
4108bcb0991SDimitry Andric//===----------------------------------------------------------------------===//
4118bcb0991SDimitry Andric// SVE pattern match helpers.
4128bcb0991SDimitry Andric//===----------------------------------------------------------------------===//
4138bcb0991SDimitry Andric
4148bcb0991SDimitry Andricclass SVE_1_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
4158bcb0991SDimitry Andric                   Instruction inst>
4168bcb0991SDimitry Andric: Pat<(vtd (op vt1:$Op1)),
4178bcb0991SDimitry Andric      (inst $Op1)>;
4188bcb0991SDimitry Andric
419e8d8bef9SDimitry Andricclass SVE_1_Op_Passthru_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
420e8d8bef9SDimitry Andric                            ValueType vts, Instruction inst>
421e8d8bef9SDimitry Andric: Pat<(vtd (op pg:$Op1, vts:$Op2, vtd:$Op3)),
422e8d8bef9SDimitry Andric      (inst $Op3, $Op1, $Op2)>;
423e8d8bef9SDimitry Andric
424fe6060f1SDimitry Andric
425fe6060f1SDimitry Andricmulticlass SVE_1_Op_PassthruUndef_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
426fe6060f1SDimitry Andric                                 ValueType vts, Instruction inst> {
427fe6060f1SDimitry Andric  def : Pat<(vtd (op pg:$Op1, vts:$Op2, (vtd undef))),
428fe6060f1SDimitry Andric            (inst (IMPLICIT_DEF), $Op1, $Op2)>;
429fe6060f1SDimitry Andric  def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, vtd:$Op3)),
430fe6060f1SDimitry Andric            (inst $Op3, $Op1, $Op2)>;
431fe6060f1SDimitry Andric}
432fe6060f1SDimitry Andric
433e8d8bef9SDimitry Andric// Used to match FP_ROUND_MERGE_PASSTHRU, which has an additional flag for the
434e8d8bef9SDimitry Andric// type of rounding. This is matched by timm0_1 in pattern below and ignored.
435e8d8bef9SDimitry Andricclass SVE_1_Op_Passthru_Round_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
436e8d8bef9SDimitry Andric                                  ValueType vts, Instruction inst>
437e8d8bef9SDimitry Andric: Pat<(vtd (op pg:$Op1, vts:$Op2, (i64 timm0_1), vtd:$Op3)),
438e8d8bef9SDimitry Andric      (inst $Op3, $Op1, $Op2)>;
439e8d8bef9SDimitry Andric
440d56accc7SDimitry Andricmulticlass SVE_1_Op_PassthruUndef_Round_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
441d56accc7SDimitry Andric                                  ValueType vts, Instruction inst>{
442d56accc7SDimitry Andric  def : Pat<(vtd (op pg:$Op1, vts:$Op2, (i64 timm0_1), (vtd undef))),
443d56accc7SDimitry Andric            (inst (IMPLICIT_DEF), $Op1, $Op2)>;
444d56accc7SDimitry Andric  def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, (i64 timm0_1), vtd:$Op3)),
445d56accc7SDimitry Andric            (inst $Op3, $Op1, $Op2)>;
446d56accc7SDimitry Andric}
447d56accc7SDimitry Andric
44806c3fb27SDimitry Andricdef SVEDup0 : ComplexPattern<vAny, 0, "SelectDupZero", []>;
44906c3fb27SDimitry Andricdef SVEDupNeg0 : ComplexPattern<vAny, 0, "SelectDupNegativeZero", []>;
45006c3fb27SDimitry Andric
45106c3fb27SDimitry Andricclass SVE_1_Op_PassthruZero_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
45206c3fb27SDimitry Andric                   ValueType vt2, Instruction inst>
45306c3fb27SDimitry Andric   : Pat<(vtd (op (vtd (SVEDup0)), vt1:$Op1, vt2:$Op2)),
45406c3fb27SDimitry Andric        (inst (IMPLICIT_DEF), $Op1, $Op2)>;
45506c3fb27SDimitry Andric
456480093f4SDimitry Andricclass SVE_1_Op_Imm_OptLsl_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty,
457480093f4SDimitry Andric                              ValueType it, ComplexPattern cpx, Instruction inst>
45881ad6265SDimitry Andric  : Pat<(vt (op (vt zprty:$Op1), (vt (splat_vector (it (cpx i32:$imm, i32:$shift)))))),
459480093f4SDimitry Andric        (inst $Op1, i32:$imm, i32:$shift)>;
460480093f4SDimitry Andric
46106c3fb27SDimitry Andricclass SVE_1_Op_Imm_Arith_Any_Predicate<ValueType vt, ValueType pt,
46206c3fb27SDimitry Andric                                       SDPatternOperator op, ZPRRegOp zprty,
46306c3fb27SDimitry Andric                                       ValueType it, ComplexPattern cpx,
46406c3fb27SDimitry Andric                                       Instruction inst>
46506c3fb27SDimitry Andric  : Pat<(vt (op (pt (SVEAnyPredicate)), (vt zprty:$Op1), (vt (splat_vector (it (cpx i32:$imm)))))),
4665ffd83dbSDimitry Andric        (inst $Op1, i32:$imm)>;
4675ffd83dbSDimitry Andric
468480093f4SDimitry Andricclass SVE_1_Op_Imm_Log_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty,
469480093f4SDimitry Andric                           ValueType it, ComplexPattern cpx, Instruction inst>
47081ad6265SDimitry Andric  : Pat<(vt (op (vt zprty:$Op1), (vt (splat_vector (it (cpx i64:$imm)))))),
471480093f4SDimitry Andric        (inst $Op1, i64:$imm)>;
472480093f4SDimitry Andric
473480093f4SDimitry Andricclass SVE_2_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
474480093f4SDimitry Andric                   ValueType vt2, Instruction inst>
475480093f4SDimitry Andric: Pat<(vtd (op vt1:$Op1, vt2:$Op2)),
476480093f4SDimitry Andric      (inst $Op1, $Op2)>;
477480093f4SDimitry Andric
478e8d8bef9SDimitry Andricclass SVE_2_Op_Pred_All_Active<ValueType vtd, SDPatternOperator op,
479e8d8bef9SDimitry Andric                               ValueType pt, ValueType vt1, ValueType vt2,
480e8d8bef9SDimitry Andric                               Instruction inst>
481fe6060f1SDimitry Andric: Pat<(vtd (op (pt (SVEAllActive)), vt1:$Op1, vt2:$Op2)),
482e8d8bef9SDimitry Andric      (inst $Op1, $Op2)>;
483480093f4SDimitry Andric
484fe6060f1SDimitry Andricclass SVE_2_Op_Pred_All_Active_Pt<ValueType vtd, SDPatternOperator op,
485fe6060f1SDimitry Andric                                  ValueType pt, ValueType vt1, ValueType vt2,
486fe6060f1SDimitry Andric                                  Instruction inst>
487fe6060f1SDimitry Andric: Pat<(vtd (op (pt (SVEAllActive:$Op1)), vt1:$Op2, vt2:$Op3)),
488fe6060f1SDimitry Andric      (inst $Op1, $Op2, $Op3)>;
489fe6060f1SDimitry Andric
4908bcb0991SDimitry Andricclass SVE_3_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
4918bcb0991SDimitry Andric                   ValueType vt2, ValueType vt3, Instruction inst>
4928bcb0991SDimitry Andric: Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3)),
4938bcb0991SDimitry Andric      (inst $Op1, $Op2, $Op3)>;
4940b57cec5SDimitry Andric
495fe6060f1SDimitry Andricmulticlass SVE_3_Op_Undef_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
496fe6060f1SDimitry Andric                              ValueType vt2, ValueType vt3, Instruction inst> {
497fe6060f1SDimitry Andric  def : Pat<(vtd (op (vt1 undef), vt2:$Op1, vt3:$Op2)),
498fe6060f1SDimitry Andric            (inst (IMPLICIT_DEF), $Op1, $Op2)>;
499fe6060f1SDimitry Andric  def : Pat<(vtd (op vt1:$Op1, (vt2 (SVEAllActive:$Op2)), vt3:$Op3)),
500fe6060f1SDimitry Andric            (inst $Op1, $Op2, $Op3)>;
501fe6060f1SDimitry Andric}
502fe6060f1SDimitry Andric
503480093f4SDimitry Andricclass SVE_4_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
504480093f4SDimitry Andric                   ValueType vt2, ValueType vt3, ValueType vt4,
505480093f4SDimitry Andric                   Instruction inst>
506480093f4SDimitry Andric: Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3, vt4:$Op4)),
507480093f4SDimitry Andric      (inst $Op1, $Op2, $Op3, $Op4)>;
508480093f4SDimitry Andric
509480093f4SDimitry Andricclass SVE_2_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
510480093f4SDimitry Andric                       ValueType vt2, Operand ImmTy, Instruction inst>
511480093f4SDimitry Andric: Pat<(vtd (op vt1:$Op1, (vt2 ImmTy:$Op2))),
512480093f4SDimitry Andric      (inst $Op1, ImmTy:$Op2)>;
513480093f4SDimitry Andric
51406c3fb27SDimitry Andricmulticlass SVE2p1_Cntp_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
51506c3fb27SDimitry Andric                           Instruction inst> {
51606c3fb27SDimitry Andric  def : Pat<(vtd (op vt1:$Op1, (i32 2))), (inst $Op1, 0)>;
51706c3fb27SDimitry Andric  def : Pat<(vtd (op vt1:$Op1, (i32 4))), (inst $Op1, 1)>;
51806c3fb27SDimitry Andric}
51906c3fb27SDimitry Andric
52006c3fb27SDimitry Andricmulticlass SVE2p1_While_PN_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
52106c3fb27SDimitry Andric                               Instruction inst> {
52206c3fb27SDimitry Andric  def : Pat<(vtd (op vt1:$Op1, vt1:$Op2, (i32 2))), (inst $Op1, $Op2, 0)>;
52306c3fb27SDimitry Andric  def : Pat<(vtd (op vt1:$Op1, vt1:$Op2, (i32 4))), (inst $Op1, $Op2, 1)>;
52406c3fb27SDimitry Andric}
52506c3fb27SDimitry Andric
526480093f4SDimitry Andricclass SVE_3_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
527480093f4SDimitry Andric                       ValueType vt2, ValueType vt3, Operand ImmTy,
528480093f4SDimitry Andric                       Instruction inst>
529480093f4SDimitry Andric: Pat<(vtd (op vt1:$Op1, vt2:$Op2, (vt3 ImmTy:$Op3))),
530480093f4SDimitry Andric      (inst $Op1, $Op2, ImmTy:$Op3)>;
531480093f4SDimitry Andric
532480093f4SDimitry Andricclass SVE_4_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
533480093f4SDimitry Andric                       ValueType vt2, ValueType vt3, ValueType vt4,
534480093f4SDimitry Andric                       Operand ImmTy, Instruction inst>
535480093f4SDimitry Andric: Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3, (vt4 ImmTy:$Op4))),
536480093f4SDimitry Andric      (inst $Op1, $Op2, $Op3, ImmTy:$Op4)>;
537480093f4SDimitry Andric
5380eae32dcSDimitry Andricdef SVEDup0Undef : ComplexPattern<vAny, 0, "SelectDupZeroOrUndef", []>;
539480093f4SDimitry Andric
5405ffd83dbSDimitry Andriclet AddedComplexity = 1 in {
5415ffd83dbSDimitry Andricclass SVE_3_Op_Pat_SelZero<ValueType vtd, SDPatternOperator op, ValueType vt1,
5425ffd83dbSDimitry Andric                   ValueType vt2, ValueType vt3, Instruction inst>
5435ffd83dbSDimitry Andric: Pat<(vtd (vtd (op vt1:$Op1, (vselect vt1:$Op1, vt2:$Op2, (SVEDup0)), vt3:$Op3))),
5445ffd83dbSDimitry Andric      (inst $Op1, $Op2, $Op3)>;
5455ffd83dbSDimitry Andric
5465ffd83dbSDimitry Andricclass SVE_3_Op_Pat_Shift_Imm_SelZero<ValueType vtd, SDPatternOperator op,
5475ffd83dbSDimitry Andric                                     ValueType vt1, ValueType vt2,
5485ffd83dbSDimitry Andric                                     Operand vt3, Instruction inst>
5495ffd83dbSDimitry Andric: Pat<(vtd (op vt1:$Op1, (vselect vt1:$Op1, vt2:$Op2, (SVEDup0)), (i32 (vt3:$Op3)))),
5505ffd83dbSDimitry Andric      (inst $Op1, $Op2, vt3:$Op3)>;
5515ffd83dbSDimitry Andric}
5525ffd83dbSDimitry Andric
553480093f4SDimitry Andric//
554480093f4SDimitry Andric// Common but less generic patterns.
555480093f4SDimitry Andric//
556480093f4SDimitry Andric
5575ffd83dbSDimitry Andricclass SVE_2_Op_AllActive_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
5585ffd83dbSDimitry Andric                             ValueType vt2, Instruction inst, Instruction ptrue>
5595ffd83dbSDimitry Andric: Pat<(vtd (op vt1:$Op1, vt2:$Op2)),
5605ffd83dbSDimitry Andric      (inst (ptrue 31), $Op1, $Op2)>;
5615ffd83dbSDimitry Andric
562e8d8bef9SDimitry Andricclass SVE_InReg_Extend<ValueType vt, SDPatternOperator op, ValueType pt,
563e8d8bef9SDimitry Andric                       ValueType inreg_vt, Instruction inst>
564e8d8bef9SDimitry Andric: Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, vt:$PassThru)),
565e8d8bef9SDimitry Andric      (inst $PassThru, $Pg, $Src)>;
566e8d8bef9SDimitry Andric
567fe6060f1SDimitry Andricmulticlass SVE_InReg_Extend_PassthruUndef<ValueType vt, SDPatternOperator op, ValueType pt,
568fe6060f1SDimitry Andric                                          ValueType inreg_vt, Instruction inst> {
569fe6060f1SDimitry Andric  def : Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, (vt undef))),
570fe6060f1SDimitry Andric            (inst (IMPLICIT_DEF), $Pg, $Src)>;
571fe6060f1SDimitry Andric  def : Pat<(vt (op (pt (SVEAllActive:$Pg)), vt:$Src, inreg_vt, vt:$PassThru)),
572fe6060f1SDimitry Andric            (inst $PassThru, $Pg, $Src)>;
573fe6060f1SDimitry Andric}
574fe6060f1SDimitry Andric
575e8d8bef9SDimitry Andricclass SVE_Shift_DupImm_Pred_Pat<ValueType vt, SDPatternOperator op,
576e8d8bef9SDimitry Andric                                ValueType pt, ValueType it,
577e8d8bef9SDimitry Andric                                ComplexPattern cast, Instruction inst>
57881ad6265SDimitry Andric: Pat<(vt (op pt:$Pg, vt:$Rn, (vt (splat_vector (it (cast i32:$imm)))))),
579e8d8bef9SDimitry Andric      (inst $Pg, $Rn, i32:$imm)>;
580e8d8bef9SDimitry Andric
58106c3fb27SDimitry Andricclass SVE_Shift_DupImm_Any_Predicate_Pat<ValueType vt, SDPatternOperator op,
582e8d8bef9SDimitry Andric                                         ValueType pt, ValueType it,
583e8d8bef9SDimitry Andric                                         ComplexPattern cast, Instruction inst>
58406c3fb27SDimitry Andric: Pat<(vt (op (pt (SVEAnyPredicate)), vt:$Rn, (vt (splat_vector (it (cast i32:$imm)))))),
585e8d8bef9SDimitry Andric      (inst $Rn, i32:$imm)>;
586e8d8bef9SDimitry Andric
58706c3fb27SDimitry Andricclass SVE_2_Op_Imm_Pat_Zero<ValueType vt, SDPatternOperator op, ValueType pt,
58806c3fb27SDimitry Andric                            ValueType it, ComplexPattern cpx, Instruction inst>
58906c3fb27SDimitry Andric: Pat<(vt (op pt:$Pg, (vselect pt:$Pg, vt:$Op1, (SVEDup0)),
59006c3fb27SDimitry Andric                      (vt (splat_vector (it (cpx i32:$imm)))))),
59106c3fb27SDimitry Andric      (inst $Pg, $Op1, i32:$imm)>;
59206c3fb27SDimitry Andric
593349cc55cSDimitry Andricclass SVE_2_Op_Fp_Imm_Pat<ValueType vt, SDPatternOperator op,
594349cc55cSDimitry Andric                          ValueType pt, ValueType it,
595349cc55cSDimitry Andric                          FPImmLeaf immL, int imm,
596349cc55cSDimitry Andric                          Instruction inst>
59781ad6265SDimitry Andric: Pat<(vt (op (pt PPR_3b:$Pg), (vt ZPR:$Zs1), (vt (splat_vector (it immL))))),
598349cc55cSDimitry Andric      (inst $Pg, $Zs1, imm)>;
599349cc55cSDimitry Andric
600349cc55cSDimitry Andricclass SVE_2_Op_Fp_Imm_Pat_Zero<ValueType vt, SDPatternOperator op,
601349cc55cSDimitry Andric                              ValueType pt, ValueType it,
602349cc55cSDimitry Andric                              FPImmLeaf immL, int imm,
603349cc55cSDimitry Andric                              Instruction inst>
604349cc55cSDimitry Andric: Pat<(vt (op pt:$Pg, (vselect pt:$Pg, vt:$Zs1, (SVEDup0)),
60581ad6265SDimitry Andric                      (vt (splat_vector (it immL))))),
606349cc55cSDimitry Andric      (inst $Pg, $Zs1, imm)>;
607349cc55cSDimitry Andric
60881ad6265SDimitry Andricclass SVE_Shift_Add_All_Active_Pat<ValueType vtd, SDPatternOperator op, ValueType pt,
60981ad6265SDimitry Andric                                   ValueType vt1, ValueType vt2, ValueType vt3,
61081ad6265SDimitry Andric                                   Instruction inst>
61181ad6265SDimitry Andric: Pat<(vtd (add vt1:$Op1, (op (pt (SVEAllActive)), vt2:$Op2, vt3:$Op3))),
61281ad6265SDimitry Andric      (inst $Op1, $Op2, $Op3)>;
61381ad6265SDimitry Andric
61406c3fb27SDimitry Andricclass SVE2p1_Sat_Shift_VG2_Pat<string name, SDPatternOperator intrinsic, ValueType out_vt, ValueType in_vt, Operand imm_ty>
61506c3fb27SDimitry Andric    : Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2, (i32 imm_ty:$i))),
61606c3fb27SDimitry Andric                  (!cast<Instruction>(name) (REG_SEQUENCE ZPR2Mul2, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1), imm_ty:$i)>;
61706c3fb27SDimitry Andric
618bdd1243dSDimitry Andricclass SVE2p1_Cvt_VG2_Pat<string name, SDPatternOperator intrinsic, ValueType out_vt, ValueType in_vt>
619bdd1243dSDimitry Andric    : Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2)),
620bdd1243dSDimitry Andric                  (!cast<Instruction>(name) (REG_SEQUENCE ZPR2Mul2, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1))>;
621bdd1243dSDimitry Andric
62281ad6265SDimitry Andric//===----------------------------------------------------------------------===//
62381ad6265SDimitry Andric// SVE pattern match helpers.
62481ad6265SDimitry Andric//===----------------------------------------------------------------------===//
62581ad6265SDimitry Andric
62681ad6265SDimitry Andric// Matches either an intrinsic, or a predicated operation with an all active predicate
62706c3fb27SDimitry Andricclass VSelectPredOrPassthruPatFrags<SDPatternOperator intrinsic, SDPatternOperator sdnode>
62881ad6265SDimitry Andric: PatFrags<(ops node:$Pg, node:$Op1, node:$Op2), [
62981ad6265SDimitry Andric    (intrinsic node:$Pg, node:$Op1, node:$Op2),
63081ad6265SDimitry Andric    (vselect node:$Pg, (sdnode (SVEAllActive), node:$Op1, node:$Op2), node:$Op1),
63106c3fb27SDimitry Andric  ], [{
63206c3fb27SDimitry Andric    return N->getOpcode() != ISD::VSELECT || N->getOperand(1).hasOneUse();
63306c3fb27SDimitry Andric  }]>;
63406c3fb27SDimitry Andric// Same as above with a commutative operation
63506c3fb27SDimitry Andricclass VSelectCommPredOrPassthruPatFrags<SDPatternOperator intrinsic, SDPatternOperator sdnode>
63606c3fb27SDimitry Andric: PatFrags<(ops node:$Pg, node:$Op1, node:$Op2), [
63706c3fb27SDimitry Andric    (intrinsic node:$Pg, node:$Op1, node:$Op2),
63806c3fb27SDimitry Andric    (vselect node:$Pg, (sdnode (SVEAllActive), node:$Op1, node:$Op2), node:$Op1),
63906c3fb27SDimitry Andric    (vselect node:$Pg, (sdnode (SVEAllActive), node:$Op2, node:$Op1), node:$Op1),
64006c3fb27SDimitry Andric  ], [{
64106c3fb27SDimitry Andric    return N->getOpcode() != ISD::VSELECT || N->getOperand(1).hasOneUse();
64206c3fb27SDimitry Andric  }]>;
64306c3fb27SDimitry Andric// Similarly matches either an intrinsic, or an unpredicated operation with a select
64406c3fb27SDimitry Andricclass VSelectUnpredOrPassthruPatFrags<SDPatternOperator intrinsic, SDPatternOperator sdnode>
64506c3fb27SDimitry Andric: PatFrags<(ops node:$Pg, node:$Op1, node:$Op2), [
64606c3fb27SDimitry Andric    (intrinsic node:$Pg, node:$Op1, node:$Op2),
64706c3fb27SDimitry Andric    (vselect node:$Pg, (sdnode node:$Op1, node:$Op2), node:$Op1),
64806c3fb27SDimitry Andric  ], [{
64906c3fb27SDimitry Andric    return N->getOpcode() != ISD::VSELECT || N->getOperand(1).hasOneUse();
65006c3fb27SDimitry Andric  }]>;
65181ad6265SDimitry Andric
6525ffd83dbSDimitry Andric//
6535ffd83dbSDimitry Andric// Pseudo -> Instruction mappings
6545ffd83dbSDimitry Andric//
6555ffd83dbSDimitry Andricdef getSVEPseudoMap : InstrMapping {
6565ffd83dbSDimitry Andric  let FilterClass = "SVEPseudo2Instr";
6575ffd83dbSDimitry Andric  let RowFields = ["PseudoName"];
6585ffd83dbSDimitry Andric  let ColFields = ["IsInstr"];
6595ffd83dbSDimitry Andric  let KeyCol = ["0"];
6605ffd83dbSDimitry Andric  let ValueCols = [["1"]];
6615ffd83dbSDimitry Andric}
6625ffd83dbSDimitry Andric
6635ffd83dbSDimitry Andricclass SVEPseudo2Instr<string name, bit instr> {
6645ffd83dbSDimitry Andric  string PseudoName = name;
6655ffd83dbSDimitry Andric  bit IsInstr = instr;
6665ffd83dbSDimitry Andric}
6675ffd83dbSDimitry Andric
6685ffd83dbSDimitry Andric// Lookup e.g. DIV -> DIVR
6695ffd83dbSDimitry Andricdef getSVERevInstr : InstrMapping {
6705ffd83dbSDimitry Andric  let FilterClass = "SVEInstr2Rev";
6715ffd83dbSDimitry Andric  let RowFields = ["InstrName"];
6725ffd83dbSDimitry Andric  let ColFields = ["isReverseInstr"];
6735ffd83dbSDimitry Andric  let KeyCol = ["0"];
6745ffd83dbSDimitry Andric  let ValueCols = [["1"]];
6755ffd83dbSDimitry Andric}
6765ffd83dbSDimitry Andric
6775ffd83dbSDimitry Andric// Lookup e.g. DIVR -> DIV
6785ffd83dbSDimitry Andricdef getSVENonRevInstr : InstrMapping {
6795ffd83dbSDimitry Andric  let FilterClass = "SVEInstr2Rev";
6805ffd83dbSDimitry Andric  let RowFields = ["InstrName"];
6815ffd83dbSDimitry Andric  let ColFields = ["isReverseInstr"];
6825ffd83dbSDimitry Andric  let KeyCol = ["1"];
6835ffd83dbSDimitry Andric  let ValueCols = [["0"]];
6845ffd83dbSDimitry Andric}
6855ffd83dbSDimitry Andric
6865ffd83dbSDimitry Andricclass SVEInstr2Rev<string name1, string name2, bit name1IsReverseInstr> {
6875ffd83dbSDimitry Andric  string InstrName = !if(name1IsReverseInstr, name1, name2);
6885ffd83dbSDimitry Andric  bit isReverseInstr = name1IsReverseInstr;
6895ffd83dbSDimitry Andric}
6905ffd83dbSDimitry Andric
6915ffd83dbSDimitry Andric//
6925ffd83dbSDimitry Andric// Pseudos for destructive operands
6935ffd83dbSDimitry Andric//
6945ffd83dbSDimitry Andriclet hasNoSchedulingInfo = 1 in {
6955ffd83dbSDimitry Andric  class PredTwoOpPseudo<string name, ZPRRegOp zprty,
6965ffd83dbSDimitry Andric                        FalseLanesEnum flags = FalseLanesNone>
6975ffd83dbSDimitry Andric  : SVEPseudo2Instr<name, 0>,
6985ffd83dbSDimitry Andric    Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, zprty:$Zs2), []> {
6995ffd83dbSDimitry Andric    let FalseLanes = flags;
7005ffd83dbSDimitry Andric  }
7015ffd83dbSDimitry Andric
7025ffd83dbSDimitry Andric  class PredTwoOpImmPseudo<string name, ZPRRegOp zprty, Operand immty,
7035ffd83dbSDimitry Andric                           FalseLanesEnum flags = FalseLanesNone>
7045ffd83dbSDimitry Andric  : SVEPseudo2Instr<name, 0>,
7055ffd83dbSDimitry Andric    Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, immty:$imm), []> {
7065ffd83dbSDimitry Andric    let FalseLanes = flags;
7075ffd83dbSDimitry Andric  }
708fe6060f1SDimitry Andric
709fe6060f1SDimitry Andric  class PredThreeOpPseudo<string name, ZPRRegOp zprty,
710fe6060f1SDimitry Andric                          FalseLanesEnum flags = FalseLanesNone>
711fe6060f1SDimitry Andric  : SVEPseudo2Instr<name, 0>,
712fe6060f1SDimitry Andric    Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, zprty:$Zs2, zprty:$Zs3), []> {
713fe6060f1SDimitry Andric    let FalseLanes = flags;
714fe6060f1SDimitry Andric  }
715fe6060f1SDimitry Andric}
716fe6060f1SDimitry Andric
717fe6060f1SDimitry Andric//
718fe6060f1SDimitry Andric// Pseudos for passthru operands
719fe6060f1SDimitry Andric//
720fe6060f1SDimitry Andriclet hasNoSchedulingInfo = 1 in {
72106c3fb27SDimitry Andric  class PredOneOpPassthruPseudo<string name, ZPRRegOp zprty,
72206c3fb27SDimitry Andric                                FalseLanesEnum flags = FalseLanesNone>
723fe6060f1SDimitry Andric  : SVEPseudo2Instr<name, 0>,
72406c3fb27SDimitry Andric    Pseudo<(outs zprty:$Zd), (ins zprty:$Passthru, PPR3bAny:$Pg, zprty:$Zs), []> {
72506c3fb27SDimitry Andric    let FalseLanes = flags;
72606c3fb27SDimitry Andric    let Constraints = !if(!eq(flags, FalseLanesZero), "$Zd = $Passthru,@earlyclobber $Zd", "");
72706c3fb27SDimitry Andric  }
7285ffd83dbSDimitry Andric}
7295ffd83dbSDimitry Andric
7300b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7310b57cec5SDimitry Andric// SVE Predicate Misc Group
7320b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7330b57cec5SDimitry Andric
7340b57cec5SDimitry Andricclass sve_int_pfalse<bits<6> opc, string asm>
735*0fca6ea1SDimitry Andric: I<(outs PPRorPNR8:$Pd), (ins),
7360b57cec5SDimitry Andric  asm, "\t$Pd",
7370b57cec5SDimitry Andric  "",
7380b57cec5SDimitry Andric  []>, Sched<[]> {
7390b57cec5SDimitry Andric  bits<4> Pd;
7400b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
7410b57cec5SDimitry Andric  let Inst{23-22} = opc{5-4};
7420b57cec5SDimitry Andric  let Inst{21-19} = 0b011;
7430b57cec5SDimitry Andric  let Inst{18-16} = opc{3-1};
7440b57cec5SDimitry Andric  let Inst{15-10} = 0b111001;
7450b57cec5SDimitry Andric  let Inst{9}     = opc{0};
7460b57cec5SDimitry Andric  let Inst{8-4}   = 0b00000;
7470b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
748e8d8bef9SDimitry Andric
74906c3fb27SDimitry Andric  let hasSideEffects = 0;
750e8d8bef9SDimitry Andric  let isReMaterializable = 1;
751*0fca6ea1SDimitry Andric  let Uses = [VG];
7520b57cec5SDimitry Andric}
7530b57cec5SDimitry Andric
75404eeddc0SDimitry Andricmulticlass sve_int_pfalse<bits<6> opc, string asm> {
75504eeddc0SDimitry Andric  def NAME : sve_int_pfalse<opc, asm>;
75604eeddc0SDimitry Andric
75781ad6265SDimitry Andric  def : Pat<(nxv16i1 immAllZerosV), (!cast<Instruction>(NAME))>;
75881ad6265SDimitry Andric  def : Pat<(nxv8i1 immAllZerosV), (!cast<Instruction>(NAME))>;
75981ad6265SDimitry Andric  def : Pat<(nxv4i1 immAllZerosV), (!cast<Instruction>(NAME))>;
76081ad6265SDimitry Andric  def : Pat<(nxv2i1 immAllZerosV), (!cast<Instruction>(NAME))>;
76181ad6265SDimitry Andric  def : Pat<(nxv1i1 immAllZerosV), (!cast<Instruction>(NAME))>;
76204eeddc0SDimitry Andric}
76304eeddc0SDimitry Andric
764753f127fSDimitry Andricclass sve_int_ptest<bits<6> opc, string asm, SDPatternOperator op>
7650b57cec5SDimitry Andric: I<(outs), (ins PPRAny:$Pg, PPR8:$Pn),
7660b57cec5SDimitry Andric  asm, "\t$Pg, $Pn",
7670b57cec5SDimitry Andric  "",
768753f127fSDimitry Andric  [(op (nxv16i1 PPRAny:$Pg), (nxv16i1 PPR8:$Pn))]>, Sched<[]> {
7690b57cec5SDimitry Andric  bits<4> Pg;
7700b57cec5SDimitry Andric  bits<4> Pn;
7710b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
7720b57cec5SDimitry Andric  let Inst{23-22} = opc{5-4};
7730b57cec5SDimitry Andric  let Inst{21-19} = 0b010;
7740b57cec5SDimitry Andric  let Inst{18-16} = opc{3-1};
7750b57cec5SDimitry Andric  let Inst{15-14} = 0b11;
7760b57cec5SDimitry Andric  let Inst{13-10} = Pg;
7770b57cec5SDimitry Andric  let Inst{9}     = opc{0};
7780b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
7790b57cec5SDimitry Andric  let Inst{4-0}   = 0b00000;
7800b57cec5SDimitry Andric
7810b57cec5SDimitry Andric  let Defs = [NZCV];
78206c3fb27SDimitry Andric  let hasSideEffects = 0;
783e8d8bef9SDimitry Andric  let isCompare = 1;
7840b57cec5SDimitry Andric}
7850b57cec5SDimitry Andric
786bdd1243dSDimitry Andricmulticlass sve_int_ptest<bits<6> opc, string asm, SDPatternOperator op,
787bdd1243dSDimitry Andric                         SDPatternOperator op_any> {
788bdd1243dSDimitry Andric  def NAME : sve_int_ptest<opc, asm, op>;
789bdd1243dSDimitry Andric
790bdd1243dSDimitry Andric  let hasNoSchedulingInfo = 1, isCompare = 1, Defs = [NZCV] in {
791bdd1243dSDimitry Andric  def _ANY : Pseudo<(outs), (ins PPRAny:$Pg, PPR8:$Pn),
792bdd1243dSDimitry Andric                    [(op_any (nxv16i1 PPRAny:$Pg), (nxv16i1 PPR8:$Pn))]>,
793bdd1243dSDimitry Andric             PseudoInstExpansion<(!cast<Instruction>(NAME) PPRAny:$Pg, PPR8:$Pn)>;
794bdd1243dSDimitry Andric  }
795bdd1243dSDimitry Andric}
796bdd1243dSDimitry Andric
7970b57cec5SDimitry Andricclass sve_int_pfirst_next<bits<2> sz8_64, bits<5> opc, string asm,
7980b57cec5SDimitry Andric                          PPRRegOp pprty>
7990b57cec5SDimitry Andric: I<(outs pprty:$Pdn), (ins PPRAny:$Pg, pprty:$_Pdn),
8000b57cec5SDimitry Andric  asm, "\t$Pdn, $Pg, $_Pdn",
8010b57cec5SDimitry Andric  "",
8020b57cec5SDimitry Andric  []>, Sched<[]> {
8030b57cec5SDimitry Andric  bits<4> Pdn;
8040b57cec5SDimitry Andric  bits<4> Pg;
8050b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
8060b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
8070b57cec5SDimitry Andric  let Inst{21-19} = 0b011;
8080b57cec5SDimitry Andric  let Inst{18-16} = opc{4-2};
8090b57cec5SDimitry Andric  let Inst{15-11} = 0b11000;
8100b57cec5SDimitry Andric  let Inst{10-9}  = opc{1-0};
8110b57cec5SDimitry Andric  let Inst{8-5}   = Pg;
8120b57cec5SDimitry Andric  let Inst{4}     = 0;
8130b57cec5SDimitry Andric  let Inst{3-0}   = Pdn;
8140b57cec5SDimitry Andric
8150b57cec5SDimitry Andric  let Constraints = "$Pdn = $_Pdn";
8160b57cec5SDimitry Andric  let Defs = [NZCV];
817349cc55cSDimitry Andric  let ElementSize = pprty.ElementSize;
81806c3fb27SDimitry Andric  let hasSideEffects = 0;
81906c3fb27SDimitry Andric  let isPTestLike = 1;
8200b57cec5SDimitry Andric}
8210b57cec5SDimitry Andric
822480093f4SDimitry Andricmulticlass sve_int_pfirst<bits<5> opc, string asm, SDPatternOperator op> {
823480093f4SDimitry Andric  def _B : sve_int_pfirst_next<0b01, opc, asm, PPR8>;
824480093f4SDimitry Andric
825480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
8260b57cec5SDimitry Andric}
8270b57cec5SDimitry Andric
828480093f4SDimitry Andricmulticlass sve_int_pnext<bits<5> opc, string asm, SDPatternOperator op> {
8290b57cec5SDimitry Andric  def _B : sve_int_pfirst_next<0b00, opc, asm, PPR8>;
8300b57cec5SDimitry Andric  def _H : sve_int_pfirst_next<0b01, opc, asm, PPR16>;
8310b57cec5SDimitry Andric  def _S : sve_int_pfirst_next<0b10, opc, asm, PPR32>;
8320b57cec5SDimitry Andric  def _D : sve_int_pfirst_next<0b11, opc, asm, PPR64>;
833480093f4SDimitry Andric
834480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
835480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>;
836480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>;
837480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>;
8380b57cec5SDimitry Andric}
8390b57cec5SDimitry Andric
8400b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8410b57cec5SDimitry Andric// SVE Predicate Count Group
8420b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8430b57cec5SDimitry Andric
8440b57cec5SDimitry Andricclass sve_int_count_r<bits<2> sz8_64, bits<5> opc, string asm,
8450b57cec5SDimitry Andric                      RegisterOperand dty, PPRRegOp pprty, RegisterOperand sty>
8460b57cec5SDimitry Andric: I<(outs dty:$Rdn), (ins pprty:$Pg, sty:$_Rdn),
8470b57cec5SDimitry Andric  asm, "\t$Rdn, $Pg",
8480b57cec5SDimitry Andric  "",
8490b57cec5SDimitry Andric  []>, Sched<[]> {
8500b57cec5SDimitry Andric  bits<5> Rdn;
8510b57cec5SDimitry Andric  bits<4> Pg;
8520b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
8530b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
8540b57cec5SDimitry Andric  let Inst{21-19} = 0b101;
8550b57cec5SDimitry Andric  let Inst{18-16} = opc{4-2};
8560b57cec5SDimitry Andric  let Inst{15-11} = 0b10001;
8570b57cec5SDimitry Andric  let Inst{10-9}  = opc{1-0};
8580b57cec5SDimitry Andric  let Inst{8-5}   = Pg;
8590b57cec5SDimitry Andric  let Inst{4-0}   = Rdn;
8600b57cec5SDimitry Andric
8610b57cec5SDimitry Andric  // Signed 32bit forms require their GPR operand printed.
8620b57cec5SDimitry Andric  let AsmString = !if(!eq(opc{4,2-0}, 0b0000),
8630b57cec5SDimitry Andric                      !strconcat(asm, "\t$Rdn, $Pg, $_Rdn"),
8640b57cec5SDimitry Andric                      !strconcat(asm, "\t$Rdn, $Pg"));
8650b57cec5SDimitry Andric  let Constraints = "$Rdn = $_Rdn";
86606c3fb27SDimitry Andric  let hasSideEffects = 0;
8670b57cec5SDimitry Andric}
8680b57cec5SDimitry Andric
869480093f4SDimitry Andricmulticlass sve_int_count_r_s32<bits<5> opc, string asm,
870480093f4SDimitry Andric                               SDPatternOperator op> {
8710b57cec5SDimitry Andric  def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64as32>;
8720b57cec5SDimitry Andric  def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64as32>;
8730b57cec5SDimitry Andric  def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64as32>;
8740b57cec5SDimitry Andric  def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64as32>;
875480093f4SDimitry Andric
876480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))),
877480093f4SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _B) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
878480093f4SDimitry Andric  def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))))),
879480093f4SDimitry Andric            (!cast<Instruction>(NAME # _B) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
880480093f4SDimitry Andric
881480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))),
882480093f4SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _H) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
883480093f4SDimitry Andric  def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))))),
884480093f4SDimitry Andric            (!cast<Instruction>(NAME # _H) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
885480093f4SDimitry Andric
886480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))),
887480093f4SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _S) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
888480093f4SDimitry Andric  def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))))),
889480093f4SDimitry Andric            (!cast<Instruction>(NAME # _S) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
890480093f4SDimitry Andric
891480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))),
892480093f4SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _D) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
893480093f4SDimitry Andric  def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))))),
894480093f4SDimitry Andric            (!cast<Instruction>(NAME # _D) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
8950b57cec5SDimitry Andric}
8960b57cec5SDimitry Andric
897480093f4SDimitry Andricmulticlass sve_int_count_r_u32<bits<5> opc, string asm,
898480093f4SDimitry Andric                               SDPatternOperator op> {
8990b57cec5SDimitry Andric  def _B : sve_int_count_r<0b00, opc, asm, GPR32z, PPR8, GPR32z>;
9000b57cec5SDimitry Andric  def _H : sve_int_count_r<0b01, opc, asm, GPR32z, PPR16, GPR32z>;
9010b57cec5SDimitry Andric  def _S : sve_int_count_r<0b10, opc, asm, GPR32z, PPR32, GPR32z>;
9020b57cec5SDimitry Andric  def _D : sve_int_count_r<0b11, opc, asm, GPR32z, PPR64, GPR32z>;
903480093f4SDimitry Andric
904480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))),
905480093f4SDimitry Andric            (!cast<Instruction>(NAME # _B) PPRAny:$Pg, $Rn)>;
906480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))),
907480093f4SDimitry Andric            (!cast<Instruction>(NAME # _H) PPRAny:$Pg, $Rn)>;
908480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))),
909480093f4SDimitry Andric            (!cast<Instruction>(NAME # _S) PPRAny:$Pg, $Rn)>;
910480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))),
911480093f4SDimitry Andric            (!cast<Instruction>(NAME # _D) PPRAny:$Pg, $Rn)>;
9120b57cec5SDimitry Andric}
9130b57cec5SDimitry Andric
914480093f4SDimitry Andricmulticlass sve_int_count_r_x64<bits<5> opc, string asm,
915fe6060f1SDimitry Andric                               SDPatternOperator op,
916fe6060f1SDimitry Andric                               SDPatternOperator combine_op = null_frag> {
9170b57cec5SDimitry Andric  def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64z>;
9180b57cec5SDimitry Andric  def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64z>;
9190b57cec5SDimitry Andric  def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64z>;
9200b57cec5SDimitry Andric  def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64z>;
921480093f4SDimitry Andric
922480093f4SDimitry Andric  def : Pat<(i64 (op GPR64:$Rn, (nxv16i1 PPRAny:$Pg))),
923480093f4SDimitry Andric            (!cast<Instruction>(NAME # _B) PPRAny:$Pg, $Rn)>;
924480093f4SDimitry Andric  def : Pat<(i64 (op GPR64:$Rn, (nxv8i1 PPRAny:$Pg))),
925480093f4SDimitry Andric            (!cast<Instruction>(NAME # _H) PPRAny:$Pg, $Rn)>;
926480093f4SDimitry Andric  def : Pat<(i64 (op GPR64:$Rn, (nxv4i1 PPRAny:$Pg))),
927480093f4SDimitry Andric            (!cast<Instruction>(NAME # _S) PPRAny:$Pg, $Rn)>;
928480093f4SDimitry Andric  def : Pat<(i64 (op GPR64:$Rn, (nxv2i1 PPRAny:$Pg))),
929480093f4SDimitry Andric            (!cast<Instruction>(NAME # _D) PPRAny:$Pg, $Rn)>;
930fe6060f1SDimitry Andric
9311fd87a68SDimitry Andric  // combine_op(x, cntp(all_active, p)) ==> inst p, x
932fe6060f1SDimitry Andric  def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv16i1 (SVEAllActive)), (nxv16i1 PPRAny:$pred)))),
933fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _B) PPRAny:$pred, $Rn)>;
934fe6060f1SDimitry Andric  def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv8i1 (SVEAllActive)), (nxv8i1 PPRAny:$pred)))),
935fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _H) PPRAny:$pred, $Rn)>;
936fe6060f1SDimitry Andric  def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv4i1 (SVEAllActive)), (nxv4i1 PPRAny:$pred)))),
937fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _S) PPRAny:$pred, $Rn)>;
938fe6060f1SDimitry Andric  def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv2i1 (SVEAllActive)), (nxv2i1 PPRAny:$pred)))),
939fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _D) PPRAny:$pred, $Rn)>;
9401fd87a68SDimitry Andric
9411fd87a68SDimitry Andric  // combine_op(x, cntp(p, p)) ==> inst p, x
9421fd87a68SDimitry Andric  def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv16i1 PPRAny:$pred), (nxv16i1 PPRAny:$pred)))),
9431fd87a68SDimitry Andric            (!cast<Instruction>(NAME # _B) PPRAny:$pred, $Rn)>;
9441fd87a68SDimitry Andric  def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv8i1 PPRAny:$pred), (nxv8i1 PPRAny:$pred)))),
9451fd87a68SDimitry Andric            (!cast<Instruction>(NAME # _H) PPRAny:$pred, $Rn)>;
9461fd87a68SDimitry Andric  def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv4i1 PPRAny:$pred), (nxv4i1 PPRAny:$pred)))),
9471fd87a68SDimitry Andric            (!cast<Instruction>(NAME # _S) PPRAny:$pred, $Rn)>;
9481fd87a68SDimitry Andric  def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv2i1 PPRAny:$pred), (nxv2i1 PPRAny:$pred)))),
9491fd87a68SDimitry Andric            (!cast<Instruction>(NAME # _D) PPRAny:$pred, $Rn)>;
95006c3fb27SDimitry Andric
95106c3fb27SDimitry Andric  // combine_op(x, trunc(cntp(all_active, p))) ==> inst p, x
95206c3fb27SDimitry Andric  def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv16i1 (SVEAllActive)), (nxv16i1 PPRAny:$pred))))),
953*0fca6ea1SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _B) PPRAny:$pred,
954*0fca6ea1SDimitry Andric                                     (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
955*0fca6ea1SDimitry Andric                                 sub_32)>;
95606c3fb27SDimitry Andric  def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv8i1 (SVEAllActive)), (nxv8i1 PPRAny:$pred))))),
957*0fca6ea1SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _H) PPRAny:$pred,
958*0fca6ea1SDimitry Andric                                     (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
959*0fca6ea1SDimitry Andric                                 sub_32)>;
96006c3fb27SDimitry Andric  def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv4i1 (SVEAllActive)), (nxv4i1 PPRAny:$pred))))),
961*0fca6ea1SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _S) PPRAny:$pred,
962*0fca6ea1SDimitry Andric                                     (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
963*0fca6ea1SDimitry Andric                                 sub_32)>;
96406c3fb27SDimitry Andric  def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv2i1 (SVEAllActive)), (nxv2i1 PPRAny:$pred))))),
965*0fca6ea1SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _D) PPRAny:$pred,
966*0fca6ea1SDimitry Andric                                     (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
967*0fca6ea1SDimitry Andric                                 sub_32)>;
96806c3fb27SDimitry Andric
96906c3fb27SDimitry Andric  // combine_op(x, trunc(cntp(p, p))) ==> inst p, x
97006c3fb27SDimitry Andric  def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv16i1 PPRAny:$pred), (nxv16i1 PPRAny:$pred))))),
971*0fca6ea1SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _B) PPRAny:$pred,
972*0fca6ea1SDimitry Andric                                     (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
973*0fca6ea1SDimitry Andric                                 sub_32)>;
97406c3fb27SDimitry Andric  def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv8i1 PPRAny:$pred), (nxv8i1 PPRAny:$pred))))),
975*0fca6ea1SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _H) PPRAny:$pred,
976*0fca6ea1SDimitry Andric                                     (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
977*0fca6ea1SDimitry Andric                                 sub_32)>;
97806c3fb27SDimitry Andric  def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv4i1 PPRAny:$pred), (nxv4i1 PPRAny:$pred))))),
979*0fca6ea1SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _S) PPRAny:$pred,
980*0fca6ea1SDimitry Andric                                     (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
981*0fca6ea1SDimitry Andric                                 sub_32)>;
98206c3fb27SDimitry Andric  def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv2i1 PPRAny:$pred), (nxv2i1 PPRAny:$pred))))),
983*0fca6ea1SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME # _D) PPRAny:$pred,
984*0fca6ea1SDimitry Andric                                     (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
985*0fca6ea1SDimitry Andric                                 sub_32)>;
9860b57cec5SDimitry Andric}
9870b57cec5SDimitry Andric
9880b57cec5SDimitry Andricclass sve_int_count_v<bits<2> sz8_64, bits<5> opc, string asm,
9890b57cec5SDimitry Andric                      ZPRRegOp zprty, PPRRegOp pprty>
9900b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, pprty:$Pm),
9910b57cec5SDimitry Andric  asm, "\t$Zdn, $Pm",
9920b57cec5SDimitry Andric  "",
9930b57cec5SDimitry Andric  []>, Sched<[]> {
9940b57cec5SDimitry Andric  bits<4> Pm;
9950b57cec5SDimitry Andric  bits<5> Zdn;
9960b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
9970b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
9980b57cec5SDimitry Andric  let Inst{21-19} = 0b101;
9990b57cec5SDimitry Andric  let Inst{18-16} = opc{4-2};
10000b57cec5SDimitry Andric  let Inst{15-11} = 0b10000;
10010b57cec5SDimitry Andric  let Inst{10-9}  = opc{1-0};
10020b57cec5SDimitry Andric  let Inst{8-5}   = Pm;
10030b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
10040b57cec5SDimitry Andric
10050b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
10065ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
10070b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
100806c3fb27SDimitry Andric  let hasSideEffects = 0;
10090b57cec5SDimitry Andric}
10100b57cec5SDimitry Andric
1011480093f4SDimitry Andricmulticlass sve_int_count_v<bits<5> opc, string asm,
1012480093f4SDimitry Andric                           SDPatternOperator op = null_frag> {
10130b57cec5SDimitry Andric  def _H : sve_int_count_v<0b01, opc, asm, ZPR16, PPR16>;
10140b57cec5SDimitry Andric  def _S : sve_int_count_v<0b10, opc, asm, ZPR32, PPR32>;
10150b57cec5SDimitry Andric  def _D : sve_int_count_v<0b11, opc, asm, ZPR64, PPR64>;
10160b57cec5SDimitry Andric
1017480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16,  nxv8i1, !cast<Instruction>(NAME # _H)>;
1018480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32,  nxv4i1, !cast<Instruction>(NAME # _S)>;
1019480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64,  nxv2i1, !cast<Instruction>(NAME # _D)>;
1020480093f4SDimitry Andric
10210b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Pm",
10220b57cec5SDimitry Andric                 (!cast<Instruction>(NAME # "_H") ZPR16:$Zdn, PPRAny:$Pm), 0>;
10230b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Pm",
10240b57cec5SDimitry Andric                 (!cast<Instruction>(NAME # "_S") ZPR32:$Zdn, PPRAny:$Pm), 0>;
10250b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Pm",
10260b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # "_D") ZPR64:$Zdn, PPRAny:$Pm), 0>;
10270b57cec5SDimitry Andric}
10280b57cec5SDimitry Andric
10290b57cec5SDimitry Andricclass sve_int_pcount_pred<bits<2> sz8_64, bits<4> opc, string asm,
10300b57cec5SDimitry Andric                          PPRRegOp pprty>
10310b57cec5SDimitry Andric: I<(outs GPR64:$Rd), (ins PPRAny:$Pg, pprty:$Pn),
10320b57cec5SDimitry Andric  asm, "\t$Rd, $Pg, $Pn",
10330b57cec5SDimitry Andric  "",
10340b57cec5SDimitry Andric  []>, Sched<[]> {
10350b57cec5SDimitry Andric  bits<4> Pg;
10360b57cec5SDimitry Andric  bits<4> Pn;
10370b57cec5SDimitry Andric  bits<5> Rd;
10380b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
10390b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
10400b57cec5SDimitry Andric  let Inst{21-19} = 0b100;
10410b57cec5SDimitry Andric  let Inst{18-16} = opc{3-1};
10420b57cec5SDimitry Andric  let Inst{15-14} = 0b10;
10430b57cec5SDimitry Andric  let Inst{13-10} = Pg;
10440b57cec5SDimitry Andric  let Inst{9}     = opc{0};
10450b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
10460b57cec5SDimitry Andric  let Inst{4-0}   = Rd;
104706c3fb27SDimitry Andric
104806c3fb27SDimitry Andric  let hasSideEffects = 0;
10490b57cec5SDimitry Andric}
10500b57cec5SDimitry Andric
1051480093f4SDimitry Andricmulticlass sve_int_pcount_pred<bits<4> opc, string asm,
1052480093f4SDimitry Andric                               SDPatternOperator int_op> {
10530b57cec5SDimitry Andric  def _B : sve_int_pcount_pred<0b00, opc, asm, PPR8>;
10540b57cec5SDimitry Andric  def _H : sve_int_pcount_pred<0b01, opc, asm, PPR16>;
10550b57cec5SDimitry Andric  def _S : sve_int_pcount_pred<0b10, opc, asm, PPR32>;
10560b57cec5SDimitry Andric  def _D : sve_int_pcount_pred<0b11, opc, asm, PPR64>;
1057480093f4SDimitry Andric
1058480093f4SDimitry Andric  def : SVE_2_Op_Pat<i64, int_op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
1059480093f4SDimitry Andric  def : SVE_2_Op_Pat<i64, int_op, nxv8i1,  nxv8i1,  !cast<Instruction>(NAME # _H)>;
1060480093f4SDimitry Andric  def : SVE_2_Op_Pat<i64, int_op, nxv4i1,  nxv4i1,  !cast<Instruction>(NAME # _S)>;
1061480093f4SDimitry Andric  def : SVE_2_Op_Pat<i64, int_op, nxv2i1,  nxv2i1,  !cast<Instruction>(NAME # _D)>;
10620b57cec5SDimitry Andric}
10630b57cec5SDimitry Andric
10640b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10650b57cec5SDimitry Andric// SVE Element Count Group
10660b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
10670b57cec5SDimitry Andric
10680b57cec5SDimitry Andricclass sve_int_count<bits<3> opc, string asm>
10690b57cec5SDimitry Andric: I<(outs GPR64:$Rd), (ins sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
10700b57cec5SDimitry Andric  asm, "\t$Rd, $pattern, mul $imm4",
10710b57cec5SDimitry Andric  "",
10720b57cec5SDimitry Andric  []>, Sched<[]> {
10730b57cec5SDimitry Andric  bits<5> Rd;
10740b57cec5SDimitry Andric  bits<4> imm4;
10750b57cec5SDimitry Andric  bits<5> pattern;
10760b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
10770b57cec5SDimitry Andric  let Inst{23-22} = opc{2-1};
10780b57cec5SDimitry Andric  let Inst{21-20} = 0b10;
10790b57cec5SDimitry Andric  let Inst{19-16} = imm4;
10800b57cec5SDimitry Andric  let Inst{15-11} = 0b11100;
10810b57cec5SDimitry Andric  let Inst{10}    = opc{0};
10820b57cec5SDimitry Andric  let Inst{9-5}   = pattern;
10830b57cec5SDimitry Andric  let Inst{4-0}   = Rd;
108481ad6265SDimitry Andric
108506c3fb27SDimitry Andric  let hasSideEffects = 0;
108681ad6265SDimitry Andric  let isReMaterializable = 1;
1087*0fca6ea1SDimitry Andric  let Uses = [VG];
10880b57cec5SDimitry Andric}
10890b57cec5SDimitry Andric
1090480093f4SDimitry Andricmulticlass sve_int_count<bits<3> opc, string asm, SDPatternOperator op> {
10910b57cec5SDimitry Andric  def NAME : sve_int_count<opc, asm>;
10920b57cec5SDimitry Andric
10930b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Rd, $pattern",
10940b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) GPR64:$Rd, sve_pred_enum:$pattern, 1), 1>;
10950b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Rd",
10960b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) GPR64:$Rd, 0b11111, 1), 2>;
1097480093f4SDimitry Andric
10980eae32dcSDimitry Andric  def : Pat<(i64 (mul (op sve_pred_enum:$pattern), (sve_cnt_mul_imm_i64 i32:$imm))),
1099480093f4SDimitry Andric            (!cast<Instruction>(NAME) sve_pred_enum:$pattern, sve_incdec_imm:$imm)>;
1100480093f4SDimitry Andric
11010eae32dcSDimitry Andric  def : Pat<(i64 (shl (op sve_pred_enum:$pattern), (sve_cnt_shl_imm i32:$imm))),
1102480093f4SDimitry Andric            (!cast<Instruction>(NAME) sve_pred_enum:$pattern, sve_incdec_imm:$imm)>;
1103480093f4SDimitry Andric
1104480093f4SDimitry Andric  def : Pat<(i64 (op sve_pred_enum:$pattern)),
1105480093f4SDimitry Andric            (!cast<Instruction>(NAME) sve_pred_enum:$pattern, 1)>;
11060b57cec5SDimitry Andric}
11070b57cec5SDimitry Andric
11080b57cec5SDimitry Andricclass sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty>
11090b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
11100b57cec5SDimitry Andric  asm, "\t$Zdn, $pattern, mul $imm4",
11110b57cec5SDimitry Andric  "",
11120b57cec5SDimitry Andric  []>, Sched<[]> {
11130b57cec5SDimitry Andric  bits<5> Zdn;
11140b57cec5SDimitry Andric  bits<5> pattern;
11150b57cec5SDimitry Andric  bits<4> imm4;
11160b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
11170b57cec5SDimitry Andric  let Inst{23-22} = opc{4-3};
11180b57cec5SDimitry Andric  let Inst{21}    = 0b1;
11190b57cec5SDimitry Andric  let Inst{20}    = opc{2};
11200b57cec5SDimitry Andric  let Inst{19-16} = imm4;
11210b57cec5SDimitry Andric  let Inst{15-12} = 0b1100;
11220b57cec5SDimitry Andric  let Inst{11-10} = opc{1-0};
11230b57cec5SDimitry Andric  let Inst{9-5}   = pattern;
11240b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
11250b57cec5SDimitry Andric
11260b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
11275ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
11280b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
112906c3fb27SDimitry Andric  let hasSideEffects = 0;
11300b57cec5SDimitry Andric}
11310b57cec5SDimitry Andric
1132480093f4SDimitry Andricmulticlass sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty,
1133480093f4SDimitry Andric                            SDPatternOperator op = null_frag,
1134480093f4SDimitry Andric                            ValueType vt = OtherVT> {
11350b57cec5SDimitry Andric  def NAME : sve_int_countvlv<opc, asm, zprty>;
11360b57cec5SDimitry Andric
11370b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $pattern",
11380b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zdn, sve_pred_enum:$pattern, 1), 1>;
11390b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn",
11400b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zdn, 0b11111, 1), 2>;
1141480093f4SDimitry Andric
1142480093f4SDimitry Andric  def : Pat<(vt (op (vt zprty:$Zn), (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
1143480093f4SDimitry Andric            (!cast<Instruction>(NAME) $Zn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
11440b57cec5SDimitry Andric}
11450b57cec5SDimitry Andric
11460b57cec5SDimitry Andricclass sve_int_pred_pattern_a<bits<3> opc, string asm>
11470b57cec5SDimitry Andric: I<(outs GPR64:$Rdn), (ins GPR64:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
11480b57cec5SDimitry Andric  asm, "\t$Rdn, $pattern, mul $imm4",
11490b57cec5SDimitry Andric  "",
11500b57cec5SDimitry Andric  []>, Sched<[]> {
11510b57cec5SDimitry Andric  bits<5> Rdn;
11520b57cec5SDimitry Andric  bits<5> pattern;
11530b57cec5SDimitry Andric  bits<4> imm4;
11540b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
11550b57cec5SDimitry Andric  let Inst{23-22} = opc{2-1};
11560b57cec5SDimitry Andric  let Inst{21-20} = 0b11;
11570b57cec5SDimitry Andric  let Inst{19-16} = imm4;
11580b57cec5SDimitry Andric  let Inst{15-11} = 0b11100;
11590b57cec5SDimitry Andric  let Inst{10}    = opc{0};
11600b57cec5SDimitry Andric  let Inst{9-5}   = pattern;
11610b57cec5SDimitry Andric  let Inst{4-0}   = Rdn;
11620b57cec5SDimitry Andric
11630b57cec5SDimitry Andric  let Constraints = "$Rdn = $_Rdn";
116406c3fb27SDimitry Andric  let hasSideEffects = 0;
11650b57cec5SDimitry Andric}
11660b57cec5SDimitry Andric
1167349cc55cSDimitry Andricmulticlass sve_int_pred_pattern_a<bits<3> opc, string asm,
1168349cc55cSDimitry Andric                                  SDPatternOperator op,
1169349cc55cSDimitry Andric                                  SDPatternOperator opcnt> {
117081ad6265SDimitry Andric  let Predicates = [HasSVEorSME] in {
11710b57cec5SDimitry Andric    def NAME : sve_int_pred_pattern_a<opc, asm>;
11720b57cec5SDimitry Andric
11730b57cec5SDimitry Andric    def : InstAlias<asm # "\t$Rdn, $pattern",
11740b57cec5SDimitry Andric                    (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1), 1>;
11750b57cec5SDimitry Andric    def : InstAlias<asm # "\t$Rdn",
11760b57cec5SDimitry Andric                    (!cast<Instruction>(NAME) GPR64:$Rdn, 0b11111, 1), 2>;
11770b57cec5SDimitry Andric  }
11780b57cec5SDimitry Andric
117981ad6265SDimitry Andric  let Predicates = [HasSVEorSME, UseScalarIncVL] in {
1180349cc55cSDimitry Andric    def : Pat<(i64 (op GPR64:$Rdn, (opcnt sve_pred_enum:$pattern))),
1181349cc55cSDimitry Andric              (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1)>;
1182349cc55cSDimitry Andric
11830eae32dcSDimitry Andric    def : Pat<(i64 (op GPR64:$Rdn, (mul (opcnt sve_pred_enum:$pattern), (sve_cnt_mul_imm_i64 i32:$imm)))),
1184349cc55cSDimitry Andric              (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, $imm)>;
1185349cc55cSDimitry Andric
11860eae32dcSDimitry Andric    def : Pat<(i64 (op GPR64:$Rdn, (shl (opcnt sve_pred_enum:$pattern), (sve_cnt_shl_imm i32:$imm)))),
1187349cc55cSDimitry Andric              (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, $imm)>;
1188349cc55cSDimitry Andric
1189349cc55cSDimitry Andric    def : Pat<(i32 (op GPR32:$Rdn, (i32 (trunc (opcnt (sve_pred_enum:$pattern)))))),
1190*0fca6ea1SDimitry Andric              (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF),
1191349cc55cSDimitry Andric                                               GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, 1),
1192*0fca6ea1SDimitry Andric                                    sub_32)>;
1193349cc55cSDimitry Andric
11940eae32dcSDimitry Andric    def : Pat<(i32 (op GPR32:$Rdn, (mul (i32 (trunc (opcnt (sve_pred_enum:$pattern)))), (sve_cnt_mul_imm_i32 i32:$imm)))),
1195*0fca6ea1SDimitry Andric              (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF),
1196349cc55cSDimitry Andric                                               GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, $imm),
1197*0fca6ea1SDimitry Andric                                    sub_32)>;
1198349cc55cSDimitry Andric
11990eae32dcSDimitry Andric    def : Pat<(i32 (op GPR32:$Rdn, (shl (i32 (trunc (opcnt (sve_pred_enum:$pattern)))), (sve_cnt_shl_imm i32:$imm)))),
1200*0fca6ea1SDimitry Andric              (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF),
1201349cc55cSDimitry Andric                                               GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, $imm),
1202*0fca6ea1SDimitry Andric                                    sub_32)>;
1203349cc55cSDimitry Andric  }
1204349cc55cSDimitry Andric}
1205349cc55cSDimitry Andric
12060b57cec5SDimitry Andricclass sve_int_pred_pattern_b<bits<5> opc, string asm, RegisterOperand dt,
12070b57cec5SDimitry Andric                             RegisterOperand st>
12080b57cec5SDimitry Andric: I<(outs dt:$Rdn), (ins st:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
12090b57cec5SDimitry Andric  asm, "\t$Rdn, $pattern, mul $imm4",
12100b57cec5SDimitry Andric  "",
12110b57cec5SDimitry Andric  []>, Sched<[]> {
12120b57cec5SDimitry Andric  bits<5> Rdn;
12130b57cec5SDimitry Andric  bits<5> pattern;
12140b57cec5SDimitry Andric  bits<4> imm4;
12150b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
12160b57cec5SDimitry Andric  let Inst{23-22} = opc{4-3};
12170b57cec5SDimitry Andric  let Inst{21}    = 0b1;
12180b57cec5SDimitry Andric  let Inst{20}    = opc{2};
12190b57cec5SDimitry Andric  let Inst{19-16} = imm4;
12200b57cec5SDimitry Andric  let Inst{15-12} = 0b1111;
12210b57cec5SDimitry Andric  let Inst{11-10} = opc{1-0};
12220b57cec5SDimitry Andric  let Inst{9-5}   = pattern;
12230b57cec5SDimitry Andric  let Inst{4-0}   = Rdn;
12240b57cec5SDimitry Andric
12250b57cec5SDimitry Andric  // Signed 32bit forms require their GPR operand printed.
12260b57cec5SDimitry Andric  let AsmString = !if(!eq(opc{2,0}, 0b00),
12270b57cec5SDimitry Andric                      !strconcat(asm, "\t$Rdn, $_Rdn, $pattern, mul $imm4"),
12280b57cec5SDimitry Andric                      !strconcat(asm, "\t$Rdn, $pattern, mul $imm4"));
12290b57cec5SDimitry Andric
12300b57cec5SDimitry Andric  let Constraints = "$Rdn = $_Rdn";
123106c3fb27SDimitry Andric  let hasSideEffects = 0;
12320b57cec5SDimitry Andric}
12330b57cec5SDimitry Andric
1234480093f4SDimitry Andricmulticlass sve_int_pred_pattern_b_s32<bits<5> opc, string asm,
1235480093f4SDimitry Andric                                      SDPatternOperator op> {
12360b57cec5SDimitry Andric  def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64as32>;
12370b57cec5SDimitry Andric
12380b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Rd, $Rn, $pattern",
12390b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, sve_pred_enum:$pattern, 1), 1>;
12400b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Rd, $Rn",
12410b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, 0b11111, 1), 2>;
1242480093f4SDimitry Andric
1243480093f4SDimitry Andric  // NOTE: Register allocation doesn't like tied operands of differing register
1244480093f4SDimitry Andric  //       class, hence the extra INSERT_SUBREG complication.
1245480093f4SDimitry Andric
1246480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
1247480093f4SDimitry Andric            (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32), sve_pred_enum:$pattern, sve_incdec_imm:$imm4), sub_32)>;
1248480093f4SDimitry Andric  def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))))),
1249480093f4SDimitry Andric            (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32), sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
12500b57cec5SDimitry Andric}
12510b57cec5SDimitry Andric
1252480093f4SDimitry Andricmulticlass sve_int_pred_pattern_b_u32<bits<5> opc, string asm,
1253480093f4SDimitry Andric                                      SDPatternOperator op> {
12540b57cec5SDimitry Andric  def NAME : sve_int_pred_pattern_b<opc, asm, GPR32z, GPR32z>;
12550b57cec5SDimitry Andric
12560b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Rdn, $pattern",
12570b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) GPR32z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
12580b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Rdn",
12590b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) GPR32z:$Rdn, 0b11111, 1), 2>;
1260480093f4SDimitry Andric
1261480093f4SDimitry Andric  def : Pat<(i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
1262480093f4SDimitry Andric            (!cast<Instruction>(NAME) $Rn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
12630b57cec5SDimitry Andric}
12640b57cec5SDimitry Andric
1265480093f4SDimitry Andricmulticlass sve_int_pred_pattern_b_x64<bits<5> opc, string asm,
1266480093f4SDimitry Andric                                      SDPatternOperator op> {
12670b57cec5SDimitry Andric  def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64z>;
12680b57cec5SDimitry Andric
12690b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Rdn, $pattern",
12700b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) GPR64z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
12710b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Rdn",
12720b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) GPR64z:$Rdn, 0b11111, 1), 2>;
1273480093f4SDimitry Andric
1274480093f4SDimitry Andric  def : Pat<(i64 (op GPR64:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
1275480093f4SDimitry Andric            (!cast<Instruction>(NAME) $Rn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
12760b57cec5SDimitry Andric}
12770b57cec5SDimitry Andric
12780b57cec5SDimitry Andric
12790b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
12800b57cec5SDimitry Andric// SVE Permute - Cross Lane Group
12810b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
12820b57cec5SDimitry Andric
12830b57cec5SDimitry Andricclass sve_int_perm_dup_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
12848bcb0991SDimitry Andric                         ValueType vt, RegisterClass srcRegType,
12858bcb0991SDimitry Andric                         SDPatternOperator op>
12860b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins srcRegType:$Rn),
12870b57cec5SDimitry Andric  asm, "\t$Zd, $Rn",
12880b57cec5SDimitry Andric  "",
12898bcb0991SDimitry Andric  [(set (vt zprty:$Zd), (op srcRegType:$Rn))]>, Sched<[]> {
12900b57cec5SDimitry Andric  bits<5> Rn;
12910b57cec5SDimitry Andric  bits<5> Zd;
12920b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
12930b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
12940b57cec5SDimitry Andric  let Inst{21-10} = 0b100000001110;
12950b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
12960b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
129706c3fb27SDimitry Andric
129806c3fb27SDimitry Andric  let hasSideEffects = 0;
12990b57cec5SDimitry Andric}
13000b57cec5SDimitry Andric
13018bcb0991SDimitry Andricmulticlass sve_int_perm_dup_r<string asm, SDPatternOperator op> {
13028bcb0991SDimitry Andric  def _B : sve_int_perm_dup_r<0b00, asm, ZPR8, nxv16i8, GPR32sp, op>;
13038bcb0991SDimitry Andric  def _H : sve_int_perm_dup_r<0b01, asm, ZPR16, nxv8i16, GPR32sp, op>;
13048bcb0991SDimitry Andric  def _S : sve_int_perm_dup_r<0b10, asm, ZPR32, nxv4i32, GPR32sp, op>;
13058bcb0991SDimitry Andric  def _D : sve_int_perm_dup_r<0b11, asm, ZPR64, nxv2i64, GPR64sp, op>;
13060b57cec5SDimitry Andric
13070b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Rn",
13080b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, GPR32sp:$Rn), 1>;
13090b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Rn",
13100b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, GPR32sp:$Rn), 1>;
13110b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Rn",
13120b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, GPR32sp:$Rn), 1>;
13130b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Rn",
13140b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, GPR64sp:$Rn), 1>;
13150b57cec5SDimitry Andric}
13160b57cec5SDimitry Andric
13170b57cec5SDimitry Andricclass sve_int_perm_dup_i<bits<5> tsz, Operand immtype, string asm,
13180b57cec5SDimitry Andric                         ZPRRegOp zprty>
13190b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$idx),
13200b57cec5SDimitry Andric  asm, "\t$Zd, $Zn$idx",
13210b57cec5SDimitry Andric  "",
13220b57cec5SDimitry Andric  []>, Sched<[]> {
13230b57cec5SDimitry Andric  bits<5> Zd;
13240b57cec5SDimitry Andric  bits<5> Zn;
13250b57cec5SDimitry Andric  bits<7> idx;
13260b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
13270b57cec5SDimitry Andric  let Inst{23-22} = {?,?}; // imm3h
13280b57cec5SDimitry Andric  let Inst{21}    = 0b1;
13290b57cec5SDimitry Andric  let Inst{20-16} = tsz;
13300b57cec5SDimitry Andric  let Inst{15-10} = 0b001000;
13310b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
13320b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
133306c3fb27SDimitry Andric
133406c3fb27SDimitry Andric  let hasSideEffects = 0;
13350b57cec5SDimitry Andric}
13360b57cec5SDimitry Andric
13370b57cec5SDimitry Andricmulticlass sve_int_perm_dup_i<string asm> {
13380b57cec5SDimitry Andric  def _B : sve_int_perm_dup_i<{?,?,?,?,1}, sve_elm_idx_extdup_b, asm, ZPR8> {
13390b57cec5SDimitry Andric    let Inst{23-22} = idx{5-4};
13400b57cec5SDimitry Andric    let Inst{20-17} = idx{3-0};
13410b57cec5SDimitry Andric  }
13420b57cec5SDimitry Andric  def _H : sve_int_perm_dup_i<{?,?,?,1,0}, sve_elm_idx_extdup_h, asm, ZPR16> {
13430b57cec5SDimitry Andric    let Inst{23-22} = idx{4-3};
13440b57cec5SDimitry Andric    let Inst{20-18} = idx{2-0};
13450b57cec5SDimitry Andric  }
13460b57cec5SDimitry Andric  def _S : sve_int_perm_dup_i<{?,?,1,0,0}, sve_elm_idx_extdup_s, asm, ZPR32> {
13470b57cec5SDimitry Andric    let Inst{23-22} = idx{3-2};
13480b57cec5SDimitry Andric    let Inst{20-19}    = idx{1-0};
13490b57cec5SDimitry Andric  }
13500b57cec5SDimitry Andric  def _D : sve_int_perm_dup_i<{?,1,0,0,0}, sve_elm_idx_extdup_d, asm, ZPR64> {
13510b57cec5SDimitry Andric    let Inst{23-22} = idx{2-1};
13520b57cec5SDimitry Andric    let Inst{20}    = idx{0};
13530b57cec5SDimitry Andric  }
13540b57cec5SDimitry Andric  def _Q : sve_int_perm_dup_i<{1,0,0,0,0}, sve_elm_idx_extdup_q, asm, ZPR128> {
13550b57cec5SDimitry Andric    let Inst{23-22} = idx{1-0};
13560b57cec5SDimitry Andric  }
13570b57cec5SDimitry Andric
13580b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Zn$idx",
13590b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, sve_elm_idx_extdup_b:$idx), 1>;
13600b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Zn$idx",
13610b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, sve_elm_idx_extdup_h:$idx), 1>;
13620b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Zn$idx",
13630b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, sve_elm_idx_extdup_s:$idx), 1>;
13640b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Zn$idx",
13650b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, sve_elm_idx_extdup_d:$idx), 1>;
13660b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Zn$idx",
13670b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, ZPR128:$Zn, sve_elm_idx_extdup_q:$idx), 1>;
13680b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Bn",
13690b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, FPR8asZPR:$Bn, 0), 2>;
13700b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Hn",
13710b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, FPR16asZPR:$Hn, 0), 2>;
13720b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Sn",
13730b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, FPR32asZPR:$Sn, 0), 2>;
13740b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Dn",
13750b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, FPR64asZPR:$Dn, 0), 2>;
13760b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Qn",
13770b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, FPR128asZPR:$Qn, 0), 2>;
1378fe6060f1SDimitry Andric
1379fe6060f1SDimitry Andric  // Duplicate extracted element of vector into all vector elements
138081ad6265SDimitry Andric  def : Pat<(nxv16i8 (splat_vector (i32 (vector_extract (nxv16i8 ZPR:$vec), sve_elm_idx_extdup_b:$index)))),
1381fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _B) ZPR:$vec, sve_elm_idx_extdup_b:$index)>;
138281ad6265SDimitry Andric  def : Pat<(nxv8i16 (splat_vector (i32 (vector_extract (nxv8i16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))),
1383fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>;
138481ad6265SDimitry Andric  def : Pat<(nxv4i32 (splat_vector (i32 (vector_extract (nxv4i32 ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
1385fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
138681ad6265SDimitry Andric  def : Pat<(nxv2i64 (splat_vector (i64 (vector_extract (nxv2i64 ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
1387fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
138881ad6265SDimitry Andric  def : Pat<(nxv8f16 (splat_vector (f16 (vector_extract (nxv8f16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))),
1389fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>;
139081ad6265SDimitry Andric  def : Pat<(nxv8bf16 (splat_vector (bf16 (vector_extract (nxv8bf16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))),
1391fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>;
139281ad6265SDimitry Andric  def : Pat<(nxv4f16 (splat_vector (f16 (vector_extract (nxv4f16 ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
1393fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
139481ad6265SDimitry Andric  def : Pat<(nxv2f16 (splat_vector (f16 (vector_extract (nxv2f16 ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
1395fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
139681ad6265SDimitry Andric  def : Pat<(nxv4f32 (splat_vector (f32 (vector_extract (nxv4f32 ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
1397fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
139881ad6265SDimitry Andric  def : Pat<(nxv2f32 (splat_vector (f32 (vector_extract (nxv2f32 ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
1399fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
140081ad6265SDimitry Andric  def : Pat<(nxv2f64 (splat_vector (f64 (vector_extract (nxv2f64 ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
1401fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
140281ad6265SDimitry Andric
140381ad6265SDimitry Andric  def : Pat<(nxv16i8 (AArch64duplane128 nxv16i8:$Op1, i64:$imm)),
140481ad6265SDimitry Andric            (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
140581ad6265SDimitry Andric  def : Pat<(nxv8i16 (AArch64duplane128 nxv8i16:$Op1, i64:$imm)),
140681ad6265SDimitry Andric            (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
140781ad6265SDimitry Andric  def : Pat<(nxv4i32 (AArch64duplane128 nxv4i32:$Op1, i64:$imm)),
140881ad6265SDimitry Andric            (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
140981ad6265SDimitry Andric  def : Pat<(nxv2i64 (AArch64duplane128 nxv2i64:$Op1, i64:$imm)),
141081ad6265SDimitry Andric            (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
141181ad6265SDimitry Andric  def : Pat<(nxv8f16 (AArch64duplane128 nxv8f16:$Op1, i64:$imm)),
141281ad6265SDimitry Andric            (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
141381ad6265SDimitry Andric  def : Pat<(nxv4f32 (AArch64duplane128 nxv4f32:$Op1, i64:$imm)),
141481ad6265SDimitry Andric            (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
141581ad6265SDimitry Andric  def : Pat<(nxv2f64 (AArch64duplane128 nxv2f64:$Op1, i64:$imm)),
141681ad6265SDimitry Andric            (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
141781ad6265SDimitry Andric  def : Pat<(nxv8bf16 (AArch64duplane128 nxv8bf16:$Op1, i64:$imm)),
141881ad6265SDimitry Andric            (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
14190b57cec5SDimitry Andric}
14200b57cec5SDimitry Andric
1421e8d8bef9SDimitry Andricclass sve_int_perm_tbl<bits<2> sz8_64, bits<2> opc, string asm, ZPRRegOp zprty,
1422e8d8bef9SDimitry Andric                       RegisterOperand VecList>
14230b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins VecList:$Zn, zprty:$Zm),
14240b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
14250b57cec5SDimitry Andric  "",
14260b57cec5SDimitry Andric  []>, Sched<[]> {
14270b57cec5SDimitry Andric  bits<5> Zd;
14280b57cec5SDimitry Andric  bits<5> Zm;
14290b57cec5SDimitry Andric  bits<5> Zn;
14300b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
14310b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
14320b57cec5SDimitry Andric  let Inst{21}    = 0b1;
14330b57cec5SDimitry Andric  let Inst{20-16} = Zm;
14340b57cec5SDimitry Andric  let Inst{15-13} = 0b001;
14350b57cec5SDimitry Andric  let Inst{12-11} = opc;
14360b57cec5SDimitry Andric  let Inst{10}    = 0b0;
14370b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
14380b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
143906c3fb27SDimitry Andric
144006c3fb27SDimitry Andric  let hasSideEffects = 0;
14410b57cec5SDimitry Andric}
14420b57cec5SDimitry Andric
1443480093f4SDimitry Andricmulticlass sve_int_perm_tbl<string asm, SDPatternOperator op> {
14440b57cec5SDimitry Andric  def _B : sve_int_perm_tbl<0b00, 0b10, asm, ZPR8,  Z_b>;
14450b57cec5SDimitry Andric  def _H : sve_int_perm_tbl<0b01, 0b10, asm, ZPR16, Z_h>;
14460b57cec5SDimitry Andric  def _S : sve_int_perm_tbl<0b10, 0b10, asm, ZPR32, Z_s>;
14470b57cec5SDimitry Andric  def _D : sve_int_perm_tbl<0b11, 0b10, asm, ZPR64, Z_d>;
14480b57cec5SDimitry Andric
14490b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
14500b57cec5SDimitry Andric                 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 0>;
14510b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
14520b57cec5SDimitry Andric                 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 0>;
14530b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
14540b57cec5SDimitry Andric                 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 0>;
14550b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
14560b57cec5SDimitry Andric                 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, ZPR64:$Zm), 0>;
1457480093f4SDimitry Andric
1458480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
1459480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1460480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
1461480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1462480093f4SDimitry Andric
1463480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1464480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
1465480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1466e8d8bef9SDimitry Andric
1467e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>;
14680b57cec5SDimitry Andric}
14690b57cec5SDimitry Andric
14705ffd83dbSDimitry Andricmulticlass sve2_int_perm_tbl<string asm, SDPatternOperator op> {
14710b57cec5SDimitry Andric  def _B : sve_int_perm_tbl<0b00, 0b01, asm, ZPR8,  ZZ_b>;
14720b57cec5SDimitry Andric  def _H : sve_int_perm_tbl<0b01, 0b01, asm, ZPR16, ZZ_h>;
14730b57cec5SDimitry Andric  def _S : sve_int_perm_tbl<0b10, 0b01, asm, ZPR32, ZZ_s>;
14740b57cec5SDimitry Andric  def _D : sve_int_perm_tbl<0b11, 0b01, asm, ZPR64, ZZ_d>;
14755ffd83dbSDimitry Andric
14765ffd83dbSDimitry Andric  def : Pat<(nxv16i8 (op nxv16i8:$Op1, nxv16i8:$Op2, nxv16i8:$Op3)),
14775ffd83dbSDimitry Andric            (nxv16i8 (!cast<Instruction>(NAME # _B) (REG_SEQUENCE ZPR2, nxv16i8:$Op1, zsub0,
14785ffd83dbSDimitry Andric                                                                        nxv16i8:$Op2, zsub1),
14795ffd83dbSDimitry Andric                                                     nxv16i8:$Op3))>;
14805ffd83dbSDimitry Andric
14815ffd83dbSDimitry Andric  def : Pat<(nxv8i16 (op nxv8i16:$Op1, nxv8i16:$Op2, nxv8i16:$Op3)),
14825ffd83dbSDimitry Andric            (nxv8i16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8i16:$Op1, zsub0,
14835ffd83dbSDimitry Andric                                                                        nxv8i16:$Op2, zsub1),
14845ffd83dbSDimitry Andric                                                     nxv8i16:$Op3))>;
14855ffd83dbSDimitry Andric
14865ffd83dbSDimitry Andric  def : Pat<(nxv4i32 (op nxv4i32:$Op1, nxv4i32:$Op2, nxv4i32:$Op3)),
14875ffd83dbSDimitry Andric            (nxv4i32 (!cast<Instruction>(NAME # _S) (REG_SEQUENCE ZPR2, nxv4i32:$Op1, zsub0,
14885ffd83dbSDimitry Andric                                                                        nxv4i32:$Op2, zsub1),
14895ffd83dbSDimitry Andric                                                     nxv4i32:$Op3))>;
14905ffd83dbSDimitry Andric
14915ffd83dbSDimitry Andric  def : Pat<(nxv2i64 (op nxv2i64:$Op1, nxv2i64:$Op2, nxv2i64:$Op3)),
14925ffd83dbSDimitry Andric            (nxv2i64 (!cast<Instruction>(NAME # _D) (REG_SEQUENCE ZPR2, nxv2i64:$Op1, zsub0,
14935ffd83dbSDimitry Andric                                                                        nxv2i64:$Op2, zsub1),
14945ffd83dbSDimitry Andric                                                     nxv2i64:$Op3))>;
14955ffd83dbSDimitry Andric
14965ffd83dbSDimitry Andric  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8i16:$Op3)),
14975ffd83dbSDimitry Andric            (nxv8f16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8f16:$Op1, zsub0,
14985ffd83dbSDimitry Andric                                                                        nxv8f16:$Op2, zsub1),
14995ffd83dbSDimitry Andric                                                     nxv8i16:$Op3))>;
15005ffd83dbSDimitry Andric
15015ffd83dbSDimitry Andric  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4i32:$Op3)),
15025ffd83dbSDimitry Andric            (nxv4f32 (!cast<Instruction>(NAME # _S) (REG_SEQUENCE ZPR2, nxv4f32:$Op1, zsub0,
15035ffd83dbSDimitry Andric                                                                        nxv4f32:$Op2, zsub1),
15045ffd83dbSDimitry Andric                                                     nxv4i32:$Op3))>;
15055ffd83dbSDimitry Andric
15065ffd83dbSDimitry Andric  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2i64:$Op3)),
15075ffd83dbSDimitry Andric            (nxv2f64 (!cast<Instruction>(NAME # _D) (REG_SEQUENCE ZPR2, nxv2f64:$Op1, zsub0,
15085ffd83dbSDimitry Andric                                                                        nxv2f64:$Op2, zsub1),
15095ffd83dbSDimitry Andric                                                     nxv2i64:$Op3))>;
1510e8d8bef9SDimitry Andric
1511e8d8bef9SDimitry Andric  def : Pat<(nxv8bf16 (op nxv8bf16:$Op1, nxv8bf16:$Op2, nxv8i16:$Op3)),
1512e8d8bef9SDimitry Andric            (nxv8bf16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8bf16:$Op1, zsub0,
1513e8d8bef9SDimitry Andric                                                                         nxv8bf16:$Op2, zsub1),
1514e8d8bef9SDimitry Andric                                                      nxv8i16:$Op3))>;
15150b57cec5SDimitry Andric}
15160b57cec5SDimitry Andric
1517bdd1243dSDimitry Andricclass sve2_int_perm_tbx<bits<2> sz8_64, bits<2> opc, string asm, ZPRRegOp zprty>
15180b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, zprty:$Zm),
15190b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
15200b57cec5SDimitry Andric  "",
15210b57cec5SDimitry Andric  []>, Sched<[]> {
15220b57cec5SDimitry Andric  bits<5> Zd;
15230b57cec5SDimitry Andric  bits<5> Zm;
15240b57cec5SDimitry Andric  bits<5> Zn;
15250b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
15260b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
15270b57cec5SDimitry Andric  let Inst{21}    = 0b1;
15280b57cec5SDimitry Andric  let Inst{20-16} = Zm;
1529bdd1243dSDimitry Andric  let Inst{15-13} = 0b001;
1530bdd1243dSDimitry Andric  let Inst{12-11} = opc;
1531bdd1243dSDimitry Andric  let Inst{10}    = 0b1;
15320b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
15330b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
15340b57cec5SDimitry Andric
15350b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
153606c3fb27SDimitry Andric  let hasSideEffects = 0;
15370b57cec5SDimitry Andric}
15380b57cec5SDimitry Andric
1539bdd1243dSDimitry Andricmulticlass sve2_int_perm_tbx<string asm, bits<2> opc, SDPatternOperator op> {
1540bdd1243dSDimitry Andric  def _B : sve2_int_perm_tbx<0b00, opc, asm, ZPR8>;
1541bdd1243dSDimitry Andric  def _H : sve2_int_perm_tbx<0b01, opc, asm, ZPR16>;
1542bdd1243dSDimitry Andric  def _S : sve2_int_perm_tbx<0b10, opc, asm, ZPR32>;
1543bdd1243dSDimitry Andric  def _D : sve2_int_perm_tbx<0b11, opc, asm, ZPR64>;
15445ffd83dbSDimitry Andric
15455ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
15465ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
15475ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
15485ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
15495ffd83dbSDimitry Andric
15505ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
15515ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
15525ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1553e8d8bef9SDimitry Andric
1554e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>;
15550b57cec5SDimitry Andric}
15560b57cec5SDimitry Andric
15570b57cec5SDimitry Andricclass sve_int_perm_reverse_z<bits<2> sz8_64, string asm, ZPRRegOp zprty>
15580b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn),
15590b57cec5SDimitry Andric  asm, "\t$Zd, $Zn",
15600b57cec5SDimitry Andric  "",
15610b57cec5SDimitry Andric  []>, Sched<[]> {
15620b57cec5SDimitry Andric  bits<5> Zd;
15630b57cec5SDimitry Andric  bits<5> Zn;
15640b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
15650b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
15660b57cec5SDimitry Andric  let Inst{21-10} = 0b111000001110;
15670b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
15680b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
156906c3fb27SDimitry Andric
157006c3fb27SDimitry Andric  let hasSideEffects = 0;
15710b57cec5SDimitry Andric}
15720b57cec5SDimitry Andric
1573480093f4SDimitry Andricmulticlass sve_int_perm_reverse_z<string asm, SDPatternOperator op> {
15740b57cec5SDimitry Andric  def _B : sve_int_perm_reverse_z<0b00, asm, ZPR8>;
15750b57cec5SDimitry Andric  def _H : sve_int_perm_reverse_z<0b01, asm, ZPR16>;
15760b57cec5SDimitry Andric  def _S : sve_int_perm_reverse_z<0b10, asm, ZPR32>;
15770b57cec5SDimitry Andric  def _D : sve_int_perm_reverse_z<0b11, asm, ZPR64>;
1578480093f4SDimitry Andric
1579480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv16i8, op, nxv16i8, !cast<Instruction>(NAME # _B)>;
1580480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv8i16, op, nxv8i16, !cast<Instruction>(NAME # _H)>;
1581480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv4i32, op, nxv4i32, !cast<Instruction>(NAME # _S)>;
1582480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv2i64, op, nxv2i64, !cast<Instruction>(NAME # _D)>;
1583480093f4SDimitry Andric
1584349cc55cSDimitry Andric  def : SVE_1_Op_Pat<nxv2f16, op, nxv2f16, !cast<Instruction>(NAME # _D)>;
1585349cc55cSDimitry Andric  def : SVE_1_Op_Pat<nxv4f16, op, nxv4f16, !cast<Instruction>(NAME # _S)>;
1586480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv8f16, op, nxv8f16, !cast<Instruction>(NAME # _H)>;
1587349cc55cSDimitry Andric  def : SVE_1_Op_Pat<nxv2f32, op, nxv2f32, !cast<Instruction>(NAME # _D)>;
1588480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv4f32, op, nxv4f32, !cast<Instruction>(NAME # _S)>;
1589480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>;
1590e8d8bef9SDimitry Andric
1591349cc55cSDimitry Andric  def : SVE_1_Op_Pat<nxv2bf16, op, nxv2bf16, !cast<Instruction>(NAME # _D)>;
1592349cc55cSDimitry Andric  def : SVE_1_Op_Pat<nxv4bf16, op, nxv4bf16, !cast<Instruction>(NAME # _S)>;
1593e8d8bef9SDimitry Andric  def : SVE_1_Op_Pat<nxv8bf16, op, nxv8bf16, !cast<Instruction>(NAME # _H)>;
15940b57cec5SDimitry Andric}
15950b57cec5SDimitry Andric
15961ac55f4cSDimitry Andricclass sve_int_perm_reverse_p<bits<2> sz8_64, string asm, PPRRegOp pprty,
15971ac55f4cSDimitry Andric                             SDPatternOperator op>
15980b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins pprty:$Pn),
15990b57cec5SDimitry Andric  asm, "\t$Pd, $Pn",
16000b57cec5SDimitry Andric  "",
16011ac55f4cSDimitry Andric  [(set nxv16i1:$Pd, (op nxv16i1:$Pn))]>, Sched<[]> {
16020b57cec5SDimitry Andric  bits<4> Pd;
16030b57cec5SDimitry Andric  bits<4> Pn;
16040b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
16050b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
16060b57cec5SDimitry Andric  let Inst{21-9}  = 0b1101000100000;
16070b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
16080b57cec5SDimitry Andric  let Inst{4}     = 0b0;
16090b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
161006c3fb27SDimitry Andric
161106c3fb27SDimitry Andric  let hasSideEffects = 0;
16120b57cec5SDimitry Andric}
16130b57cec5SDimitry Andric
16141ac55f4cSDimitry Andricmulticlass sve_int_perm_reverse_p<string asm, SDPatternOperator ir_op,
16151ac55f4cSDimitry Andric                                  SDPatternOperator op_b16,
16161ac55f4cSDimitry Andric                                  SDPatternOperator op_b32,
16171ac55f4cSDimitry Andric                                  SDPatternOperator op_b64> {
16181ac55f4cSDimitry Andric  def _B : sve_int_perm_reverse_p<0b00, asm, PPR8,  ir_op>;
16191ac55f4cSDimitry Andric  def _H : sve_int_perm_reverse_p<0b01, asm, PPR16, op_b16>;
16201ac55f4cSDimitry Andric  def _S : sve_int_perm_reverse_p<0b10, asm, PPR32, op_b32>;
16211ac55f4cSDimitry Andric  def _D : sve_int_perm_reverse_p<0b11, asm, PPR64, op_b64>;
1622480093f4SDimitry Andric
16231ac55f4cSDimitry Andric  def : SVE_1_Op_Pat<nxv8i1, ir_op, nxv8i1, !cast<Instruction>(NAME # _H)>;
16241ac55f4cSDimitry Andric  def : SVE_1_Op_Pat<nxv4i1, ir_op, nxv4i1, !cast<Instruction>(NAME # _S)>;
16251ac55f4cSDimitry Andric  def : SVE_1_Op_Pat<nxv2i1, ir_op, nxv2i1, !cast<Instruction>(NAME # _D)>;
16260b57cec5SDimitry Andric}
16270b57cec5SDimitry Andric
16280b57cec5SDimitry Andricclass sve_int_perm_unpk<bits<2> sz16_64, bits<2> opc, string asm,
16290b57cec5SDimitry Andric                        ZPRRegOp zprty1, ZPRRegOp zprty2>
16300b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty2:$Zn),
16310b57cec5SDimitry Andric  asm, "\t$Zd, $Zn",
16320b57cec5SDimitry Andric  "", []>, Sched<[]> {
16330b57cec5SDimitry Andric  bits<5> Zd;
16340b57cec5SDimitry Andric  bits<5> Zn;
16350b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
16360b57cec5SDimitry Andric  let Inst{23-22} = sz16_64;
16370b57cec5SDimitry Andric  let Inst{21-18} = 0b1100;
16380b57cec5SDimitry Andric  let Inst{17-16} = opc;
16390b57cec5SDimitry Andric  let Inst{15-10} = 0b001110;
16400b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
16410b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
164206c3fb27SDimitry Andric
164306c3fb27SDimitry Andric  let hasSideEffects = 0;
16440b57cec5SDimitry Andric}
16450b57cec5SDimitry Andric
16468bcb0991SDimitry Andricmulticlass sve_int_perm_unpk<bits<2> opc, string asm, SDPatternOperator op> {
16470b57cec5SDimitry Andric  def _H : sve_int_perm_unpk<0b01, opc, asm, ZPR16, ZPR8>;
16480b57cec5SDimitry Andric  def _S : sve_int_perm_unpk<0b10, opc, asm, ZPR32, ZPR16>;
16490b57cec5SDimitry Andric  def _D : sve_int_perm_unpk<0b11, opc, asm, ZPR64, ZPR32>;
16508bcb0991SDimitry Andric
16518bcb0991SDimitry Andric  def : SVE_1_Op_Pat<nxv8i16, op, nxv16i8, !cast<Instruction>(NAME # _H)>;
16528bcb0991SDimitry Andric  def : SVE_1_Op_Pat<nxv4i32, op, nxv8i16, !cast<Instruction>(NAME # _S)>;
16538bcb0991SDimitry Andric  def : SVE_1_Op_Pat<nxv2i64, op, nxv4i32, !cast<Instruction>(NAME # _D)>;
16540b57cec5SDimitry Andric}
16550b57cec5SDimitry Andric
16560b57cec5SDimitry Andricclass sve_int_perm_insrs<bits<2> sz8_64, string asm, ZPRRegOp zprty,
16570b57cec5SDimitry Andric                         RegisterClass srcRegType>
16580b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcRegType:$Rm),
16590b57cec5SDimitry Andric  asm, "\t$Zdn, $Rm",
16600b57cec5SDimitry Andric  "",
16610b57cec5SDimitry Andric  []>, Sched<[]> {
16620b57cec5SDimitry Andric  bits<5> Rm;
16630b57cec5SDimitry Andric  bits<5> Zdn;
16640b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
16650b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
16660b57cec5SDimitry Andric  let Inst{21-10} = 0b100100001110;
16670b57cec5SDimitry Andric  let Inst{9-5}   = Rm;
16680b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
16690b57cec5SDimitry Andric
16700b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
16715ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
167206c3fb27SDimitry Andric  let hasSideEffects = 0;
16730b57cec5SDimitry Andric}
16740b57cec5SDimitry Andric
1675480093f4SDimitry Andricmulticlass sve_int_perm_insrs<string asm, SDPatternOperator op> {
16760b57cec5SDimitry Andric  def _B : sve_int_perm_insrs<0b00, asm, ZPR8, GPR32>;
16770b57cec5SDimitry Andric  def _H : sve_int_perm_insrs<0b01, asm, ZPR16, GPR32>;
16780b57cec5SDimitry Andric  def _S : sve_int_perm_insrs<0b10, asm, ZPR32, GPR32>;
16790b57cec5SDimitry Andric  def _D : sve_int_perm_insrs<0b11, asm, ZPR64, GPR64>;
1680480093f4SDimitry Andric
1681480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, i32, !cast<Instruction>(NAME # _B)>;
1682480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, i32, !cast<Instruction>(NAME # _H)>;
1683480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, i32, !cast<Instruction>(NAME # _S)>;
1684480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, i64, !cast<Instruction>(NAME # _D)>;
16850b57cec5SDimitry Andric}
16860b57cec5SDimitry Andric
16870b57cec5SDimitry Andricclass sve_int_perm_insrv<bits<2> sz8_64, string asm, ZPRRegOp zprty,
1688fe6060f1SDimitry Andric                         FPRasZPROperand srcOpType>
1689fe6060f1SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcOpType:$Vm),
16900b57cec5SDimitry Andric  asm, "\t$Zdn, $Vm",
16910b57cec5SDimitry Andric  "",
16920b57cec5SDimitry Andric  []>, Sched<[]> {
16930b57cec5SDimitry Andric  bits<5> Vm;
16940b57cec5SDimitry Andric  bits<5> Zdn;
16950b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
16960b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
16970b57cec5SDimitry Andric  let Inst{21-10} = 0b110100001110;
16980b57cec5SDimitry Andric  let Inst{9-5}   = Vm;
16990b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
17000b57cec5SDimitry Andric
17010b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
17025ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
170306c3fb27SDimitry Andric  let hasSideEffects = 0;
17040b57cec5SDimitry Andric}
17050b57cec5SDimitry Andric
1706480093f4SDimitry Andricmulticlass sve_int_perm_insrv<string asm, SDPatternOperator op> {
1707fe6060f1SDimitry Andric  def _B : sve_int_perm_insrv<0b00, asm, ZPR8, FPR8asZPR>;
1708fe6060f1SDimitry Andric  def _H : sve_int_perm_insrv<0b01, asm, ZPR16, FPR16asZPR>;
1709fe6060f1SDimitry Andric  def _S : sve_int_perm_insrv<0b10, asm, ZPR32, FPR32asZPR>;
1710fe6060f1SDimitry Andric  def _D : sve_int_perm_insrv<0b11, asm, ZPR64, FPR64asZPR>;
1711480093f4SDimitry Andric
1712fe6060f1SDimitry Andric  def : Pat<(nxv8f16 (op nxv8f16:$Zn, f16:$Vm)),
1713fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _H) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, hsub))>;
1714fe6060f1SDimitry Andric  def : Pat<(nxv4f32 (op nxv4f32:$Zn, f32:$Vm)),
1715fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _S) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, ssub))>;
1716fe6060f1SDimitry Andric  def : Pat<(nxv2f64 (op nxv2f64:$Zn, f64:$Vm)),
1717fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _D) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, dsub))>;
1718e8d8bef9SDimitry Andric
1719fe6060f1SDimitry Andric  def : Pat<(nxv8bf16 (op nxv8bf16:$Zn, bf16:$Vm)),
1720fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _H) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, hsub))>;
1721fe6060f1SDimitry Andric
1722fe6060f1SDimitry Andric  // Keep integer insertions within the vector unit.
1723fe6060f1SDimitry Andric  def : Pat<(nxv16i8 (op (nxv16i8 ZPR:$Zn), (i32 (vector_extract (nxv16i8 ZPR:$Vm), 0)))),
1724fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _B) $Zn, ZPR:$Vm)>;
1725fe6060f1SDimitry Andric  def : Pat<(nxv8i16 (op (nxv8i16 ZPR:$Zn), (i32 (vector_extract (nxv8i16 ZPR:$Vm), 0)))),
1726fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _H) $Zn, ZPR:$Vm)>;
1727fe6060f1SDimitry Andric  def : Pat<(nxv4i32 (op (nxv4i32 ZPR:$Zn), (i32 (vector_extract (nxv4i32 ZPR:$Vm), 0)))),
1728fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _S) $Zn, ZPR: $Vm)>;
1729fe6060f1SDimitry Andric  def : Pat<(nxv2i64 (op (nxv2i64 ZPR:$Zn), (i64 (vector_extract (nxv2i64 ZPR:$Vm), 0)))),
1730fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # _D) $Zn, ZPR:$Vm)>;
1731fe6060f1SDimitry Andric
17320b57cec5SDimitry Andric}
17330b57cec5SDimitry Andric
17340b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
17350b57cec5SDimitry Andric// SVE Permute - Extract Group
17360b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
17370b57cec5SDimitry Andric
17380b57cec5SDimitry Andricclass sve_int_perm_extract_i<string asm>
17390b57cec5SDimitry Andric: I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn, ZPR8:$Zm, imm0_255:$imm8),
17400b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $Zm, $imm8",
17410b57cec5SDimitry Andric  "", []>, Sched<[]> {
17420b57cec5SDimitry Andric  bits<5> Zdn;
17430b57cec5SDimitry Andric  bits<5> Zm;
17440b57cec5SDimitry Andric  bits<8> imm8;
17450b57cec5SDimitry Andric  let Inst{31-21} = 0b00000101001;
17460b57cec5SDimitry Andric  let Inst{20-16} = imm8{7-3};
17470b57cec5SDimitry Andric  let Inst{15-13} = 0b000;
17480b57cec5SDimitry Andric  let Inst{12-10} = imm8{2-0};
17490b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
17500b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
17510b57cec5SDimitry Andric
17520b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
17535ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
17540b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
175506c3fb27SDimitry Andric  let hasSideEffects = 0;
17560b57cec5SDimitry Andric}
17570b57cec5SDimitry Andric
1758480093f4SDimitry Andricmulticlass sve_int_perm_extract_i<string asm, SDPatternOperator op> {
1759480093f4SDimitry Andric  def NAME : sve_int_perm_extract_i<asm>;
1760480093f4SDimitry Andric
1761480093f4SDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, imm0_255,
1762480093f4SDimitry Andric                         !cast<Instruction>(NAME)>;
1763480093f4SDimitry Andric}
1764480093f4SDimitry Andric
17650b57cec5SDimitry Andricclass sve2_int_perm_extract_i_cons<string asm>
17660b57cec5SDimitry Andric: I<(outs ZPR8:$Zd), (ins ZZ_b:$Zn, imm0_255:$imm8),
17670b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $imm8",
17680b57cec5SDimitry Andric  "", []>, Sched<[]> {
17690b57cec5SDimitry Andric  bits<5> Zd;
17700b57cec5SDimitry Andric  bits<5> Zn;
17710b57cec5SDimitry Andric  bits<8> imm8;
17720b57cec5SDimitry Andric  let Inst{31-21} = 0b00000101011;
17730b57cec5SDimitry Andric  let Inst{20-16} = imm8{7-3};
17740b57cec5SDimitry Andric  let Inst{15-13} = 0b000;
17750b57cec5SDimitry Andric  let Inst{12-10} = imm8{2-0};
17760b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
17770b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
177806c3fb27SDimitry Andric
177906c3fb27SDimitry Andric  let hasSideEffects = 0;
17800b57cec5SDimitry Andric}
17810b57cec5SDimitry Andric
17820b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
17830b57cec5SDimitry Andric// SVE Vector Select Group
17840b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
17850b57cec5SDimitry Andric
17860b57cec5SDimitry Andricclass sve_int_sel_vvv<bits<2> sz8_64, string asm, ZPRRegOp zprty>
17870b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins PPRAny:$Pg, zprty:$Zn, zprty:$Zm),
17880b57cec5SDimitry Andric  asm, "\t$Zd, $Pg, $Zn, $Zm",
17890b57cec5SDimitry Andric  "",
17900b57cec5SDimitry Andric  []>, Sched<[]> {
17910b57cec5SDimitry Andric  bits<4> Pg;
17920b57cec5SDimitry Andric  bits<5> Zd;
17930b57cec5SDimitry Andric  bits<5> Zm;
17940b57cec5SDimitry Andric  bits<5> Zn;
17950b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
17960b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
17970b57cec5SDimitry Andric  let Inst{21}    = 0b1;
17980b57cec5SDimitry Andric  let Inst{20-16} = Zm;
17990b57cec5SDimitry Andric  let Inst{15-14} = 0b11;
18000b57cec5SDimitry Andric  let Inst{13-10} = Pg;
18010b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
18020b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
180306c3fb27SDimitry Andric
180406c3fb27SDimitry Andric  let hasSideEffects = 0;
18050b57cec5SDimitry Andric}
18060b57cec5SDimitry Andric
1807480093f4SDimitry Andricmulticlass sve_int_sel_vvv<string asm, SDPatternOperator op> {
18080b57cec5SDimitry Andric  def _B : sve_int_sel_vvv<0b00, asm, ZPR8>;
18090b57cec5SDimitry Andric  def _H : sve_int_sel_vvv<0b01, asm, ZPR16>;
18100b57cec5SDimitry Andric  def _S : sve_int_sel_vvv<0b10, asm, ZPR32>;
18110b57cec5SDimitry Andric  def _D : sve_int_sel_vvv<0b11, asm, ZPR64>;
18120b57cec5SDimitry Andric
1813480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
1814480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1815480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
1816480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1817480093f4SDimitry Andric
1818480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1,  nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
1819fe6060f1SDimitry Andric  def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1,  nxv4f16, nxv4f16, !cast<Instruction>(NAME # _S)>;
1820480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1,  nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
1821fe6060f1SDimitry Andric  def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1,  nxv2f16, nxv2f16, !cast<Instruction>(NAME # _D)>;
1822480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1,  nxv2f32, nxv2f32, !cast<Instruction>(NAME # _D)>;
1823480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1,  nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
1824480093f4SDimitry Andric
1825e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1,  nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
1826e8d8bef9SDimitry Andric
18270b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Zn",
18280b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPRAny:$Pg, ZPR8:$Zn, ZPR8:$Zd), 1>;
18290b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Zn",
18300b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, ZPR16:$Zn, ZPR16:$Zd), 1>;
18310b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Zn",
18320b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, ZPR32:$Zn, ZPR32:$Zd), 1>;
18330b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Zn",
18340b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, ZPR64:$Zn, ZPR64:$Zd), 1>;
18350b57cec5SDimitry Andric}
18360b57cec5SDimitry Andric
18370b57cec5SDimitry Andric
18380b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18390b57cec5SDimitry Andric// SVE Predicate Logical Operations Group
18400b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
18410b57cec5SDimitry Andric
18420b57cec5SDimitry Andricclass sve_int_pred_log<bits<4> opc, string asm>
1843*0fca6ea1SDimitry Andric: I<(outs PPRorPNR8:$Pd), (ins PPRorPNRAny:$Pg, PPRorPNR8:$Pn, PPRorPNR8:$Pm),
18440b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z, $Pn, $Pm",
18450b57cec5SDimitry Andric  "",
18460b57cec5SDimitry Andric  []>, Sched<[]> {
18470b57cec5SDimitry Andric  bits<4> Pd;
18480b57cec5SDimitry Andric  bits<4> Pg;
18490b57cec5SDimitry Andric  bits<4> Pm;
18500b57cec5SDimitry Andric  bits<4> Pn;
18510b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
18520b57cec5SDimitry Andric  let Inst{23-22} = opc{3-2};
18530b57cec5SDimitry Andric  let Inst{21-20} = 0b00;
18540b57cec5SDimitry Andric  let Inst{19-16} = Pm;
18550b57cec5SDimitry Andric  let Inst{15-14} = 0b01;
18560b57cec5SDimitry Andric  let Inst{13-10} = Pg;
18570b57cec5SDimitry Andric  let Inst{9}     = opc{1};
18580b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
18590b57cec5SDimitry Andric  let Inst{4}     = opc{0};
18600b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
18610b57cec5SDimitry Andric
18620b57cec5SDimitry Andric  // SEL has no predication qualifier.
18630b57cec5SDimitry Andric  let AsmString = !if(!eq(opc, 0b0011),
18640b57cec5SDimitry Andric                      !strconcat(asm, "\t$Pd, $Pg, $Pn, $Pm"),
18650b57cec5SDimitry Andric                      !strconcat(asm, "\t$Pd, $Pg/z, $Pn, $Pm"));
18660b57cec5SDimitry Andric
18670b57cec5SDimitry Andric  let Defs = !if(!eq (opc{2}, 1), [NZCV], []);
186806c3fb27SDimitry Andric  let hasSideEffects = 0;
1869480093f4SDimitry Andric}
1870480093f4SDimitry Andric
18715ffd83dbSDimitry Andricmulticlass sve_int_pred_log<bits<4> opc, string asm, SDPatternOperator op,
18725ffd83dbSDimitry Andric                            SDPatternOperator op_nopred = null_frag> {
1873480093f4SDimitry Andric  def NAME : sve_int_pred_log<opc, asm>;
1874480093f4SDimitry Andric
1875480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
1876480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, nxv8i1, !cast<Instruction>(NAME)>;
1877480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, nxv4i1, !cast<Instruction>(NAME)>;
1878480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, nxv2i1, !cast<Instruction>(NAME)>;
187981ad6265SDimitry Andric  def : SVE_3_Op_Pat<nxv1i1, op, nxv1i1, nxv1i1, nxv1i1, !cast<Instruction>(NAME)>;
18805ffd83dbSDimitry Andric  def : SVE_2_Op_AllActive_Pat<nxv16i1, op_nopred, nxv16i1, nxv16i1,
18815ffd83dbSDimitry Andric                               !cast<Instruction>(NAME), PTRUE_B>;
18825ffd83dbSDimitry Andric  def : SVE_2_Op_AllActive_Pat<nxv8i1, op_nopred, nxv8i1, nxv8i1,
18835ffd83dbSDimitry Andric                               !cast<Instruction>(NAME), PTRUE_H>;
18845ffd83dbSDimitry Andric  def : SVE_2_Op_AllActive_Pat<nxv4i1, op_nopred, nxv4i1, nxv4i1,
18855ffd83dbSDimitry Andric                               !cast<Instruction>(NAME), PTRUE_S>;
18865ffd83dbSDimitry Andric  def : SVE_2_Op_AllActive_Pat<nxv2i1, op_nopred, nxv2i1, nxv2i1,
18875ffd83dbSDimitry Andric                               !cast<Instruction>(NAME), PTRUE_D>;
1888753f127fSDimitry Andric  // Emulate .Q operation using a PTRUE_D when the other lanes don't matter.
1889753f127fSDimitry Andric  def : SVE_2_Op_AllActive_Pat<nxv1i1, op_nopred, nxv1i1, nxv1i1,
1890753f127fSDimitry Andric                               !cast<Instruction>(NAME), PTRUE_D>;
18910b57cec5SDimitry Andric}
18920b57cec5SDimitry Andric
18931fd87a68SDimitry Andric// An instance of sve_int_pred_log_and but uses op_nopred's first operand as the
18941fd87a68SDimitry Andric// general predicate.
18951fd87a68SDimitry Andricmulticlass sve_int_pred_log_v2<bits<4> opc, string asm, SDPatternOperator op,
18961fd87a68SDimitry Andric                               SDPatternOperator op_nopred> :
189704eeddc0SDimitry Andric  sve_int_pred_log<opc, asm, op> {
18981fd87a68SDimitry Andric  def : Pat<(nxv16i1 (op_nopred nxv16i1:$Op1, nxv16i1:$Op2)),
189904eeddc0SDimitry Andric            (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
19001fd87a68SDimitry Andric  def : Pat<(nxv8i1 (op_nopred nxv8i1:$Op1, nxv8i1:$Op2)),
190104eeddc0SDimitry Andric            (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
19021fd87a68SDimitry Andric  def : Pat<(nxv4i1 (op_nopred nxv4i1:$Op1, nxv4i1:$Op2)),
190304eeddc0SDimitry Andric            (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
19041fd87a68SDimitry Andric  def : Pat<(nxv2i1 (op_nopred nxv2i1:$Op1, nxv2i1:$Op2)),
190504eeddc0SDimitry Andric            (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
1906753f127fSDimitry Andric  // Emulate .Q operation using a PTRUE_D when the other lanes don't matter.
1907753f127fSDimitry Andric  def : Pat<(nxv1i1 (op_nopred nxv1i1:$Op1, nxv1i1:$Op2)),
1908753f127fSDimitry Andric            (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
190904eeddc0SDimitry Andric}
191004eeddc0SDimitry Andric
19110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
19120b57cec5SDimitry Andric// SVE Logical Mask Immediate Group
19130b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
19140b57cec5SDimitry Andric
19150b57cec5SDimitry Andricclass sve_int_log_imm<bits<2> opc, string asm>
19160b57cec5SDimitry Andric: I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, logical_imm64:$imms13),
19170b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $imms13",
19180b57cec5SDimitry Andric  "", []>, Sched<[]> {
19190b57cec5SDimitry Andric  bits<5> Zdn;
19200b57cec5SDimitry Andric  bits<13> imms13;
19210b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
19220b57cec5SDimitry Andric  let Inst{23-22} = opc;
19230b57cec5SDimitry Andric  let Inst{21-18} = 0b0000;
19240b57cec5SDimitry Andric  let Inst{17-5}  = imms13;
19250b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
19260b57cec5SDimitry Andric
19270b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
19280b57cec5SDimitry Andric  let DecoderMethod = "DecodeSVELogicalImmInstruction";
19295ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
19300b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
193106c3fb27SDimitry Andric  let hasSideEffects = 0;
19320b57cec5SDimitry Andric}
19330b57cec5SDimitry Andric
1934480093f4SDimitry Andricmulticlass sve_int_log_imm<bits<2> opc, string asm, string alias, SDPatternOperator op> {
19350b57cec5SDimitry Andric  def NAME : sve_int_log_imm<opc, asm>;
19360b57cec5SDimitry Andric
1937480093f4SDimitry Andric  def : SVE_1_Op_Imm_Log_Pat<nxv16i8, op, ZPR8,  i32, SVELogicalImm8Pat,  !cast<Instruction>(NAME)>;
1938480093f4SDimitry Andric  def : SVE_1_Op_Imm_Log_Pat<nxv8i16, op, ZPR16, i32, SVELogicalImm16Pat, !cast<Instruction>(NAME)>;
1939480093f4SDimitry Andric  def : SVE_1_Op_Imm_Log_Pat<nxv4i32, op, ZPR32, i32, SVELogicalImm32Pat, !cast<Instruction>(NAME)>;
1940480093f4SDimitry Andric  def : SVE_1_Op_Imm_Log_Pat<nxv2i64, op, ZPR64, i64, SVELogicalImm64Pat, !cast<Instruction>(NAME)>;
1941480093f4SDimitry Andric
19420b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
19430b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8:$imm), 4>;
19440b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
19450b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16:$imm), 3>;
19460b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
19470b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32:$imm), 2>;
19480b57cec5SDimitry Andric
19490b57cec5SDimitry Andric  def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
19500b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8_not:$imm), 0>;
19510b57cec5SDimitry Andric  def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
19520b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16_not:$imm), 0>;
19530b57cec5SDimitry Andric  def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
19540b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32_not:$imm), 0>;
19550b57cec5SDimitry Andric  def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
19560b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR64:$Zdn, logical_imm64_not:$imm), 0>;
19570b57cec5SDimitry Andric}
19580b57cec5SDimitry Andric
1959fe6060f1SDimitry Andricmulticlass sve_int_log_imm_bic<SDPatternOperator op> {
1960fe6060f1SDimitry Andric  def : SVE_1_Op_Imm_Log_Pat<nxv16i8, op, ZPR8,  i32, SVELogicalImm8NotPat,  !cast<Instruction>("AND_ZI")>;
1961fe6060f1SDimitry Andric  def : SVE_1_Op_Imm_Log_Pat<nxv8i16, op, ZPR16, i32, SVELogicalImm16NotPat, !cast<Instruction>("AND_ZI")>;
1962fe6060f1SDimitry Andric  def : SVE_1_Op_Imm_Log_Pat<nxv4i32, op, ZPR32, i32, SVELogicalImm32NotPat, !cast<Instruction>("AND_ZI")>;
1963fe6060f1SDimitry Andric  def : SVE_1_Op_Imm_Log_Pat<nxv2i64, op, ZPR64, i64, SVELogicalImm64NotPat, !cast<Instruction>("AND_ZI")>;
1964fe6060f1SDimitry Andric}
1965fe6060f1SDimitry Andric
19660b57cec5SDimitry Andricclass sve_int_dup_mask_imm<string asm>
19670b57cec5SDimitry Andric: I<(outs ZPR64:$Zd), (ins logical_imm64:$imms),
19680b57cec5SDimitry Andric  asm, "\t$Zd, $imms",
19690b57cec5SDimitry Andric  "",
19700b57cec5SDimitry Andric  []>, Sched<[]> {
19710b57cec5SDimitry Andric  bits<5> Zd;
19720b57cec5SDimitry Andric  bits<13> imms;
19730b57cec5SDimitry Andric  let Inst{31-18} = 0b00000101110000;
19740b57cec5SDimitry Andric  let Inst{17-5} = imms;
19750b57cec5SDimitry Andric  let Inst{4-0} = Zd;
19760b57cec5SDimitry Andric
19770b57cec5SDimitry Andric  let DecoderMethod = "DecodeSVELogicalImmInstruction";
197806c3fb27SDimitry Andric  let hasSideEffects = 0;
197906c3fb27SDimitry Andric  let isReMaterializable = 1;
1980*0fca6ea1SDimitry Andric  let Uses = [VG];
19810b57cec5SDimitry Andric}
19820b57cec5SDimitry Andric
19830b57cec5SDimitry Andricmulticlass sve_int_dup_mask_imm<string asm> {
19840b57cec5SDimitry Andric  def NAME : sve_int_dup_mask_imm<asm>;
19850b57cec5SDimitry Andric
19860b57cec5SDimitry Andric  def : InstAlias<"dupm $Zd, $imm",
19870b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR8:$Zd, sve_logical_imm8:$imm), 4>;
19880b57cec5SDimitry Andric  def : InstAlias<"dupm $Zd, $imm",
19890b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR16:$Zd, sve_logical_imm16:$imm), 3>;
19900b57cec5SDimitry Andric  def : InstAlias<"dupm $Zd, $imm",
19910b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR32:$Zd, sve_logical_imm32:$imm), 2>;
19920b57cec5SDimitry Andric
19930b57cec5SDimitry Andric  // All Zd.b forms have a CPY/DUP equivalent, hence no byte alias here.
19940b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $imm",
19950b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR16:$Zd, sve_preferred_logical_imm16:$imm), 7>;
19960b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $imm",
19970b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR32:$Zd, sve_preferred_logical_imm32:$imm), 6>;
19980b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $imm",
19990b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR64:$Zd, sve_preferred_logical_imm64:$imm), 5>;
200004eeddc0SDimitry Andric
2001bdd1243dSDimitry Andric  // NOTE: No pattern for nxv16i8 because DUP has full coverage.
2002bdd1243dSDimitry Andric  def : Pat<(nxv8i16 (splat_vector (i32 (SVELogicalImm16Pat i64:$imm)))),
2003bdd1243dSDimitry Andric            (!cast<Instruction>(NAME) i64:$imm)>;
2004bdd1243dSDimitry Andric  def : Pat<(nxv4i32 (splat_vector (i32 (SVELogicalImm32Pat i64:$imm)))),
2005bdd1243dSDimitry Andric            (!cast<Instruction>(NAME) i64:$imm)>;
2006bdd1243dSDimitry Andric  def : Pat<(nxv2i64 (splat_vector (i64 (SVELogicalImm64Pat i64:$imm)))),
2007bdd1243dSDimitry Andric            (!cast<Instruction>(NAME) i64:$imm)>;
20080b57cec5SDimitry Andric}
20090b57cec5SDimitry Andric
20100b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20110b57cec5SDimitry Andric// SVE Integer Arithmetic -  Unpredicated Group.
20120b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20130b57cec5SDimitry Andric
20140b57cec5SDimitry Andricclass sve_int_bin_cons_arit_0<bits<2> sz8_64, bits<3> opc, string asm,
20150b57cec5SDimitry Andric                              ZPRRegOp zprty>
20160b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
20170b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
20180b57cec5SDimitry Andric  "", []>, Sched<[]> {
20190b57cec5SDimitry Andric  bits<5> Zd;
20200b57cec5SDimitry Andric  bits<5> Zm;
20210b57cec5SDimitry Andric  bits<5> Zn;
20220b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
20230b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
20240b57cec5SDimitry Andric  let Inst{21}    = 0b1;
20250b57cec5SDimitry Andric  let Inst{20-16} = Zm;
20260b57cec5SDimitry Andric  let Inst{15-13} = 0b000;
20270b57cec5SDimitry Andric  let Inst{12-10} = opc;
20280b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
20290b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
203006c3fb27SDimitry Andric
203106c3fb27SDimitry Andric  let hasSideEffects = 0;
20320b57cec5SDimitry Andric}
20330b57cec5SDimitry Andric
2034fe6060f1SDimitry Andricmulticlass sve_int_bin_cons_arit_0<bits<3> opc, string asm, SDPatternOperator op> {
20350b57cec5SDimitry Andric  def _B : sve_int_bin_cons_arit_0<0b00, opc, asm, ZPR8>;
20360b57cec5SDimitry Andric  def _H : sve_int_bin_cons_arit_0<0b01, opc, asm, ZPR16>;
20370b57cec5SDimitry Andric  def _S : sve_int_bin_cons_arit_0<0b10, opc, asm, ZPR32>;
20380b57cec5SDimitry Andric  def _D : sve_int_bin_cons_arit_0<0b11, opc, asm, ZPR64>;
2039480093f4SDimitry Andric
2040480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
2041480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
2042480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
2043480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
20440b57cec5SDimitry Andric}
20450b57cec5SDimitry Andric
20460b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20470b57cec5SDimitry Andric// SVE Floating Point Arithmetic - Predicated Group
20480b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
20490b57cec5SDimitry Andric
20500b57cec5SDimitry Andricclass sve_fp_2op_i_p_zds<bits<2> sz, bits<3> opc, string asm,
20510b57cec5SDimitry Andric                         ZPRRegOp zprty,
20520b57cec5SDimitry Andric                         Operand imm_ty>
20530b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, imm_ty:$i1),
20540b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $_Zdn, $i1",
20550b57cec5SDimitry Andric  "",
20560b57cec5SDimitry Andric  []>, Sched<[]> {
20570b57cec5SDimitry Andric  bits<3> Pg;
20580b57cec5SDimitry Andric  bits<5> Zdn;
20590b57cec5SDimitry Andric  bit i1;
20600b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
20610b57cec5SDimitry Andric  let Inst{23-22} = sz;
20620b57cec5SDimitry Andric  let Inst{21-19} = 0b011;
20630b57cec5SDimitry Andric  let Inst{18-16} = opc;
20640b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
20650b57cec5SDimitry Andric  let Inst{12-10} = Pg;
20660b57cec5SDimitry Andric  let Inst{9-6}   = 0b0000;
20670b57cec5SDimitry Andric  let Inst{5}     = i1;
20680b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
20690b57cec5SDimitry Andric
20700b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
20715ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
20720b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
207306c3fb27SDimitry Andric  let hasSideEffects = 0;
207406c3fb27SDimitry Andric  let mayRaiseFPException = 1;
20750b57cec5SDimitry Andric}
20760b57cec5SDimitry Andric
2077349cc55cSDimitry Andricmulticlass sve_fp_2op_i_p_zds<bits<3> opc, string asm, string Ps, Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator op> {
2078349cc55cSDimitry Andric  let DestructiveInstType = DestructiveBinaryImm in {
2079349cc55cSDimitry Andric  def _H : SVEPseudo2Instr<Ps # _H, 1>, sve_fp_2op_i_p_zds<0b01, opc, asm, ZPR16, imm_ty>;
2080349cc55cSDimitry Andric  def _S : SVEPseudo2Instr<Ps # _S, 1>, sve_fp_2op_i_p_zds<0b10, opc, asm, ZPR32, imm_ty>;
2081349cc55cSDimitry Andric  def _D : SVEPseudo2Instr<Ps # _D, 1>, sve_fp_2op_i_p_zds<0b11, opc, asm, ZPR64, imm_ty>;
2082349cc55cSDimitry Andric  }
2083349cc55cSDimitry Andric
2084349cc55cSDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_H")>;
2085349cc55cSDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_H")>;
2086349cc55cSDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_S")>;
2087349cc55cSDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_S")>;
2088349cc55cSDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_D")>;
2089349cc55cSDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_D")>;
20900b57cec5SDimitry Andric}
20910b57cec5SDimitry Andric
20920b57cec5SDimitry Andricclass sve_fp_2op_p_zds<bits<2> sz, bits<4> opc, string asm,
20930b57cec5SDimitry Andric                       ZPRRegOp zprty>
20940b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
20950b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
20960b57cec5SDimitry Andric  "",
20970b57cec5SDimitry Andric  []>, Sched<[]> {
20980b57cec5SDimitry Andric  bits<3> Pg;
20990b57cec5SDimitry Andric  bits<5> Zdn;
21000b57cec5SDimitry Andric  bits<5> Zm;
21010b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
21020b57cec5SDimitry Andric  let Inst{23-22} = sz;
21030b57cec5SDimitry Andric  let Inst{21-20} = 0b00;
21040b57cec5SDimitry Andric  let Inst{19-16} = opc;
21050b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
21060b57cec5SDimitry Andric  let Inst{12-10} = Pg;
21070b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
21080b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
21090b57cec5SDimitry Andric
21100b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
21115ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
21120b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
211306c3fb27SDimitry Andric  let hasSideEffects = 0;
211406c3fb27SDimitry Andric  let mayRaiseFPException = 1;
21150b57cec5SDimitry Andric}
21160b57cec5SDimitry Andric
21175f757f3fSDimitry Andricmulticlass sve2p1_bf_2op_p_zds<bits<4> opc, string asm, string Ps,
21185f757f3fSDimitry Andric                            SDPatternOperator op, DestructiveInstTypeEnum flags,
21195f757f3fSDimitry Andric                            string revname="", bit isReverseInstr=0> {
21205f757f3fSDimitry Andriclet DestructiveInstType = flags in {
21215f757f3fSDimitry Andric  def NAME : sve_fp_2op_p_zds<0b00, opc, asm, ZPR16>,
21225f757f3fSDimitry Andric           SVEPseudo2Instr<Ps, 1>, SVEInstr2Rev<NAME , revname , isReverseInstr>;
21235f757f3fSDimitry Andric  }
21245f757f3fSDimitry Andric
21255f757f3fSDimitry Andric  def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
21265f757f3fSDimitry Andric}
21275f757f3fSDimitry Andric
21285f757f3fSDimitry Andricmulticlass sve2p1_bf_bin_pred_zds<SDPatternOperator op> {
21295f757f3fSDimitry Andric  def _UNDEF : PredTwoOpPseudo<NAME, ZPR16, FalseLanesUndef>;
21305f757f3fSDimitry Andric
21315f757f3fSDimitry Andric  def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1,  nxv8bf16, nxv8bf16, !cast<Pseudo>(NAME # _UNDEF)>;
21325f757f3fSDimitry Andric}
21335f757f3fSDimitry Andric
21345f757f3fSDimitry Andricmulticlass sve2p1_bf_2op_p_zds_zeroing<SDPatternOperator op> {
21355f757f3fSDimitry Andric  def _ZERO : PredTwoOpPseudo<NAME, ZPR16, FalseLanesZero>;
21365f757f3fSDimitry Andric
21375f757f3fSDimitry Andric  def : SVE_3_Op_Pat_SelZero<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Pseudo>(NAME # _ZERO)>;
21385f757f3fSDimitry Andric}
21395f757f3fSDimitry Andric
21405ffd83dbSDimitry Andricmulticlass sve_fp_2op_p_zds<bits<4> opc, string asm, string Ps,
21415ffd83dbSDimitry Andric                            SDPatternOperator op, DestructiveInstTypeEnum flags,
21425ffd83dbSDimitry Andric                            string revname="", bit isReverseInstr=0> {
21435ffd83dbSDimitry Andric  let DestructiveInstType = flags in {
21445ffd83dbSDimitry Andric  def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>,
21455ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
21465ffd83dbSDimitry Andric  def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>,
21475ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
21485ffd83dbSDimitry Andric  def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>,
21495ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
21505ffd83dbSDimitry Andric  }
2151480093f4SDimitry Andric
2152480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2153480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2154480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
2155480093f4SDimitry Andric}
2156480093f4SDimitry Andric
2157480093f4SDimitry Andricmulticlass sve_fp_2op_p_zds_fscale<bits<4> opc, string asm,
2158480093f4SDimitry Andric                                   SDPatternOperator op> {
2159480093f4SDimitry Andric  def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>;
2160480093f4SDimitry Andric  def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>;
2161480093f4SDimitry Andric  def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>;
2162480093f4SDimitry Andric
2163480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
2164480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
2165480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
21660b57cec5SDimitry Andric}
21670b57cec5SDimitry Andric
21685ffd83dbSDimitry Andricmulticlass sve_fp_2op_p_zds_zeroing_hsd<SDPatternOperator op> {
216906c3fb27SDimitry Andric  def _H_ZERO : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesZero>;
217006c3fb27SDimitry Andric  def _S_ZERO : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesZero>;
217106c3fb27SDimitry Andric  def _D_ZERO : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesZero>;
21725ffd83dbSDimitry Andric
217306c3fb27SDimitry Andric  def : SVE_3_Op_Pat_SelZero<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Pseudo>(NAME # _H_ZERO)>;
217406c3fb27SDimitry Andric  def : SVE_3_Op_Pat_SelZero<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Pseudo>(NAME # _S_ZERO)>;
217506c3fb27SDimitry Andric  def : SVE_3_Op_Pat_SelZero<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Pseudo>(NAME # _D_ZERO)>;
21765ffd83dbSDimitry Andric}
21775ffd83dbSDimitry Andric
21780b57cec5SDimitry Andricclass sve_fp_ftmad<bits<2> sz, string asm, ZPRRegOp zprty>
2179349cc55cSDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, timm32_0_7:$imm3),
21800b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $Zm, $imm3",
21810b57cec5SDimitry Andric  "",
21820b57cec5SDimitry Andric  []>, Sched<[]> {
21830b57cec5SDimitry Andric  bits<5> Zdn;
21840b57cec5SDimitry Andric  bits<5> Zm;
21850b57cec5SDimitry Andric  bits<3> imm3;
21860b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
21870b57cec5SDimitry Andric  let Inst{23-22} = sz;
21880b57cec5SDimitry Andric  let Inst{21-19} = 0b010;
21890b57cec5SDimitry Andric  let Inst{18-16} = imm3;
21900b57cec5SDimitry Andric  let Inst{15-10} = 0b100000;
21910b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
21920b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
21930b57cec5SDimitry Andric
21940b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
21955ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
21960b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
219706c3fb27SDimitry Andric  let hasSideEffects = 0;
219806c3fb27SDimitry Andric  let mayRaiseFPException = 1;
21990b57cec5SDimitry Andric}
22000b57cec5SDimitry Andric
2201480093f4SDimitry Andricmulticlass sve_fp_ftmad<string asm, SDPatternOperator op> {
22020b57cec5SDimitry Andric  def _H : sve_fp_ftmad<0b01, asm, ZPR16>;
22030b57cec5SDimitry Andric  def _S : sve_fp_ftmad<0b10, asm, ZPR32>;
22040b57cec5SDimitry Andric  def _D : sve_fp_ftmad<0b11, asm, ZPR64>;
2205480093f4SDimitry Andric
2206349cc55cSDimitry Andric  def : Pat<(nxv8f16 (op (nxv8f16 ZPR16:$Zn), (nxv8f16 ZPR16:$Zm), (i32 timm32_0_7:$imm))),
2207349cc55cSDimitry Andric            (!cast<Instruction>(NAME # _H) ZPR16:$Zn, ZPR16:$Zm, timm32_0_7:$imm)>;
2208349cc55cSDimitry Andric  def : Pat<(nxv4f32 (op (nxv4f32 ZPR32:$Zn), (nxv4f32 ZPR32:$Zm), (i32 timm32_0_7:$imm))),
2209349cc55cSDimitry Andric            (!cast<Instruction>(NAME # _S) ZPR32:$Zn, ZPR32:$Zm, timm32_0_7:$imm)>;
2210349cc55cSDimitry Andric  def : Pat<(nxv2f64 (op (nxv2f64 ZPR64:$Zn), (nxv2f64 ZPR64:$Zm), (i32 timm32_0_7:$imm))),
2211349cc55cSDimitry Andric            (!cast<Instruction>(NAME # _D) ZPR64:$Zn, ZPR64:$Zm, timm32_0_7:$imm)>;
2212349cc55cSDimitry Andric}
2213349cc55cSDimitry Andric
2214349cc55cSDimitry Andricmulticlass sve_fp_2op_i_p_zds_hfd<Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator ir_op = null_frag> {
221506c3fb27SDimitry Andric  def _H_UNDEF : PredTwoOpImmPseudo<NAME # _H, ZPR16, imm_ty, FalseLanesUndef>;
221606c3fb27SDimitry Andric  def _S_UNDEF : PredTwoOpImmPseudo<NAME # _S, ZPR32, imm_ty, FalseLanesUndef>;
221706c3fb27SDimitry Andric  def _D_UNDEF : PredTwoOpImmPseudo<NAME # _D, ZPR64, imm_ty, FalseLanesUndef>;
2218349cc55cSDimitry Andric
221906c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, ir_op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_H_UNDEF")>;
222006c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, ir_op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_H_UNDEF")>;
222106c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv4f16, ir_op, nxv4i1, f16, A, 0, !cast<Instruction>(NAME # "_H_UNDEF")>;
222206c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv4f16, ir_op, nxv4i1, f16, B, 1, !cast<Instruction>(NAME # "_H_UNDEF")>;
222306c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv2f16, ir_op, nxv2i1, f16, A, 0, !cast<Instruction>(NAME # "_H_UNDEF")>;
222406c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv2f16, ir_op, nxv2i1, f16, B, 1, !cast<Instruction>(NAME # "_H_UNDEF")>;
222506c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, ir_op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_S_UNDEF")>;
222606c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, ir_op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_S_UNDEF")>;
222706c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv2f32, ir_op, nxv2i1, f32, A, 0, !cast<Instruction>(NAME # "_S_UNDEF")>;
222806c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv2f32, ir_op, nxv2i1, f32, B, 1, !cast<Instruction>(NAME # "_S_UNDEF")>;
222906c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, ir_op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_D_UNDEF")>;
223006c3fb27SDimitry Andric  def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, ir_op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_D_UNDEF")>;
2231349cc55cSDimitry Andric}
2232349cc55cSDimitry Andric
2233349cc55cSDimitry Andricmulticlass sve_fp_2op_i_p_zds_zeroing_hfd<Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator op> {
223406c3fb27SDimitry Andric  def _H_ZERO : PredTwoOpImmPseudo<NAME # _H, ZPR16, imm_ty, FalseLanesZero>;
223506c3fb27SDimitry Andric  def _S_ZERO : PredTwoOpImmPseudo<NAME # _S, ZPR32, imm_ty, FalseLanesZero>;
223606c3fb27SDimitry Andric  def _D_ZERO : PredTwoOpImmPseudo<NAME # _D, ZPR64, imm_ty, FalseLanesZero>;
2237349cc55cSDimitry Andric
2238349cc55cSDimitry Andric  let AddedComplexity = 2 in {
223906c3fb27SDimitry Andric    def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv8f16, op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_H_ZERO")>;
224006c3fb27SDimitry Andric    def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv8f16, op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_H_ZERO")>;
224106c3fb27SDimitry Andric    def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv4f32, op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_S_ZERO")>;
224206c3fb27SDimitry Andric    def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv4f32, op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_S_ZERO")>;
224306c3fb27SDimitry Andric    def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv2f64, op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_D_ZERO")>;
224406c3fb27SDimitry Andric    def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv2f64, op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_D_ZERO")>;
2245349cc55cSDimitry Andric  }
22460b57cec5SDimitry Andric}
22470b57cec5SDimitry Andric
22480b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
22490b57cec5SDimitry Andric// SVE Floating Point Arithmetic - Unpredicated Group
22500b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
22510b57cec5SDimitry Andric
2252480093f4SDimitry Andricclass sve_fp_3op_u_zd<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty>
22530b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins  zprty:$Zn, zprty:$Zm),
22540b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
22558bcb0991SDimitry Andric  "",
2256480093f4SDimitry Andric  []>, Sched<[]> {
22570b57cec5SDimitry Andric  bits<5> Zd;
22580b57cec5SDimitry Andric  bits<5> Zm;
22590b57cec5SDimitry Andric  bits<5> Zn;
22600b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
22610b57cec5SDimitry Andric  let Inst{23-22} = sz;
22620b57cec5SDimitry Andric  let Inst{21}    = 0b0;
22630b57cec5SDimitry Andric  let Inst{20-16} = Zm;
22640b57cec5SDimitry Andric  let Inst{15-13} = 0b000;
22650b57cec5SDimitry Andric  let Inst{12-10} = opc;
22660b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
22670b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
226806c3fb27SDimitry Andric
226906c3fb27SDimitry Andric  let hasSideEffects = 0;
227006c3fb27SDimitry Andric  let mayRaiseFPException = 1;
22710b57cec5SDimitry Andric}
22720b57cec5SDimitry Andric
2273*0fca6ea1SDimitry Andricmulticlass sve_fp_3op_u_zd<bits<3> opc, string asm, SDPatternOperator op> {
2274480093f4SDimitry Andric  def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>;
2275480093f4SDimitry Andric  def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>;
2276480093f4SDimitry Andric  def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>;
2277480093f4SDimitry Andric
2278480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2279480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2280480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
2281480093f4SDimitry Andric}
2282480093f4SDimitry Andric
2283*0fca6ea1SDimitry Andricmulticlass sve2p1_bf_3op_u_zd<bits<3> opc, string asm, SDPatternOperator op> {
2284*0fca6ea1SDimitry Andric  def NAME : sve_fp_3op_u_zd<0b00, opc, asm, ZPR16>;
22855f757f3fSDimitry Andric
2286*0fca6ea1SDimitry Andric  def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
22875f757f3fSDimitry Andric}
22885f757f3fSDimitry Andric
2289480093f4SDimitry Andricmulticlass sve_fp_3op_u_zd_ftsmul<bits<3> opc, string asm, SDPatternOperator op> {
2290480093f4SDimitry Andric  def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>;
2291480093f4SDimitry Andric  def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>;
2292480093f4SDimitry Andric  def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>;
2293480093f4SDimitry Andric
2294480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
2295480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
2296480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
22970b57cec5SDimitry Andric}
22980b57cec5SDimitry Andric
22990b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
23000b57cec5SDimitry Andric// SVE Floating Point Fused Multiply-Add Group
23010b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
23020b57cec5SDimitry Andric
23030b57cec5SDimitry Andricclass sve_fp_3op_p_zds_a<bits<2> sz, bits<2> opc, string asm, ZPRRegOp zprty>
23040b57cec5SDimitry Andric: I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
23050b57cec5SDimitry Andric  asm, "\t$Zda, $Pg/m, $Zn, $Zm",
23060b57cec5SDimitry Andric  "",
23070b57cec5SDimitry Andric  []>, Sched<[]> {
23080b57cec5SDimitry Andric  bits<3> Pg;
23090b57cec5SDimitry Andric  bits<5> Zda;
23100b57cec5SDimitry Andric  bits<5> Zm;
23110b57cec5SDimitry Andric  bits<5> Zn;
23120b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
23130b57cec5SDimitry Andric  let Inst{23-22} = sz;
23140b57cec5SDimitry Andric  let Inst{21}    = 0b1;
23150b57cec5SDimitry Andric  let Inst{20-16} = Zm;
23160b57cec5SDimitry Andric  let Inst{15}    = 0b0;
23170b57cec5SDimitry Andric  let Inst{14-13} = opc;
23180b57cec5SDimitry Andric  let Inst{12-10} = Pg;
23190b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
23200b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
23210b57cec5SDimitry Andric
23220b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
23230b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
2324bdd1243dSDimitry Andric  let DestructiveInstType = DestructiveTernaryCommWithRev;
232506c3fb27SDimitry Andric  let hasSideEffects = 0;
232606c3fb27SDimitry Andric  let mayRaiseFPException = 1;
23270b57cec5SDimitry Andric}
23280b57cec5SDimitry Andric
2329fe6060f1SDimitry Andricmulticlass sve_fp_3op_p_zds_a<bits<2> opc, string asm, string Ps,
2330fe6060f1SDimitry Andric                              SDPatternOperator op, string revname,
2331fe6060f1SDimitry Andric                              bit isReverseInstr=0> {
2332fe6060f1SDimitry Andric  def _H : sve_fp_3op_p_zds_a<0b01, opc, asm, ZPR16>,
2333fe6060f1SDimitry Andric           SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
2334fe6060f1SDimitry Andric  def _S : sve_fp_3op_p_zds_a<0b10, opc, asm, ZPR32>,
2335fe6060f1SDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
2336fe6060f1SDimitry Andric  def _D : sve_fp_3op_p_zds_a<0b11, opc, asm, ZPR64>,
2337fe6060f1SDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
2338480093f4SDimitry Andric
2339480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
23408a4dda33SDimitry Andric  def : SVE_4_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _H)>;
23418a4dda33SDimitry Andric  def : SVE_4_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _H)>;
2342480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
23438a4dda33SDimitry Andric  def : SVE_4_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _S)>;
2344480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
23450b57cec5SDimitry Andric}
23460b57cec5SDimitry Andric
23475f757f3fSDimitry Andricmulticlass sve_fp_3op_p_zds_a_bf<bits<2> opc, string asm, string Ps,
23485f757f3fSDimitry Andric                              SDPatternOperator op> {
23495f757f3fSDimitry Andric  def NAME : sve_fp_3op_p_zds_a<0b00, opc, asm, ZPR16>,
23505f757f3fSDimitry Andric           SVEPseudo2Instr<Ps, 1>, SVEInstr2Rev<NAME, "", 0>;
23515f757f3fSDimitry Andric
23525f757f3fSDimitry Andric  def : SVE_4_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
23535f757f3fSDimitry Andric}
23545f757f3fSDimitry Andric
23550b57cec5SDimitry Andricclass sve_fp_3op_p_zds_b<bits<2> sz, bits<2> opc, string asm,
23560b57cec5SDimitry Andric                         ZPRRegOp zprty>
23570b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
23580b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $Zm, $Za",
23590b57cec5SDimitry Andric  "",
23600b57cec5SDimitry Andric  []>, Sched<[]> {
23610b57cec5SDimitry Andric  bits<3> Pg;
23620b57cec5SDimitry Andric  bits<5> Za;
23630b57cec5SDimitry Andric  bits<5> Zdn;
23640b57cec5SDimitry Andric  bits<5> Zm;
23650b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
23660b57cec5SDimitry Andric  let Inst{23-22} = sz;
23670b57cec5SDimitry Andric  let Inst{21}    = 0b1;
23680b57cec5SDimitry Andric  let Inst{20-16} = Za;
23690b57cec5SDimitry Andric  let Inst{15}    = 0b1;
23700b57cec5SDimitry Andric  let Inst{14-13} = opc;
23710b57cec5SDimitry Andric  let Inst{12-10} = Pg;
23720b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
23730b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
23740b57cec5SDimitry Andric
23750b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
23765ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
23770b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
237806c3fb27SDimitry Andric  let hasSideEffects = 0;
237906c3fb27SDimitry Andric  let mayRaiseFPException = 1;
23800b57cec5SDimitry Andric}
23810b57cec5SDimitry Andric
2382fe6060f1SDimitry Andricmulticlass sve_fp_3op_p_zds_b<bits<2> opc, string asm, SDPatternOperator op,
2383fe6060f1SDimitry Andric                              string revname, bit isReverseInstr> {
2384fe6060f1SDimitry Andric  def _H : sve_fp_3op_p_zds_b<0b01, opc, asm, ZPR16>,
2385fe6060f1SDimitry Andric           SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
2386fe6060f1SDimitry Andric  def _S : sve_fp_3op_p_zds_b<0b10, opc, asm, ZPR32>,
2387fe6060f1SDimitry Andric           SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
2388fe6060f1SDimitry Andric  def _D : sve_fp_3op_p_zds_b<0b11, opc, asm, ZPR64>,
2389fe6060f1SDimitry Andric           SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
2390480093f4SDimitry Andric
2391480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2392480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2393480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
23940b57cec5SDimitry Andric}
23950b57cec5SDimitry Andric
23960b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
23970b57cec5SDimitry Andric// SVE Floating Point Multiply-Add - Indexed Group
23980b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
23990b57cec5SDimitry Andric
2400bdd1243dSDimitry Andricclass sve_fp_fma_by_indexed_elem<bits<2> sz, bits<2> opc, string asm,
24010b57cec5SDimitry Andric                                 ZPRRegOp zprty1,
24020b57cec5SDimitry Andric                                 ZPRRegOp zprty2, Operand itype>
24030b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty1:$Zn, zprty2:$Zm, itype:$iop),
24040b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
24050b57cec5SDimitry Andric  bits<5> Zda;
24060b57cec5SDimitry Andric  bits<5> Zn;
24070b57cec5SDimitry Andric  let Inst{31-24} = 0b01100100;
24080b57cec5SDimitry Andric  let Inst{23-22} = sz;
24090b57cec5SDimitry Andric  let Inst{21}    = 0b1;
2410bdd1243dSDimitry Andric  let Inst{15-12} = 0b0000;
2411bdd1243dSDimitry Andric  let Inst{11-10} = opc;
24120b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
24130b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
24140b57cec5SDimitry Andric
24150b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
24165ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
24170b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
241806c3fb27SDimitry Andric  let hasSideEffects = 0;
241906c3fb27SDimitry Andric  let mayRaiseFPException = 1;
24200b57cec5SDimitry Andric}
24210b57cec5SDimitry Andric
24225f757f3fSDimitry Andricmulticlass sve2p1_fp_bfma_by_indexed_elem<string asm, bits<2> opc, SDPatternOperator op> {
2423bdd1243dSDimitry Andric  def NAME : sve_fp_fma_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR3b16,
2424bdd1243dSDimitry Andric                                         VectorIndexH32b> {
2425bdd1243dSDimitry Andric    bits<3> Zm;
2426bdd1243dSDimitry Andric    bits<3> iop;
2427bdd1243dSDimitry Andric    let Inst{22} = iop{2};
2428bdd1243dSDimitry Andric    let Inst{20-19} = iop{1-0};
2429bdd1243dSDimitry Andric    let Inst{18-16} = Zm;
2430bdd1243dSDimitry Andric  }
24315f757f3fSDimitry Andric  def : Pat<(nxv8bf16 (op nxv8bf16:$op1, nxv8bf16:$op2, nxv8bf16:$op3, (i32 VectorIndexH32b_timm:$idx))),
24325f757f3fSDimitry Andric            (!cast<Instruction>(NAME) $op1, $op2, $op3, VectorIndexH32b_timm:$idx)>;
2433bdd1243dSDimitry Andric}
2434bdd1243dSDimitry Andric
2435bdd1243dSDimitry Andricmulticlass sve_fp_fma_by_indexed_elem<bits<2> opc, string asm,
2436480093f4SDimitry Andric                                      SDPatternOperator op> {
2437480093f4SDimitry Andric  def _H : sve_fp_fma_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
24380b57cec5SDimitry Andric    bits<3> Zm;
24390b57cec5SDimitry Andric    bits<3> iop;
24400b57cec5SDimitry Andric    let Inst{22} = iop{2};
24410b57cec5SDimitry Andric    let Inst{20-19} = iop{1-0};
24420b57cec5SDimitry Andric    let Inst{18-16} = Zm;
24430b57cec5SDimitry Andric  }
2444480093f4SDimitry Andric  def _S : sve_fp_fma_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR3b32, VectorIndexS32b> {
24450b57cec5SDimitry Andric    bits<3> Zm;
24460b57cec5SDimitry Andric    bits<2> iop;
24470b57cec5SDimitry Andric    let Inst{20-19} = iop;
24480b57cec5SDimitry Andric    let Inst{18-16} = Zm;
24490b57cec5SDimitry Andric  }
2450480093f4SDimitry Andric  def _D : sve_fp_fma_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR4b64, VectorIndexD32b> {
24510b57cec5SDimitry Andric    bits<4> Zm;
24520b57cec5SDimitry Andric    bit iop;
24530b57cec5SDimitry Andric    let Inst{20} = iop;
24540b57cec5SDimitry Andric    let Inst{19-16} = Zm;
24550b57cec5SDimitry Andric  }
2456480093f4SDimitry Andric
24575ffd83dbSDimitry Andric  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b_timm:$idx))),
24585ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b_timm:$idx)>;
24595ffd83dbSDimitry Andric  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b_timm:$idx))),
24605ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx)>;
24615ffd83dbSDimitry Andric  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b_timm:$idx))),
24625ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx)>;
24630b57cec5SDimitry Andric}
24640b57cec5SDimitry Andric
24650b57cec5SDimitry Andric
24660b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
24670b57cec5SDimitry Andric// SVE Floating Point Multiply - Indexed Group
24680b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
24690b57cec5SDimitry Andric
2470bdd1243dSDimitry Andricclass sve_fp_fmul_by_indexed_elem<bits<2> sz, bit o2, string asm, ZPRRegOp zprty,
24710b57cec5SDimitry Andric                                  ZPRRegOp zprty2, Operand itype>
24720b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty2:$Zm, itype:$iop),
24730b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
24740b57cec5SDimitry Andric  bits<5> Zd;
24750b57cec5SDimitry Andric  bits<5> Zn;
24760b57cec5SDimitry Andric  let Inst{31-24} = 0b01100100;
24770b57cec5SDimitry Andric  let Inst{23-22} = sz;
24780b57cec5SDimitry Andric  let Inst{21}    = 0b1;
2479bdd1243dSDimitry Andric  let Inst{15-12} = 0b0010;
2480bdd1243dSDimitry Andric  let Inst{11}    = o2;
2481bdd1243dSDimitry Andric  let Inst{10}    = 0b0;
24820b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
24830b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
248406c3fb27SDimitry Andric
248506c3fb27SDimitry Andric  let hasSideEffects = 0;
248606c3fb27SDimitry Andric  let mayRaiseFPException = 1;
24870b57cec5SDimitry Andric}
24880b57cec5SDimitry Andric
24895f757f3fSDimitry Andricmulticlass sve2p1_fp_bfmul_by_indexed_elem<string asm, SDPatternOperator ir_intrinsic> {
2490bdd1243dSDimitry Andric  def NAME : sve_fp_fmul_by_indexed_elem<{0, ?}, 0b1, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
24910b57cec5SDimitry Andric    bits<3> Zm;
24920b57cec5SDimitry Andric    bits<3> iop;
24930b57cec5SDimitry Andric    let Inst{22} = iop{2};
24940b57cec5SDimitry Andric    let Inst{20-19} = iop{1-0};
24950b57cec5SDimitry Andric    let Inst{18-16} = Zm;
24960b57cec5SDimitry Andric  }
24975f757f3fSDimitry Andric  def : Pat <(nxv8bf16 (ir_intrinsic nxv8bf16:$Op1, nxv8bf16:$Op2, (i32 VectorIndexH32b_timm:$idx))),
24985f757f3fSDimitry Andric             (!cast<Instruction>(NAME) $Op1, $Op2, VectorIndexH32b_timm:$idx)>;
2499bdd1243dSDimitry Andric}
2500bdd1243dSDimitry Andric
2501bdd1243dSDimitry Andricmulticlass sve_fp_fmul_by_indexed_elem<string asm, SDPatternOperator op> {
2502bdd1243dSDimitry Andric  def _H : sve_fp_fmul_by_indexed_elem<{0, ?}, 0b0, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
2503bdd1243dSDimitry Andric    bits<3> Zm;
2504bdd1243dSDimitry Andric    bits<3> iop;
2505bdd1243dSDimitry Andric    let Inst{22} = iop{2};
2506bdd1243dSDimitry Andric    let Inst{20-19} = iop{1-0};
2507bdd1243dSDimitry Andric    let Inst{18-16} = Zm;
2508bdd1243dSDimitry Andric  }
2509bdd1243dSDimitry Andric  def _S : sve_fp_fmul_by_indexed_elem<0b10, 0b0, asm, ZPR32, ZPR3b32, VectorIndexS32b> {
25100b57cec5SDimitry Andric    bits<3> Zm;
25110b57cec5SDimitry Andric    bits<2> iop;
25120b57cec5SDimitry Andric    let Inst{20-19} = iop;
25130b57cec5SDimitry Andric    let Inst{18-16} = Zm;
25140b57cec5SDimitry Andric  }
2515bdd1243dSDimitry Andric  def _D : sve_fp_fmul_by_indexed_elem<0b11, 0b0, asm, ZPR64, ZPR4b64, VectorIndexD32b> {
25160b57cec5SDimitry Andric    bits<4> Zm;
25170b57cec5SDimitry Andric    bit iop;
25180b57cec5SDimitry Andric    let Inst{20} = iop;
25190b57cec5SDimitry Andric    let Inst{19-16} = Zm;
25200b57cec5SDimitry Andric  }
2521480093f4SDimitry Andric
25225ffd83dbSDimitry Andric  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b_timm:$idx))),
25235ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _H) $Op1, $Op2, VectorIndexH32b_timm:$idx)>;
25245ffd83dbSDimitry Andric  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b_timm:$idx))),
25255ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _S) $Op1, $Op2, VectorIndexS32b_timm:$idx)>;
25265ffd83dbSDimitry Andric  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b_timm:$idx))),
25275ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _D) $Op1, $Op2, VectorIndexD32b_timm:$idx)>;
25280b57cec5SDimitry Andric}
25290b57cec5SDimitry Andric
25300b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
25310b57cec5SDimitry Andric// SVE Floating Point Complex Multiply-Add Group
25320b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
25330b57cec5SDimitry Andric
25340b57cec5SDimitry Andricclass sve_fp_fcmla<bits<2> sz, string asm, ZPRRegOp zprty>
25350b57cec5SDimitry Andric: I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm,
25360b57cec5SDimitry Andric                        complexrotateop:$imm),
25370b57cec5SDimitry Andric  asm, "\t$Zda, $Pg/m, $Zn, $Zm, $imm",
25380b57cec5SDimitry Andric  "", []>, Sched<[]> {
25390b57cec5SDimitry Andric  bits<5> Zda;
25400b57cec5SDimitry Andric  bits<3> Pg;
25410b57cec5SDimitry Andric  bits<5> Zn;
25420b57cec5SDimitry Andric  bits<5> Zm;
25430b57cec5SDimitry Andric  bits<2> imm;
25440b57cec5SDimitry Andric  let Inst{31-24} = 0b01100100;
25450b57cec5SDimitry Andric  let Inst{23-22} = sz;
25460b57cec5SDimitry Andric  let Inst{21}    = 0;
25470b57cec5SDimitry Andric  let Inst{20-16} = Zm;
25480b57cec5SDimitry Andric  let Inst{15}    = 0;
25490b57cec5SDimitry Andric  let Inst{14-13} = imm;
25500b57cec5SDimitry Andric  let Inst{12-10} = Pg;
25510b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
25520b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
25530b57cec5SDimitry Andric
25540b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
25555ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
25560b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
255706c3fb27SDimitry Andric  let hasSideEffects = 0;
255806c3fb27SDimitry Andric  let mayRaiseFPException = 1;
25590b57cec5SDimitry Andric}
25600b57cec5SDimitry Andric
2561480093f4SDimitry Andricmulticlass sve_fp_fcmla<string asm, SDPatternOperator op> {
25620b57cec5SDimitry Andric  def _H : sve_fp_fcmla<0b01, asm, ZPR16>;
25630b57cec5SDimitry Andric  def _S : sve_fp_fcmla<0b10, asm, ZPR32>;
25640b57cec5SDimitry Andric  def _D : sve_fp_fcmla<0b11, asm, ZPR64>;
2565480093f4SDimitry Andric
2566480093f4SDimitry Andric  def : Pat<(nxv8f16 (op nxv8i1:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, nxv8f16:$Op4, (i32 complexrotateop:$imm))),
2567480093f4SDimitry Andric            (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
2568480093f4SDimitry Andric  def : Pat<(nxv4f32 (op nxv4i1:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, nxv4f32:$Op4, (i32 complexrotateop:$imm))),
2569480093f4SDimitry Andric            (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
2570480093f4SDimitry Andric  def : Pat<(nxv2f64 (op nxv2i1:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, nxv2f64:$Op4, (i32 complexrotateop:$imm))),
2571480093f4SDimitry Andric            (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
25720b57cec5SDimitry Andric}
25730b57cec5SDimitry Andric
25740b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
25750b57cec5SDimitry Andric// SVE Floating Point Complex Multiply-Add - Indexed Group
25760b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
25770b57cec5SDimitry Andric
25780b57cec5SDimitry Andricclass sve_fp_fcmla_by_indexed_elem<bits<2> sz, string asm,
25790b57cec5SDimitry Andric                                   ZPRRegOp zprty,
25800b57cec5SDimitry Andric                                   ZPRRegOp zprty2, Operand itype>
25810b57cec5SDimitry Andric: I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty2:$Zm, itype:$iop,
25820b57cec5SDimitry Andric                        complexrotateop:$imm),
25830b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm$iop, $imm",
25840b57cec5SDimitry Andric  "", []>, Sched<[]> {
25850b57cec5SDimitry Andric  bits<5> Zda;
25860b57cec5SDimitry Andric  bits<5> Zn;
25870b57cec5SDimitry Andric  bits<2> imm;
25880b57cec5SDimitry Andric  let Inst{31-24} = 0b01100100;
25890b57cec5SDimitry Andric  let Inst{23-22} = sz;
25900b57cec5SDimitry Andric  let Inst{21}    = 0b1;
25910b57cec5SDimitry Andric  let Inst{15-12} = 0b0001;
25920b57cec5SDimitry Andric  let Inst{11-10} = imm;
25930b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
25940b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
25950b57cec5SDimitry Andric
25960b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
25975ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
25980b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
259906c3fb27SDimitry Andric  let hasSideEffects = 0;
260006c3fb27SDimitry Andric  let mayRaiseFPException = 1;
26010b57cec5SDimitry Andric}
26020b57cec5SDimitry Andric
2603480093f4SDimitry Andricmulticlass sve_fp_fcmla_by_indexed_elem<string asm, SDPatternOperator op> {
2604480093f4SDimitry Andric  def _H : sve_fp_fcmla_by_indexed_elem<0b10, asm, ZPR16, ZPR3b16, VectorIndexS32b> {
26050b57cec5SDimitry Andric    bits<3> Zm;
26060b57cec5SDimitry Andric    bits<2> iop;
26070b57cec5SDimitry Andric    let Inst{20-19} = iop;
26080b57cec5SDimitry Andric    let Inst{18-16} = Zm;
26090b57cec5SDimitry Andric  }
2610480093f4SDimitry Andric  def _S : sve_fp_fcmla_by_indexed_elem<0b11, asm, ZPR32, ZPR4b32, VectorIndexD32b> {
26110b57cec5SDimitry Andric    bits<4> Zm;
26120b57cec5SDimitry Andric    bits<1> iop;
26130b57cec5SDimitry Andric    let Inst{20} = iop;
26140b57cec5SDimitry Andric    let Inst{19-16} = Zm;
26150b57cec5SDimitry Andric  }
2616480093f4SDimitry Andric
26175ffd83dbSDimitry Andric  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
26185ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
26195ffd83dbSDimitry Andric  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
26205ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
26210b57cec5SDimitry Andric}
26220b57cec5SDimitry Andric
26230b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
26240b57cec5SDimitry Andric// SVE Floating Point Complex Addition Group
26250b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
26260b57cec5SDimitry Andric
26270b57cec5SDimitry Andricclass sve_fp_fcadd<bits<2> sz, string asm, ZPRRegOp zprty>
26280b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm,
26290b57cec5SDimitry Andric                        complexrotateopodd:$imm),
26300b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm, $imm",
26310b57cec5SDimitry Andric  "",
26320b57cec5SDimitry Andric  []>, Sched<[]> {
26330b57cec5SDimitry Andric  bits<5> Zdn;
26340b57cec5SDimitry Andric  bits<5> Zm;
26350b57cec5SDimitry Andric  bits<3> Pg;
26360b57cec5SDimitry Andric  bit imm;
26370b57cec5SDimitry Andric  let Inst{31-24} = 0b01100100;
26380b57cec5SDimitry Andric  let Inst{23-22} = sz;
26390b57cec5SDimitry Andric  let Inst{21-17} = 0;
26400b57cec5SDimitry Andric  let Inst{16}    = imm;
26410b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
26420b57cec5SDimitry Andric  let Inst{12-10} = Pg;
26430b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
26440b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
26450b57cec5SDimitry Andric
26460b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
26475ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
26480b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
264906c3fb27SDimitry Andric  let hasSideEffects = 0;
265006c3fb27SDimitry Andric  let mayRaiseFPException = 1;
26510b57cec5SDimitry Andric}
26520b57cec5SDimitry Andric
2653480093f4SDimitry Andricmulticlass sve_fp_fcadd<string asm, SDPatternOperator op> {
26540b57cec5SDimitry Andric  def _H : sve_fp_fcadd<0b01, asm, ZPR16>;
26550b57cec5SDimitry Andric  def _S : sve_fp_fcadd<0b10, asm, ZPR32>;
26560b57cec5SDimitry Andric  def _D : sve_fp_fcadd<0b11, asm, ZPR64>;
2657480093f4SDimitry Andric
2658480093f4SDimitry Andric  def : Pat<(nxv8f16 (op nxv8i1:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 complexrotateopodd:$imm))),
2659480093f4SDimitry Andric            (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
2660480093f4SDimitry Andric  def : Pat<(nxv4f32 (op nxv4i1:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 complexrotateopodd:$imm))),
2661480093f4SDimitry Andric            (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
2662480093f4SDimitry Andric  def : Pat<(nxv2f64 (op nxv2i1:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 complexrotateopodd:$imm))),
2663480093f4SDimitry Andric            (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
26640b57cec5SDimitry Andric}
26650b57cec5SDimitry Andric
26660b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
26670b57cec5SDimitry Andric// SVE2 Floating Point Convert Group
26680b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
26690b57cec5SDimitry Andric
26700b57cec5SDimitry Andricclass sve2_fp_convert_precision<bits<4> opc, string asm,
26710b57cec5SDimitry Andric                                ZPRRegOp zprty1, ZPRRegOp zprty2>
26720b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, PPR3bAny:$Pg, zprty2:$Zn),
26730b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/m, $Zn",
26740b57cec5SDimitry Andric  "",
26750b57cec5SDimitry Andric  []>, Sched<[]> {
26760b57cec5SDimitry Andric  bits<5> Zd;
26770b57cec5SDimitry Andric  bits<5> Zn;
26780b57cec5SDimitry Andric  bits<3> Pg;
26790b57cec5SDimitry Andric  let Inst{31-24} = 0b01100100;
26800b57cec5SDimitry Andric  let Inst{23-22} = opc{3-2};
26810b57cec5SDimitry Andric  let Inst{21-18} = 0b0010;
26820b57cec5SDimitry Andric  let Inst{17-16} = opc{1-0};
26830b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
26840b57cec5SDimitry Andric  let Inst{12-10} = Pg;
26850b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
26860b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
26870b57cec5SDimitry Andric
26880b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
268906c3fb27SDimitry Andric  let hasSideEffects = 0;
269006c3fb27SDimitry Andric  let mayRaiseFPException = 1;
26910b57cec5SDimitry Andric}
26920b57cec5SDimitry Andric
2693480093f4SDimitry Andricmulticlass sve2_fp_convert_down_narrow<string asm, string op> {
26940b57cec5SDimitry Andric  def _StoH : sve2_fp_convert_precision<0b1000, asm, ZPR16, ZPR32>;
26950b57cec5SDimitry Andric  def _DtoS : sve2_fp_convert_precision<0b1110, asm, ZPR32, ZPR64>;
2696480093f4SDimitry Andric
26975ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, !cast<SDPatternOperator>(op # _f16f32), nxv8f16, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _StoH)>;
26985ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
26990b57cec5SDimitry Andric}
27000b57cec5SDimitry Andric
2701480093f4SDimitry Andricmulticlass sve2_fp_convert_up_long<string asm, string op> {
27020b57cec5SDimitry Andric  def _HtoS : sve2_fp_convert_precision<0b1001, asm, ZPR32, ZPR16>;
27030b57cec5SDimitry Andric  def _StoD : sve2_fp_convert_precision<0b1111, asm, ZPR64, ZPR32>;
2704480093f4SDimitry Andric
27055ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f16), nxv4f32, nxv4i1, nxv8f16, !cast<Instruction>(NAME # _HtoS)>;
27065ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, !cast<SDPatternOperator>(op # _f64f32), nxv2f64, nxv2i1, nxv4f32, !cast<Instruction>(NAME # _StoD)>;
27070b57cec5SDimitry Andric}
27080b57cec5SDimitry Andric
2709480093f4SDimitry Andricmulticlass sve2_fp_convert_down_odd_rounding_top<string asm, string op> {
27100b57cec5SDimitry Andric  def _DtoS : sve2_fp_convert_precision<0b0010, asm, ZPR32, ZPR64>;
2711480093f4SDimitry Andric
27125ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
27130b57cec5SDimitry Andric}
27140b57cec5SDimitry Andric
27150b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
27160b57cec5SDimitry Andric// SVE2 Floating Point Pairwise Group
27170b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
27180b57cec5SDimitry Andric
27190b57cec5SDimitry Andricclass sve2_fp_pairwise_pred<bits<2> sz, bits<3> opc, string asm,
27200b57cec5SDimitry Andric                            ZPRRegOp zprty>
27210b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
27220b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
27230b57cec5SDimitry Andric  "",
27240b57cec5SDimitry Andric  []>, Sched<[]> {
27250b57cec5SDimitry Andric  bits<3> Pg;
27260b57cec5SDimitry Andric  bits<5> Zm;
27270b57cec5SDimitry Andric  bits<5> Zdn;
27280b57cec5SDimitry Andric  let Inst{31-24} = 0b01100100;
27290b57cec5SDimitry Andric  let Inst{23-22} = sz;
27300b57cec5SDimitry Andric  let Inst{21-19} = 0b010;
27310b57cec5SDimitry Andric  let Inst{18-16} = opc;
27320b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
27330b57cec5SDimitry Andric  let Inst{12-10} = Pg;
27340b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
27350b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
27360b57cec5SDimitry Andric
27370b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
27385ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
27390b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
274006c3fb27SDimitry Andric  let hasSideEffects = 0;
274106c3fb27SDimitry Andric  let mayRaiseFPException = 1;
27420b57cec5SDimitry Andric}
27430b57cec5SDimitry Andric
2744e8d8bef9SDimitry Andricmulticlass sve2_fp_pairwise_pred<bits<3> opc, string asm,
2745e8d8bef9SDimitry Andric                                 SDPatternOperator op> {
27460b57cec5SDimitry Andric  def _H : sve2_fp_pairwise_pred<0b01, opc, asm, ZPR16>;
27470b57cec5SDimitry Andric  def _S : sve2_fp_pairwise_pred<0b10, opc, asm, ZPR32>;
27480b57cec5SDimitry Andric  def _D : sve2_fp_pairwise_pred<0b11, opc, asm, ZPR64>;
2749480093f4SDimitry Andric
2750480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2751480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2752480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
27530b57cec5SDimitry Andric}
27540b57cec5SDimitry Andric
27550b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
27560b57cec5SDimitry Andric// SVE2 Floating Point Widening Multiply-Add - Indexed Group
27570b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
27580b57cec5SDimitry Andric
2759bdd1243dSDimitry Andricclass sve2_fp_mla_long_by_indexed_elem<bits<3> opc, string asm>
27600b57cec5SDimitry Andric: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm,
2761480093f4SDimitry Andric                        VectorIndexH32b:$iop),
27620b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm$iop",
27630b57cec5SDimitry Andric  "",
27640b57cec5SDimitry Andric  []>, Sched<[]> {
27650b57cec5SDimitry Andric  bits<5> Zda;
27660b57cec5SDimitry Andric  bits<5> Zn;
27670b57cec5SDimitry Andric  bits<3> Zm;
27680b57cec5SDimitry Andric  bits<3> iop;
2769bdd1243dSDimitry Andric  let Inst{31-23} = 0b011001001;
2770bdd1243dSDimitry Andric  let Inst{22}    = opc{2};
2771bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
27720b57cec5SDimitry Andric  let Inst{20-19} = iop{2-1};
27730b57cec5SDimitry Andric  let Inst{18-16} = Zm;
27740b57cec5SDimitry Andric  let Inst{15-14} = 0b01;
27750b57cec5SDimitry Andric  let Inst{13}    = opc{1};
27760b57cec5SDimitry Andric  let Inst{12}    = 0b0;
27770b57cec5SDimitry Andric  let Inst{11}    = iop{0};
27780b57cec5SDimitry Andric  let Inst{10}    = opc{0};
27790b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
27800b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
27810b57cec5SDimitry Andric
27820b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
27835ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
27840b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
278506c3fb27SDimitry Andric  let hasSideEffects = 0;
278606c3fb27SDimitry Andric  let mayRaiseFPException = 1;
27870b57cec5SDimitry Andric}
27880b57cec5SDimitry Andric
2789bdd1243dSDimitry Andricmulticlass sve2_fp_mla_long_by_indexed_elem<bits<3> opc, string asm,
2790bdd1243dSDimitry Andric                                            ValueType OutVT, ValueType InVT,
2791480093f4SDimitry Andric                                            SDPatternOperator op> {
2792480093f4SDimitry Andric  def NAME : sve2_fp_mla_long_by_indexed_elem<opc, asm>;
2793bdd1243dSDimitry Andric  def : SVE_4_Op_Imm_Pat<OutVT, op, OutVT, InVT, InVT, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME)>;
2794480093f4SDimitry Andric}
2795480093f4SDimitry Andric
27960b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
27970b57cec5SDimitry Andric// SVE2 Floating Point Widening Multiply-Add Group
27980b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
27990b57cec5SDimitry Andric
2800bdd1243dSDimitry Andricclass sve2_fp_mla_long<bits<3> opc, string asm>
28010b57cec5SDimitry Andric: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
28020b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm",
28030b57cec5SDimitry Andric  "",
28040b57cec5SDimitry Andric  []>, Sched<[]> {
28050b57cec5SDimitry Andric  bits<5> Zda;
28060b57cec5SDimitry Andric  bits<5> Zn;
28070b57cec5SDimitry Andric  bits<5> Zm;
2808bdd1243dSDimitry Andric  let Inst{31-23} = 0b011001001;
2809bdd1243dSDimitry Andric  let Inst{22}    = opc{2};
2810bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
28110b57cec5SDimitry Andric  let Inst{20-16} = Zm;
28120b57cec5SDimitry Andric  let Inst{15-14} = 0b10;
28130b57cec5SDimitry Andric  let Inst{13}    = opc{1};
28140b57cec5SDimitry Andric  let Inst{12-11} = 0b00;
28150b57cec5SDimitry Andric  let Inst{10}    = opc{0};
28160b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
28170b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
28180b57cec5SDimitry Andric
28190b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
28205ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
28210b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
282206c3fb27SDimitry Andric  let hasSideEffects = 0;
282306c3fb27SDimitry Andric  let mayRaiseFPException = 1;
28240b57cec5SDimitry Andric}
28250b57cec5SDimitry Andric
2826bdd1243dSDimitry Andricmulticlass sve2_fp_mla_long<bits<3> opc, string asm, ValueType OutVT,
2827bdd1243dSDimitry Andric                            ValueType InVT, SDPatternOperator op> {
2828480093f4SDimitry Andric  def NAME : sve2_fp_mla_long<opc, asm>;
2829bdd1243dSDimitry Andric  def : SVE_3_Op_Pat<OutVT, op, OutVT, InVT, InVT, !cast<Instruction>(NAME)>;
2830480093f4SDimitry Andric}
2831480093f4SDimitry Andric
28320b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
28330b57cec5SDimitry Andric// SVE Stack Allocation Group
28340b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
28350b57cec5SDimitry Andric
283681ad6265SDimitry Andricclass sve_int_arith_vl<bit opc, string asm, bit streaming_sve = 0b0>
28370b57cec5SDimitry Andric: I<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, simm6_32b:$imm6),
28380b57cec5SDimitry Andric  asm, "\t$Rd, $Rn, $imm6",
28390b57cec5SDimitry Andric  "",
28400b57cec5SDimitry Andric  []>, Sched<[]> {
28410b57cec5SDimitry Andric  bits<5> Rd;
28420b57cec5SDimitry Andric  bits<5> Rn;
28430b57cec5SDimitry Andric  bits<6> imm6;
28440b57cec5SDimitry Andric  let Inst{31-23} = 0b000001000;
28450b57cec5SDimitry Andric  let Inst{22}    = opc;
28460b57cec5SDimitry Andric  let Inst{21}    = 0b1;
28470b57cec5SDimitry Andric  let Inst{20-16} = Rn;
284881ad6265SDimitry Andric  let Inst{15-12} = 0b0101;
284981ad6265SDimitry Andric  let Inst{11}    = streaming_sve;
28500b57cec5SDimitry Andric  let Inst{10-5}  = imm6;
28510b57cec5SDimitry Andric  let Inst{4-0}   = Rd;
285206c3fb27SDimitry Andric
285306c3fb27SDimitry Andric  let hasSideEffects = 0;
2854*0fca6ea1SDimitry Andric  let Uses = [VG];
28550b57cec5SDimitry Andric}
28560b57cec5SDimitry Andric
285781ad6265SDimitry Andricclass sve_int_read_vl_a<bit op, bits<5> opc2, string asm, bit streaming_sve = 0b0>
28580b57cec5SDimitry Andric: I<(outs GPR64:$Rd), (ins simm6_32b:$imm6),
28590b57cec5SDimitry Andric  asm, "\t$Rd, $imm6",
28600b57cec5SDimitry Andric  "",
28610b57cec5SDimitry Andric  []>, Sched<[]> {
28620b57cec5SDimitry Andric  bits<5> Rd;
28630b57cec5SDimitry Andric  bits<6> imm6;
28640b57cec5SDimitry Andric  let Inst{31-23} = 0b000001001;
28650b57cec5SDimitry Andric  let Inst{22}    = op;
28660b57cec5SDimitry Andric  let Inst{21}    = 0b1;
28670b57cec5SDimitry Andric  let Inst{20-16} = opc2{4-0};
286881ad6265SDimitry Andric  let Inst{15-12} = 0b0101;
286981ad6265SDimitry Andric  let Inst{11}    = streaming_sve;
28700b57cec5SDimitry Andric  let Inst{10-5}  = imm6;
28710b57cec5SDimitry Andric  let Inst{4-0}   = Rd;
287281ad6265SDimitry Andric
287306c3fb27SDimitry Andric  let hasSideEffects = 0;
287481ad6265SDimitry Andric  let isReMaterializable = 1;
2875*0fca6ea1SDimitry Andric  let Uses = [VG];
28760b57cec5SDimitry Andric}
28770b57cec5SDimitry Andric
28780b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
28790b57cec5SDimitry Andric// SVE Permute - In Lane Group
28800b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
28810b57cec5SDimitry Andric
28820b57cec5SDimitry Andricclass sve_int_perm_bin_perm_zz<bits<3> opc, bits<2> sz8_64, string asm,
28830b57cec5SDimitry Andric                               ZPRRegOp zprty>
28840b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
28850b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
28860b57cec5SDimitry Andric  "",
28870b57cec5SDimitry Andric  []>, Sched<[]> {
28880b57cec5SDimitry Andric  bits<5> Zd;
28890b57cec5SDimitry Andric  bits<5> Zm;
28900b57cec5SDimitry Andric  bits<5> Zn;
28910b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
28920b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
28930b57cec5SDimitry Andric  let Inst{21}    = 0b1;
28940b57cec5SDimitry Andric  let Inst{20-16} = Zm;
28950b57cec5SDimitry Andric  let Inst{15-13} = 0b011;
28960b57cec5SDimitry Andric  let Inst{12-10} = opc;
28970b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
28980b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
289906c3fb27SDimitry Andric
290006c3fb27SDimitry Andric  let hasSideEffects = 0;
29010b57cec5SDimitry Andric}
29020b57cec5SDimitry Andric
2903480093f4SDimitry Andricmulticlass sve_int_perm_bin_perm_zz<bits<3> opc, string asm,
2904480093f4SDimitry Andric                                    SDPatternOperator op> {
29050b57cec5SDimitry Andric  def _B : sve_int_perm_bin_perm_zz<opc, 0b00, asm, ZPR8>;
29060b57cec5SDimitry Andric  def _H : sve_int_perm_bin_perm_zz<opc, 0b01, asm, ZPR16>;
29070b57cec5SDimitry Andric  def _S : sve_int_perm_bin_perm_zz<opc, 0b10, asm, ZPR32>;
29080b57cec5SDimitry Andric  def _D : sve_int_perm_bin_perm_zz<opc, 0b11, asm, ZPR64>;
2909480093f4SDimitry Andric
2910480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
2911480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
2912480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
2913480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
2914480093f4SDimitry Andric
2915480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2916480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4f16, op, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _S)>;
2917480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2918e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2f16, op, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _D)>;
2919e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2f32, op, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _D)>;
2920480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
2921e8d8bef9SDimitry Andric
2922e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
29230b57cec5SDimitry Andric}
29240b57cec5SDimitry Andric
29250b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
29260b57cec5SDimitry Andric// SVE Floating Point Unary Operations Group
29270b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
29280b57cec5SDimitry Andric
29290b57cec5SDimitry Andricclass sve_fp_2op_p_zd<bits<7> opc, string asm, RegisterOperand i_zprtype,
2930e8d8bef9SDimitry Andric                      RegisterOperand o_zprtype, ElementSizeEnum Sz>
29310b57cec5SDimitry Andric: I<(outs o_zprtype:$Zd), (ins i_zprtype:$_Zd, PPR3bAny:$Pg, i_zprtype:$Zn),
29320b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/m, $Zn",
29330b57cec5SDimitry Andric  "",
29340b57cec5SDimitry Andric  []>, Sched<[]> {
29350b57cec5SDimitry Andric  bits<3> Pg;
29360b57cec5SDimitry Andric  bits<5> Zd;
29370b57cec5SDimitry Andric  bits<5> Zn;
29380b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
29390b57cec5SDimitry Andric  let Inst{23-22} = opc{6-5};
29400b57cec5SDimitry Andric  let Inst{21}    = 0b0;
29410b57cec5SDimitry Andric  let Inst{20-16} = opc{4-0};
29420b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
29430b57cec5SDimitry Andric  let Inst{12-10} = Pg;
29440b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
29450b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
29460b57cec5SDimitry Andric
29470b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
2948349cc55cSDimitry Andric  let DestructiveInstType = DestructiveUnaryPassthru;
2949e8d8bef9SDimitry Andric  let ElementSize = Sz;
295006c3fb27SDimitry Andric  let hasSideEffects = 0;
295106c3fb27SDimitry Andric  let mayRaiseFPException = 1;
29520b57cec5SDimitry Andric}
29530b57cec5SDimitry Andric
2954480093f4SDimitry Andricmulticlass sve_fp_2op_p_zd<bits<7> opc, string asm,
2955480093f4SDimitry Andric                           RegisterOperand i_zprtype,
2956480093f4SDimitry Andric                           RegisterOperand o_zprtype,
2957e8d8bef9SDimitry Andric                           SDPatternOperator int_op,
2958e8d8bef9SDimitry Andric                           SDPatternOperator ir_op, ValueType vt1,
2959480093f4SDimitry Andric                           ValueType vt2, ValueType vt3, ElementSizeEnum Sz> {
2960d56accc7SDimitry Andric  def NAME : sve_fp_2op_p_zd<opc, asm, i_zprtype, o_zprtype, Sz>,
2961d56accc7SDimitry Andric             SVEPseudo2Instr<NAME, 1>;
2962e8d8bef9SDimitry Andric  // convert vt1 to a packed type for the intrinsic patterns
296306c3fb27SDimitry Andric  defvar packedvt1 = SVEContainerVT<vt1>.Value;
2964e8d8bef9SDimitry Andric
2965e8d8bef9SDimitry Andric  // convert vt3 to a packed type for the intrinsic patterns
296606c3fb27SDimitry Andric  defvar packedvt3 = SVEContainerVT<vt3>.Value;
2967e8d8bef9SDimitry Andric
2968e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<packedvt1, int_op, packedvt1, vt2, packedvt3, !cast<Instruction>(NAME)>;
2969e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME)>;
2970d56accc7SDimitry Andric
2971d56accc7SDimitry Andric  def _UNDEF : PredOneOpPassthruPseudo<NAME, !cast<ZPRRegOp>(i_zprtype)>;
2972d56accc7SDimitry Andric
2973d56accc7SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME # _UNDEF)>;
2974e8d8bef9SDimitry Andric}
2975e8d8bef9SDimitry Andric
2976e8d8bef9SDimitry Andricmulticlass sve_fp_2op_p_zdr<bits<7> opc, string asm,
2977e8d8bef9SDimitry Andric                            RegisterOperand i_zprtype,
2978e8d8bef9SDimitry Andric                            RegisterOperand o_zprtype,
2979e8d8bef9SDimitry Andric                            SDPatternOperator int_op,
2980e8d8bef9SDimitry Andric                            SDPatternOperator ir_op, ValueType vt1,
2981e8d8bef9SDimitry Andric                            ValueType vt2, ValueType vt3, ElementSizeEnum Sz> {
2982d56accc7SDimitry Andric  def NAME : sve_fp_2op_p_zd<opc, asm, i_zprtype, o_zprtype, Sz>,
2983d56accc7SDimitry Andric             SVEPseudo2Instr<NAME, 1>;
2984e8d8bef9SDimitry Andric
2985e8d8bef9SDimitry Andric  // convert vt1 to a packed type for the intrinsic patterns
298606c3fb27SDimitry Andric  defvar packedvt1 = SVEContainerVT<vt1>.Value;
2987e8d8bef9SDimitry Andric
2988e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<packedvt1, int_op, packedvt1, vt2, vt3, !cast<Instruction>(NAME)>;
2989e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Round_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME)>;
2990d56accc7SDimitry Andric
2991d56accc7SDimitry Andric  def _UNDEF : PredOneOpPassthruPseudo<NAME, !cast<ZPRRegOp>(i_zprtype)>;
2992d56accc7SDimitry Andric
2993d56accc7SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Round_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME # _UNDEF)>;
2994480093f4SDimitry Andric}
2995480093f4SDimitry Andric
2996480093f4SDimitry Andricmulticlass sve_fp_2op_p_zd_HSD<bits<5> opc, string asm, SDPatternOperator op> {
2997349cc55cSDimitry Andric  def _H : sve_fp_2op_p_zd<{ 0b01, opc }, asm, ZPR16, ZPR16, ElementSizeH>,
2998349cc55cSDimitry Andric           SVEPseudo2Instr<NAME # _H, 1>;
2999349cc55cSDimitry Andric  def _S : sve_fp_2op_p_zd<{ 0b10, opc }, asm, ZPR32, ZPR32, ElementSizeS>,
3000349cc55cSDimitry Andric           SVEPseudo2Instr<NAME # _S, 1>;
3001349cc55cSDimitry Andric  def _D : sve_fp_2op_p_zd<{ 0b11, opc }, asm, ZPR64, ZPR64, ElementSizeD>,
3002349cc55cSDimitry Andric           SVEPseudo2Instr<NAME # _D, 1>;
3003480093f4SDimitry Andric
3004e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
3005e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
3006e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
3007e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
3008e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
3009e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
3010349cc55cSDimitry Andric
301106c3fb27SDimitry Andric  def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
301206c3fb27SDimitry Andric  def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
301306c3fb27SDimitry Andric  def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
3014349cc55cSDimitry Andric
301506c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H_UNDEF)>;
301606c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H_UNDEF)>;
301706c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H_UNDEF)>;
301806c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S_UNDEF)>;
301906c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S_UNDEF)>;
302006c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D_UNDEF)>;
30210b57cec5SDimitry Andric}
30220b57cec5SDimitry Andric
302306c3fb27SDimitry Andricmulticlass sve2_fp_flogb<string asm, string Ps, SDPatternOperator op> {
302406c3fb27SDimitry Andric  def _H : sve_fp_2op_p_zd<0b0011010, asm, ZPR16, ZPR16, ElementSizeH>,
302506c3fb27SDimitry Andric             SVEPseudo2Instr<Ps # _H, 1>;
302606c3fb27SDimitry Andric  def _S : sve_fp_2op_p_zd<0b0011100, asm, ZPR32, ZPR32, ElementSizeS>,
302706c3fb27SDimitry Andric             SVEPseudo2Instr<Ps # _S, 1>;
302806c3fb27SDimitry Andric  def _D : sve_fp_2op_p_zd<0b0011110, asm, ZPR64, ZPR64, ElementSizeD>,
302906c3fb27SDimitry Andric             SVEPseudo2Instr<Ps # _D, 1>;
3030480093f4SDimitry Andric
3031480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
3032480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
3033480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
3034480093f4SDimitry Andric}
3035480093f4SDimitry Andric
303606c3fb27SDimitry Andricmulticlass sve2_fp_un_pred_zeroing_hsd<SDPatternOperator op> {
303706c3fb27SDimitry Andric  def _H_ZERO : PredOneOpPassthruPseudo<NAME # _H, ZPR16, FalseLanesZero>;
303806c3fb27SDimitry Andric  def _S_ZERO : PredOneOpPassthruPseudo<NAME # _S, ZPR32, FalseLanesZero>;
303906c3fb27SDimitry Andric  def _D_ZERO : PredOneOpPassthruPseudo<NAME # _D, ZPR64, FalseLanesZero>;
304006c3fb27SDimitry Andric
304106c3fb27SDimitry Andric  def : SVE_1_Op_PassthruZero_Pat<nxv8i16, op, nxv8i1, nxv8f16, !cast<Pseudo>(NAME # _H_ZERO)>;
304206c3fb27SDimitry Andric  def : SVE_1_Op_PassthruZero_Pat<nxv4i32, op, nxv4i1, nxv4f32, !cast<Pseudo>(NAME # _S_ZERO)>;
304306c3fb27SDimitry Andric  def : SVE_1_Op_PassthruZero_Pat<nxv2i64, op, nxv2i1, nxv2f64, !cast<Pseudo>(NAME # _D_ZERO)>;
304406c3fb27SDimitry Andric}
304506c3fb27SDimitry Andric
3046480093f4SDimitry Andricmulticlass sve2_fp_convert_down_odd_rounding<string asm, string op> {
3047480093f4SDimitry Andric  def _DtoS : sve_fp_2op_p_zd<0b0001010, asm, ZPR64, ZPR32, ElementSizeD>;
30485ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
30490b57cec5SDimitry Andric}
30500b57cec5SDimitry Andric
30510b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
30520b57cec5SDimitry Andric// SVE Floating Point Unary Operations - Unpredicated Group
30530b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
30540b57cec5SDimitry Andric
30550b57cec5SDimitry Andricclass sve_fp_2op_u_zd<bits<2> sz, bits<3> opc, string asm,
30560b57cec5SDimitry Andric                      ZPRRegOp zprty>
30570b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn),
30580b57cec5SDimitry Andric  asm, "\t$Zd, $Zn",
30590b57cec5SDimitry Andric  "",
30600b57cec5SDimitry Andric  []>, Sched<[]> {
30610b57cec5SDimitry Andric  bits<5> Zd;
30620b57cec5SDimitry Andric  bits<5> Zn;
30630b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
30640b57cec5SDimitry Andric  let Inst{23-22} = sz;
30650b57cec5SDimitry Andric  let Inst{21-19} = 0b001;
30660b57cec5SDimitry Andric  let Inst{18-16} = opc;
30670b57cec5SDimitry Andric  let Inst{15-10} = 0b001100;
30680b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
30690b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
307006c3fb27SDimitry Andric
307106c3fb27SDimitry Andric  let hasSideEffects = 0;
307206c3fb27SDimitry Andric  let mayRaiseFPException = 1;
30730b57cec5SDimitry Andric}
30740b57cec5SDimitry Andric
3075480093f4SDimitry Andricmulticlass sve_fp_2op_u_zd<bits<3> opc, string asm, SDPatternOperator op> {
30760b57cec5SDimitry Andric  def _H : sve_fp_2op_u_zd<0b01, opc, asm, ZPR16>;
30770b57cec5SDimitry Andric  def _S : sve_fp_2op_u_zd<0b10, opc, asm, ZPR32>;
30780b57cec5SDimitry Andric  def _D : sve_fp_2op_u_zd<0b11, opc, asm, ZPR64>;
3079480093f4SDimitry Andric
3080480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv8f16, op, nxv8f16, !cast<Instruction>(NAME # _H)>;
3081480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv4f32, op, nxv4f32, !cast<Instruction>(NAME # _S)>;
3082480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>;
30830b57cec5SDimitry Andric}
30840b57cec5SDimitry Andric
30850b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
30860b57cec5SDimitry Andric// SVE Integer Arithmetic - Binary Predicated Group
30870b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
30880b57cec5SDimitry Andric
30890b57cec5SDimitry Andricclass sve_int_bin_pred_arit_log<bits<2> sz8_64, bits<2> fmt, bits<3> opc,
30900b57cec5SDimitry Andric                                string asm, ZPRRegOp zprty>
30910b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
30920b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
30930b57cec5SDimitry Andric  bits<3> Pg;
30940b57cec5SDimitry Andric  bits<5> Zdn;
30950b57cec5SDimitry Andric  bits<5> Zm;
30960b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
30970b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
30980b57cec5SDimitry Andric  let Inst{21}    = 0b0;
30990b57cec5SDimitry Andric  let Inst{20-19} = fmt;
31000b57cec5SDimitry Andric  let Inst{18-16} = opc;
31010b57cec5SDimitry Andric  let Inst{15-13} = 0b000;
31020b57cec5SDimitry Andric  let Inst{12-10} = Pg;
31030b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
31040b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
31050b57cec5SDimitry Andric
31060b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
31075ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
31080b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
310906c3fb27SDimitry Andric  let hasSideEffects = 0;
31100b57cec5SDimitry Andric}
31110b57cec5SDimitry Andric
311281ad6265SDimitry Andricmulticlass sve_int_bin_pred_log<bits<3> opc, string asm, string Ps,
311381ad6265SDimitry Andric                                SDPatternOperator op,
311481ad6265SDimitry Andric                                DestructiveInstTypeEnum flags> {
311581ad6265SDimitry Andric  let DestructiveInstType = flags in {
311681ad6265SDimitry Andric  def _B : sve_int_bin_pred_arit_log<0b00, 0b11, opc, asm, ZPR8>,
311781ad6265SDimitry Andric             SVEPseudo2Instr<Ps # _B, 1>;
311881ad6265SDimitry Andric  def _H : sve_int_bin_pred_arit_log<0b01, 0b11, opc, asm, ZPR16>,
311981ad6265SDimitry Andric             SVEPseudo2Instr<Ps # _H, 1>;
312081ad6265SDimitry Andric  def _S : sve_int_bin_pred_arit_log<0b10, 0b11, opc, asm, ZPR32>,
312181ad6265SDimitry Andric             SVEPseudo2Instr<Ps # _S, 1>;
312281ad6265SDimitry Andric  def _D : sve_int_bin_pred_arit_log<0b11, 0b11, opc, asm, ZPR64>,
312381ad6265SDimitry Andric             SVEPseudo2Instr<Ps # _D, 1>;
312481ad6265SDimitry Andric  }
3125480093f4SDimitry Andric
3126480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3127480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3128480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3129480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
31300b57cec5SDimitry Andric}
31310b57cec5SDimitry Andric
31325ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_arit_0<bits<3> opc, string asm, string Ps,
31335ffd83dbSDimitry Andric                                   SDPatternOperator op,
31345ffd83dbSDimitry Andric                                   DestructiveInstTypeEnum flags,
31355ffd83dbSDimitry Andric                                   string revname="", bit isReverseInstr=0> {
31365ffd83dbSDimitry Andric  let DestructiveInstType = flags in {
31375ffd83dbSDimitry Andric  def _B : sve_int_bin_pred_arit_log<0b00, 0b00, opc, asm, ZPR8>,
31385ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
31395ffd83dbSDimitry Andric  def _H : sve_int_bin_pred_arit_log<0b01, 0b00, opc, asm, ZPR16>,
31405ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
31415ffd83dbSDimitry Andric  def _S : sve_int_bin_pred_arit_log<0b10, 0b00, opc, asm, ZPR32>,
31425ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
31435ffd83dbSDimitry Andric  def _D : sve_int_bin_pred_arit_log<0b11, 0b00, opc, asm, ZPR64>,
31445ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
31455ffd83dbSDimitry Andric  }
3146480093f4SDimitry Andric
3147480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3148480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3149480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3150480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
31510b57cec5SDimitry Andric}
31520b57cec5SDimitry Andric
3153e8d8bef9SDimitry Andricmulticlass sve_int_bin_pred_arit_1<bits<3> opc, string asm, string Ps,
3154e8d8bef9SDimitry Andric                                   SDPatternOperator op,
3155e8d8bef9SDimitry Andric                                   DestructiveInstTypeEnum flags> {
3156e8d8bef9SDimitry Andric  let DestructiveInstType = flags in {
3157e8d8bef9SDimitry Andric  def _B : sve_int_bin_pred_arit_log<0b00, 0b01, opc, asm, ZPR8>,
3158e8d8bef9SDimitry Andric           SVEPseudo2Instr<Ps # _B, 1>;
3159e8d8bef9SDimitry Andric  def _H : sve_int_bin_pred_arit_log<0b01, 0b01, opc, asm, ZPR16>,
3160e8d8bef9SDimitry Andric           SVEPseudo2Instr<Ps # _H, 1>;
3161e8d8bef9SDimitry Andric  def _S : sve_int_bin_pred_arit_log<0b10, 0b01, opc, asm, ZPR32>,
3162e8d8bef9SDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>;
3163e8d8bef9SDimitry Andric  def _D : sve_int_bin_pred_arit_log<0b11, 0b01, opc, asm, ZPR64>,
3164e8d8bef9SDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>;
3165e8d8bef9SDimitry Andric  }
3166480093f4SDimitry Andric
3167480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3168480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3169480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3170480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
31710b57cec5SDimitry Andric}
31720b57cec5SDimitry Andric
3173e8d8bef9SDimitry Andricmulticlass sve_int_bin_pred_arit_2<bits<3> opc, string asm, string Ps,
3174e8d8bef9SDimitry Andric                                   SDPatternOperator op,
3175e8d8bef9SDimitry Andric                                   DestructiveInstTypeEnum flags> {
3176e8d8bef9SDimitry Andric  let DestructiveInstType = flags in {
3177e8d8bef9SDimitry Andric  def _B : sve_int_bin_pred_arit_log<0b00, 0b10, opc, asm, ZPR8>,
3178e8d8bef9SDimitry Andric           SVEPseudo2Instr<Ps # _B, 1>;
3179e8d8bef9SDimitry Andric  def _H : sve_int_bin_pred_arit_log<0b01, 0b10, opc, asm, ZPR16>,
3180e8d8bef9SDimitry Andric           SVEPseudo2Instr<Ps # _H, 1>;
3181e8d8bef9SDimitry Andric  def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>,
3182e8d8bef9SDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>;
3183e8d8bef9SDimitry Andric  def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>,
3184e8d8bef9SDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>;
3185e8d8bef9SDimitry Andric  }
3186480093f4SDimitry Andric
3187480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3188480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3189480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3190480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
31910b57cec5SDimitry Andric}
31920b57cec5SDimitry Andric
31930b57cec5SDimitry Andric// Special case for divides which are not defined for 8b/16b elements.
31945ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_arit_2_div<bits<3> opc, string asm, string Ps,
31955ffd83dbSDimitry Andric                                       SDPatternOperator op,
31965ffd83dbSDimitry Andric                                       DestructiveInstTypeEnum flags,
31975ffd83dbSDimitry Andric                                       string revname="", bit isReverseInstr=0> {
31985ffd83dbSDimitry Andric  let DestructiveInstType = flags in {
31995ffd83dbSDimitry Andric  def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>,
32005ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
32015ffd83dbSDimitry Andric  def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>,
32025ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
32035ffd83dbSDimitry Andric  }
3204480093f4SDimitry Andric
3205480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3206480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
32070b57cec5SDimitry Andric}
32080b57cec5SDimitry Andric
32090b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
32100b57cec5SDimitry Andric// SVE Integer Multiply-Add Group
32110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
32120b57cec5SDimitry Andric
32130b57cec5SDimitry Andricclass sve_int_mladdsub_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
32140b57cec5SDimitry Andric                                ZPRRegOp zprty>
32150b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
32160b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $Zm, $Za",
32170b57cec5SDimitry Andric  "",
32180b57cec5SDimitry Andric  []>, Sched<[]> {
32190b57cec5SDimitry Andric  bits<3> Pg;
32200b57cec5SDimitry Andric  bits<5> Zdn;
32210b57cec5SDimitry Andric  bits<5> Za;
32220b57cec5SDimitry Andric  bits<5> Zm;
32230b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
32240b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
32250b57cec5SDimitry Andric  let Inst{21}    = 0b0;
32260b57cec5SDimitry Andric  let Inst{20-16} = Zm;
32270b57cec5SDimitry Andric  let Inst{15-14} = 0b11;
32280b57cec5SDimitry Andric  let Inst{13}    = opc;
32290b57cec5SDimitry Andric  let Inst{12-10} = Pg;
32300b57cec5SDimitry Andric  let Inst{9-5}   = Za;
32310b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
32320b57cec5SDimitry Andric
32330b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
32345ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
32350b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
323606c3fb27SDimitry Andric  let hasSideEffects = 0;
32370b57cec5SDimitry Andric}
32380b57cec5SDimitry Andric
323906c3fb27SDimitry Andricmulticlass sve_int_mladdsub_vvv_pred<bits<1> opc, string asm, SDPatternOperator op,
324006c3fb27SDimitry Andric                                     string revname, bit isReverseInstr=0> {
324106c3fb27SDimitry Andric  def _B : sve_int_mladdsub_vvv_pred<0b00, opc, asm, ZPR8>,
324206c3fb27SDimitry Andric           SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
324306c3fb27SDimitry Andric  def _H : sve_int_mladdsub_vvv_pred<0b01, opc, asm, ZPR16>,
324406c3fb27SDimitry Andric           SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
324506c3fb27SDimitry Andric  def _S : sve_int_mladdsub_vvv_pred<0b10, opc, asm, ZPR32>,
324606c3fb27SDimitry Andric           SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
324706c3fb27SDimitry Andric  def _D : sve_int_mladdsub_vvv_pred<0b11, opc, asm, ZPR64>,
324806c3fb27SDimitry Andric           SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
3249480093f4SDimitry Andric
3250480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3251480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3252480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3253480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
32540b57cec5SDimitry Andric}
32550b57cec5SDimitry Andric
32560b57cec5SDimitry Andricclass sve_int_mlas_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
32570b57cec5SDimitry Andric                            ZPRRegOp zprty>
32580b57cec5SDimitry Andric: I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
32590b57cec5SDimitry Andric  asm, "\t$Zda, $Pg/m, $Zn, $Zm",
32600b57cec5SDimitry Andric  "",
32610b57cec5SDimitry Andric  []>, Sched<[]> {
32620b57cec5SDimitry Andric  bits<3> Pg;
32630b57cec5SDimitry Andric  bits<5> Zda;
32640b57cec5SDimitry Andric  bits<5> Zm;
32650b57cec5SDimitry Andric  bits<5> Zn;
32660b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
32670b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
32680b57cec5SDimitry Andric  let Inst{21}    = 0b0;
32690b57cec5SDimitry Andric  let Inst{20-16} = Zm;
32700b57cec5SDimitry Andric  let Inst{15-14} = 0b01;
32710b57cec5SDimitry Andric  let Inst{13}    = opc;
32720b57cec5SDimitry Andric  let Inst{12-10} = Pg;
32730b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
32740b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
32750b57cec5SDimitry Andric
32760b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
327706c3fb27SDimitry Andric  let DestructiveInstType = DestructiveTernaryCommWithRev;
32780b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
327906c3fb27SDimitry Andric  let hasSideEffects = 0;
32800b57cec5SDimitry Andric}
32810b57cec5SDimitry Andric
328206c3fb27SDimitry Andricmulticlass sve_int_mlas_vvv_pred<bits<1> opc, string asm, SDPatternOperator op,
328306c3fb27SDimitry Andric                                 string Ps, string revname, bit isReverseInstr=0> {
328406c3fb27SDimitry Andric  def _B : sve_int_mlas_vvv_pred<0b00, opc, asm, ZPR8>,
328506c3fb27SDimitry Andric           SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
328606c3fb27SDimitry Andric  def _H : sve_int_mlas_vvv_pred<0b01, opc, asm, ZPR16>,
328706c3fb27SDimitry Andric           SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
328806c3fb27SDimitry Andric  def _S : sve_int_mlas_vvv_pred<0b10, opc, asm, ZPR32>,
328906c3fb27SDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
329006c3fb27SDimitry Andric  def _D : sve_int_mlas_vvv_pred<0b11, opc, asm, ZPR64>,
329106c3fb27SDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
3292480093f4SDimitry Andric
3293480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3294480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3295480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3296480093f4SDimitry Andric  def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
32970b57cec5SDimitry Andric}
32980b57cec5SDimitry Andric
329906c3fb27SDimitry Andric//class for generating pseudo for SVE MLA/MAD/MLS/MSB
330006c3fb27SDimitry Andricmulticlass sve_int_3op_p_mladdsub<SDPatternOperator op> {
330106c3fb27SDimitry Andric  def _B_UNDEF : PredThreeOpPseudo<NAME # _B, ZPR8,  FalseLanesUndef>;
330206c3fb27SDimitry Andric  def _H_UNDEF : PredThreeOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
330306c3fb27SDimitry Andric  def _S_UNDEF : PredThreeOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
330406c3fb27SDimitry Andric  def _D_UNDEF : PredThreeOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
330506c3fb27SDimitry Andric
330606c3fb27SDimitry Andric  let  AddedComplexity = 9 in {
330706c3fb27SDimitry Andric    def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B_UNDEF)>;
330806c3fb27SDimitry Andric    def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H_UNDEF)>;
330906c3fb27SDimitry Andric    def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S_UNDEF)>;
331006c3fb27SDimitry Andric    def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D_UNDEF)>;
331106c3fb27SDimitry Andric  }
331206c3fb27SDimitry Andric}
331306c3fb27SDimitry Andric
33140b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
33150b57cec5SDimitry Andric// SVE2 Integer Multiply-Add - Unpredicated Group
33160b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
33170b57cec5SDimitry Andric
33180b57cec5SDimitry Andricclass sve2_int_mla<bits<2> sz, bits<5> opc, string asm,
33190b57cec5SDimitry Andric                   ZPRRegOp zprty1, ZPRRegOp zprty2>
33200b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
33210b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
33220b57cec5SDimitry Andric  bits<5> Zda;
33230b57cec5SDimitry Andric  bits<5> Zn;
33240b57cec5SDimitry Andric  bits<5> Zm;
33250b57cec5SDimitry Andric  let Inst{31-24} = 0b01000100;
33260b57cec5SDimitry Andric  let Inst{23-22} = sz;
33270b57cec5SDimitry Andric  let Inst{21}    = 0b0;
33280b57cec5SDimitry Andric  let Inst{20-16} = Zm;
33290b57cec5SDimitry Andric  let Inst{15}    = 0b0;
33300b57cec5SDimitry Andric  let Inst{14-10} = opc;
33310b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
33320b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
33330b57cec5SDimitry Andric
33340b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
33355ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
33360b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
333706c3fb27SDimitry Andric  let hasSideEffects = 0;
33380b57cec5SDimitry Andric}
33390b57cec5SDimitry Andric
33405ffd83dbSDimitry Andricmulticlass sve2_int_mla<bit S, string asm, SDPatternOperator op> {
33410b57cec5SDimitry Andric  def _B : sve2_int_mla<0b00, { 0b1110, S }, asm, ZPR8, ZPR8>;
33420b57cec5SDimitry Andric  def _H : sve2_int_mla<0b01, { 0b1110, S }, asm, ZPR16, ZPR16>;
33430b57cec5SDimitry Andric  def _S : sve2_int_mla<0b10, { 0b1110, S }, asm, ZPR32, ZPR32>;
33440b57cec5SDimitry Andric  def _D : sve2_int_mla<0b11, { 0b1110, S }, asm, ZPR64, ZPR64>;
33455ffd83dbSDimitry Andric
33465ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
33475ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
33485ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
33495ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
33500b57cec5SDimitry Andric}
33510b57cec5SDimitry Andric
33525ffd83dbSDimitry Andricmulticlass sve2_int_mla_long<bits<5> opc, string asm, SDPatternOperator op> {
33530b57cec5SDimitry Andric  def _H : sve2_int_mla<0b01, opc, asm, ZPR16, ZPR8>;
33540b57cec5SDimitry Andric  def _S : sve2_int_mla<0b10, opc, asm, ZPR32, ZPR16>;
33550b57cec5SDimitry Andric  def _D : sve2_int_mla<0b11, opc, asm, ZPR64, ZPR32>;
33565ffd83dbSDimitry Andric
33575ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
33585ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
33595ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
33600b57cec5SDimitry Andric}
33610b57cec5SDimitry Andric
33620b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
33630b57cec5SDimitry Andric// SVE2 Integer Multiply-Add - Indexed Group
33640b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
33650b57cec5SDimitry Andric
33660b57cec5SDimitry Andricclass sve2_int_mla_by_indexed_elem<bits<2> sz, bits<6> opc, string asm,
33670b57cec5SDimitry Andric                                   ZPRRegOp zprty1, ZPRRegOp zprty2,
33680b57cec5SDimitry Andric                                   ZPRRegOp zprty3, Operand itype>
33690b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
33700b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
33710b57cec5SDimitry Andric  bits<5> Zda;
33720b57cec5SDimitry Andric  bits<5> Zn;
33730b57cec5SDimitry Andric  let Inst{31-24} = 0b01000100;
33740b57cec5SDimitry Andric  let Inst{23-22} = sz;
33750b57cec5SDimitry Andric  let Inst{21}    = 0b1;
33760b57cec5SDimitry Andric  let Inst{15-10} = opc;
33770b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
33780b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
33790b57cec5SDimitry Andric
33800b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
33815ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
33820b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
338306c3fb27SDimitry Andric  let hasSideEffects = 0;
33840b57cec5SDimitry Andric}
33850b57cec5SDimitry Andric
33865ffd83dbSDimitry Andricmulticlass sve2_int_mla_by_indexed_elem<bits<2> opc, bit S, string asm,
33875ffd83dbSDimitry Andric                                        SDPatternOperator op> {
33885ffd83dbSDimitry Andric  def _H : sve2_int_mla_by_indexed_elem<{0, ?}, { 0b000, opc, S }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH32b> {
33890b57cec5SDimitry Andric    bits<3> Zm;
33900b57cec5SDimitry Andric    bits<3> iop;
33910b57cec5SDimitry Andric    let Inst{22} = iop{2};
33920b57cec5SDimitry Andric    let Inst{20-19} = iop{1-0};
33930b57cec5SDimitry Andric    let Inst{18-16} = Zm;
33940b57cec5SDimitry Andric  }
33955ffd83dbSDimitry Andric  def _S : sve2_int_mla_by_indexed_elem<0b10, { 0b000, opc, S }, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS32b> {
33960b57cec5SDimitry Andric    bits<3> Zm;
33970b57cec5SDimitry Andric    bits<2> iop;
33980b57cec5SDimitry Andric    let Inst{20-19} = iop;
33990b57cec5SDimitry Andric    let Inst{18-16} = Zm;
34000b57cec5SDimitry Andric  }
34015ffd83dbSDimitry Andric  def _D : sve2_int_mla_by_indexed_elem<0b11, { 0b000, opc, S }, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD32b> {
34020b57cec5SDimitry Andric    bits<4> Zm;
34030b57cec5SDimitry Andric    bit iop;
34040b57cec5SDimitry Andric    let Inst{20} = iop;
34050b57cec5SDimitry Andric    let Inst{19-16} = Zm;
34060b57cec5SDimitry Andric  }
34075ffd83dbSDimitry Andric
34085ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
34095ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
34105ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
34110b57cec5SDimitry Andric}
34120b57cec5SDimitry Andric
34130b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
34140b57cec5SDimitry Andric// SVE2 Integer Multiply-Add Long - Indexed Group
34150b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
34160b57cec5SDimitry Andric
3417e8d8bef9SDimitry Andricmulticlass sve2_int_mla_long_by_indexed_elem<bits<4> opc, string asm,
3418e8d8bef9SDimitry Andric                                             SDPatternOperator op> {
34190b57cec5SDimitry Andric  def _S : sve2_int_mla_by_indexed_elem<0b10, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
34205ffd83dbSDimitry Andric                                        asm, ZPR32, ZPR16, ZPR3b16, VectorIndexH32b> {
34210b57cec5SDimitry Andric    bits<3> Zm;
34220b57cec5SDimitry Andric    bits<3> iop;
34230b57cec5SDimitry Andric    let Inst{20-19} = iop{2-1};
34240b57cec5SDimitry Andric    let Inst{18-16} = Zm;
34250b57cec5SDimitry Andric    let Inst{11} = iop{0};
34260b57cec5SDimitry Andric  }
34270b57cec5SDimitry Andric  def _D : sve2_int_mla_by_indexed_elem<0b11, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
34285ffd83dbSDimitry Andric                                        asm, ZPR64, ZPR32, ZPR4b32, VectorIndexS32b> {
34290b57cec5SDimitry Andric    bits<4> Zm;
34300b57cec5SDimitry Andric    bits<2> iop;
34310b57cec5SDimitry Andric    let Inst{20} = iop{1};
34320b57cec5SDimitry Andric    let Inst{19-16} = Zm;
34330b57cec5SDimitry Andric    let Inst{11} = iop{0};
34340b57cec5SDimitry Andric  }
34355ffd83dbSDimitry Andric
34365ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _S)>;
34375ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>;
34380b57cec5SDimitry Andric}
34390b57cec5SDimitry Andric
34400b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
34410b57cec5SDimitry Andric// SVE Integer Dot Product Group
34420b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
34430b57cec5SDimitry Andric
34440b57cec5SDimitry Andricclass sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
34450b57cec5SDimitry Andric                   ZPRRegOp zprty2>
34460b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), asm,
34470b57cec5SDimitry Andric  "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
34480b57cec5SDimitry Andric  bits<5> Zda;
34490b57cec5SDimitry Andric  bits<5> Zn;
34500b57cec5SDimitry Andric  bits<5> Zm;
34510b57cec5SDimitry Andric  let Inst{31-23} = 0b010001001;
34520b57cec5SDimitry Andric  let Inst{22}    = sz;
34530b57cec5SDimitry Andric  let Inst{21}    = 0;
34540b57cec5SDimitry Andric  let Inst{20-16} = Zm;
34550b57cec5SDimitry Andric  let Inst{15-11} = 0;
34560b57cec5SDimitry Andric  let Inst{10}    = U;
34570b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
34580b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
34590b57cec5SDimitry Andric
34600b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
34615ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
346206c3fb27SDimitry Andric  let hasSideEffects = 0;
34630b57cec5SDimitry Andric}
34640b57cec5SDimitry Andric
34658bcb0991SDimitry Andricmulticlass sve_intx_dot<bit opc, string asm, SDPatternOperator op> {
34660b57cec5SDimitry Andric  def _S : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>;
34670b57cec5SDimitry Andric  def _D : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>;
34688bcb0991SDimitry Andric
34698bcb0991SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32,  nxv16i8, nxv16i8, !cast<Instruction>(NAME # _S)>;
34708bcb0991SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64,  nxv8i16, nxv8i16, !cast<Instruction>(NAME # _D)>;
34710b57cec5SDimitry Andric}
34720b57cec5SDimitry Andric
34730b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
34740b57cec5SDimitry Andric// SVE Integer Dot Product Group - Indexed Group
34750b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
34760b57cec5SDimitry Andric
34770b57cec5SDimitry Andricclass sve_intx_dot_by_indexed_elem<bit sz, bit U, string asm,
34780b57cec5SDimitry Andric                                   ZPRRegOp zprty1, ZPRRegOp zprty2,
34790b57cec5SDimitry Andric                                   ZPRRegOp zprty3, Operand itype>
34800b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
34810b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm$iop",
34820b57cec5SDimitry Andric  "", []>, Sched<[]> {
34830b57cec5SDimitry Andric  bits<5> Zda;
34840b57cec5SDimitry Andric  bits<5> Zn;
34850b57cec5SDimitry Andric  let Inst{31-23} = 0b010001001;
34860b57cec5SDimitry Andric  let Inst{22}    = sz;
34870b57cec5SDimitry Andric  let Inst{21}    = 0b1;
34880b57cec5SDimitry Andric  let Inst{15-11} = 0;
34890b57cec5SDimitry Andric  let Inst{10}    = U;
34900b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
34910b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
34920b57cec5SDimitry Andric
34930b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
34945ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
349506c3fb27SDimitry Andric  let hasSideEffects = 0;
34960b57cec5SDimitry Andric}
34970b57cec5SDimitry Andric
34988bcb0991SDimitry Andricmulticlass sve_intx_dot_by_indexed_elem<bit opc, string asm,
34998bcb0991SDimitry Andric                                        SDPatternOperator op> {
35005ffd83dbSDimitry Andric  def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b_timm> {
35010b57cec5SDimitry Andric    bits<2> iop;
35020b57cec5SDimitry Andric    bits<3> Zm;
35030b57cec5SDimitry Andric    let Inst{20-19} = iop;
35040b57cec5SDimitry Andric    let Inst{18-16} = Zm;
35050b57cec5SDimitry Andric  }
35065ffd83dbSDimitry Andric  def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b_timm> {
35070b57cec5SDimitry Andric    bits<1> iop;
35080b57cec5SDimitry Andric    bits<4> Zm;
35090b57cec5SDimitry Andric    let Inst{20} = iop;
35100b57cec5SDimitry Andric    let Inst{19-16} = Zm;
35110b57cec5SDimitry Andric  }
35128bcb0991SDimitry Andric
3513fe6060f1SDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
3514fe6060f1SDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
35150b57cec5SDimitry Andric}
35160b57cec5SDimitry Andric
35170b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
35180b57cec5SDimitry Andric// SVE2 Complex Integer Dot Product Group
35190b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
35200b57cec5SDimitry Andric
35210b57cec5SDimitry Andricclass sve2_complex_int_arith<bits<2> sz, bits<4> opc, string asm,
35220b57cec5SDimitry Andric                             ZPRRegOp zprty1, ZPRRegOp zprty2>
35230b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm,
35240b57cec5SDimitry Andric                         complexrotateop:$rot),
35250b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm, $rot", "", []>, Sched<[]> {
35260b57cec5SDimitry Andric  bits<5> Zda;
35270b57cec5SDimitry Andric  bits<5> Zn;
35280b57cec5SDimitry Andric  bits<5> Zm;
35290b57cec5SDimitry Andric  bits<2> rot;
35300b57cec5SDimitry Andric  let Inst{31-24} = 0b01000100;
35310b57cec5SDimitry Andric  let Inst{23-22} = sz;
35320b57cec5SDimitry Andric  let Inst{21}    = 0b0;
35330b57cec5SDimitry Andric  let Inst{20-16} = Zm;
35340b57cec5SDimitry Andric  let Inst{15-12} = opc;
35350b57cec5SDimitry Andric  let Inst{11-10} = rot;
35360b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
35370b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
35380b57cec5SDimitry Andric
35390b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
35405ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
35410b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
354206c3fb27SDimitry Andric  let hasSideEffects = 0;
35430b57cec5SDimitry Andric}
35440b57cec5SDimitry Andric
35455ffd83dbSDimitry Andricmulticlass sve2_cintx_dot<string asm, SDPatternOperator op> {
35460b57cec5SDimitry Andric  def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>;
35470b57cec5SDimitry Andric  def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>;
35485ffd83dbSDimitry Andric
35495ffd83dbSDimitry Andric  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
35505ffd83dbSDimitry Andric                         (i32 complexrotateop:$imm))),
35515ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, complexrotateop:$imm)>;
35525ffd83dbSDimitry Andric  def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
35535ffd83dbSDimitry Andric                         (i32 complexrotateop:$imm))),
35545ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, complexrotateop:$imm)>;
35550b57cec5SDimitry Andric}
35560b57cec5SDimitry Andric
35570b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
35580b57cec5SDimitry Andric// SVE2 Complex Multiply-Add Group
35590b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
35600b57cec5SDimitry Andric
35615ffd83dbSDimitry Andricmulticlass sve2_int_cmla<bit opc, string asm, SDPatternOperator op> {
35620b57cec5SDimitry Andric  def _B : sve2_complex_int_arith<0b00, { 0b001, opc }, asm, ZPR8, ZPR8>;
35630b57cec5SDimitry Andric  def _H : sve2_complex_int_arith<0b01, { 0b001, opc }, asm, ZPR16, ZPR16>;
35640b57cec5SDimitry Andric  def _S : sve2_complex_int_arith<0b10, { 0b001, opc }, asm, ZPR32, ZPR32>;
35650b57cec5SDimitry Andric  def _D : sve2_complex_int_arith<0b11, { 0b001, opc }, asm, ZPR64, ZPR64>;
35665ffd83dbSDimitry Andric
35675ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, i32, complexrotateop, !cast<Instruction>(NAME # _B)>;
35685ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, i32, complexrotateop, !cast<Instruction>(NAME # _H)>;
35695ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, i32, complexrotateop, !cast<Instruction>(NAME # _S)>;
35705ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, i32, complexrotateop, !cast<Instruction>(NAME # _D)>;
35710b57cec5SDimitry Andric}
35720b57cec5SDimitry Andric
35730b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
35740b57cec5SDimitry Andric// SVE2 Complex Integer Dot Product - Indexed Group
35750b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
35760b57cec5SDimitry Andric
35770b57cec5SDimitry Andricclass sve2_complex_int_arith_indexed<bits<2> sz, bits<4> opc, string asm,
35780b57cec5SDimitry Andric                                     ZPRRegOp zprty1, ZPRRegOp zprty2,
35790b57cec5SDimitry Andric                                     ZPRRegOp zprty3, Operand itype>
35800b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop,
35810b57cec5SDimitry Andric                         complexrotateop:$rot),
35820b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm$iop, $rot", "", []>, Sched<[]> {
35830b57cec5SDimitry Andric  bits<5> Zda;
35840b57cec5SDimitry Andric  bits<5> Zn;
35850b57cec5SDimitry Andric  bits<2> rot;
35860b57cec5SDimitry Andric  let Inst{31-24} = 0b01000100;
35870b57cec5SDimitry Andric  let Inst{23-22} = sz;
35880b57cec5SDimitry Andric  let Inst{21}    = 0b1;
35890b57cec5SDimitry Andric  let Inst{15-12} = opc;
35900b57cec5SDimitry Andric  let Inst{11-10} = rot;
35910b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
35920b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
35930b57cec5SDimitry Andric
35940b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
35955ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
35960b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
359706c3fb27SDimitry Andric  let hasSideEffects = 0;
35980b57cec5SDimitry Andric}
35990b57cec5SDimitry Andric
36005ffd83dbSDimitry Andricmulticlass sve2_cintx_dot_by_indexed_elem<string asm, SDPatternOperator op> {
36015ffd83dbSDimitry Andric  def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
36020b57cec5SDimitry Andric    bits<2> iop;
36030b57cec5SDimitry Andric    bits<3> Zm;
36040b57cec5SDimitry Andric    let Inst{20-19} = iop;
36050b57cec5SDimitry Andric    let Inst{18-16} = Zm;
36060b57cec5SDimitry Andric  }
36075ffd83dbSDimitry Andric  def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
36080b57cec5SDimitry Andric    bit iop;
36090b57cec5SDimitry Andric    bits<4> Zm;
36100b57cec5SDimitry Andric    let Inst{20} = iop;
36110b57cec5SDimitry Andric    let Inst{19-16} = Zm;
36120b57cec5SDimitry Andric  }
36135ffd83dbSDimitry Andric
36145ffd83dbSDimitry Andric  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
36155ffd83dbSDimitry Andric                         (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
36165ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
36175ffd83dbSDimitry Andric  def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
36185ffd83dbSDimitry Andric                         (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
36195ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
36200b57cec5SDimitry Andric}
36210b57cec5SDimitry Andric
36220b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
36230b57cec5SDimitry Andric// SVE2 Complex Multiply-Add - Indexed Group
36240b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
36250b57cec5SDimitry Andric
36265ffd83dbSDimitry Andricmulticlass sve2_cmla_by_indexed_elem<bit opc, string asm,
36275ffd83dbSDimitry Andric                                     SDPatternOperator op> {
36285ffd83dbSDimitry Andric  def _H : sve2_complex_int_arith_indexed<0b10, { 0b011, opc }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexS32b> {
36290b57cec5SDimitry Andric    bits<2> iop;
36300b57cec5SDimitry Andric    bits<3> Zm;
36310b57cec5SDimitry Andric    let Inst{20-19} = iop;
36320b57cec5SDimitry Andric    let Inst{18-16} = Zm;
36330b57cec5SDimitry Andric  }
36345ffd83dbSDimitry Andric  def _S : sve2_complex_int_arith_indexed<0b11, { 0b011, opc }, asm, ZPR32, ZPR32, ZPR4b32, VectorIndexD32b> {
36350b57cec5SDimitry Andric    bit iop;
36360b57cec5SDimitry Andric    bits<4> Zm;
36370b57cec5SDimitry Andric    let Inst{20} = iop;
36380b57cec5SDimitry Andric    let Inst{19-16} = Zm;
36390b57cec5SDimitry Andric  }
36405ffd83dbSDimitry Andric
36415ffd83dbSDimitry Andric  def : Pat<(nxv8i16 (op (nxv8i16 ZPR16:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
36425ffd83dbSDimitry Andric                         (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
36435ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_H") ZPR16:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
36445ffd83dbSDimitry Andric
36455ffd83dbSDimitry Andric  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv4i32 ZPR32:$Op2), (nxv4i32 ZPR32:$Op3),
36465ffd83dbSDimitry Andric                         (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
36475ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR32:$Op2, ZPR32:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
36480b57cec5SDimitry Andric}
36490b57cec5SDimitry Andric
36500b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
36510b57cec5SDimitry Andric// SVE2 Integer Multiply - Unpredicated Group
36520b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
36530b57cec5SDimitry Andric
36540b57cec5SDimitry Andricclass sve2_int_mul<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty>
36550b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
36560b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
36570b57cec5SDimitry Andric  bits<5> Zd;
36580b57cec5SDimitry Andric  bits<5> Zm;
36590b57cec5SDimitry Andric  bits<5> Zn;
36600b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
36610b57cec5SDimitry Andric  let Inst{23-22} = sz;
36620b57cec5SDimitry Andric  let Inst{21}    = 0b1;
36630b57cec5SDimitry Andric  let Inst{20-16} = Zm;
36640b57cec5SDimitry Andric  let Inst{15-13} = 0b011;
36650b57cec5SDimitry Andric  let Inst{12-10} = opc;
36660b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
36670b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
366806c3fb27SDimitry Andric
366906c3fb27SDimitry Andric  let hasSideEffects = 0;
36700b57cec5SDimitry Andric}
36710b57cec5SDimitry Andric
3672*0fca6ea1SDimitry Andricmulticlass sve2_int_mul<bits<3> opc, string asm, SDPatternOperator op> {
36730b57cec5SDimitry Andric  def _B : sve2_int_mul<0b00, opc, asm, ZPR8>;
36740b57cec5SDimitry Andric  def _H : sve2_int_mul<0b01, opc, asm, ZPR16>;
36750b57cec5SDimitry Andric  def _S : sve2_int_mul<0b10, opc, asm, ZPR32>;
36760b57cec5SDimitry Andric  def _D : sve2_int_mul<0b11, opc, asm, ZPR64>;
36775ffd83dbSDimitry Andric
36785ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
36795ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
36805ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
36815ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
36825ffd83dbSDimitry Andric}
36835ffd83dbSDimitry Andric
36845ffd83dbSDimitry Andricmulticlass sve2_int_mul_single<bits<3> opc, string asm, SDPatternOperator op> {
36855ffd83dbSDimitry Andric  def _B : sve2_int_mul<0b00, opc, asm, ZPR8>;
36865ffd83dbSDimitry Andric
36875ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
36880b57cec5SDimitry Andric}
36890b57cec5SDimitry Andric
36900b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
36910b57cec5SDimitry Andric// SVE2 Integer Multiply - Indexed Group
36920b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
36930b57cec5SDimitry Andric
36940b57cec5SDimitry Andricclass sve2_int_mul_by_indexed_elem<bits<2> sz, bits<4> opc, string asm,
36950b57cec5SDimitry Andric                                   ZPRRegOp zprty1, ZPRRegOp zprty2,
36960b57cec5SDimitry Andric                                   ZPRRegOp zprty3, Operand itype>
36970b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm, itype:$iop),
36980b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
36990b57cec5SDimitry Andric  bits<5> Zd;
37000b57cec5SDimitry Andric  bits<5> Zn;
37010b57cec5SDimitry Andric  let Inst{31-24} = 0b01000100;
37020b57cec5SDimitry Andric  let Inst{23-22} = sz;
37030b57cec5SDimitry Andric  let Inst{21}    = 0b1;
37040b57cec5SDimitry Andric  let Inst{15-14} = 0b11;
37050b57cec5SDimitry Andric  let Inst{13-10} = opc;
37060b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
37070b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
370806c3fb27SDimitry Andric
370906c3fb27SDimitry Andric  let hasSideEffects = 0;
37100b57cec5SDimitry Andric}
37110b57cec5SDimitry Andric
37125ffd83dbSDimitry Andricmulticlass sve2_int_mul_by_indexed_elem<bits<4> opc, string asm,
37135ffd83dbSDimitry Andric                                        SDPatternOperator op> {
37145ffd83dbSDimitry Andric  def _H : sve2_int_mul_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH32b> {
37150b57cec5SDimitry Andric    bits<3> Zm;
37160b57cec5SDimitry Andric    bits<3> iop;
37170b57cec5SDimitry Andric    let Inst{22} = iop{2};
37180b57cec5SDimitry Andric    let Inst{20-19} = iop{1-0};
37190b57cec5SDimitry Andric    let Inst{18-16} = Zm;
37200b57cec5SDimitry Andric  }
37215ffd83dbSDimitry Andric  def _S : sve2_int_mul_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS32b> {
37220b57cec5SDimitry Andric    bits<3> Zm;
37230b57cec5SDimitry Andric    bits<2> iop;
37240b57cec5SDimitry Andric    let Inst{20-19} = iop;
37250b57cec5SDimitry Andric    let Inst{18-16} = Zm;
37260b57cec5SDimitry Andric  }
37275ffd83dbSDimitry Andric  def _D : sve2_int_mul_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD32b> {
37280b57cec5SDimitry Andric    bits<4> Zm;
37290b57cec5SDimitry Andric    bit iop;
37300b57cec5SDimitry Andric    let Inst{20} = iop;
37310b57cec5SDimitry Andric    let Inst{19-16} = Zm;
37320b57cec5SDimitry Andric  }
37335ffd83dbSDimitry Andric
37345ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
37355ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
37365ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
37370b57cec5SDimitry Andric}
37380b57cec5SDimitry Andric
37395ffd83dbSDimitry Andricmulticlass sve2_int_mul_long_by_indexed_elem<bits<3> opc, string asm,
37405ffd83dbSDimitry Andric                                             SDPatternOperator op> {
37410b57cec5SDimitry Andric  def _S : sve2_int_mul_by_indexed_elem<0b10, { opc{2-1}, ?, opc{0} }, asm,
37425ffd83dbSDimitry Andric                                        ZPR32, ZPR16, ZPR3b16, VectorIndexH32b> {
37430b57cec5SDimitry Andric    bits<3> Zm;
37440b57cec5SDimitry Andric    bits<3> iop;
37450b57cec5SDimitry Andric    let Inst{20-19} = iop{2-1};
37460b57cec5SDimitry Andric    let Inst{18-16} = Zm;
37470b57cec5SDimitry Andric    let Inst{11} = iop{0};
37480b57cec5SDimitry Andric  }
37490b57cec5SDimitry Andric  def _D : sve2_int_mul_by_indexed_elem<0b11, { opc{2-1}, ?, opc{0} }, asm,
37505ffd83dbSDimitry Andric                                        ZPR64, ZPR32, ZPR4b32, VectorIndexS32b> {
37510b57cec5SDimitry Andric    bits<4> Zm;
37520b57cec5SDimitry Andric    bits<2> iop;
37530b57cec5SDimitry Andric    let Inst{20} = iop{1};
37540b57cec5SDimitry Andric    let Inst{19-16} = Zm;
37550b57cec5SDimitry Andric    let Inst{11} = iop{0};
37560b57cec5SDimitry Andric  }
37575ffd83dbSDimitry Andric
37585ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _S)>;
37595ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>;
37600b57cec5SDimitry Andric}
37610b57cec5SDimitry Andric
37620b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
37630b57cec5SDimitry Andric// SVE2 Integer - Predicated Group
37640b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
37650b57cec5SDimitry Andric
37660b57cec5SDimitry Andricclass sve2_int_arith_pred<bits<2> sz, bits<6> opc, string asm,
37670b57cec5SDimitry Andric                          ZPRRegOp zprty>
37680b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
37690b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
37700b57cec5SDimitry Andric  bits<3> Pg;
37710b57cec5SDimitry Andric  bits<5> Zm;
37720b57cec5SDimitry Andric  bits<5> Zdn;
37730b57cec5SDimitry Andric  let Inst{31-24} = 0b01000100;
37740b57cec5SDimitry Andric  let Inst{23-22} = sz;
37755ffd83dbSDimitry Andric  let Inst{21-20} = 0b01;
37760b57cec5SDimitry Andric  let Inst{20-16} = opc{5-1};
37770b57cec5SDimitry Andric  let Inst{15-14} = 0b10;
37780b57cec5SDimitry Andric  let Inst{13}    = opc{0};
37790b57cec5SDimitry Andric  let Inst{12-10} = Pg;
37800b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
37810b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
37820b57cec5SDimitry Andric
37830b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
37845ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
37850b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
378606c3fb27SDimitry Andric  let hasSideEffects = 0;
37870b57cec5SDimitry Andric}
37880b57cec5SDimitry Andric
3789fe6060f1SDimitry Andricmulticlass sve2_int_arith_pred<bits<6> opc, string asm, SDPatternOperator op,
3790fe6060f1SDimitry Andric                               string Ps = "",
3791fe6060f1SDimitry Andric                               DestructiveInstTypeEnum flags=DestructiveOther,
3792fe6060f1SDimitry Andric                               string revname="", bit isReverseInstr=0> {
3793fe6060f1SDimitry Andric  let DestructiveInstType = flags in {
3794fe6060f1SDimitry Andric  def _B : sve2_int_arith_pred<0b00, opc, asm, ZPR8>,
3795fe6060f1SDimitry Andric           SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
3796fe6060f1SDimitry Andric  def _H : sve2_int_arith_pred<0b01, opc, asm, ZPR16>,
3797fe6060f1SDimitry Andric           SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
3798fe6060f1SDimitry Andric  def _S : sve2_int_arith_pred<0b10, opc, asm, ZPR32>,
3799fe6060f1SDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
3800fe6060f1SDimitry Andric  def _D : sve2_int_arith_pred<0b11, opc, asm, ZPR64>,
3801fe6060f1SDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
3802fe6060f1SDimitry Andric  }
38035ffd83dbSDimitry Andric
38045ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
38055ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
38065ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
38075ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
38080b57cec5SDimitry Andric}
38090b57cec5SDimitry Andric
38100b57cec5SDimitry Andricclass sve2_int_sadd_long_accum_pairwise<bits<2> sz, bit U, string asm,
38110b57cec5SDimitry Andric                                        ZPRRegOp zprty1, ZPRRegOp zprty2>
38120b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins PPR3bAny:$Pg, zprty1:$_Zda, zprty2:$Zn),
38130b57cec5SDimitry Andric  asm, "\t$Zda, $Pg/m, $Zn", "", []>, Sched<[]> {
38140b57cec5SDimitry Andric  bits<3> Pg;
38150b57cec5SDimitry Andric  bits<5> Zn;
38160b57cec5SDimitry Andric  bits<5> Zda;
38170b57cec5SDimitry Andric  let Inst{31-24} = 0b01000100;
38180b57cec5SDimitry Andric  let Inst{23-22} = sz;
38190b57cec5SDimitry Andric  let Inst{21-17} = 0b00010;
38200b57cec5SDimitry Andric  let Inst{16}    = U;
38210b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
38220b57cec5SDimitry Andric  let Inst{12-10} = Pg;
38230b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
38240b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
38250b57cec5SDimitry Andric
38260b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
38275ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
38280b57cec5SDimitry Andric  let ElementSize = zprty1.ElementSize;
382906c3fb27SDimitry Andric  let hasSideEffects = 0;
38300b57cec5SDimitry Andric}
38310b57cec5SDimitry Andric
38325ffd83dbSDimitry Andricmulticlass sve2_int_sadd_long_accum_pairwise<bit U, string asm, SDPatternOperator op> {
38330b57cec5SDimitry Andric  def _H : sve2_int_sadd_long_accum_pairwise<0b01, U, asm, ZPR16, ZPR8>;
38340b57cec5SDimitry Andric  def _S : sve2_int_sadd_long_accum_pairwise<0b10, U, asm, ZPR32, ZPR16>;
38350b57cec5SDimitry Andric  def _D : sve2_int_sadd_long_accum_pairwise<0b11, U, asm, ZPR64, ZPR32>;
38365ffd83dbSDimitry Andric
38375ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv16i8, !cast<Instruction>(NAME # _H)>;
38385ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv8i16, !cast<Instruction>(NAME # _S)>;
38395ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv4i32, !cast<Instruction>(NAME # _D)>;
38400b57cec5SDimitry Andric}
38410b57cec5SDimitry Andric
38420b57cec5SDimitry Andricclass sve2_int_un_pred_arit<bits<2> sz, bit Q, bits<2> opc,
38430b57cec5SDimitry Andric                            string asm, ZPRRegOp zprty>
38440b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
38450b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/m, $Zn",
38460b57cec5SDimitry Andric  "",
38470b57cec5SDimitry Andric  []>, Sched<[]> {
38480b57cec5SDimitry Andric  bits<3> Pg;
38490b57cec5SDimitry Andric  bits<5> Zd;
38500b57cec5SDimitry Andric  bits<5> Zn;
38510b57cec5SDimitry Andric  let Inst{31-24} = 0b01000100;
38520b57cec5SDimitry Andric  let Inst{23-22} = sz;
38530b57cec5SDimitry Andric  let Inst{21-20} = 0b00;
38540b57cec5SDimitry Andric  let Inst{19}    = Q;
38550b57cec5SDimitry Andric  let Inst{18}    = 0b0;
38560b57cec5SDimitry Andric  let Inst{17-16} = opc;
38570b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
38580b57cec5SDimitry Andric  let Inst{12-10} = Pg;
38590b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
38600b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
38610b57cec5SDimitry Andric
38620b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
3863fe6060f1SDimitry Andric  let DestructiveInstType = DestructiveUnaryPassthru;
38640b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
386506c3fb27SDimitry Andric  let hasSideEffects = 0;
38660b57cec5SDimitry Andric}
38670b57cec5SDimitry Andric
38685ffd83dbSDimitry Andricmulticlass sve2_int_un_pred_arit_s<bits<3> opc, string asm,
38695ffd83dbSDimitry Andric                                   SDPatternOperator op> {
3870fe6060f1SDimitry Andric  def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>,
3871fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _S, 1>;
3872fe6060f1SDimitry Andric
38735ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
3874fe6060f1SDimitry Andric
387506c3fb27SDimitry Andric  def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
3876fe6060f1SDimitry Andric
387706c3fb27SDimitry Andric  defm : SVE_3_Op_Undef_Pat<nxv4i32, op, nxv4i32, nxv4i1,  nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
38780b57cec5SDimitry Andric}
38790b57cec5SDimitry Andric
38805ffd83dbSDimitry Andricmulticlass sve2_int_un_pred_arit<bits<3> opc, string asm, SDPatternOperator op> {
3881fe6060f1SDimitry Andric  def _B : sve2_int_un_pred_arit<0b00, opc{2}, opc{1-0}, asm, ZPR8>,
3882fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _B, 1>;
3883fe6060f1SDimitry Andric  def _H : sve2_int_un_pred_arit<0b01, opc{2}, opc{1-0}, asm, ZPR16>,
3884fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _H, 1>;
3885fe6060f1SDimitry Andric  def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>,
3886fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _S, 1>;
3887fe6060f1SDimitry Andric  def _D : sve2_int_un_pred_arit<0b11, opc{2}, opc{1-0}, asm, ZPR64>,
3888fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _D, 1>;
38895ffd83dbSDimitry Andric
38905ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
38915ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
38925ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
38935ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
3894fe6060f1SDimitry Andric
389506c3fb27SDimitry Andric  def _B_UNDEF : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
389606c3fb27SDimitry Andric  def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
389706c3fb27SDimitry Andric  def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
389806c3fb27SDimitry Andric  def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
3899fe6060f1SDimitry Andric
390006c3fb27SDimitry Andric  defm : SVE_3_Op_Undef_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
390106c3fb27SDimitry Andric  defm : SVE_3_Op_Undef_Pat<nxv8i16, op, nxv8i16, nxv8i1,  nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
390206c3fb27SDimitry Andric  defm : SVE_3_Op_Undef_Pat<nxv4i32, op, nxv4i32, nxv4i1,  nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
390306c3fb27SDimitry Andric  defm : SVE_3_Op_Undef_Pat<nxv2i64, op, nxv2i64, nxv2i1,  nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
39040b57cec5SDimitry Andric}
39050b57cec5SDimitry Andric
39060b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
39070b57cec5SDimitry Andric// SVE2 Widening Integer Arithmetic Group
39080b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
39090b57cec5SDimitry Andric
39100b57cec5SDimitry Andricclass sve2_wide_int_arith<bits<2> sz, bits<5> opc, string asm,
39110b57cec5SDimitry Andric                          ZPRRegOp zprty1, ZPRRegOp zprty2, ZPRRegOp zprty3>
39120b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm),
39130b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
39140b57cec5SDimitry Andric  bits<5> Zd;
39150b57cec5SDimitry Andric  bits<5> Zn;
39160b57cec5SDimitry Andric  bits<5> Zm;
39170b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
39180b57cec5SDimitry Andric  let Inst{23-22} = sz;
39190b57cec5SDimitry Andric  let Inst{21}    = 0b0;
39200b57cec5SDimitry Andric  let Inst{20-16} = Zm;
39210b57cec5SDimitry Andric  let Inst{15}    = 0b0;
39220b57cec5SDimitry Andric  let Inst{14-10} = opc;
39230b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
39240b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
392506c3fb27SDimitry Andric
392606c3fb27SDimitry Andric  let hasSideEffects = 0;
39270b57cec5SDimitry Andric}
39280b57cec5SDimitry Andric
39295ffd83dbSDimitry Andricmulticlass sve2_wide_int_arith_long<bits<5> opc, string asm,
39305ffd83dbSDimitry Andric                                    SDPatternOperator op> {
39310b57cec5SDimitry Andric  def _H : sve2_wide_int_arith<0b01, opc, asm, ZPR16, ZPR8, ZPR8>;
39320b57cec5SDimitry Andric  def _S : sve2_wide_int_arith<0b10, opc, asm, ZPR32, ZPR16, ZPR16>;
39330b57cec5SDimitry Andric  def _D : sve2_wide_int_arith<0b11, opc, asm, ZPR64, ZPR32, ZPR32>;
39345ffd83dbSDimitry Andric
39355ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
39365ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
39375ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
39380b57cec5SDimitry Andric}
39390b57cec5SDimitry Andric
39405ffd83dbSDimitry Andricmulticlass sve2_wide_int_arith_wide<bits<3> opc, string asm,
39415ffd83dbSDimitry Andric                                    SDPatternOperator op> {
39420b57cec5SDimitry Andric  def _H : sve2_wide_int_arith<0b01, { 0b10, opc }, asm, ZPR16, ZPR16, ZPR8>;
39430b57cec5SDimitry Andric  def _S : sve2_wide_int_arith<0b10, { 0b10, opc }, asm, ZPR32, ZPR32, ZPR16>;
39440b57cec5SDimitry Andric  def _D : sve2_wide_int_arith<0b11, { 0b10, opc }, asm, ZPR64, ZPR64, ZPR32>;
39455ffd83dbSDimitry Andric
39465ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, !cast<Instruction>(NAME # _H)>;
39475ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, !cast<Instruction>(NAME # _S)>;
39485ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, !cast<Instruction>(NAME # _D)>;
39490b57cec5SDimitry Andric}
39500b57cec5SDimitry Andric
39515ffd83dbSDimitry Andricmulticlass sve2_wide_int_arith_pmul<bits<2> sz, bits<5> opc, string asm,
39525ffd83dbSDimitry Andric                                     SDPatternOperator op> {
39535ffd83dbSDimitry Andric  def NAME : sve2_wide_int_arith<sz, opc, asm, ZPR128, ZPR64, ZPR64>;
39545ffd83dbSDimitry Andric
39555ffd83dbSDimitry Andric  // To avoid using 128 bit elements in the IR, the pattern below works with
39565ffd83dbSDimitry Andric  // llvm intrinsics with the _pair suffix, to reflect that
39575ffd83dbSDimitry Andric  // _Q is implemented as a pair of _D.
39585ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
39595ffd83dbSDimitry Andric}
39605ffd83dbSDimitry Andric
39615ffd83dbSDimitry Andricmulticlass sve2_pmul_long<bits<1> opc, string asm, SDPatternOperator op> {
39620b57cec5SDimitry Andric  def _H : sve2_wide_int_arith<0b01, {0b1101, opc}, asm, ZPR16, ZPR8, ZPR8>;
39630b57cec5SDimitry Andric  def _D : sve2_wide_int_arith<0b11, {0b1101, opc}, asm, ZPR64, ZPR32, ZPR32>;
39645ffd83dbSDimitry Andric
39655ffd83dbSDimitry Andric  // To avoid using 128 bit elements in the IR, the patterns below work with
39665ffd83dbSDimitry Andric  // llvm intrinsics with the _pair suffix, to reflect that
39675ffd83dbSDimitry Andric  // _H is implemented as a pair of _B and _D is implemented as a pair of _S.
39685ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
39695ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
39700b57cec5SDimitry Andric}
39710b57cec5SDimitry Andric
39720b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
39730b57cec5SDimitry Andric// SVE2 Misc Group
39740b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
39750b57cec5SDimitry Andric
39760b57cec5SDimitry Andricclass sve2_misc<bits<2> sz, bits<4> opc, string asm,
39770b57cec5SDimitry Andric                ZPRRegOp zprty1, ZPRRegOp zprty2>
39780b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
39790b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
39800b57cec5SDimitry Andric  bits<5> Zd;
39810b57cec5SDimitry Andric  bits<5> Zn;
39820b57cec5SDimitry Andric  bits<5> Zm;
39830b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
39840b57cec5SDimitry Andric  let Inst{23-22} = sz;
39850b57cec5SDimitry Andric  let Inst{21}    = 0b0;
39860b57cec5SDimitry Andric  let Inst{20-16} = Zm;
39870b57cec5SDimitry Andric  let Inst{15-14} = 0b10;
39880b57cec5SDimitry Andric  let Inst{13-10} = opc;
39890b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
39900b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
399106c3fb27SDimitry Andric
399206c3fb27SDimitry Andric  let hasSideEffects = 0;
39930b57cec5SDimitry Andric}
39940b57cec5SDimitry Andric
39955ffd83dbSDimitry Andricmulticlass sve2_misc_bitwise<bits<4> opc, string asm, SDPatternOperator op> {
39960b57cec5SDimitry Andric  def _B : sve2_misc<0b00, opc, asm, ZPR8, ZPR8>;
39970b57cec5SDimitry Andric  def _H : sve2_misc<0b01, opc, asm, ZPR16, ZPR16>;
39980b57cec5SDimitry Andric  def _S : sve2_misc<0b10, opc, asm, ZPR32, ZPR32>;
39990b57cec5SDimitry Andric  def _D : sve2_misc<0b11, opc, asm, ZPR64, ZPR64>;
40005ffd83dbSDimitry Andric
40015ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
40025ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
40035ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
40045ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
40050b57cec5SDimitry Andric}
40060b57cec5SDimitry Andric
40075ffd83dbSDimitry Andricmulticlass sve2_misc_int_addsub_long_interleaved<bits<2> opc, string asm,
40085ffd83dbSDimitry Andric                                                 SDPatternOperator op> {
40090b57cec5SDimitry Andric  def _H : sve2_misc<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
40100b57cec5SDimitry Andric  def _S : sve2_misc<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
40110b57cec5SDimitry Andric  def _D : sve2_misc<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
40125ffd83dbSDimitry Andric
40135ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
40145ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
40155ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
40160b57cec5SDimitry Andric}
40170b57cec5SDimitry Andric
40180b57cec5SDimitry Andricclass sve2_bitwise_xor_interleaved<bits<2> sz, bits<1> opc, string asm,
40190b57cec5SDimitry Andric                                   ZPRRegOp zprty1, ZPRRegOp zprty2>
40200b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
40210b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
40220b57cec5SDimitry Andric  bits<5> Zd;
40230b57cec5SDimitry Andric  bits<5> Zn;
40240b57cec5SDimitry Andric  bits<5> Zm;
40250b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
40260b57cec5SDimitry Andric  let Inst{23-22} = sz;
40270b57cec5SDimitry Andric  let Inst{21}    = 0b0;
40280b57cec5SDimitry Andric  let Inst{20-16} = Zm;
40290b57cec5SDimitry Andric  let Inst{15-11} = 0b10010;
40300b57cec5SDimitry Andric  let Inst{10}    = opc;
40310b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
40320b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
40330b57cec5SDimitry Andric
40340b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
40355ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
40360b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
403706c3fb27SDimitry Andric  let hasSideEffects = 0;
40380b57cec5SDimitry Andric}
40390b57cec5SDimitry Andric
40405ffd83dbSDimitry Andricmulticlass sve2_bitwise_xor_interleaved<bit opc, string asm,
40415ffd83dbSDimitry Andric                                        SDPatternOperator op> {
40420b57cec5SDimitry Andric  def _B : sve2_bitwise_xor_interleaved<0b00, opc, asm, ZPR8,  ZPR8>;
40430b57cec5SDimitry Andric  def _H : sve2_bitwise_xor_interleaved<0b01, opc, asm, ZPR16, ZPR16>;
40440b57cec5SDimitry Andric  def _S : sve2_bitwise_xor_interleaved<0b10, opc, asm, ZPR32, ZPR32>;
40450b57cec5SDimitry Andric  def _D : sve2_bitwise_xor_interleaved<0b11, opc, asm, ZPR64, ZPR64>;
40465ffd83dbSDimitry Andric
40475ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
40485ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
40495ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
40505ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
40510b57cec5SDimitry Andric}
40520b57cec5SDimitry Andric
40530b57cec5SDimitry Andricclass sve2_bitwise_shift_left_long<bits<3> tsz8_64, bits<2> opc, string asm,
40540b57cec5SDimitry Andric                                   ZPRRegOp zprty1, ZPRRegOp zprty2,
40550b57cec5SDimitry Andric                                   Operand immtype>
40560b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
40570b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $imm",
40580b57cec5SDimitry Andric  "", []>, Sched<[]> {
40590b57cec5SDimitry Andric  bits<5> Zd;
40600b57cec5SDimitry Andric  bits<5> Zn;
40610b57cec5SDimitry Andric  bits<5> imm;
40620b57cec5SDimitry Andric  let Inst{31-23} = 0b010001010;
40630b57cec5SDimitry Andric  let Inst{22}    = tsz8_64{2};
40640b57cec5SDimitry Andric  let Inst{21}    = 0b0;
40650b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
40660b57cec5SDimitry Andric  let Inst{18-16} = imm{2-0}; // imm3
40670b57cec5SDimitry Andric  let Inst{15-12} = 0b1010;
40680b57cec5SDimitry Andric  let Inst{11-10} = opc;
40690b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
40700b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
407106c3fb27SDimitry Andric
407206c3fb27SDimitry Andric  let hasSideEffects = 0;
40730b57cec5SDimitry Andric}
40740b57cec5SDimitry Andric
40755ffd83dbSDimitry Andricmulticlass sve2_bitwise_shift_left_long<bits<2> opc, string asm,
40765ffd83dbSDimitry Andric                                        SDPatternOperator op> {
40770b57cec5SDimitry Andric  def _H : sve2_bitwise_shift_left_long<{0,0,1}, opc, asm,
40780b57cec5SDimitry Andric                                        ZPR16, ZPR8, vecshiftL8>;
40790b57cec5SDimitry Andric  def _S : sve2_bitwise_shift_left_long<{0,1,?}, opc, asm,
40800b57cec5SDimitry Andric                                        ZPR32, ZPR16, vecshiftL16> {
40810b57cec5SDimitry Andric    let Inst{19} = imm{3};
40820b57cec5SDimitry Andric  }
40830b57cec5SDimitry Andric  def _D : sve2_bitwise_shift_left_long<{1,?,?}, opc, asm,
40840b57cec5SDimitry Andric                                        ZPR64, ZPR32, vecshiftL32> {
40850b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
40860b57cec5SDimitry Andric  }
40875ffd83dbSDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv8i16, op, nxv16i8, i32, tvecshiftL8,  !cast<Instruction>(NAME # _H)>;
40885ffd83dbSDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv4i32, op, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _S)>;
40895ffd83dbSDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv2i64, op, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _D)>;
40900b57cec5SDimitry Andric}
40910b57cec5SDimitry Andric
40920b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
40930b57cec5SDimitry Andric// SVE2 Accumulate Group
40940b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
40950b57cec5SDimitry Andric
40960b57cec5SDimitry Andricclass sve2_int_bin_shift_imm<bits<4> tsz8_64, bit opc, string asm,
40970b57cec5SDimitry Andric                             ZPRRegOp zprty, Operand immtype>
40980b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, immtype:$imm),
40990b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $imm",
41000b57cec5SDimitry Andric  "", []>, Sched<[]> {
41010b57cec5SDimitry Andric  bits<5> Zd;
41020b57cec5SDimitry Andric  bits<5> Zn;
41030b57cec5SDimitry Andric  bits<6> imm;
41040b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
41050b57cec5SDimitry Andric  let Inst{23-22} = tsz8_64{3-2};
41060b57cec5SDimitry Andric  let Inst{21}    = 0b0;
41070b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
41080b57cec5SDimitry Andric  let Inst{18-16} = imm{2-0}; // imm3
41090b57cec5SDimitry Andric  let Inst{15-11} = 0b11110;
41100b57cec5SDimitry Andric  let Inst{10}    = opc;
41110b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
41120b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
41130b57cec5SDimitry Andric
41140b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
411506c3fb27SDimitry Andric  let hasSideEffects = 0;
41160b57cec5SDimitry Andric}
41170b57cec5SDimitry Andric
41185ffd83dbSDimitry Andricmulticlass sve2_int_bin_shift_imm_left<bit opc, string asm,
41195ffd83dbSDimitry Andric                                       SDPatternOperator op> {
41200b57cec5SDimitry Andric  def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
41210b57cec5SDimitry Andric  def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
41220b57cec5SDimitry Andric    let Inst{19} = imm{3};
41230b57cec5SDimitry Andric  }
41240b57cec5SDimitry Andric  def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
41250b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
41260b57cec5SDimitry Andric  }
41270b57cec5SDimitry Andric  def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
41280b57cec5SDimitry Andric    let Inst{22}    = imm{5};
41290b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
41300b57cec5SDimitry Andric  }
41315ffd83dbSDimitry Andric
41325ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftL8,  !cast<Instruction>(NAME # _B)>;
41335ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _H)>;
41345ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _S)>;
41355ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftL64, !cast<Instruction>(NAME # _D)>;
41360b57cec5SDimitry Andric}
41370b57cec5SDimitry Andric
41385ffd83dbSDimitry Andricmulticlass sve2_int_bin_shift_imm_right<bit opc, string asm,
41395ffd83dbSDimitry Andric                                        SDPatternOperator op> {
41400b57cec5SDimitry Andric  def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
41410b57cec5SDimitry Andric  def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
41420b57cec5SDimitry Andric    let Inst{19} = imm{3};
41430b57cec5SDimitry Andric  }
41440b57cec5SDimitry Andric  def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
41450b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
41460b57cec5SDimitry Andric  }
41470b57cec5SDimitry Andric  def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
41480b57cec5SDimitry Andric    let Inst{22}    = imm{5};
41490b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
41500b57cec5SDimitry Andric  }
41515ffd83dbSDimitry Andric
41525ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8,  !cast<Instruction>(NAME # _B)>;
41535ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
41545ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
41555ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
41560b57cec5SDimitry Andric}
41570b57cec5SDimitry Andric
41580b57cec5SDimitry Andricclass sve2_int_bin_accum_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
41590b57cec5SDimitry Andric                                   ZPRRegOp zprty, Operand immtype>
41600b57cec5SDimitry Andric: I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, immtype:$imm),
41610b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $imm",
41620b57cec5SDimitry Andric  "", []>, Sched<[]> {
41630b57cec5SDimitry Andric  bits<5> Zda;
41640b57cec5SDimitry Andric  bits<5> Zn;
41650b57cec5SDimitry Andric  bits<6> imm;
41660b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
41670b57cec5SDimitry Andric  let Inst{23-22} = tsz8_64{3-2};
41680b57cec5SDimitry Andric  let Inst{21}    = 0b0;
41690b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
41700b57cec5SDimitry Andric  let Inst{18-16} = imm{2-0}; // imm3
41710b57cec5SDimitry Andric  let Inst{15-12} = 0b1110;
41720b57cec5SDimitry Andric  let Inst{11-10} = opc;
41730b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
41740b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
41750b57cec5SDimitry Andric
41760b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
41775ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
41780b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
417906c3fb27SDimitry Andric  let hasSideEffects = 0;
41800b57cec5SDimitry Andric}
41810b57cec5SDimitry Andric
41825ffd83dbSDimitry Andricmulticlass sve2_int_bin_accum_shift_imm_right<bits<2> opc, string asm,
418381ad6265SDimitry Andric                                              SDPatternOperator op,
418481ad6265SDimitry Andric                                              SDPatternOperator shift_op = null_frag> {
41850b57cec5SDimitry Andric  def _B : sve2_int_bin_accum_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
41860b57cec5SDimitry Andric  def _H : sve2_int_bin_accum_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
41870b57cec5SDimitry Andric    let Inst{19} = imm{3};
41880b57cec5SDimitry Andric  }
41890b57cec5SDimitry Andric  def _S : sve2_int_bin_accum_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
41900b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
41910b57cec5SDimitry Andric  }
41920b57cec5SDimitry Andric  def _D : sve2_int_bin_accum_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
41930b57cec5SDimitry Andric    let Inst{22}    = imm{5};
41940b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
41950b57cec5SDimitry Andric  }
41965ffd83dbSDimitry Andric
41975ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8,  !cast<Instruction>(NAME # _B)>;
41985ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
41995ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
42005ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
420181ad6265SDimitry Andric
420281ad6265SDimitry Andric  def : SVE_Shift_Add_All_Active_Pat<nxv16i8, shift_op, nxv16i1, nxv16i8, nxv16i8, i32, !cast<Instruction>(NAME # _B)>;
420381ad6265SDimitry Andric  def : SVE_Shift_Add_All_Active_Pat<nxv8i16, shift_op, nxv8i1, nxv8i16, nxv8i16, i32, !cast<Instruction>(NAME # _H)>;
420481ad6265SDimitry Andric  def : SVE_Shift_Add_All_Active_Pat<nxv4i32, shift_op, nxv4i1, nxv4i32, nxv4i32, i32, !cast<Instruction>(NAME # _S)>;
420581ad6265SDimitry Andric  def : SVE_Shift_Add_All_Active_Pat<nxv2i64, shift_op, nxv2i1, nxv2i64, nxv2i64, i32, !cast<Instruction>(NAME # _D)>;
42060b57cec5SDimitry Andric}
42070b57cec5SDimitry Andric
42080b57cec5SDimitry Andricclass sve2_int_cadd<bits<2> sz, bit opc, string asm, ZPRRegOp zprty>
42090b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, complexrotateopodd:$rot),
42100b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $Zm, $rot", "", []>, Sched<[]> {
42110b57cec5SDimitry Andric  bits<5> Zdn;
42120b57cec5SDimitry Andric  bits<5> Zm;
42130b57cec5SDimitry Andric  bit rot;
42140b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
42150b57cec5SDimitry Andric  let Inst{23-22} = sz;
42160b57cec5SDimitry Andric  let Inst{21-17} = 0b00000;
42170b57cec5SDimitry Andric  let Inst{16}    = opc;
42180b57cec5SDimitry Andric  let Inst{15-11} = 0b11011;
42190b57cec5SDimitry Andric  let Inst{10}    = rot;
42200b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
42210b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
42220b57cec5SDimitry Andric
42230b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
42245ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
42250b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
422606c3fb27SDimitry Andric  let hasSideEffects = 0;
42270b57cec5SDimitry Andric}
42280b57cec5SDimitry Andric
42295ffd83dbSDimitry Andricmulticlass sve2_int_cadd<bit opc, string asm, SDPatternOperator op> {
42300b57cec5SDimitry Andric  def _B : sve2_int_cadd<0b00, opc, asm, ZPR8>;
42310b57cec5SDimitry Andric  def _H : sve2_int_cadd<0b01, opc, asm, ZPR16>;
42320b57cec5SDimitry Andric  def _S : sve2_int_cadd<0b10, opc, asm, ZPR32>;
42330b57cec5SDimitry Andric  def _D : sve2_int_cadd<0b11, opc, asm, ZPR64>;
42345ffd83dbSDimitry Andric
42355ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, complexrotateopodd, !cast<Instruction>(NAME # _B)>;
42365ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, complexrotateopodd, !cast<Instruction>(NAME # _H)>;
42375ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, complexrotateopodd, !cast<Instruction>(NAME # _S)>;
42385ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, complexrotateopodd, !cast<Instruction>(NAME # _D)>;
42390b57cec5SDimitry Andric}
42400b57cec5SDimitry Andric
42410b57cec5SDimitry Andricclass sve2_int_absdiff_accum<bits<2> sz, bits<4> opc, string asm,
42420b57cec5SDimitry Andric                             ZPRRegOp zprty1, ZPRRegOp zprty2>
42430b57cec5SDimitry Andric: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
42440b57cec5SDimitry Andric  asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
42450b57cec5SDimitry Andric  bits<5> Zda;
42460b57cec5SDimitry Andric  bits<5> Zn;
42470b57cec5SDimitry Andric  bits<5> Zm;
42480b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
42490b57cec5SDimitry Andric  let Inst{23-22} = sz;
42500b57cec5SDimitry Andric  let Inst{21}    = 0b0;
42510b57cec5SDimitry Andric  let Inst{20-16} = Zm;
42520b57cec5SDimitry Andric  let Inst{15-14} = 0b11;
42530b57cec5SDimitry Andric  let Inst{13-10} = opc;
42540b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
42550b57cec5SDimitry Andric  let Inst{4-0}   = Zda;
42560b57cec5SDimitry Andric
42570b57cec5SDimitry Andric  let Constraints = "$Zda = $_Zda";
42585ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
42590b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
426006c3fb27SDimitry Andric  let hasSideEffects = 0;
42610b57cec5SDimitry Andric}
42620b57cec5SDimitry Andric
42635ffd83dbSDimitry Andricmulticlass sve2_int_absdiff_accum<bit opc, string asm, SDPatternOperator op> {
42640b57cec5SDimitry Andric  def _B : sve2_int_absdiff_accum<0b00, { 0b111, opc }, asm, ZPR8, ZPR8>;
42650b57cec5SDimitry Andric  def _H : sve2_int_absdiff_accum<0b01, { 0b111, opc }, asm, ZPR16, ZPR16>;
42660b57cec5SDimitry Andric  def _S : sve2_int_absdiff_accum<0b10, { 0b111, opc }, asm, ZPR32, ZPR32>;
42670b57cec5SDimitry Andric  def _D : sve2_int_absdiff_accum<0b11, { 0b111, opc }, asm, ZPR64, ZPR64>;
42685ffd83dbSDimitry Andric
42695ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
42705ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
42715ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
42725ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
42730b57cec5SDimitry Andric}
42740b57cec5SDimitry Andric
42755ffd83dbSDimitry Andricmulticlass sve2_int_absdiff_accum_long<bits<2> opc, string asm,
42765ffd83dbSDimitry Andric                                       SDPatternOperator op> {
42770b57cec5SDimitry Andric  def _H : sve2_int_absdiff_accum<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
42780b57cec5SDimitry Andric  def _S : sve2_int_absdiff_accum<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
42790b57cec5SDimitry Andric  def _D : sve2_int_absdiff_accum<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
42805ffd83dbSDimitry Andric
42815ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
42825ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
42835ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
42840b57cec5SDimitry Andric}
42850b57cec5SDimitry Andric
4286e8d8bef9SDimitry Andricmulticlass sve2_int_addsub_long_carry<bits<2> opc, string asm,
4287e8d8bef9SDimitry Andric                                      SDPatternOperator op> {
42880b57cec5SDimitry Andric  def _S : sve2_int_absdiff_accum<{ opc{1}, 0b0 }, { 0b010, opc{0} }, asm,
42890b57cec5SDimitry Andric                                  ZPR32, ZPR32>;
42900b57cec5SDimitry Andric  def _D : sve2_int_absdiff_accum<{ opc{1}, 0b1 }, { 0b010, opc{0} }, asm,
42910b57cec5SDimitry Andric                                  ZPR64, ZPR64>;
42925ffd83dbSDimitry Andric
42935ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
42945ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
42950b57cec5SDimitry Andric}
42960b57cec5SDimitry Andric
42970b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
42980b57cec5SDimitry Andric// SVE2 Narrowing Group
42990b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
43000b57cec5SDimitry Andric
43010b57cec5SDimitry Andricclass sve2_int_bin_shift_imm_narrow_bottom<bits<3> tsz8_64, bits<3> opc,
43020b57cec5SDimitry Andric                                           string asm, ZPRRegOp zprty1,
43030b57cec5SDimitry Andric                                           ZPRRegOp zprty2, Operand immtype>
43040b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
43050b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $imm",
43060b57cec5SDimitry Andric  "", []>, Sched<[]> {
43070b57cec5SDimitry Andric  bits<5> Zd;
43080b57cec5SDimitry Andric  bits<5> Zn;
43090b57cec5SDimitry Andric  bits<5> imm;
43100b57cec5SDimitry Andric  let Inst{31-23} = 0b010001010;
43110b57cec5SDimitry Andric  let Inst{22}    = tsz8_64{2};
43120b57cec5SDimitry Andric  let Inst{21}    = 0b1;
43130b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
43140b57cec5SDimitry Andric  let Inst{18-16} = imm{2-0}; // imm3
43150b57cec5SDimitry Andric  let Inst{15-14} = 0b00;
43160b57cec5SDimitry Andric  let Inst{13-11} = opc;
43170b57cec5SDimitry Andric  let Inst{10}    = 0b0;
43180b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
43190b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
432006c3fb27SDimitry Andric
432106c3fb27SDimitry Andric  let hasSideEffects = 0;
43220b57cec5SDimitry Andric}
43230b57cec5SDimitry Andric
4324480093f4SDimitry Andricmulticlass sve2_int_bin_shift_imm_right_narrow_bottom<bits<3> opc, string asm,
4325480093f4SDimitry Andric                                                      SDPatternOperator op> {
43260b57cec5SDimitry Andric  def _B : sve2_int_bin_shift_imm_narrow_bottom<{0,0,1}, opc, asm, ZPR8, ZPR16,
4327480093f4SDimitry Andric                                                tvecshiftR8>;
43280b57cec5SDimitry Andric  def _H : sve2_int_bin_shift_imm_narrow_bottom<{0,1,?}, opc, asm, ZPR16, ZPR32,
4329480093f4SDimitry Andric                                                tvecshiftR16> {
43300b57cec5SDimitry Andric    let Inst{19} = imm{3};
43310b57cec5SDimitry Andric  }
43320b57cec5SDimitry Andric  def _S : sve2_int_bin_shift_imm_narrow_bottom<{1,?,?}, opc, asm, ZPR32, ZPR64,
4333e8d8bef9SDimitry Andric                                                tvecshiftR32> {
43340b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
43350b57cec5SDimitry Andric  }
4336480093f4SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv16i8, op, nxv8i16, i32, tvecshiftR8,  !cast<Instruction>(NAME # _B)>;
4337480093f4SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv8i16, op, nxv4i32, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
4338480093f4SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv4i32, op, nxv2i64, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
43390b57cec5SDimitry Andric}
43400b57cec5SDimitry Andric
43410b57cec5SDimitry Andricclass sve2_int_bin_shift_imm_narrow_top<bits<3> tsz8_64, bits<3> opc,
43420b57cec5SDimitry Andric                                        string asm, ZPRRegOp zprty1,
43430b57cec5SDimitry Andric                                        ZPRRegOp zprty2, Operand immtype>
43440b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, immtype:$imm),
43450b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $imm",
43460b57cec5SDimitry Andric  "", []>, Sched<[]> {
43470b57cec5SDimitry Andric  bits<5> Zd;
43480b57cec5SDimitry Andric  bits<5> Zn;
43490b57cec5SDimitry Andric  bits<5> imm;
43500b57cec5SDimitry Andric  let Inst{31-23} = 0b010001010;
43510b57cec5SDimitry Andric  let Inst{22}    = tsz8_64{2};
43520b57cec5SDimitry Andric  let Inst{21}    = 0b1;
43530b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
43540b57cec5SDimitry Andric  let Inst{18-16} = imm{2-0}; // imm3
43550b57cec5SDimitry Andric  let Inst{15-14} = 0b00;
43560b57cec5SDimitry Andric  let Inst{13-11} = opc;
43570b57cec5SDimitry Andric  let Inst{10}    = 0b1;
43580b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
43590b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
43600b57cec5SDimitry Andric
43610b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
436206c3fb27SDimitry Andric  let hasSideEffects = 0;
43630b57cec5SDimitry Andric}
43640b57cec5SDimitry Andric
4365480093f4SDimitry Andricmulticlass sve2_int_bin_shift_imm_right_narrow_top<bits<3> opc, string asm,
4366480093f4SDimitry Andric                                                   SDPatternOperator op> {
43670b57cec5SDimitry Andric  def _B : sve2_int_bin_shift_imm_narrow_top<{0,0,1}, opc, asm, ZPR8, ZPR16,
4368480093f4SDimitry Andric                                             tvecshiftR8>;
43690b57cec5SDimitry Andric  def _H : sve2_int_bin_shift_imm_narrow_top<{0,1,?}, opc, asm, ZPR16, ZPR32,
4370480093f4SDimitry Andric                                             tvecshiftR16> {
43710b57cec5SDimitry Andric    let Inst{19} = imm{3};
43720b57cec5SDimitry Andric  }
43730b57cec5SDimitry Andric  def _S : sve2_int_bin_shift_imm_narrow_top<{1,?,?}, opc, asm, ZPR32, ZPR64,
4374e8d8bef9SDimitry Andric                                             tvecshiftR32> {
43750b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
43760b57cec5SDimitry Andric  }
4377480093f4SDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv8i16, i32, tvecshiftR8,  !cast<Instruction>(NAME # _B)>;
4378480093f4SDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv4i32, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
4379480093f4SDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv2i64, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
43800b57cec5SDimitry Andric}
43810b57cec5SDimitry Andric
43820b57cec5SDimitry Andricclass sve2_int_addsub_narrow_high_bottom<bits<2> sz, bits<2> opc, string asm,
43830b57cec5SDimitry Andric                                         ZPRRegOp zprty1, ZPRRegOp zprty2>
43840b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
43850b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
43860b57cec5SDimitry Andric  bits<5> Zd;
43870b57cec5SDimitry Andric  bits<5> Zn;
43880b57cec5SDimitry Andric  bits<5> Zm;
43890b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
43900b57cec5SDimitry Andric  let Inst{23-22} = sz;
43910b57cec5SDimitry Andric  let Inst{21}    = 0b1;
43920b57cec5SDimitry Andric  let Inst{20-16} = Zm;
43930b57cec5SDimitry Andric  let Inst{15-13} = 0b011;
43940b57cec5SDimitry Andric  let Inst{12-11} = opc; // S, R
43950b57cec5SDimitry Andric  let Inst{10}    = 0b0; // Top
43960b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
43970b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
439806c3fb27SDimitry Andric
439906c3fb27SDimitry Andric  let hasSideEffects = 0;
44000b57cec5SDimitry Andric}
44010b57cec5SDimitry Andric
4402480093f4SDimitry Andricmulticlass sve2_int_addsub_narrow_high_bottom<bits<2> opc, string asm,
4403480093f4SDimitry Andric                                              SDPatternOperator op> {
44040b57cec5SDimitry Andric  def _B : sve2_int_addsub_narrow_high_bottom<0b01, opc, asm, ZPR8, ZPR16>;
44050b57cec5SDimitry Andric  def _H : sve2_int_addsub_narrow_high_bottom<0b10, opc, asm, ZPR16, ZPR32>;
44060b57cec5SDimitry Andric  def _S : sve2_int_addsub_narrow_high_bottom<0b11, opc, asm, ZPR32, ZPR64>;
4407480093f4SDimitry Andric
4408480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _B)>;
4409480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _H)>;
4410480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _S)>;
44110b57cec5SDimitry Andric}
44120b57cec5SDimitry Andric
44130b57cec5SDimitry Andricclass sve2_int_addsub_narrow_high_top<bits<2> sz, bits<2> opc, string asm,
44140b57cec5SDimitry Andric                                      ZPRRegOp zprty1, ZPRRegOp zprty2>
44150b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
44160b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
44170b57cec5SDimitry Andric  bits<5> Zd;
44180b57cec5SDimitry Andric  bits<5> Zn;
44190b57cec5SDimitry Andric  bits<5> Zm;
44200b57cec5SDimitry Andric  let Inst{31-24} = 0b01000101;
44210b57cec5SDimitry Andric  let Inst{23-22} = sz;
44220b57cec5SDimitry Andric  let Inst{21}    = 0b1;
44230b57cec5SDimitry Andric  let Inst{20-16} = Zm;
44240b57cec5SDimitry Andric  let Inst{15-13} = 0b011;
44250b57cec5SDimitry Andric  let Inst{12-11} = opc; // S, R
44260b57cec5SDimitry Andric  let Inst{10}    = 0b1; // Top
44270b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
44280b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
44290b57cec5SDimitry Andric
44300b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
443106c3fb27SDimitry Andric  let hasSideEffects = 0;
44320b57cec5SDimitry Andric}
44330b57cec5SDimitry Andric
4434480093f4SDimitry Andricmulticlass sve2_int_addsub_narrow_high_top<bits<2> opc, string asm,
4435480093f4SDimitry Andric                                           SDPatternOperator op> {
44360b57cec5SDimitry Andric  def _B : sve2_int_addsub_narrow_high_top<0b01, opc, asm, ZPR8, ZPR16>;
44370b57cec5SDimitry Andric  def _H : sve2_int_addsub_narrow_high_top<0b10, opc, asm, ZPR16, ZPR32>;
44380b57cec5SDimitry Andric  def _S : sve2_int_addsub_narrow_high_top<0b11, opc, asm, ZPR32, ZPR64>;
4439480093f4SDimitry Andric
4440480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _B)>;
4441480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _H)>;
4442480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _S)>;
44430b57cec5SDimitry Andric}
44440b57cec5SDimitry Andric
44450b57cec5SDimitry Andricclass sve2_int_sat_extract_narrow_bottom<bits<3> tsz8_64, bits<2> opc, string asm,
44460b57cec5SDimitry Andric                                         ZPRRegOp zprty1, ZPRRegOp zprty2>
44470b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty2:$Zn),
44480b57cec5SDimitry Andric  asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
44490b57cec5SDimitry Andric  bits<5> Zd;
44500b57cec5SDimitry Andric  bits<5> Zn;
44510b57cec5SDimitry Andric  let Inst{31-23} = 0b010001010;
44520b57cec5SDimitry Andric  let Inst{22}    = tsz8_64{2};
44530b57cec5SDimitry Andric  let Inst{21}    = 0b1;
44540b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
44550b57cec5SDimitry Andric  let Inst{18-13} = 0b000010;
44560b57cec5SDimitry Andric  let Inst{12-11} = opc;
44570b57cec5SDimitry Andric  let Inst{10}    = 0b0;
44580b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
44590b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
446006c3fb27SDimitry Andric
446106c3fb27SDimitry Andric  let hasSideEffects = 0;
44620b57cec5SDimitry Andric}
44630b57cec5SDimitry Andric
4464480093f4SDimitry Andricmulticlass sve2_int_sat_extract_narrow_bottom<bits<2> opc, string asm,
4465480093f4SDimitry Andric                                              SDPatternOperator op> {
44660b57cec5SDimitry Andric  def _B : sve2_int_sat_extract_narrow_bottom<0b001, opc, asm, ZPR8, ZPR16>;
44670b57cec5SDimitry Andric  def _H : sve2_int_sat_extract_narrow_bottom<0b010, opc, asm, ZPR16, ZPR32>;
44680b57cec5SDimitry Andric  def _S : sve2_int_sat_extract_narrow_bottom<0b100, opc, asm, ZPR32, ZPR64>;
4469480093f4SDimitry Andric
4470480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv16i8, op, nxv8i16, !cast<Instruction>(NAME # _B)>;
4471480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv8i16, op, nxv4i32, !cast<Instruction>(NAME # _H)>;
4472480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv4i32, op, nxv2i64, !cast<Instruction>(NAME # _S)>;
44730b57cec5SDimitry Andric}
44740b57cec5SDimitry Andric
44750b57cec5SDimitry Andricclass sve2_int_sat_extract_narrow_top<bits<3> tsz8_64, bits<2> opc, string asm,
44760b57cec5SDimitry Andric                                      ZPRRegOp zprty1, ZPRRegOp zprty2>
44770b57cec5SDimitry Andric: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn),
44780b57cec5SDimitry Andric  asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
44790b57cec5SDimitry Andric  bits<5> Zd;
44800b57cec5SDimitry Andric  bits<5> Zn;
44810b57cec5SDimitry Andric  let Inst{31-23} = 0b010001010;
44820b57cec5SDimitry Andric  let Inst{22}    = tsz8_64{2};
44830b57cec5SDimitry Andric  let Inst{21}    = 0b1;
44840b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
44850b57cec5SDimitry Andric  let Inst{18-13} = 0b000010;
44860b57cec5SDimitry Andric  let Inst{12-11} = opc;
44870b57cec5SDimitry Andric  let Inst{10}    = 0b1;
44880b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
44890b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
44900b57cec5SDimitry Andric
44910b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
449206c3fb27SDimitry Andric  let hasSideEffects = 0;
44930b57cec5SDimitry Andric}
44940b57cec5SDimitry Andric
4495480093f4SDimitry Andricmulticlass sve2_int_sat_extract_narrow_top<bits<2> opc, string asm,
4496480093f4SDimitry Andric                                           SDPatternOperator op> {
44970b57cec5SDimitry Andric  def _B : sve2_int_sat_extract_narrow_top<0b001, opc, asm, ZPR8, ZPR16>;
44980b57cec5SDimitry Andric  def _H : sve2_int_sat_extract_narrow_top<0b010, opc, asm, ZPR16, ZPR32>;
44990b57cec5SDimitry Andric  def _S : sve2_int_sat_extract_narrow_top<0b100, opc, asm, ZPR32, ZPR64>;
4500480093f4SDimitry Andric
4501480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv8i16, !cast<Instruction>(NAME # _B)>;
4502480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv4i32, !cast<Instruction>(NAME # _H)>;
4503480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
45040b57cec5SDimitry Andric}
45050b57cec5SDimitry Andric
45060b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
45070b57cec5SDimitry Andric// SVE Integer Arithmetic - Unary Predicated Group
45080b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
45090b57cec5SDimitry Andric
45100b57cec5SDimitry Andricclass sve_int_un_pred_arit<bits<2> sz8_64, bits<4> opc,
45110b57cec5SDimitry Andric                             string asm, ZPRRegOp zprty>
45120b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
45130b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/m, $Zn",
45140b57cec5SDimitry Andric  "",
45150b57cec5SDimitry Andric  []>, Sched<[]> {
45160b57cec5SDimitry Andric  bits<3> Pg;
45170b57cec5SDimitry Andric  bits<5> Zd;
45180b57cec5SDimitry Andric  bits<5> Zn;
45190b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
45200b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
45210b57cec5SDimitry Andric  let Inst{21-20} = 0b01;
45220b57cec5SDimitry Andric  let Inst{19}    = opc{0};
45230b57cec5SDimitry Andric  let Inst{18-16} = opc{3-1};
45240b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
45250b57cec5SDimitry Andric  let Inst{12-10} = Pg;
45260b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
45270b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
45280b57cec5SDimitry Andric
45290b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
4530fe6060f1SDimitry Andric  let DestructiveInstType = DestructiveUnaryPassthru;
45310b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
453206c3fb27SDimitry Andric  let hasSideEffects = 0;
45330b57cec5SDimitry Andric}
45340b57cec5SDimitry Andric
45358bcb0991SDimitry Andricmulticlass sve_int_un_pred_arit_0<bits<3> opc, string asm,
45368bcb0991SDimitry Andric                                  SDPatternOperator op> {
4537fe6060f1SDimitry Andric  def _B : sve_int_un_pred_arit<0b00, { opc, 0b0 }, asm, ZPR8>,
4538fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _B, 1>;
4539fe6060f1SDimitry Andric  def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>,
4540fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _H, 1>;
4541fe6060f1SDimitry Andric  def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
4542fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _S, 1>;
4543fe6060f1SDimitry Andric  def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
4544fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _D, 1>;
45458bcb0991SDimitry Andric
4546e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
4547e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
4548e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
4549e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
4550fe6060f1SDimitry Andric
455106c3fb27SDimitry Andric  def _B_UNDEF : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
455206c3fb27SDimitry Andric  def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
455306c3fb27SDimitry Andric  def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
455406c3fb27SDimitry Andric  def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4555fe6060f1SDimitry Andric
455606c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
455706c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
455806c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
455906c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
45600b57cec5SDimitry Andric}
45610b57cec5SDimitry Andric
4562480093f4SDimitry Andricmulticlass sve_int_un_pred_arit_0_h<bits<3> opc, string asm,
4563480093f4SDimitry Andric                                    SDPatternOperator op> {
4564fe6060f1SDimitry Andric  def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>,
4565fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _H, 1>;
4566fe6060f1SDimitry Andric  def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
4567fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _S, 1>;
4568fe6060f1SDimitry Andric  def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
4569fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _D, 1>;
4570480093f4SDimitry Andric
4571e8d8bef9SDimitry Andric  def : SVE_InReg_Extend<nxv8i16, op, nxv8i1, nxv8i8, !cast<Instruction>(NAME # _H)>;
4572e8d8bef9SDimitry Andric  def : SVE_InReg_Extend<nxv4i32, op, nxv4i1, nxv4i8, !cast<Instruction>(NAME # _S)>;
4573e8d8bef9SDimitry Andric  def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i8, !cast<Instruction>(NAME # _D)>;
4574fe6060f1SDimitry Andric
457506c3fb27SDimitry Andric  def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
457606c3fb27SDimitry Andric  def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
457706c3fb27SDimitry Andric  def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4578fe6060f1SDimitry Andric
457906c3fb27SDimitry Andric  defm : SVE_InReg_Extend_PassthruUndef<nxv8i16, op, nxv8i1, nxv8i8, !cast<Pseudo>(NAME # _H_UNDEF)>;
458006c3fb27SDimitry Andric  defm : SVE_InReg_Extend_PassthruUndef<nxv4i32, op, nxv4i1, nxv4i8, !cast<Pseudo>(NAME # _S_UNDEF)>;
458106c3fb27SDimitry Andric  defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i8, !cast<Pseudo>(NAME # _D_UNDEF)>;
45820b57cec5SDimitry Andric}
45830b57cec5SDimitry Andric
4584480093f4SDimitry Andricmulticlass sve_int_un_pred_arit_0_w<bits<3> opc, string asm,
4585480093f4SDimitry Andric                                    SDPatternOperator op> {
4586fe6060f1SDimitry Andric  def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
4587fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _S, 1>;
4588fe6060f1SDimitry Andric  def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
4589fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _D, 1>;
4590480093f4SDimitry Andric
4591e8d8bef9SDimitry Andric  def : SVE_InReg_Extend<nxv4i32, op, nxv4i1, nxv4i16, !cast<Instruction>(NAME # _S)>;
4592e8d8bef9SDimitry Andric  def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i16, !cast<Instruction>(NAME # _D)>;
4593fe6060f1SDimitry Andric
459406c3fb27SDimitry Andric  def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
459506c3fb27SDimitry Andric  def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4596fe6060f1SDimitry Andric
459706c3fb27SDimitry Andric  defm : SVE_InReg_Extend_PassthruUndef<nxv4i32, op, nxv4i1, nxv4i16, !cast<Pseudo>(NAME # _S_UNDEF)>;
459806c3fb27SDimitry Andric  defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i16, !cast<Pseudo>(NAME # _D_UNDEF)>;
45990b57cec5SDimitry Andric}
46000b57cec5SDimitry Andric
4601480093f4SDimitry Andricmulticlass sve_int_un_pred_arit_0_d<bits<3> opc, string asm,
4602480093f4SDimitry Andric                                    SDPatternOperator op> {
4603fe6060f1SDimitry Andric  def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
4604fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _D, 1>;
4605480093f4SDimitry Andric
4606e8d8bef9SDimitry Andric  def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i32, !cast<Instruction>(NAME # _D)>;
4607fe6060f1SDimitry Andric
460806c3fb27SDimitry Andric  def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4609fe6060f1SDimitry Andric
461006c3fb27SDimitry Andric  defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i32, !cast<Pseudo>(NAME # _D_UNDEF)>;
46110b57cec5SDimitry Andric}
46120b57cec5SDimitry Andric
46138bcb0991SDimitry Andricmulticlass sve_int_un_pred_arit_1<bits<3> opc, string asm,
46148bcb0991SDimitry Andric                                  SDPatternOperator op> {
4615fe6060f1SDimitry Andric  def _B : sve_int_un_pred_arit<0b00, { opc, 0b1 }, asm, ZPR8>,
4616fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _B, 1>;
4617fe6060f1SDimitry Andric  def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>,
4618fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _H, 1>;
4619fe6060f1SDimitry Andric  def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>,
4620fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _S, 1>;
4621fe6060f1SDimitry Andric  def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>,
4622fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _D, 1>;
46238bcb0991SDimitry Andric
4624e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
4625e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
4626e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
4627e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
4628fe6060f1SDimitry Andric
462906c3fb27SDimitry Andric  def _B_UNDEF : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
463006c3fb27SDimitry Andric  def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
463106c3fb27SDimitry Andric  def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
463206c3fb27SDimitry Andric  def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4633fe6060f1SDimitry Andric
463406c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
463506c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
463606c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
463706c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
46380b57cec5SDimitry Andric}
46390b57cec5SDimitry Andric
4640e8d8bef9SDimitry Andricmulticlass sve_int_un_pred_arit_1_fp<bits<3> opc, string asm, SDPatternOperator op> {
4641fe6060f1SDimitry Andric  def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>,
4642fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _H, 1>;
4643fe6060f1SDimitry Andric  def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>,
4644fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _S, 1>;
4645fe6060f1SDimitry Andric  def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>,
4646fe6060f1SDimitry Andric           SVEPseudo2Instr<NAME # _D, 1>;
4647480093f4SDimitry Andric
4648e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
4649e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
4650e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
4651e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
4652e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
4653e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
4654fe6060f1SDimitry Andric
465506c3fb27SDimitry Andric  def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
465606c3fb27SDimitry Andric  def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
465706c3fb27SDimitry Andric  def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4658fe6060f1SDimitry Andric
465906c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
466006c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
466106c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
466206c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
466306c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
466406c3fb27SDimitry Andric  defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Pseudo>(NAME # _D_UNDEF)>;
46650b57cec5SDimitry Andric}
46660b57cec5SDimitry Andric
46670b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
46680b57cec5SDimitry Andric// SVE Integer Wide Immediate - Unpredicated Group
46690b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
46700b57cec5SDimitry Andricclass sve_int_dup_imm<bits<2> sz8_64, string asm,
46710b57cec5SDimitry Andric                      ZPRRegOp zprty, Operand immtype>
46720b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins immtype:$imm),
46730b57cec5SDimitry Andric  asm, "\t$Zd, $imm",
46740b57cec5SDimitry Andric  "",
46750b57cec5SDimitry Andric  []>, Sched<[]> {
46760b57cec5SDimitry Andric  bits<5> Zd;
46770b57cec5SDimitry Andric  bits<9> imm;
46780b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
46790b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
46800b57cec5SDimitry Andric  let Inst{21-14} = 0b11100011;
46810b57cec5SDimitry Andric  let Inst{13}    = imm{8};   // sh
46820b57cec5SDimitry Andric  let Inst{12-5}  = imm{7-0}; // imm8
46830b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
46840b57cec5SDimitry Andric
468506c3fb27SDimitry Andric  let hasSideEffects = 0;
46860b57cec5SDimitry Andric  let isReMaterializable = 1;
4687*0fca6ea1SDimitry Andric  let Uses = [VG];
46880b57cec5SDimitry Andric}
46890b57cec5SDimitry Andric
46900b57cec5SDimitry Andricmulticlass sve_int_dup_imm<string asm> {
46910b57cec5SDimitry Andric  def _B : sve_int_dup_imm<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8>;
46920b57cec5SDimitry Andric  def _H : sve_int_dup_imm<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16>;
46930b57cec5SDimitry Andric  def _S : sve_int_dup_imm<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32>;
46940b57cec5SDimitry Andric  def _D : sve_int_dup_imm<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64>;
46950b57cec5SDimitry Andric
46960b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $imm",
46970b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, cpy_imm8_opt_lsl_i8:$imm), 1>;
46980b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $imm",
46990b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, cpy_imm8_opt_lsl_i16:$imm), 1>;
47000b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $imm",
47010b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, cpy_imm8_opt_lsl_i32:$imm), 1>;
47020b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $imm",
47030b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, cpy_imm8_opt_lsl_i64:$imm), 1>;
47040b57cec5SDimitry Andric
47050b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, #0.0",
47060b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, 0, 0), 1>;
47070b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, #0.0",
47080b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, 0, 0), 1>;
47090b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, #0.0",
47100b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, 0, 0), 1>;
47110b57cec5SDimitry Andric}
47120b57cec5SDimitry Andric
47130b57cec5SDimitry Andricclass sve_int_dup_fpimm<bits<2> sz8_64, Operand fpimmtype,
47140b57cec5SDimitry Andric                        string asm, ZPRRegOp zprty>
47150b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins fpimmtype:$imm8),
47160b57cec5SDimitry Andric  asm, "\t$Zd, $imm8",
47170b57cec5SDimitry Andric  "",
47180b57cec5SDimitry Andric  []>, Sched<[]> {
47190b57cec5SDimitry Andric  bits<5> Zd;
47200b57cec5SDimitry Andric  bits<8> imm8;
47210b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
47220b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
47230b57cec5SDimitry Andric  let Inst{21-14} = 0b11100111;
47240b57cec5SDimitry Andric  let Inst{13}    = 0b0;
47250b57cec5SDimitry Andric  let Inst{12-5}  = imm8;
47260b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
47270b57cec5SDimitry Andric
472806c3fb27SDimitry Andric  let hasSideEffects = 0;
47290b57cec5SDimitry Andric  let isReMaterializable = 1;
4730*0fca6ea1SDimitry Andric  let Uses = [VG];
47310b57cec5SDimitry Andric}
47320b57cec5SDimitry Andric
47330b57cec5SDimitry Andricmulticlass sve_int_dup_fpimm<string asm> {
47340b57cec5SDimitry Andric  def _H : sve_int_dup_fpimm<0b01, fpimm16, asm, ZPR16>;
47350b57cec5SDimitry Andric  def _S : sve_int_dup_fpimm<0b10, fpimm32, asm, ZPR32>;
47360b57cec5SDimitry Andric  def _D : sve_int_dup_fpimm<0b11, fpimm64, asm, ZPR64>;
47370b57cec5SDimitry Andric
47380b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $imm8",
47390b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, fpimm16:$imm8), 1>;
47400b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $imm8",
47410b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, fpimm32:$imm8), 1>;
47420b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $imm8",
47430b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, fpimm64:$imm8), 1>;
47440b57cec5SDimitry Andric}
47450b57cec5SDimitry Andric
47460b57cec5SDimitry Andricclass sve_int_arith_imm0<bits<2> sz8_64, bits<3> opc, string asm,
47470b57cec5SDimitry Andric                         ZPRRegOp zprty, Operand immtype>
47480b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
47490b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $imm",
47500b57cec5SDimitry Andric  "",
47510b57cec5SDimitry Andric  []>, Sched<[]> {
47520b57cec5SDimitry Andric  bits<5> Zdn;
47530b57cec5SDimitry Andric  bits<9> imm;
47540b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
47550b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
47560b57cec5SDimitry Andric  let Inst{21-19} = 0b100;
47570b57cec5SDimitry Andric  let Inst{18-16} = opc;
47580b57cec5SDimitry Andric  let Inst{15-14} = 0b11;
47590b57cec5SDimitry Andric  let Inst{13}    = imm{8};   // sh
47600b57cec5SDimitry Andric  let Inst{12-5}  = imm{7-0}; // imm8
47610b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
47620b57cec5SDimitry Andric
47630b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
47645ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
47650b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
476606c3fb27SDimitry Andric  let hasSideEffects = 0;
47670b57cec5SDimitry Andric}
47680b57cec5SDimitry Andric
4769fe6060f1SDimitry Andricmulticlass sve_int_arith_imm0<bits<3> opc, string asm, SDPatternOperator op> {
47700b57cec5SDimitry Andric  def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8,  addsub_imm8_opt_lsl_i8>;
47710b57cec5SDimitry Andric  def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>;
47720b57cec5SDimitry Andric  def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>;
47730b57cec5SDimitry Andric  def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>;
4774480093f4SDimitry Andric
4775480093f4SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv16i8, op, ZPR8,  i32, SVEAddSubImm8Pat,  !cast<Instruction>(NAME # _B)>;
4776480093f4SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv8i16, op, ZPR16, i32, SVEAddSubImm16Pat, !cast<Instruction>(NAME # _H)>;
4777480093f4SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv4i32, op, ZPR32, i32, SVEAddSubImm32Pat, !cast<Instruction>(NAME # _S)>;
4778480093f4SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv2i64, op, ZPR64, i64, SVEAddSubImm64Pat, !cast<Instruction>(NAME # _D)>;
4779480093f4SDimitry Andric}
4780480093f4SDimitry Andric
4781*0fca6ea1SDimitry Andricmulticlass sve_int_arith_imm0_ssat<bits<3> opc, string asm, SDPatternOperator op,
4782*0fca6ea1SDimitry Andric                                   SDPatternOperator inv_op> {
4783*0fca6ea1SDimitry Andric  def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8,  addsub_imm8_opt_lsl_i8>;
4784*0fca6ea1SDimitry Andric  def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>;
4785*0fca6ea1SDimitry Andric  def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>;
4786*0fca6ea1SDimitry Andric  def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>;
4787*0fca6ea1SDimitry Andric
4788*0fca6ea1SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv16i8, op, ZPR8,  i32, SVEAddSubSSatPosImm8Pat,  !cast<Instruction>(NAME # _B)>;
4789*0fca6ea1SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv8i16, op, ZPR16, i32, SVEAddSubSSatPosImm16Pat, !cast<Instruction>(NAME # _H)>;
4790*0fca6ea1SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv4i32, op, ZPR32, i32, SVEAddSubSSatPosImm32Pat, !cast<Instruction>(NAME # _S)>;
4791*0fca6ea1SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv2i64, op, ZPR64, i64, SVEAddSubSSatPosImm64Pat, !cast<Instruction>(NAME # _D)>;
4792*0fca6ea1SDimitry Andric
4793*0fca6ea1SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv16i8, inv_op, ZPR8,  i32, SVEAddSubSSatNegImm8Pat,  !cast<Instruction>(NAME # _B)>;
4794*0fca6ea1SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv8i16, inv_op, ZPR16, i32, SVEAddSubSSatNegImm16Pat, !cast<Instruction>(NAME # _H)>;
4795*0fca6ea1SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv4i32, inv_op, ZPR32, i32, SVEAddSubSSatNegImm32Pat, !cast<Instruction>(NAME # _S)>;
4796*0fca6ea1SDimitry Andric  def : SVE_1_Op_Imm_OptLsl_Pat<nxv2i64, inv_op, ZPR64, i64, SVEAddSubSSatNegImm64Pat, !cast<Instruction>(NAME # _D)>;
4797*0fca6ea1SDimitry Andric}
4798*0fca6ea1SDimitry Andric
47990b57cec5SDimitry Andricclass sve_int_arith_imm<bits<2> sz8_64, bits<6> opc, string asm,
48000b57cec5SDimitry Andric                        ZPRRegOp zprty, Operand immtype>
48010b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
48020b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $imm",
48030b57cec5SDimitry Andric  "",
48040b57cec5SDimitry Andric  []>, Sched<[]> {
48050b57cec5SDimitry Andric  bits<5> Zdn;
48060b57cec5SDimitry Andric  bits<8> imm;
48070b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
48080b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
48090b57cec5SDimitry Andric  let Inst{21-16} = opc;
48100b57cec5SDimitry Andric  let Inst{15-13} = 0b110;
48110b57cec5SDimitry Andric  let Inst{12-5} = imm;
48120b57cec5SDimitry Andric  let Inst{4-0} = Zdn;
48130b57cec5SDimitry Andric
48140b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
48155ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
48160b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
481706c3fb27SDimitry Andric  let hasSideEffects = 0;
48180b57cec5SDimitry Andric}
48190b57cec5SDimitry Andric
4820480093f4SDimitry Andricmulticlass sve_int_arith_imm1<bits<2> opc, string asm, SDPatternOperator op> {
4821bdd1243dSDimitry Andric  def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, simm8_32b>;
4822bdd1243dSDimitry Andric  def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, simm8_32b>;
4823bdd1243dSDimitry Andric  def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, simm8_32b>;
4824bdd1243dSDimitry Andric  def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, simm8_32b>;
4825480093f4SDimitry Andric
482606c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _B)>;
482706c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv8i16, nxv8i1,  op, ZPR16, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _H)>;
482806c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv4i32, nxv4i1,  op, ZPR32, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _S)>;
482906c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv2i64, nxv2i1,  op, ZPR64, i64, SVEArithSImmPat64, !cast<Instruction>(NAME # _D)>;
48300b57cec5SDimitry Andric}
48310b57cec5SDimitry Andric
4832480093f4SDimitry Andricmulticlass sve_int_arith_imm1_unsigned<bits<2> opc, string asm, SDPatternOperator op> {
4833480093f4SDimitry Andric  def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, imm0_255>;
4834480093f4SDimitry Andric  def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, imm0_255>;
4835480093f4SDimitry Andric  def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, imm0_255>;
4836480093f4SDimitry Andric  def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, imm0_255>;
4837480093f4SDimitry Andric
483806c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithUImm8Pat, !cast<Instruction>(NAME # _B)>;
483906c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithUImm16Pat, !cast<Instruction>(NAME # _H)>;
484006c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithUImm32Pat, !cast<Instruction>(NAME # _S)>;
484106c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithUImm64Pat, !cast<Instruction>(NAME # _D)>;
4842480093f4SDimitry Andric}
4843480093f4SDimitry Andric
4844480093f4SDimitry Andricmulticlass sve_int_arith_imm2<string asm, SDPatternOperator op> {
4845bdd1243dSDimitry Andric  def _B : sve_int_arith_imm<0b00, 0b110000, asm, ZPR8,  simm8_32b>;
4846bdd1243dSDimitry Andric  def _H : sve_int_arith_imm<0b01, 0b110000, asm, ZPR16, simm8_32b>;
4847bdd1243dSDimitry Andric  def _S : sve_int_arith_imm<0b10, 0b110000, asm, ZPR32, simm8_32b>;
4848bdd1243dSDimitry Andric  def _D : sve_int_arith_imm<0b11, 0b110000, asm, ZPR64, simm8_32b>;
4849480093f4SDimitry Andric
485006c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _B)>;
485106c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _H)>;
485206c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _S)>;
485306c3fb27SDimitry Andric  def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithSImmPat64, !cast<Instruction>(NAME # _D)>;
48540b57cec5SDimitry Andric}
48550b57cec5SDimitry Andric
48560b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
48570b57cec5SDimitry Andric// SVE Bitwise Logical - Unpredicated Group
48580b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
48590b57cec5SDimitry Andric
48600b57cec5SDimitry Andricclass sve_int_bin_cons_log<bits<2> opc, string asm>
48610b57cec5SDimitry Andric: I<(outs ZPR64:$Zd), (ins ZPR64:$Zn, ZPR64:$Zm),
48620b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
48630b57cec5SDimitry Andric  "",
48640b57cec5SDimitry Andric  []>, Sched<[]> {
48650b57cec5SDimitry Andric  bits<5> Zd;
48660b57cec5SDimitry Andric  bits<5> Zm;
48670b57cec5SDimitry Andric  bits<5> Zn;
48680b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
48690b57cec5SDimitry Andric  let Inst{23-22} = opc{1-0};
48700b57cec5SDimitry Andric  let Inst{21}    = 0b1;
48710b57cec5SDimitry Andric  let Inst{20-16} = Zm;
48720b57cec5SDimitry Andric  let Inst{15-10} = 0b001100;
48730b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
48740b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
487506c3fb27SDimitry Andric
487606c3fb27SDimitry Andric  let hasSideEffects = 0;
48770b57cec5SDimitry Andric}
48780b57cec5SDimitry Andric
4879480093f4SDimitry Andricmulticlass sve_int_bin_cons_log<bits<2> opc, string asm, SDPatternOperator op> {
48800b57cec5SDimitry Andric  def NAME : sve_int_bin_cons_log<opc, asm>;
48810b57cec5SDimitry Andric
4882480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
4883480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
4884480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>;
4885480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
4886480093f4SDimitry Andric
48870b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
48880b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR8:$Zd,  ZPR8:$Zn,  ZPR8:$Zm),  1>;
48890b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
48900b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 1>;
48910b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
48920b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 1>;
48930b57cec5SDimitry Andric}
48940b57cec5SDimitry Andric
48950b57cec5SDimitry Andricclass sve2_int_bitwise_ternary_op_d<bits<3> opc, string asm>
48960b57cec5SDimitry Andric: I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, ZPR64:$Zm, ZPR64:$Zk),
48970b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $Zm, $Zk",
48980b57cec5SDimitry Andric  "",
48990b57cec5SDimitry Andric  []>, Sched<[]> {
49000b57cec5SDimitry Andric  bits<5> Zdn;
49010b57cec5SDimitry Andric  bits<5> Zk;
49020b57cec5SDimitry Andric  bits<5> Zm;
49030b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
49040b57cec5SDimitry Andric  let Inst{23-22} = opc{2-1};
49050b57cec5SDimitry Andric  let Inst{21}    = 0b1;
49060b57cec5SDimitry Andric  let Inst{20-16} = Zm;
49070b57cec5SDimitry Andric  let Inst{15-11} = 0b00111;
49080b57cec5SDimitry Andric  let Inst{10}    = opc{0};
49090b57cec5SDimitry Andric  let Inst{9-5}   = Zk;
49100b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
49110b57cec5SDimitry Andric
49120b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
49135ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
49140b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
491506c3fb27SDimitry Andric  let hasSideEffects = 0;
49160b57cec5SDimitry Andric}
49170b57cec5SDimitry Andric
4918*0fca6ea1SDimitry Andricmulticlass sve2_int_bitwise_ternary_op<bits<3> opc, string asm,
4919*0fca6ea1SDimitry Andric                                       SDPatternOperator op> {
49200b57cec5SDimitry Andric  def NAME : sve2_int_bitwise_ternary_op_d<opc, asm>;
49210b57cec5SDimitry Andric
49220b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
49230b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR8:$Zdn,  ZPR8:$Zm,  ZPR8:$Zk),  1>;
49240b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
49250b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR16:$Zdn, ZPR16:$Zm, ZPR16:$Zk), 1>;
49260b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
49270b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPR32:$Zdn, ZPR32:$Zm, ZPR32:$Zk), 1>;
49285ffd83dbSDimitry Andric
49295ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
49305ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
49315ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>;
49325ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
49330b57cec5SDimitry Andric}
49340b57cec5SDimitry Andric
49350b57cec5SDimitry Andricclass sve2_int_rotate_right_imm<bits<4> tsz8_64, string asm,
49360b57cec5SDimitry Andric                                ZPRRegOp zprty, Operand immtype>
49370b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, immtype:$imm),
49380b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $Zm, $imm",
49390b57cec5SDimitry Andric  "",
49400b57cec5SDimitry Andric  []>, Sched<[]> {
49410b57cec5SDimitry Andric  bits<5> Zdn;
49420b57cec5SDimitry Andric  bits<5> Zm;
49430b57cec5SDimitry Andric  bits<6> imm;
49440b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
49450b57cec5SDimitry Andric  let Inst{23-22} = tsz8_64{3-2};
49460b57cec5SDimitry Andric  let Inst{21}    = 0b1;
49470b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
49480b57cec5SDimitry Andric  let Inst{18-16} = imm{2-0}; // imm3
49490b57cec5SDimitry Andric  let Inst{15-10} = 0b001101;
49500b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
49510b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
49520b57cec5SDimitry Andric
49530b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
49545ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
49550b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
495606c3fb27SDimitry Andric  let hasSideEffects = 0;
49570b57cec5SDimitry Andric}
49580b57cec5SDimitry Andric
49595ffd83dbSDimitry Andricmulticlass sve2_int_rotate_right_imm<string asm, SDPatternOperator op> {
49600b57cec5SDimitry Andric  def _B : sve2_int_rotate_right_imm<{0,0,0,1}, asm, ZPR8, vecshiftR8>;
49610b57cec5SDimitry Andric  def _H : sve2_int_rotate_right_imm<{0,0,1,?}, asm, ZPR16, vecshiftR16> {
49620b57cec5SDimitry Andric    let Inst{19} = imm{3};
49630b57cec5SDimitry Andric  }
49640b57cec5SDimitry Andric  def _S : sve2_int_rotate_right_imm<{0,1,?,?}, asm, ZPR32, vecshiftR32> {
49650b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
49660b57cec5SDimitry Andric  }
49670b57cec5SDimitry Andric  def _D : sve2_int_rotate_right_imm<{1,?,?,?}, asm, ZPR64, vecshiftR64> {
49680b57cec5SDimitry Andric    let Inst{22}    = imm{5};
49690b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
49700b57cec5SDimitry Andric  }
4971e8d8bef9SDimitry Andric
49725ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8,  !cast<Instruction>(NAME # _B)>;
49735ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
49745ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
49755ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
49760b57cec5SDimitry Andric}
49770b57cec5SDimitry Andric
49780b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
49790b57cec5SDimitry Andric// SVE Integer Wide Immediate - Predicated Group
49800b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
49810b57cec5SDimitry Andric
49820b57cec5SDimitry Andricclass sve_int_dup_fpimm_pred<bits<2> sz, Operand fpimmtype,
49830b57cec5SDimitry Andric                             string asm, ZPRRegOp zprty>
49840b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPRAny:$Pg, fpimmtype:$imm8),
49850b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/m, $imm8",
49860b57cec5SDimitry Andric  "",
49870b57cec5SDimitry Andric  []>, Sched<[]> {
49880b57cec5SDimitry Andric  bits<4> Pg;
49890b57cec5SDimitry Andric  bits<5> Zd;
49900b57cec5SDimitry Andric  bits<8> imm8;
49910b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
49920b57cec5SDimitry Andric  let Inst{23-22} = sz;
49930b57cec5SDimitry Andric  let Inst{21-20} = 0b01;
49940b57cec5SDimitry Andric  let Inst{19-16} = Pg;
49950b57cec5SDimitry Andric  let Inst{15-13} = 0b110;
49960b57cec5SDimitry Andric  let Inst{12-5}  = imm8;
49970b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
49980b57cec5SDimitry Andric
49990b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
50005ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
50010b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
500206c3fb27SDimitry Andric  let hasSideEffects = 0;
50030b57cec5SDimitry Andric}
50040b57cec5SDimitry Andric
50050b57cec5SDimitry Andricmulticlass sve_int_dup_fpimm_pred<string asm> {
50060b57cec5SDimitry Andric  def _H : sve_int_dup_fpimm_pred<0b01, fpimm16, asm, ZPR16>;
50070b57cec5SDimitry Andric  def _S : sve_int_dup_fpimm_pred<0b10, fpimm32, asm, ZPR32>;
50080b57cec5SDimitry Andric  def _D : sve_int_dup_fpimm_pred<0b11, fpimm64, asm, ZPR64>;
50090b57cec5SDimitry Andric
50100b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
50110b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, fpimm16:$imm8), 1>;
50120b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
50130b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, fpimm32:$imm8), 1>;
50140b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
50150b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, fpimm64:$imm8), 1>;
50160b57cec5SDimitry Andric}
50170b57cec5SDimitry Andric
50180b57cec5SDimitry Andricclass sve_int_dup_imm_pred<bits<2> sz8_64, bit m, string asm,
50190b57cec5SDimitry Andric                           ZPRRegOp zprty, string pred_qual, dag iops>
50200b57cec5SDimitry Andric: I<(outs zprty:$Zd), iops,
50210b57cec5SDimitry Andric  asm, "\t$Zd, $Pg"#pred_qual#", $imm",
50220b57cec5SDimitry Andric  "", []>, Sched<[]> {
50230b57cec5SDimitry Andric  bits<5> Zd;
50240b57cec5SDimitry Andric  bits<4> Pg;
50250b57cec5SDimitry Andric  bits<9> imm;
50260b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
50270b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
50280b57cec5SDimitry Andric  let Inst{21-20} = 0b01;
50290b57cec5SDimitry Andric  let Inst{19-16} = Pg;
50300b57cec5SDimitry Andric  let Inst{15}    = 0b0;
50310b57cec5SDimitry Andric  let Inst{14}    = m;
50320b57cec5SDimitry Andric  let Inst{13}    = imm{8};   // sh
50330b57cec5SDimitry Andric  let Inst{12-5}  = imm{7-0}; // imm8
50340b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
50350b57cec5SDimitry Andric
50365ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
50370b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
503806c3fb27SDimitry Andric  let hasSideEffects = 0;
50390b57cec5SDimitry Andric}
50400b57cec5SDimitry Andric
50415ffd83dbSDimitry Andricmulticlass sve_int_dup_imm_pred_merge_inst<
504281ad6265SDimitry Andric    bits<2> sz8_64, string asm, ZPRRegOp zprty, imm8_opt_lsl cpyimm,
504381ad6265SDimitry Andric    ValueType intty, ValueType predty, ValueType scalarty, ComplexPattern cpx> {
50445ffd83dbSDimitry Andric  let Constraints = "$Zd = $_Zd" in
50455ffd83dbSDimitry Andric  def NAME : sve_int_dup_imm_pred<sz8_64, 1, asm, zprty,  "/m",
50465ffd83dbSDimitry Andric                                  (ins zprty:$_Zd, PPRAny:$Pg, cpyimm:$imm)>;
50475ffd83dbSDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $imm",
50485ffd83dbSDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>;
504981ad6265SDimitry Andric  def : Pat<(vselect predty:$Pg,
505081ad6265SDimitry Andric                (intty (splat_vector (scalarty (cpx i32:$imm, i32:$shift)))),
505181ad6265SDimitry Andric                ZPR:$Zd),
505281ad6265SDimitry Andric            (!cast<Instruction>(NAME) $Zd, $Pg, $imm, $shift)>;
50530b57cec5SDimitry Andric}
50540b57cec5SDimitry Andric
50555ffd83dbSDimitry Andricmulticlass sve_int_dup_imm_pred_merge<string asm> {
505681ad6265SDimitry Andric  defm _B : sve_int_dup_imm_pred_merge_inst<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8,
505781ad6265SDimitry Andric                                            nxv16i8, nxv16i1, i32, SVECpyDupImm8Pat>;
505881ad6265SDimitry Andric  defm _H : sve_int_dup_imm_pred_merge_inst<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16,
505981ad6265SDimitry Andric                                            nxv8i16, nxv8i1, i32, SVECpyDupImm16Pat>;
506081ad6265SDimitry Andric  defm _S : sve_int_dup_imm_pred_merge_inst<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32,
506181ad6265SDimitry Andric                                            nxv4i32, nxv4i1, i32, SVECpyDupImm32Pat>;
506281ad6265SDimitry Andric  defm _D : sve_int_dup_imm_pred_merge_inst<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64,
506381ad6265SDimitry Andric                                            nxv2i64, nxv2i1, i64, SVECpyDupImm64Pat>;
50640b57cec5SDimitry Andric
50650b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
50660b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, 0, 0), 0>;
50670b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
50680b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, 0, 0), 0>;
50690b57cec5SDimitry Andric  def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
50700b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, 0, 0), 0>;
507181ad6265SDimitry Andric
507281ad6265SDimitry Andric  def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv8f16 ZPR:$Zd)),
507381ad6265SDimitry Andric            (!cast<Instruction>(NAME # _H) $Zd, $Pg, 0, 0)>;
507481ad6265SDimitry Andric  def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv4f16 ZPR:$Zd)),
507581ad6265SDimitry Andric            (!cast<Instruction>(NAME # _S) $Zd, $Pg, 0, 0)>;
507681ad6265SDimitry Andric  def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv2f16 ZPR:$Zd)),
507781ad6265SDimitry Andric            (!cast<Instruction>(NAME # _D) $Zd, $Pg, 0, 0)>;
507881ad6265SDimitry Andric  def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv4f32 ZPR:$Zd)),
507981ad6265SDimitry Andric            (!cast<Instruction>(NAME # _S) $Zd, $Pg, 0, 0)>;
508081ad6265SDimitry Andric  def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv2f32 ZPR:$Zd)),
508181ad6265SDimitry Andric            (!cast<Instruction>(NAME # _D) $Zd, $Pg, 0, 0)>;
508281ad6265SDimitry Andric  def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv2f64 ZPR:$Zd)),
508381ad6265SDimitry Andric            (!cast<Instruction>(NAME # _D) $Zd, $Pg, 0, 0)>;
50840b57cec5SDimitry Andric}
50850b57cec5SDimitry Andric
50865ffd83dbSDimitry Andricmulticlass sve_int_dup_imm_pred_zero_inst<
508781ad6265SDimitry Andric    bits<2> sz8_64, string asm, ZPRRegOp zprty, imm8_opt_lsl cpyimm,
508881ad6265SDimitry Andric    ValueType intty, ValueType predty, ValueType scalarty, ComplexPattern cpx> {
50895ffd83dbSDimitry Andric  def NAME : sve_int_dup_imm_pred<sz8_64, 0, asm, zprty, "/z",
50905ffd83dbSDimitry Andric                                  (ins PPRAny:$Pg, cpyimm:$imm)>;
50915ffd83dbSDimitry Andric  def : InstAlias<"mov $Zd, $Pg/z, $imm",
50925ffd83dbSDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>;
50935ffd83dbSDimitry Andric  def : Pat<(intty (zext (predty PPRAny:$Ps1))),
50945ffd83dbSDimitry Andric            (!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>;
50955ffd83dbSDimitry Andric  def : Pat<(intty (sext (predty PPRAny:$Ps1))),
50965ffd83dbSDimitry Andric            (!cast<Instruction>(NAME) PPRAny:$Ps1, -1, 0)>;
50975ffd83dbSDimitry Andric  def : Pat<(intty (anyext (predty PPRAny:$Ps1))),
50985ffd83dbSDimitry Andric            (!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>;
509981ad6265SDimitry Andric  def : Pat<(vselect predty:$Pg,
510081ad6265SDimitry Andric                (intty (splat_vector (scalarty (cpx i32:$imm, i32:$shift)))),
510181ad6265SDimitry Andric                (intty (splat_vector (scalarty 0)))),
510281ad6265SDimitry Andric            (!cast<Instruction>(NAME) $Pg, $imm, $shift)>;
51035ffd83dbSDimitry Andric}
51040b57cec5SDimitry Andric
51055ffd83dbSDimitry Andricmulticlass sve_int_dup_imm_pred_zero<string asm> {
510681ad6265SDimitry Andric  defm _B : sve_int_dup_imm_pred_zero_inst<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8,
510781ad6265SDimitry Andric                                           nxv16i8, nxv16i1, i32, SVECpyDupImm8Pat>;
510881ad6265SDimitry Andric  defm _H : sve_int_dup_imm_pred_zero_inst<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16,
510981ad6265SDimitry Andric                                           nxv8i16, nxv8i1, i32, SVECpyDupImm16Pat>;
511081ad6265SDimitry Andric  defm _S : sve_int_dup_imm_pred_zero_inst<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32,
511181ad6265SDimitry Andric                                           nxv4i32, nxv4i1, i32, SVECpyDupImm32Pat>;
511281ad6265SDimitry Andric  defm _D : sve_int_dup_imm_pred_zero_inst<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64,
511381ad6265SDimitry Andric                                           nxv2i64, nxv2i1, i64, SVECpyDupImm64Pat>;
51140b57cec5SDimitry Andric}
51150b57cec5SDimitry Andric
51160b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
51170b57cec5SDimitry Andric// SVE Integer Compare - Vectors Group
51180b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
51190b57cec5SDimitry Andric
51200b57cec5SDimitry Andricclass sve_int_cmp<bit cmp_1, bits<2> sz8_64, bits<3> opc, string asm,
51210b57cec5SDimitry Andric                  PPRRegOp pprty, ZPRRegOp zprty1, ZPRRegOp zprty2>
51220b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty1:$Zn, zprty2:$Zm),
51230b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z, $Zn, $Zm",
51240b57cec5SDimitry Andric  "",
51250b57cec5SDimitry Andric  []>, Sched<[]> {
51260b57cec5SDimitry Andric  bits<4> Pd;
51270b57cec5SDimitry Andric  bits<3> Pg;
51280b57cec5SDimitry Andric  bits<5> Zm;
51290b57cec5SDimitry Andric  bits<5> Zn;
51300b57cec5SDimitry Andric  let Inst{31-24} = 0b00100100;
51310b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
51320b57cec5SDimitry Andric  let Inst{21}    = 0b0;
51330b57cec5SDimitry Andric  let Inst{20-16} = Zm;
51340b57cec5SDimitry Andric  let Inst{15}    = opc{2};
51350b57cec5SDimitry Andric  let Inst{14}    = cmp_1;
51360b57cec5SDimitry Andric  let Inst{13}    = opc{1};
51370b57cec5SDimitry Andric  let Inst{12-10} = Pg;
51380b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
51390b57cec5SDimitry Andric  let Inst{4}     = opc{0};
51400b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
51410b57cec5SDimitry Andric
51420b57cec5SDimitry Andric  let Defs = [NZCV];
5143e8d8bef9SDimitry Andric  let ElementSize = pprty.ElementSize;
514406c3fb27SDimitry Andric  let hasSideEffects = 0;
5145e8d8bef9SDimitry Andric  let isPTestLike = 1;
51460b57cec5SDimitry Andric}
51470b57cec5SDimitry Andric
51485ffd83dbSDimitry Andricmulticlass SVE_SETCC_Pat<CondCode cc, CondCode invcc, ValueType predvt,
5149fe6060f1SDimitry Andric                         ValueType intvt, Instruction cmp> {
51505ffd83dbSDimitry Andric  def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, intvt:$Op3, cc)),
51515ffd83dbSDimitry Andric            (cmp $Op1, $Op2, $Op3)>;
51525ffd83dbSDimitry Andric  def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, intvt:$Op3, invcc)),
51535ffd83dbSDimitry Andric            (cmp $Op1, $Op3, $Op2)>;
5154*0fca6ea1SDimitry Andric  def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z_oneuse (predvt (SVEAllActive)), intvt:$Op2, intvt:$Op3, cc))),
515504eeddc0SDimitry Andric            (cmp $Pg, $Op2, $Op3)>;
5156*0fca6ea1SDimitry Andric  def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z_oneuse (predvt (SVEAllActive)), intvt:$Op2, intvt:$Op3, invcc))),
515704eeddc0SDimitry Andric            (cmp $Pg, $Op3, $Op2)>;
51585ffd83dbSDimitry Andric}
51595ffd83dbSDimitry Andric
5160fe6060f1SDimitry Andricmulticlass SVE_SETCC_Pat_With_Zero<CondCode cc, CondCode invcc, ValueType predvt,
5161fe6060f1SDimitry Andric                                   ValueType intvt, Instruction cmp> {
5162fe6060f1SDimitry Andric  def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, (SVEDup0), cc)),
5163fe6060f1SDimitry Andric            (cmp $Op1, $Op2)>;
5164fe6060f1SDimitry Andric  def : Pat<(predvt (AArch64setcc_z predvt:$Op1, (SVEDup0), intvt:$Op2, invcc)),
5165fe6060f1SDimitry Andric            (cmp $Op1, $Op2)>;
5166*0fca6ea1SDimitry Andric  def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z_oneuse (predvt (SVEAllActive)), intvt:$Op1, (SVEDup0), cc))),
516781ad6265SDimitry Andric            (cmp $Pg, $Op1)>;
5168*0fca6ea1SDimitry Andric  def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z_oneuse (predvt (SVEAllActive)), (SVEDup0), intvt:$Op1, invcc))),
516981ad6265SDimitry Andric            (cmp $Pg, $Op1)>;
5170fe6060f1SDimitry Andric}
5171fe6060f1SDimitry Andric
51725ffd83dbSDimitry Andricmulticlass sve_int_cmp_0<bits<3> opc, string asm, CondCode cc, CondCode invcc> {
51730b57cec5SDimitry Andric  def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR8>;
51740b57cec5SDimitry Andric  def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR16>;
51750b57cec5SDimitry Andric  def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR32>;
51760b57cec5SDimitry Andric  def _D : sve_int_cmp<0b0, 0b11, opc, asm, PPR64, ZPR64, ZPR64>;
5177480093f4SDimitry Andric
51785ffd83dbSDimitry Andric  defm : SVE_SETCC_Pat<cc, invcc, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
51795ffd83dbSDimitry Andric  defm : SVE_SETCC_Pat<cc, invcc, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
51805ffd83dbSDimitry Andric  defm : SVE_SETCC_Pat<cc, invcc, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
51815ffd83dbSDimitry Andric  defm : SVE_SETCC_Pat<cc, invcc, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
51820b57cec5SDimitry Andric}
51830b57cec5SDimitry Andric
5184480093f4SDimitry Andricmulticlass sve_int_cmp_0_wide<bits<3> opc, string asm, SDPatternOperator op> {
51850b57cec5SDimitry Andric  def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
51860b57cec5SDimitry Andric  def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
51870b57cec5SDimitry Andric  def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
5188480093f4SDimitry Andric
5189480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
5190480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i1,  op, nxv8i1,  nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
5191480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i1,  op, nxv4i1,  nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
51920b57cec5SDimitry Andric}
51930b57cec5SDimitry Andric
5194480093f4SDimitry Andricmulticlass sve_int_cmp_1_wide<bits<3> opc, string asm, SDPatternOperator op> {
51950b57cec5SDimitry Andric  def _B : sve_int_cmp<0b1, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
51960b57cec5SDimitry Andric  def _H : sve_int_cmp<0b1, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
51970b57cec5SDimitry Andric  def _S : sve_int_cmp<0b1, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
5198480093f4SDimitry Andric
5199480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
5200480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i1,  op, nxv8i1,  nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
5201480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i1,  op, nxv4i1,  nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
52020b57cec5SDimitry Andric}
52030b57cec5SDimitry Andric
52040b57cec5SDimitry Andric
52050b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
52060b57cec5SDimitry Andric// SVE Integer Compare - Signed Immediate Group
52070b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
52080b57cec5SDimitry Andric
52090b57cec5SDimitry Andricclass sve_int_scmp_vi<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty,
52100b57cec5SDimitry Andric                      ZPRRegOp zprty,
52110b57cec5SDimitry Andric                      Operand immtype>
52120b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm5),
52130b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z, $Zn, $imm5",
52140b57cec5SDimitry Andric  "",
52150b57cec5SDimitry Andric  []>, Sched<[]> {
52160b57cec5SDimitry Andric  bits<4> Pd;
52170b57cec5SDimitry Andric  bits<3> Pg;
52180b57cec5SDimitry Andric  bits<5> Zn;
52190b57cec5SDimitry Andric  bits<5> imm5;
52200b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
52210b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
52220b57cec5SDimitry Andric  let Inst{21}    = 0b0;
52230b57cec5SDimitry Andric  let Inst{20-16} = imm5;
52240b57cec5SDimitry Andric  let Inst{15}    = opc{2};
52250b57cec5SDimitry Andric  let Inst{14}    = 0b0;
52260b57cec5SDimitry Andric  let Inst{13}    = opc{1};
52270b57cec5SDimitry Andric  let Inst{12-10} = Pg;
52280b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
52290b57cec5SDimitry Andric  let Inst{4}     = opc{0};
52300b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
52310b57cec5SDimitry Andric
52320b57cec5SDimitry Andric  let Defs = [NZCV];
5233480093f4SDimitry Andric  let ElementSize = pprty.ElementSize;
523406c3fb27SDimitry Andric  let hasSideEffects = 0;
5235e8d8bef9SDimitry Andric  let isPTestLike = 1;
52360b57cec5SDimitry Andric}
52370b57cec5SDimitry Andric
52385ffd83dbSDimitry Andricmulticlass SVE_SETCC_Imm_Pat<CondCode cc, CondCode commuted_cc,
52395ffd83dbSDimitry Andric                             ValueType predvt, ValueType intvt,
52405ffd83dbSDimitry Andric                             Operand immtype, Instruction cmp> {
52415ffd83dbSDimitry Andric  def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg),
52425ffd83dbSDimitry Andric                                    (intvt ZPR:$Zs1),
524381ad6265SDimitry Andric                                    (intvt (splat_vector (immtype:$imm))),
52445ffd83dbSDimitry Andric                                    cc)),
52455ffd83dbSDimitry Andric            (cmp $Pg, $Zs1, immtype:$imm)>;
52465ffd83dbSDimitry Andric  def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg),
524781ad6265SDimitry Andric                                    (intvt (splat_vector (immtype:$imm))),
52485ffd83dbSDimitry Andric                                    (intvt ZPR:$Zs1),
52495ffd83dbSDimitry Andric                                    commuted_cc)),
52505ffd83dbSDimitry Andric            (cmp $Pg, $Zs1, immtype:$imm)>;
525181ad6265SDimitry Andric  def : Pat<(predvt (and predvt:$Pg,
5252*0fca6ea1SDimitry Andric                         (AArch64setcc_z_oneuse (predvt (SVEAllActive)),
525381ad6265SDimitry Andric                                         (intvt ZPR:$Zs1),
525481ad6265SDimitry Andric                                         (intvt (splat_vector (immtype:$imm))),
525581ad6265SDimitry Andric                                         cc))),
525681ad6265SDimitry Andric            (cmp $Pg, $Zs1, immtype:$imm)>;
525781ad6265SDimitry Andric  def : Pat<(predvt (and predvt:$Pg,
5258*0fca6ea1SDimitry Andric                         (AArch64setcc_z_oneuse (predvt (SVEAllActive)),
525981ad6265SDimitry Andric                                         (intvt (splat_vector (immtype:$imm))),
526081ad6265SDimitry Andric                                         (intvt ZPR:$Zs1),
526181ad6265SDimitry Andric                                         commuted_cc))),
526281ad6265SDimitry Andric            (cmp $Pg, $Zs1, immtype:$imm)>;
52635ffd83dbSDimitry Andric}
52645ffd83dbSDimitry Andric
52655ffd83dbSDimitry Andricmulticlass sve_int_scmp_vi<bits<3> opc, string asm, CondCode cc, CondCode commuted_cc> {
52660b57cec5SDimitry Andric  def _B : sve_int_scmp_vi<0b00, opc, asm, PPR8, ZPR8, simm5_32b>;
52670b57cec5SDimitry Andric  def _H : sve_int_scmp_vi<0b01, opc, asm, PPR16, ZPR16, simm5_32b>;
52680b57cec5SDimitry Andric  def _S : sve_int_scmp_vi<0b10, opc, asm, PPR32, ZPR32, simm5_32b>;
52690b57cec5SDimitry Andric  def _D : sve_int_scmp_vi<0b11, opc, asm, PPR64, ZPR64, simm5_64b>;
5270480093f4SDimitry Andric
52715ffd83dbSDimitry Andric  defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv16i1, nxv16i8, simm5_32b,
52725ffd83dbSDimitry Andric                           !cast<Instruction>(NAME # _B)>;
52735ffd83dbSDimitry Andric  defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv8i1,  nxv8i16, simm5_32b,
52745ffd83dbSDimitry Andric                           !cast<Instruction>(NAME # _H)>;
52755ffd83dbSDimitry Andric  defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv4i1,  nxv4i32, simm5_32b,
52765ffd83dbSDimitry Andric                           !cast<Instruction>(NAME # _S)>;
52775ffd83dbSDimitry Andric  defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv2i1,  nxv2i64, simm5_64b,
52785ffd83dbSDimitry Andric                           !cast<Instruction>(NAME # _D)>;
52790b57cec5SDimitry Andric}
52800b57cec5SDimitry Andric
52810b57cec5SDimitry Andric
52820b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
52830b57cec5SDimitry Andric// SVE Integer Compare - Unsigned Immediate Group
52840b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
52850b57cec5SDimitry Andric
52860b57cec5SDimitry Andricclass sve_int_ucmp_vi<bits<2> sz8_64, bits<2> opc, string asm, PPRRegOp pprty,
52870b57cec5SDimitry Andric                      ZPRRegOp zprty, Operand immtype>
52880b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm7),
52890b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z, $Zn, $imm7",
52900b57cec5SDimitry Andric  "",
52910b57cec5SDimitry Andric  []>, Sched<[]> {
52920b57cec5SDimitry Andric  bits<4> Pd;
52930b57cec5SDimitry Andric  bits<3> Pg;
52940b57cec5SDimitry Andric  bits<5> Zn;
52950b57cec5SDimitry Andric  bits<7> imm7;
52960b57cec5SDimitry Andric  let Inst{31-24} = 0b00100100;
52970b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
52980b57cec5SDimitry Andric  let Inst{21}    = 1;
52990b57cec5SDimitry Andric  let Inst{20-14} = imm7;
53000b57cec5SDimitry Andric  let Inst{13}    = opc{1};
53010b57cec5SDimitry Andric  let Inst{12-10} = Pg;
53020b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
53030b57cec5SDimitry Andric  let Inst{4}     = opc{0};
53040b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
53050b57cec5SDimitry Andric
53060b57cec5SDimitry Andric  let Defs = [NZCV];
5307e8d8bef9SDimitry Andric  let ElementSize = pprty.ElementSize;
530806c3fb27SDimitry Andric  let hasSideEffects = 0;
5309e8d8bef9SDimitry Andric  let isPTestLike = 1;
53100b57cec5SDimitry Andric}
53110b57cec5SDimitry Andric
5312480093f4SDimitry Andricmulticlass sve_int_ucmp_vi<bits<2> opc, string asm, CondCode cc,
53135ffd83dbSDimitry Andric                           CondCode commuted_cc> {
53140b57cec5SDimitry Andric  def _B : sve_int_ucmp_vi<0b00, opc, asm, PPR8, ZPR8, imm0_127>;
53150b57cec5SDimitry Andric  def _H : sve_int_ucmp_vi<0b01, opc, asm, PPR16, ZPR16, imm0_127>;
53160b57cec5SDimitry Andric  def _S : sve_int_ucmp_vi<0b10, opc, asm, PPR32, ZPR32, imm0_127>;
5317480093f4SDimitry Andric  def _D : sve_int_ucmp_vi<0b11, opc, asm, PPR64, ZPR64, imm0_127_64b>;
5318480093f4SDimitry Andric
53195ffd83dbSDimitry Andric  defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv16i1, nxv16i8, imm0_127,
53205ffd83dbSDimitry Andric                           !cast<Instruction>(NAME # _B)>;
53215ffd83dbSDimitry Andric  defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv8i1,  nxv8i16, imm0_127,
53225ffd83dbSDimitry Andric                           !cast<Instruction>(NAME # _H)>;
53235ffd83dbSDimitry Andric  defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv4i1,  nxv4i32, imm0_127,
53245ffd83dbSDimitry Andric                           !cast<Instruction>(NAME # _S)>;
53255ffd83dbSDimitry Andric  defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv2i1,  nxv2i64, imm0_127_64b,
53265ffd83dbSDimitry Andric                           !cast<Instruction>(NAME # _D)>;
53270b57cec5SDimitry Andric}
53280b57cec5SDimitry Andric
53290b57cec5SDimitry Andric
53300b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
53310b57cec5SDimitry Andric// SVE Integer Compare - Scalars Group
53320b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
53330b57cec5SDimitry Andric
53340b57cec5SDimitry Andricclass sve_int_cterm<bit sz, bit opc, string asm, RegisterClass rt>
53350b57cec5SDimitry Andric: I<(outs), (ins rt:$Rn, rt:$Rm),
53360b57cec5SDimitry Andric  asm, "\t$Rn, $Rm",
53370b57cec5SDimitry Andric  "",
53380b57cec5SDimitry Andric  []>, Sched<[]> {
53390b57cec5SDimitry Andric  bits<5> Rm;
53400b57cec5SDimitry Andric  bits<5> Rn;
53410b57cec5SDimitry Andric  let Inst{31-23} = 0b001001011;
53420b57cec5SDimitry Andric  let Inst{22}    = sz;
53430b57cec5SDimitry Andric  let Inst{21}    = 0b1;
53440b57cec5SDimitry Andric  let Inst{20-16} = Rm;
53450b57cec5SDimitry Andric  let Inst{15-10} = 0b001000;
53460b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
53470b57cec5SDimitry Andric  let Inst{4}     = opc;
53480b57cec5SDimitry Andric  let Inst{3-0}   = 0b0000;
53490b57cec5SDimitry Andric
53500b57cec5SDimitry Andric  let Defs = [NZCV];
535106c3fb27SDimitry Andric  let hasSideEffects = 0;
53520b57cec5SDimitry Andric}
53530b57cec5SDimitry Andric
53540b57cec5SDimitry Andricclass sve_int_while_rr<bits<2> sz8_64, bits<4> opc, string asm,
5355e8d8bef9SDimitry Andric                       RegisterClass gprty, PPRRegOp pprty>
53560b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins gprty:$Rn, gprty:$Rm),
53570b57cec5SDimitry Andric  asm, "\t$Pd, $Rn, $Rm",
53580b57cec5SDimitry Andric  "", []>, Sched<[]> {
53590b57cec5SDimitry Andric  bits<4> Pd;
53600b57cec5SDimitry Andric  bits<5> Rm;
53610b57cec5SDimitry Andric  bits<5> Rn;
53620b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
53630b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
53640b57cec5SDimitry Andric  let Inst{21}    = 0b1;
53650b57cec5SDimitry Andric  let Inst{20-16} = Rm;
53660b57cec5SDimitry Andric  let Inst{15-13} = 0b000;
53670b57cec5SDimitry Andric  let Inst{12-10} = opc{3-1};
53680b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
53690b57cec5SDimitry Andric  let Inst{4}     = opc{0};
53700b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
53710b57cec5SDimitry Andric
53720b57cec5SDimitry Andric  let Defs = [NZCV];
5373e8d8bef9SDimitry Andric  let ElementSize = pprty.ElementSize;
537406c3fb27SDimitry Andric  let hasSideEffects = 0;
5375e8d8bef9SDimitry Andric  let isWhile = 1;
53760b57cec5SDimitry Andric}
53770b57cec5SDimitry Andric
5378*0fca6ea1SDimitry Andricmulticlass sve_int_while4_rr<bits<3> opc, string asm, SDPatternOperator op,
5379*0fca6ea1SDimitry Andric                             SDPatternOperator rev_op> {
5380e8d8bef9SDimitry Andric  def _B : sve_int_while_rr<0b00, { 0, opc }, asm, GPR32, PPR8>;
5381e8d8bef9SDimitry Andric  def _H : sve_int_while_rr<0b01, { 0, opc }, asm, GPR32, PPR16>;
5382e8d8bef9SDimitry Andric  def _S : sve_int_while_rr<0b10, { 0, opc }, asm, GPR32, PPR32>;
5383e8d8bef9SDimitry Andric  def _D : sve_int_while_rr<0b11, { 0, opc }, asm, GPR32, PPR64>;
5384480093f4SDimitry Andric
5385480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i1, op, i32, i32, !cast<Instruction>(NAME # _B)>;
5386480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i1,  op, i32, i32, !cast<Instruction>(NAME # _H)>;
5387480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i1,  op, i32, i32, !cast<Instruction>(NAME # _S)>;
5388480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i1,  op, i32, i32, !cast<Instruction>(NAME # _D)>;
5389*0fca6ea1SDimitry Andric
5390*0fca6ea1SDimitry Andric  def : Pat<(nxv16i1 (vector_reverse (rev_op i32:$op2, i32:$op1))),
5391*0fca6ea1SDimitry Andric            (!cast<Instruction>(NAME # "_B") $op1, $op2)>;
5392*0fca6ea1SDimitry Andric  def : Pat<(nxv8i1 (vector_reverse (rev_op i32:$op2, i32:$op1))),
5393*0fca6ea1SDimitry Andric            (!cast<Instruction>(NAME # "_H") $op1, $op2)>;
5394*0fca6ea1SDimitry Andric  def : Pat<(nxv4i1 (vector_reverse (rev_op i32:$op2, i32:$op1))),
5395*0fca6ea1SDimitry Andric            (!cast<Instruction>(NAME # "_S") $op1, $op2)>;
5396*0fca6ea1SDimitry Andric  def : Pat<(nxv2i1 (vector_reverse (rev_op i32:$op2, i32:$op1))),
5397*0fca6ea1SDimitry Andric            (!cast<Instruction>(NAME # "_D") $op1, $op2)>;
53980b57cec5SDimitry Andric}
53990b57cec5SDimitry Andric
5400*0fca6ea1SDimitry Andricmulticlass sve_int_while8_rr<bits<3> opc, string asm, SDPatternOperator op,
5401*0fca6ea1SDimitry Andric                             SDPatternOperator rev_op> {
5402e8d8bef9SDimitry Andric  def _B : sve_int_while_rr<0b00, { 1, opc }, asm, GPR64, PPR8>;
5403e8d8bef9SDimitry Andric  def _H : sve_int_while_rr<0b01, { 1, opc }, asm, GPR64, PPR16>;
5404e8d8bef9SDimitry Andric  def _S : sve_int_while_rr<0b10, { 1, opc }, asm, GPR64, PPR32>;
5405e8d8bef9SDimitry Andric  def _D : sve_int_while_rr<0b11, { 1, opc }, asm, GPR64, PPR64>;
5406480093f4SDimitry Andric
5407480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv16i1, op, i64, i64, !cast<Instruction>(NAME # _B)>;
5408480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8i1,  op, i64, i64, !cast<Instruction>(NAME # _H)>;
5409480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i1,  op, i64, i64, !cast<Instruction>(NAME # _S)>;
5410480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i1,  op, i64, i64, !cast<Instruction>(NAME # _D)>;
5411*0fca6ea1SDimitry Andric
5412*0fca6ea1SDimitry Andric  def : Pat<(nxv16i1 (vector_reverse (rev_op i64:$op2, i64:$op1))),
5413*0fca6ea1SDimitry Andric            (!cast<Instruction>(NAME # "_B") $op1, $op2)>;
5414*0fca6ea1SDimitry Andric  def : Pat<(nxv8i1 (vector_reverse (rev_op i64:$op2, i64:$op1))),
5415*0fca6ea1SDimitry Andric            (!cast<Instruction>(NAME # "_H") $op1, $op2)>;
5416*0fca6ea1SDimitry Andric  def : Pat<(nxv4i1 (vector_reverse (rev_op i64:$op2, i64:$op1))),
5417*0fca6ea1SDimitry Andric            (!cast<Instruction>(NAME # "_S") $op1, $op2)>;
5418*0fca6ea1SDimitry Andric  def : Pat<(nxv2i1 (vector_reverse (rev_op i64:$op2, i64:$op1))),
5419*0fca6ea1SDimitry Andric            (!cast<Instruction>(NAME # "_D") $op1, $op2)>;
54200b57cec5SDimitry Andric}
54210b57cec5SDimitry Andric
54220b57cec5SDimitry Andricclass sve2_int_while_rr<bits<2> sz8_64, bits<1> rw, string asm,
54230b57cec5SDimitry Andric                        PPRRegOp pprty>
54240b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins GPR64:$Rn, GPR64:$Rm),
54250b57cec5SDimitry Andric  asm, "\t$Pd, $Rn, $Rm",
54260b57cec5SDimitry Andric  "", []>, Sched<[]> {
54270b57cec5SDimitry Andric  bits<4> Pd;
54280b57cec5SDimitry Andric  bits<5> Rm;
54290b57cec5SDimitry Andric  bits<5> Rn;
54300b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
54310b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
54320b57cec5SDimitry Andric  let Inst{21}    = 0b1;
54330b57cec5SDimitry Andric  let Inst{20-16} = Rm;
54340b57cec5SDimitry Andric  let Inst{15-10} = 0b001100;
54350b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
54360b57cec5SDimitry Andric  let Inst{4}     = rw;
54370b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
54380b57cec5SDimitry Andric
54390b57cec5SDimitry Andric  let Defs = [NZCV];
5440e8d8bef9SDimitry Andric  let ElementSize = pprty.ElementSize;
544106c3fb27SDimitry Andric  let hasSideEffects = 0;
5442e8d8bef9SDimitry Andric  let isWhile = 1;
54430b57cec5SDimitry Andric}
54440b57cec5SDimitry Andric
54455ffd83dbSDimitry Andricmulticlass sve2_int_while_rr<bits<1> rw, string asm, string op> {
54460b57cec5SDimitry Andric  def _B : sve2_int_while_rr<0b00, rw, asm, PPR8>;
54470b57cec5SDimitry Andric  def _H : sve2_int_while_rr<0b01, rw, asm, PPR16>;
54480b57cec5SDimitry Andric  def _S : sve2_int_while_rr<0b10, rw, asm, PPR32>;
54490b57cec5SDimitry Andric  def _D : sve2_int_while_rr<0b11, rw, asm, PPR64>;
54505ffd83dbSDimitry Andric
54515ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv16i1, !cast<SDPatternOperator>(op # _b), i64, i64, !cast<Instruction>(NAME # _B)>;
54525ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8i1,  !cast<SDPatternOperator>(op # _h), i64, i64, !cast<Instruction>(NAME # _H)>;
54535ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4i1,  !cast<SDPatternOperator>(op # _s), i64, i64, !cast<Instruction>(NAME # _S)>;
54545ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2i1,  !cast<SDPatternOperator>(op # _d), i64, i64, !cast<Instruction>(NAME # _D)>;
54550b57cec5SDimitry Andric}
54560b57cec5SDimitry Andric
54570b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
54580b57cec5SDimitry Andric// SVE Floating Point Fast Reduction Group
54590b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
54600b57cec5SDimitry Andric
54610b57cec5SDimitry Andricclass sve_fp_fast_red<bits<2> sz, bits<3> opc, string asm,
54625ffd83dbSDimitry Andric                      ZPRRegOp zprty, FPRasZPROperand dstOpType>
54635ffd83dbSDimitry Andric: I<(outs dstOpType:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
54640b57cec5SDimitry Andric  asm, "\t$Vd, $Pg, $Zn",
54650b57cec5SDimitry Andric  "",
54660b57cec5SDimitry Andric  []>, Sched<[]> {
54670b57cec5SDimitry Andric  bits<5> Zn;
54680b57cec5SDimitry Andric  bits<5> Vd;
54690b57cec5SDimitry Andric  bits<3> Pg;
54700b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
54710b57cec5SDimitry Andric  let Inst{23-22} = sz;
54720b57cec5SDimitry Andric  let Inst{21-19} = 0b000;
54730b57cec5SDimitry Andric  let Inst{18-16} = opc;
54740b57cec5SDimitry Andric  let Inst{15-13} = 0b001;
54750b57cec5SDimitry Andric  let Inst{12-10} = Pg;
54760b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
54770b57cec5SDimitry Andric  let Inst{4-0}   = Vd;
547806c3fb27SDimitry Andric
547906c3fb27SDimitry Andric  let hasSideEffects = 0;
548006c3fb27SDimitry Andric  let mayRaiseFPException = 1;
54810b57cec5SDimitry Andric}
54820b57cec5SDimitry Andric
5483480093f4SDimitry Andricmulticlass sve_fp_fast_red<bits<3> opc, string asm, SDPatternOperator op> {
54845ffd83dbSDimitry Andric  def _H : sve_fp_fast_red<0b01, opc, asm, ZPR16, FPR16asZPR>;
54855ffd83dbSDimitry Andric  def _S : sve_fp_fast_red<0b10, opc, asm, ZPR32, FPR32asZPR>;
54865ffd83dbSDimitry Andric  def _D : sve_fp_fast_red<0b11, opc, asm, ZPR64, FPR64asZPR>;
5487480093f4SDimitry Andric
5488e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
5489e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
54905ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
5491e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
54925ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
54935ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
54940b57cec5SDimitry Andric}
54950b57cec5SDimitry Andric
54960b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
54970b57cec5SDimitry Andric// SVE Floating Point Accumulating Reduction Group
54980b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
54990b57cec5SDimitry Andric
55000b57cec5SDimitry Andricclass sve_fp_2op_p_vd<bits<2> sz, bits<3> opc, string asm,
55015ffd83dbSDimitry Andric                      ZPRRegOp zprty, FPRasZPROperand dstOpType>
55025ffd83dbSDimitry Andric: I<(outs dstOpType:$Vdn), (ins PPR3bAny:$Pg, dstOpType:$_Vdn, zprty:$Zm),
55030b57cec5SDimitry Andric  asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
55040b57cec5SDimitry Andric  "",
55050b57cec5SDimitry Andric  []>,
55060b57cec5SDimitry Andric  Sched<[]> {
55070b57cec5SDimitry Andric  bits<3> Pg;
55080b57cec5SDimitry Andric  bits<5> Vdn;
55090b57cec5SDimitry Andric  bits<5> Zm;
55100b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
55110b57cec5SDimitry Andric  let Inst{23-22} = sz;
55120b57cec5SDimitry Andric  let Inst{21-19} = 0b011;
55130b57cec5SDimitry Andric  let Inst{18-16} = opc;
55140b57cec5SDimitry Andric  let Inst{15-13} = 0b001;
55150b57cec5SDimitry Andric  let Inst{12-10} = Pg;
55160b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
55170b57cec5SDimitry Andric  let Inst{4-0}   = Vdn;
55180b57cec5SDimitry Andric
55190b57cec5SDimitry Andric  let Constraints = "$Vdn = $_Vdn";
552006c3fb27SDimitry Andric  let hasSideEffects = 0;
552106c3fb27SDimitry Andric  let mayRaiseFPException = 1;
55220b57cec5SDimitry Andric}
55230b57cec5SDimitry Andric
5524480093f4SDimitry Andricmulticlass sve_fp_2op_p_vd<bits<3> opc, string asm, SDPatternOperator op> {
55255ffd83dbSDimitry Andric  def _H : sve_fp_2op_p_vd<0b01, opc, asm, ZPR16, FPR16asZPR>;
55265ffd83dbSDimitry Andric  def _S : sve_fp_2op_p_vd<0b10, opc, asm, ZPR32, FPR32asZPR>;
55275ffd83dbSDimitry Andric  def _D : sve_fp_2op_p_vd<0b11, opc, asm, ZPR64, FPR64asZPR>;
5528480093f4SDimitry Andric
5529e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _H)>;
5530e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _H)>;
55315ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
5532e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _S)>;
55335ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
55345ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
55350b57cec5SDimitry Andric}
55360b57cec5SDimitry Andric
55370b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
55380b57cec5SDimitry Andric// SVE Floating Point Compare - Vectors Group
55390b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
55400b57cec5SDimitry Andric
55410b57cec5SDimitry Andricclass sve_fp_3op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
55420b57cec5SDimitry Andric                      ZPRRegOp zprty>
55430b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
55440b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z, $Zn, $Zm",
55450b57cec5SDimitry Andric  "",
55460b57cec5SDimitry Andric  []>, Sched<[]> {
55470b57cec5SDimitry Andric  bits<4> Pd;
55480b57cec5SDimitry Andric  bits<3> Pg;
55490b57cec5SDimitry Andric  bits<5> Zm;
55500b57cec5SDimitry Andric  bits<5> Zn;
55510b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
55520b57cec5SDimitry Andric  let Inst{23-22} = sz;
55530b57cec5SDimitry Andric  let Inst{21}    = 0b0;
55540b57cec5SDimitry Andric  let Inst{20-16} = Zm;
55550b57cec5SDimitry Andric  let Inst{15}    = opc{2};
55560b57cec5SDimitry Andric  let Inst{14}    = 0b1;
55570b57cec5SDimitry Andric  let Inst{13}    = opc{1};
55580b57cec5SDimitry Andric  let Inst{12-10} = Pg;
55590b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
55600b57cec5SDimitry Andric  let Inst{4}     = opc{0};
55610b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
556206c3fb27SDimitry Andric
556306c3fb27SDimitry Andric  let hasSideEffects = 0;
556406c3fb27SDimitry Andric  let mayRaiseFPException = 1;
55650b57cec5SDimitry Andric}
55660b57cec5SDimitry Andric
5567480093f4SDimitry Andricmulticlass sve_fp_3op_p_pd<bits<3> opc, string asm, SDPatternOperator op> {
55680b57cec5SDimitry Andric  def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
55690b57cec5SDimitry Andric  def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
55700b57cec5SDimitry Andric  def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
5571480093f4SDimitry Andric
5572480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
5573480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
5574480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i1, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
55750b57cec5SDimitry Andric}
55760b57cec5SDimitry Andric
5577fe6060f1SDimitry Andricmulticlass sve_fp_3op_p_pd_cc<bits<3> opc, string asm,
5578fe6060f1SDimitry Andric                              CondCode cc1, CondCode cc2,
5579fe6060f1SDimitry Andric                              CondCode invcc1, CondCode invcc2> {
5580fe6060f1SDimitry Andric  def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
5581fe6060f1SDimitry Andric  def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
5582fe6060f1SDimitry Andric  def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
5583fe6060f1SDimitry Andric
5584fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc1, invcc1, nxv8i1,  nxv8f16, !cast<Instruction>(NAME # _H)>;
5585fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc1, invcc1, nxv4i1,  nxv4f16, !cast<Instruction>(NAME # _H)>;
5586fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1,  nxv2f16, !cast<Instruction>(NAME # _H)>;
5587fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc1, invcc1, nxv4i1,  nxv4f32, !cast<Instruction>(NAME # _S)>;
5588fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1,  nxv2f32, !cast<Instruction>(NAME # _S)>;
5589fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1,  nxv2f64, !cast<Instruction>(NAME # _D)>;
5590fe6060f1SDimitry Andric
5591fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc2, invcc2, nxv8i1,  nxv8f16, !cast<Instruction>(NAME # _H)>;
5592fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc2, invcc2, nxv4i1,  nxv4f16, !cast<Instruction>(NAME # _H)>;
5593fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1,  nxv2f16, !cast<Instruction>(NAME # _H)>;
5594fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc2, invcc2, nxv4i1,  nxv4f32, !cast<Instruction>(NAME # _S)>;
5595fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1,  nxv2f32, !cast<Instruction>(NAME # _S)>;
5596fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1,  nxv2f64, !cast<Instruction>(NAME # _D)>;
55975ffd83dbSDimitry Andric}
55980b57cec5SDimitry Andric
55990b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
56000b57cec5SDimitry Andric// SVE Floating Point Compare - with Zero Group
56010b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
56020b57cec5SDimitry Andric
56030b57cec5SDimitry Andricclass sve_fp_2op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
56040b57cec5SDimitry Andric                      ZPRRegOp zprty>
56050b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn),
56060b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z, $Zn, #0.0",
56070b57cec5SDimitry Andric  "",
56080b57cec5SDimitry Andric  []>, Sched<[]> {
56090b57cec5SDimitry Andric  bits<4> Pd;
56100b57cec5SDimitry Andric  bits<3> Pg;
56110b57cec5SDimitry Andric  bits<5> Zn;
56120b57cec5SDimitry Andric  let Inst{31-24} = 0b01100101;
56130b57cec5SDimitry Andric  let Inst{23-22} = sz;
56140b57cec5SDimitry Andric  let Inst{21-18} = 0b0100;
56150b57cec5SDimitry Andric  let Inst{17-16} = opc{2-1};
56160b57cec5SDimitry Andric  let Inst{15-13} = 0b001;
56170b57cec5SDimitry Andric  let Inst{12-10} = Pg;
56180b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
56190b57cec5SDimitry Andric  let Inst{4}     = opc{0};
56200b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
562106c3fb27SDimitry Andric
562206c3fb27SDimitry Andric  let hasSideEffects = 0;
562306c3fb27SDimitry Andric  let mayRaiseFPException = 1;
56240b57cec5SDimitry Andric}
56250b57cec5SDimitry Andric
5626fe6060f1SDimitry Andricmulticlass sve_fp_2op_p_pd<bits<3> opc, string asm,
5627fe6060f1SDimitry Andric                           CondCode cc1, CondCode cc2,
5628fe6060f1SDimitry Andric                           CondCode invcc1, CondCode invcc2> {
56290b57cec5SDimitry Andric  def _H : sve_fp_2op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
56300b57cec5SDimitry Andric  def _S : sve_fp_2op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
56310b57cec5SDimitry Andric  def _D : sve_fp_2op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
5632fe6060f1SDimitry Andric
5633fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv8i1,  nxv8f16, !cast<Instruction>(NAME # _H)>;
5634fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv4i1,  nxv4f16, !cast<Instruction>(NAME # _H)>;
5635fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1,  nxv2f16, !cast<Instruction>(NAME # _H)>;
5636fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv4i1,  nxv4f32, !cast<Instruction>(NAME # _S)>;
5637fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1,  nxv2f32, !cast<Instruction>(NAME # _S)>;
5638fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1,  nxv2f64, !cast<Instruction>(NAME # _D)>;
5639fe6060f1SDimitry Andric
5640fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv8i1,  nxv8f16, !cast<Instruction>(NAME # _H)>;
5641fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv4i1,  nxv4f16, !cast<Instruction>(NAME # _H)>;
5642fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1,  nxv2f16, !cast<Instruction>(NAME # _H)>;
5643fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv4i1,  nxv4f32, !cast<Instruction>(NAME # _S)>;
5644fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1,  nxv2f32, !cast<Instruction>(NAME # _S)>;
5645fe6060f1SDimitry Andric  defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1,  nxv2f64, !cast<Instruction>(NAME # _D)>;
56460b57cec5SDimitry Andric}
56470b57cec5SDimitry Andric
56480b57cec5SDimitry Andric
56490b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
56500b57cec5SDimitry Andric//SVE Index Generation Group
56510b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
56520b57cec5SDimitry Andric
5653fe6060f1SDimitry Andricdef simm5_8b_tgt : TImmLeaf<i8, [{ return (int8_t)Imm >= -16 && (int8_t)Imm < 16; }]>;
5654fe6060f1SDimitry Andricdef simm5_16b_tgt : TImmLeaf<i16, [{ return (int16_t)Imm >= -16 && (int16_t)Imm < 16; }]>;
5655fe6060f1SDimitry Andricdef simm5_32b_tgt : TImmLeaf<i32, [{ return (int32_t)Imm >= -16 && (int32_t)Imm < 16; }]>;
5656fe6060f1SDimitry Andricdef simm5_64b_tgt : TImmLeaf<i64, [{ return (int64_t)Imm >= -16 && (int64_t)Imm < 16; }]>;
5657fe6060f1SDimitry Andricdef i64imm_32bit_tgt : TImmLeaf<i64, [{
5658fe6060f1SDimitry Andric  return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
5659fe6060f1SDimitry Andric}]>;
5660fe6060f1SDimitry Andric
56610b57cec5SDimitry Andricclass sve_int_index_ii<bits<2> sz8_64, string asm, ZPRRegOp zprty,
56620b57cec5SDimitry Andric                       Operand imm_ty>
56630b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins imm_ty:$imm5, imm_ty:$imm5b),
56640b57cec5SDimitry Andric  asm, "\t$Zd, $imm5, $imm5b",
56650b57cec5SDimitry Andric  "", []>, Sched<[]> {
56660b57cec5SDimitry Andric  bits<5> Zd;
56670b57cec5SDimitry Andric  bits<5> imm5;
56680b57cec5SDimitry Andric  bits<5> imm5b;
56690b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
56700b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
56710b57cec5SDimitry Andric  let Inst{21}    = 0b1;
56720b57cec5SDimitry Andric  let Inst{20-16} = imm5b;
56730b57cec5SDimitry Andric  let Inst{15-10} = 0b010000;
56740b57cec5SDimitry Andric  let Inst{9-5}   = imm5;
56750b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
567681ad6265SDimitry Andric
567706c3fb27SDimitry Andric  let hasSideEffects = 0;
567881ad6265SDimitry Andric  let isReMaterializable = 1;
5679*0fca6ea1SDimitry Andric  let Uses = [VG];
56800b57cec5SDimitry Andric}
56810b57cec5SDimitry Andric
5682349cc55cSDimitry Andricmulticlass sve_int_index_ii<string asm> {
56835ffd83dbSDimitry Andric  def _B : sve_int_index_ii<0b00, asm, ZPR8, simm5_8b>;
56845ffd83dbSDimitry Andric  def _H : sve_int_index_ii<0b01, asm, ZPR16, simm5_16b>;
56850b57cec5SDimitry Andric  def _S : sve_int_index_ii<0b10, asm, ZPR32, simm5_32b>;
56860b57cec5SDimitry Andric  def _D : sve_int_index_ii<0b11, asm, ZPR64, simm5_64b>;
56875ffd83dbSDimitry Andric
5688fe6060f1SDimitry Andric  def : Pat<(nxv16i8 (step_vector simm5_8b_tgt:$imm5b)),
5689fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_B") (i32 0), (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
5690fe6060f1SDimitry Andric  def : Pat<(nxv8i16 (step_vector simm5_16b_tgt:$imm5b)),
5691fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_H") (i32 0), (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
5692fe6060f1SDimitry Andric  def : Pat<(nxv4i32 (step_vector simm5_32b_tgt:$imm5b)),
5693fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_S") (i32 0), simm5_32b:$imm5b)>;
5694fe6060f1SDimitry Andric  def : Pat<(nxv2i64 (step_vector simm5_64b_tgt:$imm5b)),
5695fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") (i64 0), simm5_64b:$imm5b)>;
5696fe6060f1SDimitry Andric
5697fe6060f1SDimitry Andric  // add(step_vector(step), dup(X)) -> index(X, step).
569881ad6265SDimitry Andric  def : Pat<(add (nxv16i8 (step_vector_oneuse simm5_8b_tgt:$imm5b)), (nxv16i8 (splat_vector(simm5_8b:$imm5)))),
5699fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
570081ad6265SDimitry Andric  def : Pat<(add (nxv8i16 (step_vector_oneuse simm5_16b_tgt:$imm5b)), (nxv8i16 (splat_vector(simm5_16b:$imm5)))),
5701fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
570281ad6265SDimitry Andric  def : Pat<(add (nxv4i32 (step_vector_oneuse simm5_32b_tgt:$imm5b)), (nxv4i32 (splat_vector(simm5_32b:$imm5)))),
57035ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, simm5_32b:$imm5b)>;
570481ad6265SDimitry Andric  def : Pat<(add (nxv2i64 (step_vector_oneuse simm5_64b_tgt:$imm5b)), (nxv2i64 (splat_vector(simm5_64b:$imm5)))),
57055ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, simm5_64b:$imm5b)>;
57060b57cec5SDimitry Andric}
57070b57cec5SDimitry Andric
57080b57cec5SDimitry Andricclass sve_int_index_ir<bits<2> sz8_64, string asm, ZPRRegOp zprty,
57090b57cec5SDimitry Andric                       RegisterClass srcRegType, Operand imm_ty>
57100b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins imm_ty:$imm5, srcRegType:$Rm),
57110b57cec5SDimitry Andric  asm, "\t$Zd, $imm5, $Rm",
57120b57cec5SDimitry Andric  "", []>, Sched<[]> {
57130b57cec5SDimitry Andric  bits<5> Rm;
57140b57cec5SDimitry Andric  bits<5> Zd;
57150b57cec5SDimitry Andric  bits<5> imm5;
57160b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
57170b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
57180b57cec5SDimitry Andric  let Inst{21}    = 0b1;
57190b57cec5SDimitry Andric  let Inst{20-16} = Rm;
57200b57cec5SDimitry Andric  let Inst{15-10} = 0b010010;
57210b57cec5SDimitry Andric  let Inst{9-5}   = imm5;
57220b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
572306c3fb27SDimitry Andric
572406c3fb27SDimitry Andric  let hasSideEffects = 0;
57250b57cec5SDimitry Andric}
57260b57cec5SDimitry Andric
5727349cc55cSDimitry Andricmulticlass sve_int_index_ir<string asm, SDPatternOperator mulop, SDPatternOperator muloneuseop> {
57285ffd83dbSDimitry Andric  def _B : sve_int_index_ir<0b00, asm, ZPR8, GPR32, simm5_8b>;
57295ffd83dbSDimitry Andric  def _H : sve_int_index_ir<0b01, asm, ZPR16, GPR32, simm5_16b>;
57300b57cec5SDimitry Andric  def _S : sve_int_index_ir<0b10, asm, ZPR32, GPR32, simm5_32b>;
57310b57cec5SDimitry Andric  def _D : sve_int_index_ir<0b11, asm, ZPR64, GPR64, simm5_64b>;
57325ffd83dbSDimitry Andric
5733fe6060f1SDimitry Andric  def : Pat<(nxv16i8 (step_vector i8:$imm)),
5734fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_B") (i32 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
5735fe6060f1SDimitry Andric  def : Pat<(nxv8i16 (step_vector i16:$imm)),
5736fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_H") (i32 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
5737fe6060f1SDimitry Andric  def : Pat<(nxv4i32 (step_vector i32:$imm)),
5738fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_S") (i32 0), (!cast<Instruction>("MOVi32imm") $imm))>;
5739fe6060f1SDimitry Andric  def : Pat<(nxv2i64 (step_vector i64:$imm)),
5740fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") (i64 0), (!cast<Instruction>("MOVi64imm") $imm))>;
5741fe6060f1SDimitry Andric  def : Pat<(nxv2i64 (step_vector i64imm_32bit_tgt:$imm)),
5742fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") (i64 0), (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
5743fe6060f1SDimitry Andric
5744fe6060f1SDimitry Andric  // add(step_vector(step), dup(X)) -> index(X, step).
574581ad6265SDimitry Andric  def : Pat<(add (nxv16i8 (step_vector_oneuse i8:$imm)), (nxv16i8 (splat_vector(simm5_8b:$imm5)))),
5746fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
574781ad6265SDimitry Andric  def : Pat<(add (nxv8i16 (step_vector_oneuse i16:$imm)), (nxv8i16 (splat_vector(simm5_16b:$imm5)))),
5748fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
574981ad6265SDimitry Andric  def : Pat<(add (nxv4i32 (step_vector_oneuse i32:$imm)), (nxv4i32 (splat_vector(simm5_32b:$imm5)))),
5750fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, (!cast<Instruction>("MOVi32imm") $imm))>;
575181ad6265SDimitry Andric  def : Pat<(add (nxv2i64 (step_vector_oneuse i64:$imm)), (nxv2i64 (splat_vector(simm5_64b:$imm5)))),
5752fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, (!cast<Instruction>("MOVi64imm") $imm))>;
575381ad6265SDimitry Andric  def : Pat<(add (nxv2i64 (step_vector_oneuse i64imm_32bit_tgt:$imm)), (nxv2i64 (splat_vector(simm5_64b:$imm5)))),
5754fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
5755fe6060f1SDimitry Andric
5756fe6060f1SDimitry Andric  // mul(step_vector(1), dup(Y)) -> index(0, Y).
5757*0fca6ea1SDimitry Andric  def : Pat<(mulop (nxv16i1 (SVEAllActive)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (splat_vector(i32 GPR32:$Rm)))),
5758fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_B") (i32 0), GPR32:$Rm)>;
5759*0fca6ea1SDimitry Andric  def : Pat<(mulop (nxv8i1 (SVEAllActive)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (splat_vector(i32 GPR32:$Rm)))),
5760fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_H") (i32 0), GPR32:$Rm)>;
5761*0fca6ea1SDimitry Andric  def : Pat<(mulop (nxv4i1 (SVEAllActive)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (splat_vector(i32 GPR32:$Rm)))),
5762fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_S") (i32 0), GPR32:$Rm)>;
5763*0fca6ea1SDimitry Andric  def : Pat<(mulop (nxv2i1 (SVEAllActive)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (splat_vector(i64 GPR64:$Rm)))),
5764fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") (i64 0), GPR64:$Rm)>;
5765fe6060f1SDimitry Andric
5766fe6060f1SDimitry Andric  // add(mul(step_vector(1), dup(Y)), dup(X)) -> index(X, Y).
5767*0fca6ea1SDimitry Andric  def : Pat<(add (muloneuseop (nxv16i1 (SVEAllActive)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (splat_vector(i32 GPR32:$Rm)))), (nxv16i8 (splat_vector(simm5_8b:$imm5)))),
57685ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, GPR32:$Rm)>;
5769*0fca6ea1SDimitry Andric  def : Pat<(add (muloneuseop (nxv8i1 (SVEAllActive)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (splat_vector(i32 GPR32:$Rm)))), (nxv8i16 (splat_vector(simm5_16b:$imm5)))),
57705ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, GPR32:$Rm)>;
5771*0fca6ea1SDimitry Andric  def : Pat<(add (muloneuseop (nxv4i1 (SVEAllActive)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (splat_vector(i32 GPR32:$Rm)))), (nxv4i32 (splat_vector(simm5_32b:$imm5)))),
57725ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, GPR32:$Rm)>;
5773*0fca6ea1SDimitry Andric  def : Pat<(add (muloneuseop (nxv2i1 (SVEAllActive)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (splat_vector(i64 GPR64:$Rm)))), (nxv2i64 (splat_vector(simm5_64b:$imm5)))),
57745ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, GPR64:$Rm)>;
57750b57cec5SDimitry Andric}
57760b57cec5SDimitry Andric
57770b57cec5SDimitry Andricclass sve_int_index_ri<bits<2> sz8_64, string asm, ZPRRegOp zprty,
57780b57cec5SDimitry Andric                       RegisterClass srcRegType, Operand imm_ty>
57790b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins srcRegType:$Rn, imm_ty:$imm5),
57800b57cec5SDimitry Andric  asm, "\t$Zd, $Rn, $imm5",
57810b57cec5SDimitry Andric  "", []>, Sched<[]> {
57820b57cec5SDimitry Andric  bits<5> Rn;
57830b57cec5SDimitry Andric  bits<5> Zd;
57840b57cec5SDimitry Andric  bits<5> imm5;
57850b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
57860b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
57870b57cec5SDimitry Andric  let Inst{21}    = 0b1;
57880b57cec5SDimitry Andric  let Inst{20-16} = imm5;
57890b57cec5SDimitry Andric  let Inst{15-10} = 0b010001;
57900b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
57910b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
579206c3fb27SDimitry Andric
579306c3fb27SDimitry Andric  let hasSideEffects = 0;
57940b57cec5SDimitry Andric}
57950b57cec5SDimitry Andric
5796349cc55cSDimitry Andricmulticlass sve_int_index_ri<string asm> {
57975ffd83dbSDimitry Andric  def _B : sve_int_index_ri<0b00, asm, ZPR8, GPR32, simm5_8b>;
57985ffd83dbSDimitry Andric  def _H : sve_int_index_ri<0b01, asm, ZPR16, GPR32, simm5_16b>;
57990b57cec5SDimitry Andric  def _S : sve_int_index_ri<0b10, asm, ZPR32, GPR32, simm5_32b>;
58000b57cec5SDimitry Andric  def _D : sve_int_index_ri<0b11, asm, ZPR64, GPR64, simm5_64b>;
58015ffd83dbSDimitry Andric
5802fe6060f1SDimitry Andric  // add(step_vector(step), dup(X)) -> index(X, step).
580381ad6265SDimitry Andric  def : Pat<(add (nxv16i8 (step_vector_oneuse simm5_8b_tgt:$imm5)), (nxv16i8 (splat_vector(i32 GPR32:$Rm)))),
5804fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_B") GPR32:$Rm, (!cast<SDNodeXForm>("trunc_imm") $imm5))>;
580581ad6265SDimitry Andric  def : Pat<(add (nxv8i16 (step_vector_oneuse simm5_16b_tgt:$imm5)), (nxv8i16 (splat_vector(i32 GPR32:$Rm)))),
5806fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_H") GPR32:$Rm, (!cast<SDNodeXForm>("trunc_imm") $imm5))>;
580781ad6265SDimitry Andric  def : Pat<(add (nxv4i32 (step_vector_oneuse simm5_32b_tgt:$imm5)), (nxv4i32 (splat_vector(i32 GPR32:$Rm)))),
58085ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_S") GPR32:$Rm, simm5_32b:$imm5)>;
580981ad6265SDimitry Andric  def : Pat<(add (nxv2i64 (step_vector_oneuse simm5_64b_tgt:$imm5)), (nxv2i64 (splat_vector(i64 GPR64:$Rm)))),
58105ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # "_D") GPR64:$Rm, simm5_64b:$imm5)>;
58110b57cec5SDimitry Andric}
58120b57cec5SDimitry Andric
58130b57cec5SDimitry Andricclass sve_int_index_rr<bits<2> sz8_64, string asm, ZPRRegOp zprty,
58140b57cec5SDimitry Andric                       RegisterClass srcRegType>
58150b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins srcRegType:$Rn, srcRegType:$Rm),
58160b57cec5SDimitry Andric  asm, "\t$Zd, $Rn, $Rm",
58170b57cec5SDimitry Andric  "", []>, Sched<[]> {
58180b57cec5SDimitry Andric  bits<5> Zd;
58190b57cec5SDimitry Andric  bits<5> Rm;
58200b57cec5SDimitry Andric  bits<5> Rn;
58210b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
58220b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
58230b57cec5SDimitry Andric  let Inst{21}    = 0b1;
58240b57cec5SDimitry Andric  let Inst{20-16} = Rm;
58250b57cec5SDimitry Andric  let Inst{15-10} = 0b010011;
58260b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
58270b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
582806c3fb27SDimitry Andric
582906c3fb27SDimitry Andric  let hasSideEffects = 0;
58300b57cec5SDimitry Andric}
58310b57cec5SDimitry Andric
5832349cc55cSDimitry Andricmulticlass sve_int_index_rr<string asm, SDPatternOperator mulop> {
58330b57cec5SDimitry Andric  def _B : sve_int_index_rr<0b00, asm, ZPR8, GPR32>;
58340b57cec5SDimitry Andric  def _H : sve_int_index_rr<0b01, asm, ZPR16, GPR32>;
58350b57cec5SDimitry Andric  def _S : sve_int_index_rr<0b10, asm, ZPR32, GPR32>;
58360b57cec5SDimitry Andric  def _D : sve_int_index_rr<0b11, asm, ZPR64, GPR64>;
58375ffd83dbSDimitry Andric
5838fe6060f1SDimitry Andric  // add(step_vector(step), dup(X)) -> index(X, step).
583981ad6265SDimitry Andric  def : Pat<(add (nxv16i8 (step_vector_oneuse i8:$imm)), (nxv16i8 (splat_vector(i32 GPR32:$Rn)))),
5840fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_B") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
584181ad6265SDimitry Andric  def : Pat<(add (nxv8i16 (step_vector_oneuse i16:$imm)), (nxv8i16 (splat_vector(i32 GPR32:$Rn)))),
5842fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_H") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
584381ad6265SDimitry Andric  def : Pat<(add (nxv4i32 (step_vector_oneuse i32:$imm)), (nxv4i32 (splat_vector(i32 GPR32:$Rn)))),
5844fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_S") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") $imm))>;
584581ad6265SDimitry Andric  def : Pat<(add (nxv2i64 (step_vector_oneuse i64:$imm)), (nxv2i64 (splat_vector(i64 GPR64:$Rn)))),
5846fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") GPR64:$Rn, (!cast<Instruction>("MOVi64imm") $imm))>;
584781ad6265SDimitry Andric  def : Pat<(add (nxv2i64 (step_vector_oneuse i64imm_32bit_tgt:$imm)), (nxv2i64 (splat_vector(i64 GPR64:$Rn)))),
5848fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") GPR64:$Rn, (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
5849fe6060f1SDimitry Andric
5850fe6060f1SDimitry Andric  // add(mul(step_vector(1), dup(Y)), dup(X)) -> index(X, Y).
5851*0fca6ea1SDimitry Andric  def : Pat<(add (mulop (nxv16i1 (SVEAllActive)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (splat_vector(i32 GPR32:$Rm)))), (nxv16i8 (splat_vector(i32 GPR32:$Rn)))),
5852fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_B") GPR32:$Rn, GPR32:$Rm)>;
5853*0fca6ea1SDimitry Andric  def : Pat<(add (mulop (nxv8i1 (SVEAllActive)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (splat_vector(i32 GPR32:$Rm)))),(nxv8i16 (splat_vector(i32 GPR32:$Rn)))),
5854fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_H") GPR32:$Rn, GPR32:$Rm)>;
5855*0fca6ea1SDimitry Andric  def : Pat<(add (mulop (nxv4i1 (SVEAllActive)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (splat_vector(i32 GPR32:$Rm)))),(nxv4i32 (splat_vector(i32 GPR32:$Rn)))),
5856fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_S") GPR32:$Rn, GPR32:$Rm)>;
5857*0fca6ea1SDimitry Andric  def : Pat<(add (mulop (nxv2i1 (SVEAllActive)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (splat_vector(i64 GPR64:$Rm)))),(nxv2i64 (splat_vector(i64 GPR64:$Rn)))),
5858fe6060f1SDimitry Andric            (!cast<Instruction>(NAME # "_D") GPR64:$Rn, GPR64:$Rm)>;
58590b57cec5SDimitry Andric}
5860e8d8bef9SDimitry Andric
58610b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
58620b57cec5SDimitry Andric// SVE Bitwise Shift - Predicated Group
58630b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5864e8d8bef9SDimitry Andric
58650b57cec5SDimitry Andricclass sve_int_bin_pred_shift_imm<bits<4> tsz8_64, bits<4> opc, string asm,
58665ffd83dbSDimitry Andric                                 ZPRRegOp zprty, Operand immtype>
58670b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, immtype:$imm),
58680b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $_Zdn, $imm",
58690b57cec5SDimitry Andric  "",
58700b57cec5SDimitry Andric  []>, Sched<[]> {
58710b57cec5SDimitry Andric  bits<3> Pg;
58720b57cec5SDimitry Andric  bits<5> Zdn;
58730b57cec5SDimitry Andric  bits<6> imm;
58740b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
58750b57cec5SDimitry Andric  let Inst{23-22} = tsz8_64{3-2};
58760b57cec5SDimitry Andric  let Inst{21-20} = 0b00;
58770b57cec5SDimitry Andric  let Inst{19-16} = opc;
58780b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
58790b57cec5SDimitry Andric  let Inst{12-10} = Pg;
58800b57cec5SDimitry Andric  let Inst{9-8}   = tsz8_64{1-0};
58810b57cec5SDimitry Andric  let Inst{7-5}   = imm{2-0}; // imm3
58820b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
58830b57cec5SDimitry Andric
58840b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
58855ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveBinaryImm;
58865ffd83dbSDimitry Andric  let ElementSize = zprty.ElementSize;
588706c3fb27SDimitry Andric  let hasSideEffects = 0;
58880b57cec5SDimitry Andric}
58890b57cec5SDimitry Andric
5890e8d8bef9SDimitry Andricmulticlass sve_int_bin_pred_shift_imm_left<bits<4> opc, string asm, string Ps,
5891e8d8bef9SDimitry Andric                                           SDPatternOperator op = null_frag> {
5892e8d8bef9SDimitry Andric  def _B : SVEPseudo2Instr<Ps # _B, 1>,
58935ffd83dbSDimitry Andric           sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
5894e8d8bef9SDimitry Andric  def _H : SVEPseudo2Instr<Ps # _H, 1>,
58955ffd83dbSDimitry Andric           sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
58960b57cec5SDimitry Andric    let Inst{8} = imm{3};
58970b57cec5SDimitry Andric  }
5898e8d8bef9SDimitry Andric  def _S : SVEPseudo2Instr<Ps # _S, 1>,
58995ffd83dbSDimitry Andric           sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
59000b57cec5SDimitry Andric    let Inst{9-8} = imm{4-3};
59010b57cec5SDimitry Andric  }
5902e8d8bef9SDimitry Andric  def _D : SVEPseudo2Instr<Ps # _D, 1>,
59035ffd83dbSDimitry Andric           sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
59045ffd83dbSDimitry Andric    let Inst{22}  = imm{5};
59055ffd83dbSDimitry Andric    let Inst{9-8} = imm{4-3};
59065ffd83dbSDimitry Andric  }
59075ffd83dbSDimitry Andric
59085ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i1, nxv16i8, i32, tvecshiftL8,  !cast<Instruction>(NAME # _B)>;
59095ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i1,  nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _H)>;
59105ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i1,  nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _S)>;
59115ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i1,  nxv2i64, i32, tvecshiftL64, !cast<Instruction>(NAME # _D)>;
59125ffd83dbSDimitry Andric}
59135ffd83dbSDimitry Andric
5914e8d8bef9SDimitry Andric// As above but shift amount takes the form of a "vector immediate".
5915e8d8bef9SDimitry Andricmulticlass sve_int_bin_pred_shift_imm_left_dup<bits<4> opc, string asm,
5916e8d8bef9SDimitry Andric                                               string Ps, SDPatternOperator op>
5917e8d8bef9SDimitry Andric: sve_int_bin_pred_shift_imm_left<opc, asm, Ps, null_frag> {
5918e8d8bef9SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmL8,  !cast<Instruction>(NAME # _B)>;
5919e8d8bef9SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1,  i32, SVEShiftImmL16, !cast<Instruction>(NAME # _H)>;
5920e8d8bef9SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1,  i32, SVEShiftImmL32, !cast<Instruction>(NAME # _S)>;
5921e8d8bef9SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1,  i64, SVEShiftImmL64, !cast<Instruction>(NAME # _D)>;
5922e8d8bef9SDimitry Andric}
5923e8d8bef9SDimitry Andric
59245ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_shift_imm_left_zeroing_bhsd<SDPatternOperator op> {
592506c3fb27SDimitry Andric  def _B_ZERO : PredTwoOpImmPseudo<NAME # _B, ZPR8,  tvecshiftL8,  FalseLanesZero>;
592606c3fb27SDimitry Andric  def _H_ZERO : PredTwoOpImmPseudo<NAME # _H, ZPR16, tvecshiftL16, FalseLanesZero>;
592706c3fb27SDimitry Andric  def _S_ZERO : PredTwoOpImmPseudo<NAME # _S, ZPR32, tvecshiftL32, FalseLanesZero>;
592806c3fb27SDimitry Andric  def _D_ZERO : PredTwoOpImmPseudo<NAME # _D, ZPR64, tvecshiftL64, FalseLanesZero>;
59295ffd83dbSDimitry Andric
593006c3fb27SDimitry Andric  def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv16i8, op, nxv16i1, nxv16i8, tvecshiftL8,  !cast<Pseudo>(NAME # _B_ZERO)>;
593106c3fb27SDimitry Andric  def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv8i16, op, nxv8i1,  nxv8i16, tvecshiftL16, !cast<Pseudo>(NAME # _H_ZERO)>;
593206c3fb27SDimitry Andric  def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv4i32, op, nxv4i1,  nxv4i32, tvecshiftL32, !cast<Pseudo>(NAME # _S_ZERO)>;
593306c3fb27SDimitry Andric  def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv2i64, op, nxv2i1,  nxv2i64, tvecshiftL64, !cast<Pseudo>(NAME # _D_ZERO)>;
59345ffd83dbSDimitry Andric}
59355ffd83dbSDimitry Andric
59365ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_shift_imm_right<bits<4> opc, string asm, string Ps,
5937480093f4SDimitry Andric                                            SDPatternOperator op = null_frag> {
59385ffd83dbSDimitry Andric  def _B : SVEPseudo2Instr<Ps # _B, 1>,
59395ffd83dbSDimitry Andric           sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
59405ffd83dbSDimitry Andric  def _H : SVEPseudo2Instr<Ps # _H, 1>,
59415ffd83dbSDimitry Andric           sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
59420b57cec5SDimitry Andric    let Inst{8} = imm{3};
59430b57cec5SDimitry Andric  }
59445ffd83dbSDimitry Andric  def _S : SVEPseudo2Instr<Ps # _S, 1>,
59455ffd83dbSDimitry Andric           sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
59460b57cec5SDimitry Andric    let Inst{9-8} = imm{4-3};
59470b57cec5SDimitry Andric  }
59485ffd83dbSDimitry Andric  def _D : SVEPseudo2Instr<Ps # _D, 1>,
59495ffd83dbSDimitry Andric           sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
59500b57cec5SDimitry Andric    let Inst{22}  = imm{5};
59510b57cec5SDimitry Andric    let Inst{9-8} = imm{4-3};
59520b57cec5SDimitry Andric  }
5953480093f4SDimitry Andric
59545ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i1, nxv16i8, i32, tvecshiftR8,  !cast<Instruction>(NAME # _B)>;
59555ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i1,  nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
59565ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i1,  nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
59575ffd83dbSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i1,  nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
59585ffd83dbSDimitry Andric}
59595ffd83dbSDimitry Andric
5960e8d8bef9SDimitry Andric// As above but shift amount takes the form of a "vector immediate".
5961e8d8bef9SDimitry Andricmulticlass sve_int_bin_pred_shift_imm_right_dup<bits<4> opc, string asm,
5962e8d8bef9SDimitry Andric                                            string Ps, SDPatternOperator op>
5963e8d8bef9SDimitry Andric: sve_int_bin_pred_shift_imm_right<opc, asm, Ps, null_frag> {
5964e8d8bef9SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmR8,  !cast<Instruction>(NAME # _B)>;
5965e8d8bef9SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1,  i32, SVEShiftImmR16, !cast<Instruction>(NAME # _H)>;
5966e8d8bef9SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1,  i32, SVEShiftImmR32, !cast<Instruction>(NAME # _S)>;
5967e8d8bef9SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1,  i64, SVEShiftImmR64, !cast<Instruction>(NAME # _D)>;
5968e8d8bef9SDimitry Andric}
5969e8d8bef9SDimitry Andric
59705ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_shift_imm_right_zeroing_bhsd<SDPatternOperator op = null_frag> {
597106c3fb27SDimitry Andric  def _B_ZERO : PredTwoOpImmPseudo<NAME # _B, ZPR8, vecshiftR8, FalseLanesZero>;
597206c3fb27SDimitry Andric  def _H_ZERO : PredTwoOpImmPseudo<NAME # _H, ZPR16, vecshiftR16, FalseLanesZero>;
597306c3fb27SDimitry Andric  def _S_ZERO : PredTwoOpImmPseudo<NAME # _S, ZPR32, vecshiftR32, FalseLanesZero>;
597406c3fb27SDimitry Andric  def _D_ZERO : PredTwoOpImmPseudo<NAME # _D, ZPR64, vecshiftR64, FalseLanesZero>;
59755ffd83dbSDimitry Andric
597606c3fb27SDimitry Andric  def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv16i8, op, nxv16i1, nxv16i8, tvecshiftR8, !cast<Pseudo>(NAME # _B_ZERO)>;
597706c3fb27SDimitry Andric  def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv8i16, op, nxv8i1, nxv8i16, tvecshiftR16, !cast<Pseudo>(NAME # _H_ZERO)>;
597806c3fb27SDimitry Andric  def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv4i32, op, nxv4i1, nxv4i32, tvecshiftR32, !cast<Pseudo>(NAME # _S_ZERO)>;
597906c3fb27SDimitry Andric  def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv2i64, op, nxv2i1, nxv2i64, tvecshiftR64, !cast<Pseudo>(NAME # _D_ZERO)>;
59800b57cec5SDimitry Andric}
59810b57cec5SDimitry Andric
59820b57cec5SDimitry Andricclass sve_int_bin_pred_shift<bits<2> sz8_64, bit wide, bits<3> opc,
59830b57cec5SDimitry Andric                             string asm, ZPRRegOp zprty, ZPRRegOp zprty2>
59840b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty2:$Zm),
59850b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
59860b57cec5SDimitry Andric  "",
59870b57cec5SDimitry Andric  []>, Sched<[]> {
59880b57cec5SDimitry Andric  bits<3> Pg;
59890b57cec5SDimitry Andric  bits<5> Zdn;
59900b57cec5SDimitry Andric  bits<5> Zm;
59910b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
59920b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
59930b57cec5SDimitry Andric  let Inst{21-20} = 0b01;
59940b57cec5SDimitry Andric  let Inst{19}    = wide;
59950b57cec5SDimitry Andric  let Inst{18-16} = opc;
59960b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
59970b57cec5SDimitry Andric  let Inst{12-10} = Pg;
59980b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
59990b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
60000b57cec5SDimitry Andric
60010b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
60025ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
60030b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
600406c3fb27SDimitry Andric  let hasSideEffects = 0;
60050b57cec5SDimitry Andric}
60060b57cec5SDimitry Andric
60075ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_shift<bits<3> opc, string asm, string Ps,
60085ffd83dbSDimitry Andric                                  SDPatternOperator op, string revname, bit isReverseInstr = 0> {
60095ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveBinaryCommWithRev in {
60105ffd83dbSDimitry Andric  def _B : sve_int_bin_pred_shift<0b00, 0b0, opc, asm, ZPR8, ZPR8>,
60115ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
60125ffd83dbSDimitry Andric  def _H : sve_int_bin_pred_shift<0b01, 0b0, opc, asm, ZPR16, ZPR16>,
60135ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
60145ffd83dbSDimitry Andric  def _S : sve_int_bin_pred_shift<0b10, 0b0, opc, asm, ZPR32, ZPR32>,
60155ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
60165ffd83dbSDimitry Andric  def _D : sve_int_bin_pred_shift<0b11, 0b0, opc, asm, ZPR64, ZPR64>,
60175ffd83dbSDimitry Andric           SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
60185ffd83dbSDimitry Andric  }
6019480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
6020480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
6021480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
6022480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
60230b57cec5SDimitry Andric}
60240b57cec5SDimitry Andric
60255ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_zeroing_bhsd<SDPatternOperator op> {
602606c3fb27SDimitry Andric  def _B_ZERO : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesZero>;
602706c3fb27SDimitry Andric  def _H_ZERO : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesZero>;
602806c3fb27SDimitry Andric  def _S_ZERO : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesZero>;
602906c3fb27SDimitry Andric  def _D_ZERO : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesZero>;
60305ffd83dbSDimitry Andric
603106c3fb27SDimitry Andric  def : SVE_3_Op_Pat_SelZero<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _B_ZERO)>;
603206c3fb27SDimitry Andric  def : SVE_3_Op_Pat_SelZero<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _H_ZERO)>;
603306c3fb27SDimitry Andric  def : SVE_3_Op_Pat_SelZero<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _S_ZERO)>;
603406c3fb27SDimitry Andric  def : SVE_3_Op_Pat_SelZero<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _D_ZERO)>;
603506c3fb27SDimitry Andric}
603606c3fb27SDimitry Andric
603706c3fb27SDimitry Andricmulticlass sve_int_bin_pred_imm_zeroing_bhsd<SDPatternOperator op,
603806c3fb27SDimitry Andric                                   ComplexPattern imm_b, ComplexPattern imm_h,
603906c3fb27SDimitry Andric                                   ComplexPattern imm_s, ComplexPattern imm_d> {
604006c3fb27SDimitry Andric  def _B_ZERO : PredTwoOpImmPseudo<NAME # _B, ZPR8,  Operand<i32>, FalseLanesZero>;
604106c3fb27SDimitry Andric  def _H_ZERO : PredTwoOpImmPseudo<NAME # _H, ZPR16, Operand<i32>, FalseLanesZero>;
604206c3fb27SDimitry Andric  def _S_ZERO : PredTwoOpImmPseudo<NAME # _S, ZPR32, Operand<i32>, FalseLanesZero>;
604306c3fb27SDimitry Andric  def _D_ZERO : PredTwoOpImmPseudo<NAME # _D, ZPR64, Operand<i32>, FalseLanesZero>;
604406c3fb27SDimitry Andric
604506c3fb27SDimitry Andric  def : SVE_2_Op_Imm_Pat_Zero<nxv16i8, op, nxv16i1, i32, imm_b, !cast<Pseudo>(NAME # _B_ZERO)>;
604606c3fb27SDimitry Andric  def : SVE_2_Op_Imm_Pat_Zero<nxv8i16, op, nxv8i1,  i32, imm_h, !cast<Pseudo>(NAME # _H_ZERO)>;
604706c3fb27SDimitry Andric  def : SVE_2_Op_Imm_Pat_Zero<nxv4i32, op, nxv4i1,  i32, imm_s, !cast<Pseudo>(NAME # _S_ZERO)>;
604806c3fb27SDimitry Andric  def : SVE_2_Op_Imm_Pat_Zero<nxv2i64, op, nxv2i1,  i64, imm_d, !cast<Pseudo>(NAME # _D_ZERO)>;
60495ffd83dbSDimitry Andric}
60505ffd83dbSDimitry Andric
6051480093f4SDimitry Andricmulticlass sve_int_bin_pred_shift_wide<bits<3> opc, string asm,
6052480093f4SDimitry Andric                                  SDPatternOperator op> {
60530b57cec5SDimitry Andric  def _B : sve_int_bin_pred_shift<0b00, 0b1, opc, asm, ZPR8, ZPR64>;
60540b57cec5SDimitry Andric  def _H : sve_int_bin_pred_shift<0b01, 0b1, opc, asm, ZPR16, ZPR64>;
60550b57cec5SDimitry Andric  def _S : sve_int_bin_pred_shift<0b10, 0b1, opc, asm, ZPR32, ZPR64>;
6056480093f4SDimitry Andric
6057480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
6058480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
6059480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
60600b57cec5SDimitry Andric}
60610b57cec5SDimitry Andric
60620b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
60630b57cec5SDimitry Andric// SVE Shift - Unpredicated Group
60640b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
60650b57cec5SDimitry Andric
60660b57cec5SDimitry Andricclass sve_int_bin_cons_shift_wide<bits<2> sz8_64, bits<2> opc, string asm,
60670b57cec5SDimitry Andric                               ZPRRegOp zprty>
60680b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, ZPR64:$Zm),
60690b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
60700b57cec5SDimitry Andric  "",
60710b57cec5SDimitry Andric  []>, Sched<[]> {
60720b57cec5SDimitry Andric  bits<5> Zd;
60730b57cec5SDimitry Andric  bits<5> Zm;
60740b57cec5SDimitry Andric  bits<5> Zn;
60750b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
60760b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
60770b57cec5SDimitry Andric  let Inst{21}    = 0b1;
60780b57cec5SDimitry Andric  let Inst{20-16} = Zm;
60790b57cec5SDimitry Andric  let Inst{15-12} = 0b1000;
60800b57cec5SDimitry Andric  let Inst{11-10} = opc;
60810b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
60820b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
608306c3fb27SDimitry Andric
608406c3fb27SDimitry Andric  let hasSideEffects = 0;
60850b57cec5SDimitry Andric}
60860b57cec5SDimitry Andric
6087fe6060f1SDimitry Andricmulticlass sve_int_bin_cons_shift_wide<bits<2> opc, string asm, SDPatternOperator op> {
60880b57cec5SDimitry Andric  def _B : sve_int_bin_cons_shift_wide<0b00, opc, asm, ZPR8>;
60890b57cec5SDimitry Andric  def _H : sve_int_bin_cons_shift_wide<0b01, opc, asm, ZPR16>;
60900b57cec5SDimitry Andric  def _S : sve_int_bin_cons_shift_wide<0b10, opc, asm, ZPR32>;
6091fe6060f1SDimitry Andric
6092fe6060f1SDimitry Andric  def : SVE_2_Op_Pred_All_Active<nxv16i8, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
6093fe6060f1SDimitry Andric  def : SVE_2_Op_Pred_All_Active<nxv8i16, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
6094fe6060f1SDimitry Andric  def : SVE_2_Op_Pred_All_Active<nxv4i32, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
60950b57cec5SDimitry Andric}
60960b57cec5SDimitry Andric
60970b57cec5SDimitry Andricclass sve_int_bin_cons_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
60980b57cec5SDimitry Andric                               ZPRRegOp zprty, Operand immtype>
60990b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$imm),
61000b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $imm",
61015ffd83dbSDimitry Andric  "",
61025ffd83dbSDimitry Andric  []>, Sched<[]> {
61030b57cec5SDimitry Andric  bits<5> Zd;
61040b57cec5SDimitry Andric  bits<5> Zn;
61050b57cec5SDimitry Andric  bits<6> imm;
61060b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
61070b57cec5SDimitry Andric  let Inst{23-22} = tsz8_64{3-2};
61080b57cec5SDimitry Andric  let Inst{21}    = 0b1;
61090b57cec5SDimitry Andric  let Inst{20-19} = tsz8_64{1-0};
61100b57cec5SDimitry Andric  let Inst{18-16} = imm{2-0}; // imm3
61110b57cec5SDimitry Andric  let Inst{15-12} = 0b1001;
61120b57cec5SDimitry Andric  let Inst{11-10} = opc;
61130b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
61140b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
611506c3fb27SDimitry Andric
611606c3fb27SDimitry Andric  let hasSideEffects = 0;
61170b57cec5SDimitry Andric}
61180b57cec5SDimitry Andric
61195ffd83dbSDimitry Andricmulticlass sve_int_bin_cons_shift_imm_left<bits<2> opc, string asm,
61205ffd83dbSDimitry Andric                                           SDPatternOperator op> {
61210b57cec5SDimitry Andric  def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
61220b57cec5SDimitry Andric  def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
61230b57cec5SDimitry Andric    let Inst{19} = imm{3};
61240b57cec5SDimitry Andric  }
61250b57cec5SDimitry Andric  def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
61260b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
61270b57cec5SDimitry Andric  }
61280b57cec5SDimitry Andric  def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
61290b57cec5SDimitry Andric    let Inst{22}    = imm{5};
61300b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
61310b57cec5SDimitry Andric  }
61325ffd83dbSDimitry Andric
613306c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmL8,  !cast<Instruction>(NAME # _B)>;
613406c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv8i16, op, nxv8i1,  i32, SVEShiftImmL16, !cast<Instruction>(NAME # _H)>;
613506c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv4i32, op, nxv4i1,  i32, SVEShiftImmL32, !cast<Instruction>(NAME # _S)>;
613606c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv2i64, op, nxv2i1,  i64, SVEShiftImmL64, !cast<Instruction>(NAME # _D)>;
61370b57cec5SDimitry Andric}
61380b57cec5SDimitry Andric
61395ffd83dbSDimitry Andricmulticlass sve_int_bin_cons_shift_imm_right<bits<2> opc, string asm,
61405ffd83dbSDimitry Andric                                            SDPatternOperator op> {
61410b57cec5SDimitry Andric  def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
61420b57cec5SDimitry Andric  def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
61430b57cec5SDimitry Andric    let Inst{19} = imm{3};
61440b57cec5SDimitry Andric  }
61450b57cec5SDimitry Andric  def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
61460b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
61470b57cec5SDimitry Andric  }
61480b57cec5SDimitry Andric  def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
61490b57cec5SDimitry Andric    let Inst{22}    = imm{5};
61500b57cec5SDimitry Andric    let Inst{20-19} = imm{4-3};
61510b57cec5SDimitry Andric  }
61525ffd83dbSDimitry Andric
615306c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmR8,  !cast<Instruction>(NAME # _B)>;
615406c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv8i16, op, nxv8i1,  i32, SVEShiftImmR16, !cast<Instruction>(NAME # _H)>;
615506c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv4i32, op, nxv4i1,  i32, SVEShiftImmR32, !cast<Instruction>(NAME # _S)>;
615606c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv2i64, op, nxv2i1,  i64, SVEShiftImmR64, !cast<Instruction>(NAME # _D)>;
61570b57cec5SDimitry Andric}
6158e8d8bef9SDimitry Andric
61590b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
61600b57cec5SDimitry Andric// SVE Memory - Store Group
61610b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
61620b57cec5SDimitry Andric
61630b57cec5SDimitry Andricclass sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
61640b57cec5SDimitry Andric                     RegisterOperand VecList>
61650b57cec5SDimitry Andric: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
61660b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
61670b57cec5SDimitry Andric  "",
61680b57cec5SDimitry Andric  []>, Sched<[]> {
61690b57cec5SDimitry Andric  bits<3> Pg;
61700b57cec5SDimitry Andric  bits<5> Rn;
61710b57cec5SDimitry Andric  bits<5> Zt;
61720b57cec5SDimitry Andric  bits<4> imm4;
61730b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
61740b57cec5SDimitry Andric  let Inst{24-23} = msz;
61750b57cec5SDimitry Andric  let Inst{22-21} = esz;
61760b57cec5SDimitry Andric  let Inst{20}    = 0;
61770b57cec5SDimitry Andric  let Inst{19-16} = imm4;
61780b57cec5SDimitry Andric  let Inst{15-13} = 0b111;
61790b57cec5SDimitry Andric  let Inst{12-10} = Pg;
61800b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
61810b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
61820b57cec5SDimitry Andric
618306c3fb27SDimitry Andric  let hasSideEffects = 0;
61840b57cec5SDimitry Andric  let mayStore = 1;
61850b57cec5SDimitry Andric}
61860b57cec5SDimitry Andric
61870b57cec5SDimitry Andricmulticlass sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
61880b57cec5SDimitry Andric                          RegisterOperand listty, ZPRRegOp zprty>
61890b57cec5SDimitry Andric{
61900b57cec5SDimitry Andric  def NAME : sve_mem_cst_si<msz, esz, asm, listty>;
61910b57cec5SDimitry Andric
61920b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
61930b57cec5SDimitry Andric                 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
61940b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
61950b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
61960b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
61970b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
61980b57cec5SDimitry Andric}
61990b57cec5SDimitry Andric
62000b57cec5SDimitry Andricclass sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
62010b57cec5SDimitry Andric                     string asm, Operand immtype>
62020b57cec5SDimitry Andric: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
62030b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
62040b57cec5SDimitry Andric  "",
62050b57cec5SDimitry Andric  []>, Sched<[]> {
62060b57cec5SDimitry Andric  bits<3> Pg;
62070b57cec5SDimitry Andric  bits<5> Rn;
62080b57cec5SDimitry Andric  bits<5> Zt;
62090b57cec5SDimitry Andric  bits<4> imm4;
62100b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
62110b57cec5SDimitry Andric  let Inst{24-23} = sz;
62120b57cec5SDimitry Andric  let Inst{22-21} = nregs;
62130b57cec5SDimitry Andric  let Inst{20}    = 1;
62140b57cec5SDimitry Andric  let Inst{19-16} = imm4;
62150b57cec5SDimitry Andric  let Inst{15-13} = 0b111;
62160b57cec5SDimitry Andric  let Inst{12-10} = Pg;
62170b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
62180b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
62190b57cec5SDimitry Andric
622006c3fb27SDimitry Andric  let hasSideEffects = 0;
62210b57cec5SDimitry Andric  let mayStore = 1;
62220b57cec5SDimitry Andric}
62230b57cec5SDimitry Andric
62240b57cec5SDimitry Andricmulticlass sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
62250b57cec5SDimitry Andric                          string asm, Operand immtype> {
62260b57cec5SDimitry Andric  def NAME : sve_mem_est_si<sz, nregs, VecList, asm, immtype>;
62270b57cec5SDimitry Andric
62280b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
62290b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
62300b57cec5SDimitry Andric}
62310b57cec5SDimitry Andric
6232bdd1243dSDimitry Andric
6233bdd1243dSDimitry Andric// SVE store multiple structures (quadwords, scalar plus immediate)
6234bdd1243dSDimitry Andricclass sve_mem_128b_est_si<bits<2> nregs, RegisterOperand VecList,
6235bdd1243dSDimitry Andric                          string asm, Operand immtype>
6236bdd1243dSDimitry Andric    : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
6237bdd1243dSDimitry Andric        asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
6238bdd1243dSDimitry Andric        "", []>, Sched<[]> {
6239bdd1243dSDimitry Andric  bits<5> Zt;
6240bdd1243dSDimitry Andric  bits<5> Rn;
6241bdd1243dSDimitry Andric  bits<3> Pg;
6242bdd1243dSDimitry Andric  bits<4> imm4;
6243bdd1243dSDimitry Andric  let Inst{31-24} = 0b11100100;
6244bdd1243dSDimitry Andric  let Inst{23-22} = nregs;
6245bdd1243dSDimitry Andric  let Inst{21-20} = 0b00;
6246bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
6247bdd1243dSDimitry Andric  let Inst{15-13} = 0b000;
6248bdd1243dSDimitry Andric  let Inst{12-10} = Pg;
6249bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
6250bdd1243dSDimitry Andric  let Inst{4-0}   = Zt;
6251bdd1243dSDimitry Andric
625206c3fb27SDimitry Andric  let hasSideEffects = 0;
6253bdd1243dSDimitry Andric  let mayStore = 1;
6254bdd1243dSDimitry Andric}
6255bdd1243dSDimitry Andric
6256bdd1243dSDimitry Andricmulticlass sve_mem_128b_est_si<bits<2> nregs, RegisterOperand VecList,
6257bdd1243dSDimitry Andric                               string asm, Operand immtype> {
6258bdd1243dSDimitry Andric  def NAME : sve_mem_128b_est_si<nregs, VecList, asm, immtype>;
6259bdd1243dSDimitry Andric
6260bdd1243dSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
6261bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
6262bdd1243dSDimitry Andric}
6263bdd1243dSDimitry Andric
6264bdd1243dSDimitry Andric
62650b57cec5SDimitry Andricclass sve_mem_est_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
62660b57cec5SDimitry Andric                     string asm, RegisterOperand gprty>
62670b57cec5SDimitry Andric: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
62680b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Rn, $Rm]",
62690b57cec5SDimitry Andric  "",
62700b57cec5SDimitry Andric  []>, Sched<[]> {
62710b57cec5SDimitry Andric  bits<3> Pg;
62720b57cec5SDimitry Andric  bits<5> Rm;
62730b57cec5SDimitry Andric  bits<5> Rn;
62740b57cec5SDimitry Andric  bits<5> Zt;
62750b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
62760b57cec5SDimitry Andric  let Inst{24-23} = sz;
62770b57cec5SDimitry Andric  let Inst{22-21} = nregs;
62780b57cec5SDimitry Andric  let Inst{20-16} = Rm;
62790b57cec5SDimitry Andric  let Inst{15-13} = 0b011;
62800b57cec5SDimitry Andric  let Inst{12-10} = Pg;
62810b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
62820b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
62830b57cec5SDimitry Andric
628406c3fb27SDimitry Andric  let hasSideEffects = 0;
62850b57cec5SDimitry Andric  let mayStore = 1;
62860b57cec5SDimitry Andric}
62870b57cec5SDimitry Andric
6288bdd1243dSDimitry Andric
6289bdd1243dSDimitry Andric// SVE store multiple structures (quadwords, scalar plus scalar)
6290bdd1243dSDimitry Andricclass sve_mem_128b_est_ss<bits<2> nregs, RegisterOperand VecList,
6291bdd1243dSDimitry Andric                          string asm, RegisterOperand gprty>
6292bdd1243dSDimitry Andric    : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
6293bdd1243dSDimitry Andric        asm, "\t$Zt, $Pg, [$Rn, $Rm]",
6294bdd1243dSDimitry Andric        "", []>, Sched<[]> {
6295bdd1243dSDimitry Andric  bits<5> Zt;
6296bdd1243dSDimitry Andric  bits<5> Rn;
6297bdd1243dSDimitry Andric  bits<3> Pg;
6298bdd1243dSDimitry Andric  bits<5> Rm;
6299bdd1243dSDimitry Andric  let Inst{31-24} = 0b11100100;
6300bdd1243dSDimitry Andric  let Inst{23-22} = nregs;
6301bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
6302bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
6303bdd1243dSDimitry Andric  let Inst{15-13} = 0b000;
6304bdd1243dSDimitry Andric  let Inst{12-10} = Pg;
6305bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
6306bdd1243dSDimitry Andric  let Inst{4-0}   = Zt;
6307bdd1243dSDimitry Andric
630806c3fb27SDimitry Andric  let hasSideEffects = 0;
6309bdd1243dSDimitry Andric  let mayStore = 1;
6310bdd1243dSDimitry Andric}
6311bdd1243dSDimitry Andric
6312bdd1243dSDimitry Andric
63130b57cec5SDimitry Andricclass sve_mem_cst_ss_base<bits<4> dtype, string asm,
63140b57cec5SDimitry Andric                          RegisterOperand listty, RegisterOperand gprty>
63150b57cec5SDimitry Andric: I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
63160b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Rn, $Rm]",
63170b57cec5SDimitry Andric  "",
63180b57cec5SDimitry Andric  []>, Sched<[]> {
63190b57cec5SDimitry Andric  bits<3> Pg;
63200b57cec5SDimitry Andric  bits<5> Rm;
63210b57cec5SDimitry Andric  bits<5> Rn;
63220b57cec5SDimitry Andric  bits<5> Zt;
63230b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
63240b57cec5SDimitry Andric  let Inst{24-21} = dtype;
63250b57cec5SDimitry Andric  let Inst{20-16} = Rm;
63260b57cec5SDimitry Andric  let Inst{15-13} = 0b010;
63270b57cec5SDimitry Andric  let Inst{12-10} = Pg;
63280b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
63290b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
63300b57cec5SDimitry Andric
633106c3fb27SDimitry Andric  let hasSideEffects = 0;
63320b57cec5SDimitry Andric  let mayStore = 1;
63330b57cec5SDimitry Andric}
63340b57cec5SDimitry Andric
63350b57cec5SDimitry Andricmulticlass sve_mem_cst_ss<bits<4> dtype, string asm,
63360b57cec5SDimitry Andric                          RegisterOperand listty, ZPRRegOp zprty,
63370b57cec5SDimitry Andric                          RegisterOperand gprty> {
63380b57cec5SDimitry Andric  def NAME : sve_mem_cst_ss_base<dtype, asm, listty, gprty>;
63390b57cec5SDimitry Andric
63400b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
63410b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
63420b57cec5SDimitry Andric}
63430b57cec5SDimitry Andric
63440b57cec5SDimitry Andricclass sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand VecList>
63450b57cec5SDimitry Andric: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
63460b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
63470b57cec5SDimitry Andric  "",
63480b57cec5SDimitry Andric  []>, Sched<[]> {
63490b57cec5SDimitry Andric  bits<3> Pg;
63500b57cec5SDimitry Andric  bits<5> Rn;
63510b57cec5SDimitry Andric  bits<5> Zt;
63520b57cec5SDimitry Andric  bits<4> imm4;
63530b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
63540b57cec5SDimitry Andric  let Inst{24-23} = msz;
63550b57cec5SDimitry Andric  let Inst{22-20} = 0b001;
63560b57cec5SDimitry Andric  let Inst{19-16} = imm4;
63570b57cec5SDimitry Andric  let Inst{15-13} = 0b111;
63580b57cec5SDimitry Andric  let Inst{12-10} = Pg;
63590b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
63600b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
63610b57cec5SDimitry Andric
636206c3fb27SDimitry Andric  let hasSideEffects = 0;
63630b57cec5SDimitry Andric  let mayStore = 1;
63640b57cec5SDimitry Andric}
63650b57cec5SDimitry Andric
63660b57cec5SDimitry Andricmulticlass sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand listty,
63670b57cec5SDimitry Andric                            ZPRRegOp zprty> {
63680b57cec5SDimitry Andric  def NAME : sve_mem_cstnt_si<msz, asm, listty>;
63690b57cec5SDimitry Andric
63700b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
63710b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
63720b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
63730b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
63740b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
63750b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
63760b57cec5SDimitry Andric}
63770b57cec5SDimitry Andric
63780b57cec5SDimitry Andricclass sve_mem_cstnt_ss_base<bits<2> msz, string asm, RegisterOperand listty,
63790b57cec5SDimitry Andric                            RegisterOperand gprty>
63800b57cec5SDimitry Andric: I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
63810b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Rn, $Rm]",
63820b57cec5SDimitry Andric  "",
63830b57cec5SDimitry Andric  []>, Sched<[]> {
63840b57cec5SDimitry Andric  bits<3> Pg;
63850b57cec5SDimitry Andric  bits<5> Rm;
63860b57cec5SDimitry Andric  bits<5> Rn;
63870b57cec5SDimitry Andric  bits<5> Zt;
63880b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
63890b57cec5SDimitry Andric  let Inst{24-23} = msz;
63900b57cec5SDimitry Andric  let Inst{22-21} = 0b00;
63910b57cec5SDimitry Andric  let Inst{20-16} = Rm;
63920b57cec5SDimitry Andric  let Inst{15-13} = 0b011;
63930b57cec5SDimitry Andric  let Inst{12-10} = Pg;
63940b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
63950b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
63960b57cec5SDimitry Andric
639706c3fb27SDimitry Andric  let hasSideEffects = 0;
63980b57cec5SDimitry Andric  let mayStore = 1;
63990b57cec5SDimitry Andric}
64000b57cec5SDimitry Andric
64010b57cec5SDimitry Andricmulticlass sve_mem_cstnt_ss<bits<2> msz, string asm, RegisterOperand listty,
64020b57cec5SDimitry Andric                            ZPRRegOp zprty, RegisterOperand gprty> {
64030b57cec5SDimitry Andric  def NAME : sve_mem_cstnt_ss_base<msz, asm, listty, gprty>;
64040b57cec5SDimitry Andric
64050b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
64060b57cec5SDimitry Andric                 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
64070b57cec5SDimitry Andric}
64080b57cec5SDimitry Andric
64090b57cec5SDimitry Andricclass sve2_mem_sstnt_vs_base<bits<3> opc, string asm,
64100b57cec5SDimitry Andric                             RegisterOperand listty, ZPRRegOp zprty>
64110b57cec5SDimitry Andric: I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm),
64120b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Zn, $Rm]",
64130b57cec5SDimitry Andric  "",
64140b57cec5SDimitry Andric  []>, Sched<[]> {
64150b57cec5SDimitry Andric  bits<3> Pg;
64160b57cec5SDimitry Andric  bits<5> Rm;
64170b57cec5SDimitry Andric  bits<5> Zn;
64180b57cec5SDimitry Andric  bits<5> Zt;
64190b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
64200b57cec5SDimitry Andric  let Inst{24-22} = opc;
64210b57cec5SDimitry Andric  let Inst{21}    = 0b0;
64220b57cec5SDimitry Andric  let Inst{20-16} = Rm;
64230b57cec5SDimitry Andric  let Inst{15-13} = 0b001;
64240b57cec5SDimitry Andric  let Inst{12-10} = Pg;
64250b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
64260b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
64270b57cec5SDimitry Andric
642806c3fb27SDimitry Andric  let hasSideEffects = 0;
64290b57cec5SDimitry Andric  let mayStore = 1;
64300b57cec5SDimitry Andric}
64310b57cec5SDimitry Andric
64325ffd83dbSDimitry Andricmulticlass sve2_mem_sstnt_vs_32_ptrs<bits<3> opc, string asm,
64335ffd83dbSDimitry Andric                             SDPatternOperator op,
64345ffd83dbSDimitry Andric                             ValueType vt> {
6435*0fca6ea1SDimitry Andric  def NAME : sve2_mem_sstnt_vs_base<opc, asm, Z_s, ZPR32>;
64360b57cec5SDimitry Andric
64370b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]",
6438*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 0>;
64390b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6440*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 0>;
64410b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6442*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 1>;
64435ffd83dbSDimitry Andric
64445ffd83dbSDimitry Andric  def : Pat <(op (nxv4i32 ZPR32:$Zt), (nxv4i1 PPR3bAny:$Pg), (nxv4i32 ZPR32:$Zn), (i64 GPR64:$Rm), vt),
6445*0fca6ea1SDimitry Andric             (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm)>;
64465ffd83dbSDimitry Andric}
64475ffd83dbSDimitry Andric
64485ffd83dbSDimitry Andricmulticlass sve2_mem_sstnt_vs_64_ptrs<bits<3> opc, string asm,
64495ffd83dbSDimitry Andric                             SDPatternOperator op,
64505ffd83dbSDimitry Andric                             ValueType vt> {
6451*0fca6ea1SDimitry Andric  def NAME : sve2_mem_sstnt_vs_base<opc, asm, Z_d, ZPR64>;
64525ffd83dbSDimitry Andric
64535ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]",
6454*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 0>;
64555ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6456*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 0>;
64575ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6458*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
64595ffd83dbSDimitry Andric
64605ffd83dbSDimitry Andric  def : Pat <(op (nxv2i64 ZPR64:$Zt), (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64:$Rm), vt),
6461*0fca6ea1SDimitry Andric             (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
64620b57cec5SDimitry Andric}
64630b57cec5SDimitry Andric
64640b57cec5SDimitry Andricclass sve_mem_sst_sv<bits<3> opc, bit xs, bit scaled, string asm,
64650b57cec5SDimitry Andric                     RegisterOperand VecList, RegisterOperand zprext>
64660b57cec5SDimitry Andric: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
64670b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Rn, $Zm]",
64680b57cec5SDimitry Andric  "",
64690b57cec5SDimitry Andric  []>, Sched<[]> {
64700b57cec5SDimitry Andric  bits<3> Pg;
64710b57cec5SDimitry Andric  bits<5> Rn;
64720b57cec5SDimitry Andric  bits<5> Zm;
64730b57cec5SDimitry Andric  bits<5> Zt;
64740b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
64750b57cec5SDimitry Andric  let Inst{24-22} = opc;
64760b57cec5SDimitry Andric  let Inst{21}    = scaled;
64770b57cec5SDimitry Andric  let Inst{20-16} = Zm;
64780b57cec5SDimitry Andric  let Inst{15}    = 0b1;
64790b57cec5SDimitry Andric  let Inst{14}    = xs;
64800b57cec5SDimitry Andric  let Inst{13}    = 0;
64810b57cec5SDimitry Andric  let Inst{12-10} = Pg;
64820b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
64830b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
64840b57cec5SDimitry Andric
648506c3fb27SDimitry Andric  let hasSideEffects = 0;
64860b57cec5SDimitry Andric  let mayStore = 1;
64870b57cec5SDimitry Andric}
64880b57cec5SDimitry Andric
6489480093f4SDimitry Andricmulticlass sve_mem_32b_sst_sv_32_scaled<bits<3> opc, string asm,
6490480093f4SDimitry Andric                                    SDPatternOperator sxtw_op,
6491480093f4SDimitry Andric                                    SDPatternOperator uxtw_op,
64920b57cec5SDimitry Andric                                    RegisterOperand sxtw_opnd,
6493480093f4SDimitry Andric                                    RegisterOperand uxtw_opnd,
6494480093f4SDimitry Andric                                    ValueType vt > {
6495480093f4SDimitry Andric  def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, Z_s, uxtw_opnd>;
6496480093f4SDimitry Andric  def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, Z_s, sxtw_opnd>;
64970b57cec5SDimitry Andric
64980b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6499480093f4SDimitry Andric                 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
65000b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6501480093f4SDimitry Andric                 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
6502480093f4SDimitry Andric
6503480093f4SDimitry Andric  def : Pat<(uxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
6504480093f4SDimitry Andric            (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6505480093f4SDimitry Andric  def : Pat<(sxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
6506480093f4SDimitry Andric            (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
65070b57cec5SDimitry Andric}
65080b57cec5SDimitry Andric
6509480093f4SDimitry Andricmulticlass sve_mem_64b_sst_sv_32_scaled<bits<3> opc, string asm,
6510480093f4SDimitry Andric                                    SDPatternOperator sxtw_op,
6511480093f4SDimitry Andric                                    SDPatternOperator uxtw_op,
65120b57cec5SDimitry Andric                                    RegisterOperand sxtw_opnd,
6513480093f4SDimitry Andric                                    RegisterOperand uxtw_opnd,
6514480093f4SDimitry Andric                                    ValueType vt > {
6515480093f4SDimitry Andric  def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, Z_d, uxtw_opnd>;
6516480093f4SDimitry Andric  def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, Z_d, sxtw_opnd>;
65170b57cec5SDimitry Andric
65180b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6519480093f4SDimitry Andric                 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
65200b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6521480093f4SDimitry Andric                 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
6522480093f4SDimitry Andric
6523480093f4SDimitry Andric  def : Pat<(uxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
6524480093f4SDimitry Andric            (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6525480093f4SDimitry Andric  def : Pat<(sxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
6526480093f4SDimitry Andric            (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6527480093f4SDimitry Andric}
6528480093f4SDimitry Andric
6529480093f4SDimitry Andricmulticlass sve_mem_64b_sst_sv_32_unscaled<bits<3> opc, string asm,
6530480093f4SDimitry Andric                                         SDPatternOperator sxtw_op,
6531480093f4SDimitry Andric                                         SDPatternOperator uxtw_op,
6532480093f4SDimitry Andric                                         RegisterOperand sxtw_opnd,
6533480093f4SDimitry Andric                                         RegisterOperand uxtw_opnd,
6534480093f4SDimitry Andric                                         ValueType vt> {
6535480093f4SDimitry Andric  def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, Z_d, uxtw_opnd>;
6536480093f4SDimitry Andric  def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, Z_d, sxtw_opnd>;
6537480093f4SDimitry Andric
6538480093f4SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6539480093f4SDimitry Andric                 (!cast<Instruction>(NAME # _UXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
6540480093f4SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6541480093f4SDimitry Andric                 (!cast<Instruction>(NAME # _SXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
6542480093f4SDimitry Andric
6543480093f4SDimitry Andric  def : Pat<(uxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
6544480093f4SDimitry Andric            (!cast<Instruction>(NAME # _UXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6545480093f4SDimitry Andric  def : Pat<(sxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
6546480093f4SDimitry Andric            (!cast<Instruction>(NAME # _SXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6547480093f4SDimitry Andric}
6548480093f4SDimitry Andric
6549480093f4SDimitry Andricmulticlass sve_mem_32b_sst_sv_32_unscaled<bits<3> opc, string asm,
6550480093f4SDimitry Andric                                          SDPatternOperator sxtw_op,
6551480093f4SDimitry Andric                                          SDPatternOperator uxtw_op,
6552480093f4SDimitry Andric                                          RegisterOperand sxtw_opnd,
6553480093f4SDimitry Andric                                          RegisterOperand uxtw_opnd,
6554480093f4SDimitry Andric                                          ValueType vt> {
6555480093f4SDimitry Andric  def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, Z_s, uxtw_opnd>;
6556480093f4SDimitry Andric  def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, Z_s, sxtw_opnd>;
6557480093f4SDimitry Andric
6558480093f4SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6559480093f4SDimitry Andric                 (!cast<Instruction>(NAME # _UXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
6560480093f4SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6561480093f4SDimitry Andric                 (!cast<Instruction>(NAME # _SXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
6562480093f4SDimitry Andric
6563480093f4SDimitry Andric  def : Pat<(uxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
6564480093f4SDimitry Andric            (!cast<Instruction>(NAME # _UXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6565480093f4SDimitry Andric  def : Pat<(sxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
6566480093f4SDimitry Andric            (!cast<Instruction>(NAME # _SXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
65670b57cec5SDimitry Andric}
65680b57cec5SDimitry Andric
65690b57cec5SDimitry Andricclass sve_mem_sst_sv2<bits<2> msz, bit scaled, string asm,
65700b57cec5SDimitry Andric                      RegisterOperand zprext>
65710b57cec5SDimitry Andric: I<(outs), (ins Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
65720b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Rn, $Zm]",
65730b57cec5SDimitry Andric  "",
65740b57cec5SDimitry Andric  []>, Sched<[]> {
65750b57cec5SDimitry Andric  bits<3> Pg;
65760b57cec5SDimitry Andric  bits<5> Rn;
65770b57cec5SDimitry Andric  bits<5> Zm;
65780b57cec5SDimitry Andric  bits<5> Zt;
65790b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
65800b57cec5SDimitry Andric  let Inst{24-23} = msz;
65810b57cec5SDimitry Andric  let Inst{22}    = 0b0;
65820b57cec5SDimitry Andric  let Inst{21}    = scaled;
65830b57cec5SDimitry Andric  let Inst{20-16} = Zm;
65840b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
65850b57cec5SDimitry Andric  let Inst{12-10} = Pg;
65860b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
65870b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
65880b57cec5SDimitry Andric
658906c3fb27SDimitry Andric  let hasSideEffects = 0;
65900b57cec5SDimitry Andric  let mayStore = 1;
65910b57cec5SDimitry Andric}
65920b57cec5SDimitry Andric
65930b57cec5SDimitry Andricmulticlass sve_mem_sst_sv_64_scaled<bits<2> msz, string asm,
6594480093f4SDimitry Andric                                    SDPatternOperator op,
6595480093f4SDimitry Andric                                    RegisterOperand zprext,
6596480093f4SDimitry Andric                                    ValueType vt> {
659781ad6265SDimitry Andric  def _SCALED : sve_mem_sst_sv2<msz, 1, asm, zprext>;
65980b57cec5SDimitry Andric
65990b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
660081ad6265SDimitry Andric                 (!cast<Instruction>(NAME # _SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
66010b57cec5SDimitry Andric
6602480093f4SDimitry Andric  def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt),
660381ad6265SDimitry Andric            (!cast<Instruction>(NAME # _SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
66040b57cec5SDimitry Andric}
66050b57cec5SDimitry Andric
6606480093f4SDimitry Andricmulticlass sve_mem_sst_sv_64_unscaled<bits<2> msz, string asm,
6607480093f4SDimitry Andric                                      SDPatternOperator op,
6608480093f4SDimitry Andric                                      ValueType vt> {
660981ad6265SDimitry Andric  def NAME : sve_mem_sst_sv2<msz, 0, asm, ZPR64ExtLSL8>;
66100b57cec5SDimitry Andric
66110b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
661281ad6265SDimitry Andric                 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
6613480093f4SDimitry Andric
6614480093f4SDimitry Andric  def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
661581ad6265SDimitry Andric            (!cast<Instruction>(NAME) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
66160b57cec5SDimitry Andric}
66170b57cec5SDimitry Andric
66180b57cec5SDimitry Andricclass sve_mem_sst_vi<bits<3> opc, string asm, ZPRRegOp zprty,
66190b57cec5SDimitry Andric                     RegisterOperand VecList, Operand imm_ty>
66200b57cec5SDimitry Andric: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, zprty:$Zn, imm_ty:$imm5),
66210b57cec5SDimitry Andric  asm, "\t$Zt, $Pg, [$Zn, $imm5]",
66220b57cec5SDimitry Andric  "",
66230b57cec5SDimitry Andric  []>, Sched<[]> {
66240b57cec5SDimitry Andric  bits<3> Pg;
66250b57cec5SDimitry Andric  bits<5> imm5;
66260b57cec5SDimitry Andric  bits<5> Zn;
66270b57cec5SDimitry Andric  bits<5> Zt;
66280b57cec5SDimitry Andric  let Inst{31-25} = 0b1110010;
66290b57cec5SDimitry Andric  let Inst{24-23} = opc{2-1};
66300b57cec5SDimitry Andric  let Inst{22}    = 0b1;
66310b57cec5SDimitry Andric  let Inst{21}    = opc{0};
66320b57cec5SDimitry Andric  let Inst{20-16} = imm5;
66330b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
66340b57cec5SDimitry Andric  let Inst{12-10} = Pg;
66350b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
66360b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
66370b57cec5SDimitry Andric
663806c3fb27SDimitry Andric  let hasSideEffects = 0;
66390b57cec5SDimitry Andric  let mayStore = 1;
66400b57cec5SDimitry Andric}
66410b57cec5SDimitry Andric
6642480093f4SDimitry Andricmulticlass sve_mem_32b_sst_vi_ptrs<bits<3> opc, string asm,
6643480093f4SDimitry Andric                                   Operand imm_ty,
6644480093f4SDimitry Andric                                   SDPatternOperator op,
6645480093f4SDimitry Andric                                   ValueType vt> {
6646480093f4SDimitry Andric  def _IMM : sve_mem_sst_vi<opc, asm, ZPR32, Z_s, imm_ty>;
66470b57cec5SDimitry Andric
66480b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6649480093f4SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>;
66500b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]",
6651480093f4SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>;
66520b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6653480093f4SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
6654480093f4SDimitry Andric
6655480093f4SDimitry Andric  def : Pat<(op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), (nxv4i32 ZPR:$ptrs), imm_ty:$index, vt),
6656480093f4SDimitry Andric            (!cast<Instruction>(NAME # _IMM) ZPR:$data, PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
6657480093f4SDimitry Andric}
6658480093f4SDimitry Andric
6659480093f4SDimitry Andricmulticlass sve_mem_64b_sst_vi_ptrs<bits<3> opc, string asm,
6660480093f4SDimitry Andric                                   Operand imm_ty,
6661480093f4SDimitry Andric                                   SDPatternOperator op,
6662480093f4SDimitry Andric                                   ValueType vt> {
6663480093f4SDimitry Andric  def _IMM : sve_mem_sst_vi<opc, asm, ZPR64, Z_d, imm_ty>;
6664480093f4SDimitry Andric
6665480093f4SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6666480093f4SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>;
6667480093f4SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]",
6668480093f4SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>;
6669480093f4SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
667016d6b3b3SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
6671480093f4SDimitry Andric
6672480093f4SDimitry Andric  def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), (nxv2i64 ZPR:$ptrs), imm_ty:$index, vt),
6673480093f4SDimitry Andric            (!cast<Instruction>(NAME # _IMM) ZPR:$data, PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
66740b57cec5SDimitry Andric}
66750b57cec5SDimitry Andric
66760b57cec5SDimitry Andricclass sve_mem_z_spill<string asm>
66770b57cec5SDimitry Andric: I<(outs), (ins ZPRAny:$Zt, GPR64sp:$Rn, simm9:$imm9),
66780b57cec5SDimitry Andric  asm, "\t$Zt, [$Rn, $imm9, mul vl]",
66790b57cec5SDimitry Andric  "",
66800b57cec5SDimitry Andric  []>, Sched<[]> {
66810b57cec5SDimitry Andric  bits<5> Rn;
66820b57cec5SDimitry Andric  bits<5> Zt;
66830b57cec5SDimitry Andric  bits<9> imm9;
66840b57cec5SDimitry Andric  let Inst{31-22} = 0b1110010110;
66850b57cec5SDimitry Andric  let Inst{21-16} = imm9{8-3};
66860b57cec5SDimitry Andric  let Inst{15-13} = 0b010;
66870b57cec5SDimitry Andric  let Inst{12-10} = imm9{2-0};
66880b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
66890b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
66900b57cec5SDimitry Andric
669106c3fb27SDimitry Andric  let hasSideEffects = 0;
66920b57cec5SDimitry Andric  let mayStore = 1;
66930b57cec5SDimitry Andric}
66940b57cec5SDimitry Andric
66950b57cec5SDimitry Andricmulticlass sve_mem_z_spill<string asm> {
66960b57cec5SDimitry Andric  def NAME : sve_mem_z_spill<asm>;
66970b57cec5SDimitry Andric
66980b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, [$Rn]",
66990b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
67000b57cec5SDimitry Andric}
67010b57cec5SDimitry Andric
67020b57cec5SDimitry Andricclass sve_mem_p_spill<string asm>
6703*0fca6ea1SDimitry Andric: I<(outs), (ins PPRorPNRAny:$Pt, GPR64sp:$Rn, simm9:$imm9),
67040b57cec5SDimitry Andric  asm, "\t$Pt, [$Rn, $imm9, mul vl]",
67050b57cec5SDimitry Andric  "",
67060b57cec5SDimitry Andric  []>, Sched<[]> {
67070b57cec5SDimitry Andric  bits<4> Pt;
67080b57cec5SDimitry Andric  bits<5> Rn;
67090b57cec5SDimitry Andric  bits<9> imm9;
67100b57cec5SDimitry Andric  let Inst{31-22} = 0b1110010110;
67110b57cec5SDimitry Andric  let Inst{21-16} = imm9{8-3};
67120b57cec5SDimitry Andric  let Inst{15-13} = 0b000;
67130b57cec5SDimitry Andric  let Inst{12-10} = imm9{2-0};
67140b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
67150b57cec5SDimitry Andric  let Inst{4}     = 0b0;
67160b57cec5SDimitry Andric  let Inst{3-0}   = Pt;
67170b57cec5SDimitry Andric
671806c3fb27SDimitry Andric  let hasSideEffects = 0;
67190b57cec5SDimitry Andric  let mayStore = 1;
67200b57cec5SDimitry Andric}
67210b57cec5SDimitry Andric
67220b57cec5SDimitry Andricmulticlass sve_mem_p_spill<string asm> {
67230b57cec5SDimitry Andric  def NAME : sve_mem_p_spill<asm>;
67240b57cec5SDimitry Andric
67250b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Pt, [$Rn]",
6726*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME) PPRorPNRAny:$Pt, GPR64sp:$Rn, 0), 1>;
67270b57cec5SDimitry Andric}
67280b57cec5SDimitry Andric
67290b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
67300b57cec5SDimitry Andric// SVE Permute - Predicates Group
67310b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
67320b57cec5SDimitry Andric
67330b57cec5SDimitry Andricclass sve_int_perm_bin_perm_pp<bits<3> opc, bits<2> sz8_64, string asm,
67341ac55f4cSDimitry Andric                               PPRRegOp pprty, SDPatternOperator op>
67350b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins pprty:$Pn, pprty:$Pm),
67360b57cec5SDimitry Andric  asm, "\t$Pd, $Pn, $Pm",
67371ac55f4cSDimitry Andric  "",
67381ac55f4cSDimitry Andric  [(set nxv16i1:$Pd, (op nxv16i1:$Pn, nxv16i1:$Pm))]>, Sched<[]> {
67390b57cec5SDimitry Andric  bits<4> Pd;
67400b57cec5SDimitry Andric  bits<4> Pm;
67410b57cec5SDimitry Andric  bits<4> Pn;
67420b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
67430b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
67440b57cec5SDimitry Andric  let Inst{21-20} = 0b10;
67450b57cec5SDimitry Andric  let Inst{19-16} = Pm;
67460b57cec5SDimitry Andric  let Inst{15-13} = 0b010;
67470b57cec5SDimitry Andric  let Inst{12-10} = opc;
67480b57cec5SDimitry Andric  let Inst{9}     = 0b0;
67490b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
67500b57cec5SDimitry Andric  let Inst{4}     = 0b0;
67510b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
675206c3fb27SDimitry Andric
675306c3fb27SDimitry Andric  let hasSideEffects = 0;
67540b57cec5SDimitry Andric}
67550b57cec5SDimitry Andric
6756480093f4SDimitry Andricmulticlass sve_int_perm_bin_perm_pp<bits<3> opc, string asm,
67571ac55f4cSDimitry Andric                                    SDPatternOperator ir_op,
67581ac55f4cSDimitry Andric                                    SDPatternOperator op_b16,
67591ac55f4cSDimitry Andric                                    SDPatternOperator op_b32,
67601ac55f4cSDimitry Andric                                    SDPatternOperator op_b64> {
67611ac55f4cSDimitry Andric  def _B : sve_int_perm_bin_perm_pp<opc, 0b00, asm, PPR8,  ir_op>;
67621ac55f4cSDimitry Andric  def _H : sve_int_perm_bin_perm_pp<opc, 0b01, asm, PPR16, op_b16>;
67631ac55f4cSDimitry Andric  def _S : sve_int_perm_bin_perm_pp<opc, 0b10, asm, PPR32, op_b32>;
67641ac55f4cSDimitry Andric  def _D : sve_int_perm_bin_perm_pp<opc, 0b11, asm, PPR64, op_b64>;
6765480093f4SDimitry Andric
67661ac55f4cSDimitry Andric  def : SVE_2_Op_Pat<nxv8i1, ir_op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>;
67671ac55f4cSDimitry Andric  def : SVE_2_Op_Pat<nxv4i1, ir_op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>;
67681ac55f4cSDimitry Andric  def : SVE_2_Op_Pat<nxv2i1, ir_op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>;
67690b57cec5SDimitry Andric}
67700b57cec5SDimitry Andric
67710b57cec5SDimitry Andricclass sve_int_perm_punpk<bit opc, string asm>
67720b57cec5SDimitry Andric: I<(outs PPR16:$Pd), (ins PPR8:$Pn),
67730b57cec5SDimitry Andric  asm, "\t$Pd, $Pn",
67740b57cec5SDimitry Andric  "",
67750b57cec5SDimitry Andric  []>, Sched<[]> {
67760b57cec5SDimitry Andric  bits<4> Pd;
67770b57cec5SDimitry Andric  bits<4> Pn;
67780b57cec5SDimitry Andric  let Inst{31-17} = 0b000001010011000;
67790b57cec5SDimitry Andric  let Inst{16}    = opc;
67800b57cec5SDimitry Andric  let Inst{15-9}  = 0b0100000;
67810b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
67820b57cec5SDimitry Andric  let Inst{4}     = 0b0;
67830b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
678406c3fb27SDimitry Andric
678506c3fb27SDimitry Andric  let hasSideEffects = 0;
67860b57cec5SDimitry Andric}
67870b57cec5SDimitry Andric
67888bcb0991SDimitry Andricmulticlass sve_int_perm_punpk<bit opc, string asm, SDPatternOperator op> {
67898bcb0991SDimitry Andric  def NAME : sve_int_perm_punpk<opc, asm>;
67908bcb0991SDimitry Andric
67918bcb0991SDimitry Andric  def : SVE_1_Op_Pat<nxv8i1, op, nxv16i1, !cast<Instruction>(NAME)>;
67928bcb0991SDimitry Andric  def : SVE_1_Op_Pat<nxv4i1, op, nxv8i1,  !cast<Instruction>(NAME)>;
67938bcb0991SDimitry Andric  def : SVE_1_Op_Pat<nxv2i1, op, nxv4i1,  !cast<Instruction>(NAME)>;
67948bcb0991SDimitry Andric}
67958bcb0991SDimitry Andric
6796*0fca6ea1SDimitry Andricclass sve_int_rdffr_pred<bit s, string asm, SDPatternOperator op = null_frag>
67970b57cec5SDimitry Andric: I<(outs PPR8:$Pd), (ins PPRAny:$Pg),
67980b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z",
67990b57cec5SDimitry Andric  "",
6800*0fca6ea1SDimitry Andric  [(set (nxv16i1 PPR8:$Pd), (op (nxv16i1 PPRAny:$Pg)))]>, Sched<[]> {
68010b57cec5SDimitry Andric  bits<4> Pd;
68020b57cec5SDimitry Andric  bits<4> Pg;
68030b57cec5SDimitry Andric  let Inst{31-23} = 0b001001010;
68040b57cec5SDimitry Andric  let Inst{22}    = s;
68050b57cec5SDimitry Andric  let Inst{21-9}  = 0b0110001111000;
68060b57cec5SDimitry Andric  let Inst{8-5}   = Pg;
68070b57cec5SDimitry Andric  let Inst{4}     = 0;
68080b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
68090b57cec5SDimitry Andric
6810e8d8bef9SDimitry Andric  let Defs = !if(s, [NZCV], []);
68110b57cec5SDimitry Andric  let Uses = [FFR];
681206c3fb27SDimitry Andric  let hasSideEffects = 1;
68130b57cec5SDimitry Andric}
68140b57cec5SDimitry Andric
6815*0fca6ea1SDimitry Andricclass sve_int_rdffr_unpred<string asm, SDPatternOperator op> : I<
68160b57cec5SDimitry Andric  (outs PPR8:$Pd), (ins),
68170b57cec5SDimitry Andric  asm, "\t$Pd",
68180b57cec5SDimitry Andric  "",
6819*0fca6ea1SDimitry Andric  [(set (nxv16i1 PPR8:$Pd), (op))]>, Sched<[]> {
68200b57cec5SDimitry Andric  bits<4> Pd;
68210b57cec5SDimitry Andric  let Inst{31-4} = 0b0010010100011001111100000000;
68220b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
68230b57cec5SDimitry Andric
68240b57cec5SDimitry Andric  let Uses = [FFR];
682506c3fb27SDimitry Andric  let hasSideEffects = 1;
68260b57cec5SDimitry Andric}
68270b57cec5SDimitry Andric
68285ffd83dbSDimitry Andricclass sve_int_wrffr<string asm, SDPatternOperator op>
68290b57cec5SDimitry Andric: I<(outs), (ins PPR8:$Pn),
68300b57cec5SDimitry Andric  asm, "\t$Pn",
68310b57cec5SDimitry Andric  "",
68325ffd83dbSDimitry Andric  [(op (nxv16i1 PPR8:$Pn))]>, Sched<[]> {
68330b57cec5SDimitry Andric  bits<4> Pn;
68340b57cec5SDimitry Andric  let Inst{31-9} = 0b00100101001010001001000;
68350b57cec5SDimitry Andric  let Inst{8-5}  = Pn;
68360b57cec5SDimitry Andric  let Inst{4-0}  = 0b00000;
68370b57cec5SDimitry Andric
68380b57cec5SDimitry Andric  let Defs = [FFR];
683906c3fb27SDimitry Andric  let hasSideEffects = 1;
68400b57cec5SDimitry Andric}
68410b57cec5SDimitry Andric
68425ffd83dbSDimitry Andricclass sve_int_setffr<string asm, SDPatternOperator op>
68430b57cec5SDimitry Andric: I<(outs), (ins),
68440b57cec5SDimitry Andric  asm, "",
68450b57cec5SDimitry Andric  "",
68465ffd83dbSDimitry Andric  [(op)]>, Sched<[]> {
68470b57cec5SDimitry Andric  let Inst{31-0} = 0b00100101001011001001000000000000;
68480b57cec5SDimitry Andric
68490b57cec5SDimitry Andric  let Defs = [FFR];
685006c3fb27SDimitry Andric  let hasSideEffects = 1;
68510b57cec5SDimitry Andric}
68520b57cec5SDimitry Andric
68530b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
68540b57cec5SDimitry Andric// SVE Permute Vector - Predicated Group
68550b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
68560b57cec5SDimitry Andric
68570b57cec5SDimitry Andricclass sve_int_perm_clast_rz<bits<2> sz8_64, bit ab, string asm,
68580b57cec5SDimitry Andric                            ZPRRegOp zprty, RegisterClass rt>
68590b57cec5SDimitry Andric: I<(outs rt:$Rdn), (ins PPR3bAny:$Pg, rt:$_Rdn, zprty:$Zm),
68600b57cec5SDimitry Andric  asm, "\t$Rdn, $Pg, $_Rdn, $Zm",
68610b57cec5SDimitry Andric  "",
68620b57cec5SDimitry Andric  []>, Sched<[]> {
68630b57cec5SDimitry Andric  bits<3> Pg;
68640b57cec5SDimitry Andric  bits<5> Rdn;
68650b57cec5SDimitry Andric  bits<5> Zm;
68660b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
68670b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
68680b57cec5SDimitry Andric  let Inst{21-17} = 0b11000;
68690b57cec5SDimitry Andric  let Inst{16}    = ab;
68700b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
68710b57cec5SDimitry Andric  let Inst{12-10} = Pg;
68720b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
68730b57cec5SDimitry Andric  let Inst{4-0}   = Rdn;
68740b57cec5SDimitry Andric
68750b57cec5SDimitry Andric  let Constraints = "$Rdn = $_Rdn";
687606c3fb27SDimitry Andric  let hasSideEffects = 0;
68770b57cec5SDimitry Andric}
68780b57cec5SDimitry Andric
6879480093f4SDimitry Andricmulticlass sve_int_perm_clast_rz<bit ab, string asm, SDPatternOperator op> {
68800b57cec5SDimitry Andric  def _B : sve_int_perm_clast_rz<0b00, ab, asm, ZPR8, GPR32>;
68810b57cec5SDimitry Andric  def _H : sve_int_perm_clast_rz<0b01, ab, asm, ZPR16, GPR32>;
68820b57cec5SDimitry Andric  def _S : sve_int_perm_clast_rz<0b10, ab, asm, ZPR32, GPR32>;
68830b57cec5SDimitry Andric  def _D : sve_int_perm_clast_rz<0b11, ab, asm, ZPR64, GPR64>;
6884480093f4SDimitry Andric
6885480093f4SDimitry Andric  def : SVE_3_Op_Pat<i32, op, nxv16i1, i32, nxv16i8, !cast<Instruction>(NAME # _B)>;
6886480093f4SDimitry Andric  def : SVE_3_Op_Pat<i32, op, nxv8i1,  i32, nxv8i16, !cast<Instruction>(NAME # _H)>;
6887480093f4SDimitry Andric  def : SVE_3_Op_Pat<i32, op, nxv4i1,  i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
6888480093f4SDimitry Andric  def : SVE_3_Op_Pat<i64, op, nxv2i1,  i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
68890b57cec5SDimitry Andric}
68900b57cec5SDimitry Andric
68910b57cec5SDimitry Andricclass sve_int_perm_clast_vz<bits<2> sz8_64, bit ab, string asm,
68920b57cec5SDimitry Andric                            ZPRRegOp zprty, RegisterClass rt>
68930b57cec5SDimitry Andric: I<(outs rt:$Vdn), (ins PPR3bAny:$Pg, rt:$_Vdn, zprty:$Zm),
68940b57cec5SDimitry Andric  asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
68950b57cec5SDimitry Andric  "",
68960b57cec5SDimitry Andric  []>, Sched<[]> {
68970b57cec5SDimitry Andric  bits<3> Pg;
68980b57cec5SDimitry Andric  bits<5> Vdn;
68990b57cec5SDimitry Andric  bits<5> Zm;
69000b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
69010b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
69020b57cec5SDimitry Andric  let Inst{21-17} = 0b10101;
69030b57cec5SDimitry Andric  let Inst{16}    = ab;
69040b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
69050b57cec5SDimitry Andric  let Inst{12-10} = Pg;
69060b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
69070b57cec5SDimitry Andric  let Inst{4-0}   = Vdn;
69080b57cec5SDimitry Andric
69090b57cec5SDimitry Andric  let Constraints = "$Vdn = $_Vdn";
691006c3fb27SDimitry Andric  let hasSideEffects = 0;
69110b57cec5SDimitry Andric}
69120b57cec5SDimitry Andric
6913480093f4SDimitry Andricmulticlass sve_int_perm_clast_vz<bit ab, string asm, SDPatternOperator op> {
69140b57cec5SDimitry Andric  def _B : sve_int_perm_clast_vz<0b00, ab, asm, ZPR8, FPR8>;
69150b57cec5SDimitry Andric  def _H : sve_int_perm_clast_vz<0b01, ab, asm, ZPR16, FPR16>;
69160b57cec5SDimitry Andric  def _S : sve_int_perm_clast_vz<0b10, ab, asm, ZPR32, FPR32>;
69170b57cec5SDimitry Andric  def _D : sve_int_perm_clast_vz<0b11, ab, asm, ZPR64, FPR64>;
6918480093f4SDimitry Andric
6919480093f4SDimitry Andric  def : SVE_3_Op_Pat<f16, op, nxv8i1, f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
6920480093f4SDimitry Andric  def : SVE_3_Op_Pat<f32, op, nxv4i1, f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
6921480093f4SDimitry Andric  def : SVE_3_Op_Pat<f64, op, nxv2i1, f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
6922e8d8bef9SDimitry Andric
6923e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<bf16, op, nxv8i1, bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
69240b57cec5SDimitry Andric}
69250b57cec5SDimitry Andric
69260b57cec5SDimitry Andricclass sve_int_perm_clast_zz<bits<2> sz8_64, bit ab, string asm,
69270b57cec5SDimitry Andric                            ZPRRegOp zprty>
69280b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
69290b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
69300b57cec5SDimitry Andric  "",
69310b57cec5SDimitry Andric  []>, Sched<[]> {
69320b57cec5SDimitry Andric  bits<3> Pg;
69330b57cec5SDimitry Andric  bits<5> Zdn;
69340b57cec5SDimitry Andric  bits<5> Zm;
69350b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
69360b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
69370b57cec5SDimitry Andric  let Inst{21-17} = 0b10100;
69380b57cec5SDimitry Andric  let Inst{16}    = ab;
69390b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
69400b57cec5SDimitry Andric  let Inst{12-10} = Pg;
69410b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
69420b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
69430b57cec5SDimitry Andric
69440b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
69455ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
69460b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
694706c3fb27SDimitry Andric  let hasSideEffects = 0;
69480b57cec5SDimitry Andric}
69490b57cec5SDimitry Andric
6950480093f4SDimitry Andricmulticlass sve_int_perm_clast_zz<bit ab, string asm, SDPatternOperator op> {
69510b57cec5SDimitry Andric  def _B : sve_int_perm_clast_zz<0b00, ab, asm, ZPR8>;
69520b57cec5SDimitry Andric  def _H : sve_int_perm_clast_zz<0b01, ab, asm, ZPR16>;
69530b57cec5SDimitry Andric  def _S : sve_int_perm_clast_zz<0b10, ab, asm, ZPR32>;
69540b57cec5SDimitry Andric  def _D : sve_int_perm_clast_zz<0b11, ab, asm, ZPR64>;
6955480093f4SDimitry Andric
6956480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
6957480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
6958480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
6959480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
6960480093f4SDimitry Andric
6961480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
6962480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
6963480093f4SDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
6964e8d8bef9SDimitry Andric
6965e8d8bef9SDimitry Andric  def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
69660b57cec5SDimitry Andric}
69670b57cec5SDimitry Andric
69680b57cec5SDimitry Andricclass sve_int_perm_last_r<bits<2> sz8_64, bit ab, string asm,
69690b57cec5SDimitry Andric                          ZPRRegOp zprty, RegisterClass resultRegType>
69700b57cec5SDimitry Andric: I<(outs resultRegType:$Rd), (ins PPR3bAny:$Pg, zprty:$Zn),
69710b57cec5SDimitry Andric  asm, "\t$Rd, $Pg, $Zn",
69720b57cec5SDimitry Andric  "",
69730b57cec5SDimitry Andric  []>, Sched<[]> {
69740b57cec5SDimitry Andric  bits<3> Pg;
69750b57cec5SDimitry Andric  bits<5> Rd;
69760b57cec5SDimitry Andric  bits<5> Zn;
69770b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
69780b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
69790b57cec5SDimitry Andric  let Inst{21-17} = 0b10000;
69800b57cec5SDimitry Andric  let Inst{16}    = ab;
69810b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
69820b57cec5SDimitry Andric  let Inst{12-10} = Pg;
69830b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
69840b57cec5SDimitry Andric  let Inst{4-0}   = Rd;
698506c3fb27SDimitry Andric
698606c3fb27SDimitry Andric  let hasSideEffects = 0;
69870b57cec5SDimitry Andric}
69880b57cec5SDimitry Andric
6989480093f4SDimitry Andricmulticlass sve_int_perm_last_r<bit ab, string asm, SDPatternOperator op> {
69900b57cec5SDimitry Andric  def _B : sve_int_perm_last_r<0b00, ab, asm, ZPR8, GPR32>;
69910b57cec5SDimitry Andric  def _H : sve_int_perm_last_r<0b01, ab, asm, ZPR16, GPR32>;
69920b57cec5SDimitry Andric  def _S : sve_int_perm_last_r<0b10, ab, asm, ZPR32, GPR32>;
69930b57cec5SDimitry Andric  def _D : sve_int_perm_last_r<0b11, ab, asm, ZPR64, GPR64>;
6994480093f4SDimitry Andric
6995480093f4SDimitry Andric  def : SVE_2_Op_Pat<i32, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
6996480093f4SDimitry Andric  def : SVE_2_Op_Pat<i32, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
6997480093f4SDimitry Andric  def : SVE_2_Op_Pat<i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
6998480093f4SDimitry Andric  def : SVE_2_Op_Pat<i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
69990b57cec5SDimitry Andric}
70000b57cec5SDimitry Andric
70010b57cec5SDimitry Andricclass sve_int_perm_last_v<bits<2> sz8_64, bit ab, string asm,
70020b57cec5SDimitry Andric                          ZPRRegOp zprty, RegisterClass dstRegtype>
70030b57cec5SDimitry Andric: I<(outs dstRegtype:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
70040b57cec5SDimitry Andric  asm, "\t$Vd, $Pg, $Zn",
70050b57cec5SDimitry Andric  "",
70060b57cec5SDimitry Andric  []>, Sched<[]> {
70070b57cec5SDimitry Andric  bits<3> Pg;
70080b57cec5SDimitry Andric  bits<5> Vd;
70090b57cec5SDimitry Andric  bits<5> Zn;
70100b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
70110b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
70120b57cec5SDimitry Andric  let Inst{21-17} = 0b10001;
70130b57cec5SDimitry Andric  let Inst{16}    = ab;
70140b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
70150b57cec5SDimitry Andric  let Inst{12-10} = Pg;
70160b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
70170b57cec5SDimitry Andric  let Inst{4-0}   = Vd;
701806c3fb27SDimitry Andric
701906c3fb27SDimitry Andric  let hasSideEffects = 0;
70200b57cec5SDimitry Andric}
70210b57cec5SDimitry Andric
7022480093f4SDimitry Andricmulticlass sve_int_perm_last_v<bit ab, string asm, SDPatternOperator op> {
70230b57cec5SDimitry Andric  def _B : sve_int_perm_last_v<0b00, ab, asm, ZPR8, FPR8>;
70240b57cec5SDimitry Andric  def _H : sve_int_perm_last_v<0b01, ab, asm, ZPR16, FPR16>;
70250b57cec5SDimitry Andric  def _S : sve_int_perm_last_v<0b10, ab, asm, ZPR32, FPR32>;
70260b57cec5SDimitry Andric  def _D : sve_int_perm_last_v<0b11, ab, asm, ZPR64, FPR64>;
7027480093f4SDimitry Andric
7028480093f4SDimitry Andric  def : SVE_2_Op_Pat<f16, op, nxv8i1,  nxv8f16, !cast<Instruction>(NAME # _H)>;
7029480093f4SDimitry Andric  def : SVE_2_Op_Pat<f32, op, nxv4i1,  nxv4f32, !cast<Instruction>(NAME # _S)>;
7030480093f4SDimitry Andric  def : SVE_2_Op_Pat<f32, op, nxv2i1,  nxv2f32, !cast<Instruction>(NAME # _S)>;
7031480093f4SDimitry Andric  def : SVE_2_Op_Pat<f64, op, nxv2i1,  nxv2f64, !cast<Instruction>(NAME # _D)>;
7032e8d8bef9SDimitry Andric
7033e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<bf16, op, nxv8i1,  nxv8bf16, !cast<Instruction>(NAME # _H)>;
70340b57cec5SDimitry Andric}
70350b57cec5SDimitry Andric
70360b57cec5SDimitry Andricclass sve_int_perm_splice<bits<2> sz8_64, string asm, ZPRRegOp zprty>
70370b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
70380b57cec5SDimitry Andric  asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
70390b57cec5SDimitry Andric  "",
70400b57cec5SDimitry Andric  []>, Sched<[]> {
70410b57cec5SDimitry Andric  bits<3> Pg;
70420b57cec5SDimitry Andric  bits<5> Zdn;
70430b57cec5SDimitry Andric  bits<5> Zm;
70440b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
70450b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
70460b57cec5SDimitry Andric  let Inst{21-13} = 0b101100100;
70470b57cec5SDimitry Andric  let Inst{12-10} = Pg;
70480b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
70490b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
70500b57cec5SDimitry Andric
70510b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
70525ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
70530b57cec5SDimitry Andric  let ElementSize = ElementSizeNone;
705406c3fb27SDimitry Andric  let hasSideEffects = 0;
70550b57cec5SDimitry Andric}
70560b57cec5SDimitry Andric
7057480093f4SDimitry Andricmulticlass sve_int_perm_splice<string asm, SDPatternOperator op> {
70580b57cec5SDimitry Andric  def _B : sve_int_perm_splice<0b00, asm, ZPR8>;
70590b57cec5SDimitry Andric  def _H : sve_int_perm_splice<0b01, asm, ZPR16>;
70600b57cec5SDimitry Andric  def _S : sve_int_perm_splice<0b10, asm, ZPR32>;
70610b57cec5SDimitry Andric  def _D : sve_int_perm_splice<0b11, asm, ZPR64>;
7062480093f4SDimitry Andric
7063*0fca6ea1SDimitry Andric foreach VT = [nxv16i8] in
7064*0fca6ea1SDimitry Andric   def : SVE_3_Op_Pat<VT, op, nxv16i1, VT, VT, !cast<Instruction>(NAME # _B)>;
7065480093f4SDimitry Andric
7066*0fca6ea1SDimitry Andric foreach VT = [nxv8i16, nxv8f16, nxv8bf16] in
7067*0fca6ea1SDimitry Andric   def : SVE_3_Op_Pat<VT, op, nxv8i1, VT, VT, !cast<Instruction>(NAME # _H)>;
7068e8d8bef9SDimitry Andric
7069*0fca6ea1SDimitry Andric foreach VT = [nxv4i32, nxv4f16, nxv4f32, nxv4bf16] in
7070*0fca6ea1SDimitry Andric   def : SVE_3_Op_Pat<VT, op, nxv4i1, VT, VT, !cast<Instruction>(NAME # _S)>;
7071*0fca6ea1SDimitry Andric
7072*0fca6ea1SDimitry Andric foreach VT = [nxv2i64, nxv2f16, nxv2f32, nxv2f64, nxv2bf16] in
7073*0fca6ea1SDimitry Andric   def : SVE_3_Op_Pat<VT, op, nxv2i1, VT, VT, !cast<Instruction>(NAME # _D)>;
70740b57cec5SDimitry Andric}
70750b57cec5SDimitry Andric
70760b57cec5SDimitry Andricclass sve2_int_perm_splice_cons<bits<2> sz8_64, string asm,
70770b57cec5SDimitry Andric                               ZPRRegOp zprty, RegisterOperand VecList>
70780b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, VecList:$Zn),
70790b57cec5SDimitry Andric  asm, "\t$Zd, $Pg, $Zn",
70800b57cec5SDimitry Andric  "",
70810b57cec5SDimitry Andric  []>, Sched<[]> {
70820b57cec5SDimitry Andric  bits<3> Pg;
70830b57cec5SDimitry Andric  bits<5> Zn;
70840b57cec5SDimitry Andric  bits<5> Zd;
70850b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
70860b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
70870b57cec5SDimitry Andric  let Inst{21-13} = 0b101101100;
70880b57cec5SDimitry Andric  let Inst{12-10} = Pg;
70890b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
70900b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
709106c3fb27SDimitry Andric
709206c3fb27SDimitry Andric  let hasSideEffects = 0;
70930b57cec5SDimitry Andric}
70940b57cec5SDimitry Andric
70950b57cec5SDimitry Andricmulticlass sve2_int_perm_splice_cons<string asm> {
70960b57cec5SDimitry Andric  def _B : sve2_int_perm_splice_cons<0b00, asm, ZPR8,  ZZ_b>;
70970b57cec5SDimitry Andric  def _H : sve2_int_perm_splice_cons<0b01, asm, ZPR16, ZZ_h>;
70980b57cec5SDimitry Andric  def _S : sve2_int_perm_splice_cons<0b10, asm, ZPR32, ZZ_s>;
70990b57cec5SDimitry Andric  def _D : sve2_int_perm_splice_cons<0b11, asm, ZPR64, ZZ_d>;
71000b57cec5SDimitry Andric}
71010b57cec5SDimitry Andric
71020b57cec5SDimitry Andricclass sve_int_perm_rev<bits<2> sz8_64, bits<2> opc, string asm,
71030b57cec5SDimitry Andric                       ZPRRegOp zprty>
71040b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
71050b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/m, $Zn",
71060b57cec5SDimitry Andric  "",
71070b57cec5SDimitry Andric  []>, Sched<[]> {
71080b57cec5SDimitry Andric  bits<5> Zd;
71090b57cec5SDimitry Andric  bits<3> Pg;
71100b57cec5SDimitry Andric  bits<5> Zn;
71110b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
71120b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
71130b57cec5SDimitry Andric  let Inst{21-18} = 0b1001;
71140b57cec5SDimitry Andric  let Inst{17-16} = opc;
71150b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
71160b57cec5SDimitry Andric  let Inst{12-10} = Pg;
71170b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
71180b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
71190b57cec5SDimitry Andric
71200b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
71215ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
71220b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
712306c3fb27SDimitry Andric  let hasSideEffects = 0;
71240b57cec5SDimitry Andric}
71250b57cec5SDimitry Andric
7126480093f4SDimitry Andricmulticlass sve_int_perm_rev_rbit<string asm, SDPatternOperator op> {
71270b57cec5SDimitry Andric  def _B : sve_int_perm_rev<0b00, 0b11, asm, ZPR8>;
71280b57cec5SDimitry Andric  def _H : sve_int_perm_rev<0b01, 0b11, asm, ZPR16>;
71290b57cec5SDimitry Andric  def _S : sve_int_perm_rev<0b10, 0b11, asm, ZPR32>;
71300b57cec5SDimitry Andric  def _D : sve_int_perm_rev<0b11, 0b11, asm, ZPR64>;
7131480093f4SDimitry Andric
7132e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
7133e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
7134e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
7135e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
71360b57cec5SDimitry Andric}
71370b57cec5SDimitry Andric
7138e8d8bef9SDimitry Andricmulticlass sve_int_perm_rev_revb<string asm, SDPatternOperator op> {
71390b57cec5SDimitry Andric  def _H : sve_int_perm_rev<0b01, 0b00, asm, ZPR16>;
71400b57cec5SDimitry Andric  def _S : sve_int_perm_rev<0b10, 0b00, asm, ZPR32>;
71410b57cec5SDimitry Andric  def _D : sve_int_perm_rev<0b11, 0b00, asm, ZPR64>;
7142480093f4SDimitry Andric
7143e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
7144e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
7145e8d8bef9SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
71460b57cec5SDimitry Andric}
71470b57cec5SDimitry Andric
7148480093f4SDimitry Andricmulticlass sve_int_perm_rev_revh<string asm, SDPatternOperator op> {
71490b57cec5SDimitry Andric  def _S : sve_int_perm_rev<0b10, 0b01, asm, ZPR32>;
71500b57cec5SDimitry Andric  def _D : sve_int_perm_rev<0b11, 0b01, asm, ZPR64>;
7151480093f4SDimitry Andric
71520eae32dcSDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
71530eae32dcSDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
71540b57cec5SDimitry Andric}
71550b57cec5SDimitry Andric
7156480093f4SDimitry Andricmulticlass sve_int_perm_rev_revw<string asm, SDPatternOperator op> {
71570b57cec5SDimitry Andric  def _D : sve_int_perm_rev<0b11, 0b10, asm, ZPR64>;
7158480093f4SDimitry Andric
71590eae32dcSDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
71600b57cec5SDimitry Andric}
71610b57cec5SDimitry Andric
71620b57cec5SDimitry Andricclass sve_int_perm_cpy_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
71630b57cec5SDimitry Andric                         RegisterClass srcRegType>
71640b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegType:$Rn),
71650b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/m, $Rn",
71660b57cec5SDimitry Andric  "",
71670b57cec5SDimitry Andric  []>, Sched<[]> {
71680b57cec5SDimitry Andric  bits<3> Pg;
71690b57cec5SDimitry Andric  bits<5> Rn;
71700b57cec5SDimitry Andric  bits<5> Zd;
71710b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
71720b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
71730b57cec5SDimitry Andric  let Inst{21-13} = 0b101000101;
71740b57cec5SDimitry Andric  let Inst{12-10} = Pg;
71750b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
71760b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
71770b57cec5SDimitry Andric
71780b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
71795ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
71800b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
718106c3fb27SDimitry Andric  let hasSideEffects = 0;
71820b57cec5SDimitry Andric}
71830b57cec5SDimitry Andric
71845ffd83dbSDimitry Andricmulticlass sve_int_perm_cpy_r<string asm, SDPatternOperator op> {
71850b57cec5SDimitry Andric  def _B : sve_int_perm_cpy_r<0b00, asm, ZPR8, GPR32sp>;
71860b57cec5SDimitry Andric  def _H : sve_int_perm_cpy_r<0b01, asm, ZPR16, GPR32sp>;
71870b57cec5SDimitry Andric  def _S : sve_int_perm_cpy_r<0b10, asm, ZPR32, GPR32sp>;
71880b57cec5SDimitry Andric  def _D : sve_int_perm_cpy_r<0b11, asm, ZPR64, GPR64sp>;
71890b57cec5SDimitry Andric
71900b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Rn",
71910b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
71920b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Rn",
71930b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
71940b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Rn",
71950b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
71960b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Rn",
71970b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, GPR64sp:$Rn), 1>;
71985ffd83dbSDimitry Andric
71995ffd83dbSDimitry Andric  def : Pat<(nxv16i8 (op nxv16i1:$pg, i32:$splat, nxv16i8:$passthru)),
72005ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _B) $passthru, $pg, $splat)>;
72015ffd83dbSDimitry Andric  def : Pat<(nxv8i16 (op nxv8i1:$pg, i32:$splat, nxv8i16:$passthru)),
72025ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
72035ffd83dbSDimitry Andric  def : Pat<(nxv4i32 (op nxv4i1:$pg, i32:$splat, nxv4i32:$passthru)),
72045ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
72055ffd83dbSDimitry Andric  def : Pat<(nxv2i64 (op nxv2i1:$pg, i64:$splat, nxv2i64:$passthru)),
72065ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _D) $passthru, $pg, $splat)>;
72070b57cec5SDimitry Andric}
72080b57cec5SDimitry Andric
72090b57cec5SDimitry Andricclass sve_int_perm_cpy_v<bits<2> sz8_64, string asm, ZPRRegOp zprty,
72100b57cec5SDimitry Andric                         RegisterClass srcRegtype>
72110b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegtype:$Vn),
72120b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/m, $Vn",
72130b57cec5SDimitry Andric  "",
72140b57cec5SDimitry Andric  []>, Sched<[]> {
72150b57cec5SDimitry Andric  bits<3> Pg;
72160b57cec5SDimitry Andric  bits<5> Vn;
72170b57cec5SDimitry Andric  bits<5> Zd;
72180b57cec5SDimitry Andric  let Inst{31-24} = 0b00000101;
72190b57cec5SDimitry Andric  let Inst{23-22} = sz8_64;
72200b57cec5SDimitry Andric  let Inst{21-13} = 0b100000100;
72210b57cec5SDimitry Andric  let Inst{12-10} = Pg;
72220b57cec5SDimitry Andric  let Inst{9-5}   = Vn;
72230b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
72240b57cec5SDimitry Andric
72250b57cec5SDimitry Andric  let Constraints = "$Zd = $_Zd";
72265ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
72270b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
722806c3fb27SDimitry Andric  let hasSideEffects = 0;
72290b57cec5SDimitry Andric}
72300b57cec5SDimitry Andric
72315ffd83dbSDimitry Andricmulticlass sve_int_perm_cpy_v<string asm, SDPatternOperator op> {
72320b57cec5SDimitry Andric  def _B : sve_int_perm_cpy_v<0b00, asm, ZPR8, FPR8>;
72330b57cec5SDimitry Andric  def _H : sve_int_perm_cpy_v<0b01, asm, ZPR16, FPR16>;
72340b57cec5SDimitry Andric  def _S : sve_int_perm_cpy_v<0b10, asm, ZPR32, FPR32>;
72350b57cec5SDimitry Andric  def _D : sve_int_perm_cpy_v<0b11, asm, ZPR64, FPR64>;
72360b57cec5SDimitry Andric
72370b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Vn",
72380b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, FPR8:$Vn), 1>;
72390b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Vn",
72400b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, FPR16:$Vn), 1>;
72410b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Vn",
72420b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, FPR32:$Vn), 1>;
72430b57cec5SDimitry Andric  def : InstAlias<"mov $Zd, $Pg/m, $Vn",
72440b57cec5SDimitry Andric                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, FPR64:$Vn), 1>;
72455ffd83dbSDimitry Andric
72465ffd83dbSDimitry Andric  def : Pat<(nxv8f16 (op nxv8i1:$pg, f16:$splat, nxv8f16:$passthru)),
72475ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
72488a4dda33SDimitry Andric  def : Pat<(nxv4f16 (op nxv4i1:$pg, f16:$splat, nxv4f16:$passthru)),
72498a4dda33SDimitry Andric            (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
72508a4dda33SDimitry Andric  def : Pat<(nxv2f16 (op nxv2i1:$pg, f16:$splat, nxv2f16:$passthru)),
72518a4dda33SDimitry Andric            (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
72525ffd83dbSDimitry Andric  def : Pat<(nxv2f32 (op nxv2i1:$pg, f32:$splat, nxv2f32:$passthru)),
72535ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
72545ffd83dbSDimitry Andric  def : Pat<(nxv4f32 (op nxv4i1:$pg, f32:$splat, nxv4f32:$passthru)),
72555ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
72565ffd83dbSDimitry Andric  def : Pat<(nxv2f64 (op nxv2i1:$pg, f64:$splat, nxv2f64:$passthru)),
72575ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _D) $passthru, $pg, $splat)>;
7258e8d8bef9SDimitry Andric
7259e8d8bef9SDimitry Andric  def : Pat<(nxv8bf16 (op nxv8i1:$pg, bf16:$splat, nxv8bf16:$passthru)),
7260e8d8bef9SDimitry Andric            (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
72610b57cec5SDimitry Andric}
72620b57cec5SDimitry Andric
72630b57cec5SDimitry Andricclass sve_int_perm_compact<bit sz, string asm, ZPRRegOp zprty>
72640b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
72650b57cec5SDimitry Andric  asm, "\t$Zd, $Pg, $Zn",
72660b57cec5SDimitry Andric  "",
72670b57cec5SDimitry Andric  []>, Sched<[]> {
72680b57cec5SDimitry Andric  bits<3> Pg;
72690b57cec5SDimitry Andric  bits<5> Zd;
72700b57cec5SDimitry Andric  bits<5> Zn;
72710b57cec5SDimitry Andric  let Inst{31-23} = 0b000001011;
72720b57cec5SDimitry Andric  let Inst{22}    = sz;
72730b57cec5SDimitry Andric  let Inst{21-13} = 0b100001100;
72740b57cec5SDimitry Andric  let Inst{12-10} = Pg;
72750b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
72760b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
727706c3fb27SDimitry Andric
727806c3fb27SDimitry Andric  let hasSideEffects = 0;
72790b57cec5SDimitry Andric}
72800b57cec5SDimitry Andric
7281480093f4SDimitry Andricmulticlass sve_int_perm_compact<string asm, SDPatternOperator op> {
72820b57cec5SDimitry Andric  def _S : sve_int_perm_compact<0b0, asm, ZPR32>;
72830b57cec5SDimitry Andric  def _D : sve_int_perm_compact<0b1, asm, ZPR64>;
7284480093f4SDimitry Andric
7285480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7286480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
7287480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7288480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
72890b57cec5SDimitry Andric}
72900b57cec5SDimitry Andric
72910b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
72920b57cec5SDimitry Andric// SVE Memory - Contiguous Load Group
72930b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
72940b57cec5SDimitry Andric
72950b57cec5SDimitry Andricclass sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
72960b57cec5SDimitry Andric                          RegisterOperand VecList>
72970b57cec5SDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
72980b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
72990b57cec5SDimitry Andric  "",
73000b57cec5SDimitry Andric  []>, Sched<[]> {
73010b57cec5SDimitry Andric  bits<3> Pg;
73020b57cec5SDimitry Andric  bits<5> Rn;
73030b57cec5SDimitry Andric  bits<5> Zt;
73040b57cec5SDimitry Andric  bits<4> imm4;
73050b57cec5SDimitry Andric  let Inst{31-25} = 0b1010010;
73060b57cec5SDimitry Andric  let Inst{24-21} = dtype;
73070b57cec5SDimitry Andric  let Inst{20}    = nf;
73080b57cec5SDimitry Andric  let Inst{19-16} = imm4;
73090b57cec5SDimitry Andric  let Inst{15-13} = 0b101;
73100b57cec5SDimitry Andric  let Inst{12-10} = Pg;
73110b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
73120b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
73130b57cec5SDimitry Andric
7314e8d8bef9SDimitry Andric  let Defs = !if(nf, [FFR], []);
731506c3fb27SDimitry Andric  let Uses = !if(nf, [FFR], []);
731606c3fb27SDimitry Andric  let hasSideEffects = nf;
731706c3fb27SDimitry Andric  let mayLoad = 1;
73180b57cec5SDimitry Andric}
73190b57cec5SDimitry Andric
7320*0fca6ea1SDimitry Andricmulticlass sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
7321*0fca6ea1SDimitry Andric                               RegisterOperand listty, ZPRRegOp zprty> {
7322*0fca6ea1SDimitry Andric  def NAME : sve_mem_cld_si_base<dtype, nf, asm, listty>;
73235f757f3fSDimitry Andric
73245f757f3fSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
73255f757f3fSDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
73265f757f3fSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
73275f757f3fSDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
73285f757f3fSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
73295f757f3fSDimitry Andric                  (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
73305f757f3fSDimitry Andric}
73310b57cec5SDimitry Andric
7332*0fca6ea1SDimitry Andricmulticlass sve_mem_cld_si<bits<4> dtype, string asm, RegisterOperand listty,
7333*0fca6ea1SDimitry Andric                          ZPRRegOp zprty>
7334*0fca6ea1SDimitry Andric: sve_mem_cld_si_base<dtype, 0, asm, listty, zprty>;
7335*0fca6ea1SDimitry Andric
7336*0fca6ea1SDimitry Andricmulticlass sve_mem_cldnf_si<bits<4> dtype, string asm, RegisterOperand listty,
7337*0fca6ea1SDimitry Andric                            ZPRRegOp zprty>
7338*0fca6ea1SDimitry Andric: sve_mem_cld_si_base<dtype, 1, asm, listty, zprty>;
7339*0fca6ea1SDimitry Andric
73400b57cec5SDimitry Andricclass sve_mem_cldnt_si_base<bits<2> msz, string asm, RegisterOperand VecList>
73410b57cec5SDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
73420b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
73430b57cec5SDimitry Andric  "",
73440b57cec5SDimitry Andric  []>, Sched<[]> {
73450b57cec5SDimitry Andric  bits<5> Zt;
73460b57cec5SDimitry Andric  bits<3> Pg;
73470b57cec5SDimitry Andric  bits<5> Rn;
73480b57cec5SDimitry Andric  bits<4> imm4;
73490b57cec5SDimitry Andric  let Inst{31-25} = 0b1010010;
73500b57cec5SDimitry Andric  let Inst{24-23} = msz;
73510b57cec5SDimitry Andric  let Inst{22-20} = 0b000;
73520b57cec5SDimitry Andric  let Inst{19-16} = imm4;
73530b57cec5SDimitry Andric  let Inst{15-13} = 0b111;
73540b57cec5SDimitry Andric  let Inst{12-10} = Pg;
73550b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
73560b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
73570b57cec5SDimitry Andric
735806c3fb27SDimitry Andric  let hasSideEffects = 0;
73590b57cec5SDimitry Andric  let mayLoad = 1;
73600b57cec5SDimitry Andric}
73610b57cec5SDimitry Andric
73620b57cec5SDimitry Andricmulticlass sve_mem_cldnt_si<bits<2> msz, string asm, RegisterOperand listty,
73630b57cec5SDimitry Andric                            ZPRRegOp zprty> {
73640b57cec5SDimitry Andric  def NAME : sve_mem_cldnt_si_base<msz, asm, listty>;
73650b57cec5SDimitry Andric
73660b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
73670b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
73680b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
73690b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
73700b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
73710b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
73720b57cec5SDimitry Andric}
73730b57cec5SDimitry Andric
73740b57cec5SDimitry Andricclass sve_mem_cldnt_ss_base<bits<2> msz, string asm, RegisterOperand VecList,
73750b57cec5SDimitry Andric                            RegisterOperand gprty>
73760b57cec5SDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
73770b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
73780b57cec5SDimitry Andric  "",
73790b57cec5SDimitry Andric  []>, Sched<[]> {
73800b57cec5SDimitry Andric  bits<3> Pg;
73810b57cec5SDimitry Andric  bits<5> Rm;
73820b57cec5SDimitry Andric  bits<5> Rn;
73830b57cec5SDimitry Andric  bits<5> Zt;
73840b57cec5SDimitry Andric  let Inst{31-25} = 0b1010010;
73850b57cec5SDimitry Andric  let Inst{24-23} = msz;
73860b57cec5SDimitry Andric  let Inst{22-21} = 0b00;
73870b57cec5SDimitry Andric  let Inst{20-16} = Rm;
73880b57cec5SDimitry Andric  let Inst{15-13} = 0b110;
73890b57cec5SDimitry Andric  let Inst{12-10} = Pg;
73900b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
73910b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
73920b57cec5SDimitry Andric
739306c3fb27SDimitry Andric  let hasSideEffects = 0;
73940b57cec5SDimitry Andric  let mayLoad = 1;
73950b57cec5SDimitry Andric}
73960b57cec5SDimitry Andric
73970b57cec5SDimitry Andricmulticlass sve_mem_cldnt_ss<bits<2> msz, string asm, RegisterOperand listty,
73980b57cec5SDimitry Andric                            ZPRRegOp zprty, RegisterOperand gprty> {
73990b57cec5SDimitry Andric  def NAME : sve_mem_cldnt_ss_base<msz, asm, listty, gprty>;
74000b57cec5SDimitry Andric
74010b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
74020b57cec5SDimitry Andric                 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
74030b57cec5SDimitry Andric}
74040b57cec5SDimitry Andric
74050b57cec5SDimitry Andricclass sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand VecList>
74060b57cec5SDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4),
74070b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> {
74080b57cec5SDimitry Andric  bits<5> Zt;
74090b57cec5SDimitry Andric  bits<5> Rn;
74100b57cec5SDimitry Andric  bits<3> Pg;
74110b57cec5SDimitry Andric  bits<4> imm4;
74120b57cec5SDimitry Andric  let Inst{31-25} = 0b1010010;
74130b57cec5SDimitry Andric  let Inst{24-23} = sz;
74140b57cec5SDimitry Andric  let Inst{22-20} = 0;
74150b57cec5SDimitry Andric  let Inst{19-16} = imm4;
74160b57cec5SDimitry Andric  let Inst{15-13} = 0b001;
74170b57cec5SDimitry Andric  let Inst{12-10} = Pg;
74180b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
74190b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
74200b57cec5SDimitry Andric
742106c3fb27SDimitry Andric  let hasSideEffects = 0;
74220b57cec5SDimitry Andric  let mayLoad = 1;
74230b57cec5SDimitry Andric}
74240b57cec5SDimitry Andric
74250b57cec5SDimitry Andricmulticlass sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand listty,
74260b57cec5SDimitry Andric                           ZPRRegOp zprty> {
74270b57cec5SDimitry Andric  def NAME : sve_mem_ldqr_si<sz, asm, listty>;
74280b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
74290b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
74300b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
74310b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
74320b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]",
74330b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4), 0>;
74340b57cec5SDimitry Andric}
74350b57cec5SDimitry Andric
74360b57cec5SDimitry Andricclass sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand VecList,
74370b57cec5SDimitry Andric                      RegisterOperand gprty>
74380b57cec5SDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
74390b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> {
74400b57cec5SDimitry Andric  bits<5> Zt;
74410b57cec5SDimitry Andric  bits<3> Pg;
74420b57cec5SDimitry Andric  bits<5> Rn;
74430b57cec5SDimitry Andric  bits<5> Rm;
74440b57cec5SDimitry Andric  let Inst{31-25} = 0b1010010;
74450b57cec5SDimitry Andric  let Inst{24-23} = sz;
74460b57cec5SDimitry Andric  let Inst{22-21} = 0;
74470b57cec5SDimitry Andric  let Inst{20-16} = Rm;
74480b57cec5SDimitry Andric  let Inst{15-13} = 0;
74490b57cec5SDimitry Andric  let Inst{12-10} = Pg;
74500b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
74510b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
74520b57cec5SDimitry Andric
745306c3fb27SDimitry Andric  let hasSideEffects = 0;
74540b57cec5SDimitry Andric  let mayLoad = 1;
74550b57cec5SDimitry Andric}
74560b57cec5SDimitry Andric
74570b57cec5SDimitry Andricmulticlass sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand listty,
74580b57cec5SDimitry Andric                           ZPRRegOp zprty, RegisterOperand gprty> {
74590b57cec5SDimitry Andric  def NAME : sve_mem_ldqr_ss<sz, asm, listty, gprty>;
74600b57cec5SDimitry Andric
74610b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
74620b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
74630b57cec5SDimitry Andric}
74640b57cec5SDimitry Andric
74650b57cec5SDimitry Andricclass sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
74660b57cec5SDimitry Andric                     RegisterOperand VecList, Operand immtype>
74670b57cec5SDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6),
74680b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $imm6]",
74690b57cec5SDimitry Andric  "",
74700b57cec5SDimitry Andric  []>, Sched<[]> {
74710b57cec5SDimitry Andric  bits<3> Pg;
74720b57cec5SDimitry Andric  bits<5> Rn;
74730b57cec5SDimitry Andric  bits<5> Zt;
74740b57cec5SDimitry Andric  bits<6> imm6;
74750b57cec5SDimitry Andric  let Inst{31-25} = 0b1000010;
74760b57cec5SDimitry Andric  let Inst{24-23} = dtypeh;
74770b57cec5SDimitry Andric  let Inst{22}    = 1;
74780b57cec5SDimitry Andric  let Inst{21-16} = imm6;
74790b57cec5SDimitry Andric  let Inst{15}    = 0b1;
74800b57cec5SDimitry Andric  let Inst{14-13} = dtypel;
74810b57cec5SDimitry Andric  let Inst{12-10} = Pg;
74820b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
74830b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
74840b57cec5SDimitry Andric
748506c3fb27SDimitry Andric  let hasSideEffects = 0;
74860b57cec5SDimitry Andric  let mayLoad = 1;
74870b57cec5SDimitry Andric}
74880b57cec5SDimitry Andric
74890b57cec5SDimitry Andricmulticlass sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
74900b57cec5SDimitry Andric                          RegisterOperand zlistty, ZPRRegOp zprty, Operand immtype> {
74910b57cec5SDimitry Andric  def NAME : sve_mem_ld_dup<dtypeh, dtypel, asm, zlistty, immtype>;
74920b57cec5SDimitry Andric
74930b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
74940b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
74950b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm6]",
74960b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6), 0>;
74970b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
74980b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) zlistty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
74990b57cec5SDimitry Andric}
75000b57cec5SDimitry Andric
75010b57cec5SDimitry Andricclass sve_mem_cld_ss_base<bits<4> dtype, bit ff, dag iops, string asm,
75020b57cec5SDimitry Andric                          RegisterOperand VecList>
75030b57cec5SDimitry Andric: I<(outs VecList:$Zt), iops,
75040b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
75050b57cec5SDimitry Andric  "",
75060b57cec5SDimitry Andric  []>, Sched<[]> {
75070b57cec5SDimitry Andric  bits<5> Zt;
75080b57cec5SDimitry Andric  bits<3> Pg;
75090b57cec5SDimitry Andric  bits<5> Rm;
75100b57cec5SDimitry Andric  bits<5> Rn;
75110b57cec5SDimitry Andric  let Inst{31-25} = 0b1010010;
75120b57cec5SDimitry Andric  let Inst{24-21} = dtype;
75130b57cec5SDimitry Andric  let Inst{20-16} = Rm;
75140b57cec5SDimitry Andric  let Inst{15-14} = 0b01;
75150b57cec5SDimitry Andric  let Inst{13}    = ff;
75160b57cec5SDimitry Andric  let Inst{12-10} = Pg;
75170b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
75180b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
75190b57cec5SDimitry Andric
7520e8d8bef9SDimitry Andric  let Defs = !if(ff, [FFR], []);
752106c3fb27SDimitry Andric  let Uses = !if(ff, [FFR], []);
752206c3fb27SDimitry Andric  let hasSideEffects = ff;
752306c3fb27SDimitry Andric  let mayLoad = 1;
75240b57cec5SDimitry Andric}
75250b57cec5SDimitry Andric
75260b57cec5SDimitry Andricmulticlass sve_mem_cld_ss<bits<4> dtype, string asm, RegisterOperand listty,
75270b57cec5SDimitry Andric                          ZPRRegOp zprty, RegisterOperand gprty> {
7528*0fca6ea1SDimitry Andric  def NAME : sve_mem_cld_ss_base<dtype, 0, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
75290b57cec5SDimitry Andric                               asm, listty>;
75300b57cec5SDimitry Andric
75310b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
75320b57cec5SDimitry Andric                 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
75330b57cec5SDimitry Andric}
75340b57cec5SDimitry Andric
75350b57cec5SDimitry Andricmulticlass sve_mem_cldff_ss<bits<4> dtype, string asm, RegisterOperand listty,
75360b57cec5SDimitry Andric                            ZPRRegOp zprty, RegisterOperand gprty> {
7537*0fca6ea1SDimitry Andric  def NAME : sve_mem_cld_ss_base<dtype, 1, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), asm, listty>;
75380b57cec5SDimitry Andric
75390b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
7540*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
75410b57cec5SDimitry Andric
75420b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
7543*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 1>;
75440b57cec5SDimitry Andric
75450b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
7546*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 0>;
75475f757f3fSDimitry Andric}
75480b57cec5SDimitry Andric
7549bdd1243dSDimitry Andricclass sve_mem_eld_si<bits<2> sz, bits<3> nregs, RegisterOperand VecList,
75500b57cec5SDimitry Andric                     string asm, Operand immtype>
75510b57cec5SDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
75520b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
75530b57cec5SDimitry Andric  "",
75540b57cec5SDimitry Andric  []>, Sched<[]> {
75550b57cec5SDimitry Andric  bits<5> Zt;
75560b57cec5SDimitry Andric  bits<3> Pg;
75570b57cec5SDimitry Andric  bits<5> Rn;
75580b57cec5SDimitry Andric  bits<4> imm4;
75590b57cec5SDimitry Andric  let Inst{31-25} = 0b1010010;
75600b57cec5SDimitry Andric  let Inst{24-23} = sz;
7561bdd1243dSDimitry Andric  let Inst{22-21} = nregs{1-0};
7562bdd1243dSDimitry Andric  let Inst{20}    = nregs{2};
75630b57cec5SDimitry Andric  let Inst{19-16} = imm4;
75640b57cec5SDimitry Andric  let Inst{15-13} = 0b111;
75650b57cec5SDimitry Andric  let Inst{12-10} = Pg;
75660b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
75670b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
75680b57cec5SDimitry Andric
756906c3fb27SDimitry Andric  let hasSideEffects = 0;
75700b57cec5SDimitry Andric  let mayLoad = 1;
75710b57cec5SDimitry Andric}
75720b57cec5SDimitry Andric
7573bdd1243dSDimitry Andricmulticlass sve_mem_eld_si<bits<2> sz, bits<3> nregs, RegisterOperand VecList,
75740b57cec5SDimitry Andric                          string asm, Operand immtype> {
75750b57cec5SDimitry Andric  def NAME : sve_mem_eld_si<sz, nregs, VecList, asm, immtype>;
75760b57cec5SDimitry Andric
75770b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
75780b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
75790b57cec5SDimitry Andric}
75800b57cec5SDimitry Andric
7581bdd1243dSDimitry Andric
7582bdd1243dSDimitry Andricclass sve_mem_eld_ss<bits<2> sz, bits<3> nregs, RegisterOperand VecList,
75830b57cec5SDimitry Andric                     string asm, RegisterOperand gprty>
75840b57cec5SDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
75850b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
75860b57cec5SDimitry Andric  "",
75870b57cec5SDimitry Andric  []>, Sched<[]> {
75880b57cec5SDimitry Andric  bits<3> Pg;
75890b57cec5SDimitry Andric  bits<5> Rm;
75900b57cec5SDimitry Andric  bits<5> Rn;
75910b57cec5SDimitry Andric  bits<5> Zt;
75920b57cec5SDimitry Andric  let Inst{31-25} = 0b1010010;
75930b57cec5SDimitry Andric  let Inst{24-23} = sz;
7594bdd1243dSDimitry Andric  let Inst{22-21} = nregs{1-0};
75950b57cec5SDimitry Andric  let Inst{20-16} = Rm;
7596bdd1243dSDimitry Andric  let Inst{15}    = 0b1;
7597bdd1243dSDimitry Andric  let Inst{14}    = nregs{2};
7598bdd1243dSDimitry Andric  let Inst{13}    = 0b0;
75990b57cec5SDimitry Andric  let Inst{12-10} = Pg;
76000b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
76010b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
76020b57cec5SDimitry Andric
760306c3fb27SDimitry Andric  let hasSideEffects = 0;
76040b57cec5SDimitry Andric  let mayLoad = 1;
76050b57cec5SDimitry Andric}
76060b57cec5SDimitry Andric
76070b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
76080b57cec5SDimitry Andric// SVE Memory - 32-bit Gather and Unsized Contiguous Group
76090b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
76100b57cec5SDimitry Andric
76110b57cec5SDimitry Andric// bit xs      is '1' if offsets are signed
76120b57cec5SDimitry Andric// bit scaled  is '1' if the offsets are scaled
76130b57cec5SDimitry Andricclass sve_mem_32b_gld_sv<bits<4> opc, bit xs, bit scaled, string asm,
76140b57cec5SDimitry Andric                         RegisterOperand zprext>
76150b57cec5SDimitry Andric: I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
76160b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
76170b57cec5SDimitry Andric  "",
76180b57cec5SDimitry Andric  []>, Sched<[]> {
76190b57cec5SDimitry Andric  bits<3> Pg;
76200b57cec5SDimitry Andric  bits<5> Rn;
76210b57cec5SDimitry Andric  bits<5> Zm;
76220b57cec5SDimitry Andric  bits<5> Zt;
76230b57cec5SDimitry Andric  let Inst{31-25} = 0b1000010;
76240b57cec5SDimitry Andric  let Inst{24-23} = opc{3-2};
76250b57cec5SDimitry Andric  let Inst{22}    = xs;
76260b57cec5SDimitry Andric  let Inst{21}    = scaled;
76270b57cec5SDimitry Andric  let Inst{20-16} = Zm;
76280b57cec5SDimitry Andric  let Inst{15}    = 0b0;
76290b57cec5SDimitry Andric  let Inst{14-13} = opc{1-0};
76300b57cec5SDimitry Andric  let Inst{12-10} = Pg;
76310b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
76320b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
76330b57cec5SDimitry Andric
763406c3fb27SDimitry Andric
76350b57cec5SDimitry Andric  let Defs = !if(!eq(opc{0}, 1), [FFR], []);
76360b57cec5SDimitry Andric  let Uses = !if(!eq(opc{0}, 1), [FFR], []);
763706c3fb27SDimitry Andric  let hasSideEffects = opc{0};
763806c3fb27SDimitry Andric  let mayLoad = 1;
76390b57cec5SDimitry Andric}
76400b57cec5SDimitry Andric
76410b57cec5SDimitry Andricmulticlass sve_mem_32b_gld_sv_32_scaled<bits<4> opc, string asm,
7642480093f4SDimitry Andric                                        SDPatternOperator sxtw_op,
7643480093f4SDimitry Andric                                        SDPatternOperator uxtw_op,
76440b57cec5SDimitry Andric                                        RegisterOperand sxtw_opnd,
7645480093f4SDimitry Andric                                        RegisterOperand uxtw_opnd,
7646480093f4SDimitry Andric                                        ValueType vt> {
7647*0fca6ea1SDimitry Andric  def _UXTW_SCALED : sve_mem_32b_gld_sv<opc, 0, 1, asm, uxtw_opnd>;
7648*0fca6ea1SDimitry Andric  def _SXTW_SCALED : sve_mem_32b_gld_sv<opc, 1, 1, asm, sxtw_opnd>;
76490b57cec5SDimitry Andric
76500b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
7651*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
76520b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
7653*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
76545ffd83dbSDimitry Andric
7655480093f4SDimitry Andric  def : Pat<(nxv4i32 (uxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$indices), vt)),
76565ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _UXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
7657480093f4SDimitry Andric  def : Pat<(nxv4i32 (sxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$indices), vt)),
76585ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _SXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
76590b57cec5SDimitry Andric}
76600b57cec5SDimitry Andric
76610b57cec5SDimitry Andricmulticlass sve_mem_32b_gld_vs_32_unscaled<bits<4> opc, string asm,
7662480093f4SDimitry Andric                                          SDPatternOperator sxtw_op,
7663480093f4SDimitry Andric                                          SDPatternOperator uxtw_op,
76640b57cec5SDimitry Andric                                          RegisterOperand sxtw_opnd,
7665480093f4SDimitry Andric                                          RegisterOperand uxtw_opnd,
7666480093f4SDimitry Andric                                          ValueType vt> {
7667*0fca6ea1SDimitry Andric  def _UXTW : sve_mem_32b_gld_sv<opc, 0, 0, asm, uxtw_opnd>;
7668*0fca6ea1SDimitry Andric  def _SXTW : sve_mem_32b_gld_sv<opc, 1, 0, asm, sxtw_opnd>;
76690b57cec5SDimitry Andric
76700b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
7671*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _UXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
76720b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
7673*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _SXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
76745ffd83dbSDimitry Andric
7675480093f4SDimitry Andric  def : Pat<(nxv4i32 (uxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt)),
76765ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _UXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
7677480093f4SDimitry Andric  def : Pat<(nxv4i32 (sxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt)),
76785ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _SXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
76790b57cec5SDimitry Andric}
76800b57cec5SDimitry Andric
76810b57cec5SDimitry Andric
76820b57cec5SDimitry Andricclass sve_mem_32b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
76830b57cec5SDimitry Andric: I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
76840b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
76850b57cec5SDimitry Andric  "",
76860b57cec5SDimitry Andric  []>, Sched<[]> {
76870b57cec5SDimitry Andric  bits<3> Pg;
76880b57cec5SDimitry Andric  bits<5> Zn;
76890b57cec5SDimitry Andric  bits<5> Zt;
76900b57cec5SDimitry Andric  bits<5> imm5;
76910b57cec5SDimitry Andric  let Inst{31-25} = 0b1000010;
76920b57cec5SDimitry Andric  let Inst{24-23} = opc{3-2};
76930b57cec5SDimitry Andric  let Inst{22-21} = 0b01;
76940b57cec5SDimitry Andric  let Inst{20-16} = imm5;
76950b57cec5SDimitry Andric  let Inst{15}    = 0b1;
76960b57cec5SDimitry Andric  let Inst{14-13} = opc{1-0};
76970b57cec5SDimitry Andric  let Inst{12-10} = Pg;
76980b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
76990b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
77000b57cec5SDimitry Andric
770106c3fb27SDimitry Andric
77020b57cec5SDimitry Andric  let Defs = !if(!eq(opc{0}, 1), [FFR], []);
77030b57cec5SDimitry Andric  let Uses = !if(!eq(opc{0}, 1), [FFR], []);
770406c3fb27SDimitry Andric  let hasSideEffects = opc{0};
770506c3fb27SDimitry Andric  let mayLoad = 1;
77060b57cec5SDimitry Andric}
77070b57cec5SDimitry Andric
7708480093f4SDimitry Andricmulticlass sve_mem_32b_gld_vi_32_ptrs<bits<4> opc, string asm, Operand imm_ty,
7709480093f4SDimitry Andric                                      SDPatternOperator op, ValueType vt> {
7710*0fca6ea1SDimitry Andric  def _IMM : sve_mem_32b_gld_vi<opc, asm, imm_ty>;
77110b57cec5SDimitry Andric
77120b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
7713*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>;
77140b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
7715*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>;
77160b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
7717*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
77185ffd83dbSDimitry Andric
7719480093f4SDimitry Andric  def : Pat<(nxv4i32 (op (nxv4i1 PPR:$gp), (nxv4i32 ZPR:$ptrs), imm_ty:$index, vt)),
77205ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _IMM) PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
77210b57cec5SDimitry Andric}
77220b57cec5SDimitry Andric
77230b57cec5SDimitry Andricclass sve_mem_prfm_si<bits<2> msz, string asm>
77240b57cec5SDimitry Andric: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, simm6s1:$imm6),
77250b57cec5SDimitry Andric  asm, "\t$prfop, $Pg, [$Rn, $imm6, mul vl]",
77260b57cec5SDimitry Andric  "",
77270b57cec5SDimitry Andric  []>, Sched<[]> {
77280b57cec5SDimitry Andric  bits<5> Rn;
77290b57cec5SDimitry Andric  bits<3> Pg;
77300b57cec5SDimitry Andric  bits<6> imm6;
77310b57cec5SDimitry Andric  bits<4> prfop;
77320b57cec5SDimitry Andric  let Inst{31-22} = 0b1000010111;
77330b57cec5SDimitry Andric  let Inst{21-16} = imm6;
77340b57cec5SDimitry Andric  let Inst{15}    = 0b0;
77350b57cec5SDimitry Andric  let Inst{14-13} = msz;
77360b57cec5SDimitry Andric  let Inst{12-10} = Pg;
77370b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
77380b57cec5SDimitry Andric  let Inst{4}     = 0b0;
77390b57cec5SDimitry Andric  let Inst{3-0}   = prfop;
77400b57cec5SDimitry Andric
77410b57cec5SDimitry Andric  let hasSideEffects = 1;
77420b57cec5SDimitry Andric}
77430b57cec5SDimitry Andric
77440b57cec5SDimitry Andricmulticlass sve_mem_prfm_si<bits<2> msz, string asm> {
77450b57cec5SDimitry Andric  def NAME : sve_mem_prfm_si<msz, asm>;
77460b57cec5SDimitry Andric
77470b57cec5SDimitry Andric  def : InstAlias<asm # "\t$prfop, $Pg, [$Rn]",
77480b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
77490b57cec5SDimitry Andric}
77500b57cec5SDimitry Andric
77510b57cec5SDimitry Andricclass sve_mem_prfm_ss<bits<3> opc, string asm, RegisterOperand gprty>
77520b57cec5SDimitry Andric: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
77530b57cec5SDimitry Andric  asm, "\t$prfop, $Pg, [$Rn, $Rm]",
77540b57cec5SDimitry Andric  "",
77550b57cec5SDimitry Andric  []>, Sched<[]> {
77560b57cec5SDimitry Andric  bits<5> Rm;
77570b57cec5SDimitry Andric  bits<5> Rn;
77580b57cec5SDimitry Andric  bits<3> Pg;
77590b57cec5SDimitry Andric  bits<4> prfop;
77600b57cec5SDimitry Andric  let Inst{31-25} = 0b1000010;
77610b57cec5SDimitry Andric  let Inst{24-23} = opc{2-1};
77620b57cec5SDimitry Andric  let Inst{22-21} = 0b00;
77630b57cec5SDimitry Andric  let Inst{20-16} = Rm;
77640b57cec5SDimitry Andric  let Inst{15}    = 0b1;
77650b57cec5SDimitry Andric  let Inst{14}    = opc{0};
77660b57cec5SDimitry Andric  let Inst{13}    = 0b0;
77670b57cec5SDimitry Andric  let Inst{12-10} = Pg;
77680b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
77690b57cec5SDimitry Andric  let Inst{4}     = 0b0;
77700b57cec5SDimitry Andric  let Inst{3-0}   = prfop;
77710b57cec5SDimitry Andric
77720b57cec5SDimitry Andric  let hasSideEffects = 1;
77730b57cec5SDimitry Andric}
77740b57cec5SDimitry Andric
77750b57cec5SDimitry Andricclass sve_mem_32b_prfm_sv<bits<2> msz, bit xs, string asm,
77760b57cec5SDimitry Andric                          RegisterOperand zprext>
77770b57cec5SDimitry Andric: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
77780b57cec5SDimitry Andric  asm, "\t$prfop, $Pg, [$Rn, $Zm]",
77790b57cec5SDimitry Andric  "",
77800b57cec5SDimitry Andric  []>, Sched<[]> {
77810b57cec5SDimitry Andric  bits<3> Pg;
77820b57cec5SDimitry Andric  bits<5> Rn;
77830b57cec5SDimitry Andric  bits<5> Zm;
77840b57cec5SDimitry Andric  bits<4> prfop;
77850b57cec5SDimitry Andric  let Inst{31-23} = 0b100001000;
77860b57cec5SDimitry Andric  let Inst{22}    = xs;
77870b57cec5SDimitry Andric  let Inst{21}    = 0b1;
77880b57cec5SDimitry Andric  let Inst{20-16} = Zm;
77890b57cec5SDimitry Andric  let Inst{15}    = 0b0;
77900b57cec5SDimitry Andric  let Inst{14-13} = msz;
77910b57cec5SDimitry Andric  let Inst{12-10} = Pg;
77920b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
77930b57cec5SDimitry Andric  let Inst{4}     = 0b0;
77940b57cec5SDimitry Andric  let Inst{3-0}   = prfop;
77950b57cec5SDimitry Andric
77960b57cec5SDimitry Andric  let hasSideEffects = 1;
77970b57cec5SDimitry Andric}
77980b57cec5SDimitry Andric
77990b57cec5SDimitry Andricmulticlass sve_mem_32b_prfm_sv_scaled<bits<2> msz, string asm,
78000b57cec5SDimitry Andric                                      RegisterOperand sxtw_opnd,
78015ffd83dbSDimitry Andric                                      RegisterOperand uxtw_opnd,
7802fe6060f1SDimitry Andric                                      SDPatternOperator op_sxtw,
7803fe6060f1SDimitry Andric                                      SDPatternOperator op_uxtw> {
78040b57cec5SDimitry Andric  def _UXTW_SCALED : sve_mem_32b_prfm_sv<msz, 0, asm, uxtw_opnd>;
78050b57cec5SDimitry Andric  def _SXTW_SCALED : sve_mem_32b_prfm_sv<msz, 1, asm, sxtw_opnd>;
78065ffd83dbSDimitry Andric
78075ffd83dbSDimitry Andric  def : Pat<(op_uxtw (nxv4i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv4i32 uxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
78085ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _UXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
78095ffd83dbSDimitry Andric
78105ffd83dbSDimitry Andric  def : Pat<(op_sxtw (nxv4i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv4i32 sxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
78115ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _SXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
78120b57cec5SDimitry Andric}
78130b57cec5SDimitry Andric
78140b57cec5SDimitry Andricclass sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
78150b57cec5SDimitry Andric: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
78160b57cec5SDimitry Andric  asm, "\t$prfop, $Pg, [$Zn, $imm5]",
78170b57cec5SDimitry Andric  "",
78180b57cec5SDimitry Andric  []>, Sched<[]> {
78190b57cec5SDimitry Andric  bits<3> Pg;
78200b57cec5SDimitry Andric  bits<5> Zn;
78210b57cec5SDimitry Andric  bits<5> imm5;
78220b57cec5SDimitry Andric  bits<4> prfop;
78230b57cec5SDimitry Andric  let Inst{31-25} = 0b1000010;
78240b57cec5SDimitry Andric  let Inst{24-23} = msz;
78250b57cec5SDimitry Andric  let Inst{22-21} = 0b00;
78260b57cec5SDimitry Andric  let Inst{20-16} = imm5;
78270b57cec5SDimitry Andric  let Inst{15-13} = 0b111;
78280b57cec5SDimitry Andric  let Inst{12-10} = Pg;
78290b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
78300b57cec5SDimitry Andric  let Inst{4}     = 0b0;
78310b57cec5SDimitry Andric  let Inst{3-0}   = prfop;
783206c3fb27SDimitry Andric
783306c3fb27SDimitry Andric  let hasSideEffects = 1;
78340b57cec5SDimitry Andric}
78350b57cec5SDimitry Andric
78365ffd83dbSDimitry Andricmulticlass sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty, SDPatternOperator op> {
78370b57cec5SDimitry Andric  def NAME : sve_mem_32b_prfm_vi<msz, asm, imm_ty>;
78380b57cec5SDimitry Andric
78390b57cec5SDimitry Andric  def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
78400b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
78415ffd83dbSDimitry Andric
78425ffd83dbSDimitry Andric  def : Pat<(op (nxv4i1 PPR_3b:$Pg), (nxv4i32 ZPR32:$Zn), (i64 imm_ty:$imm), (i32 sve_prfop:$prfop)),
78435ffd83dbSDimitry Andric            (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR_3b:$Pg, ZPR32:$Zn, imm_ty:$imm)>;
78440b57cec5SDimitry Andric}
78450b57cec5SDimitry Andric
78460b57cec5SDimitry Andricclass sve_mem_z_fill<string asm>
78470b57cec5SDimitry Andric: I<(outs ZPRAny:$Zt), (ins GPR64sp:$Rn, simm9:$imm9),
78480b57cec5SDimitry Andric  asm, "\t$Zt, [$Rn, $imm9, mul vl]",
78490b57cec5SDimitry Andric  "",
78500b57cec5SDimitry Andric  []>, Sched<[]> {
78510b57cec5SDimitry Andric  bits<5> Rn;
78520b57cec5SDimitry Andric  bits<5> Zt;
78530b57cec5SDimitry Andric  bits<9> imm9;
78540b57cec5SDimitry Andric  let Inst{31-22} = 0b1000010110;
78550b57cec5SDimitry Andric  let Inst{21-16} = imm9{8-3};
78560b57cec5SDimitry Andric  let Inst{15-13} = 0b010;
78570b57cec5SDimitry Andric  let Inst{12-10} = imm9{2-0};
78580b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
78590b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
78600b57cec5SDimitry Andric
786106c3fb27SDimitry Andric  let hasSideEffects = 0;
78620b57cec5SDimitry Andric  let mayLoad = 1;
78630b57cec5SDimitry Andric}
78640b57cec5SDimitry Andric
78650b57cec5SDimitry Andricmulticlass sve_mem_z_fill<string asm> {
78660b57cec5SDimitry Andric  def NAME : sve_mem_z_fill<asm>;
78670b57cec5SDimitry Andric
78680b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, [$Rn]",
78690b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
78700b57cec5SDimitry Andric}
78710b57cec5SDimitry Andric
78720b57cec5SDimitry Andricclass sve_mem_p_fill<string asm>
7873*0fca6ea1SDimitry Andric: I<(outs PPRorPNRAny:$Pt), (ins GPR64sp:$Rn, simm9:$imm9),
78740b57cec5SDimitry Andric  asm, "\t$Pt, [$Rn, $imm9, mul vl]",
78750b57cec5SDimitry Andric  "",
78760b57cec5SDimitry Andric  []>, Sched<[]> {
78770b57cec5SDimitry Andric  bits<4> Pt;
78780b57cec5SDimitry Andric  bits<5> Rn;
78790b57cec5SDimitry Andric  bits<9> imm9;
78800b57cec5SDimitry Andric  let Inst{31-22} = 0b1000010110;
78810b57cec5SDimitry Andric  let Inst{21-16} = imm9{8-3};
78820b57cec5SDimitry Andric  let Inst{15-13} = 0b000;
78830b57cec5SDimitry Andric  let Inst{12-10} = imm9{2-0};
78840b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
78850b57cec5SDimitry Andric  let Inst{4}     = 0b0;
78860b57cec5SDimitry Andric  let Inst{3-0}   = Pt;
78870b57cec5SDimitry Andric
788806c3fb27SDimitry Andric  let hasSideEffects = 0;
78890b57cec5SDimitry Andric  let mayLoad = 1;
78900b57cec5SDimitry Andric}
78910b57cec5SDimitry Andric
78920b57cec5SDimitry Andricmulticlass sve_mem_p_fill<string asm> {
78930b57cec5SDimitry Andric  def NAME : sve_mem_p_fill<asm>;
78940b57cec5SDimitry Andric
78950b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Pt, [$Rn]",
7896*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME) PPRorPNRAny:$Pt, GPR64sp:$Rn, 0), 1>;
78970b57cec5SDimitry Andric}
78980b57cec5SDimitry Andric
78990b57cec5SDimitry Andricclass sve2_mem_gldnt_vs_base<bits<5> opc, dag iops, string asm,
79000b57cec5SDimitry Andric                             RegisterOperand VecList>
79010b57cec5SDimitry Andric: I<(outs VecList:$Zt), iops,
79020b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Zn, $Rm]",
79030b57cec5SDimitry Andric  "",
79040b57cec5SDimitry Andric  []>, Sched<[]> {
79050b57cec5SDimitry Andric  bits<3> Pg;
79060b57cec5SDimitry Andric  bits<5> Rm;
79070b57cec5SDimitry Andric  bits<5> Zn;
79080b57cec5SDimitry Andric  bits<5> Zt;
79090b57cec5SDimitry Andric  let Inst{31}    = 0b1;
79100b57cec5SDimitry Andric  let Inst{30}    = opc{4};
79110b57cec5SDimitry Andric  let Inst{29-25} = 0b00010;
79120b57cec5SDimitry Andric  let Inst{24-23} = opc{3-2};
79130b57cec5SDimitry Andric  let Inst{22-21} = 0b00;
79140b57cec5SDimitry Andric  let Inst{20-16} = Rm;
79150b57cec5SDimitry Andric  let Inst{15}    = 0b1;
79160b57cec5SDimitry Andric  let Inst{14-13} = opc{1-0};
79170b57cec5SDimitry Andric  let Inst{12-10} = Pg;
79180b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
79190b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
79200b57cec5SDimitry Andric
792106c3fb27SDimitry Andric  let hasSideEffects = 0;
79220b57cec5SDimitry Andric  let mayLoad = 1;
79230b57cec5SDimitry Andric}
79240b57cec5SDimitry Andric
79255ffd83dbSDimitry Andricmulticlass sve2_mem_gldnt_vs_32_ptrs<bits<5> opc, string asm,
79265ffd83dbSDimitry Andric                                  SDPatternOperator op,
79275ffd83dbSDimitry Andric                                  ValueType vt> {
7928*0fca6ea1SDimitry Andric  def NAME : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), asm, Z_s>;
79290b57cec5SDimitry Andric
79300b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]",
7931*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 0>;
79320b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
7933*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 0>;
79340b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
7935*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 1>;
79365ffd83dbSDimitry Andric
79375ffd83dbSDimitry Andric  def : Pat <(nxv4i32 (op (nxv4i1 PPR3bAny:$Pg), (nxv4i32 ZPR32:$Zd), (i64 GPR64:$Rm), vt)),
7938*0fca6ea1SDimitry Andric             (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR32:$Zd, GPR64:$Rm)>;
79395ffd83dbSDimitry Andric}
79405ffd83dbSDimitry Andric
79415ffd83dbSDimitry Andricmulticlass sve2_mem_gldnt_vs_64_ptrs<bits<5> opc, string asm,
79425ffd83dbSDimitry Andric                                   SDPatternOperator op,
79435ffd83dbSDimitry Andric                                   ValueType vt> {
7944*0fca6ea1SDimitry Andric  def NAME : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), asm, Z_d>;
79455ffd83dbSDimitry Andric
79465ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]",
7947*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 0>;
79485ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
7949*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 0>;
79505ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
7951*0fca6ea1SDimitry Andric                 (!cast<Instruction>(NAME) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
79525ffd83dbSDimitry Andric
79535ffd83dbSDimitry Andric  def : Pat <(nxv2i64 (op (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zd), (i64 GPR64:$Rm), vt)),
7954*0fca6ea1SDimitry Andric             (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zd, GPR64:$Rm)>;
79550b57cec5SDimitry Andric}
79560b57cec5SDimitry Andric
79570b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
79580b57cec5SDimitry Andric// SVE Memory - 64-bit Gather Group
79590b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
79600b57cec5SDimitry Andric
79610b57cec5SDimitry Andric// bit xs      is '1' if offsets are signed
79620b57cec5SDimitry Andric// bit scaled  is '1' if the offsets are scaled
79630b57cec5SDimitry Andric// bit lsl     is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
79640b57cec5SDimitry Andricclass sve_mem_64b_gld_sv<bits<4> opc, bit xs, bit scaled, bit lsl, string asm,
79650b57cec5SDimitry Andric                         RegisterOperand zprext>
79660b57cec5SDimitry Andric: I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
79670b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
79680b57cec5SDimitry Andric  "",
79690b57cec5SDimitry Andric  []>, Sched<[]> {
79700b57cec5SDimitry Andric  bits<3> Pg;
79710b57cec5SDimitry Andric  bits<5> Rn;
79720b57cec5SDimitry Andric  bits<5> Zm;
79730b57cec5SDimitry Andric  bits<5> Zt;
79740b57cec5SDimitry Andric  let Inst{31-25} = 0b1100010;
79750b57cec5SDimitry Andric  let Inst{24-23} = opc{3-2};
79760b57cec5SDimitry Andric  let Inst{22}    = xs;
79770b57cec5SDimitry Andric  let Inst{21}    = scaled;
79780b57cec5SDimitry Andric  let Inst{20-16} = Zm;
79790b57cec5SDimitry Andric  let Inst{15}    = lsl;
79800b57cec5SDimitry Andric  let Inst{14-13} = opc{1-0};
79810b57cec5SDimitry Andric  let Inst{12-10} = Pg;
79820b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
79830b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
79840b57cec5SDimitry Andric
798506c3fb27SDimitry Andric
79860b57cec5SDimitry Andric  let Defs = !if(!eq(opc{0}, 1), [FFR], []);
79870b57cec5SDimitry Andric  let Uses = !if(!eq(opc{0}, 1), [FFR], []);
798806c3fb27SDimitry Andric  let hasSideEffects = opc{0};
798906c3fb27SDimitry Andric  let mayLoad = 1;
79900b57cec5SDimitry Andric}
79910b57cec5SDimitry Andric
79920b57cec5SDimitry Andricmulticlass sve_mem_64b_gld_sv_32_scaled<bits<4> opc, string asm,
7993480093f4SDimitry Andric                                        SDPatternOperator sxtw_op,
7994480093f4SDimitry Andric                                        SDPatternOperator uxtw_op,
79950b57cec5SDimitry Andric                                        RegisterOperand sxtw_opnd,
7996480093f4SDimitry Andric                                        RegisterOperand uxtw_opnd,
7997480093f4SDimitry Andric                                        ValueType vt> {
7998*0fca6ea1SDimitry Andric  def _UXTW_SCALED : sve_mem_64b_gld_sv<opc, 0, 1, 0, asm, uxtw_opnd>;
7999*0fca6ea1SDimitry Andric  def _SXTW_SCALED : sve_mem_64b_gld_sv<opc, 1, 1, 0, asm, sxtw_opnd>;
80000b57cec5SDimitry Andric
80010b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8002*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
80030b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8004*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
80055ffd83dbSDimitry Andric
8006480093f4SDimitry Andric  def : Pat<(nxv2i64 (uxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
80075ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _UXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
8008480093f4SDimitry Andric  def : Pat<(nxv2i64 (sxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
80095ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _SXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
80100b57cec5SDimitry Andric}
80110b57cec5SDimitry Andric
80120b57cec5SDimitry Andricmulticlass sve_mem_64b_gld_vs_32_unscaled<bits<4> opc, string asm,
8013480093f4SDimitry Andric                                          SDPatternOperator sxtw_op,
8014480093f4SDimitry Andric                                          SDPatternOperator uxtw_op,
80150b57cec5SDimitry Andric                                          RegisterOperand sxtw_opnd,
8016480093f4SDimitry Andric                                          RegisterOperand uxtw_opnd,
8017480093f4SDimitry Andric                                          ValueType vt> {
8018*0fca6ea1SDimitry Andric  def _UXTW : sve_mem_64b_gld_sv<opc, 0, 0, 0, asm, uxtw_opnd>;
8019*0fca6ea1SDimitry Andric  def _SXTW : sve_mem_64b_gld_sv<opc, 1, 0, 0, asm, sxtw_opnd>;
80200b57cec5SDimitry Andric
80210b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8022*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _UXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
80230b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8024*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _SXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
80255ffd83dbSDimitry Andric
8026480093f4SDimitry Andric  def : Pat<(nxv2i64 (uxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
80275ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _UXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
8028480093f4SDimitry Andric  def : Pat<(nxv2i64 (sxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
80295ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _SXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
80300b57cec5SDimitry Andric}
80310b57cec5SDimitry Andric
80320b57cec5SDimitry Andricmulticlass sve_mem_64b_gld_sv2_64_scaled<bits<4> opc, string asm,
8033480093f4SDimitry Andric                                         SDPatternOperator op,
8034480093f4SDimitry Andric                                         RegisterOperand zprext, ValueType vt> {
8035*0fca6ea1SDimitry Andric  def _SCALED : sve_mem_64b_gld_sv<opc, 1, 1, 1, asm, zprext>;
80360b57cec5SDimitry Andric
80370b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8038*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
80395ffd83dbSDimitry Andric
8040480093f4SDimitry Andric  def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
80415ffd83dbSDimitry Andric                     (!cast<Instruction>(NAME # _SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
80420b57cec5SDimitry Andric}
80430b57cec5SDimitry Andric
8044480093f4SDimitry Andricmulticlass sve_mem_64b_gld_vs2_64_unscaled<bits<4> opc, string asm,
8045480093f4SDimitry Andric                                           SDPatternOperator op, ValueType vt> {
8046*0fca6ea1SDimitry Andric  def NAME : sve_mem_64b_gld_sv<opc, 1, 0, 1, asm, ZPR64ExtLSL8>;
80470b57cec5SDimitry Andric
80480b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8049*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
80505ffd83dbSDimitry Andric
8051480093f4SDimitry Andric  def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
80525ffd83dbSDimitry Andric            (!cast<Instruction>(NAME) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
80530b57cec5SDimitry Andric}
80540b57cec5SDimitry Andric
80550b57cec5SDimitry Andricclass sve_mem_64b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
80560b57cec5SDimitry Andric: I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
80570b57cec5SDimitry Andric  asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
80580b57cec5SDimitry Andric  "",
80590b57cec5SDimitry Andric  []>, Sched<[]> {
80600b57cec5SDimitry Andric  bits<3> Pg;
80610b57cec5SDimitry Andric  bits<5> Zn;
80620b57cec5SDimitry Andric  bits<5> Zt;
80630b57cec5SDimitry Andric  bits<5> imm5;
80640b57cec5SDimitry Andric  let Inst{31-25} = 0b1100010;
80650b57cec5SDimitry Andric  let Inst{24-23} = opc{3-2};
80660b57cec5SDimitry Andric  let Inst{22-21} = 0b01;
80670b57cec5SDimitry Andric  let Inst{20-16} = imm5;
80680b57cec5SDimitry Andric  let Inst{15}    = 0b1;
80690b57cec5SDimitry Andric  let Inst{14-13} = opc{1-0};
80700b57cec5SDimitry Andric  let Inst{12-10} = Pg;
80710b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
80720b57cec5SDimitry Andric  let Inst{4-0}   = Zt;
80730b57cec5SDimitry Andric
80740b57cec5SDimitry Andric  let Defs = !if(!eq(opc{0}, 1), [FFR], []);
80750b57cec5SDimitry Andric  let Uses = !if(!eq(opc{0}, 1), [FFR], []);
807606c3fb27SDimitry Andric  let hasSideEffects = opc{0};
807706c3fb27SDimitry Andric  let mayLoad = 1;
80780b57cec5SDimitry Andric}
80790b57cec5SDimitry Andric
8080480093f4SDimitry Andricmulticlass sve_mem_64b_gld_vi_64_ptrs<bits<4> opc, string asm, Operand imm_ty,
8081480093f4SDimitry Andric                                      SDPatternOperator op, ValueType vt> {
8082*0fca6ea1SDimitry Andric  def _IMM : sve_mem_64b_gld_vi<opc, asm, imm_ty>;
80830b57cec5SDimitry Andric
80840b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8085*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>;
80860b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
8087*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>;
80880b57cec5SDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8089*0fca6ea1SDimitry Andric                  (!cast<Instruction>(NAME # _IMM) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
80905ffd83dbSDimitry Andric
8091480093f4SDimitry Andric  def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), (nxv2i64 ZPR:$ptrs), imm_ty:$index, vt)),
80925ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _IMM) PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
80930b57cec5SDimitry Andric}
80940b57cec5SDimitry Andric
80950b57cec5SDimitry Andric// bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
80960b57cec5SDimitry Andricclass sve_mem_64b_prfm_sv<bits<2> msz, bit xs, bit lsl, string asm,
80970b57cec5SDimitry Andric                          RegisterOperand zprext>
80980b57cec5SDimitry Andric: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
80990b57cec5SDimitry Andric  asm, "\t$prfop, $Pg, [$Rn, $Zm]",
81000b57cec5SDimitry Andric  "",
81010b57cec5SDimitry Andric  []>, Sched<[]> {
81020b57cec5SDimitry Andric  bits<3> Pg;
81030b57cec5SDimitry Andric  bits<5> Rn;
81040b57cec5SDimitry Andric  bits<5> Zm;
81050b57cec5SDimitry Andric  bits<4> prfop;
81060b57cec5SDimitry Andric  let Inst{31-23} = 0b110001000;
81070b57cec5SDimitry Andric  let Inst{22}    = xs;
81080b57cec5SDimitry Andric  let Inst{21}    = 0b1;
81090b57cec5SDimitry Andric  let Inst{20-16} = Zm;
81100b57cec5SDimitry Andric  let Inst{15}    = lsl;
81110b57cec5SDimitry Andric  let Inst{14-13} = msz;
81120b57cec5SDimitry Andric  let Inst{12-10} = Pg;
81130b57cec5SDimitry Andric  let Inst{9-5}   = Rn;
81140b57cec5SDimitry Andric  let Inst{4}     = 0b0;
81150b57cec5SDimitry Andric  let Inst{3-0}   = prfop;
81160b57cec5SDimitry Andric
81170b57cec5SDimitry Andric  let hasSideEffects = 1;
81180b57cec5SDimitry Andric}
81190b57cec5SDimitry Andric
81200b57cec5SDimitry Andricmulticlass sve_mem_64b_prfm_sv_ext_scaled<bits<2> msz, string asm,
81210b57cec5SDimitry Andric                                          RegisterOperand sxtw_opnd,
81225ffd83dbSDimitry Andric                                          RegisterOperand uxtw_opnd,
8123fe6060f1SDimitry Andric                                          SDPatternOperator op_sxtw,
8124fe6060f1SDimitry Andric                                          SDPatternOperator op_uxtw> {
81250b57cec5SDimitry Andric  def _UXTW_SCALED : sve_mem_64b_prfm_sv<msz, 0, 0, asm, uxtw_opnd>;
81260b57cec5SDimitry Andric  def _SXTW_SCALED : sve_mem_64b_prfm_sv<msz, 1, 0, asm, sxtw_opnd>;
81275ffd83dbSDimitry Andric
81285ffd83dbSDimitry Andric  def : Pat<(op_uxtw (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 uxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
81295ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _UXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
81305ffd83dbSDimitry Andric
81315ffd83dbSDimitry Andric  def : Pat<(op_sxtw (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 sxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
81325ffd83dbSDimitry Andric            (!cast<Instruction>(NAME # _SXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
81335ffd83dbSDimitry Andric
81340b57cec5SDimitry Andric}
81350b57cec5SDimitry Andric
81360b57cec5SDimitry Andricmulticlass sve_mem_64b_prfm_sv_lsl_scaled<bits<2> msz, string asm,
8137fe6060f1SDimitry Andric                                          RegisterOperand zprext, SDPatternOperator frag> {
81380b57cec5SDimitry Andric  def NAME : sve_mem_64b_prfm_sv<msz, 1, 1, asm, zprext>;
81395ffd83dbSDimitry Andric
81405ffd83dbSDimitry Andric  def : Pat<(frag (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 zprext:$Zm), (i32 sve_prfop:$prfop)),
81415ffd83dbSDimitry Andric            (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm)>;
81425ffd83dbSDimitry Andric
81430b57cec5SDimitry Andric}
81440b57cec5SDimitry Andric
81450b57cec5SDimitry Andricclass sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
81460b57cec5SDimitry Andric: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
81470b57cec5SDimitry Andric  asm, "\t$prfop, $Pg, [$Zn, $imm5]",
81480b57cec5SDimitry Andric  "",
81490b57cec5SDimitry Andric  []>, Sched<[]> {
81500b57cec5SDimitry Andric  bits<3> Pg;
81510b57cec5SDimitry Andric  bits<5> Zn;
81520b57cec5SDimitry Andric  bits<5> imm5;
81530b57cec5SDimitry Andric  bits<4> prfop;
81540b57cec5SDimitry Andric  let Inst{31-25} = 0b1100010;
81550b57cec5SDimitry Andric  let Inst{24-23} = msz;
81560b57cec5SDimitry Andric  let Inst{22-21} = 0b00;
81570b57cec5SDimitry Andric  let Inst{20-16} = imm5;
81580b57cec5SDimitry Andric  let Inst{15-13} = 0b111;
81590b57cec5SDimitry Andric  let Inst{12-10} = Pg;
81600b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
81610b57cec5SDimitry Andric  let Inst{4}     = 0b0;
81620b57cec5SDimitry Andric  let Inst{3-0}   = prfop;
81630b57cec5SDimitry Andric
81640b57cec5SDimitry Andric  let hasSideEffects = 1;
81650b57cec5SDimitry Andric}
81660b57cec5SDimitry Andric
81675ffd83dbSDimitry Andricmulticlass sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty, SDPatternOperator op> {
81680b57cec5SDimitry Andric  def NAME : sve_mem_64b_prfm_vi<msz, asm, imm_ty>;
81690b57cec5SDimitry Andric
81700b57cec5SDimitry Andric  def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
81710b57cec5SDimitry Andric                  (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
81720b57cec5SDimitry Andric
81735ffd83dbSDimitry Andric  def : Pat<(op (nxv2i1 PPR_3b:$Pg), (nxv2i64 ZPR32:$Zn), (i64 imm_ty:$imm), (i32 sve_prfop:$prfop)),
81745ffd83dbSDimitry Andric            (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR_3b:$Pg, ZPR32:$Zn, imm_ty:$imm)>;
81755ffd83dbSDimitry Andric}
81760b57cec5SDimitry Andric
81770b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
81780b57cec5SDimitry Andric// SVE Compute Vector Address Group
81790b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
81800b57cec5SDimitry Andric
81810b57cec5SDimitry Andricclass sve_int_bin_cons_misc_0_a<bits<2> opc, bits<2> msz, string asm,
81820b57cec5SDimitry Andric                                ZPRRegOp zprty, RegisterOperand zprext>
81830b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, zprext:$Zm),
81840b57cec5SDimitry Andric  asm, "\t$Zd, [$Zn, $Zm]",
81850b57cec5SDimitry Andric  "",
81860b57cec5SDimitry Andric  []>, Sched<[]> {
81870b57cec5SDimitry Andric  bits<5> Zd;
81880b57cec5SDimitry Andric  bits<5> Zn;
81890b57cec5SDimitry Andric  bits<5> Zm;
81900b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
81910b57cec5SDimitry Andric  let Inst{23-22} = opc;
81920b57cec5SDimitry Andric  let Inst{21}    = 0b1;
81930b57cec5SDimitry Andric  let Inst{20-16} = Zm;
81940b57cec5SDimitry Andric  let Inst{15-12} = 0b1010;
81950b57cec5SDimitry Andric  let Inst{11-10} = msz;
81960b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
81970b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
819806c3fb27SDimitry Andric
819906c3fb27SDimitry Andric  let hasSideEffects = 0;
82000b57cec5SDimitry Andric}
82010b57cec5SDimitry Andric
82020b57cec5SDimitry Andricmulticlass sve_int_bin_cons_misc_0_a_uxtw<bits<2> opc, string asm> {
82030b57cec5SDimitry Andric  def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtUXTW8>;
82040b57cec5SDimitry Andric  def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtUXTW16>;
82050b57cec5SDimitry Andric  def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtUXTW32>;
82060b57cec5SDimitry Andric  def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtUXTW64>;
82070b57cec5SDimitry Andric}
82080b57cec5SDimitry Andric
82090b57cec5SDimitry Andricmulticlass sve_int_bin_cons_misc_0_a_sxtw<bits<2> opc, string asm> {
82100b57cec5SDimitry Andric  def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtSXTW8>;
82110b57cec5SDimitry Andric  def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtSXTW16>;
82120b57cec5SDimitry Andric  def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtSXTW32>;
82130b57cec5SDimitry Andric  def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtSXTW64>;
82140b57cec5SDimitry Andric}
82150b57cec5SDimitry Andric
82160b57cec5SDimitry Andricmulticlass sve_int_bin_cons_misc_0_a_32_lsl<bits<2> opc, string asm> {
82170b57cec5SDimitry Andric  def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR32, ZPR32ExtLSL8>;
82180b57cec5SDimitry Andric  def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR32, ZPR32ExtLSL16>;
82190b57cec5SDimitry Andric  def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR32, ZPR32ExtLSL32>;
82200b57cec5SDimitry Andric  def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR32, ZPR32ExtLSL64>;
82210b57cec5SDimitry Andric}
82220b57cec5SDimitry Andric
82230b57cec5SDimitry Andricmulticlass sve_int_bin_cons_misc_0_a_64_lsl<bits<2> opc, string asm> {
82240b57cec5SDimitry Andric  def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtLSL8>;
82250b57cec5SDimitry Andric  def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtLSL16>;
82260b57cec5SDimitry Andric  def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtLSL32>;
82270b57cec5SDimitry Andric  def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtLSL64>;
82280b57cec5SDimitry Andric}
82290b57cec5SDimitry Andric
82300b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
82310b57cec5SDimitry Andric// SVE Integer Misc - Unpredicated Group
82320b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
82330b57cec5SDimitry Andric
82340b57cec5SDimitry Andricclass sve_int_bin_cons_misc_0_b<bits<2> sz, string asm, ZPRRegOp zprty>
82350b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
82360b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
82370b57cec5SDimitry Andric  "",
82380b57cec5SDimitry Andric  []>, Sched<[]> {
82390b57cec5SDimitry Andric  bits<5> Zd;
82400b57cec5SDimitry Andric  bits<5> Zm;
82410b57cec5SDimitry Andric  bits<5> Zn;
82420b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
82430b57cec5SDimitry Andric  let Inst{23-22} = sz;
82440b57cec5SDimitry Andric  let Inst{21}    = 0b1;
82450b57cec5SDimitry Andric  let Inst{20-16} = Zm;
82460b57cec5SDimitry Andric  let Inst{15-10} = 0b101100;
82470b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
82480b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
824906c3fb27SDimitry Andric
825006c3fb27SDimitry Andric  let hasSideEffects = 0;
82510b57cec5SDimitry Andric}
82520b57cec5SDimitry Andric
8253480093f4SDimitry Andricmulticlass sve_int_bin_cons_misc_0_b<string asm, SDPatternOperator op> {
82540b57cec5SDimitry Andric  def _H : sve_int_bin_cons_misc_0_b<0b01, asm, ZPR16>;
82550b57cec5SDimitry Andric  def _S : sve_int_bin_cons_misc_0_b<0b10, asm, ZPR32>;
82560b57cec5SDimitry Andric  def _D : sve_int_bin_cons_misc_0_b<0b11, asm, ZPR64>;
8257480093f4SDimitry Andric
8258480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
8259480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
8260480093f4SDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
82610b57cec5SDimitry Andric}
82620b57cec5SDimitry Andric
82630b57cec5SDimitry Andricclass sve_int_bin_cons_misc_0_c<bits<8> opc, string asm, ZPRRegOp zprty>
82640b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn),
82650b57cec5SDimitry Andric  asm, "\t$Zd, $Zn",
82660b57cec5SDimitry Andric  "",
82670b57cec5SDimitry Andric  []>, Sched<[]> {
82680b57cec5SDimitry Andric  bits<5> Zd;
82690b57cec5SDimitry Andric  bits<5> Zn;
82700b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
82710b57cec5SDimitry Andric  let Inst{23-22} = opc{7-6};
82720b57cec5SDimitry Andric  let Inst{21}    = 0b1;
82730b57cec5SDimitry Andric  let Inst{20-16} = opc{5-1};
82740b57cec5SDimitry Andric  let Inst{15-11} = 0b10111;
82750b57cec5SDimitry Andric  let Inst{10}    = opc{0};
82760b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
82770b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
8278bdd1243dSDimitry Andric
8279bdd1243dSDimitry Andric  let hasSideEffects = 0;
82800b57cec5SDimitry Andric}
82810b57cec5SDimitry Andric
8282480093f4SDimitry Andricmulticlass sve_int_bin_cons_misc_0_c_fexpa<string asm, SDPatternOperator op> {
8283480093f4SDimitry Andric  def _H : sve_int_bin_cons_misc_0_c<0b01000000, asm, ZPR16>;
8284480093f4SDimitry Andric  def _S : sve_int_bin_cons_misc_0_c<0b10000000, asm, ZPR32>;
8285480093f4SDimitry Andric  def _D : sve_int_bin_cons_misc_0_c<0b11000000, asm, ZPR64>;
8286480093f4SDimitry Andric
8287480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv8f16, op, nxv8i16, !cast<Instruction>(NAME # _H)>;
8288480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv4f32, op, nxv4i32, !cast<Instruction>(NAME # _S)>;
8289480093f4SDimitry Andric  def : SVE_1_Op_Pat<nxv2f64, op, nxv2i64, !cast<Instruction>(NAME # _D)>;
8290480093f4SDimitry Andric}
8291480093f4SDimitry Andric
82920b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
82930b57cec5SDimitry Andric// SVE Integer Reduction Group
82940b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
82950b57cec5SDimitry Andric
82960b57cec5SDimitry Andricclass sve_int_reduce<bits<2> sz8_32, bits<2> fmt, bits<3> opc, string asm,
8297e8d8bef9SDimitry Andric                     ZPRRegOp zprty, FPRasZPROperand dstOpType>
8298e8d8bef9SDimitry Andric: I<(outs dstOpType:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
82990b57cec5SDimitry Andric  asm, "\t$Vd, $Pg, $Zn",
83000b57cec5SDimitry Andric  "",
83010b57cec5SDimitry Andric  []>, Sched<[]> {
83020b57cec5SDimitry Andric  bits<3> Pg;
83030b57cec5SDimitry Andric  bits<5> Vd;
83040b57cec5SDimitry Andric  bits<5> Zn;
83050b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
83060b57cec5SDimitry Andric  let Inst{23-22} = sz8_32;
83070b57cec5SDimitry Andric  let Inst{21}    = 0b0;
83080b57cec5SDimitry Andric  let Inst{20-19} = fmt;
83090b57cec5SDimitry Andric  let Inst{18-16} = opc;
83100b57cec5SDimitry Andric  let Inst{15-13} = 0b001;
83110b57cec5SDimitry Andric  let Inst{12-10} = Pg;
83120b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
83130b57cec5SDimitry Andric  let Inst{4-0}   = Vd;
831406c3fb27SDimitry Andric
831506c3fb27SDimitry Andric  let hasSideEffects = 0;
83160b57cec5SDimitry Andric}
83170b57cec5SDimitry Andric
8318e8d8bef9SDimitry Andricmulticlass sve_int_reduce_0_saddv<bits<3> opc, string asm,
8319e8d8bef9SDimitry Andric                                  SDPatternOperator op> {
8320e8d8bef9SDimitry Andric  def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64asZPR>;
8321e8d8bef9SDimitry Andric  def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64asZPR>;
8322e8d8bef9SDimitry Andric  def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64asZPR>;
8323480093f4SDimitry Andric
8324e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
8325e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
8326e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
83270b57cec5SDimitry Andric}
83280b57cec5SDimitry Andric
8329e8d8bef9SDimitry Andricmulticlass sve_int_reduce_0_uaddv<bits<3> opc, string asm,
8330e8d8bef9SDimitry Andric                                  SDPatternOperator op> {
8331e8d8bef9SDimitry Andric  def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64asZPR>;
8332e8d8bef9SDimitry Andric  def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64asZPR>;
8333e8d8bef9SDimitry Andric  def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64asZPR>;
8334e8d8bef9SDimitry Andric  def _D : sve_int_reduce<0b11, 0b00, opc, asm, ZPR64, FPR64asZPR>;
8335480093f4SDimitry Andric
8336e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
8337e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
8338e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
8339e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
83400b57cec5SDimitry Andric}
83410b57cec5SDimitry Andric
8342e8d8bef9SDimitry Andricmulticlass sve_int_reduce_1<bits<3> opc, string asm,
8343e8d8bef9SDimitry Andric                            SDPatternOperator op> {
8344e8d8bef9SDimitry Andric  def _B : sve_int_reduce<0b00, 0b01, opc, asm, ZPR8, FPR8asZPR>;
8345e8d8bef9SDimitry Andric  def _H : sve_int_reduce<0b01, 0b01, opc, asm, ZPR16, FPR16asZPR>;
8346e8d8bef9SDimitry Andric  def _S : sve_int_reduce<0b10, 0b01, opc, asm, ZPR32, FPR32asZPR>;
8347e8d8bef9SDimitry Andric  def _D : sve_int_reduce<0b11, 0b01, opc, asm, ZPR64, FPR64asZPR>;
8348480093f4SDimitry Andric
8349e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
8350e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
8351e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
8352e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
83530b57cec5SDimitry Andric}
83540b57cec5SDimitry Andric
8355e8d8bef9SDimitry Andricmulticlass sve_int_reduce_2<bits<3> opc, string asm,
8356e8d8bef9SDimitry Andric                            SDPatternOperator op> {
8357e8d8bef9SDimitry Andric  def _B : sve_int_reduce<0b00, 0b11, opc, asm, ZPR8, FPR8asZPR>;
8358e8d8bef9SDimitry Andric  def _H : sve_int_reduce<0b01, 0b11, opc, asm, ZPR16, FPR16asZPR>;
8359e8d8bef9SDimitry Andric  def _S : sve_int_reduce<0b10, 0b11, opc, asm, ZPR32, FPR32asZPR>;
8360e8d8bef9SDimitry Andric  def _D : sve_int_reduce<0b11, 0b11, opc, asm, ZPR64, FPR64asZPR>;
8361480093f4SDimitry Andric
8362e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
8363e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
8364e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
8365e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
83660b57cec5SDimitry Andric}
83670b57cec5SDimitry Andric
83680b57cec5SDimitry Andricclass sve_int_movprfx_pred<bits<2> sz8_32, bits<3> opc, string asm,
83690b57cec5SDimitry Andric                           ZPRRegOp zprty, string pg_suffix, dag iops>
83700b57cec5SDimitry Andric: I<(outs zprty:$Zd), iops,
83710b57cec5SDimitry Andric  asm, "\t$Zd, $Pg"#pg_suffix#", $Zn",
83720b57cec5SDimitry Andric  "",
83730b57cec5SDimitry Andric  []>, Sched<[]> {
83740b57cec5SDimitry Andric  bits<3> Pg;
83750b57cec5SDimitry Andric  bits<5> Zd;
83760b57cec5SDimitry Andric  bits<5> Zn;
83770b57cec5SDimitry Andric  let Inst{31-24} = 0b00000100;
83780b57cec5SDimitry Andric  let Inst{23-22} = sz8_32;
83790b57cec5SDimitry Andric  let Inst{21-19} = 0b010;
83800b57cec5SDimitry Andric  let Inst{18-16} = opc;
83810b57cec5SDimitry Andric  let Inst{15-13} = 0b001;
83820b57cec5SDimitry Andric  let Inst{12-10} = Pg;
83830b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
83840b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
83850b57cec5SDimitry Andric
83860b57cec5SDimitry Andric  let ElementSize = zprty.ElementSize;
838706c3fb27SDimitry Andric  let hasSideEffects = 0;
83880b57cec5SDimitry Andric}
83890b57cec5SDimitry Andric
83900b57cec5SDimitry Andricmulticlass sve_int_movprfx_pred_merge<bits<3> opc, string asm> {
83910b57cec5SDimitry Andriclet Constraints = "$Zd = $_Zd" in {
83920b57cec5SDimitry Andric  def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/m",
83930b57cec5SDimitry Andric                                (ins ZPR8:$_Zd, PPR3bAny:$Pg, ZPR8:$Zn)>;
83940b57cec5SDimitry Andric  def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/m",
83950b57cec5SDimitry Andric                                (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR16:$Zn)>;
83960b57cec5SDimitry Andric  def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/m",
83970b57cec5SDimitry Andric                                (ins ZPR32:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn)>;
83980b57cec5SDimitry Andric  def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/m",
83990b57cec5SDimitry Andric                                (ins ZPR64:$_Zd, PPR3bAny:$Pg, ZPR64:$Zn)>;
84000b57cec5SDimitry Andric}
84010b57cec5SDimitry Andric}
84020b57cec5SDimitry Andric
84030b57cec5SDimitry Andricmulticlass sve_int_movprfx_pred_zero<bits<3> opc, string asm> {
84040b57cec5SDimitry Andric  def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/z",
84050b57cec5SDimitry Andric                                (ins PPR3bAny:$Pg, ZPR8:$Zn)>;
84060b57cec5SDimitry Andric  def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/z",
84070b57cec5SDimitry Andric                                (ins PPR3bAny:$Pg, ZPR16:$Zn)>;
84080b57cec5SDimitry Andric  def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/z",
84090b57cec5SDimitry Andric                                (ins PPR3bAny:$Pg, ZPR32:$Zn)>;
84100b57cec5SDimitry Andric  def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/z",
84110b57cec5SDimitry Andric                                (ins PPR3bAny:$Pg, ZPR64:$Zn)>;
84120b57cec5SDimitry Andric}
84130b57cec5SDimitry Andric
84140b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
84150b57cec5SDimitry Andric// SVE Propagate Break Group
84160b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
84170b57cec5SDimitry Andric
84180b57cec5SDimitry Andricclass sve_int_brkp<bits<2> opc, string asm>
84190b57cec5SDimitry Andric: I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm),
84200b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z, $Pn, $Pm",
84210b57cec5SDimitry Andric  "",
84220b57cec5SDimitry Andric  []>, Sched<[]> {
84230b57cec5SDimitry Andric  bits<4> Pd;
84240b57cec5SDimitry Andric  bits<4> Pg;
84250b57cec5SDimitry Andric  bits<4> Pm;
84260b57cec5SDimitry Andric  bits<4> Pn;
84270b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
84280b57cec5SDimitry Andric  let Inst{23}    = 0b0;
84290b57cec5SDimitry Andric  let Inst{22}    = opc{1};
84300b57cec5SDimitry Andric  let Inst{21-20} = 0b00;
84310b57cec5SDimitry Andric  let Inst{19-16} = Pm;
84320b57cec5SDimitry Andric  let Inst{15-14} = 0b11;
84330b57cec5SDimitry Andric  let Inst{13-10} = Pg;
84340b57cec5SDimitry Andric  let Inst{9}     = 0b0;
84350b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
84360b57cec5SDimitry Andric  let Inst{4}     = opc{0};
84370b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
84380b57cec5SDimitry Andric
84390b57cec5SDimitry Andric  let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
844006c3fb27SDimitry Andric  let hasSideEffects = 0;
84410b57cec5SDimitry Andric}
84420b57cec5SDimitry Andric
84435ffd83dbSDimitry Andricmulticlass sve_int_brkp<bits<2> opc, string asm, SDPatternOperator op> {
84445ffd83dbSDimitry Andric  def NAME : sve_int_brkp<opc, asm>;
84455ffd83dbSDimitry Andric
84465ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
84475ffd83dbSDimitry Andric}
84485ffd83dbSDimitry Andric
84490b57cec5SDimitry Andric
84500b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
84510b57cec5SDimitry Andric// SVE Partition Break Group
84520b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
84530b57cec5SDimitry Andric
84540b57cec5SDimitry Andricclass sve_int_brkn<bit S, string asm>
84550b57cec5SDimitry Andric: I<(outs PPR8:$Pdm), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$_Pdm),
84560b57cec5SDimitry Andric  asm, "\t$Pdm, $Pg/z, $Pn, $_Pdm",
84570b57cec5SDimitry Andric  "",
84580b57cec5SDimitry Andric  []>, Sched<[]> {
84590b57cec5SDimitry Andric  bits<4> Pdm;
84600b57cec5SDimitry Andric  bits<4> Pg;
84610b57cec5SDimitry Andric  bits<4> Pn;
84620b57cec5SDimitry Andric  let Inst{31-23} = 0b001001010;
84630b57cec5SDimitry Andric  let Inst{22}    = S;
84640b57cec5SDimitry Andric  let Inst{21-14} = 0b01100001;
84650b57cec5SDimitry Andric  let Inst{13-10} = Pg;
84660b57cec5SDimitry Andric  let Inst{9}     = 0b0;
84670b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
84680b57cec5SDimitry Andric  let Inst{4}     = 0b0;
84690b57cec5SDimitry Andric  let Inst{3-0}   = Pdm;
84700b57cec5SDimitry Andric
84710b57cec5SDimitry Andric  let Constraints = "$Pdm = $_Pdm";
8472e8d8bef9SDimitry Andric  let Defs = !if(S, [NZCV], []);
8473bdd1243dSDimitry Andric  let ElementSize = ElementSizeB;
847406c3fb27SDimitry Andric  let hasSideEffects = 0;
84750b57cec5SDimitry Andric}
84760b57cec5SDimitry Andric
84775ffd83dbSDimitry Andricmulticlass sve_int_brkn<bits<1> opc, string asm, SDPatternOperator op> {
84785ffd83dbSDimitry Andric  def NAME : sve_int_brkn<opc, asm>;
84795ffd83dbSDimitry Andric
84805ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
84815ffd83dbSDimitry Andric}
84825ffd83dbSDimitry Andric
84830b57cec5SDimitry Andricclass sve_int_break<bits<3> opc, string asm, string suffix, dag iops>
84840b57cec5SDimitry Andric: I<(outs PPR8:$Pd), iops,
84850b57cec5SDimitry Andric  asm, "\t$Pd, $Pg"#suffix#", $Pn",
84860b57cec5SDimitry Andric  "",
84870b57cec5SDimitry Andric  []>, Sched<[]> {
84880b57cec5SDimitry Andric  bits<4> Pd;
84890b57cec5SDimitry Andric  bits<4> Pg;
84900b57cec5SDimitry Andric  bits<4> Pn;
84910b57cec5SDimitry Andric  let Inst{31-24} = 0b00100101;
84920b57cec5SDimitry Andric  let Inst{23-22} = opc{2-1};
84930b57cec5SDimitry Andric  let Inst{21-14} = 0b01000001;
84940b57cec5SDimitry Andric  let Inst{13-10} = Pg;
84950b57cec5SDimitry Andric  let Inst{9}     = 0b0;
84960b57cec5SDimitry Andric  let Inst{8-5}   = Pn;
84970b57cec5SDimitry Andric  let Inst{4}     = opc{0};
84980b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
84990b57cec5SDimitry Andric
85000b57cec5SDimitry Andric  let Constraints = !if(!eq (opc{0}, 1), "$Pd = $_Pd", "");
85010b57cec5SDimitry Andric  let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
850206c3fb27SDimitry Andric  let hasSideEffects = 0;
85030b57cec5SDimitry Andric}
85040b57cec5SDimitry Andric
85055ffd83dbSDimitry Andricmulticlass sve_int_break_m<bits<3> opc, string asm, SDPatternOperator op> {
85060b57cec5SDimitry Andric  def NAME : sve_int_break<opc, asm, "/m", (ins PPR8:$_Pd, PPRAny:$Pg, PPR8:$Pn)>;
85075ffd83dbSDimitry Andric
85085ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
85090b57cec5SDimitry Andric}
85100b57cec5SDimitry Andric
85115ffd83dbSDimitry Andricmulticlass sve_int_break_z<bits<3> opc, string asm, SDPatternOperator op> {
85120b57cec5SDimitry Andric  def NAME : sve_int_break<opc, asm, "/z", (ins PPRAny:$Pg, PPR8:$Pn)>;
85135ffd83dbSDimitry Andric
85145ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
85150b57cec5SDimitry Andric}
85160b57cec5SDimitry Andric
85170b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
85180b57cec5SDimitry Andric// SVE2 String Processing Group
85190b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
85200b57cec5SDimitry Andric
85210b57cec5SDimitry Andricclass sve2_char_match<bit sz, bit opc, string asm,
85220b57cec5SDimitry Andric                      PPRRegOp pprty, ZPRRegOp zprty>
85230b57cec5SDimitry Andric: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
85240b57cec5SDimitry Andric  asm, "\t$Pd, $Pg/z, $Zn, $Zm",
85250b57cec5SDimitry Andric  "",
85260b57cec5SDimitry Andric  []>, Sched<[]> {
85270b57cec5SDimitry Andric  bits<4> Pd;
85280b57cec5SDimitry Andric  bits<3> Pg;
85290b57cec5SDimitry Andric  bits<5> Zm;
85300b57cec5SDimitry Andric  bits<5> Zn;
85310b57cec5SDimitry Andric  let Inst{31-23} = 0b010001010;
85320b57cec5SDimitry Andric  let Inst{22}    = sz;
85330b57cec5SDimitry Andric  let Inst{21}    = 0b1;
85340b57cec5SDimitry Andric  let Inst{20-16} = Zm;
85350b57cec5SDimitry Andric  let Inst{15-13} = 0b100;
85360b57cec5SDimitry Andric  let Inst{12-10} = Pg;
85370b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
85380b57cec5SDimitry Andric  let Inst{4}     = opc;
85390b57cec5SDimitry Andric  let Inst{3-0}   = Pd;
85400b57cec5SDimitry Andric
85410b57cec5SDimitry Andric  let Defs = [NZCV];
8542bdd1243dSDimitry Andric  let ElementSize = pprty.ElementSize;
854306c3fb27SDimitry Andric  let hasSideEffects = 0;
8544fe6060f1SDimitry Andric  let isPTestLike = 1;
85450b57cec5SDimitry Andric}
85460b57cec5SDimitry Andric
85475ffd83dbSDimitry Andricmulticlass sve2_char_match<bit opc, string asm, SDPatternOperator op> {
85480b57cec5SDimitry Andric  def _B : sve2_char_match<0b0, opc, asm, PPR8, ZPR8>;
85490b57cec5SDimitry Andric  def _H : sve2_char_match<0b1, opc, asm, PPR16, ZPR16>;
85505ffd83dbSDimitry Andric
85515ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
85525ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8i1,  op, nxv8i1,  nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
85530b57cec5SDimitry Andric}
85540b57cec5SDimitry Andric
85550b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
85560b57cec5SDimitry Andric// SVE2 Histogram Computation - Segment Group
85570b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
85580b57cec5SDimitry Andric
85595ffd83dbSDimitry Andricclass sve2_hist_gen_segment<string asm, SDPatternOperator op>
85600b57cec5SDimitry Andric: I<(outs ZPR8:$Zd), (ins ZPR8:$Zn, ZPR8:$Zm),
85610b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
85620b57cec5SDimitry Andric  "",
85635ffd83dbSDimitry Andric  [(set nxv16i8:$Zd, (op nxv16i8:$Zn, nxv16i8:$Zm))]>, Sched<[]> {
85640b57cec5SDimitry Andric  bits<5> Zd;
85650b57cec5SDimitry Andric  bits<5> Zn;
85660b57cec5SDimitry Andric  bits<5> Zm;
85670b57cec5SDimitry Andric  let Inst{31-21} = 0b01000101001;
85680b57cec5SDimitry Andric  let Inst{20-16} = Zm;
85690b57cec5SDimitry Andric  let Inst{15-10} = 0b101000;
85700b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
85710b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
857206c3fb27SDimitry Andric
857306c3fb27SDimitry Andric  let hasSideEffects = 0;
85740b57cec5SDimitry Andric}
85750b57cec5SDimitry Andric
85760b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
85770b57cec5SDimitry Andric// SVE2 Histogram Computation - Vector Group
85780b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
85790b57cec5SDimitry Andric
85800b57cec5SDimitry Andricclass sve2_hist_gen_vector<bit sz, string asm, ZPRRegOp zprty>
85810b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
85820b57cec5SDimitry Andric  asm, "\t$Zd, $Pg/z, $Zn, $Zm",
85830b57cec5SDimitry Andric  "",
85840b57cec5SDimitry Andric  []>, Sched<[]> {
85850b57cec5SDimitry Andric  bits<5> Zd;
85860b57cec5SDimitry Andric  bits<5> Zn;
85870b57cec5SDimitry Andric  bits<3> Pg;
85880b57cec5SDimitry Andric  bits<5> Zm;
85890b57cec5SDimitry Andric  let Inst{31-23} = 0b010001011;
85900b57cec5SDimitry Andric  let Inst{22}    = sz;
85910b57cec5SDimitry Andric  let Inst{21}    = 0b1;
85920b57cec5SDimitry Andric  let Inst{20-16} = Zm;
85930b57cec5SDimitry Andric  let Inst{15-13} = 0b110;
85940b57cec5SDimitry Andric  let Inst{12-10} = Pg;
85950b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
85960b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
859706c3fb27SDimitry Andric
859806c3fb27SDimitry Andric  let hasSideEffects = 0;
85990b57cec5SDimitry Andric}
86000b57cec5SDimitry Andric
86015ffd83dbSDimitry Andricmulticlass sve2_hist_gen_vector<string asm, SDPatternOperator op> {
86020b57cec5SDimitry Andric  def _S : sve2_hist_gen_vector<0b0, asm, ZPR32>;
86030b57cec5SDimitry Andric  def _D : sve2_hist_gen_vector<0b1, asm, ZPR64>;
86045ffd83dbSDimitry Andric
86055ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
86065ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
86070b57cec5SDimitry Andric}
86080b57cec5SDimitry Andric
86090b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
86100b57cec5SDimitry Andric// SVE2 Crypto Extensions Group
86110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
86120b57cec5SDimitry Andric
86130b57cec5SDimitry Andricclass sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty>
86140b57cec5SDimitry Andric: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
86150b57cec5SDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
86160b57cec5SDimitry Andric  "",
86170b57cec5SDimitry Andric  []>, Sched<[]> {
86180b57cec5SDimitry Andric  bits<5> Zd;
86190b57cec5SDimitry Andric  bits<5> Zn;
86200b57cec5SDimitry Andric  bits<5> Zm;
86210b57cec5SDimitry Andric  let Inst{31-21} = 0b01000101001;
86220b57cec5SDimitry Andric  let Inst{20-16} = Zm;
86230b57cec5SDimitry Andric  let Inst{15-11} = 0b11110;
86240b57cec5SDimitry Andric  let Inst{10}    = opc;
86250b57cec5SDimitry Andric  let Inst{9-5}   = Zn;
86260b57cec5SDimitry Andric  let Inst{4-0}   = Zd;
862706c3fb27SDimitry Andric
862806c3fb27SDimitry Andric  let hasSideEffects = 0;
86290b57cec5SDimitry Andric}
86300b57cec5SDimitry Andric
86315ffd83dbSDimitry Andricmulticlass sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty,
86325ffd83dbSDimitry Andric                                   SDPatternOperator op, ValueType vt> {
86335ffd83dbSDimitry Andric  def NAME : sve2_crypto_cons_bin_op<opc, asm, zprty>;
86345ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<vt, op, vt, vt, !cast<Instruction>(NAME)>;
86355ffd83dbSDimitry Andric}
86365ffd83dbSDimitry Andric
86370b57cec5SDimitry Andricclass sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty>
86380b57cec5SDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm),
86390b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn, $Zm",
86400b57cec5SDimitry Andric  "",
86410b57cec5SDimitry Andric  []>, Sched<[]> {
86420b57cec5SDimitry Andric  bits<5> Zdn;
86430b57cec5SDimitry Andric  bits<5> Zm;
86440b57cec5SDimitry Andric  let Inst{31-17} = 0b010001010010001;
86450b57cec5SDimitry Andric  let Inst{16}    = opc{1};
86460b57cec5SDimitry Andric  let Inst{15-11} = 0b11100;
86470b57cec5SDimitry Andric  let Inst{10}    = opc{0};
86480b57cec5SDimitry Andric  let Inst{9-5}   = Zm;
86490b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
86500b57cec5SDimitry Andric
86510b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
865206c3fb27SDimitry Andric  let hasSideEffects = 0;
86530b57cec5SDimitry Andric}
86540b57cec5SDimitry Andric
86555ffd83dbSDimitry Andricmulticlass sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty,
86565ffd83dbSDimitry Andric                                  SDPatternOperator op, ValueType vt> {
86575ffd83dbSDimitry Andric  def NAME : sve2_crypto_des_bin_op<opc, asm, zprty>;
86585ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<vt, op, vt, vt, !cast<Instruction>(NAME)>;
86595ffd83dbSDimitry Andric}
86605ffd83dbSDimitry Andric
86615ffd83dbSDimitry Andricclass sve2_crypto_unary_op<bit opc, string asm, ZPRRegOp zprty>
86625ffd83dbSDimitry Andric: I<(outs zprty:$Zdn), (ins zprty:$_Zdn),
86630b57cec5SDimitry Andric  asm, "\t$Zdn, $_Zdn",
86640b57cec5SDimitry Andric  "",
86650b57cec5SDimitry Andric  []>, Sched<[]> {
86660b57cec5SDimitry Andric  bits<5> Zdn;
86670b57cec5SDimitry Andric  let Inst{31-11} = 0b010001010010000011100;
86680b57cec5SDimitry Andric  let Inst{10}    = opc;
86690b57cec5SDimitry Andric  let Inst{9-5}   = 0b00000;
86700b57cec5SDimitry Andric  let Inst{4-0}   = Zdn;
86710b57cec5SDimitry Andric
86720b57cec5SDimitry Andric  let Constraints = "$Zdn = $_Zdn";
867306c3fb27SDimitry Andric  let hasSideEffects = 0;
86740b57cec5SDimitry Andric}
86755ffd83dbSDimitry Andric
86765ffd83dbSDimitry Andricmulticlass sve2_crypto_unary_op<bit opc, string asm, SDPatternOperator op> {
86775ffd83dbSDimitry Andric  def NAME : sve2_crypto_unary_op<opc, asm, ZPR8>;
86785ffd83dbSDimitry Andric  def : SVE_1_Op_Pat<nxv16i8, op, nxv16i8, !cast<Instruction>(NAME)>;
86795ffd83dbSDimitry Andric}
86805ffd83dbSDimitry Andric
86815ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
86825ffd83dbSDimitry Andric// SVE BFloat16 Group
86835ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
86845ffd83dbSDimitry Andric
86855f757f3fSDimitry Andricclass sve_float_dot<bit bf, bit o2, ZPRRegOp dst_ty, ZPRRegOp src_ty, string asm>
86865f757f3fSDimitry Andric: I<(outs dst_ty:$Zda), (ins dst_ty:$_Zda, src_ty:$Zn, src_ty:$Zm),
8687bdd1243dSDimitry Andric     asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
86885ffd83dbSDimitry Andric  bits<5> Zda;
86895ffd83dbSDimitry Andric  bits<5> Zn;
8690bdd1243dSDimitry Andric  bits<5> Zm;
8691bdd1243dSDimitry Andric  let Inst{31-23} = 0b011001000;
8692bdd1243dSDimitry Andric  let Inst{22}    = bf;
8693bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
8694bdd1243dSDimitry Andric  let Inst{20-16} = Zm;
86955f757f3fSDimitry Andric  let Inst{15-11} = 0b10000;
86965f757f3fSDimitry Andric  let Inst{10}    = o2;
86975ffd83dbSDimitry Andric  let Inst{9-5}   = Zn;
86985ffd83dbSDimitry Andric  let Inst{4-0}   = Zda;
86995ffd83dbSDimitry Andric
87005ffd83dbSDimitry Andric  let Constraints = "$Zda = $_Zda";
87015ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
870206c3fb27SDimitry Andric  let hasSideEffects = 0;
870306c3fb27SDimitry Andric  let mayRaiseFPException = 1;
87045ffd83dbSDimitry Andric}
87055ffd83dbSDimitry Andric
87065f757f3fSDimitry Andricmulticlass sve_float_dot<bit bf, bit o2, ZPRRegOp dst_ty, ZPRRegOp src_ty,
87075f757f3fSDimitry Andric                         string asm, ValueType InVT, SDPatternOperator op> {
87085f757f3fSDimitry Andric  def NAME : sve_float_dot<bf, o2, dst_ty, src_ty, asm>;
8709bdd1243dSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, InVT, InVT, !cast<Instruction>(NAME)>;
87105ffd83dbSDimitry Andric}
87115ffd83dbSDimitry Andric
87125f757f3fSDimitry Andricclass sve_float_dot_indexed<bit bf, ZPRRegOp dst_ty, ZPRRegOp src1_ty,
87135f757f3fSDimitry Andric                            ZPRRegOp src2_ty, Operand iop_ty, string asm>
87145f757f3fSDimitry Andric: I<(outs dst_ty:$Zda), (ins dst_ty:$_Zda, src1_ty:$Zn, src2_ty:$Zm, iop_ty:$iop),
8715bdd1243dSDimitry Andric    asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
8716bdd1243dSDimitry Andric  bits<5> Zda;
8717bdd1243dSDimitry Andric  bits<5> Zn;
87185ffd83dbSDimitry Andric  bits<3> Zm;
8719bdd1243dSDimitry Andric  let Inst{31-23} = 0b011001000;
8720bdd1243dSDimitry Andric  let Inst{22}    = bf;
8721bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
87225ffd83dbSDimitry Andric  let Inst{18-16} = Zm;
87235f757f3fSDimitry Andric  let Inst{15-12} = 0b0100;
8724bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
8725bdd1243dSDimitry Andric  let Inst{4-0}   = Zda;
8726bdd1243dSDimitry Andric
8727bdd1243dSDimitry Andric  let Constraints = "$Zda = $_Zda";
8728bdd1243dSDimitry Andric  let DestructiveInstType = DestructiveOther;
872906c3fb27SDimitry Andric  let hasSideEffects = 0;
873006c3fb27SDimitry Andric  let mayRaiseFPException = 1;
87315ffd83dbSDimitry Andric}
87325ffd83dbSDimitry Andric
87335f757f3fSDimitry Andricmulticlass sve_float_dot_indexed<bit bf, bits<2> opc, ZPRRegOp src1_ty,
87345f757f3fSDimitry Andric                                 ZPRRegOp src2_ty, string asm, ValueType InVT,
87355f757f3fSDimitry Andric                                 SDPatternOperator op> {
87365f757f3fSDimitry Andric  def NAME : sve_float_dot_indexed<bf, ZPR32, src1_ty, src2_ty, VectorIndexS32b, asm> {
87375f757f3fSDimitry Andric    bits<2> iop;
87385f757f3fSDimitry Andric    let Inst{20-19} = iop;
87395f757f3fSDimitry Andric    let Inst{11-10} = opc;
87405f757f3fSDimitry Andric  }
8741bdd1243dSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv4f32, op, nxv4f32, InVT, InVT, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME)>;
87425ffd83dbSDimitry Andric}
87435ffd83dbSDimitry Andric
87445ffd83dbSDimitry Andricclass sve_bfloat_matmul<string asm>
87455ffd83dbSDimitry Andric: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
87465ffd83dbSDimitry Andric  asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
87475ffd83dbSDimitry Andric  bits<5> Zm;
87485ffd83dbSDimitry Andric  bits<5> Zda;
87495ffd83dbSDimitry Andric  bits<5> Zn;
87505ffd83dbSDimitry Andric  let Inst{31-21} = 0b01100100011;
87515ffd83dbSDimitry Andric  let Inst{20-16} = Zm;
87525ffd83dbSDimitry Andric  let Inst{15-10} = 0b111001;
87535ffd83dbSDimitry Andric  let Inst{9-5}   = Zn;
87545ffd83dbSDimitry Andric  let Inst{4-0}   = Zda;
87555ffd83dbSDimitry Andric
87565ffd83dbSDimitry Andric  let Constraints = "$Zda = $_Zda";
87575ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
87585ffd83dbSDimitry Andric  let ElementSize = ElementSizeH;
875906c3fb27SDimitry Andric  let hasSideEffects = 0;
876006c3fb27SDimitry Andric  let mayRaiseFPException = 1;
87615ffd83dbSDimitry Andric}
87625ffd83dbSDimitry Andric
87635ffd83dbSDimitry Andricmulticlass sve_bfloat_matmul<string asm, SDPatternOperator op> {
87645ffd83dbSDimitry Andric  def NAME : sve_bfloat_matmul<asm>;
87655ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16 ,!cast<Instruction>(NAME)>;
87665ffd83dbSDimitry Andric}
87675ffd83dbSDimitry Andric
87685ffd83dbSDimitry Andricclass sve_bfloat_convert<bit N, string asm>
87695ffd83dbSDimitry Andric: I<(outs ZPR16:$Zd), (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn),
87705ffd83dbSDimitry Andric  asm, "\t$Zd, $Pg/m, $Zn", "", []>, Sched<[]> {
87715ffd83dbSDimitry Andric  bits<5> Zd;
87725ffd83dbSDimitry Andric  bits<3> Pg;
87735ffd83dbSDimitry Andric  bits<5> Zn;
87745ffd83dbSDimitry Andric  let Inst{31-25} = 0b0110010;
87755ffd83dbSDimitry Andric  let Inst{24}    = N;
87765ffd83dbSDimitry Andric  let Inst{23-13} = 0b10001010101;
87775ffd83dbSDimitry Andric  let Inst{12-10} = Pg;
87785ffd83dbSDimitry Andric  let Inst{9-5}   = Zn;
87795ffd83dbSDimitry Andric  let Inst{4-0}   = Zd;
87805ffd83dbSDimitry Andric
87815ffd83dbSDimitry Andric  let Constraints = "$Zd = $_Zd";
87825ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
87835ffd83dbSDimitry Andric  let ElementSize = ElementSizeS;
878406c3fb27SDimitry Andric  let hasSideEffects = 0;
878506c3fb27SDimitry Andric  let mayRaiseFPException = 1;
87865ffd83dbSDimitry Andric}
87875ffd83dbSDimitry Andric
87885ffd83dbSDimitry Andricmulticlass sve_bfloat_convert<bit N, string asm, SDPatternOperator op> {
87895ffd83dbSDimitry Andric  def NAME : sve_bfloat_convert<N, asm>;
87905ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i1, nxv4f32, !cast<Instruction>(NAME)>;
87915ffd83dbSDimitry Andric}
87925ffd83dbSDimitry Andric
87935ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
87945ffd83dbSDimitry Andric// SVE Integer Matrix Multiply Group
87955ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
87965ffd83dbSDimitry Andric
87975ffd83dbSDimitry Andricclass sve_int_matmul<bits<2> uns, string asm>
87985ffd83dbSDimitry Andric: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR8:$Zm), asm,
87995ffd83dbSDimitry Andric  "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
88005ffd83dbSDimitry Andric  bits<5> Zda;
88015ffd83dbSDimitry Andric  bits<5> Zn;
88025ffd83dbSDimitry Andric  bits<5> Zm;
88035ffd83dbSDimitry Andric  let Inst{31-24} = 0b01000101;
88045ffd83dbSDimitry Andric  let Inst{23-22} = uns;
88055ffd83dbSDimitry Andric  let Inst{21}    = 0;
88065ffd83dbSDimitry Andric  let Inst{20-16} = Zm;
88075ffd83dbSDimitry Andric  let Inst{15-10} = 0b100110;
88085ffd83dbSDimitry Andric  let Inst{9-5}   = Zn;
88095ffd83dbSDimitry Andric  let Inst{4-0}   = Zda;
88105ffd83dbSDimitry Andric
88115ffd83dbSDimitry Andric  let Constraints = "$Zda = $_Zda";
88125ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
88135ffd83dbSDimitry Andric  let ElementSize = ZPR32.ElementSize;
881406c3fb27SDimitry Andric  let hasSideEffects = 0;
88155ffd83dbSDimitry Andric}
88165ffd83dbSDimitry Andric
88175ffd83dbSDimitry Andricmulticlass sve_int_matmul<bits<2> uns, string asm, SDPatternOperator op> {
88185ffd83dbSDimitry Andric  def NAME : sve_int_matmul<uns, asm>;
88195ffd83dbSDimitry Andric
88205ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op , nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
88215ffd83dbSDimitry Andric}
88225ffd83dbSDimitry Andric
88235ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
88245ffd83dbSDimitry Andric// SVE Integer Dot Product Mixed Sign Group
88255ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
88265ffd83dbSDimitry Andric
88275ffd83dbSDimitry Andricclass sve_int_dot_mixed<string asm>
88285ffd83dbSDimitry Andric: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR8:$Zm), asm,
88295ffd83dbSDimitry Andric  "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
88305ffd83dbSDimitry Andric  bits<5> Zda;
88315ffd83dbSDimitry Andric  bits<5> Zn;
88325ffd83dbSDimitry Andric  bits<5> Zm;
88335ffd83dbSDimitry Andric  let Inst{31-21} = 0b01000100100;
88345ffd83dbSDimitry Andric  let Inst{20-16} = Zm;
88355ffd83dbSDimitry Andric  let Inst{15-10} = 0b011110;
88365ffd83dbSDimitry Andric  let Inst{9-5}   = Zn;
88375ffd83dbSDimitry Andric  let Inst{4-0}   = Zda;
88385ffd83dbSDimitry Andric
88395ffd83dbSDimitry Andric  let Constraints = "$Zda = $_Zda";
88405ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
88415ffd83dbSDimitry Andric  let ElementSize = ZPR32.ElementSize;
884206c3fb27SDimitry Andric  let hasSideEffects = 0;
88435ffd83dbSDimitry Andric}
88445ffd83dbSDimitry Andric
88455ffd83dbSDimitry Andricmulticlass sve_int_dot_mixed<string asm, SDPatternOperator op> {
88465ffd83dbSDimitry Andric  def NAME : sve_int_dot_mixed<asm>;
88475ffd83dbSDimitry Andric
88485ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op , nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
88495ffd83dbSDimitry Andric}
88505ffd83dbSDimitry Andric
88515ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
88525ffd83dbSDimitry Andric// SVE Integer Dot Product Mixed Sign - Indexed Group
88535ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
88545ffd83dbSDimitry Andric
88555ffd83dbSDimitry Andricclass sve_int_dot_mixed_indexed<bit U, string asm>
88565ffd83dbSDimitry Andric: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, VectorIndexS32b:$idx),
88575ffd83dbSDimitry Andric    asm, "\t$Zda, $Zn, $Zm$idx", "", []>, Sched<[]> {
88585ffd83dbSDimitry Andric  bits<5> Zda;
88595ffd83dbSDimitry Andric  bits<5> Zn;
88605ffd83dbSDimitry Andric  bits<3> Zm;
88615ffd83dbSDimitry Andric  bits<2> idx;
88625ffd83dbSDimitry Andric  let Inst{31-21} = 0b01000100101;
88635ffd83dbSDimitry Andric  let Inst{20-19} = idx;
88645ffd83dbSDimitry Andric  let Inst{18-16} = Zm;
88655ffd83dbSDimitry Andric  let Inst{15-11} = 0b00011;
88665ffd83dbSDimitry Andric  let Inst{10}    = U;
88675ffd83dbSDimitry Andric  let Inst{9-5}   = Zn;
88685ffd83dbSDimitry Andric  let Inst{4-0}   = Zda;
88695ffd83dbSDimitry Andric
88705ffd83dbSDimitry Andric  let Constraints = "$Zda = $_Zda";
88715ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
88725ffd83dbSDimitry Andric  let ElementSize = ZPR32.ElementSize;
887306c3fb27SDimitry Andric  let hasSideEffects = 0;
88745ffd83dbSDimitry Andric}
88755ffd83dbSDimitry Andric
88765ffd83dbSDimitry Andricmulticlass sve_int_dot_mixed_indexed<bit U, string asm, SDPatternOperator op> {
88775ffd83dbSDimitry Andric  def NAME : sve_int_dot_mixed_indexed<U, asm>;
88785ffd83dbSDimitry Andric
88795ffd83dbSDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME)>;
88805ffd83dbSDimitry Andric}
88815ffd83dbSDimitry Andric
88825ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
88835ffd83dbSDimitry Andric// SVE Floating Point Matrix Multiply Accumulate Group
88845ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
88855ffd83dbSDimitry Andric
88865ffd83dbSDimitry Andricclass sve_fp_matrix_mla<bit sz, string asm, ZPRRegOp zprty>
88875ffd83dbSDimitry Andric: I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty:$Zm),
88885ffd83dbSDimitry Andric    asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
88895ffd83dbSDimitry Andric  bits<5> Zda;
88905ffd83dbSDimitry Andric  bits<5> Zn;
88915ffd83dbSDimitry Andric  bits<5> Zm;
88925ffd83dbSDimitry Andric  let Inst{31-23} = 0b011001001;
88935ffd83dbSDimitry Andric  let Inst{22}    = sz;
88945ffd83dbSDimitry Andric  let Inst{21}    = 1;
88955ffd83dbSDimitry Andric  let Inst{20-16} = Zm;
88965ffd83dbSDimitry Andric  let Inst{15-10} = 0b111001;
88975ffd83dbSDimitry Andric  let Inst{9-5}   = Zn;
88985ffd83dbSDimitry Andric  let Inst{4-0}   = Zda;
88995ffd83dbSDimitry Andric
89005ffd83dbSDimitry Andric  let Constraints = "$Zda = $_Zda";
89015ffd83dbSDimitry Andric  let DestructiveInstType = DestructiveOther;
89025ffd83dbSDimitry Andric  let ElementSize = zprty.ElementSize;
890306c3fb27SDimitry Andric  let hasSideEffects = 0;
890406c3fb27SDimitry Andric  let mayRaiseFPException = 1;
89055ffd83dbSDimitry Andric}
89065ffd83dbSDimitry Andric
89075ffd83dbSDimitry Andricmulticlass sve_fp_matrix_mla<bit sz, string asm, ZPRRegOp zprty, SDPatternOperator op, ValueType vt> {
89085ffd83dbSDimitry Andric  def NAME : sve_fp_matrix_mla<sz, asm, zprty>;
89095ffd83dbSDimitry Andric
89105ffd83dbSDimitry Andric  def : SVE_3_Op_Pat<vt, op , vt, vt, vt, !cast<Instruction>(NAME)>;
89115ffd83dbSDimitry Andric}
89125ffd83dbSDimitry Andric
89135ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
89145ffd83dbSDimitry Andric// SVE Memory - Contiguous Load And Replicate 256-bit Group
89155ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
89165ffd83dbSDimitry Andric
89175ffd83dbSDimitry Andricclass sve_mem_ldor_si<bits<2> sz, string asm, RegisterOperand VecList>
89185ffd83dbSDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s32:$imm4),
89195ffd83dbSDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> {
89205ffd83dbSDimitry Andric  bits<5> Zt;
89215ffd83dbSDimitry Andric  bits<5> Rn;
89225ffd83dbSDimitry Andric  bits<3> Pg;
89235ffd83dbSDimitry Andric  bits<4> imm4;
89245ffd83dbSDimitry Andric  let Inst{31-25} = 0b1010010;
89255ffd83dbSDimitry Andric  let Inst{24-23} = sz;
89265ffd83dbSDimitry Andric  let Inst{22-20} = 0b010;
89275ffd83dbSDimitry Andric  let Inst{19-16} = imm4;
89285ffd83dbSDimitry Andric  let Inst{15-13} = 0b001;
89295ffd83dbSDimitry Andric  let Inst{12-10} = Pg;
89305ffd83dbSDimitry Andric  let Inst{9-5}   = Rn;
89315ffd83dbSDimitry Andric  let Inst{4-0}   = Zt;
89325ffd83dbSDimitry Andric
893306c3fb27SDimitry Andric  let hasSideEffects = 0;
89345ffd83dbSDimitry Andric  let mayLoad = 1;
89355ffd83dbSDimitry Andric}
89365ffd83dbSDimitry Andric
89375ffd83dbSDimitry Andricmulticlass sve_mem_ldor_si<bits<2> sz, string asm, RegisterOperand listty,
89385ffd83dbSDimitry Andric                           ZPRRegOp zprty, ValueType Ty, ValueType PredTy, SDNode Ld1ro> {
89395ffd83dbSDimitry Andric  def NAME : sve_mem_ldor_si<sz, asm, listty>;
89405ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
89415ffd83dbSDimitry Andric                  (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
89425ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
89435ffd83dbSDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
89445ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]",
89455ffd83dbSDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s32:$imm4), 0>;
89465ffd83dbSDimitry Andric
89475ffd83dbSDimitry Andric  // Base addressing mode
8948979e22ffSDimitry Andric  def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$Pg), GPR64sp:$base)),
8949979e22ffSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, GPR64sp:$base, (i64 0))>;
8950979e22ffSDimitry Andric  let AddedComplexity = 2 in {
8951979e22ffSDimitry Andric    // Reg + Imm addressing mode
8952979e22ffSDimitry Andric    def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$Pg), (add GPR64:$base, (i64 simm4s32:$imm)))),
8953979e22ffSDimitry Andric              (!cast<Instruction>(NAME) $Pg, $base, simm4s32:$imm)>;
8954979e22ffSDimitry Andric  }
89555ffd83dbSDimitry Andric}
89565ffd83dbSDimitry Andric
89575ffd83dbSDimitry Andricclass sve_mem_ldor_ss<bits<2> sz, string asm, RegisterOperand VecList,
89585ffd83dbSDimitry Andric                      RegisterOperand gprty>
89595ffd83dbSDimitry Andric: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
89605ffd83dbSDimitry Andric  asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> {
89615ffd83dbSDimitry Andric  bits<5> Zt;
89625ffd83dbSDimitry Andric  bits<3> Pg;
89635ffd83dbSDimitry Andric  bits<5> Rn;
89645ffd83dbSDimitry Andric  bits<5> Rm;
89655ffd83dbSDimitry Andric  let Inst{31-25} = 0b1010010;
89665ffd83dbSDimitry Andric  let Inst{24-23} = sz;
89675ffd83dbSDimitry Andric  let Inst{22-21} = 0b01;
89685ffd83dbSDimitry Andric  let Inst{20-16} = Rm;
89695ffd83dbSDimitry Andric  let Inst{15-13} = 0;
89705ffd83dbSDimitry Andric  let Inst{12-10} = Pg;
89715ffd83dbSDimitry Andric  let Inst{9-5}   = Rn;
89725ffd83dbSDimitry Andric  let Inst{4-0}   = Zt;
89735ffd83dbSDimitry Andric
897406c3fb27SDimitry Andric  let hasSideEffects = 0;
89755ffd83dbSDimitry Andric  let mayLoad = 1;
89765ffd83dbSDimitry Andric}
89775ffd83dbSDimitry Andric
89785ffd83dbSDimitry Andricmulticlass sve_mem_ldor_ss<bits<2> sz, string asm, RegisterOperand listty,
89795ffd83dbSDimitry Andric                           ZPRRegOp zprty, RegisterOperand gprty, ValueType Ty,
89805ffd83dbSDimitry Andric                           ValueType PredTy, SDNode Ld1ro, ComplexPattern AddrCP> {
89815ffd83dbSDimitry Andric  def NAME : sve_mem_ldor_ss<sz, asm, listty, gprty>;
89825ffd83dbSDimitry Andric
89835ffd83dbSDimitry Andric  def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
89845ffd83dbSDimitry Andric                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
89855ffd83dbSDimitry Andric
89865ffd83dbSDimitry Andric  def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$gp), (AddrCP GPR64sp:$base, gprty:$offset))),
89875ffd83dbSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$gp, GPR64sp:$base, gprty:$offset)>;
89885ffd83dbSDimitry Andric}
89895ffd83dbSDimitry Andric
89905ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
89915ffd83dbSDimitry Andric// SVE Interleave 128-bit Elements Group
89925ffd83dbSDimitry Andric//===----------------------------------------------------------------------===//
89935ffd83dbSDimitry Andric
89945ffd83dbSDimitry Andricclass sve_int_perm_bin_perm_128_zz<bits<2> opc, bit P, string asm>
89955ffd83dbSDimitry Andric: I<(outs ZPR128:$Zd), (ins ZPR128:$Zn, ZPR128:$Zm),
89965ffd83dbSDimitry Andric  asm, "\t$Zd, $Zn, $Zm",
89975ffd83dbSDimitry Andric  "",
89985ffd83dbSDimitry Andric  []>, Sched<[]> {
89995ffd83dbSDimitry Andric  bits<5> Zd;
90005ffd83dbSDimitry Andric  bits<5> Zm;
90015ffd83dbSDimitry Andric  bits<5> Zn;
90025ffd83dbSDimitry Andric  let Inst{31-21} = 0b00000101101;
90035ffd83dbSDimitry Andric  let Inst{20-16} = Zm;
90045ffd83dbSDimitry Andric  let Inst{15-13} = 0b000;
90055ffd83dbSDimitry Andric  let Inst{12-11} = opc;
90065ffd83dbSDimitry Andric  let Inst{10}    = P;
90075ffd83dbSDimitry Andric  let Inst{9-5}   = Zn;
90085ffd83dbSDimitry Andric  let Inst{4-0}   = Zd;
900906c3fb27SDimitry Andric
901006c3fb27SDimitry Andric  let hasSideEffects = 0;
90115ffd83dbSDimitry Andric}
90125ffd83dbSDimitry Andric
90135ffd83dbSDimitry Andricmulticlass sve_int_perm_bin_perm_128_zz<bits<2> opc, bit P, string asm, SDPatternOperator op> {
90145ffd83dbSDimitry Andric  def NAME : sve_int_perm_bin_perm_128_zz<opc, P, asm>;
90155ffd83dbSDimitry Andric
90165ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv16i8,  op, nxv16i8,  nxv16i8,  !cast<Instruction>(NAME)>;
90175ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8i16,  op, nxv8i16,  nxv8i16,  !cast<Instruction>(NAME)>;
90185ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv8f16,  op, nxv8f16,  nxv8f16,  !cast<Instruction>(NAME)>;
90195ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32,  op, nxv4i32,  nxv4i32,  !cast<Instruction>(NAME)>;
90205ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv4f32,  op, nxv4f32,  nxv4f32,  !cast<Instruction>(NAME)>;
90215ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64,  op, nxv2i64,  nxv2i64,  !cast<Instruction>(NAME)>;
90225ffd83dbSDimitry Andric  def : SVE_2_Op_Pat<nxv2f64,  op, nxv2f64,  nxv2f64,  !cast<Instruction>(NAME)>;
9023e8d8bef9SDimitry Andric  def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
90245ffd83dbSDimitry Andric}
90255ffd83dbSDimitry Andric
90265ffd83dbSDimitry Andric/// Addressing modes
90270eae32dcSDimitry Andricdef am_sve_indexed_s4 :ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<-8,7>", [], [SDNPWantRoot]>;
90280eae32dcSDimitry Andricdef am_sve_indexed_s6 :ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<-32,31>", [], [SDNPWantRoot]>;
90295ffd83dbSDimitry Andric
90300eae32dcSDimitry Andricdef am_sve_regreg_lsl0 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<0>", []>;
90310eae32dcSDimitry Andricdef am_sve_regreg_lsl1 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<1>", []>;
90320eae32dcSDimitry Andricdef am_sve_regreg_lsl2 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<2>", []>;
90330eae32dcSDimitry Andricdef am_sve_regreg_lsl3 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<3>", []>;
903481ad6265SDimitry Andricdef am_sve_regreg_lsl4 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<4>", []>;
90355ffd83dbSDimitry Andric
90365ffd83dbSDimitry Andric// Predicated pseudo floating point two operand instructions.
90375ffd83dbSDimitry Andricmulticlass sve_fp_bin_pred_hfd<SDPatternOperator op> {
903806c3fb27SDimitry Andric  def _H_UNDEF : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
903906c3fb27SDimitry Andric  def _S_UNDEF : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
904006c3fb27SDimitry Andric  def _D_UNDEF : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
90415ffd83dbSDimitry Andric
904206c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
904306c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
904406c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
904506c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
904606c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
904706c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Pseudo>(NAME # _D_UNDEF)>;
904806c3fb27SDimitry Andric}
904906c3fb27SDimitry Andric
905006c3fb27SDimitry Andric// Predicated pseudo floating point three operand instructions.
905106c3fb27SDimitry Andricmulticlass sve_fp_3op_pred_hfd<SDPatternOperator op> {
905206c3fb27SDimitry Andric  def _H_UNDEF : PredThreeOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
905306c3fb27SDimitry Andric  def _S_UNDEF : PredThreeOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
905406c3fb27SDimitry Andric  def _D_UNDEF : PredThreeOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
905506c3fb27SDimitry Andric
905606c3fb27SDimitry Andric  def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H_UNDEF)>;
905706c3fb27SDimitry Andric  def : SVE_4_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _H_UNDEF)>;
905806c3fb27SDimitry Andric  def : SVE_4_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _H_UNDEF)>;
905906c3fb27SDimitry Andric  def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S_UNDEF)>;
906006c3fb27SDimitry Andric  def : SVE_4_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _S_UNDEF)>;
906106c3fb27SDimitry Andric  def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D_UNDEF)>;
90625ffd83dbSDimitry Andric}
90635ffd83dbSDimitry Andric
90645f757f3fSDimitry Andricmulticlass sve_fp_3op_pred_bf<SDPatternOperator op> {
90655f757f3fSDimitry Andric  def _UNDEF : PredThreeOpPseudo<NAME, ZPR16, FalseLanesUndef>;
90665f757f3fSDimitry Andric
90675f757f3fSDimitry Andric  def : SVE_4_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _UNDEF)>;
90685f757f3fSDimitry Andric}
90695f757f3fSDimitry Andric
90705ffd83dbSDimitry Andric// Predicated pseudo integer two operand instructions.
90715ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_bhsd<SDPatternOperator op> {
907206c3fb27SDimitry Andric  def _B_UNDEF : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>;
907306c3fb27SDimitry Andric  def _H_UNDEF : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
907406c3fb27SDimitry Andric  def _S_UNDEF : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
907506c3fb27SDimitry Andric  def _D_UNDEF : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
90765ffd83dbSDimitry Andric
907706c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
907806c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1,  nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
907906c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1,  nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
908006c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1,  nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
90815ffd83dbSDimitry Andric}
90825ffd83dbSDimitry Andric
90835ffd83dbSDimitry Andric// As sve_int_bin_pred but when only i32 and i64 vector types are required.
90845ffd83dbSDimitry Andricmulticlass sve_int_bin_pred_sd<SDPatternOperator op> {
908506c3fb27SDimitry Andric  def _S_UNDEF : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
908606c3fb27SDimitry Andric  def _D_UNDEF : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
90875ffd83dbSDimitry Andric
908806c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
908906c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
90905ffd83dbSDimitry Andric}
9091e8d8bef9SDimitry Andric
9092e8d8bef9SDimitry Andric// Predicated pseudo integer two operand instructions. Second operand is an
9093e8d8bef9SDimitry Andric// immediate specified by imm_[bhsd].
9094e8d8bef9SDimitry Andricmulticlass sve_int_shift_pred_bhsd<SDPatternOperator op,
9095e8d8bef9SDimitry Andric                                   ComplexPattern imm_b, ComplexPattern imm_h,
9096e8d8bef9SDimitry Andric                                   ComplexPattern imm_s, ComplexPattern imm_d> {
909706c3fb27SDimitry Andric  def _B_UNDEF : PredTwoOpImmPseudo<NAME # _B, ZPR8,  Operand<i32>, FalseLanesUndef>;
909806c3fb27SDimitry Andric  def _H_UNDEF : PredTwoOpImmPseudo<NAME # _H, ZPR16, Operand<i32>, FalseLanesUndef>;
909906c3fb27SDimitry Andric  def _S_UNDEF : PredTwoOpImmPseudo<NAME # _S, ZPR32, Operand<i32>, FalseLanesUndef>;
910006c3fb27SDimitry Andric  def _D_UNDEF : PredTwoOpImmPseudo<NAME # _D, ZPR64, Operand<i32>, FalseLanesUndef>;
9101e8d8bef9SDimitry Andric
910206c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, imm_b, !cast<Instruction>(NAME # _B_UNDEF)>;
910306c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1,  i32, imm_h, !cast<Instruction>(NAME # _H_UNDEF)>;
910406c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1,  i32, imm_s, !cast<Instruction>(NAME # _S_UNDEF)>;
910506c3fb27SDimitry Andric  def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1,  i64, imm_d, !cast<Instruction>(NAME # _D_UNDEF)>;
9106e8d8bef9SDimitry Andric}
9107fe6060f1SDimitry Andric
9108fe6060f1SDimitry Andricmulticlass sve_int_bin_pred_all_active_bhsd<SDPatternOperator op> {
910906c3fb27SDimitry Andric  def _B_UNDEF : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>;
911006c3fb27SDimitry Andric  def _H_UNDEF : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
911106c3fb27SDimitry Andric  def _S_UNDEF : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
911206c3fb27SDimitry Andric  def _D_UNDEF : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
9113fe6060f1SDimitry Andric
911406c3fb27SDimitry Andric  def : SVE_2_Op_Pred_All_Active_Pt<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
911506c3fb27SDimitry Andric  def : SVE_2_Op_Pred_All_Active_Pt<nxv8i16, op, nxv8i1,  nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
911606c3fb27SDimitry Andric  def : SVE_2_Op_Pred_All_Active_Pt<nxv4i32, op, nxv4i1,  nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
911706c3fb27SDimitry Andric  def : SVE_2_Op_Pred_All_Active_Pt<nxv2i64, op, nxv2i1,  nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
9118fe6060f1SDimitry Andric}
9119349cc55cSDimitry Andric
9120bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
9121bdd1243dSDimitry Andric// SME2 or SVE2.1 Instructions
9122bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
9123bdd1243dSDimitry Andric
9124bdd1243dSDimitry Andricclass sve2p1_fclamp<string asm, bits<2> sz, ZPRRegOp zpr_ty>
9125bdd1243dSDimitry Andric    : I<(outs zpr_ty:$Zd), (ins zpr_ty:$_Zd, zpr_ty:$Zn, zpr_ty:$Zm),
9126bdd1243dSDimitry Andric        asm, "\t$Zd, $Zn, $Zm", "", []>,
9127bdd1243dSDimitry Andric      Sched<[]> {
9128bdd1243dSDimitry Andric  bits<5> Zm;
9129bdd1243dSDimitry Andric  bits<5> Zn;
9130bdd1243dSDimitry Andric  bits<5> Zd;
9131bdd1243dSDimitry Andric  let Inst{31-24} = 0b01100100;
9132bdd1243dSDimitry Andric  let Inst{23-22} = sz;
9133bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
9134bdd1243dSDimitry Andric  let Inst{20-16} = Zm;
9135bdd1243dSDimitry Andric  let Inst{15-10} = 0b001001;
9136bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
9137bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
9138bdd1243dSDimitry Andric
9139bdd1243dSDimitry Andric  let Constraints = "$Zd = $_Zd";
9140bdd1243dSDimitry Andric  let DestructiveInstType = DestructiveOther;
9141bdd1243dSDimitry Andric  let ElementSize = zpr_ty.ElementSize;
914206c3fb27SDimitry Andric  let hasSideEffects = 0;
9143bdd1243dSDimitry Andric}
9144bdd1243dSDimitry Andric
9145bdd1243dSDimitry Andricmulticlass sve2p1_fclamp<string asm, SDPatternOperator op> {
9146bdd1243dSDimitry Andric  def _H : sve2p1_fclamp<asm, 0b01, ZPR16>;
9147bdd1243dSDimitry Andric  def _S : sve2p1_fclamp<asm, 0b10, ZPR32>;
9148bdd1243dSDimitry Andric  def _D : sve2p1_fclamp<asm, 0b11, ZPR64>;
9149bdd1243dSDimitry Andric
9150bdd1243dSDimitry Andric  def : SVE_3_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
9151bdd1243dSDimitry Andric  def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
9152bdd1243dSDimitry Andric  def : SVE_3_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
9153bdd1243dSDimitry Andric}
9154bdd1243dSDimitry Andric
91555f757f3fSDimitry Andricmulticlass sve2p1_bfclamp<string asm, SDPatternOperator op> {
91565f757f3fSDimitry Andric  def NAME : sve2p1_fclamp<asm, 0b00, ZPR16>;
91575f757f3fSDimitry Andric  def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
91585f757f3fSDimitry Andric}
91595f757f3fSDimitry Andric
9160bdd1243dSDimitry Andric// SVE two-way dot product
9161bdd1243dSDimitry Andricclass sve2p1_two_way_dot_vv<string mnemonic, bit u>
9162bdd1243dSDimitry Andric    : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
9163bdd1243dSDimitry Andric        mnemonic, "\t$Zda, $Zn, $Zm",
9164bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9165bdd1243dSDimitry Andric  bits<5> Zda;
9166bdd1243dSDimitry Andric  bits<5> Zn;
9167bdd1243dSDimitry Andric  bits<5> Zm;
9168bdd1243dSDimitry Andric  let Inst{31-21} = 0b01000100000;
9169bdd1243dSDimitry Andric  let Inst{20-16} = Zm;
9170bdd1243dSDimitry Andric  let Inst{15-11} = 0b11001;
9171bdd1243dSDimitry Andric  let Inst{10}    = u;
9172bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
9173bdd1243dSDimitry Andric  let Inst{4-0}   = Zda;
9174bdd1243dSDimitry Andric
9175bdd1243dSDimitry Andric  let Constraints = "$Zda = $_Zda";
9176bdd1243dSDimitry Andric  let DestructiveInstType = DestructiveOther;
917706c3fb27SDimitry Andric  let hasSideEffects = 0;
9178bdd1243dSDimitry Andric}
9179bdd1243dSDimitry Andric
918006c3fb27SDimitry Andricmulticlass sve2p1_two_way_dot_vv<string mnemonic, bit u, SDPatternOperator intrinsic> {
918106c3fb27SDimitry Andric  def NAME : sve2p1_two_way_dot_vv<mnemonic, u>;
918206c3fb27SDimitry Andric
918306c3fb27SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, intrinsic, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
918406c3fb27SDimitry Andric}
9185bdd1243dSDimitry Andric
9186bdd1243dSDimitry Andric// SVE two-way dot product (indexed)
9187bdd1243dSDimitry Andricclass sve2p1_two_way_dot_vvi<string mnemonic, bit u>
9188bdd1243dSDimitry Andric    : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, VectorIndexS32b:$i2),
9189bdd1243dSDimitry Andric        mnemonic, "\t$Zda, $Zn, $Zm$i2",
9190bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9191bdd1243dSDimitry Andric  bits<5> Zda;
9192bdd1243dSDimitry Andric  bits<5> Zn;
9193bdd1243dSDimitry Andric  bits<3> Zm;
9194bdd1243dSDimitry Andric  bits<2> i2;
9195bdd1243dSDimitry Andric  let Inst{31-21} = 0b01000100100;
9196bdd1243dSDimitry Andric  let Inst{20-19} = i2;
9197bdd1243dSDimitry Andric  let Inst{18-16} = Zm;
9198bdd1243dSDimitry Andric  let Inst{15-11} = 0b11001;
9199bdd1243dSDimitry Andric  let Inst{10}    = u;
9200bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
9201bdd1243dSDimitry Andric  let Inst{4-0}   = Zda;
9202bdd1243dSDimitry Andric
9203bdd1243dSDimitry Andric  let Constraints = "$Zda = $_Zda";
9204bdd1243dSDimitry Andric  let DestructiveInstType = DestructiveOther;
920506c3fb27SDimitry Andric  let hasSideEffects = 0;
9206bdd1243dSDimitry Andric}
9207bdd1243dSDimitry Andric
920806c3fb27SDimitry Andricmulticlass sve2p1_two_way_dot_vvi<string mnemonic, bit u, SDPatternOperator intrinsic> {
920906c3fb27SDimitry Andric  def NAME : sve2p1_two_way_dot_vvi<mnemonic, u>;
9210bdd1243dSDimitry Andric
921106c3fb27SDimitry Andric  def : SVE_4_Op_Imm_Pat<nxv4i32, intrinsic, nxv4i32, nxv8i16, nxv8i16, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME)>;
921206c3fb27SDimitry Andric}
921306c3fb27SDimitry Andric
921406c3fb27SDimitry Andricclass sve2p1_ptrue_pn<string mnemonic, bits<2> sz, PNRP8to15RegOp pnrty, SDPatternOperator op>
9215bdd1243dSDimitry Andric    : I<(outs pnrty:$PNd), (ins ), mnemonic, "\t$PNd",
921606c3fb27SDimitry Andric        "", [(set pnrty:$PNd, (op))]>, Sched<[]> {
9217bdd1243dSDimitry Andric  bits<3> PNd;
9218bdd1243dSDimitry Andric  let Inst{31-24}  = 0b00100101;
9219bdd1243dSDimitry Andric  let Inst{23-22} = sz;
9220bdd1243dSDimitry Andric  let Inst{21-3}  = 0b1000000111100000010;
9221bdd1243dSDimitry Andric  let Inst{2-0}   = PNd;
922206c3fb27SDimitry Andric
922306c3fb27SDimitry Andric  let hasSideEffects = 0;
92245f757f3fSDimitry Andric  let isReMaterializable = 1;
9225*0fca6ea1SDimitry Andric  let Uses = [VG];
9226bdd1243dSDimitry Andric}
9227bdd1243dSDimitry Andric
9228bdd1243dSDimitry Andric
9229bdd1243dSDimitry Andricmulticlass sve2p1_ptrue_pn<string mnemonic> {
923006c3fb27SDimitry Andric def _B : sve2p1_ptrue_pn<mnemonic, 0b00, PNR8_p8to15, int_aarch64_sve_ptrue_c8>;
923106c3fb27SDimitry Andric def _H : sve2p1_ptrue_pn<mnemonic, 0b01, PNR16_p8to15, int_aarch64_sve_ptrue_c16>;
923206c3fb27SDimitry Andric def _S : sve2p1_ptrue_pn<mnemonic, 0b10, PNR32_p8to15, int_aarch64_sve_ptrue_c32>;
923306c3fb27SDimitry Andric def _D : sve2p1_ptrue_pn<mnemonic, 0b11, PNR64_p8to15, int_aarch64_sve_ptrue_c64>;
9234bdd1243dSDimitry Andric}
9235bdd1243dSDimitry Andric
9236bdd1243dSDimitry Andric
9237bdd1243dSDimitry Andric// SVE extract mask predicate from predicate-as-counter
9238bdd1243dSDimitry Andricclass sve2p1_pred_as_ctr_to_mask_base<string mnemonic, bits<2> sz, bits<3> opc,
9239bdd1243dSDimitry Andric                                      RegisterOperand pprty, Operand idxty>
9240bdd1243dSDimitry Andric    : I<(outs pprty:$Pd), (ins PNRAny_p8to15:$PNn, idxty:$index),
9241bdd1243dSDimitry Andric        mnemonic, "\t$Pd, $PNn$index",
9242bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9243bdd1243dSDimitry Andric  bits<4> Pd;
9244bdd1243dSDimitry Andric  bits<3> PNn;
9245bdd1243dSDimitry Andric  bits<2> imm2;
9246bdd1243dSDimitry Andric  let Inst{31-24} = 0b00100101;
9247bdd1243dSDimitry Andric  let Inst{23-22} = sz;
9248bdd1243dSDimitry Andric  let Inst{21-11} = 0b10000001110;
9249bdd1243dSDimitry Andric  let Inst{10-8}  = opc;
9250bdd1243dSDimitry Andric  let Inst{7-5}   = PNn;
9251bdd1243dSDimitry Andric  let Inst{4}     = 0b1;
9252bdd1243dSDimitry Andric  let Inst{3-0}   = Pd;
925306c3fb27SDimitry Andric
925406c3fb27SDimitry Andric  let hasSideEffects = 0;
9255bdd1243dSDimitry Andric}
9256bdd1243dSDimitry Andric
9257bdd1243dSDimitry Andricclass sve2p1_pred_as_ctr_to_mask<string mnemonic, bits<2> sz, PPRRegOp pprty>
925806c3fb27SDimitry Andric    : sve2p1_pred_as_ctr_to_mask_base<mnemonic, sz, {0, ?, ?}, pprty, VectorIndexS32b_timm> {
9259bdd1243dSDimitry Andric  bits<2> index;
9260bdd1243dSDimitry Andric  let Inst{9-8} = index;
9261bdd1243dSDimitry Andric}
9262bdd1243dSDimitry Andric
926306c3fb27SDimitry Andricmulticlass sve2p1_pred_as_ctr_to_mask<string mnemonic, SDPatternOperator op> {
9264bdd1243dSDimitry Andric def _B : sve2p1_pred_as_ctr_to_mask<mnemonic, 0b00, PPR8>;
9265bdd1243dSDimitry Andric def _H : sve2p1_pred_as_ctr_to_mask<mnemonic, 0b01, PPR16>;
9266bdd1243dSDimitry Andric def _S : sve2p1_pred_as_ctr_to_mask<mnemonic, 0b10, PPR32>;
9267bdd1243dSDimitry Andric def _D : sve2p1_pred_as_ctr_to_mask<mnemonic, 0b11, PPR64>;
926806c3fb27SDimitry Andric
926906c3fb27SDimitry Andric def : SVE_2_Op_Imm_Pat<nxv16i1, op, aarch64svcount, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _B)>;
927006c3fb27SDimitry Andric def : SVE_2_Op_Imm_Pat<nxv8i1,  op, aarch64svcount, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _H)>;
927106c3fb27SDimitry Andric def : SVE_2_Op_Imm_Pat<nxv4i1,  op, aarch64svcount, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
927206c3fb27SDimitry Andric def : SVE_2_Op_Imm_Pat<nxv2i1,  op, aarch64svcount, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>;
9273bdd1243dSDimitry Andric}
9274bdd1243dSDimitry Andric
9275bdd1243dSDimitry Andric
9276bdd1243dSDimitry Andricclass sve2p1_pred_as_ctr_to_mask_pair<string mnemonic, bits<2> sz, RegisterOperand pprty>
9277bdd1243dSDimitry Andric    : sve2p1_pred_as_ctr_to_mask_base<mnemonic, sz, {1, 0, ?}, pprty, VectorIndexD> {
9278bdd1243dSDimitry Andric  bit index;
9279bdd1243dSDimitry Andric  let Inst{8}    = index;
9280bdd1243dSDimitry Andric}
9281bdd1243dSDimitry Andric
9282bdd1243dSDimitry Andricmulticlass sve2p1_pred_as_ctr_to_mask_pair<string mnemonic> {
9283bdd1243dSDimitry Andric def _B : sve2p1_pred_as_ctr_to_mask_pair<mnemonic, 0b00, PP_b>;
9284bdd1243dSDimitry Andric def _H : sve2p1_pred_as_ctr_to_mask_pair<mnemonic, 0b01, PP_h>;
9285bdd1243dSDimitry Andric def _S : sve2p1_pred_as_ctr_to_mask_pair<mnemonic, 0b10, PP_s>;
9286bdd1243dSDimitry Andric def _D : sve2p1_pred_as_ctr_to_mask_pair<mnemonic, 0b11, PP_d>;
9287bdd1243dSDimitry Andric}
9288bdd1243dSDimitry Andric
9289bdd1243dSDimitry Andric
9290bdd1243dSDimitry Andric// SME2 multi-vec extract narrow
9291bdd1243dSDimitry Andricclass sve2p1_multi_vec_extract_narrow<string mnemonic, bits<2> opc, bits<3> tsz>
9292bdd1243dSDimitry Andric    : I<(outs ZPR16:$Zd), (ins ZZ_s_mul_r:$Zn),
9293bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn",
9294bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9295bdd1243dSDimitry Andric  bits<5> Zd;
9296bdd1243dSDimitry Andric  bits<4> Zn;
9297bdd1243dSDimitry Andric  let Inst{31-23} = 0b010001010;
9298bdd1243dSDimitry Andric  let Inst{22}    = tsz{2};
9299bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
9300bdd1243dSDimitry Andric  let Inst{20-19} = tsz{1-0};
9301bdd1243dSDimitry Andric  let Inst{18-13} = 0b001010;
9302bdd1243dSDimitry Andric  let Inst{12-11} = opc;
9303bdd1243dSDimitry Andric  let Inst{10}    = 0b0;
9304bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
9305bdd1243dSDimitry Andric  let Inst{5}     = 0b0;
9306bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
930706c3fb27SDimitry Andric
930806c3fb27SDimitry Andric  let hasSideEffects = 0;
9309bdd1243dSDimitry Andric}
9310bdd1243dSDimitry Andric
9311bdd1243dSDimitry Andricmulticlass sve2p1_multi_vec_extract_narrow<string mnemonic, bits<2> opc, SDPatternOperator intrinsic> {
9312bdd1243dSDimitry Andric  def NAME : sve2p1_multi_vec_extract_narrow<mnemonic, opc, 0b010>;
9313bdd1243dSDimitry Andric  def : SVE2p1_Cvt_VG2_Pat<NAME, intrinsic, nxv8i16, nxv4i32>;
9314bdd1243dSDimitry Andric}
9315bdd1243dSDimitry Andric
9316bdd1243dSDimitry Andric// SVE2 multi-vec shift narrow
9317bdd1243dSDimitry Andricclass sve2p1_multi_vec_shift_narrow<string mnemonic, bits<3> opc, bits<2> tsz>
931806c3fb27SDimitry Andric    : I<(outs ZPR16:$Zd), (ins ZZ_s_mul_r:$Zn, tvecshiftR16:$imm4),
9319bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn, $imm4",
9320bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9321bdd1243dSDimitry Andric  bits<5> Zd;
9322bdd1243dSDimitry Andric  bits<4> Zn;
9323bdd1243dSDimitry Andric  bits<4> imm4;
9324bdd1243dSDimitry Andric  let Inst{31-23} = 0b010001011;
9325bdd1243dSDimitry Andric  let Inst{22}    = tsz{1};
9326bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
9327bdd1243dSDimitry Andric  let Inst{20}    = tsz{0};
9328bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
9329bdd1243dSDimitry Andric  let Inst{15-14} = 0b00;
9330bdd1243dSDimitry Andric  let Inst{13-11} = opc;
9331bdd1243dSDimitry Andric  let Inst{10}    = 0b0;
9332bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
9333bdd1243dSDimitry Andric  let Inst{5}     = 0b0;
9334bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
933506c3fb27SDimitry Andric
933606c3fb27SDimitry Andric  let hasSideEffects = 0;
9337bdd1243dSDimitry Andric}
9338bdd1243dSDimitry Andric
933906c3fb27SDimitry Andricmulticlass sve2p1_multi_vec_shift_narrow<string mnemonic, bits<3> opc, SDPatternOperator intrinsic> {
934006c3fb27SDimitry Andric  def NAME : sve2p1_multi_vec_shift_narrow<mnemonic, opc, 0b01>;
934106c3fb27SDimitry Andric
934206c3fb27SDimitry Andric  def : SVE2p1_Sat_Shift_VG2_Pat<NAME, intrinsic, nxv8i16, nxv4i32, tvecshiftR16>;
9343bdd1243dSDimitry Andric}
9344bdd1243dSDimitry Andric
9345bdd1243dSDimitry Andric
9346bdd1243dSDimitry Andric// SME2 multi-vec contiguous load (scalar plus scalar, two registers)
9347bdd1243dSDimitry Andricclass sve2p1_mem_cld_ss_2z<string mnemonic, bits<2> msz, bit n,
9348bdd1243dSDimitry Andric                         RegisterOperand vector_ty, RegisterOperand gpr_ty>
9349bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zt),
9350bdd1243dSDimitry Andric        (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
9351bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $PNg/z, [$Rn, $Rm]",
9352bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9353bdd1243dSDimitry Andric  bits<4> Zt;
9354bdd1243dSDimitry Andric  bits<5> Rm;
9355bdd1243dSDimitry Andric  bits<5> Rn;
9356bdd1243dSDimitry Andric  bits<3> PNg;
9357bdd1243dSDimitry Andric  let Inst{31-21} = 0b10100000000;
9358bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9359bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
9360bdd1243dSDimitry Andric  let Inst{14-13} = msz;
9361bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
9362bdd1243dSDimitry Andric  let Inst{9-5} = Rn;
9363bdd1243dSDimitry Andric  let Inst{4-1} = Zt;
9364bdd1243dSDimitry Andric  let Inst{0}   = n;
9365bdd1243dSDimitry Andric
936606c3fb27SDimitry Andric  let hasSideEffects = 0;
9367bdd1243dSDimitry Andric  let mayLoad = 1;
9368bdd1243dSDimitry Andric}
9369bdd1243dSDimitry Andric
93705f757f3fSDimitry Andricmulticlass sve2p1_mem_cld_ss_2z<string mnemonic, bits<2> msz, bit n,
93715f757f3fSDimitry Andric                         RegisterOperand vector_ty, RegisterOperand gpr_ty, RegisterOperand vector_pseudo_ty> {
93725f757f3fSDimitry Andric  def NAME # _PSEUDO : Pseudo<(outs vector_pseudo_ty:$Zt), (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm), []>;
93735f757f3fSDimitry Andric  def NAME : sve2p1_mem_cld_ss_2z<mnemonic, msz, n, vector_ty, gpr_ty>;
93745f757f3fSDimitry Andric}
93755f757f3fSDimitry Andric
9376bdd1243dSDimitry Andric// SME2 multi-vec contiguous load (scalar plus immediate, two registers)
9377bdd1243dSDimitry Andricclass sve2p1_mem_cld_si_2z<string mnemonic, bits<2> msz, bit n,
9378bdd1243dSDimitry Andric                         RegisterOperand vector_ty>
9379bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zt),
9380bdd1243dSDimitry Andric        (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s2:$imm4),
9381bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $PNg/z, [$Rn, $imm4, mul vl]",
9382bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9383bdd1243dSDimitry Andric  bits<4> Zt;
9384bdd1243dSDimitry Andric  bits<5> Rn;
9385bdd1243dSDimitry Andric  bits<3> PNg;
9386bdd1243dSDimitry Andric  bits<4> imm4;
9387bdd1243dSDimitry Andric  let Inst{31-20} = 0b101000000100;
9388bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
9389bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
9390bdd1243dSDimitry Andric  let Inst{14-13} = msz;
9391bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
9392bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
9393bdd1243dSDimitry Andric  let Inst{4-1}   = Zt;
9394bdd1243dSDimitry Andric  let Inst{0}     = n;
9395bdd1243dSDimitry Andric
939606c3fb27SDimitry Andric  let hasSideEffects = 0;
9397bdd1243dSDimitry Andric  let mayLoad = 1;
9398bdd1243dSDimitry Andric}
9399bdd1243dSDimitry Andric
9400bdd1243dSDimitry Andricmulticlass sve2p1_mem_cld_si_2z<string mnemonic, bits<2> msz, bit n,
94015f757f3fSDimitry Andric                              RegisterOperand vector_ty, RegisterOperand vector_pseudo_ty> {
9402bdd1243dSDimitry Andric  def NAME : sve2p1_mem_cld_si_2z<mnemonic, msz, n, vector_ty>;
9403bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $PNg/z, [$Rn]",
9404bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, 0), 1>;
94055f757f3fSDimitry Andric  def NAME # _PSEUDO : Pseudo<(outs vector_pseudo_ty:$Zt), (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s2:$imm4), []>;
9406bdd1243dSDimitry Andric}
9407bdd1243dSDimitry Andric
9408bdd1243dSDimitry Andric// SME2 multi-vec contiguous load (scalar plus scalar, four registers)
9409bdd1243dSDimitry Andricclass sve2p1_mem_cld_ss_4z<string mnemonic, bits<2> msz, bit n,
9410bdd1243dSDimitry Andric                         RegisterOperand vector_ty, RegisterOperand gpr_ty>
9411bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zt),
9412bdd1243dSDimitry Andric        (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
9413bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $PNg/z, [$Rn, $Rm]",
9414bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9415bdd1243dSDimitry Andric  bits<3> Zt;
9416bdd1243dSDimitry Andric  bits<5> Rm;
9417bdd1243dSDimitry Andric  bits<5> Rn;
9418bdd1243dSDimitry Andric  bits<3> PNg;
9419bdd1243dSDimitry Andric  let Inst{31-21} = 0b10100000000;
9420bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9421bdd1243dSDimitry Andric  let Inst{15}    = 0b1;
9422bdd1243dSDimitry Andric  let Inst{14-13} = msz;
9423bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
9424bdd1243dSDimitry Andric  let Inst{9-5} = Rn;
9425bdd1243dSDimitry Andric  let Inst{4-2} = Zt;
9426bdd1243dSDimitry Andric  let Inst{1}   = 0b0;
9427bdd1243dSDimitry Andric  let Inst{0}   = n;
9428bdd1243dSDimitry Andric
942906c3fb27SDimitry Andric  let hasSideEffects = 0;
9430bdd1243dSDimitry Andric  let mayLoad = 1;
9431bdd1243dSDimitry Andric}
9432bdd1243dSDimitry Andric
94335f757f3fSDimitry Andricmulticlass sve2p1_mem_cld_ss_4z<string mnemonic, bits<2> msz, bit n,
94345f757f3fSDimitry Andric                         RegisterOperand vector_ty, RegisterOperand gpr_ty, RegisterOperand vector_pseudo_ty> {
94355f757f3fSDimitry Andric  def NAME # _PSEUDO : Pseudo<(outs vector_pseudo_ty:$Zt), (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm), []>;
94365f757f3fSDimitry Andric  def NAME : sve2p1_mem_cld_ss_4z<mnemonic, msz, n, vector_ty, gpr_ty>;
94375f757f3fSDimitry Andric}
94385f757f3fSDimitry Andric
9439bdd1243dSDimitry Andric// SME2 multi-vec contiguous load (scalar plus immediate, four registers)
9440bdd1243dSDimitry Andricclass sve2p1_mem_cld_si_4z<string mnemonic, bits<2> msz, bit n,
9441bdd1243dSDimitry Andric                         RegisterOperand vector_ty>
9442bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zt),
9443bdd1243dSDimitry Andric        (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s4:$imm4),
9444bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $PNg/z, [$Rn, $imm4, mul vl]",
9445bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9446bdd1243dSDimitry Andric  bits<3> Zt;
9447bdd1243dSDimitry Andric  bits<5> Rn;
9448bdd1243dSDimitry Andric  bits<3> PNg;
9449bdd1243dSDimitry Andric  bits<4> imm4;
9450bdd1243dSDimitry Andric  let Inst{31-20} = 0b101000000100;
9451bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
9452bdd1243dSDimitry Andric  let Inst{15}    = 0b1;
9453bdd1243dSDimitry Andric  let Inst{14-13} = msz;
9454bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
9455bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
9456bdd1243dSDimitry Andric  let Inst{4-2}   = Zt;
9457bdd1243dSDimitry Andric  let Inst{1}     = 0b0;
9458bdd1243dSDimitry Andric  let Inst{0}     = n;
9459bdd1243dSDimitry Andric
946006c3fb27SDimitry Andric  let hasSideEffects = 0;
9461bdd1243dSDimitry Andric  let mayLoad = 1;
9462bdd1243dSDimitry Andric}
9463bdd1243dSDimitry Andric
9464bdd1243dSDimitry Andricmulticlass sve2p1_mem_cld_si_4z<string mnemonic, bits<2> msz, bit n,
94655f757f3fSDimitry Andric                              RegisterOperand vector_ty, RegisterOperand vector_pseudo_ty> {
9466bdd1243dSDimitry Andric  def NAME : sve2p1_mem_cld_si_4z<mnemonic, msz, n, vector_ty>;
9467bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $PNg/z, [$Rn]",
9468bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, 0), 1>;
94695f757f3fSDimitry Andric  def NAME # _PSEUDO : Pseudo<(outs vector_pseudo_ty:$Zt), (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s4:$imm4), []>;
9470bdd1243dSDimitry Andric}
9471bdd1243dSDimitry Andric
9472bdd1243dSDimitry Andric// SME2 multi-vec contiguous store (scalar plus scalar, two registers)
9473bdd1243dSDimitry Andricclass sve2p1_mem_cst_ss_2z<string mnemonic, bits<2> msz, bit n,
9474bdd1243dSDimitry Andric                           RegisterOperand vector_ty, RegisterOperand gpr_ty>
9475bdd1243dSDimitry Andric    : I<(outs ),
9476bdd1243dSDimitry Andric        (ins vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
9477bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $PNg, [$Rn, $Rm]",
9478bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9479bdd1243dSDimitry Andric  bits<4> Zt;
9480bdd1243dSDimitry Andric  bits<5> Rm;
9481bdd1243dSDimitry Andric  bits<5> Rn;
9482bdd1243dSDimitry Andric  bits<3> PNg;
9483bdd1243dSDimitry Andric  let Inst{31-21} = 0b10100000001;
9484bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9485bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
9486bdd1243dSDimitry Andric  let Inst{14-13} = msz;
9487bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
9488bdd1243dSDimitry Andric  let Inst{9-5} = Rn;
9489bdd1243dSDimitry Andric  let Inst{4-1} = Zt;
9490bdd1243dSDimitry Andric  let Inst{0}   = n;
9491bdd1243dSDimitry Andric
949206c3fb27SDimitry Andric  let hasSideEffects = 0;
9493bdd1243dSDimitry Andric  let mayStore = 1;
9494bdd1243dSDimitry Andric}
9495bdd1243dSDimitry Andric
9496bdd1243dSDimitry Andric
9497bdd1243dSDimitry Andric// SME2 multi-vec contiguous store (scalar plus immediate, two registers)
9498bdd1243dSDimitry Andricclass sve2p1_mem_cst_si_2z<string mnemonic, bits<2> msz, bit n,
9499bdd1243dSDimitry Andric                           RegisterOperand vector_ty>
9500bdd1243dSDimitry Andric    : I<(outs ),
9501bdd1243dSDimitry Andric        (ins vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s2:$imm4),
9502bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $PNg, [$Rn, $imm4, mul vl]",
9503bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9504bdd1243dSDimitry Andric  bits<4> Zt;
9505bdd1243dSDimitry Andric  bits<5> Rn;
9506bdd1243dSDimitry Andric  bits<3> PNg;
9507bdd1243dSDimitry Andric  bits<4> imm4;
9508bdd1243dSDimitry Andric  let Inst{31-20} = 0b101000000110;
9509bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
9510bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
9511bdd1243dSDimitry Andric  let Inst{14-13} = msz;
9512bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
9513bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
9514bdd1243dSDimitry Andric  let Inst{4-1}   = Zt;
9515bdd1243dSDimitry Andric  let Inst{0}     = n;
9516bdd1243dSDimitry Andric
951706c3fb27SDimitry Andric  let hasSideEffects = 0;
9518bdd1243dSDimitry Andric  let mayStore = 1;
9519bdd1243dSDimitry Andric}
9520bdd1243dSDimitry Andric
9521bdd1243dSDimitry Andric
9522bdd1243dSDimitry Andricmulticlass sve2p1_mem_cst_si_2z<string mnemonic, bits<2> msz, bit n,
9523bdd1243dSDimitry Andric                              RegisterOperand vector_ty> {
9524bdd1243dSDimitry Andric  def NAME : sve2p1_mem_cst_si_2z<mnemonic, msz, n, vector_ty>;
9525bdd1243dSDimitry Andric
9526bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $PNg, [$Rn]",
9527bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, 0), 1>;
9528bdd1243dSDimitry Andric}
9529bdd1243dSDimitry Andric
9530bdd1243dSDimitry Andric
9531bdd1243dSDimitry Andric// SME2 multi-vec contiguous store (scalar plus scalar, four registers)
9532bdd1243dSDimitry Andricclass sve2p1_mem_cst_ss_4z<string mnemonic, bits<2> msz, bit n,
9533bdd1243dSDimitry Andric                           RegisterOperand vector_ty, RegisterOperand gpr_ty>
9534bdd1243dSDimitry Andric    : I<(outs ),
9535bdd1243dSDimitry Andric        (ins vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
9536bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $PNg, [$Rn, $Rm]",
9537bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9538bdd1243dSDimitry Andric  bits<3> Zt;
9539bdd1243dSDimitry Andric  bits<5> Rm;
9540bdd1243dSDimitry Andric  bits<5> Rn;
9541bdd1243dSDimitry Andric  bits<3> PNg;
9542bdd1243dSDimitry Andric  let Inst{31-21} = 0b10100000001;
9543bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9544bdd1243dSDimitry Andric  let Inst{15}    = 0b1;
9545bdd1243dSDimitry Andric  let Inst{14-13} = msz;
9546bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
9547bdd1243dSDimitry Andric  let Inst{9-5} = Rn;
9548bdd1243dSDimitry Andric  let Inst{4-2} = Zt;
9549bdd1243dSDimitry Andric  let Inst{1}   = 0b0;
9550bdd1243dSDimitry Andric  let Inst{0}   = n;
9551bdd1243dSDimitry Andric
9552bdd1243dSDimitry Andric  let mayStore = 1;
9553bdd1243dSDimitry Andric}
9554bdd1243dSDimitry Andric
9555bdd1243dSDimitry Andric
9556bdd1243dSDimitry Andric// SME2 multi-vec contiguous store (scalar plus immediate, four registers)
9557bdd1243dSDimitry Andricclass sve2p1_mem_cst_si_4z<string mnemonic, bits<2> msz, bit n,
9558bdd1243dSDimitry Andric                           RegisterOperand vector_ty>
9559bdd1243dSDimitry Andric    : I<(outs ),
9560bdd1243dSDimitry Andric        (ins vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s4:$imm4),
9561bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $PNg, [$Rn, $imm4, mul vl]",
9562bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9563bdd1243dSDimitry Andric  bits<3> Zt;
9564bdd1243dSDimitry Andric  bits<5> Rn;
9565bdd1243dSDimitry Andric  bits<3> PNg;
9566bdd1243dSDimitry Andric  bits<4> imm4;
9567bdd1243dSDimitry Andric  let Inst{31-20} = 0b101000000110;
9568bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
9569bdd1243dSDimitry Andric  let Inst{15}    = 0b1;
9570bdd1243dSDimitry Andric  let Inst{14-13} = msz;
9571bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
9572bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
9573bdd1243dSDimitry Andric  let Inst{4-2}   = Zt;
9574bdd1243dSDimitry Andric  let Inst{1}     = 0b0;
9575bdd1243dSDimitry Andric  let Inst{0}     = n;
9576bdd1243dSDimitry Andric
957706c3fb27SDimitry Andric  let hasSideEffects = 0;
9578bdd1243dSDimitry Andric  let mayStore = 1;
9579bdd1243dSDimitry Andric}
9580bdd1243dSDimitry Andric
9581bdd1243dSDimitry Andric
9582bdd1243dSDimitry Andricmulticlass sve2p1_mem_cst_si_4z<string mnemonic, bits<2> msz, bit n,
9583bdd1243dSDimitry Andric                                RegisterOperand vector_ty> {
9584bdd1243dSDimitry Andric  def NAME : sve2p1_mem_cst_si_4z<mnemonic, msz, n, vector_ty>;
9585bdd1243dSDimitry Andric
9586bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $PNg, [$Rn]",
9587bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn,0), 1>;
9588bdd1243dSDimitry Andric}
9589bdd1243dSDimitry Andric
9590bdd1243dSDimitry Andric// SVE predicate count (predicate-as-counter)
9591bdd1243dSDimitry Andricclass sve2p1_pcount_pn<string mnemonic, bits<3> opc, bits<2> sz, PNRRegOp pnrty>
9592bdd1243dSDimitry Andric   : I<(outs GPR64:$Rd),
9593bdd1243dSDimitry Andric       (ins pnrty:$PNn, sve_vec_len_specifier_enum:$vl),
9594bdd1243dSDimitry Andric       mnemonic, "\t$Rd, $PNn, $vl",
9595bdd1243dSDimitry Andric       "", []>, Sched<[]> {
9596bdd1243dSDimitry Andric  bits<5> Rd;
9597bdd1243dSDimitry Andric  bits<4> PNn;
9598bdd1243dSDimitry Andric  bits<1> vl;
9599bdd1243dSDimitry Andric  let Inst{31-24} = 0b00100101;
9600bdd1243dSDimitry Andric  let Inst{23-22} = sz;
9601bdd1243dSDimitry Andric  let Inst{21-19} = 0b100;
9602bdd1243dSDimitry Andric  let Inst{18-16} = opc;
9603bdd1243dSDimitry Andric  let Inst{15-11} = 0b10000;
9604bdd1243dSDimitry Andric  let Inst{10}    = vl;
9605bdd1243dSDimitry Andric  let Inst{9}     = 0b1;
9606bdd1243dSDimitry Andric  let Inst{8-5}   = PNn;
9607bdd1243dSDimitry Andric  let Inst{4-0}   = Rd;
960806c3fb27SDimitry Andric
960906c3fb27SDimitry Andric  let hasSideEffects = 0;
9610bdd1243dSDimitry Andric}
9611bdd1243dSDimitry Andric
9612bdd1243dSDimitry Andricmulticlass sve2p1_pcount_pn<string mnemonic, bits<3> opc> {
9613bdd1243dSDimitry Andric  def _B : sve2p1_pcount_pn<mnemonic, opc, 0b00, PNR8>;
9614bdd1243dSDimitry Andric  def _H : sve2p1_pcount_pn<mnemonic, opc, 0b01, PNR16>;
9615bdd1243dSDimitry Andric  def _S : sve2p1_pcount_pn<mnemonic, opc, 0b10, PNR32>;
9616bdd1243dSDimitry Andric  def _D : sve2p1_pcount_pn<mnemonic, opc, 0b11, PNR64>;
961706c3fb27SDimitry Andric
961806c3fb27SDimitry Andric  defm : SVE2p1_Cntp_Pat<i64, int_aarch64_sve_cntp_c8,  aarch64svcount, !cast<Instruction>(NAME # _B)>;
961906c3fb27SDimitry Andric  defm : SVE2p1_Cntp_Pat<i64, int_aarch64_sve_cntp_c16, aarch64svcount, !cast<Instruction>(NAME # _H)>;
962006c3fb27SDimitry Andric  defm : SVE2p1_Cntp_Pat<i64, int_aarch64_sve_cntp_c32, aarch64svcount, !cast<Instruction>(NAME # _S)>;
962106c3fb27SDimitry Andric  defm : SVE2p1_Cntp_Pat<i64, int_aarch64_sve_cntp_c64, aarch64svcount, !cast<Instruction>(NAME # _D)>;
9622bdd1243dSDimitry Andric}
9623bdd1243dSDimitry Andric
9624bdd1243dSDimitry Andric
9625bdd1243dSDimitry Andric// SVE integer compare scalar count and limit (predicate-as-counter)
9626bdd1243dSDimitry Andricclass sve2p1_int_while_rr_pn<string mnemonic, bits<2> sz, bits<3> opc,
9627bdd1243dSDimitry Andric                             PNRP8to15RegOp pnrty>
9628bdd1243dSDimitry Andric    : I<(outs pnrty:$PNd), (ins GPR64:$Rn, GPR64:$Rm, sve_vec_len_specifier_enum:$vl),
9629bdd1243dSDimitry Andric        mnemonic, "\t$PNd, $Rn, $Rm, $vl",
9630bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9631bdd1243dSDimitry Andric  bits<3> PNd;
9632bdd1243dSDimitry Andric  bits<5> Rn;
9633bdd1243dSDimitry Andric  bits<1> vl;
9634bdd1243dSDimitry Andric  bits<5> Rm;
9635bdd1243dSDimitry Andric  let Inst{31-24} = 0b00100101;
9636bdd1243dSDimitry Andric  let Inst{23-22} = sz;
9637bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
9638bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9639bdd1243dSDimitry Andric  let Inst{15-14} = 0b01;
9640bdd1243dSDimitry Andric  let Inst{13}    = vl;
9641bdd1243dSDimitry Andric  let Inst{12}    = 0b0;
9642bdd1243dSDimitry Andric  let Inst{11-10} = opc{2-1};
9643bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
9644bdd1243dSDimitry Andric  let Inst{4}     = 0b1;
9645bdd1243dSDimitry Andric  let Inst{3}     = opc{0};
9646bdd1243dSDimitry Andric  let Inst{2-0}   = PNd;
9647bdd1243dSDimitry Andric
9648bdd1243dSDimitry Andric  let Defs = [NZCV];
964906c3fb27SDimitry Andric  let hasSideEffects = 0;
9650bdd1243dSDimitry Andric}
9651bdd1243dSDimitry Andric
9652bdd1243dSDimitry Andric
9653bdd1243dSDimitry Andricmulticlass sve2p1_int_while_rr_pn<string mnemonic, bits<3> opc> {
9654bdd1243dSDimitry Andric def _B : sve2p1_int_while_rr_pn<mnemonic, 0b00, opc, PNR8_p8to15>;
9655bdd1243dSDimitry Andric def _H : sve2p1_int_while_rr_pn<mnemonic, 0b01, opc, PNR16_p8to15>;
9656bdd1243dSDimitry Andric def _S : sve2p1_int_while_rr_pn<mnemonic, 0b10, opc, PNR32_p8to15>;
9657bdd1243dSDimitry Andric def _D : sve2p1_int_while_rr_pn<mnemonic, 0b11, opc, PNR64_p8to15>;
965806c3fb27SDimitry Andric
965906c3fb27SDimitry Andric defm : SVE2p1_While_PN_Pat<aarch64svcount, !cast<SDPatternOperator>("int_aarch64_sve_" # mnemonic # "_c8"),
966006c3fb27SDimitry Andric                            i64, !cast<Instruction>(NAME # _B)>;
966106c3fb27SDimitry Andric defm : SVE2p1_While_PN_Pat<aarch64svcount, !cast<SDPatternOperator>("int_aarch64_sve_" # mnemonic # "_c16"),
966206c3fb27SDimitry Andric                            i64, !cast<Instruction>(NAME # _H)>;
966306c3fb27SDimitry Andric defm : SVE2p1_While_PN_Pat<aarch64svcount, !cast<SDPatternOperator>("int_aarch64_sve_" # mnemonic # "_c32"),
966406c3fb27SDimitry Andric                            i64, !cast<Instruction>(NAME # _S)>;
966506c3fb27SDimitry Andric defm : SVE2p1_While_PN_Pat<aarch64svcount, !cast<SDPatternOperator>("int_aarch64_sve_" # mnemonic # "_c64"),
966606c3fb27SDimitry Andric                            i64, !cast<Instruction>(NAME # _D)>;
9667bdd1243dSDimitry Andric}
9668bdd1243dSDimitry Andric
9669bdd1243dSDimitry Andric
9670bdd1243dSDimitry Andric// SVE integer compare scalar count and limit (predicate pair)
9671bdd1243dSDimitry Andricclass sve2p1_int_while_rr_pair<string mnemonic, bits<2> sz, bits<3> opc,
9672bdd1243dSDimitry Andric                             RegisterOperand ppr_ty>
9673bdd1243dSDimitry Andric    : I<(outs ppr_ty:$Pd), (ins GPR64:$Rn, GPR64:$Rm),
9674bdd1243dSDimitry Andric        mnemonic, "\t$Pd, $Rn, $Rm",
9675bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9676bdd1243dSDimitry Andric  bits<3> Pd;
9677bdd1243dSDimitry Andric  bits<5> Rn;
9678bdd1243dSDimitry Andric  bits<5> Rm;
9679bdd1243dSDimitry Andric  let Inst{31-24} = 0b00100101;
9680bdd1243dSDimitry Andric  let Inst{23-22} = sz;
9681bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
9682bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9683bdd1243dSDimitry Andric  let Inst{15-12} = 0b0101;
9684bdd1243dSDimitry Andric  let Inst{11-10} = opc{2-1};
9685bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
9686bdd1243dSDimitry Andric  let Inst{4}     = 0b1;
9687bdd1243dSDimitry Andric  let Inst{3-1}   = Pd;
9688bdd1243dSDimitry Andric  let Inst{0}     = opc{0};
9689bdd1243dSDimitry Andric
9690bdd1243dSDimitry Andric  let Defs = [NZCV];
969106c3fb27SDimitry Andric  let hasSideEffects = 0;
9692bdd1243dSDimitry Andric}
9693bdd1243dSDimitry Andric
9694bdd1243dSDimitry Andric
9695bdd1243dSDimitry Andricmulticlass sve2p1_int_while_rr_pair<string mnemonic, bits<3> opc> {
9696bdd1243dSDimitry Andric def _B : sve2p1_int_while_rr_pair<mnemonic, 0b00, opc, PP_b_mul_r>;
9697bdd1243dSDimitry Andric def _H : sve2p1_int_while_rr_pair<mnemonic, 0b01, opc, PP_h_mul_r>;
9698bdd1243dSDimitry Andric def _S : sve2p1_int_while_rr_pair<mnemonic, 0b10, opc, PP_s_mul_r>;
9699bdd1243dSDimitry Andric def _D : sve2p1_int_while_rr_pair<mnemonic, 0b11, opc, PP_d_mul_r>;
9700bdd1243dSDimitry Andric}
9701bdd1243dSDimitry Andric
9702bdd1243dSDimitry Andric
9703bdd1243dSDimitry Andricclass sve_mem_128b_gld_64_unscaled<string mnemonic>
9704bdd1243dSDimitry Andric    : I<(outs Z_q:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm),
9705bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $Pg/z, [$Zn, $Rm]",
9706bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9707bdd1243dSDimitry Andric  bits<5> Zt;
9708bdd1243dSDimitry Andric  bits<5> Zn;
9709bdd1243dSDimitry Andric  bits<3> Pg;
9710bdd1243dSDimitry Andric  bits<5> Rm;
9711bdd1243dSDimitry Andric  let Inst{31-21} = 0b11000100000;
9712bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9713bdd1243dSDimitry Andric  let Inst{15-13} = 0b101;
9714bdd1243dSDimitry Andric  let Inst{12-10} = Pg;
9715bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
9716bdd1243dSDimitry Andric  let Inst{4-0}   = Zt;
9717bdd1243dSDimitry Andric
971806c3fb27SDimitry Andric  let hasSideEffects = 0;
9719bdd1243dSDimitry Andric  let mayLoad = 1;
9720bdd1243dSDimitry Andric}
9721bdd1243dSDimitry Andric
9722bdd1243dSDimitry Andric
97235f757f3fSDimitry Andricmulticlass sve_mem_128b_gld_64_unscaled<string mnemonic, SDPatternOperator op> {
9724bdd1243dSDimitry Andric  def NAME : sve_mem_128b_gld_64_unscaled<mnemonic>;
9725bdd1243dSDimitry Andric
9726bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Zn]",
9727bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
97285f757f3fSDimitry Andric
97295f757f3fSDimitry Andric
97305f757f3fSDimitry Andric  def : Pat<(nxv2i64 (op (nxv2i1 PPR3bAny:$Pg),  (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv2i64)),
97315f757f3fSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
97325f757f3fSDimitry Andric  def : Pat<(nxv4i32 (op (nxv4i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn),  (i64 GPR64sp:$Rm), nxv4i32)),
97335f757f3fSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
97345f757f3fSDimitry Andric  def : Pat<(nxv8i16 (op (nxv8i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8i16)),
97355f757f3fSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
97365f757f3fSDimitry Andric  def : Pat<(nxv16i8 (op (nxv16i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv16i8)),
97375f757f3fSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
97385f757f3fSDimitry Andric
97395f757f3fSDimitry Andric  def : Pat<(nxv2f64 (op (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv2f64)),
97405f757f3fSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
97415f757f3fSDimitry Andric  def : Pat<(nxv4f32 (op (nxv4i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv4f32)),
97425f757f3fSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
97435f757f3fSDimitry Andric  def : Pat<(nxv8f16 (op (nxv8i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8f16)),
97445f757f3fSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
97455f757f3fSDimitry Andric  def : Pat<(nxv8bf16 (op (nxv8i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8bf16)),
97465f757f3fSDimitry Andric            (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
9747bdd1243dSDimitry Andric}
9748bdd1243dSDimitry Andric
9749bdd1243dSDimitry Andricclass sve_mem_sst_128b_64_unscaled<string mnemonic>
9750bdd1243dSDimitry Andric    : I<(outs ), (ins Z_q:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm),
9751bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $Pg, [$Zn, $Rm]",
9752bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9753bdd1243dSDimitry Andric  bits<5> Zt;
9754bdd1243dSDimitry Andric  bits<5> Zn;
9755bdd1243dSDimitry Andric  bits<3> Pg;
9756bdd1243dSDimitry Andric  bits<5> Rm;
9757bdd1243dSDimitry Andric  let Inst{31-21} = 0b11100100001;
9758bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9759bdd1243dSDimitry Andric  let Inst{15-13} = 0b001;
9760bdd1243dSDimitry Andric  let Inst{12-10} = Pg;
9761bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
9762bdd1243dSDimitry Andric  let Inst{4-0}   = Zt;
9763bdd1243dSDimitry Andric
976406c3fb27SDimitry Andric  let hasSideEffects = 0;
9765bdd1243dSDimitry Andric  let mayStore = 1;
9766bdd1243dSDimitry Andric}
9767bdd1243dSDimitry Andric
9768bdd1243dSDimitry Andric
97695f757f3fSDimitry Andricmulticlass sve_mem_sst_128b_64_unscaled<string mnemonic, SDPatternOperator op> {
9770bdd1243dSDimitry Andric  def NAME : sve_mem_sst_128b_64_unscaled<mnemonic>;
9771bdd1243dSDimitry Andric
9772bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $Pg, [$Zn]",
9773bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
97745f757f3fSDimitry Andric
97755f757f3fSDimitry Andric  def : Pat<(op (nxv2i64 Z_q:$Zt), (nxv2i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv2i64),
97765f757f3fSDimitry Andric            (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
97775f757f3fSDimitry Andric  def : Pat<(op (nxv4i32 Z_q:$Zt), (nxv4i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv4i32),
97785f757f3fSDimitry Andric            (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
97795f757f3fSDimitry Andric  def : Pat<(op (nxv8i16 Z_q:$Zt), (nxv8i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8i16),
97805f757f3fSDimitry Andric            (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp,ZPR64:$Zn, GPR64:$Rm)>;
97815f757f3fSDimitry Andric  def : Pat<(op (nxv16i8 Z_q:$Zt), (nxv16i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv16i8),
97825f757f3fSDimitry Andric            (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
97835f757f3fSDimitry Andric
97845f757f3fSDimitry Andric  def : Pat<(op (nxv2f64 Z_q:$Zt), (nxv2i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv2f64),
97855f757f3fSDimitry Andric            (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
97865f757f3fSDimitry Andric  def : Pat<(op (nxv4f32 Z_q:$Zt), (nxv4i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv4f32),
97875f757f3fSDimitry Andric            (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
97885f757f3fSDimitry Andric  def : Pat<(op (nxv8f16 Z_q:$Zt), (nxv8i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8f16),
97895f757f3fSDimitry Andric            (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
97905f757f3fSDimitry Andric  def : Pat<(op (nxv8bf16 Z_q:$Zt), (nxv8i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8bf16),
97915f757f3fSDimitry Andric            (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
9792bdd1243dSDimitry Andric}
9793bdd1243dSDimitry Andric
9794bdd1243dSDimitry Andric
9795bdd1243dSDimitry Andric// SVE contiguous load (quadwords, scalar plus immediate)
9796bdd1243dSDimitry Andricclass sve_mem_128b_cld_si<bits<2> dtype, string mnemonic>
9797bdd1243dSDimitry Andric    : I<(outs Z_q:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
9798bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
9799bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9800bdd1243dSDimitry Andric  bits<5> Zt;
9801bdd1243dSDimitry Andric  bits<5> Rn;
9802bdd1243dSDimitry Andric  bits<3> Pg;
9803bdd1243dSDimitry Andric  bits<4> imm4;
9804bdd1243dSDimitry Andric  let Inst{31-25} = 0b1010010;
9805bdd1243dSDimitry Andric  let Inst{24-23} = dtype;
9806bdd1243dSDimitry Andric  let Inst{22-20} = 0b001;
9807bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
9808bdd1243dSDimitry Andric  let Inst{15-13} = 0b001;
9809bdd1243dSDimitry Andric  let Inst{12-10} = Pg;
9810bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
9811bdd1243dSDimitry Andric  let Inst{4-0}   = Zt;
9812bdd1243dSDimitry Andric
981306c3fb27SDimitry Andric  let hasSideEffects = 0;
9814bdd1243dSDimitry Andric  let mayLoad = 1;
9815bdd1243dSDimitry Andric}
9816bdd1243dSDimitry Andric
9817bdd1243dSDimitry Andricmulticlass sve_mem_128b_cld_si<bits<2> dtype, string mnemonic> {
9818bdd1243dSDimitry Andric  def NAME : sve_mem_128b_cld_si<dtype, mnemonic>;
9819bdd1243dSDimitry Andric
9820bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Rn]",
9821bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
9822bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Rn]",
9823bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) ZPR128:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
9824bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Rn, $imm4, mul vl]",
9825bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) ZPR128:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
9826bdd1243dSDimitry Andric}
9827bdd1243dSDimitry Andric
9828bdd1243dSDimitry Andric
9829bdd1243dSDimitry Andric// SVE contiguous load (quadwords, scalar plus scalar)
9830bdd1243dSDimitry Andricclass sve_mem_128b_cld_ss<bits<2> dtype, string mnemonic, RegisterOperand gprsh_ty>
9831bdd1243dSDimitry Andric    : I<(outs Z_q:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprsh_ty:$Rm),
9832bdd1243dSDimitry Andric        mnemonic, "\t$Zt, $Pg/z, [$Rn, $Rm]", "",
9833bdd1243dSDimitry Andric        []>, Sched<[]> {
9834bdd1243dSDimitry Andric  bits<5> Zt;
9835bdd1243dSDimitry Andric  bits<5> Rn;
9836bdd1243dSDimitry Andric  bits<3> Pg;
9837bdd1243dSDimitry Andric  bits<5> Rm;
9838bdd1243dSDimitry Andric  let Inst{31-25} = 0b1010010;
9839bdd1243dSDimitry Andric  let Inst{24-23} = dtype;
9840bdd1243dSDimitry Andric  let Inst{22-21} = 0b00;
9841bdd1243dSDimitry Andric  let Inst{20-16} = Rm;
9842bdd1243dSDimitry Andric  let Inst{15-13} = 0b100;
9843bdd1243dSDimitry Andric  let Inst{12-10} = Pg;
9844bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
9845bdd1243dSDimitry Andric  let Inst{4-0}   = Zt;
9846bdd1243dSDimitry Andric
984706c3fb27SDimitry Andric  let hasSideEffects = 0;
9848bdd1243dSDimitry Andric  let mayLoad = 1;
9849bdd1243dSDimitry Andric}
9850bdd1243dSDimitry Andric
9851bdd1243dSDimitry Andricmulticlass sve_mem_128b_cld_ss<bits<2> dtype, string mnemonic, RegisterOperand gprsh_ty> {
9852bdd1243dSDimitry Andric  def NAME : sve_mem_128b_cld_ss<dtype, mnemonic, gprsh_ty>;
9853bdd1243dSDimitry Andric
9854bdd1243dSDimitry Andric  def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Rn, $Rm]",
9855bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME) ZPR128:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprsh_ty:$Rm), 0>;
9856bdd1243dSDimitry Andric}
9857bdd1243dSDimitry Andric
9858bdd1243dSDimitry Andric
9859bdd1243dSDimitry Andric// SVE floating-point recursive reduction (quadwords)
9860bdd1243dSDimitry Andricclass sve2p1_fp_reduction_q<bits<2> sz, bits<3> opc, string mnemonic,
9861bdd1243dSDimitry Andric                            RegisterOperand zpr_ty, string vec_sfx>
9862bdd1243dSDimitry Andric    : I<(outs V128:$Vd), (ins PPR3bAny:$Pg, zpr_ty:$Zn),
9863bdd1243dSDimitry Andric        mnemonic, "\t$Vd." # vec_sfx # ", $Pg, $Zn",
9864bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9865bdd1243dSDimitry Andric  bits<5> Vd;
9866bdd1243dSDimitry Andric  bits<5> Zn;
9867bdd1243dSDimitry Andric  bits<3> Pg;
9868bdd1243dSDimitry Andric  let Inst{31-24} = 0b01100100;
9869bdd1243dSDimitry Andric  let Inst{23-22} = sz;
9870bdd1243dSDimitry Andric  let Inst{21-19} = 0b010;
9871bdd1243dSDimitry Andric  let Inst{18-16} = opc;
9872bdd1243dSDimitry Andric  let Inst{15-13} = 0b101;
9873bdd1243dSDimitry Andric  let Inst{12-10} = Pg;
9874bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
9875bdd1243dSDimitry Andric  let Inst{4-0}   = Vd;
987606c3fb27SDimitry Andric
987706c3fb27SDimitry Andric  let hasSideEffects = 0;
987806c3fb27SDimitry Andric  let mayRaiseFPException = 1;
9879bdd1243dSDimitry Andric}
9880bdd1243dSDimitry Andric
98815f757f3fSDimitry Andricmulticlass sve2p1_fp_reduction_q<bits<3> opc, string mnemonic, SDPatternOperator op> {
9882bdd1243dSDimitry Andric  def _H : sve2p1_fp_reduction_q<0b01, opc, mnemonic, ZPR16, "8h">;
9883bdd1243dSDimitry Andric  def _S : sve2p1_fp_reduction_q<0b10, opc, mnemonic, ZPR32, "4s">;
9884bdd1243dSDimitry Andric  def _D : sve2p1_fp_reduction_q<0b11, opc, mnemonic, ZPR64, "2d">;
98855f757f3fSDimitry Andric
98865f757f3fSDimitry Andric  def : SVE_2_Op_Pat<v8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
98875f757f3fSDimitry Andric  def : SVE_2_Op_Pat<v4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
98885f757f3fSDimitry Andric  def : SVE_2_Op_Pat<v2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
9889bdd1243dSDimitry Andric}
9890bdd1243dSDimitry Andric
9891bdd1243dSDimitry Andric
9892bdd1243dSDimitry Andric// SVE Permute Vector - Quadwords (DUPQ)
9893bdd1243dSDimitry Andricclass sve2p1_dupq<bits<5> ind_tsz, string mnemonic, ZPRRegOp zprty, Operand itype>
9894bdd1243dSDimitry Andric    : I<(outs zprty:$Zd), (ins zprty:$Zn, itype:$index),
9895bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn$index",
9896bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9897bdd1243dSDimitry Andric  bits<5> Zd;
9898bdd1243dSDimitry Andric  bits<5> Zn;
9899bdd1243dSDimitry Andric  let Inst{31-21} = 0b00000101001;
9900bdd1243dSDimitry Andric  let Inst{20-16} = ind_tsz;
9901bdd1243dSDimitry Andric  let Inst{15-10} = 0b001001;
9902bdd1243dSDimitry Andric  let Inst{9-5} = Zn;
9903bdd1243dSDimitry Andric  let Inst{4-0} = Zd;
990406c3fb27SDimitry Andric
990506c3fb27SDimitry Andric  let hasSideEffects = 0;
9906bdd1243dSDimitry Andric}
9907bdd1243dSDimitry Andric
9908*0fca6ea1SDimitry Andricmulticlass sve2p1_dupq<string mnemonic, SDPatternOperator Op> {
9909*0fca6ea1SDimitry Andric  def _B : sve2p1_dupq<{?, ?, ?, ?, 1}, mnemonic, ZPR8, VectorIndexB32b_timm> {
9910bdd1243dSDimitry Andric    bits<4> index;
9911bdd1243dSDimitry Andric    let Inst{20-17} = index;
9912bdd1243dSDimitry Andric  }
9913*0fca6ea1SDimitry Andric  def _H : sve2p1_dupq<{?, ?, ?, 1, 0}, mnemonic, ZPR16, VectorIndexH32b_timm> {
9914bdd1243dSDimitry Andric    bits<3> index;
9915bdd1243dSDimitry Andric    let Inst{20-18} = index;
9916bdd1243dSDimitry Andric  }
9917*0fca6ea1SDimitry Andric  def _S : sve2p1_dupq<{?, ?, 1, 0, 0}, mnemonic, ZPR32, VectorIndexS32b_timm> {
9918bdd1243dSDimitry Andric    bits<2> index;
9919bdd1243dSDimitry Andric    let Inst{20-19} = index;
9920bdd1243dSDimitry Andric  }
9921*0fca6ea1SDimitry Andric  def _D : sve2p1_dupq<{?, 1, 0, 0, 0}, mnemonic, ZPR64, VectorIndexD32b_timm> {
9922bdd1243dSDimitry Andric    bits<1> index;
9923bdd1243dSDimitry Andric    let Inst{20} = index;
9924bdd1243dSDimitry Andric  }
9925*0fca6ea1SDimitry Andric
9926*0fca6ea1SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv16i8, Op, nxv16i8, i32, VectorIndexB32b_timm, !cast<Instruction>(NAME # _B)>;
9927*0fca6ea1SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv8i16, Op, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
9928*0fca6ea1SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv4i32, Op, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
9929*0fca6ea1SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv2i64, Op, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
9930*0fca6ea1SDimitry Andric
9931*0fca6ea1SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv8f16, Op, nxv8f16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
9932*0fca6ea1SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv4f32, Op, nxv4f32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
9933*0fca6ea1SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv2f64, Op, nxv2f64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
9934*0fca6ea1SDimitry Andric  def : SVE_2_Op_Imm_Pat<nxv8bf16, Op, nxv8bf16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
9935bdd1243dSDimitry Andric}
9936bdd1243dSDimitry Andric
9937bdd1243dSDimitry Andric
9938bdd1243dSDimitry Andric// SVE Permute Vector - Quadwords (EXTQ)
9939bdd1243dSDimitry Andricclass sve2p1_extq<string mnemonic>
99405f757f3fSDimitry Andric    : I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn, ZPR8:$Zm, timm32_0_15:$imm4),
9941bdd1243dSDimitry Andric        mnemonic, "\t$Zdn, $_Zdn, $Zm, $imm4",
9942bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9943bdd1243dSDimitry Andric  bits<5> Zdn;
9944bdd1243dSDimitry Andric  bits<5> Zm;
9945bdd1243dSDimitry Andric  bits<4> imm4;
9946bdd1243dSDimitry Andric  let Inst{31-20} = 0b000001010110;
9947bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
9948bdd1243dSDimitry Andric  let Inst{15-10} = 0b001001;
9949bdd1243dSDimitry Andric  let Inst{9-5} = Zm;
9950bdd1243dSDimitry Andric  let Inst{4-0} = Zdn;
9951bdd1243dSDimitry Andric
9952bdd1243dSDimitry Andric  let Constraints = "$Zdn = $_Zdn";
9953bdd1243dSDimitry Andric  let DestructiveInstType = DestructiveOther;
9954bdd1243dSDimitry Andric  let ElementSize = ZPR8.ElementSize;
995506c3fb27SDimitry Andric  let hasSideEffects = 0;
9956bdd1243dSDimitry Andric}
9957bdd1243dSDimitry Andric
99585f757f3fSDimitry Andricmulticlass sve2p1_extq<string mnemonic, SDPatternOperator Op> {
99595f757f3fSDimitry Andric  def NAME : sve2p1_extq<mnemonic>;
99605f757f3fSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv16i8, Op, nxv16i8, nxv16i8, i32, timm32_0_15, !cast<Instruction>(NAME)>;
99615f757f3fSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8i16, Op, nxv8i16, nxv8i16, i32, timm32_0_15, !cast<Instruction>(NAME)>;
99625f757f3fSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4i32, Op, nxv4i32, nxv4i32, i32, timm32_0_15, !cast<Instruction>(NAME)>;
99635f757f3fSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2i64, Op, nxv2i64, nxv2i64, i32, timm32_0_15, !cast<Instruction>(NAME)>;
99645f757f3fSDimitry Andric
99655f757f3fSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8f16, Op, nxv8f16, nxv8f16, i32, timm32_0_15, !cast<Instruction>(NAME)>;
99665f757f3fSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv4f32, Op, nxv4f32, nxv4f32, i32, timm32_0_15, !cast<Instruction>(NAME)>;
99675f757f3fSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv2f64, Op, nxv2f64, nxv2f64, i32, timm32_0_15, !cast<Instruction>(NAME)>;
99685f757f3fSDimitry Andric  def : SVE_3_Op_Imm_Pat<nxv8bf16, Op, nxv8bf16, nxv8bf16, i32, timm32_0_15, !cast<Instruction>(NAME
99695f757f3fSDimitry Andric)>;
99705f757f3fSDimitry Andric}
9971bdd1243dSDimitry Andric
9972bdd1243dSDimitry Andric// SVE move predicate from vector
9973bdd1243dSDimitry Andricclass sve2p1_vector_to_pred<bits<4> opc, string mnemonic,
9974bdd1243dSDimitry Andric                            PPRRegOp ppr_ty, Operand itype>
9975bdd1243dSDimitry Andric    : I<(outs ppr_ty:$Pd), (ins ZPRAny:$Zn, itype:$index),
9976bdd1243dSDimitry Andric        mnemonic, "\t$Pd, $Zn$index",
9977bdd1243dSDimitry Andric        "", []>, Sched<[]> {
9978bdd1243dSDimitry Andric  bits<4> Pd;
9979bdd1243dSDimitry Andric  bits<5> Zn;
9980bdd1243dSDimitry Andric  let Inst{31-24} = 0b00000101;
9981bdd1243dSDimitry Andric  let Inst{23-22} = opc{3-2};
9982bdd1243dSDimitry Andric  let Inst{21-19} = 0b101;
9983bdd1243dSDimitry Andric  let Inst{18-17} = opc{1-0};
9984bdd1243dSDimitry Andric  let Inst{16-10} = 0b0001110;
9985bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
9986bdd1243dSDimitry Andric  let Inst{4}     = 0b0;
9987bdd1243dSDimitry Andric  let Inst{3-0}   = Pd;
998806c3fb27SDimitry Andric
998906c3fb27SDimitry Andric  let hasSideEffects = 0;
9990bdd1243dSDimitry Andric}
9991bdd1243dSDimitry Andric
99925f757f3fSDimitry Andricmulticlass sve2p1_vector_to_pred<string mnemonic, SDPatternOperator Op_lane, SDPatternOperator Op> {
99935f757f3fSDimitry Andric  def _B : sve2p1_vector_to_pred<{0, 0, 0, 1}, mnemonic, PPR8,  VectorIndex032b>;
9994bdd1243dSDimitry Andric  def _H : sve2p1_vector_to_pred<{0, 0, 1, ?}, mnemonic, PPR16, VectorIndexD32b> {
9995bdd1243dSDimitry Andric    bits<1> index;
9996bdd1243dSDimitry Andric    let Inst{17} = index;
9997bdd1243dSDimitry Andric  }
9998bdd1243dSDimitry Andric  def _S : sve2p1_vector_to_pred<{0, 1, ?, ?}, mnemonic, PPR32, VectorIndexS32b> {
9999bdd1243dSDimitry Andric    bits<2> index;
10000bdd1243dSDimitry Andric    let Inst{18-17} = index;
10001bdd1243dSDimitry Andric  }
10002bdd1243dSDimitry Andric  def _D : sve2p1_vector_to_pred<{1, ?, ?, ?}, mnemonic, PPR64, VectorIndexH32b> {
10003bdd1243dSDimitry Andric    bits<3> index;
10004bdd1243dSDimitry Andric    let Inst{22}    = index{2};
10005bdd1243dSDimitry Andric    let Inst{18-17} = index{1-0};
10006bdd1243dSDimitry Andric  }
10007bdd1243dSDimitry Andric
10008bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$Pd, $Zn",
10009bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME # _B) PPR8:$Pd, ZPRAny:$Zn, 0), 1>;
100101db9f3b2SDimitry Andric  def : InstAlias<mnemonic # "\t$Pd, $Zn",
100111db9f3b2SDimitry Andric                 (!cast<Instruction>(NAME # _H) PPR16:$Pd, ZPRAny:$Zn, 0), 0>;
100121db9f3b2SDimitry Andric  def : InstAlias<mnemonic # "\t$Pd, $Zn",
100131db9f3b2SDimitry Andric                 (!cast<Instruction>(NAME # _S) PPR32:$Pd, ZPRAny:$Zn, 0), 0>;
100141db9f3b2SDimitry Andric  def : InstAlias<mnemonic # "\t$Pd, $Zn",
100151db9f3b2SDimitry Andric                 (!cast<Instruction>(NAME # _D) PPR64:$Pd, ZPRAny:$Zn, 0), 0>;
100165f757f3fSDimitry Andric
100175f757f3fSDimitry Andric  // any_lane
100185f757f3fSDimitry Andric  def : Pat<(nxv16i1 (Op_lane (nxv16i8 ZPRAny:$Zn), (i32 timm32_0_0:$Idx))),
100195f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _B) ZPRAny:$Zn, timm32_0_0:$Idx)>;
100205f757f3fSDimitry Andric  def : Pat<(nxv8i1 (Op_lane (nxv8i16 ZPRAny:$Zn), (i32 timm32_0_1:$Idx))),
100215f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _H) ZPRAny:$Zn, timm32_0_1:$Idx)>;
100225f757f3fSDimitry Andric  def : Pat<(nxv4i1 (Op_lane (nxv4i32 ZPRAny:$Zn), (i32 timm32_0_3:$Idx))),
100235f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _S) ZPRAny:$Zn, timm32_0_3:$Idx)>;
100245f757f3fSDimitry Andric  def : Pat<(nxv2i1 (Op_lane (nxv2i64 ZPRAny:$Zn), (i32 timm32_0_7:$Idx))),
100255f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _D) ZPRAny:$Zn, timm32_0_7:$Idx)>;
100265f757f3fSDimitry Andric // lane_0
100275f757f3fSDimitry Andric def : Pat<(nxv16i1 (Op (nxv16i8 ZPRAny:$Zn))),
100285f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _B) ZPRAny:$Zn, 0)>;
100295f757f3fSDimitry Andric  def : Pat<(nxv8i1 (Op (nxv8i16 ZPRAny:$Zn))),
100305f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _H) ZPRAny:$Zn, 0)>;
100315f757f3fSDimitry Andric  def : Pat<(nxv4i1 (Op (nxv4i32 ZPRAny:$Zn))),
100325f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _S) ZPRAny:$Zn, 0)>;
100335f757f3fSDimitry Andric  def : Pat<(nxv2i1 (Op (nxv2i64 ZPRAny:$Zn))),
100345f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _D) ZPRAny:$Zn, 0)>;
10035bdd1243dSDimitry Andric}
10036bdd1243dSDimitry Andric
10037bdd1243dSDimitry Andric
10038bdd1243dSDimitry Andric// SVE move predicate into vector
10039bdd1243dSDimitry Andricclass sve2p1_pred_to_vector<bits<4> opc, string mnemonic,
10040bdd1243dSDimitry Andric                            PPRRegOp ppr_ty, Operand itype>
10041bdd1243dSDimitry Andric    : I<(outs ZPRAny:$Zd), (ins ZPRAny:$_Zd, itype:$index, ppr_ty:$Pn),
10042bdd1243dSDimitry Andric        mnemonic, "\t$Zd$index, $Pn",
10043bdd1243dSDimitry Andric        "", []>, Sched<[]> {
10044bdd1243dSDimitry Andric  bits<5> Zd;
10045bdd1243dSDimitry Andric  bits<4> Pn;
10046bdd1243dSDimitry Andric  let Inst{31-24} = 0b00000101;
10047bdd1243dSDimitry Andric  let Inst{23-22} = opc{3-2};
10048bdd1243dSDimitry Andric  let Inst{21-19} = 0b101;
10049bdd1243dSDimitry Andric  let Inst{18-17} = opc{1-0};
10050bdd1243dSDimitry Andric  let Inst{16-9}  = 0b10011100;
10051bdd1243dSDimitry Andric  let Inst{8-5}   = Pn;
10052bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
10053bdd1243dSDimitry Andric
10054bdd1243dSDimitry Andric  let Constraints = "$Zd = $_Zd";
1005506c3fb27SDimitry Andric  let hasSideEffects = 0;
10056bdd1243dSDimitry Andric}
10057bdd1243dSDimitry Andric
100585f757f3fSDimitry Andricmulticlass sve2p1_pred_to_vector<string mnemonic, SDPatternOperator MergeOp,
100595f757f3fSDimitry Andric                                 SDPatternOperator ZeroOp> {
10060bdd1243dSDimitry Andric  def _B : sve2p1_pred_to_vector<{0, 0, 0, 1}, mnemonic, PPR8,  VectorIndex0>;
10061bdd1243dSDimitry Andric  def _H : sve2p1_pred_to_vector<{0, 0, 1, ?}, mnemonic, PPR16, VectorIndexD32b> {
10062bdd1243dSDimitry Andric    bits<1> index;
10063bdd1243dSDimitry Andric    let Inst{17} = index;
10064bdd1243dSDimitry Andric  }
10065bdd1243dSDimitry Andric  def _S : sve2p1_pred_to_vector<{0, 1, ?, ?}, mnemonic, PPR32, VectorIndexS32b> {
10066bdd1243dSDimitry Andric    bits<2> index;
10067bdd1243dSDimitry Andric    let Inst{18-17} = index;
10068bdd1243dSDimitry Andric  }
10069bdd1243dSDimitry Andric  def _D : sve2p1_pred_to_vector<{1, ?, ?, ?}, mnemonic, PPR64, VectorIndexH32b> {
10070bdd1243dSDimitry Andric    bits<3> index;
10071bdd1243dSDimitry Andric    let Inst{22}    = index{2};
10072bdd1243dSDimitry Andric    let Inst{18-17} = index{1-0};
10073bdd1243dSDimitry Andric  }
10074bdd1243dSDimitry Andric
10075bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$Zd, $Pn",
10076bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME # _B) ZPRAny:$Zd, 0, PPR8:$Pn), 1>;
100771db9f3b2SDimitry Andric  def : InstAlias<mnemonic # "\t$Zd, $Pn",
100781db9f3b2SDimitry Andric                 (!cast<Instruction>(NAME # _H) ZPRAny:$Zd, 0, PPR16:$Pn), 0>;
100791db9f3b2SDimitry Andric  def : InstAlias<mnemonic # "\t$Zd, $Pn",
100801db9f3b2SDimitry Andric                 (!cast<Instruction>(NAME # _S) ZPRAny:$Zd, 0, PPR32:$Pn), 0>;
100811db9f3b2SDimitry Andric  def : InstAlias<mnemonic # "\t$Zd, $Pn",
100821db9f3b2SDimitry Andric                 (!cast<Instruction>(NAME # _D) ZPRAny:$Zd, 0, PPR64:$Pn), 0>;
100835f757f3fSDimitry Andric
100845f757f3fSDimitry Andric  // Merge
100855f757f3fSDimitry Andric  def : Pat<(nxv8i16 (MergeOp (nxv8i16 ZPRAny:$Zd), (nxv8i1 PPR16:$Pn), (i32 timm32_1_1:$Idx))),
100865f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _H) ZPRAny:$Zd, timm32_1_1:$Idx, PPR16:$Pn)>;
100875f757f3fSDimitry Andric  def : Pat<(nxv4i32 (MergeOp (nxv4i32 ZPRAny:$Zd), (nxv4i1 PPR32:$Pn), (i32 timm32_1_3:$Idx))),
100885f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _S) ZPRAny:$Zd, timm32_1_3:$Idx, PPR32:$Pn)>;
100895f757f3fSDimitry Andric  def : Pat<(nxv2i64 (MergeOp (nxv2i64 ZPRAny:$Zd), (nxv2i1 PPR64:$Pn), (i32 timm32_1_7:$Idx))),
100905f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _D) ZPRAny:$Zd, timm32_1_7:$Idx, PPR64:$Pn)>;
100915f757f3fSDimitry Andric
100925f757f3fSDimitry Andric  // Zero
100935f757f3fSDimitry Andric  def : Pat<(nxv16i8 (ZeroOp (nxv16i1 PPR8:$Pn))),
100945f757f3fSDimitry Andric           (!cast<Instruction>(NAME # _B) (IMPLICIT_DEF), 0, PPR8:$Pn)>;
100955f757f3fSDimitry Andric  def : Pat<(nxv8i16 (ZeroOp (nxv8i1 PPR16:$Pn))),
100965f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _H) (IMPLICIT_DEF), 0, PPR16:$Pn)>;
100975f757f3fSDimitry Andric  def : Pat<(nxv4i32 (ZeroOp (nxv4i1 PPR32:$Pn))),
100985f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _S) (IMPLICIT_DEF), 0, PPR32:$Pn)>;
100995f757f3fSDimitry Andric  def : Pat<(nxv2i64 (ZeroOp (nxv2i1 PPR64:$Pn))),
101005f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _D) (IMPLICIT_DEF), 0, PPR64:$Pn)>;
10101bdd1243dSDimitry Andric}
10102bdd1243dSDimitry Andric
10103bdd1243dSDimitry Andric
10104bdd1243dSDimitry Andric// SVE bitwise logical/add/min/max reductions (quadwords)
10105bdd1243dSDimitry Andricclass sve2p1_int_reduce_q<bits<2> sz, bits<4> opc, string mnemonic,
10106bdd1243dSDimitry Andric                          RegisterOperand zpr_ty, string vec_sfx>
10107bdd1243dSDimitry Andric    : I<(outs V128:$Vd), (ins PPR3bAny:$Pg, zpr_ty:$Zn),
10108bdd1243dSDimitry Andric        mnemonic, "\t$Vd." # vec_sfx # ", $Pg, $Zn",
10109bdd1243dSDimitry Andric        "", []>, Sched<[]> {
10110bdd1243dSDimitry Andric  bits<5> Vd;
10111bdd1243dSDimitry Andric  bits<5> Zn;
10112bdd1243dSDimitry Andric  bits<3> Pg;
10113bdd1243dSDimitry Andric  let Inst{31-24} = 0b00000100;
10114bdd1243dSDimitry Andric  let Inst{23-22} = sz;
10115bdd1243dSDimitry Andric  let Inst{21}    = 0b0;
10116bdd1243dSDimitry Andric  let Inst{20-19} = opc{3-2};
10117bdd1243dSDimitry Andric  let Inst{18}    = 0b1;
10118bdd1243dSDimitry Andric  let Inst{17-16} = opc{1-0};
10119bdd1243dSDimitry Andric  let Inst{15-13} = 0b001;
10120bdd1243dSDimitry Andric  let Inst{12-10} = Pg;
10121bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
10122bdd1243dSDimitry Andric  let Inst{4-0}   = Vd;
1012306c3fb27SDimitry Andric
1012406c3fb27SDimitry Andric  let hasSideEffects = 0;
10125bdd1243dSDimitry Andric}
10126bdd1243dSDimitry Andric
101275f757f3fSDimitry Andricmulticlass sve2p1_int_reduce_q<bits<4> opc, string mnemonic, SDPatternOperator op> {
10128bdd1243dSDimitry Andric  def _B : sve2p1_int_reduce_q<0b00, opc, mnemonic, ZPR8,  "16b">;
10129bdd1243dSDimitry Andric  def _H : sve2p1_int_reduce_q<0b01, opc, mnemonic, ZPR16, "8h">;
10130bdd1243dSDimitry Andric  def _S : sve2p1_int_reduce_q<0b10, opc, mnemonic, ZPR32, "4s">;
10131bdd1243dSDimitry Andric  def _D : sve2p1_int_reduce_q<0b11, opc, mnemonic, ZPR64, "2d">;
101325f757f3fSDimitry Andric
101335f757f3fSDimitry Andric  def : SVE_2_Op_Pat<v16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
101345f757f3fSDimitry Andric  def : SVE_2_Op_Pat<v8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
101355f757f3fSDimitry Andric  def : SVE_2_Op_Pat<v4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
101365f757f3fSDimitry Andric  def : SVE_2_Op_Pat<v2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
10137bdd1243dSDimitry Andric}
10138bdd1243dSDimitry Andric
10139bdd1243dSDimitry Andric
10140bdd1243dSDimitry Andric// SVE permute vector elements (quadwords)
10141bdd1243dSDimitry Andricclass sve2p1_permute_vec_elems_q<bits<2> sz, bits<3> opc, string mnemonic,
10142bdd1243dSDimitry Andric                                 ZPRRegOp zpr_ty, RegisterOperand src1_ty>
10143bdd1243dSDimitry Andric    : I<(outs zpr_ty:$Zd), (ins src1_ty:$Zn, zpr_ty:$Zm),
10144bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn, $Zm",
10145bdd1243dSDimitry Andric        "", []>, Sched<[]> {
10146bdd1243dSDimitry Andric  bits<5> Zd;
10147bdd1243dSDimitry Andric  bits<5> Zn;
10148bdd1243dSDimitry Andric  bits<5> Zm;
10149bdd1243dSDimitry Andric  let Inst{31-24} = 0b01000100;
10150bdd1243dSDimitry Andric  let Inst{23-22} = sz;
10151bdd1243dSDimitry Andric  let Inst{21}    = 0b0;
10152bdd1243dSDimitry Andric  let Inst{20-16} = Zm;
10153bdd1243dSDimitry Andric  let Inst{15-13} = 0b111;
10154bdd1243dSDimitry Andric  let Inst{12-10} = opc;
10155bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
10156bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
1015706c3fb27SDimitry Andric
1015806c3fb27SDimitry Andric  let hasSideEffects = 0;
10159bdd1243dSDimitry Andric}
10160bdd1243dSDimitry Andric
101615f757f3fSDimitry Andricmulticlass sve2p1_permute_vec_elems_q<bits<3> opc, string mnemonic,
101625f757f3fSDimitry Andric                                      SDPatternOperator op> {
10163bdd1243dSDimitry Andric  def _B : sve2p1_permute_vec_elems_q<0b00, opc, mnemonic, ZPR8,  ZPR8>;
10164bdd1243dSDimitry Andric  def _H : sve2p1_permute_vec_elems_q<0b01, opc, mnemonic, ZPR16, ZPR16>;
10165bdd1243dSDimitry Andric  def _S : sve2p1_permute_vec_elems_q<0b10, opc, mnemonic, ZPR32, ZPR32>;
10166bdd1243dSDimitry Andric  def _D : sve2p1_permute_vec_elems_q<0b11, opc, mnemonic, ZPR64, ZPR64>;
101675f757f3fSDimitry Andric
101685f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
101695f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
101705f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
101715f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
101725f757f3fSDimitry Andric
101735f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
101745f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
101755f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
101765f757f3fSDimitry Andric
101775f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
10178bdd1243dSDimitry Andric}
10179bdd1243dSDimitry Andric
101805f757f3fSDimitry Andricmulticlass sve2p1_tblq<string mnemonic, SDPatternOperator op> {
10181bdd1243dSDimitry Andric  def _B : sve2p1_permute_vec_elems_q<0b00, 0b110, mnemonic, ZPR8,  Z_b>;
10182bdd1243dSDimitry Andric  def _H : sve2p1_permute_vec_elems_q<0b01, 0b110, mnemonic, ZPR16, Z_h>;
10183bdd1243dSDimitry Andric  def _S : sve2p1_permute_vec_elems_q<0b10, 0b110, mnemonic, ZPR32, Z_s>;
10184bdd1243dSDimitry Andric  def _D : sve2p1_permute_vec_elems_q<0b11, 0b110, mnemonic, ZPR64, Z_d>;
101855f757f3fSDimitry Andric
101865f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
101875f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
101885f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
101895f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
101905f757f3fSDimitry Andric
101915f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
101925f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
101935f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
101945f757f3fSDimitry Andric
101955f757f3fSDimitry Andric  def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>;
101965f757f3fSDimitry Andric}
101975f757f3fSDimitry Andric
101985f757f3fSDimitry Andric//===----------------------------------------------------------------------===//
101995f757f3fSDimitry Andric// SVE2 FP8 Instructions
102005f757f3fSDimitry Andric//===----------------------------------------------------------------------===//
102015f757f3fSDimitry Andric
102025f757f3fSDimitry Andric// FP8 upconvert
102035f757f3fSDimitry Andricclass sve2_fp8_cvt_single<bit L, bits<2> opc, string mnemonic,
102045f757f3fSDimitry Andric                          ZPRRegOp dst_ty, ZPRRegOp src_ty>
102055f757f3fSDimitry Andric    : I<(outs dst_ty:$Zd), (ins src_ty:$Zn),
102065f757f3fSDimitry Andric      mnemonic, "\t$Zd, $Zn",
102075f757f3fSDimitry Andric      "", []>, Sched<[]>{
102085f757f3fSDimitry Andric  bits<5> Zd;
102095f757f3fSDimitry Andric  bits<5> Zn;
102105f757f3fSDimitry Andric  let Inst{31-17} = 0b011001010000100;
102115f757f3fSDimitry Andric  let Inst{16}    = L;
102125f757f3fSDimitry Andric  let Inst{15-12} = 0b0011;
102135f757f3fSDimitry Andric  let Inst{11-10} = opc;
102145f757f3fSDimitry Andric  let Inst{9-5}   = Zn;
102155f757f3fSDimitry Andric  let Inst{4-0}   = Zd;
102165f757f3fSDimitry Andric}
102175f757f3fSDimitry Andric
102185f757f3fSDimitry Andricmulticlass sve2_fp8_cvt_single<bit L, bits<2> opc, string mnemonic> {
102195f757f3fSDimitry Andric  def _BtoH : sve2_fp8_cvt_single<L, opc, mnemonic, ZPR16, ZPR8>;
102205f757f3fSDimitry Andric}
102215f757f3fSDimitry Andric
102225f757f3fSDimitry Andric// FP8 downconvert
102235f757f3fSDimitry Andricclass sve2_fp8_down_cvt_single<bits<2> opc, string mnemonic,
102245f757f3fSDimitry Andric                              ZPRRegOp dst_ty, RegisterOperand src_ty>
102255f757f3fSDimitry Andric    : I<(outs dst_ty:$Zd), (ins src_ty:$Zn),
102265f757f3fSDimitry Andric      mnemonic, "\t$Zd, $Zn",
102275f757f3fSDimitry Andric      "", []>, Sched<[]>{
102285f757f3fSDimitry Andric  bits<5> Zd;
102295f757f3fSDimitry Andric  bits<4> Zn;
102305f757f3fSDimitry Andric  let Inst{31-12} = 0b01100101000010100011;
102315f757f3fSDimitry Andric  let Inst{11-10} = opc;
102325f757f3fSDimitry Andric  let Inst{9-6} = Zn;
102335f757f3fSDimitry Andric  let Inst{5} = 0b0;
102345f757f3fSDimitry Andric  let Inst{4-0} = Zd;
102355f757f3fSDimitry Andric}
102365f757f3fSDimitry Andric
102375f757f3fSDimitry Andricmulticlass sve2_fp8_down_cvt_single<bits<2> opc, string mnemonic, RegisterOperand src> {
102385f757f3fSDimitry Andric  def NAME : sve2_fp8_down_cvt_single<opc, mnemonic, ZPR8, src>;
102395f757f3fSDimitry Andric}
102405f757f3fSDimitry Andric
102415f757f3fSDimitry Andric// FP8 Widening Multiply-Add Long - Indexed Group
102425f757f3fSDimitry Andricclass sve2_fp8_mla_long_by_indexed_elem<bit T, string mnemonic>
102435f757f3fSDimitry Andric    : I<(outs ZPR16:$Zda),
102445f757f3fSDimitry Andric      (ins ZPR16:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, VectorIndexB:$imm4),
102455f757f3fSDimitry Andric      mnemonic, "\t$Zda, $Zn, $Zm$imm4",
102465f757f3fSDimitry Andric      "", []>, Sched<[]>{
102475f757f3fSDimitry Andric  bits<5> Zda;
102485f757f3fSDimitry Andric  bits<5> Zn;
102495f757f3fSDimitry Andric  bits<3> Zm;
102505f757f3fSDimitry Andric  bits<4> imm4;
102515f757f3fSDimitry Andric  let Inst{31-24} = 0b01100100;
102525f757f3fSDimitry Andric  let Inst{23}    = T;
102535f757f3fSDimitry Andric  let Inst{22-21} = 0b01;
102545f757f3fSDimitry Andric  let Inst{20-19} = imm4{3-2};
102555f757f3fSDimitry Andric  let Inst{18-16} = Zm;
102565f757f3fSDimitry Andric  let Inst{15-12} = 0b0101;
102575f757f3fSDimitry Andric  let Inst{11-10} = imm4{1-0};
102585f757f3fSDimitry Andric  let Inst{9-5}   = Zn;
102595f757f3fSDimitry Andric  let Inst{4-0}   = Zda;
102605f757f3fSDimitry Andric  let Constraints = "$Zda = $_Zda";
102615f757f3fSDimitry Andric  let DestructiveInstType = DestructiveOther;
102625f757f3fSDimitry Andric  let ElementSize         = ZPR16.ElementSize;
102635f757f3fSDimitry Andric}
102645f757f3fSDimitry Andric
102655f757f3fSDimitry Andric// FP8 Widening Multiply-Add (Long)/(Long Long) Group
102665f757f3fSDimitry Andricclass sve2_fp8_mla<bits<3>opc, ZPRRegOp dst_ty, string mnemonic>
102675f757f3fSDimitry Andric    : I<(outs dst_ty:$Zda),
102685f757f3fSDimitry Andric      (ins dst_ty:$_Zda, ZPR8:$Zn, ZPR8:$Zm),
102695f757f3fSDimitry Andric      mnemonic, "\t$Zda, $Zn, $Zm",
102705f757f3fSDimitry Andric      "", []>, Sched<[]>{
102715f757f3fSDimitry Andric  bits<5> Zda;
102725f757f3fSDimitry Andric  bits<5> Zn;
102735f757f3fSDimitry Andric  bits<5> Zm;
102745f757f3fSDimitry Andric  let Inst{31-24} = 0b01100100;
102755f757f3fSDimitry Andric  let Inst{23}    = opc{2};
102765f757f3fSDimitry Andric  let Inst{22-21} = 0b01;
102775f757f3fSDimitry Andric  let Inst{20-16} = Zm;
102785f757f3fSDimitry Andric  let Inst{15-14} = 0b10;
102795f757f3fSDimitry Andric  let Inst{13-12} = opc{1-0};
102805f757f3fSDimitry Andric  let Inst{11-10} = 0b10;
102815f757f3fSDimitry Andric  let Inst{9-5}   = Zn;
102825f757f3fSDimitry Andric  let Inst{4-0}   = Zda;
102835f757f3fSDimitry Andric  let Constraints = "$Zda = $_Zda";
102845f757f3fSDimitry Andric  let DestructiveInstType = DestructiveOther;
102855f757f3fSDimitry Andric  let ElementSize         = dst_ty.ElementSize;
102865f757f3fSDimitry Andric}
102875f757f3fSDimitry Andric
102885f757f3fSDimitry Andric// FP8 Widening Multiply-Add Long Long - Indexed Group
102895f757f3fSDimitry Andricclass sve2_fp8_mla_long_long_by_indexed_elem<bits<2> TT, string mnemonic>
102905f757f3fSDimitry Andric    : I<(outs ZPR32:$Zda),
102915f757f3fSDimitry Andric      (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, VectorIndexB:$imm4),
102925f757f3fSDimitry Andric      mnemonic, "\t$Zda, $Zn, $Zm$imm4",
102935f757f3fSDimitry Andric      "", []>, Sched<[]>{
102945f757f3fSDimitry Andric  bits<5> Zda;
102955f757f3fSDimitry Andric  bits<5> Zn;
102965f757f3fSDimitry Andric  bits<3> Zm;
102975f757f3fSDimitry Andric  bits<4> imm4;
102985f757f3fSDimitry Andric  let Inst{31-24} = 0b01100100;
102995f757f3fSDimitry Andric  let Inst{23-22} = TT;
103005f757f3fSDimitry Andric  let Inst{21}    = 0b1;
103015f757f3fSDimitry Andric  let Inst{20-19} = imm4{3-2};
103025f757f3fSDimitry Andric  let Inst{18-16} = Zm;
103035f757f3fSDimitry Andric  let Inst{15-12} = 0b1100;
103045f757f3fSDimitry Andric  let Inst{11-10} = imm4{1-0};
103055f757f3fSDimitry Andric  let Inst{9-5}   = Zn;
103065f757f3fSDimitry Andric  let Inst{4-0}   = Zda;
103075f757f3fSDimitry Andric  let Constraints = "$Zda = $_Zda";
103085f757f3fSDimitry Andric  let DestructiveInstType = DestructiveOther;
103095f757f3fSDimitry Andric  let ElementSize         = ZPR32.ElementSize;
103105f757f3fSDimitry Andric}
103115f757f3fSDimitry Andric
103125f757f3fSDimitry Andric// FP8 Widening Dot-Product - Indexed Group
103135f757f3fSDimitry Andricmulticlass sve2_fp8_dot_indexed<string mnemonic>{
103145f757f3fSDimitry Andric  def NAME : sve_float_dot_indexed<0b0, ZPR16, ZPR8, ZPR3b8, VectorIndexH, mnemonic> {
103155f757f3fSDimitry Andric    bits<3> iop;
103165f757f3fSDimitry Andric    let Inst{20-19} = iop{2-1};
103175f757f3fSDimitry Andric    let Inst{11} = iop{0};
103185f757f3fSDimitry Andric    let Inst{10} = 0b1;
103195f757f3fSDimitry Andric  }
103205f757f3fSDimitry Andric}
103215f757f3fSDimitry Andric
103225f757f3fSDimitry Andric// FP8 Look up table
103235f757f3fSDimitry Andricclass sve2_lut_vector_index<ZPRRegOp zd_ty, RegisterOperand zn_ty,
103245f757f3fSDimitry Andric                            Operand idx_ty, bits<4>opc, string mnemonic>
103255f757f3fSDimitry Andric    : I<(outs zd_ty:$Zd), (ins zn_ty:$Zn, ZPRAny:$Zm, idx_ty:$idx),
103265f757f3fSDimitry Andric      mnemonic, "\t$Zd, $Zn, $Zm$idx",
103275f757f3fSDimitry Andric      "", []>, Sched<[]> {
103285f757f3fSDimitry Andric  bits<5> Zd;
103295f757f3fSDimitry Andric  bits<5> Zn;
103305f757f3fSDimitry Andric  bits<5> Zm;
103315f757f3fSDimitry Andric  let Inst{31-24} = 0b01000101;
103325f757f3fSDimitry Andric  let Inst{22}    = opc{3};
103335f757f3fSDimitry Andric  let Inst{21}    = 0b1;
103345f757f3fSDimitry Andric  let Inst{20-16} = Zm;
103355f757f3fSDimitry Andric  let Inst{15-13} = 0b101;
103365f757f3fSDimitry Andric  let Inst{12-10} = opc{2-0};
103375f757f3fSDimitry Andric  let Inst{9-5}   = Zn;
103385f757f3fSDimitry Andric  let Inst{4-0}   = Zd;
103395f757f3fSDimitry Andric}
103405f757f3fSDimitry Andric
103415f757f3fSDimitry Andric// FP8 Look up table read with 2-bit indices
103425f757f3fSDimitry Andricmulticlass sve2_luti2_vector_index<string mnemonic> {
103435f757f3fSDimitry Andric  def _B : sve2_lut_vector_index<ZPR8, Z_b, VectorIndexS32b, {?, 0b100}, mnemonic> {
103445f757f3fSDimitry Andric    bits<2> idx;
103455f757f3fSDimitry Andric    let Inst{23-22} = idx;
103465f757f3fSDimitry Andric  }
103475f757f3fSDimitry Andric  def _H : sve2_lut_vector_index<ZPR16, Z_h, VectorIndexH32b, {?,?,0b10}, mnemonic> {
103485f757f3fSDimitry Andric    bits<3> idx;
103495f757f3fSDimitry Andric    let Inst{23-22} = idx{2-1};
103505f757f3fSDimitry Andric    let Inst{12}    = idx{0};
103515f757f3fSDimitry Andric  }
103525f757f3fSDimitry Andric}
103535f757f3fSDimitry Andric
103545f757f3fSDimitry Andric// FP8 Look up table read with 4-bit indices
103555f757f3fSDimitry Andricmulticlass sve2_luti4_vector_index<string mnemonic> {
103565f757f3fSDimitry Andric  def _B : sve2_lut_vector_index<ZPR8, Z_b, VectorIndexD32b, 0b1001, mnemonic> {
103575f757f3fSDimitry Andric    bit idx;
103585f757f3fSDimitry Andric    let Inst{23} = idx;
103595f757f3fSDimitry Andric  }
103605f757f3fSDimitry Andric  def _H : sve2_lut_vector_index<ZPR16, Z_h, VectorIndexS32b, {?, 0b111}, mnemonic> {
103615f757f3fSDimitry Andric    bits<2> idx;
103625f757f3fSDimitry Andric    let Inst{23-22} = idx;
103635f757f3fSDimitry Andric  }
103645f757f3fSDimitry Andric}
103655f757f3fSDimitry Andric
103665f757f3fSDimitry Andric// FP8 Look up table read with 4-bit indices (two contiguous registers)
103675f757f3fSDimitry Andricmulticlass sve2_luti4_vector_vg2_index<string mnemonic> {
103685f757f3fSDimitry Andric  def _H : sve2_lut_vector_index<ZPR16, ZZ_h, VectorIndexS32b, {?, 0b101}, mnemonic> {
103695f757f3fSDimitry Andric    bits<2> idx;
103705f757f3fSDimitry Andric    let Inst{23-22} = idx;
103715f757f3fSDimitry Andric  }
10372bdd1243dSDimitry Andric}
10373cb14a3feSDimitry Andric
10374cb14a3feSDimitry Andric//===----------------------------------------------------------------------===//
10375cb14a3feSDimitry Andric// Checked Pointer Arithmetic (FEAT_CPA)
10376cb14a3feSDimitry Andric//===----------------------------------------------------------------------===//
10377cb14a3feSDimitry Andricclass sve_int_mad_cpa<string asm>
10378cb14a3feSDimitry Andric    : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, ZPR64:$Zm, ZPR64:$Za),
10379cb14a3feSDimitry Andric        asm, "\t$Zdn, $Zm, $Za", "", []>, Sched<[]> {
10380cb14a3feSDimitry Andric  bits<5> Zdn;
10381cb14a3feSDimitry Andric  bits<5> Zm;
10382cb14a3feSDimitry Andric  bits<5> Za;
10383cb14a3feSDimitry Andric  let Inst{31-24} = 0b01000100;
10384cb14a3feSDimitry Andric  let Inst{23-22} = 0b11; // sz
10385cb14a3feSDimitry Andric  let Inst{21}    = 0b0;
10386cb14a3feSDimitry Andric  let Inst{20-16} = Zm;
10387cb14a3feSDimitry Andric  let Inst{15}    = 0b1;
10388cb14a3feSDimitry Andric  let Inst{14-10} = 0b10110; // opc
10389cb14a3feSDimitry Andric  let Inst{9-5}   = Za;
10390cb14a3feSDimitry Andric  let Inst{4-0}   = Zdn;
10391cb14a3feSDimitry Andric
10392cb14a3feSDimitry Andric  let Constraints = "$Zdn = $_Zdn";
10393cb14a3feSDimitry Andric  let DestructiveInstType = DestructiveOther;
10394cb14a3feSDimitry Andric  let ElementSize = ZPR64.ElementSize;
10395cb14a3feSDimitry Andric  let hasSideEffects = 0;
10396cb14a3feSDimitry Andric}
10397cb14a3feSDimitry Andric
10398cb14a3feSDimitry Andricclass sve_int_mla_cpa<string asm>
10399cb14a3feSDimitry Andric    : sve2_int_mla<0b11, 0b10100, asm, ZPR64, ZPR64> {
10400cb14a3feSDimitry Andric  let Inst{15} = 0b1;
10401cb14a3feSDimitry Andric
10402cb14a3feSDimitry Andric  let ElementSize = ZPR64.ElementSize;
10403cb14a3feSDimitry Andric}
10404