1 //=-- SVEInstrFormats.td - AArch64 SVE Instruction classes -*- tablegen -*--=//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // AArch64 Scalable Vector Extension (SVE) Instruction Class Definitions.
11 //===----------------------------------------------------------------------===//
13 // Helper class to hold conversions of legal fixed-length vector types.
14 class NEONType<ValueType VT> {
15 // The largest legal scalable vector type that can hold VT.
16 ValueType SVEContainer = !cond(
17 !eq(VT, v8i8): nxv16i8,
18 !eq(VT, v16i8): nxv16i8,
19 !eq(VT, v4i16): nxv8i16,
20 !eq(VT, v8i16): nxv8i16,
21 !eq(VT, v2i32): nxv4i32,
22 !eq(VT, v4i32): nxv4i32,
23 !eq(VT, v1i64): nxv2i64,
24 !eq(VT, v2i64): nxv2i64,
25 !eq(VT, v4f16): nxv8f16,
26 !eq(VT, v8f16): nxv8f16,
27 !eq(VT, v2f32): nxv4f32,
28 !eq(VT, v4f32): nxv4f32,
29 !eq(VT, v1f64): nxv2f64,
30 !eq(VT, v2f64): nxv2f64,
31 !eq(VT, v4bf16): nxv8bf16,
32 !eq(VT, v8bf16): nxv8bf16,
36 // Helper class to hold conversions of legal scalable vector types.
37 class SVEType<ValueType VT> {
38 // The largest legal scalable vector type that can hold VT.
39 // Non-matches return VT because only packed types remain.
40 ValueType Packed = !cond(
41 !eq(VT, nxv2f16): nxv8f16,
42 !eq(VT, nxv4f16): nxv8f16,
43 !eq(VT, nxv2f32): nxv4f32,
44 !eq(VT, nxv2bf16): nxv8bf16,
45 !eq(VT, nxv4bf16): nxv8bf16,
48 // The legal scalable vector that is half the length of VT.
49 ValueType HalfLength = !cond(
50 !eq(VT, nxv8f16): nxv4f16,
51 !eq(VT, nxv4f16): nxv2f16,
52 !eq(VT, nxv4f32): nxv2f32,
53 !eq(VT, nxv8bf16): nxv4bf16,
54 !eq(VT, nxv4bf16): nxv2bf16,
57 // The legal scalable vector that is quarter the length of VT.
58 ValueType QuarterLength = !cond(
59 !eq(VT, nxv8f16): nxv2f16,
60 !eq(VT, nxv8bf16): nxv2bf16,
63 // The 64-bit vector subreg of VT.
64 ValueType DSub = !cond(
65 !eq(VT, nxv16i8): v8i8,
66 !eq(VT, nxv8i16): v4i16,
67 !eq(VT, nxv4i32): v2i32,
68 !eq(VT, nxv2i64): v1i64,
69 !eq(VT, nxv2f16): v4f16,
70 !eq(VT, nxv4f16): v4f16,
71 !eq(VT, nxv8f16): v4f16,
72 !eq(VT, nxv2f32): v2f32,
73 !eq(VT, nxv4f32): v2f32,
74 !eq(VT, nxv2f64): v1f64,
75 !eq(VT, nxv2bf16): v4bf16,
76 !eq(VT, nxv4bf16): v4bf16,
77 !eq(VT, nxv8bf16): v4bf16,
80 // The 128-bit vector subreg of VT.
81 ValueType ZSub = !cond(
82 !eq(VT, nxv16i8): v16i8,
83 !eq(VT, nxv8i16): v8i16,
84 !eq(VT, nxv4i32): v4i32,
85 !eq(VT, nxv2i64): v2i64,
86 !eq(VT, nxv2f16): v8f16,
87 !eq(VT, nxv4f16): v8f16,
88 !eq(VT, nxv8f16): v8f16,
89 !eq(VT, nxv2f32): v4f32,
90 !eq(VT, nxv4f32): v4f32,
91 !eq(VT, nxv2f64): v2f64,
92 !eq(VT, nxv2bf16): v8bf16,
93 !eq(VT, nxv4bf16): v8bf16,
94 !eq(VT, nxv8bf16): v8bf16,
97 // The legal scalar used to hold a vector element.
98 ValueType EltAsScalar = !cond(
99 !eq(VT, nxv16i8): i32,
100 !eq(VT, nxv8i16): i32,
101 !eq(VT, nxv4i32): i32,
102 !eq(VT, nxv2i64): i64,
103 !eq(VT, nxv2f16): f16,
104 !eq(VT, nxv4f16): f16,
105 !eq(VT, nxv8f16): f16,
106 !eq(VT, nxv2f32): f32,
107 !eq(VT, nxv4f32): f32,
108 !eq(VT, nxv2f64): f64,
109 !eq(VT, nxv2bf16): bf16,
110 !eq(VT, nxv4bf16): bf16,
111 !eq(VT, nxv8bf16): bf16,
115 def SDT_AArch64Setcc : SDTypeProfile<1, 4, [
116 SDTCisVec<0>, SDTCisVec<1>, SDTCisVec<2>, SDTCisVec<3>,
117 SDTCVecEltisVT<0, i1>, SDTCVecEltisVT<1, i1>, SDTCisSameAs<2, 3>,
121 def AArch64setcc_z : SDNode<"AArch64ISD::SETCC_MERGE_ZERO", SDT_AArch64Setcc>;
122 def AArch64setcc_z_oneuse : PatFrag<(ops node:$pg, node:$op1, node:$op2, node:$cc),
123 (AArch64setcc_z node:$pg, node:$op1, node:$op2, node:$cc), [{
124 return N->hasOneUse();
127 def SVEPatternOperand : AsmOperandClass {
128 let Name = "SVEPattern";
129 let ParserMethod = "tryParseSVEPattern";
130 let PredicateMethod = "isSVEPattern";
131 let RenderMethod = "addImmOperands";
132 let DiagnosticType = "InvalidSVEPattern";
135 def sve_pred_enum : Operand<i32>, TImmLeaf<i32, [{
136 return (((uint32_t)Imm) < 32);
139 let PrintMethod = "printSVEPattern";
140 let ParserMatchClass = SVEPatternOperand;
143 def SVEVecLenSpecifierOperand : AsmOperandClass {
144 let Name = "SVEVecLenSpecifier";
145 let ParserMethod = "tryParseSVEVecLenSpecifier";
146 let PredicateMethod = "isSVEVecLenSpecifier";
147 let RenderMethod = "addImmOperands";
148 let DiagnosticType = "InvalidSVEVecLenSpecifier";
151 def sve_vec_len_specifier_enum : Operand<i32>, TImmLeaf<i32, [{
152 return (((uint32_t)Imm) < 2);
155 let PrintMethod = "printSVEVecLenSpecifier";
156 let ParserMatchClass = SVEVecLenSpecifierOperand;
159 def SVEPrefetchOperand : AsmOperandClass {
160 let Name = "SVEPrefetch";
161 let ParserMethod = "tryParsePrefetch<true>";
162 let PredicateMethod = "isPrefetch";
163 let RenderMethod = "addPrefetchOperands";
166 def sve_prfop : Operand<i32>, TImmLeaf<i32, [{
167 return (((uint32_t)Imm) <= 15);
169 let PrintMethod = "printPrefetchOp<true>";
170 let ParserMatchClass = SVEPrefetchOperand;
173 class SVELogicalImmOperand<int Width> : AsmOperandClass {
174 let Name = "SVELogicalImm" # Width;
175 let DiagnosticType = "LogicalSecondSource";
176 let PredicateMethod = "isLogicalImm<int" # Width # "_t>";
177 let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>";
180 def sve_logical_imm8 : Operand<i64> {
181 let ParserMatchClass = SVELogicalImmOperand<8>;
182 let PrintMethod = "printLogicalImm<int8_t>";
184 let MCOperandPredicate = [{
187 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
188 return AArch64_AM::isSVEMaskOfIdenticalElements<int8_t>(Val);
192 def sve_logical_imm16 : Operand<i64> {
193 let ParserMatchClass = SVELogicalImmOperand<16>;
194 let PrintMethod = "printLogicalImm<int16_t>";
196 let MCOperandPredicate = [{
199 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
200 return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val);
204 def sve_logical_imm32 : Operand<i64> {
205 let ParserMatchClass = SVELogicalImmOperand<32>;
206 let PrintMethod = "printLogicalImm<int32_t>";
208 let MCOperandPredicate = [{
211 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
212 return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val);
216 class SVEPreferredLogicalImmOperand<int Width> : AsmOperandClass {
217 let Name = "SVEPreferredLogicalImm" # Width;
218 let PredicateMethod = "isSVEPreferredLogicalImm<int" # Width # "_t>";
219 let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>";
222 def sve_preferred_logical_imm16 : Operand<i64> {
223 let ParserMatchClass = SVEPreferredLogicalImmOperand<16>;
224 let PrintMethod = "printSVELogicalImm<int16_t>";
226 let MCOperandPredicate = [{
229 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
230 return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val) &&
231 AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
235 def sve_preferred_logical_imm32 : Operand<i64> {
236 let ParserMatchClass = SVEPreferredLogicalImmOperand<32>;
237 let PrintMethod = "printSVELogicalImm<int32_t>";
239 let MCOperandPredicate = [{
242 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
243 return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val) &&
244 AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
248 def sve_preferred_logical_imm64 : Operand<i64> {
249 let ParserMatchClass = SVEPreferredLogicalImmOperand<64>;
250 let PrintMethod = "printSVELogicalImm<int64_t>";
252 let MCOperandPredicate = [{
255 int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
256 return AArch64_AM::isSVEMaskOfIdenticalElements<int64_t>(Val) &&
257 AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
261 class SVELogicalImmNotOperand<int Width> : AsmOperandClass {
262 let Name = "SVELogicalImm" # Width # "Not";
263 let DiagnosticType = "LogicalSecondSource";
264 let PredicateMethod = "isLogicalImm<int" # Width # "_t>";
265 let RenderMethod = "addLogicalImmNotOperands<int" # Width # "_t>";
268 def sve_logical_imm8_not : Operand<i64> {
269 let ParserMatchClass = SVELogicalImmNotOperand<8>;
272 def sve_logical_imm16_not : Operand<i64> {
273 let ParserMatchClass = SVELogicalImmNotOperand<16>;
276 def sve_logical_imm32_not : Operand<i64> {
277 let ParserMatchClass = SVELogicalImmNotOperand<32>;
280 class SVEShiftedImmOperand<int ElementWidth, string Infix, string Predicate>
282 let Name = "SVE" # Infix # "Imm" # ElementWidth;
283 let DiagnosticType = "Invalid" # Name;
284 let RenderMethod = "addImmWithOptionalShiftOperands<8>";
285 let ParserMethod = "tryParseImmWithOptionalShift";
286 let PredicateMethod = Predicate;
289 def SVECpyImmOperand8 : SVEShiftedImmOperand<8, "Cpy", "isSVECpyImm<int8_t>">;
290 def SVECpyImmOperand16 : SVEShiftedImmOperand<16, "Cpy", "isSVECpyImm<int16_t>">;
291 def SVECpyImmOperand32 : SVEShiftedImmOperand<32, "Cpy", "isSVECpyImm<int32_t>">;
292 def SVECpyImmOperand64 : SVEShiftedImmOperand<64, "Cpy", "isSVECpyImm<int64_t>">;
294 def SVEAddSubImmOperand8 : SVEShiftedImmOperand<8, "AddSub", "isSVEAddSubImm<int8_t>">;
295 def SVEAddSubImmOperand16 : SVEShiftedImmOperand<16, "AddSub", "isSVEAddSubImm<int16_t>">;
296 def SVEAddSubImmOperand32 : SVEShiftedImmOperand<32, "AddSub", "isSVEAddSubImm<int32_t>">;
297 def SVEAddSubImmOperand64 : SVEShiftedImmOperand<64, "AddSub", "isSVEAddSubImm<int64_t>">;
299 class imm8_opt_lsl<int ElementWidth, string printType,
300 AsmOperandClass OpndClass>
302 let EncoderMethod = "getImm8OptLsl";
303 let DecoderMethod = "DecodeImm8OptLsl<" # ElementWidth # ">";
304 let PrintMethod = "printImm8OptLsl<" # printType # ">";
305 let ParserMatchClass = OpndClass;
306 let MIOperandInfo = (ops i32imm, i32imm);
309 def cpy_imm8_opt_lsl_i8 : imm8_opt_lsl<8, "int8_t", SVECpyImmOperand8>;
310 def cpy_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "int16_t", SVECpyImmOperand16>;
311 def cpy_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "int32_t", SVECpyImmOperand32>;
312 def cpy_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "int64_t", SVECpyImmOperand64>;
314 def addsub_imm8_opt_lsl_i8 : imm8_opt_lsl<8, "uint8_t", SVEAddSubImmOperand8>;
315 def addsub_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "uint16_t", SVEAddSubImmOperand16>;
316 def addsub_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "uint32_t", SVEAddSubImmOperand32>;
317 def addsub_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "uint64_t", SVEAddSubImmOperand64>;
319 def SVEAddSubImm8Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i8>", []>;
320 def SVEAddSubImm16Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i16>", []>;
321 def SVEAddSubImm32Pat : ComplexPattern<i32, 2, "SelectSVEAddSubImm<MVT::i32>", []>;
322 def SVEAddSubImm64Pat : ComplexPattern<i64, 2, "SelectSVEAddSubImm<MVT::i64>", []>;
324 def SVEAddSubSSatNegImm8Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i8, true>", []>;
325 def SVEAddSubSSatNegImm16Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i16, true>", []>;
326 def SVEAddSubSSatNegImm32Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i32, true>", []>;
327 def SVEAddSubSSatNegImm64Pat : ComplexPattern<i64, 2, "SelectSVEAddSubSSatImm<MVT::i64, true>", []>;
329 def SVEAddSubSSatPosImm8Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i8, false>", []>;
330 def SVEAddSubSSatPosImm16Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i16, false>", []>;
331 def SVEAddSubSSatPosImm32Pat : ComplexPattern<i32, 2, "SelectSVEAddSubSSatImm<MVT::i32, false>", []>;
332 def SVEAddSubSSatPosImm64Pat : ComplexPattern<i64, 2, "SelectSVEAddSubSSatImm<MVT::i64, false>", []>;
334 def SVECpyDupImm8Pat : ComplexPattern<i32, 2, "SelectSVECpyDupImm<MVT::i8>", []>;
335 def SVECpyDupImm16Pat : ComplexPattern<i32, 2, "SelectSVECpyDupImm<MVT::i16>", []>;
336 def SVECpyDupImm32Pat : ComplexPattern<i32, 2, "SelectSVECpyDupImm<MVT::i32>", []>;
337 def SVECpyDupImm64Pat : ComplexPattern<i64, 2, "SelectSVECpyDupImm<MVT::i64>", []>;
339 def SVELogicalImm8Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i8>", []>;
340 def SVELogicalImm16Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i16>", []>;
341 def SVELogicalImm32Pat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i32>", []>;
342 def SVELogicalImm64Pat : ComplexPattern<i64, 1, "SelectSVELogicalImm<MVT::i64>", []>;
344 def SVELogicalImm8NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i8, true>", []>;
345 def SVELogicalImm16NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i16, true>", []>;
346 def SVELogicalImm32NotPat : ComplexPattern<i32, 1, "SelectSVELogicalImm<MVT::i32, true>", []>;
347 def SVELogicalImm64NotPat : ComplexPattern<i64, 1, "SelectSVELogicalImm<MVT::i64, true>", []>;
349 def SVEArithUImm8Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i8>", []>;
350 def SVEArithUImm16Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i16>", []>;
351 def SVEArithUImm32Pat : ComplexPattern<i32, 1, "SelectSVEArithImm<MVT::i32>", []>;
352 def SVEArithUImm64Pat : ComplexPattern<i64, 1, "SelectSVEArithImm<MVT::i64>", []>;
354 def SVEArithSImmPat32 : ComplexPattern<i32, 1, "SelectSVESignedArithImm", []>;
355 def SVEArithSImmPat64 : ComplexPattern<i64, 1, "SelectSVESignedArithImm", []>;
357 def SVEShiftImmL8 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 7>", []>;
358 def SVEShiftImmL16 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 15>", []>;
359 def SVEShiftImmL32 : ComplexPattern<i32, 1, "SelectSVEShiftImm<0, 31>", []>;
360 def SVEShiftImmL64 : ComplexPattern<i64, 1, "SelectSVEShiftImm<0, 63>", []>;
361 def SVEShiftImmR8 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 8, true>", []>;
362 def SVEShiftImmR16 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 16, true>", []>;
363 def SVEShiftImmR32 : ComplexPattern<i32, 1, "SelectSVEShiftImm<1, 32, true>", []>;
364 def SVEShiftImmR64 : ComplexPattern<i64, 1, "SelectSVEShiftImm<1, 64, true>", []>;
366 def SVEShiftSplatImmR : ComplexPattern<iAny, 1, "SelectSVEShiftSplatImmR", []>;
368 def SVEAllActive : ComplexPattern<untyped, 0, "SelectAllActivePredicate", []>;
369 def SVEAnyPredicate : ComplexPattern<untyped, 0, "SelectAnyPredicate", []>;
371 class SVEExactFPImm<string Suffix, string ValA, string ValB> : AsmOperandClass {
372 let Name = "SVEExactFPImmOperand" # Suffix;
373 let DiagnosticType = "Invalid" # Name;
374 let ParserMethod = "tryParseFPImm<false>";
375 let PredicateMethod = "isExactFPImm<" # ValA # ", " # ValB # ">";
376 let RenderMethod = "addExactFPImmOperands<" # ValA # ", " # ValB # ">";
379 class SVEExactFPImmOperand<string Suffix, string ValA, string ValB> : Operand<i32> {
380 let PrintMethod = "printExactFPImm<" # ValA # ", " # ValB # ">";
381 let ParserMatchClass = SVEExactFPImm<Suffix, ValA, ValB>;
384 def sve_fpimm_half_one
385 : SVEExactFPImmOperand<"HalfOne", "AArch64ExactFPImm::half",
386 "AArch64ExactFPImm::one">;
387 def sve_fpimm_half_two
388 : SVEExactFPImmOperand<"HalfTwo", "AArch64ExactFPImm::half",
389 "AArch64ExactFPImm::two">;
390 def sve_fpimm_zero_one
391 : SVEExactFPImmOperand<"ZeroOne", "AArch64ExactFPImm::zero",
392 "AArch64ExactFPImm::one">;
394 def sve_incdec_imm : Operand<i32>, TImmLeaf<i32, [{
395 return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17);
397 let ParserMatchClass = Imm1_16Operand;
398 let EncoderMethod = "getSVEIncDecImm";
399 let DecoderMethod = "DecodeSVEIncDecImm";
402 // This allows i32 immediate extraction from i64 based arithmetic.
403 def sve_cnt_mul_imm_i32 : ComplexPattern<i32, 1, "SelectCntImm<1, 16, 1, false>">;
404 def sve_cnt_mul_imm_i64 : ComplexPattern<i64, 1, "SelectCntImm<1, 16, 1, false>">;
405 def sve_cnt_shl_imm : ComplexPattern<i64, 1, "SelectCntImm<1, 16, 1, true>">;
407 def sve_ext_imm_0_31 : ComplexPattern<i64, 1, "SelectEXTImm<31, 8>">;
408 def sve_ext_imm_0_63 : ComplexPattern<i64, 1, "SelectEXTImm<63, 4>">;
409 def sve_ext_imm_0_127 : ComplexPattern<i64, 1, "SelectEXTImm<127, 2>">;
410 def sve_ext_imm_0_255 : ComplexPattern<i64, 1, "SelectEXTImm<255, 1>">;
412 def int_aarch64_sve_cntp_oneuse : PatFrag<(ops node:$pred, node:$src2),
413 (int_aarch64_sve_cntp node:$pred, node:$src2), [{
414 return N->hasOneUse();
417 def step_vector_oneuse : PatFrag<(ops node:$idx),
418 (step_vector node:$idx), [{
419 return N->hasOneUse();
423 //===----------------------------------------------------------------------===//
424 // SVE PTrue - These are used extensively throughout the pattern matching so
425 // it's important we define them first.
426 //===----------------------------------------------------------------------===//
428 class sve_int_ptrue<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty,
429 ValueType vt, SDPatternOperator op>
430 : I<(outs pprty:$Pd), (ins sve_pred_enum:$pattern),
431 asm, "\t$Pd, $pattern",
433 [(set (vt pprty:$Pd), (op sve_pred_enum:$pattern))]>, Sched<[]> {
436 let Inst{31-24} = 0b00100101;
437 let Inst{23-22} = sz8_64;
438 let Inst{21-19} = 0b011;
439 let Inst{18-17} = opc{2-1};
440 let Inst{16} = opc{0};
441 let Inst{15-10} = 0b111000;
442 let Inst{9-5} = pattern;
446 let Defs = !if(!eq (opc{0}, 1), [NZCV], []);
447 let ElementSize = pprty.ElementSize;
448 let hasSideEffects = 0;
449 let isReMaterializable = 1;
453 multiclass sve_int_ptrue<bits<3> opc, string asm, SDPatternOperator op> {
454 def _B : sve_int_ptrue<0b00, opc, asm, PPR8, nxv16i1, op>;
455 def _H : sve_int_ptrue<0b01, opc, asm, PPR16, nxv8i1, op>;
456 def _S : sve_int_ptrue<0b10, opc, asm, PPR32, nxv4i1, op>;
457 def _D : sve_int_ptrue<0b11, opc, asm, PPR64, nxv2i1, op>;
459 def : InstAlias<asm # "\t$Pd",
460 (!cast<Instruction>(NAME # _B) PPR8:$Pd, 0b11111), 1>;
461 def : InstAlias<asm # "\t$Pd",
462 (!cast<Instruction>(NAME # _H) PPR16:$Pd, 0b11111), 1>;
463 def : InstAlias<asm # "\t$Pd",
464 (!cast<Instruction>(NAME # _S) PPR32:$Pd, 0b11111), 1>;
465 def : InstAlias<asm # "\t$Pd",
466 (!cast<Instruction>(NAME # _D) PPR64:$Pd, 0b11111), 1>;
469 def SDT_AArch64PTrue : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
470 def AArch64ptrue : SDNode<"AArch64ISD::PTRUE", SDT_AArch64PTrue>;
472 let Predicates = [HasSVE_or_SME] in {
473 defm PTRUE : sve_int_ptrue<0b000, "ptrue", AArch64ptrue>;
474 defm PTRUES : sve_int_ptrue<0b001, "ptrues", null_frag>;
476 def : Pat<(nxv16i1 immAllOnesV), (PTRUE_B 31)>;
477 def : Pat<(nxv8i1 immAllOnesV), (PTRUE_H 31)>;
478 def : Pat<(nxv4i1 immAllOnesV), (PTRUE_S 31)>;
479 def : Pat<(nxv2i1 immAllOnesV), (PTRUE_D 31)>;
482 //===----------------------------------------------------------------------===//
483 // SVE pattern match helpers.
484 //===----------------------------------------------------------------------===//
485 def SVEDup0 : ComplexPattern<vAny, 0, "SelectDupZero", []>;
486 def SVEDup0Undef : ComplexPattern<vAny, 0, "SelectDupZeroOrUndef", []>;
487 def SVEAny : ComplexPattern<vAny, 0, "SelectAny", []>;
489 class SVE_1_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
491 : Pat<(vtd (op vt1:$Op1)),
494 class SVE_1_Op_Passthru_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
495 ValueType vts, Instruction inst>
496 : Pat<(vtd (op pg:$Op1, vts:$Op2, vtd:$Op3)),
497 (inst $Op3, $Op1, $Op2)>;
500 multiclass SVE_1_Op_PassthruUndef_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
501 ValueType vts, Instruction inst> {
502 def : Pat<(vtd (op pg:$Op1, vts:$Op2, (vtd undef))),
503 (inst (IMPLICIT_DEF), $Op1, $Op2)>;
504 def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, vtd:$Op3)),
505 (inst $Op3, $Op1, $Op2)>;
508 multiclass SVE_1_Op_PassthruUndefZero_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
509 ValueType vts, Instruction inst> {
510 let AddedComplexity = 1 in {
511 def : Pat<(vtd (op pg:$Op1, vts:$Op2, (vtd (SVEDup0Undef)))),
513 def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, (vtd (SVEAny)))),
518 // Used to match FP_ROUND_MERGE_PASSTHRU, which has an additional flag for the
519 // type of rounding. This is matched by timm0_1 in pattern below and ignored.
520 class SVE_1_Op_Passthru_Round_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
521 ValueType vts, Instruction inst>
522 : Pat<(vtd (op pg:$Op1, vts:$Op2, (i64 timm0_1), vtd:$Op3)),
523 (inst $Op3, $Op1, $Op2)>;
525 multiclass SVE_1_Op_PassthruUndef_Round_Pat<ValueType vtd, SDPatternOperator op, ValueType pg,
526 ValueType vts, Instruction inst>{
527 def : Pat<(vtd (op pg:$Op1, vts:$Op2, (i64 timm0_1), (vtd undef))),
528 (inst (IMPLICIT_DEF), $Op1, $Op2)>;
529 def : Pat<(vtd (op (pg (SVEAllActive:$Op1)), vts:$Op2, (i64 timm0_1), vtd:$Op3)),
530 (inst $Op3, $Op1, $Op2)>;
533 class SVE_1_Op_PassthruZero_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
534 ValueType vt2, Instruction inst>
535 : Pat<(vtd (op (vtd (SVEDup0)), vt1:$Op1, vt2:$Op2)),
536 (inst (IMPLICIT_DEF), $Op1, $Op2)>;
538 class SVE_1_Op_Imm_OptLsl_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty,
539 ValueType it, ComplexPattern cpx, Instruction inst>
540 : Pat<(vt (op (vt zprty:$Op1), (vt (splat_vector (it (cpx i32:$imm, i32:$shift)))))),
541 (inst $Op1, i32:$imm, i32:$shift)>;
543 class SVE_1_Op_Imm_Arith_Any_Predicate<ValueType vt, ValueType pt,
544 SDPatternOperator op, ZPRRegOp zprty,
545 ValueType it, ComplexPattern cpx,
547 : Pat<(vt (op (pt (SVEAnyPredicate)), (vt zprty:$Op1), (vt (splat_vector (it (cpx i32:$imm)))))),
548 (inst $Op1, i32:$imm)>;
550 class SVE_1_Op_Imm_Log_Pat<ValueType vt, SDPatternOperator op, ZPRRegOp zprty,
551 ValueType it, ComplexPattern cpx, Instruction inst>
552 : Pat<(vt (op (vt zprty:$Op1), (vt (splat_vector (it (cpx i64:$imm)))))),
553 (inst $Op1, i64:$imm)>;
555 class SVE_2_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
556 ValueType vt2, Instruction inst>
557 : Pat<(vtd (op vt1:$Op1, vt2:$Op2)),
560 class SVE_2_Op_Pred_All_Active<ValueType vtd, SDPatternOperator op,
561 ValueType pt, ValueType vt1, ValueType vt2,
563 : Pat<(vtd (op (pt (SVEAllActive)), vt1:$Op1, vt2:$Op2)),
566 class SVE_2_Op_Pred_All_Active_Pt<ValueType vtd, SDPatternOperator op,
567 ValueType pt, ValueType vt1, ValueType vt2,
569 : Pat<(vtd (op (pt (SVEAllActive:$Op1)), vt1:$Op2, vt2:$Op3)),
570 (inst $Op1, $Op2, $Op3)>;
572 class SVE_3_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
573 ValueType vt2, ValueType vt3, Instruction inst>
574 : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3)),
575 (inst $Op1, $Op2, $Op3)>;
577 multiclass SVE_3_Op_Undef_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
578 ValueType vt2, ValueType vt3, Instruction inst> {
579 def : Pat<(vtd (op (vt1 undef), vt2:$Op1, vt3:$Op2)),
580 (inst (IMPLICIT_DEF), $Op1, $Op2)>;
581 def : Pat<(vtd (op vt1:$Op1, (vt2 (SVEAllActive:$Op2)), vt3:$Op3)),
582 (inst $Op1, $Op2, $Op3)>;
585 multiclass SVE_3_Op_UndefZero_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
586 ValueType vt2, ValueType vt3, Instruction inst> {
587 let AddedComplexity = 1 in {
588 def : Pat<(vtd (op (vt1 (SVEDup0Undef)), vt2:$Op1, vt3:$Op2)),
590 def : Pat<(vtd (op (vt1 (SVEAny)), (vt2 (SVEAllActive:$Op2)), vt3:$Op3)),
595 class SVE_4_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
596 ValueType vt2, ValueType vt3, ValueType vt4,
598 : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3, vt4:$Op4)),
599 (inst $Op1, $Op2, $Op3, $Op4)>;
601 class SVE_2_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
602 ValueType vt2, Operand ImmTy, Instruction inst>
603 : Pat<(vtd (op vt1:$Op1, (vt2 ImmTy:$Op2))),
604 (inst $Op1, ImmTy:$Op2)>;
606 multiclass SVE2p1_Cntp_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
608 def : Pat<(vtd (op vt1:$Op1, (i32 2))), (inst $Op1, 0)>;
609 def : Pat<(vtd (op vt1:$Op1, (i32 4))), (inst $Op1, 1)>;
612 multiclass SVE2p1_While_PN_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
614 def : Pat<(vtd (op vt1:$Op1, vt1:$Op2, (i32 2))), (inst $Op1, $Op2, 0)>;
615 def : Pat<(vtd (op vt1:$Op1, vt1:$Op2, (i32 4))), (inst $Op1, $Op2, 1)>;
618 class SVE_3_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
619 ValueType vt2, ValueType vt3, Operand ImmTy,
621 : Pat<(vtd (op vt1:$Op1, vt2:$Op2, (vt3 ImmTy:$Op3))),
622 (inst $Op1, $Op2, ImmTy:$Op3)>;
624 class SVE_4_Op_Imm_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
625 ValueType vt2, ValueType vt3, ValueType vt4,
626 Operand ImmTy, Instruction inst>
627 : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3, (vt4 ImmTy:$Op4))),
628 (inst $Op1, $Op2, $Op3, ImmTy:$Op4)>;
630 let AddedComplexity = 1 in {
631 class SVE_3_Op_Pat_SelZero<ValueType vtd, SDPatternOperator op, ValueType vt1,
632 ValueType vt2, ValueType vt3, Instruction inst>
633 : Pat<(vtd (vtd (op vt1:$Op1, (vselect vt1:$Op1, vt2:$Op2, (SVEDup0)), vt3:$Op3))),
634 (inst $Op1, $Op2, $Op3)>;
636 class SVE_3_Op_Pat_Shift_Imm_SelZero<ValueType vtd, SDPatternOperator op,
637 ValueType vt1, ValueType vt2,
638 Operand vt3, Instruction inst>
639 : Pat<(vtd (op vt1:$Op1, (vselect vt1:$Op1, vt2:$Op2, (SVEDup0)), (i32 (vt3:$Op3)))),
640 (inst $Op1, $Op2, vt3:$Op3)>;
644 // Common but less generic patterns.
647 class SVE_2_Op_AllActive_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
648 ValueType vt2, Instruction inst, Instruction ptrue>
649 : Pat<(vtd (op vt1:$Op1, vt2:$Op2)),
650 (inst (ptrue 31), $Op1, $Op2)>;
652 class SVE_InReg_Extend<ValueType vt, SDPatternOperator op, ValueType pt,
653 ValueType inreg_vt, Instruction inst>
654 : Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, vt:$PassThru)),
655 (inst $PassThru, $Pg, $Src)>;
657 multiclass SVE_InReg_Extend_PassthruUndef<ValueType vt, SDPatternOperator op, ValueType pt,
658 ValueType inreg_vt, Instruction inst> {
659 def : Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, (vt undef))),
660 (inst (IMPLICIT_DEF), $Pg, $Src)>;
661 def : Pat<(vt (op (pt (SVEAllActive:$Pg)), vt:$Src, inreg_vt, vt:$PassThru)),
662 (inst $PassThru, $Pg, $Src)>;
665 multiclass SVE_InReg_Extend_PassthruUndefZero<ValueType vt, SDPatternOperator op, ValueType pt,
666 ValueType inreg_vt, Instruction inst> {
667 let AddedComplexity = 1 in {
668 def : Pat<(vt (op pt:$Pg, vt:$Src, inreg_vt, (vt (SVEDup0Undef)))),
671 def : Pat<(vt (op (pt (SVEAllActive:$Pg)), vt:$Src, inreg_vt, (vt (SVEAny)))),
676 class SVE_Shift_DupImm_Pred_Pat<ValueType vt, SDPatternOperator op,
677 ValueType pt, ValueType it,
678 ComplexPattern cast, Instruction inst>
679 : Pat<(vt (op pt:$Pg, vt:$Rn, (vt (splat_vector (it (cast i32:$imm)))))),
680 (inst $Pg, $Rn, i32:$imm)>;
682 class SVE_Shift_DupImm_Any_Predicate_Pat<ValueType vt, SDPatternOperator op,
683 ValueType pt, ValueType it,
684 ComplexPattern cast, Instruction inst>
685 : Pat<(vt (op (pt (SVEAnyPredicate)), vt:$Rn, (vt (splat_vector (it (cast i32:$imm)))))),
686 (inst $Rn, i32:$imm)>;
688 class SVE_2_Op_Imm_Pat_Zero<ValueType vt, SDPatternOperator op, ValueType pt,
689 ValueType it, ComplexPattern cpx, Instruction inst>
690 : Pat<(vt (op pt:$Pg, (vselect pt:$Pg, vt:$Op1, (SVEDup0)),
691 (vt (splat_vector (it (cpx i32:$imm)))))),
692 (inst $Pg, $Op1, i32:$imm)>;
694 class SVE_2_Op_Fp_Imm_Pat<ValueType vt, SDPatternOperator op,
695 ValueType pt, ValueType it,
696 FPImmLeaf immL, int imm,
698 : Pat<(vt (op (pt PPR_3b:$Pg), (vt ZPR:$Zs1), (vt (splat_vector (it immL))))),
699 (inst $Pg, $Zs1, imm)>;
701 class SVE_2_Op_Fp_Imm_Pat_Zero<ValueType vt, SDPatternOperator op,
702 ValueType pt, ValueType it,
703 FPImmLeaf immL, int imm,
705 : Pat<(vt (op pt:$Pg, (vselect pt:$Pg, vt:$Zs1, (SVEDup0)),
706 (vt (splat_vector (it immL))))),
707 (inst $Pg, $Zs1, imm)>;
709 class SVE_Shift_Add_All_Active_Pat<ValueType vtd, SDPatternOperator op, ValueType pt,
710 ValueType vt1, ValueType vt2, ValueType vt3,
712 : Pat<(vtd (add vt1:$Op1, (op (pt (SVEAllActive)), vt2:$Op2, vt3:$Op3))),
713 (inst $Op1, $Op2, $Op3)>;
715 class SVE2p1_Sat_Shift_VG2_Pat<string name, SDPatternOperator intrinsic, ValueType out_vt, ValueType in_vt, Operand imm_ty>
716 : Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2, (i32 imm_ty:$i))),
717 (!cast<Instruction>(name) (REG_SEQUENCE ZPR2Mul2, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1), imm_ty:$i)>;
719 class SVE2p1_Cvt_VG2_Pat<string name, SDPatternOperator intrinsic, ValueType out_vt, ValueType in_vt>
720 : Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2)),
721 (!cast<Instruction>(name) (REG_SEQUENCE ZPR2Mul2, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1))>;
723 //===----------------------------------------------------------------------===//
724 // SVE pattern match helpers.
725 //===----------------------------------------------------------------------===//
727 // Matches either an intrinsic, or a predicated operation with an all active predicate
728 class VSelectPredOrPassthruPatFrags<SDPatternOperator intrinsic, SDPatternOperator sdnode>
729 : PatFrags<(ops node:$Pg, node:$Op1, node:$Op2), [
730 (intrinsic node:$Pg, node:$Op1, node:$Op2),
731 (vselect node:$Pg, (sdnode (SVEAllActive), node:$Op1, node:$Op2), node:$Op1),
733 return N->getOpcode() != ISD::VSELECT || N->getOperand(1).hasOneUse();
735 // Same as above with a commutative operation
736 class VSelectCommPredOrPassthruPatFrags<SDPatternOperator intrinsic, SDPatternOperator sdnode>
737 : PatFrags<(ops node:$Pg, node:$Op1, node:$Op2), [
738 (intrinsic node:$Pg, node:$Op1, node:$Op2),
739 (vselect node:$Pg, (sdnode (SVEAllActive), node:$Op1, node:$Op2), node:$Op1),
740 (vselect node:$Pg, (sdnode (SVEAllActive), node:$Op2, node:$Op1), node:$Op1),
742 return N->getOpcode() != ISD::VSELECT || N->getOperand(1).hasOneUse();
744 // Similarly matches either an intrinsic, or an unpredicated operation with a select
745 class VSelectUnpredOrPassthruPatFrags<SDPatternOperator intrinsic, SDPatternOperator sdnode>
746 : PatFrags<(ops node:$Pg, node:$Op1, node:$Op2), [
747 (intrinsic node:$Pg, node:$Op1, node:$Op2),
748 (vselect node:$Pg, (sdnode node:$Op1, node:$Op2), node:$Op1),
750 return N->getOpcode() != ISD::VSELECT || N->getOperand(1).hasOneUse();
754 // Pseudo -> Instruction mappings
756 def getSVEPseudoMap : InstrMapping {
757 let FilterClass = "SVEPseudo2Instr";
758 let RowFields = ["PseudoName"];
759 let ColFields = ["IsInstr"];
761 let ValueCols = [["1"]];
764 class SVEPseudo2Instr<string name, bit instr> {
765 string PseudoName = name;
769 // Lookup e.g. DIV -> DIVR
770 def getSVERevInstr : InstrMapping {
771 let FilterClass = "SVEInstr2Rev";
772 let RowFields = ["InstrName"];
773 let ColFields = ["isReverseInstr"];
775 let ValueCols = [["1"]];
778 // Lookup e.g. DIVR -> DIV
779 def getSVENonRevInstr : InstrMapping {
780 let FilterClass = "SVEInstr2Rev";
781 let RowFields = ["InstrName"];
782 let ColFields = ["isReverseInstr"];
784 let ValueCols = [["0"]];
787 class SVEInstr2Rev<string name1, string name2, bit name1IsReverseInstr> {
788 string InstrName = !if(name1IsReverseInstr, name1, name2);
789 bit isReverseInstr = name1IsReverseInstr;
793 // Pseudos for destructive operands
795 let hasNoSchedulingInfo = 1 in {
796 class PredTwoOpPseudo<string name, ZPRRegOp zprty,
797 FalseLanesEnum flags = FalseLanesNone>
798 : SVEPseudo2Instr<name, 0>,
799 Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, zprty:$Zs2), []> {
800 let FalseLanes = flags;
803 class PredTwoOpImmPseudo<string name, ZPRRegOp zprty, Operand immty,
804 FalseLanesEnum flags = FalseLanesNone>
805 : SVEPseudo2Instr<name, 0>,
806 Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, immty:$imm), []> {
807 let FalseLanes = flags;
810 class PredThreeOpPseudo<string name, ZPRRegOp zprty,
811 FalseLanesEnum flags = FalseLanesNone>
812 : SVEPseudo2Instr<name, 0>,
813 Pseudo<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zs1, zprty:$Zs2, zprty:$Zs3), []> {
814 let FalseLanes = flags;
819 // Pseudos for passthru operands
821 let hasNoSchedulingInfo = 1 in {
822 class PredOneOpPassthruPseudo<string name, ZPRRegOp zprty,
823 FalseLanesEnum flags = FalseLanesNone>
824 : SVEPseudo2Instr<name, 0>,
825 Pseudo<(outs zprty:$Zd), (ins zprty:$Passthru, PPR3bAny:$Pg, zprty:$Zs), []> {
826 let FalseLanes = flags;
827 let Constraints = !if(!eq(flags, FalseLanesZero), "$Zd = $Passthru,@earlyclobber $Zd", "");
831 //===----------------------------------------------------------------------===//
832 // SVE Predicate Misc Group
833 //===----------------------------------------------------------------------===//
835 class sve_int_pfalse<bits<6> opc, string asm>
836 : I<(outs PPRorPNR8:$Pd), (ins),
841 let Inst{31-24} = 0b00100101;
842 let Inst{23-22} = opc{5-4};
843 let Inst{21-19} = 0b011;
844 let Inst{18-16} = opc{3-1};
845 let Inst{15-10} = 0b111001;
846 let Inst{9} = opc{0};
847 let Inst{8-4} = 0b00000;
850 let hasSideEffects = 0;
851 let isReMaterializable = 1;
855 multiclass sve_int_pfalse<bits<6> opc, string asm> {
856 def NAME : sve_int_pfalse<opc, asm>;
858 def : Pat<(nxv16i1 immAllZerosV), (!cast<Instruction>(NAME))>;
859 def : Pat<(nxv8i1 immAllZerosV), (!cast<Instruction>(NAME))>;
860 def : Pat<(nxv4i1 immAllZerosV), (!cast<Instruction>(NAME))>;
861 def : Pat<(nxv2i1 immAllZerosV), (!cast<Instruction>(NAME))>;
862 def : Pat<(nxv1i1 immAllZerosV), (!cast<Instruction>(NAME))>;
865 class sve_int_ptest<bits<6> opc, string asm, SDPatternOperator op>
866 : I<(outs), (ins PPRAny:$Pg, PPR8:$Pn),
869 [(set NZCV, (op (nxv16i1 PPRAny:$Pg), (nxv16i1 PPR8:$Pn)))]>, Sched<[]> {
872 let Inst{31-24} = 0b00100101;
873 let Inst{23-22} = opc{5-4};
874 let Inst{21-19} = 0b010;
875 let Inst{18-16} = opc{3-1};
876 let Inst{15-14} = 0b11;
877 let Inst{13-10} = Pg;
878 let Inst{9} = opc{0};
880 let Inst{4-0} = 0b00000;
883 let hasSideEffects = 0;
887 multiclass sve_int_ptest<bits<6> opc, string asm, SDPatternOperator op,
888 SDPatternOperator op_any> {
889 def NAME : sve_int_ptest<opc, asm, op>;
891 let hasNoSchedulingInfo = 1, isCompare = 1, Defs = [NZCV] in {
892 def _ANY : Pseudo<(outs), (ins PPRAny:$Pg, PPR8:$Pn),
893 [(set NZCV, (op_any (nxv16i1 PPRAny:$Pg), (nxv16i1 PPR8:$Pn)))]>,
894 PseudoInstExpansion<(!cast<Instruction>(NAME) PPRAny:$Pg, PPR8:$Pn)>;
898 class sve_int_pfirst_next<bits<2> sz8_64, bits<5> opc, string asm,
900 : I<(outs pprty:$Pdn), (ins PPRAny:$Pg, pprty:$_Pdn),
901 asm, "\t$Pdn, $Pg, $_Pdn",
906 let Inst{31-24} = 0b00100101;
907 let Inst{23-22} = sz8_64;
908 let Inst{21-19} = 0b011;
909 let Inst{18-16} = opc{4-2};
910 let Inst{15-11} = 0b11000;
911 let Inst{10-9} = opc{1-0};
916 let Constraints = "$Pdn = $_Pdn";
918 let ElementSize = pprty.ElementSize;
919 let hasSideEffects = 0;
923 multiclass sve_int_pfirst<bits<5> opc, string asm, SDPatternOperator op> {
924 def _B : sve_int_pfirst_next<0b01, opc, asm, PPR8>;
926 def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
929 multiclass sve_int_pnext<bits<5> opc, string asm, SDPatternOperator op> {
930 def _B : sve_int_pfirst_next<0b00, opc, asm, PPR8>;
931 def _H : sve_int_pfirst_next<0b01, opc, asm, PPR16>;
932 def _S : sve_int_pfirst_next<0b10, opc, asm, PPR32>;
933 def _D : sve_int_pfirst_next<0b11, opc, asm, PPR64>;
935 def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
936 def : SVE_2_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>;
937 def : SVE_2_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>;
938 def : SVE_2_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>;
941 //===----------------------------------------------------------------------===//
942 // SVE Predicate Count Group
943 //===----------------------------------------------------------------------===//
945 class sve_int_count_r<bits<2> sz8_64, bits<5> opc, string asm,
946 RegisterOperand dty, PPRRegOp pprty, RegisterOperand sty>
947 : I<(outs dty:$Rdn), (ins pprty:$Pg, sty:$_Rdn),
953 let Inst{31-24} = 0b00100101;
954 let Inst{23-22} = sz8_64;
955 let Inst{21-19} = 0b101;
956 let Inst{18-16} = opc{4-2};
957 let Inst{15-11} = 0b10001;
958 let Inst{10-9} = opc{1-0};
962 // Signed 32bit forms require their GPR operand printed.
963 let AsmString = !if(!eq(opc{4,2-0}, 0b0000),
964 !strconcat(asm, "\t$Rdn, $Pg, $_Rdn"),
965 !strconcat(asm, "\t$Rdn, $Pg"));
966 let Constraints = "$Rdn = $_Rdn";
967 let hasSideEffects = 0;
970 multiclass sve_int_count_r_s32<bits<5> opc, string asm,
971 SDPatternOperator op> {
972 def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64as32>;
973 def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64as32>;
974 def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64as32>;
975 def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64as32>;
977 def : Pat<(i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))),
978 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _B) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
979 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))))),
980 (!cast<Instruction>(NAME # _B) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
982 def : Pat<(i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))),
983 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _H) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
984 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))))),
985 (!cast<Instruction>(NAME # _H) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
987 def : Pat<(i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))),
988 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _S) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
989 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))))),
990 (!cast<Instruction>(NAME # _S) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
992 def : Pat<(i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))),
993 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _D) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32)), sub_32)>;
994 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))))),
995 (!cast<Instruction>(NAME # _D) PPRAny:$Pg, (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32))>;
998 multiclass sve_int_count_r_u32<bits<5> opc, string asm,
999 SDPatternOperator op> {
1000 def _B : sve_int_count_r<0b00, opc, asm, GPR32z, PPR8, GPR32z>;
1001 def _H : sve_int_count_r<0b01, opc, asm, GPR32z, PPR16, GPR32z>;
1002 def _S : sve_int_count_r<0b10, opc, asm, GPR32z, PPR32, GPR32z>;
1003 def _D : sve_int_count_r<0b11, opc, asm, GPR32z, PPR64, GPR32z>;
1005 def : Pat<(i32 (op GPR32:$Rn, (nxv16i1 PPRAny:$Pg))),
1006 (!cast<Instruction>(NAME # _B) PPRAny:$Pg, $Rn)>;
1007 def : Pat<(i32 (op GPR32:$Rn, (nxv8i1 PPRAny:$Pg))),
1008 (!cast<Instruction>(NAME # _H) PPRAny:$Pg, $Rn)>;
1009 def : Pat<(i32 (op GPR32:$Rn, (nxv4i1 PPRAny:$Pg))),
1010 (!cast<Instruction>(NAME # _S) PPRAny:$Pg, $Rn)>;
1011 def : Pat<(i32 (op GPR32:$Rn, (nxv2i1 PPRAny:$Pg))),
1012 (!cast<Instruction>(NAME # _D) PPRAny:$Pg, $Rn)>;
1015 multiclass sve_int_count_r_x64<bits<5> opc, string asm,
1016 SDPatternOperator op,
1017 SDPatternOperator combine_op = null_frag> {
1018 def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64z>;
1019 def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64z>;
1020 def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64z>;
1021 def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64z>;
1023 def : Pat<(i64 (op GPR64:$Rn, (nxv16i1 PPRAny:$Pg))),
1024 (!cast<Instruction>(NAME # _B) PPRAny:$Pg, $Rn)>;
1025 def : Pat<(i64 (op GPR64:$Rn, (nxv8i1 PPRAny:$Pg))),
1026 (!cast<Instruction>(NAME # _H) PPRAny:$Pg, $Rn)>;
1027 def : Pat<(i64 (op GPR64:$Rn, (nxv4i1 PPRAny:$Pg))),
1028 (!cast<Instruction>(NAME # _S) PPRAny:$Pg, $Rn)>;
1029 def : Pat<(i64 (op GPR64:$Rn, (nxv2i1 PPRAny:$Pg))),
1030 (!cast<Instruction>(NAME # _D) PPRAny:$Pg, $Rn)>;
1032 // combine_op(x, cntp(all_active, p)) ==> inst p, x
1033 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv16i1 (SVEAllActive)), (nxv16i1 PPRAny:$pred)))),
1034 (!cast<Instruction>(NAME # _B) PPRAny:$pred, $Rn)>;
1035 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv8i1 (SVEAllActive)), (nxv8i1 PPRAny:$pred)))),
1036 (!cast<Instruction>(NAME # _H) PPRAny:$pred, $Rn)>;
1037 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv4i1 (SVEAllActive)), (nxv4i1 PPRAny:$pred)))),
1038 (!cast<Instruction>(NAME # _S) PPRAny:$pred, $Rn)>;
1039 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv2i1 (SVEAllActive)), (nxv2i1 PPRAny:$pred)))),
1040 (!cast<Instruction>(NAME # _D) PPRAny:$pred, $Rn)>;
1042 // combine_op(x, cntp(p, p)) ==> inst p, x
1043 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv16i1 PPRAny:$pred), (nxv16i1 PPRAny:$pred)))),
1044 (!cast<Instruction>(NAME # _B) PPRAny:$pred, $Rn)>;
1045 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv8i1 PPRAny:$pred), (nxv8i1 PPRAny:$pred)))),
1046 (!cast<Instruction>(NAME # _H) PPRAny:$pred, $Rn)>;
1047 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv4i1 PPRAny:$pred), (nxv4i1 PPRAny:$pred)))),
1048 (!cast<Instruction>(NAME # _S) PPRAny:$pred, $Rn)>;
1049 def : Pat<(i64 (combine_op GPR64:$Rn, (int_aarch64_sve_cntp_oneuse (nxv2i1 PPRAny:$pred), (nxv2i1 PPRAny:$pred)))),
1050 (!cast<Instruction>(NAME # _D) PPRAny:$pred, $Rn)>;
1052 // combine_op(x, trunc(cntp(all_active, p))) ==> inst p, x
1053 def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv16i1 (SVEAllActive)), (nxv16i1 PPRAny:$pred))))),
1054 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _B) PPRAny:$pred,
1055 (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
1057 def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv8i1 (SVEAllActive)), (nxv8i1 PPRAny:$pred))))),
1058 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _H) PPRAny:$pred,
1059 (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
1061 def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv4i1 (SVEAllActive)), (nxv4i1 PPRAny:$pred))))),
1062 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _S) PPRAny:$pred,
1063 (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
1065 def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv2i1 (SVEAllActive)), (nxv2i1 PPRAny:$pred))))),
1066 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _D) PPRAny:$pred,
1067 (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
1070 // combine_op(x, trunc(cntp(p, p))) ==> inst p, x
1071 def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv16i1 PPRAny:$pred), (nxv16i1 PPRAny:$pred))))),
1072 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _B) PPRAny:$pred,
1073 (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
1075 def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv8i1 PPRAny:$pred), (nxv8i1 PPRAny:$pred))))),
1076 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _H) PPRAny:$pred,
1077 (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
1079 def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv4i1 PPRAny:$pred), (nxv4i1 PPRAny:$pred))))),
1080 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _S) PPRAny:$pred,
1081 (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
1083 def : Pat<(i32 (combine_op GPR32:$Rn, (trunc (int_aarch64_sve_cntp_oneuse (nxv2i1 PPRAny:$pred), (nxv2i1 PPRAny:$pred))))),
1084 (EXTRACT_SUBREG (!cast<Instruction>(NAME # _D) PPRAny:$pred,
1085 (INSERT_SUBREG (IMPLICIT_DEF), GPR32:$Rn, sub_32)),
1089 class sve_int_count_v<bits<2> sz8_64, bits<5> opc, string asm,
1090 ZPRRegOp zprty, PPRRegOp pprty>
1091 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, pprty:$Pm),
1097 let Inst{31-24} = 0b00100101;
1098 let Inst{23-22} = sz8_64;
1099 let Inst{21-19} = 0b101;
1100 let Inst{18-16} = opc{4-2};
1101 let Inst{15-11} = 0b10000;
1102 let Inst{10-9} = opc{1-0};
1104 let Inst{4-0} = Zdn;
1106 let Constraints = "$Zdn = $_Zdn";
1107 let DestructiveInstType = DestructiveOther;
1108 let ElementSize = ElementSizeNone;
1109 let hasSideEffects = 0;
1112 multiclass sve_int_count_v<bits<5> opc, string asm,
1113 SDPatternOperator op = null_frag> {
1114 def _H : sve_int_count_v<0b01, opc, asm, ZPR16, PPR16>;
1115 def _S : sve_int_count_v<0b10, opc, asm, ZPR32, PPR32>;
1116 def _D : sve_int_count_v<0b11, opc, asm, ZPR64, PPR64>;
1118 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, !cast<Instruction>(NAME # _H)>;
1119 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, !cast<Instruction>(NAME # _S)>;
1120 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, !cast<Instruction>(NAME # _D)>;
1122 def : InstAlias<asm # "\t$Zdn, $Pm",
1123 (!cast<Instruction>(NAME # "_H") ZPR16:$Zdn, PPRAny:$Pm), 0>;
1124 def : InstAlias<asm # "\t$Zdn, $Pm",
1125 (!cast<Instruction>(NAME # "_S") ZPR32:$Zdn, PPRAny:$Pm), 0>;
1126 def : InstAlias<asm # "\t$Zdn, $Pm",
1127 (!cast<Instruction>(NAME # "_D") ZPR64:$Zdn, PPRAny:$Pm), 0>;
1130 class sve_int_pcount_pred<bits<2> sz8_64, bits<3> opc, string asm,
1132 : I<(outs GPR64:$Rd), (ins PPRAny:$Pg, pprty:$Pn),
1133 asm, "\t$Rd, $Pg, $Pn",
1139 let Inst{31-24} = 0b00100101;
1140 let Inst{23-22} = sz8_64;
1141 let Inst{21-19} = 0b100;
1142 let Inst{18-16} = opc{2-0};
1143 let Inst{15-14} = 0b10;
1144 let Inst{13-10} = Pg;
1149 let hasSideEffects = 0;
1152 multiclass sve_int_pcount_pred<bits<3> opc, string asm,
1153 SDPatternOperator int_op> {
1154 def _B : sve_int_pcount_pred<0b00, opc, asm, PPR8>;
1155 def _H : sve_int_pcount_pred<0b01, opc, asm, PPR16>;
1156 def _S : sve_int_pcount_pred<0b10, opc, asm, PPR32>;
1157 def _D : sve_int_pcount_pred<0b11, opc, asm, PPR64>;
1159 def : SVE_2_Op_Pat<i64, int_op, nxv16i1, nxv16i1, !cast<Instruction>(NAME # _B)>;
1160 def : SVE_2_Op_Pat<i64, int_op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>;
1161 def : SVE_2_Op_Pat<i64, int_op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>;
1162 def : SVE_2_Op_Pat<i64, int_op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>;
1165 multiclass sve_int_pcount_pred_tmp<bits<3> opc, string asm> {
1166 def _B : sve_int_pcount_pred<0b00, opc, asm, PPR8>;
1167 def _H : sve_int_pcount_pred<0b01, opc, asm, PPR16>;
1168 def _S : sve_int_pcount_pred<0b10, opc, asm, PPR32>;
1169 def _D : sve_int_pcount_pred<0b11, opc, asm, PPR64>;
1171 //===----------------------------------------------------------------------===//
1172 // SVE Element Count Group
1173 //===----------------------------------------------------------------------===//
1175 class sve_int_count<bits<3> opc, string asm>
1176 : I<(outs GPR64:$Rd), (ins sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
1177 asm, "\t$Rd, $pattern, mul $imm4",
1183 let Inst{31-24} = 0b00000100;
1184 let Inst{23-22} = opc{2-1};
1185 let Inst{21-20} = 0b10;
1186 let Inst{19-16} = imm4;
1187 let Inst{15-11} = 0b11100;
1188 let Inst{10} = opc{0};
1189 let Inst{9-5} = pattern;
1192 let hasSideEffects = 0;
1193 let isReMaterializable = 1;
1197 multiclass sve_int_count<bits<3> opc, string asm, SDPatternOperator op> {
1198 def NAME : sve_int_count<opc, asm>;
1200 def : InstAlias<asm # "\t$Rd, $pattern",
1201 (!cast<Instruction>(NAME) GPR64:$Rd, sve_pred_enum:$pattern, 1), 1>;
1202 def : InstAlias<asm # "\t$Rd",
1203 (!cast<Instruction>(NAME) GPR64:$Rd, 0b11111, 1), 2>;
1205 def : Pat<(i64 (mul (op sve_pred_enum:$pattern), (sve_cnt_mul_imm_i64 i32:$imm))),
1206 (!cast<Instruction>(NAME) sve_pred_enum:$pattern, sve_incdec_imm:$imm)>;
1208 def : Pat<(i64 (shl (op sve_pred_enum:$pattern), (sve_cnt_shl_imm i32:$imm))),
1209 (!cast<Instruction>(NAME) sve_pred_enum:$pattern, sve_incdec_imm:$imm)>;
1211 def : Pat<(i64 (op sve_pred_enum:$pattern)),
1212 (!cast<Instruction>(NAME) sve_pred_enum:$pattern, 1)>;
1215 class sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty>
1216 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
1217 asm, "\t$Zdn, $pattern, mul $imm4",
1223 let Inst{31-24} = 0b00000100;
1224 let Inst{23-22} = opc{4-3};
1226 let Inst{20} = opc{2};
1227 let Inst{19-16} = imm4;
1228 let Inst{15-12} = 0b1100;
1229 let Inst{11-10} = opc{1-0};
1230 let Inst{9-5} = pattern;
1231 let Inst{4-0} = Zdn;
1233 let Constraints = "$Zdn = $_Zdn";
1234 let DestructiveInstType = DestructiveOther;
1235 let ElementSize = ElementSizeNone;
1236 let hasSideEffects = 0;
1239 multiclass sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty,
1240 SDPatternOperator op = null_frag,
1241 ValueType vt = OtherVT> {
1242 def NAME : sve_int_countvlv<opc, asm, zprty>;
1244 def : InstAlias<asm # "\t$Zdn, $pattern",
1245 (!cast<Instruction>(NAME) zprty:$Zdn, sve_pred_enum:$pattern, 1), 1>;
1246 def : InstAlias<asm # "\t$Zdn",
1247 (!cast<Instruction>(NAME) zprty:$Zdn, 0b11111, 1), 2>;
1249 def : Pat<(vt (op (vt zprty:$Zn), (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
1250 (!cast<Instruction>(NAME) $Zn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
1253 class sve_int_pred_pattern_a<bits<3> opc, string asm>
1254 : I<(outs GPR64:$Rdn), (ins GPR64:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
1255 asm, "\t$Rdn, $pattern, mul $imm4",
1261 let Inst{31-24} = 0b00000100;
1262 let Inst{23-22} = opc{2-1};
1263 let Inst{21-20} = 0b11;
1264 let Inst{19-16} = imm4;
1265 let Inst{15-11} = 0b11100;
1266 let Inst{10} = opc{0};
1267 let Inst{9-5} = pattern;
1268 let Inst{4-0} = Rdn;
1270 let Constraints = "$Rdn = $_Rdn";
1271 let hasSideEffects = 0;
1274 multiclass sve_int_pred_pattern_a<bits<3> opc, string asm,
1275 SDPatternOperator op,
1276 SDPatternOperator opcnt> {
1277 let Predicates = [HasSVE_or_SME] in {
1278 def NAME : sve_int_pred_pattern_a<opc, asm>;
1280 def : InstAlias<asm # "\t$Rdn, $pattern",
1281 (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1), 1>;
1282 def : InstAlias<asm # "\t$Rdn",
1283 (!cast<Instruction>(NAME) GPR64:$Rdn, 0b11111, 1), 2>;
1286 let Predicates = [HasSVE_or_SME, UseScalarIncVL] in {
1287 def : Pat<(i64 (op GPR64:$Rdn, (opcnt sve_pred_enum:$pattern))),
1288 (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1)>;
1290 def : Pat<(i64 (op GPR64:$Rdn, (mul (opcnt sve_pred_enum:$pattern), (sve_cnt_mul_imm_i64 i32:$imm)))),
1291 (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, $imm)>;
1293 def : Pat<(i64 (op GPR64:$Rdn, (shl (opcnt sve_pred_enum:$pattern), (sve_cnt_shl_imm i32:$imm)))),
1294 (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, $imm)>;
1296 def : Pat<(i32 (op GPR32:$Rdn, (i32 (trunc (opcnt (sve_pred_enum:$pattern)))))),
1297 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF),
1298 GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, 1),
1301 def : Pat<(i32 (op GPR32:$Rdn, (mul (i32 (trunc (opcnt (sve_pred_enum:$pattern)))), (sve_cnt_mul_imm_i32 i32:$imm)))),
1302 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF),
1303 GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, $imm),
1306 def : Pat<(i32 (op GPR32:$Rdn, (shl (i32 (trunc (opcnt (sve_pred_enum:$pattern)))), (sve_cnt_shl_imm i32:$imm)))),
1307 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF),
1308 GPR32:$Rdn, sub_32), sve_pred_enum:$pattern, $imm),
1313 class sve_int_pred_pattern_b<bits<5> opc, string asm, RegisterOperand dt,
1315 : I<(outs dt:$Rdn), (ins st:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
1316 asm, "\t$Rdn, $pattern, mul $imm4",
1322 let Inst{31-24} = 0b00000100;
1323 let Inst{23-22} = opc{4-3};
1325 let Inst{20} = opc{2};
1326 let Inst{19-16} = imm4;
1327 let Inst{15-12} = 0b1111;
1328 let Inst{11-10} = opc{1-0};
1329 let Inst{9-5} = pattern;
1330 let Inst{4-0} = Rdn;
1332 // Signed 32bit forms require their GPR operand printed.
1333 let AsmString = !if(!eq(opc{2,0}, 0b00),
1334 !strconcat(asm, "\t$Rdn, $_Rdn, $pattern, mul $imm4"),
1335 !strconcat(asm, "\t$Rdn, $pattern, mul $imm4"));
1337 let Constraints = "$Rdn = $_Rdn";
1338 let hasSideEffects = 0;
1341 multiclass sve_int_pred_pattern_b_s32<bits<5> opc, string asm,
1342 SDPatternOperator op> {
1343 def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64as32>;
1345 def : InstAlias<asm # "\t$Rd, $Rn, $pattern",
1346 (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, sve_pred_enum:$pattern, 1), 1>;
1347 def : InstAlias<asm # "\t$Rd, $Rn",
1348 (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, 0b11111, 1), 2>;
1350 // NOTE: Register allocation doesn't like tied operands of differing register
1351 // class, hence the extra INSERT_SUBREG complication.
1353 def : Pat<(i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
1354 (EXTRACT_SUBREG (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32), sve_pred_enum:$pattern, sve_incdec_imm:$imm4), sub_32)>;
1355 def : Pat<(i64 (sext (i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))))),
1356 (!cast<Instruction>(NAME) (INSERT_SUBREG (IMPLICIT_DEF), $Rn, sub_32), sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
1359 multiclass sve_int_pred_pattern_b_u32<bits<5> opc, string asm,
1360 SDPatternOperator op> {
1361 def NAME : sve_int_pred_pattern_b<opc, asm, GPR32z, GPR32z>;
1363 def : InstAlias<asm # "\t$Rdn, $pattern",
1364 (!cast<Instruction>(NAME) GPR32z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
1365 def : InstAlias<asm # "\t$Rdn",
1366 (!cast<Instruction>(NAME) GPR32z:$Rdn, 0b11111, 1), 2>;
1368 def : Pat<(i32 (op GPR32:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
1369 (!cast<Instruction>(NAME) $Rn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
1372 multiclass sve_int_pred_pattern_b_x64<bits<5> opc, string asm,
1373 SDPatternOperator op> {
1374 def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64z>;
1376 def : InstAlias<asm # "\t$Rdn, $pattern",
1377 (!cast<Instruction>(NAME) GPR64z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
1378 def : InstAlias<asm # "\t$Rdn",
1379 (!cast<Instruction>(NAME) GPR64z:$Rdn, 0b11111, 1), 2>;
1381 def : Pat<(i64 (op GPR64:$Rn, (sve_pred_enum:$pattern), (sve_incdec_imm:$imm4))),
1382 (!cast<Instruction>(NAME) $Rn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4)>;
1386 //===----------------------------------------------------------------------===//
1387 // SVE Permute - Cross Lane Group
1388 //===----------------------------------------------------------------------===//
1390 class sve_int_perm_dup_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
1391 ValueType vt, RegisterClass srcRegType,
1392 SDPatternOperator op>
1393 : I<(outs zprty:$Zd), (ins srcRegType:$Rn),
1396 [(set (vt zprty:$Zd), (op srcRegType:$Rn))]>, Sched<[]> {
1399 let Inst{31-24} = 0b00000101;
1400 let Inst{23-22} = sz8_64;
1401 let Inst{21-10} = 0b100000001110;
1405 let hasSideEffects = 0;
1408 multiclass sve_int_perm_dup_r<string asm, SDPatternOperator op> {
1409 def _B : sve_int_perm_dup_r<0b00, asm, ZPR8, nxv16i8, GPR32sp, op>;
1410 def _H : sve_int_perm_dup_r<0b01, asm, ZPR16, nxv8i16, GPR32sp, op>;
1411 def _S : sve_int_perm_dup_r<0b10, asm, ZPR32, nxv4i32, GPR32sp, op>;
1412 def _D : sve_int_perm_dup_r<0b11, asm, ZPR64, nxv2i64, GPR64sp, op>;
1414 def : InstAlias<"mov $Zd, $Rn",
1415 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, GPR32sp:$Rn), 1>;
1416 def : InstAlias<"mov $Zd, $Rn",
1417 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, GPR32sp:$Rn), 1>;
1418 def : InstAlias<"mov $Zd, $Rn",
1419 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, GPR32sp:$Rn), 1>;
1420 def : InstAlias<"mov $Zd, $Rn",
1421 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, GPR64sp:$Rn), 1>;
1424 class sve_int_perm_dup_i<bits<5> tsz, Operand immtype, string asm,
1426 : I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$idx),
1427 asm, "\t$Zd, $Zn$idx",
1433 let Inst{31-24} = 0b00000101;
1434 let Inst{23-22} = {?,?}; // imm3h
1436 let Inst{20-16} = tsz;
1437 let Inst{15-10} = 0b001000;
1441 let hasSideEffects = 0;
1444 multiclass sve_int_perm_dup_i<string asm> {
1445 def _B : sve_int_perm_dup_i<{?,?,?,?,1}, sve_elm_idx_extdup_b, asm, ZPR8> {
1446 let Inst{23-22} = idx{5-4};
1447 let Inst{20-17} = idx{3-0};
1449 def _H : sve_int_perm_dup_i<{?,?,?,1,0}, sve_elm_idx_extdup_h, asm, ZPR16> {
1450 let Inst{23-22} = idx{4-3};
1451 let Inst{20-18} = idx{2-0};
1453 def _S : sve_int_perm_dup_i<{?,?,1,0,0}, sve_elm_idx_extdup_s, asm, ZPR32> {
1454 let Inst{23-22} = idx{3-2};
1455 let Inst{20-19} = idx{1-0};
1457 def _D : sve_int_perm_dup_i<{?,1,0,0,0}, sve_elm_idx_extdup_d, asm, ZPR64> {
1458 let Inst{23-22} = idx{2-1};
1459 let Inst{20} = idx{0};
1461 def _Q : sve_int_perm_dup_i<{1,0,0,0,0}, sve_elm_idx_extdup_q, asm, ZPR128> {
1462 let Inst{23-22} = idx{1-0};
1465 def : InstAlias<"mov $Zd, $Zn$idx",
1466 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, sve_elm_idx_extdup_b:$idx), 1>;
1467 def : InstAlias<"mov $Zd, $Zn$idx",
1468 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, sve_elm_idx_extdup_h:$idx), 1>;
1469 def : InstAlias<"mov $Zd, $Zn$idx",
1470 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, sve_elm_idx_extdup_s:$idx), 1>;
1471 def : InstAlias<"mov $Zd, $Zn$idx",
1472 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, sve_elm_idx_extdup_d:$idx), 1>;
1473 def : InstAlias<"mov $Zd, $Zn$idx",
1474 (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, ZPR128:$Zn, sve_elm_idx_extdup_q:$idx), 1>;
1475 def : InstAlias<"mov $Zd, $Bn",
1476 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, FPR8asZPR:$Bn, 0), 2>;
1477 def : InstAlias<"mov $Zd, $Hn",
1478 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, FPR16asZPR:$Hn, 0), 2>;
1479 def : InstAlias<"mov $Zd, $Sn",
1480 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, FPR32asZPR:$Sn, 0), 2>;
1481 def : InstAlias<"mov $Zd, $Dn",
1482 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, FPR64asZPR:$Dn, 0), 2>;
1483 def : InstAlias<"mov $Zd, $Qn",
1484 (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, FPR128asZPR:$Qn, 0), 2>;
1486 // Duplicate an extracted vector element across a vector.
1488 def : Pat<(nxv16i8 (splat_vector (i32 (vector_extract (nxv16i8 ZPR:$vec), sve_elm_idx_extdup_b:$index)))),
1489 (!cast<Instruction>(NAME # _B) ZPR:$vec, sve_elm_idx_extdup_b:$index)>;
1490 def : Pat<(nxv16i8 (splat_vector (i32 (vector_extract (v16i8 V128:$vec), sve_elm_idx_extdup_b:$index)))),
1491 (!cast<Instruction>(NAME # _B) (SUBREG_TO_REG (i64 0), $vec, zsub), sve_elm_idx_extdup_b:$index)>;
1492 def : Pat<(nxv16i8 (splat_vector (i32 (vector_extract (v8i8 V64:$vec), sve_elm_idx_extdup_b:$index)))),
1493 (!cast<Instruction>(NAME # _B) (SUBREG_TO_REG (i64 0), $vec, dsub), sve_elm_idx_extdup_b:$index)>;
1495 foreach VT = [nxv8i16, nxv2f16, nxv4f16, nxv8f16, nxv2bf16, nxv4bf16, nxv8bf16] in {
1496 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (SVEType<VT>.Packed ZPR:$vec), sve_elm_idx_extdup_h:$index)))),
1497 (!cast<Instruction>(NAME # _H) ZPR:$vec, sve_elm_idx_extdup_h:$index)>;
1498 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (SVEType<VT>.ZSub V128:$vec), sve_elm_idx_extdup_h:$index)))),
1499 (!cast<Instruction>(NAME # _H) (SUBREG_TO_REG (i64 0), $vec, zsub), sve_elm_idx_extdup_h:$index)>;
1500 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (SVEType<VT>.DSub V64:$vec), sve_elm_idx_extdup_h:$index)))),
1501 (!cast<Instruction>(NAME # _H) (SUBREG_TO_REG (i64 0), $vec, dsub), sve_elm_idx_extdup_h:$index)>;
1504 foreach VT = [nxv4i32, nxv2f32, nxv4f32 ] in {
1505 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (SVEType<VT>.Packed ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
1506 (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
1507 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (SVEType<VT>.ZSub V128:$vec), sve_elm_idx_extdup_s:$index)))),
1508 (!cast<Instruction>(NAME # _S) (SUBREG_TO_REG (i64 0), $vec, zsub), sve_elm_idx_extdup_s:$index)>;
1509 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (SVEType<VT>.DSub V64:$vec), sve_elm_idx_extdup_s:$index)))),
1510 (!cast<Instruction>(NAME # _S) (SUBREG_TO_REG (i64 0), $vec, dsub), sve_elm_idx_extdup_s:$index)>;
1513 foreach VT = [nxv2i64, nxv2f64] in {
1514 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (VT ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
1515 (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
1516 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (SVEType<VT>.ZSub V128:$vec), sve_elm_idx_extdup_d:$index)))),
1517 (!cast<Instruction>(NAME # _D) (SUBREG_TO_REG (i64 0), $vec, zsub), sve_elm_idx_extdup_d:$index)>;
1518 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (SVEType<VT>.DSub V64:$vec), sve_elm_idx_extdup_d:$index)))),
1519 (!cast<Instruction>(NAME # _D) (SUBREG_TO_REG (i64 0), $vec, dsub), sve_elm_idx_extdup_d:$index)>;
1522 // When extracting from an unpacked vector the index must be scaled to account
1523 // for the "holes" in the underlying packed vector type. We get the scaling
1524 // for free by "promoting" the element type to one whose underlying vector
1525 // type is packed. This is only valid when extracting from a vector whose
1526 // length is the same or bigger than the result of the splat.
1528 foreach VT = [nxv4f16, nxv4bf16] in {
1529 def : Pat<(SVEType<VT>.HalfLength (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (VT ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
1530 (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
1531 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (VT ZPR:$vec), sve_elm_idx_extdup_s:$index)))),
1532 (!cast<Instruction>(NAME # _S) ZPR:$vec, sve_elm_idx_extdup_s:$index)>;
1535 foreach VT = [nxv2f16, nxv2f32, nxv2bf16] in {
1536 def : Pat<(VT (splat_vector (SVEType<VT>.EltAsScalar (vector_extract (VT ZPR:$vec), sve_elm_idx_extdup_d:$index)))),
1537 (!cast<Instruction>(NAME # _D) ZPR:$vec, sve_elm_idx_extdup_d:$index)>;
1540 // Duplicate an indexed 128-bit segment across a vector.
1542 def : Pat<(nxv16i8 (AArch64duplane128 nxv16i8:$Op1, i64:$imm)),
1543 (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
1544 def : Pat<(nxv8i16 (AArch64duplane128 nxv8i16:$Op1, i64:$imm)),
1545 (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
1546 def : Pat<(nxv4i32 (AArch64duplane128 nxv4i32:$Op1, i64:$imm)),
1547 (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
1548 def : Pat<(nxv2i64 (AArch64duplane128 nxv2i64:$Op1, i64:$imm)),
1549 (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
1550 def : Pat<(nxv8f16 (AArch64duplane128 nxv8f16:$Op1, i64:$imm)),
1551 (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
1552 def : Pat<(nxv4f32 (AArch64duplane128 nxv4f32:$Op1, i64:$imm)),
1553 (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
1554 def : Pat<(nxv2f64 (AArch64duplane128 nxv2f64:$Op1, i64:$imm)),
1555 (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
1556 def : Pat<(nxv8bf16 (AArch64duplane128 nxv8bf16:$Op1, i64:$imm)),
1557 (!cast<Instruction>(NAME # _Q) $Op1, $imm)>;
1560 class sve_int_perm_tbl<bits<2> sz8_64, bits<2> opc, string asm, ZPRRegOp zprty,
1561 RegisterOperand VecList>
1562 : I<(outs zprty:$Zd), (ins VecList:$Zn, zprty:$Zm),
1563 asm, "\t$Zd, $Zn, $Zm",
1569 let Inst{31-24} = 0b00000101;
1570 let Inst{23-22} = sz8_64;
1572 let Inst{20-16} = Zm;
1573 let Inst{15-13} = 0b001;
1574 let Inst{12-11} = opc;
1579 let hasSideEffects = 0;
1582 multiclass sve_int_perm_tbl<string asm, SDPatternOperator op> {
1583 def _B : sve_int_perm_tbl<0b00, 0b10, asm, ZPR8, Z_b>;
1584 def _H : sve_int_perm_tbl<0b01, 0b10, asm, ZPR16, Z_h>;
1585 def _S : sve_int_perm_tbl<0b10, 0b10, asm, ZPR32, Z_s>;
1586 def _D : sve_int_perm_tbl<0b11, 0b10, asm, ZPR64, Z_d>;
1588 def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
1589 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 0>;
1590 def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
1591 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 0>;
1592 def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
1593 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 0>;
1594 def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
1595 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, ZPR64:$Zm), 0>;
1597 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
1598 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1599 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
1600 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1602 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1603 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
1604 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1606 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1609 multiclass sve2_int_perm_tbl<string asm, SDPatternOperator op> {
1610 def _B : sve_int_perm_tbl<0b00, 0b01, asm, ZPR8, ZZ_b>;
1611 def _H : sve_int_perm_tbl<0b01, 0b01, asm, ZPR16, ZZ_h>;
1612 def _S : sve_int_perm_tbl<0b10, 0b01, asm, ZPR32, ZZ_s>;
1613 def _D : sve_int_perm_tbl<0b11, 0b01, asm, ZPR64, ZZ_d>;
1615 def : Pat<(nxv16i8 (op nxv16i8:$Op1, nxv16i8:$Op2, nxv16i8:$Op3)),
1616 (nxv16i8 (!cast<Instruction>(NAME # _B) (REG_SEQUENCE ZPR2, nxv16i8:$Op1, zsub0,
1617 nxv16i8:$Op2, zsub1),
1620 def : Pat<(nxv8i16 (op nxv8i16:$Op1, nxv8i16:$Op2, nxv8i16:$Op3)),
1621 (nxv8i16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8i16:$Op1, zsub0,
1622 nxv8i16:$Op2, zsub1),
1625 def : Pat<(nxv4i32 (op nxv4i32:$Op1, nxv4i32:$Op2, nxv4i32:$Op3)),
1626 (nxv4i32 (!cast<Instruction>(NAME # _S) (REG_SEQUENCE ZPR2, nxv4i32:$Op1, zsub0,
1627 nxv4i32:$Op2, zsub1),
1630 def : Pat<(nxv2i64 (op nxv2i64:$Op1, nxv2i64:$Op2, nxv2i64:$Op3)),
1631 (nxv2i64 (!cast<Instruction>(NAME # _D) (REG_SEQUENCE ZPR2, nxv2i64:$Op1, zsub0,
1632 nxv2i64:$Op2, zsub1),
1635 def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8i16:$Op3)),
1636 (nxv8f16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8f16:$Op1, zsub0,
1637 nxv8f16:$Op2, zsub1),
1640 def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4i32:$Op3)),
1641 (nxv4f32 (!cast<Instruction>(NAME # _S) (REG_SEQUENCE ZPR2, nxv4f32:$Op1, zsub0,
1642 nxv4f32:$Op2, zsub1),
1645 def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2i64:$Op3)),
1646 (nxv2f64 (!cast<Instruction>(NAME # _D) (REG_SEQUENCE ZPR2, nxv2f64:$Op1, zsub0,
1647 nxv2f64:$Op2, zsub1),
1650 def : Pat<(nxv8bf16 (op nxv8bf16:$Op1, nxv8bf16:$Op2, nxv8i16:$Op3)),
1651 (nxv8bf16 (!cast<Instruction>(NAME # _H) (REG_SEQUENCE ZPR2, nxv8bf16:$Op1, zsub0,
1652 nxv8bf16:$Op2, zsub1),
1656 class sve2_int_perm_tbx<bits<2> sz8_64, bits<2> opc, string asm, ZPRRegOp zprty>
1657 : I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, zprty:$Zm),
1658 asm, "\t$Zd, $Zn, $Zm",
1664 let Inst{31-24} = 0b00000101;
1665 let Inst{23-22} = sz8_64;
1667 let Inst{20-16} = Zm;
1668 let Inst{15-13} = 0b001;
1669 let Inst{12-11} = opc;
1674 let Constraints = "$Zd = $_Zd";
1675 let hasSideEffects = 0;
1678 multiclass sve2_int_perm_tbx<string asm, bits<2> opc, SDPatternOperator op> {
1679 def _B : sve2_int_perm_tbx<0b00, opc, asm, ZPR8>;
1680 def _H : sve2_int_perm_tbx<0b01, opc, asm, ZPR16>;
1681 def _S : sve2_int_perm_tbx<0b10, opc, asm, ZPR32>;
1682 def _D : sve2_int_perm_tbx<0b11, opc, asm, ZPR64>;
1684 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
1685 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1686 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
1687 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1689 def : SVE_3_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1690 def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
1691 def : SVE_3_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1693 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1696 class sve_int_perm_reverse_z<bits<2> sz8_64, string asm, ZPRRegOp zprty>
1697 : I<(outs zprty:$Zd), (ins zprty:$Zn),
1703 let Inst{31-24} = 0b00000101;
1704 let Inst{23-22} = sz8_64;
1705 let Inst{21-10} = 0b111000001110;
1709 let hasSideEffects = 0;
1712 multiclass sve_int_perm_reverse_z<string asm, SDPatternOperator op> {
1713 def _B : sve_int_perm_reverse_z<0b00, asm, ZPR8>;
1714 def _H : sve_int_perm_reverse_z<0b01, asm, ZPR16>;
1715 def _S : sve_int_perm_reverse_z<0b10, asm, ZPR32>;
1716 def _D : sve_int_perm_reverse_z<0b11, asm, ZPR64>;
1718 def : SVE_1_Op_Pat<nxv16i8, op, nxv16i8, !cast<Instruction>(NAME # _B)>;
1719 def : SVE_1_Op_Pat<nxv8i16, op, nxv8i16, !cast<Instruction>(NAME # _H)>;
1720 def : SVE_1_Op_Pat<nxv4i32, op, nxv4i32, !cast<Instruction>(NAME # _S)>;
1721 def : SVE_1_Op_Pat<nxv2i64, op, nxv2i64, !cast<Instruction>(NAME # _D)>;
1723 def : SVE_1_Op_Pat<nxv2f16, op, nxv2f16, !cast<Instruction>(NAME # _D)>;
1724 def : SVE_1_Op_Pat<nxv4f16, op, nxv4f16, !cast<Instruction>(NAME # _S)>;
1725 def : SVE_1_Op_Pat<nxv8f16, op, nxv8f16, !cast<Instruction>(NAME # _H)>;
1726 def : SVE_1_Op_Pat<nxv2f32, op, nxv2f32, !cast<Instruction>(NAME # _D)>;
1727 def : SVE_1_Op_Pat<nxv4f32, op, nxv4f32, !cast<Instruction>(NAME # _S)>;
1728 def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>;
1730 def : SVE_1_Op_Pat<nxv2bf16, op, nxv2bf16, !cast<Instruction>(NAME # _D)>;
1731 def : SVE_1_Op_Pat<nxv4bf16, op, nxv4bf16, !cast<Instruction>(NAME # _S)>;
1732 def : SVE_1_Op_Pat<nxv8bf16, op, nxv8bf16, !cast<Instruction>(NAME # _H)>;
1735 class sve_int_perm_reverse_p<bits<2> sz8_64, string asm, PPRRegOp pprty,
1736 SDPatternOperator op>
1737 : I<(outs pprty:$Pd), (ins pprty:$Pn),
1740 [(set nxv16i1:$Pd, (op nxv16i1:$Pn))]>, Sched<[]> {
1743 let Inst{31-24} = 0b00000101;
1744 let Inst{23-22} = sz8_64;
1745 let Inst{21-9} = 0b1101000100000;
1750 let hasSideEffects = 0;
1753 multiclass sve_int_perm_reverse_p<string asm, SDPatternOperator ir_op,
1754 SDPatternOperator op_b16,
1755 SDPatternOperator op_b32,
1756 SDPatternOperator op_b64> {
1757 def _B : sve_int_perm_reverse_p<0b00, asm, PPR8, ir_op>;
1758 def _H : sve_int_perm_reverse_p<0b01, asm, PPR16, op_b16>;
1759 def _S : sve_int_perm_reverse_p<0b10, asm, PPR32, op_b32>;
1760 def _D : sve_int_perm_reverse_p<0b11, asm, PPR64, op_b64>;
1762 def : SVE_1_Op_Pat<nxv8i1, ir_op, nxv8i1, !cast<Instruction>(NAME # _H)>;
1763 def : SVE_1_Op_Pat<nxv4i1, ir_op, nxv4i1, !cast<Instruction>(NAME # _S)>;
1764 def : SVE_1_Op_Pat<nxv2i1, ir_op, nxv2i1, !cast<Instruction>(NAME # _D)>;
1767 class sve_int_perm_unpk<bits<2> sz16_64, bits<2> opc, string asm,
1768 ZPRRegOp zprty1, ZPRRegOp zprty2>
1769 : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
1771 "", []>, Sched<[]> {
1774 let Inst{31-24} = 0b00000101;
1775 let Inst{23-22} = sz16_64;
1776 let Inst{21-18} = 0b1100;
1777 let Inst{17-16} = opc;
1778 let Inst{15-10} = 0b001110;
1782 let hasSideEffects = 0;
1785 multiclass sve_int_perm_unpk<bits<2> opc, string asm, SDPatternOperator op> {
1786 def _H : sve_int_perm_unpk<0b01, opc, asm, ZPR16, ZPR8>;
1787 def _S : sve_int_perm_unpk<0b10, opc, asm, ZPR32, ZPR16>;
1788 def _D : sve_int_perm_unpk<0b11, opc, asm, ZPR64, ZPR32>;
1790 def : SVE_1_Op_Pat<nxv8i16, op, nxv16i8, !cast<Instruction>(NAME # _H)>;
1791 def : SVE_1_Op_Pat<nxv4i32, op, nxv8i16, !cast<Instruction>(NAME # _S)>;
1792 def : SVE_1_Op_Pat<nxv2i64, op, nxv4i32, !cast<Instruction>(NAME # _D)>;
1795 class sve_int_perm_insrs<bits<2> sz8_64, string asm, ZPRRegOp zprty,
1796 RegisterClass srcRegType>
1797 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcRegType:$Rm),
1803 let Inst{31-24} = 0b00000101;
1804 let Inst{23-22} = sz8_64;
1805 let Inst{21-10} = 0b100100001110;
1807 let Inst{4-0} = Zdn;
1809 let Constraints = "$Zdn = $_Zdn";
1810 let DestructiveInstType = DestructiveOther;
1811 let hasSideEffects = 0;
1814 multiclass sve_int_perm_insrs<string asm, SDPatternOperator op> {
1815 def _B : sve_int_perm_insrs<0b00, asm, ZPR8, GPR32>;
1816 def _H : sve_int_perm_insrs<0b01, asm, ZPR16, GPR32>;
1817 def _S : sve_int_perm_insrs<0b10, asm, ZPR32, GPR32>;
1818 def _D : sve_int_perm_insrs<0b11, asm, ZPR64, GPR64>;
1820 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, i32, !cast<Instruction>(NAME # _B)>;
1821 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, i32, !cast<Instruction>(NAME # _H)>;
1822 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, i32, !cast<Instruction>(NAME # _S)>;
1823 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, i64, !cast<Instruction>(NAME # _D)>;
1826 class sve_int_perm_insrv<bits<2> sz8_64, string asm, ZPRRegOp zprty,
1827 FPRasZPROperand srcOpType>
1828 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcOpType:$Vm),
1834 let Inst{31-24} = 0b00000101;
1835 let Inst{23-22} = sz8_64;
1836 let Inst{21-10} = 0b110100001110;
1838 let Inst{4-0} = Zdn;
1840 let Constraints = "$Zdn = $_Zdn";
1841 let DestructiveInstType = DestructiveOther;
1842 let hasSideEffects = 0;
1845 multiclass sve_int_perm_insrv<string asm, SDPatternOperator op> {
1846 def _B : sve_int_perm_insrv<0b00, asm, ZPR8, FPR8asZPR>;
1847 def _H : sve_int_perm_insrv<0b01, asm, ZPR16, FPR16asZPR>;
1848 def _S : sve_int_perm_insrv<0b10, asm, ZPR32, FPR32asZPR>;
1849 def _D : sve_int_perm_insrv<0b11, asm, ZPR64, FPR64asZPR>;
1851 def : Pat<(nxv8f16 (op nxv8f16:$Zn, f16:$Vm)),
1852 (!cast<Instruction>(NAME # _H) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, hsub))>;
1853 def : Pat<(nxv4f32 (op nxv4f32:$Zn, f32:$Vm)),
1854 (!cast<Instruction>(NAME # _S) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, ssub))>;
1855 def : Pat<(nxv2f64 (op nxv2f64:$Zn, f64:$Vm)),
1856 (!cast<Instruction>(NAME # _D) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, dsub))>;
1858 def : Pat<(nxv8bf16 (op nxv8bf16:$Zn, bf16:$Vm)),
1859 (!cast<Instruction>(NAME # _H) $Zn, (INSERT_SUBREG (IMPLICIT_DEF), $Vm, hsub))>;
1861 // Keep integer insertions within the vector unit.
1862 def : Pat<(nxv16i8 (op (nxv16i8 ZPR:$Zn), (i32 (vector_extract (nxv16i8 ZPR:$Vm), 0)))),
1863 (!cast<Instruction>(NAME # _B) $Zn, ZPR:$Vm)>;
1864 def : Pat<(nxv8i16 (op (nxv8i16 ZPR:$Zn), (i32 (vector_extract (nxv8i16 ZPR:$Vm), 0)))),
1865 (!cast<Instruction>(NAME # _H) $Zn, ZPR:$Vm)>;
1866 def : Pat<(nxv4i32 (op (nxv4i32 ZPR:$Zn), (i32 (vector_extract (nxv4i32 ZPR:$Vm), 0)))),
1867 (!cast<Instruction>(NAME # _S) $Zn, ZPR: $Vm)>;
1868 def : Pat<(nxv2i64 (op (nxv2i64 ZPR:$Zn), (i64 (vector_extract (nxv2i64 ZPR:$Vm), 0)))),
1869 (!cast<Instruction>(NAME # _D) $Zn, ZPR:$Vm)>;
1873 //===----------------------------------------------------------------------===//
1874 // SVE Permute - Extract Group
1875 //===----------------------------------------------------------------------===//
1877 class sve_int_perm_extract_i<string asm>
1878 : I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn, ZPR8:$Zm, imm0_255:$imm8),
1879 asm, "\t$Zdn, $_Zdn, $Zm, $imm8",
1880 "", []>, Sched<[]> {
1884 let Inst{31-21} = 0b00000101001;
1885 let Inst{20-16} = imm8{7-3};
1886 let Inst{15-13} = 0b000;
1887 let Inst{12-10} = imm8{2-0};
1889 let Inst{4-0} = Zdn;
1891 let Constraints = "$Zdn = $_Zdn";
1892 let DestructiveInstType = DestructiveOther;
1893 let ElementSize = ElementSizeNone;
1894 let hasSideEffects = 0;
1897 multiclass sve_int_perm_extract_i<string asm, SDPatternOperator op> {
1898 def NAME : sve_int_perm_extract_i<asm>;
1900 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, imm0_255,
1901 !cast<Instruction>(NAME)>;
1904 class sve2_int_perm_extract_i_cons<string asm>
1905 : I<(outs ZPR8:$Zd), (ins ZZ_b:$Zn, imm0_255:$imm8),
1906 asm, "\t$Zd, $Zn, $imm8",
1907 "", []>, Sched<[]> {
1911 let Inst{31-21} = 0b00000101011;
1912 let Inst{20-16} = imm8{7-3};
1913 let Inst{15-13} = 0b000;
1914 let Inst{12-10} = imm8{2-0};
1918 let hasSideEffects = 0;
1921 //===----------------------------------------------------------------------===//
1922 // SVE Vector Select Group
1923 //===----------------------------------------------------------------------===//
1925 class sve_int_sel_vvv<bits<2> sz8_64, string asm, ZPRRegOp zprty>
1926 : I<(outs zprty:$Zd), (ins PPRAny:$Pg, zprty:$Zn, zprty:$Zm),
1927 asm, "\t$Zd, $Pg, $Zn, $Zm",
1934 let Inst{31-24} = 0b00000101;
1935 let Inst{23-22} = sz8_64;
1937 let Inst{20-16} = Zm;
1938 let Inst{15-14} = 0b11;
1939 let Inst{13-10} = Pg;
1943 let hasSideEffects = 0;
1946 multiclass sve_int_sel_vvv<string asm, SDPatternOperator op> {
1947 def _B : sve_int_sel_vvv<0b00, asm, ZPR8>;
1948 def _H : sve_int_sel_vvv<0b01, asm, ZPR16>;
1949 def _S : sve_int_sel_vvv<0b10, asm, ZPR32>;
1950 def _D : sve_int_sel_vvv<0b11, asm, ZPR64>;
1952 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
1953 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
1954 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
1955 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1957 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
1958 def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _S)>;
1959 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
1960 def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _D)>;
1961 def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _D)>;
1962 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
1964 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
1966 def : InstAlias<"mov $Zd, $Pg/m, $Zn",
1967 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPRAny:$Pg, ZPR8:$Zn, ZPR8:$Zd), 1>;
1968 def : InstAlias<"mov $Zd, $Pg/m, $Zn",
1969 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, ZPR16:$Zn, ZPR16:$Zd), 1>;
1970 def : InstAlias<"mov $Zd, $Pg/m, $Zn",
1971 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, ZPR32:$Zn, ZPR32:$Zd), 1>;
1972 def : InstAlias<"mov $Zd, $Pg/m, $Zn",
1973 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, ZPR64:$Zn, ZPR64:$Zd), 1>;
1977 //===----------------------------------------------------------------------===//
1978 // SVE Predicate Logical Operations Group
1979 //===----------------------------------------------------------------------===//
1981 class sve_int_pred_log<bits<4> opc, string asm>
1982 : I<(outs PPRorPNR8:$Pd), (ins PPRorPNRAny:$Pg, PPRorPNR8:$Pn, PPRorPNR8:$Pm),
1983 asm, "\t$Pd, $Pg/z, $Pn, $Pm",
1990 let Inst{31-24} = 0b00100101;
1991 let Inst{23-22} = opc{3-2};
1992 let Inst{21-20} = 0b00;
1993 let Inst{19-16} = Pm;
1994 let Inst{15-14} = 0b01;
1995 let Inst{13-10} = Pg;
1996 let Inst{9} = opc{1};
1998 let Inst{4} = opc{0};
2001 // SEL has no predication qualifier.
2002 let AsmString = !if(!eq(opc, 0b0011),
2003 !strconcat(asm, "\t$Pd, $Pg, $Pn, $Pm"),
2004 !strconcat(asm, "\t$Pd, $Pg/z, $Pn, $Pm"));
2006 let Defs = !if(!eq (opc{2}, 1), [NZCV], []);
2007 let hasSideEffects = 0;
2010 multiclass sve_int_pred_log<bits<4> opc, string asm, SDPatternOperator op,
2011 SDPatternOperator op_nopred = null_frag> {
2012 def NAME : sve_int_pred_log<opc, asm>;
2014 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
2015 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i1, nxv8i1, !cast<Instruction>(NAME)>;
2016 def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i1, nxv4i1, !cast<Instruction>(NAME)>;
2017 def : SVE_3_Op_Pat<nxv2i1, op, nxv2i1, nxv2i1, nxv2i1, !cast<Instruction>(NAME)>;
2018 def : SVE_3_Op_Pat<nxv1i1, op, nxv1i1, nxv1i1, nxv1i1, !cast<Instruction>(NAME)>;
2019 def : SVE_2_Op_AllActive_Pat<nxv16i1, op_nopred, nxv16i1, nxv16i1,
2020 !cast<Instruction>(NAME), PTRUE_B>;
2021 def : SVE_2_Op_AllActive_Pat<nxv8i1, op_nopred, nxv8i1, nxv8i1,
2022 !cast<Instruction>(NAME), PTRUE_H>;
2023 def : SVE_2_Op_AllActive_Pat<nxv4i1, op_nopred, nxv4i1, nxv4i1,
2024 !cast<Instruction>(NAME), PTRUE_S>;
2025 def : SVE_2_Op_AllActive_Pat<nxv2i1, op_nopred, nxv2i1, nxv2i1,
2026 !cast<Instruction>(NAME), PTRUE_D>;
2027 // Emulate .Q operation using a PTRUE_D when the other lanes don't matter.
2028 def : SVE_2_Op_AllActive_Pat<nxv1i1, op_nopred, nxv1i1, nxv1i1,
2029 !cast<Instruction>(NAME), PTRUE_D>;
2032 // An instance of sve_int_pred_log_and but uses op_nopred's first operand as the
2033 // general predicate.
2034 multiclass sve_int_pred_log_v2<bits<4> opc, string asm, SDPatternOperator op,
2035 SDPatternOperator op_nopred> :
2036 sve_int_pred_log<opc, asm, op> {
2037 def : Pat<(nxv16i1 (op_nopred nxv16i1:$Op1, nxv16i1:$Op2)),
2038 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
2039 def : Pat<(nxv8i1 (op_nopred nxv8i1:$Op1, nxv8i1:$Op2)),
2040 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
2041 def : Pat<(nxv4i1 (op_nopred nxv4i1:$Op1, nxv4i1:$Op2)),
2042 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
2043 def : Pat<(nxv2i1 (op_nopred nxv2i1:$Op1, nxv2i1:$Op2)),
2044 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
2045 // Emulate .Q operation using a PTRUE_D when the other lanes don't matter.
2046 def : Pat<(nxv1i1 (op_nopred nxv1i1:$Op1, nxv1i1:$Op2)),
2047 (!cast<Instruction>(NAME) $Op1, $Op1, $Op2)>;
2050 //===----------------------------------------------------------------------===//
2051 // SVE Logical Mask Immediate Group
2052 //===----------------------------------------------------------------------===//
2054 class sve_int_log_imm<bits<2> opc, string asm>
2055 : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, logical_imm64:$imms13),
2056 asm, "\t$Zdn, $_Zdn, $imms13",
2057 "", []>, Sched<[]> {
2060 let Inst{31-24} = 0b00000101;
2061 let Inst{23-22} = opc;
2062 let Inst{21-18} = 0b0000;
2063 let Inst{17-5} = imms13;
2064 let Inst{4-0} = Zdn;
2066 let Constraints = "$Zdn = $_Zdn";
2067 let DecoderMethod = "DecodeSVELogicalImmInstruction";
2068 let DestructiveInstType = DestructiveOther;
2069 let ElementSize = ElementSizeNone;
2070 let hasSideEffects = 0;
2073 multiclass sve_int_log_imm<bits<2> opc, string asm, string alias, SDPatternOperator op> {
2074 def NAME : sve_int_log_imm<opc, asm>;
2076 def : SVE_1_Op_Imm_Log_Pat<nxv16i8, op, ZPR8, i32, SVELogicalImm8Pat, !cast<Instruction>(NAME)>;
2077 def : SVE_1_Op_Imm_Log_Pat<nxv8i16, op, ZPR16, i32, SVELogicalImm16Pat, !cast<Instruction>(NAME)>;
2078 def : SVE_1_Op_Imm_Log_Pat<nxv4i32, op, ZPR32, i32, SVELogicalImm32Pat, !cast<Instruction>(NAME)>;
2079 def : SVE_1_Op_Imm_Log_Pat<nxv2i64, op, ZPR64, i64, SVELogicalImm64Pat, !cast<Instruction>(NAME)>;
2081 def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
2082 (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8:$imm), 4>;
2083 def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
2084 (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16:$imm), 3>;
2085 def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
2086 (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32:$imm), 2>;
2088 def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
2089 (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8_not:$imm), 0>;
2090 def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
2091 (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16_not:$imm), 0>;
2092 def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
2093 (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32_not:$imm), 0>;
2094 def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
2095 (!cast<Instruction>(NAME) ZPR64:$Zdn, logical_imm64_not:$imm), 0>;
2098 multiclass sve_int_log_imm_bic<SDPatternOperator op> {
2099 def : SVE_1_Op_Imm_Log_Pat<nxv16i8, op, ZPR8, i32, SVELogicalImm8NotPat, !cast<Instruction>("AND_ZI")>;
2100 def : SVE_1_Op_Imm_Log_Pat<nxv8i16, op, ZPR16, i32, SVELogicalImm16NotPat, !cast<Instruction>("AND_ZI")>;
2101 def : SVE_1_Op_Imm_Log_Pat<nxv4i32, op, ZPR32, i32, SVELogicalImm32NotPat, !cast<Instruction>("AND_ZI")>;
2102 def : SVE_1_Op_Imm_Log_Pat<nxv2i64, op, ZPR64, i64, SVELogicalImm64NotPat, !cast<Instruction>("AND_ZI")>;
2105 class sve_int_dup_mask_imm<string asm>
2106 : I<(outs ZPR64:$Zd), (ins logical_imm64:$imms),
2107 asm, "\t$Zd, $imms",
2112 let Inst{31-18} = 0b00000101110000;
2113 let Inst{17-5} = imms;
2116 let DecoderMethod = "DecodeSVELogicalImmInstruction";
2117 let hasSideEffects = 0;
2118 let isReMaterializable = 1;
2122 multiclass sve_int_dup_mask_imm<string asm> {
2123 def NAME : sve_int_dup_mask_imm<asm>;
2125 def : InstAlias<"dupm $Zd, $imm",
2126 (!cast<Instruction>(NAME) ZPR8:$Zd, sve_logical_imm8:$imm), 4>;
2127 def : InstAlias<"dupm $Zd, $imm",
2128 (!cast<Instruction>(NAME) ZPR16:$Zd, sve_logical_imm16:$imm), 3>;
2129 def : InstAlias<"dupm $Zd, $imm",
2130 (!cast<Instruction>(NAME) ZPR32:$Zd, sve_logical_imm32:$imm), 2>;
2132 // All Zd.b forms have a CPY/DUP equivalent, hence no byte alias here.
2133 def : InstAlias<"mov $Zd, $imm",
2134 (!cast<Instruction>(NAME) ZPR16:$Zd, sve_preferred_logical_imm16:$imm), 7>;
2135 def : InstAlias<"mov $Zd, $imm",
2136 (!cast<Instruction>(NAME) ZPR32:$Zd, sve_preferred_logical_imm32:$imm), 6>;
2137 def : InstAlias<"mov $Zd, $imm",
2138 (!cast<Instruction>(NAME) ZPR64:$Zd, sve_preferred_logical_imm64:$imm), 5>;
2140 // NOTE: No pattern for nxv16i8 because DUP has full coverage.
2141 def : Pat<(nxv8i16 (splat_vector (i32 (SVELogicalImm16Pat i64:$imm)))),
2142 (!cast<Instruction>(NAME) i64:$imm)>;
2143 def : Pat<(nxv4i32 (splat_vector (i32 (SVELogicalImm32Pat i64:$imm)))),
2144 (!cast<Instruction>(NAME) i64:$imm)>;
2145 def : Pat<(nxv2i64 (splat_vector (i64 (SVELogicalImm64Pat i64:$imm)))),
2146 (!cast<Instruction>(NAME) i64:$imm)>;
2149 //===----------------------------------------------------------------------===//
2150 // SVE Integer Arithmetic - Unpredicated Group.
2151 //===----------------------------------------------------------------------===//
2153 class sve_int_bin_cons_arit_0<bits<2> sz8_64, bits<3> opc, string asm,
2155 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
2156 asm, "\t$Zd, $Zn, $Zm",
2157 "", []>, Sched<[]> {
2161 let Inst{31-24} = 0b00000100;
2162 let Inst{23-22} = sz8_64;
2164 let Inst{20-16} = Zm;
2165 let Inst{15-13} = 0b000;
2166 let Inst{12-10} = opc;
2170 let hasSideEffects = 0;
2173 multiclass sve_int_bin_cons_arit_0<bits<3> opc, string asm, SDPatternOperator op> {
2174 def _B : sve_int_bin_cons_arit_0<0b00, opc, asm, ZPR8>;
2175 def _H : sve_int_bin_cons_arit_0<0b01, opc, asm, ZPR16>;
2176 def _S : sve_int_bin_cons_arit_0<0b10, opc, asm, ZPR32>;
2177 def _D : sve_int_bin_cons_arit_0<0b11, opc, asm, ZPR64>;
2179 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
2180 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
2181 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
2182 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
2185 //===----------------------------------------------------------------------===//
2186 // SVE Floating Point Arithmetic - Predicated Group
2187 //===----------------------------------------------------------------------===//
2189 class sve_fp_2op_i_p_zds<bits<2> sz, bits<3> opc, string asm,
2192 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, imm_ty:$i1),
2193 asm, "\t$Zdn, $Pg/m, $_Zdn, $i1",
2199 let Inst{31-24} = 0b01100101;
2200 let Inst{23-22} = sz;
2201 let Inst{21-19} = 0b011;
2202 let Inst{18-16} = opc;
2203 let Inst{15-13} = 0b100;
2204 let Inst{12-10} = Pg;
2205 let Inst{9-6} = 0b0000;
2207 let Inst{4-0} = Zdn;
2209 let Constraints = "$Zdn = $_Zdn";
2210 let DestructiveInstType = DestructiveOther;
2211 let ElementSize = zprty.ElementSize;
2212 let hasSideEffects = 0;
2213 let mayRaiseFPException = 1;
2216 multiclass sve_fp_2op_i_p_zds<bits<3> opc, string asm, string Ps, Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator op> {
2217 let DestructiveInstType = DestructiveBinaryImm in {
2218 def _H : SVEPseudo2Instr<Ps # _H, 1>, sve_fp_2op_i_p_zds<0b01, opc, asm, ZPR16, imm_ty>;
2219 def _S : SVEPseudo2Instr<Ps # _S, 1>, sve_fp_2op_i_p_zds<0b10, opc, asm, ZPR32, imm_ty>;
2220 def _D : SVEPseudo2Instr<Ps # _D, 1>, sve_fp_2op_i_p_zds<0b11, opc, asm, ZPR64, imm_ty>;
2223 def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_H")>;
2224 def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_H")>;
2225 def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_S")>;
2226 def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_S")>;
2227 def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_D")>;
2228 def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_D")>;
2231 class sve_fp_2op_p_zds<bits<2> sz, bits<4> opc, string asm,
2233 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
2234 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
2240 let Inst{31-24} = 0b01100101;
2241 let Inst{23-22} = sz;
2242 let Inst{21-20} = 0b00;
2243 let Inst{19-16} = opc;
2244 let Inst{15-13} = 0b100;
2245 let Inst{12-10} = Pg;
2247 let Inst{4-0} = Zdn;
2249 let Constraints = "$Zdn = $_Zdn";
2250 let DestructiveInstType = DestructiveOther;
2251 let ElementSize = zprty.ElementSize;
2252 let hasSideEffects = 0;
2253 let mayRaiseFPException = 1;
2256 multiclass sve_fp_2op_p_zds<bits<4> opc, string asm, string Ps,
2257 SDPatternOperator op, DestructiveInstTypeEnum flags,
2258 string revname="", bit isReverseInstr=0> {
2259 let DestructiveInstType = flags in {
2260 def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>,
2261 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
2262 def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>,
2263 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
2264 def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>,
2265 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
2268 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2269 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2270 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
2273 multiclass sve_fp_2op_p_zds_fscale<bits<4> opc, string asm,
2274 SDPatternOperator op> {
2275 def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>;
2276 def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>;
2277 def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>;
2279 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
2280 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
2281 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
2284 multiclass sve_fp_2op_p_zds_bfloat<bits<4> opc, string asm, string Ps,
2285 SDPatternOperator op,
2286 DestructiveInstTypeEnum flags,
2287 string revname="", bit isReverseInstr=0> {
2288 let DestructiveInstType = flags in {
2289 def NAME : sve_fp_2op_p_zds<0b00, opc, asm, ZPR16>,
2290 SVEPseudo2Instr<Ps, 1>, SVEInstr2Rev<NAME , revname , isReverseInstr>;
2293 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
2296 class sve_fp_2op_p_zds_bfscale<bits<4> opc, string asm, DestructiveInstTypeEnum flags>
2297 : sve_fp_2op_p_zds<0b00, opc, asm, ZPR16>{
2298 let DestructiveInstType = flags;
2301 multiclass sve_fp_2op_p_zds_zeroing_hsd<SDPatternOperator op> {
2302 def _H_ZERO : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesZero>;
2303 def _S_ZERO : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesZero>;
2304 def _D_ZERO : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesZero>;
2306 def : SVE_3_Op_Pat_SelZero<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Pseudo>(NAME # _H_ZERO)>;
2307 def : SVE_3_Op_Pat_SelZero<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Pseudo>(NAME # _S_ZERO)>;
2308 def : SVE_3_Op_Pat_SelZero<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Pseudo>(NAME # _D_ZERO)>;
2311 multiclass sve_fp_2op_p_zds_zeroing_bfloat<SDPatternOperator op> {
2312 def _ZERO : PredTwoOpPseudo<NAME, ZPR16, FalseLanesZero>;
2314 def : SVE_3_Op_Pat_SelZero<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Pseudo>(NAME # _ZERO)>;
2317 class sve_fp_ftmad<bits<2> sz, string asm, ZPRRegOp zprty>
2318 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, timm32_0_7:$imm3),
2319 asm, "\t$Zdn, $_Zdn, $Zm, $imm3",
2325 let Inst{31-24} = 0b01100101;
2326 let Inst{23-22} = sz;
2327 let Inst{21-19} = 0b010;
2328 let Inst{18-16} = imm3;
2329 let Inst{15-10} = 0b100000;
2331 let Inst{4-0} = Zdn;
2333 let Constraints = "$Zdn = $_Zdn";
2334 let DestructiveInstType = DestructiveOther;
2335 let ElementSize = ElementSizeNone;
2336 let hasSideEffects = 0;
2337 let mayRaiseFPException = 1;
2340 multiclass sve_fp_ftmad<string asm, SDPatternOperator op> {
2341 def _H : sve_fp_ftmad<0b01, asm, ZPR16>;
2342 def _S : sve_fp_ftmad<0b10, asm, ZPR32>;
2343 def _D : sve_fp_ftmad<0b11, asm, ZPR64>;
2345 def : Pat<(nxv8f16 (op (nxv8f16 ZPR16:$Zn), (nxv8f16 ZPR16:$Zm), (i32 timm32_0_7:$imm))),
2346 (!cast<Instruction>(NAME # _H) ZPR16:$Zn, ZPR16:$Zm, timm32_0_7:$imm)>;
2347 def : Pat<(nxv4f32 (op (nxv4f32 ZPR32:$Zn), (nxv4f32 ZPR32:$Zm), (i32 timm32_0_7:$imm))),
2348 (!cast<Instruction>(NAME # _S) ZPR32:$Zn, ZPR32:$Zm, timm32_0_7:$imm)>;
2349 def : Pat<(nxv2f64 (op (nxv2f64 ZPR64:$Zn), (nxv2f64 ZPR64:$Zm), (i32 timm32_0_7:$imm))),
2350 (!cast<Instruction>(NAME # _D) ZPR64:$Zn, ZPR64:$Zm, timm32_0_7:$imm)>;
2353 multiclass sve_fp_2op_i_p_zds_hfd<Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator ir_op = null_frag> {
2354 def _H_UNDEF : PredTwoOpImmPseudo<NAME # _H, ZPR16, imm_ty, FalseLanesUndef>;
2355 def _S_UNDEF : PredTwoOpImmPseudo<NAME # _S, ZPR32, imm_ty, FalseLanesUndef>;
2356 def _D_UNDEF : PredTwoOpImmPseudo<NAME # _D, ZPR64, imm_ty, FalseLanesUndef>;
2358 def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, ir_op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_H_UNDEF")>;
2359 def : SVE_2_Op_Fp_Imm_Pat<nxv8f16, ir_op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_H_UNDEF")>;
2360 def : SVE_2_Op_Fp_Imm_Pat<nxv4f16, ir_op, nxv4i1, f16, A, 0, !cast<Instruction>(NAME # "_H_UNDEF")>;
2361 def : SVE_2_Op_Fp_Imm_Pat<nxv4f16, ir_op, nxv4i1, f16, B, 1, !cast<Instruction>(NAME # "_H_UNDEF")>;
2362 def : SVE_2_Op_Fp_Imm_Pat<nxv2f16, ir_op, nxv2i1, f16, A, 0, !cast<Instruction>(NAME # "_H_UNDEF")>;
2363 def : SVE_2_Op_Fp_Imm_Pat<nxv2f16, ir_op, nxv2i1, f16, B, 1, !cast<Instruction>(NAME # "_H_UNDEF")>;
2364 def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, ir_op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_S_UNDEF")>;
2365 def : SVE_2_Op_Fp_Imm_Pat<nxv4f32, ir_op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_S_UNDEF")>;
2366 def : SVE_2_Op_Fp_Imm_Pat<nxv2f32, ir_op, nxv2i1, f32, A, 0, !cast<Instruction>(NAME # "_S_UNDEF")>;
2367 def : SVE_2_Op_Fp_Imm_Pat<nxv2f32, ir_op, nxv2i1, f32, B, 1, !cast<Instruction>(NAME # "_S_UNDEF")>;
2368 def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, ir_op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_D_UNDEF")>;
2369 def : SVE_2_Op_Fp_Imm_Pat<nxv2f64, ir_op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_D_UNDEF")>;
2372 multiclass sve_fp_2op_i_p_zds_zeroing_hfd<Operand imm_ty, FPImmLeaf A, FPImmLeaf B, SDPatternOperator op> {
2373 def _H_ZERO : PredTwoOpImmPseudo<NAME # _H, ZPR16, imm_ty, FalseLanesZero>;
2374 def _S_ZERO : PredTwoOpImmPseudo<NAME # _S, ZPR32, imm_ty, FalseLanesZero>;
2375 def _D_ZERO : PredTwoOpImmPseudo<NAME # _D, ZPR64, imm_ty, FalseLanesZero>;
2377 let AddedComplexity = 2 in {
2378 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv8f16, op, nxv8i1, f16, A, 0, !cast<Instruction>(NAME # "_H_ZERO")>;
2379 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv8f16, op, nxv8i1, f16, B, 1, !cast<Instruction>(NAME # "_H_ZERO")>;
2380 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv4f32, op, nxv4i1, f32, A, 0, !cast<Instruction>(NAME # "_S_ZERO")>;
2381 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv4f32, op, nxv4i1, f32, B, 1, !cast<Instruction>(NAME # "_S_ZERO")>;
2382 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv2f64, op, nxv2i1, f64, A, 0, !cast<Instruction>(NAME # "_D_ZERO")>;
2383 def : SVE_2_Op_Fp_Imm_Pat_Zero<nxv2f64, op, nxv2i1, f64, B, 1, !cast<Instruction>(NAME # "_D_ZERO")>;
2387 //===----------------------------------------------------------------------===//
2388 // SVE Floating Point Arithmetic - Unpredicated Group
2389 //===----------------------------------------------------------------------===//
2391 class sve_fp_3op_u_zd<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty>
2392 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
2393 asm, "\t$Zd, $Zn, $Zm",
2399 let Inst{31-24} = 0b01100101;
2400 let Inst{23-22} = sz;
2402 let Inst{20-16} = Zm;
2403 let Inst{15-13} = 0b000;
2404 let Inst{12-10} = opc;
2408 let hasSideEffects = 0;
2409 let mayRaiseFPException = 1;
2412 multiclass sve_fp_3op_u_zd<bits<3> opc, string asm, SDPatternOperator op> {
2413 def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>;
2414 def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>;
2415 def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>;
2417 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2418 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2419 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
2422 multiclass sve_fp_3op_u_zd_bfloat<bits<3> opc, string asm, SDPatternOperator op> {
2423 def NAME : sve_fp_3op_u_zd<0b00, opc, asm, ZPR16>;
2425 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
2426 def : SVE_2_Op_Pat<nxv4bf16, op, nxv4bf16, nxv4bf16, !cast<Instruction>(NAME)>;
2427 def : SVE_2_Op_Pat<nxv2bf16, op, nxv2bf16, nxv2bf16, !cast<Instruction>(NAME)>;
2430 multiclass sve_fp_3op_u_zd_ftsmul<bits<3> opc, string asm, SDPatternOperator op> {
2431 def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>;
2432 def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>;
2433 def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>;
2435 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
2436 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
2437 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
2440 //===----------------------------------------------------------------------===//
2441 // SVE Floating Point Fused Multiply-Add Group
2442 //===----------------------------------------------------------------------===//
2444 class sve_fp_3op_p_zds_a<bits<2> sz, bits<2> opc, string asm, ZPRRegOp zprty>
2445 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
2446 asm, "\t$Zda, $Pg/m, $Zn, $Zm",
2453 let Inst{31-24} = 0b01100101;
2454 let Inst{23-22} = sz;
2456 let Inst{20-16} = Zm;
2458 let Inst{14-13} = opc;
2459 let Inst{12-10} = Pg;
2461 let Inst{4-0} = Zda;
2463 let Constraints = "$Zda = $_Zda";
2464 let ElementSize = zprty.ElementSize;
2465 let DestructiveInstType = DestructiveTernaryCommWithRev;
2466 let hasSideEffects = 0;
2467 let mayRaiseFPException = 1;
2470 multiclass sve_fp_3op_p_zds_a<bits<2> opc, string asm, string Ps,
2471 SDPatternOperator op, string revname,
2472 bit isReverseInstr=0> {
2473 def _H : sve_fp_3op_p_zds_a<0b01, opc, asm, ZPR16>,
2474 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
2475 def _S : sve_fp_3op_p_zds_a<0b10, opc, asm, ZPR32>,
2476 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
2477 def _D : sve_fp_3op_p_zds_a<0b11, opc, asm, ZPR64>,
2478 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
2480 def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2481 def : SVE_4_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _H)>;
2482 def : SVE_4_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _H)>;
2483 def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2484 def : SVE_4_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _S)>;
2485 def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
2488 multiclass sve_fp_3op_p_zds_a_bfloat<bits<2> opc, string asm, string Ps,
2489 SDPatternOperator op> {
2490 def NAME : sve_fp_3op_p_zds_a<0b00, opc, asm, ZPR16>,
2491 SVEPseudo2Instr<Ps, 1>, SVEInstr2Rev<NAME, "", 0>;
2493 def : SVE_4_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
2496 class sve_fp_3op_p_zds_b<bits<2> sz, bits<2> opc, string asm,
2498 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
2499 asm, "\t$Zdn, $Pg/m, $Zm, $Za",
2506 let Inst{31-24} = 0b01100101;
2507 let Inst{23-22} = sz;
2509 let Inst{20-16} = Za;
2511 let Inst{14-13} = opc;
2512 let Inst{12-10} = Pg;
2514 let Inst{4-0} = Zdn;
2516 let Constraints = "$Zdn = $_Zdn";
2517 let DestructiveInstType = DestructiveOther;
2518 let ElementSize = zprty.ElementSize;
2519 let hasSideEffects = 0;
2520 let mayRaiseFPException = 1;
2523 multiclass sve_fp_3op_p_zds_b<bits<2> opc, string asm, SDPatternOperator op,
2524 string revname, bit isReverseInstr> {
2525 def _H : sve_fp_3op_p_zds_b<0b01, opc, asm, ZPR16>,
2526 SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
2527 def _S : sve_fp_3op_p_zds_b<0b10, opc, asm, ZPR32>,
2528 SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
2529 def _D : sve_fp_3op_p_zds_b<0b11, opc, asm, ZPR64>,
2530 SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
2532 def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2533 def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2534 def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
2537 //===----------------------------------------------------------------------===//
2538 // SVE Floating Point Multiply-Add - Indexed Group
2539 //===----------------------------------------------------------------------===//
2541 class sve_fp_fma_by_indexed_elem<bits<2> sz, bits<2> opc, string asm,
2543 ZPRRegOp zprty2, Operand itype>
2544 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty1:$Zn, zprty2:$Zm, itype:$iop),
2545 asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
2548 let Inst{31-24} = 0b01100100;
2549 let Inst{23-22} = sz;
2551 let Inst{15-12} = 0b0000;
2552 let Inst{11-10} = opc;
2554 let Inst{4-0} = Zda;
2556 let Constraints = "$Zda = $_Zda";
2557 let DestructiveInstType = DestructiveOther;
2558 let ElementSize = ElementSizeNone;
2559 let hasSideEffects = 0;
2560 let mayRaiseFPException = 1;
2563 multiclass sve_fp_fma_by_indexed_elem<bits<2> opc, string asm,
2564 SDPatternOperator op> {
2565 def _H : sve_fp_fma_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
2568 let Inst{22} = iop{2};
2569 let Inst{20-19} = iop{1-0};
2570 let Inst{18-16} = Zm;
2572 def _S : sve_fp_fma_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR3b32, VectorIndexS32b> {
2575 let Inst{20-19} = iop;
2576 let Inst{18-16} = Zm;
2578 def _D : sve_fp_fma_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR4b64, VectorIndexD32b> {
2582 let Inst{19-16} = Zm;
2585 def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b_timm:$idx))),
2586 (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b_timm:$idx)>;
2587 def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b_timm:$idx))),
2588 (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx)>;
2589 def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b_timm:$idx))),
2590 (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx)>;
2593 multiclass sve_fp_fma_by_indexed_elem_bfloat<string asm, bits<2> opc,
2594 SDPatternOperator op> {
2595 def NAME : sve_fp_fma_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
2598 let Inst{22} = iop{2};
2599 let Inst{20-19} = iop{1-0};
2600 let Inst{18-16} = Zm;
2603 def : Pat<(nxv8bf16 (op nxv8bf16:$op1, nxv8bf16:$op2, nxv8bf16:$op3, (i32 VectorIndexH32b_timm:$idx))),
2604 (!cast<Instruction>(NAME) $op1, $op2, $op3, VectorIndexH32b_timm:$idx)>;
2607 //===----------------------------------------------------------------------===//
2608 // SVE Floating Point Multiply - Indexed Group
2609 //===----------------------------------------------------------------------===//
2611 class sve_fp_fmul_by_indexed_elem<bits<2> sz, bit o2, string asm, ZPRRegOp zprty,
2612 ZPRRegOp zprty2, Operand itype>
2613 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty2:$Zm, itype:$iop),
2614 asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
2617 let Inst{31-24} = 0b01100100;
2618 let Inst{23-22} = sz;
2620 let Inst{15-12} = 0b0010;
2626 let hasSideEffects = 0;
2627 let mayRaiseFPException = 1;
2630 multiclass sve_fp_fmul_by_indexed_elem<string asm, SDPatternOperator op> {
2631 def _H : sve_fp_fmul_by_indexed_elem<{0, ?}, 0b0, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
2634 let Inst{22} = iop{2};
2635 let Inst{20-19} = iop{1-0};
2636 let Inst{18-16} = Zm;
2638 def _S : sve_fp_fmul_by_indexed_elem<0b10, 0b0, asm, ZPR32, ZPR3b32, VectorIndexS32b> {
2641 let Inst{20-19} = iop;
2642 let Inst{18-16} = Zm;
2644 def _D : sve_fp_fmul_by_indexed_elem<0b11, 0b0, asm, ZPR64, ZPR4b64, VectorIndexD32b> {
2648 let Inst{19-16} = Zm;
2651 def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b_timm:$idx))),
2652 (!cast<Instruction>(NAME # _H) $Op1, $Op2, VectorIndexH32b_timm:$idx)>;
2653 def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b_timm:$idx))),
2654 (!cast<Instruction>(NAME # _S) $Op1, $Op2, VectorIndexS32b_timm:$idx)>;
2655 def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b_timm:$idx))),
2656 (!cast<Instruction>(NAME # _D) $Op1, $Op2, VectorIndexD32b_timm:$idx)>;
2659 multiclass sve_fp_fmul_by_indexed_elem_bfloat<string asm,
2660 SDPatternOperator op> {
2661 def NAME : sve_fp_fmul_by_indexed_elem<{0, ?}, 0b1, asm, ZPR16, ZPR3b16, VectorIndexH32b> {
2664 let Inst{22} = iop{2};
2665 let Inst{20-19} = iop{1-0};
2666 let Inst{18-16} = Zm;
2668 def : Pat <(nxv8bf16 (op nxv8bf16:$Op1, nxv8bf16:$Op2, (i32 VectorIndexH32b_timm:$idx))),
2669 (!cast<Instruction>(NAME) $Op1, $Op2, VectorIndexH32b_timm:$idx)>;
2672 //===----------------------------------------------------------------------===//
2673 // SVE Floating Point Complex Multiply-Add Group
2674 //===----------------------------------------------------------------------===//
2676 class sve_fp_fcmla<bits<2> sz, string asm, ZPRRegOp zprty>
2677 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm,
2678 complexrotateop:$imm),
2679 asm, "\t$Zda, $Pg/m, $Zn, $Zm, $imm",
2680 "", []>, Sched<[]> {
2686 let Inst{31-24} = 0b01100100;
2687 let Inst{23-22} = sz;
2689 let Inst{20-16} = Zm;
2691 let Inst{14-13} = imm;
2692 let Inst{12-10} = Pg;
2694 let Inst{4-0} = Zda;
2696 let Constraints = "$Zda = $_Zda";
2697 let DestructiveInstType = DestructiveOther;
2698 let ElementSize = zprty.ElementSize;
2699 let hasSideEffects = 0;
2700 let mayRaiseFPException = 1;
2703 multiclass sve_fp_fcmla<string asm, SDPatternOperator op> {
2704 def _H : sve_fp_fcmla<0b01, asm, ZPR16>;
2705 def _S : sve_fp_fcmla<0b10, asm, ZPR32>;
2706 def _D : sve_fp_fcmla<0b11, asm, ZPR64>;
2708 def : Pat<(nxv8f16 (op nxv8i1:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, nxv8f16:$Op4, (i32 complexrotateop:$imm))),
2709 (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
2710 def : Pat<(nxv4f32 (op nxv4i1:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, nxv4f32:$Op4, (i32 complexrotateop:$imm))),
2711 (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
2712 def : Pat<(nxv2f64 (op nxv2i1:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, nxv2f64:$Op4, (i32 complexrotateop:$imm))),
2713 (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, $Op4, complexrotateop:$imm)>;
2716 //===----------------------------------------------------------------------===//
2717 // SVE Floating Point Complex Multiply-Add - Indexed Group
2718 //===----------------------------------------------------------------------===//
2720 class sve_fp_fcmla_by_indexed_elem<bits<2> sz, string asm,
2722 ZPRRegOp zprty2, Operand itype>
2723 : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty2:$Zm, itype:$iop,
2724 complexrotateop:$imm),
2725 asm, "\t$Zda, $Zn, $Zm$iop, $imm",
2726 "", []>, Sched<[]> {
2730 let Inst{31-24} = 0b01100100;
2731 let Inst{23-22} = sz;
2733 let Inst{15-12} = 0b0001;
2734 let Inst{11-10} = imm;
2736 let Inst{4-0} = Zda;
2738 let Constraints = "$Zda = $_Zda";
2739 let DestructiveInstType = DestructiveOther;
2740 let ElementSize = ElementSizeNone;
2741 let hasSideEffects = 0;
2742 let mayRaiseFPException = 1;
2745 multiclass sve_fp_fcmla_by_indexed_elem<string asm, SDPatternOperator op> {
2746 def _H : sve_fp_fcmla_by_indexed_elem<0b10, asm, ZPR16, ZPR3b16, VectorIndexS32b> {
2749 let Inst{20-19} = iop;
2750 let Inst{18-16} = Zm;
2752 def _S : sve_fp_fcmla_by_indexed_elem<0b11, asm, ZPR32, ZPR4b32, VectorIndexD32b> {
2756 let Inst{19-16} = Zm;
2759 def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
2760 (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
2761 def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
2762 (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
2765 //===----------------------------------------------------------------------===//
2766 // SVE Floating Point Complex Addition Group
2767 //===----------------------------------------------------------------------===//
2769 class sve_fp_fcadd<bits<2> sz, string asm, ZPRRegOp zprty>
2770 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm,
2771 complexrotateopodd:$imm),
2772 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm, $imm",
2779 let Inst{31-24} = 0b01100100;
2780 let Inst{23-22} = sz;
2781 let Inst{21-17} = 0;
2783 let Inst{15-13} = 0b100;
2784 let Inst{12-10} = Pg;
2786 let Inst{4-0} = Zdn;
2788 let Constraints = "$Zdn = $_Zdn";
2789 let DestructiveInstType = DestructiveOther;
2790 let ElementSize = zprty.ElementSize;
2791 let hasSideEffects = 0;
2792 let mayRaiseFPException = 1;
2795 multiclass sve_fp_fcadd<string asm, SDPatternOperator op> {
2796 def _H : sve_fp_fcadd<0b01, asm, ZPR16>;
2797 def _S : sve_fp_fcadd<0b10, asm, ZPR32>;
2798 def _D : sve_fp_fcadd<0b11, asm, ZPR64>;
2800 def : Pat<(nxv8f16 (op nxv8i1:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 complexrotateopodd:$imm))),
2801 (!cast<Instruction>(NAME # _H) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
2802 def : Pat<(nxv4f32 (op nxv4i1:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 complexrotateopodd:$imm))),
2803 (!cast<Instruction>(NAME # _S) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
2804 def : Pat<(nxv2f64 (op nxv2i1:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 complexrotateopodd:$imm))),
2805 (!cast<Instruction>(NAME # _D) $Op1, $Op2, $Op3, complexrotateopodd:$imm)>;
2808 //===----------------------------------------------------------------------===//
2809 // SVE2 Floating Point Convert Group
2810 //===----------------------------------------------------------------------===//
2812 class sve2_fp_convert_precision<bits<4> opc, bit merging, string asm,
2813 ZPRRegOp zprty1, ZPRRegOp zprty2, bit destructive=merging>
2814 : I<(outs zprty1:$Zd),
2815 !if(destructive, (ins zprty1:$_Zd, PPR3bAny:$Pg, zprty2:$Zn),
2816 (ins PPR3bAny:$Pg, zprty2:$Zn)),
2817 asm, "\t$Zd, " # !if(merging, "$Pg/m", "$Pg/z") # ", $Zn",
2823 let Inst{31-24} = 0b01100100;
2824 let Inst{23-22} = opc{3-2};
2825 let Inst{21-20} = 0b00;
2826 let Inst{19} = merging;
2828 let Inst{17-16} = opc{1-0};
2829 let Inst{15-13} = 0b101;
2830 let Inst{12-10} = Pg;
2834 let Constraints = !if(destructive, "$Zd = $_Zd", "");
2835 let hasSideEffects = 0;
2836 let mayRaiseFPException = 1;
2839 multiclass sve2_fp_convert_down_narrow<string asm, string op> {
2840 def _StoH : sve2_fp_convert_precision<0b1000, 0b1, asm, ZPR16, ZPR32>;
2841 def _DtoS : sve2_fp_convert_precision<0b1110, 0b1, asm, ZPR32, ZPR64>;
2843 def : SVE_3_Op_Pat<nxv8f16, !cast<SDPatternOperator>(op # _f16f32), nxv8f16, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _StoH)>;
2844 def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
2847 multiclass sve2_fp_convert_up_long<string asm, string op> {
2848 def _HtoS : sve2_fp_convert_precision<0b1001, 0b1, asm, ZPR32, ZPR16>;
2849 def _StoD : sve2_fp_convert_precision<0b1111, 0b1, asm, ZPR64, ZPR32>;
2851 def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f16), nxv4f32, nxv4i1, nxv8f16, !cast<Instruction>(NAME # _HtoS)>;
2852 def : SVE_3_Op_Pat<nxv2f64, !cast<SDPatternOperator>(op # _f64f32), nxv2f64, nxv2i1, nxv4f32, !cast<Instruction>(NAME # _StoD)>;
2855 multiclass sve2_fp_convert_down_odd_rounding_top<string asm, string op> {
2856 def _DtoS : sve2_fp_convert_precision<0b0010, 0b1, asm, ZPR32, ZPR64>;
2858 def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
2861 multiclass sve2_fp_convert_up_long_z<string asm, string op> {
2862 def _HtoS : sve2_fp_convert_precision<0b1001, 0b0, asm, ZPR32, ZPR16>;
2863 def _StoD : sve2_fp_convert_precision<0b1111, 0b0, asm, ZPR64, ZPR32>;
2865 defm : SVE_3_Op_UndefZero_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f16), nxv4f32, nxv4i1, nxv8f16, !cast<Instruction>(NAME # _HtoS)>;
2866 defm : SVE_3_Op_UndefZero_Pat<nxv2f64, !cast<SDPatternOperator>(op # _f64f32), nxv2f64, nxv2i1, nxv4f32, !cast<Instruction>(NAME # _StoD)>;
2869 multiclass sve2_fp_convert_down_narrow_z<string asm> {
2870 def _StoH : sve2_fp_convert_precision<0b1000, 0b0, asm, ZPR16, ZPR32, /*destructive*/ true>;
2871 def _DtoS : sve2_fp_convert_precision<0b1110, 0b0, asm, ZPR32, ZPR64, /*destructive*/ true>;
2874 //===----------------------------------------------------------------------===//
2875 // SVE2 Floating Point Pairwise Group
2876 //===----------------------------------------------------------------------===//
2878 class sve2_fp_pairwise_pred<bits<2> sz, bits<3> opc, string asm,
2880 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
2881 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
2887 let Inst{31-24} = 0b01100100;
2888 let Inst{23-22} = sz;
2889 let Inst{21-19} = 0b010;
2890 let Inst{18-16} = opc;
2891 let Inst{15-13} = 0b100;
2892 let Inst{12-10} = Pg;
2894 let Inst{4-0} = Zdn;
2896 let Constraints = "$Zdn = $_Zdn";
2897 let DestructiveInstType = DestructiveOther;
2898 let ElementSize = zprty.ElementSize;
2899 let hasSideEffects = 0;
2900 let mayRaiseFPException = 1;
2903 multiclass sve2_fp_pairwise_pred<bits<3> opc, string asm,
2904 SDPatternOperator op> {
2905 def _H : sve2_fp_pairwise_pred<0b01, opc, asm, ZPR16>;
2906 def _S : sve2_fp_pairwise_pred<0b10, opc, asm, ZPR32>;
2907 def _D : sve2_fp_pairwise_pred<0b11, opc, asm, ZPR64>;
2909 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
2910 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
2911 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
2914 //===----------------------------------------------------------------------===//
2915 // SVE2 Floating Point Widening Multiply-Add - Indexed Group
2916 //===----------------------------------------------------------------------===//
2918 class sve2_fp_mla_long_by_indexed_elem<bits<3> opc, string asm>
2919 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm,
2920 VectorIndexH32b:$iop),
2921 asm, "\t$Zda, $Zn, $Zm$iop",
2928 let Inst{31-23} = 0b011001001;
2929 let Inst{22} = opc{2};
2931 let Inst{20-19} = iop{2-1};
2932 let Inst{18-16} = Zm;
2933 let Inst{15-14} = 0b01;
2934 let Inst{13} = opc{1};
2936 let Inst{11} = iop{0};
2937 let Inst{10} = opc{0};
2939 let Inst{4-0} = Zda;
2941 let Constraints = "$Zda = $_Zda";
2942 let DestructiveInstType = DestructiveOther;
2943 let ElementSize = ElementSizeNone;
2944 let hasSideEffects = 0;
2945 let mayRaiseFPException = 1;
2948 multiclass sve2_fp_mla_long_by_indexed_elem<bits<3> opc, string asm,
2949 ValueType OutVT, ValueType InVT,
2950 SDPatternOperator op> {
2951 def NAME : sve2_fp_mla_long_by_indexed_elem<opc, asm>;
2952 def : SVE_4_Op_Imm_Pat<OutVT, op, OutVT, InVT, InVT, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME)>;
2955 //===----------------------------------------------------------------------===//
2956 // SVE2 Floating Point Widening Multiply-Add Group
2957 //===----------------------------------------------------------------------===//
2959 class sve2_fp_mla_long<bits<3> opc, string asm>
2960 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
2961 asm, "\t$Zda, $Zn, $Zm",
2967 let Inst{31-23} = 0b011001001;
2968 let Inst{22} = opc{2};
2970 let Inst{20-16} = Zm;
2971 let Inst{15-14} = 0b10;
2972 let Inst{13} = opc{1};
2973 let Inst{12-11} = 0b00;
2974 let Inst{10} = opc{0};
2976 let Inst{4-0} = Zda;
2978 let Constraints = "$Zda = $_Zda";
2979 let DestructiveInstType = DestructiveOther;
2980 let ElementSize = ElementSizeNone;
2981 let hasSideEffects = 0;
2982 let mayRaiseFPException = 1;
2985 multiclass sve2_fp_mla_long<bits<3> opc, string asm, ValueType OutVT,
2986 ValueType InVT, SDPatternOperator op> {
2987 def NAME : sve2_fp_mla_long<opc, asm>;
2988 def : SVE_3_Op_Pat<OutVT, op, OutVT, InVT, InVT, !cast<Instruction>(NAME)>;
2991 //===----------------------------------------------------------------------===//
2992 // SVE Stack Allocation Group
2993 //===----------------------------------------------------------------------===//
2995 class sve_int_arith_vl<bit opc, string asm, bit streaming_sve = 0b0>
2996 : I<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, simm6_32b:$imm6),
2997 asm, "\t$Rd, $Rn, $imm6",
3003 let Inst{31-23} = 0b000001000;
3006 let Inst{20-16} = Rn;
3007 let Inst{15-12} = 0b0101;
3008 let Inst{11} = streaming_sve;
3009 let Inst{10-5} = imm6;
3012 let hasSideEffects = 0;
3016 class sve_int_read_vl_a<bit op, bits<5> opc2, string asm, bit streaming_sve = 0b0>
3017 : I<(outs GPR64:$Rd), (ins simm6_32b:$imm6),
3018 asm, "\t$Rd, $imm6",
3023 let Inst{31-23} = 0b000001001;
3026 let Inst{20-16} = opc2{4-0};
3027 let Inst{15-12} = 0b0101;
3028 let Inst{11} = streaming_sve;
3029 let Inst{10-5} = imm6;
3032 let hasSideEffects = 0;
3033 let isReMaterializable = 1;
3037 //===----------------------------------------------------------------------===//
3038 // SVE Permute - In Lane Group
3039 //===----------------------------------------------------------------------===//
3041 class sve_int_perm_bin_perm_zz<bits<3> opc, bits<2> sz8_64, string asm,
3043 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
3044 asm, "\t$Zd, $Zn, $Zm",
3050 let Inst{31-24} = 0b00000101;
3051 let Inst{23-22} = sz8_64;
3053 let Inst{20-16} = Zm;
3054 let Inst{15-13} = 0b011;
3055 let Inst{12-10} = opc;
3059 let hasSideEffects = 0;
3062 multiclass sve_int_perm_bin_perm_zz<bits<3> opc, string asm,
3063 SDPatternOperator op> {
3064 def _B : sve_int_perm_bin_perm_zz<opc, 0b00, asm, ZPR8>;
3065 def _H : sve_int_perm_bin_perm_zz<opc, 0b01, asm, ZPR16>;
3066 def _S : sve_int_perm_bin_perm_zz<opc, 0b10, asm, ZPR32>;
3067 def _D : sve_int_perm_bin_perm_zz<opc, 0b11, asm, ZPR64>;
3069 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3070 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3071 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3072 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3074 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
3075 def : SVE_2_Op_Pat<nxv4f16, op, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _S)>;
3076 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
3077 def : SVE_2_Op_Pat<nxv2f16, op, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _D)>;
3078 def : SVE_2_Op_Pat<nxv2f32, op, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _D)>;
3079 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
3081 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
3084 //===----------------------------------------------------------------------===//
3085 // SVE Floating Point Unary Operations Group
3086 //===----------------------------------------------------------------------===//
3088 class sve_fp_2op_p_zd<bits<7> opc, string asm, RegisterOperand i_zprtype,
3089 RegisterOperand o_zprtype, ElementSizeEnum Sz>
3090 : I<(outs o_zprtype:$Zd), (ins i_zprtype:$_Zd, PPR3bAny:$Pg, i_zprtype:$Zn),
3091 asm, "\t$Zd, $Pg/m, $Zn",
3097 let Inst{31-24} = 0b01100101;
3098 let Inst{23-22} = opc{6-5};
3100 let Inst{20-16} = opc{4-0};
3101 let Inst{15-13} = 0b101;
3102 let Inst{12-10} = Pg;
3106 let Constraints = "$Zd = $_Zd";
3107 let DestructiveInstType = DestructiveUnaryPassthru;
3108 let ElementSize = Sz;
3109 let hasSideEffects = 0;
3110 let mayRaiseFPException = 1;
3113 multiclass sve_fp_2op_p_zd<bits<7> opc, string asm,
3114 RegisterOperand i_zprtype,
3115 RegisterOperand o_zprtype,
3116 SDPatternOperator int_op,
3117 SDPatternOperator ir_op, ValueType vt1,
3118 ValueType vt2, ValueType vt3, ElementSizeEnum Sz> {
3119 def NAME : sve_fp_2op_p_zd<opc, asm, i_zprtype, o_zprtype, Sz>,
3120 SVEPseudo2Instr<NAME, 1>;
3121 // convert vt1 to a packed type for the intrinsic patterns
3122 defvar packedvt1 = SVEType<vt1>.Packed;
3124 // convert vt3 to a packed type for the intrinsic patterns
3125 defvar packedvt3 = SVEType<vt3>.Packed;
3127 def : SVE_3_Op_Pat<packedvt1, int_op, packedvt1, vt2, packedvt3, !cast<Instruction>(NAME)>;
3128 def : SVE_1_Op_Passthru_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME)>;
3130 def _UNDEF : PredOneOpPassthruPseudo<NAME, !cast<ZPRRegOp>(i_zprtype)>;
3132 defm : SVE_1_Op_PassthruUndef_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME # _UNDEF)>;
3135 multiclass sve_fp_2op_p_zdr<bits<7> opc, string asm,
3136 RegisterOperand i_zprtype,
3137 RegisterOperand o_zprtype,
3138 SDPatternOperator int_op,
3139 SDPatternOperator ir_op, ValueType vt1,
3140 ValueType vt2, ValueType vt3, ElementSizeEnum Sz> {
3141 def NAME : sve_fp_2op_p_zd<opc, asm, i_zprtype, o_zprtype, Sz>,
3142 SVEPseudo2Instr<NAME, 1>;
3144 // convert vt1 to a packed type for the intrinsic patterns
3145 defvar packedvt1 = SVEType<vt1>.Packed;
3147 def : SVE_3_Op_Pat<packedvt1, int_op, packedvt1, vt2, vt3, !cast<Instruction>(NAME)>;
3148 def : SVE_1_Op_Passthru_Round_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME)>;
3150 def _UNDEF : PredOneOpPassthruPseudo<NAME, !cast<ZPRRegOp>(i_zprtype)>;
3152 defm : SVE_1_Op_PassthruUndef_Round_Pat<vt1, ir_op, vt2, vt3, !cast<Instruction>(NAME # _UNDEF)>;
3155 multiclass sve_fp_2op_p_zd_HSD<bits<5> opc, string asm, SDPatternOperator op> {
3156 def _H : sve_fp_2op_p_zd<{ 0b01, opc }, asm, ZPR16, ZPR16, ElementSizeH>,
3157 SVEPseudo2Instr<NAME # _H, 1>;
3158 def _S : sve_fp_2op_p_zd<{ 0b10, opc }, asm, ZPR32, ZPR32, ElementSizeS>,
3159 SVEPseudo2Instr<NAME # _S, 1>;
3160 def _D : sve_fp_2op_p_zd<{ 0b11, opc }, asm, ZPR64, ZPR64, ElementSizeD>,
3161 SVEPseudo2Instr<NAME # _D, 1>;
3163 def : SVE_1_Op_Passthru_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
3164 def : SVE_1_Op_Passthru_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
3165 def : SVE_1_Op_Passthru_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
3166 def : SVE_1_Op_Passthru_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
3167 def : SVE_1_Op_Passthru_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
3168 def : SVE_1_Op_Passthru_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
3170 def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
3171 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
3172 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
3174 defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H_UNDEF)>;
3175 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H_UNDEF)>;
3176 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H_UNDEF)>;
3177 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S_UNDEF)>;
3178 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S_UNDEF)>;
3179 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D_UNDEF)>;
3182 multiclass sve2_fp_flogb<string asm, string Ps, SDPatternOperator op> {
3183 def _H : sve_fp_2op_p_zd<0b0011010, asm, ZPR16, ZPR16, ElementSizeH>,
3184 SVEPseudo2Instr<Ps # _H, 1>;
3185 def _S : sve_fp_2op_p_zd<0b0011100, asm, ZPR32, ZPR32, ElementSizeS>,
3186 SVEPseudo2Instr<Ps # _S, 1>;
3187 def _D : sve_fp_2op_p_zd<0b0011110, asm, ZPR64, ZPR64, ElementSizeD>,
3188 SVEPseudo2Instr<Ps # _D, 1>;
3190 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
3191 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
3192 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
3195 multiclass sve2_fp_un_pred_zeroing_hsd<SDPatternOperator op> {
3196 def _H_ZERO : PredOneOpPassthruPseudo<NAME # _H, ZPR16, FalseLanesZero>;
3197 def _S_ZERO : PredOneOpPassthruPseudo<NAME # _S, ZPR32, FalseLanesZero>;
3198 def _D_ZERO : PredOneOpPassthruPseudo<NAME # _D, ZPR64, FalseLanesZero>;
3200 def : SVE_1_Op_PassthruZero_Pat<nxv8i16, op, nxv8i1, nxv8f16, !cast<Pseudo>(NAME # _H_ZERO)>;
3201 def : SVE_1_Op_PassthruZero_Pat<nxv4i32, op, nxv4i1, nxv4f32, !cast<Pseudo>(NAME # _S_ZERO)>;
3202 def : SVE_1_Op_PassthruZero_Pat<nxv2i64, op, nxv2i1, nxv2f64, !cast<Pseudo>(NAME # _D_ZERO)>;
3205 multiclass sve2_fp_convert_down_odd_rounding<string asm, string op, SDPatternOperator ir_op = null_frag> {
3206 def _DtoS : sve_fp_2op_p_zd<0b0001010, asm, ZPR64, ZPR32, ElementSizeD>;
3208 def : SVE_3_Op_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
3209 def : SVE_1_Op_Passthru_Pat<nxv2f32, ir_op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
3212 multiclass sve_fp_2op_p_zd_frint<bits<2> opc, string asm> {
3213 def _S : sve_fp_2op_p_zd<{ 0b0010, opc{1}, 0, opc{0} }, asm, ZPR32, ZPR32, ElementSizeS>;
3214 def _D : sve_fp_2op_p_zd<{ 0b0010, opc{1}, 1, opc{0} }, asm, ZPR64, ZPR64, ElementSizeD>;
3217 //===----------------------------------------------------------------------===//
3218 // SVE Floating Point Unary Operations - Unpredicated Group
3219 //===----------------------------------------------------------------------===//
3221 class sve_fp_2op_u_zd<bits<2> sz, bits<3> opc, string asm,
3223 : I<(outs zprty:$Zd), (ins zprty:$Zn),
3229 let Inst{31-24} = 0b01100101;
3230 let Inst{23-22} = sz;
3231 let Inst{21-19} = 0b001;
3232 let Inst{18-16} = opc;
3233 let Inst{15-10} = 0b001100;
3237 let hasSideEffects = 0;
3238 let mayRaiseFPException = 1;
3241 multiclass sve_fp_2op_u_zd<bits<3> opc, string asm, SDPatternOperator op> {
3242 def _H : sve_fp_2op_u_zd<0b01, opc, asm, ZPR16>;
3243 def _S : sve_fp_2op_u_zd<0b10, opc, asm, ZPR32>;
3244 def _D : sve_fp_2op_u_zd<0b11, opc, asm, ZPR64>;
3246 def : SVE_1_Op_Pat<nxv8f16, op, nxv8f16, !cast<Instruction>(NAME # _H)>;
3247 def : SVE_1_Op_Pat<nxv4f32, op, nxv4f32, !cast<Instruction>(NAME # _S)>;
3248 def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>;
3251 //===----------------------------------------------------------------------===//
3252 // SVE Floating Point Unary Operations - Zeroing Predicate Group
3253 //===----------------------------------------------------------------------===//
3255 class sve_fp_z2op_p_zd<bits<7> opc,string asm, RegisterOperand i_zprtype,
3256 RegisterOperand o_zprtype>
3257 : I<(outs o_zprtype:$Zd), (ins PPR3bAny:$Pg, i_zprtype:$Zn),
3258 asm, "\t$Zd, $Pg/z, $Zn",
3264 let Inst{31-24} = 0b01100100;
3265 let Inst{23-22} = opc{6-5};
3266 let Inst{21-19} = 0b011;
3267 let Inst{18-16} = opc{4-2};
3269 let Inst{14-13} = opc{1-0};
3270 let Inst{12-10} = Pg;
3274 let hasSideEffects = 0;
3275 let mayRaiseFPException = 1;
3278 multiclass sve_fp_z2op_p_zd<string asm, SDPatternOperator op> {
3279 def _DtoS : sve_fp_z2op_p_zd<0b0001010, asm, ZPR64, ZPR32>;
3281 defm : SVE_3_Op_UndefZero_Pat<nxv4f32, op, nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
3284 multiclass sve_fp_z2op_p_zd_hsd<bits<5> opc, string asm, SDPatternOperator op> {
3285 def _H : sve_fp_z2op_p_zd<{ 0b01, opc }, asm, ZPR16, ZPR16>;
3286 def _S : sve_fp_z2op_p_zd<{ 0b10, opc }, asm, ZPR32, ZPR32>;
3287 def _D : sve_fp_z2op_p_zd<{ 0b11, opc }, asm, ZPR64, ZPR64>;
3289 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
3290 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
3291 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
3292 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
3293 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
3294 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
3297 multiclass sve_fp_z2op_p_zd_frint<bits<2> opc, string asm> {
3298 def _S : sve_fp_z2op_p_zd<{ 0b0010, opc{1}, 0, opc{0} }, asm, ZPR32, ZPR32>;
3299 def _D : sve_fp_z2op_p_zd<{ 0b0010, opc{1}, 1, opc{0} }, asm, ZPR64, ZPR64>;
3302 multiclass sve_fp_z2op_p_zd_bfcvt<string asm, SDPatternOperator op> {
3303 def NAME : sve_fp_z2op_p_zd<0b1001010, asm, ZPR32, ZPR16>;
3305 defm : SVE_3_Op_UndefZero_Pat<nxv8bf16, op, nxv8bf16, nxv4i1, nxv4f32, !cast<Instruction>(NAME)>;
3308 multiclass sve_fp_z2op_p_zd_d<bit U, string asm, string int_op, SDPatternOperator ir_op> {
3309 def _HtoH : sve_fp_z2op_p_zd<{ 0b011101, U }, asm, ZPR16, ZPR16>;
3310 def _HtoS : sve_fp_z2op_p_zd<{ 0b011110, U }, asm, ZPR16, ZPR32>;
3311 def _HtoD : sve_fp_z2op_p_zd<{ 0b011111, U }, asm, ZPR16, ZPR64>;
3312 def _StoS : sve_fp_z2op_p_zd<{ 0b101110, U }, asm, ZPR32, ZPR32>;
3313 def _StoD : sve_fp_z2op_p_zd<{ 0b111110, U }, asm, ZPR32, ZPR64>;
3314 def _DtoS : sve_fp_z2op_p_zd<{ 0b111100, U }, asm, ZPR64, ZPR32>;
3315 def _DtoD : sve_fp_z2op_p_zd<{ 0b111111, U }, asm, ZPR64, ZPR64>;
3317 defm : SVE_3_Op_UndefZero_Pat<nxv4i32, !cast<SDPatternOperator>(int_op # _i32f64), nxv4i32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
3318 defm : SVE_3_Op_UndefZero_Pat<nxv2i64, !cast<SDPatternOperator>(int_op # _i64f32), nxv2i64, nxv2i1, nxv4f32, !cast<Instruction>(NAME # _StoD)>;
3319 defm : SVE_3_Op_UndefZero_Pat<nxv4i32, !cast<SDPatternOperator>(int_op # _i32f16), nxv4i32, nxv4i1, nxv8f16, !cast<Instruction>(NAME # _HtoS)>;
3320 defm : SVE_3_Op_UndefZero_Pat<nxv2i64, !cast<SDPatternOperator>(int_op # _i64f16), nxv2i64, nxv2i1, nxv8f16, !cast<Instruction>(NAME # _HtoD)>;
3322 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8i16, ir_op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _HtoH)>;
3323 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4i32, ir_op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _StoS)>;
3324 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, ir_op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoD)>;
3327 multiclass sve_fp_z2op_p_zd_c<bit U, string asm, string int_op, SDPatternOperator ir_op> {
3328 def _HtoH : sve_fp_z2op_p_zd<{ 0b011001, U }, asm, ZPR16, ZPR16>;
3329 def _StoH : sve_fp_z2op_p_zd<{ 0b011010, U }, asm, ZPR32, ZPR16>;
3330 def _StoS : sve_fp_z2op_p_zd<{ 0b101010, U }, asm, ZPR32, ZPR32>;
3331 def _StoD : sve_fp_z2op_p_zd<{ 0b111000, U }, asm, ZPR32, ZPR64>;
3332 def _DtoS : sve_fp_z2op_p_zd<{ 0b111010, U }, asm, ZPR64, ZPR32>;
3333 def _DtoH : sve_fp_z2op_p_zd<{ 0b011011, U }, asm, ZPR64, ZPR16>;
3334 def _DtoD : sve_fp_z2op_p_zd<{ 0b111011, U }, asm, ZPR64, ZPR64>;
3336 defm : SVE_3_Op_UndefZero_Pat<nxv4f32, !cast<SDPatternOperator>(int_op # _f32i64), nxv4f32, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _DtoS)>;
3337 defm : SVE_3_Op_UndefZero_Pat<nxv2f64, !cast<SDPatternOperator>(int_op # _f64i32), nxv2f64, nxv2i1, nxv4i32, !cast<Instruction>(NAME # _StoD)>;
3338 defm : SVE_3_Op_UndefZero_Pat<nxv8f16, !cast<SDPatternOperator>(int_op # _f16i32), nxv8f16, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _StoH)>;
3339 defm : SVE_3_Op_UndefZero_Pat<nxv8f16, !cast<SDPatternOperator>(int_op # _f16i64), nxv8f16, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _DtoH)>;
3341 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8f16, ir_op, nxv8i1,nxv8i16, !cast<Instruction>(NAME # _HtoH)>;
3342 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4f32, ir_op, nxv4i1,nxv4i32, !cast<Instruction>(NAME # _StoS)>;
3343 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2f64, ir_op, nxv2i1,nxv2i64, !cast<Instruction>(NAME # _DtoD)>;
3346 multiclass sve_fp_z2op_p_zd_d_flogb<string asm, SDPatternOperator op> {
3347 def _H : sve_fp_z2op_p_zd<0b0011001, asm, ZPR16, ZPR16>;
3348 def _S : sve_fp_z2op_p_zd<0b0011010, asm, ZPR32, ZPR32>;
3349 def _D : sve_fp_z2op_p_zd<0b0011011, asm, ZPR64, ZPR64>;
3351 defm : SVE_3_Op_UndefZero_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
3352 defm : SVE_3_Op_UndefZero_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
3353 defm : SVE_3_Op_UndefZero_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
3356 multiclass sve_fp_z2op_p_zd_b_0<string asm, string op> {
3357 def _StoH : sve_fp_z2op_p_zd<0b1001000, asm, ZPR32, ZPR16>;
3358 def _HtoS : sve_fp_z2op_p_zd<0b1001001, asm, ZPR16, ZPR32>;
3359 def _DtoH : sve_fp_z2op_p_zd<0b1101000, asm, ZPR64, ZPR16>;
3360 def _HtoD : sve_fp_z2op_p_zd<0b1101001, asm, ZPR16, ZPR64>;
3361 def _DtoS : sve_fp_z2op_p_zd<0b1101010, asm, ZPR64, ZPR32>;
3362 def _StoD : sve_fp_z2op_p_zd<0b1101011, asm, ZPR32, ZPR64>;
3364 defm : SVE_3_Op_UndefZero_Pat<nxv8f16, !cast<SDPatternOperator>(op # _f16f32), nxv8f16, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _StoH)>;
3365 defm : SVE_3_Op_UndefZero_Pat<nxv8f16, !cast<SDPatternOperator>(op # _f16f64), nxv8f16, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoH)>;
3366 defm : SVE_3_Op_UndefZero_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f64), nxv4f32, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _DtoS)>;
3367 defm : SVE_3_Op_UndefZero_Pat<nxv4f32, !cast<SDPatternOperator>(op # _f32f16), nxv4f32, nxv4i1, nxv8f16, !cast<Instruction>(NAME # _HtoS)>;
3368 defm : SVE_3_Op_UndefZero_Pat<nxv2f64, !cast<SDPatternOperator>(op # _f64f16), nxv2f64, nxv2i1, nxv8f16, !cast<Instruction>(NAME # _HtoD)>;
3369 defm : SVE_3_Op_UndefZero_Pat<nxv2f64, !cast<SDPatternOperator>(op # _f64f32), nxv2f64, nxv2i1, nxv4f32, !cast<Instruction>(NAME # _StoD)>;
3372 //===----------------------------------------------------------------------===//
3373 // SVE Integer Arithmetic - Binary Predicated Group
3374 //===----------------------------------------------------------------------===//
3376 class sve_int_bin_pred_arit_log<bits<2> sz8_64, bits<2> fmt, bits<3> opc,
3377 string asm, ZPRRegOp zprty>
3378 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
3379 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
3383 let Inst{31-24} = 0b00000100;
3384 let Inst{23-22} = sz8_64;
3386 let Inst{20-19} = fmt;
3387 let Inst{18-16} = opc;
3388 let Inst{15-13} = 0b000;
3389 let Inst{12-10} = Pg;
3391 let Inst{4-0} = Zdn;
3393 let Constraints = "$Zdn = $_Zdn";
3394 let DestructiveInstType = DestructiveOther;
3395 let ElementSize = zprty.ElementSize;
3396 let hasSideEffects = 0;
3399 multiclass sve_int_bin_pred_log<bits<3> opc, string asm, string Ps,
3400 SDPatternOperator op,
3401 DestructiveInstTypeEnum flags> {
3402 let DestructiveInstType = flags in {
3403 def _B : sve_int_bin_pred_arit_log<0b00, 0b11, opc, asm, ZPR8>,
3404 SVEPseudo2Instr<Ps # _B, 1>;
3405 def _H : sve_int_bin_pred_arit_log<0b01, 0b11, opc, asm, ZPR16>,
3406 SVEPseudo2Instr<Ps # _H, 1>;
3407 def _S : sve_int_bin_pred_arit_log<0b10, 0b11, opc, asm, ZPR32>,
3408 SVEPseudo2Instr<Ps # _S, 1>;
3409 def _D : sve_int_bin_pred_arit_log<0b11, 0b11, opc, asm, ZPR64>,
3410 SVEPseudo2Instr<Ps # _D, 1>;
3413 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3414 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3415 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3416 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3419 multiclass sve_int_bin_pred_arit_0<bits<3> opc, string asm, string Ps,
3420 SDPatternOperator op,
3421 DestructiveInstTypeEnum flags,
3422 string revname="", bit isReverseInstr=0> {
3423 let DestructiveInstType = flags in {
3424 def _B : sve_int_bin_pred_arit_log<0b00, 0b00, opc, asm, ZPR8>,
3425 SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
3426 def _H : sve_int_bin_pred_arit_log<0b01, 0b00, opc, asm, ZPR16>,
3427 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
3428 def _S : sve_int_bin_pred_arit_log<0b10, 0b00, opc, asm, ZPR32>,
3429 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
3430 def _D : sve_int_bin_pred_arit_log<0b11, 0b00, opc, asm, ZPR64>,
3431 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
3434 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3435 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3436 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3437 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3440 multiclass sve_int_bin_pred_arit_1<bits<3> opc, string asm, string Ps,
3441 SDPatternOperator op,
3442 DestructiveInstTypeEnum flags> {
3443 let DestructiveInstType = flags in {
3444 def _B : sve_int_bin_pred_arit_log<0b00, 0b01, opc, asm, ZPR8>,
3445 SVEPseudo2Instr<Ps # _B, 1>;
3446 def _H : sve_int_bin_pred_arit_log<0b01, 0b01, opc, asm, ZPR16>,
3447 SVEPseudo2Instr<Ps # _H, 1>;
3448 def _S : sve_int_bin_pred_arit_log<0b10, 0b01, opc, asm, ZPR32>,
3449 SVEPseudo2Instr<Ps # _S, 1>;
3450 def _D : sve_int_bin_pred_arit_log<0b11, 0b01, opc, asm, ZPR64>,
3451 SVEPseudo2Instr<Ps # _D, 1>;
3454 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3455 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3456 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3457 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3460 multiclass sve_int_bin_pred_arit_2<bits<3> opc, string asm, string Ps,
3461 SDPatternOperator op,
3462 DestructiveInstTypeEnum flags> {
3463 let DestructiveInstType = flags in {
3464 def _B : sve_int_bin_pred_arit_log<0b00, 0b10, opc, asm, ZPR8>,
3465 SVEPseudo2Instr<Ps # _B, 1>;
3466 def _H : sve_int_bin_pred_arit_log<0b01, 0b10, opc, asm, ZPR16>,
3467 SVEPseudo2Instr<Ps # _H, 1>;
3468 def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>,
3469 SVEPseudo2Instr<Ps # _S, 1>;
3470 def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>,
3471 SVEPseudo2Instr<Ps # _D, 1>;
3474 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3475 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3476 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3477 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3480 // Special case for divides which are not defined for 8b/16b elements.
3481 multiclass sve_int_bin_pred_arit_2_div<bits<3> opc, string asm, string Ps,
3482 SDPatternOperator op,
3483 DestructiveInstTypeEnum flags,
3484 string revname="", bit isReverseInstr=0> {
3485 let DestructiveInstType = flags in {
3486 def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>,
3487 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
3488 def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>,
3489 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
3492 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3493 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3496 //===----------------------------------------------------------------------===//
3497 // SVE Integer Multiply-Add Group
3498 //===----------------------------------------------------------------------===//
3500 class sve_int_mladdsub_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
3502 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
3503 asm, "\t$Zdn, $Pg/m, $Zm, $Za",
3510 let Inst{31-24} = 0b00000100;
3511 let Inst{23-22} = sz8_64;
3513 let Inst{20-16} = Zm;
3514 let Inst{15-14} = 0b11;
3516 let Inst{12-10} = Pg;
3518 let Inst{4-0} = Zdn;
3520 let Constraints = "$Zdn = $_Zdn";
3521 let DestructiveInstType = DestructiveOther;
3522 let ElementSize = zprty.ElementSize;
3523 let hasSideEffects = 0;
3526 multiclass sve_int_mladdsub_vvv_pred<bits<1> opc, string asm, SDPatternOperator op,
3527 string revname, bit isReverseInstr=0> {
3528 def _B : sve_int_mladdsub_vvv_pred<0b00, opc, asm, ZPR8>,
3529 SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
3530 def _H : sve_int_mladdsub_vvv_pred<0b01, opc, asm, ZPR16>,
3531 SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
3532 def _S : sve_int_mladdsub_vvv_pred<0b10, opc, asm, ZPR32>,
3533 SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
3534 def _D : sve_int_mladdsub_vvv_pred<0b11, opc, asm, ZPR64>,
3535 SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
3537 def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3538 def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3539 def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3540 def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3543 class sve_int_mlas_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
3545 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
3546 asm, "\t$Zda, $Pg/m, $Zn, $Zm",
3553 let Inst{31-24} = 0b00000100;
3554 let Inst{23-22} = sz8_64;
3556 let Inst{20-16} = Zm;
3557 let Inst{15-14} = 0b01;
3559 let Inst{12-10} = Pg;
3561 let Inst{4-0} = Zda;
3563 let Constraints = "$Zda = $_Zda";
3564 let DestructiveInstType = DestructiveTernaryCommWithRev;
3565 let ElementSize = zprty.ElementSize;
3566 let hasSideEffects = 0;
3569 multiclass sve_int_mlas_vvv_pred<bits<1> opc, string asm, SDPatternOperator op,
3570 string Ps, string revname, bit isReverseInstr=0> {
3571 def _B : sve_int_mlas_vvv_pred<0b00, opc, asm, ZPR8>,
3572 SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
3573 def _H : sve_int_mlas_vvv_pred<0b01, opc, asm, ZPR16>,
3574 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
3575 def _S : sve_int_mlas_vvv_pred<0b10, opc, asm, ZPR32>,
3576 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
3577 def _D : sve_int_mlas_vvv_pred<0b11, opc, asm, ZPR64>,
3578 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
3580 def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3581 def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3582 def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3583 def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3586 //class for generating pseudo for SVE MLA/MAD/MLS/MSB
3587 multiclass sve_int_3op_p_mladdsub<SDPatternOperator op> {
3588 def _B_UNDEF : PredThreeOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>;
3589 def _H_UNDEF : PredThreeOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
3590 def _S_UNDEF : PredThreeOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
3591 def _D_UNDEF : PredThreeOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
3593 let AddedComplexity = 9 in {
3594 def : SVE_4_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B_UNDEF)>;
3595 def : SVE_4_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H_UNDEF)>;
3596 def : SVE_4_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S_UNDEF)>;
3597 def : SVE_4_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D_UNDEF)>;
3601 //===----------------------------------------------------------------------===//
3602 // SVE2 Integer Multiply-Add - Unpredicated Group
3603 //===----------------------------------------------------------------------===//
3605 class sve2_int_mla<bits<2> sz, bits<5> opc, string asm,
3606 ZPRRegOp zprty1, ZPRRegOp zprty2>
3607 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
3608 asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
3612 let Inst{31-24} = 0b01000100;
3613 let Inst{23-22} = sz;
3615 let Inst{20-16} = Zm;
3617 let Inst{14-10} = opc;
3619 let Inst{4-0} = Zda;
3621 let Constraints = "$Zda = $_Zda";
3622 let DestructiveInstType = DestructiveOther;
3623 let ElementSize = ElementSizeNone;
3624 let hasSideEffects = 0;
3627 multiclass sve2_int_mla<bit S, string asm, SDPatternOperator op> {
3628 def _B : sve2_int_mla<0b00, { 0b1110, S }, asm, ZPR8, ZPR8>;
3629 def _H : sve2_int_mla<0b01, { 0b1110, S }, asm, ZPR16, ZPR16>;
3630 def _S : sve2_int_mla<0b10, { 0b1110, S }, asm, ZPR32, ZPR32>;
3631 def _D : sve2_int_mla<0b11, { 0b1110, S }, asm, ZPR64, ZPR64>;
3633 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3634 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3635 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3636 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3639 multiclass sve2_int_mla_long<bits<5> opc, string asm, SDPatternOperator op> {
3640 def _H : sve2_int_mla<0b01, opc, asm, ZPR16, ZPR8>;
3641 def _S : sve2_int_mla<0b10, opc, asm, ZPR32, ZPR16>;
3642 def _D : sve2_int_mla<0b11, opc, asm, ZPR64, ZPR32>;
3644 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
3645 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
3646 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
3649 //===----------------------------------------------------------------------===//
3650 // SVE2 Integer Multiply-Add - Indexed Group
3651 //===----------------------------------------------------------------------===//
3653 class sve2_int_mla_by_indexed_elem<bits<2> sz, bits<6> opc, string asm,
3654 ZPRRegOp zprty1, ZPRRegOp zprty2,
3655 ZPRRegOp zprty3, Operand itype>
3656 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
3657 asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
3660 let Inst{31-24} = 0b01000100;
3661 let Inst{23-22} = sz;
3663 let Inst{15-10} = opc;
3665 let Inst{4-0} = Zda;
3667 let Constraints = "$Zda = $_Zda";
3668 let DestructiveInstType = DestructiveOther;
3669 let ElementSize = ElementSizeNone;
3670 let hasSideEffects = 0;
3673 multiclass sve2_int_mla_by_indexed_elem<bits<2> opc, bit S, string asm,
3674 SDPatternOperator op> {
3675 def _H : sve2_int_mla_by_indexed_elem<{0, ?}, { 0b000, opc, S }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH32b> {
3678 let Inst{22} = iop{2};
3679 let Inst{20-19} = iop{1-0};
3680 let Inst{18-16} = Zm;
3682 def _S : sve2_int_mla_by_indexed_elem<0b10, { 0b000, opc, S }, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS32b> {
3685 let Inst{20-19} = iop;
3686 let Inst{18-16} = Zm;
3688 def _D : sve2_int_mla_by_indexed_elem<0b11, { 0b000, opc, S }, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD32b> {
3692 let Inst{19-16} = Zm;
3695 def : SVE_4_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
3696 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
3697 def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
3700 //===----------------------------------------------------------------------===//
3701 // SVE2 Integer Multiply-Add Long - Indexed Group
3702 //===----------------------------------------------------------------------===//
3704 multiclass sve2_int_mla_long_by_indexed_elem<bits<4> opc, string asm,
3705 SDPatternOperator op> {
3706 def _S : sve2_int_mla_by_indexed_elem<0b10, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
3707 asm, ZPR32, ZPR16, ZPR3b16, VectorIndexH32b> {
3710 let Inst{20-19} = iop{2-1};
3711 let Inst{18-16} = Zm;
3712 let Inst{11} = iop{0};
3714 def _D : sve2_int_mla_by_indexed_elem<0b11, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
3715 asm, ZPR64, ZPR32, ZPR4b32, VectorIndexS32b> {
3718 let Inst{20} = iop{1};
3719 let Inst{19-16} = Zm;
3720 let Inst{11} = iop{0};
3723 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _S)>;
3724 def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>;
3727 //===----------------------------------------------------------------------===//
3728 // SVE Integer Dot Product Group
3729 //===----------------------------------------------------------------------===//
3731 class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
3733 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), asm,
3734 "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
3738 let Inst{31-23} = 0b010001001;
3741 let Inst{20-16} = Zm;
3742 let Inst{15-11} = 0;
3745 let Inst{4-0} = Zda;
3747 let Constraints = "$Zda = $_Zda";
3748 let DestructiveInstType = DestructiveOther;
3749 let hasSideEffects = 0;
3752 multiclass sve_intx_dot<bit opc, string asm, SDPatternOperator op> {
3753 def _S : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>;
3754 def _D : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>;
3756 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _S)>;
3757 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _D)>;
3760 //===----------------------------------------------------------------------===//
3761 // SVE Integer Dot Product Group - Indexed Group
3762 //===----------------------------------------------------------------------===//
3764 class sve_intx_dot_by_indexed_elem<bit sz, bit U, string asm,
3765 ZPRRegOp zprty1, ZPRRegOp zprty2,
3766 ZPRRegOp zprty3, Operand itype>
3767 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
3768 asm, "\t$Zda, $Zn, $Zm$iop",
3769 "", []>, Sched<[]> {
3772 let Inst{31-23} = 0b010001001;
3775 let Inst{15-11} = 0;
3778 let Inst{4-0} = Zda;
3780 let Constraints = "$Zda = $_Zda";
3781 let DestructiveInstType = DestructiveOther;
3782 let hasSideEffects = 0;
3785 multiclass sve_intx_dot_by_indexed_elem<bit opc, string asm,
3786 SDPatternOperator op> {
3787 def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b_timm> {
3790 let Inst{20-19} = iop;
3791 let Inst{18-16} = Zm;
3793 def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b_timm> {
3797 let Inst{19-16} = Zm;
3800 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
3801 def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
3804 //===----------------------------------------------------------------------===//
3805 // SVE2 Complex Integer Dot Product Group
3806 //===----------------------------------------------------------------------===//
3808 class sve2_complex_int_arith<bits<2> sz, bits<4> opc, string asm,
3809 ZPRRegOp zprty1, ZPRRegOp zprty2>
3810 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm,
3811 complexrotateop:$rot),
3812 asm, "\t$Zda, $Zn, $Zm, $rot", "", []>, Sched<[]> {
3817 let Inst{31-24} = 0b01000100;
3818 let Inst{23-22} = sz;
3820 let Inst{20-16} = Zm;
3821 let Inst{15-12} = opc;
3822 let Inst{11-10} = rot;
3824 let Inst{4-0} = Zda;
3826 let Constraints = "$Zda = $_Zda";
3827 let DestructiveInstType = DestructiveOther;
3828 let ElementSize = ElementSizeNone;
3829 let hasSideEffects = 0;
3832 multiclass sve2_cintx_dot<string asm, SDPatternOperator op> {
3833 def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>;
3834 def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>;
3836 def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
3837 (i32 complexrotateop:$imm))),
3838 (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, complexrotateop:$imm)>;
3839 def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
3840 (i32 complexrotateop:$imm))),
3841 (!cast<Instruction>(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, complexrotateop:$imm)>;
3844 //===----------------------------------------------------------------------===//
3845 // SVE2 Complex Multiply-Add Group
3846 //===----------------------------------------------------------------------===//
3848 multiclass sve2_int_cmla<bit opc, string asm, SDPatternOperator op> {
3849 def _B : sve2_complex_int_arith<0b00, { 0b001, opc }, asm, ZPR8, ZPR8>;
3850 def _H : sve2_complex_int_arith<0b01, { 0b001, opc }, asm, ZPR16, ZPR16>;
3851 def _S : sve2_complex_int_arith<0b10, { 0b001, opc }, asm, ZPR32, ZPR32>;
3852 def _D : sve2_complex_int_arith<0b11, { 0b001, opc }, asm, ZPR64, ZPR64>;
3854 def : SVE_4_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, i32, complexrotateop, !cast<Instruction>(NAME # _B)>;
3855 def : SVE_4_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, i32, complexrotateop, !cast<Instruction>(NAME # _H)>;
3856 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, i32, complexrotateop, !cast<Instruction>(NAME # _S)>;
3857 def : SVE_4_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, i32, complexrotateop, !cast<Instruction>(NAME # _D)>;
3860 //===----------------------------------------------------------------------===//
3861 // SVE2 Complex Integer Dot Product - Indexed Group
3862 //===----------------------------------------------------------------------===//
3864 class sve2_complex_int_arith_indexed<bits<2> sz, bits<4> opc, string asm,
3865 ZPRRegOp zprty1, ZPRRegOp zprty2,
3866 ZPRRegOp zprty3, Operand itype>
3867 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop,
3868 complexrotateop:$rot),
3869 asm, "\t$Zda, $Zn, $Zm$iop, $rot", "", []>, Sched<[]> {
3873 let Inst{31-24} = 0b01000100;
3874 let Inst{23-22} = sz;
3876 let Inst{15-12} = opc;
3877 let Inst{11-10} = rot;
3879 let Inst{4-0} = Zda;
3881 let Constraints = "$Zda = $_Zda";
3882 let DestructiveInstType = DestructiveOther;
3883 let ElementSize = ElementSizeNone;
3884 let hasSideEffects = 0;
3887 multiclass sve2_cintx_dot_by_indexed_elem<string asm, SDPatternOperator op> {
3888 def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
3891 let Inst{20-19} = iop;
3892 let Inst{18-16} = Zm;
3894 def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
3898 let Inst{19-16} = Zm;
3901 def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
3902 (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
3903 (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
3904 def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
3905 (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
3906 (!cast<Instruction>(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
3909 //===----------------------------------------------------------------------===//
3910 // SVE2 Complex Multiply-Add - Indexed Group
3911 //===----------------------------------------------------------------------===//
3913 multiclass sve2_cmla_by_indexed_elem<bit opc, string asm,
3914 SDPatternOperator op> {
3915 def _H : sve2_complex_int_arith_indexed<0b10, { 0b011, opc }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexS32b> {
3918 let Inst{20-19} = iop;
3919 let Inst{18-16} = Zm;
3921 def _S : sve2_complex_int_arith_indexed<0b11, { 0b011, opc }, asm, ZPR32, ZPR32, ZPR4b32, VectorIndexD32b> {
3925 let Inst{19-16} = Zm;
3928 def : Pat<(nxv8i16 (op (nxv8i16 ZPR16:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
3929 (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
3930 (!cast<Instruction>(NAME # "_H") ZPR16:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
3932 def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv4i32 ZPR32:$Op2), (nxv4i32 ZPR32:$Op3),
3933 (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
3934 (!cast<Instruction>(NAME # "_S") ZPR32:$Op1, ZPR32:$Op2, ZPR32:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
3937 //===----------------------------------------------------------------------===//
3938 // SVE2 Integer Multiply - Unpredicated Group
3939 //===----------------------------------------------------------------------===//
3941 class sve2_int_mul<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty>
3942 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
3943 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
3947 let Inst{31-24} = 0b00000100;
3948 let Inst{23-22} = sz;
3950 let Inst{20-16} = Zm;
3951 let Inst{15-13} = 0b011;
3952 let Inst{12-10} = opc;
3956 let hasSideEffects = 0;
3959 multiclass sve2_int_mul<bits<3> opc, string asm, SDPatternOperator op> {
3960 def _B : sve2_int_mul<0b00, opc, asm, ZPR8>;
3961 def _H : sve2_int_mul<0b01, opc, asm, ZPR16>;
3962 def _S : sve2_int_mul<0b10, opc, asm, ZPR32>;
3963 def _D : sve2_int_mul<0b11, opc, asm, ZPR64>;
3965 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3966 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
3967 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
3968 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
3971 multiclass sve2_int_mul_single<bits<3> opc, string asm, SDPatternOperator op> {
3972 def _B : sve2_int_mul<0b00, opc, asm, ZPR8>;
3974 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
3977 //===----------------------------------------------------------------------===//
3978 // SVE2 Integer Multiply - Indexed Group
3979 //===----------------------------------------------------------------------===//
3981 class sve2_int_mul_by_indexed_elem<bits<2> sz, bits<4> opc, string asm,
3982 ZPRRegOp zprty1, ZPRRegOp zprty2,
3983 ZPRRegOp zprty3, Operand itype>
3984 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm, itype:$iop),
3985 asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
3988 let Inst{31-24} = 0b01000100;
3989 let Inst{23-22} = sz;
3991 let Inst{15-14} = 0b11;
3992 let Inst{13-10} = opc;
3996 let hasSideEffects = 0;
3999 multiclass sve2_int_mul_by_indexed_elem<bits<4> opc, string asm,
4000 SDPatternOperator op> {
4001 def _H : sve2_int_mul_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH32b> {
4004 let Inst{22} = iop{2};
4005 let Inst{20-19} = iop{1-0};
4006 let Inst{18-16} = Zm;
4008 def _S : sve2_int_mul_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS32b> {
4011 let Inst{20-19} = iop;
4012 let Inst{18-16} = Zm;
4014 def _D : sve2_int_mul_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD32b> {
4018 let Inst{19-16} = Zm;
4021 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
4022 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
4023 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
4026 multiclass sve2_int_mul_long_by_indexed_elem<bits<3> opc, string asm,
4027 SDPatternOperator op> {
4028 def _S : sve2_int_mul_by_indexed_elem<0b10, { opc{2-1}, ?, opc{0} }, asm,
4029 ZPR32, ZPR16, ZPR3b16, VectorIndexH32b> {
4032 let Inst{20-19} = iop{2-1};
4033 let Inst{18-16} = Zm;
4034 let Inst{11} = iop{0};
4036 def _D : sve2_int_mul_by_indexed_elem<0b11, { opc{2-1}, ?, opc{0} }, asm,
4037 ZPR64, ZPR32, ZPR4b32, VectorIndexS32b> {
4040 let Inst{20} = iop{1};
4041 let Inst{19-16} = Zm;
4042 let Inst{11} = iop{0};
4045 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv8i16, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _S)>;
4046 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv4i32, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>;
4049 //===----------------------------------------------------------------------===//
4050 // SVE2 Integer - Predicated Group
4051 //===----------------------------------------------------------------------===//
4053 class sve2_int_arith_pred<bits<2> sz, bits<6> opc, string asm,
4055 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
4056 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
4060 let Inst{31-24} = 0b01000100;
4061 let Inst{23-22} = sz;
4062 let Inst{21-20} = 0b01;
4063 let Inst{20-16} = opc{5-1};
4064 let Inst{15-14} = 0b10;
4065 let Inst{13} = opc{0};
4066 let Inst{12-10} = Pg;
4068 let Inst{4-0} = Zdn;
4070 let Constraints = "$Zdn = $_Zdn";
4071 let DestructiveInstType = DestructiveOther;
4072 let ElementSize = zprty.ElementSize;
4073 let hasSideEffects = 0;
4076 multiclass sve2_int_arith_pred<bits<6> opc, string asm, SDPatternOperator op,
4078 DestructiveInstTypeEnum flags=DestructiveOther,
4079 string revname="", bit isReverseInstr=0> {
4080 let DestructiveInstType = flags in {
4081 def _B : sve2_int_arith_pred<0b00, opc, asm, ZPR8>,
4082 SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
4083 def _H : sve2_int_arith_pred<0b01, opc, asm, ZPR16>,
4084 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
4085 def _S : sve2_int_arith_pred<0b10, opc, asm, ZPR32>,
4086 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
4087 def _D : sve2_int_arith_pred<0b11, opc, asm, ZPR64>,
4088 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
4091 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
4092 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
4093 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
4094 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
4097 class sve2_int_sadd_long_accum_pairwise<bits<2> sz, bit U, string asm,
4098 ZPRRegOp zprty1, ZPRRegOp zprty2>
4099 : I<(outs zprty1:$Zda), (ins PPR3bAny:$Pg, zprty1:$_Zda, zprty2:$Zn),
4100 asm, "\t$Zda, $Pg/m, $Zn", "", []>, Sched<[]> {
4104 let Inst{31-24} = 0b01000100;
4105 let Inst{23-22} = sz;
4106 let Inst{21-17} = 0b00010;
4108 let Inst{15-13} = 0b101;
4109 let Inst{12-10} = Pg;
4111 let Inst{4-0} = Zda;
4113 let Constraints = "$Zda = $_Zda";
4114 let DestructiveInstType = DestructiveOther;
4115 let ElementSize = zprty1.ElementSize;
4116 let hasSideEffects = 0;
4119 multiclass sve2_int_sadd_long_accum_pairwise<bit U, string asm, SDPatternOperator op> {
4120 def _H : sve2_int_sadd_long_accum_pairwise<0b01, U, asm, ZPR16, ZPR8>;
4121 def _S : sve2_int_sadd_long_accum_pairwise<0b10, U, asm, ZPR32, ZPR16>;
4122 def _D : sve2_int_sadd_long_accum_pairwise<0b11, U, asm, ZPR64, ZPR32>;
4124 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv16i8, !cast<Instruction>(NAME # _H)>;
4125 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv8i16, !cast<Instruction>(NAME # _S)>;
4126 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv4i32, !cast<Instruction>(NAME # _D)>;
4129 class sve2_int_un_pred_arit<bits<2> sz, bits<2> opc,
4130 string asm, ZPRRegOp zprty>
4131 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
4132 asm, "\t$Zd, $Pg/m, $Zn",
4138 let Inst{31-24} = 0b01000100;
4139 let Inst{23-22} = sz;
4140 let Inst{21-20} = 0b00;
4141 let Inst{19} = opc{1};
4142 let Inst{18-17} = 0b00;
4143 let Inst{16} = opc{0};
4144 let Inst{15-13} = 0b101;
4145 let Inst{12-10} = Pg;
4148 let Constraints = "$Zd = $_Zd";
4149 let DestructiveInstType = DestructiveUnaryPassthru;
4150 let ElementSize = zprty.ElementSize;
4151 let hasSideEffects = 0;
4154 class sve2_int_un_pred_arit_z<bits<2> sz, bits<2> opc,
4155 string asm, ZPRRegOp zprty>
4156 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
4157 asm, "\t$Zd, $Pg/z, $Zn",
4163 let Inst{31-24} = 0b01000100;
4164 let Inst{23-22} = sz;
4165 let Inst{21-20} = 0b00;
4166 let Inst{19} = opc{1};
4167 let Inst{18-17} = 0b01;
4168 let Inst{16} = opc{0};
4169 let Inst{15-13} = 0b101;
4170 let Inst{12-10} = Pg;
4173 let hasSideEffects = 0;
4176 multiclass sve2_int_un_pred_arit_s<bits<2> opc, string asm,
4177 SDPatternOperator op> {
4178 def _S : sve2_int_un_pred_arit<0b10, opc, asm, ZPR32>,
4179 SVEPseudo2Instr<NAME # _S, 1>;
4181 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
4183 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
4185 defm : SVE_3_Op_Undef_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
4188 multiclass sve2_int_un_pred_arit<bits<2> opc, string asm, SDPatternOperator op> {
4189 def _B : sve2_int_un_pred_arit<0b00, opc, asm, ZPR8>,
4190 SVEPseudo2Instr<NAME # _B, 1>;
4191 def _H : sve2_int_un_pred_arit<0b01, opc, asm, ZPR16>,
4192 SVEPseudo2Instr<NAME # _H, 1>;
4193 def _S : sve2_int_un_pred_arit<0b10, opc, asm, ZPR32>,
4194 SVEPseudo2Instr<NAME # _S, 1>;
4195 def _D : sve2_int_un_pred_arit<0b11, opc, asm, ZPR64>,
4196 SVEPseudo2Instr<NAME # _D, 1>;
4198 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
4199 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
4200 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
4201 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
4203 def _B_UNDEF : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
4204 def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
4205 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
4206 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4208 defm : SVE_3_Op_Undef_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
4209 defm : SVE_3_Op_Undef_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
4210 defm : SVE_3_Op_Undef_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
4211 defm : SVE_3_Op_Undef_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
4214 multiclass sve2_int_un_pred_arit_z_S<bits<2> opc, string asm, SDPatternOperator op> {
4215 def _S : sve2_int_un_pred_arit_z<0b10, opc, asm, ZPR32>;
4217 defm : SVE_3_Op_UndefZero_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
4220 multiclass sve2_int_un_pred_arit_z<bits<2> opc, string asm, SDPatternOperator op> {
4221 def _B : sve2_int_un_pred_arit_z<0b00, opc, asm, ZPR8>;
4222 def _H : sve2_int_un_pred_arit_z<0b01, opc, asm, ZPR16>;
4223 def _S : sve2_int_un_pred_arit_z<0b10, opc, asm, ZPR32>;
4224 def _D : sve2_int_un_pred_arit_z<0b11, opc, asm, ZPR64>;
4226 defm : SVE_3_Op_UndefZero_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
4227 defm : SVE_3_Op_UndefZero_Pat<nxv8i16, op, nxv8i16, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
4228 defm : SVE_3_Op_UndefZero_Pat<nxv4i32, op, nxv4i32, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
4229 defm : SVE_3_Op_UndefZero_Pat<nxv2i64, op, nxv2i64, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
4232 //===----------------------------------------------------------------------===//
4233 // SVE2 Widening Integer Arithmetic Group
4234 //===----------------------------------------------------------------------===//
4236 class sve2_wide_int_arith<bits<2> sz, bits<5> opc, string asm,
4237 ZPRRegOp zprty1, ZPRRegOp zprty2, ZPRRegOp zprty3>
4238 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm),
4239 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
4243 let Inst{31-24} = 0b01000101;
4244 let Inst{23-22} = sz;
4246 let Inst{20-16} = Zm;
4248 let Inst{14-10} = opc;
4252 let hasSideEffects = 0;
4255 multiclass sve2_wide_int_arith_long<bits<5> opc, string asm,
4256 SDPatternOperator op> {
4257 def _H : sve2_wide_int_arith<0b01, opc, asm, ZPR16, ZPR8, ZPR8>;
4258 def _S : sve2_wide_int_arith<0b10, opc, asm, ZPR32, ZPR16, ZPR16>;
4259 def _D : sve2_wide_int_arith<0b11, opc, asm, ZPR64, ZPR32, ZPR32>;
4261 def : SVE_2_Op_Pat<nxv8i16, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
4262 def : SVE_2_Op_Pat<nxv4i32, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
4263 def : SVE_2_Op_Pat<nxv2i64, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
4266 multiclass sve2_wide_int_arith_wide<bits<3> opc, string asm,
4267 SDPatternOperator op> {
4268 def _H : sve2_wide_int_arith<0b01, { 0b10, opc }, asm, ZPR16, ZPR16, ZPR8>;
4269 def _S : sve2_wide_int_arith<0b10, { 0b10, opc }, asm, ZPR32, ZPR32, ZPR16>;
4270 def _D : sve2_wide_int_arith<0b11, { 0b10, opc }, asm, ZPR64, ZPR64, ZPR32>;
4272 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, !cast<Instruction>(NAME # _H)>;
4273 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, !cast<Instruction>(NAME # _S)>;
4274 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, !cast<Instruction>(NAME # _D)>;
4277 multiclass sve2_wide_int_arith_pmul<bits<2> sz, bits<5> opc, string asm,
4278 SDPatternOperator op> {
4279 def NAME : sve2_wide_int_arith<sz, opc, asm, ZPR128, ZPR64, ZPR64>;
4281 // To avoid using 128 bit elements in the IR, the pattern below works with
4282 // llvm intrinsics with the _pair suffix, to reflect that
4283 // _Q is implemented as a pair of _D.
4284 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
4287 multiclass sve2_pmul_long<bits<1> opc, string asm, SDPatternOperator op> {
4288 def _H : sve2_wide_int_arith<0b01, {0b1101, opc}, asm, ZPR16, ZPR8, ZPR8>;
4289 def _D : sve2_wide_int_arith<0b11, {0b1101, opc}, asm, ZPR64, ZPR32, ZPR32>;
4291 // To avoid using 128 bit elements in the IR, the patterns below work with
4292 // llvm intrinsics with the _pair suffix, to reflect that
4293 // _H is implemented as a pair of _B and _D is implemented as a pair of _S.
4294 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
4295 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
4298 //===----------------------------------------------------------------------===//
4300 //===----------------------------------------------------------------------===//
4302 class sve2_misc<bits<2> sz, bits<4> opc, string asm,
4303 ZPRRegOp zprty1, ZPRRegOp zprty2>
4304 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
4305 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
4309 let Inst{31-24} = 0b01000101;
4310 let Inst{23-22} = sz;
4312 let Inst{20-16} = Zm;
4313 let Inst{15-14} = 0b10;
4314 let Inst{13-10} = opc;
4318 let hasSideEffects = 0;
4321 multiclass sve2_misc_bitwise<bits<4> opc, string asm, SDPatternOperator op> {
4322 def _B : sve2_misc<0b00, opc, asm, ZPR8, ZPR8>;
4323 def _H : sve2_misc<0b01, opc, asm, ZPR16, ZPR16>;
4324 def _S : sve2_misc<0b10, opc, asm, ZPR32, ZPR32>;
4325 def _D : sve2_misc<0b11, opc, asm, ZPR64, ZPR64>;
4327 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
4328 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
4329 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
4330 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
4333 multiclass sve2_misc_int_addsub_long_interleaved<bits<2> opc, string asm,
4334 SDPatternOperator op> {
4335 def _H : sve2_misc<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
4336 def _S : sve2_misc<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
4337 def _D : sve2_misc<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
4339 def : SVE_2_Op_Pat<nxv8i16, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
4340 def : SVE_2_Op_Pat<nxv4i32, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
4341 def : SVE_2_Op_Pat<nxv2i64, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
4344 class sve2_bitwise_xor_interleaved<bits<2> sz, bits<1> opc, string asm,
4345 ZPRRegOp zprty1, ZPRRegOp zprty2>
4346 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
4347 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
4351 let Inst{31-24} = 0b01000101;
4352 let Inst{23-22} = sz;
4354 let Inst{20-16} = Zm;
4355 let Inst{15-11} = 0b10010;
4360 let Constraints = "$Zd = $_Zd";
4361 let DestructiveInstType = DestructiveOther;
4362 let ElementSize = ElementSizeNone;
4363 let hasSideEffects = 0;
4366 multiclass sve2_bitwise_xor_interleaved<bit opc, string asm,
4367 SDPatternOperator op> {
4368 def _B : sve2_bitwise_xor_interleaved<0b00, opc, asm, ZPR8, ZPR8>;
4369 def _H : sve2_bitwise_xor_interleaved<0b01, opc, asm, ZPR16, ZPR16>;
4370 def _S : sve2_bitwise_xor_interleaved<0b10, opc, asm, ZPR32, ZPR32>;
4371 def _D : sve2_bitwise_xor_interleaved<0b11, opc, asm, ZPR64, ZPR64>;
4373 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
4374 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
4375 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
4376 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
4379 class sve2_bitwise_shift_left_long<bits<3> tsz8_64, bits<2> opc, string asm,
4380 ZPRRegOp zprty1, ZPRRegOp zprty2,
4382 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
4383 asm, "\t$Zd, $Zn, $imm",
4384 "", []>, Sched<[]> {
4388 let Inst{31-23} = 0b010001010;
4389 let Inst{22} = tsz8_64{2};
4391 let Inst{20-19} = tsz8_64{1-0};
4392 let Inst{18-16} = imm{2-0}; // imm3
4393 let Inst{15-12} = 0b1010;
4394 let Inst{11-10} = opc;
4398 let hasSideEffects = 0;
4401 multiclass sve2_bitwise_shift_left_long<bits<2> opc, string asm,
4402 SDPatternOperator op> {
4403 def _H : sve2_bitwise_shift_left_long<{0,0,1}, opc, asm,
4404 ZPR16, ZPR8, vecshiftL8>;
4405 def _S : sve2_bitwise_shift_left_long<{0,1,?}, opc, asm,
4406 ZPR32, ZPR16, vecshiftL16> {
4407 let Inst{19} = imm{3};
4409 def _D : sve2_bitwise_shift_left_long<{1,?,?}, opc, asm,
4410 ZPR64, ZPR32, vecshiftL32> {
4411 let Inst{20-19} = imm{4-3};
4413 def : SVE_2_Op_Imm_Pat<nxv8i16, op, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _H)>;
4414 def : SVE_2_Op_Imm_Pat<nxv4i32, op, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _S)>;
4415 def : SVE_2_Op_Imm_Pat<nxv2i64, op, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _D)>;
4418 //===----------------------------------------------------------------------===//
4419 // SVE2 Accumulate Group
4420 //===----------------------------------------------------------------------===//
4422 class sve2_int_bin_shift_imm<bits<4> tsz8_64, bit opc, string asm,
4423 ZPRRegOp zprty, Operand immtype>
4424 : I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, immtype:$imm),
4425 asm, "\t$Zd, $Zn, $imm",
4426 "", []>, Sched<[]> {
4430 let Inst{31-24} = 0b01000101;
4431 let Inst{23-22} = tsz8_64{3-2};
4433 let Inst{20-19} = tsz8_64{1-0};
4434 let Inst{18-16} = imm{2-0}; // imm3
4435 let Inst{15-11} = 0b11110;
4440 let Constraints = "$Zd = $_Zd";
4441 let hasSideEffects = 0;
4444 multiclass sve2_int_bin_shift_imm_left<bit opc, string asm,
4445 SDPatternOperator op> {
4446 def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
4447 def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
4448 let Inst{19} = imm{3};
4450 def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
4451 let Inst{20-19} = imm{4-3};
4453 def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
4454 let Inst{22} = imm{5};
4455 let Inst{20-19} = imm{4-3};
4458 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _B)>;
4459 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _H)>;
4460 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _S)>;
4461 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftL64, !cast<Instruction>(NAME # _D)>;
4464 multiclass sve2_int_bin_shift_imm_right<bit opc, string asm,
4465 SDPatternOperator op> {
4466 def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
4467 def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
4468 let Inst{19} = imm{3};
4470 def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
4471 let Inst{20-19} = imm{4-3};
4473 def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
4474 let Inst{22} = imm{5};
4475 let Inst{20-19} = imm{4-3};
4478 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
4479 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
4480 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
4481 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
4484 class sve2_int_bin_accum_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
4485 ZPRRegOp zprty, Operand immtype>
4486 : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, immtype:$imm),
4487 asm, "\t$Zda, $Zn, $imm",
4488 "", []>, Sched<[]> {
4492 let Inst{31-24} = 0b01000101;
4493 let Inst{23-22} = tsz8_64{3-2};
4495 let Inst{20-19} = tsz8_64{1-0};
4496 let Inst{18-16} = imm{2-0}; // imm3
4497 let Inst{15-12} = 0b1110;
4498 let Inst{11-10} = opc;
4500 let Inst{4-0} = Zda;
4502 let Constraints = "$Zda = $_Zda";
4503 let DestructiveInstType = DestructiveOther;
4504 let ElementSize = ElementSizeNone;
4505 let hasSideEffects = 0;
4508 multiclass sve2_int_bin_accum_shift_imm_right<bits<2> opc, string asm,
4509 SDPatternOperator op,
4510 SDPatternOperator shift_op = null_frag> {
4511 def _B : sve2_int_bin_accum_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
4512 def _H : sve2_int_bin_accum_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
4513 let Inst{19} = imm{3};
4515 def _S : sve2_int_bin_accum_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
4516 let Inst{20-19} = imm{4-3};
4518 def _D : sve2_int_bin_accum_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
4519 let Inst{22} = imm{5};
4520 let Inst{20-19} = imm{4-3};
4523 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
4524 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
4525 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
4526 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
4528 def : SVE_Shift_Add_All_Active_Pat<nxv16i8, shift_op, nxv16i1, nxv16i8, nxv16i8, i32, !cast<Instruction>(NAME # _B)>;
4529 def : SVE_Shift_Add_All_Active_Pat<nxv8i16, shift_op, nxv8i1, nxv8i16, nxv8i16, i32, !cast<Instruction>(NAME # _H)>;
4530 def : SVE_Shift_Add_All_Active_Pat<nxv4i32, shift_op, nxv4i1, nxv4i32, nxv4i32, i32, !cast<Instruction>(NAME # _S)>;
4531 def : SVE_Shift_Add_All_Active_Pat<nxv2i64, shift_op, nxv2i1, nxv2i64, nxv2i64, i32, !cast<Instruction>(NAME # _D)>;
4534 class sve2_int_cadd<bits<2> sz, bit opc, string asm, ZPRRegOp zprty>
4535 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, complexrotateopodd:$rot),
4536 asm, "\t$Zdn, $_Zdn, $Zm, $rot", "", []>, Sched<[]> {
4540 let Inst{31-24} = 0b01000101;
4541 let Inst{23-22} = sz;
4542 let Inst{21-17} = 0b00000;
4544 let Inst{15-11} = 0b11011;
4547 let Inst{4-0} = Zdn;
4549 let Constraints = "$Zdn = $_Zdn";
4550 let DestructiveInstType = DestructiveOther;
4551 let ElementSize = ElementSizeNone;
4552 let hasSideEffects = 0;
4555 multiclass sve2_int_cadd<bit opc, string asm, SDPatternOperator op> {
4556 def _B : sve2_int_cadd<0b00, opc, asm, ZPR8>;
4557 def _H : sve2_int_cadd<0b01, opc, asm, ZPR16>;
4558 def _S : sve2_int_cadd<0b10, opc, asm, ZPR32>;
4559 def _D : sve2_int_cadd<0b11, opc, asm, ZPR64>;
4561 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, complexrotateopodd, !cast<Instruction>(NAME # _B)>;
4562 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, complexrotateopodd, !cast<Instruction>(NAME # _H)>;
4563 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, complexrotateopodd, !cast<Instruction>(NAME # _S)>;
4564 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, complexrotateopodd, !cast<Instruction>(NAME # _D)>;
4567 class sve2_int_absdiff_accum<bits<2> sz, bits<4> opc, string asm,
4568 ZPRRegOp zprty1, ZPRRegOp zprty2>
4569 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
4570 asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
4574 let Inst{31-24} = 0b01000101;
4575 let Inst{23-22} = sz;
4577 let Inst{20-16} = Zm;
4578 let Inst{15-14} = 0b11;
4579 let Inst{13-10} = opc;
4581 let Inst{4-0} = Zda;
4583 let Constraints = "$Zda = $_Zda";
4584 let DestructiveInstType = DestructiveOther;
4585 let ElementSize = ElementSizeNone;
4586 let hasSideEffects = 0;
4589 multiclass sve2_int_absdiff_accum<bit opc, string asm, SDPatternOperator op> {
4590 def _B : sve2_int_absdiff_accum<0b00, { 0b111, opc }, asm, ZPR8, ZPR8>;
4591 def _H : sve2_int_absdiff_accum<0b01, { 0b111, opc }, asm, ZPR16, ZPR16>;
4592 def _S : sve2_int_absdiff_accum<0b10, { 0b111, opc }, asm, ZPR32, ZPR32>;
4593 def _D : sve2_int_absdiff_accum<0b11, { 0b111, opc }, asm, ZPR64, ZPR64>;
4595 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
4596 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
4597 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
4598 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
4601 multiclass sve2_int_absdiff_accum_long<bits<2> opc, string asm,
4602 SDPatternOperator op> {
4603 def _H : sve2_int_absdiff_accum<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
4604 def _S : sve2_int_absdiff_accum<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
4605 def _D : sve2_int_absdiff_accum<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
4607 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _H)>;
4608 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _S)>;
4609 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _D)>;
4612 multiclass sve2_int_addsub_long_carry<bits<2> opc, string asm,
4613 SDPatternOperator op> {
4614 def _S : sve2_int_absdiff_accum<{ opc{1}, 0b0 }, { 0b010, opc{0} }, asm,
4616 def _D : sve2_int_absdiff_accum<{ opc{1}, 0b1 }, { 0b010, opc{0} }, asm,
4619 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
4620 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
4623 //===----------------------------------------------------------------------===//
4624 // SVE2 Narrowing Group
4625 //===----------------------------------------------------------------------===//
4627 class sve2_int_bin_shift_imm_narrow_bottom<bits<3> tsz8_64, bits<3> opc,
4628 string asm, ZPRRegOp zprty1,
4629 ZPRRegOp zprty2, Operand immtype>
4630 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
4631 asm, "\t$Zd, $Zn, $imm",
4632 "", []>, Sched<[]> {
4636 let Inst{31-23} = 0b010001010;
4637 let Inst{22} = tsz8_64{2};
4639 let Inst{20-19} = tsz8_64{1-0};
4640 let Inst{18-16} = imm{2-0}; // imm3
4641 let Inst{15-14} = 0b00;
4642 let Inst{13-11} = opc;
4647 let hasSideEffects = 0;
4650 multiclass sve2_int_bin_shift_imm_right_narrow_bottom<bits<3> opc, string asm,
4651 SDPatternOperator op> {
4652 def _B : sve2_int_bin_shift_imm_narrow_bottom<{0,0,1}, opc, asm, ZPR8, ZPR16,
4654 def _H : sve2_int_bin_shift_imm_narrow_bottom<{0,1,?}, opc, asm, ZPR16, ZPR32,
4656 let Inst{19} = imm{3};
4658 def _S : sve2_int_bin_shift_imm_narrow_bottom<{1,?,?}, opc, asm, ZPR32, ZPR64,
4660 let Inst{20-19} = imm{4-3};
4662 def : SVE_2_Op_Imm_Pat<nxv16i8, op, nxv8i16, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
4663 def : SVE_2_Op_Imm_Pat<nxv8i16, op, nxv4i32, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
4664 def : SVE_2_Op_Imm_Pat<nxv4i32, op, nxv2i64, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
4667 class sve2_int_bin_shift_imm_narrow_top<bits<3> tsz8_64, bits<3> opc,
4668 string asm, ZPRRegOp zprty1,
4669 ZPRRegOp zprty2, Operand immtype>
4670 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, immtype:$imm),
4671 asm, "\t$Zd, $Zn, $imm",
4672 "", []>, Sched<[]> {
4676 let Inst{31-23} = 0b010001010;
4677 let Inst{22} = tsz8_64{2};
4679 let Inst{20-19} = tsz8_64{1-0};
4680 let Inst{18-16} = imm{2-0}; // imm3
4681 let Inst{15-14} = 0b00;
4682 let Inst{13-11} = opc;
4687 let Constraints = "$Zd = $_Zd";
4688 let hasSideEffects = 0;
4691 multiclass sve2_int_bin_shift_imm_right_narrow_top<bits<3> opc, string asm,
4692 SDPatternOperator op> {
4693 def _B : sve2_int_bin_shift_imm_narrow_top<{0,0,1}, opc, asm, ZPR8, ZPR16,
4695 def _H : sve2_int_bin_shift_imm_narrow_top<{0,1,?}, opc, asm, ZPR16, ZPR32,
4697 let Inst{19} = imm{3};
4699 def _S : sve2_int_bin_shift_imm_narrow_top<{1,?,?}, opc, asm, ZPR32, ZPR64,
4701 let Inst{20-19} = imm{4-3};
4703 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv8i16, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
4704 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv4i32, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
4705 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv2i64, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
4708 class sve2_int_addsub_narrow_high_bottom<bits<2> sz, bits<2> opc, string asm,
4709 ZPRRegOp zprty1, ZPRRegOp zprty2>
4710 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
4711 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
4715 let Inst{31-24} = 0b01000101;
4716 let Inst{23-22} = sz;
4718 let Inst{20-16} = Zm;
4719 let Inst{15-13} = 0b011;
4720 let Inst{12-11} = opc; // S, R
4721 let Inst{10} = 0b0; // Top
4725 let hasSideEffects = 0;
4728 multiclass sve2_int_addsub_narrow_high_bottom<bits<2> opc, string asm,
4729 SDPatternOperator op> {
4730 def _B : sve2_int_addsub_narrow_high_bottom<0b01, opc, asm, ZPR8, ZPR16>;
4731 def _H : sve2_int_addsub_narrow_high_bottom<0b10, opc, asm, ZPR16, ZPR32>;
4732 def _S : sve2_int_addsub_narrow_high_bottom<0b11, opc, asm, ZPR32, ZPR64>;
4734 def : SVE_2_Op_Pat<nxv16i8, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _B)>;
4735 def : SVE_2_Op_Pat<nxv8i16, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _H)>;
4736 def : SVE_2_Op_Pat<nxv4i32, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _S)>;
4739 class sve2_int_addsub_narrow_high_top<bits<2> sz, bits<2> opc, string asm,
4740 ZPRRegOp zprty1, ZPRRegOp zprty2>
4741 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
4742 asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
4746 let Inst{31-24} = 0b01000101;
4747 let Inst{23-22} = sz;
4749 let Inst{20-16} = Zm;
4750 let Inst{15-13} = 0b011;
4751 let Inst{12-11} = opc; // S, R
4752 let Inst{10} = 0b1; // Top
4756 let Constraints = "$Zd = $_Zd";
4757 let hasSideEffects = 0;
4760 multiclass sve2_int_addsub_narrow_high_top<bits<2> opc, string asm,
4761 SDPatternOperator op> {
4762 def _B : sve2_int_addsub_narrow_high_top<0b01, opc, asm, ZPR8, ZPR16>;
4763 def _H : sve2_int_addsub_narrow_high_top<0b10, opc, asm, ZPR16, ZPR32>;
4764 def _S : sve2_int_addsub_narrow_high_top<0b11, opc, asm, ZPR32, ZPR64>;
4766 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _B)>;
4767 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _H)>;
4768 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _S)>;
4771 class sve2_int_sat_extract_narrow_bottom<bits<3> tsz8_64, bits<2> opc, string asm,
4772 ZPRRegOp zprty1, ZPRRegOp zprty2>
4773 : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
4774 asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
4777 let Inst{31-23} = 0b010001010;
4778 let Inst{22} = tsz8_64{2};
4780 let Inst{20-19} = tsz8_64{1-0};
4781 let Inst{18-13} = 0b000010;
4782 let Inst{12-11} = opc;
4787 let hasSideEffects = 0;
4790 multiclass sve2_int_sat_extract_narrow_bottom<bits<2> opc, string asm,
4791 SDPatternOperator op> {
4792 def _B : sve2_int_sat_extract_narrow_bottom<0b001, opc, asm, ZPR8, ZPR16>;
4793 def _H : sve2_int_sat_extract_narrow_bottom<0b010, opc, asm, ZPR16, ZPR32>;
4794 def _S : sve2_int_sat_extract_narrow_bottom<0b100, opc, asm, ZPR32, ZPR64>;
4796 def : SVE_1_Op_Pat<nxv16i8, op, nxv8i16, !cast<Instruction>(NAME # _B)>;
4797 def : SVE_1_Op_Pat<nxv8i16, op, nxv4i32, !cast<Instruction>(NAME # _H)>;
4798 def : SVE_1_Op_Pat<nxv4i32, op, nxv2i64, !cast<Instruction>(NAME # _S)>;
4801 class sve2_int_sat_extract_narrow_top<bits<3> tsz8_64, bits<2> opc, string asm,
4802 ZPRRegOp zprty1, ZPRRegOp zprty2>
4803 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn),
4804 asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
4807 let Inst{31-23} = 0b010001010;
4808 let Inst{22} = tsz8_64{2};
4810 let Inst{20-19} = tsz8_64{1-0};
4811 let Inst{18-13} = 0b000010;
4812 let Inst{12-11} = opc;
4817 let Constraints = "$Zd = $_Zd";
4818 let hasSideEffects = 0;
4821 multiclass sve2_int_sat_extract_narrow_top<bits<2> opc, string asm,
4822 SDPatternOperator op> {
4823 def _B : sve2_int_sat_extract_narrow_top<0b001, opc, asm, ZPR8, ZPR16>;
4824 def _H : sve2_int_sat_extract_narrow_top<0b010, opc, asm, ZPR16, ZPR32>;
4825 def _S : sve2_int_sat_extract_narrow_top<0b100, opc, asm, ZPR32, ZPR64>;
4827 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv8i16, !cast<Instruction>(NAME # _B)>;
4828 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv4i32, !cast<Instruction>(NAME # _H)>;
4829 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
4832 //===----------------------------------------------------------------------===//
4833 // SVE Integer Arithmetic - Unary Predicated Group
4834 //===----------------------------------------------------------------------===//
4836 class sve_int_un_pred_arit<bits<2> sz8_64, bits<4> opc,
4837 string asm, ZPRRegOp zprty>
4838 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
4839 asm, "\t$Zd, $Pg/m, $Zn",
4845 let Inst{31-24} = 0b00000100;
4846 let Inst{23-22} = sz8_64;
4847 let Inst{21-20} = 0b01;
4848 let Inst{19} = opc{0};
4849 let Inst{18-16} = opc{3-1};
4850 let Inst{15-13} = 0b101;
4851 let Inst{12-10} = Pg;
4855 let Constraints = "$Zd = $_Zd";
4856 let DestructiveInstType = DestructiveUnaryPassthru;
4857 let ElementSize = zprty.ElementSize;
4858 let hasSideEffects = 0;
4861 class sve_int_un_pred_arit_z<bits<2> sz8_64, bits<4> opc,
4862 string asm, ZPRRegOp zprty>
4863 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
4864 asm, "\t$Zd, $Pg/z, $Zn",
4870 let Inst{31-24} = 0b00000100;
4871 let Inst{23-22} = sz8_64;
4872 let Inst{21-20} = 0b00;
4873 let Inst{19} = opc{0};
4874 let Inst{18-16} = opc{3-1};
4875 let Inst{15-13} = 0b101;
4876 let Inst{12-10} = Pg;
4880 let hasSideEffects = 0;
4883 multiclass sve_int_un_pred_arit<bits<3> opc, string asm,
4884 SDPatternOperator op> {
4885 def _B : sve_int_un_pred_arit<0b00, { opc, 0b0 }, asm, ZPR8>,
4886 SVEPseudo2Instr<NAME # _B, 1>;
4887 def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>,
4888 SVEPseudo2Instr<NAME # _H, 1>;
4889 def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
4890 SVEPseudo2Instr<NAME # _S, 1>;
4891 def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
4892 SVEPseudo2Instr<NAME # _D, 1>;
4894 def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
4895 def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
4896 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
4897 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
4899 def _B_UNDEF : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
4900 def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
4901 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
4902 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4904 defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
4905 defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
4906 defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
4907 defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
4910 multiclass sve_int_un_pred_arit_z<bits<3> opc, string asm, SDPatternOperator op> {
4911 def _B : sve_int_un_pred_arit_z<0b00, { opc, 0b0 }, asm, ZPR8>;
4912 def _H : sve_int_un_pred_arit_z<0b01, { opc, 0b0 }, asm, ZPR16>;
4913 def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b0 }, asm, ZPR32>;
4914 def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b0 }, asm, ZPR64>;
4916 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
4917 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
4918 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
4919 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
4922 multiclass sve_int_un_pred_arit_h<bits<3> opc, string asm,
4923 SDPatternOperator op> {
4924 def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>,
4925 SVEPseudo2Instr<NAME # _H, 1>;
4926 def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
4927 SVEPseudo2Instr<NAME # _S, 1>;
4928 def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
4929 SVEPseudo2Instr<NAME # _D, 1>;
4931 def : SVE_InReg_Extend<nxv8i16, op, nxv8i1, nxv8i8, !cast<Instruction>(NAME # _H)>;
4932 def : SVE_InReg_Extend<nxv4i32, op, nxv4i1, nxv4i8, !cast<Instruction>(NAME # _S)>;
4933 def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i8, !cast<Instruction>(NAME # _D)>;
4935 def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
4936 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
4937 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4939 defm : SVE_InReg_Extend_PassthruUndef<nxv8i16, op, nxv8i1, nxv8i8, !cast<Pseudo>(NAME # _H_UNDEF)>;
4940 defm : SVE_InReg_Extend_PassthruUndef<nxv4i32, op, nxv4i1, nxv4i8, !cast<Pseudo>(NAME # _S_UNDEF)>;
4941 defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i8, !cast<Pseudo>(NAME # _D_UNDEF)>;
4944 multiclass sve_int_un_pred_arit_h_z<bits<3> opc, string asm, SDPatternOperator op> {
4945 def _H : sve_int_un_pred_arit_z<0b01, { opc, 0b0 }, asm, ZPR16>;
4946 def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b0 }, asm, ZPR32>;
4947 def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b0 }, asm, ZPR64>;
4949 defm : SVE_InReg_Extend_PassthruUndefZero<nxv8i16, op, nxv8i1, nxv8i8, !cast<Instruction>(NAME # _H)>;
4950 defm : SVE_InReg_Extend_PassthruUndefZero<nxv4i32, op, nxv4i1, nxv4i8, !cast<Instruction>(NAME # _S)>;
4951 defm : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i8, !cast<Instruction>(NAME # _D)>;
4954 multiclass sve_int_un_pred_arit_w<bits<3> opc, string asm,
4955 SDPatternOperator op> {
4956 def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>,
4957 SVEPseudo2Instr<NAME # _S, 1>;
4958 def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
4959 SVEPseudo2Instr<NAME # _D, 1>;
4961 def : SVE_InReg_Extend<nxv4i32, op, nxv4i1, nxv4i16, !cast<Instruction>(NAME # _S)>;
4962 def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i16, !cast<Instruction>(NAME # _D)>;
4964 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
4965 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4967 defm : SVE_InReg_Extend_PassthruUndef<nxv4i32, op, nxv4i1, nxv4i16, !cast<Pseudo>(NAME # _S_UNDEF)>;
4968 defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i16, !cast<Pseudo>(NAME # _D_UNDEF)>;
4971 multiclass sve_int_un_pred_arit_w_z<bits<3> opc, string asm, SDPatternOperator op> {
4972 def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b0 }, asm, ZPR32>;
4973 def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b0 }, asm, ZPR64>;
4975 defm : SVE_InReg_Extend_PassthruUndefZero<nxv4i32, op, nxv4i1, nxv4i16, !cast<Instruction>(NAME # _S)>;
4976 defm : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i16, !cast<Instruction>(NAME # _D)>;
4979 multiclass sve_int_un_pred_arit_d<bits<3> opc, string asm,
4980 SDPatternOperator op> {
4981 def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>,
4982 SVEPseudo2Instr<NAME # _D, 1>;
4984 def : SVE_InReg_Extend<nxv2i64, op, nxv2i1, nxv2i32, !cast<Instruction>(NAME # _D)>;
4986 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
4988 defm : SVE_InReg_Extend_PassthruUndef<nxv2i64, op, nxv2i1, nxv2i32, !cast<Pseudo>(NAME # _D_UNDEF)>;
4991 multiclass sve_int_un_pred_arit_d_z<bits<3> opc, string asm, SDPatternOperator op> {
4992 def _D : sve_int_un_pred_arit_z<0b11, {opc, 0b0}, asm, ZPR64>;
4994 defm : SVE_InReg_Extend_PassthruUndefZero<nxv2i64, op, nxv2i1, nxv2i32, !cast<Instruction>(NAME # _D)>;
4997 multiclass sve_int_un_pred_arit_bitwise<bits<3> opc, string asm,
4998 SDPatternOperator op> {
4999 def _B : sve_int_un_pred_arit<0b00, { opc, 0b1 }, asm, ZPR8>,
5000 SVEPseudo2Instr<NAME # _B, 1>;
5001 def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>,
5002 SVEPseudo2Instr<NAME # _H, 1>;
5003 def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>,
5004 SVEPseudo2Instr<NAME # _S, 1>;
5005 def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>,
5006 SVEPseudo2Instr<NAME # _D, 1>;
5008 def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
5009 def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
5010 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
5011 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
5013 def _B_UNDEF : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
5014 def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
5015 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
5016 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
5018 defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
5019 defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
5020 defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
5021 defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
5024 multiclass sve_int_un_pred_arit_bitwise_z<bits<3> opc, string asm, SDPatternOperator op> {
5025 def _B : sve_int_un_pred_arit_z<0b00, { opc, 0b1 }, asm, ZPR8>;
5026 def _H : sve_int_un_pred_arit_z<0b01, { opc, 0b1 }, asm, ZPR16>;
5027 def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b1 }, asm, ZPR32>;
5028 def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b1 }, asm, ZPR64>;
5030 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
5031 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
5032 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
5033 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
5036 multiclass sve_int_un_pred_arit_bitwise_fp<bits<3> opc, string asm,
5037 SDPatternOperator op> {
5038 def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>,
5039 SVEPseudo2Instr<NAME # _H, 1>;
5040 def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>,
5041 SVEPseudo2Instr<NAME # _S, 1>;
5042 def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>,
5043 SVEPseudo2Instr<NAME # _D, 1>;
5045 def : SVE_1_Op_Passthru_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
5046 def : SVE_1_Op_Passthru_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
5047 def : SVE_1_Op_Passthru_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
5048 def : SVE_1_Op_Passthru_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
5049 def : SVE_1_Op_Passthru_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
5050 def : SVE_1_Op_Passthru_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
5052 def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
5053 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
5054 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
5056 defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
5057 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
5058 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
5059 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
5060 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
5061 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Pseudo>(NAME # _D_UNDEF)>;
5064 multiclass sve_int_un_pred_arit_bitwise_fp_z<bits<3> opc, string asm, SDPatternOperator op> {
5065 def _H : sve_int_un_pred_arit_z<0b01, { opc, 0b1 }, asm, ZPR16>;
5066 def _S : sve_int_un_pred_arit_z<0b10, { opc, 0b1 }, asm, ZPR32>;
5067 def _D : sve_int_un_pred_arit_z<0b11, { opc, 0b1 }, asm, ZPR64>;
5069 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
5070 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
5071 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
5072 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
5073 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
5074 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
5077 multiclass sve_fp_un_pred_arit_hsd<SDPatternOperator op> {
5078 def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
5079 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
5080 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
5082 defm : SVE_1_Op_PassthruUndef_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
5083 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
5084 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
5085 defm : SVE_1_Op_PassthruUndef_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
5086 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
5087 defm : SVE_1_Op_PassthruUndef_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Pseudo>(NAME # _D_UNDEF)>;
5090 multiclass sve_int_un_pred_arit_bhsd<SDPatternOperator op> {
5091 def _B_UNDEF : PredOneOpPassthruPseudo<NAME # _B, ZPR8>;
5092 def _H_UNDEF : PredOneOpPassthruPseudo<NAME # _H, ZPR16>;
5093 def _S_UNDEF : PredOneOpPassthruPseudo<NAME # _S, ZPR32>;
5094 def _D_UNDEF : PredOneOpPassthruPseudo<NAME # _D, ZPR64>;
5096 defm : SVE_1_Op_PassthruUndef_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
5097 defm : SVE_1_Op_PassthruUndef_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
5098 defm : SVE_1_Op_PassthruUndef_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
5099 defm : SVE_1_Op_PassthruUndef_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
5102 //===----------------------------------------------------------------------===//
5103 // SVE Integer Wide Immediate - Unpredicated Group
5104 //===----------------------------------------------------------------------===//
5105 class sve_int_dup_imm<bits<2> sz8_64, string asm,
5106 ZPRRegOp zprty, Operand immtype>
5107 : I<(outs zprty:$Zd), (ins immtype:$imm),
5113 let Inst{31-24} = 0b00100101;
5114 let Inst{23-22} = sz8_64;
5115 let Inst{21-14} = 0b11100011;
5116 let Inst{13} = imm{8}; // sh
5117 let Inst{12-5} = imm{7-0}; // imm8
5120 let hasSideEffects = 0;
5121 let isReMaterializable = 1;
5125 multiclass sve_int_dup_imm<string asm> {
5126 def _B : sve_int_dup_imm<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8>;
5127 def _H : sve_int_dup_imm<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16>;
5128 def _S : sve_int_dup_imm<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32>;
5129 def _D : sve_int_dup_imm<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64>;
5131 def : InstAlias<"mov $Zd, $imm",
5132 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, cpy_imm8_opt_lsl_i8:$imm), 1>;
5133 def : InstAlias<"mov $Zd, $imm",
5134 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, cpy_imm8_opt_lsl_i16:$imm), 1>;
5135 def : InstAlias<"mov $Zd, $imm",
5136 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, cpy_imm8_opt_lsl_i32:$imm), 1>;
5137 def : InstAlias<"mov $Zd, $imm",
5138 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, cpy_imm8_opt_lsl_i64:$imm), 1>;
5140 def : InstAlias<"fmov $Zd, #0.0",
5141 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, 0, 0), 1>;
5142 def : InstAlias<"fmov $Zd, #0.0",
5143 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, 0, 0), 1>;
5144 def : InstAlias<"fmov $Zd, #0.0",
5145 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, 0, 0), 1>;
5148 class sve_int_dup_fpimm<bits<2> sz8_64, Operand fpimmtype,
5149 string asm, ZPRRegOp zprty>
5150 : I<(outs zprty:$Zd), (ins fpimmtype:$imm8),
5151 asm, "\t$Zd, $imm8",
5156 let Inst{31-24} = 0b00100101;
5157 let Inst{23-22} = sz8_64;
5158 let Inst{21-14} = 0b11100111;
5160 let Inst{12-5} = imm8;
5163 let hasSideEffects = 0;
5164 let isReMaterializable = 1;
5168 multiclass sve_int_dup_fpimm<string asm> {
5169 def _H : sve_int_dup_fpimm<0b01, fpimm16, asm, ZPR16>;
5170 def _S : sve_int_dup_fpimm<0b10, fpimm32, asm, ZPR32>;
5171 def _D : sve_int_dup_fpimm<0b11, fpimm64, asm, ZPR64>;
5173 def : InstAlias<"fmov $Zd, $imm8",
5174 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, fpimm16:$imm8), 1>;
5175 def : InstAlias<"fmov $Zd, $imm8",
5176 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, fpimm32:$imm8), 1>;
5177 def : InstAlias<"fmov $Zd, $imm8",
5178 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, fpimm64:$imm8), 1>;
5181 class sve_int_arith_imm0<bits<2> sz8_64, bits<3> opc, string asm,
5182 ZPRRegOp zprty, Operand immtype>
5183 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
5184 asm, "\t$Zdn, $_Zdn, $imm",
5189 let Inst{31-24} = 0b00100101;
5190 let Inst{23-22} = sz8_64;
5191 let Inst{21-19} = 0b100;
5192 let Inst{18-16} = opc;
5193 let Inst{15-14} = 0b11;
5194 let Inst{13} = imm{8}; // sh
5195 let Inst{12-5} = imm{7-0}; // imm8
5196 let Inst{4-0} = Zdn;
5198 let Constraints = "$Zdn = $_Zdn";
5199 let DestructiveInstType = DestructiveOther;
5200 let ElementSize = ElementSizeNone;
5201 let hasSideEffects = 0;
5204 multiclass sve_int_arith_imm0<bits<3> opc, string asm, SDPatternOperator op> {
5205 def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8, addsub_imm8_opt_lsl_i8>;
5206 def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>;
5207 def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>;
5208 def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>;
5210 def : SVE_1_Op_Imm_OptLsl_Pat<nxv16i8, op, ZPR8, i32, SVEAddSubImm8Pat, !cast<Instruction>(NAME # _B)>;
5211 def : SVE_1_Op_Imm_OptLsl_Pat<nxv8i16, op, ZPR16, i32, SVEAddSubImm16Pat, !cast<Instruction>(NAME # _H)>;
5212 def : SVE_1_Op_Imm_OptLsl_Pat<nxv4i32, op, ZPR32, i32, SVEAddSubImm32Pat, !cast<Instruction>(NAME # _S)>;
5213 def : SVE_1_Op_Imm_OptLsl_Pat<nxv2i64, op, ZPR64, i64, SVEAddSubImm64Pat, !cast<Instruction>(NAME # _D)>;
5216 multiclass sve_int_arith_imm0_ssat<bits<3> opc, string asm, SDPatternOperator op,
5217 SDPatternOperator inv_op> {
5218 def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8, addsub_imm8_opt_lsl_i8>;
5219 def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>;
5220 def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>;
5221 def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>;
5223 def : SVE_1_Op_Imm_OptLsl_Pat<nxv16i8, op, ZPR8, i32, SVEAddSubSSatPosImm8Pat, !cast<Instruction>(NAME # _B)>;
5224 def : SVE_1_Op_Imm_OptLsl_Pat<nxv8i16, op, ZPR16, i32, SVEAddSubSSatPosImm16Pat, !cast<Instruction>(NAME # _H)>;
5225 def : SVE_1_Op_Imm_OptLsl_Pat<nxv4i32, op, ZPR32, i32, SVEAddSubSSatPosImm32Pat, !cast<Instruction>(NAME # _S)>;
5226 def : SVE_1_Op_Imm_OptLsl_Pat<nxv2i64, op, ZPR64, i64, SVEAddSubSSatPosImm64Pat, !cast<Instruction>(NAME # _D)>;
5228 def : SVE_1_Op_Imm_OptLsl_Pat<nxv16i8, inv_op, ZPR8, i32, SVEAddSubSSatNegImm8Pat, !cast<Instruction>(NAME # _B)>;
5229 def : SVE_1_Op_Imm_OptLsl_Pat<nxv8i16, inv_op, ZPR16, i32, SVEAddSubSSatNegImm16Pat, !cast<Instruction>(NAME # _H)>;
5230 def : SVE_1_Op_Imm_OptLsl_Pat<nxv4i32, inv_op, ZPR32, i32, SVEAddSubSSatNegImm32Pat, !cast<Instruction>(NAME # _S)>;
5231 def : SVE_1_Op_Imm_OptLsl_Pat<nxv2i64, inv_op, ZPR64, i64, SVEAddSubSSatNegImm64Pat, !cast<Instruction>(NAME # _D)>;
5234 class sve_int_arith_imm<bits<2> sz8_64, bits<6> opc, string asm,
5235 ZPRRegOp zprty, Operand immtype>
5236 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
5237 asm, "\t$Zdn, $_Zdn, $imm",
5242 let Inst{31-24} = 0b00100101;
5243 let Inst{23-22} = sz8_64;
5244 let Inst{21-16} = opc;
5245 let Inst{15-13} = 0b110;
5246 let Inst{12-5} = imm;
5247 let Inst{4-0} = Zdn;
5249 let Constraints = "$Zdn = $_Zdn";
5250 let DestructiveInstType = DestructiveOther;
5251 let ElementSize = ElementSizeNone;
5252 let hasSideEffects = 0;
5255 multiclass sve_int_arith_imm1<bits<2> opc, string asm, SDPatternOperator op> {
5256 def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, simm8_32b>;
5257 def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, simm8_32b>;
5258 def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, simm8_32b>;
5259 def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, simm8_32b>;
5261 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _B)>;
5262 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _H)>;
5263 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _S)>;
5264 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithSImmPat64, !cast<Instruction>(NAME # _D)>;
5267 multiclass sve_int_arith_imm1_unsigned<bits<2> opc, string asm, SDPatternOperator op> {
5268 def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, imm0_255>;
5269 def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, imm0_255>;
5270 def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, imm0_255>;
5271 def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, imm0_255>;
5273 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithUImm8Pat, !cast<Instruction>(NAME # _B)>;
5274 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithUImm16Pat, !cast<Instruction>(NAME # _H)>;
5275 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithUImm32Pat, !cast<Instruction>(NAME # _S)>;
5276 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithUImm64Pat, !cast<Instruction>(NAME # _D)>;
5279 multiclass sve_int_arith_imm2<string asm, SDPatternOperator op> {
5280 def _B : sve_int_arith_imm<0b00, 0b110000, asm, ZPR8, simm8_32b>;
5281 def _H : sve_int_arith_imm<0b01, 0b110000, asm, ZPR16, simm8_32b>;
5282 def _S : sve_int_arith_imm<0b10, 0b110000, asm, ZPR32, simm8_32b>;
5283 def _D : sve_int_arith_imm<0b11, 0b110000, asm, ZPR64, simm8_32b>;
5285 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv16i8, nxv16i1, op, ZPR8, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _B)>;
5286 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv8i16, nxv8i1, op, ZPR16, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _H)>;
5287 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv4i32, nxv4i1, op, ZPR32, i32, SVEArithSImmPat32, !cast<Instruction>(NAME # _S)>;
5288 def : SVE_1_Op_Imm_Arith_Any_Predicate<nxv2i64, nxv2i1, op, ZPR64, i64, SVEArithSImmPat64, !cast<Instruction>(NAME # _D)>;
5291 //===----------------------------------------------------------------------===//
5292 // SVE Bitwise Logical - Unpredicated Group
5293 //===----------------------------------------------------------------------===//
5295 class sve_int_bin_cons_log<bits<2> opc, string asm>
5296 : I<(outs ZPR64:$Zd), (ins ZPR64:$Zn, ZPR64:$Zm),
5297 asm, "\t$Zd, $Zn, $Zm",
5303 let Inst{31-24} = 0b00000100;
5304 let Inst{23-22} = opc{1-0};
5306 let Inst{20-16} = Zm;
5307 let Inst{15-10} = 0b001100;
5311 let hasSideEffects = 0;
5314 multiclass sve_int_bin_cons_log<bits<2> opc, string asm, SDPatternOperator op> {
5315 def NAME : sve_int_bin_cons_log<opc, asm>;
5317 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
5318 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
5319 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>;
5320 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
5322 def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
5323 (!cast<Instruction>(NAME) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 1>;
5324 def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
5325 (!cast<Instruction>(NAME) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 1>;
5326 def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
5327 (!cast<Instruction>(NAME) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 1>;
5330 class sve2_int_bitwise_ternary_op_d<bits<3> opc, string asm>
5331 : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, ZPR64:$Zm, ZPR64:$Zk),
5332 asm, "\t$Zdn, $_Zdn, $Zm, $Zk",
5338 let Inst{31-24} = 0b00000100;
5339 let Inst{23-22} = opc{2-1};
5341 let Inst{20-16} = Zm;
5342 let Inst{15-11} = 0b00111;
5343 let Inst{10} = opc{0};
5345 let Inst{4-0} = Zdn;
5347 let Constraints = "$Zdn = $_Zdn";
5348 let DestructiveInstType = DestructiveOther;
5349 let ElementSize = ElementSizeNone;
5350 let hasSideEffects = 0;
5353 multiclass sve2_int_bitwise_ternary_op<bits<3> opc, string asm,
5354 SDPatternOperator op> {
5355 def NAME : sve2_int_bitwise_ternary_op_d<opc, asm>;
5357 def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
5358 (!cast<Instruction>(NAME) ZPR8:$Zdn, ZPR8:$Zm, ZPR8:$Zk), 1>;
5359 def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
5360 (!cast<Instruction>(NAME) ZPR16:$Zdn, ZPR16:$Zm, ZPR16:$Zk), 1>;
5361 def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
5362 (!cast<Instruction>(NAME) ZPR32:$Zdn, ZPR32:$Zm, ZPR32:$Zk), 1>;
5364 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
5365 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
5366 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>;
5367 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
5370 class sve2_int_rotate_right_imm<bits<4> tsz8_64, string asm,
5371 ZPRRegOp zprty, Operand immtype>
5372 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, immtype:$imm),
5373 asm, "\t$Zdn, $_Zdn, $Zm, $imm",
5379 let Inst{31-24} = 0b00000100;
5380 let Inst{23-22} = tsz8_64{3-2};
5382 let Inst{20-19} = tsz8_64{1-0};
5383 let Inst{18-16} = imm{2-0}; // imm3
5384 let Inst{15-10} = 0b001101;
5386 let Inst{4-0} = Zdn;
5388 let Constraints = "$Zdn = $_Zdn";
5389 let DestructiveInstType = DestructiveOther;
5390 let ElementSize = ElementSizeNone;
5391 let hasSideEffects = 0;
5394 multiclass sve2_int_rotate_right_imm<string asm, SDPatternOperator op> {
5395 def _B : sve2_int_rotate_right_imm<{0,0,0,1}, asm, ZPR8, vecshiftR8>;
5396 def _H : sve2_int_rotate_right_imm<{0,0,1,?}, asm, ZPR16, vecshiftR16> {
5397 let Inst{19} = imm{3};
5399 def _S : sve2_int_rotate_right_imm<{0,1,?,?}, asm, ZPR32, vecshiftR32> {
5400 let Inst{20-19} = imm{4-3};
5402 def _D : sve2_int_rotate_right_imm<{1,?,?,?}, asm, ZPR64, vecshiftR64> {
5403 let Inst{22} = imm{5};
5404 let Inst{20-19} = imm{4-3};
5407 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i8, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
5408 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i16, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
5409 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
5410 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i64, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
5413 //===----------------------------------------------------------------------===//
5414 // SVE Integer Wide Immediate - Predicated Group
5415 //===----------------------------------------------------------------------===//
5417 class sve_int_dup_fpimm_pred<bits<2> sz, Operand fpimmtype,
5418 string asm, ZPRRegOp zprty>
5419 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPRAny:$Pg, fpimmtype:$imm8),
5420 asm, "\t$Zd, $Pg/m, $imm8",
5426 let Inst{31-24} = 0b00000101;
5427 let Inst{23-22} = sz;
5428 let Inst{21-20} = 0b01;
5429 let Inst{19-16} = Pg;
5430 let Inst{15-13} = 0b110;
5431 let Inst{12-5} = imm8;
5434 let Constraints = "$Zd = $_Zd";
5435 let DestructiveInstType = DestructiveOther;
5436 let ElementSize = zprty.ElementSize;
5437 let hasSideEffects = 0;
5440 multiclass sve_int_dup_fpimm_pred<string asm> {
5441 def _H : sve_int_dup_fpimm_pred<0b01, fpimm16, asm, ZPR16>;
5442 def _S : sve_int_dup_fpimm_pred<0b10, fpimm32, asm, ZPR32>;
5443 def _D : sve_int_dup_fpimm_pred<0b11, fpimm64, asm, ZPR64>;
5445 def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
5446 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, fpimm16:$imm8), 1>;
5447 def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
5448 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, fpimm32:$imm8), 1>;
5449 def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
5450 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, fpimm64:$imm8), 1>;
5453 class sve_int_dup_imm_pred<bits<2> sz8_64, bit m, string asm,
5454 ZPRRegOp zprty, string pred_qual, dag iops>
5455 : I<(outs zprty:$Zd), iops,
5456 asm, "\t$Zd, $Pg"#pred_qual#", $imm",
5457 "", []>, Sched<[]> {
5461 let Inst{31-24} = 0b00000101;
5462 let Inst{23-22} = sz8_64;
5463 let Inst{21-20} = 0b01;
5464 let Inst{19-16} = Pg;
5467 let Inst{13} = imm{8}; // sh
5468 let Inst{12-5} = imm{7-0}; // imm8
5471 let DestructiveInstType = DestructiveOther;
5472 let ElementSize = zprty.ElementSize;
5473 let hasSideEffects = 0;
5476 multiclass sve_int_dup_imm_pred_merge_inst<
5477 bits<2> sz8_64, string asm, ZPRRegOp zprty, imm8_opt_lsl cpyimm,
5478 ValueType intty, ValueType predty, ValueType scalarty, ComplexPattern cpx> {
5479 let Constraints = "$Zd = $_Zd" in
5480 def NAME : sve_int_dup_imm_pred<sz8_64, 1, asm, zprty, "/m",
5481 (ins zprty:$_Zd, PPRAny:$Pg, cpyimm:$imm)>;
5482 def : InstAlias<"mov $Zd, $Pg/m, $imm",
5483 (!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>;
5484 def : Pat<(vselect predty:$Pg,
5485 (intty (splat_vector (scalarty (cpx i32:$imm, i32:$shift)))),
5487 (!cast<Instruction>(NAME) $Zd, $Pg, $imm, $shift)>;
5490 multiclass sve_int_dup_imm_pred_merge<string asm, SDPatternOperator op> {
5491 defm _B : sve_int_dup_imm_pred_merge_inst<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8,
5492 nxv16i8, nxv16i1, i32, SVECpyDupImm8Pat>;
5493 defm _H : sve_int_dup_imm_pred_merge_inst<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16,
5494 nxv8i16, nxv8i1, i32, SVECpyDupImm16Pat>;
5495 defm _S : sve_int_dup_imm_pred_merge_inst<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32,
5496 nxv4i32, nxv4i1, i32, SVECpyDupImm32Pat>;
5497 defm _D : sve_int_dup_imm_pred_merge_inst<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64,
5498 nxv2i64, nxv2i1, i64, SVECpyDupImm64Pat>;
5500 def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
5501 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, 0, 0), 0>;
5502 def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
5503 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, 0, 0), 0>;
5504 def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
5505 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, 0, 0), 0>;
5507 def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv8f16 ZPR:$Zd)),
5508 (!cast<Instruction>(NAME # _H) $Zd, $Pg, 0, 0)>;
5509 def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv4f16 ZPR:$Zd)),
5510 (!cast<Instruction>(NAME # _S) $Zd, $Pg, 0, 0)>;
5511 def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv2f16 ZPR:$Zd)),
5512 (!cast<Instruction>(NAME # _D) $Zd, $Pg, 0, 0)>;
5513 def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv4f32 ZPR:$Zd)),
5514 (!cast<Instruction>(NAME # _S) $Zd, $Pg, 0, 0)>;
5515 def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv2f32 ZPR:$Zd)),
5516 (!cast<Instruction>(NAME # _D) $Zd, $Pg, 0, 0)>;
5517 def : Pat<(vselect PPRAny:$Pg, (SVEDup0), (nxv2f64 ZPR:$Zd)),
5518 (!cast<Instruction>(NAME # _D) $Zd, $Pg, 0, 0)>;
5520 def : Pat<(nxv16i8 (op nxv16i1:$pg, (i32 (SVECpyDupImm8Pat i32:$a, i32:$b)), nxv16i8:$zd)),
5521 (!cast<Instruction>(NAME # _B) $zd, $pg, $a, $b)>;
5522 def : Pat<(nxv8i16 (op nxv8i1:$pg, (i32 (SVECpyDupImm16Pat i32:$a, i32:$b)), nxv8i16:$zd)),
5523 (!cast<Instruction>(NAME # _H) $zd, $pg, $a, $b)>;
5524 def : Pat<(nxv4i32 (op nxv4i1:$pg, (i32 (SVECpyDupImm32Pat i32:$a, i32:$b)), nxv4i32:$zd)),
5525 (!cast<Instruction>(NAME # _S) $zd, $pg, $a, $b)>;
5526 def : Pat<(nxv2i64 (op nxv2i1:$pg, (i64 (SVECpyDupImm64Pat i32:$a, i32:$b)), nxv2i64:$zd)),
5527 (!cast<Instruction>(NAME # _D) $zd, $pg, $a, $b)>;
5530 multiclass sve_int_dup_imm_pred_zero_inst<
5531 bits<2> sz8_64, string asm, ZPRRegOp zprty, imm8_opt_lsl cpyimm,
5532 ValueType intty, ValueType predty, ValueType scalarty, ComplexPattern cpx> {
5533 def NAME : sve_int_dup_imm_pred<sz8_64, 0, asm, zprty, "/z",
5534 (ins PPRAny:$Pg, cpyimm:$imm)>;
5535 def : InstAlias<"mov $Zd, $Pg/z, $imm",
5536 (!cast<Instruction>(NAME) zprty:$Zd, PPRAny:$Pg, cpyimm:$imm), 1>;
5537 def : Pat<(intty (zext (predty PPRAny:$Ps1))),
5538 (!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>;
5539 def : Pat<(intty (sext (predty PPRAny:$Ps1))),
5540 (!cast<Instruction>(NAME) PPRAny:$Ps1, -1, 0)>;
5541 def : Pat<(intty (anyext (predty PPRAny:$Ps1))),
5542 (!cast<Instruction>(NAME) PPRAny:$Ps1, 1, 0)>;
5543 def : Pat<(vselect predty:$Pg,
5544 (intty (splat_vector (scalarty (cpx i32:$imm, i32:$shift)))),
5545 (intty (splat_vector (scalarty 0)))),
5546 (!cast<Instruction>(NAME) $Pg, $imm, $shift)>;
5549 multiclass sve_int_dup_imm_pred_zero<string asm, SDPatternOperator op> {
5550 defm _B : sve_int_dup_imm_pred_zero_inst<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8,
5551 nxv16i8, nxv16i1, i32, SVECpyDupImm8Pat>;
5552 defm _H : sve_int_dup_imm_pred_zero_inst<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16,
5553 nxv8i16, nxv8i1, i32, SVECpyDupImm16Pat>;
5554 defm _S : sve_int_dup_imm_pred_zero_inst<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32,
5555 nxv4i32, nxv4i1, i32, SVECpyDupImm32Pat>;
5556 defm _D : sve_int_dup_imm_pred_zero_inst<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64,
5557 nxv2i64, nxv2i1, i64, SVECpyDupImm64Pat>;
5559 def : Pat<(nxv16i8 (op nxv16i1:$pg, (i32 (SVECpyDupImm8Pat i32:$a, i32:$b)), (SVEDup0))),
5560 (!cast<Instruction>(NAME # _B) $pg, $a, $b)>;
5561 def : Pat<(nxv8i16 (op nxv8i1:$pg, (i32 (SVECpyDupImm16Pat i32:$a, i32:$b)), (SVEDup0))),
5562 (!cast<Instruction>(NAME # _H) $pg, $a, $b)>;
5563 def : Pat<(nxv4i32 (op nxv4i1:$pg, (i32 (SVECpyDupImm32Pat i32:$a, i32:$b)), (SVEDup0))),
5564 (!cast<Instruction>(NAME # _S) $pg, $a, $b)>;
5565 def : Pat<(nxv2i64 (op nxv2i1:$pg, (i64 (SVECpyDupImm64Pat i32:$a, i32:$b)), (SVEDup0))),
5566 (!cast<Instruction>(NAME # _D) $pg, $a, $b)>;
5569 //===----------------------------------------------------------------------===//
5570 // SVE Integer Compare - Vectors Group
5571 //===----------------------------------------------------------------------===//
5573 class sve_int_cmp<bit cmp_1, bits<2> sz8_64, bits<3> opc, string asm,
5574 PPRRegOp pprty, ZPRRegOp zprty1, ZPRRegOp zprty2>
5575 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty1:$Zn, zprty2:$Zm),
5576 asm, "\t$Pd, $Pg/z, $Zn, $Zm",
5583 let Inst{31-24} = 0b00100100;
5584 let Inst{23-22} = sz8_64;
5586 let Inst{20-16} = Zm;
5587 let Inst{15} = opc{2};
5588 let Inst{14} = cmp_1;
5589 let Inst{13} = opc{1};
5590 let Inst{12-10} = Pg;
5592 let Inst{4} = opc{0};
5596 let ElementSize = pprty.ElementSize;
5597 let hasSideEffects = 0;
5598 let isPTestLike = 1;
5601 multiclass SVE_SETCC_Pat<CondCode cc, CondCode invcc, ValueType predvt,
5602 ValueType intvt, Instruction cmp> {
5603 def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, intvt:$Op3, cc)),
5604 (cmp $Op1, $Op2, $Op3)>;
5605 def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, intvt:$Op3, invcc)),
5606 (cmp $Op1, $Op3, $Op2)>;
5607 def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z_oneuse (predvt (SVEAllActive)), intvt:$Op2, intvt:$Op3, cc))),
5608 (cmp $Pg, $Op2, $Op3)>;
5609 def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z_oneuse (predvt (SVEAllActive)), intvt:$Op2, intvt:$Op3, invcc))),
5610 (cmp $Pg, $Op3, $Op2)>;
5613 multiclass SVE_SETCC_Pat_With_Zero<CondCode cc, CondCode invcc, ValueType predvt,
5614 ValueType intvt, Instruction cmp> {
5615 def : Pat<(predvt (AArch64setcc_z predvt:$Op1, intvt:$Op2, (SVEDup0), cc)),
5617 def : Pat<(predvt (AArch64setcc_z predvt:$Op1, (SVEDup0), intvt:$Op2, invcc)),
5619 def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z_oneuse (predvt (SVEAllActive)), intvt:$Op1, (SVEDup0), cc))),
5621 def : Pat<(predvt (and predvt:$Pg, (AArch64setcc_z_oneuse (predvt (SVEAllActive)), (SVEDup0), intvt:$Op1, invcc))),
5625 multiclass sve_int_cmp_0<bits<3> opc, string asm, CondCode cc, CondCode invcc> {
5626 def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR8>;
5627 def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR16>;
5628 def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR32>;
5629 def _D : sve_int_cmp<0b0, 0b11, opc, asm, PPR64, ZPR64, ZPR64>;
5631 defm : SVE_SETCC_Pat<cc, invcc, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
5632 defm : SVE_SETCC_Pat<cc, invcc, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
5633 defm : SVE_SETCC_Pat<cc, invcc, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
5634 defm : SVE_SETCC_Pat<cc, invcc, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
5637 multiclass sve_int_cmp_0_wide<bits<3> opc, string asm, SDPatternOperator op> {
5638 def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
5639 def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
5640 def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
5642 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
5643 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
5644 def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
5647 multiclass sve_int_cmp_1_wide<bits<3> opc, string asm, SDPatternOperator op> {
5648 def _B : sve_int_cmp<0b1, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
5649 def _H : sve_int_cmp<0b1, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
5650 def _S : sve_int_cmp<0b1, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
5652 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
5653 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
5654 def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
5658 //===----------------------------------------------------------------------===//
5659 // SVE Integer Compare - Signed Immediate Group
5660 //===----------------------------------------------------------------------===//
5662 class sve_int_scmp_vi<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty,
5665 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm5),
5666 asm, "\t$Pd, $Pg/z, $Zn, $imm5",
5673 let Inst{31-24} = 0b00100101;
5674 let Inst{23-22} = sz8_64;
5676 let Inst{20-16} = imm5;
5677 let Inst{15} = opc{2};
5679 let Inst{13} = opc{1};
5680 let Inst{12-10} = Pg;
5682 let Inst{4} = opc{0};
5686 let ElementSize = pprty.ElementSize;
5687 let hasSideEffects = 0;
5688 let isPTestLike = 1;
5691 multiclass SVE_SETCC_Imm_Pat<CondCode cc, CondCode commuted_cc,
5692 ValueType predvt, ValueType intvt,
5693 Operand immtype, Instruction cmp> {
5694 def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg),
5696 (intvt (splat_vector (immtype:$imm))),
5698 (cmp $Pg, $Zs1, immtype:$imm)>;
5699 def : Pat<(predvt (AArch64setcc_z (predvt PPR_3b:$Pg),
5700 (intvt (splat_vector (immtype:$imm))),
5703 (cmp $Pg, $Zs1, immtype:$imm)>;
5704 def : Pat<(predvt (and predvt:$Pg,
5705 (AArch64setcc_z_oneuse (predvt (SVEAllActive)),
5707 (intvt (splat_vector (immtype:$imm))),
5709 (cmp $Pg, $Zs1, immtype:$imm)>;
5710 def : Pat<(predvt (and predvt:$Pg,
5711 (AArch64setcc_z_oneuse (predvt (SVEAllActive)),
5712 (intvt (splat_vector (immtype:$imm))),
5715 (cmp $Pg, $Zs1, immtype:$imm)>;
5718 multiclass sve_int_scmp_vi<bits<3> opc, string asm, CondCode cc, CondCode commuted_cc> {
5719 def _B : sve_int_scmp_vi<0b00, opc, asm, PPR8, ZPR8, simm5_32b>;
5720 def _H : sve_int_scmp_vi<0b01, opc, asm, PPR16, ZPR16, simm5_32b>;
5721 def _S : sve_int_scmp_vi<0b10, opc, asm, PPR32, ZPR32, simm5_32b>;
5722 def _D : sve_int_scmp_vi<0b11, opc, asm, PPR64, ZPR64, simm5_64b>;
5724 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv16i1, nxv16i8, simm5_32b,
5725 !cast<Instruction>(NAME # _B)>;
5726 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv8i1, nxv8i16, simm5_32b,
5727 !cast<Instruction>(NAME # _H)>;
5728 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv4i1, nxv4i32, simm5_32b,
5729 !cast<Instruction>(NAME # _S)>;
5730 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv2i1, nxv2i64, simm5_64b,
5731 !cast<Instruction>(NAME # _D)>;
5735 //===----------------------------------------------------------------------===//
5736 // SVE Integer Compare - Unsigned Immediate Group
5737 //===----------------------------------------------------------------------===//
5739 class sve_int_ucmp_vi<bits<2> sz8_64, bits<2> opc, string asm, PPRRegOp pprty,
5740 ZPRRegOp zprty, Operand immtype>
5741 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm7),
5742 asm, "\t$Pd, $Pg/z, $Zn, $imm7",
5749 let Inst{31-24} = 0b00100100;
5750 let Inst{23-22} = sz8_64;
5752 let Inst{20-14} = imm7;
5753 let Inst{13} = opc{1};
5754 let Inst{12-10} = Pg;
5756 let Inst{4} = opc{0};
5760 let ElementSize = pprty.ElementSize;
5761 let hasSideEffects = 0;
5762 let isPTestLike = 1;
5765 multiclass sve_int_ucmp_vi<bits<2> opc, string asm, CondCode cc,
5766 CondCode commuted_cc> {
5767 def _B : sve_int_ucmp_vi<0b00, opc, asm, PPR8, ZPR8, imm0_127>;
5768 def _H : sve_int_ucmp_vi<0b01, opc, asm, PPR16, ZPR16, imm0_127>;
5769 def _S : sve_int_ucmp_vi<0b10, opc, asm, PPR32, ZPR32, imm0_127>;
5770 def _D : sve_int_ucmp_vi<0b11, opc, asm, PPR64, ZPR64, imm0_127_64b>;
5772 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv16i1, nxv16i8, imm0_127,
5773 !cast<Instruction>(NAME # _B)>;
5774 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv8i1, nxv8i16, imm0_127,
5775 !cast<Instruction>(NAME # _H)>;
5776 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv4i1, nxv4i32, imm0_127,
5777 !cast<Instruction>(NAME # _S)>;
5778 defm : SVE_SETCC_Imm_Pat<cc, commuted_cc, nxv2i1, nxv2i64, imm0_127_64b,
5779 !cast<Instruction>(NAME # _D)>;
5783 //===----------------------------------------------------------------------===//
5784 // SVE Integer Compare - Scalars Group
5785 //===----------------------------------------------------------------------===//
5787 class sve_int_cterm<bit sz, bit opc, string asm, RegisterClass rt>
5788 : I<(outs), (ins rt:$Rn, rt:$Rm),
5794 let Inst{31-23} = 0b001001011;
5797 let Inst{20-16} = Rm;
5798 let Inst{15-10} = 0b001000;
5801 let Inst{3-0} = 0b0000;
5804 let hasSideEffects = 0;
5807 class sve_int_while_rr<bits<2> sz8_64, bits<4> opc, string asm,
5808 RegisterClass gprty, PPRRegOp pprty>
5809 : I<(outs pprty:$Pd), (ins gprty:$Rn, gprty:$Rm),
5810 asm, "\t$Pd, $Rn, $Rm",
5811 "", []>, Sched<[]> {
5815 let Inst{31-24} = 0b00100101;
5816 let Inst{23-22} = sz8_64;
5818 let Inst{20-16} = Rm;
5819 let Inst{15-13} = 0b000;
5820 let Inst{12-10} = opc{3-1};
5822 let Inst{4} = opc{0};
5826 let ElementSize = pprty.ElementSize;
5827 let hasSideEffects = 0;
5831 multiclass sve_int_while4_rr<bits<3> opc, string asm, SDPatternOperator op,
5832 SDPatternOperator rev_op> {
5833 def _B : sve_int_while_rr<0b00, { 0, opc }, asm, GPR32, PPR8>;
5834 def _H : sve_int_while_rr<0b01, { 0, opc }, asm, GPR32, PPR16>;
5835 def _S : sve_int_while_rr<0b10, { 0, opc }, asm, GPR32, PPR32>;
5836 def _D : sve_int_while_rr<0b11, { 0, opc }, asm, GPR32, PPR64>;
5838 def : SVE_2_Op_Pat<nxv16i1, op, i32, i32, !cast<Instruction>(NAME # _B)>;
5839 def : SVE_2_Op_Pat<nxv8i1, op, i32, i32, !cast<Instruction>(NAME # _H)>;
5840 def : SVE_2_Op_Pat<nxv4i1, op, i32, i32, !cast<Instruction>(NAME # _S)>;
5841 def : SVE_2_Op_Pat<nxv2i1, op, i32, i32, !cast<Instruction>(NAME # _D)>;
5843 def : Pat<(nxv16i1 (vector_reverse (rev_op i32:$op2, i32:$op1))),
5844 (!cast<Instruction>(NAME # "_B") $op1, $op2)>;
5845 def : Pat<(nxv8i1 (vector_reverse (rev_op i32:$op2, i32:$op1))),
5846 (!cast<Instruction>(NAME # "_H") $op1, $op2)>;
5847 def : Pat<(nxv4i1 (vector_reverse (rev_op i32:$op2, i32:$op1))),
5848 (!cast<Instruction>(NAME # "_S") $op1, $op2)>;
5849 def : Pat<(nxv2i1 (vector_reverse (rev_op i32:$op2, i32:$op1))),
5850 (!cast<Instruction>(NAME # "_D") $op1, $op2)>;
5853 multiclass sve_int_while8_rr<bits<3> opc, string asm, SDPatternOperator op,
5854 SDPatternOperator rev_op> {
5855 def _B : sve_int_while_rr<0b00, { 1, opc }, asm, GPR64, PPR8>;
5856 def _H : sve_int_while_rr<0b01, { 1, opc }, asm, GPR64, PPR16>;
5857 def _S : sve_int_while_rr<0b10, { 1, opc }, asm, GPR64, PPR32>;
5858 def _D : sve_int_while_rr<0b11, { 1, opc }, asm, GPR64, PPR64>;
5860 def : SVE_2_Op_Pat<nxv16i1, op, i64, i64, !cast<Instruction>(NAME # _B)>;
5861 def : SVE_2_Op_Pat<nxv8i1, op, i64, i64, !cast<Instruction>(NAME # _H)>;
5862 def : SVE_2_Op_Pat<nxv4i1, op, i64, i64, !cast<Instruction>(NAME # _S)>;
5863 def : SVE_2_Op_Pat<nxv2i1, op, i64, i64, !cast<Instruction>(NAME # _D)>;
5865 def : Pat<(nxv16i1 (vector_reverse (rev_op i64:$op2, i64:$op1))),
5866 (!cast<Instruction>(NAME # "_B") $op1, $op2)>;
5867 def : Pat<(nxv8i1 (vector_reverse (rev_op i64:$op2, i64:$op1))),
5868 (!cast<Instruction>(NAME # "_H") $op1, $op2)>;
5869 def : Pat<(nxv4i1 (vector_reverse (rev_op i64:$op2, i64:$op1))),
5870 (!cast<Instruction>(NAME # "_S") $op1, $op2)>;
5871 def : Pat<(nxv2i1 (vector_reverse (rev_op i64:$op2, i64:$op1))),
5872 (!cast<Instruction>(NAME # "_D") $op1, $op2)>;
5875 class sve2_int_while_rr<bits<2> sz8_64, bits<1> rw, string asm,
5877 : I<(outs pprty:$Pd), (ins GPR64:$Rn, GPR64:$Rm),
5878 asm, "\t$Pd, $Rn, $Rm",
5879 "", []>, Sched<[]> {
5883 let Inst{31-24} = 0b00100101;
5884 let Inst{23-22} = sz8_64;
5886 let Inst{20-16} = Rm;
5887 let Inst{15-10} = 0b001100;
5893 let ElementSize = pprty.ElementSize;
5894 let hasSideEffects = 0;
5898 multiclass sve2_int_while_rr<bits<1> rw, string asm, string op> {
5899 def _B : sve2_int_while_rr<0b00, rw, asm, PPR8>;
5900 def _H : sve2_int_while_rr<0b01, rw, asm, PPR16>;
5901 def _S : sve2_int_while_rr<0b10, rw, asm, PPR32>;
5902 def _D : sve2_int_while_rr<0b11, rw, asm, PPR64>;
5904 def : SVE_2_Op_Pat<nxv16i1, !cast<SDPatternOperator>(op # _b), i64, i64, !cast<Instruction>(NAME # _B)>;
5905 def : SVE_2_Op_Pat<nxv8i1, !cast<SDPatternOperator>(op # _h), i64, i64, !cast<Instruction>(NAME # _H)>;
5906 def : SVE_2_Op_Pat<nxv4i1, !cast<SDPatternOperator>(op # _s), i64, i64, !cast<Instruction>(NAME # _S)>;
5907 def : SVE_2_Op_Pat<nxv2i1, !cast<SDPatternOperator>(op # _d), i64, i64, !cast<Instruction>(NAME # _D)>;
5910 //===----------------------------------------------------------------------===//
5911 // SVE Floating Point Fast Reduction Group
5912 //===----------------------------------------------------------------------===//
5914 class sve_fp_fast_red<bits<2> sz, bits<3> opc, string asm,
5915 ZPRRegOp zprty, FPRasZPROperand dstOpType>
5916 : I<(outs dstOpType:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
5917 asm, "\t$Vd, $Pg, $Zn",
5923 let Inst{31-24} = 0b01100101;
5924 let Inst{23-22} = sz;
5925 let Inst{21-19} = 0b000;
5926 let Inst{18-16} = opc;
5927 let Inst{15-13} = 0b001;
5928 let Inst{12-10} = Pg;
5932 let hasSideEffects = 0;
5933 let mayRaiseFPException = 1;
5936 multiclass sve_fp_fast_red<bits<3> opc, string asm, SDPatternOperator op> {
5937 def _H : sve_fp_fast_red<0b01, opc, asm, ZPR16, FPR16asZPR>;
5938 def _S : sve_fp_fast_red<0b10, opc, asm, ZPR32, FPR32asZPR>;
5939 def _D : sve_fp_fast_red<0b11, opc, asm, ZPR64, FPR64asZPR>;
5941 def : SVE_2_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
5942 def : SVE_2_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
5943 def : SVE_2_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
5944 def : SVE_2_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
5945 def : SVE_2_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
5946 def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
5949 //===----------------------------------------------------------------------===//
5950 // SVE Floating Point Accumulating Reduction Group
5951 //===----------------------------------------------------------------------===//
5953 class sve_fp_2op_p_vd<bits<2> sz, bits<3> opc, string asm,
5954 ZPRRegOp zprty, FPRasZPROperand dstOpType>
5955 : I<(outs dstOpType:$Vdn), (ins PPR3bAny:$Pg, dstOpType:$_Vdn, zprty:$Zm),
5956 asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
5963 let Inst{31-24} = 0b01100101;
5964 let Inst{23-22} = sz;
5965 let Inst{21-19} = 0b011;
5966 let Inst{18-16} = opc;
5967 let Inst{15-13} = 0b001;
5968 let Inst{12-10} = Pg;
5970 let Inst{4-0} = Vdn;
5972 let Constraints = "$Vdn = $_Vdn";
5973 let hasSideEffects = 0;
5974 let mayRaiseFPException = 1;
5977 multiclass sve_fp_2op_p_vd<bits<3> opc, string asm, SDPatternOperator op> {
5978 def _H : sve_fp_2op_p_vd<0b01, opc, asm, ZPR16, FPR16asZPR>;
5979 def _S : sve_fp_2op_p_vd<0b10, opc, asm, ZPR32, FPR32asZPR>;
5980 def _D : sve_fp_2op_p_vd<0b11, opc, asm, ZPR64, FPR64asZPR>;
5982 def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _H)>;
5983 def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _H)>;
5984 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
5985 def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _S)>;
5986 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
5987 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
5990 //===----------------------------------------------------------------------===//
5991 // SVE Floating Point Compare - Vectors Group
5992 //===----------------------------------------------------------------------===//
5994 class sve_fp_3op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
5996 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
5997 asm, "\t$Pd, $Pg/z, $Zn, $Zm",
6004 let Inst{31-24} = 0b01100101;
6005 let Inst{23-22} = sz;
6007 let Inst{20-16} = Zm;
6008 let Inst{15} = opc{2};
6010 let Inst{13} = opc{1};
6011 let Inst{12-10} = Pg;
6013 let Inst{4} = opc{0};
6016 let hasSideEffects = 0;
6017 let mayRaiseFPException = 1;
6020 multiclass sve_fp_3op_p_pd<bits<3> opc, string asm, SDPatternOperator op> {
6021 def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
6022 def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
6023 def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
6025 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
6026 def : SVE_3_Op_Pat<nxv4i1, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
6027 def : SVE_3_Op_Pat<nxv2i1, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
6030 multiclass sve_fp_3op_p_pd_cc<bits<3> opc, string asm,
6031 CondCode cc1, CondCode cc2,
6032 CondCode invcc1, CondCode invcc2> {
6033 def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
6034 def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
6035 def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
6037 defm : SVE_SETCC_Pat<cc1, invcc1, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
6038 defm : SVE_SETCC_Pat<cc1, invcc1, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
6039 defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
6040 defm : SVE_SETCC_Pat<cc1, invcc1, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
6041 defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
6042 defm : SVE_SETCC_Pat<cc1, invcc1, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
6044 defm : SVE_SETCC_Pat<cc2, invcc2, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
6045 defm : SVE_SETCC_Pat<cc2, invcc2, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
6046 defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
6047 defm : SVE_SETCC_Pat<cc2, invcc2, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
6048 defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
6049 defm : SVE_SETCC_Pat<cc2, invcc2, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
6052 //===----------------------------------------------------------------------===//
6053 // SVE Floating Point Compare - with Zero Group
6054 //===----------------------------------------------------------------------===//
6056 class sve_fp_2op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
6058 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn),
6059 asm, "\t$Pd, $Pg/z, $Zn, #0.0",
6065 let Inst{31-24} = 0b01100101;
6066 let Inst{23-22} = sz;
6067 let Inst{21-18} = 0b0100;
6068 let Inst{17-16} = opc{2-1};
6069 let Inst{15-13} = 0b001;
6070 let Inst{12-10} = Pg;
6072 let Inst{4} = opc{0};
6075 let hasSideEffects = 0;
6076 let mayRaiseFPException = 1;
6079 multiclass sve_fp_2op_p_pd<bits<3> opc, string asm,
6080 CondCode cc1, CondCode cc2,
6081 CondCode invcc1, CondCode invcc2> {
6082 def _H : sve_fp_2op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
6083 def _S : sve_fp_2op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
6084 def _D : sve_fp_2op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
6086 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
6087 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
6088 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
6089 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
6090 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
6091 defm : SVE_SETCC_Pat_With_Zero<cc1, invcc1, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
6093 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
6094 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv4i1, nxv4f16, !cast<Instruction>(NAME # _H)>;
6095 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f16, !cast<Instruction>(NAME # _H)>;
6096 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
6097 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
6098 defm : SVE_SETCC_Pat_With_Zero<cc2, invcc2, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
6102 //===----------------------------------------------------------------------===//
6103 //SVE Index Generation Group
6104 //===----------------------------------------------------------------------===//
6106 def simm5_8b_tgt : TImmLeaf<i8, [{ return (int8_t)Imm >= -16 && (int8_t)Imm < 16; }]>;
6107 def simm5_16b_tgt : TImmLeaf<i16, [{ return (int16_t)Imm >= -16 && (int16_t)Imm < 16; }]>;
6108 def simm5_32b_tgt : TImmLeaf<i32, [{ return (int32_t)Imm >= -16 && (int32_t)Imm < 16; }]>;
6109 def simm5_64b_tgt : TImmLeaf<i64, [{ return (int64_t)Imm >= -16 && (int64_t)Imm < 16; }]>;
6110 def i64imm_32bit_tgt : TImmLeaf<i64, [{
6111 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
6114 class sve_int_index_ii<bits<2> sz8_64, string asm, ZPRRegOp zprty,
6116 : I<(outs zprty:$Zd), (ins imm_ty:$imm5, imm_ty:$imm5b),
6117 asm, "\t$Zd, $imm5, $imm5b",
6118 "", []>, Sched<[]> {
6122 let Inst{31-24} = 0b00000100;
6123 let Inst{23-22} = sz8_64;
6125 let Inst{20-16} = imm5b;
6126 let Inst{15-10} = 0b010000;
6127 let Inst{9-5} = imm5;
6130 let hasSideEffects = 0;
6131 let isReMaterializable = 1;
6135 multiclass sve_int_index_ii<string asm> {
6136 def _B : sve_int_index_ii<0b00, asm, ZPR8, simm5_8b>;
6137 def _H : sve_int_index_ii<0b01, asm, ZPR16, simm5_16b>;
6138 def _S : sve_int_index_ii<0b10, asm, ZPR32, simm5_32b>;
6139 def _D : sve_int_index_ii<0b11, asm, ZPR64, simm5_64b>;
6141 def : Pat<(nxv16i8 (step_vector simm5_8b_tgt:$imm5b)),
6142 (!cast<Instruction>(NAME # "_B") (i32 0), (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
6143 def : Pat<(nxv8i16 (step_vector simm5_16b_tgt:$imm5b)),
6144 (!cast<Instruction>(NAME # "_H") (i32 0), (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
6145 def : Pat<(nxv4i32 (step_vector simm5_32b_tgt:$imm5b)),
6146 (!cast<Instruction>(NAME # "_S") (i32 0), simm5_32b:$imm5b)>;
6147 def : Pat<(nxv2i64 (step_vector simm5_64b_tgt:$imm5b)),
6148 (!cast<Instruction>(NAME # "_D") (i64 0), simm5_64b:$imm5b)>;
6150 // add(step_vector(step), dup(X)) -> index(X, step).
6151 def : Pat<(add (nxv16i8 (step_vector_oneuse simm5_8b_tgt:$imm5b)), (nxv16i8 (splat_vector(simm5_8b:$imm5)))),
6152 (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
6153 def : Pat<(add (nxv8i16 (step_vector_oneuse simm5_16b_tgt:$imm5b)), (nxv8i16 (splat_vector(simm5_16b:$imm5)))),
6154 (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, (!cast<SDNodeXForm>("trunc_imm") $imm5b))>;
6155 def : Pat<(add (nxv4i32 (step_vector_oneuse simm5_32b_tgt:$imm5b)), (nxv4i32 (splat_vector(simm5_32b:$imm5)))),
6156 (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, simm5_32b:$imm5b)>;
6157 def : Pat<(add (nxv2i64 (step_vector_oneuse simm5_64b_tgt:$imm5b)), (nxv2i64 (splat_vector(simm5_64b:$imm5)))),
6158 (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, simm5_64b:$imm5b)>;
6161 class sve_int_index_ir<bits<2> sz8_64, string asm, ZPRRegOp zprty,
6162 RegisterClass srcRegType, Operand imm_ty>
6163 : I<(outs zprty:$Zd), (ins imm_ty:$imm5, srcRegType:$Rm),
6164 asm, "\t$Zd, $imm5, $Rm",
6165 "", []>, Sched<[]> {
6169 let Inst{31-24} = 0b00000100;
6170 let Inst{23-22} = sz8_64;
6172 let Inst{20-16} = Rm;
6173 let Inst{15-10} = 0b010010;
6174 let Inst{9-5} = imm5;
6177 let hasSideEffects = 0;
6180 multiclass sve_int_index_ir<string asm, SDPatternOperator mulop, SDPatternOperator muloneuseop> {
6181 def _B : sve_int_index_ir<0b00, asm, ZPR8, GPR32, simm5_8b>;
6182 def _H : sve_int_index_ir<0b01, asm, ZPR16, GPR32, simm5_16b>;
6183 def _S : sve_int_index_ir<0b10, asm, ZPR32, GPR32, simm5_32b>;
6184 def _D : sve_int_index_ir<0b11, asm, ZPR64, GPR64, simm5_64b>;
6186 def : Pat<(nxv16i8 (step_vector i8:$imm)),
6187 (!cast<Instruction>(NAME # "_B") (i32 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
6188 def : Pat<(nxv8i16 (step_vector i16:$imm)),
6189 (!cast<Instruction>(NAME # "_H") (i32 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
6190 def : Pat<(nxv4i32 (step_vector i32:$imm)),
6191 (!cast<Instruction>(NAME # "_S") (i32 0), (!cast<Instruction>("MOVi32imm") $imm))>;
6192 def : Pat<(nxv2i64 (step_vector i64:$imm)),
6193 (!cast<Instruction>(NAME # "_D") (i64 0), (!cast<Instruction>("MOVi64imm") $imm))>;
6194 def : Pat<(nxv2i64 (step_vector i64imm_32bit_tgt:$imm)),
6195 (!cast<Instruction>(NAME # "_D") (i64 0), (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
6197 // add(step_vector(step), dup(X)) -> index(X, step).
6198 def : Pat<(add (nxv16i8 (step_vector_oneuse i8:$imm)), (nxv16i8 (splat_vector(simm5_8b:$imm5)))),
6199 (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
6200 def : Pat<(add (nxv8i16 (step_vector_oneuse i16:$imm)), (nxv8i16 (splat_vector(simm5_16b:$imm5)))),
6201 (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
6202 def : Pat<(add (nxv4i32 (step_vector_oneuse i32:$imm)), (nxv4i32 (splat_vector(simm5_32b:$imm5)))),
6203 (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, (!cast<Instruction>("MOVi32imm") $imm))>;
6204 def : Pat<(add (nxv2i64 (step_vector_oneuse i64:$imm)), (nxv2i64 (splat_vector(simm5_64b:$imm5)))),
6205 (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, (!cast<Instruction>("MOVi64imm") $imm))>;
6206 def : Pat<(add (nxv2i64 (step_vector_oneuse i64imm_32bit_tgt:$imm)), (nxv2i64 (splat_vector(simm5_64b:$imm5)))),
6207 (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
6209 // mul(step_vector(1), dup(Y)) -> index(0, Y).
6210 def : Pat<(mulop (nxv16i1 (SVEAllActive)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (splat_vector(i32 GPR32:$Rm)))),
6211 (!cast<Instruction>(NAME # "_B") (i32 0), GPR32:$Rm)>;
6212 def : Pat<(mulop (nxv8i1 (SVEAllActive)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (splat_vector(i32 GPR32:$Rm)))),
6213 (!cast<Instruction>(NAME # "_H") (i32 0), GPR32:$Rm)>;
6214 def : Pat<(mulop (nxv4i1 (SVEAllActive)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (splat_vector(i32 GPR32:$Rm)))),
6215 (!cast<Instruction>(NAME # "_S") (i32 0), GPR32:$Rm)>;
6216 def : Pat<(mulop (nxv2i1 (SVEAllActive)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (splat_vector(i64 GPR64:$Rm)))),
6217 (!cast<Instruction>(NAME # "_D") (i64 0), GPR64:$Rm)>;
6219 // add(mul(step_vector(1), dup(Y)), dup(X)) -> index(X, Y).
6220 def : Pat<(add (muloneuseop (nxv16i1 (SVEAllActive)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (splat_vector(i32 GPR32:$Rm)))), (nxv16i8 (splat_vector(simm5_8b:$imm5)))),
6221 (!cast<Instruction>(NAME # "_B") simm5_8b:$imm5, GPR32:$Rm)>;
6222 def : Pat<(add (muloneuseop (nxv8i1 (SVEAllActive)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (splat_vector(i32 GPR32:$Rm)))), (nxv8i16 (splat_vector(simm5_16b:$imm5)))),
6223 (!cast<Instruction>(NAME # "_H") simm5_16b:$imm5, GPR32:$Rm)>;
6224 def : Pat<(add (muloneuseop (nxv4i1 (SVEAllActive)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (splat_vector(i32 GPR32:$Rm)))), (nxv4i32 (splat_vector(simm5_32b:$imm5)))),
6225 (!cast<Instruction>(NAME # "_S") simm5_32b:$imm5, GPR32:$Rm)>;
6226 def : Pat<(add (muloneuseop (nxv2i1 (SVEAllActive)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (splat_vector(i64 GPR64:$Rm)))), (nxv2i64 (splat_vector(simm5_64b:$imm5)))),
6227 (!cast<Instruction>(NAME # "_D") simm5_64b:$imm5, GPR64:$Rm)>;
6230 class sve_int_index_ri<bits<2> sz8_64, string asm, ZPRRegOp zprty,
6231 RegisterClass srcRegType, Operand imm_ty>
6232 : I<(outs zprty:$Zd), (ins srcRegType:$Rn, imm_ty:$imm5),
6233 asm, "\t$Zd, $Rn, $imm5",
6234 "", []>, Sched<[]> {
6238 let Inst{31-24} = 0b00000100;
6239 let Inst{23-22} = sz8_64;
6241 let Inst{20-16} = imm5;
6242 let Inst{15-10} = 0b010001;
6246 let hasSideEffects = 0;
6249 multiclass sve_int_index_ri<string asm> {
6250 def _B : sve_int_index_ri<0b00, asm, ZPR8, GPR32, simm5_8b>;
6251 def _H : sve_int_index_ri<0b01, asm, ZPR16, GPR32, simm5_16b>;
6252 def _S : sve_int_index_ri<0b10, asm, ZPR32, GPR32, simm5_32b>;
6253 def _D : sve_int_index_ri<0b11, asm, ZPR64, GPR64, simm5_64b>;
6255 // add(step_vector(step), dup(X)) -> index(X, step).
6256 def : Pat<(add (nxv16i8 (step_vector_oneuse simm5_8b_tgt:$imm5)), (nxv16i8 (splat_vector(i32 GPR32:$Rm)))),
6257 (!cast<Instruction>(NAME # "_B") GPR32:$Rm, (!cast<SDNodeXForm>("trunc_imm") $imm5))>;
6258 def : Pat<(add (nxv8i16 (step_vector_oneuse simm5_16b_tgt:$imm5)), (nxv8i16 (splat_vector(i32 GPR32:$Rm)))),
6259 (!cast<Instruction>(NAME # "_H") GPR32:$Rm, (!cast<SDNodeXForm>("trunc_imm") $imm5))>;
6260 def : Pat<(add (nxv4i32 (step_vector_oneuse simm5_32b_tgt:$imm5)), (nxv4i32 (splat_vector(i32 GPR32:$Rm)))),
6261 (!cast<Instruction>(NAME # "_S") GPR32:$Rm, simm5_32b:$imm5)>;
6262 def : Pat<(add (nxv2i64 (step_vector_oneuse simm5_64b_tgt:$imm5)), (nxv2i64 (splat_vector(i64 GPR64:$Rm)))),
6263 (!cast<Instruction>(NAME # "_D") GPR64:$Rm, simm5_64b:$imm5)>;
6266 class sve_int_index_rr<bits<2> sz8_64, string asm, ZPRRegOp zprty,
6267 RegisterClass srcRegType>
6268 : I<(outs zprty:$Zd), (ins srcRegType:$Rn, srcRegType:$Rm),
6269 asm, "\t$Zd, $Rn, $Rm",
6270 "", []>, Sched<[]> {
6274 let Inst{31-24} = 0b00000100;
6275 let Inst{23-22} = sz8_64;
6277 let Inst{20-16} = Rm;
6278 let Inst{15-10} = 0b010011;
6282 let hasSideEffects = 0;
6285 multiclass sve_int_index_rr<string asm, SDPatternOperator mulop> {
6286 def _B : sve_int_index_rr<0b00, asm, ZPR8, GPR32>;
6287 def _H : sve_int_index_rr<0b01, asm, ZPR16, GPR32>;
6288 def _S : sve_int_index_rr<0b10, asm, ZPR32, GPR32>;
6289 def _D : sve_int_index_rr<0b11, asm, ZPR64, GPR64>;
6291 // add(step_vector(step), dup(X)) -> index(X, step).
6292 def : Pat<(add (nxv16i8 (step_vector_oneuse i8:$imm)), (nxv16i8 (splat_vector(i32 GPR32:$Rn)))),
6293 (!cast<Instruction>(NAME # "_B") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
6294 def : Pat<(add (nxv8i16 (step_vector_oneuse i16:$imm)), (nxv8i16 (splat_vector(i32 GPR32:$Rn)))),
6295 (!cast<Instruction>(NAME # "_H") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)))>;
6296 def : Pat<(add (nxv4i32 (step_vector_oneuse i32:$imm)), (nxv4i32 (splat_vector(i32 GPR32:$Rn)))),
6297 (!cast<Instruction>(NAME # "_S") GPR32:$Rn, (!cast<Instruction>("MOVi32imm") $imm))>;
6298 def : Pat<(add (nxv2i64 (step_vector_oneuse i64:$imm)), (nxv2i64 (splat_vector(i64 GPR64:$Rn)))),
6299 (!cast<Instruction>(NAME # "_D") GPR64:$Rn, (!cast<Instruction>("MOVi64imm") $imm))>;
6300 def : Pat<(add (nxv2i64 (step_vector_oneuse i64imm_32bit_tgt:$imm)), (nxv2i64 (splat_vector(i64 GPR64:$Rn)))),
6301 (!cast<Instruction>(NAME # "_D") GPR64:$Rn, (SUBREG_TO_REG (i64 0), (!cast<Instruction>("MOVi32imm") (!cast<SDNodeXForm>("trunc_imm") $imm)), sub_32))>;
6303 // add(mul(step_vector(1), dup(Y)), dup(X)) -> index(X, Y).
6304 def : Pat<(add (mulop (nxv16i1 (SVEAllActive)), (nxv16i8 (step_vector_oneuse (i8 1))), (nxv16i8 (splat_vector(i32 GPR32:$Rm)))), (nxv16i8 (splat_vector(i32 GPR32:$Rn)))),
6305 (!cast<Instruction>(NAME # "_B") GPR32:$Rn, GPR32:$Rm)>;
6306 def : Pat<(add (mulop (nxv8i1 (SVEAllActive)), (nxv8i16 (step_vector_oneuse (i16 1))), (nxv8i16 (splat_vector(i32 GPR32:$Rm)))),(nxv8i16 (splat_vector(i32 GPR32:$Rn)))),
6307 (!cast<Instruction>(NAME # "_H") GPR32:$Rn, GPR32:$Rm)>;
6308 def : Pat<(add (mulop (nxv4i1 (SVEAllActive)), (nxv4i32 (step_vector_oneuse (i32 1))), (nxv4i32 (splat_vector(i32 GPR32:$Rm)))),(nxv4i32 (splat_vector(i32 GPR32:$Rn)))),
6309 (!cast<Instruction>(NAME # "_S") GPR32:$Rn, GPR32:$Rm)>;
6310 def : Pat<(add (mulop (nxv2i1 (SVEAllActive)), (nxv2i64 (step_vector_oneuse (i64 1))), (nxv2i64 (splat_vector(i64 GPR64:$Rm)))),(nxv2i64 (splat_vector(i64 GPR64:$Rn)))),
6311 (!cast<Instruction>(NAME # "_D") GPR64:$Rn, GPR64:$Rm)>;
6314 //===----------------------------------------------------------------------===//
6315 // SVE Bitwise Shift - Predicated Group
6316 //===----------------------------------------------------------------------===//
6318 class sve_int_bin_pred_shift_imm<bits<4> tsz8_64, bits<4> opc, string asm,
6319 ZPRRegOp zprty, Operand immtype>
6320 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, immtype:$imm),
6321 asm, "\t$Zdn, $Pg/m, $_Zdn, $imm",
6327 let Inst{31-24} = 0b00000100;
6328 let Inst{23-22} = tsz8_64{3-2};
6329 let Inst{21-20} = 0b00;
6330 let Inst{19-16} = opc;
6331 let Inst{15-13} = 0b100;
6332 let Inst{12-10} = Pg;
6333 let Inst{9-8} = tsz8_64{1-0};
6334 let Inst{7-5} = imm{2-0}; // imm3
6335 let Inst{4-0} = Zdn;
6337 let Constraints = "$Zdn = $_Zdn";
6338 let DestructiveInstType = DestructiveBinaryImm;
6339 let ElementSize = zprty.ElementSize;
6340 let hasSideEffects = 0;
6343 multiclass sve_int_bin_pred_shift_imm_left<bits<4> opc, string asm, string Ps,
6344 SDPatternOperator op = null_frag> {
6345 def _B : SVEPseudo2Instr<Ps # _B, 1>,
6346 sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
6347 def _H : SVEPseudo2Instr<Ps # _H, 1>,
6348 sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
6349 let Inst{8} = imm{3};
6351 def _S : SVEPseudo2Instr<Ps # _S, 1>,
6352 sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
6353 let Inst{9-8} = imm{4-3};
6355 def _D : SVEPseudo2Instr<Ps # _D, 1>,
6356 sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
6357 let Inst{22} = imm{5};
6358 let Inst{9-8} = imm{4-3};
6361 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i1, nxv16i8, i32, tvecshiftL8, !cast<Instruction>(NAME # _B)>;
6362 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i1, nxv8i16, i32, tvecshiftL16, !cast<Instruction>(NAME # _H)>;
6363 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i1, nxv4i32, i32, tvecshiftL32, !cast<Instruction>(NAME # _S)>;
6364 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i1, nxv2i64, i32, tvecshiftL64, !cast<Instruction>(NAME # _D)>;
6367 // As above but shift amount takes the form of a "vector immediate".
6368 multiclass sve_int_bin_pred_shift_imm_left_dup<bits<4> opc, string asm,
6369 string Ps, SDPatternOperator op>
6370 : sve_int_bin_pred_shift_imm_left<opc, asm, Ps, null_frag> {
6371 def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmL8, !cast<Instruction>(NAME # _B)>;
6372 def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmL16, !cast<Instruction>(NAME # _H)>;
6373 def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmL32, !cast<Instruction>(NAME # _S)>;
6374 def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmL64, !cast<Instruction>(NAME # _D)>;
6377 multiclass sve_int_bin_pred_shift_imm_left_zeroing_bhsd<SDPatternOperator op> {
6378 def _B_ZERO : PredTwoOpImmPseudo<NAME # _B, ZPR8, tvecshiftL8, FalseLanesZero>;
6379 def _H_ZERO : PredTwoOpImmPseudo<NAME # _H, ZPR16, tvecshiftL16, FalseLanesZero>;
6380 def _S_ZERO : PredTwoOpImmPseudo<NAME # _S, ZPR32, tvecshiftL32, FalseLanesZero>;
6381 def _D_ZERO : PredTwoOpImmPseudo<NAME # _D, ZPR64, tvecshiftL64, FalseLanesZero>;
6383 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv16i8, op, nxv16i1, nxv16i8, tvecshiftL8, !cast<Pseudo>(NAME # _B_ZERO)>;
6384 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv8i16, op, nxv8i1, nxv8i16, tvecshiftL16, !cast<Pseudo>(NAME # _H_ZERO)>;
6385 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv4i32, op, nxv4i1, nxv4i32, tvecshiftL32, !cast<Pseudo>(NAME # _S_ZERO)>;
6386 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv2i64, op, nxv2i1, nxv2i64, tvecshiftL64, !cast<Pseudo>(NAME # _D_ZERO)>;
6389 multiclass sve_int_bin_pred_shift_imm_right<bits<4> opc, string asm, string Ps,
6390 SDPatternOperator op = null_frag> {
6391 def _B : SVEPseudo2Instr<Ps # _B, 1>,
6392 sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
6393 def _H : SVEPseudo2Instr<Ps # _H, 1>,
6394 sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
6395 let Inst{8} = imm{3};
6397 def _S : SVEPseudo2Instr<Ps # _S, 1>,
6398 sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
6399 let Inst{9-8} = imm{4-3};
6401 def _D : SVEPseudo2Instr<Ps # _D, 1>,
6402 sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
6403 let Inst{22} = imm{5};
6404 let Inst{9-8} = imm{4-3};
6407 def : SVE_3_Op_Imm_Pat<nxv16i8, op, nxv16i1, nxv16i8, i32, tvecshiftR8, !cast<Instruction>(NAME # _B)>;
6408 def : SVE_3_Op_Imm_Pat<nxv8i16, op, nxv8i1, nxv8i16, i32, tvecshiftR16, !cast<Instruction>(NAME # _H)>;
6409 def : SVE_3_Op_Imm_Pat<nxv4i32, op, nxv4i1, nxv4i32, i32, tvecshiftR32, !cast<Instruction>(NAME # _S)>;
6410 def : SVE_3_Op_Imm_Pat<nxv2i64, op, nxv2i1, nxv2i64, i32, tvecshiftR64, !cast<Instruction>(NAME # _D)>;
6413 // As above but shift amount takes the form of a "vector immediate".
6414 multiclass sve_int_bin_pred_shift_imm_right_dup<bits<4> opc, string asm,
6415 string Ps, SDPatternOperator op>
6416 : sve_int_bin_pred_shift_imm_right<opc, asm, Ps, null_frag> {
6417 def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmR8, !cast<Instruction>(NAME # _B)>;
6418 def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmR16, !cast<Instruction>(NAME # _H)>;
6419 def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmR32, !cast<Instruction>(NAME # _S)>;
6420 def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmR64, !cast<Instruction>(NAME # _D)>;
6423 multiclass sve_int_bin_pred_shift_imm_right_zeroing_bhsd<SDPatternOperator op = null_frag> {
6424 def _B_ZERO : PredTwoOpImmPseudo<NAME # _B, ZPR8, vecshiftR8, FalseLanesZero>;
6425 def _H_ZERO : PredTwoOpImmPseudo<NAME # _H, ZPR16, vecshiftR16, FalseLanesZero>;
6426 def _S_ZERO : PredTwoOpImmPseudo<NAME # _S, ZPR32, vecshiftR32, FalseLanesZero>;
6427 def _D_ZERO : PredTwoOpImmPseudo<NAME # _D, ZPR64, vecshiftR64, FalseLanesZero>;
6429 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv16i8, op, nxv16i1, nxv16i8, tvecshiftR8, !cast<Pseudo>(NAME # _B_ZERO)>;
6430 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv8i16, op, nxv8i1, nxv8i16, tvecshiftR16, !cast<Pseudo>(NAME # _H_ZERO)>;
6431 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv4i32, op, nxv4i1, nxv4i32, tvecshiftR32, !cast<Pseudo>(NAME # _S_ZERO)>;
6432 def : SVE_3_Op_Pat_Shift_Imm_SelZero<nxv2i64, op, nxv2i1, nxv2i64, tvecshiftR64, !cast<Pseudo>(NAME # _D_ZERO)>;
6435 class sve_int_bin_pred_shift<bits<2> sz8_64, bit wide, bits<3> opc,
6436 string asm, ZPRRegOp zprty, ZPRRegOp zprty2>
6437 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty2:$Zm),
6438 asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
6444 let Inst{31-24} = 0b00000100;
6445 let Inst{23-22} = sz8_64;
6446 let Inst{21-20} = 0b01;
6447 let Inst{19} = wide;
6448 let Inst{18-16} = opc;
6449 let Inst{15-13} = 0b100;
6450 let Inst{12-10} = Pg;
6452 let Inst{4-0} = Zdn;
6454 let Constraints = "$Zdn = $_Zdn";
6455 let DestructiveInstType = DestructiveOther;
6456 let ElementSize = zprty.ElementSize;
6457 let hasSideEffects = 0;
6460 multiclass sve_int_bin_pred_shift<bits<3> opc, string asm, string Ps,
6461 SDPatternOperator op, string revname, bit isReverseInstr = 0> {
6462 let DestructiveInstType = DestructiveBinaryCommWithRev in {
6463 def _B : sve_int_bin_pred_shift<0b00, 0b0, opc, asm, ZPR8, ZPR8>,
6464 SVEPseudo2Instr<Ps # _B, 1>, SVEInstr2Rev<NAME # _B, revname # _B, isReverseInstr>;
6465 def _H : sve_int_bin_pred_shift<0b01, 0b0, opc, asm, ZPR16, ZPR16>,
6466 SVEPseudo2Instr<Ps # _H, 1>, SVEInstr2Rev<NAME # _H, revname # _H, isReverseInstr>;
6467 def _S : sve_int_bin_pred_shift<0b10, 0b0, opc, asm, ZPR32, ZPR32>,
6468 SVEPseudo2Instr<Ps # _S, 1>, SVEInstr2Rev<NAME # _S, revname # _S, isReverseInstr>;
6469 def _D : sve_int_bin_pred_shift<0b11, 0b0, opc, asm, ZPR64, ZPR64>,
6470 SVEPseudo2Instr<Ps # _D, 1>, SVEInstr2Rev<NAME # _D, revname # _D, isReverseInstr>;
6472 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
6473 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
6474 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
6475 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
6478 multiclass sve_int_bin_pred_zeroing_bhsd<SDPatternOperator op> {
6479 def _B_ZERO : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesZero>;
6480 def _H_ZERO : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesZero>;
6481 def _S_ZERO : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesZero>;
6482 def _D_ZERO : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesZero>;
6484 def : SVE_3_Op_Pat_SelZero<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _B_ZERO)>;
6485 def : SVE_3_Op_Pat_SelZero<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _H_ZERO)>;
6486 def : SVE_3_Op_Pat_SelZero<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _S_ZERO)>;
6487 def : SVE_3_Op_Pat_SelZero<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _D_ZERO)>;
6490 multiclass sve_int_bin_pred_imm_zeroing_bhsd<SDPatternOperator op,
6491 ComplexPattern imm_b, ComplexPattern imm_h,
6492 ComplexPattern imm_s, ComplexPattern imm_d> {
6493 def _B_ZERO : PredTwoOpImmPseudo<NAME # _B, ZPR8, Operand<i32>, FalseLanesZero>;
6494 def _H_ZERO : PredTwoOpImmPseudo<NAME # _H, ZPR16, Operand<i32>, FalseLanesZero>;
6495 def _S_ZERO : PredTwoOpImmPseudo<NAME # _S, ZPR32, Operand<i32>, FalseLanesZero>;
6496 def _D_ZERO : PredTwoOpImmPseudo<NAME # _D, ZPR64, Operand<i32>, FalseLanesZero>;
6498 def : SVE_2_Op_Imm_Pat_Zero<nxv16i8, op, nxv16i1, i32, imm_b, !cast<Pseudo>(NAME # _B_ZERO)>;
6499 def : SVE_2_Op_Imm_Pat_Zero<nxv8i16, op, nxv8i1, i32, imm_h, !cast<Pseudo>(NAME # _H_ZERO)>;
6500 def : SVE_2_Op_Imm_Pat_Zero<nxv4i32, op, nxv4i1, i32, imm_s, !cast<Pseudo>(NAME # _S_ZERO)>;
6501 def : SVE_2_Op_Imm_Pat_Zero<nxv2i64, op, nxv2i1, i64, imm_d, !cast<Pseudo>(NAME # _D_ZERO)>;
6504 multiclass sve_int_bin_pred_shift_wide<bits<3> opc, string asm,
6505 SDPatternOperator op> {
6506 def _B : sve_int_bin_pred_shift<0b00, 0b1, opc, asm, ZPR8, ZPR64>;
6507 def _H : sve_int_bin_pred_shift<0b01, 0b1, opc, asm, ZPR16, ZPR64>;
6508 def _S : sve_int_bin_pred_shift<0b10, 0b1, opc, asm, ZPR32, ZPR64>;
6510 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
6511 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
6512 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
6515 //===----------------------------------------------------------------------===//
6516 // SVE Shift - Unpredicated Group
6517 //===----------------------------------------------------------------------===//
6519 class sve_int_bin_cons_shift_wide<bits<2> sz8_64, bits<2> opc, string asm,
6521 : I<(outs zprty:$Zd), (ins zprty:$Zn, ZPR64:$Zm),
6522 asm, "\t$Zd, $Zn, $Zm",
6528 let Inst{31-24} = 0b00000100;
6529 let Inst{23-22} = sz8_64;
6531 let Inst{20-16} = Zm;
6532 let Inst{15-12} = 0b1000;
6533 let Inst{11-10} = opc;
6537 let hasSideEffects = 0;
6540 multiclass sve_int_bin_cons_shift_wide<bits<2> opc, string asm, SDPatternOperator op> {
6541 def _B : sve_int_bin_cons_shift_wide<0b00, opc, asm, ZPR8>;
6542 def _H : sve_int_bin_cons_shift_wide<0b01, opc, asm, ZPR16>;
6543 def _S : sve_int_bin_cons_shift_wide<0b10, opc, asm, ZPR32>;
6545 def : SVE_2_Op_Pred_All_Active<nxv16i8, op, nxv16i1, nxv16i8, nxv2i64, !cast<Instruction>(NAME # _B)>;
6546 def : SVE_2_Op_Pred_All_Active<nxv8i16, op, nxv8i1, nxv8i16, nxv2i64, !cast<Instruction>(NAME # _H)>;
6547 def : SVE_2_Op_Pred_All_Active<nxv4i32, op, nxv4i1, nxv4i32, nxv2i64, !cast<Instruction>(NAME # _S)>;
6550 class sve_int_bin_cons_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
6551 ZPRRegOp zprty, Operand immtype>
6552 : I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$imm),
6553 asm, "\t$Zd, $Zn, $imm",
6559 let Inst{31-24} = 0b00000100;
6560 let Inst{23-22} = tsz8_64{3-2};
6562 let Inst{20-19} = tsz8_64{1-0};
6563 let Inst{18-16} = imm{2-0}; // imm3
6564 let Inst{15-12} = 0b1001;
6565 let Inst{11-10} = opc;
6569 let hasSideEffects = 0;
6572 multiclass sve_int_bin_cons_shift_imm_left<bits<2> opc, string asm,
6573 SDPatternOperator op> {
6574 def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
6575 def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
6576 let Inst{19} = imm{3};
6578 def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
6579 let Inst{20-19} = imm{4-3};
6581 def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
6582 let Inst{22} = imm{5};
6583 let Inst{20-19} = imm{4-3};
6586 def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmL8, !cast<Instruction>(NAME # _B)>;
6587 def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmL16, !cast<Instruction>(NAME # _H)>;
6588 def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmL32, !cast<Instruction>(NAME # _S)>;
6589 def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmL64, !cast<Instruction>(NAME # _D)>;
6592 multiclass sve_int_bin_cons_shift_imm_right<bits<2> opc, string asm,
6593 SDPatternOperator op> {
6594 def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
6595 def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
6596 let Inst{19} = imm{3};
6598 def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
6599 let Inst{20-19} = imm{4-3};
6601 def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
6602 let Inst{22} = imm{5};
6603 let Inst{20-19} = imm{4-3};
6606 def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv16i8, op, nxv16i1, i32, SVEShiftImmR8, !cast<Instruction>(NAME # _B)>;
6607 def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv8i16, op, nxv8i1, i32, SVEShiftImmR16, !cast<Instruction>(NAME # _H)>;
6608 def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv4i32, op, nxv4i1, i32, SVEShiftImmR32, !cast<Instruction>(NAME # _S)>;
6609 def : SVE_Shift_DupImm_Any_Predicate_Pat<nxv2i64, op, nxv2i1, i64, SVEShiftImmR64, !cast<Instruction>(NAME # _D)>;
6612 //===----------------------------------------------------------------------===//
6613 // SVE Memory - Store Group
6614 //===----------------------------------------------------------------------===//
6616 class sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
6617 RegisterOperand VecList>
6618 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
6619 asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
6626 let Inst{31-25} = 0b1110010;
6627 let Inst{24-23} = msz;
6628 let Inst{22-21} = esz;
6630 let Inst{19-16} = imm4;
6631 let Inst{15-13} = 0b111;
6632 let Inst{12-10} = Pg;
6636 let hasSideEffects = 0;
6640 multiclass sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
6641 RegisterOperand listty, ZPRRegOp zprty>
6643 def NAME : sve_mem_cst_si<msz, esz, asm, listty>;
6645 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
6646 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
6647 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
6648 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
6649 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
6650 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
6653 class sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
6654 string asm, Operand immtype>
6655 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
6656 asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
6663 let Inst{31-25} = 0b1110010;
6664 let Inst{24-23} = sz;
6665 let Inst{22-21} = nregs;
6667 let Inst{19-16} = imm4;
6668 let Inst{15-13} = 0b111;
6669 let Inst{12-10} = Pg;
6673 let hasSideEffects = 0;
6677 multiclass sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
6678 string asm, Operand immtype> {
6679 def NAME : sve_mem_est_si<sz, nregs, VecList, asm, immtype>;
6681 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
6682 (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
6686 // SVE store multiple structures (quadwords, scalar plus immediate)
6687 class sve_mem_128b_est_si<bits<2> nregs, RegisterOperand VecList,
6688 string asm, Operand immtype>
6689 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
6690 asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
6691 "", []>, Sched<[]> {
6696 let Inst{31-24} = 0b11100100;
6697 let Inst{23-22} = nregs;
6698 let Inst{21-20} = 0b00;
6699 let Inst{19-16} = imm4;
6700 let Inst{15-13} = 0b000;
6701 let Inst{12-10} = Pg;
6705 let hasSideEffects = 0;
6709 multiclass sve_mem_128b_est_si<bits<2> nregs, RegisterOperand VecList,
6710 string asm, Operand immtype> {
6711 def NAME : sve_mem_128b_est_si<nregs, VecList, asm, immtype>;
6713 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
6714 (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
6718 class sve_mem_est_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
6719 string asm, RegisterOperand gprty>
6720 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
6721 asm, "\t$Zt, $Pg, [$Rn, $Rm]",
6728 let Inst{31-25} = 0b1110010;
6729 let Inst{24-23} = sz;
6730 let Inst{22-21} = nregs;
6731 let Inst{20-16} = Rm;
6732 let Inst{15-13} = 0b011;
6733 let Inst{12-10} = Pg;
6737 let hasSideEffects = 0;
6742 // SVE store multiple structures (quadwords, scalar plus scalar)
6743 class sve_mem_128b_est_ss<bits<2> nregs, RegisterOperand VecList,
6744 string asm, RegisterOperand gprty>
6745 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
6746 asm, "\t$Zt, $Pg, [$Rn, $Rm]",
6747 "", []>, Sched<[]> {
6752 let Inst{31-24} = 0b11100100;
6753 let Inst{23-22} = nregs;
6755 let Inst{20-16} = Rm;
6756 let Inst{15-13} = 0b000;
6757 let Inst{12-10} = Pg;
6761 let hasSideEffects = 0;
6766 class sve_mem_cst_ss_base<bits<4> dtype, string asm,
6767 RegisterOperand listty, RegisterOperand gprty>
6768 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
6769 asm, "\t$Zt, $Pg, [$Rn, $Rm]",
6776 let Inst{31-25} = 0b1110010;
6777 let Inst{24-21} = dtype;
6778 let Inst{20-16} = Rm;
6779 let Inst{15-13} = 0b010;
6780 let Inst{12-10} = Pg;
6784 let hasSideEffects = 0;
6788 multiclass sve_mem_cst_ss<bits<4> dtype, string asm,
6789 RegisterOperand listty, ZPRRegOp zprty,
6790 RegisterOperand gprty> {
6791 def NAME : sve_mem_cst_ss_base<dtype, asm, listty, gprty>;
6793 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
6794 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
6797 class sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand VecList>
6798 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
6799 asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
6806 let Inst{31-25} = 0b1110010;
6807 let Inst{24-23} = msz;
6808 let Inst{22-20} = 0b001;
6809 let Inst{19-16} = imm4;
6810 let Inst{15-13} = 0b111;
6811 let Inst{12-10} = Pg;
6815 let hasSideEffects = 0;
6819 multiclass sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand listty,
6821 def NAME : sve_mem_cstnt_si<msz, asm, listty>;
6823 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
6824 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
6825 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
6826 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
6827 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
6828 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
6831 class sve_mem_cstnt_ss_base<bits<2> msz, string asm, RegisterOperand listty,
6832 RegisterOperand gprty>
6833 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
6834 asm, "\t$Zt, $Pg, [$Rn, $Rm]",
6841 let Inst{31-25} = 0b1110010;
6842 let Inst{24-23} = msz;
6843 let Inst{22-21} = 0b00;
6844 let Inst{20-16} = Rm;
6845 let Inst{15-13} = 0b011;
6846 let Inst{12-10} = Pg;
6850 let hasSideEffects = 0;
6854 multiclass sve_mem_cstnt_ss<bits<2> msz, string asm, RegisterOperand listty,
6855 ZPRRegOp zprty, RegisterOperand gprty> {
6856 def NAME : sve_mem_cstnt_ss_base<msz, asm, listty, gprty>;
6858 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
6859 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
6862 class sve2_mem_sstnt_vs_base<bits<3> opc, string asm,
6863 RegisterOperand listty, ZPRRegOp zprty>
6864 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm),
6865 asm, "\t$Zt, $Pg, [$Zn, $Rm]",
6872 let Inst{31-25} = 0b1110010;
6873 let Inst{24-22} = opc;
6875 let Inst{20-16} = Rm;
6876 let Inst{15-13} = 0b001;
6877 let Inst{12-10} = Pg;
6881 let hasSideEffects = 0;
6885 multiclass sve2_mem_sstnt_vs_32_ptrs<bits<3> opc, string asm,
6886 SDPatternOperator op,
6888 def NAME : sve2_mem_sstnt_vs_base<opc, asm, Z_s, ZPR32>;
6890 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]",
6891 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 0>;
6892 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6893 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 0>;
6894 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6895 (!cast<Instruction>(NAME) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 1>;
6897 def : Pat <(op (nxv4i32 ZPR32:$Zt), (nxv4i1 PPR3bAny:$Pg), (nxv4i32 ZPR32:$Zn), (i64 GPR64:$Rm), vt),
6898 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm)>;
6901 multiclass sve2_mem_sstnt_vs_64_ptrs<bits<3> opc, string asm,
6902 SDPatternOperator op,
6904 def NAME : sve2_mem_sstnt_vs_base<opc, asm, Z_d, ZPR64>;
6906 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]",
6907 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 0>;
6908 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6909 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 0>;
6910 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
6911 (!cast<Instruction>(NAME) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
6913 def : Pat <(op (nxv2i64 ZPR64:$Zt), (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64:$Rm), vt),
6914 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
6917 class sve_mem_sst_sv<bits<3> opc, bit xs, bit scaled, string asm,
6918 RegisterOperand VecList, RegisterOperand zprext>
6919 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
6920 asm, "\t$Zt, $Pg, [$Rn, $Zm]",
6927 let Inst{31-25} = 0b1110010;
6928 let Inst{24-22} = opc;
6929 let Inst{21} = scaled;
6930 let Inst{20-16} = Zm;
6934 let Inst{12-10} = Pg;
6938 let hasSideEffects = 0;
6942 multiclass sve_mem_32b_sst_sv_32_scaled<bits<3> opc, string asm,
6943 SDPatternOperator sxtw_op,
6944 SDPatternOperator uxtw_op,
6945 RegisterOperand sxtw_opnd,
6946 RegisterOperand uxtw_opnd,
6948 def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, Z_s, uxtw_opnd>;
6949 def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, Z_s, sxtw_opnd>;
6951 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6952 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
6953 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6954 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
6956 def : Pat<(uxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
6957 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6958 def : Pat<(sxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
6959 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6962 multiclass sve_mem_64b_sst_sv_32_scaled<bits<3> opc, string asm,
6963 SDPatternOperator sxtw_op,
6964 SDPatternOperator uxtw_op,
6965 RegisterOperand sxtw_opnd,
6966 RegisterOperand uxtw_opnd,
6968 def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, Z_d, uxtw_opnd>;
6969 def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, Z_d, sxtw_opnd>;
6971 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6972 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
6973 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6974 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
6976 def : Pat<(uxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
6977 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6978 def : Pat<(sxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
6979 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6982 multiclass sve_mem_64b_sst_sv_32_unscaled<bits<3> opc, string asm,
6983 SDPatternOperator sxtw_op,
6984 SDPatternOperator uxtw_op,
6985 RegisterOperand sxtw_opnd,
6986 RegisterOperand uxtw_opnd,
6988 def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, Z_d, uxtw_opnd>;
6989 def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, Z_d, sxtw_opnd>;
6991 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6992 (!cast<Instruction>(NAME # _UXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
6993 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
6994 (!cast<Instruction>(NAME # _SXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
6996 def : Pat<(uxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
6997 (!cast<Instruction>(NAME # _UXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
6998 def : Pat<(sxtw_op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
6999 (!cast<Instruction>(NAME # _SXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
7002 multiclass sve_mem_32b_sst_sv_32_unscaled<bits<3> opc, string asm,
7003 SDPatternOperator sxtw_op,
7004 SDPatternOperator uxtw_op,
7005 RegisterOperand sxtw_opnd,
7006 RegisterOperand uxtw_opnd,
7008 def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, Z_s, uxtw_opnd>;
7009 def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, Z_s, sxtw_opnd>;
7011 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
7012 (!cast<Instruction>(NAME # _UXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
7013 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
7014 (!cast<Instruction>(NAME # _SXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
7016 def : Pat<(uxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
7017 (!cast<Instruction>(NAME # _UXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
7018 def : Pat<(sxtw_op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt),
7019 (!cast<Instruction>(NAME # _SXTW) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
7022 class sve_mem_sst_sv2<bits<2> msz, bit scaled, string asm,
7023 RegisterOperand zprext>
7024 : I<(outs), (ins Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
7025 asm, "\t$Zt, $Pg, [$Rn, $Zm]",
7032 let Inst{31-25} = 0b1110010;
7033 let Inst{24-23} = msz;
7035 let Inst{21} = scaled;
7036 let Inst{20-16} = Zm;
7037 let Inst{15-13} = 0b101;
7038 let Inst{12-10} = Pg;
7042 let hasSideEffects = 0;
7046 multiclass sve_mem_sst_sv_64_scaled<bits<2> msz, string asm,
7047 SDPatternOperator op,
7048 RegisterOperand zprext,
7050 def _SCALED : sve_mem_sst_sv2<msz, 1, asm, zprext>;
7052 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
7053 (!cast<Instruction>(NAME # _SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
7055 def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt),
7056 (!cast<Instruction>(NAME # _SCALED) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
7059 multiclass sve_mem_sst_sv_64_unscaled<bits<2> msz, string asm,
7060 SDPatternOperator op,
7062 def NAME : sve_mem_sst_sv2<msz, 0, asm, ZPR64ExtLSL8>;
7064 def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
7065 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
7067 def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt),
7068 (!cast<Instruction>(NAME) ZPR:$data, PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
7071 class sve_mem_sst_vi<bits<3> opc, string asm, ZPRRegOp zprty,
7072 RegisterOperand VecList, Operand imm_ty>
7073 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, zprty:$Zn, imm_ty:$imm5),
7074 asm, "\t$Zt, $Pg, [$Zn, $imm5]",
7081 let Inst{31-25} = 0b1110010;
7082 let Inst{24-23} = opc{2-1};
7084 let Inst{21} = opc{0};
7085 let Inst{20-16} = imm5;
7086 let Inst{15-13} = 0b101;
7087 let Inst{12-10} = Pg;
7091 let hasSideEffects = 0;
7095 multiclass sve_mem_32b_sst_vi_ptrs<bits<3> opc, string asm,
7097 SDPatternOperator op,
7099 def _IMM : sve_mem_sst_vi<opc, asm, ZPR32, Z_s, imm_ty>;
7101 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
7102 (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>;
7103 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]",
7104 (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>;
7105 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
7106 (!cast<Instruction>(NAME # _IMM) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
7108 def : Pat<(op (nxv4i32 ZPR:$data), (nxv4i1 PPR:$gp), (nxv4i32 ZPR:$ptrs), imm_ty:$index, vt),
7109 (!cast<Instruction>(NAME # _IMM) ZPR:$data, PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
7112 multiclass sve_mem_64b_sst_vi_ptrs<bits<3> opc, string asm,
7114 SDPatternOperator op,
7116 def _IMM : sve_mem_sst_vi<opc, asm, ZPR64, Z_d, imm_ty>;
7118 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
7119 (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>;
7120 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]",
7121 (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>;
7122 def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
7123 (!cast<Instruction>(NAME # _IMM) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
7125 def : Pat<(op (nxv2i64 ZPR:$data), (nxv2i1 PPR:$gp), (nxv2i64 ZPR:$ptrs), imm_ty:$index, vt),
7126 (!cast<Instruction>(NAME # _IMM) ZPR:$data, PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
7129 class sve_mem_z_spill<string asm>
7130 : I<(outs), (ins ZPRAny:$Zt, GPR64sp:$Rn, simm9:$imm9),
7131 asm, "\t$Zt, [$Rn, $imm9, mul vl]",
7137 let Inst{31-22} = 0b1110010110;
7138 let Inst{21-16} = imm9{8-3};
7139 let Inst{15-13} = 0b010;
7140 let Inst{12-10} = imm9{2-0};
7144 let hasSideEffects = 0;
7148 multiclass sve_mem_z_spill<string asm> {
7149 def NAME : sve_mem_z_spill<asm>;
7151 def : InstAlias<asm # "\t$Zt, [$Rn]",
7152 (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
7155 class sve_mem_p_spill<string asm>
7156 : I<(outs), (ins PPRorPNRAny:$Pt, GPR64sp:$Rn, simm9:$imm9),
7157 asm, "\t$Pt, [$Rn, $imm9, mul vl]",
7163 let Inst{31-22} = 0b1110010110;
7164 let Inst{21-16} = imm9{8-3};
7165 let Inst{15-13} = 0b000;
7166 let Inst{12-10} = imm9{2-0};
7171 let hasSideEffects = 0;
7175 multiclass sve_mem_p_spill<string asm> {
7176 def NAME : sve_mem_p_spill<asm>;
7178 def : InstAlias<asm # "\t$Pt, [$Rn]",
7179 (!cast<Instruction>(NAME) PPRorPNRAny:$Pt, GPR64sp:$Rn, 0), 1>;
7182 //===----------------------------------------------------------------------===//
7183 // SVE Permute - Predicates Group
7184 //===----------------------------------------------------------------------===//
7186 class sve_int_perm_bin_perm_pp<bits<3> opc, bits<2> sz8_64, string asm,
7187 PPRRegOp pprty, SDPatternOperator op>
7188 : I<(outs pprty:$Pd), (ins pprty:$Pn, pprty:$Pm),
7189 asm, "\t$Pd, $Pn, $Pm",
7191 [(set nxv16i1:$Pd, (op nxv16i1:$Pn, nxv16i1:$Pm))]>, Sched<[]> {
7195 let Inst{31-24} = 0b00000101;
7196 let Inst{23-22} = sz8_64;
7197 let Inst{21-20} = 0b10;
7198 let Inst{19-16} = Pm;
7199 let Inst{15-13} = 0b010;
7200 let Inst{12-10} = opc;
7206 let hasSideEffects = 0;
7209 multiclass sve_int_perm_bin_perm_pp<bits<3> opc, string asm,
7210 SDPatternOperator ir_op,
7211 SDPatternOperator op_b16,
7212 SDPatternOperator op_b32,
7213 SDPatternOperator op_b64> {
7214 def _B : sve_int_perm_bin_perm_pp<opc, 0b00, asm, PPR8, ir_op>;
7215 def _H : sve_int_perm_bin_perm_pp<opc, 0b01, asm, PPR16, op_b16>;
7216 def _S : sve_int_perm_bin_perm_pp<opc, 0b10, asm, PPR32, op_b32>;
7217 def _D : sve_int_perm_bin_perm_pp<opc, 0b11, asm, PPR64, op_b64>;
7219 def : SVE_2_Op_Pat<nxv8i1, ir_op, nxv8i1, nxv8i1, !cast<Instruction>(NAME # _H)>;
7220 def : SVE_2_Op_Pat<nxv4i1, ir_op, nxv4i1, nxv4i1, !cast<Instruction>(NAME # _S)>;
7221 def : SVE_2_Op_Pat<nxv2i1, ir_op, nxv2i1, nxv2i1, !cast<Instruction>(NAME # _D)>;
7224 class sve_int_perm_punpk<bit opc, string asm>
7225 : I<(outs PPR16:$Pd), (ins PPR8:$Pn),
7231 let Inst{31-17} = 0b000001010011000;
7233 let Inst{15-9} = 0b0100000;
7238 let hasSideEffects = 0;
7241 multiclass sve_int_perm_punpk<bit opc, string asm, SDPatternOperator op> {
7242 def NAME : sve_int_perm_punpk<opc, asm>;
7244 def : SVE_1_Op_Pat<nxv8i1, op, nxv16i1, !cast<Instruction>(NAME)>;
7245 def : SVE_1_Op_Pat<nxv4i1, op, nxv8i1, !cast<Instruction>(NAME)>;
7246 def : SVE_1_Op_Pat<nxv2i1, op, nxv4i1, !cast<Instruction>(NAME)>;
7249 class sve_int_rdffr_pred<bit s, string asm, SDPatternOperator op = null_frag>
7250 : I<(outs PPR8:$Pd), (ins PPRAny:$Pg),
7251 asm, "\t$Pd, $Pg/z",
7253 [(set (nxv16i1 PPR8:$Pd), (op (nxv16i1 PPRAny:$Pg)))]>, Sched<[]> {
7256 let Inst{31-23} = 0b001001010;
7258 let Inst{21-9} = 0b0110001111000;
7263 let Defs = !if(s, [NZCV], []);
7265 let hasSideEffects = 1;
7268 class sve_int_rdffr_unpred<string asm, SDPatternOperator op> : I<
7269 (outs PPR8:$Pd), (ins),
7272 [(set (nxv16i1 PPR8:$Pd), (op))]>, Sched<[]> {
7274 let Inst{31-4} = 0b0010010100011001111100000000;
7278 let hasSideEffects = 1;
7281 class sve_int_wrffr<string asm, SDPatternOperator op>
7282 : I<(outs), (ins PPR8:$Pn),
7285 [(op (nxv16i1 PPR8:$Pn))]>, Sched<[]> {
7287 let Inst{31-9} = 0b00100101001010001001000;
7289 let Inst{4-0} = 0b00000;
7292 let hasSideEffects = 1;
7295 class sve_int_setffr<string asm, SDPatternOperator op>
7299 [(op)]>, Sched<[]> {
7300 let Inst{31-0} = 0b00100101001011001001000000000000;
7303 let hasSideEffects = 1;
7306 //===----------------------------------------------------------------------===//
7307 // SVE Permute Vector - Predicated Group
7308 //===----------------------------------------------------------------------===//
7310 class sve_int_perm_clast_rz<bits<2> sz8_64, bit ab, string asm,
7311 ZPRRegOp zprty, RegisterClass rt>
7312 : I<(outs rt:$Rdn), (ins PPR3bAny:$Pg, rt:$_Rdn, zprty:$Zm),
7313 asm, "\t$Rdn, $Pg, $_Rdn, $Zm",
7319 let Inst{31-24} = 0b00000101;
7320 let Inst{23-22} = sz8_64;
7321 let Inst{21-17} = 0b11000;
7323 let Inst{15-13} = 0b101;
7324 let Inst{12-10} = Pg;
7326 let Inst{4-0} = Rdn;
7328 let Constraints = "$Rdn = $_Rdn";
7329 let hasSideEffects = 0;
7332 multiclass sve_int_perm_clast_rz<bit ab, string asm, SDPatternOperator op> {
7333 def _B : sve_int_perm_clast_rz<0b00, ab, asm, ZPR8, GPR32>;
7334 def _H : sve_int_perm_clast_rz<0b01, ab, asm, ZPR16, GPR32>;
7335 def _S : sve_int_perm_clast_rz<0b10, ab, asm, ZPR32, GPR32>;
7336 def _D : sve_int_perm_clast_rz<0b11, ab, asm, ZPR64, GPR64>;
7338 def : SVE_3_Op_Pat<i32, op, nxv16i1, i32, nxv16i8, !cast<Instruction>(NAME # _B)>;
7339 def : SVE_3_Op_Pat<i32, op, nxv8i1, i32, nxv8i16, !cast<Instruction>(NAME # _H)>;
7340 def : SVE_3_Op_Pat<i32, op, nxv4i1, i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
7341 def : SVE_3_Op_Pat<i64, op, nxv2i1, i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
7344 class sve_int_perm_clast_vz<bits<2> sz8_64, bit ab, string asm,
7345 ZPRRegOp zprty, RegisterClass rt>
7346 : I<(outs rt:$Vdn), (ins PPR3bAny:$Pg, rt:$_Vdn, zprty:$Zm),
7347 asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
7353 let Inst{31-24} = 0b00000101;
7354 let Inst{23-22} = sz8_64;
7355 let Inst{21-17} = 0b10101;
7357 let Inst{15-13} = 0b100;
7358 let Inst{12-10} = Pg;
7360 let Inst{4-0} = Vdn;
7362 let Constraints = "$Vdn = $_Vdn";
7363 let hasSideEffects = 0;
7366 multiclass sve_int_perm_clast_vz<bit ab, string asm, SDPatternOperator op> {
7367 def _B : sve_int_perm_clast_vz<0b00, ab, asm, ZPR8, FPR8>;
7368 def _H : sve_int_perm_clast_vz<0b01, ab, asm, ZPR16, FPR16>;
7369 def _S : sve_int_perm_clast_vz<0b10, ab, asm, ZPR32, FPR32>;
7370 def _D : sve_int_perm_clast_vz<0b11, ab, asm, ZPR64, FPR64>;
7372 def : SVE_3_Op_Pat<f16, op, nxv8i1, f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
7373 def : SVE_3_Op_Pat<f32, op, nxv4i1, f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
7374 def : SVE_3_Op_Pat<f64, op, nxv2i1, f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
7376 def : SVE_3_Op_Pat<bf16, op, nxv8i1, bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
7379 class sve_int_perm_clast_zz<bits<2> sz8_64, bit ab, string asm,
7381 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
7382 asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
7388 let Inst{31-24} = 0b00000101;
7389 let Inst{23-22} = sz8_64;
7390 let Inst{21-17} = 0b10100;
7392 let Inst{15-13} = 0b100;
7393 let Inst{12-10} = Pg;
7395 let Inst{4-0} = Zdn;
7397 let Constraints = "$Zdn = $_Zdn";
7398 let DestructiveInstType = DestructiveOther;
7399 let ElementSize = ElementSizeNone;
7400 let hasSideEffects = 0;
7403 multiclass sve_int_perm_clast_zz<bit ab, string asm, SDPatternOperator op> {
7404 def _B : sve_int_perm_clast_zz<0b00, ab, asm, ZPR8>;
7405 def _H : sve_int_perm_clast_zz<0b01, ab, asm, ZPR16>;
7406 def _S : sve_int_perm_clast_zz<0b10, ab, asm, ZPR32>;
7407 def _D : sve_int_perm_clast_zz<0b11, ab, asm, ZPR64>;
7409 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
7410 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
7411 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
7412 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
7414 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
7415 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
7416 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
7418 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
7421 class sve_int_perm_last_r<bits<2> sz8_64, bit ab, string asm,
7422 ZPRRegOp zprty, RegisterClass resultRegType>
7423 : I<(outs resultRegType:$Rd), (ins PPR3bAny:$Pg, zprty:$Zn),
7424 asm, "\t$Rd, $Pg, $Zn",
7430 let Inst{31-24} = 0b00000101;
7431 let Inst{23-22} = sz8_64;
7432 let Inst{21-17} = 0b10000;
7434 let Inst{15-13} = 0b101;
7435 let Inst{12-10} = Pg;
7439 let hasSideEffects = 0;
7442 multiclass sve_int_perm_last_r<bit ab, string asm, SDPatternOperator op> {
7443 def _B : sve_int_perm_last_r<0b00, ab, asm, ZPR8, GPR32>;
7444 def _H : sve_int_perm_last_r<0b01, ab, asm, ZPR16, GPR32>;
7445 def _S : sve_int_perm_last_r<0b10, ab, asm, ZPR32, GPR32>;
7446 def _D : sve_int_perm_last_r<0b11, ab, asm, ZPR64, GPR64>;
7448 def : SVE_2_Op_Pat<i32, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
7449 def : SVE_2_Op_Pat<i32, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
7450 def : SVE_2_Op_Pat<i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7451 def : SVE_2_Op_Pat<i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7454 class sve_int_perm_last_v<bits<2> sz8_64, bit ab, string asm,
7455 ZPRRegOp zprty, RegisterClass dstRegtype>
7456 : I<(outs dstRegtype:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
7457 asm, "\t$Vd, $Pg, $Zn",
7463 let Inst{31-24} = 0b00000101;
7464 let Inst{23-22} = sz8_64;
7465 let Inst{21-17} = 0b10001;
7467 let Inst{15-13} = 0b100;
7468 let Inst{12-10} = Pg;
7472 let hasSideEffects = 0;
7475 multiclass sve_int_perm_last_v<bit ab, string asm, SDPatternOperator op> {
7476 def _B : sve_int_perm_last_v<0b00, ab, asm, ZPR8, FPR8>;
7477 def _H : sve_int_perm_last_v<0b01, ab, asm, ZPR16, FPR16>;
7478 def _S : sve_int_perm_last_v<0b10, ab, asm, ZPR32, FPR32>;
7479 def _D : sve_int_perm_last_v<0b11, ab, asm, ZPR64, FPR64>;
7481 def : SVE_2_Op_Pat<f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
7482 def : SVE_2_Op_Pat<f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
7483 def : SVE_2_Op_Pat<f32, op, nxv2i1, nxv2f32, !cast<Instruction>(NAME # _S)>;
7484 def : SVE_2_Op_Pat<f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
7486 def : SVE_2_Op_Pat<bf16, op, nxv8i1, nxv8bf16, !cast<Instruction>(NAME # _H)>;
7489 class sve_int_perm_splice<bits<2> sz8_64, string asm, ZPRRegOp zprty>
7490 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
7491 asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
7497 let Inst{31-24} = 0b00000101;
7498 let Inst{23-22} = sz8_64;
7499 let Inst{21-13} = 0b101100100;
7500 let Inst{12-10} = Pg;
7502 let Inst{4-0} = Zdn;
7504 let Constraints = "$Zdn = $_Zdn";
7505 let DestructiveInstType = DestructiveOther;
7506 let ElementSize = ElementSizeNone;
7507 let hasSideEffects = 0;
7510 multiclass sve_int_perm_splice<string asm, SDPatternOperator op> {
7511 def _B : sve_int_perm_splice<0b00, asm, ZPR8>;
7512 def _H : sve_int_perm_splice<0b01, asm, ZPR16>;
7513 def _S : sve_int_perm_splice<0b10, asm, ZPR32>;
7514 def _D : sve_int_perm_splice<0b11, asm, ZPR64>;
7516 foreach VT = [nxv16i8] in
7517 def : SVE_3_Op_Pat<VT, op, nxv16i1, VT, VT, !cast<Instruction>(NAME # _B)>;
7519 foreach VT = [nxv8i16, nxv8f16, nxv8bf16] in
7520 def : SVE_3_Op_Pat<VT, op, nxv8i1, VT, VT, !cast<Instruction>(NAME # _H)>;
7522 foreach VT = [nxv4i32, nxv4f16, nxv4f32, nxv4bf16] in
7523 def : SVE_3_Op_Pat<VT, op, nxv4i1, VT, VT, !cast<Instruction>(NAME # _S)>;
7525 foreach VT = [nxv2i64, nxv2f16, nxv2f32, nxv2f64, nxv2bf16] in
7526 def : SVE_3_Op_Pat<VT, op, nxv2i1, VT, VT, !cast<Instruction>(NAME # _D)>;
7529 class sve2_int_perm_splice_cons<bits<2> sz8_64, string asm,
7530 ZPRRegOp zprty, RegisterOperand VecList>
7531 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, VecList:$Zn),
7532 asm, "\t$Zd, $Pg, $Zn",
7538 let Inst{31-24} = 0b00000101;
7539 let Inst{23-22} = sz8_64;
7540 let Inst{21-13} = 0b101101100;
7541 let Inst{12-10} = Pg;
7545 let hasSideEffects = 0;
7548 multiclass sve2_int_perm_splice_cons<string asm, SDPatternOperator op> {
7549 def _B : sve2_int_perm_splice_cons<0b00, asm, ZPR8, ZZ_b>;
7550 def _H : sve2_int_perm_splice_cons<0b01, asm, ZPR16, ZZ_h>;
7551 def _S : sve2_int_perm_splice_cons<0b10, asm, ZPR32, ZZ_s>;
7552 def _D : sve2_int_perm_splice_cons<0b11, asm, ZPR64, ZZ_d>;
7554 let AddedComplexity = 2 in {
7555 foreach VT = [nxv16i8] in
7556 def : Pat<(VT (op nxv16i1:$pred, VT:$zn1, VT:$zn2)),
7557 (!cast<Instruction>(NAME # _B)
7558 nxv16i1:$pred, (REG_SEQUENCE ZPR2, VT:$zn1, zsub0, VT:$zn2, zsub1))>;
7560 foreach VT = [nxv8i16, nxv8f16, nxv8bf16] in
7561 def : Pat<(VT (op nxv8i1:$pred, VT:$zn1, VT:$zn2)),
7562 (!cast<Instruction>(NAME # _H)
7563 nxv8i1:$pred, (REG_SEQUENCE ZPR2, VT:$zn1, zsub0, VT:$zn2, zsub1))>;
7565 foreach VT = [nxv4i32, nxv4f16, nxv4f32, nxv4bf16] in
7566 def : Pat<(VT (op nxv4i1:$pred, VT:$zn1, VT:$zn2)),
7567 (!cast<Instruction>(NAME # _S)
7568 nxv4i1:$pred, (REG_SEQUENCE ZPR2, VT:$zn1, zsub0, VT:$zn2, zsub1))>;
7570 foreach VT = [nxv2i64, nxv2f16, nxv2f32, nxv2f64, nxv2bf16] in
7571 def : Pat<(VT (op nxv2i1:$pred, VT:$zn1, VT:$zn2)),
7572 (!cast<Instruction>(NAME # _D)
7573 nxv2i1:$pred, (REG_SEQUENCE ZPR2, VT:$zn1, zsub0, VT:$zn2, zsub1))>;
7577 class sve2_int_perm_expand<bits<2> sz, string asm,
7579 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
7580 asm, "\t$Zd, $Pg, $Zn",
7586 let Inst{31-24} = 0b00000101;
7587 let Inst{23-22} = sz;
7588 let Inst{21-13} = 0b110001100;
7589 let Inst{12-10} = Pg;
7593 let hasSideEffects = 0;
7596 multiclass sve2_int_perm_expand<string asm> {
7597 def _B : sve2_int_perm_expand<0b00, asm, ZPR8>;
7598 def _H : sve2_int_perm_expand<0b01, asm, ZPR16>;
7599 def _S : sve2_int_perm_expand<0b10, asm, ZPR32>;
7600 def _D : sve2_int_perm_expand<0b11, asm, ZPR64>;
7603 class sve_int_perm_rev<bits<2> sz8_64, bits<2> opc, string asm,
7605 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
7606 asm, "\t$Zd, $Pg/m, $Zn",
7612 let Inst{31-24} = 0b00000101;
7613 let Inst{23-22} = sz8_64;
7614 let Inst{21-18} = 0b1001;
7615 let Inst{17-16} = opc;
7616 let Inst{15-13} = 0b100;
7617 let Inst{12-10} = Pg;
7621 let Constraints = "$Zd = $_Zd";
7622 let DestructiveInstType = DestructiveOther;
7623 let ElementSize = zprty.ElementSize;
7624 let hasSideEffects = 0;
7627 multiclass sve_int_perm_rev_rbit<string asm, SDPatternOperator op> {
7628 def _B : sve_int_perm_rev<0b00, 0b11, asm, ZPR8>;
7629 def _H : sve_int_perm_rev<0b01, 0b11, asm, ZPR16>;
7630 def _S : sve_int_perm_rev<0b10, 0b11, asm, ZPR32>;
7631 def _D : sve_int_perm_rev<0b11, 0b11, asm, ZPR64>;
7633 def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
7634 def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
7635 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7636 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7639 multiclass sve_int_perm_rev_revb<string asm, SDPatternOperator op> {
7640 def _H : sve_int_perm_rev<0b01, 0b00, asm, ZPR16>;
7641 def _S : sve_int_perm_rev<0b10, 0b00, asm, ZPR32>;
7642 def _D : sve_int_perm_rev<0b11, 0b00, asm, ZPR64>;
7644 def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
7645 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7646 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7649 multiclass sve_int_perm_rev_revh<string asm, SDPatternOperator op> {
7650 def _S : sve_int_perm_rev<0b10, 0b01, asm, ZPR32>;
7651 def _D : sve_int_perm_rev<0b11, 0b01, asm, ZPR64>;
7653 def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7654 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7657 multiclass sve_int_perm_rev_revw<string asm, SDPatternOperator op> {
7658 def _D : sve_int_perm_rev<0b11, 0b10, asm, ZPR64>;
7660 def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7663 class sve_int_perm_rev_z<bits<2> sz, bits<4> opc, string asm,
7665 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
7666 asm, "\t$Zd, $Pg/z, $Zn",
7672 let Inst{31-24} = 0b00000101;
7673 let Inst{23-22} = sz;
7674 let Inst{21-20} = 0b10;
7675 let Inst{19-16} = opc;
7676 let Inst{15-13} = 0b101;
7677 let Inst{12-10} = Pg;
7681 let hasSideEffects = 0;
7684 multiclass sve_int_perm_rev_rbit_z<string asm, SDPatternOperator op> {
7685 def _B : sve_int_perm_rev_z<0b00, 0b0111, asm, ZPR8>;
7686 def _H : sve_int_perm_rev_z<0b01, 0b0111, asm, ZPR16>;
7687 def _S : sve_int_perm_rev_z<0b10, 0b0111, asm, ZPR32>;
7688 def _D : sve_int_perm_rev_z<0b11, 0b0111, asm, ZPR64>;
7690 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
7691 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
7692 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7693 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7696 multiclass sve_int_perm_rev_revb_z<string asm, SDPatternOperator op> {
7697 def _H : sve_int_perm_rev_z<0b01, 0b0100, asm, ZPR16>;
7698 def _S : sve_int_perm_rev_z<0b10, 0b0100, asm, ZPR32>;
7699 def _D : sve_int_perm_rev_z<0b11, 0b0100, asm, ZPR64>;
7701 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
7702 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7703 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7706 multiclass sve_int_perm_rev_revh_z<string asm, SDPatternOperator op> {
7707 def _S : sve_int_perm_rev_z<0b10, 0b0101, asm, ZPR32>;
7708 def _D : sve_int_perm_rev_z<0b11, 0b0101, asm, ZPR64>;
7710 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7711 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7714 multiclass sve_int_perm_rev_revw_z<string asm, SDPatternOperator op> {
7715 def _D : sve_int_perm_rev_z<0b11, 0b0110, asm, ZPR64>;
7717 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7720 multiclass sve_int_perm_rev_revd_z<string asm, SDPatternOperator op> {
7721 def NAME : sve_int_perm_rev_z<0b00, 0b1110, asm, ZPR128>;
7723 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME)>;
7724 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME)>;
7725 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME)>;
7726 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME)>;
7728 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, !cast<Instruction>(NAME)>;
7729 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME)>;
7730 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME)>;
7731 defm : SVE_1_Op_PassthruUndefZero_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME)>;
7734 class sve_int_perm_cpy_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
7735 RegisterClass srcRegType>
7736 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegType:$Rn),
7737 asm, "\t$Zd, $Pg/m, $Rn",
7743 let Inst{31-24} = 0b00000101;
7744 let Inst{23-22} = sz8_64;
7745 let Inst{21-13} = 0b101000101;
7746 let Inst{12-10} = Pg;
7750 let Constraints = "$Zd = $_Zd";
7751 let DestructiveInstType = DestructiveOther;
7752 let ElementSize = zprty.ElementSize;
7753 let hasSideEffects = 0;
7756 multiclass sve_int_perm_cpy_r<string asm, SDPatternOperator op> {
7757 def _B : sve_int_perm_cpy_r<0b00, asm, ZPR8, GPR32sp>;
7758 def _H : sve_int_perm_cpy_r<0b01, asm, ZPR16, GPR32sp>;
7759 def _S : sve_int_perm_cpy_r<0b10, asm, ZPR32, GPR32sp>;
7760 def _D : sve_int_perm_cpy_r<0b11, asm, ZPR64, GPR64sp>;
7762 def : InstAlias<"mov $Zd, $Pg/m, $Rn",
7763 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
7764 def : InstAlias<"mov $Zd, $Pg/m, $Rn",
7765 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
7766 def : InstAlias<"mov $Zd, $Pg/m, $Rn",
7767 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
7768 def : InstAlias<"mov $Zd, $Pg/m, $Rn",
7769 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, GPR64sp:$Rn), 1>;
7771 def : Pat<(nxv16i8 (op nxv16i1:$pg, i32:$splat, nxv16i8:$passthru)),
7772 (!cast<Instruction>(NAME # _B) $passthru, $pg, $splat)>;
7773 def : Pat<(nxv8i16 (op nxv8i1:$pg, i32:$splat, nxv8i16:$passthru)),
7774 (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
7775 def : Pat<(nxv4i32 (op nxv4i1:$pg, i32:$splat, nxv4i32:$passthru)),
7776 (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
7777 def : Pat<(nxv2i64 (op nxv2i1:$pg, i64:$splat, nxv2i64:$passthru)),
7778 (!cast<Instruction>(NAME # _D) $passthru, $pg, $splat)>;
7781 class sve_int_perm_cpy_v<bits<2> sz8_64, string asm, ZPRRegOp zprty,
7782 RegisterClass srcRegtype>
7783 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegtype:$Vn),
7784 asm, "\t$Zd, $Pg/m, $Vn",
7790 let Inst{31-24} = 0b00000101;
7791 let Inst{23-22} = sz8_64;
7792 let Inst{21-13} = 0b100000100;
7793 let Inst{12-10} = Pg;
7797 let Constraints = "$Zd = $_Zd";
7798 let DestructiveInstType = DestructiveOther;
7799 let ElementSize = zprty.ElementSize;
7800 let hasSideEffects = 0;
7803 multiclass sve_int_perm_cpy_v<string asm, SDPatternOperator op> {
7804 def _B : sve_int_perm_cpy_v<0b00, asm, ZPR8, FPR8>;
7805 def _H : sve_int_perm_cpy_v<0b01, asm, ZPR16, FPR16>;
7806 def _S : sve_int_perm_cpy_v<0b10, asm, ZPR32, FPR32>;
7807 def _D : sve_int_perm_cpy_v<0b11, asm, ZPR64, FPR64>;
7809 def : InstAlias<"mov $Zd, $Pg/m, $Vn",
7810 (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, FPR8:$Vn), 1>;
7811 def : InstAlias<"mov $Zd, $Pg/m, $Vn",
7812 (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, FPR16:$Vn), 1>;
7813 def : InstAlias<"mov $Zd, $Pg/m, $Vn",
7814 (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, FPR32:$Vn), 1>;
7815 def : InstAlias<"mov $Zd, $Pg/m, $Vn",
7816 (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, FPR64:$Vn), 1>;
7818 def : Pat<(nxv8f16 (op nxv8i1:$pg, f16:$splat, nxv8f16:$passthru)),
7819 (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
7820 def : Pat<(nxv4f16 (op nxv4i1:$pg, f16:$splat, nxv4f16:$passthru)),
7821 (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
7822 def : Pat<(nxv2f16 (op nxv2i1:$pg, f16:$splat, nxv2f16:$passthru)),
7823 (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
7824 def : Pat<(nxv2f32 (op nxv2i1:$pg, f32:$splat, nxv2f32:$passthru)),
7825 (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
7826 def : Pat<(nxv4f32 (op nxv4i1:$pg, f32:$splat, nxv4f32:$passthru)),
7827 (!cast<Instruction>(NAME # _S) $passthru, $pg, $splat)>;
7828 def : Pat<(nxv2f64 (op nxv2i1:$pg, f64:$splat, nxv2f64:$passthru)),
7829 (!cast<Instruction>(NAME # _D) $passthru, $pg, $splat)>;
7831 def : Pat<(nxv8bf16 (op nxv8i1:$pg, bf16:$splat, nxv8bf16:$passthru)),
7832 (!cast<Instruction>(NAME # _H) $passthru, $pg, $splat)>;
7835 class sve_int_perm_compact<bits<2> sz, string asm, ZPRRegOp zprty>
7836 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
7837 asm, "\t$Zd, $Pg, $Zn",
7843 let Inst{31-24} = 0b00000101;
7844 let Inst{23-22} = sz;
7845 let Inst{21-13} = 0b100001100;
7846 let Inst{12-10} = Pg;
7850 let hasSideEffects = 0;
7853 multiclass sve_int_perm_compact_sd<string asm, SDPatternOperator op> {
7854 def _S : sve_int_perm_compact<0b10, asm, ZPR32>;
7855 def _D : sve_int_perm_compact<0b11, asm, ZPR64>;
7857 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
7858 def : SVE_2_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
7859 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
7860 def : SVE_2_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
7863 multiclass sve_int_perm_compact_bh<string asm> {
7864 def _B : sve_int_perm_compact<0b00, asm, ZPR8>;
7865 def _H : sve_int_perm_compact<0b01, asm, ZPR16>;
7868 //===----------------------------------------------------------------------===//
7869 // SVE Memory - Contiguous Load Group
7870 //===----------------------------------------------------------------------===//
7872 class sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
7873 RegisterOperand VecList>
7874 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
7875 asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
7882 let Inst{31-25} = 0b1010010;
7883 let Inst{24-21} = dtype;
7885 let Inst{19-16} = imm4;
7886 let Inst{15-13} = 0b101;
7887 let Inst{12-10} = Pg;
7891 let Defs = !if(nf, [FFR], []);
7892 let Uses = !if(nf, [FFR], []);
7893 let hasSideEffects = nf;
7897 multiclass sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
7898 RegisterOperand listty, ZPRRegOp zprty> {
7899 def NAME : sve_mem_cld_si_base<dtype, nf, asm, listty>;
7901 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
7902 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
7903 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
7904 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
7905 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
7906 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
7909 multiclass sve_mem_cld_si<bits<4> dtype, string asm, RegisterOperand listty,
7911 : sve_mem_cld_si_base<dtype, 0, asm, listty, zprty>;
7913 multiclass sve_mem_cldnf_si<bits<4> dtype, string asm, RegisterOperand listty,
7915 : sve_mem_cld_si_base<dtype, 1, asm, listty, zprty>;
7917 class sve_mem_cldnt_si_base<bits<2> msz, string asm, RegisterOperand VecList>
7918 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
7919 asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
7926 let Inst{31-25} = 0b1010010;
7927 let Inst{24-23} = msz;
7928 let Inst{22-20} = 0b000;
7929 let Inst{19-16} = imm4;
7930 let Inst{15-13} = 0b111;
7931 let Inst{12-10} = Pg;
7935 let hasSideEffects = 0;
7939 multiclass sve_mem_cldnt_si<bits<2> msz, string asm, RegisterOperand listty,
7941 def NAME : sve_mem_cldnt_si_base<msz, asm, listty>;
7943 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
7944 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
7945 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
7946 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
7947 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
7948 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
7951 class sve_mem_cldnt_ss_base<bits<2> msz, string asm, RegisterOperand VecList,
7952 RegisterOperand gprty>
7953 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
7954 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
7961 let Inst{31-25} = 0b1010010;
7962 let Inst{24-23} = msz;
7963 let Inst{22-21} = 0b00;
7964 let Inst{20-16} = Rm;
7965 let Inst{15-13} = 0b110;
7966 let Inst{12-10} = Pg;
7970 let hasSideEffects = 0;
7974 multiclass sve_mem_cldnt_ss<bits<2> msz, string asm, RegisterOperand listty,
7975 ZPRRegOp zprty, RegisterOperand gprty> {
7976 def NAME : sve_mem_cldnt_ss_base<msz, asm, listty, gprty>;
7978 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
7979 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
7982 class sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand VecList>
7983 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4),
7984 asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> {
7989 let Inst{31-25} = 0b1010010;
7990 let Inst{24-23} = sz;
7991 let Inst{22-20} = 0;
7992 let Inst{19-16} = imm4;
7993 let Inst{15-13} = 0b001;
7994 let Inst{12-10} = Pg;
7998 let hasSideEffects = 0;
8002 multiclass sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand listty,
8004 def NAME : sve_mem_ldqr_si<sz, asm, listty>;
8005 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
8006 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
8007 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
8008 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
8009 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]",
8010 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4), 0>;
8013 class sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand VecList,
8014 RegisterOperand gprty>
8015 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
8016 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> {
8021 let Inst{31-25} = 0b1010010;
8022 let Inst{24-23} = sz;
8023 let Inst{22-21} = 0;
8024 let Inst{20-16} = Rm;
8025 let Inst{15-13} = 0;
8026 let Inst{12-10} = Pg;
8030 let hasSideEffects = 0;
8034 multiclass sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand listty,
8035 ZPRRegOp zprty, RegisterOperand gprty> {
8036 def NAME : sve_mem_ldqr_ss<sz, asm, listty, gprty>;
8038 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
8039 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
8042 class sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
8043 RegisterOperand VecList, Operand immtype>
8044 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6),
8045 asm, "\t$Zt, $Pg/z, [$Rn, $imm6]",
8052 let Inst{31-25} = 0b1000010;
8053 let Inst{24-23} = dtypeh;
8055 let Inst{21-16} = imm6;
8057 let Inst{14-13} = dtypel;
8058 let Inst{12-10} = Pg;
8062 let hasSideEffects = 0;
8066 multiclass sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
8067 RegisterOperand zlistty, ZPRRegOp zprty, Operand immtype> {
8068 def NAME : sve_mem_ld_dup<dtypeh, dtypel, asm, zlistty, immtype>;
8070 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
8071 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
8072 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm6]",
8073 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6), 0>;
8074 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
8075 (!cast<Instruction>(NAME) zlistty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
8078 class sve_mem_cld_ss_base<bits<4> dtype, bit ff, dag iops, string asm,
8079 RegisterOperand VecList>
8080 : I<(outs VecList:$Zt), iops,
8081 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
8088 let Inst{31-25} = 0b1010010;
8089 let Inst{24-21} = dtype;
8090 let Inst{20-16} = Rm;
8091 let Inst{15-14} = 0b01;
8093 let Inst{12-10} = Pg;
8097 let Defs = !if(ff, [FFR], []);
8098 let Uses = !if(ff, [FFR], []);
8099 let hasSideEffects = ff;
8103 multiclass sve_mem_cld_ss<bits<4> dtype, string asm, RegisterOperand listty,
8104 ZPRRegOp zprty, RegisterOperand gprty> {
8105 def NAME : sve_mem_cld_ss_base<dtype, 0, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
8108 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
8109 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
8112 multiclass sve_mem_cldff_ss<bits<4> dtype, string asm, RegisterOperand listty,
8113 ZPRRegOp zprty, RegisterOperand gprty> {
8114 def NAME : sve_mem_cld_ss_base<dtype, 1, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), asm, listty>;
8116 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
8117 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
8119 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
8120 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 1>;
8122 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
8123 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 0>;
8126 class sve_mem_eld_si<bits<2> sz, bits<3> nregs, RegisterOperand VecList,
8127 string asm, Operand immtype>
8128 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
8129 asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
8136 let Inst{31-25} = 0b1010010;
8137 let Inst{24-23} = sz;
8138 let Inst{22-21} = nregs{1-0};
8139 let Inst{20} = nregs{2};
8140 let Inst{19-16} = imm4;
8141 let Inst{15-13} = 0b111;
8142 let Inst{12-10} = Pg;
8146 let hasSideEffects = 0;
8150 multiclass sve_mem_eld_si<bits<2> sz, bits<3> nregs, RegisterOperand VecList,
8151 string asm, Operand immtype> {
8152 def NAME : sve_mem_eld_si<sz, nregs, VecList, asm, immtype>;
8154 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
8155 (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
8159 class sve_mem_eld_ss<bits<2> sz, bits<3> nregs, RegisterOperand VecList,
8160 string asm, RegisterOperand gprty>
8161 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
8162 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
8169 let Inst{31-25} = 0b1010010;
8170 let Inst{24-23} = sz;
8171 let Inst{22-21} = nregs{1-0};
8172 let Inst{20-16} = Rm;
8174 let Inst{14} = nregs{2};
8176 let Inst{12-10} = Pg;
8180 let hasSideEffects = 0;
8184 //===----------------------------------------------------------------------===//
8185 // SVE Memory - 32-bit Gather and Unsized Contiguous Group
8186 //===----------------------------------------------------------------------===//
8188 // bit xs is '1' if offsets are signed
8189 // bit scaled is '1' if the offsets are scaled
8190 class sve_mem_32b_gld_sv<bits<4> opc, bit xs, bit scaled, string asm,
8191 RegisterOperand zprext>
8192 : I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
8193 asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
8200 let Inst{31-25} = 0b1000010;
8201 let Inst{24-23} = opc{3-2};
8203 let Inst{21} = scaled;
8204 let Inst{20-16} = Zm;
8206 let Inst{14-13} = opc{1-0};
8207 let Inst{12-10} = Pg;
8212 let Defs = !if(!eq(opc{0}, 1), [FFR], []);
8213 let Uses = !if(!eq(opc{0}, 1), [FFR], []);
8214 let hasSideEffects = opc{0};
8218 multiclass sve_mem_32b_gld_sv_32_scaled<bits<4> opc, string asm,
8219 SDPatternOperator sxtw_op,
8220 SDPatternOperator uxtw_op,
8221 RegisterOperand sxtw_opnd,
8222 RegisterOperand uxtw_opnd,
8224 def _UXTW_SCALED : sve_mem_32b_gld_sv<opc, 0, 1, asm, uxtw_opnd>;
8225 def _SXTW_SCALED : sve_mem_32b_gld_sv<opc, 1, 1, asm, sxtw_opnd>;
8227 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8228 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
8229 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8230 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
8232 def : Pat<(nxv4i32 (uxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$indices), vt)),
8233 (!cast<Instruction>(NAME # _UXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
8234 def : Pat<(nxv4i32 (sxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$indices), vt)),
8235 (!cast<Instruction>(NAME # _SXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
8238 multiclass sve_mem_32b_gld_vs_32_unscaled<bits<4> opc, string asm,
8239 SDPatternOperator sxtw_op,
8240 SDPatternOperator uxtw_op,
8241 RegisterOperand sxtw_opnd,
8242 RegisterOperand uxtw_opnd,
8244 def _UXTW : sve_mem_32b_gld_sv<opc, 0, 0, asm, uxtw_opnd>;
8245 def _SXTW : sve_mem_32b_gld_sv<opc, 1, 0, asm, sxtw_opnd>;
8247 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8248 (!cast<Instruction>(NAME # _UXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
8249 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8250 (!cast<Instruction>(NAME # _SXTW) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
8252 def : Pat<(nxv4i32 (uxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt)),
8253 (!cast<Instruction>(NAME # _UXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
8254 def : Pat<(nxv4i32 (sxtw_op (nxv4i1 PPR:$gp), GPR64sp:$base, (nxv4i32 ZPR:$offsets), vt)),
8255 (!cast<Instruction>(NAME # _SXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
8259 class sve_mem_32b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
8260 : I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
8261 asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
8268 let Inst{31-25} = 0b1000010;
8269 let Inst{24-23} = opc{3-2};
8270 let Inst{22-21} = 0b01;
8271 let Inst{20-16} = imm5;
8273 let Inst{14-13} = opc{1-0};
8274 let Inst{12-10} = Pg;
8279 let Defs = !if(!eq(opc{0}, 1), [FFR], []);
8280 let Uses = !if(!eq(opc{0}, 1), [FFR], []);
8281 let hasSideEffects = opc{0};
8285 multiclass sve_mem_32b_gld_vi_32_ptrs<bits<4> opc, string asm, Operand imm_ty,
8286 SDPatternOperator op, ValueType vt> {
8287 def _IMM : sve_mem_32b_gld_vi<opc, asm, imm_ty>;
8289 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8290 (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>;
8291 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
8292 (!cast<Instruction>(NAME # _IMM) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>;
8293 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8294 (!cast<Instruction>(NAME # _IMM) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
8296 def : Pat<(nxv4i32 (op (nxv4i1 PPR:$gp), (nxv4i32 ZPR:$ptrs), imm_ty:$index, vt)),
8297 (!cast<Instruction>(NAME # _IMM) PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
8300 class sve_mem_prfm_si<bits<2> msz, string asm>
8301 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, simm6s1:$imm6),
8302 asm, "\t$prfop, $Pg, [$Rn, $imm6, mul vl]",
8309 let Inst{31-22} = 0b1000010111;
8310 let Inst{21-16} = imm6;
8312 let Inst{14-13} = msz;
8313 let Inst{12-10} = Pg;
8316 let Inst{3-0} = prfop;
8318 let hasSideEffects = 1;
8321 multiclass sve_mem_prfm_si<bits<2> msz, string asm> {
8322 def NAME : sve_mem_prfm_si<msz, asm>;
8324 def : InstAlias<asm # "\t$prfop, $Pg, [$Rn]",
8325 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
8328 class sve_mem_prfm_ss<bits<3> opc, string asm, RegisterOperand gprty>
8329 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
8330 asm, "\t$prfop, $Pg, [$Rn, $Rm]",
8337 let Inst{31-25} = 0b1000010;
8338 let Inst{24-23} = opc{2-1};
8339 let Inst{22-21} = 0b00;
8340 let Inst{20-16} = Rm;
8342 let Inst{14} = opc{0};
8344 let Inst{12-10} = Pg;
8347 let Inst{3-0} = prfop;
8349 let hasSideEffects = 1;
8352 class sve_mem_32b_prfm_sv<bits<2> msz, bit xs, string asm,
8353 RegisterOperand zprext>
8354 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
8355 asm, "\t$prfop, $Pg, [$Rn, $Zm]",
8362 let Inst{31-23} = 0b100001000;
8365 let Inst{20-16} = Zm;
8367 let Inst{14-13} = msz;
8368 let Inst{12-10} = Pg;
8371 let Inst{3-0} = prfop;
8373 let hasSideEffects = 1;
8376 multiclass sve_mem_32b_prfm_sv_scaled<bits<2> msz, string asm,
8377 RegisterOperand sxtw_opnd,
8378 RegisterOperand uxtw_opnd,
8379 SDPatternOperator op_sxtw,
8380 SDPatternOperator op_uxtw> {
8381 def _UXTW_SCALED : sve_mem_32b_prfm_sv<msz, 0, asm, uxtw_opnd>;
8382 def _SXTW_SCALED : sve_mem_32b_prfm_sv<msz, 1, asm, sxtw_opnd>;
8384 def : Pat<(op_uxtw (nxv4i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv4i32 uxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
8385 (!cast<Instruction>(NAME # _UXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
8387 def : Pat<(op_sxtw (nxv4i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv4i32 sxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
8388 (!cast<Instruction>(NAME # _SXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
8391 class sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
8392 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
8393 asm, "\t$prfop, $Pg, [$Zn, $imm5]",
8400 let Inst{31-25} = 0b1000010;
8401 let Inst{24-23} = msz;
8402 let Inst{22-21} = 0b00;
8403 let Inst{20-16} = imm5;
8404 let Inst{15-13} = 0b111;
8405 let Inst{12-10} = Pg;
8408 let Inst{3-0} = prfop;
8410 let hasSideEffects = 1;
8413 multiclass sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty, SDPatternOperator op> {
8414 def NAME : sve_mem_32b_prfm_vi<msz, asm, imm_ty>;
8416 def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
8417 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
8419 def : Pat<(op (nxv4i1 PPR_3b:$Pg), (nxv4i32 ZPR32:$Zn), (i64 imm_ty:$imm), (i32 sve_prfop:$prfop)),
8420 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR_3b:$Pg, ZPR32:$Zn, imm_ty:$imm)>;
8423 class sve_mem_z_fill<string asm>
8424 : I<(outs ZPRAny:$Zt), (ins GPR64sp:$Rn, simm9:$imm9),
8425 asm, "\t$Zt, [$Rn, $imm9, mul vl]",
8431 let Inst{31-22} = 0b1000010110;
8432 let Inst{21-16} = imm9{8-3};
8433 let Inst{15-13} = 0b010;
8434 let Inst{12-10} = imm9{2-0};
8438 let hasSideEffects = 0;
8442 multiclass sve_mem_z_fill<string asm> {
8443 def NAME : sve_mem_z_fill<asm>;
8445 def : InstAlias<asm # "\t$Zt, [$Rn]",
8446 (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
8449 class sve_mem_p_fill<string asm>
8450 : I<(outs PPRorPNRAny:$Pt), (ins GPR64sp:$Rn, simm9:$imm9),
8451 asm, "\t$Pt, [$Rn, $imm9, mul vl]",
8457 let Inst{31-22} = 0b1000010110;
8458 let Inst{21-16} = imm9{8-3};
8459 let Inst{15-13} = 0b000;
8460 let Inst{12-10} = imm9{2-0};
8465 let hasSideEffects = 0;
8469 multiclass sve_mem_p_fill<string asm> {
8470 def NAME : sve_mem_p_fill<asm>;
8472 def : InstAlias<asm # "\t$Pt, [$Rn]",
8473 (!cast<Instruction>(NAME) PPRorPNRAny:$Pt, GPR64sp:$Rn, 0), 1>;
8476 class sve2_mem_gldnt_vs_base<bits<5> opc, dag iops, string asm,
8477 RegisterOperand VecList>
8478 : I<(outs VecList:$Zt), iops,
8479 asm, "\t$Zt, $Pg/z, [$Zn, $Rm]",
8487 let Inst{30} = opc{4};
8488 let Inst{29-25} = 0b00010;
8489 let Inst{24-23} = opc{3-2};
8490 let Inst{22-21} = 0b00;
8491 let Inst{20-16} = Rm;
8493 let Inst{14-13} = opc{1-0};
8494 let Inst{12-10} = Pg;
8498 let hasSideEffects = 0;
8502 multiclass sve2_mem_gldnt_vs_32_ptrs<bits<5> opc, string asm,
8503 SDPatternOperator op,
8505 def NAME : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), asm, Z_s>;
8507 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]",
8508 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, GPR64:$Rm), 0>;
8509 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8510 (!cast<Instruction>(NAME) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 0>;
8511 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8512 (!cast<Instruction>(NAME) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, XZR), 1>;
8514 def : Pat <(nxv4i32 (op (nxv4i1 PPR3bAny:$Pg), (nxv4i32 ZPR32:$Zd), (i64 GPR64:$Rm), vt)),
8515 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR32:$Zd, GPR64:$Rm)>;
8518 multiclass sve2_mem_gldnt_vs_64_ptrs<bits<5> opc, string asm,
8519 SDPatternOperator op,
8521 def NAME : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), asm, Z_d>;
8523 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]",
8524 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm), 0>;
8525 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8526 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 0>;
8527 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8528 (!cast<Instruction>(NAME) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
8530 def : Pat <(nxv2i64 (op (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zd), (i64 GPR64:$Rm), vt)),
8531 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zd, GPR64:$Rm)>;
8534 //===----------------------------------------------------------------------===//
8535 // SVE Memory - 64-bit Gather Group
8536 //===----------------------------------------------------------------------===//
8538 // bit xs is '1' if offsets are signed
8539 // bit scaled is '1' if the offsets are scaled
8540 // bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
8541 class sve_mem_64b_gld_sv<bits<4> opc, bit xs, bit scaled, bit lsl, string asm,
8542 RegisterOperand zprext>
8543 : I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
8544 asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
8551 let Inst{31-25} = 0b1100010;
8552 let Inst{24-23} = opc{3-2};
8554 let Inst{21} = scaled;
8555 let Inst{20-16} = Zm;
8557 let Inst{14-13} = opc{1-0};
8558 let Inst{12-10} = Pg;
8563 let Defs = !if(!eq(opc{0}, 1), [FFR], []);
8564 let Uses = !if(!eq(opc{0}, 1), [FFR], []);
8565 let hasSideEffects = opc{0};
8569 multiclass sve_mem_64b_gld_sv_32_scaled<bits<4> opc, string asm,
8570 SDPatternOperator sxtw_op,
8571 SDPatternOperator uxtw_op,
8572 RegisterOperand sxtw_opnd,
8573 RegisterOperand uxtw_opnd,
8575 def _UXTW_SCALED : sve_mem_64b_gld_sv<opc, 0, 1, 0, asm, uxtw_opnd>;
8576 def _SXTW_SCALED : sve_mem_64b_gld_sv<opc, 1, 1, 0, asm, sxtw_opnd>;
8578 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8579 (!cast<Instruction>(NAME # _UXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
8580 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8581 (!cast<Instruction>(NAME # _SXTW_SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
8583 def : Pat<(nxv2i64 (uxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
8584 (!cast<Instruction>(NAME # _UXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
8585 def : Pat<(nxv2i64 (sxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
8586 (!cast<Instruction>(NAME # _SXTW_SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
8589 multiclass sve_mem_64b_gld_vs_32_unscaled<bits<4> opc, string asm,
8590 SDPatternOperator sxtw_op,
8591 SDPatternOperator uxtw_op,
8592 RegisterOperand sxtw_opnd,
8593 RegisterOperand uxtw_opnd,
8595 def _UXTW : sve_mem_64b_gld_sv<opc, 0, 0, 0, asm, uxtw_opnd>;
8596 def _SXTW : sve_mem_64b_gld_sv<opc, 1, 0, 0, asm, sxtw_opnd>;
8598 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8599 (!cast<Instruction>(NAME # _UXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
8600 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8601 (!cast<Instruction>(NAME # _SXTW) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
8603 def : Pat<(nxv2i64 (uxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
8604 (!cast<Instruction>(NAME # _UXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
8605 def : Pat<(nxv2i64 (sxtw_op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
8606 (!cast<Instruction>(NAME # _SXTW) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
8609 multiclass sve_mem_64b_gld_sv2_64_scaled<bits<4> opc, string asm,
8610 SDPatternOperator op,
8611 RegisterOperand zprext, ValueType vt> {
8612 def _SCALED : sve_mem_64b_gld_sv<opc, 1, 1, 1, asm, zprext>;
8614 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8615 (!cast<Instruction>(NAME # _SCALED) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
8617 def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$indices), vt)),
8618 (!cast<Instruction>(NAME # _SCALED) PPR:$gp, GPR64sp:$base, ZPR:$indices)>;
8621 multiclass sve_mem_64b_gld_vs2_64_unscaled<bits<4> opc, string asm,
8622 SDPatternOperator op, ValueType vt> {
8623 def NAME : sve_mem_64b_gld_sv<opc, 1, 0, 1, asm, ZPR64ExtLSL8>;
8625 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
8626 (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
8628 def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), GPR64sp:$base, (nxv2i64 ZPR:$offsets), vt)),
8629 (!cast<Instruction>(NAME) PPR:$gp, GPR64sp:$base, ZPR:$offsets)>;
8632 class sve_mem_64b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
8633 : I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
8634 asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
8641 let Inst{31-25} = 0b1100010;
8642 let Inst{24-23} = opc{3-2};
8643 let Inst{22-21} = 0b01;
8644 let Inst{20-16} = imm5;
8646 let Inst{14-13} = opc{1-0};
8647 let Inst{12-10} = Pg;
8651 let Defs = !if(!eq(opc{0}, 1), [FFR], []);
8652 let Uses = !if(!eq(opc{0}, 1), [FFR], []);
8653 let hasSideEffects = opc{0};
8657 multiclass sve_mem_64b_gld_vi_64_ptrs<bits<4> opc, string asm, Operand imm_ty,
8658 SDPatternOperator op, ValueType vt> {
8659 def _IMM : sve_mem_64b_gld_vi<opc, asm, imm_ty>;
8661 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8662 (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>;
8663 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
8664 (!cast<Instruction>(NAME # _IMM) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>;
8665 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
8666 (!cast<Instruction>(NAME # _IMM) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
8668 def : Pat<(nxv2i64 (op (nxv2i1 PPR:$gp), (nxv2i64 ZPR:$ptrs), imm_ty:$index, vt)),
8669 (!cast<Instruction>(NAME # _IMM) PPR:$gp, ZPR:$ptrs, imm_ty:$index)>;
8672 // bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
8673 class sve_mem_64b_prfm_sv<bits<2> msz, bit xs, bit lsl, string asm,
8674 RegisterOperand zprext>
8675 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
8676 asm, "\t$prfop, $Pg, [$Rn, $Zm]",
8683 let Inst{31-23} = 0b110001000;
8686 let Inst{20-16} = Zm;
8688 let Inst{14-13} = msz;
8689 let Inst{12-10} = Pg;
8692 let Inst{3-0} = prfop;
8694 let hasSideEffects = 1;
8697 multiclass sve_mem_64b_prfm_sv_ext_scaled<bits<2> msz, string asm,
8698 RegisterOperand sxtw_opnd,
8699 RegisterOperand uxtw_opnd,
8700 SDPatternOperator op_sxtw,
8701 SDPatternOperator op_uxtw> {
8702 def _UXTW_SCALED : sve_mem_64b_prfm_sv<msz, 0, 0, asm, uxtw_opnd>;
8703 def _SXTW_SCALED : sve_mem_64b_prfm_sv<msz, 1, 0, asm, sxtw_opnd>;
8705 def : Pat<(op_uxtw (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 uxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
8706 (!cast<Instruction>(NAME # _UXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm)>;
8708 def : Pat<(op_sxtw (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 sxtw_opnd:$Zm), (i32 sve_prfop:$prfop)),
8709 (!cast<Instruction>(NAME # _SXTW_SCALED) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm)>;
8713 multiclass sve_mem_64b_prfm_sv_lsl_scaled<bits<2> msz, string asm,
8714 RegisterOperand zprext, SDPatternOperator frag> {
8715 def NAME : sve_mem_64b_prfm_sv<msz, 1, 1, asm, zprext>;
8717 def : Pat<(frag (nxv2i1 PPR3bAny:$Pg), (i64 GPR64sp:$Rn), (nxv2i64 zprext:$Zm), (i32 sve_prfop:$prfop)),
8718 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm)>;
8722 class sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
8723 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
8724 asm, "\t$prfop, $Pg, [$Zn, $imm5]",
8731 let Inst{31-25} = 0b1100010;
8732 let Inst{24-23} = msz;
8733 let Inst{22-21} = 0b00;
8734 let Inst{20-16} = imm5;
8735 let Inst{15-13} = 0b111;
8736 let Inst{12-10} = Pg;
8739 let Inst{3-0} = prfop;
8741 let hasSideEffects = 1;
8744 multiclass sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty, SDPatternOperator op> {
8745 def NAME : sve_mem_64b_prfm_vi<msz, asm, imm_ty>;
8747 def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
8748 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
8750 def : Pat<(op (nxv2i1 PPR_3b:$Pg), (nxv2i64 ZPR32:$Zn), (i64 imm_ty:$imm), (i32 sve_prfop:$prfop)),
8751 (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR_3b:$Pg, ZPR32:$Zn, imm_ty:$imm)>;
8754 //===----------------------------------------------------------------------===//
8755 // SVE Compute Vector Address Group
8756 //===----------------------------------------------------------------------===//
8758 class sve_int_bin_cons_misc_0_a<bits<2> opc, bits<2> msz, string asm,
8759 ZPRRegOp zprty, RegisterOperand zprext>
8760 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprext:$Zm),
8761 asm, "\t$Zd, [$Zn, $Zm]",
8767 let Inst{31-24} = 0b00000100;
8768 let Inst{23-22} = opc;
8770 let Inst{20-16} = Zm;
8771 let Inst{15-12} = 0b1010;
8772 let Inst{11-10} = msz;
8776 let hasSideEffects = 0;
8779 multiclass sve_int_bin_cons_misc_0_a_uxtw<bits<2> opc, string asm> {
8780 def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtUXTW8>;
8781 def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtUXTW16>;
8782 def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtUXTW32>;
8783 def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtUXTW64>;
8786 multiclass sve_int_bin_cons_misc_0_a_sxtw<bits<2> opc, string asm> {
8787 def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtSXTW8>;
8788 def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtSXTW16>;
8789 def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtSXTW32>;
8790 def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtSXTW64>;
8793 multiclass sve_int_bin_cons_misc_0_a_32_lsl<bits<2> opc, string asm> {
8794 def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR32, ZPR32ExtLSL8>;
8795 def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR32, ZPR32ExtLSL16>;
8796 def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR32, ZPR32ExtLSL32>;
8797 def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR32, ZPR32ExtLSL64>;
8800 multiclass sve_int_bin_cons_misc_0_a_64_lsl<bits<2> opc, string asm> {
8801 def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtLSL8>;
8802 def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtLSL16>;
8803 def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtLSL32>;
8804 def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtLSL64>;
8807 //===----------------------------------------------------------------------===//
8808 // SVE Integer Misc - Unpredicated Group
8809 //===----------------------------------------------------------------------===//
8811 class sve_int_bin_cons_misc_0_b<bits<2> sz, string asm, ZPRRegOp zprty>
8812 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
8813 asm, "\t$Zd, $Zn, $Zm",
8819 let Inst{31-24} = 0b00000100;
8820 let Inst{23-22} = sz;
8822 let Inst{20-16} = Zm;
8823 let Inst{15-10} = 0b101100;
8827 let hasSideEffects = 0;
8830 multiclass sve_int_bin_cons_misc_0_b<string asm, SDPatternOperator op> {
8831 def _H : sve_int_bin_cons_misc_0_b<0b01, asm, ZPR16>;
8832 def _S : sve_int_bin_cons_misc_0_b<0b10, asm, ZPR32>;
8833 def _D : sve_int_bin_cons_misc_0_b<0b11, asm, ZPR64>;
8835 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
8836 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
8837 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
8840 class sve_int_bin_cons_misc_0_c<bits<8> opc, string asm, ZPRRegOp zprty>
8841 : I<(outs zprty:$Zd), (ins zprty:$Zn),
8847 let Inst{31-24} = 0b00000100;
8848 let Inst{23-22} = opc{7-6};
8850 let Inst{20-16} = opc{5-1};
8851 let Inst{15-11} = 0b10111;
8852 let Inst{10} = opc{0};
8856 let hasSideEffects = 0;
8859 multiclass sve_int_bin_cons_misc_0_c_fexpa<string asm, SDPatternOperator op> {
8860 def _H : sve_int_bin_cons_misc_0_c<0b01000000, asm, ZPR16>;
8861 def _S : sve_int_bin_cons_misc_0_c<0b10000000, asm, ZPR32>;
8862 def _D : sve_int_bin_cons_misc_0_c<0b11000000, asm, ZPR64>;
8864 def : SVE_1_Op_Pat<nxv8f16, op, nxv8i16, !cast<Instruction>(NAME # _H)>;
8865 def : SVE_1_Op_Pat<nxv4f32, op, nxv4i32, !cast<Instruction>(NAME # _S)>;
8866 def : SVE_1_Op_Pat<nxv2f64, op, nxv2i64, !cast<Instruction>(NAME # _D)>;
8869 //===----------------------------------------------------------------------===//
8870 // SVE Integer Reduction Group
8871 //===----------------------------------------------------------------------===//
8873 class sve_int_reduce<bits<2> sz8_32, bits<2> fmt, bits<3> opc, string asm,
8874 ZPRRegOp zprty, FPRasZPROperand dstOpType>
8875 : I<(outs dstOpType:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
8876 asm, "\t$Vd, $Pg, $Zn",
8882 let Inst{31-24} = 0b00000100;
8883 let Inst{23-22} = sz8_32;
8885 let Inst{20-19} = fmt;
8886 let Inst{18-16} = opc;
8887 let Inst{15-13} = 0b001;
8888 let Inst{12-10} = Pg;
8892 let hasSideEffects = 0;
8895 multiclass sve_int_reduce_0_saddv<bits<3> opc, string asm,
8896 SDPatternOperator op> {
8897 def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64asZPR>;
8898 def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64asZPR>;
8899 def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64asZPR>;
8901 def : SVE_2_Op_Pat<nxv2i64, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
8902 def : SVE_2_Op_Pat<nxv2i64, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
8903 def : SVE_2_Op_Pat<nxv2i64, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
8906 multiclass sve_int_reduce_0_uaddv<bits<3> opc, string asm,
8907 SDPatternOperator op> {
8908 def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64asZPR>;
8909 def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64asZPR>;
8910 def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64asZPR>;
8911 def _D : sve_int_reduce<0b11, 0b00, opc, asm, ZPR64, FPR64asZPR>;
8913 def : SVE_2_Op_Pat<nxv2i64, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
8914 def : SVE_2_Op_Pat<nxv2i64, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
8915 def : SVE_2_Op_Pat<nxv2i64, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
8916 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
8919 multiclass sve_int_reduce_1<bits<3> opc, string asm,
8920 SDPatternOperator op> {
8921 def _B : sve_int_reduce<0b00, 0b01, opc, asm, ZPR8, FPR8asZPR>;
8922 def _H : sve_int_reduce<0b01, 0b01, opc, asm, ZPR16, FPR16asZPR>;
8923 def _S : sve_int_reduce<0b10, 0b01, opc, asm, ZPR32, FPR32asZPR>;
8924 def _D : sve_int_reduce<0b11, 0b01, opc, asm, ZPR64, FPR64asZPR>;
8926 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
8927 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
8928 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
8929 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
8932 multiclass sve_int_reduce_2<bits<3> opc, string asm,
8933 SDPatternOperator op> {
8934 def _B : sve_int_reduce<0b00, 0b11, opc, asm, ZPR8, FPR8asZPR>;
8935 def _H : sve_int_reduce<0b01, 0b11, opc, asm, ZPR16, FPR16asZPR>;
8936 def _S : sve_int_reduce<0b10, 0b11, opc, asm, ZPR32, FPR32asZPR>;
8937 def _D : sve_int_reduce<0b11, 0b11, opc, asm, ZPR64, FPR64asZPR>;
8939 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
8940 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
8941 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
8942 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
8945 class sve_int_movprfx_pred<bits<2> sz8_32, bits<3> opc, string asm,
8946 ZPRRegOp zprty, string pg_suffix, dag iops>
8947 : I<(outs zprty:$Zd), iops,
8948 asm, "\t$Zd, $Pg"#pg_suffix#", $Zn",
8954 let Inst{31-24} = 0b00000100;
8955 let Inst{23-22} = sz8_32;
8956 let Inst{21-19} = 0b010;
8957 let Inst{18-16} = opc;
8958 let Inst{15-13} = 0b001;
8959 let Inst{12-10} = Pg;
8963 let ElementSize = zprty.ElementSize;
8964 let hasSideEffects = 0;
8967 multiclass sve_int_movprfx_pred_merge<bits<3> opc, string asm> {
8968 let Constraints = "$Zd = $_Zd" in {
8969 def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/m",
8970 (ins ZPR8:$_Zd, PPR3bAny:$Pg, ZPR8:$Zn)>;
8971 def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/m",
8972 (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR16:$Zn)>;
8973 def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/m",
8974 (ins ZPR32:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn)>;
8975 def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/m",
8976 (ins ZPR64:$_Zd, PPR3bAny:$Pg, ZPR64:$Zn)>;
8980 multiclass sve_int_movprfx_pred_zero<bits<3> opc, string asm> {
8981 def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/z",
8982 (ins PPR3bAny:$Pg, ZPR8:$Zn)>;
8983 def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/z",
8984 (ins PPR3bAny:$Pg, ZPR16:$Zn)>;
8985 def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/z",
8986 (ins PPR3bAny:$Pg, ZPR32:$Zn)>;
8987 def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/z",
8988 (ins PPR3bAny:$Pg, ZPR64:$Zn)>;
8991 //===----------------------------------------------------------------------===//
8992 // SVE Propagate Break Group
8993 //===----------------------------------------------------------------------===//
8995 class sve_int_brkp<bits<2> opc, string asm>
8996 : I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm),
8997 asm, "\t$Pd, $Pg/z, $Pn, $Pm",
9004 let Inst{31-24} = 0b00100101;
9006 let Inst{22} = opc{1};
9007 let Inst{21-20} = 0b00;
9008 let Inst{19-16} = Pm;
9009 let Inst{15-14} = 0b11;
9010 let Inst{13-10} = Pg;
9013 let Inst{4} = opc{0};
9016 let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
9017 let hasSideEffects = 0;
9020 multiclass sve_int_brkp<bits<2> opc, string asm, SDPatternOperator op> {
9021 def NAME : sve_int_brkp<opc, asm>;
9023 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
9027 //===----------------------------------------------------------------------===//
9028 // SVE Partition Break Group
9029 //===----------------------------------------------------------------------===//
9031 class sve_int_brkn<bit S, string asm>
9032 : I<(outs PPR8:$Pdm), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$_Pdm),
9033 asm, "\t$Pdm, $Pg/z, $Pn, $_Pdm",
9039 let Inst{31-23} = 0b001001010;
9041 let Inst{21-14} = 0b01100001;
9042 let Inst{13-10} = Pg;
9046 let Inst{3-0} = Pdm;
9048 let Constraints = "$Pdm = $_Pdm";
9049 let Defs = !if(S, [NZCV], []);
9050 let ElementSize = ElementSizeB;
9051 let hasSideEffects = 0;
9054 multiclass sve_int_brkn<bits<1> opc, string asm, SDPatternOperator op> {
9055 def NAME : sve_int_brkn<opc, asm>;
9057 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
9060 class sve_int_break<bits<3> opc, string asm, string suffix, dag iops>
9061 : I<(outs PPR8:$Pd), iops,
9062 asm, "\t$Pd, $Pg"#suffix#", $Pn",
9068 let Inst{31-24} = 0b00100101;
9069 let Inst{23-22} = opc{2-1};
9070 let Inst{21-14} = 0b01000001;
9071 let Inst{13-10} = Pg;
9074 let Inst{4} = opc{0};
9077 let Constraints = !if(!eq (opc{0}, 1), "$Pd = $_Pd", "");
9078 let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
9079 let hasSideEffects = 0;
9082 multiclass sve_int_break_m<bits<3> opc, string asm, SDPatternOperator op> {
9083 def NAME : sve_int_break<opc, asm, "/m", (ins PPR8:$_Pd, PPRAny:$Pg, PPR8:$Pn)>;
9085 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
9088 multiclass sve_int_break_z<bits<3> opc, string asm, SDPatternOperator op> {
9089 def NAME : sve_int_break<opc, asm, "/z", (ins PPRAny:$Pg, PPR8:$Pn)>;
9091 def : SVE_2_Op_Pat<nxv16i1, op, nxv16i1, nxv16i1, !cast<Instruction>(NAME)>;
9094 //===----------------------------------------------------------------------===//
9095 // SVE2 String Processing Group
9096 //===----------------------------------------------------------------------===//
9098 class sve2_char_match<bit sz, bit opc, string asm,
9099 PPRRegOp pprty, ZPRRegOp zprty>
9100 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
9101 asm, "\t$Pd, $Pg/z, $Zn, $Zm",
9108 let Inst{31-23} = 0b010001010;
9111 let Inst{20-16} = Zm;
9112 let Inst{15-13} = 0b100;
9113 let Inst{12-10} = Pg;
9119 let ElementSize = pprty.ElementSize;
9120 let hasSideEffects = 0;
9121 let isPTestLike = 1;
9124 multiclass sve2_char_match<bit opc, string asm, SDPatternOperator op> {
9125 def _B : sve2_char_match<0b0, opc, asm, PPR8, ZPR8>;
9126 def _H : sve2_char_match<0b1, opc, asm, PPR16, ZPR16>;
9128 def : SVE_3_Op_Pat<nxv16i1, op, nxv16i1, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
9129 def : SVE_3_Op_Pat<nxv8i1, op, nxv8i1, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
9132 //===----------------------------------------------------------------------===//
9133 // SVE2 Histogram Computation - Segment Group
9134 //===----------------------------------------------------------------------===//
9136 class sve2_hist_gen_segment<string asm, SDPatternOperator op>
9137 : I<(outs ZPR8:$Zd), (ins ZPR8:$Zn, ZPR8:$Zm),
9138 asm, "\t$Zd, $Zn, $Zm",
9140 [(set nxv16i8:$Zd, (op nxv16i8:$Zn, nxv16i8:$Zm))]>, Sched<[]> {
9144 let Inst{31-21} = 0b01000101001;
9145 let Inst{20-16} = Zm;
9146 let Inst{15-10} = 0b101000;
9150 let hasSideEffects = 0;
9153 //===----------------------------------------------------------------------===//
9154 // SVE2 Histogram Computation - Vector Group
9155 //===----------------------------------------------------------------------===//
9157 class sve2_hist_gen_vector<bit sz, string asm, ZPRRegOp zprty>
9158 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
9159 asm, "\t$Zd, $Pg/z, $Zn, $Zm",
9166 let Inst{31-23} = 0b010001011;
9169 let Inst{20-16} = Zm;
9170 let Inst{15-13} = 0b110;
9171 let Inst{12-10} = Pg;
9175 let hasSideEffects = 0;
9178 multiclass sve2_hist_gen_vector<string asm, SDPatternOperator op> {
9179 def _S : sve2_hist_gen_vector<0b0, asm, ZPR32>;
9180 def _D : sve2_hist_gen_vector<0b1, asm, ZPR64>;
9182 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
9183 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
9186 //===----------------------------------------------------------------------===//
9187 // SVE2 Crypto Extensions Group
9188 //===----------------------------------------------------------------------===//
9190 class sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty>
9191 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
9192 asm, "\t$Zd, $Zn, $Zm",
9198 let Inst{31-21} = 0b01000101001;
9199 let Inst{20-16} = Zm;
9200 let Inst{15-11} = 0b11110;
9205 let hasSideEffects = 0;
9208 multiclass sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty,
9209 SDPatternOperator op, ValueType vt> {
9210 def NAME : sve2_crypto_cons_bin_op<opc, asm, zprty>;
9211 def : SVE_2_Op_Pat<vt, op, vt, vt, !cast<Instruction>(NAME)>;
9214 class sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty>
9215 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm),
9216 asm, "\t$Zdn, $_Zdn, $Zm",
9221 let Inst{31-17} = 0b010001010010001;
9222 let Inst{16} = opc{1};
9223 let Inst{15-11} = 0b11100;
9224 let Inst{10} = opc{0};
9226 let Inst{4-0} = Zdn;
9228 let Constraints = "$Zdn = $_Zdn";
9229 let hasSideEffects = 0;
9232 multiclass sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty,
9233 SDPatternOperator op, ValueType vt> {
9234 def NAME : sve2_crypto_des_bin_op<opc, asm, zprty>;
9235 def : SVE_2_Op_Pat<vt, op, vt, vt, !cast<Instruction>(NAME)>;
9238 class sve2_crypto_unary_op<bit opc, string asm, ZPRRegOp zprty>
9239 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn),
9240 asm, "\t$Zdn, $_Zdn",
9244 let Inst{31-11} = 0b010001010010000011100;
9246 let Inst{9-5} = 0b00000;
9247 let Inst{4-0} = Zdn;
9249 let Constraints = "$Zdn = $_Zdn";
9250 let hasSideEffects = 0;
9253 multiclass sve2_crypto_unary_op<bit opc, string asm, SDPatternOperator op> {
9254 def NAME : sve2_crypto_unary_op<opc, asm, ZPR8>;
9255 def : SVE_1_Op_Pat<nxv16i8, op, nxv16i8, !cast<Instruction>(NAME)>;
9258 class sve_crypto_binary_multi2<bits<3> opc, string asm>
9259 : I<(outs ZZ_b_mul_r:$Zdn),
9260 (ins ZZ_b_mul_r:$_Zdn, ZPR128:$Zm, VectorIndexS32b_timm:$imm2),
9262 "\t$Zdn, $_Zdn, $Zm$imm2",
9268 let Inst{31-21} = 0b01000101001;
9269 let Inst{20-19} = imm2;
9270 let Inst{18-17} = 0b01;
9271 let Inst{16} = opc{2};
9272 let Inst{15-11} = 0b11101;
9273 let Inst{10} = opc{1};
9275 let Inst{4-1} = Zdn;
9276 let Inst{0} = opc{0};
9278 let Constraints = "$Zdn = $_Zdn";
9279 let hasSideEffects = 0;
9282 class sve_crypto_binary_multi4<bits<4> opc, string asm>
9283 : I<(outs ZZZZ_b_mul_r:$Zdn),
9284 (ins ZZZZ_b_mul_r:$_Zdn, ZPR128:$Zm, VectorIndexS32b_timm:$imm2),
9286 "\t$Zdn, $_Zdn, $Zm$imm2",
9292 let Inst{31-21} = 0b01000101001;
9293 let Inst{20-19} = imm2;
9294 let Inst{18-17} = 0b11;
9295 let Inst{16} = opc{3};
9296 let Inst{15-11} = 0b11101;
9297 let Inst{10} = opc{2};
9299 let Inst{4-2} = Zdn;
9300 let Inst{1-0} = opc{1-0};
9302 let Constraints = "$Zdn = $_Zdn";
9303 let hasSideEffects = 0;
9306 class sve_crypto_pmlal_multi<string asm>
9307 : I<(outs ZZ_q_mul_r:$Zda),
9308 (ins ZZ_q_mul_r:$_Zda, ZPR64:$Zn, ZPR64:$Zm),
9316 let Inst{31-21} = 0b01000101001;
9317 let Inst{20-16} = Zm;
9318 let Inst{15-10} = 0b111111;
9320 let Inst{4-1} = Zda;
9323 let Constraints = "$Zda = $_Zda";
9324 let hasSideEffects = 0;
9327 class sve_crypto_pmull_multi<string asm>
9328 : I<(outs ZZ_q_mul_r:$Zd),
9329 (ins ZPR64:$Zn, ZPR64:$Zm),
9337 let Inst{31-21} = 0b01000101001;
9338 let Inst{20-16} = Zm;
9339 let Inst{15-10} = 0b111110;
9343 let hasSideEffects = 0;
9346 //===----------------------------------------------------------------------===//
9347 // SVE BFloat16 Group
9348 //===----------------------------------------------------------------------===//
9350 class sve_float_dot<bit bf, bit o2, ZPRRegOp dst_ty, ZPRRegOp src_ty, string asm>
9351 : I<(outs dst_ty:$Zda), (ins dst_ty:$_Zda, src_ty:$Zn, src_ty:$Zm),
9352 asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
9356 let Inst{31-23} = 0b011001000;
9359 let Inst{20-16} = Zm;
9360 let Inst{15-11} = 0b10000;
9363 let Inst{4-0} = Zda;
9365 let Constraints = "$Zda = $_Zda";
9366 let DestructiveInstType = DestructiveOther;
9367 let hasSideEffects = 0;
9368 let mayRaiseFPException = 1;
9371 multiclass sve_float_dot<bit bf, bit o2, ZPRRegOp dst_ty, ZPRRegOp src_ty,
9372 string asm, ValueType InVT, SDPatternOperator op> {
9373 def NAME : sve_float_dot<bf, o2, dst_ty, src_ty, asm>;
9374 def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, InVT, InVT, !cast<Instruction>(NAME)>;
9377 multiclass sve_fp8_dot<bit bf, ZPRRegOp dstrc, string asm, ValueType vt,
9378 SDPatternOperator op> {
9379 def NAME : sve_float_dot<bf, 0b1, dstrc, ZPR8, asm> {
9380 let Uses = [FPMR, FPCR];
9386 def : SVE_3_Op_Pat<vt, op, vt, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
9389 class sve_float_dot_indexed<bit bf, ZPRRegOp dst_ty, ZPRRegOp src1_ty,
9390 ZPRRegOp src2_ty, Operand iop_ty, string asm>
9391 : I<(outs dst_ty:$Zda), (ins dst_ty:$_Zda, src1_ty:$Zn, src2_ty:$Zm, iop_ty:$iop),
9392 asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
9396 let Inst{31-23} = 0b011001000;
9399 let Inst{18-16} = Zm;
9400 let Inst{15-12} = 0b0100;
9402 let Inst{4-0} = Zda;
9404 let Constraints = "$Zda = $_Zda";
9405 let DestructiveInstType = DestructiveOther;
9406 let hasSideEffects = 0;
9407 let mayRaiseFPException = 1;
9410 multiclass sve_float_dot_indexed<bit bf, bits<2> opc, ZPRRegOp src1_ty,
9411 ZPRRegOp src2_ty, string asm, ValueType InVT,
9412 SDPatternOperator op> {
9413 def NAME : sve_float_dot_indexed<bf, ZPR32, src1_ty, src2_ty, VectorIndexS32b, asm> {
9415 let Inst{20-19} = iop;
9416 let Inst{11-10} = opc;
9418 def : SVE_4_Op_Imm_Pat<nxv4f32, op, nxv4f32, InVT, InVT, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME)>;
9421 multiclass sve_bfloat_convert<string asm, SDPatternOperator op, SDPatternOperator ir_op> {
9422 def NAME : sve_fp_2op_p_zd<0b1001010, asm, ZPR32, ZPR16, ElementSizeS>;
9424 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv4i1, nxv4f32, !cast<Instruction>(NAME)>;
9425 def : SVE_1_Op_Passthru_Round_Pat<nxv4bf16, ir_op, nxv4i1, nxv4f32, !cast<Instruction>(NAME)>;
9426 def : SVE_1_Op_Passthru_Round_Pat<nxv2bf16, ir_op, nxv2i1, nxv2f32, !cast<Instruction>(NAME)>;
9429 multiclass sve_bfloat_convert_top<string asm, SDPatternOperator op> {
9430 def NAME : sve2_fp_convert_precision<0b1010, 0b1, asm, ZPR16, ZPR32>;
9432 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv4i1, nxv4f32, !cast<Instruction>(NAME)>;
9435 //===----------------------------------------------------------------------===//
9436 // SVE Integer Matrix Multiply Group
9437 //===----------------------------------------------------------------------===//
9439 class sve_int_matmul<bits<2> uns, string asm>
9440 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR8:$Zm), asm,
9441 "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
9445 let Inst{31-24} = 0b01000101;
9446 let Inst{23-22} = uns;
9448 let Inst{20-16} = Zm;
9449 let Inst{15-10} = 0b100110;
9451 let Inst{4-0} = Zda;
9453 let Constraints = "$Zda = $_Zda";
9454 let DestructiveInstType = DestructiveOther;
9455 let ElementSize = ZPR32.ElementSize;
9456 let hasSideEffects = 0;
9459 multiclass sve_int_matmul<bits<2> uns, string asm, SDPatternOperator op> {
9460 def NAME : sve_int_matmul<uns, asm>;
9462 def : SVE_3_Op_Pat<nxv4i32, op , nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
9465 //===----------------------------------------------------------------------===//
9466 // SVE Integer Dot Product Mixed Sign Group
9467 //===----------------------------------------------------------------------===//
9469 class sve_int_dot_mixed<string asm>
9470 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR8:$Zm), asm,
9471 "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
9475 let Inst{31-21} = 0b01000100100;
9476 let Inst{20-16} = Zm;
9477 let Inst{15-10} = 0b011110;
9479 let Inst{4-0} = Zda;
9481 let Constraints = "$Zda = $_Zda";
9482 let DestructiveInstType = DestructiveOther;
9483 let ElementSize = ZPR32.ElementSize;
9484 let hasSideEffects = 0;
9487 multiclass sve_int_dot_mixed<string asm, SDPatternOperator op> {
9488 def NAME : sve_int_dot_mixed<asm>;
9490 def : SVE_3_Op_Pat<nxv4i32, op , nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
9493 //===----------------------------------------------------------------------===//
9494 // SVE Integer Dot Product Mixed Sign - Indexed Group
9495 //===----------------------------------------------------------------------===//
9497 class sve_int_dot_mixed_indexed<bit U, string asm>
9498 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, VectorIndexS32b:$idx),
9499 asm, "\t$Zda, $Zn, $Zm$idx", "", []>, Sched<[]> {
9504 let Inst{31-21} = 0b01000100101;
9505 let Inst{20-19} = idx;
9506 let Inst{18-16} = Zm;
9507 let Inst{15-11} = 0b00011;
9510 let Inst{4-0} = Zda;
9512 let Constraints = "$Zda = $_Zda";
9513 let DestructiveInstType = DestructiveOther;
9514 let ElementSize = ZPR32.ElementSize;
9515 let hasSideEffects = 0;
9518 multiclass sve_int_dot_mixed_indexed<bit U, string asm, SDPatternOperator op> {
9519 def NAME : sve_int_dot_mixed_indexed<U, asm>;
9521 def : SVE_4_Op_Imm_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME)>;
9524 //===----------------------------------------------------------------------===//
9525 // SVE Floating Point Matrix Multiply Accumulate Group
9526 //===----------------------------------------------------------------------===//
9528 class sve_fp_matrix_mla<bits<2> opc, string asm, ZPRRegOp zda_ty, ZPRRegOp reg_ty>
9529 : I<(outs zda_ty:$Zda), (ins zda_ty:$_Zda, reg_ty:$Zn, reg_ty:$Zm),
9530 asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
9534 let Inst{31-24} = 0b01100100;
9535 let Inst{23-22} = opc;
9537 let Inst{20-16} = Zm;
9538 let Inst{15-10} = 0b111001;
9540 let Inst{4-0} = Zda;
9542 let Constraints = "$Zda = $_Zda";
9543 let DestructiveInstType = DestructiveOther;
9544 let hasSideEffects = 0;
9545 let mayRaiseFPException = 1;
9548 multiclass sve_fp_matrix_mla<bits<2> opc, string asm, ZPRRegOp zda_ty, ZPRRegOp reg_ty, SDPatternOperator op, ValueType zda_vt, ValueType reg_vt> {
9549 def NAME : sve_fp_matrix_mla<opc, asm, zda_ty, reg_ty>;
9551 def : SVE_3_Op_Pat<zda_vt, op , zda_vt, reg_vt, reg_vt, !cast<Instruction>(NAME)>;
9554 //===----------------------------------------------------------------------===//
9555 // SVE Memory - Contiguous Load And Replicate 256-bit Group
9556 //===----------------------------------------------------------------------===//
9558 class sve_mem_ldor_si<bits<2> sz, string asm, RegisterOperand VecList>
9559 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s32:$imm4),
9560 asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> {
9565 let Inst{31-25} = 0b1010010;
9566 let Inst{24-23} = sz;
9567 let Inst{22-20} = 0b010;
9568 let Inst{19-16} = imm4;
9569 let Inst{15-13} = 0b001;
9570 let Inst{12-10} = Pg;
9574 let hasSideEffects = 0;
9578 multiclass sve_mem_ldor_si<bits<2> sz, string asm, RegisterOperand listty,
9579 ZPRRegOp zprty, ValueType Ty, ValueType PredTy, SDNode Ld1ro> {
9580 def NAME : sve_mem_ldor_si<sz, asm, listty>;
9581 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
9582 (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
9583 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
9584 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
9585 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]",
9586 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s32:$imm4), 0>;
9588 // Base addressing mode
9589 def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$Pg), GPR64sp:$base)),
9590 (!cast<Instruction>(NAME) PPR3bAny:$Pg, GPR64sp:$base, (i64 0))>;
9591 let AddedComplexity = 2 in {
9592 // Reg + Imm addressing mode
9593 def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$Pg), (add GPR64:$base, (i64 simm4s32:$imm)))),
9594 (!cast<Instruction>(NAME) $Pg, $base, simm4s32:$imm)>;
9598 class sve_mem_ldor_ss<bits<2> sz, string asm, RegisterOperand VecList,
9599 RegisterOperand gprty>
9600 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
9601 asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> {
9606 let Inst{31-25} = 0b1010010;
9607 let Inst{24-23} = sz;
9608 let Inst{22-21} = 0b01;
9609 let Inst{20-16} = Rm;
9610 let Inst{15-13} = 0;
9611 let Inst{12-10} = Pg;
9615 let hasSideEffects = 0;
9619 multiclass sve_mem_ldor_ss<bits<2> sz, string asm, RegisterOperand listty,
9620 ZPRRegOp zprty, RegisterOperand gprty, ValueType Ty,
9621 ValueType PredTy, SDNode Ld1ro, ComplexPattern AddrCP> {
9622 def NAME : sve_mem_ldor_ss<sz, asm, listty, gprty>;
9624 def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
9625 (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
9627 def : Pat<(Ty (Ld1ro (PredTy PPR3bAny:$gp), (AddrCP GPR64sp:$base, gprty:$offset))),
9628 (!cast<Instruction>(NAME) PPR3bAny:$gp, GPR64sp:$base, gprty:$offset)>;
9631 //===----------------------------------------------------------------------===//
9632 // SVE Interleave 128-bit Elements Group
9633 //===----------------------------------------------------------------------===//
9635 class sve_int_perm_bin_perm_128_zz<bits<2> opc, bit P, string asm>
9636 : I<(outs ZPR128:$Zd), (ins ZPR128:$Zn, ZPR128:$Zm),
9637 asm, "\t$Zd, $Zn, $Zm",
9643 let Inst{31-21} = 0b00000101101;
9644 let Inst{20-16} = Zm;
9645 let Inst{15-13} = 0b000;
9646 let Inst{12-11} = opc;
9651 let hasSideEffects = 0;
9654 multiclass sve_int_perm_bin_perm_128_zz<bits<2> opc, bit P, string asm, SDPatternOperator op> {
9655 def NAME : sve_int_perm_bin_perm_128_zz<opc, P, asm>;
9657 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
9658 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
9659 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME)>;
9660 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME)>;
9661 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME)>;
9662 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME)>;
9663 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME)>;
9664 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
9667 /// Addressing modes
9668 let WantsRoot = true in {
9669 def am_sve_indexed_s4 : ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<-8, 7>">;
9670 def am_sve_indexed_s6 : ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<-32, 31>">;
9673 def am_sve_regreg_lsl0 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<0>", []>;
9674 def am_sve_regreg_lsl1 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<1>", []>;
9675 def am_sve_regreg_lsl2 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<2>", []>;
9676 def am_sve_regreg_lsl3 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<3>", []>;
9677 def am_sve_regreg_lsl4 : ComplexPattern<iPTR, 2, "SelectSVERegRegAddrMode<4>", []>;
9679 // Predicated pseudo floating point two operand instructions.
9680 multiclass sve_fp_bin_pred_hfd<SDPatternOperator op> {
9681 def _H_UNDEF : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
9682 def _S_UNDEF : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
9683 def _D_UNDEF : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
9685 def : SVE_3_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
9686 def : SVE_3_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
9687 def : SVE_3_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, !cast<Pseudo>(NAME # _H_UNDEF)>;
9688 def : SVE_3_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
9689 def : SVE_3_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, !cast<Pseudo>(NAME # _S_UNDEF)>;
9690 def : SVE_3_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, !cast<Pseudo>(NAME # _D_UNDEF)>;
9693 // Predicated pseudo floating point (BFloat) two operand instructions.
9694 multiclass sve_fp_bin_pred_bfloat<SDPatternOperator op> {
9695 def _UNDEF : PredTwoOpPseudo<NAME, ZPR16, FalseLanesUndef>;
9697 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, !cast<Pseudo>(NAME # _UNDEF)>;
9698 def : SVE_3_Op_Pat<nxv4bf16, op, nxv4i1, nxv4bf16, nxv4bf16, !cast<Pseudo>(NAME # _UNDEF)>;
9699 def : SVE_3_Op_Pat<nxv2bf16, op, nxv2i1, nxv2bf16, nxv2bf16, !cast<Pseudo>(NAME # _UNDEF)>;
9702 // Predicated pseudo floating point three operand instructions.
9703 multiclass sve_fp_3op_pred_hfd<SDPatternOperator op> {
9704 def _H_UNDEF : PredThreeOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
9705 def _S_UNDEF : PredThreeOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
9706 def _D_UNDEF : PredThreeOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
9708 def : SVE_4_Op_Pat<nxv8f16, op, nxv8i1, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H_UNDEF)>;
9709 def : SVE_4_Op_Pat<nxv4f16, op, nxv4i1, nxv4f16, nxv4f16, nxv4f16, !cast<Instruction>(NAME # _H_UNDEF)>;
9710 def : SVE_4_Op_Pat<nxv2f16, op, nxv2i1, nxv2f16, nxv2f16, nxv2f16, !cast<Instruction>(NAME # _H_UNDEF)>;
9711 def : SVE_4_Op_Pat<nxv4f32, op, nxv4i1, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S_UNDEF)>;
9712 def : SVE_4_Op_Pat<nxv2f32, op, nxv2i1, nxv2f32, nxv2f32, nxv2f32, !cast<Instruction>(NAME # _S_UNDEF)>;
9713 def : SVE_4_Op_Pat<nxv2f64, op, nxv2i1, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D_UNDEF)>;
9716 // Predicated pseudo floating point (BFloat) three operand instructions.
9717 multiclass sve_fp_3op_pred_bfloat<SDPatternOperator op> {
9718 def _UNDEF : PredThreeOpPseudo<NAME, ZPR16, FalseLanesUndef>;
9720 def : SVE_4_Op_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _UNDEF)>;
9721 def : SVE_4_Op_Pat<nxv4bf16, op, nxv4i1, nxv4bf16, nxv4bf16, nxv4bf16, !cast<Instruction>(NAME # _UNDEF)>;
9722 def : SVE_4_Op_Pat<nxv2bf16, op, nxv2i1, nxv2bf16, nxv2bf16, nxv2bf16, !cast<Instruction>(NAME # _UNDEF)>;
9725 // Predicated pseudo integer two operand instructions.
9726 multiclass sve_int_bin_pred_bhsd<SDPatternOperator op> {
9727 def _B_UNDEF : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>;
9728 def _H_UNDEF : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
9729 def _S_UNDEF : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
9730 def _D_UNDEF : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
9732 def : SVE_3_Op_Pat<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
9733 def : SVE_3_Op_Pat<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
9734 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
9735 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
9738 // As sve_int_bin_pred but when only i32 and i64 vector types are required.
9739 multiclass sve_int_bin_pred_sd<SDPatternOperator op> {
9740 def _S_UNDEF : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
9741 def _D_UNDEF : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
9743 def : SVE_3_Op_Pat<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
9744 def : SVE_3_Op_Pat<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
9747 // Predicated pseudo integer two operand instructions. Second operand is an
9748 // immediate specified by imm_[bhsd].
9749 multiclass sve_int_shift_pred_bhsd<SDPatternOperator op,
9750 ComplexPattern imm_b, ComplexPattern imm_h,
9751 ComplexPattern imm_s, ComplexPattern imm_d> {
9752 def _B_UNDEF : PredTwoOpImmPseudo<NAME # _B, ZPR8, Operand<i32>, FalseLanesUndef>;
9753 def _H_UNDEF : PredTwoOpImmPseudo<NAME # _H, ZPR16, Operand<i32>, FalseLanesUndef>;
9754 def _S_UNDEF : PredTwoOpImmPseudo<NAME # _S, ZPR32, Operand<i32>, FalseLanesUndef>;
9755 def _D_UNDEF : PredTwoOpImmPseudo<NAME # _D, ZPR64, Operand<i32>, FalseLanesUndef>;
9757 def : SVE_Shift_DupImm_Pred_Pat<nxv16i8, op, nxv16i1, i32, imm_b, !cast<Instruction>(NAME # _B_UNDEF)>;
9758 def : SVE_Shift_DupImm_Pred_Pat<nxv8i16, op, nxv8i1, i32, imm_h, !cast<Instruction>(NAME # _H_UNDEF)>;
9759 def : SVE_Shift_DupImm_Pred_Pat<nxv4i32, op, nxv4i1, i32, imm_s, !cast<Instruction>(NAME # _S_UNDEF)>;
9760 def : SVE_Shift_DupImm_Pred_Pat<nxv2i64, op, nxv2i1, i64, imm_d, !cast<Instruction>(NAME # _D_UNDEF)>;
9763 multiclass sve_int_bin_pred_all_active_bhsd<SDPatternOperator op> {
9764 def _B_UNDEF : PredTwoOpPseudo<NAME # _B, ZPR8, FalseLanesUndef>;
9765 def _H_UNDEF : PredTwoOpPseudo<NAME # _H, ZPR16, FalseLanesUndef>;
9766 def _S_UNDEF : PredTwoOpPseudo<NAME # _S, ZPR32, FalseLanesUndef>;
9767 def _D_UNDEF : PredTwoOpPseudo<NAME # _D, ZPR64, FalseLanesUndef>;
9769 def : SVE_2_Op_Pred_All_Active_Pt<nxv16i8, op, nxv16i1, nxv16i8, nxv16i8, !cast<Pseudo>(NAME # _B_UNDEF)>;
9770 def : SVE_2_Op_Pred_All_Active_Pt<nxv8i16, op, nxv8i1, nxv8i16, nxv8i16, !cast<Pseudo>(NAME # _H_UNDEF)>;
9771 def : SVE_2_Op_Pred_All_Active_Pt<nxv4i32, op, nxv4i1, nxv4i32, nxv4i32, !cast<Pseudo>(NAME # _S_UNDEF)>;
9772 def : SVE_2_Op_Pred_All_Active_Pt<nxv2i64, op, nxv2i1, nxv2i64, nxv2i64, !cast<Pseudo>(NAME # _D_UNDEF)>;
9775 //===----------------------------------------------------------------------===//
9776 // SME2 or SVE2.1 Instructions
9777 //===----------------------------------------------------------------------===//
9779 class sve_fp_clamp<string asm, bits<2> sz, ZPRRegOp zpr_ty>
9780 : I<(outs zpr_ty:$Zd), (ins zpr_ty:$_Zd, zpr_ty:$Zn, zpr_ty:$Zm),
9781 asm, "\t$Zd, $Zn, $Zm", "", []>,
9786 let Inst{31-24} = 0b01100100;
9787 let Inst{23-22} = sz;
9789 let Inst{20-16} = Zm;
9790 let Inst{15-10} = 0b001001;
9794 let Constraints = "$Zd = $_Zd";
9795 let DestructiveInstType = DestructiveOther;
9796 let ElementSize = zpr_ty.ElementSize;
9797 let hasSideEffects = 0;
9800 multiclass sve_fp_clamp<string asm, SDPatternOperator op> {
9801 def _H : sve_fp_clamp<asm, 0b01, ZPR16>;
9802 def _S : sve_fp_clamp<asm, 0b10, ZPR32>;
9803 def _D : sve_fp_clamp<asm, 0b11, ZPR64>;
9805 def : SVE_3_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
9806 def : SVE_3_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
9807 def : SVE_3_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
9810 multiclass sve_fp_clamp_bfloat<string asm, SDPatternOperator op> {
9811 def NAME : sve_fp_clamp<asm, 0b00, ZPR16>;
9813 def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
9816 // SVE two-way dot product
9817 class sve2p1_two_way_dot_vv<string mnemonic, bit u>
9818 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
9819 mnemonic, "\t$Zda, $Zn, $Zm",
9820 "", []>, Sched<[]> {
9824 let Inst{31-21} = 0b01000100000;
9825 let Inst{20-16} = Zm;
9826 let Inst{15-11} = 0b11001;
9829 let Inst{4-0} = Zda;
9831 let Constraints = "$Zda = $_Zda";
9832 let DestructiveInstType = DestructiveOther;
9833 let hasSideEffects = 0;
9836 multiclass sve2p1_two_way_dot_vv<string mnemonic, bit u, SDPatternOperator intrinsic> {
9837 def NAME : sve2p1_two_way_dot_vv<mnemonic, u>;
9839 def : SVE_3_Op_Pat<nxv4i32, intrinsic, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
9842 // SVE two-way dot product (indexed)
9843 class sve2p1_two_way_dot_vvi<string mnemonic, bit u>
9844 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, VectorIndexS32b:$i2),
9845 mnemonic, "\t$Zda, $Zn, $Zm$i2",
9846 "", []>, Sched<[]> {
9851 let Inst{31-21} = 0b01000100100;
9852 let Inst{20-19} = i2;
9853 let Inst{18-16} = Zm;
9854 let Inst{15-11} = 0b11001;
9857 let Inst{4-0} = Zda;
9859 let Constraints = "$Zda = $_Zda";
9860 let DestructiveInstType = DestructiveOther;
9861 let hasSideEffects = 0;
9864 multiclass sve2p1_two_way_dot_vvi<string mnemonic, bit u, SDPatternOperator intrinsic> {
9865 def NAME : sve2p1_two_way_dot_vvi<mnemonic, u>;
9867 def : SVE_4_Op_Imm_Pat<nxv4i32, intrinsic, nxv4i32, nxv8i16, nxv8i16, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME)>;
9870 class sve2p1_ptrue_pn<string mnemonic, bits<2> sz, PNRP8to15RegOp pnrty, SDPatternOperator op>
9871 : I<(outs pnrty:$PNd), (ins ), mnemonic, "\t$PNd",
9872 "", [(set pnrty:$PNd, (op))]>, Sched<[]> {
9874 let Inst{31-24} = 0b00100101;
9875 let Inst{23-22} = sz;
9876 let Inst{21-3} = 0b1000000111100000010;
9877 let Inst{2-0} = PNd;
9879 let hasSideEffects = 0;
9880 let isReMaterializable = 1;
9885 multiclass sve2p1_ptrue_pn<string mnemonic> {
9886 def _B : sve2p1_ptrue_pn<mnemonic, 0b00, PNR8_p8to15, int_aarch64_sve_ptrue_c8>;
9887 def _H : sve2p1_ptrue_pn<mnemonic, 0b01, PNR16_p8to15, int_aarch64_sve_ptrue_c16>;
9888 def _S : sve2p1_ptrue_pn<mnemonic, 0b10, PNR32_p8to15, int_aarch64_sve_ptrue_c32>;
9889 def _D : sve2p1_ptrue_pn<mnemonic, 0b11, PNR64_p8to15, int_aarch64_sve_ptrue_c64>;
9893 // SVE extract mask predicate from predicate-as-counter
9894 class sve2p1_pred_as_ctr_to_mask_base<string mnemonic, bits<2> sz, bits<3> opc,
9895 RegisterOperand pprty, Operand idxty>
9896 : I<(outs pprty:$Pd), (ins PNRAny_p8to15:$PNn, idxty:$index),
9897 mnemonic, "\t$Pd, $PNn$index",
9898 "", []>, Sched<[]> {
9902 let Inst{31-24} = 0b00100101;
9903 let Inst{23-22} = sz;
9904 let Inst{21-11} = 0b10000001110;
9905 let Inst{10-8} = opc;
9906 let Inst{7-5} = PNn;
9910 let hasSideEffects = 0;
9913 class sve2p1_pred_as_ctr_to_mask<string mnemonic, bits<2> sz, PPRRegOp pprty>
9914 : sve2p1_pred_as_ctr_to_mask_base<mnemonic, sz, {0, ?, ?}, pprty, VectorIndexS32b_timm> {
9916 let Inst{9-8} = index;
9919 multiclass sve2p1_pred_as_ctr_to_mask<string mnemonic, SDPatternOperator op> {
9920 def _B : sve2p1_pred_as_ctr_to_mask<mnemonic, 0b00, PPR8>;
9921 def _H : sve2p1_pred_as_ctr_to_mask<mnemonic, 0b01, PPR16>;
9922 def _S : sve2p1_pred_as_ctr_to_mask<mnemonic, 0b10, PPR32>;
9923 def _D : sve2p1_pred_as_ctr_to_mask<mnemonic, 0b11, PPR64>;
9925 def : SVE_2_Op_Imm_Pat<nxv16i1, op, aarch64svcount, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _B)>;
9926 def : SVE_2_Op_Imm_Pat<nxv8i1, op, aarch64svcount, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _H)>;
9927 def : SVE_2_Op_Imm_Pat<nxv4i1, op, aarch64svcount, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
9928 def : SVE_2_Op_Imm_Pat<nxv2i1, op, aarch64svcount, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _D)>;
9932 class sve2p1_pred_as_ctr_to_mask_pair<string mnemonic, bits<2> sz, RegisterOperand pprty>
9933 : sve2p1_pred_as_ctr_to_mask_base<mnemonic, sz, {1, 0, ?}, pprty, VectorIndexD> {
9935 let Inst{8} = index;
9938 multiclass sve2p1_pred_as_ctr_to_mask_pair<string mnemonic> {
9939 def _B : sve2p1_pred_as_ctr_to_mask_pair<mnemonic, 0b00, PP_b>;
9940 def _H : sve2p1_pred_as_ctr_to_mask_pair<mnemonic, 0b01, PP_h>;
9941 def _S : sve2p1_pred_as_ctr_to_mask_pair<mnemonic, 0b10, PP_s>;
9942 def _D : sve2p1_pred_as_ctr_to_mask_pair<mnemonic, 0b11, PP_d>;
9946 // SME2 multi-vec extract narrow
9947 class sve2p1_multi_vec_extract_narrow<string mnemonic, bits<2> opc, bits<3> tsz>
9948 : I<(outs ZPR16:$Zd), (ins ZZ_s_mul_r:$Zn),
9949 mnemonic, "\t$Zd, $Zn",
9950 "", []>, Sched<[]> {
9953 let Inst{31-23} = 0b010001010;
9954 let Inst{22} = tsz{2};
9956 let Inst{20-19} = tsz{1-0};
9957 let Inst{18-13} = 0b001010;
9958 let Inst{12-11} = opc;
9964 let hasSideEffects = 0;
9967 multiclass sve2p1_multi_vec_extract_narrow<string mnemonic, bits<2> opc, SDPatternOperator intrinsic> {
9968 def NAME : sve2p1_multi_vec_extract_narrow<mnemonic, opc, 0b010>;
9969 def : SVE2p1_Cvt_VG2_Pat<NAME, intrinsic, nxv8i16, nxv4i32>;
9972 // SVE2 multi-vec shift narrow
9973 class sve2p1_multi_vec_shift_narrow<string mnemonic, bits<3> opc, bits<2> tsz>
9974 : I<(outs ZPR16:$Zd), (ins ZZ_s_mul_r:$Zn, tvecshiftR16:$imm4),
9975 mnemonic, "\t$Zd, $Zn, $imm4",
9976 "", []>, Sched<[]> {
9980 let Inst{31-23} = 0b010001011;
9981 let Inst{22} = tsz{1};
9983 let Inst{20} = tsz{0};
9984 let Inst{19-16} = imm4;
9985 let Inst{15-14} = 0b00;
9986 let Inst{13-11} = opc;
9992 let hasSideEffects = 0;
9995 multiclass sve2p1_multi_vec_shift_narrow<string mnemonic, bits<3> opc, SDPatternOperator intrinsic> {
9996 def NAME : sve2p1_multi_vec_shift_narrow<mnemonic, opc, 0b01>;
9998 def : SVE2p1_Sat_Shift_VG2_Pat<NAME, intrinsic, nxv8i16, nxv4i32, tvecshiftR16>;
10002 // SME2 multi-vec contiguous load (scalar plus scalar, two registers)
10003 class sve2p1_mem_cld_ss_2z<string mnemonic, bits<2> msz, bit n,
10004 RegisterOperand vector_ty, RegisterOperand gpr_ty>
10005 : I<(outs vector_ty:$Zt),
10006 (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
10007 mnemonic, "\t$Zt, $PNg/z, [$Rn, $Rm]",
10008 "", []>, Sched<[]> {
10013 let Inst{31-21} = 0b10100000000;
10014 let Inst{20-16} = Rm;
10015 let Inst{15} = 0b0;
10016 let Inst{14-13} = msz;
10017 let Inst{12-10} = PNg;
10018 let Inst{9-5} = Rn;
10019 let Inst{4-1} = Zt;
10022 let hasSideEffects = 0;
10026 multiclass sve2p1_mem_cld_ss_2z<string mnemonic, bits<2> msz, bit n,
10027 RegisterOperand vector_ty, RegisterOperand gpr_ty, RegisterOperand vector_pseudo_ty> {
10028 def NAME # _PSEUDO : Pseudo<(outs vector_pseudo_ty:$Zt), (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm), []>;
10029 def NAME : sve2p1_mem_cld_ss_2z<mnemonic, msz, n, vector_ty, gpr_ty>;
10032 // SME2 multi-vec contiguous load (scalar plus immediate, two registers)
10033 class sve2p1_mem_cld_si_2z<string mnemonic, bits<2> msz, bit n,
10034 RegisterOperand vector_ty>
10035 : I<(outs vector_ty:$Zt),
10036 (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s2:$imm4),
10037 mnemonic, "\t$Zt, $PNg/z, [$Rn, $imm4, mul vl]",
10038 "", []>, Sched<[]> {
10043 let Inst{31-20} = 0b101000000100;
10044 let Inst{19-16} = imm4;
10045 let Inst{15} = 0b0;
10046 let Inst{14-13} = msz;
10047 let Inst{12-10} = PNg;
10048 let Inst{9-5} = Rn;
10049 let Inst{4-1} = Zt;
10052 let hasSideEffects = 0;
10056 multiclass sve2p1_mem_cld_si_2z<string mnemonic, bits<2> msz, bit n,
10057 RegisterOperand vector_ty, RegisterOperand vector_pseudo_ty> {
10058 def NAME : sve2p1_mem_cld_si_2z<mnemonic, msz, n, vector_ty>;
10059 def : InstAlias<mnemonic # " $Zt, $PNg/z, [$Rn]",
10060 (!cast<Instruction>(NAME) vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, 0), 1>;
10061 def NAME # _PSEUDO : Pseudo<(outs vector_pseudo_ty:$Zt), (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s2:$imm4), []>;
10064 // SME2 multi-vec contiguous load (scalar plus scalar, four registers)
10065 class sve2p1_mem_cld_ss_4z<string mnemonic, bits<2> msz, bit n,
10066 RegisterOperand vector_ty, RegisterOperand gpr_ty>
10067 : I<(outs vector_ty:$Zt),
10068 (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
10069 mnemonic, "\t$Zt, $PNg/z, [$Rn, $Rm]",
10070 "", []>, Sched<[]> {
10075 let Inst{31-21} = 0b10100000000;
10076 let Inst{20-16} = Rm;
10077 let Inst{15} = 0b1;
10078 let Inst{14-13} = msz;
10079 let Inst{12-10} = PNg;
10080 let Inst{9-5} = Rn;
10081 let Inst{4-2} = Zt;
10085 let hasSideEffects = 0;
10089 multiclass sve2p1_mem_cld_ss_4z<string mnemonic, bits<2> msz, bit n,
10090 RegisterOperand vector_ty, RegisterOperand gpr_ty, RegisterOperand vector_pseudo_ty> {
10091 def NAME # _PSEUDO : Pseudo<(outs vector_pseudo_ty:$Zt), (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm), []>;
10092 def NAME : sve2p1_mem_cld_ss_4z<mnemonic, msz, n, vector_ty, gpr_ty>;
10095 // SME2 multi-vec contiguous load (scalar plus immediate, four registers)
10096 class sve2p1_mem_cld_si_4z<string mnemonic, bits<2> msz, bit n,
10097 RegisterOperand vector_ty>
10098 : I<(outs vector_ty:$Zt),
10099 (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s4:$imm4),
10100 mnemonic, "\t$Zt, $PNg/z, [$Rn, $imm4, mul vl]",
10101 "", []>, Sched<[]> {
10106 let Inst{31-20} = 0b101000000100;
10107 let Inst{19-16} = imm4;
10108 let Inst{15} = 0b1;
10109 let Inst{14-13} = msz;
10110 let Inst{12-10} = PNg;
10111 let Inst{9-5} = Rn;
10112 let Inst{4-2} = Zt;
10116 let hasSideEffects = 0;
10120 multiclass sve2p1_mem_cld_si_4z<string mnemonic, bits<2> msz, bit n,
10121 RegisterOperand vector_ty, RegisterOperand vector_pseudo_ty> {
10122 def NAME : sve2p1_mem_cld_si_4z<mnemonic, msz, n, vector_ty>;
10123 def : InstAlias<mnemonic # " $Zt, $PNg/z, [$Rn]",
10124 (!cast<Instruction>(NAME) vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, 0), 1>;
10125 def NAME # _PSEUDO : Pseudo<(outs vector_pseudo_ty:$Zt), (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s4:$imm4), []>;
10128 // SME2 multi-vec contiguous store (scalar plus scalar, two registers)
10129 class sve2p1_mem_cst_ss_2z<string mnemonic, bits<2> msz, bit n,
10130 RegisterOperand vector_ty, RegisterOperand gpr_ty>
10132 (ins vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
10133 mnemonic, "\t$Zt, $PNg, [$Rn, $Rm]",
10134 "", []>, Sched<[]> {
10139 let Inst{31-21} = 0b10100000001;
10140 let Inst{20-16} = Rm;
10141 let Inst{15} = 0b0;
10142 let Inst{14-13} = msz;
10143 let Inst{12-10} = PNg;
10144 let Inst{9-5} = Rn;
10145 let Inst{4-1} = Zt;
10148 let hasSideEffects = 0;
10153 // SME2 multi-vec contiguous store (scalar plus immediate, two registers)
10154 class sve2p1_mem_cst_si_2z<string mnemonic, bits<2> msz, bit n,
10155 RegisterOperand vector_ty>
10157 (ins vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s2:$imm4),
10158 mnemonic, "\t$Zt, $PNg, [$Rn, $imm4, mul vl]",
10159 "", []>, Sched<[]> {
10164 let Inst{31-20} = 0b101000000110;
10165 let Inst{19-16} = imm4;
10166 let Inst{15} = 0b0;
10167 let Inst{14-13} = msz;
10168 let Inst{12-10} = PNg;
10169 let Inst{9-5} = Rn;
10170 let Inst{4-1} = Zt;
10173 let hasSideEffects = 0;
10178 multiclass sve2p1_mem_cst_si_2z<string mnemonic, bits<2> msz, bit n,
10179 RegisterOperand vector_ty> {
10180 def NAME : sve2p1_mem_cst_si_2z<mnemonic, msz, n, vector_ty>;
10182 def : InstAlias<mnemonic # " $Zt, $PNg, [$Rn]",
10183 (!cast<Instruction>(NAME) vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, 0), 1>;
10187 // SME2 multi-vec contiguous store (scalar plus scalar, four registers)
10188 class sve2p1_mem_cst_ss_4z<string mnemonic, bits<2> msz, bit n,
10189 RegisterOperand vector_ty, RegisterOperand gpr_ty>
10191 (ins vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
10192 mnemonic, "\t$Zt, $PNg, [$Rn, $Rm]",
10193 "", []>, Sched<[]> {
10198 let Inst{31-21} = 0b10100000001;
10199 let Inst{20-16} = Rm;
10200 let Inst{15} = 0b1;
10201 let Inst{14-13} = msz;
10202 let Inst{12-10} = PNg;
10203 let Inst{9-5} = Rn;
10204 let Inst{4-2} = Zt;
10212 // SME2 multi-vec contiguous store (scalar plus immediate, four registers)
10213 class sve2p1_mem_cst_si_4z<string mnemonic, bits<2> msz, bit n,
10214 RegisterOperand vector_ty>
10216 (ins vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, simm4s4:$imm4),
10217 mnemonic, "\t$Zt, $PNg, [$Rn, $imm4, mul vl]",
10218 "", []>, Sched<[]> {
10223 let Inst{31-20} = 0b101000000110;
10224 let Inst{19-16} = imm4;
10225 let Inst{15} = 0b1;
10226 let Inst{14-13} = msz;
10227 let Inst{12-10} = PNg;
10228 let Inst{9-5} = Rn;
10229 let Inst{4-2} = Zt;
10233 let hasSideEffects = 0;
10238 multiclass sve2p1_mem_cst_si_4z<string mnemonic, bits<2> msz, bit n,
10239 RegisterOperand vector_ty> {
10240 def NAME : sve2p1_mem_cst_si_4z<mnemonic, msz, n, vector_ty>;
10242 def : InstAlias<mnemonic # " $Zt, $PNg, [$Rn]",
10243 (!cast<Instruction>(NAME) vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn,0), 1>;
10246 // SVE predicate count (predicate-as-counter)
10247 class sve2p1_pcount_pn<string mnemonic, bits<3> opc, bits<2> sz, PNRRegOp pnrty>
10248 : I<(outs GPR64:$Rd),
10249 (ins pnrty:$PNn, sve_vec_len_specifier_enum:$vl),
10250 mnemonic, "\t$Rd, $PNn, $vl",
10251 "", []>, Sched<[]> {
10255 let Inst{31-24} = 0b00100101;
10256 let Inst{23-22} = sz;
10257 let Inst{21-19} = 0b100;
10258 let Inst{18-16} = opc;
10259 let Inst{15-11} = 0b10000;
10262 let Inst{8-5} = PNn;
10263 let Inst{4-0} = Rd;
10265 let hasSideEffects = 0;
10268 multiclass sve2p1_pcount_pn<string mnemonic, bits<3> opc> {
10269 def _B : sve2p1_pcount_pn<mnemonic, opc, 0b00, PNR8>;
10270 def _H : sve2p1_pcount_pn<mnemonic, opc, 0b01, PNR16>;
10271 def _S : sve2p1_pcount_pn<mnemonic, opc, 0b10, PNR32>;
10272 def _D : sve2p1_pcount_pn<mnemonic, opc, 0b11, PNR64>;
10274 defm : SVE2p1_Cntp_Pat<i64, int_aarch64_sve_cntp_c8, aarch64svcount, !cast<Instruction>(NAME # _B)>;
10275 defm : SVE2p1_Cntp_Pat<i64, int_aarch64_sve_cntp_c16, aarch64svcount, !cast<Instruction>(NAME # _H)>;
10276 defm : SVE2p1_Cntp_Pat<i64, int_aarch64_sve_cntp_c32, aarch64svcount, !cast<Instruction>(NAME # _S)>;
10277 defm : SVE2p1_Cntp_Pat<i64, int_aarch64_sve_cntp_c64, aarch64svcount, !cast<Instruction>(NAME # _D)>;
10281 // SVE integer compare scalar count and limit (predicate-as-counter)
10282 class sve2p1_int_while_rr_pn<string mnemonic, bits<2> sz, bits<3> opc,
10283 PNRP8to15RegOp pnrty>
10284 : I<(outs pnrty:$PNd), (ins GPR64:$Rn, GPR64:$Rm, sve_vec_len_specifier_enum:$vl),
10285 mnemonic, "\t$PNd, $Rn, $Rm, $vl",
10286 "", []>, Sched<[]> {
10291 let Inst{31-24} = 0b00100101;
10292 let Inst{23-22} = sz;
10293 let Inst{21} = 0b1;
10294 let Inst{20-16} = Rm;
10295 let Inst{15-14} = 0b01;
10297 let Inst{12} = 0b0;
10298 let Inst{11-10} = opc{2-1};
10299 let Inst{9-5} = Rn;
10301 let Inst{3} = opc{0};
10302 let Inst{2-0} = PNd;
10305 let hasSideEffects = 0;
10309 multiclass sve2p1_int_while_rr_pn<string mnemonic, bits<3> opc> {
10310 def _B : sve2p1_int_while_rr_pn<mnemonic, 0b00, opc, PNR8_p8to15>;
10311 def _H : sve2p1_int_while_rr_pn<mnemonic, 0b01, opc, PNR16_p8to15>;
10312 def _S : sve2p1_int_while_rr_pn<mnemonic, 0b10, opc, PNR32_p8to15>;
10313 def _D : sve2p1_int_while_rr_pn<mnemonic, 0b11, opc, PNR64_p8to15>;
10315 defm : SVE2p1_While_PN_Pat<aarch64svcount, !cast<SDPatternOperator>("int_aarch64_sve_" # mnemonic # "_c8"),
10316 i64, !cast<Instruction>(NAME # _B)>;
10317 defm : SVE2p1_While_PN_Pat<aarch64svcount, !cast<SDPatternOperator>("int_aarch64_sve_" # mnemonic # "_c16"),
10318 i64, !cast<Instruction>(NAME # _H)>;
10319 defm : SVE2p1_While_PN_Pat<aarch64svcount, !cast<SDPatternOperator>("int_aarch64_sve_" # mnemonic # "_c32"),
10320 i64, !cast<Instruction>(NAME # _S)>;
10321 defm : SVE2p1_While_PN_Pat<aarch64svcount, !cast<SDPatternOperator>("int_aarch64_sve_" # mnemonic # "_c64"),
10322 i64, !cast<Instruction>(NAME # _D)>;
10326 // SVE integer compare scalar count and limit (predicate pair)
10327 class sve2p1_int_while_rr_pair<string mnemonic, bits<2> sz, bits<3> opc,
10328 RegisterOperand ppr_ty>
10329 : I<(outs ppr_ty:$Pd), (ins GPR64:$Rn, GPR64:$Rm),
10330 mnemonic, "\t$Pd, $Rn, $Rm",
10331 "", []>, Sched<[]> {
10335 let Inst{31-24} = 0b00100101;
10336 let Inst{23-22} = sz;
10337 let Inst{21} = 0b1;
10338 let Inst{20-16} = Rm;
10339 let Inst{15-12} = 0b0101;
10340 let Inst{11-10} = opc{2-1};
10341 let Inst{9-5} = Rn;
10343 let Inst{3-1} = Pd;
10344 let Inst{0} = opc{0};
10347 let hasSideEffects = 0;
10351 multiclass sve2p1_int_while_rr_pair<string mnemonic, bits<3> opc> {
10352 def _B : sve2p1_int_while_rr_pair<mnemonic, 0b00, opc, PP_b_mul_r>;
10353 def _H : sve2p1_int_while_rr_pair<mnemonic, 0b01, opc, PP_h_mul_r>;
10354 def _S : sve2p1_int_while_rr_pair<mnemonic, 0b10, opc, PP_s_mul_r>;
10355 def _D : sve2p1_int_while_rr_pair<mnemonic, 0b11, opc, PP_d_mul_r>;
10359 class sve_mem_128b_gld_64_unscaled<string mnemonic>
10360 : I<(outs Z_q:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm),
10361 mnemonic, "\t$Zt, $Pg/z, [$Zn, $Rm]",
10362 "", []>, Sched<[]> {
10367 let Inst{31-21} = 0b11000100000;
10368 let Inst{20-16} = Rm;
10369 let Inst{15-13} = 0b101;
10370 let Inst{12-10} = Pg;
10371 let Inst{9-5} = Zn;
10372 let Inst{4-0} = Zt;
10374 let hasSideEffects = 0;
10379 multiclass sve_mem_128b_gld_64_unscaled<string mnemonic, SDPatternOperator op> {
10380 def NAME : sve_mem_128b_gld_64_unscaled<mnemonic>;
10382 def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Zn]",
10383 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
10386 def : Pat<(nxv2i64 (op (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv2i64)),
10387 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
10388 def : Pat<(nxv4i32 (op (nxv4i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv4i32)),
10389 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
10390 def : Pat<(nxv8i16 (op (nxv8i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8i16)),
10391 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
10392 def : Pat<(nxv16i8 (op (nxv16i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv16i8)),
10393 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
10395 def : Pat<(nxv2f64 (op (nxv2i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv2f64)),
10396 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
10397 def : Pat<(nxv4f32 (op (nxv4i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv4f32)),
10398 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
10399 def : Pat<(nxv8f16 (op (nxv8i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8f16)),
10400 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
10401 def : Pat<(nxv8bf16 (op (nxv8i1 PPR3bAny:$Pg), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8bf16)),
10402 (!cast<Instruction>(NAME) PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm)>;
10405 class sve_mem_sst_128b_64_unscaled<string mnemonic>
10406 : I<(outs ), (ins Z_q:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, GPR64:$Rm),
10407 mnemonic, "\t$Zt, $Pg, [$Zn, $Rm]",
10408 "", []>, Sched<[]> {
10413 let Inst{31-21} = 0b11100100001;
10414 let Inst{20-16} = Rm;
10415 let Inst{15-13} = 0b001;
10416 let Inst{12-10} = Pg;
10417 let Inst{9-5} = Zn;
10418 let Inst{4-0} = Zt;
10420 let hasSideEffects = 0;
10425 multiclass sve_mem_sst_128b_64_unscaled<string mnemonic, SDPatternOperator op> {
10426 def NAME : sve_mem_sst_128b_64_unscaled<mnemonic>;
10428 def : InstAlias<mnemonic # " $Zt, $Pg, [$Zn]",
10429 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, XZR), 1>;
10431 def : Pat<(op (nxv2i64 Z_q:$Zt), (nxv2i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv2i64),
10432 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
10433 def : Pat<(op (nxv4i32 Z_q:$Zt), (nxv4i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv4i32),
10434 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
10435 def : Pat<(op (nxv8i16 Z_q:$Zt), (nxv8i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8i16),
10436 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp,ZPR64:$Zn, GPR64:$Rm)>;
10437 def : Pat<(op (nxv16i8 Z_q:$Zt), (nxv16i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv16i8),
10438 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
10440 def : Pat<(op (nxv2f64 Z_q:$Zt), (nxv2i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv2f64),
10441 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
10442 def : Pat<(op (nxv4f32 Z_q:$Zt), (nxv4i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv4f32),
10443 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
10444 def : Pat<(op (nxv8f16 Z_q:$Zt), (nxv8i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8f16),
10445 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
10446 def : Pat<(op (nxv8bf16 Z_q:$Zt), (nxv8i1 PPR3bAny:$gp), (nxv2i64 ZPR64:$Zn), (i64 GPR64sp:$Rm), nxv8bf16),
10447 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$gp, ZPR64:$Zn, GPR64:$Rm)>;
10451 // SVE contiguous load (quadwords, scalar plus immediate)
10452 class sve_mem_128b_cld_si<bits<2> dtype, string mnemonic>
10453 : I<(outs Z_q:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
10454 mnemonic, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
10455 "", []>, Sched<[]> {
10460 let Inst{31-25} = 0b1010010;
10461 let Inst{24-23} = dtype;
10462 let Inst{22-20} = 0b001;
10463 let Inst{19-16} = imm4;
10464 let Inst{15-13} = 0b001;
10465 let Inst{12-10} = Pg;
10466 let Inst{9-5} = Rn;
10467 let Inst{4-0} = Zt;
10469 let hasSideEffects = 0;
10473 multiclass sve_mem_128b_cld_si<bits<2> dtype, string mnemonic> {
10474 def NAME : sve_mem_128b_cld_si<dtype, mnemonic>;
10476 def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Rn]",
10477 (!cast<Instruction>(NAME) Z_q:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
10478 def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Rn]",
10479 (!cast<Instruction>(NAME) ZPR128:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
10480 def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Rn, $imm4, mul vl]",
10481 (!cast<Instruction>(NAME) ZPR128:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
10485 // SVE contiguous load (quadwords, scalar plus scalar)
10486 class sve_mem_128b_cld_ss<bits<2> dtype, string mnemonic, RegisterOperand gprsh_ty>
10487 : I<(outs Z_q:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprsh_ty:$Rm),
10488 mnemonic, "\t$Zt, $Pg/z, [$Rn, $Rm]", "",
10494 let Inst{31-25} = 0b1010010;
10495 let Inst{24-23} = dtype;
10496 let Inst{22-21} = 0b00;
10497 let Inst{20-16} = Rm;
10498 let Inst{15-13} = 0b100;
10499 let Inst{12-10} = Pg;
10500 let Inst{9-5} = Rn;
10501 let Inst{4-0} = Zt;
10503 let hasSideEffects = 0;
10507 multiclass sve_mem_128b_cld_ss<bits<2> dtype, string mnemonic, RegisterOperand gprsh_ty> {
10508 def NAME : sve_mem_128b_cld_ss<dtype, mnemonic, gprsh_ty>;
10510 def : InstAlias<mnemonic # " $Zt, $Pg/z, [$Rn, $Rm]",
10511 (!cast<Instruction>(NAME) ZPR128:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprsh_ty:$Rm), 0>;
10515 // SVE floating-point recursive reduction (quadwords)
10516 class sve2p1_fp_reduction_q<bits<2> sz, bits<3> opc, string mnemonic,
10517 RegisterOperand zpr_ty, string vec_sfx>
10518 : I<(outs V128:$Vd), (ins PPR3bAny:$Pg, zpr_ty:$Zn),
10519 mnemonic, "\t$Vd." # vec_sfx # ", $Pg, $Zn",
10520 "", []>, Sched<[]> {
10524 let Inst{31-24} = 0b01100100;
10525 let Inst{23-22} = sz;
10526 let Inst{21-19} = 0b010;
10527 let Inst{18-16} = opc;
10528 let Inst{15-13} = 0b101;
10529 let Inst{12-10} = Pg;
10530 let Inst{9-5} = Zn;
10531 let Inst{4-0} = Vd;
10533 let hasSideEffects = 0;
10534 let mayRaiseFPException = 1;
10537 multiclass sve2p1_fp_reduction_q<bits<3> opc, string mnemonic, SDPatternOperator op> {
10538 def _H : sve2p1_fp_reduction_q<0b01, opc, mnemonic, ZPR16, "8h">;
10539 def _S : sve2p1_fp_reduction_q<0b10, opc, mnemonic, ZPR32, "4s">;
10540 def _D : sve2p1_fp_reduction_q<0b11, opc, mnemonic, ZPR64, "2d">;
10542 def : SVE_2_Op_Pat<v8f16, op, nxv8i1, nxv8f16, !cast<Instruction>(NAME # _H)>;
10543 def : SVE_2_Op_Pat<v4f32, op, nxv4i1, nxv4f32, !cast<Instruction>(NAME # _S)>;
10544 def : SVE_2_Op_Pat<v2f64, op, nxv2i1, nxv2f64, !cast<Instruction>(NAME # _D)>;
10548 // SVE Permute Vector - Quadwords (DUPQ)
10549 class sve2p1_dupq<bits<5> ind_tsz, string mnemonic, ZPRRegOp zprty, Operand itype>
10550 : I<(outs zprty:$Zd), (ins zprty:$Zn, itype:$index),
10551 mnemonic, "\t$Zd, $Zn$index",
10552 "", []>, Sched<[]> {
10555 let Inst{31-21} = 0b00000101001;
10556 let Inst{20-16} = ind_tsz;
10557 let Inst{15-10} = 0b001001;
10558 let Inst{9-5} = Zn;
10559 let Inst{4-0} = Zd;
10561 let hasSideEffects = 0;
10564 multiclass sve2p1_dupq<string mnemonic, SDPatternOperator Op> {
10565 def _B : sve2p1_dupq<{?, ?, ?, ?, 1}, mnemonic, ZPR8, VectorIndexB32b_timm> {
10567 let Inst{20-17} = index;
10569 def _H : sve2p1_dupq<{?, ?, ?, 1, 0}, mnemonic, ZPR16, VectorIndexH32b_timm> {
10571 let Inst{20-18} = index;
10573 def _S : sve2p1_dupq<{?, ?, 1, 0, 0}, mnemonic, ZPR32, VectorIndexS32b_timm> {
10575 let Inst{20-19} = index;
10577 def _D : sve2p1_dupq<{?, 1, 0, 0, 0}, mnemonic, ZPR64, VectorIndexD32b_timm> {
10579 let Inst{20} = index;
10582 def : SVE_2_Op_Imm_Pat<nxv16i8, Op, nxv16i8, i32, VectorIndexB32b_timm, !cast<Instruction>(NAME # _B)>;
10583 def : SVE_2_Op_Imm_Pat<nxv8i16, Op, nxv8i16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
10584 def : SVE_2_Op_Imm_Pat<nxv4i32, Op, nxv4i32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
10585 def : SVE_2_Op_Imm_Pat<nxv2i64, Op, nxv2i64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
10587 def : SVE_2_Op_Imm_Pat<nxv8f16, Op, nxv8f16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
10588 def : SVE_2_Op_Imm_Pat<nxv4f32, Op, nxv4f32, i32, VectorIndexS32b_timm, !cast<Instruction>(NAME # _S)>;
10589 def : SVE_2_Op_Imm_Pat<nxv2f64, Op, nxv2f64, i32, VectorIndexD32b_timm, !cast<Instruction>(NAME # _D)>;
10590 def : SVE_2_Op_Imm_Pat<nxv8bf16, Op, nxv8bf16, i32, VectorIndexH32b_timm, !cast<Instruction>(NAME # _H)>;
10594 // SVE Permute Vector - Quadwords (EXTQ)
10595 class sve2p1_extq<string mnemonic>
10596 : I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn, ZPR8:$Zm, timm32_0_15:$imm4),
10597 mnemonic, "\t$Zdn, $_Zdn, $Zm, $imm4",
10598 "", []>, Sched<[]> {
10602 let Inst{31-20} = 0b000001010110;
10603 let Inst{19-16} = imm4;
10604 let Inst{15-10} = 0b001001;
10605 let Inst{9-5} = Zm;
10606 let Inst{4-0} = Zdn;
10608 let Constraints = "$Zdn = $_Zdn";
10609 let DestructiveInstType = DestructiveOther;
10610 let ElementSize = ZPR8.ElementSize;
10611 let hasSideEffects = 0;
10614 multiclass sve2p1_extq<string mnemonic, SDPatternOperator Op> {
10615 def NAME : sve2p1_extq<mnemonic>;
10616 def : SVE_3_Op_Imm_Pat<nxv16i8, Op, nxv16i8, nxv16i8, i32, timm32_0_15, !cast<Instruction>(NAME)>;
10617 def : SVE_3_Op_Imm_Pat<nxv8i16, Op, nxv8i16, nxv8i16, i32, extq_timm32_0_7m2, !cast<Instruction>(NAME)>;
10618 def : SVE_3_Op_Imm_Pat<nxv4i32, Op, nxv4i32, nxv4i32, i32, extq_timm32_0_3m4, !cast<Instruction>(NAME)>;
10619 def : SVE_3_Op_Imm_Pat<nxv2i64, Op, nxv2i64, nxv2i64, i32, extq_timm32_0_1m8, !cast<Instruction>(NAME)>;
10621 def : SVE_3_Op_Imm_Pat<nxv8f16, Op, nxv8f16, nxv8f16, i32, extq_timm32_0_7m2, !cast<Instruction>(NAME)>;
10622 def : SVE_3_Op_Imm_Pat<nxv4f32, Op, nxv4f32, nxv4f32, i32, extq_timm32_0_3m4, !cast<Instruction>(NAME)>;
10623 def : SVE_3_Op_Imm_Pat<nxv2f64, Op, nxv2f64, nxv2f64, i32, extq_timm32_0_1m8, !cast<Instruction>(NAME)>;
10624 def : SVE_3_Op_Imm_Pat<nxv8bf16, Op, nxv8bf16, nxv8bf16, i32, extq_timm32_0_7m2, !cast<Instruction>(NAME)>;
10627 // SVE move predicate from vector
10628 class sve2p1_vector_to_pred<bits<4> opc, string mnemonic,
10629 PPRRegOp ppr_ty, Operand itype>
10630 : I<(outs ppr_ty:$Pd), (ins ZPRAny:$Zn, itype:$index),
10631 mnemonic, "\t$Pd, $Zn$index",
10632 "", []>, Sched<[]> {
10635 let Inst{31-24} = 0b00000101;
10636 let Inst{23-22} = opc{3-2};
10637 let Inst{21-19} = 0b101;
10638 let Inst{18-17} = opc{1-0};
10639 let Inst{16-10} = 0b0001110;
10640 let Inst{9-5} = Zn;
10642 let Inst{3-0} = Pd;
10644 let hasSideEffects = 0;
10647 multiclass sve2p1_vector_to_pred<string mnemonic, SDPatternOperator Op_lane, SDPatternOperator Op> {
10648 def _B : sve2p1_vector_to_pred<{0, 0, 0, 1}, mnemonic, PPR8, VectorIndex032b>;
10649 def _H : sve2p1_vector_to_pred<{0, 0, 1, ?}, mnemonic, PPR16, VectorIndexD32b> {
10651 let Inst{17} = index;
10653 def _S : sve2p1_vector_to_pred<{0, 1, ?, ?}, mnemonic, PPR32, VectorIndexS32b> {
10655 let Inst{18-17} = index;
10657 def _D : sve2p1_vector_to_pred<{1, ?, ?, ?}, mnemonic, PPR64, VectorIndexH32b> {
10659 let Inst{22} = index{2};
10660 let Inst{18-17} = index{1-0};
10663 def : InstAlias<mnemonic # "\t$Pd, $Zn",
10664 (!cast<Instruction>(NAME # _B) PPR8:$Pd, ZPRAny:$Zn, 0), 1>;
10665 def : InstAlias<mnemonic # "\t$Pd, $Zn",
10666 (!cast<Instruction>(NAME # _H) PPR16:$Pd, ZPRAny:$Zn, 0), 0>;
10667 def : InstAlias<mnemonic # "\t$Pd, $Zn",
10668 (!cast<Instruction>(NAME # _S) PPR32:$Pd, ZPRAny:$Zn, 0), 0>;
10669 def : InstAlias<mnemonic # "\t$Pd, $Zn",
10670 (!cast<Instruction>(NAME # _D) PPR64:$Pd, ZPRAny:$Zn, 0), 0>;
10673 def : Pat<(nxv16i1 (Op_lane (nxv16i8 ZPRAny:$Zn), (i32 timm32_0_0:$Idx))),
10674 (!cast<Instruction>(NAME # _B) ZPRAny:$Zn, timm32_0_0:$Idx)>;
10675 def : Pat<(nxv8i1 (Op_lane (nxv8i16 ZPRAny:$Zn), (i32 timm32_0_1:$Idx))),
10676 (!cast<Instruction>(NAME # _H) ZPRAny:$Zn, timm32_0_1:$Idx)>;
10677 def : Pat<(nxv4i1 (Op_lane (nxv4i32 ZPRAny:$Zn), (i32 timm32_0_3:$Idx))),
10678 (!cast<Instruction>(NAME # _S) ZPRAny:$Zn, timm32_0_3:$Idx)>;
10679 def : Pat<(nxv2i1 (Op_lane (nxv2i64 ZPRAny:$Zn), (i32 timm32_0_7:$Idx))),
10680 (!cast<Instruction>(NAME # _D) ZPRAny:$Zn, timm32_0_7:$Idx)>;
10682 def : Pat<(nxv16i1 (Op (nxv16i8 ZPRAny:$Zn))),
10683 (!cast<Instruction>(NAME # _B) ZPRAny:$Zn, 0)>;
10684 def : Pat<(nxv8i1 (Op (nxv8i16 ZPRAny:$Zn))),
10685 (!cast<Instruction>(NAME # _H) ZPRAny:$Zn, 0)>;
10686 def : Pat<(nxv4i1 (Op (nxv4i32 ZPRAny:$Zn))),
10687 (!cast<Instruction>(NAME # _S) ZPRAny:$Zn, 0)>;
10688 def : Pat<(nxv2i1 (Op (nxv2i64 ZPRAny:$Zn))),
10689 (!cast<Instruction>(NAME # _D) ZPRAny:$Zn, 0)>;
10693 // SVE move predicate into vector
10694 class sve2p1_pred_to_vector<bits<4> opc, string mnemonic,
10695 PPRRegOp ppr_ty, Operand itype>
10696 : I<(outs ZPRAny:$Zd), (ins ZPRAny:$_Zd, itype:$index, ppr_ty:$Pn),
10697 mnemonic, "\t$Zd$index, $Pn",
10698 "", []>, Sched<[]> {
10701 let Inst{31-24} = 0b00000101;
10702 let Inst{23-22} = opc{3-2};
10703 let Inst{21-19} = 0b101;
10704 let Inst{18-17} = opc{1-0};
10705 let Inst{16-9} = 0b10011100;
10706 let Inst{8-5} = Pn;
10707 let Inst{4-0} = Zd;
10709 let Constraints = "$Zd = $_Zd";
10710 let hasSideEffects = 0;
10713 multiclass sve2p1_pred_to_vector<string mnemonic, SDPatternOperator MergeOp,
10714 SDPatternOperator ZeroOp> {
10715 def _B : sve2p1_pred_to_vector<{0, 0, 0, 1}, mnemonic, PPR8, VectorIndex0>;
10716 def _H : sve2p1_pred_to_vector<{0, 0, 1, ?}, mnemonic, PPR16, VectorIndexD32b> {
10718 let Inst{17} = index;
10720 def _S : sve2p1_pred_to_vector<{0, 1, ?, ?}, mnemonic, PPR32, VectorIndexS32b> {
10722 let Inst{18-17} = index;
10724 def _D : sve2p1_pred_to_vector<{1, ?, ?, ?}, mnemonic, PPR64, VectorIndexH32b> {
10726 let Inst{22} = index{2};
10727 let Inst{18-17} = index{1-0};
10730 def : InstAlias<mnemonic # "\t$Zd, $Pn",
10731 (!cast<Instruction>(NAME # _B) ZPRAny:$Zd, 0, PPR8:$Pn), 1>;
10732 def : InstAlias<mnemonic # "\t$Zd, $Pn",
10733 (!cast<Instruction>(NAME # _H) ZPRAny:$Zd, 0, PPR16:$Pn), 0>;
10734 def : InstAlias<mnemonic # "\t$Zd, $Pn",
10735 (!cast<Instruction>(NAME # _S) ZPRAny:$Zd, 0, PPR32:$Pn), 0>;
10736 def : InstAlias<mnemonic # "\t$Zd, $Pn",
10737 (!cast<Instruction>(NAME # _D) ZPRAny:$Zd, 0, PPR64:$Pn), 0>;
10740 def : Pat<(nxv8i16 (MergeOp (nxv8i16 ZPRAny:$Zd), (nxv8i1 PPR16:$Pn), (i32 timm32_1_1:$Idx))),
10741 (!cast<Instruction>(NAME # _H) ZPRAny:$Zd, timm32_1_1:$Idx, PPR16:$Pn)>;
10742 def : Pat<(nxv4i32 (MergeOp (nxv4i32 ZPRAny:$Zd), (nxv4i1 PPR32:$Pn), (i32 timm32_1_3:$Idx))),
10743 (!cast<Instruction>(NAME # _S) ZPRAny:$Zd, timm32_1_3:$Idx, PPR32:$Pn)>;
10744 def : Pat<(nxv2i64 (MergeOp (nxv2i64 ZPRAny:$Zd), (nxv2i1 PPR64:$Pn), (i32 timm32_1_7:$Idx))),
10745 (!cast<Instruction>(NAME # _D) ZPRAny:$Zd, timm32_1_7:$Idx, PPR64:$Pn)>;
10748 def : Pat<(nxv16i8 (ZeroOp (nxv16i1 PPR8:$Pn))),
10749 (!cast<Instruction>(NAME # _B) (IMPLICIT_DEF), 0, PPR8:$Pn)>;
10750 def : Pat<(nxv8i16 (ZeroOp (nxv8i1 PPR16:$Pn))),
10751 (!cast<Instruction>(NAME # _H) (IMPLICIT_DEF), 0, PPR16:$Pn)>;
10752 def : Pat<(nxv4i32 (ZeroOp (nxv4i1 PPR32:$Pn))),
10753 (!cast<Instruction>(NAME # _S) (IMPLICIT_DEF), 0, PPR32:$Pn)>;
10754 def : Pat<(nxv2i64 (ZeroOp (nxv2i1 PPR64:$Pn))),
10755 (!cast<Instruction>(NAME # _D) (IMPLICIT_DEF), 0, PPR64:$Pn)>;
10759 // SVE bitwise logical/add/min/max reductions (quadwords)
10760 class sve2p1_int_reduce_q<bits<2> sz, bits<4> opc, string mnemonic,
10761 RegisterOperand zpr_ty, string vec_sfx>
10762 : I<(outs V128:$Vd), (ins PPR3bAny:$Pg, zpr_ty:$Zn),
10763 mnemonic, "\t$Vd." # vec_sfx # ", $Pg, $Zn",
10764 "", []>, Sched<[]> {
10768 let Inst{31-24} = 0b00000100;
10769 let Inst{23-22} = sz;
10770 let Inst{21} = 0b0;
10771 let Inst{20-19} = opc{3-2};
10772 let Inst{18} = 0b1;
10773 let Inst{17-16} = opc{1-0};
10774 let Inst{15-13} = 0b001;
10775 let Inst{12-10} = Pg;
10776 let Inst{9-5} = Zn;
10777 let Inst{4-0} = Vd;
10779 let hasSideEffects = 0;
10782 multiclass sve2p1_int_reduce_q<bits<4> opc, string mnemonic, SDPatternOperator op> {
10783 def _B : sve2p1_int_reduce_q<0b00, opc, mnemonic, ZPR8, "16b">;
10784 def _H : sve2p1_int_reduce_q<0b01, opc, mnemonic, ZPR16, "8h">;
10785 def _S : sve2p1_int_reduce_q<0b10, opc, mnemonic, ZPR32, "4s">;
10786 def _D : sve2p1_int_reduce_q<0b11, opc, mnemonic, ZPR64, "2d">;
10788 def : SVE_2_Op_Pat<v16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
10789 def : SVE_2_Op_Pat<v8i16, op, nxv8i1, nxv8i16, !cast<Instruction>(NAME # _H)>;
10790 def : SVE_2_Op_Pat<v4i32, op, nxv4i1, nxv4i32, !cast<Instruction>(NAME # _S)>;
10791 def : SVE_2_Op_Pat<v2i64, op, nxv2i1, nxv2i64, !cast<Instruction>(NAME # _D)>;
10795 // SVE permute vector elements (quadwords)
10796 class sve2p1_permute_vec_elems_q<bits<2> sz, bits<3> opc, string mnemonic,
10797 ZPRRegOp zpr_ty, RegisterOperand src1_ty>
10798 : I<(outs zpr_ty:$Zd), (ins src1_ty:$Zn, zpr_ty:$Zm),
10799 mnemonic, "\t$Zd, $Zn, $Zm",
10800 "", []>, Sched<[]> {
10804 let Inst{31-24} = 0b01000100;
10805 let Inst{23-22} = sz;
10806 let Inst{21} = 0b0;
10807 let Inst{20-16} = Zm;
10808 let Inst{15-13} = 0b111;
10809 let Inst{12-10} = opc;
10810 let Inst{9-5} = Zn;
10811 let Inst{4-0} = Zd;
10813 let hasSideEffects = 0;
10816 multiclass sve2p1_permute_vec_elems_q<bits<3> opc, string mnemonic,
10817 SDPatternOperator op> {
10818 def _B : sve2p1_permute_vec_elems_q<0b00, opc, mnemonic, ZPR8, ZPR8>;
10819 def _H : sve2p1_permute_vec_elems_q<0b01, opc, mnemonic, ZPR16, ZPR16>;
10820 def _S : sve2p1_permute_vec_elems_q<0b10, opc, mnemonic, ZPR32, ZPR32>;
10821 def _D : sve2p1_permute_vec_elems_q<0b11, opc, mnemonic, ZPR64, ZPR64>;
10823 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
10824 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
10825 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
10826 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
10828 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8f16, !cast<Instruction>(NAME # _H)>;
10829 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4f32, !cast<Instruction>(NAME # _S)>;
10830 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2f64, !cast<Instruction>(NAME # _D)>;
10832 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME # _H)>;
10835 multiclass sve2p1_tblq<string mnemonic, SDPatternOperator op> {
10836 def _B : sve2p1_permute_vec_elems_q<0b00, 0b110, mnemonic, ZPR8, Z_b>;
10837 def _H : sve2p1_permute_vec_elems_q<0b01, 0b110, mnemonic, ZPR16, Z_h>;
10838 def _S : sve2p1_permute_vec_elems_q<0b10, 0b110, mnemonic, ZPR32, Z_s>;
10839 def _D : sve2p1_permute_vec_elems_q<0b11, 0b110, mnemonic, ZPR64, Z_d>;
10841 def : SVE_2_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
10842 def : SVE_2_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
10843 def : SVE_2_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
10844 def : SVE_2_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
10846 def : SVE_2_Op_Pat<nxv8f16, op, nxv8f16, nxv8i16, !cast<Instruction>(NAME # _H)>;
10847 def : SVE_2_Op_Pat<nxv4f32, op, nxv4f32, nxv4i32, !cast<Instruction>(NAME # _S)>;
10848 def : SVE_2_Op_Pat<nxv2f64, op, nxv2f64, nxv2i64, !cast<Instruction>(NAME # _D)>;
10850 def : SVE_2_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8i16, !cast<Instruction>(NAME # _H)>;
10853 //===----------------------------------------------------------------------===//
10854 // SVE2 FP8 Instructions
10855 //===----------------------------------------------------------------------===//
10858 class sve2_fp8_cvt_single<bit L, bits<2> opc, string mnemonic,
10859 ZPRRegOp dst_ty, ZPRRegOp src_ty>
10860 : I<(outs dst_ty:$Zd), (ins src_ty:$Zn),
10861 mnemonic, "\t$Zd, $Zn",
10862 "", []>, Sched<[]>{
10865 let Inst{31-17} = 0b011001010000100;
10867 let Inst{15-12} = 0b0011;
10868 let Inst{11-10} = opc;
10869 let Inst{9-5} = Zn;
10870 let Inst{4-0} = Zd;
10871 let Uses = [FPMR, FPCR];
10877 multiclass sve2_fp8_cvt_single<bit L, bits<2> opc, string mnemonic, ValueType vtd, SDPatternOperator op> {
10878 def _BtoH : sve2_fp8_cvt_single<L, opc, mnemonic, ZPR16, ZPR8>;
10880 def : SVE_1_Op_Pat<vtd, op, nxv16i8, !cast<Instruction>(NAME # _BtoH)>;
10884 class sve2_fp8_down_cvt_single<bits<2> opc, string mnemonic,
10885 ZPRRegOp dst_ty, RegisterOperand src_ty>
10886 : I<(outs dst_ty:$Zd), (ins src_ty:$Zn),
10887 mnemonic, "\t$Zd, $Zn",
10888 "", []>, Sched<[]>{
10891 let Inst{31-12} = 0b01100101000010100011;
10892 let Inst{11-10} = opc;
10893 let Inst{9-6} = Zn;
10895 let Inst{4-0} = Zd;
10896 let Uses = [FPMR, FPCR];
10902 multiclass sve2_fp8_down_cvt_single<bits<2> opc, string mnemonic, RegisterOperand src,
10903 ValueType ty, SDPatternOperator op> {
10904 def NAME : sve2_fp8_down_cvt_single<opc, mnemonic, ZPR8, src>;
10906 def : Pat<(nxv16i8 (op ty:$Zn1, ty:$Zn2)),
10907 (!cast<Instruction>(NAME) (REG_SEQUENCE ZPR2Mul2, $Zn1, zsub0, $Zn2, zsub1))>;
10910 class sve2_fp8_down_cvt_single_top<bits<2> opc, string mnemonic, RegisterOperand src_ty>
10911 : I<(outs ZPR8:$Zd), (ins ZPR8:$_Zd, src_ty:$Zn), mnemonic, "\t$Zd, $Zn","", []>, Sched<[]> {
10915 let Inst{31-12} = 0b01100101000010100011;
10916 let Inst{11-10} = opc;
10917 let Inst{9-6} = Zn;
10919 let Inst{4-0} = Zd;
10921 let Constraints = "$Zd = $_Zd";
10922 let DestructiveInstType = DestructiveOther;
10923 let ElementSize = ZPR8.ElementSize;
10925 let Uses = [FPMR, FPCR];
10930 multiclass sve2_fp8_down_cvt_single_top<bits<2> opc, string mnemonic, RegisterOperand src_ty,
10931 ValueType ty, SDPatternOperator op> {
10932 def NAME : sve2_fp8_down_cvt_single_top<opc, mnemonic, src_ty>;
10934 def : Pat<(nxv16i8 (op nxv16i8:$Zd, ty:$Zn1, ty:$Zn2)),
10935 (!cast<Instruction>(NAME) $Zd, (REG_SEQUENCE ZPR2Mul2, $Zn1, zsub0, $Zn2, zsub1))>;
10938 // FP8 Widening Multiply-Add Long - Indexed Group
10939 class sve2_fp8_mla_long_by_indexed_elem<bit T, string mnemonic>
10940 : I<(outs ZPR16:$Zda),
10941 (ins ZPR16:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, VectorIndexB32b:$imm4),
10942 mnemonic, "\t$Zda, $Zn, $Zm$imm4",
10943 "", []>, Sched<[]>{
10948 let Inst{31-24} = 0b01100100;
10950 let Inst{22-21} = 0b01;
10951 let Inst{20-19} = imm4{3-2};
10952 let Inst{18-16} = Zm;
10953 let Inst{15-12} = 0b0101;
10954 let Inst{11-10} = imm4{1-0};
10955 let Inst{9-5} = Zn;
10956 let Inst{4-0} = Zda;
10957 let Constraints = "$Zda = $_Zda";
10958 let DestructiveInstType = DestructiveOther;
10959 let ElementSize = ZPR16.ElementSize;
10960 let Uses = [FPMR, FPCR];
10963 multiclass sve2_fp8_mla_long_by_indexed_elem<bit T, string mnemonic, SDPatternOperator op> {
10964 def NAME : sve2_fp8_mla_long_by_indexed_elem<T, mnemonic>;
10966 def : SVE_4_Op_Pat<nxv8f16, op, nxv8f16, nxv16i8, nxv16i8, i32, !cast<Instruction>(NAME)>;
10969 // FP8 Widening Multiply-Add (Long)/(Long Long) Group
10970 class sve2_fp8_mla<bits<3>opc, ZPRRegOp dst_ty, string mnemonic>
10971 : I<(outs dst_ty:$Zda),
10972 (ins dst_ty:$_Zda, ZPR8:$Zn, ZPR8:$Zm),
10973 mnemonic, "\t$Zda, $Zn, $Zm",
10974 "", []>, Sched<[]>{
10978 let Inst{31-24} = 0b01100100;
10979 let Inst{23} = opc{2};
10980 let Inst{22-21} = 0b01;
10981 let Inst{20-16} = Zm;
10982 let Inst{15-14} = 0b10;
10983 let Inst{13-12} = opc{1-0};
10984 let Inst{11-10} = 0b10;
10985 let Inst{9-5} = Zn;
10986 let Inst{4-0} = Zda;
10987 let Constraints = "$Zda = $_Zda";
10988 let DestructiveInstType = DestructiveOther;
10989 let ElementSize = dst_ty.ElementSize;
10990 let Uses = [FPMR, FPCR];
10993 multiclass sve2_fp8_mla<bits<3> opc, ZPRRegOp dst_ty, string mnemonic, ValueType vta, SDPatternOperator op> {
10994 def NAME : sve2_fp8_mla<opc, dst_ty, mnemonic>;
10996 def : SVE_3_Op_Pat<vta, op, vta, nxv16i8, nxv16i8, !cast<Instruction>(NAME)>;
10999 // FP8 Widening Multiply-Add Long Long - Indexed Group
11000 class sve2_fp8_mla_long_long_by_indexed_elem<bits<2> TT, string mnemonic>
11001 : I<(outs ZPR32:$Zda),
11002 (ins ZPR32:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, VectorIndexB32b:$imm4),
11003 mnemonic, "\t$Zda, $Zn, $Zm$imm4",
11004 "", []>, Sched<[]>{
11009 let Inst{31-24} = 0b01100100;
11010 let Inst{23-22} = TT;
11011 let Inst{21} = 0b1;
11012 let Inst{20-19} = imm4{3-2};
11013 let Inst{18-16} = Zm;
11014 let Inst{15-12} = 0b1100;
11015 let Inst{11-10} = imm4{1-0};
11016 let Inst{9-5} = Zn;
11017 let Inst{4-0} = Zda;
11018 let Constraints = "$Zda = $_Zda";
11019 let DestructiveInstType = DestructiveOther;
11020 let ElementSize = ZPR32.ElementSize;
11021 let Uses = [FPMR, FPCR];
11024 multiclass sve2_fp8_mla_long_long_by_indexed_elem<bits<2> TT, string mnemonic, SDPatternOperator op> {
11025 def NAME : sve2_fp8_mla_long_long_by_indexed_elem<TT, mnemonic>;
11027 def : SVE_4_Op_Pat<nxv4f32, op, nxv4f32, nxv16i8, nxv16i8, i32, !cast<Instruction>(NAME)>;
11030 // FP8 Matrix Multiply-accumulate Group
11031 class sve2_fp8_mmla<bit opc, ZPRRegOp dst_ty, string mnemonic>
11032 : I<(outs dst_ty:$Zda),
11033 (ins dst_ty:$_Zda, ZPR8:$Zn, ZPR8:$Zm),
11034 mnemonic, "\t$Zda, $Zn, $Zm",
11035 "", []>, Sched<[]>{
11039 let Inst{31-23} = 0b011001000;
11040 let Inst{22} = opc;
11041 let Inst{21} = 0b1;
11042 let Inst{20-16} = Zm;
11043 let Inst{15-10} = 0b111000;
11044 let Inst{9-5} = Zn;
11045 let Inst{4-0} = Zda;
11046 let Constraints = "$Zda = $_Zda";
11047 let DestructiveInstType = DestructiveOther;
11048 let ElementSize = dst_ty.ElementSize;
11049 let Uses = [FPMR, FPCR];
11052 class sve_fp8_dot_indexed<bits<4> opc, ZPRRegOp dst_ty, Operand iop_ty, string mnemonic>
11053 : I<(outs dst_ty:$Zda), (ins dst_ty:$_Zda, ZPR8:$Zn, ZPR3b8:$Zm, iop_ty:$iop),
11054 mnemonic, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
11058 let Inst{31-23} = 0b011001000;
11059 let Inst{22} = opc{3};
11060 let Inst{21} = 0b1;
11061 let Inst{20-19} = opc{2-1};
11062 let Inst{18-16} = Zm;
11063 let Inst{15-12} = 0b0100;
11064 let Inst{11} = opc{0};
11065 let Inst{10} = 0b1;
11066 let Inst{9-5} = Zn;
11067 let Inst{4-0} = Zda;
11069 let Uses = [FPMR, FPCR];
11070 let Constraints = "$Zda = $_Zda";
11071 let DestructiveInstType = DestructiveOther;
11072 let hasSideEffects = 0;
11073 let mayRaiseFPException = 1;
11079 // FP8 Widening Dot-Product - Indexed Group
11080 multiclass sve2_fp8_dot_indexed_h<string asm, SDPatternOperator op> {
11081 def NAME : sve_fp8_dot_indexed<{0, ?, ?, ?}, ZPR16, VectorIndexH32b, asm> {
11084 let Inst{20-19} = iop{2-1};
11085 let Inst{11} = iop{0};
11088 def : SVE_4_Op_Pat<nxv8f16, op, nxv8f16, nxv16i8, nxv16i8, i32, !cast<Instruction>(NAME)>;
11091 multiclass sve2_fp8_dot_indexed_s<string asm, SDPatternOperator op> {
11092 def NAME : sve_fp8_dot_indexed<{1, ?, ?, 0}, ZPR32, VectorIndexS32b, asm> {
11095 let Inst{20-19} = iop{1-0};
11098 def : SVE_4_Op_Pat<nxv4f32, op, nxv4f32, nxv16i8, nxv16i8, i32, !cast<Instruction>(NAME)>;
11101 // FP8 Look up table
11102 class sve2_lut_vector_index<ZPRRegOp zd_ty, RegisterOperand zn_ty,
11103 Operand idx_ty, bits<4>opc, string mnemonic>
11104 : I<(outs zd_ty:$Zd), (ins zn_ty:$Zn, ZPRAny:$Zm, idx_ty:$idx),
11105 mnemonic, "\t$Zd, $Zn, $Zm$idx",
11106 "", []>, Sched<[]> {
11110 let Inst{31-24} = 0b01000101;
11111 let Inst{22} = opc{3};
11112 let Inst{21} = 0b1;
11113 let Inst{20-16} = Zm;
11114 let Inst{15-13} = 0b101;
11115 let Inst{12-10} = opc{2-0};
11116 let Inst{9-5} = Zn;
11117 let Inst{4-0} = Zd;
11120 // FP8 Look up table read with 2-bit indices
11121 multiclass sve2_luti2_vector_index<string mnemonic> {
11122 def _B : sve2_lut_vector_index<ZPR8, Z_b, VectorIndexS32b, {?, 0b100}, mnemonic> {
11124 let Inst{23-22} = idx;
11126 def _H : sve2_lut_vector_index<ZPR16, Z_h, VectorIndexH32b, {?,?,0b10}, mnemonic> {
11128 let Inst{23-22} = idx{2-1};
11129 let Inst{12} = idx{0};
11132 def : SVE_3_Op_Imm_Pat<nxv16i8, int_aarch64_sve_luti2_lane, nxv16i8, nxv16i8,
11133 i32, timm32_0_3, !cast<Instruction>(NAME # _B)>;
11134 def : SVE_3_Op_Imm_Pat<nxv8i16, int_aarch64_sve_luti2_lane, nxv8i16, nxv16i8,
11135 i32, timm32_0_7, !cast<Instruction>(NAME # _H)>;
11136 def : SVE_3_Op_Imm_Pat<nxv8f16, int_aarch64_sve_luti2_lane, nxv8f16, nxv16i8,
11137 i32, timm32_0_7, !cast<Instruction>(NAME # _H)>;
11138 def : SVE_3_Op_Imm_Pat<nxv8bf16, int_aarch64_sve_luti2_lane, nxv8bf16, nxv16i8,
11139 i32, timm32_0_7, !cast<Instruction>(NAME # _H)>;
11142 // FP8 Look up table read with 4-bit indices
11143 multiclass sve2_luti4_vector_index<string mnemonic> {
11144 def _B : sve2_lut_vector_index<ZPR8, Z_b, VectorIndexD32b, 0b1001, mnemonic> {
11146 let Inst{23} = idx;
11148 def _H : sve2_lut_vector_index<ZPR16, Z_h, VectorIndexS32b, {?, 0b111}, mnemonic> {
11150 let Inst{23-22} = idx;
11153 def : SVE_3_Op_Imm_Pat<nxv16i8, int_aarch64_sve_luti4_lane, nxv16i8, nxv16i8,
11154 i32, timm32_0_1, !cast<Instruction>(NAME # _B)>;
11155 def : SVE_3_Op_Imm_Pat<nxv8i16, int_aarch64_sve_luti4_lane, nxv8i16, nxv16i8,
11156 i32, timm32_0_3, !cast<Instruction>(NAME # _H)>;
11157 def : SVE_3_Op_Imm_Pat<nxv8f16, int_aarch64_sve_luti4_lane, nxv8f16, nxv16i8,
11158 i32, timm32_0_3, !cast<Instruction>(NAME # _H)>;
11159 def : SVE_3_Op_Imm_Pat<nxv8bf16, int_aarch64_sve_luti4_lane, nxv8bf16, nxv16i8,
11160 i32, timm32_0_3, !cast<Instruction>(NAME # _H)>;
11163 // FP8 Look up table read with 4-bit indices (two contiguous registers)
11164 multiclass sve2_luti4_vector_vg2_index<string mnemonic> {
11165 def NAME : sve2_lut_vector_index<ZPR16, ZZ_h, VectorIndexS32b, {?, 0b101}, mnemonic> {
11167 let Inst{23-22} = idx;
11170 def : Pat<(nxv8i16 (int_aarch64_sve_luti4_lane_x2 nxv8i16:$Op1, nxv8i16:$Op2,
11171 nxv16i8:$Op3, (i32 timm32_0_3:$Op4))),
11172 (nxv8i16 (!cast<Instruction>(NAME) (REG_SEQUENCE ZPR2, nxv8i16:$Op1, zsub0,
11173 nxv8i16:$Op2, zsub1),
11174 nxv16i8:$Op3, timm32_0_3:$Op4))>;
11175 def : Pat<(nxv8f16 (int_aarch64_sve_luti4_lane_x2 nxv8f16:$Op1, nxv8f16:$Op2,
11176 nxv16i8:$Op3, (i32 timm32_0_3:$Op4))),
11177 (nxv8f16 (!cast<Instruction>(NAME) (REG_SEQUENCE ZPR2, nxv8f16:$Op1, zsub0,
11178 nxv8f16:$Op2, zsub1),
11179 nxv16i8:$Op3, timm32_0_3:$Op4))>;
11180 def : Pat<(nxv8bf16 (int_aarch64_sve_luti4_lane_x2 nxv8bf16:$Op1, nxv8bf16:$Op2,
11181 nxv16i8:$Op3, (i32 timm32_0_3:$Op4))),
11182 (nxv8bf16 (!cast<Instruction>(NAME) (REG_SEQUENCE ZPR2, nxv8bf16:$Op1, zsub0,
11183 nxv8bf16:$Op2, zsub1),
11184 nxv16i8:$Op3, timm32_0_3:$Op4))>;
11187 //===----------------------------------------------------------------------===//
11188 // Checked Pointer Arithmetic (FEAT_CPA)
11189 //===----------------------------------------------------------------------===//
11190 class sve_int_mad_cpa<string asm>
11191 : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, ZPR64:$Zm, ZPR64:$Za),
11192 asm, "\t$Zdn, $Zm, $Za", "", []>, Sched<[]> {
11196 let Inst{31-24} = 0b01000100;
11197 let Inst{23-22} = 0b11; // sz
11198 let Inst{21} = 0b0;
11199 let Inst{20-16} = Zm;
11200 let Inst{15} = 0b1;
11201 let Inst{14-10} = 0b10110; // opc
11202 let Inst{9-5} = Za;
11203 let Inst{4-0} = Zdn;
11205 let Constraints = "$Zdn = $_Zdn";
11206 let DestructiveInstType = DestructiveOther;
11207 let ElementSize = ZPR64.ElementSize;
11208 let hasSideEffects = 0;
11211 class sve_int_mla_cpa<string asm>
11212 : sve2_int_mla<0b11, 0b10100, asm, ZPR64, ZPR64> {
11213 let Inst{15} = 0b1;
11215 let ElementSize = ZPR64.ElementSize;