[x86] fix assert with horizontal math + broadcast of vector (PR43402)
[llvm-core.git] / lib / Target / AArch64 / SVEInstrFormats.td
blob8c8713b464e816cf0b103903f3b391c1a022d49a
1 //=-- SVEInstrFormats.td -  AArch64 SVE Instruction classes -*- tablegen -*--=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // AArch64 Scalable Vector Extension (SVE) Instruction Class Definitions.
11 //===----------------------------------------------------------------------===//
13 def SVEPatternOperand : AsmOperandClass {
14   let Name = "SVEPattern";
15   let ParserMethod = "tryParseSVEPattern";
16   let PredicateMethod = "isSVEPattern";
17   let RenderMethod = "addImmOperands";
18   let DiagnosticType = "InvalidSVEPattern";
21 def sve_pred_enum : Operand<i32>, ImmLeaf<i32, [{
22   return (((uint32_t)Imm) < 32);
23   }]> {
25   let PrintMethod = "printSVEPattern";
26   let ParserMatchClass = SVEPatternOperand;
29 def SVEPrefetchOperand : AsmOperandClass {
30   let Name = "SVEPrefetch";
31   let ParserMethod = "tryParsePrefetch<true>";
32   let PredicateMethod = "isPrefetch";
33   let RenderMethod = "addPrefetchOperands";
36 def sve_prfop : Operand<i32>, ImmLeaf<i32, [{
37     return (((uint32_t)Imm) <= 15);
38   }]> {
39   let PrintMethod = "printPrefetchOp<true>";
40   let ParserMatchClass = SVEPrefetchOperand;
43 class SVELogicalImmOperand<int Width> : AsmOperandClass {
44   let Name = "SVELogicalImm" # Width;
45   let DiagnosticType = "LogicalSecondSource";
46   let PredicateMethod = "isLogicalImm<int" # Width # "_t>";
47   let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>";
50 def sve_logical_imm8 : Operand<i64> {
51   let ParserMatchClass = SVELogicalImmOperand<8>;
52   let PrintMethod = "printLogicalImm<int8_t>";
54   let MCOperandPredicate = [{
55     if (!MCOp.isImm())
56       return false;
57     int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
58     return AArch64_AM::isSVEMaskOfIdenticalElements<int8_t>(Val);
59   }];
62 def sve_logical_imm16 : Operand<i64> {
63   let ParserMatchClass = SVELogicalImmOperand<16>;
64   let PrintMethod = "printLogicalImm<int16_t>";
66   let MCOperandPredicate = [{
67     if (!MCOp.isImm())
68       return false;
69     int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
70     return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val);
71   }];
74 def sve_logical_imm32 : Operand<i64> {
75   let ParserMatchClass = SVELogicalImmOperand<32>;
76   let PrintMethod = "printLogicalImm<int32_t>";
78   let MCOperandPredicate = [{
79     if (!MCOp.isImm())
80       return false;
81     int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
82     return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val);
83   }];
86 class SVEPreferredLogicalImmOperand<int Width> : AsmOperandClass {
87   let Name = "SVEPreferredLogicalImm" # Width;
88   let PredicateMethod = "isSVEPreferredLogicalImm<int" # Width # "_t>";
89   let RenderMethod = "addLogicalImmOperands<int" # Width # "_t>";
92 def sve_preferred_logical_imm16 : Operand<i64> {
93   let ParserMatchClass = SVEPreferredLogicalImmOperand<16>;
94   let PrintMethod = "printSVELogicalImm<int16_t>";
96   let MCOperandPredicate = [{
97     if (!MCOp.isImm())
98       return false;
99     int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
100     return AArch64_AM::isSVEMaskOfIdenticalElements<int16_t>(Val) &&
101            AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
102   }];
105 def sve_preferred_logical_imm32 : Operand<i64> {
106   let ParserMatchClass =  SVEPreferredLogicalImmOperand<32>;
107   let PrintMethod = "printSVELogicalImm<int32_t>";
109   let MCOperandPredicate = [{
110     if (!MCOp.isImm())
111       return false;
112     int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
113     return AArch64_AM::isSVEMaskOfIdenticalElements<int32_t>(Val) &&
114            AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
115   }];
118 def sve_preferred_logical_imm64 : Operand<i64> {
119   let ParserMatchClass = SVEPreferredLogicalImmOperand<64>;
120   let PrintMethod = "printSVELogicalImm<int64_t>";
122   let MCOperandPredicate = [{
123     if (!MCOp.isImm())
124       return false;
125     int64_t Val = AArch64_AM::decodeLogicalImmediate(MCOp.getImm(), 64);
126     return AArch64_AM::isSVEMaskOfIdenticalElements<int64_t>(Val) &&
127            AArch64_AM::isSVEMoveMaskPreferredLogicalImmediate(Val);
128   }];
131 class SVELogicalImmNotOperand<int Width> : AsmOperandClass {
132   let Name = "SVELogicalImm" # Width # "Not";
133   let DiagnosticType = "LogicalSecondSource";
134   let PredicateMethod = "isLogicalImm<int" # Width # "_t>";
135   let RenderMethod = "addLogicalImmNotOperands<int" # Width # "_t>";
138 def sve_logical_imm8_not : Operand<i64> {
139   let ParserMatchClass = SVELogicalImmNotOperand<8>;
142 def sve_logical_imm16_not : Operand<i64> {
143   let ParserMatchClass = SVELogicalImmNotOperand<16>;
146 def sve_logical_imm32_not : Operand<i64> {
147   let ParserMatchClass = SVELogicalImmNotOperand<32>;
150 class SVEShiftedImmOperand<int ElementWidth, string Infix, string Predicate>
151     : AsmOperandClass {
152   let Name = "SVE" # Infix # "Imm" # ElementWidth;
153   let DiagnosticType = "Invalid" # Name;
154   let RenderMethod = "addImmWithOptionalShiftOperands<8>";
155   let ParserMethod = "tryParseImmWithOptionalShift";
156   let PredicateMethod = Predicate;
159 def SVECpyImmOperand8  : SVEShiftedImmOperand<8,  "Cpy", "isSVECpyImm<int8_t>">;
160 def SVECpyImmOperand16 : SVEShiftedImmOperand<16, "Cpy", "isSVECpyImm<int16_t>">;
161 def SVECpyImmOperand32 : SVEShiftedImmOperand<32, "Cpy", "isSVECpyImm<int32_t>">;
162 def SVECpyImmOperand64 : SVEShiftedImmOperand<64, "Cpy", "isSVECpyImm<int64_t>">;
164 def SVEAddSubImmOperand8  : SVEShiftedImmOperand<8,  "AddSub", "isSVEAddSubImm<int8_t>">;
165 def SVEAddSubImmOperand16 : SVEShiftedImmOperand<16, "AddSub", "isSVEAddSubImm<int16_t>">;
166 def SVEAddSubImmOperand32 : SVEShiftedImmOperand<32, "AddSub", "isSVEAddSubImm<int32_t>">;
167 def SVEAddSubImmOperand64 : SVEShiftedImmOperand<64, "AddSub", "isSVEAddSubImm<int64_t>">;
169 class imm8_opt_lsl<int ElementWidth, string printType,
170                    AsmOperandClass OpndClass, code Predicate>
171     : Operand<i32>, ImmLeaf<i32, Predicate> {
172   let EncoderMethod = "getImm8OptLsl";
173   let DecoderMethod = "DecodeImm8OptLsl<" # ElementWidth # ">";
174   let PrintMethod = "printImm8OptLsl<" # printType # ">";
175   let ParserMatchClass = OpndClass;
176   let MIOperandInfo = (ops i32imm, i32imm);
179 def cpy_imm8_opt_lsl_i8  : imm8_opt_lsl<8,  "int8_t",  SVECpyImmOperand8,  [{
180   return AArch64_AM::isSVECpyImm<int8_t>(Imm);
181 }]>;
182 def cpy_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "int16_t", SVECpyImmOperand16, [{
183   return AArch64_AM::isSVECpyImm<int16_t>(Imm);
184 }]>;
185 def cpy_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "int32_t", SVECpyImmOperand32, [{
186   return AArch64_AM::isSVECpyImm<int32_t>(Imm);
187 }]>;
188 def cpy_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "int64_t", SVECpyImmOperand64, [{
189   return AArch64_AM::isSVECpyImm<int64_t>(Imm);
190 }]>;
192 def addsub_imm8_opt_lsl_i8  : imm8_opt_lsl<8,  "uint8_t",  SVEAddSubImmOperand8,  [{
193   return AArch64_AM::isSVEAddSubImm<int8_t>(Imm);
194 }]>;
195 def addsub_imm8_opt_lsl_i16 : imm8_opt_lsl<16, "uint16_t", SVEAddSubImmOperand16, [{
196   return AArch64_AM::isSVEAddSubImm<int16_t>(Imm);
197 }]>;
198 def addsub_imm8_opt_lsl_i32 : imm8_opt_lsl<32, "uint32_t", SVEAddSubImmOperand32, [{
199   return AArch64_AM::isSVEAddSubImm<int32_t>(Imm);
200 }]>;
201 def addsub_imm8_opt_lsl_i64 : imm8_opt_lsl<64, "uint64_t", SVEAddSubImmOperand64, [{
202   return AArch64_AM::isSVEAddSubImm<int64_t>(Imm);
203 }]>;
205 class SVEExactFPImm<string Suffix, string ValA, string ValB> : AsmOperandClass {
206   let Name = "SVEExactFPImmOperand" # Suffix;
207   let DiagnosticType = "Invalid" # Name;
208   let ParserMethod = "tryParseFPImm<false>";
209   let PredicateMethod = "isExactFPImm<" # ValA # ", " # ValB # ">";
210   let RenderMethod = "addExactFPImmOperands<" # ValA # ", " # ValB # ">";
213 class SVEExactFPImmOperand<string Suffix, string ValA, string ValB> : Operand<i32> {
214   let PrintMethod = "printExactFPImm<" # ValA # ", " # ValB # ">";
215   let ParserMatchClass = SVEExactFPImm<Suffix, ValA, ValB>;
218 def sve_fpimm_half_one
219     : SVEExactFPImmOperand<"HalfOne", "AArch64ExactFPImm::half",
220                            "AArch64ExactFPImm::one">;
221 def sve_fpimm_half_two
222     : SVEExactFPImmOperand<"HalfTwo", "AArch64ExactFPImm::half",
223                            "AArch64ExactFPImm::two">;
224 def sve_fpimm_zero_one
225     : SVEExactFPImmOperand<"ZeroOne", "AArch64ExactFPImm::zero",
226                            "AArch64ExactFPImm::one">;
228 def sve_incdec_imm : Operand<i32>, ImmLeaf<i32, [{
229   return (((uint32_t)Imm) > 0) && (((uint32_t)Imm) < 17);
230 }]> {
231   let ParserMatchClass = Imm1_16Operand;
232   let EncoderMethod = "getSVEIncDecImm";
233   let DecoderMethod = "DecodeSVEIncDecImm";
236 //===----------------------------------------------------------------------===//
237 // SVE PTrue - These are used extensively throughout the pattern matching so
238 //             it's important we define them first.
239 //===----------------------------------------------------------------------===//
241 class sve_int_ptrue<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty>
242 : I<(outs pprty:$Pd), (ins sve_pred_enum:$pattern),
243   asm, "\t$Pd, $pattern",
244   "",
245   []>, Sched<[]> {
246   bits<4> Pd;
247   bits<5> pattern;
248   let Inst{31-24} = 0b00100101;
249   let Inst{23-22} = sz8_64;
250   let Inst{21-19} = 0b011;
251   let Inst{18-17} = opc{2-1};
252   let Inst{16}    = opc{0};
253   let Inst{15-10} = 0b111000;
254   let Inst{9-5}   = pattern;
255   let Inst{4}     = 0b0;
256   let Inst{3-0}   = Pd;
258   let Defs = !if(!eq (opc{0}, 1), [NZCV], []);
261 multiclass sve_int_ptrue<bits<3> opc, string asm> {
262   def _B : sve_int_ptrue<0b00, opc, asm, PPR8>;
263   def _H : sve_int_ptrue<0b01, opc, asm, PPR16>;
264   def _S : sve_int_ptrue<0b10, opc, asm, PPR32>;
265   def _D : sve_int_ptrue<0b11, opc, asm, PPR64>;
267   def : InstAlias<asm # "\t$Pd",
268                   (!cast<Instruction>(NAME # _B) PPR8:$Pd, 0b11111), 1>;
269   def : InstAlias<asm # "\t$Pd",
270                   (!cast<Instruction>(NAME # _H) PPR16:$Pd, 0b11111), 1>;
271   def : InstAlias<asm # "\t$Pd",
272                   (!cast<Instruction>(NAME # _S) PPR32:$Pd, 0b11111), 1>;
273   def : InstAlias<asm # "\t$Pd",
274                   (!cast<Instruction>(NAME # _D) PPR64:$Pd, 0b11111), 1>;
277 let Predicates = [HasSVE] in {
278   defm PTRUE  : sve_int_ptrue<0b000, "ptrue">;
279   defm PTRUES : sve_int_ptrue<0b001, "ptrues">;
282 //===----------------------------------------------------------------------===//
283 // SVE pattern match helpers.
284 //===----------------------------------------------------------------------===//
286 class SVE_3_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
287                    ValueType vt2, ValueType vt3, Instruction inst>
288 : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3)),
289       (inst $Op1, $Op2, $Op3)>;
291 //===----------------------------------------------------------------------===//
292 // SVE Predicate Misc Group
293 //===----------------------------------------------------------------------===//
295 class sve_int_pfalse<bits<6> opc, string asm>
296 : I<(outs PPR8:$Pd), (ins),
297   asm, "\t$Pd",
298   "",
299   []>, Sched<[]> {
300   bits<4> Pd;
301   let Inst{31-24} = 0b00100101;
302   let Inst{23-22} = opc{5-4};
303   let Inst{21-19} = 0b011;
304   let Inst{18-16} = opc{3-1};
305   let Inst{15-10} = 0b111001;
306   let Inst{9}     = opc{0};
307   let Inst{8-4}   = 0b00000;
308   let Inst{3-0}   = Pd;
311 class sve_int_ptest<bits<6> opc, string asm>
312 : I<(outs), (ins PPRAny:$Pg, PPR8:$Pn),
313   asm, "\t$Pg, $Pn",
314   "",
315   []>, Sched<[]> {
316   bits<4> Pg;
317   bits<4> Pn;
318   let Inst{31-24} = 0b00100101;
319   let Inst{23-22} = opc{5-4};
320   let Inst{21-19} = 0b010;
321   let Inst{18-16} = opc{3-1};
322   let Inst{15-14} = 0b11;
323   let Inst{13-10} = Pg;
324   let Inst{9}     = opc{0};
325   let Inst{8-5}   = Pn;
326   let Inst{4-0}   = 0b00000;
328   let Defs = [NZCV];
331 class sve_int_pfirst_next<bits<2> sz8_64, bits<5> opc, string asm,
332                           PPRRegOp pprty>
333 : I<(outs pprty:$Pdn), (ins PPRAny:$Pg, pprty:$_Pdn),
334   asm, "\t$Pdn, $Pg, $_Pdn",
335   "",
336   []>, Sched<[]> {
337   bits<4> Pdn;
338   bits<4> Pg;
339   let Inst{31-24} = 0b00100101;
340   let Inst{23-22} = sz8_64;
341   let Inst{21-19} = 0b011;
342   let Inst{18-16} = opc{4-2};
343   let Inst{15-11} = 0b11000;
344   let Inst{10-9}  = opc{1-0};
345   let Inst{8-5}   = Pg;
346   let Inst{4}     = 0;
347   let Inst{3-0}   = Pdn;
349   let Constraints = "$Pdn = $_Pdn";
350   let Defs = [NZCV];
353 multiclass sve_int_pfirst<bits<5> opc, string asm> {
354   def : sve_int_pfirst_next<0b01, opc, asm, PPR8>;
357 multiclass sve_int_pnext<bits<5> opc, string asm> {
358   def _B : sve_int_pfirst_next<0b00, opc, asm, PPR8>;
359   def _H : sve_int_pfirst_next<0b01, opc, asm, PPR16>;
360   def _S : sve_int_pfirst_next<0b10, opc, asm, PPR32>;
361   def _D : sve_int_pfirst_next<0b11, opc, asm, PPR64>;
364 //===----------------------------------------------------------------------===//
365 // SVE Predicate Count Group
366 //===----------------------------------------------------------------------===//
368 class sve_int_count_r<bits<2> sz8_64, bits<5> opc, string asm,
369                       RegisterOperand dty, PPRRegOp pprty, RegisterOperand sty>
370 : I<(outs dty:$Rdn), (ins pprty:$Pg, sty:$_Rdn),
371   asm, "\t$Rdn, $Pg",
372   "",
373   []>, Sched<[]> {
374   bits<5> Rdn;
375   bits<4> Pg;
376   let Inst{31-24} = 0b00100101;
377   let Inst{23-22} = sz8_64;
378   let Inst{21-19} = 0b101;
379   let Inst{18-16} = opc{4-2};
380   let Inst{15-11} = 0b10001;
381   let Inst{10-9}  = opc{1-0};
382   let Inst{8-5}   = Pg;
383   let Inst{4-0}   = Rdn;
385   // Signed 32bit forms require their GPR operand printed.
386   let AsmString = !if(!eq(opc{4,2-0}, 0b0000),
387                       !strconcat(asm, "\t$Rdn, $Pg, $_Rdn"),
388                       !strconcat(asm, "\t$Rdn, $Pg"));
389   let Constraints = "$Rdn = $_Rdn";
392 multiclass sve_int_count_r_s32<bits<5> opc, string asm> {
393   def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64as32>;
394   def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64as32>;
395   def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64as32>;
396   def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64as32>;
399 multiclass sve_int_count_r_u32<bits<5> opc, string asm> {
400   def _B : sve_int_count_r<0b00, opc, asm, GPR32z, PPR8, GPR32z>;
401   def _H : sve_int_count_r<0b01, opc, asm, GPR32z, PPR16, GPR32z>;
402   def _S : sve_int_count_r<0b10, opc, asm, GPR32z, PPR32, GPR32z>;
403   def _D : sve_int_count_r<0b11, opc, asm, GPR32z, PPR64, GPR32z>;
406 multiclass sve_int_count_r_x64<bits<5> opc, string asm> {
407   def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64z>;
408   def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64z>;
409   def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64z>;
410   def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64z>;
413 class sve_int_count_v<bits<2> sz8_64, bits<5> opc, string asm,
414                       ZPRRegOp zprty, PPRRegOp pprty>
415 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, pprty:$Pm),
416   asm, "\t$Zdn, $Pm",
417   "",
418   []>, Sched<[]> {
419   bits<4> Pm;
420   bits<5> Zdn;
421   let Inst{31-24} = 0b00100101;
422   let Inst{23-22} = sz8_64;
423   let Inst{21-19} = 0b101;
424   let Inst{18-16} = opc{4-2};
425   let Inst{15-11} = 0b10000;
426   let Inst{10-9}  = opc{1-0};
427   let Inst{8-5}   = Pm;
428   let Inst{4-0}   = Zdn;
430   let Constraints = "$Zdn = $_Zdn";
431   let DestructiveInstType = Destructive;
432   let ElementSize = ElementSizeNone;
435 multiclass sve_int_count_v<bits<5> opc, string asm> {
436   def _H : sve_int_count_v<0b01, opc, asm, ZPR16, PPR16>;
437   def _S : sve_int_count_v<0b10, opc, asm, ZPR32, PPR32>;
438   def _D : sve_int_count_v<0b11, opc, asm, ZPR64, PPR64>;
440   def : InstAlias<asm # "\t$Zdn, $Pm",
441                  (!cast<Instruction>(NAME # "_H") ZPR16:$Zdn, PPRAny:$Pm), 0>;
442   def : InstAlias<asm # "\t$Zdn, $Pm",
443                  (!cast<Instruction>(NAME # "_S") ZPR32:$Zdn, PPRAny:$Pm), 0>;
444   def : InstAlias<asm # "\t$Zdn, $Pm",
445                   (!cast<Instruction>(NAME # "_D") ZPR64:$Zdn, PPRAny:$Pm), 0>;
448 class sve_int_pcount_pred<bits<2> sz8_64, bits<4> opc, string asm,
449                           PPRRegOp pprty>
450 : I<(outs GPR64:$Rd), (ins PPRAny:$Pg, pprty:$Pn),
451   asm, "\t$Rd, $Pg, $Pn",
452   "",
453   []>, Sched<[]> {
454   bits<4> Pg;
455   bits<4> Pn;
456   bits<5> Rd;
457   let Inst{31-24} = 0b00100101;
458   let Inst{23-22} = sz8_64;
459   let Inst{21-19} = 0b100;
460   let Inst{18-16} = opc{3-1};
461   let Inst{15-14} = 0b10;
462   let Inst{13-10} = Pg;
463   let Inst{9}     = opc{0};
464   let Inst{8-5}   = Pn;
465   let Inst{4-0}   = Rd;
468 multiclass sve_int_pcount_pred<bits<4> opc, string asm> {
469   def _B : sve_int_pcount_pred<0b00, opc, asm, PPR8>;
470   def _H : sve_int_pcount_pred<0b01, opc, asm, PPR16>;
471   def _S : sve_int_pcount_pred<0b10, opc, asm, PPR32>;
472   def _D : sve_int_pcount_pred<0b11, opc, asm, PPR64>;
475 //===----------------------------------------------------------------------===//
476 // SVE Element Count Group
477 //===----------------------------------------------------------------------===//
479 class sve_int_count<bits<3> opc, string asm>
480 : I<(outs GPR64:$Rd), (ins sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
481   asm, "\t$Rd, $pattern, mul $imm4",
482   "",
483   []>, Sched<[]> {
484   bits<5> Rd;
485   bits<4> imm4;
486   bits<5> pattern;
487   let Inst{31-24} = 0b00000100;
488   let Inst{23-22} = opc{2-1};
489   let Inst{21-20} = 0b10;
490   let Inst{19-16} = imm4;
491   let Inst{15-11} = 0b11100;
492   let Inst{10}    = opc{0};
493   let Inst{9-5}   = pattern;
494   let Inst{4-0}   = Rd;
497 multiclass sve_int_count<bits<3> opc, string asm> {
498   def NAME : sve_int_count<opc, asm>;
500   def : InstAlias<asm # "\t$Rd, $pattern",
501                   (!cast<Instruction>(NAME) GPR64:$Rd, sve_pred_enum:$pattern, 1), 1>;
502   def : InstAlias<asm # "\t$Rd",
503                   (!cast<Instruction>(NAME) GPR64:$Rd, 0b11111, 1), 2>;
506 class sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty>
507 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
508   asm, "\t$Zdn, $pattern, mul $imm4",
509   "",
510   []>, Sched<[]> {
511   bits<5> Zdn;
512   bits<5> pattern;
513   bits<4> imm4;
514   let Inst{31-24} = 0b00000100;
515   let Inst{23-22} = opc{4-3};
516   let Inst{21}    = 0b1;
517   let Inst{20}    = opc{2};
518   let Inst{19-16} = imm4;
519   let Inst{15-12} = 0b1100;
520   let Inst{11-10} = opc{1-0};
521   let Inst{9-5}   = pattern;
522   let Inst{4-0}   = Zdn;
524   let Constraints = "$Zdn = $_Zdn";
525   let DestructiveInstType = Destructive;
526   let ElementSize = ElementSizeNone;
529 multiclass sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty> {
530   def NAME : sve_int_countvlv<opc, asm, zprty>;
532   def : InstAlias<asm # "\t$Zdn, $pattern",
533                   (!cast<Instruction>(NAME) zprty:$Zdn, sve_pred_enum:$pattern, 1), 1>;
534   def : InstAlias<asm # "\t$Zdn",
535                   (!cast<Instruction>(NAME) zprty:$Zdn, 0b11111, 1), 2>;
538 class sve_int_pred_pattern_a<bits<3> opc, string asm>
539 : I<(outs GPR64:$Rdn), (ins GPR64:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
540   asm, "\t$Rdn, $pattern, mul $imm4",
541   "",
542   []>, Sched<[]> {
543   bits<5> Rdn;
544   bits<5> pattern;
545   bits<4> imm4;
546   let Inst{31-24} = 0b00000100;
547   let Inst{23-22} = opc{2-1};
548   let Inst{21-20} = 0b11;
549   let Inst{19-16} = imm4;
550   let Inst{15-11} = 0b11100;
551   let Inst{10}    = opc{0};
552   let Inst{9-5}   = pattern;
553   let Inst{4-0}   = Rdn;
555   let Constraints = "$Rdn = $_Rdn";
558 multiclass sve_int_pred_pattern_a<bits<3> opc, string asm> {
559   def NAME : sve_int_pred_pattern_a<opc, asm>;
561   def : InstAlias<asm # "\t$Rdn, $pattern",
562                   (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1), 1>;
563   def : InstAlias<asm # "\t$Rdn",
564                   (!cast<Instruction>(NAME) GPR64:$Rdn, 0b11111, 1), 2>;
567 class sve_int_pred_pattern_b<bits<5> opc, string asm, RegisterOperand dt,
568                              RegisterOperand st>
569 : I<(outs dt:$Rdn), (ins st:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
570   asm, "\t$Rdn, $pattern, mul $imm4",
571   "",
572   []>, Sched<[]> {
573   bits<5> Rdn;
574   bits<5> pattern;
575   bits<4> imm4;
576   let Inst{31-24} = 0b00000100;
577   let Inst{23-22} = opc{4-3};
578   let Inst{21}    = 0b1;
579   let Inst{20}    = opc{2};
580   let Inst{19-16} = imm4;
581   let Inst{15-12} = 0b1111;
582   let Inst{11-10} = opc{1-0};
583   let Inst{9-5}   = pattern;
584   let Inst{4-0}   = Rdn;
586   // Signed 32bit forms require their GPR operand printed.
587   let AsmString = !if(!eq(opc{2,0}, 0b00),
588                       !strconcat(asm, "\t$Rdn, $_Rdn, $pattern, mul $imm4"),
589                       !strconcat(asm, "\t$Rdn, $pattern, mul $imm4"));
591   let Constraints = "$Rdn = $_Rdn";
594 multiclass sve_int_pred_pattern_b_s32<bits<5> opc, string asm> {
595   def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64as32>;
597   def : InstAlias<asm # "\t$Rd, $Rn, $pattern",
598                   (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, sve_pred_enum:$pattern, 1), 1>;
599   def : InstAlias<asm # "\t$Rd, $Rn",
600                   (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, 0b11111, 1), 2>;
603 multiclass sve_int_pred_pattern_b_u32<bits<5> opc, string asm> {
604   def NAME : sve_int_pred_pattern_b<opc, asm, GPR32z, GPR32z>;
606   def : InstAlias<asm # "\t$Rdn, $pattern",
607                   (!cast<Instruction>(NAME) GPR32z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
608   def : InstAlias<asm # "\t$Rdn",
609                   (!cast<Instruction>(NAME) GPR32z:$Rdn, 0b11111, 1), 2>;
612 multiclass sve_int_pred_pattern_b_x64<bits<5> opc, string asm> {
613   def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64z>;
615   def : InstAlias<asm # "\t$Rdn, $pattern",
616                   (!cast<Instruction>(NAME) GPR64z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
617   def : InstAlias<asm # "\t$Rdn",
618                   (!cast<Instruction>(NAME) GPR64z:$Rdn, 0b11111, 1), 2>;
622 //===----------------------------------------------------------------------===//
623 // SVE Permute - Cross Lane Group
624 //===----------------------------------------------------------------------===//
626 class sve_int_perm_dup_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
627                          RegisterClass srcRegType>
628 : I<(outs zprty:$Zd), (ins srcRegType:$Rn),
629   asm, "\t$Zd, $Rn",
630   "",
631   []>, Sched<[]> {
632   bits<5> Rn;
633   bits<5> Zd;
634   let Inst{31-24} = 0b00000101;
635   let Inst{23-22} = sz8_64;
636   let Inst{21-10} = 0b100000001110;
637   let Inst{9-5}   = Rn;
638   let Inst{4-0}   = Zd;
641 multiclass sve_int_perm_dup_r<string asm> {
642   def _B : sve_int_perm_dup_r<0b00, asm, ZPR8, GPR32sp>;
643   def _H : sve_int_perm_dup_r<0b01, asm, ZPR16, GPR32sp>;
644   def _S : sve_int_perm_dup_r<0b10, asm, ZPR32, GPR32sp>;
645   def _D : sve_int_perm_dup_r<0b11, asm, ZPR64, GPR64sp>;
647   def : InstAlias<"mov $Zd, $Rn",
648                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, GPR32sp:$Rn), 1>;
649   def : InstAlias<"mov $Zd, $Rn",
650                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, GPR32sp:$Rn), 1>;
651   def : InstAlias<"mov $Zd, $Rn",
652                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, GPR32sp:$Rn), 1>;
653   def : InstAlias<"mov $Zd, $Rn",
654                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, GPR64sp:$Rn), 1>;
657 class sve_int_perm_dup_i<bits<5> tsz, Operand immtype, string asm,
658                          ZPRRegOp zprty>
659 : I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$idx),
660   asm, "\t$Zd, $Zn$idx",
661   "",
662   []>, Sched<[]> {
663   bits<5> Zd;
664   bits<5> Zn;
665   bits<7> idx;
666   let Inst{31-24} = 0b00000101;
667   let Inst{23-22} = {?,?}; // imm3h
668   let Inst{21}    = 0b1;
669   let Inst{20-16} = tsz;
670   let Inst{15-10} = 0b001000;
671   let Inst{9-5}   = Zn;
672   let Inst{4-0}   = Zd;
675 multiclass sve_int_perm_dup_i<string asm> {
676   def _B : sve_int_perm_dup_i<{?,?,?,?,1}, sve_elm_idx_extdup_b, asm, ZPR8> {
677     let Inst{23-22} = idx{5-4};
678     let Inst{20-17} = idx{3-0};
679   }
680   def _H : sve_int_perm_dup_i<{?,?,?,1,0}, sve_elm_idx_extdup_h, asm, ZPR16> {
681     let Inst{23-22} = idx{4-3};
682     let Inst{20-18} = idx{2-0};
683   }
684   def _S : sve_int_perm_dup_i<{?,?,1,0,0}, sve_elm_idx_extdup_s, asm, ZPR32> {
685     let Inst{23-22} = idx{3-2};
686     let Inst{20-19}    = idx{1-0};
687   }
688   def _D : sve_int_perm_dup_i<{?,1,0,0,0}, sve_elm_idx_extdup_d, asm, ZPR64> {
689     let Inst{23-22} = idx{2-1};
690     let Inst{20}    = idx{0};
691   }
692   def _Q : sve_int_perm_dup_i<{1,0,0,0,0}, sve_elm_idx_extdup_q, asm, ZPR128> {
693     let Inst{23-22} = idx{1-0};
694   }
696   def : InstAlias<"mov $Zd, $Zn$idx",
697                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, sve_elm_idx_extdup_b:$idx), 1>;
698   def : InstAlias<"mov $Zd, $Zn$idx",
699                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, sve_elm_idx_extdup_h:$idx), 1>;
700   def : InstAlias<"mov $Zd, $Zn$idx",
701                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, sve_elm_idx_extdup_s:$idx), 1>;
702   def : InstAlias<"mov $Zd, $Zn$idx",
703                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, sve_elm_idx_extdup_d:$idx), 1>;
704   def : InstAlias<"mov $Zd, $Zn$idx",
705                   (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, ZPR128:$Zn, sve_elm_idx_extdup_q:$idx), 1>;
706   def : InstAlias<"mov $Zd, $Bn",
707                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, FPR8asZPR:$Bn, 0), 2>;
708   def : InstAlias<"mov $Zd, $Hn",
709                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, FPR16asZPR:$Hn, 0), 2>;
710   def : InstAlias<"mov $Zd, $Sn",
711                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, FPR32asZPR:$Sn, 0), 2>;
712   def : InstAlias<"mov $Zd, $Dn",
713                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, FPR64asZPR:$Dn, 0), 2>;
714   def : InstAlias<"mov $Zd, $Qn",
715                   (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, FPR128asZPR:$Qn, 0), 2>;
718 class sve_int_perm_tbl<bits<2> sz8_64, bits<2> opc, string asm,
719                        ZPRRegOp zprty, RegisterOperand VecList>
720 : I<(outs zprty:$Zd), (ins VecList:$Zn, zprty:$Zm),
721   asm, "\t$Zd, $Zn, $Zm",
722   "",
723   []>, Sched<[]> {
724   bits<5> Zd;
725   bits<5> Zm;
726   bits<5> Zn;
727   let Inst{31-24} = 0b00000101;
728   let Inst{23-22} = sz8_64;
729   let Inst{21}    = 0b1;
730   let Inst{20-16} = Zm;
731   let Inst{15-13} = 0b001;
732   let Inst{12-11} = opc;
733   let Inst{10}    = 0b0;
734   let Inst{9-5}   = Zn;
735   let Inst{4-0}   = Zd;
738 multiclass sve_int_perm_tbl<string asm> {
739   def _B : sve_int_perm_tbl<0b00, 0b10, asm, ZPR8,  Z_b>;
740   def _H : sve_int_perm_tbl<0b01, 0b10, asm, ZPR16, Z_h>;
741   def _S : sve_int_perm_tbl<0b10, 0b10, asm, ZPR32, Z_s>;
742   def _D : sve_int_perm_tbl<0b11, 0b10, asm, ZPR64, Z_d>;
744   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
745                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 0>;
746   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
747                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 0>;
748   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
749                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 0>;
750   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
751                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, ZPR64:$Zm), 0>;
754 multiclass sve2_int_perm_tbl<string asm> {
755   def _B : sve_int_perm_tbl<0b00, 0b01, asm, ZPR8,  ZZ_b>;
756   def _H : sve_int_perm_tbl<0b01, 0b01, asm, ZPR16, ZZ_h>;
757   def _S : sve_int_perm_tbl<0b10, 0b01, asm, ZPR32, ZZ_s>;
758   def _D : sve_int_perm_tbl<0b11, 0b01, asm, ZPR64, ZZ_d>;
761 class sve2_int_perm_tbx<bits<2> sz8_64, string asm, ZPRRegOp zprty>
762 : I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, zprty:$Zm),
763   asm, "\t$Zd, $Zn, $Zm",
764   "",
765   []>, Sched<[]> {
766   bits<5> Zd;
767   bits<5> Zm;
768   bits<5> Zn;
769   let Inst{31-24} = 0b00000101;
770   let Inst{23-22} = sz8_64;
771   let Inst{21}    = 0b1;
772   let Inst{20-16} = Zm;
773   let Inst{15-10} = 0b001011;
774   let Inst{9-5}   = Zn;
775   let Inst{4-0}   = Zd;
777   let Constraints = "$Zd = $_Zd";
780 multiclass sve2_int_perm_tbx<string asm> {
781   def _B : sve2_int_perm_tbx<0b00, asm, ZPR8>;
782   def _H : sve2_int_perm_tbx<0b01, asm, ZPR16>;
783   def _S : sve2_int_perm_tbx<0b10, asm, ZPR32>;
784   def _D : sve2_int_perm_tbx<0b11, asm, ZPR64>;
787 class sve_int_perm_reverse_z<bits<2> sz8_64, string asm, ZPRRegOp zprty>
788 : I<(outs zprty:$Zd), (ins zprty:$Zn),
789   asm, "\t$Zd, $Zn",
790   "",
791   []>, Sched<[]> {
792   bits<5> Zd;
793   bits<5> Zn;
794   let Inst{31-24} = 0b00000101;
795   let Inst{23-22} = sz8_64;
796   let Inst{21-10} = 0b111000001110;
797   let Inst{9-5}   = Zn;
798   let Inst{4-0}   = Zd;
801 multiclass sve_int_perm_reverse_z<string asm> {
802   def _B : sve_int_perm_reverse_z<0b00, asm, ZPR8>;
803   def _H : sve_int_perm_reverse_z<0b01, asm, ZPR16>;
804   def _S : sve_int_perm_reverse_z<0b10, asm, ZPR32>;
805   def _D : sve_int_perm_reverse_z<0b11, asm, ZPR64>;
808 class sve_int_perm_reverse_p<bits<2> sz8_64, string asm, PPRRegOp pprty>
809 : I<(outs pprty:$Pd), (ins pprty:$Pn),
810   asm, "\t$Pd, $Pn",
811   "",
812   []>, Sched<[]> {
813   bits<4> Pd;
814   bits<4> Pn;
815   let Inst{31-24} = 0b00000101;
816   let Inst{23-22} = sz8_64;
817   let Inst{21-9}  = 0b1101000100000;
818   let Inst{8-5}   = Pn;
819   let Inst{4}     = 0b0;
820   let Inst{3-0}   = Pd;
823 multiclass sve_int_perm_reverse_p<string asm> {
824   def _B : sve_int_perm_reverse_p<0b00, asm, PPR8>;
825   def _H : sve_int_perm_reverse_p<0b01, asm, PPR16>;
826   def _S : sve_int_perm_reverse_p<0b10, asm, PPR32>;
827   def _D : sve_int_perm_reverse_p<0b11, asm, PPR64>;
830 class sve_int_perm_unpk<bits<2> sz16_64, bits<2> opc, string asm,
831                         ZPRRegOp zprty1, ZPRRegOp zprty2>
832 : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
833   asm, "\t$Zd, $Zn",
834   "", []>, Sched<[]> {
835   bits<5> Zd;
836   bits<5> Zn;
837   let Inst{31-24} = 0b00000101;
838   let Inst{23-22} = sz16_64;
839   let Inst{21-18} = 0b1100;
840   let Inst{17-16} = opc;
841   let Inst{15-10} = 0b001110;
842   let Inst{9-5}   = Zn;
843   let Inst{4-0}   = Zd;
846 multiclass sve_int_perm_unpk<bits<2> opc, string asm> {
847   def _H : sve_int_perm_unpk<0b01, opc, asm, ZPR16, ZPR8>;
848   def _S : sve_int_perm_unpk<0b10, opc, asm, ZPR32, ZPR16>;
849   def _D : sve_int_perm_unpk<0b11, opc, asm, ZPR64, ZPR32>;
852 class sve_int_perm_insrs<bits<2> sz8_64, string asm, ZPRRegOp zprty,
853                          RegisterClass srcRegType>
854 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcRegType:$Rm),
855   asm, "\t$Zdn, $Rm",
856   "",
857   []>, Sched<[]> {
858   bits<5> Rm;
859   bits<5> Zdn;
860   let Inst{31-24} = 0b00000101;
861   let Inst{23-22} = sz8_64;
862   let Inst{21-10} = 0b100100001110;
863   let Inst{9-5}   = Rm;
864   let Inst{4-0}   = Zdn;
866   let Constraints = "$Zdn = $_Zdn";
867   let DestructiveInstType = Destructive;
868   let ElementSize = ElementSizeNone;
871 multiclass sve_int_perm_insrs<string asm> {
872   def _B : sve_int_perm_insrs<0b00, asm, ZPR8, GPR32>;
873   def _H : sve_int_perm_insrs<0b01, asm, ZPR16, GPR32>;
874   def _S : sve_int_perm_insrs<0b10, asm, ZPR32, GPR32>;
875   def _D : sve_int_perm_insrs<0b11, asm, ZPR64, GPR64>;
878 class sve_int_perm_insrv<bits<2> sz8_64, string asm, ZPRRegOp zprty,
879                          RegisterClass srcRegType>
880 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcRegType:$Vm),
881   asm, "\t$Zdn, $Vm",
882   "",
883   []>, Sched<[]> {
884   bits<5> Vm;
885   bits<5> Zdn;
886   let Inst{31-24} = 0b00000101;
887   let Inst{23-22} = sz8_64;
888   let Inst{21-10} = 0b110100001110;
889   let Inst{9-5}   = Vm;
890   let Inst{4-0}   = Zdn;
892   let Constraints = "$Zdn = $_Zdn";
893   let DestructiveInstType = Destructive;
894   let ElementSize = ElementSizeNone;
897 multiclass sve_int_perm_insrv<string asm> {
898   def _B : sve_int_perm_insrv<0b00, asm, ZPR8, FPR8>;
899   def _H : sve_int_perm_insrv<0b01, asm, ZPR16, FPR16>;
900   def _S : sve_int_perm_insrv<0b10, asm, ZPR32, FPR32>;
901   def _D : sve_int_perm_insrv<0b11, asm, ZPR64, FPR64>;
904 //===----------------------------------------------------------------------===//
905 // SVE Permute - Extract Group
906 //===----------------------------------------------------------------------===//
908 class sve_int_perm_extract_i<string asm>
909 : I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn, ZPR8:$Zm, imm0_255:$imm8),
910   asm, "\t$Zdn, $_Zdn, $Zm, $imm8",
911   "", []>, Sched<[]> {
912   bits<5> Zdn;
913   bits<5> Zm;
914   bits<8> imm8;
915   let Inst{31-21} = 0b00000101001;
916   let Inst{20-16} = imm8{7-3};
917   let Inst{15-13} = 0b000;
918   let Inst{12-10} = imm8{2-0};
919   let Inst{9-5}   = Zm;
920   let Inst{4-0}   = Zdn;
922   let Constraints = "$Zdn = $_Zdn";
923   let DestructiveInstType = Destructive;
924   let ElementSize = ElementSizeNone;
927 class sve2_int_perm_extract_i_cons<string asm>
928 : I<(outs ZPR8:$Zd), (ins ZZ_b:$Zn, imm0_255:$imm8),
929   asm, "\t$Zd, $Zn, $imm8",
930   "", []>, Sched<[]> {
931   bits<5> Zd;
932   bits<5> Zn;
933   bits<8> imm8;
934   let Inst{31-21} = 0b00000101011;
935   let Inst{20-16} = imm8{7-3};
936   let Inst{15-13} = 0b000;
937   let Inst{12-10} = imm8{2-0};
938   let Inst{9-5}   = Zn;
939   let Inst{4-0}   = Zd;
942 //===----------------------------------------------------------------------===//
943 // SVE Vector Select Group
944 //===----------------------------------------------------------------------===//
946 class sve_int_sel_vvv<bits<2> sz8_64, string asm, ZPRRegOp zprty>
947 : I<(outs zprty:$Zd), (ins PPRAny:$Pg, zprty:$Zn, zprty:$Zm),
948   asm, "\t$Zd, $Pg, $Zn, $Zm",
949   "",
950   []>, Sched<[]> {
951   bits<4> Pg;
952   bits<5> Zd;
953   bits<5> Zm;
954   bits<5> Zn;
955   let Inst{31-24} = 0b00000101;
956   let Inst{23-22} = sz8_64;
957   let Inst{21}    = 0b1;
958   let Inst{20-16} = Zm;
959   let Inst{15-14} = 0b11;
960   let Inst{13-10} = Pg;
961   let Inst{9-5}   = Zn;
962   let Inst{4-0}   = Zd;
965 multiclass sve_int_sel_vvv<string asm> {
966   def _B : sve_int_sel_vvv<0b00, asm, ZPR8>;
967   def _H : sve_int_sel_vvv<0b01, asm, ZPR16>;
968   def _S : sve_int_sel_vvv<0b10, asm, ZPR32>;
969   def _D : sve_int_sel_vvv<0b11, asm, ZPR64>;
971   def : InstAlias<"mov $Zd, $Pg/m, $Zn",
972                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPRAny:$Pg, ZPR8:$Zn, ZPR8:$Zd), 1>;
973   def : InstAlias<"mov $Zd, $Pg/m, $Zn",
974                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, ZPR16:$Zn, ZPR16:$Zd), 1>;
975   def : InstAlias<"mov $Zd, $Pg/m, $Zn",
976                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, ZPR32:$Zn, ZPR32:$Zd), 1>;
977   def : InstAlias<"mov $Zd, $Pg/m, $Zn",
978                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, ZPR64:$Zn, ZPR64:$Zd), 1>;
982 //===----------------------------------------------------------------------===//
983 // SVE Predicate Logical Operations Group
984 //===----------------------------------------------------------------------===//
986 class sve_int_pred_log<bits<4> opc, string asm>
987 : I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm),
988   asm, "\t$Pd, $Pg/z, $Pn, $Pm",
989   "",
990   []>, Sched<[]> {
991   bits<4> Pd;
992   bits<4> Pg;
993   bits<4> Pm;
994   bits<4> Pn;
995   let Inst{31-24} = 0b00100101;
996   let Inst{23-22} = opc{3-2};
997   let Inst{21-20} = 0b00;
998   let Inst{19-16} = Pm;
999   let Inst{15-14} = 0b01;
1000   let Inst{13-10} = Pg;
1001   let Inst{9}     = opc{1};
1002   let Inst{8-5}   = Pn;
1003   let Inst{4}     = opc{0};
1004   let Inst{3-0}   = Pd;
1006   // SEL has no predication qualifier.
1007   let AsmString = !if(!eq(opc, 0b0011),
1008                       !strconcat(asm, "\t$Pd, $Pg, $Pn, $Pm"),
1009                       !strconcat(asm, "\t$Pd, $Pg/z, $Pn, $Pm"));
1011   let Defs = !if(!eq (opc{2}, 1), [NZCV], []);
1015 //===----------------------------------------------------------------------===//
1016 // SVE Logical Mask Immediate Group
1017 //===----------------------------------------------------------------------===//
1019 class sve_int_log_imm<bits<2> opc, string asm>
1020 : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, logical_imm64:$imms13),
1021   asm, "\t$Zdn, $_Zdn, $imms13",
1022   "", []>, Sched<[]> {
1023   bits<5> Zdn;
1024   bits<13> imms13;
1025   let Inst{31-24} = 0b00000101;
1026   let Inst{23-22} = opc;
1027   let Inst{21-18} = 0b0000;
1028   let Inst{17-5}  = imms13;
1029   let Inst{4-0}   = Zdn;
1031   let Constraints = "$Zdn = $_Zdn";
1032   let DecoderMethod = "DecodeSVELogicalImmInstruction";
1033   let DestructiveInstType = Destructive;
1034   let ElementSize = ElementSizeNone;
1037 multiclass sve_int_log_imm<bits<2> opc, string asm, string alias> {
1038   def NAME : sve_int_log_imm<opc, asm>;
1040   def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
1041                   (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8:$imm), 4>;
1042   def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
1043                   (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16:$imm), 3>;
1044   def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
1045                   (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32:$imm), 2>;
1047   def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
1048                   (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8_not:$imm), 0>;
1049   def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
1050                   (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16_not:$imm), 0>;
1051   def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
1052                   (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32_not:$imm), 0>;
1053   def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
1054                   (!cast<Instruction>(NAME) ZPR64:$Zdn, logical_imm64_not:$imm), 0>;
1057 class sve_int_dup_mask_imm<string asm>
1058 : I<(outs ZPR64:$Zd), (ins logical_imm64:$imms),
1059   asm, "\t$Zd, $imms",
1060   "",
1061   []>, Sched<[]> {
1062   bits<5> Zd;
1063   bits<13> imms;
1064   let Inst{31-18} = 0b00000101110000;
1065   let Inst{17-5} = imms;
1066   let Inst{4-0} = Zd;
1068   let isReMaterializable = 1;
1069   let DecoderMethod = "DecodeSVELogicalImmInstruction";
1072 multiclass sve_int_dup_mask_imm<string asm> {
1073   def NAME : sve_int_dup_mask_imm<asm>;
1075   def : InstAlias<"dupm $Zd, $imm",
1076                   (!cast<Instruction>(NAME) ZPR8:$Zd, sve_logical_imm8:$imm), 4>;
1077   def : InstAlias<"dupm $Zd, $imm",
1078                   (!cast<Instruction>(NAME) ZPR16:$Zd, sve_logical_imm16:$imm), 3>;
1079   def : InstAlias<"dupm $Zd, $imm",
1080                   (!cast<Instruction>(NAME) ZPR32:$Zd, sve_logical_imm32:$imm), 2>;
1082   // All Zd.b forms have a CPY/DUP equivalent, hence no byte alias here.
1083   def : InstAlias<"mov $Zd, $imm",
1084                   (!cast<Instruction>(NAME) ZPR16:$Zd, sve_preferred_logical_imm16:$imm), 7>;
1085   def : InstAlias<"mov $Zd, $imm",
1086                   (!cast<Instruction>(NAME) ZPR32:$Zd, sve_preferred_logical_imm32:$imm), 6>;
1087   def : InstAlias<"mov $Zd, $imm",
1088                   (!cast<Instruction>(NAME) ZPR64:$Zd, sve_preferred_logical_imm64:$imm), 5>;
1091 //===----------------------------------------------------------------------===//
1092 // SVE Integer Arithmetic -  Unpredicated Group.
1093 //===----------------------------------------------------------------------===//
1095 class sve_int_bin_cons_arit_0<bits<2> sz8_64, bits<3> opc, string asm,
1096                               ZPRRegOp zprty>
1097 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
1098   asm, "\t$Zd, $Zn, $Zm",
1099   "", []>, Sched<[]> {
1100   bits<5> Zd;
1101   bits<5> Zm;
1102   bits<5> Zn;
1103   let Inst{31-24} = 0b00000100;
1104   let Inst{23-22} = sz8_64;
1105   let Inst{21}    = 0b1;
1106   let Inst{20-16} = Zm;
1107   let Inst{15-13} = 0b000;
1108   let Inst{12-10} = opc;
1109   let Inst{9-5}   = Zn;
1110   let Inst{4-0}   = Zd;
1113 multiclass sve_int_bin_cons_arit_0<bits<3> opc, string asm> {
1114   def _B : sve_int_bin_cons_arit_0<0b00, opc, asm, ZPR8>;
1115   def _H : sve_int_bin_cons_arit_0<0b01, opc, asm, ZPR16>;
1116   def _S : sve_int_bin_cons_arit_0<0b10, opc, asm, ZPR32>;
1117   def _D : sve_int_bin_cons_arit_0<0b11, opc, asm, ZPR64>;
1120 //===----------------------------------------------------------------------===//
1121 // SVE Floating Point Arithmetic - Predicated Group
1122 //===----------------------------------------------------------------------===//
1124 class sve_fp_2op_i_p_zds<bits<2> sz, bits<3> opc, string asm,
1125                          ZPRRegOp zprty,
1126                          Operand imm_ty>
1127 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, imm_ty:$i1),
1128   asm, "\t$Zdn, $Pg/m, $_Zdn, $i1",
1129   "",
1130   []>, Sched<[]> {
1131   bits<3> Pg;
1132   bits<5> Zdn;
1133   bit i1;
1134   let Inst{31-24} = 0b01100101;
1135   let Inst{23-22} = sz;
1136   let Inst{21-19} = 0b011;
1137   let Inst{18-16} = opc;
1138   let Inst{15-13} = 0b100;
1139   let Inst{12-10} = Pg;
1140   let Inst{9-6}   = 0b0000;
1141   let Inst{5}     = i1;
1142   let Inst{4-0}   = Zdn;
1144   let Constraints = "$Zdn = $_Zdn";
1145   let DestructiveInstType = Destructive;
1146   let ElementSize = zprty.ElementSize;
1149 multiclass sve_fp_2op_i_p_zds<bits<3> opc, string asm, Operand imm_ty> {
1150   def _H : sve_fp_2op_i_p_zds<0b01, opc, asm, ZPR16, imm_ty>;
1151   def _S : sve_fp_2op_i_p_zds<0b10, opc, asm, ZPR32, imm_ty>;
1152   def _D : sve_fp_2op_i_p_zds<0b11, opc, asm, ZPR64, imm_ty>;
1155 class sve_fp_2op_p_zds<bits<2> sz, bits<4> opc, string asm,
1156                        ZPRRegOp zprty>
1157 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
1158   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
1159   "",
1160   []>, Sched<[]> {
1161   bits<3> Pg;
1162   bits<5> Zdn;
1163   bits<5> Zm;
1164   let Inst{31-24} = 0b01100101;
1165   let Inst{23-22} = sz;
1166   let Inst{21-20} = 0b00;
1167   let Inst{19-16} = opc;
1168   let Inst{15-13} = 0b100;
1169   let Inst{12-10} = Pg;
1170   let Inst{9-5}   = Zm;
1171   let Inst{4-0}   = Zdn;
1173   let Constraints = "$Zdn = $_Zdn";
1174   let DestructiveInstType = Destructive;
1175   let ElementSize = zprty.ElementSize;
1178 multiclass sve_fp_2op_p_zds<bits<4> opc, string asm> {
1179   def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>;
1180   def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>;
1181   def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>;
1184 class sve_fp_ftmad<bits<2> sz, string asm, ZPRRegOp zprty>
1185 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, imm0_7:$imm3),
1186   asm, "\t$Zdn, $_Zdn, $Zm, $imm3",
1187   "",
1188   []>, Sched<[]> {
1189   bits<5> Zdn;
1190   bits<5> Zm;
1191   bits<3> imm3;
1192   let Inst{31-24} = 0b01100101;
1193   let Inst{23-22} = sz;
1194   let Inst{21-19} = 0b010;
1195   let Inst{18-16} = imm3;
1196   let Inst{15-10} = 0b100000;
1197   let Inst{9-5}   = Zm;
1198   let Inst{4-0}   = Zdn;
1200   let Constraints = "$Zdn = $_Zdn";
1201   let DestructiveInstType = Destructive;
1202   let ElementSize = ElementSizeNone;
1205 multiclass sve_fp_ftmad<string asm> {
1206   def _H : sve_fp_ftmad<0b01, asm, ZPR16>;
1207   def _S : sve_fp_ftmad<0b10, asm, ZPR32>;
1208   def _D : sve_fp_ftmad<0b11, asm, ZPR64>;
1212 //===----------------------------------------------------------------------===//
1213 // SVE Floating Point Arithmetic - Unpredicated Group
1214 //===----------------------------------------------------------------------===//
1216 class sve_fp_3op_u_zd<bits<2> sz, bits<3> opc, string asm,
1217                       ZPRRegOp zprty>
1218 : I<(outs zprty:$Zd), (ins  zprty:$Zn, zprty:$Zm),
1219   asm, "\t$Zd, $Zn, $Zm",
1220   "", []>, Sched<[]> {
1221   bits<5> Zd;
1222   bits<5> Zm;
1223   bits<5> Zn;
1224   let Inst{31-24} = 0b01100101;
1225   let Inst{23-22} = sz;
1226   let Inst{21}    = 0b0;
1227   let Inst{20-16} = Zm;
1228   let Inst{15-13} = 0b000;
1229   let Inst{12-10} = opc;
1230   let Inst{9-5}   = Zn;
1231   let Inst{4-0}   = Zd;
1234 multiclass sve_fp_3op_u_zd<bits<3> opc, string asm> {
1235   def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>;
1236   def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>;
1237   def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>;
1240 //===----------------------------------------------------------------------===//
1241 // SVE Floating Point Fused Multiply-Add Group
1242 //===----------------------------------------------------------------------===//
1244 class sve_fp_3op_p_zds_a<bits<2> sz, bits<2> opc, string asm, ZPRRegOp zprty>
1245 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
1246   asm, "\t$Zda, $Pg/m, $Zn, $Zm",
1247   "",
1248   []>, Sched<[]> {
1249   bits<3> Pg;
1250   bits<5> Zda;
1251   bits<5> Zm;
1252   bits<5> Zn;
1253   let Inst{31-24} = 0b01100101;
1254   let Inst{23-22} = sz;
1255   let Inst{21}    = 0b1;
1256   let Inst{20-16} = Zm;
1257   let Inst{15}    = 0b0;
1258   let Inst{14-13} = opc;
1259   let Inst{12-10} = Pg;
1260   let Inst{9-5}   = Zn;
1261   let Inst{4-0}   = Zda;
1263   let Constraints = "$Zda = $_Zda";
1264   let DestructiveInstType = Destructive;
1265   let ElementSize = zprty.ElementSize;
1268 multiclass sve_fp_3op_p_zds_a<bits<2> opc, string asm> {
1269   def _H : sve_fp_3op_p_zds_a<0b01, opc, asm, ZPR16>;
1270   def _S : sve_fp_3op_p_zds_a<0b10, opc, asm, ZPR32>;
1271   def _D : sve_fp_3op_p_zds_a<0b11, opc, asm, ZPR64>;
1274 class sve_fp_3op_p_zds_b<bits<2> sz, bits<2> opc, string asm,
1275                          ZPRRegOp zprty>
1276 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
1277   asm, "\t$Zdn, $Pg/m, $Zm, $Za",
1278   "",
1279   []>, Sched<[]> {
1280   bits<3> Pg;
1281   bits<5> Za;
1282   bits<5> Zdn;
1283   bits<5> Zm;
1284   let Inst{31-24} = 0b01100101;
1285   let Inst{23-22} = sz;
1286   let Inst{21}    = 0b1;
1287   let Inst{20-16} = Za;
1288   let Inst{15}    = 0b1;
1289   let Inst{14-13} = opc;
1290   let Inst{12-10} = Pg;
1291   let Inst{9-5}   = Zm;
1292   let Inst{4-0}   = Zdn;
1294   let Constraints = "$Zdn = $_Zdn";
1295   let DestructiveInstType = Destructive;
1296   let ElementSize = zprty.ElementSize;
1299 multiclass sve_fp_3op_p_zds_b<bits<2> opc, string asm> {
1300   def _H : sve_fp_3op_p_zds_b<0b01, opc, asm, ZPR16>;
1301   def _S : sve_fp_3op_p_zds_b<0b10, opc, asm, ZPR32>;
1302   def _D : sve_fp_3op_p_zds_b<0b11, opc, asm, ZPR64>;
1305 //===----------------------------------------------------------------------===//
1306 // SVE Floating Point Multiply-Add - Indexed Group
1307 //===----------------------------------------------------------------------===//
1309 class sve_fp_fma_by_indexed_elem<bits<2> sz, bit opc, string asm,
1310                                  ZPRRegOp zprty1,
1311                                  ZPRRegOp zprty2, Operand itype>
1312 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty1:$Zn, zprty2:$Zm, itype:$iop),
1313   asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
1314   bits<5> Zda;
1315   bits<5> Zn;
1316   let Inst{31-24} = 0b01100100;
1317   let Inst{23-22} = sz;
1318   let Inst{21}    = 0b1;
1319   let Inst{15-11} = 0;
1320   let Inst{10}    = opc;
1321   let Inst{9-5}   = Zn;
1322   let Inst{4-0}   = Zda;
1324   let Constraints = "$Zda = $_Zda";
1325   let DestructiveInstType = Destructive;
1326   let ElementSize = ElementSizeNone;
1329 multiclass sve_fp_fma_by_indexed_elem<bit opc, string asm> {
1330   def _H : sve_fp_fma_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR3b16, VectorIndexH> {
1331     bits<3> Zm;
1332     bits<3> iop;
1333     let Inst{22} = iop{2};
1334     let Inst{20-19} = iop{1-0};
1335     let Inst{18-16} = Zm;
1336   }
1337   def _S : sve_fp_fma_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR3b32, VectorIndexS> {
1338     bits<3> Zm;
1339     bits<2> iop;
1340     let Inst{20-19} = iop;
1341     let Inst{18-16} = Zm;
1342   }
1343   def _D : sve_fp_fma_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR4b64, VectorIndexD> {
1344     bits<4> Zm;
1345     bit iop;
1346     let Inst{20} = iop;
1347     let Inst{19-16} = Zm;
1348   }
1352 //===----------------------------------------------------------------------===//
1353 // SVE Floating Point Multiply - Indexed Group
1354 //===----------------------------------------------------------------------===//
1356 class sve_fp_fmul_by_indexed_elem<bits<2> sz, string asm, ZPRRegOp zprty,
1357                                       ZPRRegOp zprty2, Operand itype>
1358 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty2:$Zm, itype:$iop),
1359   asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
1360   bits<5> Zd;
1361   bits<5> Zn;
1362   let Inst{31-24} = 0b01100100;
1363   let Inst{23-22} = sz;
1364   let Inst{21}    = 0b1;
1365   let Inst{15-10} = 0b001000;
1366   let Inst{9-5}   = Zn;
1367   let Inst{4-0}   = Zd;
1370 multiclass sve_fp_fmul_by_indexed_elem<string asm> {
1371   def _H : sve_fp_fmul_by_indexed_elem<{0, ?}, asm, ZPR16, ZPR3b16, VectorIndexH> {
1372     bits<3> Zm;
1373     bits<3> iop;
1374     let Inst{22} = iop{2};
1375     let Inst{20-19} = iop{1-0};
1376     let Inst{18-16} = Zm;
1377   }
1378   def _S : sve_fp_fmul_by_indexed_elem<0b10, asm, ZPR32, ZPR3b32, VectorIndexS> {
1379     bits<3> Zm;
1380     bits<2> iop;
1381     let Inst{20-19} = iop;
1382     let Inst{18-16} = Zm;
1383   }
1384   def _D : sve_fp_fmul_by_indexed_elem<0b11, asm, ZPR64, ZPR4b64, VectorIndexD> {
1385     bits<4> Zm;
1386     bit iop;
1387     let Inst{20} = iop;
1388     let Inst{19-16} = Zm;
1389   }
1392 //===----------------------------------------------------------------------===//
1393 // SVE Floating Point Complex Multiply-Add Group
1394 //===----------------------------------------------------------------------===//
1396 class sve_fp_fcmla<bits<2> sz, string asm, ZPRRegOp zprty>
1397 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm,
1398                         complexrotateop:$imm),
1399   asm, "\t$Zda, $Pg/m, $Zn, $Zm, $imm",
1400   "", []>, Sched<[]> {
1401   bits<5> Zda;
1402   bits<3> Pg;
1403   bits<5> Zn;
1404   bits<5> Zm;
1405   bits<2> imm;
1406   let Inst{31-24} = 0b01100100;
1407   let Inst{23-22} = sz;
1408   let Inst{21}    = 0;
1409   let Inst{20-16} = Zm;
1410   let Inst{15}    = 0;
1411   let Inst{14-13} = imm;
1412   let Inst{12-10} = Pg;
1413   let Inst{9-5}   = Zn;
1414   let Inst{4-0}   = Zda;
1416   let Constraints = "$Zda = $_Zda";
1417   let DestructiveInstType = Destructive;
1418   let ElementSize = zprty.ElementSize;
1421 multiclass sve_fp_fcmla<string asm> {
1422   def _H : sve_fp_fcmla<0b01, asm, ZPR16>;
1423   def _S : sve_fp_fcmla<0b10, asm, ZPR32>;
1424   def _D : sve_fp_fcmla<0b11, asm, ZPR64>;
1427 //===----------------------------------------------------------------------===//
1428 // SVE Floating Point Complex Multiply-Add - Indexed Group
1429 //===----------------------------------------------------------------------===//
1431 class sve_fp_fcmla_by_indexed_elem<bits<2> sz, string asm,
1432                                    ZPRRegOp zprty,
1433                                    ZPRRegOp zprty2, Operand itype>
1434 : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty2:$Zm, itype:$iop,
1435                         complexrotateop:$imm),
1436   asm, "\t$Zda, $Zn, $Zm$iop, $imm",
1437   "", []>, Sched<[]> {
1438   bits<5> Zda;
1439   bits<5> Zn;
1440   bits<2> imm;
1441   let Inst{31-24} = 0b01100100;
1442   let Inst{23-22} = sz;
1443   let Inst{21}    = 0b1;
1444   let Inst{15-12} = 0b0001;
1445   let Inst{11-10} = imm;
1446   let Inst{9-5}   = Zn;
1447   let Inst{4-0}   = Zda;
1449   let Constraints = "$Zda = $_Zda";
1450   let DestructiveInstType = Destructive;
1451   let ElementSize = ElementSizeNone;
1454 multiclass sve_fp_fcmla_by_indexed_elem<string asm> {
1455   def _H : sve_fp_fcmla_by_indexed_elem<0b10, asm, ZPR16, ZPR3b16, VectorIndexS> {
1456     bits<3> Zm;
1457     bits<2> iop;
1458     let Inst{20-19} = iop;
1459     let Inst{18-16} = Zm;
1460   }
1461   def _S : sve_fp_fcmla_by_indexed_elem<0b11, asm, ZPR32, ZPR4b32, VectorIndexD> {
1462     bits<4> Zm;
1463     bits<1> iop;
1464     let Inst{20} = iop;
1465     let Inst{19-16} = Zm;
1466   }
1469 //===----------------------------------------------------------------------===//
1470 // SVE Floating Point Complex Addition Group
1471 //===----------------------------------------------------------------------===//
1473 class sve_fp_fcadd<bits<2> sz, string asm, ZPRRegOp zprty>
1474 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm,
1475                         complexrotateopodd:$imm),
1476   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm, $imm",
1477   "",
1478   []>, Sched<[]> {
1479   bits<5> Zdn;
1480   bits<5> Zm;
1481   bits<3> Pg;
1482   bit imm;
1483   let Inst{31-24} = 0b01100100;
1484   let Inst{23-22} = sz;
1485   let Inst{21-17} = 0;
1486   let Inst{16}    = imm;
1487   let Inst{15-13} = 0b100;
1488   let Inst{12-10} = Pg;
1489   let Inst{9-5}   = Zm;
1490   let Inst{4-0}   = Zdn;
1492   let Constraints = "$Zdn = $_Zdn";
1493   let DestructiveInstType = Destructive;
1494   let ElementSize = zprty.ElementSize;
1497 multiclass sve_fp_fcadd<string asm> {
1498   def _H : sve_fp_fcadd<0b01, asm, ZPR16>;
1499   def _S : sve_fp_fcadd<0b10, asm, ZPR32>;
1500   def _D : sve_fp_fcadd<0b11, asm, ZPR64>;
1503 //===----------------------------------------------------------------------===//
1504 // SVE2 Floating Point Convert Group
1505 //===----------------------------------------------------------------------===//
1507 class sve2_fp_convert_precision<bits<4> opc, string asm,
1508                                 ZPRRegOp zprty1, ZPRRegOp zprty2>
1509 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, PPR3bAny:$Pg, zprty2:$Zn),
1510   asm, "\t$Zd, $Pg/m, $Zn",
1511   "",
1512   []>, Sched<[]> {
1513   bits<5> Zd;
1514   bits<5> Zn;
1515   bits<3> Pg;
1516   let Inst{31-24} = 0b01100100;
1517   let Inst{23-22} = opc{3-2};
1518   let Inst{21-18} = 0b0010;
1519   let Inst{17-16} = opc{1-0};
1520   let Inst{15-13} = 0b101;
1521   let Inst{12-10} = Pg;
1522   let Inst{9-5}   = Zn;
1523   let Inst{4-0}   = Zd;
1525   let Constraints = "$Zd = $_Zd";
1528 multiclass sve2_fp_convert_down_narrow<string asm> {
1529   def _StoH : sve2_fp_convert_precision<0b1000, asm, ZPR16, ZPR32>;
1530   def _DtoS : sve2_fp_convert_precision<0b1110, asm, ZPR32, ZPR64>;
1533 multiclass sve2_fp_convert_up_long<string asm> {
1534   def _HtoS : sve2_fp_convert_precision<0b1001, asm, ZPR32, ZPR16>;
1535   def _StoD : sve2_fp_convert_precision<0b1111, asm, ZPR64, ZPR32>;
1538 multiclass sve2_fp_convert_down_odd_rounding<string asm> {
1539   def _DtoS : sve2_fp_convert_precision<0b0010, asm, ZPR32, ZPR64>;
1542 //===----------------------------------------------------------------------===//
1543 // SVE2 Floating Point Pairwise Group
1544 //===----------------------------------------------------------------------===//
1546 class sve2_fp_pairwise_pred<bits<2> sz, bits<3> opc, string asm,
1547                             ZPRRegOp zprty>
1548 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
1549   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
1550   "",
1551   []>, Sched<[]> {
1552   bits<3> Pg;
1553   bits<5> Zm;
1554   bits<5> Zdn;
1555   let Inst{31-24} = 0b01100100;
1556   let Inst{23-22} = sz;
1557   let Inst{21-19} = 0b010;
1558   let Inst{18-16} = opc;
1559   let Inst{15-13} = 0b100;
1560   let Inst{12-10} = Pg;
1561   let Inst{9-5}   = Zm;
1562   let Inst{4-0}   = Zdn;
1564   let Constraints = "$Zdn = $_Zdn";
1565   let DestructiveInstType = Destructive;
1566   let ElementSize = zprty.ElementSize;
1569 multiclass sve2_fp_pairwise_pred<bits<3> opc, string asm> {
1570   def _H : sve2_fp_pairwise_pred<0b01, opc, asm, ZPR16>;
1571   def _S : sve2_fp_pairwise_pred<0b10, opc, asm, ZPR32>;
1572   def _D : sve2_fp_pairwise_pred<0b11, opc, asm, ZPR64>;
1575 //===----------------------------------------------------------------------===//
1576 // SVE2 Floating Point Widening Multiply-Add - Indexed Group
1577 //===----------------------------------------------------------------------===//
1579 class sve2_fp_mla_long_by_indexed_elem<bits<2> opc, string asm>
1580 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm,
1581                         VectorIndexH:$iop),
1582   asm, "\t$Zda, $Zn, $Zm$iop",
1583   "",
1584   []>, Sched<[]> {
1585   bits<5> Zda;
1586   bits<5> Zn;
1587   bits<3> Zm;
1588   bits<3> iop;
1589   let Inst{31-21} = 0b01100100101;
1590   let Inst{20-19} = iop{2-1};
1591   let Inst{18-16} = Zm;
1592   let Inst{15-14} = 0b01;
1593   let Inst{13}    = opc{1};
1594   let Inst{12}    = 0b0;
1595   let Inst{11}    = iop{0};
1596   let Inst{10}    = opc{0};
1597   let Inst{9-5}   = Zn;
1598   let Inst{4-0}   = Zda;
1600   let Constraints = "$Zda = $_Zda";
1601   let DestructiveInstType = Destructive;
1602   let ElementSize = ElementSizeNone;
1605 //===----------------------------------------------------------------------===//
1606 // SVE2 Floating Point Widening Multiply-Add Group
1607 //===----------------------------------------------------------------------===//
1609 class sve2_fp_mla_long<bits<2> opc, string asm>
1610 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
1611   asm, "\t$Zda, $Zn, $Zm",
1612   "",
1613   []>, Sched<[]> {
1614   bits<5> Zda;
1615   bits<5> Zn;
1616   bits<5> Zm;
1617   let Inst{31-21} = 0b01100100101;
1618   let Inst{20-16} = Zm;
1619   let Inst{15-14} = 0b10;
1620   let Inst{13}    = opc{1};
1621   let Inst{12-11} = 0b00;
1622   let Inst{10}    = opc{0};
1623   let Inst{9-5}   = Zn;
1624   let Inst{4-0}   = Zda;
1626   let Constraints = "$Zda = $_Zda";
1627   let DestructiveInstType = Destructive;
1628   let ElementSize = ElementSizeNone;
1631 //===----------------------------------------------------------------------===//
1632 // SVE Stack Allocation Group
1633 //===----------------------------------------------------------------------===//
1635 class sve_int_arith_vl<bit opc, string asm>
1636 : I<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, simm6_32b:$imm6),
1637   asm, "\t$Rd, $Rn, $imm6",
1638   "",
1639   []>, Sched<[]> {
1640   bits<5> Rd;
1641   bits<5> Rn;
1642   bits<6> imm6;
1643   let Inst{31-23} = 0b000001000;
1644   let Inst{22}    = opc;
1645   let Inst{21}    = 0b1;
1646   let Inst{20-16} = Rn;
1647   let Inst{15-11} = 0b01010;
1648   let Inst{10-5}  = imm6;
1649   let Inst{4-0}   = Rd;
1652 class sve_int_read_vl_a<bit op, bits<5> opc2, string asm>
1653 : I<(outs GPR64:$Rd), (ins simm6_32b:$imm6),
1654   asm, "\t$Rd, $imm6",
1655   "",
1656   []>, Sched<[]> {
1657   bits<5> Rd;
1658   bits<6> imm6;
1659   let Inst{31-23} = 0b000001001;
1660   let Inst{22}    = op;
1661   let Inst{21}    = 0b1;
1662   let Inst{20-16} = opc2{4-0};
1663   let Inst{15-11} = 0b01010;
1664   let Inst{10-5}  = imm6;
1665   let Inst{4-0}   = Rd;
1668 //===----------------------------------------------------------------------===//
1669 // SVE Permute - In Lane Group
1670 //===----------------------------------------------------------------------===//
1672 class sve_int_perm_bin_perm_zz<bits<3> opc, bits<2> sz8_64, string asm,
1673                                ZPRRegOp zprty>
1674 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
1675   asm, "\t$Zd, $Zn, $Zm",
1676   "",
1677   []>, Sched<[]> {
1678   bits<5> Zd;
1679   bits<5> Zm;
1680   bits<5> Zn;
1681   let Inst{31-24} = 0b00000101;
1682   let Inst{23-22} = sz8_64;
1683   let Inst{21}    = 0b1;
1684   let Inst{20-16} = Zm;
1685   let Inst{15-13} = 0b011;
1686   let Inst{12-10} = opc;
1687   let Inst{9-5}   = Zn;
1688   let Inst{4-0}   = Zd;
1691 multiclass sve_int_perm_bin_perm_zz<bits<3> opc, string asm> {
1692   def _B : sve_int_perm_bin_perm_zz<opc, 0b00, asm, ZPR8>;
1693   def _H : sve_int_perm_bin_perm_zz<opc, 0b01, asm, ZPR16>;
1694   def _S : sve_int_perm_bin_perm_zz<opc, 0b10, asm, ZPR32>;
1695   def _D : sve_int_perm_bin_perm_zz<opc, 0b11, asm, ZPR64>;
1698 //===----------------------------------------------------------------------===//
1699 // SVE Floating Point Unary Operations Group
1700 //===----------------------------------------------------------------------===//
1702 class sve_fp_2op_p_zd<bits<7> opc, string asm, RegisterOperand i_zprtype,
1703                       RegisterOperand o_zprtype, ElementSizeEnum size>
1704 : I<(outs o_zprtype:$Zd), (ins i_zprtype:$_Zd, PPR3bAny:$Pg, i_zprtype:$Zn),
1705   asm, "\t$Zd, $Pg/m, $Zn",
1706   "",
1707   []>, Sched<[]> {
1708   bits<3> Pg;
1709   bits<5> Zd;
1710   bits<5> Zn;
1711   let Inst{31-24} = 0b01100101;
1712   let Inst{23-22} = opc{6-5};
1713   let Inst{21}    = 0b0;
1714   let Inst{20-16} = opc{4-0};
1715   let Inst{15-13} = 0b101;
1716   let Inst{12-10} = Pg;
1717   let Inst{9-5}   = Zn;
1718   let Inst{4-0}   = Zd;
1720   let Constraints = "$Zd = $_Zd";
1721   let DestructiveInstType = Destructive;
1722   let ElementSize = size;
1725 multiclass sve_fp_2op_p_zd_HSD<bits<5> opc, string asm> {
1726   def _H : sve_fp_2op_p_zd<{ 0b01, opc }, asm, ZPR16, ZPR16, ElementSizeH>;
1727   def _S : sve_fp_2op_p_zd<{ 0b10, opc }, asm, ZPR32, ZPR32, ElementSizeS>;
1728   def _D : sve_fp_2op_p_zd<{ 0b11, opc }, asm, ZPR64, ZPR64, ElementSizeD>;
1731 multiclass sve2_fp_flogb<string asm> {
1732   def _H : sve_fp_2op_p_zd<0b0011010, asm, ZPR16, ZPR16, ElementSizeH>;
1733   def _S : sve_fp_2op_p_zd<0b0011100, asm, ZPR32, ZPR32, ElementSizeS>;
1734   def _D : sve_fp_2op_p_zd<0b0011110, asm, ZPR64, ZPR64, ElementSizeD>;
1737 //===----------------------------------------------------------------------===//
1738 // SVE Floating Point Unary Operations - Unpredicated Group
1739 //===----------------------------------------------------------------------===//
1741 class sve_fp_2op_u_zd<bits<2> sz, bits<3> opc, string asm,
1742                       ZPRRegOp zprty>
1743 : I<(outs zprty:$Zd), (ins zprty:$Zn),
1744   asm, "\t$Zd, $Zn",
1745   "",
1746   []>, Sched<[]> {
1747   bits<5> Zd;
1748   bits<5> Zn;
1749   let Inst{31-24} = 0b01100101;
1750   let Inst{23-22} = sz;
1751   let Inst{21-19} = 0b001;
1752   let Inst{18-16} = opc;
1753   let Inst{15-10} = 0b001100;
1754   let Inst{9-5}   = Zn;
1755   let Inst{4-0}   = Zd;
1758 multiclass sve_fp_2op_u_zd<bits<3> opc, string asm> {
1759   def _H : sve_fp_2op_u_zd<0b01, opc, asm, ZPR16>;
1760   def _S : sve_fp_2op_u_zd<0b10, opc, asm, ZPR32>;
1761   def _D : sve_fp_2op_u_zd<0b11, opc, asm, ZPR64>;
1764 //===----------------------------------------------------------------------===//
1765 // SVE Integer Arithmetic - Binary Predicated Group
1766 //===----------------------------------------------------------------------===//
1768 class sve_int_bin_pred_arit_log<bits<2> sz8_64, bits<2> fmt, bits<3> opc,
1769                                 string asm, ZPRRegOp zprty>
1770 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
1771   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
1772   bits<3> Pg;
1773   bits<5> Zdn;
1774   bits<5> Zm;
1775   let Inst{31-24} = 0b00000100;
1776   let Inst{23-22} = sz8_64;
1777   let Inst{21}    = 0b0;
1778   let Inst{20-19} = fmt;
1779   let Inst{18-16} = opc;
1780   let Inst{15-13} = 0b000;
1781   let Inst{12-10} = Pg;
1782   let Inst{9-5}   = Zm;
1783   let Inst{4-0}   = Zdn;
1785   let Constraints = "$Zdn = $_Zdn";
1786   let DestructiveInstType = Destructive;
1787   let ElementSize = zprty.ElementSize;
1790 multiclass sve_int_bin_pred_log<bits<3> opc, string asm> {
1791   def _B : sve_int_bin_pred_arit_log<0b00, 0b11, opc, asm, ZPR8>;
1792   def _H : sve_int_bin_pred_arit_log<0b01, 0b11, opc, asm, ZPR16>;
1793   def _S : sve_int_bin_pred_arit_log<0b10, 0b11, opc, asm, ZPR32>;
1794   def _D : sve_int_bin_pred_arit_log<0b11, 0b11, opc, asm, ZPR64>;
1797 multiclass sve_int_bin_pred_arit_0<bits<3> opc, string asm> {
1798   def _B : sve_int_bin_pred_arit_log<0b00, 0b00, opc, asm, ZPR8>;
1799   def _H : sve_int_bin_pred_arit_log<0b01, 0b00, opc, asm, ZPR16>;
1800   def _S : sve_int_bin_pred_arit_log<0b10, 0b00, opc, asm, ZPR32>;
1801   def _D : sve_int_bin_pred_arit_log<0b11, 0b00, opc, asm, ZPR64>;
1804 multiclass sve_int_bin_pred_arit_1<bits<3> opc, string asm> {
1805   def _B : sve_int_bin_pred_arit_log<0b00, 0b01, opc, asm, ZPR8>;
1806   def _H : sve_int_bin_pred_arit_log<0b01, 0b01, opc, asm, ZPR16>;
1807   def _S : sve_int_bin_pred_arit_log<0b10, 0b01, opc, asm, ZPR32>;
1808   def _D : sve_int_bin_pred_arit_log<0b11, 0b01, opc, asm, ZPR64>;
1811 multiclass sve_int_bin_pred_arit_2<bits<3> opc, string asm> {
1812   def _B : sve_int_bin_pred_arit_log<0b00, 0b10, opc, asm, ZPR8>;
1813   def _H : sve_int_bin_pred_arit_log<0b01, 0b10, opc, asm, ZPR16>;
1814   def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>;
1815   def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>;
1818 // Special case for divides which are not defined for 8b/16b elements.
1819 multiclass sve_int_bin_pred_arit_2_div<bits<3> opc, string asm> {
1820   def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>;
1821   def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>;
1824 //===----------------------------------------------------------------------===//
1825 // SVE Integer Multiply-Add Group
1826 //===----------------------------------------------------------------------===//
1828 class sve_int_mladdsub_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
1829                                 ZPRRegOp zprty>
1830 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
1831   asm, "\t$Zdn, $Pg/m, $Zm, $Za",
1832   "",
1833   []>, Sched<[]> {
1834   bits<3> Pg;
1835   bits<5> Zdn;
1836   bits<5> Za;
1837   bits<5> Zm;
1838   let Inst{31-24} = 0b00000100;
1839   let Inst{23-22} = sz8_64;
1840   let Inst{21}    = 0b0;
1841   let Inst{20-16} = Zm;
1842   let Inst{15-14} = 0b11;
1843   let Inst{13}    = opc;
1844   let Inst{12-10} = Pg;
1845   let Inst{9-5}   = Za;
1846   let Inst{4-0}   = Zdn;
1848   let Constraints = "$Zdn = $_Zdn";
1849   let DestructiveInstType = Destructive;
1850   let ElementSize = zprty.ElementSize;
1853 multiclass sve_int_mladdsub_vvv_pred<bits<1> opc, string asm> {
1854   def _B : sve_int_mladdsub_vvv_pred<0b00, opc, asm, ZPR8>;
1855   def _H : sve_int_mladdsub_vvv_pred<0b01, opc, asm, ZPR16>;
1856   def _S : sve_int_mladdsub_vvv_pred<0b10, opc, asm, ZPR32>;
1857   def _D : sve_int_mladdsub_vvv_pred<0b11, opc, asm, ZPR64>;
1860 class sve_int_mlas_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
1861                             ZPRRegOp zprty>
1862 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
1863   asm, "\t$Zda, $Pg/m, $Zn, $Zm",
1864   "",
1865   []>, Sched<[]> {
1866   bits<3> Pg;
1867   bits<5> Zda;
1868   bits<5> Zm;
1869   bits<5> Zn;
1870   let Inst{31-24} = 0b00000100;
1871   let Inst{23-22} = sz8_64;
1872   let Inst{21}    = 0b0;
1873   let Inst{20-16} = Zm;
1874   let Inst{15-14} = 0b01;
1875   let Inst{13}    = opc;
1876   let Inst{12-10} = Pg;
1877   let Inst{9-5}   = Zn;
1878   let Inst{4-0}   = Zda;
1880   let Constraints = "$Zda = $_Zda";
1881   let DestructiveInstType = Destructive;
1882   let ElementSize = zprty.ElementSize;
1885 multiclass sve_int_mlas_vvv_pred<bits<1> opc, string asm> {
1886   def _B : sve_int_mlas_vvv_pred<0b00, opc, asm, ZPR8>;
1887   def _H : sve_int_mlas_vvv_pred<0b01, opc, asm, ZPR16>;
1888   def _S : sve_int_mlas_vvv_pred<0b10, opc, asm, ZPR32>;
1889   def _D : sve_int_mlas_vvv_pred<0b11, opc, asm, ZPR64>;
1892 //===----------------------------------------------------------------------===//
1893 // SVE2 Integer Multiply-Add - Unpredicated Group
1894 //===----------------------------------------------------------------------===//
1896 class sve2_int_mla<bits<2> sz, bits<5> opc, string asm,
1897                    ZPRRegOp zprty1, ZPRRegOp zprty2>
1898 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
1899   asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
1900   bits<5> Zda;
1901   bits<5> Zn;
1902   bits<5> Zm;
1903   let Inst{31-24} = 0b01000100;
1904   let Inst{23-22} = sz;
1905   let Inst{21}    = 0b0;
1906   let Inst{20-16} = Zm;
1907   let Inst{15}    = 0b0;
1908   let Inst{14-10} = opc;
1909   let Inst{9-5}   = Zn;
1910   let Inst{4-0}   = Zda;
1912   let Constraints = "$Zda = $_Zda";
1913   let DestructiveInstType = Destructive;
1914   let ElementSize = ElementSizeNone;
1917 multiclass sve2_int_mla<bit S, string asm> {
1918   def _B : sve2_int_mla<0b00, { 0b1110, S }, asm, ZPR8, ZPR8>;
1919   def _H : sve2_int_mla<0b01, { 0b1110, S }, asm, ZPR16, ZPR16>;
1920   def _S : sve2_int_mla<0b10, { 0b1110, S }, asm, ZPR32, ZPR32>;
1921   def _D : sve2_int_mla<0b11, { 0b1110, S }, asm, ZPR64, ZPR64>;
1924 multiclass sve2_int_mla_long<bits<5> opc, string asm> {
1925   def _H : sve2_int_mla<0b01, opc, asm, ZPR16, ZPR8>;
1926   def _S : sve2_int_mla<0b10, opc, asm, ZPR32, ZPR16>;
1927   def _D : sve2_int_mla<0b11, opc, asm, ZPR64, ZPR32>;
1930 //===----------------------------------------------------------------------===//
1931 // SVE2 Integer Multiply-Add - Indexed Group
1932 //===----------------------------------------------------------------------===//
1934 class sve2_int_mla_by_indexed_elem<bits<2> sz, bits<6> opc, string asm,
1935                                    ZPRRegOp zprty1, ZPRRegOp zprty2,
1936                                    ZPRRegOp zprty3, Operand itype>
1937 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
1938   asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
1939   bits<5> Zda;
1940   bits<5> Zn;
1941   let Inst{31-24} = 0b01000100;
1942   let Inst{23-22} = sz;
1943   let Inst{21}    = 0b1;
1944   let Inst{15-10} = opc;
1945   let Inst{9-5}   = Zn;
1946   let Inst{4-0}   = Zda;
1948   let Constraints = "$Zda = $_Zda";
1949   let DestructiveInstType = Destructive;
1950   let ElementSize = ElementSizeNone;
1953 multiclass sve2_int_mla_by_indexed_elem<bits<2> opc, bit S, string asm> {
1954   def _H : sve2_int_mla_by_indexed_elem<{0, ?}, { 0b000, opc, S }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH> {
1955     bits<3> Zm;
1956     bits<3> iop;
1957     let Inst{22} = iop{2};
1958     let Inst{20-19} = iop{1-0};
1959     let Inst{18-16} = Zm;
1960   }
1961   def _S : sve2_int_mla_by_indexed_elem<0b10, { 0b000, opc, S }, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS> {
1962     bits<3> Zm;
1963     bits<2> iop;
1964     let Inst{20-19} = iop;
1965     let Inst{18-16} = Zm;
1966   }
1967   def _D : sve2_int_mla_by_indexed_elem<0b11, { 0b000, opc, S }, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD> {
1968     bits<4> Zm;
1969     bit iop;
1970     let Inst{20} = iop;
1971     let Inst{19-16} = Zm;
1972   }
1975 //===----------------------------------------------------------------------===//
1976 // SVE2 Integer Multiply-Add Long - Indexed Group
1977 //===----------------------------------------------------------------------===//
1979 multiclass sve2_int_mla_long_by_indexed_elem<bits<4> opc, string asm> {
1980   def _S : sve2_int_mla_by_indexed_elem<0b10, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
1981                                         asm, ZPR32, ZPR16, ZPR3b16, VectorIndexH> {
1982     bits<3> Zm;
1983     bits<3> iop;
1984     let Inst{20-19} = iop{2-1};
1985     let Inst{18-16} = Zm;
1986     let Inst{11} = iop{0};
1987   }
1988   def _D : sve2_int_mla_by_indexed_elem<0b11, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
1989                                         asm, ZPR64, ZPR32, ZPR4b32, VectorIndexS> {
1990     bits<4> Zm;
1991     bits<2> iop;
1992     let Inst{20} = iop{1};
1993     let Inst{19-16} = Zm;
1994     let Inst{11} = iop{0};
1995   }
1998 //===----------------------------------------------------------------------===//
1999 // SVE Integer Dot Product Group
2000 //===----------------------------------------------------------------------===//
2002 class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
2003                    ZPRRegOp zprty2>
2004 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), asm,
2005   "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
2006   bits<5> Zda;
2007   bits<5> Zn;
2008   bits<5> Zm;
2009   let Inst{31-23} = 0b010001001;
2010   let Inst{22}    = sz;
2011   let Inst{21}    = 0;
2012   let Inst{20-16} = Zm;
2013   let Inst{15-11} = 0;
2014   let Inst{10}    = U;
2015   let Inst{9-5}   = Zn;
2016   let Inst{4-0}   = Zda;
2018   let Constraints = "$Zda = $_Zda";
2019   let DestructiveInstType = Destructive;
2020   let ElementSize = zprty1.ElementSize;
2023 multiclass sve_intx_dot<bit opc, string asm> {
2024   def _S : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>;
2025   def _D : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>;
2028 //===----------------------------------------------------------------------===//
2029 // SVE Integer Dot Product Group - Indexed Group
2030 //===----------------------------------------------------------------------===//
2032 class sve_intx_dot_by_indexed_elem<bit sz, bit U, string asm,
2033                                    ZPRRegOp zprty1, ZPRRegOp zprty2,
2034                                    ZPRRegOp zprty3, Operand itype>
2035 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
2036   asm, "\t$Zda, $Zn, $Zm$iop",
2037   "", []>, Sched<[]> {
2038   bits<5> Zda;
2039   bits<5> Zn;
2040   let Inst{31-23} = 0b010001001;
2041   let Inst{22}    = sz;
2042   let Inst{21}    = 0b1;
2043   let Inst{15-11} = 0;
2044   let Inst{10}    = U;
2045   let Inst{9-5}   = Zn;
2046   let Inst{4-0}   = Zda;
2048   let Constraints = "$Zda = $_Zda";
2049   let DestructiveInstType = Destructive;
2050   let ElementSize = ElementSizeNone;
2053 multiclass sve_intx_dot_by_indexed_elem<bit opc, string asm> {
2054   def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS> {
2055     bits<2> iop;
2056     bits<3> Zm;
2057     let Inst{20-19} = iop;
2058     let Inst{18-16} = Zm;
2059   }
2060   def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD> {
2061     bits<1> iop;
2062     bits<4> Zm;
2063     let Inst{20} = iop;
2064     let Inst{19-16} = Zm;
2065   }
2068 //===----------------------------------------------------------------------===//
2069 // SVE2 Complex Integer Dot Product Group
2070 //===----------------------------------------------------------------------===//
2072 class sve2_complex_int_arith<bits<2> sz, bits<4> opc, string asm,
2073                              ZPRRegOp zprty1, ZPRRegOp zprty2>
2074 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm,
2075                          complexrotateop:$rot),
2076   asm, "\t$Zda, $Zn, $Zm, $rot", "", []>, Sched<[]> {
2077   bits<5> Zda;
2078   bits<5> Zn;
2079   bits<5> Zm;
2080   bits<2> rot;
2081   let Inst{31-24} = 0b01000100;
2082   let Inst{23-22} = sz;
2083   let Inst{21}    = 0b0;
2084   let Inst{20-16} = Zm;
2085   let Inst{15-12} = opc;
2086   let Inst{11-10} = rot;
2087   let Inst{9-5}   = Zn;
2088   let Inst{4-0}   = Zda;
2090   let Constraints = "$Zda = $_Zda";
2091   let DestructiveInstType = Destructive;
2092   let ElementSize = ElementSizeNone;
2095 multiclass sve2_cintx_dot<string asm> {
2096   def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>;
2097   def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>;
2100 //===----------------------------------------------------------------------===//
2101 // SVE2 Complex Multiply-Add Group
2102 //===----------------------------------------------------------------------===//
2104 multiclass sve2_int_cmla<bit opc, string asm> {
2105   def _B : sve2_complex_int_arith<0b00, { 0b001, opc }, asm, ZPR8, ZPR8>;
2106   def _H : sve2_complex_int_arith<0b01, { 0b001, opc }, asm, ZPR16, ZPR16>;
2107   def _S : sve2_complex_int_arith<0b10, { 0b001, opc }, asm, ZPR32, ZPR32>;
2108   def _D : sve2_complex_int_arith<0b11, { 0b001, opc }, asm, ZPR64, ZPR64>;
2111 //===----------------------------------------------------------------------===//
2112 // SVE2 Complex Integer Dot Product - Indexed Group
2113 //===----------------------------------------------------------------------===//
2115 class sve2_complex_int_arith_indexed<bits<2> sz, bits<4> opc, string asm,
2116                                      ZPRRegOp zprty1, ZPRRegOp zprty2,
2117                                      ZPRRegOp zprty3, Operand itype>
2118 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop,
2119                          complexrotateop:$rot),
2120   asm, "\t$Zda, $Zn, $Zm$iop, $rot", "", []>, Sched<[]> {
2121   bits<5> Zda;
2122   bits<5> Zn;
2123   bits<2> rot;
2124   let Inst{31-24} = 0b01000100;
2125   let Inst{23-22} = sz;
2126   let Inst{21}    = 0b1;
2127   let Inst{15-12} = opc;
2128   let Inst{11-10} = rot;
2129   let Inst{9-5}   = Zn;
2130   let Inst{4-0}   = Zda;
2132   let Constraints = "$Zda = $_Zda";
2133   let DestructiveInstType = Destructive;
2134   let ElementSize = ElementSizeNone;
2137 multiclass sve2_cintx_dot_by_indexed_elem<string asm> {
2138   def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS> {
2139     bits<2> iop;
2140     bits<3> Zm;
2141     let Inst{20-19} = iop;
2142     let Inst{18-16} = Zm;
2143   }
2144   def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD> {
2145     bit iop;
2146     bits<4> Zm;
2147     let Inst{20} = iop;
2148     let Inst{19-16} = Zm;
2149   }
2152 //===----------------------------------------------------------------------===//
2153 // SVE2 Complex Multiply-Add - Indexed Group
2154 //===----------------------------------------------------------------------===//
2156 multiclass sve2_cmla_by_indexed_elem<bit opc, string asm> {
2157   def _H : sve2_complex_int_arith_indexed<0b10, { 0b011, opc }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexS> {
2158     bits<2> iop;
2159     bits<3> Zm;
2160     let Inst{20-19} = iop;
2161     let Inst{18-16} = Zm;
2162   }
2163   def _S : sve2_complex_int_arith_indexed<0b11, { 0b011, opc }, asm, ZPR32, ZPR32, ZPR4b32, VectorIndexD> {
2164     bit iop;
2165     bits<4> Zm;
2166     let Inst{20} = iop;
2167     let Inst{19-16} = Zm;
2168   }
2171 //===----------------------------------------------------------------------===//
2172 // SVE2 Integer Multiply - Unpredicated Group
2173 //===----------------------------------------------------------------------===//
2175 class sve2_int_mul<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty>
2176 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
2177   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2178   bits<5> Zd;
2179   bits<5> Zm;
2180   bits<5> Zn;
2181   let Inst{31-24} = 0b00000100;
2182   let Inst{23-22} = sz;
2183   let Inst{21}    = 0b1;
2184   let Inst{20-16} = Zm;
2185   let Inst{15-13} = 0b011;
2186   let Inst{12-10} = opc;
2187   let Inst{9-5}   = Zn;
2188   let Inst{4-0}   = Zd;
2191 multiclass sve2_int_mul<bits<3> opc, string asm> {
2192   def _B : sve2_int_mul<0b00, opc, asm, ZPR8>;
2193   def _H : sve2_int_mul<0b01, opc, asm, ZPR16>;
2194   def _S : sve2_int_mul<0b10, opc, asm, ZPR32>;
2195   def _D : sve2_int_mul<0b11, opc, asm, ZPR64>;
2198 //===----------------------------------------------------------------------===//
2199 // SVE2 Integer Multiply - Indexed Group
2200 //===----------------------------------------------------------------------===//
2202 class sve2_int_mul_by_indexed_elem<bits<2> sz, bits<4> opc, string asm,
2203                                    ZPRRegOp zprty1, ZPRRegOp zprty2,
2204                                    ZPRRegOp zprty3, Operand itype>
2205 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm, itype:$iop),
2206   asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
2207   bits<5> Zd;
2208   bits<5> Zn;
2209   let Inst{31-24} = 0b01000100;
2210   let Inst{23-22} = sz;
2211   let Inst{21}    = 0b1;
2212   let Inst{15-14} = 0b11;
2213   let Inst{13-10} = opc;
2214   let Inst{9-5}   = Zn;
2215   let Inst{4-0}   = Zd;
2218 multiclass sve2_int_mul_by_indexed_elem<bits<4> opc, string asm> {
2219   def _H : sve2_int_mul_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH> {
2220     bits<3> Zm;
2221     bits<3> iop;
2222     let Inst{22} = iop{2};
2223     let Inst{20-19} = iop{1-0};
2224     let Inst{18-16} = Zm;
2225   }
2226   def _S : sve2_int_mul_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS> {
2227     bits<3> Zm;
2228     bits<2> iop;
2229     let Inst{20-19} = iop;
2230     let Inst{18-16} = Zm;
2231   }
2232   def _D : sve2_int_mul_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD> {
2233     bits<4> Zm;
2234     bit iop;
2235     let Inst{20} = iop;
2236     let Inst{19-16} = Zm;
2237   }
2240 multiclass sve2_int_mul_long_by_indexed_elem<bits<3> opc, string asm> {
2241   def _S : sve2_int_mul_by_indexed_elem<0b10, { opc{2-1}, ?, opc{0} }, asm,
2242                                         ZPR32, ZPR16, ZPR3b16, VectorIndexH> {
2243     bits<3> Zm;
2244     bits<3> iop;
2245     let Inst{20-19} = iop{2-1};
2246     let Inst{18-16} = Zm;
2247     let Inst{11} = iop{0};
2248   }
2249   def _D : sve2_int_mul_by_indexed_elem<0b11, { opc{2-1}, ?, opc{0} }, asm,
2250                                         ZPR64, ZPR32, ZPR4b32, VectorIndexS> {
2251     bits<4> Zm;
2252     bits<2> iop;
2253     let Inst{20} = iop{1};
2254     let Inst{19-16} = Zm;
2255     let Inst{11} = iop{0};
2256   }
2259 //===----------------------------------------------------------------------===//
2260 // SVE2 Integer - Predicated Group
2261 //===----------------------------------------------------------------------===//
2263 class sve2_int_arith_pred<bits<2> sz, bits<6> opc, string asm,
2264                           ZPRRegOp zprty>
2265 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
2266   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
2267   bits<3> Pg;
2268   bits<5> Zm;
2269   bits<5> Zdn;
2270   let Inst{31-24} = 0b01000100;
2271   let Inst{23-22} = sz;
2272   let Inst{21}    = 0b0;
2273   let Inst{20-16} = opc{5-1};
2274   let Inst{15-14} = 0b10;
2275   let Inst{13}    = opc{0};
2276   let Inst{12-10} = Pg;
2277   let Inst{9-5}   = Zm;
2278   let Inst{4-0}   = Zdn;
2280   let Constraints = "$Zdn = $_Zdn";
2281   let DestructiveInstType = Destructive;
2282   let ElementSize = zprty.ElementSize;
2285 multiclass sve2_int_arith_pred<bits<6> opc, string asm> {
2286   def _B : sve2_int_arith_pred<0b00, opc, asm, ZPR8>;
2287   def _H : sve2_int_arith_pred<0b01, opc, asm, ZPR16>;
2288   def _S : sve2_int_arith_pred<0b10, opc, asm, ZPR32>;
2289   def _D : sve2_int_arith_pred<0b11, opc, asm, ZPR64>;
2292 class sve2_int_sadd_long_accum_pairwise<bits<2> sz, bit U, string asm,
2293                                         ZPRRegOp zprty1, ZPRRegOp zprty2>
2294 : I<(outs zprty1:$Zda), (ins PPR3bAny:$Pg, zprty1:$_Zda, zprty2:$Zn),
2295   asm, "\t$Zda, $Pg/m, $Zn", "", []>, Sched<[]> {
2296   bits<3> Pg;
2297   bits<5> Zn;
2298   bits<5> Zda;
2299   let Inst{31-24} = 0b01000100;
2300   let Inst{23-22} = sz;
2301   let Inst{21-17} = 0b00010;
2302   let Inst{16}    = U;
2303   let Inst{15-13} = 0b101;
2304   let Inst{12-10} = Pg;
2305   let Inst{9-5}   = Zn;
2306   let Inst{4-0}   = Zda;
2308   let Constraints = "$Zda = $_Zda";
2309   let DestructiveInstType = Destructive;
2310   let ElementSize = zprty1.ElementSize;
2313 multiclass sve2_int_sadd_long_accum_pairwise<bit U, string asm> {
2314   def _H : sve2_int_sadd_long_accum_pairwise<0b01, U, asm, ZPR16, ZPR8>;
2315   def _S : sve2_int_sadd_long_accum_pairwise<0b10, U, asm, ZPR32, ZPR16>;
2316   def _D : sve2_int_sadd_long_accum_pairwise<0b11, U, asm, ZPR64, ZPR32>;
2319 class sve2_int_un_pred_arit<bits<2> sz, bit Q, bits<2> opc,
2320                             string asm, ZPRRegOp zprty>
2321 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
2322   asm, "\t$Zd, $Pg/m, $Zn",
2323   "",
2324   []>, Sched<[]> {
2325   bits<3> Pg;
2326   bits<5> Zd;
2327   bits<5> Zn;
2328   let Inst{31-24} = 0b01000100;
2329   let Inst{23-22} = sz;
2330   let Inst{21-20} = 0b00;
2331   let Inst{19}    = Q;
2332   let Inst{18}    = 0b0;
2333   let Inst{17-16} = opc;
2334   let Inst{15-13} = 0b101;
2335   let Inst{12-10} = Pg;
2336   let Inst{9-5}   = Zn;
2337   let Inst{4-0}   = Zd;
2339   let Constraints = "$Zd = $_Zd";
2340   let DestructiveInstType = Destructive;
2341   let ElementSize = zprty.ElementSize;
2344 multiclass sve2_int_un_pred_arit_s<bits<3> opc, string asm> {
2345   def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>;
2348 multiclass sve2_int_un_pred_arit<bits<3> opc, string asm> {
2349   def _B : sve2_int_un_pred_arit<0b00, opc{2}, opc{1-0}, asm, ZPR8>;
2350   def _H : sve2_int_un_pred_arit<0b01, opc{2}, opc{1-0}, asm, ZPR16>;
2351   def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>;
2352   def _D : sve2_int_un_pred_arit<0b11, opc{2}, opc{1-0}, asm, ZPR64>;
2355 //===----------------------------------------------------------------------===//
2356 // SVE2 Widening Integer Arithmetic Group
2357 //===----------------------------------------------------------------------===//
2359 class sve2_wide_int_arith<bits<2> sz, bits<5> opc, string asm,
2360                           ZPRRegOp zprty1, ZPRRegOp zprty2, ZPRRegOp zprty3>
2361 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm),
2362   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2363   bits<5> Zd;
2364   bits<5> Zn;
2365   bits<5> Zm;
2366   let Inst{31-24} = 0b01000101;
2367   let Inst{23-22} = sz;
2368   let Inst{21}    = 0b0;
2369   let Inst{20-16} = Zm;
2370   let Inst{15}    = 0b0;
2371   let Inst{14-10} = opc;
2372   let Inst{9-5}   = Zn;
2373   let Inst{4-0}   = Zd;
2376 multiclass sve2_wide_int_arith_long<bits<5> opc, string asm> {
2377   def _H : sve2_wide_int_arith<0b01, opc, asm, ZPR16, ZPR8, ZPR8>;
2378   def _S : sve2_wide_int_arith<0b10, opc, asm, ZPR32, ZPR16, ZPR16>;
2379   def _D : sve2_wide_int_arith<0b11, opc, asm, ZPR64, ZPR32, ZPR32>;
2382 multiclass sve2_wide_int_arith_wide<bits<3> opc, string asm> {
2383   def _H : sve2_wide_int_arith<0b01, { 0b10, opc }, asm, ZPR16, ZPR16, ZPR8>;
2384   def _S : sve2_wide_int_arith<0b10, { 0b10, opc }, asm, ZPR32, ZPR32, ZPR16>;
2385   def _D : sve2_wide_int_arith<0b11, { 0b10, opc }, asm, ZPR64, ZPR64, ZPR32>;
2388 multiclass sve2_pmul_long<bits<1> opc, string asm> {
2389   def _H : sve2_wide_int_arith<0b01, {0b1101, opc}, asm, ZPR16, ZPR8, ZPR8>;
2390   def _D : sve2_wide_int_arith<0b11, {0b1101, opc}, asm, ZPR64, ZPR32, ZPR32>;
2393 //===----------------------------------------------------------------------===//
2394 // SVE2 Misc Group
2395 //===----------------------------------------------------------------------===//
2397 class sve2_misc<bits<2> sz, bits<4> opc, string asm,
2398                 ZPRRegOp zprty1, ZPRRegOp zprty2>
2399 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
2400   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2401   bits<5> Zd;
2402   bits<5> Zn;
2403   bits<5> Zm;
2404   let Inst{31-24} = 0b01000101;
2405   let Inst{23-22} = sz;
2406   let Inst{21}    = 0b0;
2407   let Inst{20-16} = Zm;
2408   let Inst{15-14} = 0b10;
2409   let Inst{13-10} = opc;
2410   let Inst{9-5}   = Zn;
2411   let Inst{4-0}   = Zd;
2414 multiclass sve2_misc_bitwise<bits<4> opc, string asm> {
2415   def _B : sve2_misc<0b00, opc, asm, ZPR8, ZPR8>;
2416   def _H : sve2_misc<0b01, opc, asm, ZPR16, ZPR16>;
2417   def _S : sve2_misc<0b10, opc, asm, ZPR32, ZPR32>;
2418   def _D : sve2_misc<0b11, opc, asm, ZPR64, ZPR64>;
2421 multiclass sve2_misc_int_addsub_long_interleaved<bits<2> opc, string asm> {
2422   def _H : sve2_misc<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
2423   def _S : sve2_misc<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
2424   def _D : sve2_misc<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
2427 class sve2_bitwise_xor_interleaved<bits<2> sz, bits<1> opc, string asm,
2428                                    ZPRRegOp zprty1, ZPRRegOp zprty2>
2429 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
2430   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2431   bits<5> Zd;
2432   bits<5> Zn;
2433   bits<5> Zm;
2434   let Inst{31-24} = 0b01000101;
2435   let Inst{23-22} = sz;
2436   let Inst{21}    = 0b0;
2437   let Inst{20-16} = Zm;
2438   let Inst{15-11} = 0b10010;
2439   let Inst{10}    = opc;
2440   let Inst{9-5}   = Zn;
2441   let Inst{4-0}   = Zd;
2443   let Constraints = "$Zd = $_Zd";
2444   let DestructiveInstType = Destructive;
2445   let ElementSize = ElementSizeNone;
2448 multiclass sve2_bitwise_xor_interleaved<bit opc, string asm> {
2449   def _B : sve2_bitwise_xor_interleaved<0b00, opc, asm, ZPR8,  ZPR8>;
2450   def _H : sve2_bitwise_xor_interleaved<0b01, opc, asm, ZPR16, ZPR16>;
2451   def _S : sve2_bitwise_xor_interleaved<0b10, opc, asm, ZPR32, ZPR32>;
2452   def _D : sve2_bitwise_xor_interleaved<0b11, opc, asm, ZPR64, ZPR64>;
2455 class sve2_bitwise_shift_left_long<bits<3> tsz8_64, bits<2> opc, string asm,
2456                                    ZPRRegOp zprty1, ZPRRegOp zprty2,
2457                                    Operand immtype>
2458 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
2459   asm, "\t$Zd, $Zn, $imm",
2460   "", []>, Sched<[]> {
2461   bits<5> Zd;
2462   bits<5> Zn;
2463   bits<5> imm;
2464   let Inst{31-23} = 0b010001010;
2465   let Inst{22}    = tsz8_64{2};
2466   let Inst{21}    = 0b0;
2467   let Inst{20-19} = tsz8_64{1-0};
2468   let Inst{18-16} = imm{2-0}; // imm3
2469   let Inst{15-12} = 0b1010;
2470   let Inst{11-10} = opc;
2471   let Inst{9-5}   = Zn;
2472   let Inst{4-0}   = Zd;
2475 multiclass sve2_bitwise_shift_left_long<bits<2> opc, string asm> {
2476   def _H : sve2_bitwise_shift_left_long<{0,0,1}, opc, asm,
2477                                         ZPR16, ZPR8, vecshiftL8>;
2478   def _S : sve2_bitwise_shift_left_long<{0,1,?}, opc, asm,
2479                                         ZPR32, ZPR16, vecshiftL16> {
2480     let Inst{19} = imm{3};
2481   }
2482   def _D : sve2_bitwise_shift_left_long<{1,?,?}, opc, asm,
2483                                         ZPR64, ZPR32, vecshiftL32> {
2484     let Inst{20-19} = imm{4-3};
2485   }
2488 //===----------------------------------------------------------------------===//
2489 // SVE2 Accumulate Group
2490 //===----------------------------------------------------------------------===//
2492 class sve2_int_bin_shift_imm<bits<4> tsz8_64, bit opc, string asm,
2493                              ZPRRegOp zprty, Operand immtype>
2494 : I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, immtype:$imm),
2495   asm, "\t$Zd, $Zn, $imm",
2496   "", []>, Sched<[]> {
2497   bits<5> Zd;
2498   bits<5> Zn;
2499   bits<6> imm;
2500   let Inst{31-24} = 0b01000101;
2501   let Inst{23-22} = tsz8_64{3-2};
2502   let Inst{21}    = 0b0;
2503   let Inst{20-19} = tsz8_64{1-0};
2504   let Inst{18-16} = imm{2-0}; // imm3
2505   let Inst{15-11} = 0b11110;
2506   let Inst{10}    = opc;
2507   let Inst{9-5}   = Zn;
2508   let Inst{4-0}   = Zd;
2510   let Constraints = "$Zd = $_Zd";
2513 multiclass sve2_int_bin_shift_imm_left<bit opc, string asm> {
2514   def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
2515   def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
2516     let Inst{19} = imm{3};
2517   }
2518   def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
2519     let Inst{20-19} = imm{4-3};
2520   }
2521   def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
2522     let Inst{22}    = imm{5};
2523     let Inst{20-19} = imm{4-3};
2524   }
2527 multiclass sve2_int_bin_shift_imm_right<bit opc, string asm> {
2528   def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
2529   def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
2530     let Inst{19} = imm{3};
2531   }
2532   def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
2533     let Inst{20-19} = imm{4-3};
2534   }
2535   def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
2536     let Inst{22}    = imm{5};
2537     let Inst{20-19} = imm{4-3};
2538   }
2541 class sve2_int_bin_accum_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
2542                                    ZPRRegOp zprty, Operand immtype>
2543 : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, immtype:$imm),
2544   asm, "\t$Zda, $Zn, $imm",
2545   "", []>, Sched<[]> {
2546   bits<5> Zda;
2547   bits<5> Zn;
2548   bits<6> imm;
2549   let Inst{31-24} = 0b01000101;
2550   let Inst{23-22} = tsz8_64{3-2};
2551   let Inst{21}    = 0b0;
2552   let Inst{20-19} = tsz8_64{1-0};
2553   let Inst{18-16} = imm{2-0}; // imm3
2554   let Inst{15-12} = 0b1110;
2555   let Inst{11-10} = opc;
2556   let Inst{9-5}   = Zn;
2557   let Inst{4-0}   = Zda;
2559   let Constraints = "$Zda = $_Zda";
2560   let DestructiveInstType = Destructive;
2561   let ElementSize = ElementSizeNone;
2564 multiclass sve2_int_bin_accum_shift_imm_right<bits<2> opc, string asm> {
2565   def _B : sve2_int_bin_accum_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
2566   def _H : sve2_int_bin_accum_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
2567     let Inst{19} = imm{3};
2568   }
2569   def _S : sve2_int_bin_accum_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
2570     let Inst{20-19} = imm{4-3};
2571   }
2572   def _D : sve2_int_bin_accum_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
2573     let Inst{22}    = imm{5};
2574     let Inst{20-19} = imm{4-3};
2575   }
2578 class sve2_int_cadd<bits<2> sz, bit opc, string asm, ZPRRegOp zprty>
2579 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, complexrotateopodd:$rot),
2580   asm, "\t$Zdn, $_Zdn, $Zm, $rot", "", []>, Sched<[]> {
2581   bits<5> Zdn;
2582   bits<5> Zm;
2583   bit rot;
2584   let Inst{31-24} = 0b01000101;
2585   let Inst{23-22} = sz;
2586   let Inst{21-17} = 0b00000;
2587   let Inst{16}    = opc;
2588   let Inst{15-11} = 0b11011;
2589   let Inst{10}    = rot;
2590   let Inst{9-5}   = Zm;
2591   let Inst{4-0}   = Zdn;
2593   let Constraints = "$Zdn = $_Zdn";
2594   let DestructiveInstType = Destructive;
2595   let ElementSize = ElementSizeNone;
2598 multiclass sve2_int_cadd<bit opc, string asm> {
2599   def _B : sve2_int_cadd<0b00, opc, asm, ZPR8>;
2600   def _H : sve2_int_cadd<0b01, opc, asm, ZPR16>;
2601   def _S : sve2_int_cadd<0b10, opc, asm, ZPR32>;
2602   def _D : sve2_int_cadd<0b11, opc, asm, ZPR64>;
2605 class sve2_int_absdiff_accum<bits<2> sz, bits<4> opc, string asm,
2606                              ZPRRegOp zprty1, ZPRRegOp zprty2>
2607 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
2608   asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
2609   bits<5> Zda;
2610   bits<5> Zn;
2611   bits<5> Zm;
2612   let Inst{31-24} = 0b01000101;
2613   let Inst{23-22} = sz;
2614   let Inst{21}    = 0b0;
2615   let Inst{20-16} = Zm;
2616   let Inst{15-14} = 0b11;
2617   let Inst{13-10} = opc;
2618   let Inst{9-5}   = Zn;
2619   let Inst{4-0}   = Zda;
2621   let Constraints = "$Zda = $_Zda";
2622   let DestructiveInstType = Destructive;
2623   let ElementSize = ElementSizeNone;
2626 multiclass sve2_int_absdiff_accum<bit opc, string asm> {
2627   def _B : sve2_int_absdiff_accum<0b00, { 0b111, opc }, asm, ZPR8, ZPR8>;
2628   def _H : sve2_int_absdiff_accum<0b01, { 0b111, opc }, asm, ZPR16, ZPR16>;
2629   def _S : sve2_int_absdiff_accum<0b10, { 0b111, opc }, asm, ZPR32, ZPR32>;
2630   def _D : sve2_int_absdiff_accum<0b11, { 0b111, opc }, asm, ZPR64, ZPR64>;
2633 multiclass sve2_int_absdiff_accum_long<bits<2> opc, string asm> {
2634   def _H : sve2_int_absdiff_accum<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
2635   def _S : sve2_int_absdiff_accum<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
2636   def _D : sve2_int_absdiff_accum<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
2639 multiclass sve2_int_addsub_long_carry<bits<2> opc, string asm> {
2640   def _S : sve2_int_absdiff_accum<{ opc{1}, 0b0 }, { 0b010, opc{0} }, asm,
2641                                   ZPR32, ZPR32>;
2642   def _D : sve2_int_absdiff_accum<{ opc{1}, 0b1 }, { 0b010, opc{0} }, asm,
2643                                   ZPR64, ZPR64>;
2646 //===----------------------------------------------------------------------===//
2647 // SVE2 Narrowing Group
2648 //===----------------------------------------------------------------------===//
2650 class sve2_int_bin_shift_imm_narrow_bottom<bits<3> tsz8_64, bits<3> opc,
2651                                            string asm, ZPRRegOp zprty1,
2652                                            ZPRRegOp zprty2, Operand immtype>
2653 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
2654   asm, "\t$Zd, $Zn, $imm",
2655   "", []>, Sched<[]> {
2656   bits<5> Zd;
2657   bits<5> Zn;
2658   bits<5> imm;
2659   let Inst{31-23} = 0b010001010;
2660   let Inst{22}    = tsz8_64{2};
2661   let Inst{21}    = 0b1;
2662   let Inst{20-19} = tsz8_64{1-0};
2663   let Inst{18-16} = imm{2-0}; // imm3
2664   let Inst{15-14} = 0b00;
2665   let Inst{13-11} = opc;
2666   let Inst{10}    = 0b0;
2667   let Inst{9-5}   = Zn;
2668   let Inst{4-0}   = Zd;
2671 multiclass sve2_int_bin_shift_imm_right_narrow_bottom<bits<3> opc, string asm> {
2672   def _B : sve2_int_bin_shift_imm_narrow_bottom<{0,0,1}, opc, asm, ZPR8, ZPR16,
2673                                                 vecshiftR8>;
2674   def _H : sve2_int_bin_shift_imm_narrow_bottom<{0,1,?}, opc, asm, ZPR16, ZPR32,
2675                                                 vecshiftR16> {
2676     let Inst{19} = imm{3};
2677   }
2678   def _S : sve2_int_bin_shift_imm_narrow_bottom<{1,?,?}, opc, asm, ZPR32, ZPR64,
2679                                                 vecshiftR32> {
2680     let Inst{20-19} = imm{4-3};
2681   }
2684 class sve2_int_bin_shift_imm_narrow_top<bits<3> tsz8_64, bits<3> opc,
2685                                         string asm, ZPRRegOp zprty1,
2686                                         ZPRRegOp zprty2, Operand immtype>
2687 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, immtype:$imm),
2688   asm, "\t$Zd, $Zn, $imm",
2689   "", []>, Sched<[]> {
2690   bits<5> Zd;
2691   bits<5> Zn;
2692   bits<5> imm;
2693   let Inst{31-23} = 0b010001010;
2694   let Inst{22}    = tsz8_64{2};
2695   let Inst{21}    = 0b1;
2696   let Inst{20-19} = tsz8_64{1-0};
2697   let Inst{18-16} = imm{2-0}; // imm3
2698   let Inst{15-14} = 0b00;
2699   let Inst{13-11} = opc;
2700   let Inst{10}    = 0b1;
2701   let Inst{9-5}   = Zn;
2702   let Inst{4-0}   = Zd;
2704   let Constraints = "$Zd = $_Zd";
2707 multiclass sve2_int_bin_shift_imm_right_narrow_top<bits<3> opc, string asm> {
2708   def _B : sve2_int_bin_shift_imm_narrow_top<{0,0,1}, opc, asm, ZPR8, ZPR16,
2709                                              vecshiftR8>;
2710   def _H : sve2_int_bin_shift_imm_narrow_top<{0,1,?}, opc, asm, ZPR16, ZPR32,
2711                                              vecshiftR16> {
2712     let Inst{19} = imm{3};
2713   }
2714   def _S : sve2_int_bin_shift_imm_narrow_top<{1,?,?}, opc, asm, ZPR32, ZPR64,
2715                                              vecshiftR32> {
2716     let Inst{20-19} = imm{4-3};
2717   }
2720 class sve2_int_addsub_narrow_high_bottom<bits<2> sz, bits<2> opc, string asm,
2721                                          ZPRRegOp zprty1, ZPRRegOp zprty2>
2722 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
2723   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2724   bits<5> Zd;
2725   bits<5> Zn;
2726   bits<5> Zm;
2727   let Inst{31-24} = 0b01000101;
2728   let Inst{23-22} = sz;
2729   let Inst{21}    = 0b1;
2730   let Inst{20-16} = Zm;
2731   let Inst{15-13} = 0b011;
2732   let Inst{12-11} = opc; // S, R
2733   let Inst{10}    = 0b0; // Top
2734   let Inst{9-5}   = Zn;
2735   let Inst{4-0}   = Zd;
2738 multiclass sve2_int_addsub_narrow_high_bottom<bits<2> opc, string asm> {
2739   def _B : sve2_int_addsub_narrow_high_bottom<0b01, opc, asm, ZPR8, ZPR16>;
2740   def _H : sve2_int_addsub_narrow_high_bottom<0b10, opc, asm, ZPR16, ZPR32>;
2741   def _S : sve2_int_addsub_narrow_high_bottom<0b11, opc, asm, ZPR32, ZPR64>;
2744 class sve2_int_addsub_narrow_high_top<bits<2> sz, bits<2> opc, string asm,
2745                                       ZPRRegOp zprty1, ZPRRegOp zprty2>
2746 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
2747   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2748   bits<5> Zd;
2749   bits<5> Zn;
2750   bits<5> Zm;
2751   let Inst{31-24} = 0b01000101;
2752   let Inst{23-22} = sz;
2753   let Inst{21}    = 0b1;
2754   let Inst{20-16} = Zm;
2755   let Inst{15-13} = 0b011;
2756   let Inst{12-11} = opc; // S, R
2757   let Inst{10}    = 0b1; // Top
2758   let Inst{9-5}   = Zn;
2759   let Inst{4-0}   = Zd;
2761   let Constraints = "$Zd = $_Zd";
2764 multiclass sve2_int_addsub_narrow_high_top<bits<2> opc, string asm> {
2765   def _B : sve2_int_addsub_narrow_high_top<0b01, opc, asm, ZPR8, ZPR16>;
2766   def _H : sve2_int_addsub_narrow_high_top<0b10, opc, asm, ZPR16, ZPR32>;
2767   def _S : sve2_int_addsub_narrow_high_top<0b11, opc, asm, ZPR32, ZPR64>;
2770 class sve2_int_sat_extract_narrow_bottom<bits<3> tsz8_64, bits<2> opc, string asm,
2771                                          ZPRRegOp zprty1, ZPRRegOp zprty2>
2772 : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
2773   asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
2774   bits<5> Zd;
2775   bits<5> Zn;
2776   let Inst{31-23} = 0b010001010;
2777   let Inst{22}    = tsz8_64{2};
2778   let Inst{21}    = 0b1;
2779   let Inst{20-19} = tsz8_64{1-0};
2780   let Inst{18-13} = 0b000010;
2781   let Inst{12-11} = opc;
2782   let Inst{10}    = 0b0;
2783   let Inst{9-5}   = Zn;
2784   let Inst{4-0}   = Zd;
2787 multiclass sve2_int_sat_extract_narrow_bottom<bits<2> opc, string asm> {
2788   def _B : sve2_int_sat_extract_narrow_bottom<0b001, opc, asm, ZPR8, ZPR16>;
2789   def _H : sve2_int_sat_extract_narrow_bottom<0b010, opc, asm, ZPR16, ZPR32>;
2790   def _S : sve2_int_sat_extract_narrow_bottom<0b100, opc, asm, ZPR32, ZPR64>;
2793 class sve2_int_sat_extract_narrow_top<bits<3> tsz8_64, bits<2> opc, string asm,
2794                                       ZPRRegOp zprty1, ZPRRegOp zprty2>
2795 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn),
2796   asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
2797   bits<5> Zd;
2798   bits<5> Zn;
2799   let Inst{31-23} = 0b010001010;
2800   let Inst{22}    = tsz8_64{2};
2801   let Inst{21}    = 0b1;
2802   let Inst{20-19} = tsz8_64{1-0};
2803   let Inst{18-13} = 0b000010;
2804   let Inst{12-11} = opc;
2805   let Inst{10}    = 0b1;
2806   let Inst{9-5}   = Zn;
2807   let Inst{4-0}   = Zd;
2809   let Constraints = "$Zd = $_Zd";
2812 multiclass sve2_int_sat_extract_narrow_top<bits<2> opc, string asm> {
2813   def _B : sve2_int_sat_extract_narrow_top<0b001, opc, asm, ZPR8, ZPR16>;
2814   def _H : sve2_int_sat_extract_narrow_top<0b010, opc, asm, ZPR16, ZPR32>;
2815   def _S : sve2_int_sat_extract_narrow_top<0b100, opc, asm, ZPR32, ZPR64>;
2818 //===----------------------------------------------------------------------===//
2819 // SVE Integer Arithmetic - Unary Predicated Group
2820 //===----------------------------------------------------------------------===//
2822 class sve_int_un_pred_arit<bits<2> sz8_64, bits<4> opc,
2823                              string asm, ZPRRegOp zprty>
2824 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
2825   asm, "\t$Zd, $Pg/m, $Zn",
2826   "",
2827   []>, Sched<[]> {
2828   bits<3> Pg;
2829   bits<5> Zd;
2830   bits<5> Zn;
2831   let Inst{31-24} = 0b00000100;
2832   let Inst{23-22} = sz8_64;
2833   let Inst{21-20} = 0b01;
2834   let Inst{19}    = opc{0};
2835   let Inst{18-16} = opc{3-1};
2836   let Inst{15-13} = 0b101;
2837   let Inst{12-10} = Pg;
2838   let Inst{9-5}   = Zn;
2839   let Inst{4-0}   = Zd;
2841   let Constraints = "$Zd = $_Zd";
2842   let DestructiveInstType = Destructive;
2843   let ElementSize = zprty.ElementSize;
2846 multiclass sve_int_un_pred_arit_0<bits<3> opc, string asm,
2847                                   SDPatternOperator op> {
2848   def _B : sve_int_un_pred_arit<0b00, { opc, 0b0 }, asm, ZPR8>;
2849   def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>;
2850   def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>;
2851   def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>;
2853   def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
2854   def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
2855   def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
2856   def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
2859 multiclass sve_int_un_pred_arit_0_h<bits<3> opc, string asm> {
2860   def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>;
2861   def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>;
2862   def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>;
2865 multiclass sve_int_un_pred_arit_0_w<bits<3> opc, string asm> {
2866   def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>;
2867   def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>;
2870 multiclass sve_int_un_pred_arit_0_d<bits<3> opc, string asm> {
2871   def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>;
2874 multiclass sve_int_un_pred_arit_1<bits<3> opc, string asm> {
2875   def _B : sve_int_un_pred_arit<0b00, { opc, 0b1 }, asm, ZPR8>;
2876   def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>;
2877   def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>;
2878   def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>;
2881 multiclass sve_int_un_pred_arit_1_fp<bits<3> opc, string asm> {
2882   def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>;
2883   def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>;
2884   def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>;
2887 //===----------------------------------------------------------------------===//
2888 // SVE Integer Wide Immediate - Unpredicated Group
2889 //===----------------------------------------------------------------------===//
2890 class sve_int_dup_imm<bits<2> sz8_64, string asm,
2891                       ZPRRegOp zprty, Operand immtype>
2892 : I<(outs zprty:$Zd), (ins immtype:$imm),
2893   asm, "\t$Zd, $imm",
2894   "",
2895   []>, Sched<[]> {
2896   bits<5> Zd;
2897   bits<9> imm;
2898   let Inst{31-24} = 0b00100101;
2899   let Inst{23-22} = sz8_64;
2900   let Inst{21-14} = 0b11100011;
2901   let Inst{13}    = imm{8};   // sh
2902   let Inst{12-5}  = imm{7-0}; // imm8
2903   let Inst{4-0}   = Zd;
2905   let isReMaterializable = 1;
2908 multiclass sve_int_dup_imm<string asm> {
2909   def _B : sve_int_dup_imm<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8>;
2910   def _H : sve_int_dup_imm<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16>;
2911   def _S : sve_int_dup_imm<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32>;
2912   def _D : sve_int_dup_imm<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64>;
2914   def : InstAlias<"mov $Zd, $imm",
2915                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, cpy_imm8_opt_lsl_i8:$imm), 1>;
2916   def : InstAlias<"mov $Zd, $imm",
2917                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, cpy_imm8_opt_lsl_i16:$imm), 1>;
2918   def : InstAlias<"mov $Zd, $imm",
2919                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, cpy_imm8_opt_lsl_i32:$imm), 1>;
2920   def : InstAlias<"mov $Zd, $imm",
2921                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, cpy_imm8_opt_lsl_i64:$imm), 1>;
2923   def : InstAlias<"fmov $Zd, #0.0",
2924                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, 0, 0), 1>;
2925   def : InstAlias<"fmov $Zd, #0.0",
2926                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, 0, 0), 1>;
2927   def : InstAlias<"fmov $Zd, #0.0",
2928                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, 0, 0), 1>;
2931 class sve_int_dup_fpimm<bits<2> sz8_64, Operand fpimmtype,
2932                         string asm, ZPRRegOp zprty>
2933 : I<(outs zprty:$Zd), (ins fpimmtype:$imm8),
2934   asm, "\t$Zd, $imm8",
2935   "",
2936   []>, Sched<[]> {
2937   bits<5> Zd;
2938   bits<8> imm8;
2939   let Inst{31-24} = 0b00100101;
2940   let Inst{23-22} = sz8_64;
2941   let Inst{21-14} = 0b11100111;
2942   let Inst{13}    = 0b0;
2943   let Inst{12-5}  = imm8;
2944   let Inst{4-0}   = Zd;
2946   let isReMaterializable = 1;
2949 multiclass sve_int_dup_fpimm<string asm> {
2950   def _H : sve_int_dup_fpimm<0b01, fpimm16, asm, ZPR16>;
2951   def _S : sve_int_dup_fpimm<0b10, fpimm32, asm, ZPR32>;
2952   def _D : sve_int_dup_fpimm<0b11, fpimm64, asm, ZPR64>;
2954   def : InstAlias<"fmov $Zd, $imm8",
2955                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, fpimm16:$imm8), 1>;
2956   def : InstAlias<"fmov $Zd, $imm8",
2957                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, fpimm32:$imm8), 1>;
2958   def : InstAlias<"fmov $Zd, $imm8",
2959                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, fpimm64:$imm8), 1>;
2962 class sve_int_arith_imm0<bits<2> sz8_64, bits<3> opc, string asm,
2963                          ZPRRegOp zprty, Operand immtype>
2964 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
2965   asm, "\t$Zdn, $_Zdn, $imm",
2966   "",
2967   []>, Sched<[]> {
2968   bits<5> Zdn;
2969   bits<9> imm;
2970   let Inst{31-24} = 0b00100101;
2971   let Inst{23-22} = sz8_64;
2972   let Inst{21-19} = 0b100;
2973   let Inst{18-16} = opc;
2974   let Inst{15-14} = 0b11;
2975   let Inst{13}    = imm{8};   // sh
2976   let Inst{12-5}  = imm{7-0}; // imm8
2977   let Inst{4-0}   = Zdn;
2979   let Constraints = "$Zdn = $_Zdn";
2980   let DestructiveInstType = Destructive;
2981   let ElementSize = ElementSizeNone;
2984 multiclass sve_int_arith_imm0<bits<3> opc, string asm> {
2985   def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8, addsub_imm8_opt_lsl_i8>;
2986   def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>;
2987   def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>;
2988   def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>;
2991 class sve_int_arith_imm<bits<2> sz8_64, bits<6> opc, string asm,
2992                         ZPRRegOp zprty, Operand immtype>
2993 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
2994   asm, "\t$Zdn, $_Zdn, $imm",
2995   "",
2996   []>, Sched<[]> {
2997   bits<5> Zdn;
2998   bits<8> imm;
2999   let Inst{31-24} = 0b00100101;
3000   let Inst{23-22} = sz8_64;
3001   let Inst{21-16} = opc;
3002   let Inst{15-13} = 0b110;
3003   let Inst{12-5} = imm;
3004   let Inst{4-0} = Zdn;
3006   let Constraints = "$Zdn = $_Zdn";
3007   let DestructiveInstType = Destructive;
3008   let ElementSize = ElementSizeNone;
3011 multiclass sve_int_arith_imm1<bits<2> opc, string asm, Operand immtype> {
3012   def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, immtype>;
3013   def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, immtype>;
3014   def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, immtype>;
3015   def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, immtype>;
3018 multiclass sve_int_arith_imm2<string asm> {
3019   def _B : sve_int_arith_imm<0b00, 0b110000, asm, ZPR8,  simm8>;
3020   def _H : sve_int_arith_imm<0b01, 0b110000, asm, ZPR16, simm8>;
3021   def _S : sve_int_arith_imm<0b10, 0b110000, asm, ZPR32, simm8>;
3022   def _D : sve_int_arith_imm<0b11, 0b110000, asm, ZPR64, simm8>;
3025 //===----------------------------------------------------------------------===//
3026 // SVE Bitwise Logical - Unpredicated Group
3027 //===----------------------------------------------------------------------===//
3029 class sve_int_bin_cons_log<bits<2> opc, string asm>
3030 : I<(outs ZPR64:$Zd), (ins ZPR64:$Zn, ZPR64:$Zm),
3031   asm, "\t$Zd, $Zn, $Zm",
3032   "",
3033   []>, Sched<[]> {
3034   bits<5> Zd;
3035   bits<5> Zm;
3036   bits<5> Zn;
3037   let Inst{31-24} = 0b00000100;
3038   let Inst{23-22} = opc{1-0};
3039   let Inst{21}    = 0b1;
3040   let Inst{20-16} = Zm;
3041   let Inst{15-10} = 0b001100;
3042   let Inst{9-5}   = Zn;
3043   let Inst{4-0}   = Zd;
3046 multiclass sve_int_bin_cons_log<bits<2> opc, string asm> {
3047   def NAME : sve_int_bin_cons_log<opc, asm>;
3049   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
3050                   (!cast<Instruction>(NAME) ZPR8:$Zd,  ZPR8:$Zn,  ZPR8:$Zm),  1>;
3051   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
3052                   (!cast<Instruction>(NAME) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 1>;
3053   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
3054                   (!cast<Instruction>(NAME) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 1>;
3057 class sve2_int_bitwise_ternary_op_d<bits<3> opc, string asm>
3058 : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, ZPR64:$Zm, ZPR64:$Zk),
3059   asm, "\t$Zdn, $_Zdn, $Zm, $Zk",
3060   "",
3061   []>, Sched<[]> {
3062   bits<5> Zdn;
3063   bits<5> Zk;
3064   bits<5> Zm;
3065   let Inst{31-24} = 0b00000100;
3066   let Inst{23-22} = opc{2-1};
3067   let Inst{21}    = 0b1;
3068   let Inst{20-16} = Zm;
3069   let Inst{15-11} = 0b00111;
3070   let Inst{10}    = opc{0};
3071   let Inst{9-5}   = Zk;
3072   let Inst{4-0}   = Zdn;
3074   let Constraints = "$Zdn = $_Zdn";
3075   let DestructiveInstType = Destructive;
3076   let ElementSize = ElementSizeNone;
3079 multiclass sve2_int_bitwise_ternary_op<bits<3> opc, string asm> {
3080   def NAME : sve2_int_bitwise_ternary_op_d<opc, asm>;
3082   def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
3083                   (!cast<Instruction>(NAME) ZPR8:$Zdn,  ZPR8:$Zm,  ZPR8:$Zk),  1>;
3084   def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
3085                   (!cast<Instruction>(NAME) ZPR16:$Zdn, ZPR16:$Zm, ZPR16:$Zk), 1>;
3086   def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
3087                   (!cast<Instruction>(NAME) ZPR32:$Zdn, ZPR32:$Zm, ZPR32:$Zk), 1>;
3090 class sve2_int_rotate_right_imm<bits<4> tsz8_64, string asm,
3091                                 ZPRRegOp zprty, Operand immtype>
3092 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, immtype:$imm),
3093   asm, "\t$Zdn, $_Zdn, $Zm, $imm",
3094   "",
3095   []>, Sched<[]> {
3096   bits<5> Zdn;
3097   bits<5> Zm;
3098   bits<6> imm;
3099   let Inst{31-24} = 0b00000100;
3100   let Inst{23-22} = tsz8_64{3-2};
3101   let Inst{21}    = 0b1;
3102   let Inst{20-19} = tsz8_64{1-0};
3103   let Inst{18-16} = imm{2-0}; // imm3
3104   let Inst{15-10} = 0b001101;
3105   let Inst{9-5}   = Zm;
3106   let Inst{4-0}   = Zdn;
3108   let Constraints = "$Zdn = $_Zdn";
3109   let DestructiveInstType = Destructive;
3110   let ElementSize = ElementSizeNone;
3113 multiclass sve2_int_rotate_right_imm<string asm> {
3114   def _B : sve2_int_rotate_right_imm<{0,0,0,1}, asm, ZPR8, vecshiftR8>;
3115   def _H : sve2_int_rotate_right_imm<{0,0,1,?}, asm, ZPR16, vecshiftR16> {
3116     let Inst{19} = imm{3};
3117   }
3118   def _S : sve2_int_rotate_right_imm<{0,1,?,?}, asm, ZPR32, vecshiftR32> {
3119     let Inst{20-19} = imm{4-3};
3120   }
3121   def _D : sve2_int_rotate_right_imm<{1,?,?,?}, asm, ZPR64, vecshiftR64> {
3122     let Inst{22}    = imm{5};
3123     let Inst{20-19} = imm{4-3};
3124   }
3127 //===----------------------------------------------------------------------===//
3128 // SVE Integer Wide Immediate - Predicated Group
3129 //===----------------------------------------------------------------------===//
3131 class sve_int_dup_fpimm_pred<bits<2> sz, Operand fpimmtype,
3132                              string asm, ZPRRegOp zprty>
3133 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPRAny:$Pg, fpimmtype:$imm8),
3134   asm, "\t$Zd, $Pg/m, $imm8",
3135   "",
3136   []>, Sched<[]> {
3137   bits<4> Pg;
3138   bits<5> Zd;
3139   bits<8> imm8;
3140   let Inst{31-24} = 0b00000101;
3141   let Inst{23-22} = sz;
3142   let Inst{21-20} = 0b01;
3143   let Inst{19-16} = Pg;
3144   let Inst{15-13} = 0b110;
3145   let Inst{12-5}  = imm8;
3146   let Inst{4-0}   = Zd;
3148   let Constraints = "$Zd = $_Zd";
3149   let DestructiveInstType = Destructive;
3150   let ElementSize = zprty.ElementSize;
3153 multiclass sve_int_dup_fpimm_pred<string asm> {
3154   def _H : sve_int_dup_fpimm_pred<0b01, fpimm16, asm, ZPR16>;
3155   def _S : sve_int_dup_fpimm_pred<0b10, fpimm32, asm, ZPR32>;
3156   def _D : sve_int_dup_fpimm_pred<0b11, fpimm64, asm, ZPR64>;
3158   def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
3159                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, fpimm16:$imm8), 1>;
3160   def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
3161                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, fpimm32:$imm8), 1>;
3162   def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
3163                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, fpimm64:$imm8), 1>;
3166 class sve_int_dup_imm_pred<bits<2> sz8_64, bit m, string asm,
3167                            ZPRRegOp zprty, string pred_qual, dag iops>
3168 : I<(outs zprty:$Zd), iops,
3169   asm, "\t$Zd, $Pg"#pred_qual#", $imm",
3170   "", []>, Sched<[]> {
3171   bits<5> Zd;
3172   bits<4> Pg;
3173   bits<9> imm;
3174   let Inst{31-24} = 0b00000101;
3175   let Inst{23-22} = sz8_64;
3176   let Inst{21-20} = 0b01;
3177   let Inst{19-16} = Pg;
3178   let Inst{15}    = 0b0;
3179   let Inst{14}    = m;
3180   let Inst{13}    = imm{8};   // sh
3181   let Inst{12-5}  = imm{7-0}; // imm8
3182   let Inst{4-0}   = Zd;
3184   let DestructiveInstType = Destructive;
3185   let ElementSize = zprty.ElementSize;
3188 multiclass sve_int_dup_imm_pred_merge<string asm> {
3189   let Constraints = "$Zd = $_Zd" in {
3190   def _B : sve_int_dup_imm_pred<0b00, 1, asm, ZPR8,  "/m", (ins ZPR8:$_Zd,  PPRAny:$Pg, cpy_imm8_opt_lsl_i8:$imm)>;
3191   def _H : sve_int_dup_imm_pred<0b01, 1, asm, ZPR16, "/m", (ins ZPR16:$_Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i16:$imm)>;
3192   def _S : sve_int_dup_imm_pred<0b10, 1, asm, ZPR32, "/m", (ins ZPR32:$_Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i32:$imm)>;
3193   def _D : sve_int_dup_imm_pred<0b11, 1, asm, ZPR64, "/m", (ins ZPR64:$_Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i64:$imm)>;
3194   }
3196   def : InstAlias<"mov $Zd, $Pg/m, $imm",
3197                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd,  PPRAny:$Pg, cpy_imm8_opt_lsl_i8:$imm), 1>;
3198   def : InstAlias<"mov $Zd, $Pg/m, $imm",
3199                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i16:$imm), 1>;
3200   def : InstAlias<"mov $Zd, $Pg/m, $imm",
3201                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i32:$imm), 1>;
3202   def : InstAlias<"mov $Zd, $Pg/m, $imm",
3203                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i64:$imm), 1>;
3205   def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
3206                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, 0, 0), 0>;
3207   def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
3208                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, 0, 0), 0>;
3209   def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
3210                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, 0, 0), 0>;
3213 multiclass sve_int_dup_imm_pred_zero<string asm> {
3214   def _B : sve_int_dup_imm_pred<0b00, 0, asm, ZPR8,  "/z", (ins PPRAny:$Pg, cpy_imm8_opt_lsl_i8:$imm)>;
3215   def _H : sve_int_dup_imm_pred<0b01, 0, asm, ZPR16, "/z", (ins PPRAny:$Pg, cpy_imm8_opt_lsl_i16:$imm)>;
3216   def _S : sve_int_dup_imm_pred<0b10, 0, asm, ZPR32, "/z", (ins PPRAny:$Pg, cpy_imm8_opt_lsl_i32:$imm)>;
3217   def _D : sve_int_dup_imm_pred<0b11, 0, asm, ZPR64, "/z", (ins PPRAny:$Pg, cpy_imm8_opt_lsl_i64:$imm)>;
3219   def : InstAlias<"mov $Zd, $Pg/z, $imm",
3220                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd,  PPRAny:$Pg, cpy_imm8_opt_lsl_i8:$imm), 1>;
3221   def : InstAlias<"mov $Zd, $Pg/z, $imm",
3222                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i16:$imm), 1>;
3223   def : InstAlias<"mov $Zd, $Pg/z, $imm",
3224                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i32:$imm), 1>;
3225   def : InstAlias<"mov $Zd, $Pg/z, $imm",
3226                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i64:$imm), 1>;
3229 //===----------------------------------------------------------------------===//
3230 // SVE Integer Compare - Vectors Group
3231 //===----------------------------------------------------------------------===//
3233 class sve_int_cmp<bit cmp_1, bits<2> sz8_64, bits<3> opc, string asm,
3234                   PPRRegOp pprty, ZPRRegOp zprty1, ZPRRegOp zprty2>
3235 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty1:$Zn, zprty2:$Zm),
3236   asm, "\t$Pd, $Pg/z, $Zn, $Zm",
3237   "",
3238   []>, Sched<[]> {
3239   bits<4> Pd;
3240   bits<3> Pg;
3241   bits<5> Zm;
3242   bits<5> Zn;
3243   let Inst{31-24} = 0b00100100;
3244   let Inst{23-22} = sz8_64;
3245   let Inst{21}    = 0b0;
3246   let Inst{20-16} = Zm;
3247   let Inst{15}    = opc{2};
3248   let Inst{14}    = cmp_1;
3249   let Inst{13}    = opc{1};
3250   let Inst{12-10} = Pg;
3251   let Inst{9-5}   = Zn;
3252   let Inst{4}     = opc{0};
3253   let Inst{3-0}   = Pd;
3255   let Defs = [NZCV];
3258 multiclass sve_int_cmp_0<bits<3> opc, string asm> {
3259   def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR8>;
3260   def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR16>;
3261   def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR32>;
3262   def _D : sve_int_cmp<0b0, 0b11, opc, asm, PPR64, ZPR64, ZPR64>;
3265 multiclass sve_int_cmp_0_wide<bits<3> opc, string asm> {
3266   def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
3267   def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
3268   def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
3271 multiclass sve_int_cmp_1_wide<bits<3> opc, string asm> {
3272   def _B : sve_int_cmp<0b1, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
3273   def _H : sve_int_cmp<0b1, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
3274   def _S : sve_int_cmp<0b1, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
3278 //===----------------------------------------------------------------------===//
3279 // SVE Integer Compare - Signed Immediate Group
3280 //===----------------------------------------------------------------------===//
3282 class sve_int_scmp_vi<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty,
3283                       ZPRRegOp zprty,
3284                       Operand immtype>
3285 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm5),
3286   asm, "\t$Pd, $Pg/z, $Zn, $imm5",
3287   "",
3288   []>, Sched<[]> {
3289   bits<4> Pd;
3290   bits<3> Pg;
3291   bits<5> Zn;
3292   bits<5> imm5;
3293   let Inst{31-24} = 0b00100101;
3294   let Inst{23-22} = sz8_64;
3295   let Inst{21}    = 0b0;
3296   let Inst{20-16} = imm5;
3297   let Inst{15}    = opc{2};
3298   let Inst{14}    = 0b0;
3299   let Inst{13}    = opc{1};
3300   let Inst{12-10} = Pg;
3301   let Inst{9-5}   = Zn;
3302   let Inst{4}     = opc{0};
3303   let Inst{3-0}   = Pd;
3305   let Defs = [NZCV];
3308 multiclass sve_int_scmp_vi<bits<3> opc, string asm> {
3309   def _B : sve_int_scmp_vi<0b00, opc, asm, PPR8, ZPR8, simm5_32b>;
3310   def _H : sve_int_scmp_vi<0b01, opc, asm, PPR16, ZPR16, simm5_32b>;
3311   def _S : sve_int_scmp_vi<0b10, opc, asm, PPR32, ZPR32, simm5_32b>;
3312   def _D : sve_int_scmp_vi<0b11, opc, asm, PPR64, ZPR64, simm5_64b>;
3316 //===----------------------------------------------------------------------===//
3317 // SVE Integer Compare - Unsigned Immediate Group
3318 //===----------------------------------------------------------------------===//
3320 class sve_int_ucmp_vi<bits<2> sz8_64, bits<2> opc, string asm, PPRRegOp pprty,
3321                       ZPRRegOp zprty, Operand immtype>
3322 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm7),
3323   asm, "\t$Pd, $Pg/z, $Zn, $imm7",
3324   "",
3325   []>, Sched<[]> {
3326   bits<4> Pd;
3327   bits<3> Pg;
3328   bits<5> Zn;
3329   bits<7> imm7;
3330   let Inst{31-24} = 0b00100100;
3331   let Inst{23-22} = sz8_64;
3332   let Inst{21}    = 1;
3333   let Inst{20-14} = imm7;
3334   let Inst{13}    = opc{1};
3335   let Inst{12-10} = Pg;
3336   let Inst{9-5}   = Zn;
3337   let Inst{4}     = opc{0};
3338   let Inst{3-0}   = Pd;
3340   let Defs = [NZCV];
3343 multiclass sve_int_ucmp_vi<bits<2> opc, string asm> {
3344   def _B : sve_int_ucmp_vi<0b00, opc, asm, PPR8, ZPR8, imm0_127>;
3345   def _H : sve_int_ucmp_vi<0b01, opc, asm, PPR16, ZPR16, imm0_127>;
3346   def _S : sve_int_ucmp_vi<0b10, opc, asm, PPR32, ZPR32, imm0_127>;
3347   def _D : sve_int_ucmp_vi<0b11, opc, asm, PPR64, ZPR64, imm0_127>;
3351 //===----------------------------------------------------------------------===//
3352 // SVE Integer Compare - Scalars Group
3353 //===----------------------------------------------------------------------===//
3355 class sve_int_cterm<bit sz, bit opc, string asm, RegisterClass rt>
3356 : I<(outs), (ins rt:$Rn, rt:$Rm),
3357   asm, "\t$Rn, $Rm",
3358   "",
3359   []>, Sched<[]> {
3360   bits<5> Rm;
3361   bits<5> Rn;
3362   let Inst{31-23} = 0b001001011;
3363   let Inst{22}    = sz;
3364   let Inst{21}    = 0b1;
3365   let Inst{20-16} = Rm;
3366   let Inst{15-10} = 0b001000;
3367   let Inst{9-5}   = Rn;
3368   let Inst{4}     = opc;
3369   let Inst{3-0}   = 0b0000;
3371   let Defs = [NZCV];
3374 class sve_int_while_rr<bits<2> sz8_64, bits<4> opc, string asm,
3375                        RegisterClass gprty, PPRRegOp pprty>
3376 : I<(outs pprty:$Pd), (ins gprty:$Rn, gprty:$Rm),
3377   asm, "\t$Pd, $Rn, $Rm",
3378   "", []>, Sched<[]> {
3379   bits<4> Pd;
3380   bits<5> Rm;
3381   bits<5> Rn;
3382   let Inst{31-24} = 0b00100101;
3383   let Inst{23-22} = sz8_64;
3384   let Inst{21}    = 0b1;
3385   let Inst{20-16} = Rm;
3386   let Inst{15-13} = 0b000;
3387   let Inst{12-10} = opc{3-1};
3388   let Inst{9-5}   = Rn;
3389   let Inst{4}     = opc{0};
3390   let Inst{3-0}   = Pd;
3392   let Defs = [NZCV];
3395 multiclass sve_int_while4_rr<bits<3> opc, string asm> {
3396   def _B : sve_int_while_rr<0b00, { 0, opc }, asm, GPR32, PPR8>;
3397   def _H : sve_int_while_rr<0b01, { 0, opc }, asm, GPR32, PPR16>;
3398   def _S : sve_int_while_rr<0b10, { 0, opc }, asm, GPR32, PPR32>;
3399   def _D : sve_int_while_rr<0b11, { 0, opc }, asm, GPR32, PPR64>;
3402 multiclass sve_int_while8_rr<bits<3> opc, string asm> {
3403   def _B : sve_int_while_rr<0b00, { 1, opc }, asm, GPR64, PPR8>;
3404   def _H : sve_int_while_rr<0b01, { 1, opc }, asm, GPR64, PPR16>;
3405   def _S : sve_int_while_rr<0b10, { 1, opc }, asm, GPR64, PPR32>;
3406   def _D : sve_int_while_rr<0b11, { 1, opc }, asm, GPR64, PPR64>;
3409 class sve2_int_while_rr<bits<2> sz8_64, bits<1> rw, string asm,
3410                         PPRRegOp pprty>
3411 : I<(outs pprty:$Pd), (ins GPR64:$Rn, GPR64:$Rm),
3412   asm, "\t$Pd, $Rn, $Rm",
3413   "", []>, Sched<[]> {
3414   bits<4> Pd;
3415   bits<5> Rm;
3416   bits<5> Rn;
3417   let Inst{31-24} = 0b00100101;
3418   let Inst{23-22} = sz8_64;
3419   let Inst{21}    = 0b1;
3420   let Inst{20-16} = Rm;
3421   let Inst{15-10} = 0b001100;
3422   let Inst{9-5}   = Rn;
3423   let Inst{4}     = rw;
3424   let Inst{3-0}   = Pd;
3426   let Defs = [NZCV];
3429 multiclass sve2_int_while_rr<bits<1> rw, string asm> {
3430   def _B : sve2_int_while_rr<0b00, rw, asm, PPR8>;
3431   def _H : sve2_int_while_rr<0b01, rw, asm, PPR16>;
3432   def _S : sve2_int_while_rr<0b10, rw, asm, PPR32>;
3433   def _D : sve2_int_while_rr<0b11, rw, asm, PPR64>;
3436 //===----------------------------------------------------------------------===//
3437 // SVE Floating Point Fast Reduction Group
3438 //===----------------------------------------------------------------------===//
3440 class sve_fp_fast_red<bits<2> sz, bits<3> opc, string asm,
3441                       ZPRRegOp zprty, RegisterClass dstRegClass>
3442 : I<(outs dstRegClass:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
3443   asm, "\t$Vd, $Pg, $Zn",
3444   "",
3445   []>, Sched<[]> {
3446   bits<5> Zn;
3447   bits<5> Vd;
3448   bits<3> Pg;
3449   let Inst{31-24} = 0b01100101;
3450   let Inst{23-22} = sz;
3451   let Inst{21-19} = 0b000;
3452   let Inst{18-16} = opc;
3453   let Inst{15-13} = 0b001;
3454   let Inst{12-10} = Pg;
3455   let Inst{9-5}   = Zn;
3456   let Inst{4-0}   = Vd;
3459 multiclass sve_fp_fast_red<bits<3> opc, string asm> {
3460   def _H : sve_fp_fast_red<0b01, opc, asm, ZPR16, FPR16>;
3461   def _S : sve_fp_fast_red<0b10, opc, asm, ZPR32, FPR32>;
3462   def _D : sve_fp_fast_red<0b11, opc, asm, ZPR64, FPR64>;
3466 //===----------------------------------------------------------------------===//
3467 // SVE Floating Point Accumulating Reduction Group
3468 //===----------------------------------------------------------------------===//
3470 class sve_fp_2op_p_vd<bits<2> sz, bits<3> opc, string asm,
3471                       ZPRRegOp zprty, RegisterClass dstRegClass>
3472 : I<(outs dstRegClass:$Vdn), (ins PPR3bAny:$Pg, dstRegClass:$_Vdn, zprty:$Zm),
3473   asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
3474   "",
3475   []>,
3476   Sched<[]> {
3477   bits<3> Pg;
3478   bits<5> Vdn;
3479   bits<5> Zm;
3480   let Inst{31-24} = 0b01100101;
3481   let Inst{23-22} = sz;
3482   let Inst{21-19} = 0b011;
3483   let Inst{18-16} = opc;
3484   let Inst{15-13} = 0b001;
3485   let Inst{12-10} = Pg;
3486   let Inst{9-5}   = Zm;
3487   let Inst{4-0}   = Vdn;
3489   let Constraints = "$Vdn = $_Vdn";
3492 multiclass sve_fp_2op_p_vd<bits<3> opc, string asm> {
3493   def _H : sve_fp_2op_p_vd<0b01, opc, asm, ZPR16, FPR16>;
3494   def _S : sve_fp_2op_p_vd<0b10, opc, asm, ZPR32, FPR32>;
3495   def _D : sve_fp_2op_p_vd<0b11, opc, asm, ZPR64, FPR64>;
3498 //===----------------------------------------------------------------------===//
3499 // SVE Floating Point Compare - Vectors Group
3500 //===----------------------------------------------------------------------===//
3502 class sve_fp_3op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
3503                       ZPRRegOp zprty>
3504 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
3505   asm, "\t$Pd, $Pg/z, $Zn, $Zm",
3506   "",
3507   []>, Sched<[]> {
3508   bits<4> Pd;
3509   bits<3> Pg;
3510   bits<5> Zm;
3511   bits<5> Zn;
3512   let Inst{31-24} = 0b01100101;
3513   let Inst{23-22} = sz;
3514   let Inst{21}    = 0b0;
3515   let Inst{20-16} = Zm;
3516   let Inst{15}    = opc{2};
3517   let Inst{14}    = 0b1;
3518   let Inst{13}    = opc{1};
3519   let Inst{12-10} = Pg;
3520   let Inst{9-5}   = Zn;
3521   let Inst{4}     = opc{0};
3522   let Inst{3-0}   = Pd;
3525 multiclass sve_fp_3op_p_pd<bits<3> opc, string asm> {
3526   def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
3527   def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
3528   def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
3532 //===----------------------------------------------------------------------===//
3533 // SVE Floating Point Compare - with Zero Group
3534 //===----------------------------------------------------------------------===//
3536 class sve_fp_2op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
3537                       ZPRRegOp zprty>
3538 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn),
3539   asm, "\t$Pd, $Pg/z, $Zn, #0.0",
3540   "",
3541   []>, Sched<[]> {
3542   bits<4> Pd;
3543   bits<3> Pg;
3544   bits<5> Zn;
3545   let Inst{31-24} = 0b01100101;
3546   let Inst{23-22} = sz;
3547   let Inst{21-18} = 0b0100;
3548   let Inst{17-16} = opc{2-1};
3549   let Inst{15-13} = 0b001;
3550   let Inst{12-10} = Pg;
3551   let Inst{9-5}   = Zn;
3552   let Inst{4}     = opc{0};
3553   let Inst{3-0}   = Pd;
3556 multiclass sve_fp_2op_p_pd<bits<3> opc, string asm> {
3557   def _H : sve_fp_2op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
3558   def _S : sve_fp_2op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
3559   def _D : sve_fp_2op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
3563 //===----------------------------------------------------------------------===//
3564 //SVE Index Generation Group
3565 //===----------------------------------------------------------------------===//
3567 class sve_int_index_ii<bits<2> sz8_64, string asm, ZPRRegOp zprty,
3568                        Operand imm_ty>
3569 : I<(outs zprty:$Zd), (ins imm_ty:$imm5, imm_ty:$imm5b),
3570   asm, "\t$Zd, $imm5, $imm5b",
3571   "", []>, Sched<[]> {
3572   bits<5> Zd;
3573   bits<5> imm5;
3574   bits<5> imm5b;
3575   let Inst{31-24} = 0b00000100;
3576   let Inst{23-22} = sz8_64;
3577   let Inst{21}    = 0b1;
3578   let Inst{20-16} = imm5b;
3579   let Inst{15-10} = 0b010000;
3580   let Inst{9-5}   = imm5;
3581   let Inst{4-0}   = Zd;
3584 multiclass sve_int_index_ii<string asm> {
3585   def _B : sve_int_index_ii<0b00, asm, ZPR8, simm5_32b>;
3586   def _H : sve_int_index_ii<0b01, asm, ZPR16, simm5_32b>;
3587   def _S : sve_int_index_ii<0b10, asm, ZPR32, simm5_32b>;
3588   def _D : sve_int_index_ii<0b11, asm, ZPR64, simm5_64b>;
3591 class sve_int_index_ir<bits<2> sz8_64, string asm, ZPRRegOp zprty,
3592                        RegisterClass srcRegType, Operand imm_ty>
3593 : I<(outs zprty:$Zd), (ins imm_ty:$imm5, srcRegType:$Rm),
3594   asm, "\t$Zd, $imm5, $Rm",
3595   "", []>, Sched<[]> {
3596   bits<5> Rm;
3597   bits<5> Zd;
3598   bits<5> imm5;
3599   let Inst{31-24} = 0b00000100;
3600   let Inst{23-22} = sz8_64;
3601   let Inst{21}    = 0b1;
3602   let Inst{20-16} = Rm;
3603   let Inst{15-10} = 0b010010;
3604   let Inst{9-5}   = imm5;
3605   let Inst{4-0}   = Zd;
3608 multiclass sve_int_index_ir<string asm> {
3609   def _B : sve_int_index_ir<0b00, asm, ZPR8, GPR32, simm5_32b>;
3610   def _H : sve_int_index_ir<0b01, asm, ZPR16, GPR32, simm5_32b>;
3611   def _S : sve_int_index_ir<0b10, asm, ZPR32, GPR32, simm5_32b>;
3612   def _D : sve_int_index_ir<0b11, asm, ZPR64, GPR64, simm5_64b>;
3615 class sve_int_index_ri<bits<2> sz8_64, string asm, ZPRRegOp zprty,
3616                        RegisterClass srcRegType, Operand imm_ty>
3617 : I<(outs zprty:$Zd), (ins srcRegType:$Rn, imm_ty:$imm5),
3618   asm, "\t$Zd, $Rn, $imm5",
3619   "", []>, Sched<[]> {
3620   bits<5> Rn;
3621   bits<5> Zd;
3622   bits<5> imm5;
3623   let Inst{31-24} = 0b00000100;
3624   let Inst{23-22} = sz8_64;
3625   let Inst{21}    = 0b1;
3626   let Inst{20-16} = imm5;
3627   let Inst{15-10} = 0b010001;
3628   let Inst{9-5}   = Rn;
3629   let Inst{4-0}   = Zd;
3632 multiclass sve_int_index_ri<string asm> {
3633   def _B : sve_int_index_ri<0b00, asm, ZPR8, GPR32, simm5_32b>;
3634   def _H : sve_int_index_ri<0b01, asm, ZPR16, GPR32, simm5_32b>;
3635   def _S : sve_int_index_ri<0b10, asm, ZPR32, GPR32, simm5_32b>;
3636   def _D : sve_int_index_ri<0b11, asm, ZPR64, GPR64, simm5_64b>;
3639 class sve_int_index_rr<bits<2> sz8_64, string asm, ZPRRegOp zprty,
3640                        RegisterClass srcRegType>
3641 : I<(outs zprty:$Zd), (ins srcRegType:$Rn, srcRegType:$Rm),
3642   asm, "\t$Zd, $Rn, $Rm",
3643   "", []>, Sched<[]> {
3644   bits<5> Zd;
3645   bits<5> Rm;
3646   bits<5> Rn;
3647   let Inst{31-24} = 0b00000100;
3648   let Inst{23-22} = sz8_64;
3649   let Inst{21}    = 0b1;
3650   let Inst{20-16} = Rm;
3651   let Inst{15-10} = 0b010011;
3652   let Inst{9-5}   = Rn;
3653   let Inst{4-0}   = Zd;
3656 multiclass sve_int_index_rr<string asm> {
3657   def _B : sve_int_index_rr<0b00, asm, ZPR8, GPR32>;
3658   def _H : sve_int_index_rr<0b01, asm, ZPR16, GPR32>;
3659   def _S : sve_int_index_rr<0b10, asm, ZPR32, GPR32>;
3660   def _D : sve_int_index_rr<0b11, asm, ZPR64, GPR64>;
3663 //===----------------------------------------------------------------------===//
3664 // SVE Bitwise Shift - Predicated Group
3665 //===----------------------------------------------------------------------===//
3666 class sve_int_bin_pred_shift_imm<bits<4> tsz8_64, bits<4> opc, string asm,
3667                                  ZPRRegOp zprty, Operand immtype,
3668                                  ElementSizeEnum size>
3669 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, immtype:$imm),
3670   asm, "\t$Zdn, $Pg/m, $_Zdn, $imm",
3671   "",
3672   []>, Sched<[]> {
3673   bits<3> Pg;
3674   bits<5> Zdn;
3675   bits<6> imm;
3676   let Inst{31-24} = 0b00000100;
3677   let Inst{23-22} = tsz8_64{3-2};
3678   let Inst{21-20} = 0b00;
3679   let Inst{19-16} = opc;
3680   let Inst{15-13} = 0b100;
3681   let Inst{12-10} = Pg;
3682   let Inst{9-8}   = tsz8_64{1-0};
3683   let Inst{7-5}   = imm{2-0}; // imm3
3684   let Inst{4-0}   = Zdn;
3686   let Constraints = "$Zdn = $_Zdn";
3687   let DestructiveInstType = Destructive;
3688   let ElementSize = size;
3691 multiclass sve_int_bin_pred_shift_imm_left<bits<4> opc, string asm> {
3692   def _B : sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8,
3693                                       ElementSizeB>;
3694   def _H : sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16,
3695                                       ElementSizeH> {
3696     let Inst{8} = imm{3};
3697   }
3698   def _S : sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32,
3699                                       ElementSizeS> {
3700     let Inst{9-8} = imm{4-3};
3701   }
3702   def _D : sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64,
3703                                       ElementSizeD> {
3704     let Inst{22}  = imm{5};
3705     let Inst{9-8} = imm{4-3};
3706   }
3709 multiclass sve_int_bin_pred_shift_imm_right<bits<4> opc, string asm> {
3710   def _B : sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8,
3711                                       ElementSizeB>;
3712   def _H : sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16,
3713                                       ElementSizeH> {
3714     let Inst{8} = imm{3};
3715   }
3716   def _S : sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32,
3717                                       ElementSizeS> {
3718     let Inst{9-8} = imm{4-3};
3719   }
3720   def _D : sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64,
3721                                       ElementSizeD> {
3722     let Inst{22}  = imm{5};
3723     let Inst{9-8} = imm{4-3};
3724   }
3727 class sve_int_bin_pred_shift<bits<2> sz8_64, bit wide, bits<3> opc,
3728                              string asm, ZPRRegOp zprty, ZPRRegOp zprty2>
3729 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty2:$Zm),
3730   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
3731   "",
3732   []>, Sched<[]> {
3733   bits<3> Pg;
3734   bits<5> Zdn;
3735   bits<5> Zm;
3736   let Inst{31-24} = 0b00000100;
3737   let Inst{23-22} = sz8_64;
3738   let Inst{21-20} = 0b01;
3739   let Inst{19}    = wide;
3740   let Inst{18-16} = opc;
3741   let Inst{15-13} = 0b100;
3742   let Inst{12-10} = Pg;
3743   let Inst{9-5}   = Zm;
3744   let Inst{4-0}   = Zdn;
3746   let Constraints = "$Zdn = $_Zdn";
3747   let DestructiveInstType = Destructive;
3748   let ElementSize = zprty.ElementSize;
3751 multiclass sve_int_bin_pred_shift<bits<3> opc, string asm> {
3752   def _B : sve_int_bin_pred_shift<0b00, 0b0, opc, asm, ZPR8, ZPR8>;
3753   def _H : sve_int_bin_pred_shift<0b01, 0b0, opc, asm, ZPR16, ZPR16>;
3754   def _S : sve_int_bin_pred_shift<0b10, 0b0, opc, asm, ZPR32, ZPR32>;
3755   def _D : sve_int_bin_pred_shift<0b11, 0b0, opc, asm, ZPR64, ZPR64>;
3758 multiclass sve_int_bin_pred_shift_wide<bits<3> opc, string asm> {
3759   def _B : sve_int_bin_pred_shift<0b00, 0b1, opc, asm, ZPR8, ZPR64>;
3760   def _H : sve_int_bin_pred_shift<0b01, 0b1, opc, asm, ZPR16, ZPR64>;
3761   def _S : sve_int_bin_pred_shift<0b10, 0b1, opc, asm, ZPR32, ZPR64>;
3764 //===----------------------------------------------------------------------===//
3765 // SVE Shift - Unpredicated Group
3766 //===----------------------------------------------------------------------===//
3768 class sve_int_bin_cons_shift_wide<bits<2> sz8_64, bits<2> opc, string asm,
3769                                ZPRRegOp zprty>
3770 : I<(outs zprty:$Zd), (ins zprty:$Zn, ZPR64:$Zm),
3771   asm, "\t$Zd, $Zn, $Zm",
3772   "",
3773   []>, Sched<[]> {
3774   bits<5> Zd;
3775   bits<5> Zm;
3776   bits<5> Zn;
3777   let Inst{31-24} = 0b00000100;
3778   let Inst{23-22} = sz8_64;
3779   let Inst{21}    = 0b1;
3780   let Inst{20-16} = Zm;
3781   let Inst{15-12} = 0b1000;
3782   let Inst{11-10} = opc;
3783   let Inst{9-5}   = Zn;
3784   let Inst{4-0}   = Zd;
3787 multiclass sve_int_bin_cons_shift_wide<bits<2> opc, string asm> {
3788   def _B : sve_int_bin_cons_shift_wide<0b00, opc, asm, ZPR8>;
3789   def _H : sve_int_bin_cons_shift_wide<0b01, opc, asm, ZPR16>;
3790   def _S : sve_int_bin_cons_shift_wide<0b10, opc, asm, ZPR32>;
3793 class sve_int_bin_cons_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
3794                                ZPRRegOp zprty, Operand immtype>
3795 : I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$imm),
3796   asm, "\t$Zd, $Zn, $imm",
3797   "", []>, Sched<[]> {
3798   bits<5> Zd;
3799   bits<5> Zn;
3800   bits<6> imm;
3801   let Inst{31-24} = 0b00000100;
3802   let Inst{23-22} = tsz8_64{3-2};
3803   let Inst{21}    = 0b1;
3804   let Inst{20-19} = tsz8_64{1-0};
3805   let Inst{18-16} = imm{2-0}; // imm3
3806   let Inst{15-12} = 0b1001;
3807   let Inst{11-10} = opc;
3808   let Inst{9-5}   = Zn;
3809   let Inst{4-0}   = Zd;
3812 multiclass sve_int_bin_cons_shift_imm_left<bits<2> opc, string asm> {
3813   def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
3814   def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
3815     let Inst{19} = imm{3};
3816   }
3817   def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
3818     let Inst{20-19} = imm{4-3};
3819   }
3820   def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
3821     let Inst{22}    = imm{5};
3822     let Inst{20-19} = imm{4-3};
3823   }
3826 multiclass sve_int_bin_cons_shift_imm_right<bits<2> opc, string asm> {
3827   def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
3828   def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
3829     let Inst{19} = imm{3};
3830   }
3831   def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
3832     let Inst{20-19} = imm{4-3};
3833   }
3834   def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
3835     let Inst{22}    = imm{5};
3836     let Inst{20-19} = imm{4-3};
3837   }
3839 //===----------------------------------------------------------------------===//
3840 // SVE Memory - Store Group
3841 //===----------------------------------------------------------------------===//
3843 class sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
3844                      RegisterOperand VecList>
3845 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
3846   asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3847   "",
3848   []>, Sched<[]> {
3849   bits<3> Pg;
3850   bits<5> Rn;
3851   bits<5> Zt;
3852   bits<4> imm4;
3853   let Inst{31-25} = 0b1110010;
3854   let Inst{24-23} = msz;
3855   let Inst{22-21} = esz;
3856   let Inst{20}    = 0;
3857   let Inst{19-16} = imm4;
3858   let Inst{15-13} = 0b111;
3859   let Inst{12-10} = Pg;
3860   let Inst{9-5}   = Rn;
3861   let Inst{4-0}   = Zt;
3863   let mayStore = 1;
3866 multiclass sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
3867                           RegisterOperand listty, ZPRRegOp zprty>
3869   def NAME : sve_mem_cst_si<msz, esz, asm, listty>;
3871   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3872                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
3873   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3874                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
3875   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3876                   (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
3879 class sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
3880                      string asm, Operand immtype>
3881 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
3882   asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3883   "",
3884   []>, Sched<[]> {
3885   bits<3> Pg;
3886   bits<5> Rn;
3887   bits<5> Zt;
3888   bits<4> imm4;
3889   let Inst{31-25} = 0b1110010;
3890   let Inst{24-23} = sz;
3891   let Inst{22-21} = nregs;
3892   let Inst{20}    = 1;
3893   let Inst{19-16} = imm4;
3894   let Inst{15-13} = 0b111;
3895   let Inst{12-10} = Pg;
3896   let Inst{9-5}   = Rn;
3897   let Inst{4-0}   = Zt;
3899   let mayStore = 1;
3902 multiclass sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
3903                           string asm, Operand immtype> {
3904   def NAME : sve_mem_est_si<sz, nregs, VecList, asm, immtype>;
3906   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3907                   (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
3910 class sve_mem_est_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
3911                      string asm, RegisterOperand gprty>
3912 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
3913   asm, "\t$Zt, $Pg, [$Rn, $Rm]",
3914   "",
3915   []>, Sched<[]> {
3916   bits<3> Pg;
3917   bits<5> Rm;
3918   bits<5> Rn;
3919   bits<5> Zt;
3920   let Inst{31-25} = 0b1110010;
3921   let Inst{24-23} = sz;
3922   let Inst{22-21} = nregs;
3923   let Inst{20-16} = Rm;
3924   let Inst{15-13} = 0b011;
3925   let Inst{12-10} = Pg;
3926   let Inst{9-5}   = Rn;
3927   let Inst{4-0}   = Zt;
3929   let mayStore = 1;
3932 class sve_mem_cst_ss_base<bits<4> dtype, string asm,
3933                           RegisterOperand listty, RegisterOperand gprty>
3934 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
3935   asm, "\t$Zt, $Pg, [$Rn, $Rm]",
3936   "",
3937   []>, Sched<[]> {
3938   bits<3> Pg;
3939   bits<5> Rm;
3940   bits<5> Rn;
3941   bits<5> Zt;
3942   let Inst{31-25} = 0b1110010;
3943   let Inst{24-21} = dtype;
3944   let Inst{20-16} = Rm;
3945   let Inst{15-13} = 0b010;
3946   let Inst{12-10} = Pg;
3947   let Inst{9-5}   = Rn;
3948   let Inst{4-0}   = Zt;
3950   let mayStore = 1;
3953 multiclass sve_mem_cst_ss<bits<4> dtype, string asm,
3954                           RegisterOperand listty, ZPRRegOp zprty,
3955                           RegisterOperand gprty> {
3956   def NAME : sve_mem_cst_ss_base<dtype, asm, listty, gprty>;
3958   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
3959                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
3962 class sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand VecList>
3963 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
3964   asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3965   "",
3966   []>, Sched<[]> {
3967   bits<3> Pg;
3968   bits<5> Rn;
3969   bits<5> Zt;
3970   bits<4> imm4;
3971   let Inst{31-25} = 0b1110010;
3972   let Inst{24-23} = msz;
3973   let Inst{22-20} = 0b001;
3974   let Inst{19-16} = imm4;
3975   let Inst{15-13} = 0b111;
3976   let Inst{12-10} = Pg;
3977   let Inst{9-5}   = Rn;
3978   let Inst{4-0}   = Zt;
3980   let mayStore = 1;
3983 multiclass sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand listty,
3984                             ZPRRegOp zprty> {
3985   def NAME : sve_mem_cstnt_si<msz, asm, listty>;
3987   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3988                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
3989   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3990                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
3991   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3992                   (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
3995 class sve_mem_cstnt_ss_base<bits<2> msz, string asm, RegisterOperand listty,
3996                             RegisterOperand gprty>
3997 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
3998   asm, "\t$Zt, $Pg, [$Rn, $Rm]",
3999   "",
4000   []>, Sched<[]> {
4001   bits<3> Pg;
4002   bits<5> Rm;
4003   bits<5> Rn;
4004   bits<5> Zt;
4005   let Inst{31-25} = 0b1110010;
4006   let Inst{24-23} = msz;
4007   let Inst{22-21} = 0b00;
4008   let Inst{20-16} = Rm;
4009   let Inst{15-13} = 0b011;
4010   let Inst{12-10} = Pg;
4011   let Inst{9-5}   = Rn;
4012   let Inst{4-0}   = Zt;
4014   let mayStore = 1;
4017 multiclass sve_mem_cstnt_ss<bits<2> msz, string asm, RegisterOperand listty,
4018                             ZPRRegOp zprty, RegisterOperand gprty> {
4019   def NAME : sve_mem_cstnt_ss_base<msz, asm, listty, gprty>;
4021   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
4022                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4025 class sve2_mem_sstnt_vs_base<bits<3> opc, string asm,
4026                              RegisterOperand listty, ZPRRegOp zprty>
4027 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm),
4028   asm, "\t$Zt, $Pg, [$Zn, $Rm]",
4029   "",
4030   []>, Sched<[]> {
4031   bits<3> Pg;
4032   bits<5> Rm;
4033   bits<5> Zn;
4034   bits<5> Zt;
4035   let Inst{31-25} = 0b1110010;
4036   let Inst{24-22} = opc;
4037   let Inst{21}    = 0b0;
4038   let Inst{20-16} = Rm;
4039   let Inst{15-13} = 0b001;
4040   let Inst{12-10} = Pg;
4041   let Inst{9-5}   = Zn;
4042   let Inst{4-0}   = Zt;
4044   let mayStore = 1;
4047 multiclass sve2_mem_sstnt_vs<bits<3> opc, string asm,
4048                              RegisterOperand listty, ZPRRegOp zprty> {
4049   def _REAL : sve2_mem_sstnt_vs_base<opc, asm, listty, zprty>;
4051   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]",
4052                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm), 0>;
4053   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
4054                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, XZR), 0>;
4055   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
4056                  (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, XZR), 1>;
4059 class sve_mem_sst_sv<bits<3> opc, bit xs, bit scaled, string asm,
4060                      RegisterOperand VecList, RegisterOperand zprext>
4061 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
4062   asm, "\t$Zt, $Pg, [$Rn, $Zm]",
4063   "",
4064   []>, Sched<[]> {
4065   bits<3> Pg;
4066   bits<5> Rn;
4067   bits<5> Zm;
4068   bits<5> Zt;
4069   let Inst{31-25} = 0b1110010;
4070   let Inst{24-22} = opc;
4071   let Inst{21}    = scaled;
4072   let Inst{20-16} = Zm;
4073   let Inst{15}    = 0b1;
4074   let Inst{14}    = xs;
4075   let Inst{13}    = 0;
4076   let Inst{12-10} = Pg;
4077   let Inst{9-5}   = Rn;
4078   let Inst{4-0}   = Zt;
4080   let mayStore = 1;
4083 multiclass sve_mem_sst_sv_32_scaled<bits<3> opc, string asm,
4084                                     RegisterOperand listty,
4085                                     ZPRRegOp zprty,
4086                                     RegisterOperand sxtw_opnd,
4087                                     RegisterOperand uxtw_opnd > {
4088   def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, listty, uxtw_opnd>;
4089   def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, listty, sxtw_opnd>;
4091   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4092                  (!cast<Instruction>(NAME # _UXTW_SCALED) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
4093   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4094                  (!cast<Instruction>(NAME # _SXTW_SCALED) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
4097 multiclass sve_mem_sst_sv_32_unscaled<bits<3> opc, string asm,
4098                                       RegisterOperand listty,
4099                                       ZPRRegOp zprty,
4100                                       RegisterOperand sxtw_opnd,
4101                                       RegisterOperand uxtw_opnd> {
4102   def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, listty, uxtw_opnd>;
4103   def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, listty, sxtw_opnd>;
4105   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4106                  (!cast<Instruction>(NAME # _UXTW) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
4107   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4108                  (!cast<Instruction>(NAME # _SXTW) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
4111 class sve_mem_sst_sv2<bits<2> msz, bit scaled, string asm,
4112                       RegisterOperand zprext>
4113 : I<(outs), (ins Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
4114   asm, "\t$Zt, $Pg, [$Rn, $Zm]",
4115   "",
4116   []>, Sched<[]> {
4117   bits<3> Pg;
4118   bits<5> Rn;
4119   bits<5> Zm;
4120   bits<5> Zt;
4121   let Inst{31-25} = 0b1110010;
4122   let Inst{24-23} = msz;
4123   let Inst{22}    = 0b0;
4124   let Inst{21}    = scaled;
4125   let Inst{20-16} = Zm;
4126   let Inst{15-13} = 0b101;
4127   let Inst{12-10} = Pg;
4128   let Inst{9-5}   = Rn;
4129   let Inst{4-0}   = Zt;
4131   let mayStore = 1;
4134 multiclass sve_mem_sst_sv_64_scaled<bits<2> msz, string asm,
4135                                     RegisterOperand zprext> {
4136   def "" : sve_mem_sst_sv2<msz, 1, asm, zprext>;
4138   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4139                  (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
4143 multiclass sve_mem_sst_sv_64_unscaled<bits<2> msz, string asm> {
4144   def "" : sve_mem_sst_sv2<msz, 0, asm, ZPR64ExtLSL8>;
4146   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4147                  (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
4150 class sve_mem_sst_vi<bits<3> opc, string asm, ZPRRegOp zprty,
4151                      RegisterOperand VecList, Operand imm_ty>
4152 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, zprty:$Zn, imm_ty:$imm5),
4153   asm, "\t$Zt, $Pg, [$Zn, $imm5]",
4154   "",
4155   []>, Sched<[]> {
4156   bits<3> Pg;
4157   bits<5> imm5;
4158   bits<5> Zn;
4159   bits<5> Zt;
4160   let Inst{31-25} = 0b1110010;
4161   let Inst{24-23} = opc{2-1};
4162   let Inst{22}    = 0b1;
4163   let Inst{21}    = opc{0};
4164   let Inst{20-16} = imm5;
4165   let Inst{15-13} = 0b101;
4166   let Inst{12-10} = Pg;
4167   let Inst{9-5}   = Zn;
4168   let Inst{4-0}   = Zt;
4170   let mayStore = 1;
4173 multiclass sve_mem_sst_vi_ptrs<bits<3> opc, string asm, RegisterOperand listty,
4174                                ZPRRegOp zprty, Operand imm_ty> {
4175   def _IMM : sve_mem_sst_vi<opc, asm, zprty, listty, imm_ty>;
4177   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
4178                   (!cast<Instruction>(NAME # _IMM) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, 0), 0>;
4179   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]",
4180                   (!cast<Instruction>(NAME # _IMM) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, imm_ty:$imm5), 0>;
4181   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
4182                   (!cast<Instruction>(NAME # _IMM) listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, 0), 1>;
4185 class sve_mem_z_spill<string asm>
4186 : I<(outs), (ins ZPRAny:$Zt, GPR64sp:$Rn, simm9:$imm9),
4187   asm, "\t$Zt, [$Rn, $imm9, mul vl]",
4188   "",
4189   []>, Sched<[]> {
4190   bits<5> Rn;
4191   bits<5> Zt;
4192   bits<9> imm9;
4193   let Inst{31-22} = 0b1110010110;
4194   let Inst{21-16} = imm9{8-3};
4195   let Inst{15-13} = 0b010;
4196   let Inst{12-10} = imm9{2-0};
4197   let Inst{9-5}   = Rn;
4198   let Inst{4-0}   = Zt;
4200   let mayStore = 1;
4203 multiclass sve_mem_z_spill<string asm> {
4204   def NAME : sve_mem_z_spill<asm>;
4206   def : InstAlias<asm # "\t$Zt, [$Rn]",
4207                   (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
4210 class sve_mem_p_spill<string asm>
4211 : I<(outs), (ins PPRAny:$Pt, GPR64sp:$Rn, simm9:$imm9),
4212   asm, "\t$Pt, [$Rn, $imm9, mul vl]",
4213   "",
4214   []>, Sched<[]> {
4215   bits<4> Pt;
4216   bits<5> Rn;
4217   bits<9> imm9;
4218   let Inst{31-22} = 0b1110010110;
4219   let Inst{21-16} = imm9{8-3};
4220   let Inst{15-13} = 0b000;
4221   let Inst{12-10} = imm9{2-0};
4222   let Inst{9-5}   = Rn;
4223   let Inst{4}     = 0b0;
4224   let Inst{3-0}   = Pt;
4226   let mayStore = 1;
4229 multiclass sve_mem_p_spill<string asm> {
4230   def NAME : sve_mem_p_spill<asm>;
4232   def : InstAlias<asm # "\t$Pt, [$Rn]",
4233                   (!cast<Instruction>(NAME) PPRAny:$Pt, GPR64sp:$Rn, 0), 1>;
4236 //===----------------------------------------------------------------------===//
4237 // SVE Permute - Predicates Group
4238 //===----------------------------------------------------------------------===//
4240 class sve_int_perm_bin_perm_pp<bits<3> opc, bits<2> sz8_64, string asm,
4241                                PPRRegOp pprty>
4242 : I<(outs pprty:$Pd), (ins pprty:$Pn, pprty:$Pm),
4243   asm, "\t$Pd, $Pn, $Pm",
4244   "",
4245   []>, Sched<[]> {
4246   bits<4> Pd;
4247   bits<4> Pm;
4248   bits<4> Pn;
4249   let Inst{31-24} = 0b00000101;
4250   let Inst{23-22} = sz8_64;
4251   let Inst{21-20} = 0b10;
4252   let Inst{19-16} = Pm;
4253   let Inst{15-13} = 0b010;
4254   let Inst{12-10} = opc;
4255   let Inst{9}     = 0b0;
4256   let Inst{8-5}   = Pn;
4257   let Inst{4}     = 0b0;
4258   let Inst{3-0}   = Pd;
4261 multiclass sve_int_perm_bin_perm_pp<bits<3> opc, string asm> {
4262   def _B : sve_int_perm_bin_perm_pp<opc, 0b00, asm, PPR8>;
4263   def _H : sve_int_perm_bin_perm_pp<opc, 0b01, asm, PPR16>;
4264   def _S : sve_int_perm_bin_perm_pp<opc, 0b10, asm, PPR32>;
4265   def _D : sve_int_perm_bin_perm_pp<opc, 0b11, asm, PPR64>;
4268 class sve_int_perm_punpk<bit opc, string asm>
4269 : I<(outs PPR16:$Pd), (ins PPR8:$Pn),
4270   asm, "\t$Pd, $Pn",
4271   "",
4272   []>, Sched<[]> {
4273   bits<4> Pd;
4274   bits<4> Pn;
4275   let Inst{31-17} = 0b000001010011000;
4276   let Inst{16}    = opc;
4277   let Inst{15-9}  = 0b0100000;
4278   let Inst{8-5}   = Pn;
4279   let Inst{4}     = 0b0;
4280   let Inst{3-0}   = Pd;
4283 class sve_int_rdffr_pred<bit s, string asm>
4284 : I<(outs PPR8:$Pd), (ins PPRAny:$Pg),
4285   asm, "\t$Pd, $Pg/z",
4286   "",
4287   []>, Sched<[]> {
4288   bits<4> Pd;
4289   bits<4> Pg;
4290   let Inst{31-23} = 0b001001010;
4291   let Inst{22}    = s;
4292   let Inst{21-9}  = 0b0110001111000;
4293   let Inst{8-5}   = Pg;
4294   let Inst{4}     = 0;
4295   let Inst{3-0}   = Pd;
4297   let Defs = !if(!eq (s, 1), [NZCV], []);
4298   let Uses = [FFR];
4301 class sve_int_rdffr_unpred<string asm> : I<
4302   (outs PPR8:$Pd), (ins),
4303   asm, "\t$Pd",
4304   "",
4305   []>, Sched<[]> {
4306   bits<4> Pd;
4307   let Inst{31-4} = 0b0010010100011001111100000000;
4308   let Inst{3-0}   = Pd;
4310   let Uses = [FFR];
4313 class sve_int_wrffr<string asm>
4314 : I<(outs), (ins PPR8:$Pn),
4315   asm, "\t$Pn",
4316   "",
4317   []>, Sched<[]> {
4318   bits<4> Pn;
4319   let Inst{31-9} = 0b00100101001010001001000;
4320   let Inst{8-5}  = Pn;
4321   let Inst{4-0}  = 0b00000;
4323   let hasSideEffects = 1;
4324   let Defs = [FFR];
4327 class sve_int_setffr<string asm>
4328 : I<(outs), (ins),
4329   asm, "",
4330   "",
4331   []>, Sched<[]> {
4332   let Inst{31-0} = 0b00100101001011001001000000000000;
4334   let hasSideEffects = 1;
4335   let Defs = [FFR];
4338 //===----------------------------------------------------------------------===//
4339 // SVE Permute Vector - Predicated Group
4340 //===----------------------------------------------------------------------===//
4342 class sve_int_perm_clast_rz<bits<2> sz8_64, bit ab, string asm,
4343                             ZPRRegOp zprty, RegisterClass rt>
4344 : I<(outs rt:$Rdn), (ins PPR3bAny:$Pg, rt:$_Rdn, zprty:$Zm),
4345   asm, "\t$Rdn, $Pg, $_Rdn, $Zm",
4346   "",
4347   []>, Sched<[]> {
4348   bits<3> Pg;
4349   bits<5> Rdn;
4350   bits<5> Zm;
4351   let Inst{31-24} = 0b00000101;
4352   let Inst{23-22} = sz8_64;
4353   let Inst{21-17} = 0b11000;
4354   let Inst{16}    = ab;
4355   let Inst{15-13} = 0b101;
4356   let Inst{12-10} = Pg;
4357   let Inst{9-5}   = Zm;
4358   let Inst{4-0}   = Rdn;
4360   let Constraints = "$Rdn = $_Rdn";
4363 multiclass sve_int_perm_clast_rz<bit ab, string asm> {
4364   def _B : sve_int_perm_clast_rz<0b00, ab, asm, ZPR8, GPR32>;
4365   def _H : sve_int_perm_clast_rz<0b01, ab, asm, ZPR16, GPR32>;
4366   def _S : sve_int_perm_clast_rz<0b10, ab, asm, ZPR32, GPR32>;
4367   def _D : sve_int_perm_clast_rz<0b11, ab, asm, ZPR64, GPR64>;
4370 class sve_int_perm_clast_vz<bits<2> sz8_64, bit ab, string asm,
4371                             ZPRRegOp zprty, RegisterClass rt>
4372 : I<(outs rt:$Vdn), (ins PPR3bAny:$Pg, rt:$_Vdn, zprty:$Zm),
4373   asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
4374   "",
4375   []>, Sched<[]> {
4376   bits<3> Pg;
4377   bits<5> Vdn;
4378   bits<5> Zm;
4379   let Inst{31-24} = 0b00000101;
4380   let Inst{23-22} = sz8_64;
4381   let Inst{21-17} = 0b10101;
4382   let Inst{16}    = ab;
4383   let Inst{15-13} = 0b100;
4384   let Inst{12-10} = Pg;
4385   let Inst{9-5}   = Zm;
4386   let Inst{4-0}   = Vdn;
4388   let Constraints = "$Vdn = $_Vdn";
4391 multiclass sve_int_perm_clast_vz<bit ab, string asm> {
4392   def _B : sve_int_perm_clast_vz<0b00, ab, asm, ZPR8, FPR8>;
4393   def _H : sve_int_perm_clast_vz<0b01, ab, asm, ZPR16, FPR16>;
4394   def _S : sve_int_perm_clast_vz<0b10, ab, asm, ZPR32, FPR32>;
4395   def _D : sve_int_perm_clast_vz<0b11, ab, asm, ZPR64, FPR64>;
4398 class sve_int_perm_clast_zz<bits<2> sz8_64, bit ab, string asm,
4399                             ZPRRegOp zprty>
4400 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
4401   asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
4402   "",
4403   []>, Sched<[]> {
4404   bits<3> Pg;
4405   bits<5> Zdn;
4406   bits<5> Zm;
4407   let Inst{31-24} = 0b00000101;
4408   let Inst{23-22} = sz8_64;
4409   let Inst{21-17} = 0b10100;
4410   let Inst{16}    = ab;
4411   let Inst{15-13} = 0b100;
4412   let Inst{12-10} = Pg;
4413   let Inst{9-5}   = Zm;
4414   let Inst{4-0}   = Zdn;
4416   let Constraints = "$Zdn = $_Zdn";
4417   let DestructiveInstType = Destructive;
4418   let ElementSize = ElementSizeNone;
4421 multiclass sve_int_perm_clast_zz<bit ab, string asm> {
4422   def _B : sve_int_perm_clast_zz<0b00, ab, asm, ZPR8>;
4423   def _H : sve_int_perm_clast_zz<0b01, ab, asm, ZPR16>;
4424   def _S : sve_int_perm_clast_zz<0b10, ab, asm, ZPR32>;
4425   def _D : sve_int_perm_clast_zz<0b11, ab, asm, ZPR64>;
4428 class sve_int_perm_last_r<bits<2> sz8_64, bit ab, string asm,
4429                           ZPRRegOp zprty, RegisterClass resultRegType>
4430 : I<(outs resultRegType:$Rd), (ins PPR3bAny:$Pg, zprty:$Zn),
4431   asm, "\t$Rd, $Pg, $Zn",
4432   "",
4433   []>, Sched<[]> {
4434   bits<3> Pg;
4435   bits<5> Rd;
4436   bits<5> Zn;
4437   let Inst{31-24} = 0b00000101;
4438   let Inst{23-22} = sz8_64;
4439   let Inst{21-17} = 0b10000;
4440   let Inst{16}    = ab;
4441   let Inst{15-13} = 0b101;
4442   let Inst{12-10} = Pg;
4443   let Inst{9-5}   = Zn;
4444   let Inst{4-0}   = Rd;
4447 multiclass sve_int_perm_last_r<bit ab, string asm> {
4448   def _B : sve_int_perm_last_r<0b00, ab, asm, ZPR8, GPR32>;
4449   def _H : sve_int_perm_last_r<0b01, ab, asm, ZPR16, GPR32>;
4450   def _S : sve_int_perm_last_r<0b10, ab, asm, ZPR32, GPR32>;
4451   def _D : sve_int_perm_last_r<0b11, ab, asm, ZPR64, GPR64>;
4454 class sve_int_perm_last_v<bits<2> sz8_64, bit ab, string asm,
4455                           ZPRRegOp zprty, RegisterClass dstRegtype>
4456 : I<(outs dstRegtype:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
4457   asm, "\t$Vd, $Pg, $Zn",
4458   "",
4459   []>, Sched<[]> {
4460   bits<3> Pg;
4461   bits<5> Vd;
4462   bits<5> Zn;
4463   let Inst{31-24} = 0b00000101;
4464   let Inst{23-22} = sz8_64;
4465   let Inst{21-17} = 0b10001;
4466   let Inst{16}    = ab;
4467   let Inst{15-13} = 0b100;
4468   let Inst{12-10} = Pg;
4469   let Inst{9-5}   = Zn;
4470   let Inst{4-0}   = Vd;
4473 multiclass sve_int_perm_last_v<bit ab, string asm> {
4474   def _B : sve_int_perm_last_v<0b00, ab, asm, ZPR8, FPR8>;
4475   def _H : sve_int_perm_last_v<0b01, ab, asm, ZPR16, FPR16>;
4476   def _S : sve_int_perm_last_v<0b10, ab, asm, ZPR32, FPR32>;
4477   def _D : sve_int_perm_last_v<0b11, ab, asm, ZPR64, FPR64>;
4480 class sve_int_perm_splice<bits<2> sz8_64, string asm, ZPRRegOp zprty>
4481 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
4482   asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
4483   "",
4484   []>, Sched<[]> {
4485   bits<3> Pg;
4486   bits<5> Zdn;
4487   bits<5> Zm;
4488   let Inst{31-24} = 0b00000101;
4489   let Inst{23-22} = sz8_64;
4490   let Inst{21-13} = 0b101100100;
4491   let Inst{12-10} = Pg;
4492   let Inst{9-5}   = Zm;
4493   let Inst{4-0}   = Zdn;
4495   let Constraints = "$Zdn = $_Zdn";
4496   let DestructiveInstType = Destructive;
4497   let ElementSize = ElementSizeNone;
4500 multiclass sve_int_perm_splice<string asm> {
4501   def _B : sve_int_perm_splice<0b00, asm, ZPR8>;
4502   def _H : sve_int_perm_splice<0b01, asm, ZPR16>;
4503   def _S : sve_int_perm_splice<0b10, asm, ZPR32>;
4504   def _D : sve_int_perm_splice<0b11, asm, ZPR64>;
4507 class sve2_int_perm_splice_cons<bits<2> sz8_64, string asm,
4508                                ZPRRegOp zprty, RegisterOperand VecList>
4509 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, VecList:$Zn),
4510   asm, "\t$Zd, $Pg, $Zn",
4511   "",
4512   []>, Sched<[]> {
4513   bits<3> Pg;
4514   bits<5> Zn;
4515   bits<5> Zd;
4516   let Inst{31-24} = 0b00000101;
4517   let Inst{23-22} = sz8_64;
4518   let Inst{21-13} = 0b101101100;
4519   let Inst{12-10} = Pg;
4520   let Inst{9-5}   = Zn;
4521   let Inst{4-0}   = Zd;
4524 multiclass sve2_int_perm_splice_cons<string asm> {
4525   def _B : sve2_int_perm_splice_cons<0b00, asm, ZPR8,  ZZ_b>;
4526   def _H : sve2_int_perm_splice_cons<0b01, asm, ZPR16, ZZ_h>;
4527   def _S : sve2_int_perm_splice_cons<0b10, asm, ZPR32, ZZ_s>;
4528   def _D : sve2_int_perm_splice_cons<0b11, asm, ZPR64, ZZ_d>;
4531 class sve_int_perm_rev<bits<2> sz8_64, bits<2> opc, string asm,
4532                        ZPRRegOp zprty>
4533 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
4534   asm, "\t$Zd, $Pg/m, $Zn",
4535   "",
4536   []>, Sched<[]> {
4537   bits<5> Zd;
4538   bits<3> Pg;
4539   bits<5> Zn;
4540   let Inst{31-24} = 0b00000101;
4541   let Inst{23-22} = sz8_64;
4542   let Inst{21-18} = 0b1001;
4543   let Inst{17-16} = opc;
4544   let Inst{15-13} = 0b100;
4545   let Inst{12-10} = Pg;
4546   let Inst{9-5}   = Zn;
4547   let Inst{4-0}   = Zd;
4549   let Constraints = "$Zd = $_Zd";
4550   let DestructiveInstType = Destructive;
4551   let ElementSize = zprty.ElementSize;
4554 multiclass sve_int_perm_rev_rbit<string asm> {
4555   def _B : sve_int_perm_rev<0b00, 0b11, asm, ZPR8>;
4556   def _H : sve_int_perm_rev<0b01, 0b11, asm, ZPR16>;
4557   def _S : sve_int_perm_rev<0b10, 0b11, asm, ZPR32>;
4558   def _D : sve_int_perm_rev<0b11, 0b11, asm, ZPR64>;
4561 multiclass sve_int_perm_rev_revb<string asm> {
4562   def _H : sve_int_perm_rev<0b01, 0b00, asm, ZPR16>;
4563   def _S : sve_int_perm_rev<0b10, 0b00, asm, ZPR32>;
4564   def _D : sve_int_perm_rev<0b11, 0b00, asm, ZPR64>;
4567 multiclass sve_int_perm_rev_revh<string asm> {
4568   def _S : sve_int_perm_rev<0b10, 0b01, asm, ZPR32>;
4569   def _D : sve_int_perm_rev<0b11, 0b01, asm, ZPR64>;
4572 multiclass sve_int_perm_rev_revw<string asm> {
4573   def _D : sve_int_perm_rev<0b11, 0b10, asm, ZPR64>;
4576 class sve_int_perm_cpy_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
4577                          RegisterClass srcRegType>
4578 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegType:$Rn),
4579   asm, "\t$Zd, $Pg/m, $Rn",
4580   "",
4581   []>, Sched<[]> {
4582   bits<3> Pg;
4583   bits<5> Rn;
4584   bits<5> Zd;
4585   let Inst{31-24} = 0b00000101;
4586   let Inst{23-22} = sz8_64;
4587   let Inst{21-13} = 0b101000101;
4588   let Inst{12-10} = Pg;
4589   let Inst{9-5}   = Rn;
4590   let Inst{4-0}   = Zd;
4592   let Constraints = "$Zd = $_Zd";
4593   let DestructiveInstType = Destructive;
4594   let ElementSize = zprty.ElementSize;
4597 multiclass sve_int_perm_cpy_r<string asm> {
4598   def _B : sve_int_perm_cpy_r<0b00, asm, ZPR8, GPR32sp>;
4599   def _H : sve_int_perm_cpy_r<0b01, asm, ZPR16, GPR32sp>;
4600   def _S : sve_int_perm_cpy_r<0b10, asm, ZPR32, GPR32sp>;
4601   def _D : sve_int_perm_cpy_r<0b11, asm, ZPR64, GPR64sp>;
4603   def : InstAlias<"mov $Zd, $Pg/m, $Rn",
4604                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
4605   def : InstAlias<"mov $Zd, $Pg/m, $Rn",
4606                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
4607   def : InstAlias<"mov $Zd, $Pg/m, $Rn",
4608                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
4609   def : InstAlias<"mov $Zd, $Pg/m, $Rn",
4610                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, GPR64sp:$Rn), 1>;
4613 class sve_int_perm_cpy_v<bits<2> sz8_64, string asm, ZPRRegOp zprty,
4614                          RegisterClass srcRegtype>
4615 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegtype:$Vn),
4616   asm, "\t$Zd, $Pg/m, $Vn",
4617   "",
4618   []>, Sched<[]> {
4619   bits<3> Pg;
4620   bits<5> Vn;
4621   bits<5> Zd;
4622   let Inst{31-24} = 0b00000101;
4623   let Inst{23-22} = sz8_64;
4624   let Inst{21-13} = 0b100000100;
4625   let Inst{12-10} = Pg;
4626   let Inst{9-5}   = Vn;
4627   let Inst{4-0}   = Zd;
4629   let Constraints = "$Zd = $_Zd";
4630   let DestructiveInstType = Destructive;
4631   let ElementSize = zprty.ElementSize;
4634 multiclass sve_int_perm_cpy_v<string asm> {
4635   def _B : sve_int_perm_cpy_v<0b00, asm, ZPR8, FPR8>;
4636   def _H : sve_int_perm_cpy_v<0b01, asm, ZPR16, FPR16>;
4637   def _S : sve_int_perm_cpy_v<0b10, asm, ZPR32, FPR32>;
4638   def _D : sve_int_perm_cpy_v<0b11, asm, ZPR64, FPR64>;
4640   def : InstAlias<"mov $Zd, $Pg/m, $Vn",
4641                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, FPR8:$Vn), 1>;
4642   def : InstAlias<"mov $Zd, $Pg/m, $Vn",
4643                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, FPR16:$Vn), 1>;
4644   def : InstAlias<"mov $Zd, $Pg/m, $Vn",
4645                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, FPR32:$Vn), 1>;
4646   def : InstAlias<"mov $Zd, $Pg/m, $Vn",
4647                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, FPR64:$Vn), 1>;
4650 class sve_int_perm_compact<bit sz, string asm, ZPRRegOp zprty>
4651 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
4652   asm, "\t$Zd, $Pg, $Zn",
4653   "",
4654   []>, Sched<[]> {
4655   bits<3> Pg;
4656   bits<5> Zd;
4657   bits<5> Zn;
4658   let Inst{31-23} = 0b000001011;
4659   let Inst{22}    = sz;
4660   let Inst{21-13} = 0b100001100;
4661   let Inst{12-10} = Pg;
4662   let Inst{9-5}   = Zn;
4663   let Inst{4-0}   = Zd;
4666 multiclass sve_int_perm_compact<string asm> {
4667   def _S : sve_int_perm_compact<0b0, asm, ZPR32>;
4668   def _D : sve_int_perm_compact<0b1, asm, ZPR64>;
4672 //===----------------------------------------------------------------------===//
4673 // SVE Memory - Contiguous Load Group
4674 //===----------------------------------------------------------------------===//
4676 class sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
4677                           RegisterOperand VecList>
4678 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
4679   asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4680   "",
4681   []>, Sched<[]> {
4682   bits<3> Pg;
4683   bits<5> Rn;
4684   bits<5> Zt;
4685   bits<4> imm4;
4686   let Inst{31-25} = 0b1010010;
4687   let Inst{24-21} = dtype;
4688   let Inst{20}    = nf;
4689   let Inst{19-16} = imm4;
4690   let Inst{15-13} = 0b101;
4691   let Inst{12-10} = Pg;
4692   let Inst{9-5}   = Rn;
4693   let Inst{4-0}   = Zt;
4695   let mayLoad = 1;
4696   let Uses = !if(!eq(nf, 1), [FFR], []);
4697   let Defs = !if(!eq(nf, 1), [FFR], []);
4700 multiclass sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
4701                                RegisterOperand listty, ZPRRegOp zprty> {
4702   def _REAL : sve_mem_cld_si_base<dtype, nf, asm, listty>;
4704   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4705                   (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
4706   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4707                   (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
4708   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4709                   (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4712 multiclass sve_mem_cld_si<bits<4> dtype, string asm, RegisterOperand listty,
4713                           ZPRRegOp zprty>
4714 : sve_mem_cld_si_base<dtype, 0, asm, listty, zprty>;
4716 class sve_mem_cldnt_si_base<bits<2> msz, string asm, RegisterOperand VecList>
4717 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
4718   asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4719   "",
4720   []>, Sched<[]> {
4721   bits<5> Zt;
4722   bits<3> Pg;
4723   bits<5> Rn;
4724   bits<4> imm4;
4725   let Inst{31-25} = 0b1010010;
4726   let Inst{24-23} = msz;
4727   let Inst{22-20} = 0b000;
4728   let Inst{19-16} = imm4;
4729   let Inst{15-13} = 0b111;
4730   let Inst{12-10} = Pg;
4731   let Inst{9-5}   = Rn;
4732   let Inst{4-0}   = Zt;
4734   let mayLoad = 1;
4737 multiclass sve_mem_cldnt_si<bits<2> msz, string asm, RegisterOperand listty,
4738                             ZPRRegOp zprty> {
4739   def NAME : sve_mem_cldnt_si_base<msz, asm, listty>;
4741   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4742                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
4743   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4744                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
4745   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4746                   (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4749 class sve_mem_cldnt_ss_base<bits<2> msz, string asm, RegisterOperand VecList,
4750                             RegisterOperand gprty>
4751 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4752   asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
4753   "",
4754   []>, Sched<[]> {
4755   bits<3> Pg;
4756   bits<5> Rm;
4757   bits<5> Rn;
4758   bits<5> Zt;
4759   let Inst{31-25} = 0b1010010;
4760   let Inst{24-23} = msz;
4761   let Inst{22-21} = 0b00;
4762   let Inst{20-16} = Rm;
4763   let Inst{15-13} = 0b110;
4764   let Inst{12-10} = Pg;
4765   let Inst{9-5}   = Rn;
4766   let Inst{4-0}   = Zt;
4768   let mayLoad = 1;
4771 multiclass sve_mem_cldnt_ss<bits<2> msz, string asm, RegisterOperand listty,
4772                             ZPRRegOp zprty, RegisterOperand gprty> {
4773   def NAME : sve_mem_cldnt_ss_base<msz, asm, listty, gprty>;
4775   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
4776                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4779 class sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand VecList>
4780 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4),
4781   asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> {
4782   bits<5> Zt;
4783   bits<5> Rn;
4784   bits<3> Pg;
4785   bits<4> imm4;
4786   let Inst{31-25} = 0b1010010;
4787   let Inst{24-23} = sz;
4788   let Inst{22-20} = 0;
4789   let Inst{19-16} = imm4;
4790   let Inst{15-13} = 0b001;
4791   let Inst{12-10} = Pg;
4792   let Inst{9-5}   = Rn;
4793   let Inst{4-0}   = Zt;
4795   let mayLoad = 1;
4798 multiclass sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand listty,
4799                            ZPRRegOp zprty> {
4800   def NAME : sve_mem_ldqr_si<sz, asm, listty>;
4801   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4802                   (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4803   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4804                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
4805   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]",
4806                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4), 0>;
4809 class sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand VecList,
4810                       RegisterOperand gprty>
4811 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4812   asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> {
4813   bits<5> Zt;
4814   bits<3> Pg;
4815   bits<5> Rn;
4816   bits<5> Rm;
4817   let Inst{31-25} = 0b1010010;
4818   let Inst{24-23} = sz;
4819   let Inst{22-21} = 0;
4820   let Inst{20-16} = Rm;
4821   let Inst{15-13} = 0;
4822   let Inst{12-10} = Pg;
4823   let Inst{9-5}   = Rn;
4824   let Inst{4-0}   = Zt;
4826   let mayLoad = 1;
4829 multiclass sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand listty,
4830                            ZPRRegOp zprty, RegisterOperand gprty> {
4831   def NAME : sve_mem_ldqr_ss<sz, asm, listty, gprty>;
4833   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
4834                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4837 class sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
4838                      RegisterOperand VecList, Operand immtype>
4839 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6),
4840   asm, "\t$Zt, $Pg/z, [$Rn, $imm6]",
4841   "",
4842   []>, Sched<[]> {
4843   bits<3> Pg;
4844   bits<5> Rn;
4845   bits<5> Zt;
4846   bits<6> imm6;
4847   let Inst{31-25} = 0b1000010;
4848   let Inst{24-23} = dtypeh;
4849   let Inst{22}    = 1;
4850   let Inst{21-16} = imm6;
4851   let Inst{15}    = 0b1;
4852   let Inst{14-13} = dtypel;
4853   let Inst{12-10} = Pg;
4854   let Inst{9-5}   = Rn;
4855   let Inst{4-0}   = Zt;
4857   let mayLoad = 1;
4860 multiclass sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
4861                           RegisterOperand zlistty, ZPRRegOp zprty, Operand immtype> {
4862   def NAME : sve_mem_ld_dup<dtypeh, dtypel, asm, zlistty, immtype>;
4864   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4865                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
4866   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm6]",
4867                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6), 0>;
4868   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4869                   (!cast<Instruction>(NAME) zlistty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4872 class sve_mem_cld_ss_base<bits<4> dtype, bit ff, dag iops, string asm,
4873                           RegisterOperand VecList>
4874 : I<(outs VecList:$Zt), iops,
4875   asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
4876   "",
4877   []>, Sched<[]> {
4878   bits<5> Zt;
4879   bits<3> Pg;
4880   bits<5> Rm;
4881   bits<5> Rn;
4882   let Inst{31-25} = 0b1010010;
4883   let Inst{24-21} = dtype;
4884   let Inst{20-16} = Rm;
4885   let Inst{15-14} = 0b01;
4886   let Inst{13}    = ff;
4887   let Inst{12-10} = Pg;
4888   let Inst{9-5}   = Rn;
4889   let Inst{4-0}   = Zt;
4891   let mayLoad = 1;
4892   let Uses = !if(!eq(ff, 1), [FFR], []);
4893   let Defs = !if(!eq(ff, 1), [FFR], []);
4896 multiclass sve_mem_cld_ss<bits<4> dtype, string asm, RegisterOperand listty,
4897                           ZPRRegOp zprty, RegisterOperand gprty> {
4898   def "" : sve_mem_cld_ss_base<dtype, 0, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4899                                asm, listty>;
4901   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
4902                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4905 multiclass sve_mem_cldff_ss<bits<4> dtype, string asm, RegisterOperand listty,
4906                             ZPRRegOp zprty, RegisterOperand gprty> {
4907   def _REAL : sve_mem_cld_ss_base<dtype, 1, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4908                                   asm, listty>;
4910   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
4911                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4913   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4914                  (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 1>;
4916   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4917                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 0>;
4920 multiclass sve_mem_cldnf_si<bits<4> dtype, string asm, RegisterOperand listty,
4921                             ZPRRegOp zprty>
4922 : sve_mem_cld_si_base<dtype, 1, asm, listty, zprty>;
4924 class sve_mem_eld_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
4925                      string asm, Operand immtype>
4926 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
4927   asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4928   "",
4929   []>, Sched<[]> {
4930   bits<5> Zt;
4931   bits<3> Pg;
4932   bits<5> Rn;
4933   bits<4> imm4;
4934   let Inst{31-25} = 0b1010010;
4935   let Inst{24-23} = sz;
4936   let Inst{22-21} = nregs;
4937   let Inst{20}    = 0;
4938   let Inst{19-16} = imm4;
4939   let Inst{15-13} = 0b111;
4940   let Inst{12-10} = Pg;
4941   let Inst{9-5}   = Rn;
4942   let Inst{4-0}   = Zt;
4944   let mayLoad = 1;
4947 multiclass sve_mem_eld_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
4948                           string asm, Operand immtype> {
4949   def NAME : sve_mem_eld_si<sz, nregs, VecList, asm, immtype>;
4951   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4952                   (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4955 class sve_mem_eld_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
4956                      string asm, RegisterOperand gprty>
4957 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4958   asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
4959   "",
4960   []>, Sched<[]> {
4961   bits<3> Pg;
4962   bits<5> Rm;
4963   bits<5> Rn;
4964   bits<5> Zt;
4965   let Inst{31-25} = 0b1010010;
4966   let Inst{24-23} = sz;
4967   let Inst{22-21} = nregs;
4968   let Inst{20-16} = Rm;
4969   let Inst{15-13} = 0b110;
4970   let Inst{12-10} = Pg;
4971   let Inst{9-5}   = Rn;
4972   let Inst{4-0}   = Zt;
4974   let mayLoad = 1;
4977 //===----------------------------------------------------------------------===//
4978 // SVE Memory - 32-bit Gather and Unsized Contiguous Group
4979 //===----------------------------------------------------------------------===//
4981 // bit xs      is '1' if offsets are signed
4982 // bit scaled  is '1' if the offsets are scaled
4983 class sve_mem_32b_gld_sv<bits<4> opc, bit xs, bit scaled, string asm,
4984                          RegisterOperand zprext>
4985 : I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
4986   asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
4987   "",
4988   []>, Sched<[]> {
4989   bits<3> Pg;
4990   bits<5> Rn;
4991   bits<5> Zm;
4992   bits<5> Zt;
4993   let Inst{31-25} = 0b1000010;
4994   let Inst{24-23} = opc{3-2};
4995   let Inst{22}    = xs;
4996   let Inst{21}    = scaled;
4997   let Inst{20-16} = Zm;
4998   let Inst{15}    = 0b0;
4999   let Inst{14-13} = opc{1-0};
5000   let Inst{12-10} = Pg;
5001   let Inst{9-5}   = Rn;
5002   let Inst{4-0}   = Zt;
5004   let mayLoad = 1;
5005   let Defs = !if(!eq(opc{0}, 1), [FFR], []);
5006   let Uses = !if(!eq(opc{0}, 1), [FFR], []);
5009 multiclass sve_mem_32b_gld_sv_32_scaled<bits<4> opc, string asm,
5010                                         RegisterOperand sxtw_opnd,
5011                                         RegisterOperand uxtw_opnd> {
5012   def _UXTW_SCALED_REAL : sve_mem_32b_gld_sv<opc, 0, 1, asm, uxtw_opnd>;
5013   def _SXTW_SCALED_REAL : sve_mem_32b_gld_sv<opc, 1, 1, asm, sxtw_opnd>;
5015   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5016                   (!cast<Instruction>(NAME # _UXTW_SCALED_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
5017   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5018                   (!cast<Instruction>(NAME # _SXTW_SCALED_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
5021 multiclass sve_mem_32b_gld_vs_32_unscaled<bits<4> opc, string asm,
5022                                           RegisterOperand sxtw_opnd,
5023                                           RegisterOperand uxtw_opnd> {
5024   def _UXTW_REAL : sve_mem_32b_gld_sv<opc, 0, 0, asm, uxtw_opnd>;
5025   def _SXTW_REAL : sve_mem_32b_gld_sv<opc, 1, 0, asm, sxtw_opnd>;
5027   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5028                   (!cast<Instruction>(NAME # _UXTW_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
5029   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5030                   (!cast<Instruction>(NAME # _SXTW_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
5034 class sve_mem_32b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
5035 : I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
5036   asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
5037   "",
5038   []>, Sched<[]> {
5039   bits<3> Pg;
5040   bits<5> Zn;
5041   bits<5> Zt;
5042   bits<5> imm5;
5043   let Inst{31-25} = 0b1000010;
5044   let Inst{24-23} = opc{3-2};
5045   let Inst{22-21} = 0b01;
5046   let Inst{20-16} = imm5;
5047   let Inst{15}    = 0b1;
5048   let Inst{14-13} = opc{1-0};
5049   let Inst{12-10} = Pg;
5050   let Inst{9-5}   = Zn;
5051   let Inst{4-0}   = Zt;
5053   let mayLoad = 1;
5054   let Defs = !if(!eq(opc{0}, 1), [FFR], []);
5055   let Uses = !if(!eq(opc{0}, 1), [FFR], []);
5058 multiclass sve_mem_32b_gld_vi_32_ptrs<bits<4> opc, string asm, Operand imm_ty> {
5059   def _IMM_REAL : sve_mem_32b_gld_vi<opc, asm, imm_ty>;
5061   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5062                   (!cast<Instruction>(NAME # _IMM_REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>;
5063   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
5064                   (!cast<Instruction>(NAME # _IMM_REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>;
5065   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5066                   (!cast<Instruction>(NAME # _IMM_REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
5069 class sve_mem_prfm_si<bits<2> msz, string asm>
5070 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, simm6s1:$imm6),
5071   asm, "\t$prfop, $Pg, [$Rn, $imm6, mul vl]",
5072   "",
5073   []>, Sched<[]> {
5074   bits<5> Rn;
5075   bits<3> Pg;
5076   bits<6> imm6;
5077   bits<4> prfop;
5078   let Inst{31-22} = 0b1000010111;
5079   let Inst{21-16} = imm6;
5080   let Inst{15}    = 0b0;
5081   let Inst{14-13} = msz;
5082   let Inst{12-10} = Pg;
5083   let Inst{9-5}   = Rn;
5084   let Inst{4}     = 0b0;
5085   let Inst{3-0}   = prfop;
5087   let hasSideEffects = 1;
5090 multiclass sve_mem_prfm_si<bits<2> msz, string asm> {
5091   def NAME : sve_mem_prfm_si<msz, asm>;
5093   def : InstAlias<asm # "\t$prfop, $Pg, [$Rn]",
5094                   (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
5097 class sve_mem_prfm_ss<bits<3> opc, string asm, RegisterOperand gprty>
5098 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
5099   asm, "\t$prfop, $Pg, [$Rn, $Rm]",
5100   "",
5101   []>, Sched<[]> {
5102   bits<5> Rm;
5103   bits<5> Rn;
5104   bits<3> Pg;
5105   bits<4> prfop;
5106   let Inst{31-25} = 0b1000010;
5107   let Inst{24-23} = opc{2-1};
5108   let Inst{22-21} = 0b00;
5109   let Inst{20-16} = Rm;
5110   let Inst{15}    = 0b1;
5111   let Inst{14}    = opc{0};
5112   let Inst{13}    = 0b0;
5113   let Inst{12-10} = Pg;
5114   let Inst{9-5}   = Rn;
5115   let Inst{4}     = 0b0;
5116   let Inst{3-0}   = prfop;
5118   let hasSideEffects = 1;
5121 class sve_mem_32b_prfm_sv<bits<2> msz, bit xs, string asm,
5122                           RegisterOperand zprext>
5123 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
5124   asm, "\t$prfop, $Pg, [$Rn, $Zm]",
5125   "",
5126   []>, Sched<[]> {
5127   bits<3> Pg;
5128   bits<5> Rn;
5129   bits<5> Zm;
5130   bits<4> prfop;
5131   let Inst{31-23} = 0b100001000;
5132   let Inst{22}    = xs;
5133   let Inst{21}    = 0b1;
5134   let Inst{20-16} = Zm;
5135   let Inst{15}    = 0b0;
5136   let Inst{14-13} = msz;
5137   let Inst{12-10} = Pg;
5138   let Inst{9-5}   = Rn;
5139   let Inst{4}     = 0b0;
5140   let Inst{3-0}   = prfop;
5142   let hasSideEffects = 1;
5145 multiclass sve_mem_32b_prfm_sv_scaled<bits<2> msz, string asm,
5146                                       RegisterOperand sxtw_opnd,
5147                                       RegisterOperand uxtw_opnd> {
5148   def _UXTW_SCALED : sve_mem_32b_prfm_sv<msz, 0, asm, uxtw_opnd>;
5149   def _SXTW_SCALED : sve_mem_32b_prfm_sv<msz, 1, asm, sxtw_opnd>;
5152 class sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
5153 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
5154   asm, "\t$prfop, $Pg, [$Zn, $imm5]",
5155   "",
5156   []>, Sched<[]> {
5157   bits<3> Pg;
5158   bits<5> Zn;
5159   bits<5> imm5;
5160   bits<4> prfop;
5161   let Inst{31-25} = 0b1000010;
5162   let Inst{24-23} = msz;
5163   let Inst{22-21} = 0b00;
5164   let Inst{20-16} = imm5;
5165   let Inst{15-13} = 0b111;
5166   let Inst{12-10} = Pg;
5167   let Inst{9-5}   = Zn;
5168   let Inst{4}     = 0b0;
5169   let Inst{3-0}   = prfop;
5172 multiclass sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty> {
5173   def NAME : sve_mem_32b_prfm_vi<msz, asm, imm_ty>;
5175   def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
5176                   (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
5179 class sve_mem_z_fill<string asm>
5180 : I<(outs ZPRAny:$Zt), (ins GPR64sp:$Rn, simm9:$imm9),
5181   asm, "\t$Zt, [$Rn, $imm9, mul vl]",
5182   "",
5183   []>, Sched<[]> {
5184   bits<5> Rn;
5185   bits<5> Zt;
5186   bits<9> imm9;
5187   let Inst{31-22} = 0b1000010110;
5188   let Inst{21-16} = imm9{8-3};
5189   let Inst{15-13} = 0b010;
5190   let Inst{12-10} = imm9{2-0};
5191   let Inst{9-5}   = Rn;
5192   let Inst{4-0}   = Zt;
5194   let mayLoad = 1;
5197 multiclass sve_mem_z_fill<string asm> {
5198   def NAME : sve_mem_z_fill<asm>;
5200   def : InstAlias<asm # "\t$Zt, [$Rn]",
5201                   (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
5204 class sve_mem_p_fill<string asm>
5205 : I<(outs PPRAny:$Pt), (ins GPR64sp:$Rn, simm9:$imm9),
5206   asm, "\t$Pt, [$Rn, $imm9, mul vl]",
5207   "",
5208   []>, Sched<[]> {
5209   bits<4> Pt;
5210   bits<5> Rn;
5211   bits<9> imm9;
5212   let Inst{31-22} = 0b1000010110;
5213   let Inst{21-16} = imm9{8-3};
5214   let Inst{15-13} = 0b000;
5215   let Inst{12-10} = imm9{2-0};
5216   let Inst{9-5}   = Rn;
5217   let Inst{4}     = 0b0;
5218   let Inst{3-0}   = Pt;
5220   let mayLoad = 1;
5223 multiclass sve_mem_p_fill<string asm> {
5224   def NAME : sve_mem_p_fill<asm>;
5226   def : InstAlias<asm # "\t$Pt, [$Rn]",
5227                   (!cast<Instruction>(NAME) PPRAny:$Pt, GPR64sp:$Rn, 0), 1>;
5230 class sve2_mem_gldnt_vs_base<bits<5> opc, dag iops, string asm,
5231                              RegisterOperand VecList>
5232 : I<(outs VecList:$Zt), iops,
5233   asm, "\t$Zt, $Pg/z, [$Zn, $Rm]",
5234   "",
5235   []>, Sched<[]> {
5236   bits<3> Pg;
5237   bits<5> Rm;
5238   bits<5> Zn;
5239   bits<5> Zt;
5240   let Inst{31}    = 0b1;
5241   let Inst{30}    = opc{4};
5242   let Inst{29-25} = 0b00010;
5243   let Inst{24-23} = opc{3-2};
5244   let Inst{22-21} = 0b00;
5245   let Inst{20-16} = Rm;
5246   let Inst{15}    = 0b1;
5247   let Inst{14-13} = opc{1-0};
5248   let Inst{12-10} = Pg;
5249   let Inst{9-5}   = Zn;
5250   let Inst{4-0}   = Zt;
5252   let mayLoad = 1;
5255 multiclass sve2_mem_gldnt_vs<bits<5> opc, string asm,
5256                              RegisterOperand listty, ZPRRegOp zprty> {
5257   def _REAL : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm),
5258                                      asm, listty>;
5260   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]",
5261                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm), 0>;
5262   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5263                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, XZR), 0>;
5264   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5265                  (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, XZR), 1>;
5268 //===----------------------------------------------------------------------===//
5269 // SVE Memory - 64-bit Gather Group
5270 //===----------------------------------------------------------------------===//
5272 // bit xs      is '1' if offsets are signed
5273 // bit scaled  is '1' if the offsets are scaled
5274 // bit lsl     is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
5275 class sve_mem_64b_gld_sv<bits<4> opc, bit xs, bit scaled, bit lsl, string asm,
5276                          RegisterOperand zprext>
5277 : I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
5278   asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
5279   "",
5280   []>, Sched<[]> {
5281   bits<3> Pg;
5282   bits<5> Rn;
5283   bits<5> Zm;
5284   bits<5> Zt;
5285   let Inst{31-25} = 0b1100010;
5286   let Inst{24-23} = opc{3-2};
5287   let Inst{22}    = xs;
5288   let Inst{21}    = scaled;
5289   let Inst{20-16} = Zm;
5290   let Inst{15}    = lsl;
5291   let Inst{14-13} = opc{1-0};
5292   let Inst{12-10} = Pg;
5293   let Inst{9-5}   = Rn;
5294   let Inst{4-0}   = Zt;
5296   let mayLoad = 1;
5297   let Defs = !if(!eq(opc{0}, 1), [FFR], []);
5298   let Uses = !if(!eq(opc{0}, 1), [FFR], []);
5301 multiclass sve_mem_64b_gld_sv_32_scaled<bits<4> opc, string asm,
5302                                         RegisterOperand sxtw_opnd,
5303                                         RegisterOperand uxtw_opnd> {
5304   def _UXTW_SCALED_REAL : sve_mem_64b_gld_sv<opc, 0, 1, 0, asm, uxtw_opnd>;
5305   def _SXTW_SCALED_REAL : sve_mem_64b_gld_sv<opc, 1, 1, 0, asm, sxtw_opnd>;
5307   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5308                   (!cast<Instruction>(NAME # _UXTW_SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
5309   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5310                   (!cast<Instruction>(NAME # _SXTW_SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
5313 multiclass sve_mem_64b_gld_vs_32_unscaled<bits<4> opc, string asm,
5314                                           RegisterOperand sxtw_opnd,
5315                                           RegisterOperand uxtw_opnd> {
5316   def _UXTW_REAL : sve_mem_64b_gld_sv<opc, 0, 0, 0, asm, uxtw_opnd>;
5317   def _SXTW_REAL : sve_mem_64b_gld_sv<opc, 1, 0, 0, asm, sxtw_opnd>;
5319   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5320                   (!cast<Instruction>(NAME # _UXTW_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
5321   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5322                   (!cast<Instruction>(NAME # _SXTW_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
5325 multiclass sve_mem_64b_gld_sv2_64_scaled<bits<4> opc, string asm,
5326                                          RegisterOperand zprext> {
5327   def _SCALED_REAL : sve_mem_64b_gld_sv<opc, 1, 1, 1, asm, zprext>;
5329   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5330                   (!cast<Instruction>(NAME # _SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
5333 multiclass sve_mem_64b_gld_vs2_64_unscaled<bits<4> opc, string asm> {
5334   def _REAL : sve_mem_64b_gld_sv<opc, 1, 0, 1, asm, ZPR64ExtLSL8>;
5336   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5337                   (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
5340 class sve_mem_64b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
5341 : I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
5342   asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
5343   "",
5344   []>, Sched<[]> {
5345   bits<3> Pg;
5346   bits<5> Zn;
5347   bits<5> Zt;
5348   bits<5> imm5;
5349   let Inst{31-25} = 0b1100010;
5350   let Inst{24-23} = opc{3-2};
5351   let Inst{22-21} = 0b01;
5352   let Inst{20-16} = imm5;
5353   let Inst{15}    = 0b1;
5354   let Inst{14-13} = opc{1-0};
5355   let Inst{12-10} = Pg;
5356   let Inst{9-5}   = Zn;
5357   let Inst{4-0}   = Zt;
5359   let mayLoad = 1;
5360   let Defs = !if(!eq(opc{0}, 1), [FFR], []);
5361   let Uses = !if(!eq(opc{0}, 1), [FFR], []);
5364 multiclass sve_mem_64b_gld_vi_64_ptrs<bits<4> opc, string asm, Operand imm_ty> {
5365   def _IMM_REAL : sve_mem_64b_gld_vi<opc, asm, imm_ty>;
5367   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5368                   (!cast<Instruction>(NAME # _IMM_REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>;
5369   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
5370                  (!cast<Instruction>(NAME # _IMM_REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>;
5371   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5372                   (!cast<Instruction>(NAME # _IMM_REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
5375 // bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
5376 class sve_mem_64b_prfm_sv<bits<2> msz, bit xs, bit lsl, string asm,
5377                           RegisterOperand zprext>
5378 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
5379   asm, "\t$prfop, $Pg, [$Rn, $Zm]",
5380   "",
5381   []>, Sched<[]> {
5382   bits<3> Pg;
5383   bits<5> Rn;
5384   bits<5> Zm;
5385   bits<4> prfop;
5386   let Inst{31-23} = 0b110001000;
5387   let Inst{22}    = xs;
5388   let Inst{21}    = 0b1;
5389   let Inst{20-16} = Zm;
5390   let Inst{15}    = lsl;
5391   let Inst{14-13} = msz;
5392   let Inst{12-10} = Pg;
5393   let Inst{9-5}   = Rn;
5394   let Inst{4}     = 0b0;
5395   let Inst{3-0}   = prfop;
5397   let hasSideEffects = 1;
5400 multiclass sve_mem_64b_prfm_sv_ext_scaled<bits<2> msz, string asm,
5401                                           RegisterOperand sxtw_opnd,
5402                                           RegisterOperand uxtw_opnd> {
5403   def _UXTW_SCALED : sve_mem_64b_prfm_sv<msz, 0, 0, asm, uxtw_opnd>;
5404   def _SXTW_SCALED : sve_mem_64b_prfm_sv<msz, 1, 0, asm, sxtw_opnd>;
5407 multiclass sve_mem_64b_prfm_sv_lsl_scaled<bits<2> msz, string asm,
5408                                           RegisterOperand zprext> {
5409   def NAME : sve_mem_64b_prfm_sv<msz, 1, 1, asm, zprext>;
5413 class sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
5414 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
5415   asm, "\t$prfop, $Pg, [$Zn, $imm5]",
5416   "",
5417   []>, Sched<[]> {
5418   bits<3> Pg;
5419   bits<5> Zn;
5420   bits<5> imm5;
5421   bits<4> prfop;
5422   let Inst{31-25} = 0b1100010;
5423   let Inst{24-23} = msz;
5424   let Inst{22-21} = 0b00;
5425   let Inst{20-16} = imm5;
5426   let Inst{15-13} = 0b111;
5427   let Inst{12-10} = Pg;
5428   let Inst{9-5}   = Zn;
5429   let Inst{4}     = 0b0;
5430   let Inst{3-0}   = prfop;
5432   let hasSideEffects = 1;
5435 multiclass sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty> {
5436   def NAME : sve_mem_64b_prfm_vi<msz, asm, imm_ty>;
5438   def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
5439                   (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
5443 //===----------------------------------------------------------------------===//
5444 // SVE Compute Vector Address Group
5445 //===----------------------------------------------------------------------===//
5447 class sve_int_bin_cons_misc_0_a<bits<2> opc, bits<2> msz, string asm,
5448                                 ZPRRegOp zprty, RegisterOperand zprext>
5449 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprext:$Zm),
5450   asm, "\t$Zd, [$Zn, $Zm]",
5451   "",
5452   []>, Sched<[]> {
5453   bits<5> Zd;
5454   bits<5> Zn;
5455   bits<5> Zm;
5456   let Inst{31-24} = 0b00000100;
5457   let Inst{23-22} = opc;
5458   let Inst{21}    = 0b1;
5459   let Inst{20-16} = Zm;
5460   let Inst{15-12} = 0b1010;
5461   let Inst{11-10} = msz;
5462   let Inst{9-5}   = Zn;
5463   let Inst{4-0}   = Zd;
5466 multiclass sve_int_bin_cons_misc_0_a_uxtw<bits<2> opc, string asm> {
5467   def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtUXTW8>;
5468   def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtUXTW16>;
5469   def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtUXTW32>;
5470   def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtUXTW64>;
5473 multiclass sve_int_bin_cons_misc_0_a_sxtw<bits<2> opc, string asm> {
5474   def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtSXTW8>;
5475   def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtSXTW16>;
5476   def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtSXTW32>;
5477   def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtSXTW64>;
5480 multiclass sve_int_bin_cons_misc_0_a_32_lsl<bits<2> opc, string asm> {
5481   def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR32, ZPR32ExtLSL8>;
5482   def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR32, ZPR32ExtLSL16>;
5483   def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR32, ZPR32ExtLSL32>;
5484   def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR32, ZPR32ExtLSL64>;
5487 multiclass sve_int_bin_cons_misc_0_a_64_lsl<bits<2> opc, string asm> {
5488   def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtLSL8>;
5489   def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtLSL16>;
5490   def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtLSL32>;
5491   def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtLSL64>;
5495 //===----------------------------------------------------------------------===//
5496 // SVE Integer Misc - Unpredicated Group
5497 //===----------------------------------------------------------------------===//
5499 class sve_int_bin_cons_misc_0_b<bits<2> sz, string asm, ZPRRegOp zprty>
5500 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
5501   asm, "\t$Zd, $Zn, $Zm",
5502   "",
5503   []>, Sched<[]> {
5504   bits<5> Zd;
5505   bits<5> Zm;
5506   bits<5> Zn;
5507   let Inst{31-24} = 0b00000100;
5508   let Inst{23-22} = sz;
5509   let Inst{21}    = 0b1;
5510   let Inst{20-16} = Zm;
5511   let Inst{15-10} = 0b101100;
5512   let Inst{9-5}   = Zn;
5513   let Inst{4-0}   = Zd;
5516 multiclass sve_int_bin_cons_misc_0_b<string asm> {
5517   def _H : sve_int_bin_cons_misc_0_b<0b01, asm, ZPR16>;
5518   def _S : sve_int_bin_cons_misc_0_b<0b10, asm, ZPR32>;
5519   def _D : sve_int_bin_cons_misc_0_b<0b11, asm, ZPR64>;
5522 class sve_int_bin_cons_misc_0_c<bits<8> opc, string asm, ZPRRegOp zprty>
5523 : I<(outs zprty:$Zd), (ins zprty:$Zn),
5524   asm, "\t$Zd, $Zn",
5525   "",
5526   []>, Sched<[]> {
5527   bits<5> Zd;
5528   bits<5> Zn;
5529   let Inst{31-24} = 0b00000100;
5530   let Inst{23-22} = opc{7-6};
5531   let Inst{21}    = 0b1;
5532   let Inst{20-16} = opc{5-1};
5533   let Inst{15-11} = 0b10111;
5534   let Inst{10}    = opc{0};
5535   let Inst{9-5}   = Zn;
5536   let Inst{4-0}   = Zd;
5539 //===----------------------------------------------------------------------===//
5540 // SVE Integer Reduction Group
5541 //===----------------------------------------------------------------------===//
5543 class sve_int_reduce<bits<2> sz8_32, bits<2> fmt, bits<3> opc, string asm,
5544                      ZPRRegOp zprty, RegisterClass regtype>
5545 : I<(outs regtype:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
5546   asm, "\t$Vd, $Pg, $Zn",
5547   "",
5548   []>, Sched<[]> {
5549   bits<3> Pg;
5550   bits<5> Vd;
5551   bits<5> Zn;
5552   let Inst{31-24} = 0b00000100;
5553   let Inst{23-22} = sz8_32;
5554   let Inst{21}    = 0b0;
5555   let Inst{20-19} = fmt;
5556   let Inst{18-16} = opc;
5557   let Inst{15-13} = 0b001;
5558   let Inst{12-10} = Pg;
5559   let Inst{9-5}   = Zn;
5560   let Inst{4-0}   = Vd;
5563 multiclass sve_int_reduce_0_saddv<bits<3> opc, string asm> {
5564   def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64>;
5565   def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64>;
5566   def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64>;
5569 multiclass sve_int_reduce_0_uaddv<bits<3> opc, string asm> {
5570   def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64>;
5571   def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64>;
5572   def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64>;
5573   def _D : sve_int_reduce<0b11, 0b00, opc, asm, ZPR64, FPR64>;
5576 multiclass sve_int_reduce_1<bits<3> opc, string asm> {
5577   def _B : sve_int_reduce<0b00, 0b01, opc, asm, ZPR8, FPR8>;
5578   def _H : sve_int_reduce<0b01, 0b01, opc, asm, ZPR16, FPR16>;
5579   def _S : sve_int_reduce<0b10, 0b01, opc, asm, ZPR32, FPR32>;
5580   def _D : sve_int_reduce<0b11, 0b01, opc, asm, ZPR64, FPR64>;
5583 multiclass sve_int_reduce_2<bits<3> opc, string asm> {
5584   def _B : sve_int_reduce<0b00, 0b11, opc, asm, ZPR8, FPR8>;
5585   def _H : sve_int_reduce<0b01, 0b11, opc, asm, ZPR16, FPR16>;
5586   def _S : sve_int_reduce<0b10, 0b11, opc, asm, ZPR32, FPR32>;
5587   def _D : sve_int_reduce<0b11, 0b11, opc, asm, ZPR64, FPR64>;
5590 class sve_int_movprfx_pred<bits<2> sz8_32, bits<3> opc, string asm,
5591                            ZPRRegOp zprty, string pg_suffix, dag iops>
5592 : I<(outs zprty:$Zd), iops,
5593   asm, "\t$Zd, $Pg"#pg_suffix#", $Zn",
5594   "",
5595   []>, Sched<[]> {
5596   bits<3> Pg;
5597   bits<5> Zd;
5598   bits<5> Zn;
5599   let Inst{31-24} = 0b00000100;
5600   let Inst{23-22} = sz8_32;
5601   let Inst{21-19} = 0b010;
5602   let Inst{18-16} = opc;
5603   let Inst{15-13} = 0b001;
5604   let Inst{12-10} = Pg;
5605   let Inst{9-5}   = Zn;
5606   let Inst{4-0}   = Zd;
5608   let ElementSize = zprty.ElementSize;
5611 multiclass sve_int_movprfx_pred_merge<bits<3> opc, string asm> {
5612 let Constraints = "$Zd = $_Zd" in {
5613   def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/m",
5614                                 (ins ZPR8:$_Zd, PPR3bAny:$Pg, ZPR8:$Zn)>;
5615   def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/m",
5616                                 (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR16:$Zn)>;
5617   def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/m",
5618                                 (ins ZPR32:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn)>;
5619   def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/m",
5620                                 (ins ZPR64:$_Zd, PPR3bAny:$Pg, ZPR64:$Zn)>;
5624 multiclass sve_int_movprfx_pred_zero<bits<3> opc, string asm> {
5625   def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/z",
5626                                 (ins PPR3bAny:$Pg, ZPR8:$Zn)>;
5627   def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/z",
5628                                 (ins PPR3bAny:$Pg, ZPR16:$Zn)>;
5629   def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/z",
5630                                 (ins PPR3bAny:$Pg, ZPR32:$Zn)>;
5631   def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/z",
5632                                 (ins PPR3bAny:$Pg, ZPR64:$Zn)>;
5635 //===----------------------------------------------------------------------===//
5636 // SVE Propagate Break Group
5637 //===----------------------------------------------------------------------===//
5639 class sve_int_brkp<bits<2> opc, string asm>
5640 : I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm),
5641   asm, "\t$Pd, $Pg/z, $Pn, $Pm",
5642   "",
5643   []>, Sched<[]> {
5644   bits<4> Pd;
5645   bits<4> Pg;
5646   bits<4> Pm;
5647   bits<4> Pn;
5648   let Inst{31-24} = 0b00100101;
5649   let Inst{23}    = 0b0;
5650   let Inst{22}    = opc{1};
5651   let Inst{21-20} = 0b00;
5652   let Inst{19-16} = Pm;
5653   let Inst{15-14} = 0b11;
5654   let Inst{13-10} = Pg;
5655   let Inst{9}     = 0b0;
5656   let Inst{8-5}   = Pn;
5657   let Inst{4}     = opc{0};
5658   let Inst{3-0}   = Pd;
5660   let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
5664 //===----------------------------------------------------------------------===//
5665 // SVE Partition Break Group
5666 //===----------------------------------------------------------------------===//
5668 class sve_int_brkn<bit S, string asm>
5669 : I<(outs PPR8:$Pdm), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$_Pdm),
5670   asm, "\t$Pdm, $Pg/z, $Pn, $_Pdm",
5671   "",
5672   []>, Sched<[]> {
5673   bits<4> Pdm;
5674   bits<4> Pg;
5675   bits<4> Pn;
5676   let Inst{31-23} = 0b001001010;
5677   let Inst{22}    = S;
5678   let Inst{21-14} = 0b01100001;
5679   let Inst{13-10} = Pg;
5680   let Inst{9}     = 0b0;
5681   let Inst{8-5}   = Pn;
5682   let Inst{4}     = 0b0;
5683   let Inst{3-0}   = Pdm;
5685   let Constraints = "$Pdm = $_Pdm";
5686   let Defs = !if(!eq (S, 0b1), [NZCV], []);
5689 class sve_int_break<bits<3> opc, string asm, string suffix, dag iops>
5690 : I<(outs PPR8:$Pd), iops,
5691   asm, "\t$Pd, $Pg"#suffix#", $Pn",
5692   "",
5693   []>, Sched<[]> {
5694   bits<4> Pd;
5695   bits<4> Pg;
5696   bits<4> Pn;
5697   let Inst{31-24} = 0b00100101;
5698   let Inst{23-22} = opc{2-1};
5699   let Inst{21-14} = 0b01000001;
5700   let Inst{13-10} = Pg;
5701   let Inst{9}     = 0b0;
5702   let Inst{8-5}   = Pn;
5703   let Inst{4}     = opc{0};
5704   let Inst{3-0}   = Pd;
5706   let Constraints = !if(!eq (opc{0}, 1), "$Pd = $_Pd", "");
5707   let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
5711 multiclass sve_int_break_m<bits<3> opc, string asm> {
5712   def NAME : sve_int_break<opc, asm, "/m", (ins PPR8:$_Pd, PPRAny:$Pg, PPR8:$Pn)>;
5715 multiclass sve_int_break_z<bits<3> opc, string asm> {
5716   def NAME : sve_int_break<opc, asm, "/z", (ins PPRAny:$Pg, PPR8:$Pn)>;
5719 //===----------------------------------------------------------------------===//
5720 // SVE2 String Processing Group
5721 //===----------------------------------------------------------------------===//
5723 class sve2_char_match<bit sz, bit opc, string asm,
5724                       PPRRegOp pprty, ZPRRegOp zprty>
5725 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
5726   asm, "\t$Pd, $Pg/z, $Zn, $Zm",
5727   "",
5728   []>, Sched<[]> {
5729   bits<4> Pd;
5730   bits<3> Pg;
5731   bits<5> Zm;
5732   bits<5> Zn;
5733   let Inst{31-23} = 0b010001010;
5734   let Inst{22}    = sz;
5735   let Inst{21}    = 0b1;
5736   let Inst{20-16} = Zm;
5737   let Inst{15-13} = 0b100;
5738   let Inst{12-10} = Pg;
5739   let Inst{9-5}   = Zn;
5740   let Inst{4}     = opc;
5741   let Inst{3-0}   = Pd;
5743   let Defs = [NZCV];
5746 multiclass sve2_char_match<bit opc, string asm> {
5747   def _B : sve2_char_match<0b0, opc, asm, PPR8, ZPR8>;
5748   def _H : sve2_char_match<0b1, opc, asm, PPR16, ZPR16>;
5751 //===----------------------------------------------------------------------===//
5752 // SVE2 Histogram Computation - Segment Group
5753 //===----------------------------------------------------------------------===//
5755 class sve2_hist_gen_segment<string asm>
5756 : I<(outs ZPR8:$Zd), (ins ZPR8:$Zn, ZPR8:$Zm),
5757   asm, "\t$Zd, $Zn, $Zm",
5758   "",
5759   []>, Sched<[]> {
5760   bits<5> Zd;
5761   bits<5> Zn;
5762   bits<5> Zm;
5763   let Inst{31-21} = 0b01000101001;
5764   let Inst{20-16} = Zm;
5765   let Inst{15-10} = 0b101000;
5766   let Inst{9-5}   = Zn;
5767   let Inst{4-0}   = Zd;
5770 //===----------------------------------------------------------------------===//
5771 // SVE2 Histogram Computation - Vector Group
5772 //===----------------------------------------------------------------------===//
5774 class sve2_hist_gen_vector<bit sz, string asm, ZPRRegOp zprty>
5775 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
5776   asm, "\t$Zd, $Pg/z, $Zn, $Zm",
5777   "",
5778   []>, Sched<[]> {
5779   bits<5> Zd;
5780   bits<5> Zn;
5781   bits<3> Pg;
5782   bits<5> Zm;
5783   let Inst{31-23} = 0b010001011;
5784   let Inst{22}    = sz;
5785   let Inst{21}    = 0b1;
5786   let Inst{20-16} = Zm;
5787   let Inst{15-13} = 0b110;
5788   let Inst{12-10} = Pg;
5789   let Inst{9-5}   = Zn;
5790   let Inst{4-0}   = Zd;
5793 multiclass sve2_hist_gen_vector<string asm> {
5794   def _S : sve2_hist_gen_vector<0b0, asm, ZPR32>;
5795   def _D : sve2_hist_gen_vector<0b1, asm, ZPR64>;
5798 //===----------------------------------------------------------------------===//
5799 // SVE2 Crypto Extensions Group
5800 //===----------------------------------------------------------------------===//
5802 class sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty>
5803 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
5804   asm, "\t$Zd, $Zn, $Zm",
5805   "",
5806   []>, Sched<[]> {
5807   bits<5> Zd;
5808   bits<5> Zn;
5809   bits<5> Zm;
5810   let Inst{31-21} = 0b01000101001;
5811   let Inst{20-16} = Zm;
5812   let Inst{15-11} = 0b11110;
5813   let Inst{10}    = opc;
5814   let Inst{9-5}   = Zn;
5815   let Inst{4-0}   = Zd;
5818 class sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty>
5819 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm),
5820   asm, "\t$Zdn, $_Zdn, $Zm",
5821   "",
5822   []>, Sched<[]> {
5823   bits<5> Zdn;
5824   bits<5> Zm;
5825   let Inst{31-17} = 0b010001010010001;
5826   let Inst{16}    = opc{1};
5827   let Inst{15-11} = 0b11100;
5828   let Inst{10}    = opc{0};
5829   let Inst{9-5}   = Zm;
5830   let Inst{4-0}   = Zdn;
5832   let Constraints = "$Zdn = $_Zdn";
5835 class sve2_crypto_unary_op<bit opc, string asm>
5836 : I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn),
5837   asm, "\t$Zdn, $_Zdn",
5838   "",
5839   []>, Sched<[]> {
5840   bits<5> Zdn;
5841   let Inst{31-11} = 0b010001010010000011100;
5842   let Inst{10}    = opc;
5843   let Inst{9-5}   = 0b00000;
5844   let Inst{4-0}   = Zdn;
5846   let Constraints = "$Zdn = $_Zdn";