1//=-- SVEInstrFormats.td - AArch64 SVE Instruction classes -*- tablegen -*--=// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// AArch64 Scalable Vector Extension (SVE) Instruction Class Definitions. 10// 11//===----------------------------------------------------------------------===// 12 13def SDT_AArch64Setcc : SDTypeProfile<1, 4, [ 14 SDTCisVec<0>, SDTCisVec<1>, SDTCisVec<2>, SDTCisVec<3>, 15 SDTCVecEltisVT<0, i1>, SDTCVecEltisVT<1, i1>, SDTCisSameAs<2, 3>, 16 SDTCisVT<4, OtherVT> 17]>; 18 19def AArch64setcc_z : SDNode<"AArch64ISD::SETCC_MERGE_ZERO", SDT_AArch64Setcc>; 20 21def SVEPatternOperand : AsmOperandClass { 22 let Name = "SVEPattern"; 23 let ParserMethod = "tryParseSVEPattern"; 24 let PredicateMethod = "isSVEPattern"; 25 let RenderMethod = "addImmOperands"; 26 let DiagnosticType = "InvalidSVEPattern"; 27} 28 29def sve_pred_enum : Operand<i32>, TImmLeaf<i32, [{ 30 return (((uint32_t)Imm) < 32); 31 }]> { 32 33 let PrintMethod = "printSVEPattern"; 34 let ParserMatchClass = SVEPatternOperand; 35} 36 37def SVEPrefetchOperand : AsmOperandClass { 38 let Name = "SVEPrefetch"; 39 let ParserMethod = "tryParsePrefetch<true>"; 40 let PredicateMethod = "isPrefetch"; 41 let RenderMethod = "addPrefetchOperands"; 42} 43 44def sve_prfop : Operand<i32>, TImmLeaf<i32, [{ 45 return (((uint32_t)Imm) <= 15); 46 }]> { 47 let PrintMethod = "printPrefetchOp<true>"; 48 let ParserMatchClass = SVEPrefetchOperand; 49} 50 51class SVELogicalImmOperand<int Width> : AsmOperandClass { 52 let Name = "SVELogicalImm" # Width; 53 let DiagnosticType = "LogicalSecondSource"; 54 let PredicateMethod = "isLogicalImm<int" # Width # "_t>"; 55 let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>"; 56} 57 58def sve_logical_imm8 : Operand<i64> { 59 let ParserMatchClass = SVELogicalImmOperand<8>; 60 let PrintMethod = "printLogicalImm<int8_t>"; 61 62 let MCOperandPredicate = [{ 63 if (!MCOp.isImm()) 64 return false; 65 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64); 66 return AArch64_AM::isSVEMaskOfIdenticalElements<int8_t>(Val); 67 }]; 68} 69 70def sve_logical_imm16 : Operand<i64> { 71 let ParserMatchClass = SVELogicalImmOperand<16>; 72 let PrintMethod = "printLogicalImm<int16_t>"; 73 74 let MCOperandPredicate = [{ 75 if (!MCOp.isImm()) 76 return false; 77 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64); 78 return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val); 79 }]; 80} 81 82def sve_logical_imm32 : Operand<i64> { 83 let ParserMatchClass = SVELogicalImmOperand<32>; 84 let PrintMethod = "printLogicalImm<int32_t>"; 85 86 let MCOperandPredicate = [{ 87 if (!MCOp.isImm()) 88 return false; 89 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64); 90 return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val); 91 }]; 92} 93 94class SVEPreferredLogicalImmOperand<int Width> : AsmOperandClass { 95 let Name = "SVEPreferredLogicalImm" # Width; 96 let PredicateMethod = "isSVEPreferredLogicalImm<int" # Width # "_t>"; 97 let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>"; 98} 99 100def sve_preferred_logical_imm16 : Operand<i64> { 101 let ParserMatchClass = SVEPreferredLogicalImmOperand<16>; 102 let PrintMethod = "printSVELogicalImm<int16_t>"; 103 104 let MCOperandPredicate = [{ 105 if (!MCOp.isImm()) 106 return false; 107 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64); 108 return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val) && 109 AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val); 110 }]; 111} 112 113def sve_preferred_logical_imm32 : Operand<i64> { 114 let ParserMatchClass = SVEPreferredLogicalImmOperand<32>; 115 let PrintMethod = "printSVELogicalImm<int32_t>"; 116 117 let MCOperandPredicate = [{ 118 if (!MCOp.isImm()) 119 return false; 120 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64); 121 return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val) && 122 AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val); 123 }]; 124} 125 126def sve_preferred_logical_imm64 : Operand<i64> { 127 let ParserMatchClass = SVEPreferredLogicalImmOperand<64>; 128 let PrintMethod = "printSVELogicalImm<int64_t>"; 129 130 let MCOperandPredicate = [{ 131 if (!MCOp.isImm()) 132 return false; 133 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64); 134 return AArch64_AM::isSVEMaskOfIdenticalElements<int64_t>(Val) && 135 AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val); 136 }]; 137} 138 139class SVELogicalImmNotOperand<int Width> : AsmOperandClass { 140 let Name = "SVELogicalImm" # Width # "Not"; 141 let DiagnosticType = "LogicalSecondSource"; 142 let PredicateMethod = "isLogicalImm<int" # Width # "_t>"; 143 let RenderMethod = "addLogicalImmNotOperands<int" # Width # "_t>"; 144} 145 146def sve_logical_imm8_not : Operand<i64> { 147 let ParserMatchClass = SVELogicalImmNotOperand<8>; 148} 149 150def sve_logical_imm16_not : Operand<i64> { 151 let ParserMatchClass = SVELogicalImmNotOperand<16>; 152} 153 154def sve_logical_imm32_not : Operand<i64> { 155 let ParserMatchClass = SVELogicalImmNotOperand<32>; 156} 157 158class SVEShiftedImmOperand<int ElementWidth, string Infix, string Predicate> 159 : AsmOperandClass { 160 let Name = "SVE" # Infix # "Imm" # ElementWidth; 161 let DiagnosticType = "Invalid" # Name; 162 let RenderMethod = "addImmWithOptionalShiftOperands<8>"; 163 let ParserMethod = "tryParseImmWithOptionalShift"; 164 let PredicateMethod = Predicate; 165} 166 167def SVECpyImmOperand8 : SVEShiftedImmOperand<8, "Cpy", "isSVECpyImm<int8_t>">; 168def SVECpyImmOperand16 : SVEShiftedImmOperand<16, "Cpy", "isSVECpyImm<int16_t>">; 169def SVECpyImmOperand32 : SVEShiftedImmOperand<32, "Cpy", "isSVECpyImm<int32_t>">; 170def SVECpyImmOperand64 : SVEShiftedImmOperand<64, "Cpy", "isSVECpyImm<int64_t>">; 171 172def SVEAddSubImmOperand8 : SVEShiftedImmOperand<8, "AddSub", "isSVEAddSubImm<int8_t>">; 173def SVEAddSubImmOperand16 : SVEShiftedImmOperand<16, "AddSub", "isSVEAddSubImm<int16_t>">; 174def SVEAddSubImmOperand32 : SVEShiftedImmOperand<32, "AddSub", "isSVEAddSubImm<int32_t>">; 175def SVEAddSubImmOperand64 : SVEShiftedImmOperand<64, "AddSub", "isSVEAddSubImm<int64_t>">; 176 177class imm8_opt_lsl<int ElementWidth, string printType, 178 AsmOperandClass OpndClass> 179 : Operand<i32> { 180 let EncoderMethod = "getImm8OptLsl"; 181 let DecoderMethod = "DecodeImm8OptLsl<" # ElementWidth # ">"; 182 let PrintMethod = "printImm8OptLsl<" # printType # ">"; 183 let ParserMatchClass = OpndClass; 184 let MIOperandInfo = (ops i32imm, i32imm); 185} 186 187def cpy_imm8_opt_lsl_i8 : imm8_opt_lsl<8, "int8_t", SVECpyImmOperand8>; 188def cpy_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "int16_t", SVECpyImmOperand16>; 189def cpy_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "int32_t", SVECpyImmOperand32>; 190def cpy_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "int64_t", SVECpyImmOperand64>; 191 192def addsub_imm8_opt_lsl_i8 : imm8_opt_lsl<8, "uint8_t", SVEAddSubImmOperand8>; 193def addsub_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "uint16_t", SVEAddSubImmOperand16>; 194def addsub_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "uint32_t", SVEAddSubImmOperand32>; 195def addsub_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "uint64_t", SVEAddSubImmOperand64>; 196 197def SVEAddSubImm8Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i8>", []>; 198def SVEAddSubImm16Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i16>", []>; 199def SVEAddSubImm32Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i32>", []>; 200def SVEAddSubImm64Pat : ComplexPattern<i64, 2, "SelectSVEAddSubImm<MVT::i64>", []>; 201 202def SVELogicalImm8Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i8>", []>; 203def SVELogicalImm16Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i16>", []>; 204def SVELogicalImm32Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i32>", []>; 205def SVELogicalImm64Pat : ComplexPattern<i64, 1, "SelectSVELogicalImm<MVT::i64>", []>; 206 207def SVELogicalImm8NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i8, true>", []>; 208def SVELogicalImm16NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i16, true>", []>; 209def SVELogicalImm32NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i32, true>", []>; 210def SVELogicalImm64NotPat : ComplexPattern<i64, 1, "SelectSVELogicalImm<MVT::i64, true>", []>; 211 212def SVE8BitLslImm32 : ComplexPattern<i32, 2, "SelectSVE8BitLslImm", [imm]>; 213def SVE8BitLslImm64 : ComplexPattern<i64, 2, "SelectSVE8BitLslImm", [imm]>; 214class SVE8BitLslImm<ValueType ty> { 215 ComplexPattern Pat = !cond( 216 !eq(ty, i32): SVE8BitLslImm32, 217 !eq(ty, i64): SVE8BitLslImm64); 218} 219 220def SVEArithUImm8Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i8>", []>; 221def SVEArithUImm16Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i16>", []>; 222def SVEArithUImm32Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i32>", []>; 223def SVEArithUImm64Pat : ComplexPattern<i64, 1, "SelectSVEArithImm<MVT::i64>", []>; 224 225def SVEArithSImmPat32 : ComplexPattern<i32, 1, "SelectSVESignedArithImm", []>; 226def SVEArithSImmPat64 : ComplexPattern<i64, 1, "SelectSVESignedArithImm", []>; 227 228def SVEShiftImmL8 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 7>", []>; 229def SVEShiftImmL16 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 15>", []>; 230def SVEShiftImmL32 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 31>", []>; 231def SVEShiftImmL64 : ComplexPattern<i64, 1, "SelectSVEShiftImm<0, 63>", []>; 232def SVEShiftImmR8 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 8, true>", []>; 233def SVEShiftImmR16 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 16, true>", []>; 234def SVEShiftImmR32 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 32, true>", []>; 235def SVEShiftImmR64 : ComplexPattern<i64, 1, "SelectSVEShiftImm<1, 64, true>", []>; 236 237def SVEAllActive : ComplexPattern<untyped, 0, "SelectAllActivePredicate", []>; 238 239class SVEExactFPImm<string Suffix, string ValA, string ValB> : AsmOperandClass { 240 let Name = "SVEExactFPImmOperand" # Suffix; 241 let DiagnosticType = "Invalid" # Name; 242 let ParserMethod = "tryParseFPImm<false>"; 243 let PredicateMethod = "isExactFPImm<" # ValA # ", " # ValB # ">"; 244 let RenderMethod = "addExactFPImmOperands<" # ValA # ", " # ValB # ">"; 245} 246 247class SVEExactFPImmOperand<string Suffix, string ValA, string ValB> : Operand<i32> { 248 let PrintMethod = "printExactFPImm<" # ValA # ", " # ValB # ">"; 249 let ParserMatchClass = SVEExactFPImm<Suffix, ValA, ValB>; 250} 251 252def sve_fpimm_half_one 253 : SVEExactFPImmOperand<"HalfOne", "AArch64ExactFPImm::half", 254 "AArch64ExactFPImm::one">; 255def sve_fpimm_half_two 256 : SVEExactFPImmOperand<"HalfTwo", "AArch64ExactFPImm::half", 257 "AArch64ExactFPImm::two">; 258def sve_fpimm_zero_one 259 : SVEExactFPImmOperand<"ZeroOne", "AArch64ExactFPImm::zero", 260 "AArch64ExactFPImm::one">; 261 262def sve_incdec_imm : Operand<i32>, TImmLeaf<i32, [{ 263 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17); 264}]> { 265 let ParserMatchClass = Imm1_16Operand; 266 let EncoderMethod = "getSVEIncDecImm"; 267 let DecoderMethod = "DecodeSVEIncDecImm"; 268} 269 270// This allows i32 immediate extraction from i64 based arithmetic. 271def sve_cnt_mul_imm_i32 : ComplexPattern<i32, 1, "SelectCntImm<1, 16, 1, false>">; 272def sve_cnt_mul_imm_i64 : ComplexPattern<i64, 1, "SelectCntImm<1, 16, 1, false>">; 273def sve_cnt_shl_imm : ComplexPattern<i64, 1, "SelectCntImm<1, 16, 1, true>">; 274 275def sve_ext_imm_0_31 : ComplexPattern<i64, 1, "SelectEXTImm<31, 8>">; 276def sve_ext_imm_0_63 : ComplexPattern<i64, 1, "SelectEXTImm<63, 4>">; 277def sve_ext_imm_0_127 : ComplexPattern<i64, 1, "SelectEXTImm<127, 2>">; 278def sve_ext_imm_0_255 : ComplexPattern<i64, 1, "SelectEXTImm<255, 1>">; 279 280def int_aarch64_sve_cntp_oneuse : PatFrag<(ops node:$pred, node:$src2), 281 (int_aarch64_sve_cntp node:$pred, node:$src2), [{ 282 return N->hasOneUse(); 283}]>; 284 285def step_vector_oneuse : PatFrag<(ops node:$idx), 286 (step_vector node:$idx), [{ 287 return N->hasOneUse(); 288}]>; 289 290 291//===----------------------------------------------------------------------===// 292// SVE PTrue - These are used extensively throughout the pattern matching so 293// it's important we define them first. 294//===----------------------------------------------------------------------===// 295 296class sve_int_ptrue<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty, 297 ValueType vt, SDPatternOperator op> 298: I<(outs pprty:$Pd), (ins sve_pred_enum:$pattern), 299 asm, "\t$Pd, $pattern", 300 "", 301 [(set (vt pprty:$Pd), (op sve_pred_enum:$pattern))]>, Sched<[]> { 302 bits<4> Pd; 303 bits<5> pattern; 304 let Inst{31-24} = 0b00100101; 305 let Inst{23-22} = sz8_64; 306 let Inst{21-19} = 0b011; 307 let Inst{18-17} = opc{2-1}; 308 let Inst{16} = opc{0}; 309 let Inst{15-10} = 0b111000; 310 let Inst{9-5} = pattern; 311 let Inst{4} = 0b0; 312 let Inst{3-0} = Pd; 313 314 let Defs = !if(!eq (opc{0}, 1), [NZCV], []); 315 let ElementSize = pprty.ElementSize; 316 let isReMaterializable = 1; 317} 318 319multiclass sve_int_ptrue<bits<3> opc, string asm, SDPatternOperator op> { 320 def _B : sve_int_ptrue<0b00, opc, asm, PPR8, nxv16i1, op>; 321 def _H : sve_int_ptrue<0b01, opc, asm, PPR16, nxv8i1, op>; 322 def _S : sve_int_ptrue<0b10, opc, asm, PPR32, nxv4i1, op>; 323 def _D : sve_int_ptrue<0b11, opc, asm, PPR64, nxv2i1, op>; 324 325 def : InstAlias<asm # "\t$Pd", 326 (!cast<Instruction>(NAME # _B) PPR8:$Pd, 0b11111), 1>; 327 def : InstAlias<asm # "\t$Pd", 328 (!cast<Instruction>(NAME # _H) PPR16:$Pd, 0b11111), 1>; 329 def : InstAlias<asm # "\t$Pd", 330 (!cast<Instruction>(NAME # _S) PPR32:$Pd, 0b11111), 1>; 331 def : InstAlias<asm # "\t$Pd", 332 (!cast<Instruction>(NAME # _D) PPR64:$Pd, 0b11111), 1>; 333} 334 335def SDT_AArch64PTrue : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>; 336def AArch64ptrue : SDNode<"AArch64ISD::PTRUE", SDT_AArch64PTrue>; 337 338let Predicates = [HasSVEorStreamingSVE] in { 339 defm PTRUE : sve_int_ptrue<0b000, "ptrue", AArch64ptrue>; 340 defm PTRUES : sve_int_ptrue<0b001, "ptrues", null_frag>; 341} 342 343//===----------------------------------------------------------------------===// 344// SVE pattern match helpers. 345//===----------------------------------------------------------------------===// 346 347class SVE_1_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 348 Instruction inst> 349: Pat<(vtd (op vt1:$Op1)), 350 (inst $Op1)>; 351 352class SVE_1_Op_Passthru_Pat<ValueType vtd, SDPatternOperator op, ValueType pg, 353 ValueType vts, Instruction inst> 354: Pat<(vtd (op pg:$Op1, vts:$Op2, vtd:$Op3)), 355 (inst $Op3, $Op1, $Op2)>; 356 357 358multiclass SVE_1_Op_PassthruUndef_Pat<ValueType vtd, SDPatternOperator op, ValueType pg, 359 ValueType vts, Instruction inst> { 360 def : Pat<(vtd (op pg:$Op1, vts:$Op2, (vtd undef))), 361 (inst (IMPLICIT_DEF), $Op1, $Op2)>; 362 def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, vtd:$Op3)), 363 (inst $Op3, $Op1, $Op2)>; 364} 365 366// Used to match FP_ROUND_MERGE_PASSTHRU, which has an additional flag for the 367// type of rounding. This is matched by timm0_1 in pattern below and ignored. 368class SVE_1_Op_Passthru_Round_Pat<ValueType vtd, SDPatternOperator op, ValueType pg, 369 ValueType vts, Instruction inst> 370: Pat<(vtd (op pg:$Op1, vts:$Op2, (i64 timm0_1), vtd:$Op3)), 371 (inst $Op3, $Op1, $Op2)>; 372 373multiclass SVE_1_Op_PassthruUndef_Round_Pat<ValueType vtd, SDPatternOperator op, ValueType pg, 374 ValueType vts, Instruction inst>{ 375 def : Pat<(vtd (op pg:$Op1, vts:$Op2, (i64 timm0_1), (vtd undef))), 376 (inst (IMPLICIT_DEF), $Op1, $Op2)>; 377 def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, (i64 timm0_1), vtd:$Op3)), 378 (inst $Op3, $Op1, $Op2)>; 379} 380 381class SVE_1_Op_Imm_OptLsl_Reverse_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty, 382 ValueType it, ComplexPattern cpx, Instruction inst> 383 : Pat<(vt (op (vt (AArch64dup (it (cpx i32:$imm, i32:$shift)))), (vt zprty:$Op1))), 384 (inst $Op1, i32:$imm, i32:$shift)>; 385 386class SVE_1_Op_Imm_OptLsl_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty, 387 ValueType it, ComplexPattern cpx, Instruction inst> 388 : Pat<(vt (op (vt zprty:$Op1), (vt (AArch64dup (it (cpx i32:$imm, i32:$shift)))))), 389 (inst $Op1, i32:$imm, i32:$shift)>; 390 391class SVE_1_Op_Imm_Arith_All_Active<ValueType vt, ValueType pt, SDPatternOperator op, 392 ZPRRegOp zprty, ValueType it, ComplexPattern cpx, Instruction inst> 393 : Pat<(vt (op (pt (SVEAllActive)), (vt zprty:$Op1), (vt (AArch64dup (it (cpx i32:$imm)))))), 394 (inst $Op1, i32:$imm)>; 395 396class SVE_1_Op_Imm_Log_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty, 397 ValueType it, ComplexPattern cpx, Instruction inst> 398 : Pat<(vt (op (vt zprty:$Op1), (vt (AArch64dup (it (cpx i64:$imm)))))), 399 (inst $Op1, i64:$imm)>; 400 401class SVE_2_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 402 ValueType vt2, Instruction inst> 403: Pat<(vtd (op vt1:$Op1, vt2:$Op2)), 404 (inst $Op1, $Op2)>; 405 406class SVE_2_Op_Pred_All_Active<ValueType vtd, SDPatternOperator op, 407 ValueType pt, ValueType vt1, ValueType vt2, 408 Instruction inst> 409: Pat<(vtd (op (pt (SVEAllActive)), vt1:$Op1, vt2:$Op2)), 410 (inst $Op1, $Op2)>; 411 412class SVE_2_Op_Pred_All_Active_Pt<ValueType vtd, SDPatternOperator op, 413 ValueType pt, ValueType vt1, ValueType vt2, 414 Instruction inst> 415: Pat<(vtd (op (pt (SVEAllActive:$Op1)), vt1:$Op2, vt2:$Op3)), 416 (inst $Op1, $Op2, $Op3)>; 417 418class SVE_3_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 419 ValueType vt2, ValueType vt3, Instruction inst> 420: Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3)), 421 (inst $Op1, $Op2, $Op3)>; 422 423multiclass SVE_3_Op_Undef_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 424 ValueType vt2, ValueType vt3, Instruction inst> { 425 def : Pat<(vtd (op (vt1 undef), vt2:$Op1, vt3:$Op2)), 426 (inst (IMPLICIT_DEF), $Op1, $Op2)>; 427 def : Pat<(vtd (op vt1:$Op1, (vt2 (SVEAllActive:$Op2)), vt3:$Op3)), 428 (inst $Op1, $Op2, $Op3)>; 429} 430 431class SVE_4_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 432 ValueType vt2, ValueType vt3, ValueType vt4, 433 Instruction inst> 434: Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3, vt4:$Op4)), 435 (inst $Op1, $Op2, $Op3, $Op4)>; 436 437class SVE_2_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 438 ValueType vt2, Operand ImmTy, Instruction inst> 439: Pat<(vtd (op vt1:$Op1, (vt2 ImmTy:$Op2))), 440 (inst $Op1, ImmTy:$Op2)>; 441 442class SVE_3_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 443 ValueType vt2, ValueType vt3, Operand ImmTy, 444 Instruction inst> 445: Pat<(vtd (op vt1:$Op1, vt2:$Op2, (vt3 ImmTy:$Op3))), 446 (inst $Op1, $Op2, ImmTy:$Op3)>; 447 448class SVE_4_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 449 ValueType vt2, ValueType vt3, ValueType vt4, 450 Operand ImmTy, Instruction inst> 451: Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3, (vt4 ImmTy:$Op4))), 452 (inst $Op1, $Op2, $Op3, ImmTy:$Op4)>; 453 454def SVEDup0 : ComplexPattern<vAny, 0, "SelectDupZero", []>; 455def SVEDup0Undef : ComplexPattern<vAny, 0, "SelectDupZeroOrUndef", []>; 456 457let AddedComplexity = 1 in { 458class SVE_3_Op_Pat_SelZero<ValueType vtd, SDPatternOperator op, ValueType vt1, 459 ValueType vt2, ValueType vt3, Instruction inst> 460: Pat<(vtd (vtd (op vt1:$Op1, (vselect vt1:$Op1, vt2:$Op2, (SVEDup0)), vt3:$Op3))), 461 (inst $Op1, $Op2, $Op3)>; 462 463class SVE_3_Op_Pat_Shift_Imm_SelZero<ValueType vtd, SDPatternOperator op, 464 ValueType vt1, ValueType vt2, 465 Operand vt3, Instruction inst> 466: Pat<(vtd (op vt1:$Op1, (vselect vt1:$Op1, vt2:$Op2, (SVEDup0)), (i32 (vt3:$Op3)))), 467 (inst $Op1, $Op2, vt3:$Op3)>; 468} 469 470// 471// Common but less generic patterns. 472// 473 474class SVE_1_Op_AllActive_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 475 Instruction inst, Instruction ptrue> 476: Pat<(vtd (op vt1:$Op1)), 477 (inst (IMPLICIT_DEF), (ptrue 31), $Op1)>; 478 479class SVE_2_Op_AllActive_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1, 480 ValueType vt2, Instruction inst, Instruction ptrue> 481: Pat<(vtd (op vt1:$Op1, vt2:$Op2)), 482 (inst (ptrue 31), $Op1, $Op2)>; 483 484class SVE_InReg_Extend<ValueType vt, SDPatternOperator op, ValueType pt, 485 ValueType inreg_vt, Instruction inst> 486: Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, vt:$PassThru)), 487 (inst $PassThru, $Pg, $Src)>; 488 489multiclass SVE_InReg_Extend_PassthruUndef<ValueType vt, SDPatternOperator op, ValueType pt, 490 ValueType inreg_vt, Instruction inst> { 491 def : Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, (vt undef))), 492 (inst (IMPLICIT_DEF), $Pg, $Src)>; 493 def : Pat<(vt (op (pt (SVEAllActive:$Pg)), vt:$Src, inreg_vt, vt:$PassThru)), 494 (inst $PassThru, $Pg, $Src)>; 495} 496 497class SVE_Shift_DupImm_Pred_Pat<ValueType vt, SDPatternOperator op, 498 ValueType pt, ValueType it, 499 ComplexPattern cast, Instruction inst> 500: Pat<(vt (op pt:$Pg, vt:$Rn, (vt (AArch64dup (it (cast i32:$imm)))))), 501 (inst $Pg, $Rn, i32:$imm)>; 502 503class SVE_Shift_DupImm_All_Active_Pat<ValueType vt, SDPatternOperator op, 504 ValueType pt, ValueType it, 505 ComplexPattern cast, Instruction inst> 506: Pat<(vt (op (pt (SVEAllActive)), vt:$Rn, (vt (AArch64dup (it (cast i32:$imm)))))), 507 (inst $Rn, i32:$imm)>; 508 509class SVE_2_Op_Fp_Imm_Pat<ValueType vt, SDPatternOperator op, 510 ValueType pt, ValueType it, 511 FPImmLeaf immL, int imm, 512 Instruction inst> 513: Pat<(vt (op (pt PPR_3b:$Pg), (vt ZPR:$Zs1), (vt (AArch64dup (it immL))))), 514 (inst $Pg, $Zs1, imm)>; 515 516class SVE_2_Op_Fp_Imm_Pat_Zero<ValueType vt, SDPatternOperator op, 517 ValueType pt, ValueType it, 518 FPImmLeaf immL, int imm, 519 Instruction inst> 520: Pat<(vt (op pt:$Pg, (vselect pt:$Pg, vt:$Zs1, (SVEDup0)), 521 (vt (AArch64dup (it immL))))), 522 (inst $Pg, $Zs1, imm)>; 523 524// 525// Pseudo -> Instruction mappings 526// 527def getSVEPseudoMap : InstrMapping { 528 let FilterClass = "SVEPseudo2Instr"; 529 let RowFields = ["PseudoName"]; 530 let ColFields = ["IsInstr"]; 531 let KeyCol = ["0"]; 532 let ValueCols = [["1"]]; 533} 534 535class SVEPseudo2Instr<string name, bit instr> { 536 string PseudoName = name; 537 bit IsInstr = instr; 538} 539 540// Lookup e.g. DIV -> DIVR 541def getSVERevInstr : InstrMapping { 542 let FilterClass = "SVEInstr2Rev"; 543 let RowFields = ["InstrName"]; 544 let ColFields = ["isReverseInstr"]; 545 let KeyCol = ["0"]; 546 let ValueCols = [["1"]]; 547} 548 549// Lookup e.g. DIVR -> DIV 550def getSVENonRevInstr : InstrMapping { 551 let FilterClass = "SVEInstr2Rev"; 552 let RowFields = ["InstrName"]; 553 let ColFields = ["isReverseInstr"]; 554 let KeyCol = ["1"]; 555 let ValueCols = [["0"]]; 556} 557 558class SVEInstr2Rev<string name1, string name2, bit name1IsReverseInstr> { 559 string InstrName = !if(name1IsReverseInstr, name1, name2); 560 bit isReverseInstr = name1IsReverseInstr; 561} 562 563// 564// Pseudos for destructive operands 565// 566let hasNoSchedulingInfo = 1 in { 567 class PredTwoOpPseudo<string name, ZPRRegOp zprty, 568 FalseLanesEnum flags = FalseLanesNone> 569 : SVEPseudo2Instr<name, 0>, 570 Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, zprty:$Zs2), []> { 571 let FalseLanes = flags; 572 } 573 574 class PredTwoOpImmPseudo<string name, ZPRRegOp zprty, Operand immty, 575 FalseLanesEnum flags = FalseLanesNone> 576 : SVEPseudo2Instr<name, 0>, 577 Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, immty:$imm), []> { 578 let FalseLanes = flags; 579 } 580 581 class PredThreeOpPseudo<string name, ZPRRegOp zprty, 582 FalseLanesEnum flags = FalseLanesNone> 583 : SVEPseudo2Instr<name, 0>, 584 Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, zprty:$Zs2, zprty:$Zs3), []> { 585 let FalseLanes = flags; 586 } 587} 588 589// 590// Pseudos for passthru operands 591// 592let hasNoSchedulingInfo = 1 in { 593 class PredOneOpPassthruPseudo<string name, ZPRRegOp zprty> 594 : SVEPseudo2Instr<name, 0>, 595 Pseudo<(outs zprty:$Zd), (ins zprty:$Passthru, PPR3bAny:$Pg, zprty:$Zs), []>; 596} 597 598//===----------------------------------------------------------------------===// 599// SVE Predicate Misc Group 600//===----------------------------------------------------------------------===// 601 602class sve_int_pfalse<bits<6> opc, string asm> 603: I<(outs PPR8:$Pd), (ins), 604 asm, "\t$Pd", 605 "", 606 []>, Sched<[]> { 607 bits<4> Pd; 608 let Inst{31-24} = 0b00100101; 609 let Inst{23-22} = opc{5-4}; 610 let Inst{21-19} = 0b011; 611 let Inst{18-16} = opc{3-1}; 612 let Inst{15-10} = 0b111001; 613 let Inst{9} = opc{0}; 614 let Inst{8-4} = 0b00000; 615 let Inst{3-0} = Pd; 616 617 let isReMaterializable = 1; 618} 619 620multiclass sve_int_pfalse<bits<6> opc, string asm> { 621 def NAME : sve_int_pfalse<opc, asm>; 622 623 def : Pat<(nxv16i1 (splat_vector (i32 0))), (!cast<Instruction>(NAME))>; 624 def : Pat<(nxv8i1 (splat_vector (i32 0))), (!cast<Instruction>(NAME))>; 625 def : Pat<(nxv4i1 (splat_vector (i32 0))), (!cast<Instruction>(NAME))>; 626 def : Pat<(nxv2i1 (splat_vector (i32 0))), (!cast<Instruction>(NAME))>; 627} 628 629class sve_int_ptest<bits<6> opc, string asm> 630: I<(outs), (ins PPRAny:$Pg, PPR8:$Pn), 631 asm, "\t$Pg, $Pn", 632 "", 633 []>, Sched<[]> { 634 bits<4> Pg; 635 bits<4> Pn; 636 let Inst{31-24} = 0b00100101; 637 let Inst{23-22} = opc{5-4}; 638 let Inst{21-19} = 0b010; 639 let Inst{18-16} = opc{3-1}; 640 let Inst{15-14} = 0b11; 641 let Inst{13-10} = Pg; 642 let Inst{9} = opc{0}; 643 let Inst{8-5} = Pn; 644 let Inst{4-0} = 0b00000; 645 646 let Defs = [NZCV]; 647 let isCompare = 1; 648} 649 650class sve_int_pfirst_next<bits<2> sz8_64, bits<5> opc, string asm, 651 PPRRegOp pprty> 652: I<(outs pprty:$Pdn), (ins PPRAny:$Pg, pprty:$_Pdn), 653 asm, "\t$Pdn, $Pg, $_Pdn", 654 "", 655 []>, Sched<[]> { 656 bits<4> Pdn; 657 bits<4> Pg; 658 let Inst{31-24} = 0b00100101; 659 let Inst{23-22} = sz8_64; 660 let Inst{21-19} = 0b011; 661 let Inst{18-16} = opc{4-2}; 662 let Inst{15-11} = 0b11000; 663 let Inst{10-9} = opc{1-0}; 664 let Inst{8-5} = Pg; 665 let Inst{4} = 0; 666 let Inst{3-0} = Pdn; 667 668 let Constraints = "$Pdn = $_Pdn"; 669 let Defs = [NZCV]; 670 let isPTestLike = 1; 671 let ElementSize = pprty.ElementSize; 672} 673 674multiclass sve_int_pfirst<bits<5> opc, string asm, SDPatternOperator op> { 675 def _B : sve_int_pfirst_next<0b01, opc, asm, PPR8>; 676 677 def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>; 678} 679 680multiclass sve_int_pnext<bits<5> opc, string asm, SDPatternOperator op> { 681 def _B : sve_int_pfirst_next<0b00, opc, asm, PPR8>; 682 def _H : sve_int_pfirst_next<0b01, opc, asm, PPR16>; 683 def _S : sve_int_pfirst_next<0b10, opc, asm, PPR32>; 684 def _D : sve_int_pfirst_next<0b11, opc, asm, PPR64>; 685 686 def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>; 687 def : SVE_2_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>; 688 def : SVE_2_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>; 689 def : SVE_2_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>; 690} 691 692//===----------------------------------------------------------------------===// 693// SVE Predicate Count Group 694//===----------------------------------------------------------------------===// 695 696class sve_int_count_r<bits<2> sz8_64, bits<5> opc, string asm, 697 RegisterOperand dty, PPRRegOp pprty, RegisterOperand sty> 698: I<(outs dty:$Rdn), (ins pprty:$Pg, sty:$_Rdn), 699 asm, "\t$Rdn, $Pg", 700 "", 701 []>, Sched<[]> { 702 bits<5> Rdn; 703 bits<4> Pg; 704 let Inst{31-24} = 0b00100101; 705 let Inst{23-22} = sz8_64; 706 let Inst{21-19} = 0b101; 707 let Inst{18-16} = opc{4-2}; 708 let Inst{15-11} = 0b10001; 709 let Inst{10-9} = opc{1-0}; 710 let Inst{8-5} = Pg; 711 let Inst{4-0} = Rdn; 712 713 // Signed 32bit forms require their GPR operand printed. 714 let AsmString = !if(!eq(opc{4,2-0}, 0b0000), 715 !strconcat(asm, "\t$Rdn, $Pg, $_Rdn"), 716 !strconcat(asm, "\t$Rdn, $Pg")); 717 let Constraints = "$Rdn = $_Rdn"; 718} 719 720multiclass sve_int_count_r_s32<bits<5> opc, string asm, 721 SDPatternOperator op> { 722 def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64as32>; 723 def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64as32>; 724 def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64as32>; 725 def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64as32>; 726 727 def : Pat<(i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))), 728 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _B) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>; 729 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))))), 730 (!cast<Instruction>(NAME # _B) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>; 731 732 def : Pat<(i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))), 733 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _H) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>; 734 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))))), 735 (!cast<Instruction>(NAME # _H) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>; 736 737 def : Pat<(i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))), 738 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _S) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>; 739 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))))), 740 (!cast<Instruction>(NAME # _S) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>; 741 742 def : Pat<(i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))), 743 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _D) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>; 744 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))))), 745 (!cast<Instruction>(NAME # _D) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>; 746} 747 748multiclass sve_int_count_r_u32<bits<5> opc, string asm, 749 SDPatternOperator op> { 750 def _B : sve_int_count_r<0b00, opc, asm, GPR32z, PPR8, GPR32z>; 751 def _H : sve_int_count_r<0b01, opc, asm, GPR32z, PPR16, GPR32z>; 752 def _S : sve_int_count_r<0b10, opc, asm, GPR32z, PPR32, GPR32z>; 753 def _D : sve_int_count_r<0b11, opc, asm, GPR32z, PPR64, GPR32z>; 754 755 def : Pat<(i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))), 756 (!cast<Instruction>(NAME # _B) PPRAny:$Pg, $Rn)>; 757 def : Pat<(i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))), 758 (!cast<Instruction>(NAME # _H) PPRAny:$Pg, $Rn)>; 759 def : Pat<(i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))), 760 (!cast<Instruction>(NAME # _S) PPRAny:$Pg, $Rn)>; 761 def : Pat<(i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))), 762 (!cast<Instruction>(NAME # _D) PPRAny:$Pg, $Rn)>; 763} 764 765multiclass sve_int_count_r_x64<bits<5> opc, string asm, 766 SDPatternOperator op, 767 SDPatternOperator combine_op = null_frag> { 768 def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64z>; 769 def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64z>; 770 def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64z>; 771 def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64z>; 772 773 def : Pat<(i64 (op GPR64:$Rn, (nxv16i1 PPRAny:$Pg))), 774 (!cast<Instruction>(NAME # _B) PPRAny:$Pg, $Rn)>; 775 def : Pat<(i64 (op GPR64:$Rn, (nxv8i1 PPRAny:$Pg))), 776 (!cast<Instruction>(NAME # _H) PPRAny:$Pg, $Rn)>; 777 def : Pat<(i64 (op GPR64:$Rn, (nxv4i1 PPRAny:$Pg))), 778 (!cast<Instruction>(NAME # _S) PPRAny:$Pg, $Rn)>; 779 def : Pat<(i64 (op GPR64:$Rn, (nxv2i1 PPRAny:$Pg))), 780 (!cast<Instruction>(NAME # _D) PPRAny:$Pg, $Rn)>; 781 782 // combine_op(x, cntp(all_active, p)) ==> inst p, x 783 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv16i1 (SVEAllActive)), (nxv16i1 PPRAny:$pred)))), 784 (!cast<Instruction>(NAME # _B) PPRAny:$pred, $Rn)>; 785 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv8i1 (SVEAllActive)), (nxv8i1 PPRAny:$pred)))), 786 (!cast<Instruction>(NAME # _H) PPRAny:$pred, $Rn)>; 787 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv4i1 (SVEAllActive)), (nxv4i1 PPRAny:$pred)))), 788 (!cast<Instruction>(NAME # _S) PPRAny:$pred, $Rn)>; 789 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv2i1 (SVEAllActive)), (nxv2i1 PPRAny:$pred)))), 790 (!cast<Instruction>(NAME # _D) PPRAny:$pred, $Rn)>; 791 792 // combine_op(x, cntp(p, p)) ==> inst p, x 793 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv16i1 PPRAny:$pred), (nxv16i1 PPRAny:$pred)))), 794 (!cast<Instruction>(NAME # _B) PPRAny:$pred, $Rn)>; 795 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv8i1 PPRAny:$pred), (nxv8i1 PPRAny:$pred)))), 796 (!cast<Instruction>(NAME # _H) PPRAny:$pred, $Rn)>; 797 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv4i1 PPRAny:$pred), (nxv4i1 PPRAny:$pred)))), 798 (!cast<Instruction>(NAME # _S) PPRAny:$pred, $Rn)>; 799 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv2i1 PPRAny:$pred), (nxv2i1 PPRAny:$pred)))), 800 (!cast<Instruction>(NAME # _D) PPRAny:$pred, $Rn)>; 801} 802 803class sve_int_count_v<bits<2> sz8_64, bits<5> opc, string asm, 804 ZPRRegOp zprty, PPRRegOp pprty> 805: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, pprty:$Pm), 806 asm, "\t$Zdn, $Pm", 807 "", 808 []>, Sched<[]> { 809 bits<4> Pm; 810 bits<5> Zdn; 811 let Inst{31-24} = 0b00100101; 812 let Inst{23-22} = sz8_64; 813 let Inst{21-19} = 0b101; 814 let Inst{18-16} = opc{4-2}; 815 let Inst{15-11} = 0b10000; 816 let Inst{10-9} = opc{1-0}; 817 let Inst{8-5} = Pm; 818 let Inst{4-0} = Zdn; 819 820 let Constraints = "$Zdn = $_Zdn"; 821 let DestructiveInstType = DestructiveOther; 822 let ElementSize = ElementSizeNone; 823} 824 825multiclass sve_int_count_v<bits<5> opc, string asm, 826 SDPatternOperator op = null_frag> { 827 def _H : sve_int_count_v<0b01, opc, asm, ZPR16, PPR16>; 828 def _S : sve_int_count_v<0b10, opc, asm, ZPR32, PPR32>; 829 def _D : sve_int_count_v<0b11, opc, asm, ZPR64, PPR64>; 830 831 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, !cast<Instruction>(NAME # _H)>; 832 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, !cast<Instruction>(NAME # _S)>; 833 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, !cast<Instruction>(NAME # _D)>; 834 835 def : InstAlias<asm # "\t$Zdn, $Pm", 836 (!cast<Instruction>(NAME # "_H") ZPR16:$Zdn, PPRAny:$Pm), 0>; 837 def : InstAlias<asm # "\t$Zdn, $Pm", 838 (!cast<Instruction>(NAME # "_S") ZPR32:$Zdn, PPRAny:$Pm), 0>; 839 def : InstAlias<asm # "\t$Zdn, $Pm", 840 (!cast<Instruction>(NAME # "_D") ZPR64:$Zdn, PPRAny:$Pm), 0>; 841} 842 843class sve_int_pcount_pred<bits<2> sz8_64, bits<4> opc, string asm, 844 PPRRegOp pprty> 845: I<(outs GPR64:$Rd), (ins PPRAny:$Pg, pprty:$Pn), 846 asm, "\t$Rd, $Pg, $Pn", 847 "", 848 []>, Sched<[]> { 849 bits<4> Pg; 850 bits<4> Pn; 851 bits<5> Rd; 852 let Inst{31-24} = 0b00100101; 853 let Inst{23-22} = sz8_64; 854 let Inst{21-19} = 0b100; 855 let Inst{18-16} = opc{3-1}; 856 let Inst{15-14} = 0b10; 857 let Inst{13-10} = Pg; 858 let Inst{9} = opc{0}; 859 let Inst{8-5} = Pn; 860 let Inst{4-0} = Rd; 861} 862 863multiclass sve_int_pcount_pred<bits<4> opc, string asm, 864 SDPatternOperator int_op> { 865 def _B : sve_int_pcount_pred<0b00, opc, asm, PPR8>; 866 def _H : sve_int_pcount_pred<0b01, opc, asm, PPR16>; 867 def _S : sve_int_pcount_pred<0b10, opc, asm, PPR32>; 868 def _D : sve_int_pcount_pred<0b11, opc, asm, PPR64>; 869 870 def : SVE_2_Op_Pat<i64, int_op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>; 871 def : SVE_2_Op_Pat<i64, int_op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>; 872 def : SVE_2_Op_Pat<i64, int_op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>; 873 def : SVE_2_Op_Pat<i64, int_op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>; 874} 875 876//===----------------------------------------------------------------------===// 877// SVE Element Count Group 878//===----------------------------------------------------------------------===// 879 880class sve_int_count<bits<3> opc, string asm> 881: I<(outs GPR64:$Rd), (ins sve_pred_enum:$pattern, sve_incdec_imm:$imm4), 882 asm, "\t$Rd, $pattern, mul $imm4", 883 "", 884 []>, Sched<[]> { 885 bits<5> Rd; 886 bits<4> imm4; 887 bits<5> pattern; 888 let Inst{31-24} = 0b00000100; 889 let Inst{23-22} = opc{2-1}; 890 let Inst{21-20} = 0b10; 891 let Inst{19-16} = imm4; 892 let Inst{15-11} = 0b11100; 893 let Inst{10} = opc{0}; 894 let Inst{9-5} = pattern; 895 let Inst{4-0} = Rd; 896} 897 898multiclass sve_int_count<bits<3> opc, string asm, SDPatternOperator op> { 899 def NAME : sve_int_count<opc, asm>; 900 901 def : InstAlias<asm # "\t$Rd, $pattern", 902 (!cast<Instruction>(NAME) GPR64:$Rd, sve_pred_enum:$pattern, 1), 1>; 903 def : InstAlias<asm # "\t$Rd", 904 (!cast<Instruction>(NAME) GPR64:$Rd, 0b11111, 1), 2>; 905 906 def : Pat<(i64 (mul (op sve_pred_enum:$pattern), (sve_cnt_mul_imm_i64 i32:$imm))), 907 (!cast<Instruction>(NAME) sve_pred_enum:$pattern, sve_incdec_imm:$imm)>; 908 909 def : Pat<(i64 (shl (op sve_pred_enum:$pattern), (sve_cnt_shl_imm i32:$imm))), 910 (!cast<Instruction>(NAME) sve_pred_enum:$pattern, sve_incdec_imm:$imm)>; 911 912 def : Pat<(i64 (op sve_pred_enum:$pattern)), 913 (!cast<Instruction>(NAME) sve_pred_enum:$pattern, 1)>; 914} 915 916class sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty> 917: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4), 918 asm, "\t$Zdn, $pattern, mul $imm4", 919 "", 920 []>, Sched<[]> { 921 bits<5> Zdn; 922 bits<5> pattern; 923 bits<4> imm4; 924 let Inst{31-24} = 0b00000100; 925 let Inst{23-22} = opc{4-3}; 926 let Inst{21} = 0b1; 927 let Inst{20} = opc{2}; 928 let Inst{19-16} = imm4; 929 let Inst{15-12} = 0b1100; 930 let Inst{11-10} = opc{1-0}; 931 let Inst{9-5} = pattern; 932 let Inst{4-0} = Zdn; 933 934 let Constraints = "$Zdn = $_Zdn"; 935 let DestructiveInstType = DestructiveOther; 936 let ElementSize = ElementSizeNone; 937} 938 939multiclass sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty, 940 SDPatternOperator op = null_frag, 941 ValueType vt = OtherVT> { 942 def NAME : sve_int_countvlv<opc, asm, zprty>; 943 944 def : InstAlias<asm # "\t$Zdn, $pattern", 945 (!cast<Instruction>(NAME) zprty:$Zdn, sve_pred_enum:$pattern, 1), 1>; 946 def : InstAlias<asm # "\t$Zdn", 947 (!cast<Instruction>(NAME) zprty:$Zdn, 0b11111, 1), 2>; 948 949 def : Pat<(vt (op (vt zprty:$Zn), (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))), 950 (!cast<Instruction>(NAME) $Zn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>; 951} 952 953class sve_int_pred_pattern_a<bits<3> opc, string asm> 954: I<(outs GPR64:$Rdn), (ins GPR64:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4), 955 asm, "\t$Rdn, $pattern, mul $imm4", 956 "", 957 []>, Sched<[]> { 958 bits<5> Rdn; 959 bits<5> pattern; 960 bits<4> imm4; 961 let Inst{31-24} = 0b00000100; 962 let Inst{23-22} = opc{2-1}; 963 let Inst{21-20} = 0b11; 964 let Inst{19-16} = imm4; 965 let Inst{15-11} = 0b11100; 966 let Inst{10} = opc{0}; 967 let Inst{9-5} = pattern; 968 let Inst{4-0} = Rdn; 969 970 let Constraints = "$Rdn = $_Rdn"; 971} 972 973multiclass sve_int_pred_pattern_a<bits<3> opc, string asm, 974 SDPatternOperator op, 975 SDPatternOperator opcnt> { 976 let Predicates = [HasSVEorStreamingSVE] in { 977 def NAME : sve_int_pred_pattern_a<opc, asm>; 978 979 def : InstAlias<asm # "\t$Rdn, $pattern", 980 (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1), 1>; 981 def : InstAlias<asm # "\t$Rdn", 982 (!cast<Instruction>(NAME) GPR64:$Rdn, 0b11111, 1), 2>; 983 } 984 985 let Predicates = [HasSVEorStreamingSVE, UseScalarIncVL] in { 986 def : Pat<(i64 (op GPR64:$Rdn, (opcnt sve_pred_enum:$pattern))), 987 (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1)>; 988 989 def : Pat<(i64 (op GPR64:$Rdn, (mul (opcnt sve_pred_enum:$pattern), (sve_cnt_mul_imm_i64 i32:$imm)))), 990 (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, $imm)>; 991 992 def : Pat<(i64 (op GPR64:$Rdn, (shl (opcnt sve_pred_enum:$pattern), (sve_cnt_shl_imm i32:$imm)))), 993 (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, $imm)>; 994 995 def : Pat<(i32 (op GPR32:$Rdn, (i32 (trunc (opcnt (sve_pred_enum:$pattern)))))), 996 (i32 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (i64 (IMPLICIT_DEF)), 997 GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, 1), 998 sub_32))>; 999 1000 def : Pat<(i32 (op GPR32:$Rdn, (mul (i32 (trunc (opcnt (sve_pred_enum:$pattern)))), (sve_cnt_mul_imm_i32 i32:$imm)))), 1001 (i32 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (i64 (IMPLICIT_DEF)), 1002 GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, $imm), 1003 sub_32))>; 1004 1005 def : Pat<(i32 (op GPR32:$Rdn, (shl (i32 (trunc (opcnt (sve_pred_enum:$pattern)))), (sve_cnt_shl_imm i32:$imm)))), 1006 (i32 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (i64 (IMPLICIT_DEF)), 1007 GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, $imm), 1008 sub_32))>; 1009 } 1010} 1011 1012class sve_int_pred_pattern_b<bits<5> opc, string asm, RegisterOperand dt, 1013 RegisterOperand st> 1014: I<(outs dt:$Rdn), (ins st:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4), 1015 asm, "\t$Rdn, $pattern, mul $imm4", 1016 "", 1017 []>, Sched<[]> { 1018 bits<5> Rdn; 1019 bits<5> pattern; 1020 bits<4> imm4; 1021 let Inst{31-24} = 0b00000100; 1022 let Inst{23-22} = opc{4-3}; 1023 let Inst{21} = 0b1; 1024 let Inst{20} = opc{2}; 1025 let Inst{19-16} = imm4; 1026 let Inst{15-12} = 0b1111; 1027 let Inst{11-10} = opc{1-0}; 1028 let Inst{9-5} = pattern; 1029 let Inst{4-0} = Rdn; 1030 1031 // Signed 32bit forms require their GPR operand printed. 1032 let AsmString = !if(!eq(opc{2,0}, 0b00), 1033 !strconcat(asm, "\t$Rdn, $_Rdn, $pattern, mul $imm4"), 1034 !strconcat(asm, "\t$Rdn, $pattern, mul $imm4")); 1035 1036 let Constraints = "$Rdn = $_Rdn"; 1037} 1038 1039multiclass sve_int_pred_pattern_b_s32<bits<5> opc, string asm, 1040 SDPatternOperator op> { 1041 def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64as32>; 1042 1043 def : InstAlias<asm # "\t$Rd, $Rn, $pattern", 1044 (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, sve_pred_enum:$pattern, 1), 1>; 1045 def : InstAlias<asm # "\t$Rd, $Rn", 1046 (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, 0b11111, 1), 2>; 1047 1048 // NOTE: Register allocation doesn't like tied operands of differing register 1049 // class, hence the extra INSERT_SUBREG complication. 1050 1051 def : Pat<(i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))), 1052 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32), sve_pred_enum:$pattern, sve_incdec_imm:$imm4), sub_32)>; 1053 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))))), 1054 (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32), sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>; 1055} 1056 1057multiclass sve_int_pred_pattern_b_u32<bits<5> opc, string asm, 1058 SDPatternOperator op> { 1059 def NAME : sve_int_pred_pattern_b<opc, asm, GPR32z, GPR32z>; 1060 1061 def : InstAlias<asm # "\t$Rdn, $pattern", 1062 (!cast<Instruction>(NAME) GPR32z:$Rdn, sve_pred_enum:$pattern, 1), 1>; 1063 def : InstAlias<asm # "\t$Rdn", 1064 (!cast<Instruction>(NAME) GPR32z:$Rdn, 0b11111, 1), 2>; 1065 1066 def : Pat<(i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))), 1067 (!cast<Instruction>(NAME) $Rn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>; 1068} 1069 1070multiclass sve_int_pred_pattern_b_x64<bits<5> opc, string asm, 1071 SDPatternOperator op> { 1072 def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64z>; 1073 1074 def : InstAlias<asm # "\t$Rdn, $pattern", 1075 (!cast<Instruction>(NAME) GPR64z:$Rdn, sve_pred_enum:$pattern, 1), 1>; 1076 def : InstAlias<asm # "\t$Rdn", 1077 (!cast<Instruction>(NAME) GPR64z:$Rdn, 0b11111, 1), 2>; 1078 1079 def : Pat<(i64 (op GPR64:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))), 1080 (!cast<Instruction>(NAME) $Rn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>; 1081} 1082 1083 1084//===----------------------------------------------------------------------===// 1085// SVE Permute - Cross Lane Group 1086//===----------------------------------------------------------------------===// 1087 1088class sve_int_perm_dup_r<bits<2> sz8_64, string asm, ZPRRegOp zprty, 1089 ValueType vt, RegisterClass srcRegType, 1090 SDPatternOperator op> 1091: I<(outs zprty:$Zd), (ins srcRegType:$Rn), 1092 asm, "\t$Zd, $Rn", 1093 "", 1094 [(set (vt zprty:$Zd), (op srcRegType:$Rn))]>, Sched<[]> { 1095 bits<5> Rn; 1096 bits<5> Zd; 1097 let Inst{31-24} = 0b00000101; 1098 let Inst{23-22} = sz8_64; 1099 let Inst{21-10} = 0b100000001110; 1100 let Inst{9-5} = Rn; 1101 let Inst{4-0} = Zd; 1102} 1103 1104multiclass sve_int_perm_dup_r<string asm, SDPatternOperator op> { 1105 def _B : sve_int_perm_dup_r<0b00, asm, ZPR8, nxv16i8, GPR32sp, op>; 1106 def _H : sve_int_perm_dup_r<0b01, asm, ZPR16, nxv8i16, GPR32sp, op>; 1107 def _S : sve_int_perm_dup_r<0b10, asm, ZPR32, nxv4i32, GPR32sp, op>; 1108 def _D : sve_int_perm_dup_r<0b11, asm, ZPR64, nxv2i64, GPR64sp, op>; 1109 1110 def : InstAlias<"mov $Zd, $Rn", 1111 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, GPR32sp:$Rn), 1>; 1112 def : InstAlias<"mov $Zd, $Rn", 1113 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, GPR32sp:$Rn), 1>; 1114 def : InstAlias<"mov $Zd, $Rn", 1115 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, GPR32sp:$Rn), 1>; 1116 def : InstAlias<"mov $Zd, $Rn", 1117 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, GPR64sp:$Rn), 1>; 1118} 1119 1120class sve_int_perm_dup_i<bits<5> tsz, Operand immtype, string asm, 1121 ZPRRegOp zprty> 1122: I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$idx), 1123 asm, "\t$Zd, $Zn$idx", 1124 "", 1125 []>, Sched<[]> { 1126 bits<5> Zd; 1127 bits<5> Zn; 1128 bits<7> idx; 1129 let Inst{31-24} = 0b00000101; 1130 let Inst{23-22} = {?,?}; // imm3h 1131 let Inst{21} = 0b1; 1132 let Inst{20-16} = tsz; 1133 let Inst{15-10} = 0b001000; 1134 let Inst{9-5} = Zn; 1135 let Inst{4-0} = Zd; 1136} 1137 1138multiclass sve_int_perm_dup_i<string asm> { 1139 def _B : sve_int_perm_dup_i<{?,?,?,?,1}, sve_elm_idx_extdup_b, asm, ZPR8> { 1140 let Inst{23-22} = idx{5-4}; 1141 let Inst{20-17} = idx{3-0}; 1142 } 1143 def _H : sve_int_perm_dup_i<{?,?,?,1,0}, sve_elm_idx_extdup_h, asm, ZPR16> { 1144 let Inst{23-22} = idx{4-3}; 1145 let Inst{20-18} = idx{2-0}; 1146 } 1147 def _S : sve_int_perm_dup_i<{?,?,1,0,0}, sve_elm_idx_extdup_s, asm, ZPR32> { 1148 let Inst{23-22} = idx{3-2}; 1149 let Inst{20-19} = idx{1-0}; 1150 } 1151 def _D : sve_int_perm_dup_i<{?,1,0,0,0}, sve_elm_idx_extdup_d, asm, ZPR64> { 1152 let Inst{23-22} = idx{2-1}; 1153 let Inst{20} = idx{0}; 1154 } 1155 def _Q : sve_int_perm_dup_i<{1,0,0,0,0}, sve_elm_idx_extdup_q, asm, ZPR128> { 1156 let Inst{23-22} = idx{1-0}; 1157 } 1158 1159 def : InstAlias<"mov $Zd, $Zn$idx", 1160 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, sve_elm_idx_extdup_b:$idx), 1>; 1161 def : InstAlias<"mov $Zd, $Zn$idx", 1162 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, sve_elm_idx_extdup_h:$idx), 1>; 1163 def : InstAlias<"mov $Zd, $Zn$idx", 1164 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, sve_elm_idx_extdup_s:$idx), 1>; 1165 def : InstAlias<"mov $Zd, $Zn$idx", 1166 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, sve_elm_idx_extdup_d:$idx), 1>; 1167 def : InstAlias<"mov $Zd, $Zn$idx", 1168 (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, ZPR128:$Zn, sve_elm_idx_extdup_q:$idx), 1>; 1169 def : InstAlias<"mov $Zd, $Bn", 1170 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, FPR8asZPR:$Bn, 0), 2>; 1171 def : InstAlias<"mov $Zd, $Hn", 1172 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, FPR16asZPR:$Hn, 0), 2>; 1173 def : InstAlias<"mov $Zd, $Sn", 1174 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, FPR32asZPR:$Sn, 0), 2>; 1175 def : InstAlias<"mov $Zd, $Dn", 1176 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, FPR64asZPR:$Dn, 0), 2>; 1177 def : InstAlias<"mov $Zd, $Qn", 1178 (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, FPR128asZPR:$Qn, 0), 2>; 1179 1180 // Duplicate extracted element of vector into all vector elements 1181 def : Pat<(nxv16i8 (AArch64dup (i32 (vector_extract (nxv16i8 ZPR:$vec), sve_elm_idx_extdup_b:$index)))), 1182 (!cast<Instruction>(NAME # _B) ZPR:$vec, sve_elm_idx_extdup_b:$index)>; 1183 def : Pat<(nxv8i16 (AArch64dup (i32 (vector_extract (nxv8i16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))), 1184 (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>; 1185 def : Pat<(nxv4i32 (AArch64dup (i32 (vector_extract (nxv4i32 ZPR:$vec), sve_elm_idx_extdup_s:$index)))), 1186 (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>; 1187 def : Pat<(nxv2i64 (AArch64dup (i64 (vector_extract (nxv2i64 ZPR:$vec), sve_elm_idx_extdup_d:$index)))), 1188 (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>; 1189 def : Pat<(nxv8f16 (AArch64dup (f16 (vector_extract (nxv8f16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))), 1190 (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>; 1191 def : Pat<(nxv8bf16 (AArch64dup (bf16 (vector_extract (nxv8bf16 ZPR:$vec), sve_elm_idx_extdup_h:$index)))), 1192 (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>; 1193 def : Pat<(nxv4f16 (AArch64dup (f16 (vector_extract (nxv4f16 ZPR:$vec), sve_elm_idx_extdup_s:$index)))), 1194 (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>; 1195 def : Pat<(nxv2f16 (AArch64dup (f16 (vector_extract (nxv2f16 ZPR:$vec), sve_elm_idx_extdup_d:$index)))), 1196 (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>; 1197 def : Pat<(nxv4f32 (AArch64dup (f32 (vector_extract (nxv4f32 ZPR:$vec), sve_elm_idx_extdup_s:$index)))), 1198 (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>; 1199 def : Pat<(nxv2f32 (AArch64dup (f32 (vector_extract (nxv2f32 ZPR:$vec), sve_elm_idx_extdup_d:$index)))), 1200 (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>; 1201 def : Pat<(nxv2f64 (AArch64dup (f64 (vector_extract (nxv2f64 ZPR:$vec), sve_elm_idx_extdup_d:$index)))), 1202 (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>; 1203} 1204 1205class sve_int_perm_tbl<bits<2> sz8_64, bits<2> opc, string asm, ZPRRegOp zprty, 1206 RegisterOperand VecList> 1207: I<(outs zprty:$Zd), (ins VecList:$Zn, zprty:$Zm), 1208 asm, "\t$Zd, $Zn, $Zm", 1209 "", 1210 []>, Sched<[]> { 1211 bits<5> Zd; 1212 bits<5> Zm; 1213 bits<5> Zn; 1214 let Inst{31-24} = 0b00000101; 1215 let Inst{23-22} = sz8_64; 1216 let Inst{21} = 0b1; 1217 let Inst{20-16} = Zm; 1218 let Inst{15-13} = 0b001; 1219 let Inst{12-11} = opc; 1220 let Inst{10} = 0b0; 1221 let Inst{9-5} = Zn; 1222 let Inst{4-0} = Zd; 1223} 1224 1225multiclass sve_int_perm_tbl<string asm, SDPatternOperator op> { 1226 def _B : sve_int_perm_tbl<0b00, 0b10, asm, ZPR8, Z_b>; 1227 def _H : sve_int_perm_tbl<0b01, 0b10, asm, ZPR16, Z_h>; 1228 def _S : sve_int_perm_tbl<0b10, 0b10, asm, ZPR32, Z_s>; 1229 def _D : sve_int_perm_tbl<0b11, 0b10, asm, ZPR64, Z_d>; 1230 1231 def : InstAlias<asm # "\t$Zd, $Zn, $Zm", 1232 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 0>; 1233 def : InstAlias<asm # "\t$Zd, $Zn, $Zm", 1234 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 0>; 1235 def : InstAlias<asm # "\t$Zd, $Zn, $Zm", 1236 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 0>; 1237 def : InstAlias<asm # "\t$Zd, $Zn, $Zm", 1238 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, ZPR64:$Zm), 0>; 1239 1240 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 1241 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1242 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 1243 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 1244 1245 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1246 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>; 1247 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>; 1248 1249 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1250} 1251 1252multiclass sve2_int_perm_tbl<string asm, SDPatternOperator op> { 1253 def _B : sve_int_perm_tbl<0b00, 0b01, asm, ZPR8, ZZ_b>; 1254 def _H : sve_int_perm_tbl<0b01, 0b01, asm, ZPR16, ZZ_h>; 1255 def _S : sve_int_perm_tbl<0b10, 0b01, asm, ZPR32, ZZ_s>; 1256 def _D : sve_int_perm_tbl<0b11, 0b01, asm, ZPR64, ZZ_d>; 1257 1258 def : Pat<(nxv16i8 (op nxv16i8:$Op1, nxv16i8:$Op2, nxv16i8:$Op3)), 1259 (nxv16i8 (!cast<Instruction>(NAME # _B) (REG_SEQUENCE ZPR2, nxv16i8:$Op1, zsub0, 1260 nxv16i8:$Op2, zsub1), 1261 nxv16i8:$Op3))>; 1262 1263 def : Pat<(nxv8i16 (op nxv8i16:$Op1, nxv8i16:$Op2, nxv8i16:$Op3)), 1264 (nxv8i16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8i16:$Op1, zsub0, 1265 nxv8i16:$Op2, zsub1), 1266 nxv8i16:$Op3))>; 1267 1268 def : Pat<(nxv4i32 (op nxv4i32:$Op1, nxv4i32:$Op2, nxv4i32:$Op3)), 1269 (nxv4i32 (!cast<Instruction>(NAME # _S) (REG_SEQUENCE ZPR2, nxv4i32:$Op1, zsub0, 1270 nxv4i32:$Op2, zsub1), 1271 nxv4i32:$Op3))>; 1272 1273 def : Pat<(nxv2i64 (op nxv2i64:$Op1, nxv2i64:$Op2, nxv2i64:$Op3)), 1274 (nxv2i64 (!cast<Instruction>(NAME # _D) (REG_SEQUENCE ZPR2, nxv2i64:$Op1, zsub0, 1275 nxv2i64:$Op2, zsub1), 1276 nxv2i64:$Op3))>; 1277 1278 def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8i16:$Op3)), 1279 (nxv8f16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8f16:$Op1, zsub0, 1280 nxv8f16:$Op2, zsub1), 1281 nxv8i16:$Op3))>; 1282 1283 def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4i32:$Op3)), 1284 (nxv4f32 (!cast<Instruction>(NAME # _S) (REG_SEQUENCE ZPR2, nxv4f32:$Op1, zsub0, 1285 nxv4f32:$Op2, zsub1), 1286 nxv4i32:$Op3))>; 1287 1288 def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2i64:$Op3)), 1289 (nxv2f64 (!cast<Instruction>(NAME # _D) (REG_SEQUENCE ZPR2, nxv2f64:$Op1, zsub0, 1290 nxv2f64:$Op2, zsub1), 1291 nxv2i64:$Op3))>; 1292 1293 def : Pat<(nxv8bf16 (op nxv8bf16:$Op1, nxv8bf16:$Op2, nxv8i16:$Op3)), 1294 (nxv8bf16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8bf16:$Op1, zsub0, 1295 nxv8bf16:$Op2, zsub1), 1296 nxv8i16:$Op3))>; 1297} 1298 1299class sve2_int_perm_tbx<bits<2> sz8_64, string asm, ZPRRegOp zprty> 1300: I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, zprty:$Zm), 1301 asm, "\t$Zd, $Zn, $Zm", 1302 "", 1303 []>, Sched<[]> { 1304 bits<5> Zd; 1305 bits<5> Zm; 1306 bits<5> Zn; 1307 let Inst{31-24} = 0b00000101; 1308 let Inst{23-22} = sz8_64; 1309 let Inst{21} = 0b1; 1310 let Inst{20-16} = Zm; 1311 let Inst{15-10} = 0b001011; 1312 let Inst{9-5} = Zn; 1313 let Inst{4-0} = Zd; 1314 1315 let Constraints = "$Zd = $_Zd"; 1316} 1317 1318multiclass sve2_int_perm_tbx<string asm, SDPatternOperator op> { 1319 def _B : sve2_int_perm_tbx<0b00, asm, ZPR8>; 1320 def _H : sve2_int_perm_tbx<0b01, asm, ZPR16>; 1321 def _S : sve2_int_perm_tbx<0b10, asm, ZPR32>; 1322 def _D : sve2_int_perm_tbx<0b11, asm, ZPR64>; 1323 1324 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 1325 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1326 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 1327 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 1328 1329 def : SVE_3_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1330 def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>; 1331 def : SVE_3_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>; 1332 1333 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1334} 1335 1336class sve_int_perm_reverse_z<bits<2> sz8_64, string asm, ZPRRegOp zprty> 1337: I<(outs zprty:$Zd), (ins zprty:$Zn), 1338 asm, "\t$Zd, $Zn", 1339 "", 1340 []>, Sched<[]> { 1341 bits<5> Zd; 1342 bits<5> Zn; 1343 let Inst{31-24} = 0b00000101; 1344 let Inst{23-22} = sz8_64; 1345 let Inst{21-10} = 0b111000001110; 1346 let Inst{9-5} = Zn; 1347 let Inst{4-0} = Zd; 1348} 1349 1350multiclass sve_int_perm_reverse_z<string asm, SDPatternOperator op> { 1351 def _B : sve_int_perm_reverse_z<0b00, asm, ZPR8>; 1352 def _H : sve_int_perm_reverse_z<0b01, asm, ZPR16>; 1353 def _S : sve_int_perm_reverse_z<0b10, asm, ZPR32>; 1354 def _D : sve_int_perm_reverse_z<0b11, asm, ZPR64>; 1355 1356 def : SVE_1_Op_Pat<nxv16i8, op, nxv16i8, !cast<Instruction>(NAME # _B)>; 1357 def : SVE_1_Op_Pat<nxv8i16, op, nxv8i16, !cast<Instruction>(NAME # _H)>; 1358 def : SVE_1_Op_Pat<nxv4i32, op, nxv4i32, !cast<Instruction>(NAME # _S)>; 1359 def : SVE_1_Op_Pat<nxv2i64, op, nxv2i64, !cast<Instruction>(NAME # _D)>; 1360 1361 def : SVE_1_Op_Pat<nxv2f16, op, nxv2f16, !cast<Instruction>(NAME # _D)>; 1362 def : SVE_1_Op_Pat<nxv4f16, op, nxv4f16, !cast<Instruction>(NAME # _S)>; 1363 def : SVE_1_Op_Pat<nxv8f16, op, nxv8f16, !cast<Instruction>(NAME # _H)>; 1364 def : SVE_1_Op_Pat<nxv2f32, op, nxv2f32, !cast<Instruction>(NAME # _D)>; 1365 def : SVE_1_Op_Pat<nxv4f32, op, nxv4f32, !cast<Instruction>(NAME # _S)>; 1366 def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>; 1367 1368 def : SVE_1_Op_Pat<nxv2bf16, op, nxv2bf16, !cast<Instruction>(NAME # _D)>; 1369 def : SVE_1_Op_Pat<nxv4bf16, op, nxv4bf16, !cast<Instruction>(NAME # _S)>; 1370 def : SVE_1_Op_Pat<nxv8bf16, op, nxv8bf16, !cast<Instruction>(NAME # _H)>; 1371} 1372 1373class sve_int_perm_reverse_p<bits<2> sz8_64, string asm, PPRRegOp pprty> 1374: I<(outs pprty:$Pd), (ins pprty:$Pn), 1375 asm, "\t$Pd, $Pn", 1376 "", 1377 []>, Sched<[]> { 1378 bits<4> Pd; 1379 bits<4> Pn; 1380 let Inst{31-24} = 0b00000101; 1381 let Inst{23-22} = sz8_64; 1382 let Inst{21-9} = 0b1101000100000; 1383 let Inst{8-5} = Pn; 1384 let Inst{4} = 0b0; 1385 let Inst{3-0} = Pd; 1386} 1387 1388multiclass sve_int_perm_reverse_p<string asm, SDPatternOperator op> { 1389 def _B : sve_int_perm_reverse_p<0b00, asm, PPR8>; 1390 def _H : sve_int_perm_reverse_p<0b01, asm, PPR16>; 1391 def _S : sve_int_perm_reverse_p<0b10, asm, PPR32>; 1392 def _D : sve_int_perm_reverse_p<0b11, asm, PPR64>; 1393 1394 def : SVE_1_Op_Pat<nxv16i1, op, nxv16i1, !cast<Instruction>(NAME # _B)>; 1395 def : SVE_1_Op_Pat<nxv8i1, op, nxv8i1, !cast<Instruction>(NAME # _H)>; 1396 def : SVE_1_Op_Pat<nxv4i1, op, nxv4i1, !cast<Instruction>(NAME # _S)>; 1397 def : SVE_1_Op_Pat<nxv2i1, op, nxv2i1, !cast<Instruction>(NAME # _D)>; 1398} 1399 1400class sve_int_perm_unpk<bits<2> sz16_64, bits<2> opc, string asm, 1401 ZPRRegOp zprty1, ZPRRegOp zprty2> 1402: I<(outs zprty1:$Zd), (ins zprty2:$Zn), 1403 asm, "\t$Zd, $Zn", 1404 "", []>, Sched<[]> { 1405 bits<5> Zd; 1406 bits<5> Zn; 1407 let Inst{31-24} = 0b00000101; 1408 let Inst{23-22} = sz16_64; 1409 let Inst{21-18} = 0b1100; 1410 let Inst{17-16} = opc; 1411 let Inst{15-10} = 0b001110; 1412 let Inst{9-5} = Zn; 1413 let Inst{4-0} = Zd; 1414} 1415 1416multiclass sve_int_perm_unpk<bits<2> opc, string asm, SDPatternOperator op> { 1417 def _H : sve_int_perm_unpk<0b01, opc, asm, ZPR16, ZPR8>; 1418 def _S : sve_int_perm_unpk<0b10, opc, asm, ZPR32, ZPR16>; 1419 def _D : sve_int_perm_unpk<0b11, opc, asm, ZPR64, ZPR32>; 1420 1421 def : SVE_1_Op_Pat<nxv8i16, op, nxv16i8, !cast<Instruction>(NAME # _H)>; 1422 def : SVE_1_Op_Pat<nxv4i32, op, nxv8i16, !cast<Instruction>(NAME # _S)>; 1423 def : SVE_1_Op_Pat<nxv2i64, op, nxv4i32, !cast<Instruction>(NAME # _D)>; 1424} 1425 1426class sve_int_perm_insrs<bits<2> sz8_64, string asm, ZPRRegOp zprty, 1427 RegisterClass srcRegType> 1428: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcRegType:$Rm), 1429 asm, "\t$Zdn, $Rm", 1430 "", 1431 []>, Sched<[]> { 1432 bits<5> Rm; 1433 bits<5> Zdn; 1434 let Inst{31-24} = 0b00000101; 1435 let Inst{23-22} = sz8_64; 1436 let Inst{21-10} = 0b100100001110; 1437 let Inst{9-5} = Rm; 1438 let Inst{4-0} = Zdn; 1439 1440 let Constraints = "$Zdn = $_Zdn"; 1441 let DestructiveInstType = DestructiveOther; 1442} 1443 1444multiclass sve_int_perm_insrs<string asm, SDPatternOperator op> { 1445 def _B : sve_int_perm_insrs<0b00, asm, ZPR8, GPR32>; 1446 def _H : sve_int_perm_insrs<0b01, asm, ZPR16, GPR32>; 1447 def _S : sve_int_perm_insrs<0b10, asm, ZPR32, GPR32>; 1448 def _D : sve_int_perm_insrs<0b11, asm, ZPR64, GPR64>; 1449 1450 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, i32, !cast<Instruction>(NAME # _B)>; 1451 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, i32, !cast<Instruction>(NAME # _H)>; 1452 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, i32, !cast<Instruction>(NAME # _S)>; 1453 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, i64, !cast<Instruction>(NAME # _D)>; 1454} 1455 1456class sve_int_perm_insrv<bits<2> sz8_64, string asm, ZPRRegOp zprty, 1457 FPRasZPROperand srcOpType> 1458: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcOpType:$Vm), 1459 asm, "\t$Zdn, $Vm", 1460 "", 1461 []>, Sched<[]> { 1462 bits<5> Vm; 1463 bits<5> Zdn; 1464 let Inst{31-24} = 0b00000101; 1465 let Inst{23-22} = sz8_64; 1466 let Inst{21-10} = 0b110100001110; 1467 let Inst{9-5} = Vm; 1468 let Inst{4-0} = Zdn; 1469 1470 let Constraints = "$Zdn = $_Zdn"; 1471 let DestructiveInstType = DestructiveOther; 1472} 1473 1474multiclass sve_int_perm_insrv<string asm, SDPatternOperator op> { 1475 def _B : sve_int_perm_insrv<0b00, asm, ZPR8, FPR8asZPR>; 1476 def _H : sve_int_perm_insrv<0b01, asm, ZPR16, FPR16asZPR>; 1477 def _S : sve_int_perm_insrv<0b10, asm, ZPR32, FPR32asZPR>; 1478 def _D : sve_int_perm_insrv<0b11, asm, ZPR64, FPR64asZPR>; 1479 1480 def : Pat<(nxv8f16 (op nxv8f16:$Zn, f16:$Vm)), 1481 (!cast<Instruction>(NAME # _H) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, hsub))>; 1482 def : Pat<(nxv4f32 (op nxv4f32:$Zn, f32:$Vm)), 1483 (!cast<Instruction>(NAME # _S) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, ssub))>; 1484 def : Pat<(nxv2f64 (op nxv2f64:$Zn, f64:$Vm)), 1485 (!cast<Instruction>(NAME # _D) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, dsub))>; 1486 1487 def : Pat<(nxv8bf16 (op nxv8bf16:$Zn, bf16:$Vm)), 1488 (!cast<Instruction>(NAME # _H) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, hsub))>; 1489 1490 // Keep integer insertions within the vector unit. 1491 def : Pat<(nxv16i8 (op (nxv16i8 ZPR:$Zn), (i32 (vector_extract (nxv16i8 ZPR:$Vm), 0)))), 1492 (!cast<Instruction>(NAME # _B) $Zn, ZPR:$Vm)>; 1493 def : Pat<(nxv8i16 (op (nxv8i16 ZPR:$Zn), (i32 (vector_extract (nxv8i16 ZPR:$Vm), 0)))), 1494 (!cast<Instruction>(NAME # _H) $Zn, ZPR:$Vm)>; 1495 def : Pat<(nxv4i32 (op (nxv4i32 ZPR:$Zn), (i32 (vector_extract (nxv4i32 ZPR:$Vm), 0)))), 1496 (!cast<Instruction>(NAME # _S) $Zn, ZPR: $Vm)>; 1497 def : Pat<(nxv2i64 (op (nxv2i64 ZPR:$Zn), (i64 (vector_extract (nxv2i64 ZPR:$Vm), 0)))), 1498 (!cast<Instruction>(NAME # _D) $Zn, ZPR:$Vm)>; 1499 1500} 1501 1502//===----------------------------------------------------------------------===// 1503// SVE Permute - Extract Group 1504//===----------------------------------------------------------------------===// 1505 1506class sve_int_perm_extract_i<string asm> 1507: I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn, ZPR8:$Zm, imm0_255:$imm8), 1508 asm, "\t$Zdn, $_Zdn, $Zm, $imm8", 1509 "", []>, Sched<[]> { 1510 bits<5> Zdn; 1511 bits<5> Zm; 1512 bits<8> imm8; 1513 let Inst{31-21} = 0b00000101001; 1514 let Inst{20-16} = imm8{7-3}; 1515 let Inst{15-13} = 0b000; 1516 let Inst{12-10} = imm8{2-0}; 1517 let Inst{9-5} = Zm; 1518 let Inst{4-0} = Zdn; 1519 1520 let Constraints = "$Zdn = $_Zdn"; 1521 let DestructiveInstType = DestructiveOther; 1522 let ElementSize = ElementSizeNone; 1523} 1524 1525multiclass sve_int_perm_extract_i<string asm, SDPatternOperator op> { 1526 def NAME : sve_int_perm_extract_i<asm>; 1527 1528 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, imm0_255, 1529 !cast<Instruction>(NAME)>; 1530} 1531 1532class sve2_int_perm_extract_i_cons<string asm> 1533: I<(outs ZPR8:$Zd), (ins ZZ_b:$Zn, imm0_255:$imm8), 1534 asm, "\t$Zd, $Zn, $imm8", 1535 "", []>, Sched<[]> { 1536 bits<5> Zd; 1537 bits<5> Zn; 1538 bits<8> imm8; 1539 let Inst{31-21} = 0b00000101011; 1540 let Inst{20-16} = imm8{7-3}; 1541 let Inst{15-13} = 0b000; 1542 let Inst{12-10} = imm8{2-0}; 1543 let Inst{9-5} = Zn; 1544 let Inst{4-0} = Zd; 1545} 1546 1547//===----------------------------------------------------------------------===// 1548// SVE Vector Select Group 1549//===----------------------------------------------------------------------===// 1550 1551class sve_int_sel_vvv<bits<2> sz8_64, string asm, ZPRRegOp zprty> 1552: I<(outs zprty:$Zd), (ins PPRAny:$Pg, zprty:$Zn, zprty:$Zm), 1553 asm, "\t$Zd, $Pg, $Zn, $Zm", 1554 "", 1555 []>, Sched<[]> { 1556 bits<4> Pg; 1557 bits<5> Zd; 1558 bits<5> Zm; 1559 bits<5> Zn; 1560 let Inst{31-24} = 0b00000101; 1561 let Inst{23-22} = sz8_64; 1562 let Inst{21} = 0b1; 1563 let Inst{20-16} = Zm; 1564 let Inst{15-14} = 0b11; 1565 let Inst{13-10} = Pg; 1566 let Inst{9-5} = Zn; 1567 let Inst{4-0} = Zd; 1568} 1569 1570multiclass sve_int_sel_vvv<string asm, SDPatternOperator op> { 1571 def _B : sve_int_sel_vvv<0b00, asm, ZPR8>; 1572 def _H : sve_int_sel_vvv<0b01, asm, ZPR16>; 1573 def _S : sve_int_sel_vvv<0b10, asm, ZPR32>; 1574 def _D : sve_int_sel_vvv<0b11, asm, ZPR64>; 1575 1576 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 1577 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1578 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 1579 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 1580 1581 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 1582 def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _S)>; 1583 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 1584 def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _D)>; 1585 def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _D)>; 1586 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 1587 1588 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>; 1589 1590 def : InstAlias<"mov $Zd, $Pg/m, $Zn", 1591 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPRAny:$Pg, ZPR8:$Zn, ZPR8:$Zd), 1>; 1592 def : InstAlias<"mov $Zd, $Pg/m, $Zn", 1593 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, ZPR16:$Zn, ZPR16:$Zd), 1>; 1594 def : InstAlias<"mov $Zd, $Pg/m, $Zn", 1595 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, ZPR32:$Zn, ZPR32:$Zd), 1>; 1596 def : InstAlias<"mov $Zd, $Pg/m, $Zn", 1597 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, ZPR64:$Zn, ZPR64:$Zd), 1>; 1598} 1599 1600 1601//===----------------------------------------------------------------------===// 1602// SVE Predicate Logical Operations Group 1603//===----------------------------------------------------------------------===// 1604 1605class sve_int_pred_log<bits<4> opc, string asm> 1606: I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm), 1607 asm, "\t$Pd, $Pg/z, $Pn, $Pm", 1608 "", 1609 []>, Sched<[]> { 1610 bits<4> Pd; 1611 bits<4> Pg; 1612 bits<4> Pm; 1613 bits<4> Pn; 1614 let Inst{31-24} = 0b00100101; 1615 let Inst{23-22} = opc{3-2}; 1616 let Inst{21-20} = 0b00; 1617 let Inst{19-16} = Pm; 1618 let Inst{15-14} = 0b01; 1619 let Inst{13-10} = Pg; 1620 let Inst{9} = opc{1}; 1621 let Inst{8-5} = Pn; 1622 let Inst{4} = opc{0}; 1623 let Inst{3-0} = Pd; 1624 1625 // SEL has no predication qualifier. 1626 let AsmString = !if(!eq(opc, 0b0011), 1627 !strconcat(asm, "\t$Pd, $Pg, $Pn, $Pm"), 1628 !strconcat(asm, "\t$Pd, $Pg/z, $Pn, $Pm")); 1629 1630 let Defs = !if(!eq (opc{2}, 1), [NZCV], []); 1631 1632} 1633 1634multiclass sve_int_pred_log<bits<4> opc, string asm, SDPatternOperator op, 1635 SDPatternOperator op_nopred = null_frag> { 1636 def NAME : sve_int_pred_log<opc, asm>; 1637 1638 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>; 1639 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, nxv8i1, !cast<Instruction>(NAME)>; 1640 def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, nxv4i1, !cast<Instruction>(NAME)>; 1641 def : SVE_3_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, nxv2i1, !cast<Instruction>(NAME)>; 1642 def : SVE_2_Op_AllActive_Pat<nxv16i1, op_nopred, nxv16i1, nxv16i1, 1643 !cast<Instruction>(NAME), PTRUE_B>; 1644 def : SVE_2_Op_AllActive_Pat<nxv8i1, op_nopred, nxv8i1, nxv8i1, 1645 !cast<Instruction>(NAME), PTRUE_H>; 1646 def : SVE_2_Op_AllActive_Pat<nxv4i1, op_nopred, nxv4i1, nxv4i1, 1647 !cast<Instruction>(NAME), PTRUE_S>; 1648 def : SVE_2_Op_AllActive_Pat<nxv2i1, op_nopred, nxv2i1, nxv2i1, 1649 !cast<Instruction>(NAME), PTRUE_D>; 1650} 1651 1652// An instance of sve_int_pred_log_and but uses op_nopred's first operand as the 1653// general predicate. 1654multiclass sve_int_pred_log_v2<bits<4> opc, string asm, SDPatternOperator op, 1655 SDPatternOperator op_nopred> : 1656 sve_int_pred_log<opc, asm, op> { 1657 def : Pat<(nxv16i1 (op_nopred nxv16i1:$Op1, nxv16i1:$Op2)), 1658 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>; 1659 def : Pat<(nxv8i1 (op_nopred nxv8i1:$Op1, nxv8i1:$Op2)), 1660 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>; 1661 def : Pat<(nxv4i1 (op_nopred nxv4i1:$Op1, nxv4i1:$Op2)), 1662 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>; 1663 def : Pat<(nxv2i1 (op_nopred nxv2i1:$Op1, nxv2i1:$Op2)), 1664 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>; 1665} 1666 1667//===----------------------------------------------------------------------===// 1668// SVE Logical Mask Immediate Group 1669//===----------------------------------------------------------------------===// 1670 1671class sve_int_log_imm<bits<2> opc, string asm> 1672: I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, logical_imm64:$imms13), 1673 asm, "\t$Zdn, $_Zdn, $imms13", 1674 "", []>, Sched<[]> { 1675 bits<5> Zdn; 1676 bits<13> imms13; 1677 let Inst{31-24} = 0b00000101; 1678 let Inst{23-22} = opc; 1679 let Inst{21-18} = 0b0000; 1680 let Inst{17-5} = imms13; 1681 let Inst{4-0} = Zdn; 1682 1683 let Constraints = "$Zdn = $_Zdn"; 1684 let DecoderMethod = "DecodeSVELogicalImmInstruction"; 1685 let DestructiveInstType = DestructiveOther; 1686 let ElementSize = ElementSizeNone; 1687} 1688 1689multiclass sve_int_log_imm<bits<2> opc, string asm, string alias, SDPatternOperator op> { 1690 def NAME : sve_int_log_imm<opc, asm>; 1691 1692 def : SVE_1_Op_Imm_Log_Pat<nxv16i8, op, ZPR8, i32, SVELogicalImm8Pat, !cast<Instruction>(NAME)>; 1693 def : SVE_1_Op_Imm_Log_Pat<nxv8i16, op, ZPR16, i32, SVELogicalImm16Pat, !cast<Instruction>(NAME)>; 1694 def : SVE_1_Op_Imm_Log_Pat<nxv4i32, op, ZPR32, i32, SVELogicalImm32Pat, !cast<Instruction>(NAME)>; 1695 def : SVE_1_Op_Imm_Log_Pat<nxv2i64, op, ZPR64, i64, SVELogicalImm64Pat, !cast<Instruction>(NAME)>; 1696 1697 def : InstAlias<asm # "\t$Zdn, $Zdn, $imm", 1698 (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8:$imm), 4>; 1699 def : InstAlias<asm # "\t$Zdn, $Zdn, $imm", 1700 (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16:$imm), 3>; 1701 def : InstAlias<asm # "\t$Zdn, $Zdn, $imm", 1702 (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32:$imm), 2>; 1703 1704 def : InstAlias<alias # "\t$Zdn, $Zdn, $imm", 1705 (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8_not:$imm), 0>; 1706 def : InstAlias<alias # "\t$Zdn, $Zdn, $imm", 1707 (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16_not:$imm), 0>; 1708 def : InstAlias<alias # "\t$Zdn, $Zdn, $imm", 1709 (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32_not:$imm), 0>; 1710 def : InstAlias<alias # "\t$Zdn, $Zdn, $imm", 1711 (!cast<Instruction>(NAME) ZPR64:$Zdn, logical_imm64_not:$imm), 0>; 1712} 1713 1714multiclass sve_int_log_imm_bic<SDPatternOperator op> { 1715 def : SVE_1_Op_Imm_Log_Pat<nxv16i8, op, ZPR8, i32, SVELogicalImm8NotPat, !cast<Instruction>("AND_ZI")>; 1716 def : SVE_1_Op_Imm_Log_Pat<nxv8i16, op, ZPR16, i32, SVELogicalImm16NotPat, !cast<Instruction>("AND_ZI")>; 1717 def : SVE_1_Op_Imm_Log_Pat<nxv4i32, op, ZPR32, i32, SVELogicalImm32NotPat, !cast<Instruction>("AND_ZI")>; 1718 def : SVE_1_Op_Imm_Log_Pat<nxv2i64, op, ZPR64, i64, SVELogicalImm64NotPat, !cast<Instruction>("AND_ZI")>; 1719} 1720 1721class sve_int_dup_mask_imm<string asm> 1722: I<(outs ZPR64:$Zd), (ins logical_imm64:$imms), 1723 asm, "\t$Zd, $imms", 1724 "", 1725 []>, Sched<[]> { 1726 bits<5> Zd; 1727 bits<13> imms; 1728 let Inst{31-18} = 0b00000101110000; 1729 let Inst{17-5} = imms; 1730 let Inst{4-0} = Zd; 1731 1732 let isReMaterializable = 1; 1733 let DecoderMethod = "DecodeSVELogicalImmInstruction"; 1734} 1735 1736multiclass sve_int_dup_mask_imm<string asm> { 1737 def NAME : sve_int_dup_mask_imm<asm>; 1738 1739 def : InstAlias<"dupm $Zd, $imm", 1740 (!cast<Instruction>(NAME) ZPR8:$Zd, sve_logical_imm8:$imm), 4>; 1741 def : InstAlias<"dupm $Zd, $imm", 1742 (!cast<Instruction>(NAME) ZPR16:$Zd, sve_logical_imm16:$imm), 3>; 1743 def : InstAlias<"dupm $Zd, $imm", 1744 (!cast<Instruction>(NAME) ZPR32:$Zd, sve_logical_imm32:$imm), 2>; 1745 1746 // All Zd.b forms have a CPY/DUP equivalent, hence no byte alias here. 1747 def : InstAlias<"mov $Zd, $imm", 1748 (!cast<Instruction>(NAME) ZPR16:$Zd, sve_preferred_logical_imm16:$imm), 7>; 1749 def : InstAlias<"mov $Zd, $imm", 1750 (!cast<Instruction>(NAME) ZPR32:$Zd, sve_preferred_logical_imm32:$imm), 6>; 1751 def : InstAlias<"mov $Zd, $imm", 1752 (!cast<Instruction>(NAME) ZPR64:$Zd, sve_preferred_logical_imm64:$imm), 5>; 1753 1754 def : Pat<(nxv2i64 (AArch64dup (i64 logical_imm64:$imm))), 1755 (!cast<Instruction>(NAME) logical_imm64:$imm)>; 1756} 1757 1758//===----------------------------------------------------------------------===// 1759// SVE Integer Arithmetic - Unpredicated Group. 1760//===----------------------------------------------------------------------===// 1761 1762class sve_int_bin_cons_arit_0<bits<2> sz8_64, bits<3> opc, string asm, 1763 ZPRRegOp zprty> 1764: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm), 1765 asm, "\t$Zd, $Zn, $Zm", 1766 "", []>, Sched<[]> { 1767 bits<5> Zd; 1768 bits<5> Zm; 1769 bits<5> Zn; 1770 let Inst{31-24} = 0b00000100; 1771 let Inst{23-22} = sz8_64; 1772 let Inst{21} = 0b1; 1773 let Inst{20-16} = Zm; 1774 let Inst{15-13} = 0b000; 1775 let Inst{12-10} = opc; 1776 let Inst{9-5} = Zn; 1777 let Inst{4-0} = Zd; 1778} 1779 1780multiclass sve_int_bin_cons_arit_0<bits<3> opc, string asm, SDPatternOperator op> { 1781 def _B : sve_int_bin_cons_arit_0<0b00, opc, asm, ZPR8>; 1782 def _H : sve_int_bin_cons_arit_0<0b01, opc, asm, ZPR16>; 1783 def _S : sve_int_bin_cons_arit_0<0b10, opc, asm, ZPR32>; 1784 def _D : sve_int_bin_cons_arit_0<0b11, opc, asm, ZPR64>; 1785 1786 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 1787 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1788 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 1789 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 1790} 1791 1792//===----------------------------------------------------------------------===// 1793// SVE Floating Point Arithmetic - Predicated Group 1794//===----------------------------------------------------------------------===// 1795 1796class sve_fp_2op_i_p_zds<bits<2> sz, bits<3> opc, string asm, 1797 ZPRRegOp zprty, 1798 Operand imm_ty> 1799: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, imm_ty:$i1), 1800 asm, "\t$Zdn, $Pg/m, $_Zdn, $i1", 1801 "", 1802 []>, Sched<[]> { 1803 bits<3> Pg; 1804 bits<5> Zdn; 1805 bit i1; 1806 let Inst{31-24} = 0b01100101; 1807 let Inst{23-22} = sz; 1808 let Inst{21-19} = 0b011; 1809 let Inst{18-16} = opc; 1810 let Inst{15-13} = 0b100; 1811 let Inst{12-10} = Pg; 1812 let Inst{9-6} = 0b0000; 1813 let Inst{5} = i1; 1814 let Inst{4-0} = Zdn; 1815 1816 let Constraints = "$Zdn = $_Zdn"; 1817 let DestructiveInstType = DestructiveOther; 1818 let ElementSize = zprty.ElementSize; 1819} 1820 1821multiclass sve_fp_2op_i_p_zds<bits<3> opc, string asm, string Ps, Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator op> { 1822 let DestructiveInstType = DestructiveBinaryImm in { 1823 def _H : SVEPseudo2Instr<Ps # _H, 1>, sve_fp_2op_i_p_zds<0b01, opc, asm, ZPR16, imm_ty>; 1824 def _S : SVEPseudo2Instr<Ps # _S, 1>, sve_fp_2op_i_p_zds<0b10, opc, asm, ZPR32, imm_ty>; 1825 def _D : SVEPseudo2Instr<Ps # _D, 1>, sve_fp_2op_i_p_zds<0b11, opc, asm, ZPR64, imm_ty>; 1826 } 1827 1828 def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_H")>; 1829 def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_H")>; 1830 def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_S")>; 1831 def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_S")>; 1832 def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_D")>; 1833 def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_D")>; 1834} 1835 1836class sve_fp_2op_p_zds<bits<2> sz, bits<4> opc, string asm, 1837 ZPRRegOp zprty> 1838: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm), 1839 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", 1840 "", 1841 []>, Sched<[]> { 1842 bits<3> Pg; 1843 bits<5> Zdn; 1844 bits<5> Zm; 1845 let Inst{31-24} = 0b01100101; 1846 let Inst{23-22} = sz; 1847 let Inst{21-20} = 0b00; 1848 let Inst{19-16} = opc; 1849 let Inst{15-13} = 0b100; 1850 let Inst{12-10} = Pg; 1851 let Inst{9-5} = Zm; 1852 let Inst{4-0} = Zdn; 1853 1854 let Constraints = "$Zdn = $_Zdn"; 1855 let DestructiveInstType = DestructiveOther; 1856 let ElementSize = zprty.ElementSize; 1857} 1858 1859multiclass sve_fp_2op_p_zds<bits<4> opc, string asm, string Ps, 1860 SDPatternOperator op, DestructiveInstTypeEnum flags, 1861 string revname="", bit isReverseInstr=0> { 1862 let DestructiveInstType = flags in { 1863 def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>, 1864 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>; 1865 def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>, 1866 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>; 1867 def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>, 1868 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>; 1869 } 1870 1871 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 1872 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 1873 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 1874} 1875 1876multiclass sve_fp_2op_p_zds_fscale<bits<4> opc, string asm, 1877 SDPatternOperator op> { 1878 def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>; 1879 def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>; 1880 def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>; 1881 1882 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>; 1883 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>; 1884 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>; 1885} 1886 1887multiclass sve_fp_2op_p_zds_zeroing_hsd<SDPatternOperator op> { 1888 def _ZERO_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesZero>; 1889 def _ZERO_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesZero>; 1890 def _ZERO_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesZero>; 1891 1892 def : SVE_3_Op_Pat_SelZero<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Pseudo>(NAME # _ZERO_H)>; 1893 def : SVE_3_Op_Pat_SelZero<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Pseudo>(NAME # _ZERO_S)>; 1894 def : SVE_3_Op_Pat_SelZero<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Pseudo>(NAME # _ZERO_D)>; 1895} 1896 1897class sve_fp_ftmad<bits<2> sz, string asm, ZPRRegOp zprty> 1898: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, timm32_0_7:$imm3), 1899 asm, "\t$Zdn, $_Zdn, $Zm, $imm3", 1900 "", 1901 []>, Sched<[]> { 1902 bits<5> Zdn; 1903 bits<5> Zm; 1904 bits<3> imm3; 1905 let Inst{31-24} = 0b01100101; 1906 let Inst{23-22} = sz; 1907 let Inst{21-19} = 0b010; 1908 let Inst{18-16} = imm3; 1909 let Inst{15-10} = 0b100000; 1910 let Inst{9-5} = Zm; 1911 let Inst{4-0} = Zdn; 1912 1913 let Constraints = "$Zdn = $_Zdn"; 1914 let DestructiveInstType = DestructiveOther; 1915 let ElementSize = ElementSizeNone; 1916} 1917 1918multiclass sve_fp_ftmad<string asm, SDPatternOperator op> { 1919 def _H : sve_fp_ftmad<0b01, asm, ZPR16>; 1920 def _S : sve_fp_ftmad<0b10, asm, ZPR32>; 1921 def _D : sve_fp_ftmad<0b11, asm, ZPR64>; 1922 1923 def : Pat<(nxv8f16 (op (nxv8f16 ZPR16:$Zn), (nxv8f16 ZPR16:$Zm), (i32 timm32_0_7:$imm))), 1924 (!cast<Instruction>(NAME # _H) ZPR16:$Zn, ZPR16:$Zm, timm32_0_7:$imm)>; 1925 def : Pat<(nxv4f32 (op (nxv4f32 ZPR32:$Zn), (nxv4f32 ZPR32:$Zm), (i32 timm32_0_7:$imm))), 1926 (!cast<Instruction>(NAME # _S) ZPR32:$Zn, ZPR32:$Zm, timm32_0_7:$imm)>; 1927 def : Pat<(nxv2f64 (op (nxv2f64 ZPR64:$Zn), (nxv2f64 ZPR64:$Zm), (i32 timm32_0_7:$imm))), 1928 (!cast<Instruction>(NAME # _D) ZPR64:$Zn, ZPR64:$Zm, timm32_0_7:$imm)>; 1929} 1930 1931multiclass sve_fp_2op_i_p_zds_hfd<Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator ir_op = null_frag> { 1932 def _UNDEF_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, imm_ty, FalseLanesUndef>; 1933 def _UNDEF_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, imm_ty, FalseLanesUndef>; 1934 def _UNDEF_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, imm_ty, FalseLanesUndef>; 1935 1936 def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, ir_op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_UNDEF_H")>; 1937 def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, ir_op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_UNDEF_H")>; 1938 def : SVE_2_Op_Fp_Imm_Pat<nxv4f16, ir_op, nxv4i1, f16, A, 0, !cast<Instruction>(NAME # "_UNDEF_H")>; 1939 def : SVE_2_Op_Fp_Imm_Pat<nxv4f16, ir_op, nxv4i1, f16, B, 1, !cast<Instruction>(NAME # "_UNDEF_H")>; 1940 def : SVE_2_Op_Fp_Imm_Pat<nxv2f16, ir_op, nxv2i1, f16, A, 0, !cast<Instruction>(NAME # "_UNDEF_H")>; 1941 def : SVE_2_Op_Fp_Imm_Pat<nxv2f16, ir_op, nxv2i1, f16, B, 1, !cast<Instruction>(NAME # "_UNDEF_H")>; 1942 def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, ir_op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_UNDEF_S")>; 1943 def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, ir_op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_UNDEF_S")>; 1944 def : SVE_2_Op_Fp_Imm_Pat<nxv2f32, ir_op, nxv2i1, f32, A, 0, !cast<Instruction>(NAME # "_UNDEF_S")>; 1945 def : SVE_2_Op_Fp_Imm_Pat<nxv2f32, ir_op, nxv2i1, f32, B, 1, !cast<Instruction>(NAME # "_UNDEF_S")>; 1946 def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, ir_op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_UNDEF_D")>; 1947 def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, ir_op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_UNDEF_D")>; 1948} 1949 1950multiclass sve_fp_2op_i_p_zds_zeroing_hfd<Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator op> { 1951 def _ZERO_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, imm_ty, FalseLanesZero>; 1952 def _ZERO_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, imm_ty, FalseLanesZero>; 1953 def _ZERO_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, imm_ty, FalseLanesZero>; 1954 1955 let AddedComplexity = 2 in { 1956 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv8f16, op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_ZERO_H")>; 1957 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv8f16, op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_ZERO_H")>; 1958 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv4f32, op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_ZERO_S")>; 1959 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv4f32, op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_ZERO_S")>; 1960 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv2f64, op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_ZERO_D")>; 1961 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv2f64, op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_ZERO_D")>; 1962 } 1963} 1964 1965//===----------------------------------------------------------------------===// 1966// SVE Floating Point Arithmetic - Unpredicated Group 1967//===----------------------------------------------------------------------===// 1968 1969class sve_fp_3op_u_zd<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty> 1970: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm), 1971 asm, "\t$Zd, $Zn, $Zm", 1972 "", 1973 []>, Sched<[]> { 1974 bits<5> Zd; 1975 bits<5> Zm; 1976 bits<5> Zn; 1977 let Inst{31-24} = 0b01100101; 1978 let Inst{23-22} = sz; 1979 let Inst{21} = 0b0; 1980 let Inst{20-16} = Zm; 1981 let Inst{15-13} = 0b000; 1982 let Inst{12-10} = opc; 1983 let Inst{9-5} = Zn; 1984 let Inst{4-0} = Zd; 1985} 1986 1987multiclass sve_fp_3op_u_zd<bits<3> opc, string asm, SDPatternOperator op, 1988 SDPatternOperator predicated_op = null_frag> { 1989 def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>; 1990 def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>; 1991 def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>; 1992 1993 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 1994 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 1995 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 1996 1997 def : SVE_2_Op_Pred_All_Active<nxv8f16, predicated_op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 1998 def : SVE_2_Op_Pred_All_Active<nxv4f32, predicated_op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 1999 def : SVE_2_Op_Pred_All_Active<nxv2f64, predicated_op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 2000} 2001 2002multiclass sve_fp_3op_u_zd_ftsmul<bits<3> opc, string asm, SDPatternOperator op> { 2003 def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>; 2004 def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>; 2005 def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>; 2006 2007 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2008 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2009 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2010} 2011 2012//===----------------------------------------------------------------------===// 2013// SVE Floating Point Fused Multiply-Add Group 2014//===----------------------------------------------------------------------===// 2015 2016class sve_fp_3op_p_zds_a<bits<2> sz, bits<2> opc, string asm, ZPRRegOp zprty> 2017: I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm), 2018 asm, "\t$Zda, $Pg/m, $Zn, $Zm", 2019 "", 2020 []>, Sched<[]> { 2021 bits<3> Pg; 2022 bits<5> Zda; 2023 bits<5> Zm; 2024 bits<5> Zn; 2025 let Inst{31-24} = 0b01100101; 2026 let Inst{23-22} = sz; 2027 let Inst{21} = 0b1; 2028 let Inst{20-16} = Zm; 2029 let Inst{15} = 0b0; 2030 let Inst{14-13} = opc; 2031 let Inst{12-10} = Pg; 2032 let Inst{9-5} = Zn; 2033 let Inst{4-0} = Zda; 2034 2035 let Constraints = "$Zda = $_Zda"; 2036 let ElementSize = zprty.ElementSize; 2037} 2038 2039multiclass sve_fp_3op_p_zds_a<bits<2> opc, string asm, string Ps, 2040 SDPatternOperator op, string revname, 2041 bit isReverseInstr=0> { 2042 let DestructiveInstType = DestructiveTernaryCommWithRev in { 2043 def _H : sve_fp_3op_p_zds_a<0b01, opc, asm, ZPR16>, 2044 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>; 2045 def _S : sve_fp_3op_p_zds_a<0b10, opc, asm, ZPR32>, 2046 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>; 2047 def _D : sve_fp_3op_p_zds_a<0b11, opc, asm, ZPR64>, 2048 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>; 2049 } 2050 2051 def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 2052 def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 2053 def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 2054} 2055 2056class sve_fp_3op_p_zds_b<bits<2> sz, bits<2> opc, string asm, 2057 ZPRRegOp zprty> 2058: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za), 2059 asm, "\t$Zdn, $Pg/m, $Zm, $Za", 2060 "", 2061 []>, Sched<[]> { 2062 bits<3> Pg; 2063 bits<5> Za; 2064 bits<5> Zdn; 2065 bits<5> Zm; 2066 let Inst{31-24} = 0b01100101; 2067 let Inst{23-22} = sz; 2068 let Inst{21} = 0b1; 2069 let Inst{20-16} = Za; 2070 let Inst{15} = 0b1; 2071 let Inst{14-13} = opc; 2072 let Inst{12-10} = Pg; 2073 let Inst{9-5} = Zm; 2074 let Inst{4-0} = Zdn; 2075 2076 let Constraints = "$Zdn = $_Zdn"; 2077 let DestructiveInstType = DestructiveOther; 2078 let ElementSize = zprty.ElementSize; 2079} 2080 2081multiclass sve_fp_3op_p_zds_b<bits<2> opc, string asm, SDPatternOperator op, 2082 string revname, bit isReverseInstr> { 2083 def _H : sve_fp_3op_p_zds_b<0b01, opc, asm, ZPR16>, 2084 SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>; 2085 def _S : sve_fp_3op_p_zds_b<0b10, opc, asm, ZPR32>, 2086 SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>; 2087 def _D : sve_fp_3op_p_zds_b<0b11, opc, asm, ZPR64>, 2088 SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>; 2089 2090 def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 2091 def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 2092 def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 2093} 2094 2095multiclass sve_fp_3op_p_zds_zx { 2096 def _UNDEF_H : PredThreeOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>; 2097 def _UNDEF_S : PredThreeOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>; 2098 def _UNDEF_D : PredThreeOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>; 2099} 2100 2101//===----------------------------------------------------------------------===// 2102// SVE Floating Point Multiply-Add - Indexed Group 2103//===----------------------------------------------------------------------===// 2104 2105class sve_fp_fma_by_indexed_elem<bits<2> sz, bit opc, string asm, 2106 ZPRRegOp zprty1, 2107 ZPRRegOp zprty2, Operand itype> 2108: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty1:$Zn, zprty2:$Zm, itype:$iop), 2109 asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> { 2110 bits<5> Zda; 2111 bits<5> Zn; 2112 let Inst{31-24} = 0b01100100; 2113 let Inst{23-22} = sz; 2114 let Inst{21} = 0b1; 2115 let Inst{15-11} = 0; 2116 let Inst{10} = opc; 2117 let Inst{9-5} = Zn; 2118 let Inst{4-0} = Zda; 2119 2120 let Constraints = "$Zda = $_Zda"; 2121 let DestructiveInstType = DestructiveOther; 2122 let ElementSize = ElementSizeNone; 2123} 2124 2125multiclass sve_fp_fma_by_indexed_elem<bit opc, string asm, 2126 SDPatternOperator op> { 2127 def _H : sve_fp_fma_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR3b16, VectorIndexH32b> { 2128 bits<3> Zm; 2129 bits<3> iop; 2130 let Inst{22} = iop{2}; 2131 let Inst{20-19} = iop{1-0}; 2132 let Inst{18-16} = Zm; 2133 } 2134 def _S : sve_fp_fma_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR3b32, VectorIndexS32b> { 2135 bits<3> Zm; 2136 bits<2> iop; 2137 let Inst{20-19} = iop; 2138 let Inst{18-16} = Zm; 2139 } 2140 def _D : sve_fp_fma_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR4b64, VectorIndexD32b> { 2141 bits<4> Zm; 2142 bit iop; 2143 let Inst{20} = iop; 2144 let Inst{19-16} = Zm; 2145 } 2146 2147 def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b_timm:$idx))), 2148 (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b_timm:$idx)>; 2149 def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b_timm:$idx))), 2150 (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx)>; 2151 def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b_timm:$idx))), 2152 (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx)>; 2153} 2154 2155 2156//===----------------------------------------------------------------------===// 2157// SVE Floating Point Multiply - Indexed Group 2158//===----------------------------------------------------------------------===// 2159 2160class sve_fp_fmul_by_indexed_elem<bits<2> sz, string asm, ZPRRegOp zprty, 2161 ZPRRegOp zprty2, Operand itype> 2162: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty2:$Zm, itype:$iop), 2163 asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> { 2164 bits<5> Zd; 2165 bits<5> Zn; 2166 let Inst{31-24} = 0b01100100; 2167 let Inst{23-22} = sz; 2168 let Inst{21} = 0b1; 2169 let Inst{15-10} = 0b001000; 2170 let Inst{9-5} = Zn; 2171 let Inst{4-0} = Zd; 2172} 2173 2174multiclass sve_fp_fmul_by_indexed_elem<string asm, SDPatternOperator op> { 2175 def _H : sve_fp_fmul_by_indexed_elem<{0, ?}, asm, ZPR16, ZPR3b16, VectorIndexH32b> { 2176 bits<3> Zm; 2177 bits<3> iop; 2178 let Inst{22} = iop{2}; 2179 let Inst{20-19} = iop{1-0}; 2180 let Inst{18-16} = Zm; 2181 } 2182 def _S : sve_fp_fmul_by_indexed_elem<0b10, asm, ZPR32, ZPR3b32, VectorIndexS32b> { 2183 bits<3> Zm; 2184 bits<2> iop; 2185 let Inst{20-19} = iop; 2186 let Inst{18-16} = Zm; 2187 } 2188 def _D : sve_fp_fmul_by_indexed_elem<0b11, asm, ZPR64, ZPR4b64, VectorIndexD32b> { 2189 bits<4> Zm; 2190 bit iop; 2191 let Inst{20} = iop; 2192 let Inst{19-16} = Zm; 2193 } 2194 2195 def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b_timm:$idx))), 2196 (!cast<Instruction>(NAME # _H) $Op1, $Op2, VectorIndexH32b_timm:$idx)>; 2197 def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b_timm:$idx))), 2198 (!cast<Instruction>(NAME # _S) $Op1, $Op2, VectorIndexS32b_timm:$idx)>; 2199 def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b_timm:$idx))), 2200 (!cast<Instruction>(NAME # _D) $Op1, $Op2, VectorIndexD32b_timm:$idx)>; 2201} 2202 2203//===----------------------------------------------------------------------===// 2204// SVE Floating Point Complex Multiply-Add Group 2205//===----------------------------------------------------------------------===// 2206 2207class sve_fp_fcmla<bits<2> sz, string asm, ZPRRegOp zprty> 2208: I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm, 2209 complexrotateop:$imm), 2210 asm, "\t$Zda, $Pg/m, $Zn, $Zm, $imm", 2211 "", []>, Sched<[]> { 2212 bits<5> Zda; 2213 bits<3> Pg; 2214 bits<5> Zn; 2215 bits<5> Zm; 2216 bits<2> imm; 2217 let Inst{31-24} = 0b01100100; 2218 let Inst{23-22} = sz; 2219 let Inst{21} = 0; 2220 let Inst{20-16} = Zm; 2221 let Inst{15} = 0; 2222 let Inst{14-13} = imm; 2223 let Inst{12-10} = Pg; 2224 let Inst{9-5} = Zn; 2225 let Inst{4-0} = Zda; 2226 2227 let Constraints = "$Zda = $_Zda"; 2228 let DestructiveInstType = DestructiveOther; 2229 let ElementSize = zprty.ElementSize; 2230} 2231 2232multiclass sve_fp_fcmla<string asm, SDPatternOperator op> { 2233 def _H : sve_fp_fcmla<0b01, asm, ZPR16>; 2234 def _S : sve_fp_fcmla<0b10, asm, ZPR32>; 2235 def _D : sve_fp_fcmla<0b11, asm, ZPR64>; 2236 2237 def : Pat<(nxv8f16 (op nxv8i1:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, nxv8f16:$Op4, (i32 complexrotateop:$imm))), 2238 (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>; 2239 def : Pat<(nxv4f32 (op nxv4i1:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, nxv4f32:$Op4, (i32 complexrotateop:$imm))), 2240 (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>; 2241 def : Pat<(nxv2f64 (op nxv2i1:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, nxv2f64:$Op4, (i32 complexrotateop:$imm))), 2242 (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>; 2243} 2244 2245//===----------------------------------------------------------------------===// 2246// SVE Floating Point Complex Multiply-Add - Indexed Group 2247//===----------------------------------------------------------------------===// 2248 2249class sve_fp_fcmla_by_indexed_elem<bits<2> sz, string asm, 2250 ZPRRegOp zprty, 2251 ZPRRegOp zprty2, Operand itype> 2252: I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty2:$Zm, itype:$iop, 2253 complexrotateop:$imm), 2254 asm, "\t$Zda, $Zn, $Zm$iop, $imm", 2255 "", []>, Sched<[]> { 2256 bits<5> Zda; 2257 bits<5> Zn; 2258 bits<2> imm; 2259 let Inst{31-24} = 0b01100100; 2260 let Inst{23-22} = sz; 2261 let Inst{21} = 0b1; 2262 let Inst{15-12} = 0b0001; 2263 let Inst{11-10} = imm; 2264 let Inst{9-5} = Zn; 2265 let Inst{4-0} = Zda; 2266 2267 let Constraints = "$Zda = $_Zda"; 2268 let DestructiveInstType = DestructiveOther; 2269 let ElementSize = ElementSizeNone; 2270} 2271 2272multiclass sve_fp_fcmla_by_indexed_elem<string asm, SDPatternOperator op> { 2273 def _H : sve_fp_fcmla_by_indexed_elem<0b10, asm, ZPR16, ZPR3b16, VectorIndexS32b> { 2274 bits<3> Zm; 2275 bits<2> iop; 2276 let Inst{20-19} = iop; 2277 let Inst{18-16} = Zm; 2278 } 2279 def _S : sve_fp_fcmla_by_indexed_elem<0b11, asm, ZPR32, ZPR4b32, VectorIndexD32b> { 2280 bits<4> Zm; 2281 bits<1> iop; 2282 let Inst{20} = iop; 2283 let Inst{19-16} = Zm; 2284 } 2285 2286 def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))), 2287 (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>; 2288 def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))), 2289 (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>; 2290} 2291 2292//===----------------------------------------------------------------------===// 2293// SVE Floating Point Complex Addition Group 2294//===----------------------------------------------------------------------===// 2295 2296class sve_fp_fcadd<bits<2> sz, string asm, ZPRRegOp zprty> 2297: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, 2298 complexrotateopodd:$imm), 2299 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm, $imm", 2300 "", 2301 []>, Sched<[]> { 2302 bits<5> Zdn; 2303 bits<5> Zm; 2304 bits<3> Pg; 2305 bit imm; 2306 let Inst{31-24} = 0b01100100; 2307 let Inst{23-22} = sz; 2308 let Inst{21-17} = 0; 2309 let Inst{16} = imm; 2310 let Inst{15-13} = 0b100; 2311 let Inst{12-10} = Pg; 2312 let Inst{9-5} = Zm; 2313 let Inst{4-0} = Zdn; 2314 2315 let Constraints = "$Zdn = $_Zdn"; 2316 let DestructiveInstType = DestructiveOther; 2317 let ElementSize = zprty.ElementSize; 2318} 2319 2320multiclass sve_fp_fcadd<string asm, SDPatternOperator op> { 2321 def _H : sve_fp_fcadd<0b01, asm, ZPR16>; 2322 def _S : sve_fp_fcadd<0b10, asm, ZPR32>; 2323 def _D : sve_fp_fcadd<0b11, asm, ZPR64>; 2324 2325 def : Pat<(nxv8f16 (op nxv8i1:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 complexrotateopodd:$imm))), 2326 (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>; 2327 def : Pat<(nxv4f32 (op nxv4i1:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 complexrotateopodd:$imm))), 2328 (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>; 2329 def : Pat<(nxv2f64 (op nxv2i1:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 complexrotateopodd:$imm))), 2330 (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>; 2331} 2332 2333//===----------------------------------------------------------------------===// 2334// SVE2 Floating Point Convert Group 2335//===----------------------------------------------------------------------===// 2336 2337class sve2_fp_convert_precision<bits<4> opc, string asm, 2338 ZPRRegOp zprty1, ZPRRegOp zprty2> 2339: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, PPR3bAny:$Pg, zprty2:$Zn), 2340 asm, "\t$Zd, $Pg/m, $Zn", 2341 "", 2342 []>, Sched<[]> { 2343 bits<5> Zd; 2344 bits<5> Zn; 2345 bits<3> Pg; 2346 let Inst{31-24} = 0b01100100; 2347 let Inst{23-22} = opc{3-2}; 2348 let Inst{21-18} = 0b0010; 2349 let Inst{17-16} = opc{1-0}; 2350 let Inst{15-13} = 0b101; 2351 let Inst{12-10} = Pg; 2352 let Inst{9-5} = Zn; 2353 let Inst{4-0} = Zd; 2354 2355 let Constraints = "$Zd = $_Zd"; 2356} 2357 2358multiclass sve2_fp_convert_down_narrow<string asm, string op> { 2359 def _StoH : sve2_fp_convert_precision<0b1000, asm, ZPR16, ZPR32>; 2360 def _DtoS : sve2_fp_convert_precision<0b1110, asm, ZPR32, ZPR64>; 2361 2362 def : SVE_3_Op_Pat<nxv8f16, !cast<SDPatternOperator>(op # _f16f32), nxv8f16, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _StoH)>; 2363 def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>; 2364} 2365 2366multiclass sve2_fp_convert_up_long<string asm, string op> { 2367 def _HtoS : sve2_fp_convert_precision<0b1001, asm, ZPR32, ZPR16>; 2368 def _StoD : sve2_fp_convert_precision<0b1111, asm, ZPR64, ZPR32>; 2369 2370 def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f16), nxv4f32, nxv4i1, nxv8f16, !cast<Instruction>(NAME # _HtoS)>; 2371 def : SVE_3_Op_Pat<nxv2f64, !cast<SDPatternOperator>(op # _f64f32), nxv2f64, nxv2i1, nxv4f32, !cast<Instruction>(NAME # _StoD)>; 2372} 2373 2374multiclass sve2_fp_convert_down_odd_rounding_top<string asm, string op> { 2375 def _DtoS : sve2_fp_convert_precision<0b0010, asm, ZPR32, ZPR64>; 2376 2377 def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>; 2378} 2379 2380//===----------------------------------------------------------------------===// 2381// SVE2 Floating Point Pairwise Group 2382//===----------------------------------------------------------------------===// 2383 2384class sve2_fp_pairwise_pred<bits<2> sz, bits<3> opc, string asm, 2385 ZPRRegOp zprty> 2386: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm), 2387 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", 2388 "", 2389 []>, Sched<[]> { 2390 bits<3> Pg; 2391 bits<5> Zm; 2392 bits<5> Zdn; 2393 let Inst{31-24} = 0b01100100; 2394 let Inst{23-22} = sz; 2395 let Inst{21-19} = 0b010; 2396 let Inst{18-16} = opc; 2397 let Inst{15-13} = 0b100; 2398 let Inst{12-10} = Pg; 2399 let Inst{9-5} = Zm; 2400 let Inst{4-0} = Zdn; 2401 2402 let Constraints = "$Zdn = $_Zdn"; 2403 let DestructiveInstType = DestructiveOther; 2404 let ElementSize = zprty.ElementSize; 2405} 2406 2407multiclass sve2_fp_pairwise_pred<bits<3> opc, string asm, 2408 SDPatternOperator op> { 2409 def _H : sve2_fp_pairwise_pred<0b01, opc, asm, ZPR16>; 2410 def _S : sve2_fp_pairwise_pred<0b10, opc, asm, ZPR32>; 2411 def _D : sve2_fp_pairwise_pred<0b11, opc, asm, ZPR64>; 2412 2413 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 2414 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 2415 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 2416} 2417 2418//===----------------------------------------------------------------------===// 2419// SVE2 Floating Point Widening Multiply-Add - Indexed Group 2420//===----------------------------------------------------------------------===// 2421 2422class sve2_fp_mla_long_by_indexed_elem<bits<2> opc, string asm> 2423: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, 2424 VectorIndexH32b:$iop), 2425 asm, "\t$Zda, $Zn, $Zm$iop", 2426 "", 2427 []>, Sched<[]> { 2428 bits<5> Zda; 2429 bits<5> Zn; 2430 bits<3> Zm; 2431 bits<3> iop; 2432 let Inst{31-21} = 0b01100100101; 2433 let Inst{20-19} = iop{2-1}; 2434 let Inst{18-16} = Zm; 2435 let Inst{15-14} = 0b01; 2436 let Inst{13} = opc{1}; 2437 let Inst{12} = 0b0; 2438 let Inst{11} = iop{0}; 2439 let Inst{10} = opc{0}; 2440 let Inst{9-5} = Zn; 2441 let Inst{4-0} = Zda; 2442 2443 let Constraints = "$Zda = $_Zda"; 2444 let DestructiveInstType = DestructiveOther; 2445 let ElementSize = ElementSizeNone; 2446} 2447 2448multiclass sve2_fp_mla_long_by_indexed_elem<bits<2> opc, string asm, 2449 SDPatternOperator op> { 2450 def NAME : sve2_fp_mla_long_by_indexed_elem<opc, asm>; 2451 def : SVE_4_Op_Imm_Pat<nxv4f32, op, nxv4f32, nxv8f16, nxv8f16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME)>; 2452} 2453 2454//===----------------------------------------------------------------------===// 2455// SVE2 Floating Point Widening Multiply-Add Group 2456//===----------------------------------------------------------------------===// 2457 2458class sve2_fp_mla_long<bits<2> opc, string asm> 2459: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm), 2460 asm, "\t$Zda, $Zn, $Zm", 2461 "", 2462 []>, Sched<[]> { 2463 bits<5> Zda; 2464 bits<5> Zn; 2465 bits<5> Zm; 2466 let Inst{31-21} = 0b01100100101; 2467 let Inst{20-16} = Zm; 2468 let Inst{15-14} = 0b10; 2469 let Inst{13} = opc{1}; 2470 let Inst{12-11} = 0b00; 2471 let Inst{10} = opc{0}; 2472 let Inst{9-5} = Zn; 2473 let Inst{4-0} = Zda; 2474 2475 let Constraints = "$Zda = $_Zda"; 2476 let DestructiveInstType = DestructiveOther; 2477 let ElementSize = ElementSizeNone; 2478} 2479 2480multiclass sve2_fp_mla_long<bits<2> opc, string asm, SDPatternOperator op> { 2481 def NAME : sve2_fp_mla_long<opc, asm>; 2482 def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8f16, nxv8f16, !cast<Instruction>(NAME)>; 2483} 2484 2485//===----------------------------------------------------------------------===// 2486// SVE Stack Allocation Group 2487//===----------------------------------------------------------------------===// 2488 2489class sve_int_arith_vl<bit opc, string asm> 2490: I<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, simm6_32b:$imm6), 2491 asm, "\t$Rd, $Rn, $imm6", 2492 "", 2493 []>, Sched<[]> { 2494 bits<5> Rd; 2495 bits<5> Rn; 2496 bits<6> imm6; 2497 let Inst{31-23} = 0b000001000; 2498 let Inst{22} = opc; 2499 let Inst{21} = 0b1; 2500 let Inst{20-16} = Rn; 2501 let Inst{15-11} = 0b01010; 2502 let Inst{10-5} = imm6; 2503 let Inst{4-0} = Rd; 2504} 2505 2506class sve_int_read_vl_a<bit op, bits<5> opc2, string asm> 2507: I<(outs GPR64:$Rd), (ins simm6_32b:$imm6), 2508 asm, "\t$Rd, $imm6", 2509 "", 2510 []>, Sched<[]> { 2511 bits<5> Rd; 2512 bits<6> imm6; 2513 let Inst{31-23} = 0b000001001; 2514 let Inst{22} = op; 2515 let Inst{21} = 0b1; 2516 let Inst{20-16} = opc2{4-0}; 2517 let Inst{15-11} = 0b01010; 2518 let Inst{10-5} = imm6; 2519 let Inst{4-0} = Rd; 2520} 2521 2522//===----------------------------------------------------------------------===// 2523// SVE Permute - In Lane Group 2524//===----------------------------------------------------------------------===// 2525 2526class sve_int_perm_bin_perm_zz<bits<3> opc, bits<2> sz8_64, string asm, 2527 ZPRRegOp zprty> 2528: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm), 2529 asm, "\t$Zd, $Zn, $Zm", 2530 "", 2531 []>, Sched<[]> { 2532 bits<5> Zd; 2533 bits<5> Zm; 2534 bits<5> Zn; 2535 let Inst{31-24} = 0b00000101; 2536 let Inst{23-22} = sz8_64; 2537 let Inst{21} = 0b1; 2538 let Inst{20-16} = Zm; 2539 let Inst{15-13} = 0b011; 2540 let Inst{12-10} = opc; 2541 let Inst{9-5} = Zn; 2542 let Inst{4-0} = Zd; 2543} 2544 2545multiclass sve_int_perm_bin_perm_zz<bits<3> opc, string asm, 2546 SDPatternOperator op> { 2547 def _B : sve_int_perm_bin_perm_zz<opc, 0b00, asm, ZPR8>; 2548 def _H : sve_int_perm_bin_perm_zz<opc, 0b01, asm, ZPR16>; 2549 def _S : sve_int_perm_bin_perm_zz<opc, 0b10, asm, ZPR32>; 2550 def _D : sve_int_perm_bin_perm_zz<opc, 0b11, asm, ZPR64>; 2551 2552 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 2553 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2554 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2555 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2556 2557 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 2558 def : SVE_2_Op_Pat<nxv4f16, op, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _S)>; 2559 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 2560 def : SVE_2_Op_Pat<nxv2f16, op, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _D)>; 2561 def : SVE_2_Op_Pat<nxv2f32, op, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _D)>; 2562 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 2563 2564 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>; 2565} 2566 2567//===----------------------------------------------------------------------===// 2568// SVE Floating Point Unary Operations Group 2569//===----------------------------------------------------------------------===// 2570 2571class sve_fp_2op_p_zd<bits<7> opc, string asm, RegisterOperand i_zprtype, 2572 RegisterOperand o_zprtype, ElementSizeEnum Sz> 2573: I<(outs o_zprtype:$Zd), (ins i_zprtype:$_Zd, PPR3bAny:$Pg, i_zprtype:$Zn), 2574 asm, "\t$Zd, $Pg/m, $Zn", 2575 "", 2576 []>, Sched<[]> { 2577 bits<3> Pg; 2578 bits<5> Zd; 2579 bits<5> Zn; 2580 let Inst{31-24} = 0b01100101; 2581 let Inst{23-22} = opc{6-5}; 2582 let Inst{21} = 0b0; 2583 let Inst{20-16} = opc{4-0}; 2584 let Inst{15-13} = 0b101; 2585 let Inst{12-10} = Pg; 2586 let Inst{9-5} = Zn; 2587 let Inst{4-0} = Zd; 2588 2589 let Constraints = "$Zd = $_Zd"; 2590 let DestructiveInstType = DestructiveUnaryPassthru; 2591 let ElementSize = Sz; 2592} 2593 2594multiclass sve_fp_2op_p_zd<bits<7> opc, string asm, 2595 RegisterOperand i_zprtype, 2596 RegisterOperand o_zprtype, 2597 SDPatternOperator int_op, 2598 SDPatternOperator ir_op, ValueType vt1, 2599 ValueType vt2, ValueType vt3, ElementSizeEnum Sz> { 2600 def NAME : sve_fp_2op_p_zd<opc, asm, i_zprtype, o_zprtype, Sz>, 2601 SVEPseudo2Instr<NAME, 1>; 2602 // convert vt1 to a packed type for the intrinsic patterns 2603 defvar packedvt1 = !cond(!eq(!cast<string>(vt1), "nxv2f16"): nxv8f16, 2604 !eq(!cast<string>(vt1), "nxv4f16"): nxv8f16, 2605 !eq(!cast<string>(vt1), "nxv2f32"): nxv4f32, 2606 1 : vt1); 2607 2608 // convert vt3 to a packed type for the intrinsic patterns 2609 defvar packedvt3 = !cond(!eq(!cast<string>(vt3), "nxv2f16"): nxv8f16, 2610 !eq(!cast<string>(vt3), "nxv4f16"): nxv8f16, 2611 !eq(!cast<string>(vt3), "nxv2f32"): nxv4f32, 2612 1 : vt3); 2613 2614 def : SVE_3_Op_Pat<packedvt1, int_op, packedvt1, vt2, packedvt3, !cast<Instruction>(NAME)>; 2615 def : SVE_1_Op_Passthru_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME)>; 2616 2617 def _UNDEF : PredOneOpPassthruPseudo<NAME, !cast<ZPRRegOp>(i_zprtype)>; 2618 2619 defm : SVE_1_Op_PassthruUndef_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME # _UNDEF)>; 2620} 2621 2622multiclass sve_fp_2op_p_zdr<bits<7> opc, string asm, 2623 RegisterOperand i_zprtype, 2624 RegisterOperand o_zprtype, 2625 SDPatternOperator int_op, 2626 SDPatternOperator ir_op, ValueType vt1, 2627 ValueType vt2, ValueType vt3, ElementSizeEnum Sz> { 2628 def NAME : sve_fp_2op_p_zd<opc, asm, i_zprtype, o_zprtype, Sz>, 2629 SVEPseudo2Instr<NAME, 1>; 2630 2631 // convert vt1 to a packed type for the intrinsic patterns 2632 defvar packedvt1 = !cond(!eq(!cast<string>(vt1), "nxv2f16"): nxv8f16, 2633 !eq(!cast<string>(vt1), "nxv4f16"): nxv8f16, 2634 !eq(!cast<string>(vt1), "nxv2f32"): nxv4f32, 2635 1 : vt1); 2636 2637 def : SVE_3_Op_Pat<packedvt1, int_op, packedvt1, vt2, vt3, !cast<Instruction>(NAME)>; 2638 def : SVE_1_Op_Passthru_Round_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME)>; 2639 2640 def _UNDEF : PredOneOpPassthruPseudo<NAME, !cast<ZPRRegOp>(i_zprtype)>; 2641 2642 defm : SVE_1_Op_PassthruUndef_Round_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME # _UNDEF)>; 2643} 2644 2645multiclass sve_fp_2op_p_zd_HSD<bits<5> opc, string asm, SDPatternOperator op> { 2646 def _H : sve_fp_2op_p_zd<{ 0b01, opc }, asm, ZPR16, ZPR16, ElementSizeH>, 2647 SVEPseudo2Instr<NAME # _H, 1>; 2648 def _S : sve_fp_2op_p_zd<{ 0b10, opc }, asm, ZPR32, ZPR32, ElementSizeS>, 2649 SVEPseudo2Instr<NAME # _S, 1>; 2650 def _D : sve_fp_2op_p_zd<{ 0b11, opc }, asm, ZPR64, ZPR64, ElementSizeD>, 2651 SVEPseudo2Instr<NAME # _D, 1>; 2652 2653 def : SVE_1_Op_Passthru_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 2654 def : SVE_1_Op_Passthru_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>; 2655 def : SVE_1_Op_Passthru_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>; 2656 def : SVE_1_Op_Passthru_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 2657 def : SVE_1_Op_Passthru_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>; 2658 def : SVE_1_Op_Passthru_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 2659 2660 def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>; 2661 def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>; 2662 def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>; 2663 2664 defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _UNDEF_H)>; 2665 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _UNDEF_H)>; 2666 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _UNDEF_H)>; 2667 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _UNDEF_S)>; 2668 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _UNDEF_S)>; 2669 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _UNDEF_D)>; 2670} 2671 2672multiclass sve2_fp_flogb<string asm, SDPatternOperator op> { 2673 def _H : sve_fp_2op_p_zd<0b0011010, asm, ZPR16, ZPR16, ElementSizeH>; 2674 def _S : sve_fp_2op_p_zd<0b0011100, asm, ZPR32, ZPR32, ElementSizeS>; 2675 def _D : sve_fp_2op_p_zd<0b0011110, asm, ZPR64, ZPR64, ElementSizeD>; 2676 2677 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 2678 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 2679 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 2680} 2681 2682multiclass sve2_fp_convert_down_odd_rounding<string asm, string op> { 2683 def _DtoS : sve_fp_2op_p_zd<0b0001010, asm, ZPR64, ZPR32, ElementSizeD>; 2684 def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>; 2685} 2686 2687//===----------------------------------------------------------------------===// 2688// SVE Floating Point Unary Operations - Unpredicated Group 2689//===----------------------------------------------------------------------===// 2690 2691class sve_fp_2op_u_zd<bits<2> sz, bits<3> opc, string asm, 2692 ZPRRegOp zprty> 2693: I<(outs zprty:$Zd), (ins zprty:$Zn), 2694 asm, "\t$Zd, $Zn", 2695 "", 2696 []>, Sched<[]> { 2697 bits<5> Zd; 2698 bits<5> Zn; 2699 let Inst{31-24} = 0b01100101; 2700 let Inst{23-22} = sz; 2701 let Inst{21-19} = 0b001; 2702 let Inst{18-16} = opc; 2703 let Inst{15-10} = 0b001100; 2704 let Inst{9-5} = Zn; 2705 let Inst{4-0} = Zd; 2706} 2707 2708multiclass sve_fp_2op_u_zd<bits<3> opc, string asm, SDPatternOperator op> { 2709 def _H : sve_fp_2op_u_zd<0b01, opc, asm, ZPR16>; 2710 def _S : sve_fp_2op_u_zd<0b10, opc, asm, ZPR32>; 2711 def _D : sve_fp_2op_u_zd<0b11, opc, asm, ZPR64>; 2712 2713 def : SVE_1_Op_Pat<nxv8f16, op, nxv8f16, !cast<Instruction>(NAME # _H)>; 2714 def : SVE_1_Op_Pat<nxv4f32, op, nxv4f32, !cast<Instruction>(NAME # _S)>; 2715 def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>; 2716} 2717 2718//===----------------------------------------------------------------------===// 2719// SVE Integer Arithmetic - Binary Predicated Group 2720//===----------------------------------------------------------------------===// 2721 2722class sve_int_bin_pred_arit_log<bits<2> sz8_64, bits<2> fmt, bits<3> opc, 2723 string asm, ZPRRegOp zprty> 2724: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm), 2725 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> { 2726 bits<3> Pg; 2727 bits<5> Zdn; 2728 bits<5> Zm; 2729 let Inst{31-24} = 0b00000100; 2730 let Inst{23-22} = sz8_64; 2731 let Inst{21} = 0b0; 2732 let Inst{20-19} = fmt; 2733 let Inst{18-16} = opc; 2734 let Inst{15-13} = 0b000; 2735 let Inst{12-10} = Pg; 2736 let Inst{9-5} = Zm; 2737 let Inst{4-0} = Zdn; 2738 2739 let Constraints = "$Zdn = $_Zdn"; 2740 let DestructiveInstType = DestructiveOther; 2741 let ElementSize = zprty.ElementSize; 2742} 2743 2744multiclass sve_int_bin_pred_log<bits<3> opc, string asm, SDPatternOperator op> { 2745 def _B : sve_int_bin_pred_arit_log<0b00, 0b11, opc, asm, ZPR8>; 2746 def _H : sve_int_bin_pred_arit_log<0b01, 0b11, opc, asm, ZPR16>; 2747 def _S : sve_int_bin_pred_arit_log<0b10, 0b11, opc, asm, ZPR32>; 2748 def _D : sve_int_bin_pred_arit_log<0b11, 0b11, opc, asm, ZPR64>; 2749 2750 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 2751 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2752 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2753 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2754} 2755 2756multiclass sve_int_bin_pred_arit_0<bits<3> opc, string asm, string Ps, 2757 SDPatternOperator op, 2758 DestructiveInstTypeEnum flags, 2759 string revname="", bit isReverseInstr=0> { 2760 let DestructiveInstType = flags in { 2761 def _B : sve_int_bin_pred_arit_log<0b00, 0b00, opc, asm, ZPR8>, 2762 SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>; 2763 def _H : sve_int_bin_pred_arit_log<0b01, 0b00, opc, asm, ZPR16>, 2764 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>; 2765 def _S : sve_int_bin_pred_arit_log<0b10, 0b00, opc, asm, ZPR32>, 2766 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>; 2767 def _D : sve_int_bin_pred_arit_log<0b11, 0b00, opc, asm, ZPR64>, 2768 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>; 2769 } 2770 2771 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 2772 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2773 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2774 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2775} 2776 2777multiclass sve_int_bin_pred_arit_1<bits<3> opc, string asm, string Ps, 2778 SDPatternOperator op, 2779 DestructiveInstTypeEnum flags> { 2780 let DestructiveInstType = flags in { 2781 def _B : sve_int_bin_pred_arit_log<0b00, 0b01, opc, asm, ZPR8>, 2782 SVEPseudo2Instr<Ps # _B, 1>; 2783 def _H : sve_int_bin_pred_arit_log<0b01, 0b01, opc, asm, ZPR16>, 2784 SVEPseudo2Instr<Ps # _H, 1>; 2785 def _S : sve_int_bin_pred_arit_log<0b10, 0b01, opc, asm, ZPR32>, 2786 SVEPseudo2Instr<Ps # _S, 1>; 2787 def _D : sve_int_bin_pred_arit_log<0b11, 0b01, opc, asm, ZPR64>, 2788 SVEPseudo2Instr<Ps # _D, 1>; 2789 } 2790 2791 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 2792 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2793 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2794 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2795} 2796 2797multiclass sve_int_bin_pred_arit_2<bits<3> opc, string asm, string Ps, 2798 SDPatternOperator op, 2799 DestructiveInstTypeEnum flags> { 2800 let DestructiveInstType = flags in { 2801 def _B : sve_int_bin_pred_arit_log<0b00, 0b10, opc, asm, ZPR8>, 2802 SVEPseudo2Instr<Ps # _B, 1>; 2803 def _H : sve_int_bin_pred_arit_log<0b01, 0b10, opc, asm, ZPR16>, 2804 SVEPseudo2Instr<Ps # _H, 1>; 2805 def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>, 2806 SVEPseudo2Instr<Ps # _S, 1>; 2807 def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>, 2808 SVEPseudo2Instr<Ps # _D, 1>; 2809 } 2810 2811 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 2812 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2813 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2814 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2815} 2816 2817// Special case for divides which are not defined for 8b/16b elements. 2818multiclass sve_int_bin_pred_arit_2_div<bits<3> opc, string asm, string Ps, 2819 SDPatternOperator op, 2820 DestructiveInstTypeEnum flags, 2821 string revname="", bit isReverseInstr=0> { 2822 let DestructiveInstType = flags in { 2823 def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>, 2824 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>; 2825 def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>, 2826 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>; 2827 } 2828 2829 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2830 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2831} 2832 2833//===----------------------------------------------------------------------===// 2834// SVE Integer Multiply-Add Group 2835//===----------------------------------------------------------------------===// 2836 2837class sve_int_mladdsub_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm, 2838 ZPRRegOp zprty> 2839: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za), 2840 asm, "\t$Zdn, $Pg/m, $Zm, $Za", 2841 "", 2842 []>, Sched<[]> { 2843 bits<3> Pg; 2844 bits<5> Zdn; 2845 bits<5> Za; 2846 bits<5> Zm; 2847 let Inst{31-24} = 0b00000100; 2848 let Inst{23-22} = sz8_64; 2849 let Inst{21} = 0b0; 2850 let Inst{20-16} = Zm; 2851 let Inst{15-14} = 0b11; 2852 let Inst{13} = opc; 2853 let Inst{12-10} = Pg; 2854 let Inst{9-5} = Za; 2855 let Inst{4-0} = Zdn; 2856 2857 let Constraints = "$Zdn = $_Zdn"; 2858 let DestructiveInstType = DestructiveOther; 2859 let ElementSize = zprty.ElementSize; 2860} 2861 2862multiclass sve_int_mladdsub_vvv_pred<bits<1> opc, string asm, SDPatternOperator op> { 2863 def _B : sve_int_mladdsub_vvv_pred<0b00, opc, asm, ZPR8>; 2864 def _H : sve_int_mladdsub_vvv_pred<0b01, opc, asm, ZPR16>; 2865 def _S : sve_int_mladdsub_vvv_pred<0b10, opc, asm, ZPR32>; 2866 def _D : sve_int_mladdsub_vvv_pred<0b11, opc, asm, ZPR64>; 2867 2868 def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 2869 def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2870 def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2871 def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2872} 2873 2874class sve_int_mlas_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm, 2875 ZPRRegOp zprty> 2876: I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm), 2877 asm, "\t$Zda, $Pg/m, $Zn, $Zm", 2878 "", 2879 []>, Sched<[]> { 2880 bits<3> Pg; 2881 bits<5> Zda; 2882 bits<5> Zm; 2883 bits<5> Zn; 2884 let Inst{31-24} = 0b00000100; 2885 let Inst{23-22} = sz8_64; 2886 let Inst{21} = 0b0; 2887 let Inst{20-16} = Zm; 2888 let Inst{15-14} = 0b01; 2889 let Inst{13} = opc; 2890 let Inst{12-10} = Pg; 2891 let Inst{9-5} = Zn; 2892 let Inst{4-0} = Zda; 2893 2894 let Constraints = "$Zda = $_Zda"; 2895 let DestructiveInstType = DestructiveOther; 2896 let ElementSize = zprty.ElementSize; 2897} 2898 2899multiclass sve_int_mlas_vvv_pred<bits<1> opc, string asm, SDPatternOperator op, 2900 SDPatternOperator outerop, SDPatternOperator mulop> { 2901 def _B : sve_int_mlas_vvv_pred<0b00, opc, asm, ZPR8>; 2902 def _H : sve_int_mlas_vvv_pred<0b01, opc, asm, ZPR16>; 2903 def _S : sve_int_mlas_vvv_pred<0b10, opc, asm, ZPR32>; 2904 def _D : sve_int_mlas_vvv_pred<0b11, opc, asm, ZPR64>; 2905 2906 def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 2907 def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2908 def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2909 def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2910 2911 def : Pat<(outerop nxv16i8:$Op1, (mulop nxv16i1:$pred, nxv16i8:$Op2, nxv16i8:$Op3)), 2912 (!cast<Instruction>(NAME # _B) $pred, $Op1, $Op2, $Op3)>; 2913 def : Pat<(outerop nxv8i16:$Op1, (mulop nxv8i1:$pred, nxv8i16:$Op2, nxv8i16:$Op3)), 2914 (!cast<Instruction>(NAME # _H) $pred, $Op1, $Op2, $Op3)>; 2915 def : Pat<(outerop nxv4i32:$Op1, (mulop nxv4i1:$pred, nxv4i32:$Op2, nxv4i32:$Op3)), 2916 (!cast<Instruction>(NAME # _S) $pred, $Op1, $Op2, $Op3)>; 2917 def : Pat<(outerop nxv2i64:$Op1, (mulop nxv2i1:$pred, nxv2i64:$Op2, nxv2i64:$Op3)), 2918 (!cast<Instruction>(NAME # _D) $pred, $Op1, $Op2, $Op3)>; 2919} 2920 2921//===----------------------------------------------------------------------===// 2922// SVE2 Integer Multiply-Add - Unpredicated Group 2923//===----------------------------------------------------------------------===// 2924 2925class sve2_int_mla<bits<2> sz, bits<5> opc, string asm, 2926 ZPRRegOp zprty1, ZPRRegOp zprty2> 2927: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), 2928 asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> { 2929 bits<5> Zda; 2930 bits<5> Zn; 2931 bits<5> Zm; 2932 let Inst{31-24} = 0b01000100; 2933 let Inst{23-22} = sz; 2934 let Inst{21} = 0b0; 2935 let Inst{20-16} = Zm; 2936 let Inst{15} = 0b0; 2937 let Inst{14-10} = opc; 2938 let Inst{9-5} = Zn; 2939 let Inst{4-0} = Zda; 2940 2941 let Constraints = "$Zda = $_Zda"; 2942 let DestructiveInstType = DestructiveOther; 2943 let ElementSize = ElementSizeNone; 2944} 2945 2946multiclass sve2_int_mla<bit S, string asm, SDPatternOperator op> { 2947 def _B : sve2_int_mla<0b00, { 0b1110, S }, asm, ZPR8, ZPR8>; 2948 def _H : sve2_int_mla<0b01, { 0b1110, S }, asm, ZPR16, ZPR16>; 2949 def _S : sve2_int_mla<0b10, { 0b1110, S }, asm, ZPR32, ZPR32>; 2950 def _D : sve2_int_mla<0b11, { 0b1110, S }, asm, ZPR64, ZPR64>; 2951 2952 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 2953 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 2954 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 2955 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 2956} 2957 2958multiclass sve2_int_mla_long<bits<5> opc, string asm, SDPatternOperator op> { 2959 def _H : sve2_int_mla<0b01, opc, asm, ZPR16, ZPR8>; 2960 def _S : sve2_int_mla<0b10, opc, asm, ZPR32, ZPR16>; 2961 def _D : sve2_int_mla<0b11, opc, asm, ZPR64, ZPR32>; 2962 2963 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>; 2964 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>; 2965 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>; 2966} 2967 2968//===----------------------------------------------------------------------===// 2969// SVE2 Integer Multiply-Add - Indexed Group 2970//===----------------------------------------------------------------------===// 2971 2972class sve2_int_mla_by_indexed_elem<bits<2> sz, bits<6> opc, string asm, 2973 ZPRRegOp zprty1, ZPRRegOp zprty2, 2974 ZPRRegOp zprty3, Operand itype> 2975: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop), 2976 asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> { 2977 bits<5> Zda; 2978 bits<5> Zn; 2979 let Inst{31-24} = 0b01000100; 2980 let Inst{23-22} = sz; 2981 let Inst{21} = 0b1; 2982 let Inst{15-10} = opc; 2983 let Inst{9-5} = Zn; 2984 let Inst{4-0} = Zda; 2985 2986 let Constraints = "$Zda = $_Zda"; 2987 let DestructiveInstType = DestructiveOther; 2988 let ElementSize = ElementSizeNone; 2989} 2990 2991multiclass sve2_int_mla_by_indexed_elem<bits<2> opc, bit S, string asm, 2992 SDPatternOperator op> { 2993 def _H : sve2_int_mla_by_indexed_elem<{0, ?}, { 0b000, opc, S }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH32b> { 2994 bits<3> Zm; 2995 bits<3> iop; 2996 let Inst{22} = iop{2}; 2997 let Inst{20-19} = iop{1-0}; 2998 let Inst{18-16} = Zm; 2999 } 3000 def _S : sve2_int_mla_by_indexed_elem<0b10, { 0b000, opc, S }, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS32b> { 3001 bits<3> Zm; 3002 bits<2> iop; 3003 let Inst{20-19} = iop; 3004 let Inst{18-16} = Zm; 3005 } 3006 def _D : sve2_int_mla_by_indexed_elem<0b11, { 0b000, opc, S }, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD32b> { 3007 bits<4> Zm; 3008 bit iop; 3009 let Inst{20} = iop; 3010 let Inst{19-16} = Zm; 3011 } 3012 3013 def : SVE_4_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>; 3014 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>; 3015 def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>; 3016} 3017 3018//===----------------------------------------------------------------------===// 3019// SVE2 Integer Multiply-Add Long - Indexed Group 3020//===----------------------------------------------------------------------===// 3021 3022multiclass sve2_int_mla_long_by_indexed_elem<bits<4> opc, string asm, 3023 SDPatternOperator op> { 3024 def _S : sve2_int_mla_by_indexed_elem<0b10, { opc{3}, 0b0, opc{2-1}, ?, opc{0} }, 3025 asm, ZPR32, ZPR16, ZPR3b16, VectorIndexH32b> { 3026 bits<3> Zm; 3027 bits<3> iop; 3028 let Inst{20-19} = iop{2-1}; 3029 let Inst{18-16} = Zm; 3030 let Inst{11} = iop{0}; 3031 } 3032 def _D : sve2_int_mla_by_indexed_elem<0b11, { opc{3}, 0b0, opc{2-1}, ?, opc{0} }, 3033 asm, ZPR64, ZPR32, ZPR4b32, VectorIndexS32b> { 3034 bits<4> Zm; 3035 bits<2> iop; 3036 let Inst{20} = iop{1}; 3037 let Inst{19-16} = Zm; 3038 let Inst{11} = iop{0}; 3039 } 3040 3041 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _S)>; 3042 def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>; 3043} 3044 3045//===----------------------------------------------------------------------===// 3046// SVE Integer Dot Product Group 3047//===----------------------------------------------------------------------===// 3048 3049class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1, 3050 ZPRRegOp zprty2> 3051: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), asm, 3052 "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> { 3053 bits<5> Zda; 3054 bits<5> Zn; 3055 bits<5> Zm; 3056 let Inst{31-23} = 0b010001001; 3057 let Inst{22} = sz; 3058 let Inst{21} = 0; 3059 let Inst{20-16} = Zm; 3060 let Inst{15-11} = 0; 3061 let Inst{10} = U; 3062 let Inst{9-5} = Zn; 3063 let Inst{4-0} = Zda; 3064 3065 let Constraints = "$Zda = $_Zda"; 3066 let DestructiveInstType = DestructiveOther; 3067} 3068 3069multiclass sve_intx_dot<bit opc, string asm, SDPatternOperator op> { 3070 def _S : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>; 3071 def _D : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>; 3072 3073 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _S)>; 3074 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _D)>; 3075} 3076 3077//===----------------------------------------------------------------------===// 3078// SVE Integer Dot Product Group - Indexed Group 3079//===----------------------------------------------------------------------===// 3080 3081class sve_intx_dot_by_indexed_elem<bit sz, bit U, string asm, 3082 ZPRRegOp zprty1, ZPRRegOp zprty2, 3083 ZPRRegOp zprty3, Operand itype> 3084: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop), 3085 asm, "\t$Zda, $Zn, $Zm$iop", 3086 "", []>, Sched<[]> { 3087 bits<5> Zda; 3088 bits<5> Zn; 3089 let Inst{31-23} = 0b010001001; 3090 let Inst{22} = sz; 3091 let Inst{21} = 0b1; 3092 let Inst{15-11} = 0; 3093 let Inst{10} = U; 3094 let Inst{9-5} = Zn; 3095 let Inst{4-0} = Zda; 3096 3097 let Constraints = "$Zda = $_Zda"; 3098 let DestructiveInstType = DestructiveOther; 3099} 3100 3101multiclass sve_intx_dot_by_indexed_elem<bit opc, string asm, 3102 SDPatternOperator op> { 3103 def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b_timm> { 3104 bits<2> iop; 3105 bits<3> Zm; 3106 let Inst{20-19} = iop; 3107 let Inst{18-16} = Zm; 3108 } 3109 def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b_timm> { 3110 bits<1> iop; 3111 bits<4> Zm; 3112 let Inst{20} = iop; 3113 let Inst{19-16} = Zm; 3114 } 3115 3116 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>; 3117 def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>; 3118} 3119 3120//===----------------------------------------------------------------------===// 3121// SVE2 Complex Integer Dot Product Group 3122//===----------------------------------------------------------------------===// 3123 3124class sve2_complex_int_arith<bits<2> sz, bits<4> opc, string asm, 3125 ZPRRegOp zprty1, ZPRRegOp zprty2> 3126: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm, 3127 complexrotateop:$rot), 3128 asm, "\t$Zda, $Zn, $Zm, $rot", "", []>, Sched<[]> { 3129 bits<5> Zda; 3130 bits<5> Zn; 3131 bits<5> Zm; 3132 bits<2> rot; 3133 let Inst{31-24} = 0b01000100; 3134 let Inst{23-22} = sz; 3135 let Inst{21} = 0b0; 3136 let Inst{20-16} = Zm; 3137 let Inst{15-12} = opc; 3138 let Inst{11-10} = rot; 3139 let Inst{9-5} = Zn; 3140 let Inst{4-0} = Zda; 3141 3142 let Constraints = "$Zda = $_Zda"; 3143 let DestructiveInstType = DestructiveOther; 3144 let ElementSize = ElementSizeNone; 3145} 3146 3147multiclass sve2_cintx_dot<string asm, SDPatternOperator op> { 3148 def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>; 3149 def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>; 3150 3151 def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3), 3152 (i32 complexrotateop:$imm))), 3153 (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, complexrotateop:$imm)>; 3154 def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3), 3155 (i32 complexrotateop:$imm))), 3156 (!cast<Instruction>(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, complexrotateop:$imm)>; 3157} 3158 3159//===----------------------------------------------------------------------===// 3160// SVE2 Complex Multiply-Add Group 3161//===----------------------------------------------------------------------===// 3162 3163multiclass sve2_int_cmla<bit opc, string asm, SDPatternOperator op> { 3164 def _B : sve2_complex_int_arith<0b00, { 0b001, opc }, asm, ZPR8, ZPR8>; 3165 def _H : sve2_complex_int_arith<0b01, { 0b001, opc }, asm, ZPR16, ZPR16>; 3166 def _S : sve2_complex_int_arith<0b10, { 0b001, opc }, asm, ZPR32, ZPR32>; 3167 def _D : sve2_complex_int_arith<0b11, { 0b001, opc }, asm, ZPR64, ZPR64>; 3168 3169 def : SVE_4_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, i32, complexrotateop, !cast<Instruction>(NAME # _B)>; 3170 def : SVE_4_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, i32, complexrotateop, !cast<Instruction>(NAME # _H)>; 3171 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, i32, complexrotateop, !cast<Instruction>(NAME # _S)>; 3172 def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, i32, complexrotateop, !cast<Instruction>(NAME # _D)>; 3173} 3174 3175//===----------------------------------------------------------------------===// 3176// SVE2 Complex Integer Dot Product - Indexed Group 3177//===----------------------------------------------------------------------===// 3178 3179class sve2_complex_int_arith_indexed<bits<2> sz, bits<4> opc, string asm, 3180 ZPRRegOp zprty1, ZPRRegOp zprty2, 3181 ZPRRegOp zprty3, Operand itype> 3182: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop, 3183 complexrotateop:$rot), 3184 asm, "\t$Zda, $Zn, $Zm$iop, $rot", "", []>, Sched<[]> { 3185 bits<5> Zda; 3186 bits<5> Zn; 3187 bits<2> rot; 3188 let Inst{31-24} = 0b01000100; 3189 let Inst{23-22} = sz; 3190 let Inst{21} = 0b1; 3191 let Inst{15-12} = opc; 3192 let Inst{11-10} = rot; 3193 let Inst{9-5} = Zn; 3194 let Inst{4-0} = Zda; 3195 3196 let Constraints = "$Zda = $_Zda"; 3197 let DestructiveInstType = DestructiveOther; 3198 let ElementSize = ElementSizeNone; 3199} 3200 3201multiclass sve2_cintx_dot_by_indexed_elem<string asm, SDPatternOperator op> { 3202 def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> { 3203 bits<2> iop; 3204 bits<3> Zm; 3205 let Inst{20-19} = iop; 3206 let Inst{18-16} = Zm; 3207 } 3208 def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> { 3209 bit iop; 3210 bits<4> Zm; 3211 let Inst{20} = iop; 3212 let Inst{19-16} = Zm; 3213 } 3214 3215 def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3), 3216 (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))), 3217 (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>; 3218 def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3), 3219 (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))), 3220 (!cast<Instruction>(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>; 3221} 3222 3223//===----------------------------------------------------------------------===// 3224// SVE2 Complex Multiply-Add - Indexed Group 3225//===----------------------------------------------------------------------===// 3226 3227multiclass sve2_cmla_by_indexed_elem<bit opc, string asm, 3228 SDPatternOperator op> { 3229 def _H : sve2_complex_int_arith_indexed<0b10, { 0b011, opc }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexS32b> { 3230 bits<2> iop; 3231 bits<3> Zm; 3232 let Inst{20-19} = iop; 3233 let Inst{18-16} = Zm; 3234 } 3235 def _S : sve2_complex_int_arith_indexed<0b11, { 0b011, opc }, asm, ZPR32, ZPR32, ZPR4b32, VectorIndexD32b> { 3236 bit iop; 3237 bits<4> Zm; 3238 let Inst{20} = iop; 3239 let Inst{19-16} = Zm; 3240 } 3241 3242 def : Pat<(nxv8i16 (op (nxv8i16 ZPR16:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3), 3243 (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))), 3244 (!cast<Instruction>(NAME # "_H") ZPR16:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>; 3245 3246 def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv4i32 ZPR32:$Op2), (nxv4i32 ZPR32:$Op3), 3247 (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))), 3248 (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR32:$Op2, ZPR32:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>; 3249} 3250 3251//===----------------------------------------------------------------------===// 3252// SVE2 Integer Multiply - Unpredicated Group 3253//===----------------------------------------------------------------------===// 3254 3255class sve2_int_mul<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty> 3256: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm), 3257 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> { 3258 bits<5> Zd; 3259 bits<5> Zm; 3260 bits<5> Zn; 3261 let Inst{31-24} = 0b00000100; 3262 let Inst{23-22} = sz; 3263 let Inst{21} = 0b1; 3264 let Inst{20-16} = Zm; 3265 let Inst{15-13} = 0b011; 3266 let Inst{12-10} = opc; 3267 let Inst{9-5} = Zn; 3268 let Inst{4-0} = Zd; 3269} 3270 3271multiclass sve2_int_mul<bits<3> opc, string asm, SDPatternOperator op, 3272 SDPatternOperator op_pred = null_frag> { 3273 def _B : sve2_int_mul<0b00, opc, asm, ZPR8>; 3274 def _H : sve2_int_mul<0b01, opc, asm, ZPR16>; 3275 def _S : sve2_int_mul<0b10, opc, asm, ZPR32>; 3276 def _D : sve2_int_mul<0b11, opc, asm, ZPR64>; 3277 3278 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 3279 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 3280 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 3281 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 3282 3283 def : SVE_2_Op_Pred_All_Active<nxv16i8, op_pred, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 3284 def : SVE_2_Op_Pred_All_Active<nxv8i16, op_pred, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 3285 def : SVE_2_Op_Pred_All_Active<nxv4i32, op_pred, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 3286 def : SVE_2_Op_Pred_All_Active<nxv2i64, op_pred, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 3287} 3288 3289multiclass sve2_int_mul_single<bits<3> opc, string asm, SDPatternOperator op> { 3290 def _B : sve2_int_mul<0b00, opc, asm, ZPR8>; 3291 3292 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 3293} 3294 3295//===----------------------------------------------------------------------===// 3296// SVE2 Integer Multiply - Indexed Group 3297//===----------------------------------------------------------------------===// 3298 3299class sve2_int_mul_by_indexed_elem<bits<2> sz, bits<4> opc, string asm, 3300 ZPRRegOp zprty1, ZPRRegOp zprty2, 3301 ZPRRegOp zprty3, Operand itype> 3302: I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm, itype:$iop), 3303 asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> { 3304 bits<5> Zd; 3305 bits<5> Zn; 3306 let Inst{31-24} = 0b01000100; 3307 let Inst{23-22} = sz; 3308 let Inst{21} = 0b1; 3309 let Inst{15-14} = 0b11; 3310 let Inst{13-10} = opc; 3311 let Inst{9-5} = Zn; 3312 let Inst{4-0} = Zd; 3313} 3314 3315multiclass sve2_int_mul_by_indexed_elem<bits<4> opc, string asm, 3316 SDPatternOperator op> { 3317 def _H : sve2_int_mul_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH32b> { 3318 bits<3> Zm; 3319 bits<3> iop; 3320 let Inst{22} = iop{2}; 3321 let Inst{20-19} = iop{1-0}; 3322 let Inst{18-16} = Zm; 3323 } 3324 def _S : sve2_int_mul_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS32b> { 3325 bits<3> Zm; 3326 bits<2> iop; 3327 let Inst{20-19} = iop; 3328 let Inst{18-16} = Zm; 3329 } 3330 def _D : sve2_int_mul_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD32b> { 3331 bits<4> Zm; 3332 bit iop; 3333 let Inst{20} = iop; 3334 let Inst{19-16} = Zm; 3335 } 3336 3337 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>; 3338 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>; 3339 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>; 3340} 3341 3342multiclass sve2_int_mul_long_by_indexed_elem<bits<3> opc, string asm, 3343 SDPatternOperator op> { 3344 def _S : sve2_int_mul_by_indexed_elem<0b10, { opc{2-1}, ?, opc{0} }, asm, 3345 ZPR32, ZPR16, ZPR3b16, VectorIndexH32b> { 3346 bits<3> Zm; 3347 bits<3> iop; 3348 let Inst{20-19} = iop{2-1}; 3349 let Inst{18-16} = Zm; 3350 let Inst{11} = iop{0}; 3351 } 3352 def _D : sve2_int_mul_by_indexed_elem<0b11, { opc{2-1}, ?, opc{0} }, asm, 3353 ZPR64, ZPR32, ZPR4b32, VectorIndexS32b> { 3354 bits<4> Zm; 3355 bits<2> iop; 3356 let Inst{20} = iop{1}; 3357 let Inst{19-16} = Zm; 3358 let Inst{11} = iop{0}; 3359 } 3360 3361 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _S)>; 3362 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>; 3363} 3364 3365//===----------------------------------------------------------------------===// 3366// SVE2 Integer - Predicated Group 3367//===----------------------------------------------------------------------===// 3368 3369class sve2_int_arith_pred<bits<2> sz, bits<6> opc, string asm, 3370 ZPRRegOp zprty> 3371: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm), 3372 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> { 3373 bits<3> Pg; 3374 bits<5> Zm; 3375 bits<5> Zdn; 3376 let Inst{31-24} = 0b01000100; 3377 let Inst{23-22} = sz; 3378 let Inst{21-20} = 0b01; 3379 let Inst{20-16} = opc{5-1}; 3380 let Inst{15-14} = 0b10; 3381 let Inst{13} = opc{0}; 3382 let Inst{12-10} = Pg; 3383 let Inst{9-5} = Zm; 3384 let Inst{4-0} = Zdn; 3385 3386 let Constraints = "$Zdn = $_Zdn"; 3387 let DestructiveInstType = DestructiveOther; 3388 let ElementSize = zprty.ElementSize; 3389} 3390 3391multiclass sve2_int_arith_pred<bits<6> opc, string asm, SDPatternOperator op, 3392 string Ps = "", 3393 DestructiveInstTypeEnum flags=DestructiveOther, 3394 string revname="", bit isReverseInstr=0> { 3395 let DestructiveInstType = flags in { 3396 def _B : sve2_int_arith_pred<0b00, opc, asm, ZPR8>, 3397 SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>; 3398 def _H : sve2_int_arith_pred<0b01, opc, asm, ZPR16>, 3399 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>; 3400 def _S : sve2_int_arith_pred<0b10, opc, asm, ZPR32>, 3401 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>; 3402 def _D : sve2_int_arith_pred<0b11, opc, asm, ZPR64>, 3403 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>; 3404 } 3405 3406 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 3407 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 3408 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 3409 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 3410} 3411 3412class sve2_int_sadd_long_accum_pairwise<bits<2> sz, bit U, string asm, 3413 ZPRRegOp zprty1, ZPRRegOp zprty2> 3414: I<(outs zprty1:$Zda), (ins PPR3bAny:$Pg, zprty1:$_Zda, zprty2:$Zn), 3415 asm, "\t$Zda, $Pg/m, $Zn", "", []>, Sched<[]> { 3416 bits<3> Pg; 3417 bits<5> Zn; 3418 bits<5> Zda; 3419 let Inst{31-24} = 0b01000100; 3420 let Inst{23-22} = sz; 3421 let Inst{21-17} = 0b00010; 3422 let Inst{16} = U; 3423 let Inst{15-13} = 0b101; 3424 let Inst{12-10} = Pg; 3425 let Inst{9-5} = Zn; 3426 let Inst{4-0} = Zda; 3427 3428 let Constraints = "$Zda = $_Zda"; 3429 let DestructiveInstType = DestructiveOther; 3430 let ElementSize = zprty1.ElementSize; 3431} 3432 3433multiclass sve2_int_sadd_long_accum_pairwise<bit U, string asm, SDPatternOperator op> { 3434 def _H : sve2_int_sadd_long_accum_pairwise<0b01, U, asm, ZPR16, ZPR8>; 3435 def _S : sve2_int_sadd_long_accum_pairwise<0b10, U, asm, ZPR32, ZPR16>; 3436 def _D : sve2_int_sadd_long_accum_pairwise<0b11, U, asm, ZPR64, ZPR32>; 3437 3438 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv16i8, !cast<Instruction>(NAME # _H)>; 3439 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv8i16, !cast<Instruction>(NAME # _S)>; 3440 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv4i32, !cast<Instruction>(NAME # _D)>; 3441} 3442 3443class sve2_int_un_pred_arit<bits<2> sz, bit Q, bits<2> opc, 3444 string asm, ZPRRegOp zprty> 3445: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn), 3446 asm, "\t$Zd, $Pg/m, $Zn", 3447 "", 3448 []>, Sched<[]> { 3449 bits<3> Pg; 3450 bits<5> Zd; 3451 bits<5> Zn; 3452 let Inst{31-24} = 0b01000100; 3453 let Inst{23-22} = sz; 3454 let Inst{21-20} = 0b00; 3455 let Inst{19} = Q; 3456 let Inst{18} = 0b0; 3457 let Inst{17-16} = opc; 3458 let Inst{15-13} = 0b101; 3459 let Inst{12-10} = Pg; 3460 let Inst{9-5} = Zn; 3461 let Inst{4-0} = Zd; 3462 3463 let Constraints = "$Zd = $_Zd"; 3464 let DestructiveInstType = DestructiveUnaryPassthru; 3465 let ElementSize = zprty.ElementSize; 3466} 3467 3468multiclass sve2_int_un_pred_arit_s<bits<3> opc, string asm, 3469 SDPatternOperator op> { 3470 def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>, 3471 SVEPseudo2Instr<NAME # _S, 1>; 3472 3473 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 3474 3475 def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>; 3476 3477 defm : SVE_3_Op_Undef_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>; 3478} 3479 3480multiclass sve2_int_un_pred_arit<bits<3> opc, string asm, SDPatternOperator op> { 3481 def _B : sve2_int_un_pred_arit<0b00, opc{2}, opc{1-0}, asm, ZPR8>, 3482 SVEPseudo2Instr<NAME # _B, 1>; 3483 def _H : sve2_int_un_pred_arit<0b01, opc{2}, opc{1-0}, asm, ZPR16>, 3484 SVEPseudo2Instr<NAME # _H, 1>; 3485 def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>, 3486 SVEPseudo2Instr<NAME # _S, 1>; 3487 def _D : sve2_int_un_pred_arit<0b11, opc{2}, opc{1-0}, asm, ZPR64>, 3488 SVEPseudo2Instr<NAME # _D, 1>; 3489 3490 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 3491 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 3492 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 3493 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 3494 3495 def _UNDEF_B : PredOneOpPassthruPseudo<NAME # _B, ZPR8>; 3496 def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>; 3497 def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>; 3498 def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>; 3499 3500 defm : SVE_3_Op_Undef_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>; 3501 defm : SVE_3_Op_Undef_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>; 3502 defm : SVE_3_Op_Undef_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>; 3503 defm : SVE_3_Op_Undef_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>; 3504} 3505 3506//===----------------------------------------------------------------------===// 3507// SVE2 Widening Integer Arithmetic Group 3508//===----------------------------------------------------------------------===// 3509 3510class sve2_wide_int_arith<bits<2> sz, bits<5> opc, string asm, 3511 ZPRRegOp zprty1, ZPRRegOp zprty2, ZPRRegOp zprty3> 3512: I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm), 3513 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> { 3514 bits<5> Zd; 3515 bits<5> Zn; 3516 bits<5> Zm; 3517 let Inst{31-24} = 0b01000101; 3518 let Inst{23-22} = sz; 3519 let Inst{21} = 0b0; 3520 let Inst{20-16} = Zm; 3521 let Inst{15} = 0b0; 3522 let Inst{14-10} = opc; 3523 let Inst{9-5} = Zn; 3524 let Inst{4-0} = Zd; 3525} 3526 3527multiclass sve2_wide_int_arith_long<bits<5> opc, string asm, 3528 SDPatternOperator op> { 3529 def _H : sve2_wide_int_arith<0b01, opc, asm, ZPR16, ZPR8, ZPR8>; 3530 def _S : sve2_wide_int_arith<0b10, opc, asm, ZPR32, ZPR16, ZPR16>; 3531 def _D : sve2_wide_int_arith<0b11, opc, asm, ZPR64, ZPR32, ZPR32>; 3532 3533 def : SVE_2_Op_Pat<nxv8i16, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>; 3534 def : SVE_2_Op_Pat<nxv4i32, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>; 3535 def : SVE_2_Op_Pat<nxv2i64, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>; 3536} 3537 3538multiclass sve2_wide_int_arith_wide<bits<3> opc, string asm, 3539 SDPatternOperator op> { 3540 def _H : sve2_wide_int_arith<0b01, { 0b10, opc }, asm, ZPR16, ZPR16, ZPR8>; 3541 def _S : sve2_wide_int_arith<0b10, { 0b10, opc }, asm, ZPR32, ZPR32, ZPR16>; 3542 def _D : sve2_wide_int_arith<0b11, { 0b10, opc }, asm, ZPR64, ZPR64, ZPR32>; 3543 3544 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, !cast<Instruction>(NAME # _H)>; 3545 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, !cast<Instruction>(NAME # _S)>; 3546 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, !cast<Instruction>(NAME # _D)>; 3547} 3548 3549multiclass sve2_wide_int_arith_pmul<bits<2> sz, bits<5> opc, string asm, 3550 SDPatternOperator op> { 3551 def NAME : sve2_wide_int_arith<sz, opc, asm, ZPR128, ZPR64, ZPR64>; 3552 3553 // To avoid using 128 bit elements in the IR, the pattern below works with 3554 // llvm intrinsics with the _pair suffix, to reflect that 3555 // _Q is implemented as a pair of _D. 3556 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>; 3557} 3558 3559multiclass sve2_pmul_long<bits<1> opc, string asm, SDPatternOperator op> { 3560 def _H : sve2_wide_int_arith<0b01, {0b1101, opc}, asm, ZPR16, ZPR8, ZPR8>; 3561 def _D : sve2_wide_int_arith<0b11, {0b1101, opc}, asm, ZPR64, ZPR32, ZPR32>; 3562 3563 // To avoid using 128 bit elements in the IR, the patterns below work with 3564 // llvm intrinsics with the _pair suffix, to reflect that 3565 // _H is implemented as a pair of _B and _D is implemented as a pair of _S. 3566 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>; 3567 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>; 3568} 3569 3570//===----------------------------------------------------------------------===// 3571// SVE2 Misc Group 3572//===----------------------------------------------------------------------===// 3573 3574class sve2_misc<bits<2> sz, bits<4> opc, string asm, 3575 ZPRRegOp zprty1, ZPRRegOp zprty2> 3576: I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm), 3577 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> { 3578 bits<5> Zd; 3579 bits<5> Zn; 3580 bits<5> Zm; 3581 let Inst{31-24} = 0b01000101; 3582 let Inst{23-22} = sz; 3583 let Inst{21} = 0b0; 3584 let Inst{20-16} = Zm; 3585 let Inst{15-14} = 0b10; 3586 let Inst{13-10} = opc; 3587 let Inst{9-5} = Zn; 3588 let Inst{4-0} = Zd; 3589} 3590 3591multiclass sve2_misc_bitwise<bits<4> opc, string asm, SDPatternOperator op> { 3592 def _B : sve2_misc<0b00, opc, asm, ZPR8, ZPR8>; 3593 def _H : sve2_misc<0b01, opc, asm, ZPR16, ZPR16>; 3594 def _S : sve2_misc<0b10, opc, asm, ZPR32, ZPR32>; 3595 def _D : sve2_misc<0b11, opc, asm, ZPR64, ZPR64>; 3596 3597 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 3598 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 3599 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 3600 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 3601} 3602 3603multiclass sve2_misc_int_addsub_long_interleaved<bits<2> opc, string asm, 3604 SDPatternOperator op> { 3605 def _H : sve2_misc<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>; 3606 def _S : sve2_misc<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>; 3607 def _D : sve2_misc<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>; 3608 3609 def : SVE_2_Op_Pat<nxv8i16, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>; 3610 def : SVE_2_Op_Pat<nxv4i32, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>; 3611 def : SVE_2_Op_Pat<nxv2i64, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>; 3612} 3613 3614class sve2_bitwise_xor_interleaved<bits<2> sz, bits<1> opc, string asm, 3615 ZPRRegOp zprty1, ZPRRegOp zprty2> 3616: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm), 3617 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> { 3618 bits<5> Zd; 3619 bits<5> Zn; 3620 bits<5> Zm; 3621 let Inst{31-24} = 0b01000101; 3622 let Inst{23-22} = sz; 3623 let Inst{21} = 0b0; 3624 let Inst{20-16} = Zm; 3625 let Inst{15-11} = 0b10010; 3626 let Inst{10} = opc; 3627 let Inst{9-5} = Zn; 3628 let Inst{4-0} = Zd; 3629 3630 let Constraints = "$Zd = $_Zd"; 3631 let DestructiveInstType = DestructiveOther; 3632 let ElementSize = ElementSizeNone; 3633} 3634 3635multiclass sve2_bitwise_xor_interleaved<bit opc, string asm, 3636 SDPatternOperator op> { 3637 def _B : sve2_bitwise_xor_interleaved<0b00, opc, asm, ZPR8, ZPR8>; 3638 def _H : sve2_bitwise_xor_interleaved<0b01, opc, asm, ZPR16, ZPR16>; 3639 def _S : sve2_bitwise_xor_interleaved<0b10, opc, asm, ZPR32, ZPR32>; 3640 def _D : sve2_bitwise_xor_interleaved<0b11, opc, asm, ZPR64, ZPR64>; 3641 3642 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 3643 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 3644 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 3645 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 3646} 3647 3648class sve2_bitwise_shift_left_long<bits<3> tsz8_64, bits<2> opc, string asm, 3649 ZPRRegOp zprty1, ZPRRegOp zprty2, 3650 Operand immtype> 3651: I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm), 3652 asm, "\t$Zd, $Zn, $imm", 3653 "", []>, Sched<[]> { 3654 bits<5> Zd; 3655 bits<5> Zn; 3656 bits<5> imm; 3657 let Inst{31-23} = 0b010001010; 3658 let Inst{22} = tsz8_64{2}; 3659 let Inst{21} = 0b0; 3660 let Inst{20-19} = tsz8_64{1-0}; 3661 let Inst{18-16} = imm{2-0}; // imm3 3662 let Inst{15-12} = 0b1010; 3663 let Inst{11-10} = opc; 3664 let Inst{9-5} = Zn; 3665 let Inst{4-0} = Zd; 3666} 3667 3668multiclass sve2_bitwise_shift_left_long<bits<2> opc, string asm, 3669 SDPatternOperator op> { 3670 def _H : sve2_bitwise_shift_left_long<{0,0,1}, opc, asm, 3671 ZPR16, ZPR8, vecshiftL8>; 3672 def _S : sve2_bitwise_shift_left_long<{0,1,?}, opc, asm, 3673 ZPR32, ZPR16, vecshiftL16> { 3674 let Inst{19} = imm{3}; 3675 } 3676 def _D : sve2_bitwise_shift_left_long<{1,?,?}, opc, asm, 3677 ZPR64, ZPR32, vecshiftL32> { 3678 let Inst{20-19} = imm{4-3}; 3679 } 3680 def : SVE_2_Op_Imm_Pat<nxv8i16, op, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _H)>; 3681 def : SVE_2_Op_Imm_Pat<nxv4i32, op, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _S)>; 3682 def : SVE_2_Op_Imm_Pat<nxv2i64, op, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _D)>; 3683} 3684 3685//===----------------------------------------------------------------------===// 3686// SVE2 Accumulate Group 3687//===----------------------------------------------------------------------===// 3688 3689class sve2_int_bin_shift_imm<bits<4> tsz8_64, bit opc, string asm, 3690 ZPRRegOp zprty, Operand immtype> 3691: I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, immtype:$imm), 3692 asm, "\t$Zd, $Zn, $imm", 3693 "", []>, Sched<[]> { 3694 bits<5> Zd; 3695 bits<5> Zn; 3696 bits<6> imm; 3697 let Inst{31-24} = 0b01000101; 3698 let Inst{23-22} = tsz8_64{3-2}; 3699 let Inst{21} = 0b0; 3700 let Inst{20-19} = tsz8_64{1-0}; 3701 let Inst{18-16} = imm{2-0}; // imm3 3702 let Inst{15-11} = 0b11110; 3703 let Inst{10} = opc; 3704 let Inst{9-5} = Zn; 3705 let Inst{4-0} = Zd; 3706 3707 let Constraints = "$Zd = $_Zd"; 3708} 3709 3710multiclass sve2_int_bin_shift_imm_left<bit opc, string asm, 3711 SDPatternOperator op> { 3712 def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>; 3713 def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> { 3714 let Inst{19} = imm{3}; 3715 } 3716 def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> { 3717 let Inst{20-19} = imm{4-3}; 3718 } 3719 def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> { 3720 let Inst{22} = imm{5}; 3721 let Inst{20-19} = imm{4-3}; 3722 } 3723 3724 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _B)>; 3725 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _H)>; 3726 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _S)>; 3727 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftL64, !cast<Instruction>(NAME # _D)>; 3728} 3729 3730multiclass sve2_int_bin_shift_imm_right<bit opc, string asm, 3731 SDPatternOperator op> { 3732 def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>; 3733 def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> { 3734 let Inst{19} = imm{3}; 3735 } 3736 def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> { 3737 let Inst{20-19} = imm{4-3}; 3738 } 3739 def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> { 3740 let Inst{22} = imm{5}; 3741 let Inst{20-19} = imm{4-3}; 3742 } 3743 3744 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>; 3745 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>; 3746 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>; 3747 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>; 3748} 3749 3750class sve2_int_bin_accum_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm, 3751 ZPRRegOp zprty, Operand immtype> 3752: I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, immtype:$imm), 3753 asm, "\t$Zda, $Zn, $imm", 3754 "", []>, Sched<[]> { 3755 bits<5> Zda; 3756 bits<5> Zn; 3757 bits<6> imm; 3758 let Inst{31-24} = 0b01000101; 3759 let Inst{23-22} = tsz8_64{3-2}; 3760 let Inst{21} = 0b0; 3761 let Inst{20-19} = tsz8_64{1-0}; 3762 let Inst{18-16} = imm{2-0}; // imm3 3763 let Inst{15-12} = 0b1110; 3764 let Inst{11-10} = opc; 3765 let Inst{9-5} = Zn; 3766 let Inst{4-0} = Zda; 3767 3768 let Constraints = "$Zda = $_Zda"; 3769 let DestructiveInstType = DestructiveOther; 3770 let ElementSize = ElementSizeNone; 3771} 3772 3773multiclass sve2_int_bin_accum_shift_imm_right<bits<2> opc, string asm, 3774 SDPatternOperator op> { 3775 def _B : sve2_int_bin_accum_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>; 3776 def _H : sve2_int_bin_accum_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> { 3777 let Inst{19} = imm{3}; 3778 } 3779 def _S : sve2_int_bin_accum_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> { 3780 let Inst{20-19} = imm{4-3}; 3781 } 3782 def _D : sve2_int_bin_accum_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> { 3783 let Inst{22} = imm{5}; 3784 let Inst{20-19} = imm{4-3}; 3785 } 3786 3787 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>; 3788 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>; 3789 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>; 3790 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>; 3791} 3792 3793class sve2_int_cadd<bits<2> sz, bit opc, string asm, ZPRRegOp zprty> 3794: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, complexrotateopodd:$rot), 3795 asm, "\t$Zdn, $_Zdn, $Zm, $rot", "", []>, Sched<[]> { 3796 bits<5> Zdn; 3797 bits<5> Zm; 3798 bit rot; 3799 let Inst{31-24} = 0b01000101; 3800 let Inst{23-22} = sz; 3801 let Inst{21-17} = 0b00000; 3802 let Inst{16} = opc; 3803 let Inst{15-11} = 0b11011; 3804 let Inst{10} = rot; 3805 let Inst{9-5} = Zm; 3806 let Inst{4-0} = Zdn; 3807 3808 let Constraints = "$Zdn = $_Zdn"; 3809 let DestructiveInstType = DestructiveOther; 3810 let ElementSize = ElementSizeNone; 3811} 3812 3813multiclass sve2_int_cadd<bit opc, string asm, SDPatternOperator op> { 3814 def _B : sve2_int_cadd<0b00, opc, asm, ZPR8>; 3815 def _H : sve2_int_cadd<0b01, opc, asm, ZPR16>; 3816 def _S : sve2_int_cadd<0b10, opc, asm, ZPR32>; 3817 def _D : sve2_int_cadd<0b11, opc, asm, ZPR64>; 3818 3819 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, complexrotateopodd, !cast<Instruction>(NAME # _B)>; 3820 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, complexrotateopodd, !cast<Instruction>(NAME # _H)>; 3821 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, complexrotateopodd, !cast<Instruction>(NAME # _S)>; 3822 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, complexrotateopodd, !cast<Instruction>(NAME # _D)>; 3823} 3824 3825class sve2_int_absdiff_accum<bits<2> sz, bits<4> opc, string asm, 3826 ZPRRegOp zprty1, ZPRRegOp zprty2> 3827: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), 3828 asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> { 3829 bits<5> Zda; 3830 bits<5> Zn; 3831 bits<5> Zm; 3832 let Inst{31-24} = 0b01000101; 3833 let Inst{23-22} = sz; 3834 let Inst{21} = 0b0; 3835 let Inst{20-16} = Zm; 3836 let Inst{15-14} = 0b11; 3837 let Inst{13-10} = opc; 3838 let Inst{9-5} = Zn; 3839 let Inst{4-0} = Zda; 3840 3841 let Constraints = "$Zda = $_Zda"; 3842 let DestructiveInstType = DestructiveOther; 3843 let ElementSize = ElementSizeNone; 3844} 3845 3846multiclass sve2_int_absdiff_accum<bit opc, string asm, SDPatternOperator op> { 3847 def _B : sve2_int_absdiff_accum<0b00, { 0b111, opc }, asm, ZPR8, ZPR8>; 3848 def _H : sve2_int_absdiff_accum<0b01, { 0b111, opc }, asm, ZPR16, ZPR16>; 3849 def _S : sve2_int_absdiff_accum<0b10, { 0b111, opc }, asm, ZPR32, ZPR32>; 3850 def _D : sve2_int_absdiff_accum<0b11, { 0b111, opc }, asm, ZPR64, ZPR64>; 3851 3852 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 3853 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 3854 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 3855 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 3856} 3857 3858multiclass sve2_int_absdiff_accum_long<bits<2> opc, string asm, 3859 SDPatternOperator op> { 3860 def _H : sve2_int_absdiff_accum<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>; 3861 def _S : sve2_int_absdiff_accum<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>; 3862 def _D : sve2_int_absdiff_accum<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>; 3863 3864 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>; 3865 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>; 3866 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>; 3867} 3868 3869multiclass sve2_int_addsub_long_carry<bits<2> opc, string asm, 3870 SDPatternOperator op> { 3871 def _S : sve2_int_absdiff_accum<{ opc{1}, 0b0 }, { 0b010, opc{0} }, asm, 3872 ZPR32, ZPR32>; 3873 def _D : sve2_int_absdiff_accum<{ opc{1}, 0b1 }, { 0b010, opc{0} }, asm, 3874 ZPR64, ZPR64>; 3875 3876 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 3877 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 3878} 3879 3880//===----------------------------------------------------------------------===// 3881// SVE2 Narrowing Group 3882//===----------------------------------------------------------------------===// 3883 3884class sve2_int_bin_shift_imm_narrow_bottom<bits<3> tsz8_64, bits<3> opc, 3885 string asm, ZPRRegOp zprty1, 3886 ZPRRegOp zprty2, Operand immtype> 3887: I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm), 3888 asm, "\t$Zd, $Zn, $imm", 3889 "", []>, Sched<[]> { 3890 bits<5> Zd; 3891 bits<5> Zn; 3892 bits<5> imm; 3893 let Inst{31-23} = 0b010001010; 3894 let Inst{22} = tsz8_64{2}; 3895 let Inst{21} = 0b1; 3896 let Inst{20-19} = tsz8_64{1-0}; 3897 let Inst{18-16} = imm{2-0}; // imm3 3898 let Inst{15-14} = 0b00; 3899 let Inst{13-11} = opc; 3900 let Inst{10} = 0b0; 3901 let Inst{9-5} = Zn; 3902 let Inst{4-0} = Zd; 3903} 3904 3905multiclass sve2_int_bin_shift_imm_right_narrow_bottom<bits<3> opc, string asm, 3906 SDPatternOperator op> { 3907 def _B : sve2_int_bin_shift_imm_narrow_bottom<{0,0,1}, opc, asm, ZPR8, ZPR16, 3908 tvecshiftR8>; 3909 def _H : sve2_int_bin_shift_imm_narrow_bottom<{0,1,?}, opc, asm, ZPR16, ZPR32, 3910 tvecshiftR16> { 3911 let Inst{19} = imm{3}; 3912 } 3913 def _S : sve2_int_bin_shift_imm_narrow_bottom<{1,?,?}, opc, asm, ZPR32, ZPR64, 3914 tvecshiftR32> { 3915 let Inst{20-19} = imm{4-3}; 3916 } 3917 def : SVE_2_Op_Imm_Pat<nxv16i8, op, nxv8i16, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>; 3918 def : SVE_2_Op_Imm_Pat<nxv8i16, op, nxv4i32, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>; 3919 def : SVE_2_Op_Imm_Pat<nxv4i32, op, nxv2i64, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>; 3920} 3921 3922class sve2_int_bin_shift_imm_narrow_top<bits<3> tsz8_64, bits<3> opc, 3923 string asm, ZPRRegOp zprty1, 3924 ZPRRegOp zprty2, Operand immtype> 3925: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, immtype:$imm), 3926 asm, "\t$Zd, $Zn, $imm", 3927 "", []>, Sched<[]> { 3928 bits<5> Zd; 3929 bits<5> Zn; 3930 bits<5> imm; 3931 let Inst{31-23} = 0b010001010; 3932 let Inst{22} = tsz8_64{2}; 3933 let Inst{21} = 0b1; 3934 let Inst{20-19} = tsz8_64{1-0}; 3935 let Inst{18-16} = imm{2-0}; // imm3 3936 let Inst{15-14} = 0b00; 3937 let Inst{13-11} = opc; 3938 let Inst{10} = 0b1; 3939 let Inst{9-5} = Zn; 3940 let Inst{4-0} = Zd; 3941 3942 let Constraints = "$Zd = $_Zd"; 3943} 3944 3945multiclass sve2_int_bin_shift_imm_right_narrow_top<bits<3> opc, string asm, 3946 SDPatternOperator op> { 3947 def _B : sve2_int_bin_shift_imm_narrow_top<{0,0,1}, opc, asm, ZPR8, ZPR16, 3948 tvecshiftR8>; 3949 def _H : sve2_int_bin_shift_imm_narrow_top<{0,1,?}, opc, asm, ZPR16, ZPR32, 3950 tvecshiftR16> { 3951 let Inst{19} = imm{3}; 3952 } 3953 def _S : sve2_int_bin_shift_imm_narrow_top<{1,?,?}, opc, asm, ZPR32, ZPR64, 3954 tvecshiftR32> { 3955 let Inst{20-19} = imm{4-3}; 3956 } 3957 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv8i16, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>; 3958 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv4i32, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>; 3959 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv2i64, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>; 3960} 3961 3962class sve2_int_addsub_narrow_high_bottom<bits<2> sz, bits<2> opc, string asm, 3963 ZPRRegOp zprty1, ZPRRegOp zprty2> 3964: I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm), 3965 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> { 3966 bits<5> Zd; 3967 bits<5> Zn; 3968 bits<5> Zm; 3969 let Inst{31-24} = 0b01000101; 3970 let Inst{23-22} = sz; 3971 let Inst{21} = 0b1; 3972 let Inst{20-16} = Zm; 3973 let Inst{15-13} = 0b011; 3974 let Inst{12-11} = opc; // S, R 3975 let Inst{10} = 0b0; // Top 3976 let Inst{9-5} = Zn; 3977 let Inst{4-0} = Zd; 3978} 3979 3980multiclass sve2_int_addsub_narrow_high_bottom<bits<2> opc, string asm, 3981 SDPatternOperator op> { 3982 def _B : sve2_int_addsub_narrow_high_bottom<0b01, opc, asm, ZPR8, ZPR16>; 3983 def _H : sve2_int_addsub_narrow_high_bottom<0b10, opc, asm, ZPR16, ZPR32>; 3984 def _S : sve2_int_addsub_narrow_high_bottom<0b11, opc, asm, ZPR32, ZPR64>; 3985 3986 def : SVE_2_Op_Pat<nxv16i8, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _B)>; 3987 def : SVE_2_Op_Pat<nxv8i16, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _H)>; 3988 def : SVE_2_Op_Pat<nxv4i32, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _S)>; 3989} 3990 3991class sve2_int_addsub_narrow_high_top<bits<2> sz, bits<2> opc, string asm, 3992 ZPRRegOp zprty1, ZPRRegOp zprty2> 3993: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm), 3994 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> { 3995 bits<5> Zd; 3996 bits<5> Zn; 3997 bits<5> Zm; 3998 let Inst{31-24} = 0b01000101; 3999 let Inst{23-22} = sz; 4000 let Inst{21} = 0b1; 4001 let Inst{20-16} = Zm; 4002 let Inst{15-13} = 0b011; 4003 let Inst{12-11} = opc; // S, R 4004 let Inst{10} = 0b1; // Top 4005 let Inst{9-5} = Zn; 4006 let Inst{4-0} = Zd; 4007 4008 let Constraints = "$Zd = $_Zd"; 4009} 4010 4011multiclass sve2_int_addsub_narrow_high_top<bits<2> opc, string asm, 4012 SDPatternOperator op> { 4013 def _B : sve2_int_addsub_narrow_high_top<0b01, opc, asm, ZPR8, ZPR16>; 4014 def _H : sve2_int_addsub_narrow_high_top<0b10, opc, asm, ZPR16, ZPR32>; 4015 def _S : sve2_int_addsub_narrow_high_top<0b11, opc, asm, ZPR32, ZPR64>; 4016 4017 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _B)>; 4018 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _H)>; 4019 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _S)>; 4020} 4021 4022class sve2_int_sat_extract_narrow_bottom<bits<3> tsz8_64, bits<2> opc, string asm, 4023 ZPRRegOp zprty1, ZPRRegOp zprty2> 4024: I<(outs zprty1:$Zd), (ins zprty2:$Zn), 4025 asm, "\t$Zd, $Zn", "", []>, Sched<[]> { 4026 bits<5> Zd; 4027 bits<5> Zn; 4028 let Inst{31-23} = 0b010001010; 4029 let Inst{22} = tsz8_64{2}; 4030 let Inst{21} = 0b1; 4031 let Inst{20-19} = tsz8_64{1-0}; 4032 let Inst{18-13} = 0b000010; 4033 let Inst{12-11} = opc; 4034 let Inst{10} = 0b0; 4035 let Inst{9-5} = Zn; 4036 let Inst{4-0} = Zd; 4037} 4038 4039multiclass sve2_int_sat_extract_narrow_bottom<bits<2> opc, string asm, 4040 SDPatternOperator op> { 4041 def _B : sve2_int_sat_extract_narrow_bottom<0b001, opc, asm, ZPR8, ZPR16>; 4042 def _H : sve2_int_sat_extract_narrow_bottom<0b010, opc, asm, ZPR16, ZPR32>; 4043 def _S : sve2_int_sat_extract_narrow_bottom<0b100, opc, asm, ZPR32, ZPR64>; 4044 4045 def : SVE_1_Op_Pat<nxv16i8, op, nxv8i16, !cast<Instruction>(NAME # _B)>; 4046 def : SVE_1_Op_Pat<nxv8i16, op, nxv4i32, !cast<Instruction>(NAME # _H)>; 4047 def : SVE_1_Op_Pat<nxv4i32, op, nxv2i64, !cast<Instruction>(NAME # _S)>; 4048} 4049 4050class sve2_int_sat_extract_narrow_top<bits<3> tsz8_64, bits<2> opc, string asm, 4051 ZPRRegOp zprty1, ZPRRegOp zprty2> 4052: I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn), 4053 asm, "\t$Zd, $Zn", "", []>, Sched<[]> { 4054 bits<5> Zd; 4055 bits<5> Zn; 4056 let Inst{31-23} = 0b010001010; 4057 let Inst{22} = tsz8_64{2}; 4058 let Inst{21} = 0b1; 4059 let Inst{20-19} = tsz8_64{1-0}; 4060 let Inst{18-13} = 0b000010; 4061 let Inst{12-11} = opc; 4062 let Inst{10} = 0b1; 4063 let Inst{9-5} = Zn; 4064 let Inst{4-0} = Zd; 4065 4066 let Constraints = "$Zd = $_Zd"; 4067} 4068 4069multiclass sve2_int_sat_extract_narrow_top<bits<2> opc, string asm, 4070 SDPatternOperator op> { 4071 def _B : sve2_int_sat_extract_narrow_top<0b001, opc, asm, ZPR8, ZPR16>; 4072 def _H : sve2_int_sat_extract_narrow_top<0b010, opc, asm, ZPR16, ZPR32>; 4073 def _S : sve2_int_sat_extract_narrow_top<0b100, opc, asm, ZPR32, ZPR64>; 4074 4075 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv8i16, !cast<Instruction>(NAME # _B)>; 4076 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv4i32, !cast<Instruction>(NAME # _H)>; 4077 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>; 4078} 4079 4080//===----------------------------------------------------------------------===// 4081// SVE Integer Arithmetic - Unary Predicated Group 4082//===----------------------------------------------------------------------===// 4083 4084class sve_int_un_pred_arit<bits<2> sz8_64, bits<4> opc, 4085 string asm, ZPRRegOp zprty> 4086: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn), 4087 asm, "\t$Zd, $Pg/m, $Zn", 4088 "", 4089 []>, Sched<[]> { 4090 bits<3> Pg; 4091 bits<5> Zd; 4092 bits<5> Zn; 4093 let Inst{31-24} = 0b00000100; 4094 let Inst{23-22} = sz8_64; 4095 let Inst{21-20} = 0b01; 4096 let Inst{19} = opc{0}; 4097 let Inst{18-16} = opc{3-1}; 4098 let Inst{15-13} = 0b101; 4099 let Inst{12-10} = Pg; 4100 let Inst{9-5} = Zn; 4101 let Inst{4-0} = Zd; 4102 4103 let Constraints = "$Zd = $_Zd"; 4104 let DestructiveInstType = DestructiveUnaryPassthru; 4105 let ElementSize = zprty.ElementSize; 4106} 4107 4108multiclass sve_int_un_pred_arit_0<bits<3> opc, string asm, 4109 SDPatternOperator op> { 4110 def _B : sve_int_un_pred_arit<0b00, { opc, 0b0 }, asm, ZPR8>, 4111 SVEPseudo2Instr<NAME # _B, 1>; 4112 def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>, 4113 SVEPseudo2Instr<NAME # _H, 1>; 4114 def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>, 4115 SVEPseudo2Instr<NAME # _S, 1>; 4116 def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>, 4117 SVEPseudo2Instr<NAME # _D, 1>; 4118 4119 def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 4120 def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 4121 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 4122 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 4123 4124 def _UNDEF_B : PredOneOpPassthruPseudo<NAME # _B, ZPR8>; 4125 def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>; 4126 def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>; 4127 def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>; 4128 4129 defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>; 4130 defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>; 4131 defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>; 4132 defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>; 4133} 4134 4135multiclass sve_int_un_pred_arit_0_h<bits<3> opc, string asm, 4136 SDPatternOperator op> { 4137 def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>, 4138 SVEPseudo2Instr<NAME # _H, 1>; 4139 def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>, 4140 SVEPseudo2Instr<NAME # _S, 1>; 4141 def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>, 4142 SVEPseudo2Instr<NAME # _D, 1>; 4143 4144 def : SVE_InReg_Extend<nxv8i16, op, nxv8i1, nxv8i8, !cast<Instruction>(NAME # _H)>; 4145 def : SVE_InReg_Extend<nxv4i32, op, nxv4i1, nxv4i8, !cast<Instruction>(NAME # _S)>; 4146 def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i8, !cast<Instruction>(NAME # _D)>; 4147 4148 def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>; 4149 def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>; 4150 def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>; 4151 4152 defm : SVE_InReg_Extend_PassthruUndef<nxv8i16, op, nxv8i1, nxv8i8, !cast<Pseudo>(NAME # _UNDEF_H)>; 4153 defm : SVE_InReg_Extend_PassthruUndef<nxv4i32, op, nxv4i1, nxv4i8, !cast<Pseudo>(NAME # _UNDEF_S)>; 4154 defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i8, !cast<Pseudo>(NAME # _UNDEF_D)>; 4155} 4156 4157multiclass sve_int_un_pred_arit_0_w<bits<3> opc, string asm, 4158 SDPatternOperator op> { 4159 def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>, 4160 SVEPseudo2Instr<NAME # _S, 1>; 4161 def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>, 4162 SVEPseudo2Instr<NAME # _D, 1>; 4163 4164 def : SVE_InReg_Extend<nxv4i32, op, nxv4i1, nxv4i16, !cast<Instruction>(NAME # _S)>; 4165 def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i16, !cast<Instruction>(NAME # _D)>; 4166 4167 def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>; 4168 def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>; 4169 4170 defm : SVE_InReg_Extend_PassthruUndef<nxv4i32, op, nxv4i1, nxv4i16, !cast<Pseudo>(NAME # _UNDEF_S)>; 4171 defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i16, !cast<Pseudo>(NAME # _UNDEF_D)>; 4172} 4173 4174multiclass sve_int_un_pred_arit_0_d<bits<3> opc, string asm, 4175 SDPatternOperator op> { 4176 def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>, 4177 SVEPseudo2Instr<NAME # _D, 1>; 4178 4179 def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i32, !cast<Instruction>(NAME # _D)>; 4180 4181 def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>; 4182 4183 defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i32, !cast<Pseudo>(NAME # _UNDEF_D)>; 4184} 4185 4186multiclass sve_int_un_pred_arit_1<bits<3> opc, string asm, 4187 SDPatternOperator op> { 4188 def _B : sve_int_un_pred_arit<0b00, { opc, 0b1 }, asm, ZPR8>, 4189 SVEPseudo2Instr<NAME # _B, 1>; 4190 def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>, 4191 SVEPseudo2Instr<NAME # _H, 1>; 4192 def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>, 4193 SVEPseudo2Instr<NAME # _S, 1>; 4194 def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>, 4195 SVEPseudo2Instr<NAME # _D, 1>; 4196 4197 def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 4198 def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 4199 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 4200 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 4201 4202 def _UNDEF_B : PredOneOpPassthruPseudo<NAME # _B, ZPR8>; 4203 def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>; 4204 def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>; 4205 def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>; 4206 4207 defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>; 4208 defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>; 4209 defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>; 4210 defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>; 4211} 4212 4213multiclass sve_int_un_pred_arit_1_fp<bits<3> opc, string asm, SDPatternOperator op> { 4214 def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>, 4215 SVEPseudo2Instr<NAME # _H, 1>; 4216 def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>, 4217 SVEPseudo2Instr<NAME # _S, 1>; 4218 def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>, 4219 SVEPseudo2Instr<NAME # _D, 1>; 4220 4221 def : SVE_1_Op_Passthru_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 4222 def : SVE_1_Op_Passthru_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>; 4223 def : SVE_1_Op_Passthru_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>; 4224 def : SVE_1_Op_Passthru_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 4225 def : SVE_1_Op_Passthru_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>; 4226 def : SVE_1_Op_Passthru_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 4227 4228 def _UNDEF_H : PredOneOpPassthruPseudo<NAME # _H, ZPR16>; 4229 def _UNDEF_S : PredOneOpPassthruPseudo<NAME # _S, ZPR32>; 4230 def _UNDEF_D : PredOneOpPassthruPseudo<NAME # _D, ZPR64>; 4231 4232 defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Pseudo>(NAME # _UNDEF_H)>; 4233 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Pseudo>(NAME # _UNDEF_H)>; 4234 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Pseudo>(NAME # _UNDEF_H)>; 4235 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Pseudo>(NAME # _UNDEF_S)>; 4236 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Pseudo>(NAME # _UNDEF_S)>; 4237 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Pseudo>(NAME # _UNDEF_D)>; 4238} 4239 4240//===----------------------------------------------------------------------===// 4241// SVE Integer Wide Immediate - Unpredicated Group 4242//===----------------------------------------------------------------------===// 4243class sve_int_dup_imm<bits<2> sz8_64, string asm, 4244 ZPRRegOp zprty, Operand immtype> 4245: I<(outs zprty:$Zd), (ins immtype:$imm), 4246 asm, "\t$Zd, $imm", 4247 "", 4248 []>, Sched<[]> { 4249 bits<5> Zd; 4250 bits<9> imm; 4251 let Inst{31-24} = 0b00100101; 4252 let Inst{23-22} = sz8_64; 4253 let Inst{21-14} = 0b11100011; 4254 let Inst{13} = imm{8}; // sh 4255 let Inst{12-5} = imm{7-0}; // imm8 4256 let Inst{4-0} = Zd; 4257 4258 let isReMaterializable = 1; 4259} 4260 4261multiclass sve_int_dup_imm<string asm> { 4262 def _B : sve_int_dup_imm<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8>; 4263 def _H : sve_int_dup_imm<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16>; 4264 def _S : sve_int_dup_imm<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32>; 4265 def _D : sve_int_dup_imm<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64>; 4266 4267 def : InstAlias<"mov $Zd, $imm", 4268 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, cpy_imm8_opt_lsl_i8:$imm), 1>; 4269 def : InstAlias<"mov $Zd, $imm", 4270 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, cpy_imm8_opt_lsl_i16:$imm), 1>; 4271 def : InstAlias<"mov $Zd, $imm", 4272 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, cpy_imm8_opt_lsl_i32:$imm), 1>; 4273 def : InstAlias<"mov $Zd, $imm", 4274 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, cpy_imm8_opt_lsl_i64:$imm), 1>; 4275 4276 def : InstAlias<"fmov $Zd, #0.0", 4277 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, 0, 0), 1>; 4278 def : InstAlias<"fmov $Zd, #0.0", 4279 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, 0, 0), 1>; 4280 def : InstAlias<"fmov $Zd, #0.0", 4281 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, 0, 0), 1>; 4282} 4283 4284class sve_int_dup_fpimm<bits<2> sz8_64, Operand fpimmtype, 4285 string asm, ZPRRegOp zprty> 4286: I<(outs zprty:$Zd), (ins fpimmtype:$imm8), 4287 asm, "\t$Zd, $imm8", 4288 "", 4289 []>, Sched<[]> { 4290 bits<5> Zd; 4291 bits<8> imm8; 4292 let Inst{31-24} = 0b00100101; 4293 let Inst{23-22} = sz8_64; 4294 let Inst{21-14} = 0b11100111; 4295 let Inst{13} = 0b0; 4296 let Inst{12-5} = imm8; 4297 let Inst{4-0} = Zd; 4298 4299 let isReMaterializable = 1; 4300} 4301 4302multiclass sve_int_dup_fpimm<string asm> { 4303 def _H : sve_int_dup_fpimm<0b01, fpimm16, asm, ZPR16>; 4304 def _S : sve_int_dup_fpimm<0b10, fpimm32, asm, ZPR32>; 4305 def _D : sve_int_dup_fpimm<0b11, fpimm64, asm, ZPR64>; 4306 4307 def : InstAlias<"fmov $Zd, $imm8", 4308 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, fpimm16:$imm8), 1>; 4309 def : InstAlias<"fmov $Zd, $imm8", 4310 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, fpimm32:$imm8), 1>; 4311 def : InstAlias<"fmov $Zd, $imm8", 4312 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, fpimm64:$imm8), 1>; 4313} 4314 4315class sve_int_arith_imm0<bits<2> sz8_64, bits<3> opc, string asm, 4316 ZPRRegOp zprty, Operand immtype> 4317: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm), 4318 asm, "\t$Zdn, $_Zdn, $imm", 4319 "", 4320 []>, Sched<[]> { 4321 bits<5> Zdn; 4322 bits<9> imm; 4323 let Inst{31-24} = 0b00100101; 4324 let Inst{23-22} = sz8_64; 4325 let Inst{21-19} = 0b100; 4326 let Inst{18-16} = opc; 4327 let Inst{15-14} = 0b11; 4328 let Inst{13} = imm{8}; // sh 4329 let Inst{12-5} = imm{7-0}; // imm8 4330 let Inst{4-0} = Zdn; 4331 4332 let Constraints = "$Zdn = $_Zdn"; 4333 let DestructiveInstType = DestructiveOther; 4334 let ElementSize = ElementSizeNone; 4335} 4336 4337multiclass sve_int_arith_imm0<bits<3> opc, string asm, SDPatternOperator op> { 4338 def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8, addsub_imm8_opt_lsl_i8>; 4339 def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>; 4340 def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>; 4341 def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>; 4342 4343 def : SVE_1_Op_Imm_OptLsl_Pat<nxv16i8, op, ZPR8, i32, SVEAddSubImm8Pat, !cast<Instruction>(NAME # _B)>; 4344 def : SVE_1_Op_Imm_OptLsl_Pat<nxv8i16, op, ZPR16, i32, SVEAddSubImm16Pat, !cast<Instruction>(NAME # _H)>; 4345 def : SVE_1_Op_Imm_OptLsl_Pat<nxv4i32, op, ZPR32, i32, SVEAddSubImm32Pat, !cast<Instruction>(NAME # _S)>; 4346 def : SVE_1_Op_Imm_OptLsl_Pat<nxv2i64, op, ZPR64, i64, SVEAddSubImm64Pat, !cast<Instruction>(NAME # _D)>; 4347} 4348 4349multiclass sve_int_arith_imm0_subr<bits<3> opc, string asm, SDPatternOperator op> { 4350 def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8, addsub_imm8_opt_lsl_i8>; 4351 def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>; 4352 def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>; 4353 def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>; 4354 4355 def : SVE_1_Op_Imm_OptLsl_Reverse_Pat<nxv16i8, op, ZPR8, i32, SVEAddSubImm8Pat, !cast<Instruction>(NAME # _B)>; 4356 def : SVE_1_Op_Imm_OptLsl_Reverse_Pat<nxv8i16, op, ZPR16, i32, SVEAddSubImm16Pat, !cast<Instruction>(NAME # _H)>; 4357 def : SVE_1_Op_Imm_OptLsl_Reverse_Pat<nxv4i32, op, ZPR32, i32, SVEAddSubImm32Pat, !cast<Instruction>(NAME # _S)>; 4358 def : SVE_1_Op_Imm_OptLsl_Reverse_Pat<nxv2i64, op, ZPR64, i64, SVEAddSubImm64Pat, !cast<Instruction>(NAME # _D)>; 4359} 4360 4361class sve_int_arith_imm<bits<2> sz8_64, bits<6> opc, string asm, 4362 ZPRRegOp zprty, Operand immtype> 4363: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm), 4364 asm, "\t$Zdn, $_Zdn, $imm", 4365 "", 4366 []>, Sched<[]> { 4367 bits<5> Zdn; 4368 bits<8> imm; 4369 let Inst{31-24} = 0b00100101; 4370 let Inst{23-22} = sz8_64; 4371 let Inst{21-16} = opc; 4372 let Inst{15-13} = 0b110; 4373 let Inst{12-5} = imm; 4374 let Inst{4-0} = Zdn; 4375 4376 let Constraints = "$Zdn = $_Zdn"; 4377 let DestructiveInstType = DestructiveOther; 4378 let ElementSize = ElementSizeNone; 4379} 4380 4381multiclass sve_int_arith_imm1<bits<2> opc, string asm, SDPatternOperator op> { 4382 def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, simm8>; 4383 def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, simm8>; 4384 def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, simm8>; 4385 def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, simm8>; 4386 4387 def : SVE_1_Op_Imm_Arith_All_Active<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _B)>; 4388 def : SVE_1_Op_Imm_Arith_All_Active<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _H)>; 4389 def : SVE_1_Op_Imm_Arith_All_Active<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _S)>; 4390 def : SVE_1_Op_Imm_Arith_All_Active<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithSImmPat64, !cast<Instruction>(NAME # _D)>; 4391} 4392 4393multiclass sve_int_arith_imm1_unsigned<bits<2> opc, string asm, SDPatternOperator op> { 4394 def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, imm0_255>; 4395 def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, imm0_255>; 4396 def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, imm0_255>; 4397 def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, imm0_255>; 4398 4399 def : SVE_1_Op_Imm_Arith_All_Active<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithUImm8Pat, !cast<Instruction>(NAME # _B)>; 4400 def : SVE_1_Op_Imm_Arith_All_Active<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithUImm16Pat, !cast<Instruction>(NAME # _H)>; 4401 def : SVE_1_Op_Imm_Arith_All_Active<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithUImm32Pat, !cast<Instruction>(NAME # _S)>; 4402 def : SVE_1_Op_Imm_Arith_All_Active<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithUImm64Pat, !cast<Instruction>(NAME # _D)>; 4403} 4404 4405multiclass sve_int_arith_imm2<string asm, SDPatternOperator op> { 4406 def _B : sve_int_arith_imm<0b00, 0b110000, asm, ZPR8, simm8>; 4407 def _H : sve_int_arith_imm<0b01, 0b110000, asm, ZPR16, simm8>; 4408 def _S : sve_int_arith_imm<0b10, 0b110000, asm, ZPR32, simm8>; 4409 def _D : sve_int_arith_imm<0b11, 0b110000, asm, ZPR64, simm8>; 4410 4411 def : SVE_1_Op_Imm_Arith_All_Active<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _B)>; 4412 def : SVE_1_Op_Imm_Arith_All_Active<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _H)>; 4413 def : SVE_1_Op_Imm_Arith_All_Active<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _S)>; 4414 def : SVE_1_Op_Imm_Arith_All_Active<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithSImmPat64, !cast<Instruction>(NAME # _D)>; 4415} 4416 4417//===----------------------------------------------------------------------===// 4418// SVE Bitwise Logical - Unpredicated Group 4419//===----------------------------------------------------------------------===// 4420 4421class sve_int_bin_cons_log<bits<2> opc, string asm> 4422: I<(outs ZPR64:$Zd), (ins ZPR64:$Zn, ZPR64:$Zm), 4423 asm, "\t$Zd, $Zn, $Zm", 4424 "", 4425 []>, Sched<[]> { 4426 bits<5> Zd; 4427 bits<5> Zm; 4428 bits<5> Zn; 4429 let Inst{31-24} = 0b00000100; 4430 let Inst{23-22} = opc{1-0}; 4431 let Inst{21} = 0b1; 4432 let Inst{20-16} = Zm; 4433 let Inst{15-10} = 0b001100; 4434 let Inst{9-5} = Zn; 4435 let Inst{4-0} = Zd; 4436} 4437 4438multiclass sve_int_bin_cons_log<bits<2> opc, string asm, SDPatternOperator op> { 4439 def NAME : sve_int_bin_cons_log<opc, asm>; 4440 4441 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>; 4442 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>; 4443 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>; 4444 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>; 4445 4446 def : InstAlias<asm # "\t$Zd, $Zn, $Zm", 4447 (!cast<Instruction>(NAME) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 1>; 4448 def : InstAlias<asm # "\t$Zd, $Zn, $Zm", 4449 (!cast<Instruction>(NAME) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 1>; 4450 def : InstAlias<asm # "\t$Zd, $Zn, $Zm", 4451 (!cast<Instruction>(NAME) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 1>; 4452} 4453 4454class sve2_int_bitwise_ternary_op_d<bits<3> opc, string asm> 4455: I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, ZPR64:$Zm, ZPR64:$Zk), 4456 asm, "\t$Zdn, $_Zdn, $Zm, $Zk", 4457 "", 4458 []>, Sched<[]> { 4459 bits<5> Zdn; 4460 bits<5> Zk; 4461 bits<5> Zm; 4462 let Inst{31-24} = 0b00000100; 4463 let Inst{23-22} = opc{2-1}; 4464 let Inst{21} = 0b1; 4465 let Inst{20-16} = Zm; 4466 let Inst{15-11} = 0b00111; 4467 let Inst{10} = opc{0}; 4468 let Inst{9-5} = Zk; 4469 let Inst{4-0} = Zdn; 4470 4471 let Constraints = "$Zdn = $_Zdn"; 4472 let DestructiveInstType = DestructiveOther; 4473 let ElementSize = ElementSizeNone; 4474} 4475 4476multiclass sve2_int_bitwise_ternary_op<bits<3> opc, string asm, SDPatternOperator op> { 4477 def NAME : sve2_int_bitwise_ternary_op_d<opc, asm>; 4478 4479 def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk", 4480 (!cast<Instruction>(NAME) ZPR8:$Zdn, ZPR8:$Zm, ZPR8:$Zk), 1>; 4481 def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk", 4482 (!cast<Instruction>(NAME) ZPR16:$Zdn, ZPR16:$Zm, ZPR16:$Zk), 1>; 4483 def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk", 4484 (!cast<Instruction>(NAME) ZPR32:$Zdn, ZPR32:$Zm, ZPR32:$Zk), 1>; 4485 4486 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>; 4487 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>; 4488 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>; 4489 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>; 4490} 4491 4492class sve2_int_rotate_right_imm<bits<4> tsz8_64, string asm, 4493 ZPRRegOp zprty, Operand immtype> 4494: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, immtype:$imm), 4495 asm, "\t$Zdn, $_Zdn, $Zm, $imm", 4496 "", 4497 []>, Sched<[]> { 4498 bits<5> Zdn; 4499 bits<5> Zm; 4500 bits<6> imm; 4501 let Inst{31-24} = 0b00000100; 4502 let Inst{23-22} = tsz8_64{3-2}; 4503 let Inst{21} = 0b1; 4504 let Inst{20-19} = tsz8_64{1-0}; 4505 let Inst{18-16} = imm{2-0}; // imm3 4506 let Inst{15-10} = 0b001101; 4507 let Inst{9-5} = Zm; 4508 let Inst{4-0} = Zdn; 4509 4510 let Constraints = "$Zdn = $_Zdn"; 4511 let DestructiveInstType = DestructiveOther; 4512 let ElementSize = ElementSizeNone; 4513} 4514 4515multiclass sve2_int_rotate_right_imm<string asm, SDPatternOperator op> { 4516 def _B : sve2_int_rotate_right_imm<{0,0,0,1}, asm, ZPR8, vecshiftR8>; 4517 def _H : sve2_int_rotate_right_imm<{0,0,1,?}, asm, ZPR16, vecshiftR16> { 4518 let Inst{19} = imm{3}; 4519 } 4520 def _S : sve2_int_rotate_right_imm<{0,1,?,?}, asm, ZPR32, vecshiftR32> { 4521 let Inst{20-19} = imm{4-3}; 4522 } 4523 def _D : sve2_int_rotate_right_imm<{1,?,?,?}, asm, ZPR64, vecshiftR64> { 4524 let Inst{22} = imm{5}; 4525 let Inst{20-19} = imm{4-3}; 4526 } 4527 4528 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>; 4529 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>; 4530 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>; 4531 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>; 4532} 4533 4534//===----------------------------------------------------------------------===// 4535// SVE Integer Wide Immediate - Predicated Group 4536//===----------------------------------------------------------------------===// 4537 4538class sve_int_dup_fpimm_pred<bits<2> sz, Operand fpimmtype, 4539 string asm, ZPRRegOp zprty> 4540: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPRAny:$Pg, fpimmtype:$imm8), 4541 asm, "\t$Zd, $Pg/m, $imm8", 4542 "", 4543 []>, Sched<[]> { 4544 bits<4> Pg; 4545 bits<5> Zd; 4546 bits<8> imm8; 4547 let Inst{31-24} = 0b00000101; 4548 let Inst{23-22} = sz; 4549 let Inst{21-20} = 0b01; 4550 let Inst{19-16} = Pg; 4551 let Inst{15-13} = 0b110; 4552 let Inst{12-5} = imm8; 4553 let Inst{4-0} = Zd; 4554 4555 let Constraints = "$Zd = $_Zd"; 4556 let DestructiveInstType = DestructiveOther; 4557 let ElementSize = zprty.ElementSize; 4558} 4559 4560multiclass sve_int_dup_fpimm_pred<string asm> { 4561 def _H : sve_int_dup_fpimm_pred<0b01, fpimm16, asm, ZPR16>; 4562 def _S : sve_int_dup_fpimm_pred<0b10, fpimm32, asm, ZPR32>; 4563 def _D : sve_int_dup_fpimm_pred<0b11, fpimm64, asm, ZPR64>; 4564 4565 def : InstAlias<"fmov $Zd, $Pg/m, $imm8", 4566 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, fpimm16:$imm8), 1>; 4567 def : InstAlias<"fmov $Zd, $Pg/m, $imm8", 4568 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, fpimm32:$imm8), 1>; 4569 def : InstAlias<"fmov $Zd, $Pg/m, $imm8", 4570 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, fpimm64:$imm8), 1>; 4571} 4572 4573class sve_int_dup_imm_pred<bits<2> sz8_64, bit m, string asm, 4574 ZPRRegOp zprty, string pred_qual, dag iops> 4575: I<(outs zprty:$Zd), iops, 4576 asm, "\t$Zd, $Pg"#pred_qual#", $imm", 4577 "", []>, Sched<[]> { 4578 bits<5> Zd; 4579 bits<4> Pg; 4580 bits<9> imm; 4581 let Inst{31-24} = 0b00000101; 4582 let Inst{23-22} = sz8_64; 4583 let Inst{21-20} = 0b01; 4584 let Inst{19-16} = Pg; 4585 let Inst{15} = 0b0; 4586 let Inst{14} = m; 4587 let Inst{13} = imm{8}; // sh 4588 let Inst{12-5} = imm{7-0}; // imm8 4589 let Inst{4-0} = Zd; 4590 4591 let DestructiveInstType = DestructiveOther; 4592 let ElementSize = zprty.ElementSize; 4593} 4594 4595multiclass sve_int_dup_imm_pred_merge_inst< 4596 bits<2> sz8_64, string asm, ZPRRegOp zprty, ValueType intty, 4597 ValueType predty, ValueType scalarty, imm8_opt_lsl cpyimm> { 4598 let Constraints = "$Zd = $_Zd" in 4599 def NAME : sve_int_dup_imm_pred<sz8_64, 1, asm, zprty, "/m", 4600 (ins zprty:$_Zd, PPRAny:$Pg, cpyimm:$imm)>; 4601 def : InstAlias<"mov $Zd, $Pg/m, $imm", 4602 (!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>; 4603 def : Pat<(intty 4604 (vselect predty:$Pg, 4605 (intty (AArch64dup (scalarty (SVE8BitLslImm<scalarty>.Pat i32:$imm, i32:$shift)))), 4606 intty:$Zd)), 4607 (!cast<Instruction>(NAME) zprty:$Zd, $Pg, i32:$imm, i32:$shift)>; 4608} 4609 4610multiclass sve_int_dup_imm_pred_merge<string asm> { 4611 defm _B : sve_int_dup_imm_pred_merge_inst<0b00, asm, ZPR8, nxv16i8, nxv16i1, 4612 i32, cpy_imm8_opt_lsl_i8>; 4613 defm _H : sve_int_dup_imm_pred_merge_inst<0b01, asm, ZPR16, nxv8i16, nxv8i1, 4614 i32, cpy_imm8_opt_lsl_i16>; 4615 defm _S : sve_int_dup_imm_pred_merge_inst<0b10, asm, ZPR32, nxv4i32, nxv4i1, 4616 i32, cpy_imm8_opt_lsl_i32>; 4617 defm _D : sve_int_dup_imm_pred_merge_inst<0b11, asm, ZPR64, nxv2i64, nxv2i1, 4618 i64, cpy_imm8_opt_lsl_i64>; 4619 4620 def : InstAlias<"fmov $Zd, $Pg/m, #0.0", 4621 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, 0, 0), 0>; 4622 def : InstAlias<"fmov $Zd, $Pg/m, #0.0", 4623 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, 0, 0), 0>; 4624 def : InstAlias<"fmov $Zd, $Pg/m, #0.0", 4625 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, 0, 0), 0>; 4626} 4627 4628multiclass sve_int_dup_imm_pred_zero_inst< 4629 bits<2> sz8_64, string asm, ZPRRegOp zprty, ValueType intty, 4630 ValueType predty, ValueType scalarty, imm8_opt_lsl cpyimm> { 4631 def NAME : sve_int_dup_imm_pred<sz8_64, 0, asm, zprty, "/z", 4632 (ins PPRAny:$Pg, cpyimm:$imm)>; 4633 def : InstAlias<"mov $Zd, $Pg/z, $imm", 4634 (!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>; 4635 def : Pat<(intty (zext (predty PPRAny:$Ps1))), 4636 (!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>; 4637 def : Pat<(intty (sext (predty PPRAny:$Ps1))), 4638 (!cast<Instruction>(NAME) PPRAny:$Ps1, -1, 0)>; 4639 def : Pat<(intty (anyext (predty PPRAny:$Ps1))), 4640 (!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>; 4641 def : Pat<(intty 4642 (vselect predty:$Pg, 4643 (intty (AArch64dup (scalarty (SVE8BitLslImm<scalarty>.Pat i32:$imm, i32:$shift)))), 4644 (intty (AArch64dup (scalarty 0))))), 4645 (!cast<Instruction>(NAME) $Pg, i32:$imm, i32:$shift)>; 4646} 4647 4648multiclass sve_int_dup_imm_pred_zero<string asm> { 4649 defm _B : sve_int_dup_imm_pred_zero_inst<0b00, asm, ZPR8, nxv16i8, nxv16i1, 4650 i32, cpy_imm8_opt_lsl_i8>; 4651 defm _H : sve_int_dup_imm_pred_zero_inst<0b01, asm, ZPR16, nxv8i16, nxv8i1, 4652 i32, cpy_imm8_opt_lsl_i16>; 4653 defm _S : sve_int_dup_imm_pred_zero_inst<0b10, asm, ZPR32, nxv4i32, nxv4i1, 4654 i32, cpy_imm8_opt_lsl_i32>; 4655 defm _D : sve_int_dup_imm_pred_zero_inst<0b11, asm, ZPR64, nxv2i64, nxv2i1, 4656 i64, cpy_imm8_opt_lsl_i64>; 4657} 4658 4659//===----------------------------------------------------------------------===// 4660// SVE Integer Compare - Vectors Group 4661//===----------------------------------------------------------------------===// 4662 4663class sve_int_cmp<bit cmp_1, bits<2> sz8_64, bits<3> opc, string asm, 4664 PPRRegOp pprty, ZPRRegOp zprty1, ZPRRegOp zprty2> 4665: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty1:$Zn, zprty2:$Zm), 4666 asm, "\t$Pd, $Pg/z, $Zn, $Zm", 4667 "", 4668 []>, Sched<[]> { 4669 bits<4> Pd; 4670 bits<3> Pg; 4671 bits<5> Zm; 4672 bits<5> Zn; 4673 let Inst{31-24} = 0b00100100; 4674 let Inst{23-22} = sz8_64; 4675 let Inst{21} = 0b0; 4676 let Inst{20-16} = Zm; 4677 let Inst{15} = opc{2}; 4678 let Inst{14} = cmp_1; 4679 let Inst{13} = opc{1}; 4680 let Inst{12-10} = Pg; 4681 let Inst{9-5} = Zn; 4682 let Inst{4} = opc{0}; 4683 let Inst{3-0} = Pd; 4684 4685 let Defs = [NZCV]; 4686 let ElementSize = pprty.ElementSize; 4687 let isPTestLike = 1; 4688} 4689 4690multiclass SVE_SETCC_Pat<CondCode cc, CondCode invcc, ValueType predvt, 4691 ValueType intvt, Instruction cmp> { 4692 def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, intvt:$Op3, cc)), 4693 (cmp $Op1, $Op2, $Op3)>; 4694 def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, intvt:$Op3, invcc)), 4695 (cmp $Op1, $Op3, $Op2)>; 4696 def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z (predvt (AArch64ptrue 31)), intvt:$Op2, intvt:$Op3, cc))), 4697 (cmp $Pg, $Op2, $Op3)>; 4698 def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z (predvt (AArch64ptrue 31)), intvt:$Op2, intvt:$Op3, invcc))), 4699 (cmp $Pg, $Op3, $Op2)>; 4700} 4701 4702multiclass SVE_SETCC_Pat_With_Zero<CondCode cc, CondCode invcc, ValueType predvt, 4703 ValueType intvt, Instruction cmp> { 4704 def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, (SVEDup0), cc)), 4705 (cmp $Op1, $Op2)>; 4706 def : Pat<(predvt (AArch64setcc_z predvt:$Op1, (SVEDup0), intvt:$Op2, invcc)), 4707 (cmp $Op1, $Op2)>; 4708} 4709 4710multiclass sve_int_cmp_0<bits<3> opc, string asm, CondCode cc, CondCode invcc> { 4711 def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR8>; 4712 def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR16>; 4713 def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR32>; 4714 def _D : sve_int_cmp<0b0, 0b11, opc, asm, PPR64, ZPR64, ZPR64>; 4715 4716 defm : SVE_SETCC_Pat<cc, invcc, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 4717 defm : SVE_SETCC_Pat<cc, invcc, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 4718 defm : SVE_SETCC_Pat<cc, invcc, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 4719 defm : SVE_SETCC_Pat<cc, invcc, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 4720} 4721 4722multiclass sve_int_cmp_0_wide<bits<3> opc, string asm, SDPatternOperator op> { 4723 def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR64>; 4724 def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR64>; 4725 def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR64>; 4726 4727 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>; 4728 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>; 4729 def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>; 4730} 4731 4732multiclass sve_int_cmp_1_wide<bits<3> opc, string asm, SDPatternOperator op> { 4733 def _B : sve_int_cmp<0b1, 0b00, opc, asm, PPR8, ZPR8, ZPR64>; 4734 def _H : sve_int_cmp<0b1, 0b01, opc, asm, PPR16, ZPR16, ZPR64>; 4735 def _S : sve_int_cmp<0b1, 0b10, opc, asm, PPR32, ZPR32, ZPR64>; 4736 4737 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>; 4738 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>; 4739 def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>; 4740} 4741 4742 4743//===----------------------------------------------------------------------===// 4744// SVE Integer Compare - Signed Immediate Group 4745//===----------------------------------------------------------------------===// 4746 4747class sve_int_scmp_vi<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty, 4748 ZPRRegOp zprty, 4749 Operand immtype> 4750: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm5), 4751 asm, "\t$Pd, $Pg/z, $Zn, $imm5", 4752 "", 4753 []>, Sched<[]> { 4754 bits<4> Pd; 4755 bits<3> Pg; 4756 bits<5> Zn; 4757 bits<5> imm5; 4758 let Inst{31-24} = 0b00100101; 4759 let Inst{23-22} = sz8_64; 4760 let Inst{21} = 0b0; 4761 let Inst{20-16} = imm5; 4762 let Inst{15} = opc{2}; 4763 let Inst{14} = 0b0; 4764 let Inst{13} = opc{1}; 4765 let Inst{12-10} = Pg; 4766 let Inst{9-5} = Zn; 4767 let Inst{4} = opc{0}; 4768 let Inst{3-0} = Pd; 4769 4770 let Defs = [NZCV]; 4771 let ElementSize = pprty.ElementSize; 4772 let isPTestLike = 1; 4773} 4774 4775multiclass SVE_SETCC_Imm_Pat<CondCode cc, CondCode commuted_cc, 4776 ValueType predvt, ValueType intvt, 4777 Operand immtype, Instruction cmp> { 4778 def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg), 4779 (intvt ZPR:$Zs1), 4780 (intvt (AArch64dup (immtype:$imm))), 4781 cc)), 4782 (cmp $Pg, $Zs1, immtype:$imm)>; 4783 def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg), 4784 (intvt (AArch64dup (immtype:$imm))), 4785 (intvt ZPR:$Zs1), 4786 commuted_cc)), 4787 (cmp $Pg, $Zs1, immtype:$imm)>; 4788} 4789 4790multiclass sve_int_scmp_vi<bits<3> opc, string asm, CondCode cc, CondCode commuted_cc> { 4791 def _B : sve_int_scmp_vi<0b00, opc, asm, PPR8, ZPR8, simm5_32b>; 4792 def _H : sve_int_scmp_vi<0b01, opc, asm, PPR16, ZPR16, simm5_32b>; 4793 def _S : sve_int_scmp_vi<0b10, opc, asm, PPR32, ZPR32, simm5_32b>; 4794 def _D : sve_int_scmp_vi<0b11, opc, asm, PPR64, ZPR64, simm5_64b>; 4795 4796 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv16i1, nxv16i8, simm5_32b, 4797 !cast<Instruction>(NAME # _B)>; 4798 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv8i1, nxv8i16, simm5_32b, 4799 !cast<Instruction>(NAME # _H)>; 4800 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv4i1, nxv4i32, simm5_32b, 4801 !cast<Instruction>(NAME # _S)>; 4802 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv2i1, nxv2i64, simm5_64b, 4803 !cast<Instruction>(NAME # _D)>; 4804} 4805 4806 4807//===----------------------------------------------------------------------===// 4808// SVE Integer Compare - Unsigned Immediate Group 4809//===----------------------------------------------------------------------===// 4810 4811class sve_int_ucmp_vi<bits<2> sz8_64, bits<2> opc, string asm, PPRRegOp pprty, 4812 ZPRRegOp zprty, Operand immtype> 4813: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm7), 4814 asm, "\t$Pd, $Pg/z, $Zn, $imm7", 4815 "", 4816 []>, Sched<[]> { 4817 bits<4> Pd; 4818 bits<3> Pg; 4819 bits<5> Zn; 4820 bits<7> imm7; 4821 let Inst{31-24} = 0b00100100; 4822 let Inst{23-22} = sz8_64; 4823 let Inst{21} = 1; 4824 let Inst{20-14} = imm7; 4825 let Inst{13} = opc{1}; 4826 let Inst{12-10} = Pg; 4827 let Inst{9-5} = Zn; 4828 let Inst{4} = opc{0}; 4829 let Inst{3-0} = Pd; 4830 4831 let Defs = [NZCV]; 4832 let ElementSize = pprty.ElementSize; 4833 let isPTestLike = 1; 4834} 4835 4836multiclass sve_int_ucmp_vi<bits<2> opc, string asm, CondCode cc, 4837 CondCode commuted_cc> { 4838 def _B : sve_int_ucmp_vi<0b00, opc, asm, PPR8, ZPR8, imm0_127>; 4839 def _H : sve_int_ucmp_vi<0b01, opc, asm, PPR16, ZPR16, imm0_127>; 4840 def _S : sve_int_ucmp_vi<0b10, opc, asm, PPR32, ZPR32, imm0_127>; 4841 def _D : sve_int_ucmp_vi<0b11, opc, asm, PPR64, ZPR64, imm0_127_64b>; 4842 4843 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv16i1, nxv16i8, imm0_127, 4844 !cast<Instruction>(NAME # _B)>; 4845 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv8i1, nxv8i16, imm0_127, 4846 !cast<Instruction>(NAME # _H)>; 4847 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv4i1, nxv4i32, imm0_127, 4848 !cast<Instruction>(NAME # _S)>; 4849 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv2i1, nxv2i64, imm0_127_64b, 4850 !cast<Instruction>(NAME # _D)>; 4851} 4852 4853 4854//===----------------------------------------------------------------------===// 4855// SVE Integer Compare - Scalars Group 4856//===----------------------------------------------------------------------===// 4857 4858class sve_int_cterm<bit sz, bit opc, string asm, RegisterClass rt> 4859: I<(outs), (ins rt:$Rn, rt:$Rm), 4860 asm, "\t$Rn, $Rm", 4861 "", 4862 []>, Sched<[]> { 4863 bits<5> Rm; 4864 bits<5> Rn; 4865 let Inst{31-23} = 0b001001011; 4866 let Inst{22} = sz; 4867 let Inst{21} = 0b1; 4868 let Inst{20-16} = Rm; 4869 let Inst{15-10} = 0b001000; 4870 let Inst{9-5} = Rn; 4871 let Inst{4} = opc; 4872 let Inst{3-0} = 0b0000; 4873 4874 let Defs = [NZCV]; 4875} 4876 4877class sve_int_while_rr<bits<2> sz8_64, bits<4> opc, string asm, 4878 RegisterClass gprty, PPRRegOp pprty> 4879: I<(outs pprty:$Pd), (ins gprty:$Rn, gprty:$Rm), 4880 asm, "\t$Pd, $Rn, $Rm", 4881 "", []>, Sched<[]> { 4882 bits<4> Pd; 4883 bits<5> Rm; 4884 bits<5> Rn; 4885 let Inst{31-24} = 0b00100101; 4886 let Inst{23-22} = sz8_64; 4887 let Inst{21} = 0b1; 4888 let Inst{20-16} = Rm; 4889 let Inst{15-13} = 0b000; 4890 let Inst{12-10} = opc{3-1}; 4891 let Inst{9-5} = Rn; 4892 let Inst{4} = opc{0}; 4893 let Inst{3-0} = Pd; 4894 4895 let Defs = [NZCV]; 4896 let ElementSize = pprty.ElementSize; 4897 let isWhile = 1; 4898} 4899 4900multiclass sve_int_while4_rr<bits<3> opc, string asm, SDPatternOperator op> { 4901 def _B : sve_int_while_rr<0b00, { 0, opc }, asm, GPR32, PPR8>; 4902 def _H : sve_int_while_rr<0b01, { 0, opc }, asm, GPR32, PPR16>; 4903 def _S : sve_int_while_rr<0b10, { 0, opc }, asm, GPR32, PPR32>; 4904 def _D : sve_int_while_rr<0b11, { 0, opc }, asm, GPR32, PPR64>; 4905 4906 def : SVE_2_Op_Pat<nxv16i1, op, i32, i32, !cast<Instruction>(NAME # _B)>; 4907 def : SVE_2_Op_Pat<nxv8i1, op, i32, i32, !cast<Instruction>(NAME # _H)>; 4908 def : SVE_2_Op_Pat<nxv4i1, op, i32, i32, !cast<Instruction>(NAME # _S)>; 4909 def : SVE_2_Op_Pat<nxv2i1, op, i32, i32, !cast<Instruction>(NAME # _D)>; 4910} 4911 4912multiclass sve_int_while8_rr<bits<3> opc, string asm, SDPatternOperator op> { 4913 def _B : sve_int_while_rr<0b00, { 1, opc }, asm, GPR64, PPR8>; 4914 def _H : sve_int_while_rr<0b01, { 1, opc }, asm, GPR64, PPR16>; 4915 def _S : sve_int_while_rr<0b10, { 1, opc }, asm, GPR64, PPR32>; 4916 def _D : sve_int_while_rr<0b11, { 1, opc }, asm, GPR64, PPR64>; 4917 4918 def : SVE_2_Op_Pat<nxv16i1, op, i64, i64, !cast<Instruction>(NAME # _B)>; 4919 def : SVE_2_Op_Pat<nxv8i1, op, i64, i64, !cast<Instruction>(NAME # _H)>; 4920 def : SVE_2_Op_Pat<nxv4i1, op, i64, i64, !cast<Instruction>(NAME # _S)>; 4921 def : SVE_2_Op_Pat<nxv2i1, op, i64, i64, !cast<Instruction>(NAME # _D)>; 4922} 4923 4924class sve2_int_while_rr<bits<2> sz8_64, bits<1> rw, string asm, 4925 PPRRegOp pprty> 4926: I<(outs pprty:$Pd), (ins GPR64:$Rn, GPR64:$Rm), 4927 asm, "\t$Pd, $Rn, $Rm", 4928 "", []>, Sched<[]> { 4929 bits<4> Pd; 4930 bits<5> Rm; 4931 bits<5> Rn; 4932 let Inst{31-24} = 0b00100101; 4933 let Inst{23-22} = sz8_64; 4934 let Inst{21} = 0b1; 4935 let Inst{20-16} = Rm; 4936 let Inst{15-10} = 0b001100; 4937 let Inst{9-5} = Rn; 4938 let Inst{4} = rw; 4939 let Inst{3-0} = Pd; 4940 4941 let Defs = [NZCV]; 4942 let ElementSize = pprty.ElementSize; 4943 let isWhile = 1; 4944} 4945 4946multiclass sve2_int_while_rr<bits<1> rw, string asm, string op> { 4947 def _B : sve2_int_while_rr<0b00, rw, asm, PPR8>; 4948 def _H : sve2_int_while_rr<0b01, rw, asm, PPR16>; 4949 def _S : sve2_int_while_rr<0b10, rw, asm, PPR32>; 4950 def _D : sve2_int_while_rr<0b11, rw, asm, PPR64>; 4951 4952 def : SVE_2_Op_Pat<nxv16i1, !cast<SDPatternOperator>(op # _b), i64, i64, !cast<Instruction>(NAME # _B)>; 4953 def : SVE_2_Op_Pat<nxv8i1, !cast<SDPatternOperator>(op # _h), i64, i64, !cast<Instruction>(NAME # _H)>; 4954 def : SVE_2_Op_Pat<nxv4i1, !cast<SDPatternOperator>(op # _s), i64, i64, !cast<Instruction>(NAME # _S)>; 4955 def : SVE_2_Op_Pat<nxv2i1, !cast<SDPatternOperator>(op # _d), i64, i64, !cast<Instruction>(NAME # _D)>; 4956} 4957 4958//===----------------------------------------------------------------------===// 4959// SVE Floating Point Fast Reduction Group 4960//===----------------------------------------------------------------------===// 4961 4962class sve_fp_fast_red<bits<2> sz, bits<3> opc, string asm, 4963 ZPRRegOp zprty, FPRasZPROperand dstOpType> 4964: I<(outs dstOpType:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn), 4965 asm, "\t$Vd, $Pg, $Zn", 4966 "", 4967 []>, Sched<[]> { 4968 bits<5> Zn; 4969 bits<5> Vd; 4970 bits<3> Pg; 4971 let Inst{31-24} = 0b01100101; 4972 let Inst{23-22} = sz; 4973 let Inst{21-19} = 0b000; 4974 let Inst{18-16} = opc; 4975 let Inst{15-13} = 0b001; 4976 let Inst{12-10} = Pg; 4977 let Inst{9-5} = Zn; 4978 let Inst{4-0} = Vd; 4979} 4980 4981multiclass sve_fp_fast_red<bits<3> opc, string asm, SDPatternOperator op> { 4982 def _H : sve_fp_fast_red<0b01, opc, asm, ZPR16, FPR16asZPR>; 4983 def _S : sve_fp_fast_red<0b10, opc, asm, ZPR32, FPR32asZPR>; 4984 def _D : sve_fp_fast_red<0b11, opc, asm, ZPR64, FPR64asZPR>; 4985 4986 def : SVE_2_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>; 4987 def : SVE_2_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>; 4988 def : SVE_2_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 4989 def : SVE_2_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>; 4990 def : SVE_2_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 4991 def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 4992} 4993 4994//===----------------------------------------------------------------------===// 4995// SVE Floating Point Accumulating Reduction Group 4996//===----------------------------------------------------------------------===// 4997 4998class sve_fp_2op_p_vd<bits<2> sz, bits<3> opc, string asm, 4999 ZPRRegOp zprty, FPRasZPROperand dstOpType> 5000: I<(outs dstOpType:$Vdn), (ins PPR3bAny:$Pg, dstOpType:$_Vdn, zprty:$Zm), 5001 asm, "\t$Vdn, $Pg, $_Vdn, $Zm", 5002 "", 5003 []>, 5004 Sched<[]> { 5005 bits<3> Pg; 5006 bits<5> Vdn; 5007 bits<5> Zm; 5008 let Inst{31-24} = 0b01100101; 5009 let Inst{23-22} = sz; 5010 let Inst{21-19} = 0b011; 5011 let Inst{18-16} = opc; 5012 let Inst{15-13} = 0b001; 5013 let Inst{12-10} = Pg; 5014 let Inst{9-5} = Zm; 5015 let Inst{4-0} = Vdn; 5016 5017 let Constraints = "$Vdn = $_Vdn"; 5018} 5019 5020multiclass sve_fp_2op_p_vd<bits<3> opc, string asm, SDPatternOperator op> { 5021 def _H : sve_fp_2op_p_vd<0b01, opc, asm, ZPR16, FPR16asZPR>; 5022 def _S : sve_fp_2op_p_vd<0b10, opc, asm, ZPR32, FPR32asZPR>; 5023 def _D : sve_fp_2op_p_vd<0b11, opc, asm, ZPR64, FPR64asZPR>; 5024 5025 def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _H)>; 5026 def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _H)>; 5027 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 5028 def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _S)>; 5029 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 5030 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 5031} 5032 5033//===----------------------------------------------------------------------===// 5034// SVE Floating Point Compare - Vectors Group 5035//===----------------------------------------------------------------------===// 5036 5037class sve_fp_3op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty, 5038 ZPRRegOp zprty> 5039: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm), 5040 asm, "\t$Pd, $Pg/z, $Zn, $Zm", 5041 "", 5042 []>, Sched<[]> { 5043 bits<4> Pd; 5044 bits<3> Pg; 5045 bits<5> Zm; 5046 bits<5> Zn; 5047 let Inst{31-24} = 0b01100101; 5048 let Inst{23-22} = sz; 5049 let Inst{21} = 0b0; 5050 let Inst{20-16} = Zm; 5051 let Inst{15} = opc{2}; 5052 let Inst{14} = 0b1; 5053 let Inst{13} = opc{1}; 5054 let Inst{12-10} = Pg; 5055 let Inst{9-5} = Zn; 5056 let Inst{4} = opc{0}; 5057 let Inst{3-0} = Pd; 5058} 5059 5060multiclass sve_fp_3op_p_pd<bits<3> opc, string asm, SDPatternOperator op> { 5061 def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>; 5062 def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>; 5063 def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>; 5064 5065 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 5066 def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 5067 def : SVE_3_Op_Pat<nxv2i1, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 5068} 5069 5070multiclass sve_fp_3op_p_pd_cc<bits<3> opc, string asm, 5071 CondCode cc1, CondCode cc2, 5072 CondCode invcc1, CondCode invcc2> { 5073 def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>; 5074 def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>; 5075 def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>; 5076 5077 defm : SVE_SETCC_Pat<cc1, invcc1, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 5078 defm : SVE_SETCC_Pat<cc1, invcc1, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>; 5079 defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>; 5080 defm : SVE_SETCC_Pat<cc1, invcc1, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 5081 defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>; 5082 defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 5083 5084 defm : SVE_SETCC_Pat<cc2, invcc2, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 5085 defm : SVE_SETCC_Pat<cc2, invcc2, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>; 5086 defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>; 5087 defm : SVE_SETCC_Pat<cc2, invcc2, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 5088 defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>; 5089 defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 5090} 5091 5092//===----------------------------------------------------------------------===// 5093// SVE Floating Point Compare - with Zero Group 5094//===----------------------------------------------------------------------===// 5095 5096class sve_fp_2op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty, 5097 ZPRRegOp zprty> 5098: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn), 5099 asm, "\t$Pd, $Pg/z, $Zn, #0.0", 5100 "", 5101 []>, Sched<[]> { 5102 bits<4> Pd; 5103 bits<3> Pg; 5104 bits<5> Zn; 5105 let Inst{31-24} = 0b01100101; 5106 let Inst{23-22} = sz; 5107 let Inst{21-18} = 0b0100; 5108 let Inst{17-16} = opc{2-1}; 5109 let Inst{15-13} = 0b001; 5110 let Inst{12-10} = Pg; 5111 let Inst{9-5} = Zn; 5112 let Inst{4} = opc{0}; 5113 let Inst{3-0} = Pd; 5114} 5115 5116multiclass sve_fp_2op_p_pd<bits<3> opc, string asm, 5117 CondCode cc1, CondCode cc2, 5118 CondCode invcc1, CondCode invcc2> { 5119 def _H : sve_fp_2op_p_pd<0b01, opc, asm, PPR16, ZPR16>; 5120 def _S : sve_fp_2op_p_pd<0b10, opc, asm, PPR32, ZPR32>; 5121 def _D : sve_fp_2op_p_pd<0b11, opc, asm, PPR64, ZPR64>; 5122 5123 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 5124 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>; 5125 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>; 5126 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 5127 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>; 5128 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 5129 5130 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 5131 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>; 5132 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>; 5133 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 5134 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>; 5135 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 5136} 5137 5138 5139//===----------------------------------------------------------------------===// 5140//SVE Index Generation Group 5141//===----------------------------------------------------------------------===// 5142 5143def simm5_8b_tgt : TImmLeaf<i8, [{ return (int8_t)Imm >= -16 && (int8_t)Imm < 16; }]>; 5144def simm5_16b_tgt : TImmLeaf<i16, [{ return (int16_t)Imm >= -16 && (int16_t)Imm < 16; }]>; 5145def simm5_32b_tgt : TImmLeaf<i32, [{ return (int32_t)Imm >= -16 && (int32_t)Imm < 16; }]>; 5146def simm5_64b_tgt : TImmLeaf<i64, [{ return (int64_t)Imm >= -16 && (int64_t)Imm < 16; }]>; 5147def i64imm_32bit_tgt : TImmLeaf<i64, [{ 5148 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm); 5149}]>; 5150 5151class sve_int_index_ii<bits<2> sz8_64, string asm, ZPRRegOp zprty, 5152 Operand imm_ty> 5153: I<(outs zprty:$Zd), (ins imm_ty:$imm5, imm_ty:$imm5b), 5154 asm, "\t$Zd, $imm5, $imm5b", 5155 "", []>, Sched<[]> { 5156 bits<5> Zd; 5157 bits<5> imm5; 5158 bits<5> imm5b; 5159 let Inst{31-24} = 0b00000100; 5160 let Inst{23-22} = sz8_64; 5161 let Inst{21} = 0b1; 5162 let Inst{20-16} = imm5b; 5163 let Inst{15-10} = 0b010000; 5164 let Inst{9-5} = imm5; 5165 let Inst{4-0} = Zd; 5166} 5167 5168multiclass sve_int_index_ii<string asm> { 5169 def _B : sve_int_index_ii<0b00, asm, ZPR8, simm5_8b>; 5170 def _H : sve_int_index_ii<0b01, asm, ZPR16, simm5_16b>; 5171 def _S : sve_int_index_ii<0b10, asm, ZPR32, simm5_32b>; 5172 def _D : sve_int_index_ii<0b11, asm, ZPR64, simm5_64b>; 5173 5174 def : Pat<(nxv16i8 (step_vector simm5_8b_tgt:$imm5b)), 5175 (!cast<Instruction>(NAME # "_B") (i32 0), (!cast<SDNodeXForm>("trunc_imm") $imm5b))>; 5176 def : Pat<(nxv8i16 (step_vector simm5_16b_tgt:$imm5b)), 5177 (!cast<Instruction>(NAME # "_H") (i32 0), (!cast<SDNodeXForm>("trunc_imm") $imm5b))>; 5178 def : Pat<(nxv4i32 (step_vector simm5_32b_tgt:$imm5b)), 5179 (!cast<Instruction>(NAME # "_S") (i32 0), simm5_32b:$imm5b)>; 5180 def : Pat<(nxv2i64 (step_vector simm5_64b_tgt:$imm5b)), 5181 (!cast<Instruction>(NAME # "_D") (i64 0), simm5_64b:$imm5b)>; 5182 5183 // add(step_vector(step), dup(X)) -> index(X, step). 5184 def : Pat<(add (nxv16i8 (step_vector_oneuse simm5_8b_tgt:$imm5b)), (nxv16i8 (AArch64dup(simm5_8b:$imm5)))), 5185 (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, (!cast<SDNodeXForm>("trunc_imm") $imm5b))>; 5186 def : Pat<(add (nxv8i16 (step_vector_oneuse simm5_16b_tgt:$imm5b)), (nxv8i16 (AArch64dup(simm5_16b:$imm5)))), 5187 (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, (!cast<SDNodeXForm>("trunc_imm") $imm5b))>; 5188 def : Pat<(add (nxv4i32 (step_vector_oneuse simm5_32b_tgt:$imm5b)), (nxv4i32 (AArch64dup(simm5_32b:$imm5)))), 5189 (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, simm5_32b:$imm5b)>; 5190 def : Pat<(add (nxv2i64 (step_vector_oneuse simm5_64b_tgt:$imm5b)), (nxv2i64 (AArch64dup(simm5_64b:$imm5)))), 5191 (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, simm5_64b:$imm5b)>; 5192} 5193 5194class sve_int_index_ir<bits<2> sz8_64, string asm, ZPRRegOp zprty, 5195 RegisterClass srcRegType, Operand imm_ty> 5196: I<(outs zprty:$Zd), (ins imm_ty:$imm5, srcRegType:$Rm), 5197 asm, "\t$Zd, $imm5, $Rm", 5198 "", []>, Sched<[]> { 5199 bits<5> Rm; 5200 bits<5> Zd; 5201 bits<5> imm5; 5202 let Inst{31-24} = 0b00000100; 5203 let Inst{23-22} = sz8_64; 5204 let Inst{21} = 0b1; 5205 let Inst{20-16} = Rm; 5206 let Inst{15-10} = 0b010010; 5207 let Inst{9-5} = imm5; 5208 let Inst{4-0} = Zd; 5209} 5210 5211multiclass sve_int_index_ir<string asm, SDPatternOperator mulop, SDPatternOperator muloneuseop> { 5212 def _B : sve_int_index_ir<0b00, asm, ZPR8, GPR32, simm5_8b>; 5213 def _H : sve_int_index_ir<0b01, asm, ZPR16, GPR32, simm5_16b>; 5214 def _S : sve_int_index_ir<0b10, asm, ZPR32, GPR32, simm5_32b>; 5215 def _D : sve_int_index_ir<0b11, asm, ZPR64, GPR64, simm5_64b>; 5216 5217 def : Pat<(nxv16i8 (step_vector i8:$imm)), 5218 (!cast<Instruction>(NAME # "_B") (i32 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>; 5219 def : Pat<(nxv8i16 (step_vector i16:$imm)), 5220 (!cast<Instruction>(NAME # "_H") (i32 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>; 5221 def : Pat<(nxv4i32 (step_vector i32:$imm)), 5222 (!cast<Instruction>(NAME # "_S") (i32 0), (!cast<Instruction>("MOVi32imm") $imm))>; 5223 def : Pat<(nxv2i64 (step_vector i64:$imm)), 5224 (!cast<Instruction>(NAME # "_D") (i64 0), (!cast<Instruction>("MOVi64imm") $imm))>; 5225 def : Pat<(nxv2i64 (step_vector i64imm_32bit_tgt:$imm)), 5226 (!cast<Instruction>(NAME # "_D") (i64 0), (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>; 5227 5228 // add(step_vector(step), dup(X)) -> index(X, step). 5229 def : Pat<(add (nxv16i8 (step_vector_oneuse i8:$imm)), (nxv16i8 (AArch64dup(simm5_8b:$imm5)))), 5230 (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>; 5231 def : Pat<(add (nxv8i16 (step_vector_oneuse i16:$imm)), (nxv8i16 (AArch64dup(simm5_16b:$imm5)))), 5232 (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>; 5233 def : Pat<(add (nxv4i32 (step_vector_oneuse i32:$imm)), (nxv4i32 (AArch64dup(simm5_32b:$imm5)))), 5234 (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, (!cast<Instruction>("MOVi32imm") $imm))>; 5235 def : Pat<(add (nxv2i64 (step_vector_oneuse i64:$imm)), (nxv2i64 (AArch64dup(simm5_64b:$imm5)))), 5236 (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, (!cast<Instruction>("MOVi64imm") $imm))>; 5237 def : Pat<(add (nxv2i64 (step_vector_oneuse i64imm_32bit_tgt:$imm)), (nxv2i64 (AArch64dup(simm5_64b:$imm5)))), 5238 (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>; 5239 5240 // mul(step_vector(1), dup(Y)) -> index(0, Y). 5241 def : Pat<(mulop (nxv16i1 (AArch64ptrue 31)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (AArch64dup(i32 GPR32:$Rm)))), 5242 (!cast<Instruction>(NAME # "_B") (i32 0), GPR32:$Rm)>; 5243 def : Pat<(mulop (nxv8i1 (AArch64ptrue 31)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (AArch64dup(i32 GPR32:$Rm)))), 5244 (!cast<Instruction>(NAME # "_H") (i32 0), GPR32:$Rm)>; 5245 def : Pat<(mulop (nxv4i1 (AArch64ptrue 31)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (AArch64dup(i32 GPR32:$Rm)))), 5246 (!cast<Instruction>(NAME # "_S") (i32 0), GPR32:$Rm)>; 5247 def : Pat<(mulop (nxv2i1 (AArch64ptrue 31)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (AArch64dup(i64 GPR64:$Rm)))), 5248 (!cast<Instruction>(NAME # "_D") (i64 0), GPR64:$Rm)>; 5249 5250 // add(mul(step_vector(1), dup(Y)), dup(X)) -> index(X, Y). 5251 def : Pat<(add (muloneuseop (nxv16i1 (AArch64ptrue 31)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (AArch64dup(i32 GPR32:$Rm)))), (nxv16i8 (AArch64dup(simm5_8b:$imm5)))), 5252 (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, GPR32:$Rm)>; 5253 def : Pat<(add (muloneuseop (nxv8i1 (AArch64ptrue 31)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (AArch64dup(i32 GPR32:$Rm)))), (nxv8i16 (AArch64dup(simm5_16b:$imm5)))), 5254 (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, GPR32:$Rm)>; 5255 def : Pat<(add (muloneuseop (nxv4i1 (AArch64ptrue 31)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (AArch64dup(i32 GPR32:$Rm)))), (nxv4i32 (AArch64dup(simm5_32b:$imm5)))), 5256 (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, GPR32:$Rm)>; 5257 def : Pat<(add (muloneuseop (nxv2i1 (AArch64ptrue 31)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (AArch64dup(i64 GPR64:$Rm)))), (nxv2i64 (AArch64dup(simm5_64b:$imm5)))), 5258 (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, GPR64:$Rm)>; 5259} 5260 5261class sve_int_index_ri<bits<2> sz8_64, string asm, ZPRRegOp zprty, 5262 RegisterClass srcRegType, Operand imm_ty> 5263: I<(outs zprty:$Zd), (ins srcRegType:$Rn, imm_ty:$imm5), 5264 asm, "\t$Zd, $Rn, $imm5", 5265 "", []>, Sched<[]> { 5266 bits<5> Rn; 5267 bits<5> Zd; 5268 bits<5> imm5; 5269 let Inst{31-24} = 0b00000100; 5270 let Inst{23-22} = sz8_64; 5271 let Inst{21} = 0b1; 5272 let Inst{20-16} = imm5; 5273 let Inst{15-10} = 0b010001; 5274 let Inst{9-5} = Rn; 5275 let Inst{4-0} = Zd; 5276} 5277 5278multiclass sve_int_index_ri<string asm> { 5279 def _B : sve_int_index_ri<0b00, asm, ZPR8, GPR32, simm5_8b>; 5280 def _H : sve_int_index_ri<0b01, asm, ZPR16, GPR32, simm5_16b>; 5281 def _S : sve_int_index_ri<0b10, asm, ZPR32, GPR32, simm5_32b>; 5282 def _D : sve_int_index_ri<0b11, asm, ZPR64, GPR64, simm5_64b>; 5283 5284 // add(step_vector(step), dup(X)) -> index(X, step). 5285 def : Pat<(add (nxv16i8 (step_vector_oneuse simm5_8b_tgt:$imm5)), (nxv16i8 (AArch64dup(i32 GPR32:$Rm)))), 5286 (!cast<Instruction>(NAME # "_B") GPR32:$Rm, (!cast<SDNodeXForm>("trunc_imm") $imm5))>; 5287 def : Pat<(add (nxv8i16 (step_vector_oneuse simm5_16b_tgt:$imm5)), (nxv8i16 (AArch64dup(i32 GPR32:$Rm)))), 5288 (!cast<Instruction>(NAME # "_H") GPR32:$Rm, (!cast<SDNodeXForm>("trunc_imm") $imm5))>; 5289 def : Pat<(add (nxv4i32 (step_vector_oneuse simm5_32b_tgt:$imm5)), (nxv4i32 (AArch64dup(i32 GPR32:$Rm)))), 5290 (!cast<Instruction>(NAME # "_S") GPR32:$Rm, simm5_32b:$imm5)>; 5291 def : Pat<(add (nxv2i64 (step_vector_oneuse simm5_64b_tgt:$imm5)), (nxv2i64 (AArch64dup(i64 GPR64:$Rm)))), 5292 (!cast<Instruction>(NAME # "_D") GPR64:$Rm, simm5_64b:$imm5)>; 5293} 5294 5295class sve_int_index_rr<bits<2> sz8_64, string asm, ZPRRegOp zprty, 5296 RegisterClass srcRegType> 5297: I<(outs zprty:$Zd), (ins srcRegType:$Rn, srcRegType:$Rm), 5298 asm, "\t$Zd, $Rn, $Rm", 5299 "", []>, Sched<[]> { 5300 bits<5> Zd; 5301 bits<5> Rm; 5302 bits<5> Rn; 5303 let Inst{31-24} = 0b00000100; 5304 let Inst{23-22} = sz8_64; 5305 let Inst{21} = 0b1; 5306 let Inst{20-16} = Rm; 5307 let Inst{15-10} = 0b010011; 5308 let Inst{9-5} = Rn; 5309 let Inst{4-0} = Zd; 5310} 5311 5312multiclass sve_int_index_rr<string asm, SDPatternOperator mulop> { 5313 def _B : sve_int_index_rr<0b00, asm, ZPR8, GPR32>; 5314 def _H : sve_int_index_rr<0b01, asm, ZPR16, GPR32>; 5315 def _S : sve_int_index_rr<0b10, asm, ZPR32, GPR32>; 5316 def _D : sve_int_index_rr<0b11, asm, ZPR64, GPR64>; 5317 5318 // add(step_vector(step), dup(X)) -> index(X, step). 5319 def : Pat<(add (nxv16i8 (step_vector_oneuse i8:$imm)), (nxv16i8 (AArch64dup(i32 GPR32:$Rn)))), 5320 (!cast<Instruction>(NAME # "_B") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>; 5321 def : Pat<(add (nxv8i16 (step_vector_oneuse i16:$imm)), (nxv8i16 (AArch64dup(i32 GPR32:$Rn)))), 5322 (!cast<Instruction>(NAME # "_H") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>; 5323 def : Pat<(add (nxv4i32 (step_vector_oneuse i32:$imm)), (nxv4i32 (AArch64dup(i32 GPR32:$Rn)))), 5324 (!cast<Instruction>(NAME # "_S") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") $imm))>; 5325 def : Pat<(add (nxv2i64 (step_vector_oneuse i64:$imm)), (nxv2i64 (AArch64dup(i64 GPR64:$Rn)))), 5326 (!cast<Instruction>(NAME # "_D") GPR64:$Rn, (!cast<Instruction>("MOVi64imm") $imm))>; 5327 def : Pat<(add (nxv2i64 (step_vector_oneuse i64imm_32bit_tgt:$imm)), (nxv2i64 (AArch64dup(i64 GPR64:$Rn)))), 5328 (!cast<Instruction>(NAME # "_D") GPR64:$Rn, (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>; 5329 5330 // add(mul(step_vector(1), dup(Y)), dup(X)) -> index(X, Y). 5331 def : Pat<(add (mulop (nxv16i1 (AArch64ptrue 31)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (AArch64dup(i32 GPR32:$Rm)))), (nxv16i8 (AArch64dup(i32 GPR32:$Rn)))), 5332 (!cast<Instruction>(NAME # "_B") GPR32:$Rn, GPR32:$Rm)>; 5333 def : Pat<(add (mulop (nxv8i1 (AArch64ptrue 31)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (AArch64dup(i32 GPR32:$Rm)))),(nxv8i16 (AArch64dup(i32 GPR32:$Rn)))), 5334 (!cast<Instruction>(NAME # "_H") GPR32:$Rn, GPR32:$Rm)>; 5335 def : Pat<(add (mulop (nxv4i1 (AArch64ptrue 31)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (AArch64dup(i32 GPR32:$Rm)))),(nxv4i32 (AArch64dup(i32 GPR32:$Rn)))), 5336 (!cast<Instruction>(NAME # "_S") GPR32:$Rn, GPR32:$Rm)>; 5337 def : Pat<(add (mulop (nxv2i1 (AArch64ptrue 31)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (AArch64dup(i64 GPR64:$Rm)))),(nxv2i64 (AArch64dup(i64 GPR64:$Rn)))), 5338 (!cast<Instruction>(NAME # "_D") GPR64:$Rn, GPR64:$Rm)>; 5339} 5340 5341//===----------------------------------------------------------------------===// 5342// SVE Bitwise Shift - Predicated Group 5343//===----------------------------------------------------------------------===// 5344 5345class sve_int_bin_pred_shift_imm<bits<4> tsz8_64, bits<4> opc, string asm, 5346 ZPRRegOp zprty, Operand immtype> 5347: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, immtype:$imm), 5348 asm, "\t$Zdn, $Pg/m, $_Zdn, $imm", 5349 "", 5350 []>, Sched<[]> { 5351 bits<3> Pg; 5352 bits<5> Zdn; 5353 bits<6> imm; 5354 let Inst{31-24} = 0b00000100; 5355 let Inst{23-22} = tsz8_64{3-2}; 5356 let Inst{21-20} = 0b00; 5357 let Inst{19-16} = opc; 5358 let Inst{15-13} = 0b100; 5359 let Inst{12-10} = Pg; 5360 let Inst{9-8} = tsz8_64{1-0}; 5361 let Inst{7-5} = imm{2-0}; // imm3 5362 let Inst{4-0} = Zdn; 5363 5364 let Constraints = "$Zdn = $_Zdn"; 5365 let DestructiveInstType = DestructiveBinaryImm; 5366 let ElementSize = zprty.ElementSize; 5367} 5368 5369multiclass sve_int_bin_pred_shift_imm_left<bits<4> opc, string asm, string Ps, 5370 SDPatternOperator op = null_frag> { 5371 def _B : SVEPseudo2Instr<Ps # _B, 1>, 5372 sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>; 5373 def _H : SVEPseudo2Instr<Ps # _H, 1>, 5374 sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> { 5375 let Inst{8} = imm{3}; 5376 } 5377 def _S : SVEPseudo2Instr<Ps # _S, 1>, 5378 sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> { 5379 let Inst{9-8} = imm{4-3}; 5380 } 5381 def _D : SVEPseudo2Instr<Ps # _D, 1>, 5382 sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> { 5383 let Inst{22} = imm{5}; 5384 let Inst{9-8} = imm{4-3}; 5385 } 5386 5387 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i1, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _B)>; 5388 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i1, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _H)>; 5389 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i1, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _S)>; 5390 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i1, nxv2i64, i32, tvecshiftL64, !cast<Instruction>(NAME # _D)>; 5391} 5392 5393// As above but shift amount takes the form of a "vector immediate". 5394multiclass sve_int_bin_pred_shift_imm_left_dup<bits<4> opc, string asm, 5395 string Ps, SDPatternOperator op> 5396: sve_int_bin_pred_shift_imm_left<opc, asm, Ps, null_frag> { 5397 def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmL8, !cast<Instruction>(NAME # _B)>; 5398 def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmL16, !cast<Instruction>(NAME # _H)>; 5399 def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmL32, !cast<Instruction>(NAME # _S)>; 5400 def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmL64, !cast<Instruction>(NAME # _D)>; 5401} 5402 5403multiclass sve_int_bin_pred_shift_imm_left_zeroing_bhsd<SDPatternOperator op> { 5404 def _ZERO_B : PredTwoOpImmPseudo<NAME # _B, ZPR8, tvecshiftL8, FalseLanesZero>; 5405 def _ZERO_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, tvecshiftL16, FalseLanesZero>; 5406 def _ZERO_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, tvecshiftL32, FalseLanesZero>; 5407 def _ZERO_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, tvecshiftL64, FalseLanesZero>; 5408 5409 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv16i8, op, nxv16i1, nxv16i8, tvecshiftL8, !cast<Pseudo>(NAME # _ZERO_B)>; 5410 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv8i16, op, nxv8i1, nxv8i16, tvecshiftL16, !cast<Pseudo>(NAME # _ZERO_H)>; 5411 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv4i32, op, nxv4i1, nxv4i32, tvecshiftL32, !cast<Pseudo>(NAME # _ZERO_S)>; 5412 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv2i64, op, nxv2i1, nxv2i64, tvecshiftL64, !cast<Pseudo>(NAME # _ZERO_D)>; 5413} 5414 5415multiclass sve_int_bin_pred_shift_imm_right<bits<4> opc, string asm, string Ps, 5416 SDPatternOperator op = null_frag> { 5417 def _B : SVEPseudo2Instr<Ps # _B, 1>, 5418 sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>; 5419 def _H : SVEPseudo2Instr<Ps # _H, 1>, 5420 sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> { 5421 let Inst{8} = imm{3}; 5422 } 5423 def _S : SVEPseudo2Instr<Ps # _S, 1>, 5424 sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> { 5425 let Inst{9-8} = imm{4-3}; 5426 } 5427 def _D : SVEPseudo2Instr<Ps # _D, 1>, 5428 sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> { 5429 let Inst{22} = imm{5}; 5430 let Inst{9-8} = imm{4-3}; 5431 } 5432 5433 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i1, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>; 5434 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i1, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>; 5435 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i1, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>; 5436 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i1, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>; 5437} 5438 5439// As above but shift amount takes the form of a "vector immediate". 5440multiclass sve_int_bin_pred_shift_imm_right_dup<bits<4> opc, string asm, 5441 string Ps, SDPatternOperator op> 5442: sve_int_bin_pred_shift_imm_right<opc, asm, Ps, null_frag> { 5443 def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmR8, !cast<Instruction>(NAME # _B)>; 5444 def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmR16, !cast<Instruction>(NAME # _H)>; 5445 def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmR32, !cast<Instruction>(NAME # _S)>; 5446 def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmR64, !cast<Instruction>(NAME # _D)>; 5447} 5448 5449multiclass sve_int_bin_pred_shift_imm_right_zeroing_bhsd<SDPatternOperator op = null_frag> { 5450 def _ZERO_B : PredTwoOpImmPseudo<NAME # _B, ZPR8, vecshiftR8, FalseLanesZero>; 5451 def _ZERO_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, vecshiftR16, FalseLanesZero>; 5452 def _ZERO_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, vecshiftR32, FalseLanesZero>; 5453 def _ZERO_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, vecshiftR64, FalseLanesZero>; 5454 5455 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv16i8, op, nxv16i1, nxv16i8, tvecshiftR8, !cast<Pseudo>(NAME # _ZERO_B)>; 5456 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv8i16, op, nxv8i1, nxv8i16, tvecshiftR16, !cast<Pseudo>(NAME # _ZERO_H)>; 5457 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv4i32, op, nxv4i1, nxv4i32, tvecshiftR32, !cast<Pseudo>(NAME # _ZERO_S)>; 5458 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv2i64, op, nxv2i1, nxv2i64, tvecshiftR64, !cast<Pseudo>(NAME # _ZERO_D)>; 5459} 5460 5461class sve_int_bin_pred_shift<bits<2> sz8_64, bit wide, bits<3> opc, 5462 string asm, ZPRRegOp zprty, ZPRRegOp zprty2> 5463: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty2:$Zm), 5464 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", 5465 "", 5466 []>, Sched<[]> { 5467 bits<3> Pg; 5468 bits<5> Zdn; 5469 bits<5> Zm; 5470 let Inst{31-24} = 0b00000100; 5471 let Inst{23-22} = sz8_64; 5472 let Inst{21-20} = 0b01; 5473 let Inst{19} = wide; 5474 let Inst{18-16} = opc; 5475 let Inst{15-13} = 0b100; 5476 let Inst{12-10} = Pg; 5477 let Inst{9-5} = Zm; 5478 let Inst{4-0} = Zdn; 5479 5480 let Constraints = "$Zdn = $_Zdn"; 5481 let DestructiveInstType = DestructiveOther; 5482 let ElementSize = zprty.ElementSize; 5483} 5484 5485multiclass sve_int_bin_pred_shift<bits<3> opc, string asm, string Ps, 5486 SDPatternOperator op, string revname, bit isReverseInstr = 0> { 5487 let DestructiveInstType = DestructiveBinaryCommWithRev in { 5488 def _B : sve_int_bin_pred_shift<0b00, 0b0, opc, asm, ZPR8, ZPR8>, 5489 SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>; 5490 def _H : sve_int_bin_pred_shift<0b01, 0b0, opc, asm, ZPR16, ZPR16>, 5491 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>; 5492 def _S : sve_int_bin_pred_shift<0b10, 0b0, opc, asm, ZPR32, ZPR32>, 5493 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>; 5494 def _D : sve_int_bin_pred_shift<0b11, 0b0, opc, asm, ZPR64, ZPR64>, 5495 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>; 5496 } 5497 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 5498 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 5499 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 5500 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 5501} 5502 5503multiclass sve_int_bin_pred_zeroing_bhsd<SDPatternOperator op> { 5504 def _ZERO_B : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesZero>; 5505 def _ZERO_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesZero>; 5506 def _ZERO_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesZero>; 5507 def _ZERO_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesZero>; 5508 5509 def : SVE_3_Op_Pat_SelZero<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _ZERO_B)>; 5510 def : SVE_3_Op_Pat_SelZero<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _ZERO_H)>; 5511 def : SVE_3_Op_Pat_SelZero<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _ZERO_S)>; 5512 def : SVE_3_Op_Pat_SelZero<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _ZERO_D)>; 5513} 5514 5515multiclass sve_int_bin_pred_shift_wide<bits<3> opc, string asm, 5516 SDPatternOperator op> { 5517 def _B : sve_int_bin_pred_shift<0b00, 0b1, opc, asm, ZPR8, ZPR64>; 5518 def _H : sve_int_bin_pred_shift<0b01, 0b1, opc, asm, ZPR16, ZPR64>; 5519 def _S : sve_int_bin_pred_shift<0b10, 0b1, opc, asm, ZPR32, ZPR64>; 5520 5521 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>; 5522 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>; 5523 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>; 5524} 5525 5526//===----------------------------------------------------------------------===// 5527// SVE Shift - Unpredicated Group 5528//===----------------------------------------------------------------------===// 5529 5530class sve_int_bin_cons_shift_wide<bits<2> sz8_64, bits<2> opc, string asm, 5531 ZPRRegOp zprty> 5532: I<(outs zprty:$Zd), (ins zprty:$Zn, ZPR64:$Zm), 5533 asm, "\t$Zd, $Zn, $Zm", 5534 "", 5535 []>, Sched<[]> { 5536 bits<5> Zd; 5537 bits<5> Zm; 5538 bits<5> Zn; 5539 let Inst{31-24} = 0b00000100; 5540 let Inst{23-22} = sz8_64; 5541 let Inst{21} = 0b1; 5542 let Inst{20-16} = Zm; 5543 let Inst{15-12} = 0b1000; 5544 let Inst{11-10} = opc; 5545 let Inst{9-5} = Zn; 5546 let Inst{4-0} = Zd; 5547} 5548 5549multiclass sve_int_bin_cons_shift_wide<bits<2> opc, string asm, SDPatternOperator op> { 5550 def _B : sve_int_bin_cons_shift_wide<0b00, opc, asm, ZPR8>; 5551 def _H : sve_int_bin_cons_shift_wide<0b01, opc, asm, ZPR16>; 5552 def _S : sve_int_bin_cons_shift_wide<0b10, opc, asm, ZPR32>; 5553 5554 def : SVE_2_Op_Pred_All_Active<nxv16i8, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>; 5555 def : SVE_2_Op_Pred_All_Active<nxv8i16, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>; 5556 def : SVE_2_Op_Pred_All_Active<nxv4i32, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>; 5557} 5558 5559class sve_int_bin_cons_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm, 5560 ZPRRegOp zprty, Operand immtype> 5561: I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$imm), 5562 asm, "\t$Zd, $Zn, $imm", 5563 "", 5564 []>, Sched<[]> { 5565 bits<5> Zd; 5566 bits<5> Zn; 5567 bits<6> imm; 5568 let Inst{31-24} = 0b00000100; 5569 let Inst{23-22} = tsz8_64{3-2}; 5570 let Inst{21} = 0b1; 5571 let Inst{20-19} = tsz8_64{1-0}; 5572 let Inst{18-16} = imm{2-0}; // imm3 5573 let Inst{15-12} = 0b1001; 5574 let Inst{11-10} = opc; 5575 let Inst{9-5} = Zn; 5576 let Inst{4-0} = Zd; 5577} 5578 5579multiclass sve_int_bin_cons_shift_imm_left<bits<2> opc, string asm, 5580 SDPatternOperator op> { 5581 def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>; 5582 def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> { 5583 let Inst{19} = imm{3}; 5584 } 5585 def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> { 5586 let Inst{20-19} = imm{4-3}; 5587 } 5588 def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> { 5589 let Inst{22} = imm{5}; 5590 let Inst{20-19} = imm{4-3}; 5591 } 5592 5593 def : SVE_Shift_DupImm_All_Active_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmL8, !cast<Instruction>(NAME # _B)>; 5594 def : SVE_Shift_DupImm_All_Active_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmL16, !cast<Instruction>(NAME # _H)>; 5595 def : SVE_Shift_DupImm_All_Active_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmL32, !cast<Instruction>(NAME # _S)>; 5596 def : SVE_Shift_DupImm_All_Active_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmL64, !cast<Instruction>(NAME # _D)>; 5597} 5598 5599multiclass sve_int_bin_cons_shift_imm_right<bits<2> opc, string asm, 5600 SDPatternOperator op> { 5601 def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>; 5602 def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> { 5603 let Inst{19} = imm{3}; 5604 } 5605 def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> { 5606 let Inst{20-19} = imm{4-3}; 5607 } 5608 def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> { 5609 let Inst{22} = imm{5}; 5610 let Inst{20-19} = imm{4-3}; 5611 } 5612 5613 def : SVE_Shift_DupImm_All_Active_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmR8, !cast<Instruction>(NAME # _B)>; 5614 def : SVE_Shift_DupImm_All_Active_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmR16, !cast<Instruction>(NAME # _H)>; 5615 def : SVE_Shift_DupImm_All_Active_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmR32, !cast<Instruction>(NAME # _S)>; 5616 def : SVE_Shift_DupImm_All_Active_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmR64, !cast<Instruction>(NAME # _D)>; 5617} 5618 5619//===----------------------------------------------------------------------===// 5620// SVE Memory - Store Group 5621//===----------------------------------------------------------------------===// 5622 5623class sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm, 5624 RegisterOperand VecList> 5625: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 5626 asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]", 5627 "", 5628 []>, Sched<[]> { 5629 bits<3> Pg; 5630 bits<5> Rn; 5631 bits<5> Zt; 5632 bits<4> imm4; 5633 let Inst{31-25} = 0b1110010; 5634 let Inst{24-23} = msz; 5635 let Inst{22-21} = esz; 5636 let Inst{20} = 0; 5637 let Inst{19-16} = imm4; 5638 let Inst{15-13} = 0b111; 5639 let Inst{12-10} = Pg; 5640 let Inst{9-5} = Rn; 5641 let Inst{4-0} = Zt; 5642 5643 let mayStore = 1; 5644} 5645 5646multiclass sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm, 5647 RegisterOperand listty, ZPRRegOp zprty> 5648{ 5649 def NAME : sve_mem_cst_si<msz, esz, asm, listty>; 5650 5651 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]", 5652 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>; 5653 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]", 5654 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>; 5655 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]", 5656 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 5657} 5658 5659class sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList, 5660 string asm, Operand immtype> 5661: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4), 5662 asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]", 5663 "", 5664 []>, Sched<[]> { 5665 bits<3> Pg; 5666 bits<5> Rn; 5667 bits<5> Zt; 5668 bits<4> imm4; 5669 let Inst{31-25} = 0b1110010; 5670 let Inst{24-23} = sz; 5671 let Inst{22-21} = nregs; 5672 let Inst{20} = 1; 5673 let Inst{19-16} = imm4; 5674 let Inst{15-13} = 0b111; 5675 let Inst{12-10} = Pg; 5676 let Inst{9-5} = Rn; 5677 let Inst{4-0} = Zt; 5678 5679 let mayStore = 1; 5680} 5681 5682multiclass sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList, 5683 string asm, Operand immtype> { 5684 def NAME : sve_mem_est_si<sz, nregs, VecList, asm, immtype>; 5685 5686 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]", 5687 (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 5688} 5689 5690class sve_mem_est_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList, 5691 string asm, RegisterOperand gprty> 5692: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 5693 asm, "\t$Zt, $Pg, [$Rn, $Rm]", 5694 "", 5695 []>, Sched<[]> { 5696 bits<3> Pg; 5697 bits<5> Rm; 5698 bits<5> Rn; 5699 bits<5> Zt; 5700 let Inst{31-25} = 0b1110010; 5701 let Inst{24-23} = sz; 5702 let Inst{22-21} = nregs; 5703 let Inst{20-16} = Rm; 5704 let Inst{15-13} = 0b011; 5705 let Inst{12-10} = Pg; 5706 let Inst{9-5} = Rn; 5707 let Inst{4-0} = Zt; 5708 5709 let mayStore = 1; 5710} 5711 5712class sve_mem_cst_ss_base<bits<4> dtype, string asm, 5713 RegisterOperand listty, RegisterOperand gprty> 5714: I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 5715 asm, "\t$Zt, $Pg, [$Rn, $Rm]", 5716 "", 5717 []>, Sched<[]> { 5718 bits<3> Pg; 5719 bits<5> Rm; 5720 bits<5> Rn; 5721 bits<5> Zt; 5722 let Inst{31-25} = 0b1110010; 5723 let Inst{24-21} = dtype; 5724 let Inst{20-16} = Rm; 5725 let Inst{15-13} = 0b010; 5726 let Inst{12-10} = Pg; 5727 let Inst{9-5} = Rn; 5728 let Inst{4-0} = Zt; 5729 5730 let mayStore = 1; 5731} 5732 5733multiclass sve_mem_cst_ss<bits<4> dtype, string asm, 5734 RegisterOperand listty, ZPRRegOp zprty, 5735 RegisterOperand gprty> { 5736 def NAME : sve_mem_cst_ss_base<dtype, asm, listty, gprty>; 5737 5738 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]", 5739 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>; 5740} 5741 5742class sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand VecList> 5743: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 5744 asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]", 5745 "", 5746 []>, Sched<[]> { 5747 bits<3> Pg; 5748 bits<5> Rn; 5749 bits<5> Zt; 5750 bits<4> imm4; 5751 let Inst{31-25} = 0b1110010; 5752 let Inst{24-23} = msz; 5753 let Inst{22-20} = 0b001; 5754 let Inst{19-16} = imm4; 5755 let Inst{15-13} = 0b111; 5756 let Inst{12-10} = Pg; 5757 let Inst{9-5} = Rn; 5758 let Inst{4-0} = Zt; 5759 5760 let mayStore = 1; 5761} 5762 5763multiclass sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand listty, 5764 ZPRRegOp zprty> { 5765 def NAME : sve_mem_cstnt_si<msz, asm, listty>; 5766 5767 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]", 5768 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>; 5769 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]", 5770 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>; 5771 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]", 5772 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 5773} 5774 5775class sve_mem_cstnt_ss_base<bits<2> msz, string asm, RegisterOperand listty, 5776 RegisterOperand gprty> 5777: I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 5778 asm, "\t$Zt, $Pg, [$Rn, $Rm]", 5779 "", 5780 []>, Sched<[]> { 5781 bits<3> Pg; 5782 bits<5> Rm; 5783 bits<5> Rn; 5784 bits<5> Zt; 5785 let Inst{31-25} = 0b1110010; 5786 let Inst{24-23} = msz; 5787 let Inst{22-21} = 0b00; 5788 let Inst{20-16} = Rm; 5789 let Inst{15-13} = 0b011; 5790 let Inst{12-10} = Pg; 5791 let Inst{9-5} = Rn; 5792 let Inst{4-0} = Zt; 5793 5794 let mayStore = 1; 5795} 5796 5797multiclass sve_mem_cstnt_ss<bits<2> msz, string asm, RegisterOperand listty, 5798 ZPRRegOp zprty, RegisterOperand gprty> { 5799 def NAME : sve_mem_cstnt_ss_base<msz, asm, listty, gprty>; 5800 5801 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]", 5802 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>; 5803} 5804 5805class sve2_mem_sstnt_vs_base<bits<3> opc, string asm, 5806 RegisterOperand listty, ZPRRegOp zprty> 5807: I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm), 5808 asm, "\t$Zt, $Pg, [$Zn, $Rm]", 5809 "", 5810 []>, Sched<[]> { 5811 bits<3> Pg; 5812 bits<5> Rm; 5813 bits<5> Zn; 5814 bits<5> Zt; 5815 let Inst{31-25} = 0b1110010; 5816 let Inst{24-22} = opc; 5817 let Inst{21} = 0b0; 5818 let Inst{20-16} = Rm; 5819 let Inst{15-13} = 0b001; 5820 let Inst{12-10} = Pg; 5821 let Inst{9-5} = Zn; 5822 let Inst{4-0} = Zt; 5823 5824 let mayStore = 1; 5825} 5826 5827multiclass sve2_mem_sstnt_vs_32_ptrs<bits<3> opc, string asm, 5828 SDPatternOperator op, 5829 ValueType vt> { 5830 def _REAL : sve2_mem_sstnt_vs_base<opc, asm, Z_s, ZPR32>; 5831 5832 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]", 5833 (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 0>; 5834 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]", 5835 (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 0>; 5836 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]", 5837 (!cast<Instruction>(NAME # _REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 1>; 5838 5839 def : Pat <(op (nxv4i32 ZPR32:$Zt), (nxv4i1 PPR3bAny:$Pg), (nxv4i32 ZPR32:$Zn), (i64 GPR64:$Rm), vt), 5840 (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm)>; 5841} 5842 5843multiclass sve2_mem_sstnt_vs_64_ptrs<bits<3> opc, string asm, 5844 SDPatternOperator op, 5845 ValueType vt> { 5846 def _REAL : sve2_mem_sstnt_vs_base<opc, asm, Z_d, ZPR64>; 5847 5848 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]", 5849 (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 0>; 5850 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]", 5851 (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 0>; 5852 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]", 5853 (!cast<Instruction>(NAME # _REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>; 5854 5855 def : Pat <(op (nxv2i64 ZPR64:$Zt), (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64:$Rm), vt), 5856 (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>; 5857} 5858 5859class sve_mem_sst_sv<bits<3> opc, bit xs, bit scaled, string asm, 5860 RegisterOperand VecList, RegisterOperand zprext> 5861: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 5862 asm, "\t$Zt, $Pg, [$Rn, $Zm]", 5863 "", 5864 []>, Sched<[]> { 5865 bits<3> Pg; 5866 bits<5> Rn; 5867 bits<5> Zm; 5868 bits<5> Zt; 5869 let Inst{31-25} = 0b1110010; 5870 let Inst{24-22} = opc; 5871 let Inst{21} = scaled; 5872 let Inst{20-16} = Zm; 5873 let Inst{15} = 0b1; 5874 let Inst{14} = xs; 5875 let Inst{13} = 0; 5876 let Inst{12-10} = Pg; 5877 let Inst{9-5} = Rn; 5878 let Inst{4-0} = Zt; 5879 5880 let mayStore = 1; 5881} 5882 5883multiclass sve_mem_32b_sst_sv_32_scaled<bits<3> opc, string asm, 5884 SDPatternOperator sxtw_op, 5885 SDPatternOperator uxtw_op, 5886 RegisterOperand sxtw_opnd, 5887 RegisterOperand uxtw_opnd, 5888 ValueType vt > { 5889 def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, Z_s, uxtw_opnd>; 5890 def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, Z_s, sxtw_opnd>; 5891 5892 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5893 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>; 5894 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5895 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>; 5896 5897 def : Pat<(uxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt), 5898 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 5899 def : Pat<(sxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt), 5900 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 5901} 5902 5903multiclass sve_mem_64b_sst_sv_32_scaled<bits<3> opc, string asm, 5904 SDPatternOperator sxtw_op, 5905 SDPatternOperator uxtw_op, 5906 RegisterOperand sxtw_opnd, 5907 RegisterOperand uxtw_opnd, 5908 ValueType vt > { 5909 def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, Z_d, uxtw_opnd>; 5910 def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, Z_d, sxtw_opnd>; 5911 5912 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5913 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>; 5914 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5915 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>; 5916 5917 def : Pat<(uxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt), 5918 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 5919 def : Pat<(sxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt), 5920 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 5921} 5922 5923multiclass sve_mem_64b_sst_sv_32_unscaled<bits<3> opc, string asm, 5924 SDPatternOperator sxtw_op, 5925 SDPatternOperator uxtw_op, 5926 RegisterOperand sxtw_opnd, 5927 RegisterOperand uxtw_opnd, 5928 ValueType vt> { 5929 def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, Z_d, uxtw_opnd>; 5930 def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, Z_d, sxtw_opnd>; 5931 5932 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5933 (!cast<Instruction>(NAME # _UXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>; 5934 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5935 (!cast<Instruction>(NAME # _SXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>; 5936 5937 def : Pat<(uxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt), 5938 (!cast<Instruction>(NAME # _UXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 5939 def : Pat<(sxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt), 5940 (!cast<Instruction>(NAME # _SXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 5941} 5942 5943multiclass sve_mem_32b_sst_sv_32_unscaled<bits<3> opc, string asm, 5944 SDPatternOperator sxtw_op, 5945 SDPatternOperator uxtw_op, 5946 RegisterOperand sxtw_opnd, 5947 RegisterOperand uxtw_opnd, 5948 ValueType vt> { 5949 def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, Z_s, uxtw_opnd>; 5950 def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, Z_s, sxtw_opnd>; 5951 5952 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5953 (!cast<Instruction>(NAME # _UXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>; 5954 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5955 (!cast<Instruction>(NAME # _SXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>; 5956 5957 def : Pat<(uxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt), 5958 (!cast<Instruction>(NAME # _UXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 5959 def : Pat<(sxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt), 5960 (!cast<Instruction>(NAME # _SXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 5961} 5962 5963class sve_mem_sst_sv2<bits<2> msz, bit scaled, string asm, 5964 RegisterOperand zprext> 5965: I<(outs), (ins Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 5966 asm, "\t$Zt, $Pg, [$Rn, $Zm]", 5967 "", 5968 []>, Sched<[]> { 5969 bits<3> Pg; 5970 bits<5> Rn; 5971 bits<5> Zm; 5972 bits<5> Zt; 5973 let Inst{31-25} = 0b1110010; 5974 let Inst{24-23} = msz; 5975 let Inst{22} = 0b0; 5976 let Inst{21} = scaled; 5977 let Inst{20-16} = Zm; 5978 let Inst{15-13} = 0b101; 5979 let Inst{12-10} = Pg; 5980 let Inst{9-5} = Rn; 5981 let Inst{4-0} = Zt; 5982 5983 let mayStore = 1; 5984} 5985 5986multiclass sve_mem_sst_sv_64_scaled<bits<2> msz, string asm, 5987 SDPatternOperator op, 5988 RegisterOperand zprext, 5989 ValueType vt> { 5990 def _SCALED_REAL : sve_mem_sst_sv2<msz, 1, asm, zprext>; 5991 5992 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 5993 (!cast<Instruction>(NAME # _SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>; 5994 5995 def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt), 5996 (!cast<Instruction>(NAME # _SCALED_REAL) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$indices)>; 5997} 5998 5999multiclass sve_mem_sst_sv_64_unscaled<bits<2> msz, string asm, 6000 SDPatternOperator op, 6001 ValueType vt> { 6002 def _REAL : sve_mem_sst_sv2<msz, 0, asm, ZPR64ExtLSL8>; 6003 6004 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]", 6005 (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>; 6006 6007 def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt), 6008 (!cast<Instruction>(NAME # _REAL) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 6009} 6010 6011class sve_mem_sst_vi<bits<3> opc, string asm, ZPRRegOp zprty, 6012 RegisterOperand VecList, Operand imm_ty> 6013: I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, zprty:$Zn, imm_ty:$imm5), 6014 asm, "\t$Zt, $Pg, [$Zn, $imm5]", 6015 "", 6016 []>, Sched<[]> { 6017 bits<3> Pg; 6018 bits<5> imm5; 6019 bits<5> Zn; 6020 bits<5> Zt; 6021 let Inst{31-25} = 0b1110010; 6022 let Inst{24-23} = opc{2-1}; 6023 let Inst{22} = 0b1; 6024 let Inst{21} = opc{0}; 6025 let Inst{20-16} = imm5; 6026 let Inst{15-13} = 0b101; 6027 let Inst{12-10} = Pg; 6028 let Inst{9-5} = Zn; 6029 let Inst{4-0} = Zt; 6030 6031 let mayStore = 1; 6032} 6033 6034multiclass sve_mem_32b_sst_vi_ptrs<bits<3> opc, string asm, 6035 Operand imm_ty, 6036 SDPatternOperator op, 6037 ValueType vt> { 6038 def _IMM : sve_mem_sst_vi<opc, asm, ZPR32, Z_s, imm_ty>; 6039 6040 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]", 6041 (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>; 6042 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]", 6043 (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>; 6044 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]", 6045 (!cast<Instruction>(NAME # _IMM) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>; 6046 6047 def : Pat<(op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), (nxv4i32 ZPR:$ptrs), imm_ty:$index, vt), 6048 (!cast<Instruction>(NAME # _IMM) ZPR:$data, PPR:$gp, ZPR:$ptrs, imm_ty:$index)>; 6049} 6050 6051multiclass sve_mem_64b_sst_vi_ptrs<bits<3> opc, string asm, 6052 Operand imm_ty, 6053 SDPatternOperator op, 6054 ValueType vt> { 6055 def _IMM : sve_mem_sst_vi<opc, asm, ZPR64, Z_d, imm_ty>; 6056 6057 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]", 6058 (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>; 6059 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]", 6060 (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>; 6061 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]", 6062 (!cast<Instruction>(NAME # _IMM) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>; 6063 6064 def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), (nxv2i64 ZPR:$ptrs), imm_ty:$index, vt), 6065 (!cast<Instruction>(NAME # _IMM) ZPR:$data, PPR:$gp, ZPR:$ptrs, imm_ty:$index)>; 6066} 6067 6068class sve_mem_z_spill<string asm> 6069: I<(outs), (ins ZPRAny:$Zt, GPR64sp:$Rn, simm9:$imm9), 6070 asm, "\t$Zt, [$Rn, $imm9, mul vl]", 6071 "", 6072 []>, Sched<[]> { 6073 bits<5> Rn; 6074 bits<5> Zt; 6075 bits<9> imm9; 6076 let Inst{31-22} = 0b1110010110; 6077 let Inst{21-16} = imm9{8-3}; 6078 let Inst{15-13} = 0b010; 6079 let Inst{12-10} = imm9{2-0}; 6080 let Inst{9-5} = Rn; 6081 let Inst{4-0} = Zt; 6082 6083 let mayStore = 1; 6084} 6085 6086multiclass sve_mem_z_spill<string asm> { 6087 def NAME : sve_mem_z_spill<asm>; 6088 6089 def : InstAlias<asm # "\t$Zt, [$Rn]", 6090 (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>; 6091} 6092 6093class sve_mem_p_spill<string asm> 6094: I<(outs), (ins PPRAny:$Pt, GPR64sp:$Rn, simm9:$imm9), 6095 asm, "\t$Pt, [$Rn, $imm9, mul vl]", 6096 "", 6097 []>, Sched<[]> { 6098 bits<4> Pt; 6099 bits<5> Rn; 6100 bits<9> imm9; 6101 let Inst{31-22} = 0b1110010110; 6102 let Inst{21-16} = imm9{8-3}; 6103 let Inst{15-13} = 0b000; 6104 let Inst{12-10} = imm9{2-0}; 6105 let Inst{9-5} = Rn; 6106 let Inst{4} = 0b0; 6107 let Inst{3-0} = Pt; 6108 6109 let mayStore = 1; 6110} 6111 6112multiclass sve_mem_p_spill<string asm> { 6113 def NAME : sve_mem_p_spill<asm>; 6114 6115 def : InstAlias<asm # "\t$Pt, [$Rn]", 6116 (!cast<Instruction>(NAME) PPRAny:$Pt, GPR64sp:$Rn, 0), 1>; 6117} 6118 6119//===----------------------------------------------------------------------===// 6120// SVE Permute - Predicates Group 6121//===----------------------------------------------------------------------===// 6122 6123class sve_int_perm_bin_perm_pp<bits<3> opc, bits<2> sz8_64, string asm, 6124 PPRRegOp pprty> 6125: I<(outs pprty:$Pd), (ins pprty:$Pn, pprty:$Pm), 6126 asm, "\t$Pd, $Pn, $Pm", 6127 "", []>, Sched<[]> { 6128 bits<4> Pd; 6129 bits<4> Pm; 6130 bits<4> Pn; 6131 let Inst{31-24} = 0b00000101; 6132 let Inst{23-22} = sz8_64; 6133 let Inst{21-20} = 0b10; 6134 let Inst{19-16} = Pm; 6135 let Inst{15-13} = 0b010; 6136 let Inst{12-10} = opc; 6137 let Inst{9} = 0b0; 6138 let Inst{8-5} = Pn; 6139 let Inst{4} = 0b0; 6140 let Inst{3-0} = Pd; 6141} 6142 6143multiclass sve_int_perm_bin_perm_pp<bits<3> opc, string asm, 6144 SDPatternOperator op> { 6145 def _B : sve_int_perm_bin_perm_pp<opc, 0b00, asm, PPR8>; 6146 def _H : sve_int_perm_bin_perm_pp<opc, 0b01, asm, PPR16>; 6147 def _S : sve_int_perm_bin_perm_pp<opc, 0b10, asm, PPR32>; 6148 def _D : sve_int_perm_bin_perm_pp<opc, 0b11, asm, PPR64>; 6149 6150 def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>; 6151 def : SVE_2_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>; 6152 def : SVE_2_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>; 6153 def : SVE_2_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>; 6154} 6155 6156class sve_int_perm_punpk<bit opc, string asm> 6157: I<(outs PPR16:$Pd), (ins PPR8:$Pn), 6158 asm, "\t$Pd, $Pn", 6159 "", 6160 []>, Sched<[]> { 6161 bits<4> Pd; 6162 bits<4> Pn; 6163 let Inst{31-17} = 0b000001010011000; 6164 let Inst{16} = opc; 6165 let Inst{15-9} = 0b0100000; 6166 let Inst{8-5} = Pn; 6167 let Inst{4} = 0b0; 6168 let Inst{3-0} = Pd; 6169} 6170 6171multiclass sve_int_perm_punpk<bit opc, string asm, SDPatternOperator op> { 6172 def NAME : sve_int_perm_punpk<opc, asm>; 6173 6174 def : SVE_1_Op_Pat<nxv8i1, op, nxv16i1, !cast<Instruction>(NAME)>; 6175 def : SVE_1_Op_Pat<nxv4i1, op, nxv8i1, !cast<Instruction>(NAME)>; 6176 def : SVE_1_Op_Pat<nxv2i1, op, nxv4i1, !cast<Instruction>(NAME)>; 6177} 6178 6179class sve_int_rdffr_pred<bit s, string asm> 6180: I<(outs PPR8:$Pd), (ins PPRAny:$Pg), 6181 asm, "\t$Pd, $Pg/z", 6182 "", 6183 []>, Sched<[]> { 6184 bits<4> Pd; 6185 bits<4> Pg; 6186 let Inst{31-23} = 0b001001010; 6187 let Inst{22} = s; 6188 let Inst{21-9} = 0b0110001111000; 6189 let Inst{8-5} = Pg; 6190 let Inst{4} = 0; 6191 let Inst{3-0} = Pd; 6192 6193 let Defs = !if(s, [NZCV], []); 6194 let Uses = [FFR]; 6195} 6196 6197multiclass sve_int_rdffr_pred<bit s, string asm, SDPatternOperator op> { 6198 def _REAL : sve_int_rdffr_pred<s, asm>; 6199 6200 // We need a layer of indirection because early machine code passes balk at 6201 // physical register (i.e. FFR) uses that have no previous definition. 6202 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 6203 def "" : Pseudo<(outs PPR8:$Pd), (ins PPRAny:$Pg), [(set (nxv16i1 PPR8:$Pd), (op (nxv16i1 PPRAny:$Pg)))]>, 6204 PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) PPR8:$Pd, PPRAny:$Pg)>; 6205 } 6206} 6207 6208class sve_int_rdffr_unpred<string asm> : I< 6209 (outs PPR8:$Pd), (ins), 6210 asm, "\t$Pd", 6211 "", 6212 []>, Sched<[]> { 6213 bits<4> Pd; 6214 let Inst{31-4} = 0b0010010100011001111100000000; 6215 let Inst{3-0} = Pd; 6216 6217 let Uses = [FFR]; 6218} 6219 6220multiclass sve_int_rdffr_unpred<string asm, SDPatternOperator op> { 6221 def _REAL : sve_int_rdffr_unpred<asm>; 6222 6223 // We need a layer of indirection because early machine code passes balk at 6224 // physical register (i.e. FFR) uses that have no previous definition. 6225 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 6226 def "" : Pseudo<(outs PPR8:$Pd), (ins), [(set (nxv16i1 PPR8:$Pd), (op))]>, 6227 PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) PPR8:$Pd)>; 6228 } 6229} 6230 6231class sve_int_wrffr<string asm, SDPatternOperator op> 6232: I<(outs), (ins PPR8:$Pn), 6233 asm, "\t$Pn", 6234 "", 6235 [(op (nxv16i1 PPR8:$Pn))]>, Sched<[]> { 6236 bits<4> Pn; 6237 let Inst{31-9} = 0b00100101001010001001000; 6238 let Inst{8-5} = Pn; 6239 let Inst{4-0} = 0b00000; 6240 6241 let hasSideEffects = 1; 6242 let Defs = [FFR]; 6243} 6244 6245class sve_int_setffr<string asm, SDPatternOperator op> 6246: I<(outs), (ins), 6247 asm, "", 6248 "", 6249 [(op)]>, Sched<[]> { 6250 let Inst{31-0} = 0b00100101001011001001000000000000; 6251 6252 let hasSideEffects = 1; 6253 let Defs = [FFR]; 6254} 6255 6256//===----------------------------------------------------------------------===// 6257// SVE Permute Vector - Predicated Group 6258//===----------------------------------------------------------------------===// 6259 6260class sve_int_perm_clast_rz<bits<2> sz8_64, bit ab, string asm, 6261 ZPRRegOp zprty, RegisterClass rt> 6262: I<(outs rt:$Rdn), (ins PPR3bAny:$Pg, rt:$_Rdn, zprty:$Zm), 6263 asm, "\t$Rdn, $Pg, $_Rdn, $Zm", 6264 "", 6265 []>, Sched<[]> { 6266 bits<3> Pg; 6267 bits<5> Rdn; 6268 bits<5> Zm; 6269 let Inst{31-24} = 0b00000101; 6270 let Inst{23-22} = sz8_64; 6271 let Inst{21-17} = 0b11000; 6272 let Inst{16} = ab; 6273 let Inst{15-13} = 0b101; 6274 let Inst{12-10} = Pg; 6275 let Inst{9-5} = Zm; 6276 let Inst{4-0} = Rdn; 6277 6278 let Constraints = "$Rdn = $_Rdn"; 6279} 6280 6281multiclass sve_int_perm_clast_rz<bit ab, string asm, SDPatternOperator op> { 6282 def _B : sve_int_perm_clast_rz<0b00, ab, asm, ZPR8, GPR32>; 6283 def _H : sve_int_perm_clast_rz<0b01, ab, asm, ZPR16, GPR32>; 6284 def _S : sve_int_perm_clast_rz<0b10, ab, asm, ZPR32, GPR32>; 6285 def _D : sve_int_perm_clast_rz<0b11, ab, asm, ZPR64, GPR64>; 6286 6287 def : SVE_3_Op_Pat<i32, op, nxv16i1, i32, nxv16i8, !cast<Instruction>(NAME # _B)>; 6288 def : SVE_3_Op_Pat<i32, op, nxv8i1, i32, nxv8i16, !cast<Instruction>(NAME # _H)>; 6289 def : SVE_3_Op_Pat<i32, op, nxv4i1, i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 6290 def : SVE_3_Op_Pat<i64, op, nxv2i1, i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 6291} 6292 6293class sve_int_perm_clast_vz<bits<2> sz8_64, bit ab, string asm, 6294 ZPRRegOp zprty, RegisterClass rt> 6295: I<(outs rt:$Vdn), (ins PPR3bAny:$Pg, rt:$_Vdn, zprty:$Zm), 6296 asm, "\t$Vdn, $Pg, $_Vdn, $Zm", 6297 "", 6298 []>, Sched<[]> { 6299 bits<3> Pg; 6300 bits<5> Vdn; 6301 bits<5> Zm; 6302 let Inst{31-24} = 0b00000101; 6303 let Inst{23-22} = sz8_64; 6304 let Inst{21-17} = 0b10101; 6305 let Inst{16} = ab; 6306 let Inst{15-13} = 0b100; 6307 let Inst{12-10} = Pg; 6308 let Inst{9-5} = Zm; 6309 let Inst{4-0} = Vdn; 6310 6311 let Constraints = "$Vdn = $_Vdn"; 6312} 6313 6314multiclass sve_int_perm_clast_vz<bit ab, string asm, SDPatternOperator op> { 6315 def _B : sve_int_perm_clast_vz<0b00, ab, asm, ZPR8, FPR8>; 6316 def _H : sve_int_perm_clast_vz<0b01, ab, asm, ZPR16, FPR16>; 6317 def _S : sve_int_perm_clast_vz<0b10, ab, asm, ZPR32, FPR32>; 6318 def _D : sve_int_perm_clast_vz<0b11, ab, asm, ZPR64, FPR64>; 6319 6320 def : SVE_3_Op_Pat<f16, op, nxv8i1, f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 6321 def : SVE_3_Op_Pat<f32, op, nxv4i1, f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 6322 def : SVE_3_Op_Pat<f64, op, nxv2i1, f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 6323 6324 def : SVE_3_Op_Pat<bf16, op, nxv8i1, bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>; 6325} 6326 6327class sve_int_perm_clast_zz<bits<2> sz8_64, bit ab, string asm, 6328 ZPRRegOp zprty> 6329: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm), 6330 asm, "\t$Zdn, $Pg, $_Zdn, $Zm", 6331 "", 6332 []>, Sched<[]> { 6333 bits<3> Pg; 6334 bits<5> Zdn; 6335 bits<5> Zm; 6336 let Inst{31-24} = 0b00000101; 6337 let Inst{23-22} = sz8_64; 6338 let Inst{21-17} = 0b10100; 6339 let Inst{16} = ab; 6340 let Inst{15-13} = 0b100; 6341 let Inst{12-10} = Pg; 6342 let Inst{9-5} = Zm; 6343 let Inst{4-0} = Zdn; 6344 6345 let Constraints = "$Zdn = $_Zdn"; 6346 let DestructiveInstType = DestructiveOther; 6347 let ElementSize = ElementSizeNone; 6348} 6349 6350multiclass sve_int_perm_clast_zz<bit ab, string asm, SDPatternOperator op> { 6351 def _B : sve_int_perm_clast_zz<0b00, ab, asm, ZPR8>; 6352 def _H : sve_int_perm_clast_zz<0b01, ab, asm, ZPR16>; 6353 def _S : sve_int_perm_clast_zz<0b10, ab, asm, ZPR32>; 6354 def _D : sve_int_perm_clast_zz<0b11, ab, asm, ZPR64>; 6355 6356 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 6357 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 6358 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 6359 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 6360 6361 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 6362 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 6363 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 6364 6365 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>; 6366} 6367 6368class sve_int_perm_last_r<bits<2> sz8_64, bit ab, string asm, 6369 ZPRRegOp zprty, RegisterClass resultRegType> 6370: I<(outs resultRegType:$Rd), (ins PPR3bAny:$Pg, zprty:$Zn), 6371 asm, "\t$Rd, $Pg, $Zn", 6372 "", 6373 []>, Sched<[]> { 6374 bits<3> Pg; 6375 bits<5> Rd; 6376 bits<5> Zn; 6377 let Inst{31-24} = 0b00000101; 6378 let Inst{23-22} = sz8_64; 6379 let Inst{21-17} = 0b10000; 6380 let Inst{16} = ab; 6381 let Inst{15-13} = 0b101; 6382 let Inst{12-10} = Pg; 6383 let Inst{9-5} = Zn; 6384 let Inst{4-0} = Rd; 6385} 6386 6387multiclass sve_int_perm_last_r<bit ab, string asm, SDPatternOperator op> { 6388 def _B : sve_int_perm_last_r<0b00, ab, asm, ZPR8, GPR32>; 6389 def _H : sve_int_perm_last_r<0b01, ab, asm, ZPR16, GPR32>; 6390 def _S : sve_int_perm_last_r<0b10, ab, asm, ZPR32, GPR32>; 6391 def _D : sve_int_perm_last_r<0b11, ab, asm, ZPR64, GPR64>; 6392 6393 def : SVE_2_Op_Pat<i32, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 6394 def : SVE_2_Op_Pat<i32, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 6395 def : SVE_2_Op_Pat<i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 6396 def : SVE_2_Op_Pat<i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 6397} 6398 6399class sve_int_perm_last_v<bits<2> sz8_64, bit ab, string asm, 6400 ZPRRegOp zprty, RegisterClass dstRegtype> 6401: I<(outs dstRegtype:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn), 6402 asm, "\t$Vd, $Pg, $Zn", 6403 "", 6404 []>, Sched<[]> { 6405 bits<3> Pg; 6406 bits<5> Vd; 6407 bits<5> Zn; 6408 let Inst{31-24} = 0b00000101; 6409 let Inst{23-22} = sz8_64; 6410 let Inst{21-17} = 0b10001; 6411 let Inst{16} = ab; 6412 let Inst{15-13} = 0b100; 6413 let Inst{12-10} = Pg; 6414 let Inst{9-5} = Zn; 6415 let Inst{4-0} = Vd; 6416} 6417 6418multiclass sve_int_perm_last_v<bit ab, string asm, SDPatternOperator op> { 6419 def _B : sve_int_perm_last_v<0b00, ab, asm, ZPR8, FPR8>; 6420 def _H : sve_int_perm_last_v<0b01, ab, asm, ZPR16, FPR16>; 6421 def _S : sve_int_perm_last_v<0b10, ab, asm, ZPR32, FPR32>; 6422 def _D : sve_int_perm_last_v<0b11, ab, asm, ZPR64, FPR64>; 6423 6424 def : SVE_2_Op_Pat<f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>; 6425 def : SVE_2_Op_Pat<f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 6426 def : SVE_2_Op_Pat<f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>; 6427 def : SVE_2_Op_Pat<f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 6428 6429 def : SVE_2_Op_Pat<bf16, op, nxv8i1, nxv8bf16, !cast<Instruction>(NAME # _H)>; 6430} 6431 6432class sve_int_perm_splice<bits<2> sz8_64, string asm, ZPRRegOp zprty> 6433: I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm), 6434 asm, "\t$Zdn, $Pg, $_Zdn, $Zm", 6435 "", 6436 []>, Sched<[]> { 6437 bits<3> Pg; 6438 bits<5> Zdn; 6439 bits<5> Zm; 6440 let Inst{31-24} = 0b00000101; 6441 let Inst{23-22} = sz8_64; 6442 let Inst{21-13} = 0b101100100; 6443 let Inst{12-10} = Pg; 6444 let Inst{9-5} = Zm; 6445 let Inst{4-0} = Zdn; 6446 6447 let Constraints = "$Zdn = $_Zdn"; 6448 let DestructiveInstType = DestructiveOther; 6449 let ElementSize = ElementSizeNone; 6450} 6451 6452multiclass sve_int_perm_splice<string asm, SDPatternOperator op> { 6453 def _B : sve_int_perm_splice<0b00, asm, ZPR8>; 6454 def _H : sve_int_perm_splice<0b01, asm, ZPR16>; 6455 def _S : sve_int_perm_splice<0b10, asm, ZPR32>; 6456 def _D : sve_int_perm_splice<0b11, asm, ZPR64>; 6457 6458 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 6459 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 6460 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 6461 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 6462 6463 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>; 6464 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>; 6465 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>; 6466 6467 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>; 6468} 6469 6470class sve2_int_perm_splice_cons<bits<2> sz8_64, string asm, 6471 ZPRRegOp zprty, RegisterOperand VecList> 6472: I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, VecList:$Zn), 6473 asm, "\t$Zd, $Pg, $Zn", 6474 "", 6475 []>, Sched<[]> { 6476 bits<3> Pg; 6477 bits<5> Zn; 6478 bits<5> Zd; 6479 let Inst{31-24} = 0b00000101; 6480 let Inst{23-22} = sz8_64; 6481 let Inst{21-13} = 0b101101100; 6482 let Inst{12-10} = Pg; 6483 let Inst{9-5} = Zn; 6484 let Inst{4-0} = Zd; 6485} 6486 6487multiclass sve2_int_perm_splice_cons<string asm> { 6488 def _B : sve2_int_perm_splice_cons<0b00, asm, ZPR8, ZZ_b>; 6489 def _H : sve2_int_perm_splice_cons<0b01, asm, ZPR16, ZZ_h>; 6490 def _S : sve2_int_perm_splice_cons<0b10, asm, ZPR32, ZZ_s>; 6491 def _D : sve2_int_perm_splice_cons<0b11, asm, ZPR64, ZZ_d>; 6492} 6493 6494class sve_int_perm_rev<bits<2> sz8_64, bits<2> opc, string asm, 6495 ZPRRegOp zprty> 6496: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn), 6497 asm, "\t$Zd, $Pg/m, $Zn", 6498 "", 6499 []>, Sched<[]> { 6500 bits<5> Zd; 6501 bits<3> Pg; 6502 bits<5> Zn; 6503 let Inst{31-24} = 0b00000101; 6504 let Inst{23-22} = sz8_64; 6505 let Inst{21-18} = 0b1001; 6506 let Inst{17-16} = opc; 6507 let Inst{15-13} = 0b100; 6508 let Inst{12-10} = Pg; 6509 let Inst{9-5} = Zn; 6510 let Inst{4-0} = Zd; 6511 6512 let Constraints = "$Zd = $_Zd"; 6513 let DestructiveInstType = DestructiveOther; 6514 let ElementSize = zprty.ElementSize; 6515} 6516 6517multiclass sve_int_perm_rev_rbit<string asm, SDPatternOperator op> { 6518 def _B : sve_int_perm_rev<0b00, 0b11, asm, ZPR8>; 6519 def _H : sve_int_perm_rev<0b01, 0b11, asm, ZPR16>; 6520 def _S : sve_int_perm_rev<0b10, 0b11, asm, ZPR32>; 6521 def _D : sve_int_perm_rev<0b11, 0b11, asm, ZPR64>; 6522 6523 def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 6524 def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 6525 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 6526 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 6527} 6528 6529multiclass sve_int_perm_rev_revb<string asm, SDPatternOperator op> { 6530 def _H : sve_int_perm_rev<0b01, 0b00, asm, ZPR16>; 6531 def _S : sve_int_perm_rev<0b10, 0b00, asm, ZPR32>; 6532 def _D : sve_int_perm_rev<0b11, 0b00, asm, ZPR64>; 6533 6534 def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 6535 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 6536 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 6537} 6538 6539multiclass sve_int_perm_rev_revh<string asm, SDPatternOperator op> { 6540 def _S : sve_int_perm_rev<0b10, 0b01, asm, ZPR32>; 6541 def _D : sve_int_perm_rev<0b11, 0b01, asm, ZPR64>; 6542 6543 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 6544 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 6545} 6546 6547multiclass sve_int_perm_rev_revw<string asm, SDPatternOperator op> { 6548 def _D : sve_int_perm_rev<0b11, 0b10, asm, ZPR64>; 6549 6550 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 6551} 6552 6553class sve_int_perm_cpy_r<bits<2> sz8_64, string asm, ZPRRegOp zprty, 6554 RegisterClass srcRegType> 6555: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegType:$Rn), 6556 asm, "\t$Zd, $Pg/m, $Rn", 6557 "", 6558 []>, Sched<[]> { 6559 bits<3> Pg; 6560 bits<5> Rn; 6561 bits<5> Zd; 6562 let Inst{31-24} = 0b00000101; 6563 let Inst{23-22} = sz8_64; 6564 let Inst{21-13} = 0b101000101; 6565 let Inst{12-10} = Pg; 6566 let Inst{9-5} = Rn; 6567 let Inst{4-0} = Zd; 6568 6569 let Constraints = "$Zd = $_Zd"; 6570 let DestructiveInstType = DestructiveOther; 6571 let ElementSize = zprty.ElementSize; 6572} 6573 6574multiclass sve_int_perm_cpy_r<string asm, SDPatternOperator op> { 6575 def _B : sve_int_perm_cpy_r<0b00, asm, ZPR8, GPR32sp>; 6576 def _H : sve_int_perm_cpy_r<0b01, asm, ZPR16, GPR32sp>; 6577 def _S : sve_int_perm_cpy_r<0b10, asm, ZPR32, GPR32sp>; 6578 def _D : sve_int_perm_cpy_r<0b11, asm, ZPR64, GPR64sp>; 6579 6580 def : InstAlias<"mov $Zd, $Pg/m, $Rn", 6581 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>; 6582 def : InstAlias<"mov $Zd, $Pg/m, $Rn", 6583 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>; 6584 def : InstAlias<"mov $Zd, $Pg/m, $Rn", 6585 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>; 6586 def : InstAlias<"mov $Zd, $Pg/m, $Rn", 6587 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, GPR64sp:$Rn), 1>; 6588 6589 def : Pat<(nxv16i8 (op nxv16i1:$pg, i32:$splat, nxv16i8:$passthru)), 6590 (!cast<Instruction>(NAME # _B) $passthru, $pg, $splat)>; 6591 def : Pat<(nxv8i16 (op nxv8i1:$pg, i32:$splat, nxv8i16:$passthru)), 6592 (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>; 6593 def : Pat<(nxv4i32 (op nxv4i1:$pg, i32:$splat, nxv4i32:$passthru)), 6594 (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>; 6595 def : Pat<(nxv2i64 (op nxv2i1:$pg, i64:$splat, nxv2i64:$passthru)), 6596 (!cast<Instruction>(NAME # _D) $passthru, $pg, $splat)>; 6597} 6598 6599class sve_int_perm_cpy_v<bits<2> sz8_64, string asm, ZPRRegOp zprty, 6600 RegisterClass srcRegtype> 6601: I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegtype:$Vn), 6602 asm, "\t$Zd, $Pg/m, $Vn", 6603 "", 6604 []>, Sched<[]> { 6605 bits<3> Pg; 6606 bits<5> Vn; 6607 bits<5> Zd; 6608 let Inst{31-24} = 0b00000101; 6609 let Inst{23-22} = sz8_64; 6610 let Inst{21-13} = 0b100000100; 6611 let Inst{12-10} = Pg; 6612 let Inst{9-5} = Vn; 6613 let Inst{4-0} = Zd; 6614 6615 let Constraints = "$Zd = $_Zd"; 6616 let DestructiveInstType = DestructiveOther; 6617 let ElementSize = zprty.ElementSize; 6618} 6619 6620multiclass sve_int_perm_cpy_v<string asm, SDPatternOperator op> { 6621 def _B : sve_int_perm_cpy_v<0b00, asm, ZPR8, FPR8>; 6622 def _H : sve_int_perm_cpy_v<0b01, asm, ZPR16, FPR16>; 6623 def _S : sve_int_perm_cpy_v<0b10, asm, ZPR32, FPR32>; 6624 def _D : sve_int_perm_cpy_v<0b11, asm, ZPR64, FPR64>; 6625 6626 def : InstAlias<"mov $Zd, $Pg/m, $Vn", 6627 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, FPR8:$Vn), 1>; 6628 def : InstAlias<"mov $Zd, $Pg/m, $Vn", 6629 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, FPR16:$Vn), 1>; 6630 def : InstAlias<"mov $Zd, $Pg/m, $Vn", 6631 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, FPR32:$Vn), 1>; 6632 def : InstAlias<"mov $Zd, $Pg/m, $Vn", 6633 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, FPR64:$Vn), 1>; 6634 6635 def : Pat<(nxv8f16 (op nxv8i1:$pg, f16:$splat, nxv8f16:$passthru)), 6636 (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>; 6637 def : Pat<(nxv2f32 (op nxv2i1:$pg, f32:$splat, nxv2f32:$passthru)), 6638 (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>; 6639 def : Pat<(nxv4f32 (op nxv4i1:$pg, f32:$splat, nxv4f32:$passthru)), 6640 (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>; 6641 def : Pat<(nxv2f64 (op nxv2i1:$pg, f64:$splat, nxv2f64:$passthru)), 6642 (!cast<Instruction>(NAME # _D) $passthru, $pg, $splat)>; 6643 6644 def : Pat<(nxv8bf16 (op nxv8i1:$pg, bf16:$splat, nxv8bf16:$passthru)), 6645 (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>; 6646} 6647 6648class sve_int_perm_compact<bit sz, string asm, ZPRRegOp zprty> 6649: I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn), 6650 asm, "\t$Zd, $Pg, $Zn", 6651 "", 6652 []>, Sched<[]> { 6653 bits<3> Pg; 6654 bits<5> Zd; 6655 bits<5> Zn; 6656 let Inst{31-23} = 0b000001011; 6657 let Inst{22} = sz; 6658 let Inst{21-13} = 0b100001100; 6659 let Inst{12-10} = Pg; 6660 let Inst{9-5} = Zn; 6661 let Inst{4-0} = Zd; 6662} 6663 6664multiclass sve_int_perm_compact<string asm, SDPatternOperator op> { 6665 def _S : sve_int_perm_compact<0b0, asm, ZPR32>; 6666 def _D : sve_int_perm_compact<0b1, asm, ZPR64>; 6667 6668 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 6669 def : SVE_2_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>; 6670 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 6671 def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>; 6672} 6673 6674//===----------------------------------------------------------------------===// 6675// SVE Memory - Contiguous Load Group 6676//===----------------------------------------------------------------------===// 6677 6678class sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm, 6679 RegisterOperand VecList> 6680: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 6681 asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]", 6682 "", 6683 []>, Sched<[]> { 6684 bits<3> Pg; 6685 bits<5> Rn; 6686 bits<5> Zt; 6687 bits<4> imm4; 6688 let Inst{31-25} = 0b1010010; 6689 let Inst{24-21} = dtype; 6690 let Inst{20} = nf; 6691 let Inst{19-16} = imm4; 6692 let Inst{15-13} = 0b101; 6693 let Inst{12-10} = Pg; 6694 let Inst{9-5} = Rn; 6695 let Inst{4-0} = Zt; 6696 6697 let mayLoad = 1; 6698 let Uses = !if(nf, [FFR], []); 6699 let Defs = !if(nf, [FFR], []); 6700} 6701 6702multiclass sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm, 6703 RegisterOperand listty, ZPRRegOp zprty> { 6704 def _REAL : sve_mem_cld_si_base<dtype, nf, asm, listty>; 6705 6706 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6707 (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>; 6708 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]", 6709 (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>; 6710 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6711 (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 6712 6713 // We need a layer of indirection because early machine code passes balk at 6714 // physical register (i.e. FFR) uses that have no previous definition. 6715 let hasSideEffects = 1, hasNoSchedulingInfo = 1, mayLoad = 1 in { 6716 def "" : Pseudo<(outs listty:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), []>, 6717 PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4)>; 6718 } 6719} 6720 6721multiclass sve_mem_cld_si<bits<4> dtype, string asm, RegisterOperand listty, 6722 ZPRRegOp zprty> 6723: sve_mem_cld_si_base<dtype, 0, asm, listty, zprty>; 6724 6725class sve_mem_cldnt_si_base<bits<2> msz, string asm, RegisterOperand VecList> 6726: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 6727 asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]", 6728 "", 6729 []>, Sched<[]> { 6730 bits<5> Zt; 6731 bits<3> Pg; 6732 bits<5> Rn; 6733 bits<4> imm4; 6734 let Inst{31-25} = 0b1010010; 6735 let Inst{24-23} = msz; 6736 let Inst{22-20} = 0b000; 6737 let Inst{19-16} = imm4; 6738 let Inst{15-13} = 0b111; 6739 let Inst{12-10} = Pg; 6740 let Inst{9-5} = Rn; 6741 let Inst{4-0} = Zt; 6742 6743 let mayLoad = 1; 6744} 6745 6746multiclass sve_mem_cldnt_si<bits<2> msz, string asm, RegisterOperand listty, 6747 ZPRRegOp zprty> { 6748 def NAME : sve_mem_cldnt_si_base<msz, asm, listty>; 6749 6750 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6751 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>; 6752 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]", 6753 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>; 6754 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6755 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 6756} 6757 6758class sve_mem_cldnt_ss_base<bits<2> msz, string asm, RegisterOperand VecList, 6759 RegisterOperand gprty> 6760: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 6761 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", 6762 "", 6763 []>, Sched<[]> { 6764 bits<3> Pg; 6765 bits<5> Rm; 6766 bits<5> Rn; 6767 bits<5> Zt; 6768 let Inst{31-25} = 0b1010010; 6769 let Inst{24-23} = msz; 6770 let Inst{22-21} = 0b00; 6771 let Inst{20-16} = Rm; 6772 let Inst{15-13} = 0b110; 6773 let Inst{12-10} = Pg; 6774 let Inst{9-5} = Rn; 6775 let Inst{4-0} = Zt; 6776 6777 let mayLoad = 1; 6778} 6779 6780multiclass sve_mem_cldnt_ss<bits<2> msz, string asm, RegisterOperand listty, 6781 ZPRRegOp zprty, RegisterOperand gprty> { 6782 def NAME : sve_mem_cldnt_ss_base<msz, asm, listty, gprty>; 6783 6784 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]", 6785 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>; 6786} 6787 6788class sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand VecList> 6789: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4), 6790 asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> { 6791 bits<5> Zt; 6792 bits<5> Rn; 6793 bits<3> Pg; 6794 bits<4> imm4; 6795 let Inst{31-25} = 0b1010010; 6796 let Inst{24-23} = sz; 6797 let Inst{22-20} = 0; 6798 let Inst{19-16} = imm4; 6799 let Inst{15-13} = 0b001; 6800 let Inst{12-10} = Pg; 6801 let Inst{9-5} = Rn; 6802 let Inst{4-0} = Zt; 6803 6804 let mayLoad = 1; 6805} 6806 6807multiclass sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand listty, 6808 ZPRRegOp zprty> { 6809 def NAME : sve_mem_ldqr_si<sz, asm, listty>; 6810 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6811 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 6812 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6813 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>; 6814 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]", 6815 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4), 0>; 6816} 6817 6818class sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand VecList, 6819 RegisterOperand gprty> 6820: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 6821 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> { 6822 bits<5> Zt; 6823 bits<3> Pg; 6824 bits<5> Rn; 6825 bits<5> Rm; 6826 let Inst{31-25} = 0b1010010; 6827 let Inst{24-23} = sz; 6828 let Inst{22-21} = 0; 6829 let Inst{20-16} = Rm; 6830 let Inst{15-13} = 0; 6831 let Inst{12-10} = Pg; 6832 let Inst{9-5} = Rn; 6833 let Inst{4-0} = Zt; 6834 6835 let mayLoad = 1; 6836} 6837 6838multiclass sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand listty, 6839 ZPRRegOp zprty, RegisterOperand gprty> { 6840 def NAME : sve_mem_ldqr_ss<sz, asm, listty, gprty>; 6841 6842 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]", 6843 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>; 6844} 6845 6846class sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm, 6847 RegisterOperand VecList, Operand immtype> 6848: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6), 6849 asm, "\t$Zt, $Pg/z, [$Rn, $imm6]", 6850 "", 6851 []>, Sched<[]> { 6852 bits<3> Pg; 6853 bits<5> Rn; 6854 bits<5> Zt; 6855 bits<6> imm6; 6856 let Inst{31-25} = 0b1000010; 6857 let Inst{24-23} = dtypeh; 6858 let Inst{22} = 1; 6859 let Inst{21-16} = imm6; 6860 let Inst{15} = 0b1; 6861 let Inst{14-13} = dtypel; 6862 let Inst{12-10} = Pg; 6863 let Inst{9-5} = Rn; 6864 let Inst{4-0} = Zt; 6865 6866 let mayLoad = 1; 6867} 6868 6869multiclass sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm, 6870 RegisterOperand zlistty, ZPRRegOp zprty, Operand immtype> { 6871 def NAME : sve_mem_ld_dup<dtypeh, dtypel, asm, zlistty, immtype>; 6872 6873 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6874 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>; 6875 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm6]", 6876 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6), 0>; 6877 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6878 (!cast<Instruction>(NAME) zlistty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 6879} 6880 6881class sve_mem_cld_ss_base<bits<4> dtype, bit ff, dag iops, string asm, 6882 RegisterOperand VecList> 6883: I<(outs VecList:$Zt), iops, 6884 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", 6885 "", 6886 []>, Sched<[]> { 6887 bits<5> Zt; 6888 bits<3> Pg; 6889 bits<5> Rm; 6890 bits<5> Rn; 6891 let Inst{31-25} = 0b1010010; 6892 let Inst{24-21} = dtype; 6893 let Inst{20-16} = Rm; 6894 let Inst{15-14} = 0b01; 6895 let Inst{13} = ff; 6896 let Inst{12-10} = Pg; 6897 let Inst{9-5} = Rn; 6898 let Inst{4-0} = Zt; 6899 6900 let mayLoad = 1; 6901 let Uses = !if(ff, [FFR], []); 6902 let Defs = !if(ff, [FFR], []); 6903} 6904 6905multiclass sve_mem_cld_ss<bits<4> dtype, string asm, RegisterOperand listty, 6906 ZPRRegOp zprty, RegisterOperand gprty> { 6907 def "" : sve_mem_cld_ss_base<dtype, 0, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 6908 asm, listty>; 6909 6910 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]", 6911 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>; 6912} 6913 6914multiclass sve_mem_cldff_ss<bits<4> dtype, string asm, RegisterOperand listty, 6915 ZPRRegOp zprty, RegisterOperand gprty> { 6916 def _REAL : sve_mem_cld_ss_base<dtype, 1, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 6917 asm, listty>; 6918 6919 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]", 6920 (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>; 6921 6922 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6923 (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 1>; 6924 6925 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6926 (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 0>; 6927 6928 // We need a layer of indirection because early machine code passes balk at 6929 // physical register (i.e. FFR) uses that have no previous definition. 6930 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 6931 def "" : Pseudo<(outs listty:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), []>, 6932 PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm)>; 6933 } 6934} 6935 6936multiclass sve_mem_cldnf_si<bits<4> dtype, string asm, RegisterOperand listty, 6937 ZPRRegOp zprty> 6938: sve_mem_cld_si_base<dtype, 1, asm, listty, zprty>; 6939 6940class sve_mem_eld_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList, 6941 string asm, Operand immtype> 6942: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4), 6943 asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]", 6944 "", 6945 []>, Sched<[]> { 6946 bits<5> Zt; 6947 bits<3> Pg; 6948 bits<5> Rn; 6949 bits<4> imm4; 6950 let Inst{31-25} = 0b1010010; 6951 let Inst{24-23} = sz; 6952 let Inst{22-21} = nregs; 6953 let Inst{20} = 0; 6954 let Inst{19-16} = imm4; 6955 let Inst{15-13} = 0b111; 6956 let Inst{12-10} = Pg; 6957 let Inst{9-5} = Rn; 6958 let Inst{4-0} = Zt; 6959 6960 let mayLoad = 1; 6961} 6962 6963multiclass sve_mem_eld_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList, 6964 string asm, Operand immtype> { 6965 def NAME : sve_mem_eld_si<sz, nregs, VecList, asm, immtype>; 6966 6967 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 6968 (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 6969} 6970 6971class sve_mem_eld_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList, 6972 string asm, RegisterOperand gprty> 6973: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 6974 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", 6975 "", 6976 []>, Sched<[]> { 6977 bits<3> Pg; 6978 bits<5> Rm; 6979 bits<5> Rn; 6980 bits<5> Zt; 6981 let Inst{31-25} = 0b1010010; 6982 let Inst{24-23} = sz; 6983 let Inst{22-21} = nregs; 6984 let Inst{20-16} = Rm; 6985 let Inst{15-13} = 0b110; 6986 let Inst{12-10} = Pg; 6987 let Inst{9-5} = Rn; 6988 let Inst{4-0} = Zt; 6989 6990 let mayLoad = 1; 6991} 6992 6993//===----------------------------------------------------------------------===// 6994// SVE Memory - 32-bit Gather and Unsized Contiguous Group 6995//===----------------------------------------------------------------------===// 6996 6997// bit xs is '1' if offsets are signed 6998// bit scaled is '1' if the offsets are scaled 6999class sve_mem_32b_gld_sv<bits<4> opc, bit xs, bit scaled, string asm, 7000 RegisterOperand zprext> 7001: I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 7002 asm, "\t$Zt, $Pg/z, [$Rn, $Zm]", 7003 "", 7004 []>, Sched<[]> { 7005 bits<3> Pg; 7006 bits<5> Rn; 7007 bits<5> Zm; 7008 bits<5> Zt; 7009 let Inst{31-25} = 0b1000010; 7010 let Inst{24-23} = opc{3-2}; 7011 let Inst{22} = xs; 7012 let Inst{21} = scaled; 7013 let Inst{20-16} = Zm; 7014 let Inst{15} = 0b0; 7015 let Inst{14-13} = opc{1-0}; 7016 let Inst{12-10} = Pg; 7017 let Inst{9-5} = Rn; 7018 let Inst{4-0} = Zt; 7019 7020 let mayLoad = 1; 7021 let Defs = !if(!eq(opc{0}, 1), [FFR], []); 7022 let Uses = !if(!eq(opc{0}, 1), [FFR], []); 7023} 7024 7025multiclass sve_mem_32b_gld_sv_32_scaled<bits<4> opc, string asm, 7026 SDPatternOperator sxtw_op, 7027 SDPatternOperator uxtw_op, 7028 RegisterOperand sxtw_opnd, 7029 RegisterOperand uxtw_opnd, 7030 ValueType vt> { 7031 def _UXTW_SCALED_REAL : sve_mem_32b_gld_sv<opc, 0, 1, asm, uxtw_opnd>; 7032 def _SXTW_SCALED_REAL : sve_mem_32b_gld_sv<opc, 1, 1, asm, sxtw_opnd>; 7033 7034 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7035 (!cast<Instruction>(NAME # _UXTW_SCALED_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>; 7036 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7037 (!cast<Instruction>(NAME # _SXTW_SCALED_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>; 7038 7039 // We need a layer of indirection because early machine code passes balk at 7040 // physical register (i.e. FFR) uses that have no previous definition. 7041 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 7042 def _UXTW_SCALED : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), []>, 7043 PseudoInstExpansion<(!cast<Instruction>(NAME # _UXTW_SCALED_REAL) Z_s:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>; 7044 def _SXTW_SCALED : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), []>, 7045 PseudoInstExpansion<(!cast<Instruction>(NAME # _SXTW_SCALED_REAL) Z_s:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>; 7046 } 7047 7048 def : Pat<(nxv4i32 (uxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$indices), vt)), 7049 (!cast<Instruction>(NAME # _UXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>; 7050 def : Pat<(nxv4i32 (sxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$indices), vt)), 7051 (!cast<Instruction>(NAME # _SXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>; 7052} 7053 7054multiclass sve_mem_32b_gld_vs_32_unscaled<bits<4> opc, string asm, 7055 SDPatternOperator sxtw_op, 7056 SDPatternOperator uxtw_op, 7057 RegisterOperand sxtw_opnd, 7058 RegisterOperand uxtw_opnd, 7059 ValueType vt> { 7060 def _UXTW_REAL : sve_mem_32b_gld_sv<opc, 0, 0, asm, uxtw_opnd>; 7061 def _SXTW_REAL : sve_mem_32b_gld_sv<opc, 1, 0, asm, sxtw_opnd>; 7062 7063 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7064 (!cast<Instruction>(NAME # _UXTW_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>; 7065 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7066 (!cast<Instruction>(NAME # _SXTW_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>; 7067 7068 // We need a layer of indirection because early machine code passes balk at 7069 // physical register (i.e. FFR) uses that have no previous definition. 7070 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 7071 def _UXTW : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), []>, 7072 PseudoInstExpansion<(!cast<Instruction>(NAME # _UXTW_REAL) Z_s:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>; 7073 def _SXTW : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), []>, 7074 PseudoInstExpansion<(!cast<Instruction>(NAME # _SXTW_REAL) Z_s:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>; 7075 } 7076 7077 def : Pat<(nxv4i32 (uxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt)), 7078 (!cast<Instruction>(NAME # _UXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 7079 def : Pat<(nxv4i32 (sxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt)), 7080 (!cast<Instruction>(NAME # _SXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 7081} 7082 7083 7084class sve_mem_32b_gld_vi<bits<4> opc, string asm, Operand imm_ty> 7085: I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 7086 asm, "\t$Zt, $Pg/z, [$Zn, $imm5]", 7087 "", 7088 []>, Sched<[]> { 7089 bits<3> Pg; 7090 bits<5> Zn; 7091 bits<5> Zt; 7092 bits<5> imm5; 7093 let Inst{31-25} = 0b1000010; 7094 let Inst{24-23} = opc{3-2}; 7095 let Inst{22-21} = 0b01; 7096 let Inst{20-16} = imm5; 7097 let Inst{15} = 0b1; 7098 let Inst{14-13} = opc{1-0}; 7099 let Inst{12-10} = Pg; 7100 let Inst{9-5} = Zn; 7101 let Inst{4-0} = Zt; 7102 7103 let mayLoad = 1; 7104 let Defs = !if(!eq(opc{0}, 1), [FFR], []); 7105 let Uses = !if(!eq(opc{0}, 1), [FFR], []); 7106} 7107 7108multiclass sve_mem_32b_gld_vi_32_ptrs<bits<4> opc, string asm, Operand imm_ty, 7109 SDPatternOperator op, ValueType vt> { 7110 def _IMM_REAL : sve_mem_32b_gld_vi<opc, asm, imm_ty>; 7111 7112 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]", 7113 (!cast<Instruction>(NAME # _IMM_REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>; 7114 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]", 7115 (!cast<Instruction>(NAME # _IMM_REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>; 7116 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]", 7117 (!cast<Instruction>(NAME # _IMM_REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>; 7118 7119 // We need a layer of indirection because early machine code passes balk at 7120 // physical register (i.e. FFR) uses that have no previous definition. 7121 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 7122 def _IMM : Pseudo<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), []>, 7123 PseudoInstExpansion<(!cast<Instruction>(NAME # _IMM_REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5)>; 7124 } 7125 7126 def : Pat<(nxv4i32 (op (nxv4i1 PPR:$gp), (nxv4i32 ZPR:$ptrs), imm_ty:$index, vt)), 7127 (!cast<Instruction>(NAME # _IMM) PPR:$gp, ZPR:$ptrs, imm_ty:$index)>; 7128} 7129 7130class sve_mem_prfm_si<bits<2> msz, string asm> 7131: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, simm6s1:$imm6), 7132 asm, "\t$prfop, $Pg, [$Rn, $imm6, mul vl]", 7133 "", 7134 []>, Sched<[]> { 7135 bits<5> Rn; 7136 bits<3> Pg; 7137 bits<6> imm6; 7138 bits<4> prfop; 7139 let Inst{31-22} = 0b1000010111; 7140 let Inst{21-16} = imm6; 7141 let Inst{15} = 0b0; 7142 let Inst{14-13} = msz; 7143 let Inst{12-10} = Pg; 7144 let Inst{9-5} = Rn; 7145 let Inst{4} = 0b0; 7146 let Inst{3-0} = prfop; 7147 7148 let hasSideEffects = 1; 7149} 7150 7151multiclass sve_mem_prfm_si<bits<2> msz, string asm> { 7152 def NAME : sve_mem_prfm_si<msz, asm>; 7153 7154 def : InstAlias<asm # "\t$prfop, $Pg, [$Rn]", 7155 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 7156} 7157 7158class sve_mem_prfm_ss<bits<3> opc, string asm, RegisterOperand gprty> 7159: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 7160 asm, "\t$prfop, $Pg, [$Rn, $Rm]", 7161 "", 7162 []>, Sched<[]> { 7163 bits<5> Rm; 7164 bits<5> Rn; 7165 bits<3> Pg; 7166 bits<4> prfop; 7167 let Inst{31-25} = 0b1000010; 7168 let Inst{24-23} = opc{2-1}; 7169 let Inst{22-21} = 0b00; 7170 let Inst{20-16} = Rm; 7171 let Inst{15} = 0b1; 7172 let Inst{14} = opc{0}; 7173 let Inst{13} = 0b0; 7174 let Inst{12-10} = Pg; 7175 let Inst{9-5} = Rn; 7176 let Inst{4} = 0b0; 7177 let Inst{3-0} = prfop; 7178 7179 let hasSideEffects = 1; 7180} 7181 7182class sve_mem_32b_prfm_sv<bits<2> msz, bit xs, string asm, 7183 RegisterOperand zprext> 7184: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 7185 asm, "\t$prfop, $Pg, [$Rn, $Zm]", 7186 "", 7187 []>, Sched<[]> { 7188 bits<3> Pg; 7189 bits<5> Rn; 7190 bits<5> Zm; 7191 bits<4> prfop; 7192 let Inst{31-23} = 0b100001000; 7193 let Inst{22} = xs; 7194 let Inst{21} = 0b1; 7195 let Inst{20-16} = Zm; 7196 let Inst{15} = 0b0; 7197 let Inst{14-13} = msz; 7198 let Inst{12-10} = Pg; 7199 let Inst{9-5} = Rn; 7200 let Inst{4} = 0b0; 7201 let Inst{3-0} = prfop; 7202 7203 let hasSideEffects = 1; 7204} 7205 7206multiclass sve_mem_32b_prfm_sv_scaled<bits<2> msz, string asm, 7207 RegisterOperand sxtw_opnd, 7208 RegisterOperand uxtw_opnd, 7209 SDPatternOperator op_sxtw, 7210 SDPatternOperator op_uxtw> { 7211 def _UXTW_SCALED : sve_mem_32b_prfm_sv<msz, 0, asm, uxtw_opnd>; 7212 def _SXTW_SCALED : sve_mem_32b_prfm_sv<msz, 1, asm, sxtw_opnd>; 7213 7214 def : Pat<(op_uxtw (nxv4i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv4i32 uxtw_opnd:$Zm), (i32 sve_prfop:$prfop)), 7215 (!cast<Instruction>(NAME # _UXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>; 7216 7217 def : Pat<(op_sxtw (nxv4i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv4i32 sxtw_opnd:$Zm), (i32 sve_prfop:$prfop)), 7218 (!cast<Instruction>(NAME # _SXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>; 7219} 7220 7221class sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty> 7222: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 7223 asm, "\t$prfop, $Pg, [$Zn, $imm5]", 7224 "", 7225 []>, Sched<[]> { 7226 bits<3> Pg; 7227 bits<5> Zn; 7228 bits<5> imm5; 7229 bits<4> prfop; 7230 let Inst{31-25} = 0b1000010; 7231 let Inst{24-23} = msz; 7232 let Inst{22-21} = 0b00; 7233 let Inst{20-16} = imm5; 7234 let Inst{15-13} = 0b111; 7235 let Inst{12-10} = Pg; 7236 let Inst{9-5} = Zn; 7237 let Inst{4} = 0b0; 7238 let Inst{3-0} = prfop; 7239} 7240 7241multiclass sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty, SDPatternOperator op> { 7242 def NAME : sve_mem_32b_prfm_vi<msz, asm, imm_ty>; 7243 7244 def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]", 7245 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>; 7246 7247 def : Pat<(op (nxv4i1 PPR_3b:$Pg), (nxv4i32 ZPR32:$Zn), (i64 imm_ty:$imm), (i32 sve_prfop:$prfop)), 7248 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR_3b:$Pg, ZPR32:$Zn, imm_ty:$imm)>; 7249} 7250 7251class sve_mem_z_fill<string asm> 7252: I<(outs ZPRAny:$Zt), (ins GPR64sp:$Rn, simm9:$imm9), 7253 asm, "\t$Zt, [$Rn, $imm9, mul vl]", 7254 "", 7255 []>, Sched<[]> { 7256 bits<5> Rn; 7257 bits<5> Zt; 7258 bits<9> imm9; 7259 let Inst{31-22} = 0b1000010110; 7260 let Inst{21-16} = imm9{8-3}; 7261 let Inst{15-13} = 0b010; 7262 let Inst{12-10} = imm9{2-0}; 7263 let Inst{9-5} = Rn; 7264 let Inst{4-0} = Zt; 7265 7266 let mayLoad = 1; 7267} 7268 7269multiclass sve_mem_z_fill<string asm> { 7270 def NAME : sve_mem_z_fill<asm>; 7271 7272 def : InstAlias<asm # "\t$Zt, [$Rn]", 7273 (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>; 7274} 7275 7276class sve_mem_p_fill<string asm> 7277: I<(outs PPRAny:$Pt), (ins GPR64sp:$Rn, simm9:$imm9), 7278 asm, "\t$Pt, [$Rn, $imm9, mul vl]", 7279 "", 7280 []>, Sched<[]> { 7281 bits<4> Pt; 7282 bits<5> Rn; 7283 bits<9> imm9; 7284 let Inst{31-22} = 0b1000010110; 7285 let Inst{21-16} = imm9{8-3}; 7286 let Inst{15-13} = 0b000; 7287 let Inst{12-10} = imm9{2-0}; 7288 let Inst{9-5} = Rn; 7289 let Inst{4} = 0b0; 7290 let Inst{3-0} = Pt; 7291 7292 let mayLoad = 1; 7293} 7294 7295multiclass sve_mem_p_fill<string asm> { 7296 def NAME : sve_mem_p_fill<asm>; 7297 7298 def : InstAlias<asm # "\t$Pt, [$Rn]", 7299 (!cast<Instruction>(NAME) PPRAny:$Pt, GPR64sp:$Rn, 0), 1>; 7300} 7301 7302class sve2_mem_gldnt_vs_base<bits<5> opc, dag iops, string asm, 7303 RegisterOperand VecList> 7304: I<(outs VecList:$Zt), iops, 7305 asm, "\t$Zt, $Pg/z, [$Zn, $Rm]", 7306 "", 7307 []>, Sched<[]> { 7308 bits<3> Pg; 7309 bits<5> Rm; 7310 bits<5> Zn; 7311 bits<5> Zt; 7312 let Inst{31} = 0b1; 7313 let Inst{30} = opc{4}; 7314 let Inst{29-25} = 0b00010; 7315 let Inst{24-23} = opc{3-2}; 7316 let Inst{22-21} = 0b00; 7317 let Inst{20-16} = Rm; 7318 let Inst{15} = 0b1; 7319 let Inst{14-13} = opc{1-0}; 7320 let Inst{12-10} = Pg; 7321 let Inst{9-5} = Zn; 7322 let Inst{4-0} = Zt; 7323 7324 let mayLoad = 1; 7325} 7326 7327multiclass sve2_mem_gldnt_vs_32_ptrs<bits<5> opc, string asm, 7328 SDPatternOperator op, 7329 ValueType vt> { 7330 def _REAL : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 7331 asm, Z_s>; 7332 7333 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]", 7334 (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 0>; 7335 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]", 7336 (!cast<Instruction>(NAME # _REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 0>; 7337 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]", 7338 (!cast<Instruction>(NAME # _REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 1>; 7339 7340 def : Pat <(nxv4i32 (op (nxv4i1 PPR3bAny:$Pg), (nxv4i32 ZPR32:$Zd), (i64 GPR64:$Rm), vt)), 7341 (!cast<Instruction>(NAME # _REAL) PPR3bAny:$Pg, ZPR32:$Zd, GPR64:$Rm)>; 7342} 7343 7344multiclass sve2_mem_gldnt_vs_64_ptrs<bits<5> opc, string asm, 7345 SDPatternOperator op, 7346 ValueType vt> { 7347 def _REAL : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 7348 asm, Z_d>; 7349 7350 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]", 7351 (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 0>; 7352 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]", 7353 (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 0>; 7354 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]", 7355 (!cast<Instruction>(NAME # _REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>; 7356 7357 def : Pat <(nxv2i64 (op (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zd), (i64 GPR64:$Rm), vt)), 7358 (!cast<Instruction>(NAME # _REAL) PPR3bAny:$Pg, ZPR64:$Zd, GPR64:$Rm)>; 7359} 7360 7361//===----------------------------------------------------------------------===// 7362// SVE Memory - 64-bit Gather Group 7363//===----------------------------------------------------------------------===// 7364 7365// bit xs is '1' if offsets are signed 7366// bit scaled is '1' if the offsets are scaled 7367// bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl) 7368class sve_mem_64b_gld_sv<bits<4> opc, bit xs, bit scaled, bit lsl, string asm, 7369 RegisterOperand zprext> 7370: I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 7371 asm, "\t$Zt, $Pg/z, [$Rn, $Zm]", 7372 "", 7373 []>, Sched<[]> { 7374 bits<3> Pg; 7375 bits<5> Rn; 7376 bits<5> Zm; 7377 bits<5> Zt; 7378 let Inst{31-25} = 0b1100010; 7379 let Inst{24-23} = opc{3-2}; 7380 let Inst{22} = xs; 7381 let Inst{21} = scaled; 7382 let Inst{20-16} = Zm; 7383 let Inst{15} = lsl; 7384 let Inst{14-13} = opc{1-0}; 7385 let Inst{12-10} = Pg; 7386 let Inst{9-5} = Rn; 7387 let Inst{4-0} = Zt; 7388 7389 let mayLoad = 1; 7390 let Defs = !if(!eq(opc{0}, 1), [FFR], []); 7391 let Uses = !if(!eq(opc{0}, 1), [FFR], []); 7392} 7393 7394multiclass sve_mem_64b_gld_sv_32_scaled<bits<4> opc, string asm, 7395 SDPatternOperator sxtw_op, 7396 SDPatternOperator uxtw_op, 7397 RegisterOperand sxtw_opnd, 7398 RegisterOperand uxtw_opnd, 7399 ValueType vt> { 7400 def _UXTW_SCALED_REAL : sve_mem_64b_gld_sv<opc, 0, 1, 0, asm, uxtw_opnd>; 7401 def _SXTW_SCALED_REAL : sve_mem_64b_gld_sv<opc, 1, 1, 0, asm, sxtw_opnd>; 7402 7403 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7404 (!cast<Instruction>(NAME # _UXTW_SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>; 7405 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7406 (!cast<Instruction>(NAME # _SXTW_SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>; 7407 7408 // We need a layer of indirection because early machine code passes balk at 7409 // physical register (i.e. FFR) uses that have no previous definition. 7410 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 7411 def _UXTW_SCALED : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), []>, 7412 PseudoInstExpansion<(!cast<Instruction>(NAME # _UXTW_SCALED_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>; 7413 def _SXTW_SCALED : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), []>, 7414 PseudoInstExpansion<(!cast<Instruction>(NAME # _SXTW_SCALED_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>; 7415 } 7416 7417 def : Pat<(nxv2i64 (uxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)), 7418 (!cast<Instruction>(NAME # _UXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>; 7419 def : Pat<(nxv2i64 (sxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)), 7420 (!cast<Instruction>(NAME # _SXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>; 7421} 7422 7423multiclass sve_mem_64b_gld_vs_32_unscaled<bits<4> opc, string asm, 7424 SDPatternOperator sxtw_op, 7425 SDPatternOperator uxtw_op, 7426 RegisterOperand sxtw_opnd, 7427 RegisterOperand uxtw_opnd, 7428 ValueType vt> { 7429 def _UXTW_REAL : sve_mem_64b_gld_sv<opc, 0, 0, 0, asm, uxtw_opnd>; 7430 def _SXTW_REAL : sve_mem_64b_gld_sv<opc, 1, 0, 0, asm, sxtw_opnd>; 7431 7432 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7433 (!cast<Instruction>(NAME # _UXTW_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>; 7434 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7435 (!cast<Instruction>(NAME # _SXTW_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>; 7436 7437 // We need a layer of indirection because early machine code passes balk at 7438 // physical register (i.e. FFR) uses that have no previous definition. 7439 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 7440 def _UXTW : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), []>, 7441 PseudoInstExpansion<(!cast<Instruction>(NAME # _UXTW_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>; 7442 def _SXTW : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), []>, 7443 PseudoInstExpansion<(!cast<Instruction>(NAME # _SXTW_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>; 7444 } 7445 7446 def : Pat<(nxv2i64 (uxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)), 7447 (!cast<Instruction>(NAME # _UXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 7448 def : Pat<(nxv2i64 (sxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)), 7449 (!cast<Instruction>(NAME # _SXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 7450} 7451 7452multiclass sve_mem_64b_gld_sv2_64_scaled<bits<4> opc, string asm, 7453 SDPatternOperator op, 7454 RegisterOperand zprext, ValueType vt> { 7455 def _SCALED_REAL : sve_mem_64b_gld_sv<opc, 1, 1, 1, asm, zprext>; 7456 7457 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7458 (!cast<Instruction>(NAME # _SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>; 7459 7460 // We need a layer of indirection because early machine code passes balk at 7461 // physical register (i.e. FFR) uses that have no previous definition. 7462 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 7463 def _SCALED : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), []>, 7464 PseudoInstExpansion<(!cast<Instruction>(NAME # _SCALED_REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm)>; 7465 } 7466 7467 def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)), 7468 (!cast<Instruction>(NAME # _SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>; 7469} 7470 7471multiclass sve_mem_64b_gld_vs2_64_unscaled<bits<4> opc, string asm, 7472 SDPatternOperator op, ValueType vt> { 7473 def _REAL : sve_mem_64b_gld_sv<opc, 1, 0, 1, asm, ZPR64ExtLSL8>; 7474 7475 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]", 7476 (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>; 7477 7478 // We need a layer of indirection because early machine code passes balk at 7479 // physical register (i.e. FFR) uses that have no previous definition. 7480 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 7481 def "" : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), []>, 7482 PseudoInstExpansion<(!cast<Instruction>(NAME # _REAL) Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm)>; 7483 } 7484 7485 def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)), 7486 (!cast<Instruction>(NAME) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>; 7487} 7488 7489class sve_mem_64b_gld_vi<bits<4> opc, string asm, Operand imm_ty> 7490: I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 7491 asm, "\t$Zt, $Pg/z, [$Zn, $imm5]", 7492 "", 7493 []>, Sched<[]> { 7494 bits<3> Pg; 7495 bits<5> Zn; 7496 bits<5> Zt; 7497 bits<5> imm5; 7498 let Inst{31-25} = 0b1100010; 7499 let Inst{24-23} = opc{3-2}; 7500 let Inst{22-21} = 0b01; 7501 let Inst{20-16} = imm5; 7502 let Inst{15} = 0b1; 7503 let Inst{14-13} = opc{1-0}; 7504 let Inst{12-10} = Pg; 7505 let Inst{9-5} = Zn; 7506 let Inst{4-0} = Zt; 7507 7508 let mayLoad = 1; 7509 let Defs = !if(!eq(opc{0}, 1), [FFR], []); 7510 let Uses = !if(!eq(opc{0}, 1), [FFR], []); 7511} 7512 7513multiclass sve_mem_64b_gld_vi_64_ptrs<bits<4> opc, string asm, Operand imm_ty, 7514 SDPatternOperator op, ValueType vt> { 7515 def _IMM_REAL : sve_mem_64b_gld_vi<opc, asm, imm_ty>; 7516 7517 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]", 7518 (!cast<Instruction>(NAME # _IMM_REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>; 7519 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]", 7520 (!cast<Instruction>(NAME # _IMM_REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>; 7521 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]", 7522 (!cast<Instruction>(NAME # _IMM_REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>; 7523 7524 // We need a layer of indirection because early machine code passes balk at 7525 // physical register (i.e. FFR) uses that have no previous definition. 7526 let hasSideEffects = 1, hasNoSchedulingInfo = 1 in { 7527 def _IMM : Pseudo<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), []>, 7528 PseudoInstExpansion<(!cast<Instruction>(NAME # _IMM_REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5)>; 7529 } 7530 7531 def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), (nxv2i64 ZPR:$ptrs), imm_ty:$index, vt)), 7532 (!cast<Instruction>(NAME # _IMM) PPR:$gp, ZPR:$ptrs, imm_ty:$index)>; 7533} 7534 7535// bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl) 7536class sve_mem_64b_prfm_sv<bits<2> msz, bit xs, bit lsl, string asm, 7537 RegisterOperand zprext> 7538: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 7539 asm, "\t$prfop, $Pg, [$Rn, $Zm]", 7540 "", 7541 []>, Sched<[]> { 7542 bits<3> Pg; 7543 bits<5> Rn; 7544 bits<5> Zm; 7545 bits<4> prfop; 7546 let Inst{31-23} = 0b110001000; 7547 let Inst{22} = xs; 7548 let Inst{21} = 0b1; 7549 let Inst{20-16} = Zm; 7550 let Inst{15} = lsl; 7551 let Inst{14-13} = msz; 7552 let Inst{12-10} = Pg; 7553 let Inst{9-5} = Rn; 7554 let Inst{4} = 0b0; 7555 let Inst{3-0} = prfop; 7556 7557 let hasSideEffects = 1; 7558} 7559 7560multiclass sve_mem_64b_prfm_sv_ext_scaled<bits<2> msz, string asm, 7561 RegisterOperand sxtw_opnd, 7562 RegisterOperand uxtw_opnd, 7563 SDPatternOperator op_sxtw, 7564 SDPatternOperator op_uxtw> { 7565 def _UXTW_SCALED : sve_mem_64b_prfm_sv<msz, 0, 0, asm, uxtw_opnd>; 7566 def _SXTW_SCALED : sve_mem_64b_prfm_sv<msz, 1, 0, asm, sxtw_opnd>; 7567 7568 def : Pat<(op_uxtw (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 uxtw_opnd:$Zm), (i32 sve_prfop:$prfop)), 7569 (!cast<Instruction>(NAME # _UXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>; 7570 7571 def : Pat<(op_sxtw (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 sxtw_opnd:$Zm), (i32 sve_prfop:$prfop)), 7572 (!cast<Instruction>(NAME # _SXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>; 7573 7574} 7575 7576multiclass sve_mem_64b_prfm_sv_lsl_scaled<bits<2> msz, string asm, 7577 RegisterOperand zprext, SDPatternOperator frag> { 7578 def NAME : sve_mem_64b_prfm_sv<msz, 1, 1, asm, zprext>; 7579 7580 def : Pat<(frag (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 zprext:$Zm), (i32 sve_prfop:$prfop)), 7581 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm)>; 7582 7583} 7584 7585class sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty> 7586: I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 7587 asm, "\t$prfop, $Pg, [$Zn, $imm5]", 7588 "", 7589 []>, Sched<[]> { 7590 bits<3> Pg; 7591 bits<5> Zn; 7592 bits<5> imm5; 7593 bits<4> prfop; 7594 let Inst{31-25} = 0b1100010; 7595 let Inst{24-23} = msz; 7596 let Inst{22-21} = 0b00; 7597 let Inst{20-16} = imm5; 7598 let Inst{15-13} = 0b111; 7599 let Inst{12-10} = Pg; 7600 let Inst{9-5} = Zn; 7601 let Inst{4} = 0b0; 7602 let Inst{3-0} = prfop; 7603 7604 let hasSideEffects = 1; 7605} 7606 7607multiclass sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty, SDPatternOperator op> { 7608 def NAME : sve_mem_64b_prfm_vi<msz, asm, imm_ty>; 7609 7610 def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]", 7611 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>; 7612 7613 def : Pat<(op (nxv2i1 PPR_3b:$Pg), (nxv2i64 ZPR32:$Zn), (i64 imm_ty:$imm), (i32 sve_prfop:$prfop)), 7614 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR_3b:$Pg, ZPR32:$Zn, imm_ty:$imm)>; 7615} 7616 7617//===----------------------------------------------------------------------===// 7618// SVE Compute Vector Address Group 7619//===----------------------------------------------------------------------===// 7620 7621class sve_int_bin_cons_misc_0_a<bits<2> opc, bits<2> msz, string asm, 7622 ZPRRegOp zprty, RegisterOperand zprext> 7623: I<(outs zprty:$Zd), (ins zprty:$Zn, zprext:$Zm), 7624 asm, "\t$Zd, [$Zn, $Zm]", 7625 "", 7626 []>, Sched<[]> { 7627 bits<5> Zd; 7628 bits<5> Zn; 7629 bits<5> Zm; 7630 let Inst{31-24} = 0b00000100; 7631 let Inst{23-22} = opc; 7632 let Inst{21} = 0b1; 7633 let Inst{20-16} = Zm; 7634 let Inst{15-12} = 0b1010; 7635 let Inst{11-10} = msz; 7636 let Inst{9-5} = Zn; 7637 let Inst{4-0} = Zd; 7638} 7639 7640multiclass sve_int_bin_cons_misc_0_a_uxtw<bits<2> opc, string asm> { 7641 def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtUXTW8>; 7642 def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtUXTW16>; 7643 def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtUXTW32>; 7644 def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtUXTW64>; 7645} 7646 7647multiclass sve_int_bin_cons_misc_0_a_sxtw<bits<2> opc, string asm> { 7648 def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtSXTW8>; 7649 def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtSXTW16>; 7650 def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtSXTW32>; 7651 def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtSXTW64>; 7652} 7653 7654multiclass sve_int_bin_cons_misc_0_a_32_lsl<bits<2> opc, string asm> { 7655 def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR32, ZPR32ExtLSL8>; 7656 def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR32, ZPR32ExtLSL16>; 7657 def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR32, ZPR32ExtLSL32>; 7658 def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR32, ZPR32ExtLSL64>; 7659} 7660 7661multiclass sve_int_bin_cons_misc_0_a_64_lsl<bits<2> opc, string asm> { 7662 def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtLSL8>; 7663 def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtLSL16>; 7664 def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtLSL32>; 7665 def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtLSL64>; 7666} 7667 7668//===----------------------------------------------------------------------===// 7669// SVE Integer Misc - Unpredicated Group 7670//===----------------------------------------------------------------------===// 7671 7672class sve_int_bin_cons_misc_0_b<bits<2> sz, string asm, ZPRRegOp zprty> 7673: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm), 7674 asm, "\t$Zd, $Zn, $Zm", 7675 "", 7676 []>, Sched<[]> { 7677 bits<5> Zd; 7678 bits<5> Zm; 7679 bits<5> Zn; 7680 let Inst{31-24} = 0b00000100; 7681 let Inst{23-22} = sz; 7682 let Inst{21} = 0b1; 7683 let Inst{20-16} = Zm; 7684 let Inst{15-10} = 0b101100; 7685 let Inst{9-5} = Zn; 7686 let Inst{4-0} = Zd; 7687} 7688 7689multiclass sve_int_bin_cons_misc_0_b<string asm, SDPatternOperator op> { 7690 def _H : sve_int_bin_cons_misc_0_b<0b01, asm, ZPR16>; 7691 def _S : sve_int_bin_cons_misc_0_b<0b10, asm, ZPR32>; 7692 def _D : sve_int_bin_cons_misc_0_b<0b11, asm, ZPR64>; 7693 7694 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>; 7695 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>; 7696 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>; 7697} 7698 7699class sve_int_bin_cons_misc_0_c<bits<8> opc, string asm, ZPRRegOp zprty> 7700: I<(outs zprty:$Zd), (ins zprty:$Zn), 7701 asm, "\t$Zd, $Zn", 7702 "", 7703 []>, Sched<[]> { 7704 bits<5> Zd; 7705 bits<5> Zn; 7706 let Inst{31-24} = 0b00000100; 7707 let Inst{23-22} = opc{7-6}; 7708 let Inst{21} = 0b1; 7709 let Inst{20-16} = opc{5-1}; 7710 let Inst{15-11} = 0b10111; 7711 let Inst{10} = opc{0}; 7712 let Inst{9-5} = Zn; 7713 let Inst{4-0} = Zd; 7714} 7715 7716multiclass sve_int_bin_cons_misc_0_c_fexpa<string asm, SDPatternOperator op> { 7717 def _H : sve_int_bin_cons_misc_0_c<0b01000000, asm, ZPR16>; 7718 def _S : sve_int_bin_cons_misc_0_c<0b10000000, asm, ZPR32>; 7719 def _D : sve_int_bin_cons_misc_0_c<0b11000000, asm, ZPR64>; 7720 7721 def : SVE_1_Op_Pat<nxv8f16, op, nxv8i16, !cast<Instruction>(NAME # _H)>; 7722 def : SVE_1_Op_Pat<nxv4f32, op, nxv4i32, !cast<Instruction>(NAME # _S)>; 7723 def : SVE_1_Op_Pat<nxv2f64, op, nxv2i64, !cast<Instruction>(NAME # _D)>; 7724} 7725 7726//===----------------------------------------------------------------------===// 7727// SVE Integer Reduction Group 7728//===----------------------------------------------------------------------===// 7729 7730class sve_int_reduce<bits<2> sz8_32, bits<2> fmt, bits<3> opc, string asm, 7731 ZPRRegOp zprty, FPRasZPROperand dstOpType> 7732: I<(outs dstOpType:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn), 7733 asm, "\t$Vd, $Pg, $Zn", 7734 "", 7735 []>, Sched<[]> { 7736 bits<3> Pg; 7737 bits<5> Vd; 7738 bits<5> Zn; 7739 let Inst{31-24} = 0b00000100; 7740 let Inst{23-22} = sz8_32; 7741 let Inst{21} = 0b0; 7742 let Inst{20-19} = fmt; 7743 let Inst{18-16} = opc; 7744 let Inst{15-13} = 0b001; 7745 let Inst{12-10} = Pg; 7746 let Inst{9-5} = Zn; 7747 let Inst{4-0} = Vd; 7748} 7749 7750multiclass sve_int_reduce_0_saddv<bits<3> opc, string asm, 7751 SDPatternOperator op> { 7752 def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64asZPR>; 7753 def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64asZPR>; 7754 def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64asZPR>; 7755 7756 def : SVE_2_Op_Pat<nxv2i64, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 7757 def : SVE_2_Op_Pat<nxv2i64, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 7758 def : SVE_2_Op_Pat<nxv2i64, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 7759} 7760 7761multiclass sve_int_reduce_0_uaddv<bits<3> opc, string asm, 7762 SDPatternOperator op> { 7763 def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64asZPR>; 7764 def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64asZPR>; 7765 def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64asZPR>; 7766 def _D : sve_int_reduce<0b11, 0b00, opc, asm, ZPR64, FPR64asZPR>; 7767 7768 def : SVE_2_Op_Pat<nxv2i64, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 7769 def : SVE_2_Op_Pat<nxv2i64, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 7770 def : SVE_2_Op_Pat<nxv2i64, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 7771 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 7772} 7773 7774multiclass sve_int_reduce_1<bits<3> opc, string asm, 7775 SDPatternOperator op> { 7776 def _B : sve_int_reduce<0b00, 0b01, opc, asm, ZPR8, FPR8asZPR>; 7777 def _H : sve_int_reduce<0b01, 0b01, opc, asm, ZPR16, FPR16asZPR>; 7778 def _S : sve_int_reduce<0b10, 0b01, opc, asm, ZPR32, FPR32asZPR>; 7779 def _D : sve_int_reduce<0b11, 0b01, opc, asm, ZPR64, FPR64asZPR>; 7780 7781 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 7782 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 7783 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 7784 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 7785} 7786 7787multiclass sve_int_reduce_2<bits<3> opc, string asm, 7788 SDPatternOperator op> { 7789 def _B : sve_int_reduce<0b00, 0b11, opc, asm, ZPR8, FPR8asZPR>; 7790 def _H : sve_int_reduce<0b01, 0b11, opc, asm, ZPR16, FPR16asZPR>; 7791 def _S : sve_int_reduce<0b10, 0b11, opc, asm, ZPR32, FPR32asZPR>; 7792 def _D : sve_int_reduce<0b11, 0b11, opc, asm, ZPR64, FPR64asZPR>; 7793 7794 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>; 7795 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>; 7796 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>; 7797 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>; 7798} 7799 7800class sve_int_movprfx_pred<bits<2> sz8_32, bits<3> opc, string asm, 7801 ZPRRegOp zprty, string pg_suffix, dag iops> 7802: I<(outs zprty:$Zd), iops, 7803 asm, "\t$Zd, $Pg"#pg_suffix#", $Zn", 7804 "", 7805 []>, Sched<[]> { 7806 bits<3> Pg; 7807 bits<5> Zd; 7808 bits<5> Zn; 7809 let Inst{31-24} = 0b00000100; 7810 let Inst{23-22} = sz8_32; 7811 let Inst{21-19} = 0b010; 7812 let Inst{18-16} = opc; 7813 let Inst{15-13} = 0b001; 7814 let Inst{12-10} = Pg; 7815 let Inst{9-5} = Zn; 7816 let Inst{4-0} = Zd; 7817 7818 let ElementSize = zprty.ElementSize; 7819} 7820 7821multiclass sve_int_movprfx_pred_merge<bits<3> opc, string asm> { 7822let Constraints = "$Zd = $_Zd" in { 7823 def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/m", 7824 (ins ZPR8:$_Zd, PPR3bAny:$Pg, ZPR8:$Zn)>; 7825 def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/m", 7826 (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR16:$Zn)>; 7827 def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/m", 7828 (ins ZPR32:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn)>; 7829 def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/m", 7830 (ins ZPR64:$_Zd, PPR3bAny:$Pg, ZPR64:$Zn)>; 7831} 7832} 7833 7834multiclass sve_int_movprfx_pred_zero<bits<3> opc, string asm> { 7835 def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/z", 7836 (ins PPR3bAny:$Pg, ZPR8:$Zn)>; 7837 def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/z", 7838 (ins PPR3bAny:$Pg, ZPR16:$Zn)>; 7839 def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/z", 7840 (ins PPR3bAny:$Pg, ZPR32:$Zn)>; 7841 def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/z", 7842 (ins PPR3bAny:$Pg, ZPR64:$Zn)>; 7843} 7844 7845//===----------------------------------------------------------------------===// 7846// SVE Propagate Break Group 7847//===----------------------------------------------------------------------===// 7848 7849class sve_int_brkp<bits<2> opc, string asm> 7850: I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm), 7851 asm, "\t$Pd, $Pg/z, $Pn, $Pm", 7852 "", 7853 []>, Sched<[]> { 7854 bits<4> Pd; 7855 bits<4> Pg; 7856 bits<4> Pm; 7857 bits<4> Pn; 7858 let Inst{31-24} = 0b00100101; 7859 let Inst{23} = 0b0; 7860 let Inst{22} = opc{1}; 7861 let Inst{21-20} = 0b00; 7862 let Inst{19-16} = Pm; 7863 let Inst{15-14} = 0b11; 7864 let Inst{13-10} = Pg; 7865 let Inst{9} = 0b0; 7866 let Inst{8-5} = Pn; 7867 let Inst{4} = opc{0}; 7868 let Inst{3-0} = Pd; 7869 7870 let Defs = !if(!eq (opc{1}, 1), [NZCV], []); 7871} 7872 7873multiclass sve_int_brkp<bits<2> opc, string asm, SDPatternOperator op> { 7874 def NAME : sve_int_brkp<opc, asm>; 7875 7876 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>; 7877} 7878 7879 7880//===----------------------------------------------------------------------===// 7881// SVE Partition Break Group 7882//===----------------------------------------------------------------------===// 7883 7884class sve_int_brkn<bit S, string asm> 7885: I<(outs PPR8:$Pdm), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$_Pdm), 7886 asm, "\t$Pdm, $Pg/z, $Pn, $_Pdm", 7887 "", 7888 []>, Sched<[]> { 7889 bits<4> Pdm; 7890 bits<4> Pg; 7891 bits<4> Pn; 7892 let Inst{31-23} = 0b001001010; 7893 let Inst{22} = S; 7894 let Inst{21-14} = 0b01100001; 7895 let Inst{13-10} = Pg; 7896 let Inst{9} = 0b0; 7897 let Inst{8-5} = Pn; 7898 let Inst{4} = 0b0; 7899 let Inst{3-0} = Pdm; 7900 7901 let Constraints = "$Pdm = $_Pdm"; 7902 let Defs = !if(S, [NZCV], []); 7903} 7904 7905multiclass sve_int_brkn<bits<1> opc, string asm, SDPatternOperator op> { 7906 def NAME : sve_int_brkn<opc, asm>; 7907 7908 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>; 7909} 7910 7911class sve_int_break<bits<3> opc, string asm, string suffix, dag iops> 7912: I<(outs PPR8:$Pd), iops, 7913 asm, "\t$Pd, $Pg"#suffix#", $Pn", 7914 "", 7915 []>, Sched<[]> { 7916 bits<4> Pd; 7917 bits<4> Pg; 7918 bits<4> Pn; 7919 let Inst{31-24} = 0b00100101; 7920 let Inst{23-22} = opc{2-1}; 7921 let Inst{21-14} = 0b01000001; 7922 let Inst{13-10} = Pg; 7923 let Inst{9} = 0b0; 7924 let Inst{8-5} = Pn; 7925 let Inst{4} = opc{0}; 7926 let Inst{3-0} = Pd; 7927 7928 let Constraints = !if(!eq (opc{0}, 1), "$Pd = $_Pd", ""); 7929 let Defs = !if(!eq (opc{1}, 1), [NZCV], []); 7930 7931} 7932 7933multiclass sve_int_break_m<bits<3> opc, string asm, SDPatternOperator op> { 7934 def NAME : sve_int_break<opc, asm, "/m", (ins PPR8:$_Pd, PPRAny:$Pg, PPR8:$Pn)>; 7935 7936 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>; 7937} 7938 7939multiclass sve_int_break_z<bits<3> opc, string asm, SDPatternOperator op> { 7940 def NAME : sve_int_break<opc, asm, "/z", (ins PPRAny:$Pg, PPR8:$Pn)>; 7941 7942 def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>; 7943} 7944 7945//===----------------------------------------------------------------------===// 7946// SVE2 String Processing Group 7947//===----------------------------------------------------------------------===// 7948 7949class sve2_char_match<bit sz, bit opc, string asm, 7950 PPRRegOp pprty, ZPRRegOp zprty> 7951: I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm), 7952 asm, "\t$Pd, $Pg/z, $Zn, $Zm", 7953 "", 7954 []>, Sched<[]> { 7955 bits<4> Pd; 7956 bits<3> Pg; 7957 bits<5> Zm; 7958 bits<5> Zn; 7959 let Inst{31-23} = 0b010001010; 7960 let Inst{22} = sz; 7961 let Inst{21} = 0b1; 7962 let Inst{20-16} = Zm; 7963 let Inst{15-13} = 0b100; 7964 let Inst{12-10} = Pg; 7965 let Inst{9-5} = Zn; 7966 let Inst{4} = opc; 7967 let Inst{3-0} = Pd; 7968 7969 let Defs = [NZCV]; 7970 let isPTestLike = 1; 7971} 7972 7973multiclass sve2_char_match<bit opc, string asm, SDPatternOperator op> { 7974 def _B : sve2_char_match<0b0, opc, asm, PPR8, ZPR8>; 7975 def _H : sve2_char_match<0b1, opc, asm, PPR16, ZPR16>; 7976 7977 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>; 7978 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>; 7979} 7980 7981//===----------------------------------------------------------------------===// 7982// SVE2 Histogram Computation - Segment Group 7983//===----------------------------------------------------------------------===// 7984 7985class sve2_hist_gen_segment<string asm, SDPatternOperator op> 7986: I<(outs ZPR8:$Zd), (ins ZPR8:$Zn, ZPR8:$Zm), 7987 asm, "\t$Zd, $Zn, $Zm", 7988 "", 7989 [(set nxv16i8:$Zd, (op nxv16i8:$Zn, nxv16i8:$Zm))]>, Sched<[]> { 7990 bits<5> Zd; 7991 bits<5> Zn; 7992 bits<5> Zm; 7993 let Inst{31-21} = 0b01000101001; 7994 let Inst{20-16} = Zm; 7995 let Inst{15-10} = 0b101000; 7996 let Inst{9-5} = Zn; 7997 let Inst{4-0} = Zd; 7998} 7999 8000//===----------------------------------------------------------------------===// 8001// SVE2 Histogram Computation - Vector Group 8002//===----------------------------------------------------------------------===// 8003 8004class sve2_hist_gen_vector<bit sz, string asm, ZPRRegOp zprty> 8005: I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm), 8006 asm, "\t$Zd, $Pg/z, $Zn, $Zm", 8007 "", 8008 []>, Sched<[]> { 8009 bits<5> Zd; 8010 bits<5> Zn; 8011 bits<3> Pg; 8012 bits<5> Zm; 8013 let Inst{31-23} = 0b010001011; 8014 let Inst{22} = sz; 8015 let Inst{21} = 0b1; 8016 let Inst{20-16} = Zm; 8017 let Inst{15-13} = 0b110; 8018 let Inst{12-10} = Pg; 8019 let Inst{9-5} = Zn; 8020 let Inst{4-0} = Zd; 8021} 8022 8023multiclass sve2_hist_gen_vector<string asm, SDPatternOperator op> { 8024 def _S : sve2_hist_gen_vector<0b0, asm, ZPR32>; 8025 def _D : sve2_hist_gen_vector<0b1, asm, ZPR64>; 8026 8027 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>; 8028 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>; 8029} 8030 8031//===----------------------------------------------------------------------===// 8032// SVE2 Crypto Extensions Group 8033//===----------------------------------------------------------------------===// 8034 8035class sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty> 8036: I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm), 8037 asm, "\t$Zd, $Zn, $Zm", 8038 "", 8039 []>, Sched<[]> { 8040 bits<5> Zd; 8041 bits<5> Zn; 8042 bits<5> Zm; 8043 let Inst{31-21} = 0b01000101001; 8044 let Inst{20-16} = Zm; 8045 let Inst{15-11} = 0b11110; 8046 let Inst{10} = opc; 8047 let Inst{9-5} = Zn; 8048 let Inst{4-0} = Zd; 8049} 8050 8051multiclass sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty, 8052 SDPatternOperator op, ValueType vt> { 8053 def NAME : sve2_crypto_cons_bin_op<opc, asm, zprty>; 8054 def : SVE_2_Op_Pat<vt, op, vt, vt, !cast<Instruction>(NAME)>; 8055} 8056 8057class sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty> 8058: I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm), 8059 asm, "\t$Zdn, $_Zdn, $Zm", 8060 "", 8061 []>, Sched<[]> { 8062 bits<5> Zdn; 8063 bits<5> Zm; 8064 let Inst{31-17} = 0b010001010010001; 8065 let Inst{16} = opc{1}; 8066 let Inst{15-11} = 0b11100; 8067 let Inst{10} = opc{0}; 8068 let Inst{9-5} = Zm; 8069 let Inst{4-0} = Zdn; 8070 8071 let Constraints = "$Zdn = $_Zdn"; 8072} 8073 8074multiclass sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty, 8075 SDPatternOperator op, ValueType vt> { 8076 def NAME : sve2_crypto_des_bin_op<opc, asm, zprty>; 8077 def : SVE_2_Op_Pat<vt, op, vt, vt, !cast<Instruction>(NAME)>; 8078} 8079 8080class sve2_crypto_unary_op<bit opc, string asm, ZPRRegOp zprty> 8081: I<(outs zprty:$Zdn), (ins zprty:$_Zdn), 8082 asm, "\t$Zdn, $_Zdn", 8083 "", 8084 []>, Sched<[]> { 8085 bits<5> Zdn; 8086 let Inst{31-11} = 0b010001010010000011100; 8087 let Inst{10} = opc; 8088 let Inst{9-5} = 0b00000; 8089 let Inst{4-0} = Zdn; 8090 8091 let Constraints = "$Zdn = $_Zdn"; 8092} 8093 8094multiclass sve2_crypto_unary_op<bit opc, string asm, SDPatternOperator op> { 8095 def NAME : sve2_crypto_unary_op<opc, asm, ZPR8>; 8096 def : SVE_1_Op_Pat<nxv16i8, op, nxv16i8, !cast<Instruction>(NAME)>; 8097} 8098 8099//===----------------------------------------------------------------------===// 8100// SVE BFloat16 Group 8101//===----------------------------------------------------------------------===// 8102 8103class sve_bfloat_dot_base<bits<2> opc, string asm, string ops, dag iops> 8104: I<(outs ZPR32:$Zda), iops, asm, ops, "", []>, Sched<[]> { 8105 bits<5> Zda; 8106 bits<5> Zn; 8107 let Inst{31-21} = 0b01100100011; 8108 let Inst{15-14} = opc; 8109 let Inst{13-10} = 0b0000; 8110 let Inst{9-5} = Zn; 8111 let Inst{4-0} = Zda; 8112 8113 let Constraints = "$Zda = $_Zda"; 8114 let DestructiveInstType = DestructiveOther; 8115 let ElementSize = ElementSizeH; 8116} 8117 8118class sve_bfloat_dot<string asm> 8119: sve_bfloat_dot_base<0b10, asm, "\t$Zda, $Zn, $Zm", 8120 (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm)> { 8121 bits<5> Zm; 8122 let Inst{20-16} = Zm; 8123} 8124 8125multiclass sve_bfloat_dot<string asm, SDPatternOperator op> { 8126 def NAME : sve_bfloat_dot<asm>; 8127 def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16 ,!cast<Instruction>(NAME)>; 8128} 8129 8130class sve_bfloat_dot_indexed<string asm> 8131: sve_bfloat_dot_base<0b01, asm, "\t$Zda, $Zn, $Zm$iop", 8132 (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, VectorIndexS:$iop)> { 8133 bits<2> iop; 8134 bits<3> Zm; 8135 let Inst{20-19} = iop; 8136 let Inst{18-16} = Zm; 8137} 8138 8139multiclass sve_bfloat_dot_indexed<string asm, SDPatternOperator op> { 8140 def NAME : sve_bfloat_dot_indexed<asm>; 8141 def : SVE_4_Op_Imm_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16, i64, VectorIndexS_timm, !cast<Instruction>(NAME)>; 8142} 8143 8144class sve_bfloat_matmul<string asm> 8145: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm), 8146 asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> { 8147 bits<5> Zm; 8148 bits<5> Zda; 8149 bits<5> Zn; 8150 let Inst{31-21} = 0b01100100011; 8151 let Inst{20-16} = Zm; 8152 let Inst{15-10} = 0b111001; 8153 let Inst{9-5} = Zn; 8154 let Inst{4-0} = Zda; 8155 8156 let Constraints = "$Zda = $_Zda"; 8157 let DestructiveInstType = DestructiveOther; 8158 let ElementSize = ElementSizeH; 8159} 8160 8161multiclass sve_bfloat_matmul<string asm, SDPatternOperator op> { 8162 def NAME : sve_bfloat_matmul<asm>; 8163 def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16 ,!cast<Instruction>(NAME)>; 8164} 8165 8166class sve_bfloat_matmul_longvecl<bit BT, string asm> 8167: sve_bfloat_matmul<asm> { 8168 let Inst{23} = 0b1; 8169 let Inst{14-13} = 0b00; 8170 let Inst{10} = BT; 8171} 8172 8173multiclass sve_bfloat_matmul_longvecl<bit BT, string asm, SDPatternOperator op> { 8174 def NAME : sve_bfloat_matmul_longvecl<BT, asm>; 8175 def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16 ,!cast<Instruction>(NAME)>; 8176} 8177 8178class sve_bfloat_matmul_longvecl_idx<bit BT, string asm> 8179: sve_bfloat_dot_base<0b01, asm, "\t$Zda, $Zn, $Zm$iop", 8180 (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, VectorIndexH:$iop)> { 8181 bits<3> iop; 8182 bits<3> Zm; 8183 let Inst{23} = 0b1; 8184 let Inst{20-19} = iop{2-1}; 8185 let Inst{18-16} = Zm; 8186 let Inst{11} = iop{0}; 8187 let Inst{10} = BT; 8188} 8189 8190multiclass sve_bfloat_matmul_longvecl_idx<bit BT, string asm, SDPatternOperator op> { 8191 def NAME : sve_bfloat_matmul_longvecl_idx<BT, asm>; 8192 def : SVE_4_Op_Imm_Pat<nxv4f32, op, nxv4f32, nxv8bf16, nxv8bf16, i64, VectorIndexH_timm, !cast<Instruction>(NAME)>; 8193} 8194 8195class sve_bfloat_convert<bit N, string asm> 8196: I<(outs ZPR16:$Zd), (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn), 8197 asm, "\t$Zd, $Pg/m, $Zn", "", []>, Sched<[]> { 8198 bits<5> Zd; 8199 bits<3> Pg; 8200 bits<5> Zn; 8201 let Inst{31-25} = 0b0110010; 8202 let Inst{24} = N; 8203 let Inst{23-13} = 0b10001010101; 8204 let Inst{12-10} = Pg; 8205 let Inst{9-5} = Zn; 8206 let Inst{4-0} = Zd; 8207 8208 let Constraints = "$Zd = $_Zd"; 8209 let DestructiveInstType = DestructiveOther; 8210 let hasSideEffects = 1; 8211 let ElementSize = ElementSizeS; 8212} 8213 8214multiclass sve_bfloat_convert<bit N, string asm, SDPatternOperator op> { 8215 def NAME : sve_bfloat_convert<N, asm>; 8216 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i1, nxv4f32, !cast<Instruction>(NAME)>; 8217} 8218 8219//===----------------------------------------------------------------------===// 8220// SVE Integer Matrix Multiply Group 8221//===----------------------------------------------------------------------===// 8222 8223class sve_int_matmul<bits<2> uns, string asm> 8224: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR8:$Zm), asm, 8225 "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> { 8226 bits<5> Zda; 8227 bits<5> Zn; 8228 bits<5> Zm; 8229 let Inst{31-24} = 0b01000101; 8230 let Inst{23-22} = uns; 8231 let Inst{21} = 0; 8232 let Inst{20-16} = Zm; 8233 let Inst{15-10} = 0b100110; 8234 let Inst{9-5} = Zn; 8235 let Inst{4-0} = Zda; 8236 8237 let Constraints = "$Zda = $_Zda"; 8238 let DestructiveInstType = DestructiveOther; 8239 let ElementSize = ZPR32.ElementSize; 8240} 8241 8242multiclass sve_int_matmul<bits<2> uns, string asm, SDPatternOperator op> { 8243 def NAME : sve_int_matmul<uns, asm>; 8244 8245 def : SVE_3_Op_Pat<nxv4i32, op , nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>; 8246} 8247 8248//===----------------------------------------------------------------------===// 8249// SVE Integer Dot Product Mixed Sign Group 8250//===----------------------------------------------------------------------===// 8251 8252class sve_int_dot_mixed<string asm> 8253: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR8:$Zm), asm, 8254 "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> { 8255 bits<5> Zda; 8256 bits<5> Zn; 8257 bits<5> Zm; 8258 let Inst{31-21} = 0b01000100100; 8259 let Inst{20-16} = Zm; 8260 let Inst{15-10} = 0b011110; 8261 let Inst{9-5} = Zn; 8262 let Inst{4-0} = Zda; 8263 8264 let Constraints = "$Zda = $_Zda"; 8265 let DestructiveInstType = DestructiveOther; 8266 let ElementSize = ZPR32.ElementSize; 8267} 8268 8269multiclass sve_int_dot_mixed<string asm, SDPatternOperator op> { 8270 def NAME : sve_int_dot_mixed<asm>; 8271 8272 def : SVE_3_Op_Pat<nxv4i32, op , nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>; 8273} 8274 8275//===----------------------------------------------------------------------===// 8276// SVE Integer Dot Product Mixed Sign - Indexed Group 8277//===----------------------------------------------------------------------===// 8278 8279class sve_int_dot_mixed_indexed<bit U, string asm> 8280: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, VectorIndexS32b:$idx), 8281 asm, "\t$Zda, $Zn, $Zm$idx", "", []>, Sched<[]> { 8282 bits<5> Zda; 8283 bits<5> Zn; 8284 bits<3> Zm; 8285 bits<2> idx; 8286 let Inst{31-21} = 0b01000100101; 8287 let Inst{20-19} = idx; 8288 let Inst{18-16} = Zm; 8289 let Inst{15-11} = 0b00011; 8290 let Inst{10} = U; 8291 let Inst{9-5} = Zn; 8292 let Inst{4-0} = Zda; 8293 8294 let Constraints = "$Zda = $_Zda"; 8295 let DestructiveInstType = DestructiveOther; 8296 let ElementSize = ZPR32.ElementSize; 8297} 8298 8299multiclass sve_int_dot_mixed_indexed<bit U, string asm, SDPatternOperator op> { 8300 def NAME : sve_int_dot_mixed_indexed<U, asm>; 8301 8302 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME)>; 8303} 8304 8305//===----------------------------------------------------------------------===// 8306// SVE Floating Point Matrix Multiply Accumulate Group 8307//===----------------------------------------------------------------------===// 8308 8309class sve_fp_matrix_mla<bit sz, string asm, ZPRRegOp zprty> 8310: I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty:$Zm), 8311 asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> { 8312 bits<5> Zda; 8313 bits<5> Zn; 8314 bits<5> Zm; 8315 let Inst{31-23} = 0b011001001; 8316 let Inst{22} = sz; 8317 let Inst{21} = 1; 8318 let Inst{20-16} = Zm; 8319 let Inst{15-10} = 0b111001; 8320 let Inst{9-5} = Zn; 8321 let Inst{4-0} = Zda; 8322 8323 let Constraints = "$Zda = $_Zda"; 8324 let DestructiveInstType = DestructiveOther; 8325 let ElementSize = zprty.ElementSize; 8326} 8327 8328multiclass sve_fp_matrix_mla<bit sz, string asm, ZPRRegOp zprty, SDPatternOperator op, ValueType vt> { 8329 def NAME : sve_fp_matrix_mla<sz, asm, zprty>; 8330 8331 def : SVE_3_Op_Pat<vt, op , vt, vt, vt, !cast<Instruction>(NAME)>; 8332} 8333 8334//===----------------------------------------------------------------------===// 8335// SVE Memory - Contiguous Load And Replicate 256-bit Group 8336//===----------------------------------------------------------------------===// 8337 8338class sve_mem_ldor_si<bits<2> sz, string asm, RegisterOperand VecList> 8339: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s32:$imm4), 8340 asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> { 8341 bits<5> Zt; 8342 bits<5> Rn; 8343 bits<3> Pg; 8344 bits<4> imm4; 8345 let Inst{31-25} = 0b1010010; 8346 let Inst{24-23} = sz; 8347 let Inst{22-20} = 0b010; 8348 let Inst{19-16} = imm4; 8349 let Inst{15-13} = 0b001; 8350 let Inst{12-10} = Pg; 8351 let Inst{9-5} = Rn; 8352 let Inst{4-0} = Zt; 8353 8354 let mayLoad = 1; 8355} 8356 8357multiclass sve_mem_ldor_si<bits<2> sz, string asm, RegisterOperand listty, 8358 ZPRRegOp zprty, ValueType Ty, ValueType PredTy, SDNode Ld1ro> { 8359 def NAME : sve_mem_ldor_si<sz, asm, listty>; 8360 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 8361 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>; 8362 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]", 8363 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>; 8364 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]", 8365 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s32:$imm4), 0>; 8366 8367 // Base addressing mode 8368 def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$Pg), GPR64sp:$base)), 8369 (!cast<Instruction>(NAME) PPR3bAny:$Pg, GPR64sp:$base, (i64 0))>; 8370 let AddedComplexity = 2 in { 8371 // Reg + Imm addressing mode 8372 def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$Pg), (add GPR64:$base, (i64 simm4s32:$imm)))), 8373 (!cast<Instruction>(NAME) $Pg, $base, simm4s32:$imm)>; 8374 } 8375} 8376 8377class sve_mem_ldor_ss<bits<2> sz, string asm, RegisterOperand VecList, 8378 RegisterOperand gprty> 8379: I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 8380 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> { 8381 bits<5> Zt; 8382 bits<3> Pg; 8383 bits<5> Rn; 8384 bits<5> Rm; 8385 let Inst{31-25} = 0b1010010; 8386 let Inst{24-23} = sz; 8387 let Inst{22-21} = 0b01; 8388 let Inst{20-16} = Rm; 8389 let Inst{15-13} = 0; 8390 let Inst{12-10} = Pg; 8391 let Inst{9-5} = Rn; 8392 let Inst{4-0} = Zt; 8393 8394 let mayLoad = 1; 8395} 8396 8397multiclass sve_mem_ldor_ss<bits<2> sz, string asm, RegisterOperand listty, 8398 ZPRRegOp zprty, RegisterOperand gprty, ValueType Ty, 8399 ValueType PredTy, SDNode Ld1ro, ComplexPattern AddrCP> { 8400 def NAME : sve_mem_ldor_ss<sz, asm, listty, gprty>; 8401 8402 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]", 8403 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>; 8404 8405 def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$gp), (AddrCP GPR64sp:$base, gprty:$offset))), 8406 (!cast<Instruction>(NAME) PPR3bAny:$gp, GPR64sp:$base, gprty:$offset)>; 8407} 8408 8409//===----------------------------------------------------------------------===// 8410// SVE Interleave 128-bit Elements Group 8411//===----------------------------------------------------------------------===// 8412 8413class sve_int_perm_bin_perm_128_zz<bits<2> opc, bit P, string asm> 8414: I<(outs ZPR128:$Zd), (ins ZPR128:$Zn, ZPR128:$Zm), 8415 asm, "\t$Zd, $Zn, $Zm", 8416 "", 8417 []>, Sched<[]> { 8418 bits<5> Zd; 8419 bits<5> Zm; 8420 bits<5> Zn; 8421 let Inst{31-21} = 0b00000101101; 8422 let Inst{20-16} = Zm; 8423 let Inst{15-13} = 0b000; 8424 let Inst{12-11} = opc; 8425 let Inst{10} = P; 8426 let Inst{9-5} = Zn; 8427 let Inst{4-0} = Zd; 8428} 8429 8430multiclass sve_int_perm_bin_perm_128_zz<bits<2> opc, bit P, string asm, SDPatternOperator op> { 8431 def NAME : sve_int_perm_bin_perm_128_zz<opc, P, asm>; 8432 8433 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>; 8434 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>; 8435 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME)>; 8436 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>; 8437 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME)>; 8438 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>; 8439 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME)>; 8440 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>; 8441} 8442 8443/// Addressing modes 8444def am_sve_indexed_s4 :ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<-8,7>", [], [SDNPWantRoot]>; 8445def am_sve_indexed_s6 :ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<-32,31>", [], [SDNPWantRoot]>; 8446 8447def am_sve_regreg_lsl0 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<0>", []>; 8448def am_sve_regreg_lsl1 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<1>", []>; 8449def am_sve_regreg_lsl2 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<2>", []>; 8450def am_sve_regreg_lsl3 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<3>", []>; 8451 8452// Predicated pseudo floating point two operand instructions. 8453multiclass sve_fp_bin_pred_hfd<SDPatternOperator op> { 8454 def _UNDEF_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>; 8455 def _UNDEF_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>; 8456 def _UNDEF_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>; 8457 8458 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Pseudo>(NAME # _UNDEF_H)>; 8459 def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Pseudo>(NAME # _UNDEF_H)>; 8460 def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Pseudo>(NAME # _UNDEF_H)>; 8461 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Pseudo>(NAME # _UNDEF_S)>; 8462 def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Pseudo>(NAME # _UNDEF_S)>; 8463 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Pseudo>(NAME # _UNDEF_D)>; 8464} 8465 8466// Predicated pseudo integer two operand instructions. 8467multiclass sve_int_bin_pred_bhsd<SDPatternOperator op> { 8468 def _UNDEF_B : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>; 8469 def _UNDEF_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>; 8470 def _UNDEF_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>; 8471 def _UNDEF_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>; 8472 8473 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>; 8474 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>; 8475 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>; 8476 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>; 8477} 8478 8479// As sve_int_bin_pred but when only i32 and i64 vector types are required. 8480multiclass sve_int_bin_pred_sd<SDPatternOperator op> { 8481 def _UNDEF_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>; 8482 def _UNDEF_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>; 8483 8484 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>; 8485 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>; 8486} 8487 8488// Predicated pseudo integer two operand instructions. Second operand is an 8489// immediate specified by imm_[bhsd]. 8490multiclass sve_int_shift_pred_bhsd<SDPatternOperator op, 8491 ComplexPattern imm_b, ComplexPattern imm_h, 8492 ComplexPattern imm_s, ComplexPattern imm_d> { 8493 def _UNDEF_B : PredTwoOpImmPseudo<NAME # _B, ZPR8, Operand<i32>, FalseLanesUndef>; 8494 def _UNDEF_H : PredTwoOpImmPseudo<NAME # _H, ZPR16, Operand<i32>, FalseLanesUndef>; 8495 def _UNDEF_S : PredTwoOpImmPseudo<NAME # _S, ZPR32, Operand<i32>, FalseLanesUndef>; 8496 def _UNDEF_D : PredTwoOpImmPseudo<NAME # _D, ZPR64, Operand<i32>, FalseLanesUndef>; 8497 8498 def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, imm_b, !cast<Instruction>(NAME # _UNDEF_B)>; 8499 def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, imm_h, !cast<Instruction>(NAME # _UNDEF_H)>; 8500 def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, imm_s, !cast<Instruction>(NAME # _UNDEF_S)>; 8501 def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, imm_d, !cast<Instruction>(NAME # _UNDEF_D)>; 8502} 8503 8504multiclass sve_int_bin_pred_all_active_bhsd<SDPatternOperator op> { 8505 def _UNDEF_B : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>; 8506 def _UNDEF_H : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>; 8507 def _UNDEF_S : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>; 8508 def _UNDEF_D : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>; 8509 8510 def : SVE_2_Op_Pred_All_Active_Pt<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _UNDEF_B)>; 8511 def : SVE_2_Op_Pred_All_Active_Pt<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _UNDEF_H)>; 8512 def : SVE_2_Op_Pred_All_Active_Pt<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _UNDEF_S)>; 8513 def : SVE_2_Op_Pred_All_Active_Pt<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _UNDEF_D)>; 8514} 8515 8516