[obj2yaml] - Fix BB after r373315.
[llvm-complete.git] / lib / Target / AArch64 / SVEInstrFormats.td
blobf57e111b7e1336a1e57380fc0442f978b4022a2f
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_1_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
287                    Instruction inst>
288 : Pat<(vtd (op vt1:$Op1)),
289       (inst $Op1)>;
291 class SVE_3_Op_Pat<ValueType vtd, SDPatternOperator op, ValueType vt1,
292                    ValueType vt2, ValueType vt3, Instruction inst>
293 : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3)),
294       (inst $Op1, $Op2, $Op3)>;
296 //===----------------------------------------------------------------------===//
297 // SVE Predicate Misc Group
298 //===----------------------------------------------------------------------===//
300 class sve_int_pfalse<bits<6> opc, string asm>
301 : I<(outs PPR8:$Pd), (ins),
302   asm, "\t$Pd",
303   "",
304   []>, Sched<[]> {
305   bits<4> Pd;
306   let Inst{31-24} = 0b00100101;
307   let Inst{23-22} = opc{5-4};
308   let Inst{21-19} = 0b011;
309   let Inst{18-16} = opc{3-1};
310   let Inst{15-10} = 0b111001;
311   let Inst{9}     = opc{0};
312   let Inst{8-4}   = 0b00000;
313   let Inst{3-0}   = Pd;
316 class sve_int_ptest<bits<6> opc, string asm>
317 : I<(outs), (ins PPRAny:$Pg, PPR8:$Pn),
318   asm, "\t$Pg, $Pn",
319   "",
320   []>, Sched<[]> {
321   bits<4> Pg;
322   bits<4> Pn;
323   let Inst{31-24} = 0b00100101;
324   let Inst{23-22} = opc{5-4};
325   let Inst{21-19} = 0b010;
326   let Inst{18-16} = opc{3-1};
327   let Inst{15-14} = 0b11;
328   let Inst{13-10} = Pg;
329   let Inst{9}     = opc{0};
330   let Inst{8-5}   = Pn;
331   let Inst{4-0}   = 0b00000;
333   let Defs = [NZCV];
336 class sve_int_pfirst_next<bits<2> sz8_64, bits<5> opc, string asm,
337                           PPRRegOp pprty>
338 : I<(outs pprty:$Pdn), (ins PPRAny:$Pg, pprty:$_Pdn),
339   asm, "\t$Pdn, $Pg, $_Pdn",
340   "",
341   []>, Sched<[]> {
342   bits<4> Pdn;
343   bits<4> Pg;
344   let Inst{31-24} = 0b00100101;
345   let Inst{23-22} = sz8_64;
346   let Inst{21-19} = 0b011;
347   let Inst{18-16} = opc{4-2};
348   let Inst{15-11} = 0b11000;
349   let Inst{10-9}  = opc{1-0};
350   let Inst{8-5}   = Pg;
351   let Inst{4}     = 0;
352   let Inst{3-0}   = Pdn;
354   let Constraints = "$Pdn = $_Pdn";
355   let Defs = [NZCV];
358 multiclass sve_int_pfirst<bits<5> opc, string asm> {
359   def : sve_int_pfirst_next<0b01, opc, asm, PPR8>;
362 multiclass sve_int_pnext<bits<5> opc, string asm> {
363   def _B : sve_int_pfirst_next<0b00, opc, asm, PPR8>;
364   def _H : sve_int_pfirst_next<0b01, opc, asm, PPR16>;
365   def _S : sve_int_pfirst_next<0b10, opc, asm, PPR32>;
366   def _D : sve_int_pfirst_next<0b11, opc, asm, PPR64>;
369 //===----------------------------------------------------------------------===//
370 // SVE Predicate Count Group
371 //===----------------------------------------------------------------------===//
373 class sve_int_count_r<bits<2> sz8_64, bits<5> opc, string asm,
374                       RegisterOperand dty, PPRRegOp pprty, RegisterOperand sty>
375 : I<(outs dty:$Rdn), (ins pprty:$Pg, sty:$_Rdn),
376   asm, "\t$Rdn, $Pg",
377   "",
378   []>, Sched<[]> {
379   bits<5> Rdn;
380   bits<4> Pg;
381   let Inst{31-24} = 0b00100101;
382   let Inst{23-22} = sz8_64;
383   let Inst{21-19} = 0b101;
384   let Inst{18-16} = opc{4-2};
385   let Inst{15-11} = 0b10001;
386   let Inst{10-9}  = opc{1-0};
387   let Inst{8-5}   = Pg;
388   let Inst{4-0}   = Rdn;
390   // Signed 32bit forms require their GPR operand printed.
391   let AsmString = !if(!eq(opc{4,2-0}, 0b0000),
392                       !strconcat(asm, "\t$Rdn, $Pg, $_Rdn"),
393                       !strconcat(asm, "\t$Rdn, $Pg"));
394   let Constraints = "$Rdn = $_Rdn";
397 multiclass sve_int_count_r_s32<bits<5> opc, string asm> {
398   def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64as32>;
399   def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64as32>;
400   def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64as32>;
401   def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64as32>;
404 multiclass sve_int_count_r_u32<bits<5> opc, string asm> {
405   def _B : sve_int_count_r<0b00, opc, asm, GPR32z, PPR8, GPR32z>;
406   def _H : sve_int_count_r<0b01, opc, asm, GPR32z, PPR16, GPR32z>;
407   def _S : sve_int_count_r<0b10, opc, asm, GPR32z, PPR32, GPR32z>;
408   def _D : sve_int_count_r<0b11, opc, asm, GPR32z, PPR64, GPR32z>;
411 multiclass sve_int_count_r_x64<bits<5> opc, string asm> {
412   def _B : sve_int_count_r<0b00, opc, asm, GPR64z, PPR8, GPR64z>;
413   def _H : sve_int_count_r<0b01, opc, asm, GPR64z, PPR16, GPR64z>;
414   def _S : sve_int_count_r<0b10, opc, asm, GPR64z, PPR32, GPR64z>;
415   def _D : sve_int_count_r<0b11, opc, asm, GPR64z, PPR64, GPR64z>;
418 class sve_int_count_v<bits<2> sz8_64, bits<5> opc, string asm,
419                       ZPRRegOp zprty, PPRRegOp pprty>
420 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, pprty:$Pm),
421   asm, "\t$Zdn, $Pm",
422   "",
423   []>, Sched<[]> {
424   bits<4> Pm;
425   bits<5> Zdn;
426   let Inst{31-24} = 0b00100101;
427   let Inst{23-22} = sz8_64;
428   let Inst{21-19} = 0b101;
429   let Inst{18-16} = opc{4-2};
430   let Inst{15-11} = 0b10000;
431   let Inst{10-9}  = opc{1-0};
432   let Inst{8-5}   = Pm;
433   let Inst{4-0}   = Zdn;
435   let Constraints = "$Zdn = $_Zdn";
436   let DestructiveInstType = Destructive;
437   let ElementSize = ElementSizeNone;
440 multiclass sve_int_count_v<bits<5> opc, string asm> {
441   def _H : sve_int_count_v<0b01, opc, asm, ZPR16, PPR16>;
442   def _S : sve_int_count_v<0b10, opc, asm, ZPR32, PPR32>;
443   def _D : sve_int_count_v<0b11, opc, asm, ZPR64, PPR64>;
445   def : InstAlias<asm # "\t$Zdn, $Pm",
446                  (!cast<Instruction>(NAME # "_H") ZPR16:$Zdn, PPRAny:$Pm), 0>;
447   def : InstAlias<asm # "\t$Zdn, $Pm",
448                  (!cast<Instruction>(NAME # "_S") ZPR32:$Zdn, PPRAny:$Pm), 0>;
449   def : InstAlias<asm # "\t$Zdn, $Pm",
450                   (!cast<Instruction>(NAME # "_D") ZPR64:$Zdn, PPRAny:$Pm), 0>;
453 class sve_int_pcount_pred<bits<2> sz8_64, bits<4> opc, string asm,
454                           PPRRegOp pprty>
455 : I<(outs GPR64:$Rd), (ins PPRAny:$Pg, pprty:$Pn),
456   asm, "\t$Rd, $Pg, $Pn",
457   "",
458   []>, Sched<[]> {
459   bits<4> Pg;
460   bits<4> Pn;
461   bits<5> Rd;
462   let Inst{31-24} = 0b00100101;
463   let Inst{23-22} = sz8_64;
464   let Inst{21-19} = 0b100;
465   let Inst{18-16} = opc{3-1};
466   let Inst{15-14} = 0b10;
467   let Inst{13-10} = Pg;
468   let Inst{9}     = opc{0};
469   let Inst{8-5}   = Pn;
470   let Inst{4-0}   = Rd;
473 multiclass sve_int_pcount_pred<bits<4> opc, string asm> {
474   def _B : sve_int_pcount_pred<0b00, opc, asm, PPR8>;
475   def _H : sve_int_pcount_pred<0b01, opc, asm, PPR16>;
476   def _S : sve_int_pcount_pred<0b10, opc, asm, PPR32>;
477   def _D : sve_int_pcount_pred<0b11, opc, asm, PPR64>;
480 //===----------------------------------------------------------------------===//
481 // SVE Element Count Group
482 //===----------------------------------------------------------------------===//
484 class sve_int_count<bits<3> opc, string asm>
485 : I<(outs GPR64:$Rd), (ins sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
486   asm, "\t$Rd, $pattern, mul $imm4",
487   "",
488   []>, Sched<[]> {
489   bits<5> Rd;
490   bits<4> imm4;
491   bits<5> pattern;
492   let Inst{31-24} = 0b00000100;
493   let Inst{23-22} = opc{2-1};
494   let Inst{21-20} = 0b10;
495   let Inst{19-16} = imm4;
496   let Inst{15-11} = 0b11100;
497   let Inst{10}    = opc{0};
498   let Inst{9-5}   = pattern;
499   let Inst{4-0}   = Rd;
502 multiclass sve_int_count<bits<3> opc, string asm> {
503   def NAME : sve_int_count<opc, asm>;
505   def : InstAlias<asm # "\t$Rd, $pattern",
506                   (!cast<Instruction>(NAME) GPR64:$Rd, sve_pred_enum:$pattern, 1), 1>;
507   def : InstAlias<asm # "\t$Rd",
508                   (!cast<Instruction>(NAME) GPR64:$Rd, 0b11111, 1), 2>;
511 class sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty>
512 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
513   asm, "\t$Zdn, $pattern, mul $imm4",
514   "",
515   []>, Sched<[]> {
516   bits<5> Zdn;
517   bits<5> pattern;
518   bits<4> imm4;
519   let Inst{31-24} = 0b00000100;
520   let Inst{23-22} = opc{4-3};
521   let Inst{21}    = 0b1;
522   let Inst{20}    = opc{2};
523   let Inst{19-16} = imm4;
524   let Inst{15-12} = 0b1100;
525   let Inst{11-10} = opc{1-0};
526   let Inst{9-5}   = pattern;
527   let Inst{4-0}   = Zdn;
529   let Constraints = "$Zdn = $_Zdn";
530   let DestructiveInstType = Destructive;
531   let ElementSize = ElementSizeNone;
534 multiclass sve_int_countvlv<bits<5> opc, string asm, ZPRRegOp zprty> {
535   def NAME : sve_int_countvlv<opc, asm, zprty>;
537   def : InstAlias<asm # "\t$Zdn, $pattern",
538                   (!cast<Instruction>(NAME) zprty:$Zdn, sve_pred_enum:$pattern, 1), 1>;
539   def : InstAlias<asm # "\t$Zdn",
540                   (!cast<Instruction>(NAME) zprty:$Zdn, 0b11111, 1), 2>;
543 class sve_int_pred_pattern_a<bits<3> opc, string asm>
544 : I<(outs GPR64:$Rdn), (ins GPR64:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
545   asm, "\t$Rdn, $pattern, mul $imm4",
546   "",
547   []>, Sched<[]> {
548   bits<5> Rdn;
549   bits<5> pattern;
550   bits<4> imm4;
551   let Inst{31-24} = 0b00000100;
552   let Inst{23-22} = opc{2-1};
553   let Inst{21-20} = 0b11;
554   let Inst{19-16} = imm4;
555   let Inst{15-11} = 0b11100;
556   let Inst{10}    = opc{0};
557   let Inst{9-5}   = pattern;
558   let Inst{4-0}   = Rdn;
560   let Constraints = "$Rdn = $_Rdn";
563 multiclass sve_int_pred_pattern_a<bits<3> opc, string asm> {
564   def NAME : sve_int_pred_pattern_a<opc, asm>;
566   def : InstAlias<asm # "\t$Rdn, $pattern",
567                   (!cast<Instruction>(NAME) GPR64:$Rdn, sve_pred_enum:$pattern, 1), 1>;
568   def : InstAlias<asm # "\t$Rdn",
569                   (!cast<Instruction>(NAME) GPR64:$Rdn, 0b11111, 1), 2>;
572 class sve_int_pred_pattern_b<bits<5> opc, string asm, RegisterOperand dt,
573                              RegisterOperand st>
574 : I<(outs dt:$Rdn), (ins st:$_Rdn, sve_pred_enum:$pattern, sve_incdec_imm:$imm4),
575   asm, "\t$Rdn, $pattern, mul $imm4",
576   "",
577   []>, Sched<[]> {
578   bits<5> Rdn;
579   bits<5> pattern;
580   bits<4> imm4;
581   let Inst{31-24} = 0b00000100;
582   let Inst{23-22} = opc{4-3};
583   let Inst{21}    = 0b1;
584   let Inst{20}    = opc{2};
585   let Inst{19-16} = imm4;
586   let Inst{15-12} = 0b1111;
587   let Inst{11-10} = opc{1-0};
588   let Inst{9-5}   = pattern;
589   let Inst{4-0}   = Rdn;
591   // Signed 32bit forms require their GPR operand printed.
592   let AsmString = !if(!eq(opc{2,0}, 0b00),
593                       !strconcat(asm, "\t$Rdn, $_Rdn, $pattern, mul $imm4"),
594                       !strconcat(asm, "\t$Rdn, $pattern, mul $imm4"));
596   let Constraints = "$Rdn = $_Rdn";
599 multiclass sve_int_pred_pattern_b_s32<bits<5> opc, string asm> {
600   def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64as32>;
602   def : InstAlias<asm # "\t$Rd, $Rn, $pattern",
603                   (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, sve_pred_enum:$pattern, 1), 1>;
604   def : InstAlias<asm # "\t$Rd, $Rn",
605                   (!cast<Instruction>(NAME) GPR64z:$Rd, GPR64as32:$Rn, 0b11111, 1), 2>;
608 multiclass sve_int_pred_pattern_b_u32<bits<5> opc, string asm> {
609   def NAME : sve_int_pred_pattern_b<opc, asm, GPR32z, GPR32z>;
611   def : InstAlias<asm # "\t$Rdn, $pattern",
612                   (!cast<Instruction>(NAME) GPR32z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
613   def : InstAlias<asm # "\t$Rdn",
614                   (!cast<Instruction>(NAME) GPR32z:$Rdn, 0b11111, 1), 2>;
617 multiclass sve_int_pred_pattern_b_x64<bits<5> opc, string asm> {
618   def NAME : sve_int_pred_pattern_b<opc, asm, GPR64z, GPR64z>;
620   def : InstAlias<asm # "\t$Rdn, $pattern",
621                   (!cast<Instruction>(NAME) GPR64z:$Rdn, sve_pred_enum:$pattern, 1), 1>;
622   def : InstAlias<asm # "\t$Rdn",
623                   (!cast<Instruction>(NAME) GPR64z:$Rdn, 0b11111, 1), 2>;
627 //===----------------------------------------------------------------------===//
628 // SVE Permute - Cross Lane Group
629 //===----------------------------------------------------------------------===//
631 class sve_int_perm_dup_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
632                          RegisterClass srcRegType>
633 : I<(outs zprty:$Zd), (ins srcRegType:$Rn),
634   asm, "\t$Zd, $Rn",
635   "",
636   []>, Sched<[]> {
637   bits<5> Rn;
638   bits<5> Zd;
639   let Inst{31-24} = 0b00000101;
640   let Inst{23-22} = sz8_64;
641   let Inst{21-10} = 0b100000001110;
642   let Inst{9-5}   = Rn;
643   let Inst{4-0}   = Zd;
646 multiclass sve_int_perm_dup_r<string asm> {
647   def _B : sve_int_perm_dup_r<0b00, asm, ZPR8, GPR32sp>;
648   def _H : sve_int_perm_dup_r<0b01, asm, ZPR16, GPR32sp>;
649   def _S : sve_int_perm_dup_r<0b10, asm, ZPR32, GPR32sp>;
650   def _D : sve_int_perm_dup_r<0b11, asm, ZPR64, GPR64sp>;
652   def : InstAlias<"mov $Zd, $Rn",
653                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, GPR32sp:$Rn), 1>;
654   def : InstAlias<"mov $Zd, $Rn",
655                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, GPR32sp:$Rn), 1>;
656   def : InstAlias<"mov $Zd, $Rn",
657                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, GPR32sp:$Rn), 1>;
658   def : InstAlias<"mov $Zd, $Rn",
659                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, GPR64sp:$Rn), 1>;
662 class sve_int_perm_dup_i<bits<5> tsz, Operand immtype, string asm,
663                          ZPRRegOp zprty>
664 : I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$idx),
665   asm, "\t$Zd, $Zn$idx",
666   "",
667   []>, Sched<[]> {
668   bits<5> Zd;
669   bits<5> Zn;
670   bits<7> idx;
671   let Inst{31-24} = 0b00000101;
672   let Inst{23-22} = {?,?}; // imm3h
673   let Inst{21}    = 0b1;
674   let Inst{20-16} = tsz;
675   let Inst{15-10} = 0b001000;
676   let Inst{9-5}   = Zn;
677   let Inst{4-0}   = Zd;
680 multiclass sve_int_perm_dup_i<string asm> {
681   def _B : sve_int_perm_dup_i<{?,?,?,?,1}, sve_elm_idx_extdup_b, asm, ZPR8> {
682     let Inst{23-22} = idx{5-4};
683     let Inst{20-17} = idx{3-0};
684   }
685   def _H : sve_int_perm_dup_i<{?,?,?,1,0}, sve_elm_idx_extdup_h, asm, ZPR16> {
686     let Inst{23-22} = idx{4-3};
687     let Inst{20-18} = idx{2-0};
688   }
689   def _S : sve_int_perm_dup_i<{?,?,1,0,0}, sve_elm_idx_extdup_s, asm, ZPR32> {
690     let Inst{23-22} = idx{3-2};
691     let Inst{20-19}    = idx{1-0};
692   }
693   def _D : sve_int_perm_dup_i<{?,1,0,0,0}, sve_elm_idx_extdup_d, asm, ZPR64> {
694     let Inst{23-22} = idx{2-1};
695     let Inst{20}    = idx{0};
696   }
697   def _Q : sve_int_perm_dup_i<{1,0,0,0,0}, sve_elm_idx_extdup_q, asm, ZPR128> {
698     let Inst{23-22} = idx{1-0};
699   }
701   def : InstAlias<"mov $Zd, $Zn$idx",
702                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, sve_elm_idx_extdup_b:$idx), 1>;
703   def : InstAlias<"mov $Zd, $Zn$idx",
704                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, sve_elm_idx_extdup_h:$idx), 1>;
705   def : InstAlias<"mov $Zd, $Zn$idx",
706                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, sve_elm_idx_extdup_s:$idx), 1>;
707   def : InstAlias<"mov $Zd, $Zn$idx",
708                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, sve_elm_idx_extdup_d:$idx), 1>;
709   def : InstAlias<"mov $Zd, $Zn$idx",
710                   (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, ZPR128:$Zn, sve_elm_idx_extdup_q:$idx), 1>;
711   def : InstAlias<"mov $Zd, $Bn",
712                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, FPR8asZPR:$Bn, 0), 2>;
713   def : InstAlias<"mov $Zd, $Hn",
714                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, FPR16asZPR:$Hn, 0), 2>;
715   def : InstAlias<"mov $Zd, $Sn",
716                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, FPR32asZPR:$Sn, 0), 2>;
717   def : InstAlias<"mov $Zd, $Dn",
718                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, FPR64asZPR:$Dn, 0), 2>;
719   def : InstAlias<"mov $Zd, $Qn",
720                   (!cast<Instruction>(NAME # _Q) ZPR128:$Zd, FPR128asZPR:$Qn, 0), 2>;
723 class sve_int_perm_tbl<bits<2> sz8_64, bits<2> opc, string asm,
724                        ZPRRegOp zprty, RegisterOperand VecList>
725 : I<(outs zprty:$Zd), (ins VecList:$Zn, zprty:$Zm),
726   asm, "\t$Zd, $Zn, $Zm",
727   "",
728   []>, Sched<[]> {
729   bits<5> Zd;
730   bits<5> Zm;
731   bits<5> Zn;
732   let Inst{31-24} = 0b00000101;
733   let Inst{23-22} = sz8_64;
734   let Inst{21}    = 0b1;
735   let Inst{20-16} = Zm;
736   let Inst{15-13} = 0b001;
737   let Inst{12-11} = opc;
738   let Inst{10}    = 0b0;
739   let Inst{9-5}   = Zn;
740   let Inst{4-0}   = Zd;
743 multiclass sve_int_perm_tbl<string asm> {
744   def _B : sve_int_perm_tbl<0b00, 0b10, asm, ZPR8,  Z_b>;
745   def _H : sve_int_perm_tbl<0b01, 0b10, asm, ZPR16, Z_h>;
746   def _S : sve_int_perm_tbl<0b10, 0b10, asm, ZPR32, Z_s>;
747   def _D : sve_int_perm_tbl<0b11, 0b10, asm, ZPR64, Z_d>;
749   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
750                  (!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 0>;
751   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
752                  (!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 0>;
753   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
754                  (!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 0>;
755   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
756                  (!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, ZPR64:$Zm), 0>;
759 multiclass sve2_int_perm_tbl<string asm> {
760   def _B : sve_int_perm_tbl<0b00, 0b01, asm, ZPR8,  ZZ_b>;
761   def _H : sve_int_perm_tbl<0b01, 0b01, asm, ZPR16, ZZ_h>;
762   def _S : sve_int_perm_tbl<0b10, 0b01, asm, ZPR32, ZZ_s>;
763   def _D : sve_int_perm_tbl<0b11, 0b01, asm, ZPR64, ZZ_d>;
766 class sve2_int_perm_tbx<bits<2> sz8_64, string asm, ZPRRegOp zprty>
767 : I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, zprty:$Zm),
768   asm, "\t$Zd, $Zn, $Zm",
769   "",
770   []>, Sched<[]> {
771   bits<5> Zd;
772   bits<5> Zm;
773   bits<5> Zn;
774   let Inst{31-24} = 0b00000101;
775   let Inst{23-22} = sz8_64;
776   let Inst{21}    = 0b1;
777   let Inst{20-16} = Zm;
778   let Inst{15-10} = 0b001011;
779   let Inst{9-5}   = Zn;
780   let Inst{4-0}   = Zd;
782   let Constraints = "$Zd = $_Zd";
785 multiclass sve2_int_perm_tbx<string asm> {
786   def _B : sve2_int_perm_tbx<0b00, asm, ZPR8>;
787   def _H : sve2_int_perm_tbx<0b01, asm, ZPR16>;
788   def _S : sve2_int_perm_tbx<0b10, asm, ZPR32>;
789   def _D : sve2_int_perm_tbx<0b11, asm, ZPR64>;
792 class sve_int_perm_reverse_z<bits<2> sz8_64, string asm, ZPRRegOp zprty>
793 : I<(outs zprty:$Zd), (ins zprty:$Zn),
794   asm, "\t$Zd, $Zn",
795   "",
796   []>, Sched<[]> {
797   bits<5> Zd;
798   bits<5> Zn;
799   let Inst{31-24} = 0b00000101;
800   let Inst{23-22} = sz8_64;
801   let Inst{21-10} = 0b111000001110;
802   let Inst{9-5}   = Zn;
803   let Inst{4-0}   = Zd;
806 multiclass sve_int_perm_reverse_z<string asm> {
807   def _B : sve_int_perm_reverse_z<0b00, asm, ZPR8>;
808   def _H : sve_int_perm_reverse_z<0b01, asm, ZPR16>;
809   def _S : sve_int_perm_reverse_z<0b10, asm, ZPR32>;
810   def _D : sve_int_perm_reverse_z<0b11, asm, ZPR64>;
813 class sve_int_perm_reverse_p<bits<2> sz8_64, string asm, PPRRegOp pprty>
814 : I<(outs pprty:$Pd), (ins pprty:$Pn),
815   asm, "\t$Pd, $Pn",
816   "",
817   []>, Sched<[]> {
818   bits<4> Pd;
819   bits<4> Pn;
820   let Inst{31-24} = 0b00000101;
821   let Inst{23-22} = sz8_64;
822   let Inst{21-9}  = 0b1101000100000;
823   let Inst{8-5}   = Pn;
824   let Inst{4}     = 0b0;
825   let Inst{3-0}   = Pd;
828 multiclass sve_int_perm_reverse_p<string asm> {
829   def _B : sve_int_perm_reverse_p<0b00, asm, PPR8>;
830   def _H : sve_int_perm_reverse_p<0b01, asm, PPR16>;
831   def _S : sve_int_perm_reverse_p<0b10, asm, PPR32>;
832   def _D : sve_int_perm_reverse_p<0b11, asm, PPR64>;
835 class sve_int_perm_unpk<bits<2> sz16_64, bits<2> opc, string asm,
836                         ZPRRegOp zprty1, ZPRRegOp zprty2>
837 : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
838   asm, "\t$Zd, $Zn",
839   "", []>, Sched<[]> {
840   bits<5> Zd;
841   bits<5> Zn;
842   let Inst{31-24} = 0b00000101;
843   let Inst{23-22} = sz16_64;
844   let Inst{21-18} = 0b1100;
845   let Inst{17-16} = opc;
846   let Inst{15-10} = 0b001110;
847   let Inst{9-5}   = Zn;
848   let Inst{4-0}   = Zd;
851 multiclass sve_int_perm_unpk<bits<2> opc, string asm> {
852   def _H : sve_int_perm_unpk<0b01, opc, asm, ZPR16, ZPR8>;
853   def _S : sve_int_perm_unpk<0b10, opc, asm, ZPR32, ZPR16>;
854   def _D : sve_int_perm_unpk<0b11, opc, asm, ZPR64, ZPR32>;
857 class sve_int_perm_insrs<bits<2> sz8_64, string asm, ZPRRegOp zprty,
858                          RegisterClass srcRegType>
859 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcRegType:$Rm),
860   asm, "\t$Zdn, $Rm",
861   "",
862   []>, Sched<[]> {
863   bits<5> Rm;
864   bits<5> Zdn;
865   let Inst{31-24} = 0b00000101;
866   let Inst{23-22} = sz8_64;
867   let Inst{21-10} = 0b100100001110;
868   let Inst{9-5}   = Rm;
869   let Inst{4-0}   = Zdn;
871   let Constraints = "$Zdn = $_Zdn";
872   let DestructiveInstType = Destructive;
873   let ElementSize = ElementSizeNone;
876 multiclass sve_int_perm_insrs<string asm> {
877   def _B : sve_int_perm_insrs<0b00, asm, ZPR8, GPR32>;
878   def _H : sve_int_perm_insrs<0b01, asm, ZPR16, GPR32>;
879   def _S : sve_int_perm_insrs<0b10, asm, ZPR32, GPR32>;
880   def _D : sve_int_perm_insrs<0b11, asm, ZPR64, GPR64>;
883 class sve_int_perm_insrv<bits<2> sz8_64, string asm, ZPRRegOp zprty,
884                          RegisterClass srcRegType>
885 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, srcRegType:$Vm),
886   asm, "\t$Zdn, $Vm",
887   "",
888   []>, Sched<[]> {
889   bits<5> Vm;
890   bits<5> Zdn;
891   let Inst{31-24} = 0b00000101;
892   let Inst{23-22} = sz8_64;
893   let Inst{21-10} = 0b110100001110;
894   let Inst{9-5}   = Vm;
895   let Inst{4-0}   = Zdn;
897   let Constraints = "$Zdn = $_Zdn";
898   let DestructiveInstType = Destructive;
899   let ElementSize = ElementSizeNone;
902 multiclass sve_int_perm_insrv<string asm> {
903   def _B : sve_int_perm_insrv<0b00, asm, ZPR8, FPR8>;
904   def _H : sve_int_perm_insrv<0b01, asm, ZPR16, FPR16>;
905   def _S : sve_int_perm_insrv<0b10, asm, ZPR32, FPR32>;
906   def _D : sve_int_perm_insrv<0b11, asm, ZPR64, FPR64>;
909 //===----------------------------------------------------------------------===//
910 // SVE Permute - Extract Group
911 //===----------------------------------------------------------------------===//
913 class sve_int_perm_extract_i<string asm>
914 : I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn, ZPR8:$Zm, imm0_255:$imm8),
915   asm, "\t$Zdn, $_Zdn, $Zm, $imm8",
916   "", []>, Sched<[]> {
917   bits<5> Zdn;
918   bits<5> Zm;
919   bits<8> imm8;
920   let Inst{31-21} = 0b00000101001;
921   let Inst{20-16} = imm8{7-3};
922   let Inst{15-13} = 0b000;
923   let Inst{12-10} = imm8{2-0};
924   let Inst{9-5}   = Zm;
925   let Inst{4-0}   = Zdn;
927   let Constraints = "$Zdn = $_Zdn";
928   let DestructiveInstType = Destructive;
929   let ElementSize = ElementSizeNone;
932 class sve2_int_perm_extract_i_cons<string asm>
933 : I<(outs ZPR8:$Zd), (ins ZZ_b:$Zn, imm0_255:$imm8),
934   asm, "\t$Zd, $Zn, $imm8",
935   "", []>, Sched<[]> {
936   bits<5> Zd;
937   bits<5> Zn;
938   bits<8> imm8;
939   let Inst{31-21} = 0b00000101011;
940   let Inst{20-16} = imm8{7-3};
941   let Inst{15-13} = 0b000;
942   let Inst{12-10} = imm8{2-0};
943   let Inst{9-5}   = Zn;
944   let Inst{4-0}   = Zd;
947 //===----------------------------------------------------------------------===//
948 // SVE Vector Select Group
949 //===----------------------------------------------------------------------===//
951 class sve_int_sel_vvv<bits<2> sz8_64, string asm, ZPRRegOp zprty>
952 : I<(outs zprty:$Zd), (ins PPRAny:$Pg, zprty:$Zn, zprty:$Zm),
953   asm, "\t$Zd, $Pg, $Zn, $Zm",
954   "",
955   []>, Sched<[]> {
956   bits<4> Pg;
957   bits<5> Zd;
958   bits<5> Zm;
959   bits<5> Zn;
960   let Inst{31-24} = 0b00000101;
961   let Inst{23-22} = sz8_64;
962   let Inst{21}    = 0b1;
963   let Inst{20-16} = Zm;
964   let Inst{15-14} = 0b11;
965   let Inst{13-10} = Pg;
966   let Inst{9-5}   = Zn;
967   let Inst{4-0}   = Zd;
970 multiclass sve_int_sel_vvv<string asm> {
971   def _B : sve_int_sel_vvv<0b00, asm, ZPR8>;
972   def _H : sve_int_sel_vvv<0b01, asm, ZPR16>;
973   def _S : sve_int_sel_vvv<0b10, asm, ZPR32>;
974   def _D : sve_int_sel_vvv<0b11, asm, ZPR64>;
976   def : InstAlias<"mov $Zd, $Pg/m, $Zn",
977                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPRAny:$Pg, ZPR8:$Zn, ZPR8:$Zd), 1>;
978   def : InstAlias<"mov $Zd, $Pg/m, $Zn",
979                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, ZPR16:$Zn, ZPR16:$Zd), 1>;
980   def : InstAlias<"mov $Zd, $Pg/m, $Zn",
981                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, ZPR32:$Zn, ZPR32:$Zd), 1>;
982   def : InstAlias<"mov $Zd, $Pg/m, $Zn",
983                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, ZPR64:$Zn, ZPR64:$Zd), 1>;
987 //===----------------------------------------------------------------------===//
988 // SVE Predicate Logical Operations Group
989 //===----------------------------------------------------------------------===//
991 class sve_int_pred_log<bits<4> opc, string asm>
992 : I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm),
993   asm, "\t$Pd, $Pg/z, $Pn, $Pm",
994   "",
995   []>, Sched<[]> {
996   bits<4> Pd;
997   bits<4> Pg;
998   bits<4> Pm;
999   bits<4> Pn;
1000   let Inst{31-24} = 0b00100101;
1001   let Inst{23-22} = opc{3-2};
1002   let Inst{21-20} = 0b00;
1003   let Inst{19-16} = Pm;
1004   let Inst{15-14} = 0b01;
1005   let Inst{13-10} = Pg;
1006   let Inst{9}     = opc{1};
1007   let Inst{8-5}   = Pn;
1008   let Inst{4}     = opc{0};
1009   let Inst{3-0}   = Pd;
1011   // SEL has no predication qualifier.
1012   let AsmString = !if(!eq(opc, 0b0011),
1013                       !strconcat(asm, "\t$Pd, $Pg, $Pn, $Pm"),
1014                       !strconcat(asm, "\t$Pd, $Pg/z, $Pn, $Pm"));
1016   let Defs = !if(!eq (opc{2}, 1), [NZCV], []);
1020 //===----------------------------------------------------------------------===//
1021 // SVE Logical Mask Immediate Group
1022 //===----------------------------------------------------------------------===//
1024 class sve_int_log_imm<bits<2> opc, string asm>
1025 : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, logical_imm64:$imms13),
1026   asm, "\t$Zdn, $_Zdn, $imms13",
1027   "", []>, Sched<[]> {
1028   bits<5> Zdn;
1029   bits<13> imms13;
1030   let Inst{31-24} = 0b00000101;
1031   let Inst{23-22} = opc;
1032   let Inst{21-18} = 0b0000;
1033   let Inst{17-5}  = imms13;
1034   let Inst{4-0}   = Zdn;
1036   let Constraints = "$Zdn = $_Zdn";
1037   let DecoderMethod = "DecodeSVELogicalImmInstruction";
1038   let DestructiveInstType = Destructive;
1039   let ElementSize = ElementSizeNone;
1042 multiclass sve_int_log_imm<bits<2> opc, string asm, string alias> {
1043   def NAME : sve_int_log_imm<opc, asm>;
1045   def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
1046                   (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8:$imm), 4>;
1047   def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
1048                   (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16:$imm), 3>;
1049   def : InstAlias<asm # "\t$Zdn, $Zdn, $imm",
1050                   (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32:$imm), 2>;
1052   def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
1053                   (!cast<Instruction>(NAME) ZPR8:$Zdn, sve_logical_imm8_not:$imm), 0>;
1054   def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
1055                   (!cast<Instruction>(NAME) ZPR16:$Zdn, sve_logical_imm16_not:$imm), 0>;
1056   def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
1057                   (!cast<Instruction>(NAME) ZPR32:$Zdn, sve_logical_imm32_not:$imm), 0>;
1058   def : InstAlias<alias # "\t$Zdn, $Zdn, $imm",
1059                   (!cast<Instruction>(NAME) ZPR64:$Zdn, logical_imm64_not:$imm), 0>;
1062 class sve_int_dup_mask_imm<string asm>
1063 : I<(outs ZPR64:$Zd), (ins logical_imm64:$imms),
1064   asm, "\t$Zd, $imms",
1065   "",
1066   []>, Sched<[]> {
1067   bits<5> Zd;
1068   bits<13> imms;
1069   let Inst{31-18} = 0b00000101110000;
1070   let Inst{17-5} = imms;
1071   let Inst{4-0} = Zd;
1073   let isReMaterializable = 1;
1074   let DecoderMethod = "DecodeSVELogicalImmInstruction";
1077 multiclass sve_int_dup_mask_imm<string asm> {
1078   def NAME : sve_int_dup_mask_imm<asm>;
1080   def : InstAlias<"dupm $Zd, $imm",
1081                   (!cast<Instruction>(NAME) ZPR8:$Zd, sve_logical_imm8:$imm), 4>;
1082   def : InstAlias<"dupm $Zd, $imm",
1083                   (!cast<Instruction>(NAME) ZPR16:$Zd, sve_logical_imm16:$imm), 3>;
1084   def : InstAlias<"dupm $Zd, $imm",
1085                   (!cast<Instruction>(NAME) ZPR32:$Zd, sve_logical_imm32:$imm), 2>;
1087   // All Zd.b forms have a CPY/DUP equivalent, hence no byte alias here.
1088   def : InstAlias<"mov $Zd, $imm",
1089                   (!cast<Instruction>(NAME) ZPR16:$Zd, sve_preferred_logical_imm16:$imm), 7>;
1090   def : InstAlias<"mov $Zd, $imm",
1091                   (!cast<Instruction>(NAME) ZPR32:$Zd, sve_preferred_logical_imm32:$imm), 6>;
1092   def : InstAlias<"mov $Zd, $imm",
1093                   (!cast<Instruction>(NAME) ZPR64:$Zd, sve_preferred_logical_imm64:$imm), 5>;
1096 //===----------------------------------------------------------------------===//
1097 // SVE Integer Arithmetic -  Unpredicated Group.
1098 //===----------------------------------------------------------------------===//
1100 class sve_int_bin_cons_arit_0<bits<2> sz8_64, bits<3> opc, string asm,
1101                               ZPRRegOp zprty>
1102 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
1103   asm, "\t$Zd, $Zn, $Zm",
1104   "", []>, Sched<[]> {
1105   bits<5> Zd;
1106   bits<5> Zm;
1107   bits<5> Zn;
1108   let Inst{31-24} = 0b00000100;
1109   let Inst{23-22} = sz8_64;
1110   let Inst{21}    = 0b1;
1111   let Inst{20-16} = Zm;
1112   let Inst{15-13} = 0b000;
1113   let Inst{12-10} = opc;
1114   let Inst{9-5}   = Zn;
1115   let Inst{4-0}   = Zd;
1118 multiclass sve_int_bin_cons_arit_0<bits<3> opc, string asm> {
1119   def _B : sve_int_bin_cons_arit_0<0b00, opc, asm, ZPR8>;
1120   def _H : sve_int_bin_cons_arit_0<0b01, opc, asm, ZPR16>;
1121   def _S : sve_int_bin_cons_arit_0<0b10, opc, asm, ZPR32>;
1122   def _D : sve_int_bin_cons_arit_0<0b11, opc, asm, ZPR64>;
1125 //===----------------------------------------------------------------------===//
1126 // SVE Floating Point Arithmetic - Predicated Group
1127 //===----------------------------------------------------------------------===//
1129 class sve_fp_2op_i_p_zds<bits<2> sz, bits<3> opc, string asm,
1130                          ZPRRegOp zprty,
1131                          Operand imm_ty>
1132 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, imm_ty:$i1),
1133   asm, "\t$Zdn, $Pg/m, $_Zdn, $i1",
1134   "",
1135   []>, Sched<[]> {
1136   bits<3> Pg;
1137   bits<5> Zdn;
1138   bit i1;
1139   let Inst{31-24} = 0b01100101;
1140   let Inst{23-22} = sz;
1141   let Inst{21-19} = 0b011;
1142   let Inst{18-16} = opc;
1143   let Inst{15-13} = 0b100;
1144   let Inst{12-10} = Pg;
1145   let Inst{9-6}   = 0b0000;
1146   let Inst{5}     = i1;
1147   let Inst{4-0}   = Zdn;
1149   let Constraints = "$Zdn = $_Zdn";
1150   let DestructiveInstType = Destructive;
1151   let ElementSize = zprty.ElementSize;
1154 multiclass sve_fp_2op_i_p_zds<bits<3> opc, string asm, Operand imm_ty> {
1155   def _H : sve_fp_2op_i_p_zds<0b01, opc, asm, ZPR16, imm_ty>;
1156   def _S : sve_fp_2op_i_p_zds<0b10, opc, asm, ZPR32, imm_ty>;
1157   def _D : sve_fp_2op_i_p_zds<0b11, opc, asm, ZPR64, imm_ty>;
1160 class sve_fp_2op_p_zds<bits<2> sz, bits<4> opc, string asm,
1161                        ZPRRegOp zprty>
1162 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
1163   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
1164   "",
1165   []>, Sched<[]> {
1166   bits<3> Pg;
1167   bits<5> Zdn;
1168   bits<5> Zm;
1169   let Inst{31-24} = 0b01100101;
1170   let Inst{23-22} = sz;
1171   let Inst{21-20} = 0b00;
1172   let Inst{19-16} = opc;
1173   let Inst{15-13} = 0b100;
1174   let Inst{12-10} = Pg;
1175   let Inst{9-5}   = Zm;
1176   let Inst{4-0}   = Zdn;
1178   let Constraints = "$Zdn = $_Zdn";
1179   let DestructiveInstType = Destructive;
1180   let ElementSize = zprty.ElementSize;
1183 multiclass sve_fp_2op_p_zds<bits<4> opc, string asm> {
1184   def _H : sve_fp_2op_p_zds<0b01, opc, asm, ZPR16>;
1185   def _S : sve_fp_2op_p_zds<0b10, opc, asm, ZPR32>;
1186   def _D : sve_fp_2op_p_zds<0b11, opc, asm, ZPR64>;
1189 class sve_fp_ftmad<bits<2> sz, string asm, ZPRRegOp zprty>
1190 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, imm0_7:$imm3),
1191   asm, "\t$Zdn, $_Zdn, $Zm, $imm3",
1192   "",
1193   []>, Sched<[]> {
1194   bits<5> Zdn;
1195   bits<5> Zm;
1196   bits<3> imm3;
1197   let Inst{31-24} = 0b01100101;
1198   let Inst{23-22} = sz;
1199   let Inst{21-19} = 0b010;
1200   let Inst{18-16} = imm3;
1201   let Inst{15-10} = 0b100000;
1202   let Inst{9-5}   = Zm;
1203   let Inst{4-0}   = Zdn;
1205   let Constraints = "$Zdn = $_Zdn";
1206   let DestructiveInstType = Destructive;
1207   let ElementSize = ElementSizeNone;
1210 multiclass sve_fp_ftmad<string asm> {
1211   def _H : sve_fp_ftmad<0b01, asm, ZPR16>;
1212   def _S : sve_fp_ftmad<0b10, asm, ZPR32>;
1213   def _D : sve_fp_ftmad<0b11, asm, ZPR64>;
1217 //===----------------------------------------------------------------------===//
1218 // SVE Floating Point Arithmetic - Unpredicated Group
1219 //===----------------------------------------------------------------------===//
1221 class sve_fp_3op_u_zd<bits<2> sz, bits<3> opc, string asm,
1222                       ZPRRegOp zprty>
1223 : I<(outs zprty:$Zd), (ins  zprty:$Zn, zprty:$Zm),
1224   asm, "\t$Zd, $Zn, $Zm",
1225   "", []>, Sched<[]> {
1226   bits<5> Zd;
1227   bits<5> Zm;
1228   bits<5> Zn;
1229   let Inst{31-24} = 0b01100101;
1230   let Inst{23-22} = sz;
1231   let Inst{21}    = 0b0;
1232   let Inst{20-16} = Zm;
1233   let Inst{15-13} = 0b000;
1234   let Inst{12-10} = opc;
1235   let Inst{9-5}   = Zn;
1236   let Inst{4-0}   = Zd;
1239 multiclass sve_fp_3op_u_zd<bits<3> opc, string asm> {
1240   def _H : sve_fp_3op_u_zd<0b01, opc, asm, ZPR16>;
1241   def _S : sve_fp_3op_u_zd<0b10, opc, asm, ZPR32>;
1242   def _D : sve_fp_3op_u_zd<0b11, opc, asm, ZPR64>;
1245 //===----------------------------------------------------------------------===//
1246 // SVE Floating Point Fused Multiply-Add Group
1247 //===----------------------------------------------------------------------===//
1249 class sve_fp_3op_p_zds_a<bits<2> sz, bits<2> opc, string asm, ZPRRegOp zprty>
1250 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
1251   asm, "\t$Zda, $Pg/m, $Zn, $Zm",
1252   "",
1253   []>, Sched<[]> {
1254   bits<3> Pg;
1255   bits<5> Zda;
1256   bits<5> Zm;
1257   bits<5> Zn;
1258   let Inst{31-24} = 0b01100101;
1259   let Inst{23-22} = sz;
1260   let Inst{21}    = 0b1;
1261   let Inst{20-16} = Zm;
1262   let Inst{15}    = 0b0;
1263   let Inst{14-13} = opc;
1264   let Inst{12-10} = Pg;
1265   let Inst{9-5}   = Zn;
1266   let Inst{4-0}   = Zda;
1268   let Constraints = "$Zda = $_Zda";
1269   let DestructiveInstType = Destructive;
1270   let ElementSize = zprty.ElementSize;
1273 multiclass sve_fp_3op_p_zds_a<bits<2> opc, string asm> {
1274   def _H : sve_fp_3op_p_zds_a<0b01, opc, asm, ZPR16>;
1275   def _S : sve_fp_3op_p_zds_a<0b10, opc, asm, ZPR32>;
1276   def _D : sve_fp_3op_p_zds_a<0b11, opc, asm, ZPR64>;
1279 class sve_fp_3op_p_zds_b<bits<2> sz, bits<2> opc, string asm,
1280                          ZPRRegOp zprty>
1281 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
1282   asm, "\t$Zdn, $Pg/m, $Zm, $Za",
1283   "",
1284   []>, Sched<[]> {
1285   bits<3> Pg;
1286   bits<5> Za;
1287   bits<5> Zdn;
1288   bits<5> Zm;
1289   let Inst{31-24} = 0b01100101;
1290   let Inst{23-22} = sz;
1291   let Inst{21}    = 0b1;
1292   let Inst{20-16} = Za;
1293   let Inst{15}    = 0b1;
1294   let Inst{14-13} = opc;
1295   let Inst{12-10} = Pg;
1296   let Inst{9-5}   = Zm;
1297   let Inst{4-0}   = Zdn;
1299   let Constraints = "$Zdn = $_Zdn";
1300   let DestructiveInstType = Destructive;
1301   let ElementSize = zprty.ElementSize;
1304 multiclass sve_fp_3op_p_zds_b<bits<2> opc, string asm> {
1305   def _H : sve_fp_3op_p_zds_b<0b01, opc, asm, ZPR16>;
1306   def _S : sve_fp_3op_p_zds_b<0b10, opc, asm, ZPR32>;
1307   def _D : sve_fp_3op_p_zds_b<0b11, opc, asm, ZPR64>;
1310 //===----------------------------------------------------------------------===//
1311 // SVE Floating Point Multiply-Add - Indexed Group
1312 //===----------------------------------------------------------------------===//
1314 class sve_fp_fma_by_indexed_elem<bits<2> sz, bit opc, string asm,
1315                                  ZPRRegOp zprty1,
1316                                  ZPRRegOp zprty2, Operand itype>
1317 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty1:$Zn, zprty2:$Zm, itype:$iop),
1318   asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
1319   bits<5> Zda;
1320   bits<5> Zn;
1321   let Inst{31-24} = 0b01100100;
1322   let Inst{23-22} = sz;
1323   let Inst{21}    = 0b1;
1324   let Inst{15-11} = 0;
1325   let Inst{10}    = opc;
1326   let Inst{9-5}   = Zn;
1327   let Inst{4-0}   = Zda;
1329   let Constraints = "$Zda = $_Zda";
1330   let DestructiveInstType = Destructive;
1331   let ElementSize = ElementSizeNone;
1334 multiclass sve_fp_fma_by_indexed_elem<bit opc, string asm> {
1335   def _H : sve_fp_fma_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR3b16, VectorIndexH> {
1336     bits<3> Zm;
1337     bits<3> iop;
1338     let Inst{22} = iop{2};
1339     let Inst{20-19} = iop{1-0};
1340     let Inst{18-16} = Zm;
1341   }
1342   def _S : sve_fp_fma_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR3b32, VectorIndexS> {
1343     bits<3> Zm;
1344     bits<2> iop;
1345     let Inst{20-19} = iop;
1346     let Inst{18-16} = Zm;
1347   }
1348   def _D : sve_fp_fma_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR4b64, VectorIndexD> {
1349     bits<4> Zm;
1350     bit iop;
1351     let Inst{20} = iop;
1352     let Inst{19-16} = Zm;
1353   }
1357 //===----------------------------------------------------------------------===//
1358 // SVE Floating Point Multiply - Indexed Group
1359 //===----------------------------------------------------------------------===//
1361 class sve_fp_fmul_by_indexed_elem<bits<2> sz, string asm, ZPRRegOp zprty,
1362                                       ZPRRegOp zprty2, Operand itype>
1363 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty2:$Zm, itype:$iop),
1364   asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
1365   bits<5> Zd;
1366   bits<5> Zn;
1367   let Inst{31-24} = 0b01100100;
1368   let Inst{23-22} = sz;
1369   let Inst{21}    = 0b1;
1370   let Inst{15-10} = 0b001000;
1371   let Inst{9-5}   = Zn;
1372   let Inst{4-0}   = Zd;
1375 multiclass sve_fp_fmul_by_indexed_elem<string asm> {
1376   def _H : sve_fp_fmul_by_indexed_elem<{0, ?}, asm, ZPR16, ZPR3b16, VectorIndexH> {
1377     bits<3> Zm;
1378     bits<3> iop;
1379     let Inst{22} = iop{2};
1380     let Inst{20-19} = iop{1-0};
1381     let Inst{18-16} = Zm;
1382   }
1383   def _S : sve_fp_fmul_by_indexed_elem<0b10, asm, ZPR32, ZPR3b32, VectorIndexS> {
1384     bits<3> Zm;
1385     bits<2> iop;
1386     let Inst{20-19} = iop;
1387     let Inst{18-16} = Zm;
1388   }
1389   def _D : sve_fp_fmul_by_indexed_elem<0b11, asm, ZPR64, ZPR4b64, VectorIndexD> {
1390     bits<4> Zm;
1391     bit iop;
1392     let Inst{20} = iop;
1393     let Inst{19-16} = Zm;
1394   }
1397 //===----------------------------------------------------------------------===//
1398 // SVE Floating Point Complex Multiply-Add Group
1399 //===----------------------------------------------------------------------===//
1401 class sve_fp_fcmla<bits<2> sz, string asm, ZPRRegOp zprty>
1402 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm,
1403                         complexrotateop:$imm),
1404   asm, "\t$Zda, $Pg/m, $Zn, $Zm, $imm",
1405   "", []>, Sched<[]> {
1406   bits<5> Zda;
1407   bits<3> Pg;
1408   bits<5> Zn;
1409   bits<5> Zm;
1410   bits<2> imm;
1411   let Inst{31-24} = 0b01100100;
1412   let Inst{23-22} = sz;
1413   let Inst{21}    = 0;
1414   let Inst{20-16} = Zm;
1415   let Inst{15}    = 0;
1416   let Inst{14-13} = imm;
1417   let Inst{12-10} = Pg;
1418   let Inst{9-5}   = Zn;
1419   let Inst{4-0}   = Zda;
1421   let Constraints = "$Zda = $_Zda";
1422   let DestructiveInstType = Destructive;
1423   let ElementSize = zprty.ElementSize;
1426 multiclass sve_fp_fcmla<string asm> {
1427   def _H : sve_fp_fcmla<0b01, asm, ZPR16>;
1428   def _S : sve_fp_fcmla<0b10, asm, ZPR32>;
1429   def _D : sve_fp_fcmla<0b11, asm, ZPR64>;
1432 //===----------------------------------------------------------------------===//
1433 // SVE Floating Point Complex Multiply-Add - Indexed Group
1434 //===----------------------------------------------------------------------===//
1436 class sve_fp_fcmla_by_indexed_elem<bits<2> sz, string asm,
1437                                    ZPRRegOp zprty,
1438                                    ZPRRegOp zprty2, Operand itype>
1439 : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, zprty2:$Zm, itype:$iop,
1440                         complexrotateop:$imm),
1441   asm, "\t$Zda, $Zn, $Zm$iop, $imm",
1442   "", []>, Sched<[]> {
1443   bits<5> Zda;
1444   bits<5> Zn;
1445   bits<2> imm;
1446   let Inst{31-24} = 0b01100100;
1447   let Inst{23-22} = sz;
1448   let Inst{21}    = 0b1;
1449   let Inst{15-12} = 0b0001;
1450   let Inst{11-10} = imm;
1451   let Inst{9-5}   = Zn;
1452   let Inst{4-0}   = Zda;
1454   let Constraints = "$Zda = $_Zda";
1455   let DestructiveInstType = Destructive;
1456   let ElementSize = ElementSizeNone;
1459 multiclass sve_fp_fcmla_by_indexed_elem<string asm> {
1460   def _H : sve_fp_fcmla_by_indexed_elem<0b10, asm, ZPR16, ZPR3b16, VectorIndexS> {
1461     bits<3> Zm;
1462     bits<2> iop;
1463     let Inst{20-19} = iop;
1464     let Inst{18-16} = Zm;
1465   }
1466   def _S : sve_fp_fcmla_by_indexed_elem<0b11, asm, ZPR32, ZPR4b32, VectorIndexD> {
1467     bits<4> Zm;
1468     bits<1> iop;
1469     let Inst{20} = iop;
1470     let Inst{19-16} = Zm;
1471   }
1474 //===----------------------------------------------------------------------===//
1475 // SVE Floating Point Complex Addition Group
1476 //===----------------------------------------------------------------------===//
1478 class sve_fp_fcadd<bits<2> sz, string asm, ZPRRegOp zprty>
1479 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm,
1480                         complexrotateopodd:$imm),
1481   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm, $imm",
1482   "",
1483   []>, Sched<[]> {
1484   bits<5> Zdn;
1485   bits<5> Zm;
1486   bits<3> Pg;
1487   bit imm;
1488   let Inst{31-24} = 0b01100100;
1489   let Inst{23-22} = sz;
1490   let Inst{21-17} = 0;
1491   let Inst{16}    = imm;
1492   let Inst{15-13} = 0b100;
1493   let Inst{12-10} = Pg;
1494   let Inst{9-5}   = Zm;
1495   let Inst{4-0}   = Zdn;
1497   let Constraints = "$Zdn = $_Zdn";
1498   let DestructiveInstType = Destructive;
1499   let ElementSize = zprty.ElementSize;
1502 multiclass sve_fp_fcadd<string asm> {
1503   def _H : sve_fp_fcadd<0b01, asm, ZPR16>;
1504   def _S : sve_fp_fcadd<0b10, asm, ZPR32>;
1505   def _D : sve_fp_fcadd<0b11, asm, ZPR64>;
1508 //===----------------------------------------------------------------------===//
1509 // SVE2 Floating Point Convert Group
1510 //===----------------------------------------------------------------------===//
1512 class sve2_fp_convert_precision<bits<4> opc, string asm,
1513                                 ZPRRegOp zprty1, ZPRRegOp zprty2>
1514 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, PPR3bAny:$Pg, zprty2:$Zn),
1515   asm, "\t$Zd, $Pg/m, $Zn",
1516   "",
1517   []>, Sched<[]> {
1518   bits<5> Zd;
1519   bits<5> Zn;
1520   bits<3> Pg;
1521   let Inst{31-24} = 0b01100100;
1522   let Inst{23-22} = opc{3-2};
1523   let Inst{21-18} = 0b0010;
1524   let Inst{17-16} = opc{1-0};
1525   let Inst{15-13} = 0b101;
1526   let Inst{12-10} = Pg;
1527   let Inst{9-5}   = Zn;
1528   let Inst{4-0}   = Zd;
1530   let Constraints = "$Zd = $_Zd";
1533 multiclass sve2_fp_convert_down_narrow<string asm> {
1534   def _StoH : sve2_fp_convert_precision<0b1000, asm, ZPR16, ZPR32>;
1535   def _DtoS : sve2_fp_convert_precision<0b1110, asm, ZPR32, ZPR64>;
1538 multiclass sve2_fp_convert_up_long<string asm> {
1539   def _HtoS : sve2_fp_convert_precision<0b1001, asm, ZPR32, ZPR16>;
1540   def _StoD : sve2_fp_convert_precision<0b1111, asm, ZPR64, ZPR32>;
1543 multiclass sve2_fp_convert_down_odd_rounding<string asm> {
1544   def _DtoS : sve2_fp_convert_precision<0b0010, asm, ZPR32, ZPR64>;
1547 //===----------------------------------------------------------------------===//
1548 // SVE2 Floating Point Pairwise Group
1549 //===----------------------------------------------------------------------===//
1551 class sve2_fp_pairwise_pred<bits<2> sz, bits<3> opc, string asm,
1552                             ZPRRegOp zprty>
1553 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
1554   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
1555   "",
1556   []>, Sched<[]> {
1557   bits<3> Pg;
1558   bits<5> Zm;
1559   bits<5> Zdn;
1560   let Inst{31-24} = 0b01100100;
1561   let Inst{23-22} = sz;
1562   let Inst{21-19} = 0b010;
1563   let Inst{18-16} = opc;
1564   let Inst{15-13} = 0b100;
1565   let Inst{12-10} = Pg;
1566   let Inst{9-5}   = Zm;
1567   let Inst{4-0}   = Zdn;
1569   let Constraints = "$Zdn = $_Zdn";
1570   let DestructiveInstType = Destructive;
1571   let ElementSize = zprty.ElementSize;
1574 multiclass sve2_fp_pairwise_pred<bits<3> opc, string asm> {
1575   def _H : sve2_fp_pairwise_pred<0b01, opc, asm, ZPR16>;
1576   def _S : sve2_fp_pairwise_pred<0b10, opc, asm, ZPR32>;
1577   def _D : sve2_fp_pairwise_pred<0b11, opc, asm, ZPR64>;
1580 //===----------------------------------------------------------------------===//
1581 // SVE2 Floating Point Widening Multiply-Add - Indexed Group
1582 //===----------------------------------------------------------------------===//
1584 class sve2_fp_mla_long_by_indexed_elem<bits<2> opc, string asm>
1585 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm,
1586                         VectorIndexH:$iop),
1587   asm, "\t$Zda, $Zn, $Zm$iop",
1588   "",
1589   []>, Sched<[]> {
1590   bits<5> Zda;
1591   bits<5> Zn;
1592   bits<3> Zm;
1593   bits<3> iop;
1594   let Inst{31-21} = 0b01100100101;
1595   let Inst{20-19} = iop{2-1};
1596   let Inst{18-16} = Zm;
1597   let Inst{15-14} = 0b01;
1598   let Inst{13}    = opc{1};
1599   let Inst{12}    = 0b0;
1600   let Inst{11}    = iop{0};
1601   let Inst{10}    = opc{0};
1602   let Inst{9-5}   = Zn;
1603   let Inst{4-0}   = Zda;
1605   let Constraints = "$Zda = $_Zda";
1606   let DestructiveInstType = Destructive;
1607   let ElementSize = ElementSizeNone;
1610 //===----------------------------------------------------------------------===//
1611 // SVE2 Floating Point Widening Multiply-Add Group
1612 //===----------------------------------------------------------------------===//
1614 class sve2_fp_mla_long<bits<2> opc, string asm>
1615 : I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
1616   asm, "\t$Zda, $Zn, $Zm",
1617   "",
1618   []>, Sched<[]> {
1619   bits<5> Zda;
1620   bits<5> Zn;
1621   bits<5> Zm;
1622   let Inst{31-21} = 0b01100100101;
1623   let Inst{20-16} = Zm;
1624   let Inst{15-14} = 0b10;
1625   let Inst{13}    = opc{1};
1626   let Inst{12-11} = 0b00;
1627   let Inst{10}    = opc{0};
1628   let Inst{9-5}   = Zn;
1629   let Inst{4-0}   = Zda;
1631   let Constraints = "$Zda = $_Zda";
1632   let DestructiveInstType = Destructive;
1633   let ElementSize = ElementSizeNone;
1636 //===----------------------------------------------------------------------===//
1637 // SVE Stack Allocation Group
1638 //===----------------------------------------------------------------------===//
1640 class sve_int_arith_vl<bit opc, string asm>
1641 : I<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, simm6_32b:$imm6),
1642   asm, "\t$Rd, $Rn, $imm6",
1643   "",
1644   []>, Sched<[]> {
1645   bits<5> Rd;
1646   bits<5> Rn;
1647   bits<6> imm6;
1648   let Inst{31-23} = 0b000001000;
1649   let Inst{22}    = opc;
1650   let Inst{21}    = 0b1;
1651   let Inst{20-16} = Rn;
1652   let Inst{15-11} = 0b01010;
1653   let Inst{10-5}  = imm6;
1654   let Inst{4-0}   = Rd;
1657 class sve_int_read_vl_a<bit op, bits<5> opc2, string asm>
1658 : I<(outs GPR64:$Rd), (ins simm6_32b:$imm6),
1659   asm, "\t$Rd, $imm6",
1660   "",
1661   []>, Sched<[]> {
1662   bits<5> Rd;
1663   bits<6> imm6;
1664   let Inst{31-23} = 0b000001001;
1665   let Inst{22}    = op;
1666   let Inst{21}    = 0b1;
1667   let Inst{20-16} = opc2{4-0};
1668   let Inst{15-11} = 0b01010;
1669   let Inst{10-5}  = imm6;
1670   let Inst{4-0}   = Rd;
1673 //===----------------------------------------------------------------------===//
1674 // SVE Permute - In Lane Group
1675 //===----------------------------------------------------------------------===//
1677 class sve_int_perm_bin_perm_zz<bits<3> opc, bits<2> sz8_64, string asm,
1678                                ZPRRegOp zprty>
1679 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
1680   asm, "\t$Zd, $Zn, $Zm",
1681   "",
1682   []>, Sched<[]> {
1683   bits<5> Zd;
1684   bits<5> Zm;
1685   bits<5> Zn;
1686   let Inst{31-24} = 0b00000101;
1687   let Inst{23-22} = sz8_64;
1688   let Inst{21}    = 0b1;
1689   let Inst{20-16} = Zm;
1690   let Inst{15-13} = 0b011;
1691   let Inst{12-10} = opc;
1692   let Inst{9-5}   = Zn;
1693   let Inst{4-0}   = Zd;
1696 multiclass sve_int_perm_bin_perm_zz<bits<3> opc, string asm> {
1697   def _B : sve_int_perm_bin_perm_zz<opc, 0b00, asm, ZPR8>;
1698   def _H : sve_int_perm_bin_perm_zz<opc, 0b01, asm, ZPR16>;
1699   def _S : sve_int_perm_bin_perm_zz<opc, 0b10, asm, ZPR32>;
1700   def _D : sve_int_perm_bin_perm_zz<opc, 0b11, asm, ZPR64>;
1703 //===----------------------------------------------------------------------===//
1704 // SVE Floating Point Unary Operations Group
1705 //===----------------------------------------------------------------------===//
1707 class sve_fp_2op_p_zd<bits<7> opc, string asm, RegisterOperand i_zprtype,
1708                       RegisterOperand o_zprtype, ElementSizeEnum size>
1709 : I<(outs o_zprtype:$Zd), (ins i_zprtype:$_Zd, PPR3bAny:$Pg, i_zprtype:$Zn),
1710   asm, "\t$Zd, $Pg/m, $Zn",
1711   "",
1712   []>, Sched<[]> {
1713   bits<3> Pg;
1714   bits<5> Zd;
1715   bits<5> Zn;
1716   let Inst{31-24} = 0b01100101;
1717   let Inst{23-22} = opc{6-5};
1718   let Inst{21}    = 0b0;
1719   let Inst{20-16} = opc{4-0};
1720   let Inst{15-13} = 0b101;
1721   let Inst{12-10} = Pg;
1722   let Inst{9-5}   = Zn;
1723   let Inst{4-0}   = Zd;
1725   let Constraints = "$Zd = $_Zd";
1726   let DestructiveInstType = Destructive;
1727   let ElementSize = size;
1730 multiclass sve_fp_2op_p_zd_HSD<bits<5> opc, string asm> {
1731   def _H : sve_fp_2op_p_zd<{ 0b01, opc }, asm, ZPR16, ZPR16, ElementSizeH>;
1732   def _S : sve_fp_2op_p_zd<{ 0b10, opc }, asm, ZPR32, ZPR32, ElementSizeS>;
1733   def _D : sve_fp_2op_p_zd<{ 0b11, opc }, asm, ZPR64, ZPR64, ElementSizeD>;
1736 multiclass sve2_fp_flogb<string asm> {
1737   def _H : sve_fp_2op_p_zd<0b0011010, asm, ZPR16, ZPR16, ElementSizeH>;
1738   def _S : sve_fp_2op_p_zd<0b0011100, asm, ZPR32, ZPR32, ElementSizeS>;
1739   def _D : sve_fp_2op_p_zd<0b0011110, asm, ZPR64, ZPR64, ElementSizeD>;
1742 //===----------------------------------------------------------------------===//
1743 // SVE Floating Point Unary Operations - Unpredicated Group
1744 //===----------------------------------------------------------------------===//
1746 class sve_fp_2op_u_zd<bits<2> sz, bits<3> opc, string asm,
1747                       ZPRRegOp zprty>
1748 : I<(outs zprty:$Zd), (ins zprty:$Zn),
1749   asm, "\t$Zd, $Zn",
1750   "",
1751   []>, Sched<[]> {
1752   bits<5> Zd;
1753   bits<5> Zn;
1754   let Inst{31-24} = 0b01100101;
1755   let Inst{23-22} = sz;
1756   let Inst{21-19} = 0b001;
1757   let Inst{18-16} = opc;
1758   let Inst{15-10} = 0b001100;
1759   let Inst{9-5}   = Zn;
1760   let Inst{4-0}   = Zd;
1763 multiclass sve_fp_2op_u_zd<bits<3> opc, string asm> {
1764   def _H : sve_fp_2op_u_zd<0b01, opc, asm, ZPR16>;
1765   def _S : sve_fp_2op_u_zd<0b10, opc, asm, ZPR32>;
1766   def _D : sve_fp_2op_u_zd<0b11, opc, asm, ZPR64>;
1769 //===----------------------------------------------------------------------===//
1770 // SVE Integer Arithmetic - Binary Predicated Group
1771 //===----------------------------------------------------------------------===//
1773 class sve_int_bin_pred_arit_log<bits<2> sz8_64, bits<2> fmt, bits<3> opc,
1774                                 string asm, ZPRRegOp zprty>
1775 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
1776   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
1777   bits<3> Pg;
1778   bits<5> Zdn;
1779   bits<5> Zm;
1780   let Inst{31-24} = 0b00000100;
1781   let Inst{23-22} = sz8_64;
1782   let Inst{21}    = 0b0;
1783   let Inst{20-19} = fmt;
1784   let Inst{18-16} = opc;
1785   let Inst{15-13} = 0b000;
1786   let Inst{12-10} = Pg;
1787   let Inst{9-5}   = Zm;
1788   let Inst{4-0}   = Zdn;
1790   let Constraints = "$Zdn = $_Zdn";
1791   let DestructiveInstType = Destructive;
1792   let ElementSize = zprty.ElementSize;
1795 multiclass sve_int_bin_pred_log<bits<3> opc, string asm> {
1796   def _B : sve_int_bin_pred_arit_log<0b00, 0b11, opc, asm, ZPR8>;
1797   def _H : sve_int_bin_pred_arit_log<0b01, 0b11, opc, asm, ZPR16>;
1798   def _S : sve_int_bin_pred_arit_log<0b10, 0b11, opc, asm, ZPR32>;
1799   def _D : sve_int_bin_pred_arit_log<0b11, 0b11, opc, asm, ZPR64>;
1802 multiclass sve_int_bin_pred_arit_0<bits<3> opc, string asm> {
1803   def _B : sve_int_bin_pred_arit_log<0b00, 0b00, opc, asm, ZPR8>;
1804   def _H : sve_int_bin_pred_arit_log<0b01, 0b00, opc, asm, ZPR16>;
1805   def _S : sve_int_bin_pred_arit_log<0b10, 0b00, opc, asm, ZPR32>;
1806   def _D : sve_int_bin_pred_arit_log<0b11, 0b00, opc, asm, ZPR64>;
1809 multiclass sve_int_bin_pred_arit_1<bits<3> opc, string asm> {
1810   def _B : sve_int_bin_pred_arit_log<0b00, 0b01, opc, asm, ZPR8>;
1811   def _H : sve_int_bin_pred_arit_log<0b01, 0b01, opc, asm, ZPR16>;
1812   def _S : sve_int_bin_pred_arit_log<0b10, 0b01, opc, asm, ZPR32>;
1813   def _D : sve_int_bin_pred_arit_log<0b11, 0b01, opc, asm, ZPR64>;
1816 multiclass sve_int_bin_pred_arit_2<bits<3> opc, string asm> {
1817   def _B : sve_int_bin_pred_arit_log<0b00, 0b10, opc, asm, ZPR8>;
1818   def _H : sve_int_bin_pred_arit_log<0b01, 0b10, opc, asm, ZPR16>;
1819   def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>;
1820   def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>;
1823 // Special case for divides which are not defined for 8b/16b elements.
1824 multiclass sve_int_bin_pred_arit_2_div<bits<3> opc, string asm> {
1825   def _S : sve_int_bin_pred_arit_log<0b10, 0b10, opc, asm, ZPR32>;
1826   def _D : sve_int_bin_pred_arit_log<0b11, 0b10, opc, asm, ZPR64>;
1829 //===----------------------------------------------------------------------===//
1830 // SVE Integer Multiply-Add Group
1831 //===----------------------------------------------------------------------===//
1833 class sve_int_mladdsub_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
1834                                 ZPRRegOp zprty>
1835 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm, zprty:$Za),
1836   asm, "\t$Zdn, $Pg/m, $Zm, $Za",
1837   "",
1838   []>, Sched<[]> {
1839   bits<3> Pg;
1840   bits<5> Zdn;
1841   bits<5> Za;
1842   bits<5> Zm;
1843   let Inst{31-24} = 0b00000100;
1844   let Inst{23-22} = sz8_64;
1845   let Inst{21}    = 0b0;
1846   let Inst{20-16} = Zm;
1847   let Inst{15-14} = 0b11;
1848   let Inst{13}    = opc;
1849   let Inst{12-10} = Pg;
1850   let Inst{9-5}   = Za;
1851   let Inst{4-0}   = Zdn;
1853   let Constraints = "$Zdn = $_Zdn";
1854   let DestructiveInstType = Destructive;
1855   let ElementSize = zprty.ElementSize;
1858 multiclass sve_int_mladdsub_vvv_pred<bits<1> opc, string asm> {
1859   def _B : sve_int_mladdsub_vvv_pred<0b00, opc, asm, ZPR8>;
1860   def _H : sve_int_mladdsub_vvv_pred<0b01, opc, asm, ZPR16>;
1861   def _S : sve_int_mladdsub_vvv_pred<0b10, opc, asm, ZPR32>;
1862   def _D : sve_int_mladdsub_vvv_pred<0b11, opc, asm, ZPR64>;
1865 class sve_int_mlas_vvv_pred<bits<2> sz8_64, bits<1> opc, string asm,
1866                             ZPRRegOp zprty>
1867 : I<(outs zprty:$Zda), (ins PPR3bAny:$Pg, zprty:$_Zda, zprty:$Zn, zprty:$Zm),
1868   asm, "\t$Zda, $Pg/m, $Zn, $Zm",
1869   "",
1870   []>, Sched<[]> {
1871   bits<3> Pg;
1872   bits<5> Zda;
1873   bits<5> Zm;
1874   bits<5> Zn;
1875   let Inst{31-24} = 0b00000100;
1876   let Inst{23-22} = sz8_64;
1877   let Inst{21}    = 0b0;
1878   let Inst{20-16} = Zm;
1879   let Inst{15-14} = 0b01;
1880   let Inst{13}    = opc;
1881   let Inst{12-10} = Pg;
1882   let Inst{9-5}   = Zn;
1883   let Inst{4-0}   = Zda;
1885   let Constraints = "$Zda = $_Zda";
1886   let DestructiveInstType = Destructive;
1887   let ElementSize = zprty.ElementSize;
1890 multiclass sve_int_mlas_vvv_pred<bits<1> opc, string asm> {
1891   def _B : sve_int_mlas_vvv_pred<0b00, opc, asm, ZPR8>;
1892   def _H : sve_int_mlas_vvv_pred<0b01, opc, asm, ZPR16>;
1893   def _S : sve_int_mlas_vvv_pred<0b10, opc, asm, ZPR32>;
1894   def _D : sve_int_mlas_vvv_pred<0b11, opc, asm, ZPR64>;
1897 //===----------------------------------------------------------------------===//
1898 // SVE2 Integer Multiply-Add - Unpredicated Group
1899 //===----------------------------------------------------------------------===//
1901 class sve2_int_mla<bits<2> sz, bits<5> opc, string asm,
1902                    ZPRRegOp zprty1, ZPRRegOp zprty2>
1903 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
1904   asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
1905   bits<5> Zda;
1906   bits<5> Zn;
1907   bits<5> Zm;
1908   let Inst{31-24} = 0b01000100;
1909   let Inst{23-22} = sz;
1910   let Inst{21}    = 0b0;
1911   let Inst{20-16} = Zm;
1912   let Inst{15}    = 0b0;
1913   let Inst{14-10} = opc;
1914   let Inst{9-5}   = Zn;
1915   let Inst{4-0}   = Zda;
1917   let Constraints = "$Zda = $_Zda";
1918   let DestructiveInstType = Destructive;
1919   let ElementSize = ElementSizeNone;
1922 multiclass sve2_int_mla<bit S, string asm> {
1923   def _B : sve2_int_mla<0b00, { 0b1110, S }, asm, ZPR8, ZPR8>;
1924   def _H : sve2_int_mla<0b01, { 0b1110, S }, asm, ZPR16, ZPR16>;
1925   def _S : sve2_int_mla<0b10, { 0b1110, S }, asm, ZPR32, ZPR32>;
1926   def _D : sve2_int_mla<0b11, { 0b1110, S }, asm, ZPR64, ZPR64>;
1929 multiclass sve2_int_mla_long<bits<5> opc, string asm> {
1930   def _H : sve2_int_mla<0b01, opc, asm, ZPR16, ZPR8>;
1931   def _S : sve2_int_mla<0b10, opc, asm, ZPR32, ZPR16>;
1932   def _D : sve2_int_mla<0b11, opc, asm, ZPR64, ZPR32>;
1935 //===----------------------------------------------------------------------===//
1936 // SVE2 Integer Multiply-Add - Indexed Group
1937 //===----------------------------------------------------------------------===//
1939 class sve2_int_mla_by_indexed_elem<bits<2> sz, bits<6> opc, string asm,
1940                                    ZPRRegOp zprty1, ZPRRegOp zprty2,
1941                                    ZPRRegOp zprty3, Operand itype>
1942 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
1943   asm, "\t$Zda, $Zn, $Zm$iop", "", []>, Sched<[]> {
1944   bits<5> Zda;
1945   bits<5> Zn;
1946   let Inst{31-24} = 0b01000100;
1947   let Inst{23-22} = sz;
1948   let Inst{21}    = 0b1;
1949   let Inst{15-10} = opc;
1950   let Inst{9-5}   = Zn;
1951   let Inst{4-0}   = Zda;
1953   let Constraints = "$Zda = $_Zda";
1954   let DestructiveInstType = Destructive;
1955   let ElementSize = ElementSizeNone;
1958 multiclass sve2_int_mla_by_indexed_elem<bits<2> opc, bit S, string asm> {
1959   def _H : sve2_int_mla_by_indexed_elem<{0, ?}, { 0b000, opc, S }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH> {
1960     bits<3> Zm;
1961     bits<3> iop;
1962     let Inst{22} = iop{2};
1963     let Inst{20-19} = iop{1-0};
1964     let Inst{18-16} = Zm;
1965   }
1966   def _S : sve2_int_mla_by_indexed_elem<0b10, { 0b000, opc, S }, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS> {
1967     bits<3> Zm;
1968     bits<2> iop;
1969     let Inst{20-19} = iop;
1970     let Inst{18-16} = Zm;
1971   }
1972   def _D : sve2_int_mla_by_indexed_elem<0b11, { 0b000, opc, S }, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD> {
1973     bits<4> Zm;
1974     bit iop;
1975     let Inst{20} = iop;
1976     let Inst{19-16} = Zm;
1977   }
1980 //===----------------------------------------------------------------------===//
1981 // SVE2 Integer Multiply-Add Long - Indexed Group
1982 //===----------------------------------------------------------------------===//
1984 multiclass sve2_int_mla_long_by_indexed_elem<bits<4> opc, string asm> {
1985   def _S : sve2_int_mla_by_indexed_elem<0b10, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
1986                                         asm, ZPR32, ZPR16, ZPR3b16, VectorIndexH> {
1987     bits<3> Zm;
1988     bits<3> iop;
1989     let Inst{20-19} = iop{2-1};
1990     let Inst{18-16} = Zm;
1991     let Inst{11} = iop{0};
1992   }
1993   def _D : sve2_int_mla_by_indexed_elem<0b11, { opc{3}, 0b0, opc{2-1}, ?, opc{0} },
1994                                         asm, ZPR64, ZPR32, ZPR4b32, VectorIndexS> {
1995     bits<4> Zm;
1996     bits<2> iop;
1997     let Inst{20} = iop{1};
1998     let Inst{19-16} = Zm;
1999     let Inst{11} = iop{0};
2000   }
2003 //===----------------------------------------------------------------------===//
2004 // SVE Integer Dot Product Group
2005 //===----------------------------------------------------------------------===//
2007 class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
2008                    ZPRRegOp zprty2>
2009 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), asm,
2010   "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
2011   bits<5> Zda;
2012   bits<5> Zn;
2013   bits<5> Zm;
2014   let Inst{31-23} = 0b010001001;
2015   let Inst{22}    = sz;
2016   let Inst{21}    = 0;
2017   let Inst{20-16} = Zm;
2018   let Inst{15-11} = 0;
2019   let Inst{10}    = U;
2020   let Inst{9-5}   = Zn;
2021   let Inst{4-0}   = Zda;
2023   let Constraints = "$Zda = $_Zda";
2024   let DestructiveInstType = Destructive;
2025   let ElementSize = zprty1.ElementSize;
2028 multiclass sve_intx_dot<bit opc, string asm> {
2029   def _S : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>;
2030   def _D : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>;
2033 //===----------------------------------------------------------------------===//
2034 // SVE Integer Dot Product Group - Indexed Group
2035 //===----------------------------------------------------------------------===//
2037 class sve_intx_dot_by_indexed_elem<bit sz, bit U, string asm,
2038                                    ZPRRegOp zprty1, ZPRRegOp zprty2,
2039                                    ZPRRegOp zprty3, Operand itype>
2040 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop),
2041   asm, "\t$Zda, $Zn, $Zm$iop",
2042   "", []>, Sched<[]> {
2043   bits<5> Zda;
2044   bits<5> Zn;
2045   let Inst{31-23} = 0b010001001;
2046   let Inst{22}    = sz;
2047   let Inst{21}    = 0b1;
2048   let Inst{15-11} = 0;
2049   let Inst{10}    = U;
2050   let Inst{9-5}   = Zn;
2051   let Inst{4-0}   = Zda;
2053   let Constraints = "$Zda = $_Zda";
2054   let DestructiveInstType = Destructive;
2055   let ElementSize = ElementSizeNone;
2058 multiclass sve_intx_dot_by_indexed_elem<bit opc, string asm> {
2059   def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS> {
2060     bits<2> iop;
2061     bits<3> Zm;
2062     let Inst{20-19} = iop;
2063     let Inst{18-16} = Zm;
2064   }
2065   def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD> {
2066     bits<1> iop;
2067     bits<4> Zm;
2068     let Inst{20} = iop;
2069     let Inst{19-16} = Zm;
2070   }
2073 //===----------------------------------------------------------------------===//
2074 // SVE2 Complex Integer Dot Product Group
2075 //===----------------------------------------------------------------------===//
2077 class sve2_complex_int_arith<bits<2> sz, bits<4> opc, string asm,
2078                              ZPRRegOp zprty1, ZPRRegOp zprty2>
2079 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm,
2080                          complexrotateop:$rot),
2081   asm, "\t$Zda, $Zn, $Zm, $rot", "", []>, Sched<[]> {
2082   bits<5> Zda;
2083   bits<5> Zn;
2084   bits<5> Zm;
2085   bits<2> rot;
2086   let Inst{31-24} = 0b01000100;
2087   let Inst{23-22} = sz;
2088   let Inst{21}    = 0b0;
2089   let Inst{20-16} = Zm;
2090   let Inst{15-12} = opc;
2091   let Inst{11-10} = rot;
2092   let Inst{9-5}   = Zn;
2093   let Inst{4-0}   = Zda;
2095   let Constraints = "$Zda = $_Zda";
2096   let DestructiveInstType = Destructive;
2097   let ElementSize = ElementSizeNone;
2100 multiclass sve2_cintx_dot<string asm> {
2101   def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>;
2102   def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>;
2105 //===----------------------------------------------------------------------===//
2106 // SVE2 Complex Multiply-Add Group
2107 //===----------------------------------------------------------------------===//
2109 multiclass sve2_int_cmla<bit opc, string asm> {
2110   def _B : sve2_complex_int_arith<0b00, { 0b001, opc }, asm, ZPR8, ZPR8>;
2111   def _H : sve2_complex_int_arith<0b01, { 0b001, opc }, asm, ZPR16, ZPR16>;
2112   def _S : sve2_complex_int_arith<0b10, { 0b001, opc }, asm, ZPR32, ZPR32>;
2113   def _D : sve2_complex_int_arith<0b11, { 0b001, opc }, asm, ZPR64, ZPR64>;
2116 //===----------------------------------------------------------------------===//
2117 // SVE2 Complex Integer Dot Product - Indexed Group
2118 //===----------------------------------------------------------------------===//
2120 class sve2_complex_int_arith_indexed<bits<2> sz, bits<4> opc, string asm,
2121                                      ZPRRegOp zprty1, ZPRRegOp zprty2,
2122                                      ZPRRegOp zprty3, Operand itype>
2123 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty3:$Zm, itype:$iop,
2124                          complexrotateop:$rot),
2125   asm, "\t$Zda, $Zn, $Zm$iop, $rot", "", []>, Sched<[]> {
2126   bits<5> Zda;
2127   bits<5> Zn;
2128   bits<2> rot;
2129   let Inst{31-24} = 0b01000100;
2130   let Inst{23-22} = sz;
2131   let Inst{21}    = 0b1;
2132   let Inst{15-12} = opc;
2133   let Inst{11-10} = rot;
2134   let Inst{9-5}   = Zn;
2135   let Inst{4-0}   = Zda;
2137   let Constraints = "$Zda = $_Zda";
2138   let DestructiveInstType = Destructive;
2139   let ElementSize = ElementSizeNone;
2142 multiclass sve2_cintx_dot_by_indexed_elem<string asm> {
2143   def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS> {
2144     bits<2> iop;
2145     bits<3> Zm;
2146     let Inst{20-19} = iop;
2147     let Inst{18-16} = Zm;
2148   }
2149   def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD> {
2150     bit iop;
2151     bits<4> Zm;
2152     let Inst{20} = iop;
2153     let Inst{19-16} = Zm;
2154   }
2157 //===----------------------------------------------------------------------===//
2158 // SVE2 Complex Multiply-Add - Indexed Group
2159 //===----------------------------------------------------------------------===//
2161 multiclass sve2_cmla_by_indexed_elem<bit opc, string asm> {
2162   def _H : sve2_complex_int_arith_indexed<0b10, { 0b011, opc }, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexS> {
2163     bits<2> iop;
2164     bits<3> Zm;
2165     let Inst{20-19} = iop;
2166     let Inst{18-16} = Zm;
2167   }
2168   def _S : sve2_complex_int_arith_indexed<0b11, { 0b011, opc }, asm, ZPR32, ZPR32, ZPR4b32, VectorIndexD> {
2169     bit iop;
2170     bits<4> Zm;
2171     let Inst{20} = iop;
2172     let Inst{19-16} = Zm;
2173   }
2176 //===----------------------------------------------------------------------===//
2177 // SVE2 Integer Multiply - Unpredicated Group
2178 //===----------------------------------------------------------------------===//
2180 class sve2_int_mul<bits<2> sz, bits<3> opc, string asm, ZPRRegOp zprty>
2181 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
2182   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2183   bits<5> Zd;
2184   bits<5> Zm;
2185   bits<5> Zn;
2186   let Inst{31-24} = 0b00000100;
2187   let Inst{23-22} = sz;
2188   let Inst{21}    = 0b1;
2189   let Inst{20-16} = Zm;
2190   let Inst{15-13} = 0b011;
2191   let Inst{12-10} = opc;
2192   let Inst{9-5}   = Zn;
2193   let Inst{4-0}   = Zd;
2196 multiclass sve2_int_mul<bits<3> opc, string asm> {
2197   def _B : sve2_int_mul<0b00, opc, asm, ZPR8>;
2198   def _H : sve2_int_mul<0b01, opc, asm, ZPR16>;
2199   def _S : sve2_int_mul<0b10, opc, asm, ZPR32>;
2200   def _D : sve2_int_mul<0b11, opc, asm, ZPR64>;
2203 //===----------------------------------------------------------------------===//
2204 // SVE2 Integer Multiply - Indexed Group
2205 //===----------------------------------------------------------------------===//
2207 class sve2_int_mul_by_indexed_elem<bits<2> sz, bits<4> opc, string asm,
2208                                    ZPRRegOp zprty1, ZPRRegOp zprty2,
2209                                    ZPRRegOp zprty3, Operand itype>
2210 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm, itype:$iop),
2211   asm, "\t$Zd, $Zn, $Zm$iop", "", []>, Sched<[]> {
2212   bits<5> Zd;
2213   bits<5> Zn;
2214   let Inst{31-24} = 0b01000100;
2215   let Inst{23-22} = sz;
2216   let Inst{21}    = 0b1;
2217   let Inst{15-14} = 0b11;
2218   let Inst{13-10} = opc;
2219   let Inst{9-5}   = Zn;
2220   let Inst{4-0}   = Zd;
2223 multiclass sve2_int_mul_by_indexed_elem<bits<4> opc, string asm> {
2224   def _H : sve2_int_mul_by_indexed_elem<{0, ?}, opc, asm, ZPR16, ZPR16, ZPR3b16, VectorIndexH> {
2225     bits<3> Zm;
2226     bits<3> iop;
2227     let Inst{22} = iop{2};
2228     let Inst{20-19} = iop{1-0};
2229     let Inst{18-16} = Zm;
2230   }
2231   def _S : sve2_int_mul_by_indexed_elem<0b10, opc, asm, ZPR32, ZPR32, ZPR3b32, VectorIndexS> {
2232     bits<3> Zm;
2233     bits<2> iop;
2234     let Inst{20-19} = iop;
2235     let Inst{18-16} = Zm;
2236   }
2237   def _D : sve2_int_mul_by_indexed_elem<0b11, opc, asm, ZPR64, ZPR64, ZPR4b64, VectorIndexD> {
2238     bits<4> Zm;
2239     bit iop;
2240     let Inst{20} = iop;
2241     let Inst{19-16} = Zm;
2242   }
2245 multiclass sve2_int_mul_long_by_indexed_elem<bits<3> opc, string asm> {
2246   def _S : sve2_int_mul_by_indexed_elem<0b10, { opc{2-1}, ?, opc{0} }, asm,
2247                                         ZPR32, ZPR16, ZPR3b16, VectorIndexH> {
2248     bits<3> Zm;
2249     bits<3> iop;
2250     let Inst{20-19} = iop{2-1};
2251     let Inst{18-16} = Zm;
2252     let Inst{11} = iop{0};
2253   }
2254   def _D : sve2_int_mul_by_indexed_elem<0b11, { opc{2-1}, ?, opc{0} }, asm,
2255                                         ZPR64, ZPR32, ZPR4b32, VectorIndexS> {
2256     bits<4> Zm;
2257     bits<2> iop;
2258     let Inst{20} = iop{1};
2259     let Inst{19-16} = Zm;
2260     let Inst{11} = iop{0};
2261   }
2264 //===----------------------------------------------------------------------===//
2265 // SVE2 Integer - Predicated Group
2266 //===----------------------------------------------------------------------===//
2268 class sve2_int_arith_pred<bits<2> sz, bits<6> opc, string asm,
2269                           ZPRRegOp zprty>
2270 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
2271   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm", "", []>, Sched<[]> {
2272   bits<3> Pg;
2273   bits<5> Zm;
2274   bits<5> Zdn;
2275   let Inst{31-24} = 0b01000100;
2276   let Inst{23-22} = sz;
2277   let Inst{21}    = 0b0;
2278   let Inst{20-16} = opc{5-1};
2279   let Inst{15-14} = 0b10;
2280   let Inst{13}    = opc{0};
2281   let Inst{12-10} = Pg;
2282   let Inst{9-5}   = Zm;
2283   let Inst{4-0}   = Zdn;
2285   let Constraints = "$Zdn = $_Zdn";
2286   let DestructiveInstType = Destructive;
2287   let ElementSize = zprty.ElementSize;
2290 multiclass sve2_int_arith_pred<bits<6> opc, string asm> {
2291   def _B : sve2_int_arith_pred<0b00, opc, asm, ZPR8>;
2292   def _H : sve2_int_arith_pred<0b01, opc, asm, ZPR16>;
2293   def _S : sve2_int_arith_pred<0b10, opc, asm, ZPR32>;
2294   def _D : sve2_int_arith_pred<0b11, opc, asm, ZPR64>;
2297 class sve2_int_sadd_long_accum_pairwise<bits<2> sz, bit U, string asm,
2298                                         ZPRRegOp zprty1, ZPRRegOp zprty2>
2299 : I<(outs zprty1:$Zda), (ins PPR3bAny:$Pg, zprty1:$_Zda, zprty2:$Zn),
2300   asm, "\t$Zda, $Pg/m, $Zn", "", []>, Sched<[]> {
2301   bits<3> Pg;
2302   bits<5> Zn;
2303   bits<5> Zda;
2304   let Inst{31-24} = 0b01000100;
2305   let Inst{23-22} = sz;
2306   let Inst{21-17} = 0b00010;
2307   let Inst{16}    = U;
2308   let Inst{15-13} = 0b101;
2309   let Inst{12-10} = Pg;
2310   let Inst{9-5}   = Zn;
2311   let Inst{4-0}   = Zda;
2313   let Constraints = "$Zda = $_Zda";
2314   let DestructiveInstType = Destructive;
2315   let ElementSize = zprty1.ElementSize;
2318 multiclass sve2_int_sadd_long_accum_pairwise<bit U, string asm> {
2319   def _H : sve2_int_sadd_long_accum_pairwise<0b01, U, asm, ZPR16, ZPR8>;
2320   def _S : sve2_int_sadd_long_accum_pairwise<0b10, U, asm, ZPR32, ZPR16>;
2321   def _D : sve2_int_sadd_long_accum_pairwise<0b11, U, asm, ZPR64, ZPR32>;
2324 class sve2_int_un_pred_arit<bits<2> sz, bit Q, bits<2> opc,
2325                             string asm, ZPRRegOp zprty>
2326 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
2327   asm, "\t$Zd, $Pg/m, $Zn",
2328   "",
2329   []>, Sched<[]> {
2330   bits<3> Pg;
2331   bits<5> Zd;
2332   bits<5> Zn;
2333   let Inst{31-24} = 0b01000100;
2334   let Inst{23-22} = sz;
2335   let Inst{21-20} = 0b00;
2336   let Inst{19}    = Q;
2337   let Inst{18}    = 0b0;
2338   let Inst{17-16} = opc;
2339   let Inst{15-13} = 0b101;
2340   let Inst{12-10} = Pg;
2341   let Inst{9-5}   = Zn;
2342   let Inst{4-0}   = Zd;
2344   let Constraints = "$Zd = $_Zd";
2345   let DestructiveInstType = Destructive;
2346   let ElementSize = zprty.ElementSize;
2349 multiclass sve2_int_un_pred_arit_s<bits<3> opc, string asm> {
2350   def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>;
2353 multiclass sve2_int_un_pred_arit<bits<3> opc, string asm> {
2354   def _B : sve2_int_un_pred_arit<0b00, opc{2}, opc{1-0}, asm, ZPR8>;
2355   def _H : sve2_int_un_pred_arit<0b01, opc{2}, opc{1-0}, asm, ZPR16>;
2356   def _S : sve2_int_un_pred_arit<0b10, opc{2}, opc{1-0}, asm, ZPR32>;
2357   def _D : sve2_int_un_pred_arit<0b11, opc{2}, opc{1-0}, asm, ZPR64>;
2360 //===----------------------------------------------------------------------===//
2361 // SVE2 Widening Integer Arithmetic Group
2362 //===----------------------------------------------------------------------===//
2364 class sve2_wide_int_arith<bits<2> sz, bits<5> opc, string asm,
2365                           ZPRRegOp zprty1, ZPRRegOp zprty2, ZPRRegOp zprty3>
2366 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty3:$Zm),
2367   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2368   bits<5> Zd;
2369   bits<5> Zn;
2370   bits<5> Zm;
2371   let Inst{31-24} = 0b01000101;
2372   let Inst{23-22} = sz;
2373   let Inst{21}    = 0b0;
2374   let Inst{20-16} = Zm;
2375   let Inst{15}    = 0b0;
2376   let Inst{14-10} = opc;
2377   let Inst{9-5}   = Zn;
2378   let Inst{4-0}   = Zd;
2381 multiclass sve2_wide_int_arith_long<bits<5> opc, string asm> {
2382   def _H : sve2_wide_int_arith<0b01, opc, asm, ZPR16, ZPR8, ZPR8>;
2383   def _S : sve2_wide_int_arith<0b10, opc, asm, ZPR32, ZPR16, ZPR16>;
2384   def _D : sve2_wide_int_arith<0b11, opc, asm, ZPR64, ZPR32, ZPR32>;
2387 multiclass sve2_wide_int_arith_wide<bits<3> opc, string asm> {
2388   def _H : sve2_wide_int_arith<0b01, { 0b10, opc }, asm, ZPR16, ZPR16, ZPR8>;
2389   def _S : sve2_wide_int_arith<0b10, { 0b10, opc }, asm, ZPR32, ZPR32, ZPR16>;
2390   def _D : sve2_wide_int_arith<0b11, { 0b10, opc }, asm, ZPR64, ZPR64, ZPR32>;
2393 multiclass sve2_pmul_long<bits<1> opc, string asm> {
2394   def _H : sve2_wide_int_arith<0b01, {0b1101, opc}, asm, ZPR16, ZPR8, ZPR8>;
2395   def _D : sve2_wide_int_arith<0b11, {0b1101, opc}, asm, ZPR64, ZPR32, ZPR32>;
2398 //===----------------------------------------------------------------------===//
2399 // SVE2 Misc Group
2400 //===----------------------------------------------------------------------===//
2402 class sve2_misc<bits<2> sz, bits<4> opc, string asm,
2403                 ZPRRegOp zprty1, ZPRRegOp zprty2>
2404 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
2405   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2406   bits<5> Zd;
2407   bits<5> Zn;
2408   bits<5> Zm;
2409   let Inst{31-24} = 0b01000101;
2410   let Inst{23-22} = sz;
2411   let Inst{21}    = 0b0;
2412   let Inst{20-16} = Zm;
2413   let Inst{15-14} = 0b10;
2414   let Inst{13-10} = opc;
2415   let Inst{9-5}   = Zn;
2416   let Inst{4-0}   = Zd;
2419 multiclass sve2_misc_bitwise<bits<4> opc, string asm> {
2420   def _B : sve2_misc<0b00, opc, asm, ZPR8, ZPR8>;
2421   def _H : sve2_misc<0b01, opc, asm, ZPR16, ZPR16>;
2422   def _S : sve2_misc<0b10, opc, asm, ZPR32, ZPR32>;
2423   def _D : sve2_misc<0b11, opc, asm, ZPR64, ZPR64>;
2426 multiclass sve2_misc_int_addsub_long_interleaved<bits<2> opc, string asm> {
2427   def _H : sve2_misc<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
2428   def _S : sve2_misc<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
2429   def _D : sve2_misc<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
2432 class sve2_bitwise_xor_interleaved<bits<2> sz, bits<1> opc, string asm,
2433                                    ZPRRegOp zprty1, ZPRRegOp zprty2>
2434 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
2435   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2436   bits<5> Zd;
2437   bits<5> Zn;
2438   bits<5> Zm;
2439   let Inst{31-24} = 0b01000101;
2440   let Inst{23-22} = sz;
2441   let Inst{21}    = 0b0;
2442   let Inst{20-16} = Zm;
2443   let Inst{15-11} = 0b10010;
2444   let Inst{10}    = opc;
2445   let Inst{9-5}   = Zn;
2446   let Inst{4-0}   = Zd;
2448   let Constraints = "$Zd = $_Zd";
2449   let DestructiveInstType = Destructive;
2450   let ElementSize = ElementSizeNone;
2453 multiclass sve2_bitwise_xor_interleaved<bit opc, string asm> {
2454   def _B : sve2_bitwise_xor_interleaved<0b00, opc, asm, ZPR8,  ZPR8>;
2455   def _H : sve2_bitwise_xor_interleaved<0b01, opc, asm, ZPR16, ZPR16>;
2456   def _S : sve2_bitwise_xor_interleaved<0b10, opc, asm, ZPR32, ZPR32>;
2457   def _D : sve2_bitwise_xor_interleaved<0b11, opc, asm, ZPR64, ZPR64>;
2460 class sve2_bitwise_shift_left_long<bits<3> tsz8_64, bits<2> opc, string asm,
2461                                    ZPRRegOp zprty1, ZPRRegOp zprty2,
2462                                    Operand immtype>
2463 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
2464   asm, "\t$Zd, $Zn, $imm",
2465   "", []>, Sched<[]> {
2466   bits<5> Zd;
2467   bits<5> Zn;
2468   bits<5> imm;
2469   let Inst{31-23} = 0b010001010;
2470   let Inst{22}    = tsz8_64{2};
2471   let Inst{21}    = 0b0;
2472   let Inst{20-19} = tsz8_64{1-0};
2473   let Inst{18-16} = imm{2-0}; // imm3
2474   let Inst{15-12} = 0b1010;
2475   let Inst{11-10} = opc;
2476   let Inst{9-5}   = Zn;
2477   let Inst{4-0}   = Zd;
2480 multiclass sve2_bitwise_shift_left_long<bits<2> opc, string asm> {
2481   def _H : sve2_bitwise_shift_left_long<{0,0,1}, opc, asm,
2482                                         ZPR16, ZPR8, vecshiftL8>;
2483   def _S : sve2_bitwise_shift_left_long<{0,1,?}, opc, asm,
2484                                         ZPR32, ZPR16, vecshiftL16> {
2485     let Inst{19} = imm{3};
2486   }
2487   def _D : sve2_bitwise_shift_left_long<{1,?,?}, opc, asm,
2488                                         ZPR64, ZPR32, vecshiftL32> {
2489     let Inst{20-19} = imm{4-3};
2490   }
2493 //===----------------------------------------------------------------------===//
2494 // SVE2 Accumulate Group
2495 //===----------------------------------------------------------------------===//
2497 class sve2_int_bin_shift_imm<bits<4> tsz8_64, bit opc, string asm,
2498                              ZPRRegOp zprty, Operand immtype>
2499 : I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, immtype:$imm),
2500   asm, "\t$Zd, $Zn, $imm",
2501   "", []>, Sched<[]> {
2502   bits<5> Zd;
2503   bits<5> Zn;
2504   bits<6> imm;
2505   let Inst{31-24} = 0b01000101;
2506   let Inst{23-22} = tsz8_64{3-2};
2507   let Inst{21}    = 0b0;
2508   let Inst{20-19} = tsz8_64{1-0};
2509   let Inst{18-16} = imm{2-0}; // imm3
2510   let Inst{15-11} = 0b11110;
2511   let Inst{10}    = opc;
2512   let Inst{9-5}   = Zn;
2513   let Inst{4-0}   = Zd;
2515   let Constraints = "$Zd = $_Zd";
2518 multiclass sve2_int_bin_shift_imm_left<bit opc, string asm> {
2519   def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
2520   def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
2521     let Inst{19} = imm{3};
2522   }
2523   def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
2524     let Inst{20-19} = imm{4-3};
2525   }
2526   def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
2527     let Inst{22}    = imm{5};
2528     let Inst{20-19} = imm{4-3};
2529   }
2532 multiclass sve2_int_bin_shift_imm_right<bit opc, string asm> {
2533   def _B : sve2_int_bin_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
2534   def _H : sve2_int_bin_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
2535     let Inst{19} = imm{3};
2536   }
2537   def _S : sve2_int_bin_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
2538     let Inst{20-19} = imm{4-3};
2539   }
2540   def _D : sve2_int_bin_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
2541     let Inst{22}    = imm{5};
2542     let Inst{20-19} = imm{4-3};
2543   }
2546 class sve2_int_bin_accum_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
2547                                    ZPRRegOp zprty, Operand immtype>
2548 : I<(outs zprty:$Zda), (ins zprty:$_Zda, zprty:$Zn, immtype:$imm),
2549   asm, "\t$Zda, $Zn, $imm",
2550   "", []>, Sched<[]> {
2551   bits<5> Zda;
2552   bits<5> Zn;
2553   bits<6> imm;
2554   let Inst{31-24} = 0b01000101;
2555   let Inst{23-22} = tsz8_64{3-2};
2556   let Inst{21}    = 0b0;
2557   let Inst{20-19} = tsz8_64{1-0};
2558   let Inst{18-16} = imm{2-0}; // imm3
2559   let Inst{15-12} = 0b1110;
2560   let Inst{11-10} = opc;
2561   let Inst{9-5}   = Zn;
2562   let Inst{4-0}   = Zda;
2564   let Constraints = "$Zda = $_Zda";
2565   let DestructiveInstType = Destructive;
2566   let ElementSize = ElementSizeNone;
2569 multiclass sve2_int_bin_accum_shift_imm_right<bits<2> opc, string asm> {
2570   def _B : sve2_int_bin_accum_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
2571   def _H : sve2_int_bin_accum_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
2572     let Inst{19} = imm{3};
2573   }
2574   def _S : sve2_int_bin_accum_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
2575     let Inst{20-19} = imm{4-3};
2576   }
2577   def _D : sve2_int_bin_accum_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
2578     let Inst{22}    = imm{5};
2579     let Inst{20-19} = imm{4-3};
2580   }
2583 class sve2_int_cadd<bits<2> sz, bit opc, string asm, ZPRRegOp zprty>
2584 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, complexrotateopodd:$rot),
2585   asm, "\t$Zdn, $_Zdn, $Zm, $rot", "", []>, Sched<[]> {
2586   bits<5> Zdn;
2587   bits<5> Zm;
2588   bit rot;
2589   let Inst{31-24} = 0b01000101;
2590   let Inst{23-22} = sz;
2591   let Inst{21-17} = 0b00000;
2592   let Inst{16}    = opc;
2593   let Inst{15-11} = 0b11011;
2594   let Inst{10}    = rot;
2595   let Inst{9-5}   = Zm;
2596   let Inst{4-0}   = Zdn;
2598   let Constraints = "$Zdn = $_Zdn";
2599   let DestructiveInstType = Destructive;
2600   let ElementSize = ElementSizeNone;
2603 multiclass sve2_int_cadd<bit opc, string asm> {
2604   def _B : sve2_int_cadd<0b00, opc, asm, ZPR8>;
2605   def _H : sve2_int_cadd<0b01, opc, asm, ZPR16>;
2606   def _S : sve2_int_cadd<0b10, opc, asm, ZPR32>;
2607   def _D : sve2_int_cadd<0b11, opc, asm, ZPR64>;
2610 class sve2_int_absdiff_accum<bits<2> sz, bits<4> opc, string asm,
2611                              ZPRRegOp zprty1, ZPRRegOp zprty2>
2612 : I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm),
2613   asm, "\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
2614   bits<5> Zda;
2615   bits<5> Zn;
2616   bits<5> Zm;
2617   let Inst{31-24} = 0b01000101;
2618   let Inst{23-22} = sz;
2619   let Inst{21}    = 0b0;
2620   let Inst{20-16} = Zm;
2621   let Inst{15-14} = 0b11;
2622   let Inst{13-10} = opc;
2623   let Inst{9-5}   = Zn;
2624   let Inst{4-0}   = Zda;
2626   let Constraints = "$Zda = $_Zda";
2627   let DestructiveInstType = Destructive;
2628   let ElementSize = ElementSizeNone;
2631 multiclass sve2_int_absdiff_accum<bit opc, string asm> {
2632   def _B : sve2_int_absdiff_accum<0b00, { 0b111, opc }, asm, ZPR8, ZPR8>;
2633   def _H : sve2_int_absdiff_accum<0b01, { 0b111, opc }, asm, ZPR16, ZPR16>;
2634   def _S : sve2_int_absdiff_accum<0b10, { 0b111, opc }, asm, ZPR32, ZPR32>;
2635   def _D : sve2_int_absdiff_accum<0b11, { 0b111, opc }, asm, ZPR64, ZPR64>;
2638 multiclass sve2_int_absdiff_accum_long<bits<2> opc, string asm> {
2639   def _H : sve2_int_absdiff_accum<0b01, { 0b00, opc }, asm, ZPR16, ZPR8>;
2640   def _S : sve2_int_absdiff_accum<0b10, { 0b00, opc }, asm, ZPR32, ZPR16>;
2641   def _D : sve2_int_absdiff_accum<0b11, { 0b00, opc }, asm, ZPR64, ZPR32>;
2644 multiclass sve2_int_addsub_long_carry<bits<2> opc, string asm> {
2645   def _S : sve2_int_absdiff_accum<{ opc{1}, 0b0 }, { 0b010, opc{0} }, asm,
2646                                   ZPR32, ZPR32>;
2647   def _D : sve2_int_absdiff_accum<{ opc{1}, 0b1 }, { 0b010, opc{0} }, asm,
2648                                   ZPR64, ZPR64>;
2651 //===----------------------------------------------------------------------===//
2652 // SVE2 Narrowing Group
2653 //===----------------------------------------------------------------------===//
2655 class sve2_int_bin_shift_imm_narrow_bottom<bits<3> tsz8_64, bits<3> opc,
2656                                            string asm, ZPRRegOp zprty1,
2657                                            ZPRRegOp zprty2, Operand immtype>
2658 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, immtype:$imm),
2659   asm, "\t$Zd, $Zn, $imm",
2660   "", []>, Sched<[]> {
2661   bits<5> Zd;
2662   bits<5> Zn;
2663   bits<5> imm;
2664   let Inst{31-23} = 0b010001010;
2665   let Inst{22}    = tsz8_64{2};
2666   let Inst{21}    = 0b1;
2667   let Inst{20-19} = tsz8_64{1-0};
2668   let Inst{18-16} = imm{2-0}; // imm3
2669   let Inst{15-14} = 0b00;
2670   let Inst{13-11} = opc;
2671   let Inst{10}    = 0b0;
2672   let Inst{9-5}   = Zn;
2673   let Inst{4-0}   = Zd;
2676 multiclass sve2_int_bin_shift_imm_right_narrow_bottom<bits<3> opc, string asm> {
2677   def _B : sve2_int_bin_shift_imm_narrow_bottom<{0,0,1}, opc, asm, ZPR8, ZPR16,
2678                                                 vecshiftR8>;
2679   def _H : sve2_int_bin_shift_imm_narrow_bottom<{0,1,?}, opc, asm, ZPR16, ZPR32,
2680                                                 vecshiftR16> {
2681     let Inst{19} = imm{3};
2682   }
2683   def _S : sve2_int_bin_shift_imm_narrow_bottom<{1,?,?}, opc, asm, ZPR32, ZPR64,
2684                                                 vecshiftR32> {
2685     let Inst{20-19} = imm{4-3};
2686   }
2689 class sve2_int_bin_shift_imm_narrow_top<bits<3> tsz8_64, bits<3> opc,
2690                                         string asm, ZPRRegOp zprty1,
2691                                         ZPRRegOp zprty2, Operand immtype>
2692 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, immtype:$imm),
2693   asm, "\t$Zd, $Zn, $imm",
2694   "", []>, Sched<[]> {
2695   bits<5> Zd;
2696   bits<5> Zn;
2697   bits<5> imm;
2698   let Inst{31-23} = 0b010001010;
2699   let Inst{22}    = tsz8_64{2};
2700   let Inst{21}    = 0b1;
2701   let Inst{20-19} = tsz8_64{1-0};
2702   let Inst{18-16} = imm{2-0}; // imm3
2703   let Inst{15-14} = 0b00;
2704   let Inst{13-11} = opc;
2705   let Inst{10}    = 0b1;
2706   let Inst{9-5}   = Zn;
2707   let Inst{4-0}   = Zd;
2709   let Constraints = "$Zd = $_Zd";
2712 multiclass sve2_int_bin_shift_imm_right_narrow_top<bits<3> opc, string asm> {
2713   def _B : sve2_int_bin_shift_imm_narrow_top<{0,0,1}, opc, asm, ZPR8, ZPR16,
2714                                              vecshiftR8>;
2715   def _H : sve2_int_bin_shift_imm_narrow_top<{0,1,?}, opc, asm, ZPR16, ZPR32,
2716                                              vecshiftR16> {
2717     let Inst{19} = imm{3};
2718   }
2719   def _S : sve2_int_bin_shift_imm_narrow_top<{1,?,?}, opc, asm, ZPR32, ZPR64,
2720                                              vecshiftR32> {
2721     let Inst{20-19} = imm{4-3};
2722   }
2725 class sve2_int_addsub_narrow_high_bottom<bits<2> sz, bits<2> opc, string asm,
2726                                          ZPRRegOp zprty1, ZPRRegOp zprty2>
2727 : I<(outs zprty1:$Zd), (ins zprty2:$Zn, zprty2:$Zm),
2728   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2729   bits<5> Zd;
2730   bits<5> Zn;
2731   bits<5> Zm;
2732   let Inst{31-24} = 0b01000101;
2733   let Inst{23-22} = sz;
2734   let Inst{21}    = 0b1;
2735   let Inst{20-16} = Zm;
2736   let Inst{15-13} = 0b011;
2737   let Inst{12-11} = opc; // S, R
2738   let Inst{10}    = 0b0; // Top
2739   let Inst{9-5}   = Zn;
2740   let Inst{4-0}   = Zd;
2743 multiclass sve2_int_addsub_narrow_high_bottom<bits<2> opc, string asm> {
2744   def _B : sve2_int_addsub_narrow_high_bottom<0b01, opc, asm, ZPR8, ZPR16>;
2745   def _H : sve2_int_addsub_narrow_high_bottom<0b10, opc, asm, ZPR16, ZPR32>;
2746   def _S : sve2_int_addsub_narrow_high_bottom<0b11, opc, asm, ZPR32, ZPR64>;
2749 class sve2_int_addsub_narrow_high_top<bits<2> sz, bits<2> opc, string asm,
2750                                       ZPRRegOp zprty1, ZPRRegOp zprty2>
2751 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn, zprty2:$Zm),
2752   asm, "\t$Zd, $Zn, $Zm", "", []>, Sched<[]> {
2753   bits<5> Zd;
2754   bits<5> Zn;
2755   bits<5> Zm;
2756   let Inst{31-24} = 0b01000101;
2757   let Inst{23-22} = sz;
2758   let Inst{21}    = 0b1;
2759   let Inst{20-16} = Zm;
2760   let Inst{15-13} = 0b011;
2761   let Inst{12-11} = opc; // S, R
2762   let Inst{10}    = 0b1; // Top
2763   let Inst{9-5}   = Zn;
2764   let Inst{4-0}   = Zd;
2766   let Constraints = "$Zd = $_Zd";
2769 multiclass sve2_int_addsub_narrow_high_top<bits<2> opc, string asm> {
2770   def _B : sve2_int_addsub_narrow_high_top<0b01, opc, asm, ZPR8, ZPR16>;
2771   def _H : sve2_int_addsub_narrow_high_top<0b10, opc, asm, ZPR16, ZPR32>;
2772   def _S : sve2_int_addsub_narrow_high_top<0b11, opc, asm, ZPR32, ZPR64>;
2775 class sve2_int_sat_extract_narrow_bottom<bits<3> tsz8_64, bits<2> opc, string asm,
2776                                          ZPRRegOp zprty1, ZPRRegOp zprty2>
2777 : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
2778   asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
2779   bits<5> Zd;
2780   bits<5> Zn;
2781   let Inst{31-23} = 0b010001010;
2782   let Inst{22}    = tsz8_64{2};
2783   let Inst{21}    = 0b1;
2784   let Inst{20-19} = tsz8_64{1-0};
2785   let Inst{18-13} = 0b000010;
2786   let Inst{12-11} = opc;
2787   let Inst{10}    = 0b0;
2788   let Inst{9-5}   = Zn;
2789   let Inst{4-0}   = Zd;
2792 multiclass sve2_int_sat_extract_narrow_bottom<bits<2> opc, string asm> {
2793   def _B : sve2_int_sat_extract_narrow_bottom<0b001, opc, asm, ZPR8, ZPR16>;
2794   def _H : sve2_int_sat_extract_narrow_bottom<0b010, opc, asm, ZPR16, ZPR32>;
2795   def _S : sve2_int_sat_extract_narrow_bottom<0b100, opc, asm, ZPR32, ZPR64>;
2798 class sve2_int_sat_extract_narrow_top<bits<3> tsz8_64, bits<2> opc, string asm,
2799                                       ZPRRegOp zprty1, ZPRRegOp zprty2>
2800 : I<(outs zprty1:$Zd), (ins zprty1:$_Zd, zprty2:$Zn),
2801   asm, "\t$Zd, $Zn", "", []>, Sched<[]> {
2802   bits<5> Zd;
2803   bits<5> Zn;
2804   let Inst{31-23} = 0b010001010;
2805   let Inst{22}    = tsz8_64{2};
2806   let Inst{21}    = 0b1;
2807   let Inst{20-19} = tsz8_64{1-0};
2808   let Inst{18-13} = 0b000010;
2809   let Inst{12-11} = opc;
2810   let Inst{10}    = 0b1;
2811   let Inst{9-5}   = Zn;
2812   let Inst{4-0}   = Zd;
2814   let Constraints = "$Zd = $_Zd";
2817 multiclass sve2_int_sat_extract_narrow_top<bits<2> opc, string asm> {
2818   def _B : sve2_int_sat_extract_narrow_top<0b001, opc, asm, ZPR8, ZPR16>;
2819   def _H : sve2_int_sat_extract_narrow_top<0b010, opc, asm, ZPR16, ZPR32>;
2820   def _S : sve2_int_sat_extract_narrow_top<0b100, opc, asm, ZPR32, ZPR64>;
2823 //===----------------------------------------------------------------------===//
2824 // SVE Integer Arithmetic - Unary Predicated Group
2825 //===----------------------------------------------------------------------===//
2827 class sve_int_un_pred_arit<bits<2> sz8_64, bits<4> opc,
2828                              string asm, ZPRRegOp zprty>
2829 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
2830   asm, "\t$Zd, $Pg/m, $Zn",
2831   "",
2832   []>, Sched<[]> {
2833   bits<3> Pg;
2834   bits<5> Zd;
2835   bits<5> Zn;
2836   let Inst{31-24} = 0b00000100;
2837   let Inst{23-22} = sz8_64;
2838   let Inst{21-20} = 0b01;
2839   let Inst{19}    = opc{0};
2840   let Inst{18-16} = opc{3-1};
2841   let Inst{15-13} = 0b101;
2842   let Inst{12-10} = Pg;
2843   let Inst{9-5}   = Zn;
2844   let Inst{4-0}   = Zd;
2846   let Constraints = "$Zd = $_Zd";
2847   let DestructiveInstType = Destructive;
2848   let ElementSize = zprty.ElementSize;
2851 multiclass sve_int_un_pred_arit_0<bits<3> opc, string asm,
2852                                   SDPatternOperator op> {
2853   def _B : sve_int_un_pred_arit<0b00, { opc, 0b0 }, asm, ZPR8>;
2854   def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>;
2855   def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>;
2856   def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>;
2858   def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i1, nxv16i8, !cast<Instruction>(NAME # _B)>;
2859   def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i1,  nxv8i16, !cast<Instruction>(NAME # _H)>;
2860   def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i1,  nxv4i32, !cast<Instruction>(NAME # _S)>;
2861   def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i1,  nxv2i64, !cast<Instruction>(NAME # _D)>;
2864 multiclass sve_int_un_pred_arit_0_h<bits<3> opc, string asm> {
2865   def _H : sve_int_un_pred_arit<0b01, { opc, 0b0 }, asm, ZPR16>;
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_w<bits<3> opc, string asm> {
2871   def _S : sve_int_un_pred_arit<0b10, { opc, 0b0 }, asm, ZPR32>;
2872   def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>;
2875 multiclass sve_int_un_pred_arit_0_d<bits<3> opc, string asm> {
2876   def _D : sve_int_un_pred_arit<0b11, { opc, 0b0 }, asm, ZPR64>;
2879 multiclass sve_int_un_pred_arit_1<bits<3> opc, string asm> {
2880   def _B : sve_int_un_pred_arit<0b00, { opc, 0b1 }, asm, ZPR8>;
2881   def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>;
2882   def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>;
2883   def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>;
2886 multiclass sve_int_un_pred_arit_1_fp<bits<3> opc, string asm> {
2887   def _H : sve_int_un_pred_arit<0b01, { opc, 0b1 }, asm, ZPR16>;
2888   def _S : sve_int_un_pred_arit<0b10, { opc, 0b1 }, asm, ZPR32>;
2889   def _D : sve_int_un_pred_arit<0b11, { opc, 0b1 }, asm, ZPR64>;
2892 //===----------------------------------------------------------------------===//
2893 // SVE Integer Wide Immediate - Unpredicated Group
2894 //===----------------------------------------------------------------------===//
2895 class sve_int_dup_imm<bits<2> sz8_64, string asm,
2896                       ZPRRegOp zprty, Operand immtype>
2897 : I<(outs zprty:$Zd), (ins immtype:$imm),
2898   asm, "\t$Zd, $imm",
2899   "",
2900   []>, Sched<[]> {
2901   bits<5> Zd;
2902   bits<9> imm;
2903   let Inst{31-24} = 0b00100101;
2904   let Inst{23-22} = sz8_64;
2905   let Inst{21-14} = 0b11100011;
2906   let Inst{13}    = imm{8};   // sh
2907   let Inst{12-5}  = imm{7-0}; // imm8
2908   let Inst{4-0}   = Zd;
2910   let isReMaterializable = 1;
2913 multiclass sve_int_dup_imm<string asm> {
2914   def _B : sve_int_dup_imm<0b00, asm, ZPR8, cpy_imm8_opt_lsl_i8>;
2915   def _H : sve_int_dup_imm<0b01, asm, ZPR16, cpy_imm8_opt_lsl_i16>;
2916   def _S : sve_int_dup_imm<0b10, asm, ZPR32, cpy_imm8_opt_lsl_i32>;
2917   def _D : sve_int_dup_imm<0b11, asm, ZPR64, cpy_imm8_opt_lsl_i64>;
2919   def : InstAlias<"mov $Zd, $imm",
2920                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, cpy_imm8_opt_lsl_i8:$imm), 1>;
2921   def : InstAlias<"mov $Zd, $imm",
2922                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, cpy_imm8_opt_lsl_i16:$imm), 1>;
2923   def : InstAlias<"mov $Zd, $imm",
2924                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, cpy_imm8_opt_lsl_i32:$imm), 1>;
2925   def : InstAlias<"mov $Zd, $imm",
2926                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, cpy_imm8_opt_lsl_i64:$imm), 1>;
2928   def : InstAlias<"fmov $Zd, #0.0",
2929                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, 0, 0), 1>;
2930   def : InstAlias<"fmov $Zd, #0.0",
2931                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, 0, 0), 1>;
2932   def : InstAlias<"fmov $Zd, #0.0",
2933                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, 0, 0), 1>;
2936 class sve_int_dup_fpimm<bits<2> sz8_64, Operand fpimmtype,
2937                         string asm, ZPRRegOp zprty>
2938 : I<(outs zprty:$Zd), (ins fpimmtype:$imm8),
2939   asm, "\t$Zd, $imm8",
2940   "",
2941   []>, Sched<[]> {
2942   bits<5> Zd;
2943   bits<8> imm8;
2944   let Inst{31-24} = 0b00100101;
2945   let Inst{23-22} = sz8_64;
2946   let Inst{21-14} = 0b11100111;
2947   let Inst{13}    = 0b0;
2948   let Inst{12-5}  = imm8;
2949   let Inst{4-0}   = Zd;
2951   let isReMaterializable = 1;
2954 multiclass sve_int_dup_fpimm<string asm> {
2955   def _H : sve_int_dup_fpimm<0b01, fpimm16, asm, ZPR16>;
2956   def _S : sve_int_dup_fpimm<0b10, fpimm32, asm, ZPR32>;
2957   def _D : sve_int_dup_fpimm<0b11, fpimm64, asm, ZPR64>;
2959   def : InstAlias<"fmov $Zd, $imm8",
2960                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, fpimm16:$imm8), 1>;
2961   def : InstAlias<"fmov $Zd, $imm8",
2962                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, fpimm32:$imm8), 1>;
2963   def : InstAlias<"fmov $Zd, $imm8",
2964                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, fpimm64:$imm8), 1>;
2967 class sve_int_arith_imm0<bits<2> sz8_64, bits<3> opc, string asm,
2968                          ZPRRegOp zprty, Operand immtype>
2969 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
2970   asm, "\t$Zdn, $_Zdn, $imm",
2971   "",
2972   []>, Sched<[]> {
2973   bits<5> Zdn;
2974   bits<9> imm;
2975   let Inst{31-24} = 0b00100101;
2976   let Inst{23-22} = sz8_64;
2977   let Inst{21-19} = 0b100;
2978   let Inst{18-16} = opc;
2979   let Inst{15-14} = 0b11;
2980   let Inst{13}    = imm{8};   // sh
2981   let Inst{12-5}  = imm{7-0}; // imm8
2982   let Inst{4-0}   = Zdn;
2984   let Constraints = "$Zdn = $_Zdn";
2985   let DestructiveInstType = Destructive;
2986   let ElementSize = ElementSizeNone;
2989 multiclass sve_int_arith_imm0<bits<3> opc, string asm> {
2990   def _B : sve_int_arith_imm0<0b00, opc, asm, ZPR8, addsub_imm8_opt_lsl_i8>;
2991   def _H : sve_int_arith_imm0<0b01, opc, asm, ZPR16, addsub_imm8_opt_lsl_i16>;
2992   def _S : sve_int_arith_imm0<0b10, opc, asm, ZPR32, addsub_imm8_opt_lsl_i32>;
2993   def _D : sve_int_arith_imm0<0b11, opc, asm, ZPR64, addsub_imm8_opt_lsl_i64>;
2996 class sve_int_arith_imm<bits<2> sz8_64, bits<6> opc, string asm,
2997                         ZPRRegOp zprty, Operand immtype>
2998 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, immtype:$imm),
2999   asm, "\t$Zdn, $_Zdn, $imm",
3000   "",
3001   []>, Sched<[]> {
3002   bits<5> Zdn;
3003   bits<8> imm;
3004   let Inst{31-24} = 0b00100101;
3005   let Inst{23-22} = sz8_64;
3006   let Inst{21-16} = opc;
3007   let Inst{15-13} = 0b110;
3008   let Inst{12-5} = imm;
3009   let Inst{4-0} = Zdn;
3011   let Constraints = "$Zdn = $_Zdn";
3012   let DestructiveInstType = Destructive;
3013   let ElementSize = ElementSizeNone;
3016 multiclass sve_int_arith_imm1<bits<2> opc, string asm, Operand immtype> {
3017   def _B : sve_int_arith_imm<0b00, { 0b1010, opc }, asm, ZPR8, immtype>;
3018   def _H : sve_int_arith_imm<0b01, { 0b1010, opc }, asm, ZPR16, immtype>;
3019   def _S : sve_int_arith_imm<0b10, { 0b1010, opc }, asm, ZPR32, immtype>;
3020   def _D : sve_int_arith_imm<0b11, { 0b1010, opc }, asm, ZPR64, immtype>;
3023 multiclass sve_int_arith_imm2<string asm> {
3024   def _B : sve_int_arith_imm<0b00, 0b110000, asm, ZPR8,  simm8>;
3025   def _H : sve_int_arith_imm<0b01, 0b110000, asm, ZPR16, simm8>;
3026   def _S : sve_int_arith_imm<0b10, 0b110000, asm, ZPR32, simm8>;
3027   def _D : sve_int_arith_imm<0b11, 0b110000, asm, ZPR64, simm8>;
3030 //===----------------------------------------------------------------------===//
3031 // SVE Bitwise Logical - Unpredicated Group
3032 //===----------------------------------------------------------------------===//
3034 class sve_int_bin_cons_log<bits<2> opc, string asm>
3035 : I<(outs ZPR64:$Zd), (ins ZPR64:$Zn, ZPR64:$Zm),
3036   asm, "\t$Zd, $Zn, $Zm",
3037   "",
3038   []>, Sched<[]> {
3039   bits<5> Zd;
3040   bits<5> Zm;
3041   bits<5> Zn;
3042   let Inst{31-24} = 0b00000100;
3043   let Inst{23-22} = opc{1-0};
3044   let Inst{21}    = 0b1;
3045   let Inst{20-16} = Zm;
3046   let Inst{15-10} = 0b001100;
3047   let Inst{9-5}   = Zn;
3048   let Inst{4-0}   = Zd;
3051 multiclass sve_int_bin_cons_log<bits<2> opc, string asm> {
3052   def NAME : sve_int_bin_cons_log<opc, asm>;
3054   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
3055                   (!cast<Instruction>(NAME) ZPR8:$Zd,  ZPR8:$Zn,  ZPR8:$Zm),  1>;
3056   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
3057                   (!cast<Instruction>(NAME) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 1>;
3058   def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
3059                   (!cast<Instruction>(NAME) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 1>;
3062 class sve2_int_bitwise_ternary_op_d<bits<3> opc, string asm>
3063 : I<(outs ZPR64:$Zdn), (ins ZPR64:$_Zdn, ZPR64:$Zm, ZPR64:$Zk),
3064   asm, "\t$Zdn, $_Zdn, $Zm, $Zk",
3065   "",
3066   []>, Sched<[]> {
3067   bits<5> Zdn;
3068   bits<5> Zk;
3069   bits<5> Zm;
3070   let Inst{31-24} = 0b00000100;
3071   let Inst{23-22} = opc{2-1};
3072   let Inst{21}    = 0b1;
3073   let Inst{20-16} = Zm;
3074   let Inst{15-11} = 0b00111;
3075   let Inst{10}    = opc{0};
3076   let Inst{9-5}   = Zk;
3077   let Inst{4-0}   = Zdn;
3079   let Constraints = "$Zdn = $_Zdn";
3080   let DestructiveInstType = Destructive;
3081   let ElementSize = ElementSizeNone;
3084 multiclass sve2_int_bitwise_ternary_op<bits<3> opc, string asm> {
3085   def NAME : sve2_int_bitwise_ternary_op_d<opc, asm>;
3087   def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
3088                   (!cast<Instruction>(NAME) ZPR8:$Zdn,  ZPR8:$Zm,  ZPR8:$Zk),  1>;
3089   def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
3090                   (!cast<Instruction>(NAME) ZPR16:$Zdn, ZPR16:$Zm, ZPR16:$Zk), 1>;
3091   def : InstAlias<asm # "\t$Zdn, $Zdn, $Zm, $Zk",
3092                   (!cast<Instruction>(NAME) ZPR32:$Zdn, ZPR32:$Zm, ZPR32:$Zk), 1>;
3095 class sve2_int_rotate_right_imm<bits<4> tsz8_64, string asm,
3096                                 ZPRRegOp zprty, Operand immtype>
3097 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm, immtype:$imm),
3098   asm, "\t$Zdn, $_Zdn, $Zm, $imm",
3099   "",
3100   []>, Sched<[]> {
3101   bits<5> Zdn;
3102   bits<5> Zm;
3103   bits<6> imm;
3104   let Inst{31-24} = 0b00000100;
3105   let Inst{23-22} = tsz8_64{3-2};
3106   let Inst{21}    = 0b1;
3107   let Inst{20-19} = tsz8_64{1-0};
3108   let Inst{18-16} = imm{2-0}; // imm3
3109   let Inst{15-10} = 0b001101;
3110   let Inst{9-5}   = Zm;
3111   let Inst{4-0}   = Zdn;
3113   let Constraints = "$Zdn = $_Zdn";
3114   let DestructiveInstType = Destructive;
3115   let ElementSize = ElementSizeNone;
3118 multiclass sve2_int_rotate_right_imm<string asm> {
3119   def _B : sve2_int_rotate_right_imm<{0,0,0,1}, asm, ZPR8, vecshiftR8>;
3120   def _H : sve2_int_rotate_right_imm<{0,0,1,?}, asm, ZPR16, vecshiftR16> {
3121     let Inst{19} = imm{3};
3122   }
3123   def _S : sve2_int_rotate_right_imm<{0,1,?,?}, asm, ZPR32, vecshiftR32> {
3124     let Inst{20-19} = imm{4-3};
3125   }
3126   def _D : sve2_int_rotate_right_imm<{1,?,?,?}, asm, ZPR64, vecshiftR64> {
3127     let Inst{22}    = imm{5};
3128     let Inst{20-19} = imm{4-3};
3129   }
3132 //===----------------------------------------------------------------------===//
3133 // SVE Integer Wide Immediate - Predicated Group
3134 //===----------------------------------------------------------------------===//
3136 class sve_int_dup_fpimm_pred<bits<2> sz, Operand fpimmtype,
3137                              string asm, ZPRRegOp zprty>
3138 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPRAny:$Pg, fpimmtype:$imm8),
3139   asm, "\t$Zd, $Pg/m, $imm8",
3140   "",
3141   []>, Sched<[]> {
3142   bits<4> Pg;
3143   bits<5> Zd;
3144   bits<8> imm8;
3145   let Inst{31-24} = 0b00000101;
3146   let Inst{23-22} = sz;
3147   let Inst{21-20} = 0b01;
3148   let Inst{19-16} = Pg;
3149   let Inst{15-13} = 0b110;
3150   let Inst{12-5}  = imm8;
3151   let Inst{4-0}   = Zd;
3153   let Constraints = "$Zd = $_Zd";
3154   let DestructiveInstType = Destructive;
3155   let ElementSize = zprty.ElementSize;
3158 multiclass sve_int_dup_fpimm_pred<string asm> {
3159   def _H : sve_int_dup_fpimm_pred<0b01, fpimm16, asm, ZPR16>;
3160   def _S : sve_int_dup_fpimm_pred<0b10, fpimm32, asm, ZPR32>;
3161   def _D : sve_int_dup_fpimm_pred<0b11, fpimm64, asm, ZPR64>;
3163   def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
3164                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, fpimm16:$imm8), 1>;
3165   def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
3166                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, fpimm32:$imm8), 1>;
3167   def : InstAlias<"fmov $Zd, $Pg/m, $imm8",
3168                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, fpimm64:$imm8), 1>;
3171 class sve_int_dup_imm_pred<bits<2> sz8_64, bit m, string asm,
3172                            ZPRRegOp zprty, string pred_qual, dag iops>
3173 : I<(outs zprty:$Zd), iops,
3174   asm, "\t$Zd, $Pg"#pred_qual#", $imm",
3175   "", []>, Sched<[]> {
3176   bits<5> Zd;
3177   bits<4> Pg;
3178   bits<9> imm;
3179   let Inst{31-24} = 0b00000101;
3180   let Inst{23-22} = sz8_64;
3181   let Inst{21-20} = 0b01;
3182   let Inst{19-16} = Pg;
3183   let Inst{15}    = 0b0;
3184   let Inst{14}    = m;
3185   let Inst{13}    = imm{8};   // sh
3186   let Inst{12-5}  = imm{7-0}; // imm8
3187   let Inst{4-0}   = Zd;
3189   let DestructiveInstType = Destructive;
3190   let ElementSize = zprty.ElementSize;
3193 multiclass sve_int_dup_imm_pred_merge<string asm> {
3194   let Constraints = "$Zd = $_Zd" in {
3195   def _B : sve_int_dup_imm_pred<0b00, 1, asm, ZPR8,  "/m", (ins ZPR8:$_Zd,  PPRAny:$Pg, cpy_imm8_opt_lsl_i8:$imm)>;
3196   def _H : sve_int_dup_imm_pred<0b01, 1, asm, ZPR16, "/m", (ins ZPR16:$_Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i16:$imm)>;
3197   def _S : sve_int_dup_imm_pred<0b10, 1, asm, ZPR32, "/m", (ins ZPR32:$_Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i32:$imm)>;
3198   def _D : sve_int_dup_imm_pred<0b11, 1, asm, ZPR64, "/m", (ins ZPR64:$_Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i64:$imm)>;
3199   }
3201   def : InstAlias<"mov $Zd, $Pg/m, $imm",
3202                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd,  PPRAny:$Pg, cpy_imm8_opt_lsl_i8:$imm), 1>;
3203   def : InstAlias<"mov $Zd, $Pg/m, $imm",
3204                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i16:$imm), 1>;
3205   def : InstAlias<"mov $Zd, $Pg/m, $imm",
3206                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i32:$imm), 1>;
3207   def : InstAlias<"mov $Zd, $Pg/m, $imm",
3208                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i64:$imm), 1>;
3210   def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
3211                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, 0, 0), 0>;
3212   def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
3213                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, 0, 0), 0>;
3214   def : InstAlias<"fmov $Zd, $Pg/m, #0.0",
3215                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, 0, 0), 0>;
3218 multiclass sve_int_dup_imm_pred_zero<string asm> {
3219   def _B : sve_int_dup_imm_pred<0b00, 0, asm, ZPR8,  "/z", (ins PPRAny:$Pg, cpy_imm8_opt_lsl_i8:$imm)>;
3220   def _H : sve_int_dup_imm_pred<0b01, 0, asm, ZPR16, "/z", (ins PPRAny:$Pg, cpy_imm8_opt_lsl_i16:$imm)>;
3221   def _S : sve_int_dup_imm_pred<0b10, 0, asm, ZPR32, "/z", (ins PPRAny:$Pg, cpy_imm8_opt_lsl_i32:$imm)>;
3222   def _D : sve_int_dup_imm_pred<0b11, 0, asm, ZPR64, "/z", (ins PPRAny:$Pg, cpy_imm8_opt_lsl_i64:$imm)>;
3224   def : InstAlias<"mov $Zd, $Pg/z, $imm",
3225                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd,  PPRAny:$Pg, cpy_imm8_opt_lsl_i8:$imm), 1>;
3226   def : InstAlias<"mov $Zd, $Pg/z, $imm",
3227                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i16:$imm), 1>;
3228   def : InstAlias<"mov $Zd, $Pg/z, $imm",
3229                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i32:$imm), 1>;
3230   def : InstAlias<"mov $Zd, $Pg/z, $imm",
3231                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPRAny:$Pg, cpy_imm8_opt_lsl_i64:$imm), 1>;
3234 //===----------------------------------------------------------------------===//
3235 // SVE Integer Compare - Vectors Group
3236 //===----------------------------------------------------------------------===//
3238 class sve_int_cmp<bit cmp_1, bits<2> sz8_64, bits<3> opc, string asm,
3239                   PPRRegOp pprty, ZPRRegOp zprty1, ZPRRegOp zprty2>
3240 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty1:$Zn, zprty2:$Zm),
3241   asm, "\t$Pd, $Pg/z, $Zn, $Zm",
3242   "",
3243   []>, Sched<[]> {
3244   bits<4> Pd;
3245   bits<3> Pg;
3246   bits<5> Zm;
3247   bits<5> Zn;
3248   let Inst{31-24} = 0b00100100;
3249   let Inst{23-22} = sz8_64;
3250   let Inst{21}    = 0b0;
3251   let Inst{20-16} = Zm;
3252   let Inst{15}    = opc{2};
3253   let Inst{14}    = cmp_1;
3254   let Inst{13}    = opc{1};
3255   let Inst{12-10} = Pg;
3256   let Inst{9-5}   = Zn;
3257   let Inst{4}     = opc{0};
3258   let Inst{3-0}   = Pd;
3260   let Defs = [NZCV];
3263 multiclass sve_int_cmp_0<bits<3> opc, string asm> {
3264   def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR8>;
3265   def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR16>;
3266   def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR32>;
3267   def _D : sve_int_cmp<0b0, 0b11, opc, asm, PPR64, ZPR64, ZPR64>;
3270 multiclass sve_int_cmp_0_wide<bits<3> opc, string asm> {
3271   def _B : sve_int_cmp<0b0, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
3272   def _H : sve_int_cmp<0b0, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
3273   def _S : sve_int_cmp<0b0, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
3276 multiclass sve_int_cmp_1_wide<bits<3> opc, string asm> {
3277   def _B : sve_int_cmp<0b1, 0b00, opc, asm, PPR8, ZPR8, ZPR64>;
3278   def _H : sve_int_cmp<0b1, 0b01, opc, asm, PPR16, ZPR16, ZPR64>;
3279   def _S : sve_int_cmp<0b1, 0b10, opc, asm, PPR32, ZPR32, ZPR64>;
3283 //===----------------------------------------------------------------------===//
3284 // SVE Integer Compare - Signed Immediate Group
3285 //===----------------------------------------------------------------------===//
3287 class sve_int_scmp_vi<bits<2> sz8_64, bits<3> opc, string asm, PPRRegOp pprty,
3288                       ZPRRegOp zprty,
3289                       Operand immtype>
3290 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm5),
3291   asm, "\t$Pd, $Pg/z, $Zn, $imm5",
3292   "",
3293   []>, Sched<[]> {
3294   bits<4> Pd;
3295   bits<3> Pg;
3296   bits<5> Zn;
3297   bits<5> imm5;
3298   let Inst{31-24} = 0b00100101;
3299   let Inst{23-22} = sz8_64;
3300   let Inst{21}    = 0b0;
3301   let Inst{20-16} = imm5;
3302   let Inst{15}    = opc{2};
3303   let Inst{14}    = 0b0;
3304   let Inst{13}    = opc{1};
3305   let Inst{12-10} = Pg;
3306   let Inst{9-5}   = Zn;
3307   let Inst{4}     = opc{0};
3308   let Inst{3-0}   = Pd;
3310   let Defs = [NZCV];
3313 multiclass sve_int_scmp_vi<bits<3> opc, string asm> {
3314   def _B : sve_int_scmp_vi<0b00, opc, asm, PPR8, ZPR8, simm5_32b>;
3315   def _H : sve_int_scmp_vi<0b01, opc, asm, PPR16, ZPR16, simm5_32b>;
3316   def _S : sve_int_scmp_vi<0b10, opc, asm, PPR32, ZPR32, simm5_32b>;
3317   def _D : sve_int_scmp_vi<0b11, opc, asm, PPR64, ZPR64, simm5_64b>;
3321 //===----------------------------------------------------------------------===//
3322 // SVE Integer Compare - Unsigned Immediate Group
3323 //===----------------------------------------------------------------------===//
3325 class sve_int_ucmp_vi<bits<2> sz8_64, bits<2> opc, string asm, PPRRegOp pprty,
3326                       ZPRRegOp zprty, Operand immtype>
3327 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, immtype:$imm7),
3328   asm, "\t$Pd, $Pg/z, $Zn, $imm7",
3329   "",
3330   []>, Sched<[]> {
3331   bits<4> Pd;
3332   bits<3> Pg;
3333   bits<5> Zn;
3334   bits<7> imm7;
3335   let Inst{31-24} = 0b00100100;
3336   let Inst{23-22} = sz8_64;
3337   let Inst{21}    = 1;
3338   let Inst{20-14} = imm7;
3339   let Inst{13}    = opc{1};
3340   let Inst{12-10} = Pg;
3341   let Inst{9-5}   = Zn;
3342   let Inst{4}     = opc{0};
3343   let Inst{3-0}   = Pd;
3345   let Defs = [NZCV];
3348 multiclass sve_int_ucmp_vi<bits<2> opc, string asm> {
3349   def _B : sve_int_ucmp_vi<0b00, opc, asm, PPR8, ZPR8, imm0_127>;
3350   def _H : sve_int_ucmp_vi<0b01, opc, asm, PPR16, ZPR16, imm0_127>;
3351   def _S : sve_int_ucmp_vi<0b10, opc, asm, PPR32, ZPR32, imm0_127>;
3352   def _D : sve_int_ucmp_vi<0b11, opc, asm, PPR64, ZPR64, imm0_127>;
3356 //===----------------------------------------------------------------------===//
3357 // SVE Integer Compare - Scalars Group
3358 //===----------------------------------------------------------------------===//
3360 class sve_int_cterm<bit sz, bit opc, string asm, RegisterClass rt>
3361 : I<(outs), (ins rt:$Rn, rt:$Rm),
3362   asm, "\t$Rn, $Rm",
3363   "",
3364   []>, Sched<[]> {
3365   bits<5> Rm;
3366   bits<5> Rn;
3367   let Inst{31-23} = 0b001001011;
3368   let Inst{22}    = sz;
3369   let Inst{21}    = 0b1;
3370   let Inst{20-16} = Rm;
3371   let Inst{15-10} = 0b001000;
3372   let Inst{9-5}   = Rn;
3373   let Inst{4}     = opc;
3374   let Inst{3-0}   = 0b0000;
3376   let Defs = [NZCV];
3379 class sve_int_while_rr<bits<2> sz8_64, bits<4> opc, string asm,
3380                        RegisterClass gprty, PPRRegOp pprty>
3381 : I<(outs pprty:$Pd), (ins gprty:$Rn, gprty:$Rm),
3382   asm, "\t$Pd, $Rn, $Rm",
3383   "", []>, Sched<[]> {
3384   bits<4> Pd;
3385   bits<5> Rm;
3386   bits<5> Rn;
3387   let Inst{31-24} = 0b00100101;
3388   let Inst{23-22} = sz8_64;
3389   let Inst{21}    = 0b1;
3390   let Inst{20-16} = Rm;
3391   let Inst{15-13} = 0b000;
3392   let Inst{12-10} = opc{3-1};
3393   let Inst{9-5}   = Rn;
3394   let Inst{4}     = opc{0};
3395   let Inst{3-0}   = Pd;
3397   let Defs = [NZCV];
3400 multiclass sve_int_while4_rr<bits<3> opc, string asm> {
3401   def _B : sve_int_while_rr<0b00, { 0, opc }, asm, GPR32, PPR8>;
3402   def _H : sve_int_while_rr<0b01, { 0, opc }, asm, GPR32, PPR16>;
3403   def _S : sve_int_while_rr<0b10, { 0, opc }, asm, GPR32, PPR32>;
3404   def _D : sve_int_while_rr<0b11, { 0, opc }, asm, GPR32, PPR64>;
3407 multiclass sve_int_while8_rr<bits<3> opc, string asm> {
3408   def _B : sve_int_while_rr<0b00, { 1, opc }, asm, GPR64, PPR8>;
3409   def _H : sve_int_while_rr<0b01, { 1, opc }, asm, GPR64, PPR16>;
3410   def _S : sve_int_while_rr<0b10, { 1, opc }, asm, GPR64, PPR32>;
3411   def _D : sve_int_while_rr<0b11, { 1, opc }, asm, GPR64, PPR64>;
3414 class sve2_int_while_rr<bits<2> sz8_64, bits<1> rw, string asm,
3415                         PPRRegOp pprty>
3416 : I<(outs pprty:$Pd), (ins GPR64:$Rn, GPR64:$Rm),
3417   asm, "\t$Pd, $Rn, $Rm",
3418   "", []>, Sched<[]> {
3419   bits<4> Pd;
3420   bits<5> Rm;
3421   bits<5> Rn;
3422   let Inst{31-24} = 0b00100101;
3423   let Inst{23-22} = sz8_64;
3424   let Inst{21}    = 0b1;
3425   let Inst{20-16} = Rm;
3426   let Inst{15-10} = 0b001100;
3427   let Inst{9-5}   = Rn;
3428   let Inst{4}     = rw;
3429   let Inst{3-0}   = Pd;
3431   let Defs = [NZCV];
3434 multiclass sve2_int_while_rr<bits<1> rw, string asm> {
3435   def _B : sve2_int_while_rr<0b00, rw, asm, PPR8>;
3436   def _H : sve2_int_while_rr<0b01, rw, asm, PPR16>;
3437   def _S : sve2_int_while_rr<0b10, rw, asm, PPR32>;
3438   def _D : sve2_int_while_rr<0b11, rw, asm, PPR64>;
3441 //===----------------------------------------------------------------------===//
3442 // SVE Floating Point Fast Reduction Group
3443 //===----------------------------------------------------------------------===//
3445 class sve_fp_fast_red<bits<2> sz, bits<3> opc, string asm,
3446                       ZPRRegOp zprty, RegisterClass dstRegClass>
3447 : I<(outs dstRegClass:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
3448   asm, "\t$Vd, $Pg, $Zn",
3449   "",
3450   []>, Sched<[]> {
3451   bits<5> Zn;
3452   bits<5> Vd;
3453   bits<3> Pg;
3454   let Inst{31-24} = 0b01100101;
3455   let Inst{23-22} = sz;
3456   let Inst{21-19} = 0b000;
3457   let Inst{18-16} = opc;
3458   let Inst{15-13} = 0b001;
3459   let Inst{12-10} = Pg;
3460   let Inst{9-5}   = Zn;
3461   let Inst{4-0}   = Vd;
3464 multiclass sve_fp_fast_red<bits<3> opc, string asm> {
3465   def _H : sve_fp_fast_red<0b01, opc, asm, ZPR16, FPR16>;
3466   def _S : sve_fp_fast_red<0b10, opc, asm, ZPR32, FPR32>;
3467   def _D : sve_fp_fast_red<0b11, opc, asm, ZPR64, FPR64>;
3471 //===----------------------------------------------------------------------===//
3472 // SVE Floating Point Accumulating Reduction Group
3473 //===----------------------------------------------------------------------===//
3475 class sve_fp_2op_p_vd<bits<2> sz, bits<3> opc, string asm,
3476                       ZPRRegOp zprty, RegisterClass dstRegClass>
3477 : I<(outs dstRegClass:$Vdn), (ins PPR3bAny:$Pg, dstRegClass:$_Vdn, zprty:$Zm),
3478   asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
3479   "",
3480   []>,
3481   Sched<[]> {
3482   bits<3> Pg;
3483   bits<5> Vdn;
3484   bits<5> Zm;
3485   let Inst{31-24} = 0b01100101;
3486   let Inst{23-22} = sz;
3487   let Inst{21-19} = 0b011;
3488   let Inst{18-16} = opc;
3489   let Inst{15-13} = 0b001;
3490   let Inst{12-10} = Pg;
3491   let Inst{9-5}   = Zm;
3492   let Inst{4-0}   = Vdn;
3494   let Constraints = "$Vdn = $_Vdn";
3497 multiclass sve_fp_2op_p_vd<bits<3> opc, string asm> {
3498   def _H : sve_fp_2op_p_vd<0b01, opc, asm, ZPR16, FPR16>;
3499   def _S : sve_fp_2op_p_vd<0b10, opc, asm, ZPR32, FPR32>;
3500   def _D : sve_fp_2op_p_vd<0b11, opc, asm, ZPR64, FPR64>;
3503 //===----------------------------------------------------------------------===//
3504 // SVE Floating Point Compare - Vectors Group
3505 //===----------------------------------------------------------------------===//
3507 class sve_fp_3op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
3508                       ZPRRegOp zprty>
3509 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
3510   asm, "\t$Pd, $Pg/z, $Zn, $Zm",
3511   "",
3512   []>, Sched<[]> {
3513   bits<4> Pd;
3514   bits<3> Pg;
3515   bits<5> Zm;
3516   bits<5> Zn;
3517   let Inst{31-24} = 0b01100101;
3518   let Inst{23-22} = sz;
3519   let Inst{21}    = 0b0;
3520   let Inst{20-16} = Zm;
3521   let Inst{15}    = opc{2};
3522   let Inst{14}    = 0b1;
3523   let Inst{13}    = opc{1};
3524   let Inst{12-10} = Pg;
3525   let Inst{9-5}   = Zn;
3526   let Inst{4}     = opc{0};
3527   let Inst{3-0}   = Pd;
3530 multiclass sve_fp_3op_p_pd<bits<3> opc, string asm> {
3531   def _H : sve_fp_3op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
3532   def _S : sve_fp_3op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
3533   def _D : sve_fp_3op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
3537 //===----------------------------------------------------------------------===//
3538 // SVE Floating Point Compare - with Zero Group
3539 //===----------------------------------------------------------------------===//
3541 class sve_fp_2op_p_pd<bits<2> sz, bits<3> opc, string asm, PPRRegOp pprty,
3542                       ZPRRegOp zprty>
3543 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn),
3544   asm, "\t$Pd, $Pg/z, $Zn, #0.0",
3545   "",
3546   []>, Sched<[]> {
3547   bits<4> Pd;
3548   bits<3> Pg;
3549   bits<5> Zn;
3550   let Inst{31-24} = 0b01100101;
3551   let Inst{23-22} = sz;
3552   let Inst{21-18} = 0b0100;
3553   let Inst{17-16} = opc{2-1};
3554   let Inst{15-13} = 0b001;
3555   let Inst{12-10} = Pg;
3556   let Inst{9-5}   = Zn;
3557   let Inst{4}     = opc{0};
3558   let Inst{3-0}   = Pd;
3561 multiclass sve_fp_2op_p_pd<bits<3> opc, string asm> {
3562   def _H : sve_fp_2op_p_pd<0b01, opc, asm, PPR16, ZPR16>;
3563   def _S : sve_fp_2op_p_pd<0b10, opc, asm, PPR32, ZPR32>;
3564   def _D : sve_fp_2op_p_pd<0b11, opc, asm, PPR64, ZPR64>;
3568 //===----------------------------------------------------------------------===//
3569 //SVE Index Generation Group
3570 //===----------------------------------------------------------------------===//
3572 class sve_int_index_ii<bits<2> sz8_64, string asm, ZPRRegOp zprty,
3573                        Operand imm_ty>
3574 : I<(outs zprty:$Zd), (ins imm_ty:$imm5, imm_ty:$imm5b),
3575   asm, "\t$Zd, $imm5, $imm5b",
3576   "", []>, Sched<[]> {
3577   bits<5> Zd;
3578   bits<5> imm5;
3579   bits<5> imm5b;
3580   let Inst{31-24} = 0b00000100;
3581   let Inst{23-22} = sz8_64;
3582   let Inst{21}    = 0b1;
3583   let Inst{20-16} = imm5b;
3584   let Inst{15-10} = 0b010000;
3585   let Inst{9-5}   = imm5;
3586   let Inst{4-0}   = Zd;
3589 multiclass sve_int_index_ii<string asm> {
3590   def _B : sve_int_index_ii<0b00, asm, ZPR8, simm5_32b>;
3591   def _H : sve_int_index_ii<0b01, asm, ZPR16, simm5_32b>;
3592   def _S : sve_int_index_ii<0b10, asm, ZPR32, simm5_32b>;
3593   def _D : sve_int_index_ii<0b11, asm, ZPR64, simm5_64b>;
3596 class sve_int_index_ir<bits<2> sz8_64, string asm, ZPRRegOp zprty,
3597                        RegisterClass srcRegType, Operand imm_ty>
3598 : I<(outs zprty:$Zd), (ins imm_ty:$imm5, srcRegType:$Rm),
3599   asm, "\t$Zd, $imm5, $Rm",
3600   "", []>, Sched<[]> {
3601   bits<5> Rm;
3602   bits<5> Zd;
3603   bits<5> imm5;
3604   let Inst{31-24} = 0b00000100;
3605   let Inst{23-22} = sz8_64;
3606   let Inst{21}    = 0b1;
3607   let Inst{20-16} = Rm;
3608   let Inst{15-10} = 0b010010;
3609   let Inst{9-5}   = imm5;
3610   let Inst{4-0}   = Zd;
3613 multiclass sve_int_index_ir<string asm> {
3614   def _B : sve_int_index_ir<0b00, asm, ZPR8, GPR32, simm5_32b>;
3615   def _H : sve_int_index_ir<0b01, asm, ZPR16, GPR32, simm5_32b>;
3616   def _S : sve_int_index_ir<0b10, asm, ZPR32, GPR32, simm5_32b>;
3617   def _D : sve_int_index_ir<0b11, asm, ZPR64, GPR64, simm5_64b>;
3620 class sve_int_index_ri<bits<2> sz8_64, string asm, ZPRRegOp zprty,
3621                        RegisterClass srcRegType, Operand imm_ty>
3622 : I<(outs zprty:$Zd), (ins srcRegType:$Rn, imm_ty:$imm5),
3623   asm, "\t$Zd, $Rn, $imm5",
3624   "", []>, Sched<[]> {
3625   bits<5> Rn;
3626   bits<5> Zd;
3627   bits<5> imm5;
3628   let Inst{31-24} = 0b00000100;
3629   let Inst{23-22} = sz8_64;
3630   let Inst{21}    = 0b1;
3631   let Inst{20-16} = imm5;
3632   let Inst{15-10} = 0b010001;
3633   let Inst{9-5}   = Rn;
3634   let Inst{4-0}   = Zd;
3637 multiclass sve_int_index_ri<string asm> {
3638   def _B : sve_int_index_ri<0b00, asm, ZPR8, GPR32, simm5_32b>;
3639   def _H : sve_int_index_ri<0b01, asm, ZPR16, GPR32, simm5_32b>;
3640   def _S : sve_int_index_ri<0b10, asm, ZPR32, GPR32, simm5_32b>;
3641   def _D : sve_int_index_ri<0b11, asm, ZPR64, GPR64, simm5_64b>;
3644 class sve_int_index_rr<bits<2> sz8_64, string asm, ZPRRegOp zprty,
3645                        RegisterClass srcRegType>
3646 : I<(outs zprty:$Zd), (ins srcRegType:$Rn, srcRegType:$Rm),
3647   asm, "\t$Zd, $Rn, $Rm",
3648   "", []>, Sched<[]> {
3649   bits<5> Zd;
3650   bits<5> Rm;
3651   bits<5> Rn;
3652   let Inst{31-24} = 0b00000100;
3653   let Inst{23-22} = sz8_64;
3654   let Inst{21}    = 0b1;
3655   let Inst{20-16} = Rm;
3656   let Inst{15-10} = 0b010011;
3657   let Inst{9-5}   = Rn;
3658   let Inst{4-0}   = Zd;
3661 multiclass sve_int_index_rr<string asm> {
3662   def _B : sve_int_index_rr<0b00, asm, ZPR8, GPR32>;
3663   def _H : sve_int_index_rr<0b01, asm, ZPR16, GPR32>;
3664   def _S : sve_int_index_rr<0b10, asm, ZPR32, GPR32>;
3665   def _D : sve_int_index_rr<0b11, asm, ZPR64, GPR64>;
3668 //===----------------------------------------------------------------------===//
3669 // SVE Bitwise Shift - Predicated Group
3670 //===----------------------------------------------------------------------===//
3671 class sve_int_bin_pred_shift_imm<bits<4> tsz8_64, bits<4> opc, string asm,
3672                                  ZPRRegOp zprty, Operand immtype,
3673                                  ElementSizeEnum size>
3674 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, immtype:$imm),
3675   asm, "\t$Zdn, $Pg/m, $_Zdn, $imm",
3676   "",
3677   []>, Sched<[]> {
3678   bits<3> Pg;
3679   bits<5> Zdn;
3680   bits<6> imm;
3681   let Inst{31-24} = 0b00000100;
3682   let Inst{23-22} = tsz8_64{3-2};
3683   let Inst{21-20} = 0b00;
3684   let Inst{19-16} = opc;
3685   let Inst{15-13} = 0b100;
3686   let Inst{12-10} = Pg;
3687   let Inst{9-8}   = tsz8_64{1-0};
3688   let Inst{7-5}   = imm{2-0}; // imm3
3689   let Inst{4-0}   = Zdn;
3691   let Constraints = "$Zdn = $_Zdn";
3692   let DestructiveInstType = Destructive;
3693   let ElementSize = size;
3696 multiclass sve_int_bin_pred_shift_imm_left<bits<4> opc, string asm> {
3697   def _B : sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8,
3698                                       ElementSizeB>;
3699   def _H : sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16,
3700                                       ElementSizeH> {
3701     let Inst{8} = imm{3};
3702   }
3703   def _S : sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32,
3704                                       ElementSizeS> {
3705     let Inst{9-8} = imm{4-3};
3706   }
3707   def _D : sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64,
3708                                       ElementSizeD> {
3709     let Inst{22}  = imm{5};
3710     let Inst{9-8} = imm{4-3};
3711   }
3714 multiclass sve_int_bin_pred_shift_imm_right<bits<4> opc, string asm> {
3715   def _B : sve_int_bin_pred_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8,
3716                                       ElementSizeB>;
3717   def _H : sve_int_bin_pred_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16,
3718                                       ElementSizeH> {
3719     let Inst{8} = imm{3};
3720   }
3721   def _S : sve_int_bin_pred_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32,
3722                                       ElementSizeS> {
3723     let Inst{9-8} = imm{4-3};
3724   }
3725   def _D : sve_int_bin_pred_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64,
3726                                       ElementSizeD> {
3727     let Inst{22}  = imm{5};
3728     let Inst{9-8} = imm{4-3};
3729   }
3732 class sve_int_bin_pred_shift<bits<2> sz8_64, bit wide, bits<3> opc,
3733                              string asm, ZPRRegOp zprty, ZPRRegOp zprty2>
3734 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty2:$Zm),
3735   asm, "\t$Zdn, $Pg/m, $_Zdn, $Zm",
3736   "",
3737   []>, Sched<[]> {
3738   bits<3> Pg;
3739   bits<5> Zdn;
3740   bits<5> Zm;
3741   let Inst{31-24} = 0b00000100;
3742   let Inst{23-22} = sz8_64;
3743   let Inst{21-20} = 0b01;
3744   let Inst{19}    = wide;
3745   let Inst{18-16} = opc;
3746   let Inst{15-13} = 0b100;
3747   let Inst{12-10} = Pg;
3748   let Inst{9-5}   = Zm;
3749   let Inst{4-0}   = Zdn;
3751   let Constraints = "$Zdn = $_Zdn";
3752   let DestructiveInstType = Destructive;
3753   let ElementSize = zprty.ElementSize;
3756 multiclass sve_int_bin_pred_shift<bits<3> opc, string asm> {
3757   def _B : sve_int_bin_pred_shift<0b00, 0b0, opc, asm, ZPR8, ZPR8>;
3758   def _H : sve_int_bin_pred_shift<0b01, 0b0, opc, asm, ZPR16, ZPR16>;
3759   def _S : sve_int_bin_pred_shift<0b10, 0b0, opc, asm, ZPR32, ZPR32>;
3760   def _D : sve_int_bin_pred_shift<0b11, 0b0, opc, asm, ZPR64, ZPR64>;
3763 multiclass sve_int_bin_pred_shift_wide<bits<3> opc, string asm> {
3764   def _B : sve_int_bin_pred_shift<0b00, 0b1, opc, asm, ZPR8, ZPR64>;
3765   def _H : sve_int_bin_pred_shift<0b01, 0b1, opc, asm, ZPR16, ZPR64>;
3766   def _S : sve_int_bin_pred_shift<0b10, 0b1, opc, asm, ZPR32, ZPR64>;
3769 //===----------------------------------------------------------------------===//
3770 // SVE Shift - Unpredicated Group
3771 //===----------------------------------------------------------------------===//
3773 class sve_int_bin_cons_shift_wide<bits<2> sz8_64, bits<2> opc, string asm,
3774                                ZPRRegOp zprty>
3775 : I<(outs zprty:$Zd), (ins zprty:$Zn, ZPR64:$Zm),
3776   asm, "\t$Zd, $Zn, $Zm",
3777   "",
3778   []>, Sched<[]> {
3779   bits<5> Zd;
3780   bits<5> Zm;
3781   bits<5> Zn;
3782   let Inst{31-24} = 0b00000100;
3783   let Inst{23-22} = sz8_64;
3784   let Inst{21}    = 0b1;
3785   let Inst{20-16} = Zm;
3786   let Inst{15-12} = 0b1000;
3787   let Inst{11-10} = opc;
3788   let Inst{9-5}   = Zn;
3789   let Inst{4-0}   = Zd;
3792 multiclass sve_int_bin_cons_shift_wide<bits<2> opc, string asm> {
3793   def _B : sve_int_bin_cons_shift_wide<0b00, opc, asm, ZPR8>;
3794   def _H : sve_int_bin_cons_shift_wide<0b01, opc, asm, ZPR16>;
3795   def _S : sve_int_bin_cons_shift_wide<0b10, opc, asm, ZPR32>;
3798 class sve_int_bin_cons_shift_imm<bits<4> tsz8_64, bits<2> opc, string asm,
3799                                ZPRRegOp zprty, Operand immtype>
3800 : I<(outs zprty:$Zd), (ins zprty:$Zn, immtype:$imm),
3801   asm, "\t$Zd, $Zn, $imm",
3802   "", []>, Sched<[]> {
3803   bits<5> Zd;
3804   bits<5> Zn;
3805   bits<6> imm;
3806   let Inst{31-24} = 0b00000100;
3807   let Inst{23-22} = tsz8_64{3-2};
3808   let Inst{21}    = 0b1;
3809   let Inst{20-19} = tsz8_64{1-0};
3810   let Inst{18-16} = imm{2-0}; // imm3
3811   let Inst{15-12} = 0b1001;
3812   let Inst{11-10} = opc;
3813   let Inst{9-5}   = Zn;
3814   let Inst{4-0}   = Zd;
3817 multiclass sve_int_bin_cons_shift_imm_left<bits<2> opc, string asm> {
3818   def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftL8>;
3819   def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftL16> {
3820     let Inst{19} = imm{3};
3821   }
3822   def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftL32> {
3823     let Inst{20-19} = imm{4-3};
3824   }
3825   def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftL64> {
3826     let Inst{22}    = imm{5};
3827     let Inst{20-19} = imm{4-3};
3828   }
3831 multiclass sve_int_bin_cons_shift_imm_right<bits<2> opc, string asm> {
3832   def _B : sve_int_bin_cons_shift_imm<{0,0,0,1}, opc, asm, ZPR8, vecshiftR8>;
3833   def _H : sve_int_bin_cons_shift_imm<{0,0,1,?}, opc, asm, ZPR16, vecshiftR16> {
3834     let Inst{19} = imm{3};
3835   }
3836   def _S : sve_int_bin_cons_shift_imm<{0,1,?,?}, opc, asm, ZPR32, vecshiftR32> {
3837     let Inst{20-19} = imm{4-3};
3838   }
3839   def _D : sve_int_bin_cons_shift_imm<{1,?,?,?}, opc, asm, ZPR64, vecshiftR64> {
3840     let Inst{22}    = imm{5};
3841     let Inst{20-19} = imm{4-3};
3842   }
3844 //===----------------------------------------------------------------------===//
3845 // SVE Memory - Store Group
3846 //===----------------------------------------------------------------------===//
3848 class sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
3849                      RegisterOperand VecList>
3850 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
3851   asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3852   "",
3853   []>, Sched<[]> {
3854   bits<3> Pg;
3855   bits<5> Rn;
3856   bits<5> Zt;
3857   bits<4> imm4;
3858   let Inst{31-25} = 0b1110010;
3859   let Inst{24-23} = msz;
3860   let Inst{22-21} = esz;
3861   let Inst{20}    = 0;
3862   let Inst{19-16} = imm4;
3863   let Inst{15-13} = 0b111;
3864   let Inst{12-10} = Pg;
3865   let Inst{9-5}   = Rn;
3866   let Inst{4-0}   = Zt;
3868   let mayStore = 1;
3871 multiclass sve_mem_cst_si<bits<2> msz, bits<2> esz, string asm,
3872                           RegisterOperand listty, ZPRRegOp zprty>
3874   def NAME : sve_mem_cst_si<msz, esz, asm, listty>;
3876   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3877                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
3878   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3879                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
3880   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3881                   (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
3884 class sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
3885                      string asm, Operand immtype>
3886 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
3887   asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3888   "",
3889   []>, Sched<[]> {
3890   bits<3> Pg;
3891   bits<5> Rn;
3892   bits<5> Zt;
3893   bits<4> imm4;
3894   let Inst{31-25} = 0b1110010;
3895   let Inst{24-23} = sz;
3896   let Inst{22-21} = nregs;
3897   let Inst{20}    = 1;
3898   let Inst{19-16} = imm4;
3899   let Inst{15-13} = 0b111;
3900   let Inst{12-10} = Pg;
3901   let Inst{9-5}   = Rn;
3902   let Inst{4-0}   = Zt;
3904   let mayStore = 1;
3907 multiclass sve_mem_est_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
3908                           string asm, Operand immtype> {
3909   def NAME : sve_mem_est_si<sz, nregs, VecList, asm, immtype>;
3911   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3912                   (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
3915 class sve_mem_est_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
3916                      string asm, RegisterOperand gprty>
3917 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
3918   asm, "\t$Zt, $Pg, [$Rn, $Rm]",
3919   "",
3920   []>, Sched<[]> {
3921   bits<3> Pg;
3922   bits<5> Rm;
3923   bits<5> Rn;
3924   bits<5> Zt;
3925   let Inst{31-25} = 0b1110010;
3926   let Inst{24-23} = sz;
3927   let Inst{22-21} = nregs;
3928   let Inst{20-16} = Rm;
3929   let Inst{15-13} = 0b011;
3930   let Inst{12-10} = Pg;
3931   let Inst{9-5}   = Rn;
3932   let Inst{4-0}   = Zt;
3934   let mayStore = 1;
3937 class sve_mem_cst_ss_base<bits<4> dtype, string asm,
3938                           RegisterOperand listty, RegisterOperand gprty>
3939 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
3940   asm, "\t$Zt, $Pg, [$Rn, $Rm]",
3941   "",
3942   []>, Sched<[]> {
3943   bits<3> Pg;
3944   bits<5> Rm;
3945   bits<5> Rn;
3946   bits<5> Zt;
3947   let Inst{31-25} = 0b1110010;
3948   let Inst{24-21} = dtype;
3949   let Inst{20-16} = Rm;
3950   let Inst{15-13} = 0b010;
3951   let Inst{12-10} = Pg;
3952   let Inst{9-5}   = Rn;
3953   let Inst{4-0}   = Zt;
3955   let mayStore = 1;
3958 multiclass sve_mem_cst_ss<bits<4> dtype, string asm,
3959                           RegisterOperand listty, ZPRRegOp zprty,
3960                           RegisterOperand gprty> {
3961   def NAME : sve_mem_cst_ss_base<dtype, asm, listty, gprty>;
3963   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
3964                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
3967 class sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand VecList>
3968 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
3969   asm, "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3970   "",
3971   []>, Sched<[]> {
3972   bits<3> Pg;
3973   bits<5> Rn;
3974   bits<5> Zt;
3975   bits<4> imm4;
3976   let Inst{31-25} = 0b1110010;
3977   let Inst{24-23} = msz;
3978   let Inst{22-20} = 0b001;
3979   let Inst{19-16} = imm4;
3980   let Inst{15-13} = 0b111;
3981   let Inst{12-10} = Pg;
3982   let Inst{9-5}   = Rn;
3983   let Inst{4-0}   = Zt;
3985   let mayStore = 1;
3988 multiclass sve_mem_cstnt_si<bits<2> msz, string asm, RegisterOperand listty,
3989                             ZPRRegOp zprty> {
3990   def NAME : sve_mem_cstnt_si<msz, asm, listty>;
3992   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3993                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
3994   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $imm4, mul vl]",
3995                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
3996   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn]",
3997                   (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4000 class sve_mem_cstnt_ss_base<bits<2> msz, string asm, RegisterOperand listty,
4001                             RegisterOperand gprty>
4002 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4003   asm, "\t$Zt, $Pg, [$Rn, $Rm]",
4004   "",
4005   []>, Sched<[]> {
4006   bits<3> Pg;
4007   bits<5> Rm;
4008   bits<5> Rn;
4009   bits<5> Zt;
4010   let Inst{31-25} = 0b1110010;
4011   let Inst{24-23} = msz;
4012   let Inst{22-21} = 0b00;
4013   let Inst{20-16} = Rm;
4014   let Inst{15-13} = 0b011;
4015   let Inst{12-10} = Pg;
4016   let Inst{9-5}   = Rn;
4017   let Inst{4-0}   = Zt;
4019   let mayStore = 1;
4022 multiclass sve_mem_cstnt_ss<bits<2> msz, string asm, RegisterOperand listty,
4023                             ZPRRegOp zprty, RegisterOperand gprty> {
4024   def NAME : sve_mem_cstnt_ss_base<msz, asm, listty, gprty>;
4026   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Rm]",
4027                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4030 class sve2_mem_sstnt_vs_base<bits<3> opc, string asm,
4031                              RegisterOperand listty, ZPRRegOp zprty>
4032 : I<(outs), (ins listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm),
4033   asm, "\t$Zt, $Pg, [$Zn, $Rm]",
4034   "",
4035   []>, Sched<[]> {
4036   bits<3> Pg;
4037   bits<5> Rm;
4038   bits<5> Zn;
4039   bits<5> Zt;
4040   let Inst{31-25} = 0b1110010;
4041   let Inst{24-22} = opc;
4042   let Inst{21}    = 0b0;
4043   let Inst{20-16} = Rm;
4044   let Inst{15-13} = 0b001;
4045   let Inst{12-10} = Pg;
4046   let Inst{9-5}   = Zn;
4047   let Inst{4-0}   = Zt;
4049   let mayStore = 1;
4052 multiclass sve2_mem_sstnt_vs<bits<3> opc, string asm,
4053                              RegisterOperand listty, ZPRRegOp zprty> {
4054   def _REAL : sve2_mem_sstnt_vs_base<opc, asm, listty, zprty>;
4056   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $Rm]",
4057                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm), 0>;
4058   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
4059                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, XZR), 0>;
4060   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
4061                  (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, XZR), 1>;
4064 class sve_mem_sst_sv<bits<3> opc, bit xs, bit scaled, string asm,
4065                      RegisterOperand VecList, RegisterOperand zprext>
4066 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
4067   asm, "\t$Zt, $Pg, [$Rn, $Zm]",
4068   "",
4069   []>, Sched<[]> {
4070   bits<3> Pg;
4071   bits<5> Rn;
4072   bits<5> Zm;
4073   bits<5> Zt;
4074   let Inst{31-25} = 0b1110010;
4075   let Inst{24-22} = opc;
4076   let Inst{21}    = scaled;
4077   let Inst{20-16} = Zm;
4078   let Inst{15}    = 0b1;
4079   let Inst{14}    = xs;
4080   let Inst{13}    = 0;
4081   let Inst{12-10} = Pg;
4082   let Inst{9-5}   = Rn;
4083   let Inst{4-0}   = Zt;
4085   let mayStore = 1;
4088 multiclass sve_mem_sst_sv_32_scaled<bits<3> opc, string asm,
4089                                     RegisterOperand listty,
4090                                     ZPRRegOp zprty,
4091                                     RegisterOperand sxtw_opnd,
4092                                     RegisterOperand uxtw_opnd > {
4093   def _UXTW_SCALED : sve_mem_sst_sv<opc, 0, 1, asm, listty, uxtw_opnd>;
4094   def _SXTW_SCALED : sve_mem_sst_sv<opc, 1, 1, asm, listty, sxtw_opnd>;
4096   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4097                  (!cast<Instruction>(NAME # _UXTW_SCALED) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
4098   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4099                  (!cast<Instruction>(NAME # _SXTW_SCALED) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
4102 multiclass sve_mem_sst_sv_32_unscaled<bits<3> opc, string asm,
4103                                       RegisterOperand listty,
4104                                       ZPRRegOp zprty,
4105                                       RegisterOperand sxtw_opnd,
4106                                       RegisterOperand uxtw_opnd> {
4107   def _UXTW : sve_mem_sst_sv<opc, 0, 0, asm, listty, uxtw_opnd>;
4108   def _SXTW : sve_mem_sst_sv<opc, 1, 0, asm, listty, sxtw_opnd>;
4110   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4111                  (!cast<Instruction>(NAME # _UXTW) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
4112   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4113                  (!cast<Instruction>(NAME # _SXTW) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
4116 class sve_mem_sst_sv2<bits<2> msz, bit scaled, string asm,
4117                       RegisterOperand zprext>
4118 : I<(outs), (ins Z_d:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
4119   asm, "\t$Zt, $Pg, [$Rn, $Zm]",
4120   "",
4121   []>, Sched<[]> {
4122   bits<3> Pg;
4123   bits<5> Rn;
4124   bits<5> Zm;
4125   bits<5> Zt;
4126   let Inst{31-25} = 0b1110010;
4127   let Inst{24-23} = msz;
4128   let Inst{22}    = 0b0;
4129   let Inst{21}    = scaled;
4130   let Inst{20-16} = Zm;
4131   let Inst{15-13} = 0b101;
4132   let Inst{12-10} = Pg;
4133   let Inst{9-5}   = Rn;
4134   let Inst{4-0}   = Zt;
4136   let mayStore = 1;
4139 multiclass sve_mem_sst_sv_64_scaled<bits<2> msz, string asm,
4140                                     RegisterOperand zprext> {
4141   def "" : sve_mem_sst_sv2<msz, 1, asm, zprext>;
4143   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4144                  (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
4148 multiclass sve_mem_sst_sv_64_unscaled<bits<2> msz, string asm> {
4149   def "" : sve_mem_sst_sv2<msz, 0, asm, ZPR64ExtLSL8>;
4151   def : InstAlias<asm # "\t$Zt, $Pg, [$Rn, $Zm]",
4152                  (!cast<Instruction>(NAME) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
4155 class sve_mem_sst_vi<bits<3> opc, string asm, ZPRRegOp zprty,
4156                      RegisterOperand VecList, Operand imm_ty>
4157 : I<(outs), (ins VecList:$Zt, PPR3bAny:$Pg, zprty:$Zn, imm_ty:$imm5),
4158   asm, "\t$Zt, $Pg, [$Zn, $imm5]",
4159   "",
4160   []>, Sched<[]> {
4161   bits<3> Pg;
4162   bits<5> imm5;
4163   bits<5> Zn;
4164   bits<5> Zt;
4165   let Inst{31-25} = 0b1110010;
4166   let Inst{24-23} = opc{2-1};
4167   let Inst{22}    = 0b1;
4168   let Inst{21}    = opc{0};
4169   let Inst{20-16} = imm5;
4170   let Inst{15-13} = 0b101;
4171   let Inst{12-10} = Pg;
4172   let Inst{9-5}   = Zn;
4173   let Inst{4-0}   = Zt;
4175   let mayStore = 1;
4178 multiclass sve_mem_sst_vi_ptrs<bits<3> opc, string asm, RegisterOperand listty,
4179                                ZPRRegOp zprty, Operand imm_ty> {
4180   def _IMM : sve_mem_sst_vi<opc, asm, zprty, listty, imm_ty>;
4182   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
4183                   (!cast<Instruction>(NAME # _IMM) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, 0), 0>;
4184   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn, $imm5]",
4185                   (!cast<Instruction>(NAME # _IMM) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, imm_ty:$imm5), 0>;
4186   def : InstAlias<asm # "\t$Zt, $Pg, [$Zn]",
4187                   (!cast<Instruction>(NAME # _IMM) listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, 0), 1>;
4190 class sve_mem_z_spill<string asm>
4191 : I<(outs), (ins ZPRAny:$Zt, GPR64sp:$Rn, simm9:$imm9),
4192   asm, "\t$Zt, [$Rn, $imm9, mul vl]",
4193   "",
4194   []>, Sched<[]> {
4195   bits<5> Rn;
4196   bits<5> Zt;
4197   bits<9> imm9;
4198   let Inst{31-22} = 0b1110010110;
4199   let Inst{21-16} = imm9{8-3};
4200   let Inst{15-13} = 0b010;
4201   let Inst{12-10} = imm9{2-0};
4202   let Inst{9-5}   = Rn;
4203   let Inst{4-0}   = Zt;
4205   let mayStore = 1;
4208 multiclass sve_mem_z_spill<string asm> {
4209   def NAME : sve_mem_z_spill<asm>;
4211   def : InstAlias<asm # "\t$Zt, [$Rn]",
4212                   (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
4215 class sve_mem_p_spill<string asm>
4216 : I<(outs), (ins PPRAny:$Pt, GPR64sp:$Rn, simm9:$imm9),
4217   asm, "\t$Pt, [$Rn, $imm9, mul vl]",
4218   "",
4219   []>, Sched<[]> {
4220   bits<4> Pt;
4221   bits<5> Rn;
4222   bits<9> imm9;
4223   let Inst{31-22} = 0b1110010110;
4224   let Inst{21-16} = imm9{8-3};
4225   let Inst{15-13} = 0b000;
4226   let Inst{12-10} = imm9{2-0};
4227   let Inst{9-5}   = Rn;
4228   let Inst{4}     = 0b0;
4229   let Inst{3-0}   = Pt;
4231   let mayStore = 1;
4234 multiclass sve_mem_p_spill<string asm> {
4235   def NAME : sve_mem_p_spill<asm>;
4237   def : InstAlias<asm # "\t$Pt, [$Rn]",
4238                   (!cast<Instruction>(NAME) PPRAny:$Pt, GPR64sp:$Rn, 0), 1>;
4241 //===----------------------------------------------------------------------===//
4242 // SVE Permute - Predicates Group
4243 //===----------------------------------------------------------------------===//
4245 class sve_int_perm_bin_perm_pp<bits<3> opc, bits<2> sz8_64, string asm,
4246                                PPRRegOp pprty>
4247 : I<(outs pprty:$Pd), (ins pprty:$Pn, pprty:$Pm),
4248   asm, "\t$Pd, $Pn, $Pm",
4249   "",
4250   []>, Sched<[]> {
4251   bits<4> Pd;
4252   bits<4> Pm;
4253   bits<4> Pn;
4254   let Inst{31-24} = 0b00000101;
4255   let Inst{23-22} = sz8_64;
4256   let Inst{21-20} = 0b10;
4257   let Inst{19-16} = Pm;
4258   let Inst{15-13} = 0b010;
4259   let Inst{12-10} = opc;
4260   let Inst{9}     = 0b0;
4261   let Inst{8-5}   = Pn;
4262   let Inst{4}     = 0b0;
4263   let Inst{3-0}   = Pd;
4266 multiclass sve_int_perm_bin_perm_pp<bits<3> opc, string asm> {
4267   def _B : sve_int_perm_bin_perm_pp<opc, 0b00, asm, PPR8>;
4268   def _H : sve_int_perm_bin_perm_pp<opc, 0b01, asm, PPR16>;
4269   def _S : sve_int_perm_bin_perm_pp<opc, 0b10, asm, PPR32>;
4270   def _D : sve_int_perm_bin_perm_pp<opc, 0b11, asm, PPR64>;
4273 class sve_int_perm_punpk<bit opc, string asm>
4274 : I<(outs PPR16:$Pd), (ins PPR8:$Pn),
4275   asm, "\t$Pd, $Pn",
4276   "",
4277   []>, Sched<[]> {
4278   bits<4> Pd;
4279   bits<4> Pn;
4280   let Inst{31-17} = 0b000001010011000;
4281   let Inst{16}    = opc;
4282   let Inst{15-9}  = 0b0100000;
4283   let Inst{8-5}   = Pn;
4284   let Inst{4}     = 0b0;
4285   let Inst{3-0}   = Pd;
4288 multiclass sve_int_perm_punpk<bit opc, string asm, SDPatternOperator op> {
4289   def NAME : sve_int_perm_punpk<opc, asm>;
4291   def : SVE_1_Op_Pat<nxv8i1, op, nxv16i1, !cast<Instruction>(NAME)>;
4292   def : SVE_1_Op_Pat<nxv4i1, op, nxv8i1,  !cast<Instruction>(NAME)>;
4293   def : SVE_1_Op_Pat<nxv2i1, op, nxv4i1,  !cast<Instruction>(NAME)>;
4296 class sve_int_rdffr_pred<bit s, string asm>
4297 : I<(outs PPR8:$Pd), (ins PPRAny:$Pg),
4298   asm, "\t$Pd, $Pg/z",
4299   "",
4300   []>, Sched<[]> {
4301   bits<4> Pd;
4302   bits<4> Pg;
4303   let Inst{31-23} = 0b001001010;
4304   let Inst{22}    = s;
4305   let Inst{21-9}  = 0b0110001111000;
4306   let Inst{8-5}   = Pg;
4307   let Inst{4}     = 0;
4308   let Inst{3-0}   = Pd;
4310   let Defs = !if(!eq (s, 1), [NZCV], []);
4311   let Uses = [FFR];
4314 class sve_int_rdffr_unpred<string asm> : I<
4315   (outs PPR8:$Pd), (ins),
4316   asm, "\t$Pd",
4317   "",
4318   []>, Sched<[]> {
4319   bits<4> Pd;
4320   let Inst{31-4} = 0b0010010100011001111100000000;
4321   let Inst{3-0}   = Pd;
4323   let Uses = [FFR];
4326 class sve_int_wrffr<string asm>
4327 : I<(outs), (ins PPR8:$Pn),
4328   asm, "\t$Pn",
4329   "",
4330   []>, Sched<[]> {
4331   bits<4> Pn;
4332   let Inst{31-9} = 0b00100101001010001001000;
4333   let Inst{8-5}  = Pn;
4334   let Inst{4-0}  = 0b00000;
4336   let hasSideEffects = 1;
4337   let Defs = [FFR];
4340 class sve_int_setffr<string asm>
4341 : I<(outs), (ins),
4342   asm, "",
4343   "",
4344   []>, Sched<[]> {
4345   let Inst{31-0} = 0b00100101001011001001000000000000;
4347   let hasSideEffects = 1;
4348   let Defs = [FFR];
4351 //===----------------------------------------------------------------------===//
4352 // SVE Permute Vector - Predicated Group
4353 //===----------------------------------------------------------------------===//
4355 class sve_int_perm_clast_rz<bits<2> sz8_64, bit ab, string asm,
4356                             ZPRRegOp zprty, RegisterClass rt>
4357 : I<(outs rt:$Rdn), (ins PPR3bAny:$Pg, rt:$_Rdn, zprty:$Zm),
4358   asm, "\t$Rdn, $Pg, $_Rdn, $Zm",
4359   "",
4360   []>, Sched<[]> {
4361   bits<3> Pg;
4362   bits<5> Rdn;
4363   bits<5> Zm;
4364   let Inst{31-24} = 0b00000101;
4365   let Inst{23-22} = sz8_64;
4366   let Inst{21-17} = 0b11000;
4367   let Inst{16}    = ab;
4368   let Inst{15-13} = 0b101;
4369   let Inst{12-10} = Pg;
4370   let Inst{9-5}   = Zm;
4371   let Inst{4-0}   = Rdn;
4373   let Constraints = "$Rdn = $_Rdn";
4376 multiclass sve_int_perm_clast_rz<bit ab, string asm> {
4377   def _B : sve_int_perm_clast_rz<0b00, ab, asm, ZPR8, GPR32>;
4378   def _H : sve_int_perm_clast_rz<0b01, ab, asm, ZPR16, GPR32>;
4379   def _S : sve_int_perm_clast_rz<0b10, ab, asm, ZPR32, GPR32>;
4380   def _D : sve_int_perm_clast_rz<0b11, ab, asm, ZPR64, GPR64>;
4383 class sve_int_perm_clast_vz<bits<2> sz8_64, bit ab, string asm,
4384                             ZPRRegOp zprty, RegisterClass rt>
4385 : I<(outs rt:$Vdn), (ins PPR3bAny:$Pg, rt:$_Vdn, zprty:$Zm),
4386   asm, "\t$Vdn, $Pg, $_Vdn, $Zm",
4387   "",
4388   []>, Sched<[]> {
4389   bits<3> Pg;
4390   bits<5> Vdn;
4391   bits<5> Zm;
4392   let Inst{31-24} = 0b00000101;
4393   let Inst{23-22} = sz8_64;
4394   let Inst{21-17} = 0b10101;
4395   let Inst{16}    = ab;
4396   let Inst{15-13} = 0b100;
4397   let Inst{12-10} = Pg;
4398   let Inst{9-5}   = Zm;
4399   let Inst{4-0}   = Vdn;
4401   let Constraints = "$Vdn = $_Vdn";
4404 multiclass sve_int_perm_clast_vz<bit ab, string asm> {
4405   def _B : sve_int_perm_clast_vz<0b00, ab, asm, ZPR8, FPR8>;
4406   def _H : sve_int_perm_clast_vz<0b01, ab, asm, ZPR16, FPR16>;
4407   def _S : sve_int_perm_clast_vz<0b10, ab, asm, ZPR32, FPR32>;
4408   def _D : sve_int_perm_clast_vz<0b11, ab, asm, ZPR64, FPR64>;
4411 class sve_int_perm_clast_zz<bits<2> sz8_64, bit ab, string asm,
4412                             ZPRRegOp zprty>
4413 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
4414   asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
4415   "",
4416   []>, Sched<[]> {
4417   bits<3> Pg;
4418   bits<5> Zdn;
4419   bits<5> Zm;
4420   let Inst{31-24} = 0b00000101;
4421   let Inst{23-22} = sz8_64;
4422   let Inst{21-17} = 0b10100;
4423   let Inst{16}    = ab;
4424   let Inst{15-13} = 0b100;
4425   let Inst{12-10} = Pg;
4426   let Inst{9-5}   = Zm;
4427   let Inst{4-0}   = Zdn;
4429   let Constraints = "$Zdn = $_Zdn";
4430   let DestructiveInstType = Destructive;
4431   let ElementSize = ElementSizeNone;
4434 multiclass sve_int_perm_clast_zz<bit ab, string asm> {
4435   def _B : sve_int_perm_clast_zz<0b00, ab, asm, ZPR8>;
4436   def _H : sve_int_perm_clast_zz<0b01, ab, asm, ZPR16>;
4437   def _S : sve_int_perm_clast_zz<0b10, ab, asm, ZPR32>;
4438   def _D : sve_int_perm_clast_zz<0b11, ab, asm, ZPR64>;
4441 class sve_int_perm_last_r<bits<2> sz8_64, bit ab, string asm,
4442                           ZPRRegOp zprty, RegisterClass resultRegType>
4443 : I<(outs resultRegType:$Rd), (ins PPR3bAny:$Pg, zprty:$Zn),
4444   asm, "\t$Rd, $Pg, $Zn",
4445   "",
4446   []>, Sched<[]> {
4447   bits<3> Pg;
4448   bits<5> Rd;
4449   bits<5> Zn;
4450   let Inst{31-24} = 0b00000101;
4451   let Inst{23-22} = sz8_64;
4452   let Inst{21-17} = 0b10000;
4453   let Inst{16}    = ab;
4454   let Inst{15-13} = 0b101;
4455   let Inst{12-10} = Pg;
4456   let Inst{9-5}   = Zn;
4457   let Inst{4-0}   = Rd;
4460 multiclass sve_int_perm_last_r<bit ab, string asm> {
4461   def _B : sve_int_perm_last_r<0b00, ab, asm, ZPR8, GPR32>;
4462   def _H : sve_int_perm_last_r<0b01, ab, asm, ZPR16, GPR32>;
4463   def _S : sve_int_perm_last_r<0b10, ab, asm, ZPR32, GPR32>;
4464   def _D : sve_int_perm_last_r<0b11, ab, asm, ZPR64, GPR64>;
4467 class sve_int_perm_last_v<bits<2> sz8_64, bit ab, string asm,
4468                           ZPRRegOp zprty, RegisterClass dstRegtype>
4469 : I<(outs dstRegtype:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
4470   asm, "\t$Vd, $Pg, $Zn",
4471   "",
4472   []>, Sched<[]> {
4473   bits<3> Pg;
4474   bits<5> Vd;
4475   bits<5> Zn;
4476   let Inst{31-24} = 0b00000101;
4477   let Inst{23-22} = sz8_64;
4478   let Inst{21-17} = 0b10001;
4479   let Inst{16}    = ab;
4480   let Inst{15-13} = 0b100;
4481   let Inst{12-10} = Pg;
4482   let Inst{9-5}   = Zn;
4483   let Inst{4-0}   = Vd;
4486 multiclass sve_int_perm_last_v<bit ab, string asm> {
4487   def _B : sve_int_perm_last_v<0b00, ab, asm, ZPR8, FPR8>;
4488   def _H : sve_int_perm_last_v<0b01, ab, asm, ZPR16, FPR16>;
4489   def _S : sve_int_perm_last_v<0b10, ab, asm, ZPR32, FPR32>;
4490   def _D : sve_int_perm_last_v<0b11, ab, asm, ZPR64, FPR64>;
4493 class sve_int_perm_splice<bits<2> sz8_64, string asm, ZPRRegOp zprty>
4494 : I<(outs zprty:$Zdn), (ins PPR3bAny:$Pg, zprty:$_Zdn, zprty:$Zm),
4495   asm, "\t$Zdn, $Pg, $_Zdn, $Zm",
4496   "",
4497   []>, Sched<[]> {
4498   bits<3> Pg;
4499   bits<5> Zdn;
4500   bits<5> Zm;
4501   let Inst{31-24} = 0b00000101;
4502   let Inst{23-22} = sz8_64;
4503   let Inst{21-13} = 0b101100100;
4504   let Inst{12-10} = Pg;
4505   let Inst{9-5}   = Zm;
4506   let Inst{4-0}   = Zdn;
4508   let Constraints = "$Zdn = $_Zdn";
4509   let DestructiveInstType = Destructive;
4510   let ElementSize = ElementSizeNone;
4513 multiclass sve_int_perm_splice<string asm> {
4514   def _B : sve_int_perm_splice<0b00, asm, ZPR8>;
4515   def _H : sve_int_perm_splice<0b01, asm, ZPR16>;
4516   def _S : sve_int_perm_splice<0b10, asm, ZPR32>;
4517   def _D : sve_int_perm_splice<0b11, asm, ZPR64>;
4520 class sve2_int_perm_splice_cons<bits<2> sz8_64, string asm,
4521                                ZPRRegOp zprty, RegisterOperand VecList>
4522 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, VecList:$Zn),
4523   asm, "\t$Zd, $Pg, $Zn",
4524   "",
4525   []>, Sched<[]> {
4526   bits<3> Pg;
4527   bits<5> Zn;
4528   bits<5> Zd;
4529   let Inst{31-24} = 0b00000101;
4530   let Inst{23-22} = sz8_64;
4531   let Inst{21-13} = 0b101101100;
4532   let Inst{12-10} = Pg;
4533   let Inst{9-5}   = Zn;
4534   let Inst{4-0}   = Zd;
4537 multiclass sve2_int_perm_splice_cons<string asm> {
4538   def _B : sve2_int_perm_splice_cons<0b00, asm, ZPR8,  ZZ_b>;
4539   def _H : sve2_int_perm_splice_cons<0b01, asm, ZPR16, ZZ_h>;
4540   def _S : sve2_int_perm_splice_cons<0b10, asm, ZPR32, ZZ_s>;
4541   def _D : sve2_int_perm_splice_cons<0b11, asm, ZPR64, ZZ_d>;
4544 class sve_int_perm_rev<bits<2> sz8_64, bits<2> opc, string asm,
4545                        ZPRRegOp zprty>
4546 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, zprty:$Zn),
4547   asm, "\t$Zd, $Pg/m, $Zn",
4548   "",
4549   []>, Sched<[]> {
4550   bits<5> Zd;
4551   bits<3> Pg;
4552   bits<5> Zn;
4553   let Inst{31-24} = 0b00000101;
4554   let Inst{23-22} = sz8_64;
4555   let Inst{21-18} = 0b1001;
4556   let Inst{17-16} = opc;
4557   let Inst{15-13} = 0b100;
4558   let Inst{12-10} = Pg;
4559   let Inst{9-5}   = Zn;
4560   let Inst{4-0}   = Zd;
4562   let Constraints = "$Zd = $_Zd";
4563   let DestructiveInstType = Destructive;
4564   let ElementSize = zprty.ElementSize;
4567 multiclass sve_int_perm_rev_rbit<string asm> {
4568   def _B : sve_int_perm_rev<0b00, 0b11, asm, ZPR8>;
4569   def _H : sve_int_perm_rev<0b01, 0b11, asm, ZPR16>;
4570   def _S : sve_int_perm_rev<0b10, 0b11, asm, ZPR32>;
4571   def _D : sve_int_perm_rev<0b11, 0b11, asm, ZPR64>;
4574 multiclass sve_int_perm_rev_revb<string asm> {
4575   def _H : sve_int_perm_rev<0b01, 0b00, asm, ZPR16>;
4576   def _S : sve_int_perm_rev<0b10, 0b00, asm, ZPR32>;
4577   def _D : sve_int_perm_rev<0b11, 0b00, asm, ZPR64>;
4580 multiclass sve_int_perm_rev_revh<string asm> {
4581   def _S : sve_int_perm_rev<0b10, 0b01, asm, ZPR32>;
4582   def _D : sve_int_perm_rev<0b11, 0b01, asm, ZPR64>;
4585 multiclass sve_int_perm_rev_revw<string asm> {
4586   def _D : sve_int_perm_rev<0b11, 0b10, asm, ZPR64>;
4589 class sve_int_perm_cpy_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
4590                          RegisterClass srcRegType>
4591 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegType:$Rn),
4592   asm, "\t$Zd, $Pg/m, $Rn",
4593   "",
4594   []>, Sched<[]> {
4595   bits<3> Pg;
4596   bits<5> Rn;
4597   bits<5> Zd;
4598   let Inst{31-24} = 0b00000101;
4599   let Inst{23-22} = sz8_64;
4600   let Inst{21-13} = 0b101000101;
4601   let Inst{12-10} = Pg;
4602   let Inst{9-5}   = Rn;
4603   let Inst{4-0}   = Zd;
4605   let Constraints = "$Zd = $_Zd";
4606   let DestructiveInstType = Destructive;
4607   let ElementSize = zprty.ElementSize;
4610 multiclass sve_int_perm_cpy_r<string asm> {
4611   def _B : sve_int_perm_cpy_r<0b00, asm, ZPR8, GPR32sp>;
4612   def _H : sve_int_perm_cpy_r<0b01, asm, ZPR16, GPR32sp>;
4613   def _S : sve_int_perm_cpy_r<0b10, asm, ZPR32, GPR32sp>;
4614   def _D : sve_int_perm_cpy_r<0b11, asm, ZPR64, GPR64sp>;
4616   def : InstAlias<"mov $Zd, $Pg/m, $Rn",
4617                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
4618   def : InstAlias<"mov $Zd, $Pg/m, $Rn",
4619                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
4620   def : InstAlias<"mov $Zd, $Pg/m, $Rn",
4621                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, GPR32sp:$Rn), 1>;
4622   def : InstAlias<"mov $Zd, $Pg/m, $Rn",
4623                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, GPR64sp:$Rn), 1>;
4626 class sve_int_perm_cpy_v<bits<2> sz8_64, string asm, ZPRRegOp zprty,
4627                          RegisterClass srcRegtype>
4628 : I<(outs zprty:$Zd), (ins zprty:$_Zd, PPR3bAny:$Pg, srcRegtype:$Vn),
4629   asm, "\t$Zd, $Pg/m, $Vn",
4630   "",
4631   []>, Sched<[]> {
4632   bits<3> Pg;
4633   bits<5> Vn;
4634   bits<5> Zd;
4635   let Inst{31-24} = 0b00000101;
4636   let Inst{23-22} = sz8_64;
4637   let Inst{21-13} = 0b100000100;
4638   let Inst{12-10} = Pg;
4639   let Inst{9-5}   = Vn;
4640   let Inst{4-0}   = Zd;
4642   let Constraints = "$Zd = $_Zd";
4643   let DestructiveInstType = Destructive;
4644   let ElementSize = zprty.ElementSize;
4647 multiclass sve_int_perm_cpy_v<string asm> {
4648   def _B : sve_int_perm_cpy_v<0b00, asm, ZPR8, FPR8>;
4649   def _H : sve_int_perm_cpy_v<0b01, asm, ZPR16, FPR16>;
4650   def _S : sve_int_perm_cpy_v<0b10, asm, ZPR32, FPR32>;
4651   def _D : sve_int_perm_cpy_v<0b11, asm, ZPR64, FPR64>;
4653   def : InstAlias<"mov $Zd, $Pg/m, $Vn",
4654                   (!cast<Instruction>(NAME # _B) ZPR8:$Zd, PPR3bAny:$Pg, FPR8:$Vn), 1>;
4655   def : InstAlias<"mov $Zd, $Pg/m, $Vn",
4656                   (!cast<Instruction>(NAME # _H) ZPR16:$Zd, PPR3bAny:$Pg, FPR16:$Vn), 1>;
4657   def : InstAlias<"mov $Zd, $Pg/m, $Vn",
4658                   (!cast<Instruction>(NAME # _S) ZPR32:$Zd, PPR3bAny:$Pg, FPR32:$Vn), 1>;
4659   def : InstAlias<"mov $Zd, $Pg/m, $Vn",
4660                   (!cast<Instruction>(NAME # _D) ZPR64:$Zd, PPR3bAny:$Pg, FPR64:$Vn), 1>;
4663 class sve_int_perm_compact<bit sz, string asm, ZPRRegOp zprty>
4664 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn),
4665   asm, "\t$Zd, $Pg, $Zn",
4666   "",
4667   []>, Sched<[]> {
4668   bits<3> Pg;
4669   bits<5> Zd;
4670   bits<5> Zn;
4671   let Inst{31-23} = 0b000001011;
4672   let Inst{22}    = sz;
4673   let Inst{21-13} = 0b100001100;
4674   let Inst{12-10} = Pg;
4675   let Inst{9-5}   = Zn;
4676   let Inst{4-0}   = Zd;
4679 multiclass sve_int_perm_compact<string asm> {
4680   def _S : sve_int_perm_compact<0b0, asm, ZPR32>;
4681   def _D : sve_int_perm_compact<0b1, asm, ZPR64>;
4685 //===----------------------------------------------------------------------===//
4686 // SVE Memory - Contiguous Load Group
4687 //===----------------------------------------------------------------------===//
4689 class sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
4690                           RegisterOperand VecList>
4691 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
4692   asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4693   "",
4694   []>, Sched<[]> {
4695   bits<3> Pg;
4696   bits<5> Rn;
4697   bits<5> Zt;
4698   bits<4> imm4;
4699   let Inst{31-25} = 0b1010010;
4700   let Inst{24-21} = dtype;
4701   let Inst{20}    = nf;
4702   let Inst{19-16} = imm4;
4703   let Inst{15-13} = 0b101;
4704   let Inst{12-10} = Pg;
4705   let Inst{9-5}   = Rn;
4706   let Inst{4-0}   = Zt;
4708   let mayLoad = 1;
4709   let Uses = !if(!eq(nf, 1), [FFR], []);
4710   let Defs = !if(!eq(nf, 1), [FFR], []);
4713 multiclass sve_mem_cld_si_base<bits<4> dtype, bit nf, string asm,
4714                                RegisterOperand listty, ZPRRegOp zprty> {
4715   def _REAL : sve_mem_cld_si_base<dtype, nf, asm, listty>;
4717   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4718                   (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
4719   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4720                   (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
4721   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4722                   (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4725 multiclass sve_mem_cld_si<bits<4> dtype, string asm, RegisterOperand listty,
4726                           ZPRRegOp zprty>
4727 : sve_mem_cld_si_base<dtype, 0, asm, listty, zprty>;
4729 class sve_mem_cldnt_si_base<bits<2> msz, string asm, RegisterOperand VecList>
4730 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4),
4731   asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4732   "",
4733   []>, Sched<[]> {
4734   bits<5> Zt;
4735   bits<3> Pg;
4736   bits<5> Rn;
4737   bits<4> imm4;
4738   let Inst{31-25} = 0b1010010;
4739   let Inst{24-23} = msz;
4740   let Inst{22-20} = 0b000;
4741   let Inst{19-16} = imm4;
4742   let Inst{15-13} = 0b111;
4743   let Inst{12-10} = Pg;
4744   let Inst{9-5}   = Rn;
4745   let Inst{4-0}   = Zt;
4747   let mayLoad = 1;
4750 multiclass sve_mem_cldnt_si<bits<2> msz, string asm, RegisterOperand listty,
4751                             ZPRRegOp zprty> {
4752   def NAME : sve_mem_cldnt_si_base<msz, asm, listty>;
4754   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4755                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
4756   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4757                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s1:$imm4), 0>;
4758   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4759                   (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4762 class sve_mem_cldnt_ss_base<bits<2> msz, string asm, RegisterOperand VecList,
4763                             RegisterOperand gprty>
4764 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4765   asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
4766   "",
4767   []>, Sched<[]> {
4768   bits<3> Pg;
4769   bits<5> Rm;
4770   bits<5> Rn;
4771   bits<5> Zt;
4772   let Inst{31-25} = 0b1010010;
4773   let Inst{24-23} = msz;
4774   let Inst{22-21} = 0b00;
4775   let Inst{20-16} = Rm;
4776   let Inst{15-13} = 0b110;
4777   let Inst{12-10} = Pg;
4778   let Inst{9-5}   = Rn;
4779   let Inst{4-0}   = Zt;
4781   let mayLoad = 1;
4784 multiclass sve_mem_cldnt_ss<bits<2> msz, string asm, RegisterOperand listty,
4785                             ZPRRegOp zprty, RegisterOperand gprty> {
4786   def NAME : sve_mem_cldnt_ss_base<msz, asm, listty, gprty>;
4788   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
4789                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4792 class sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand VecList>
4793 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4),
4794   asm, "\t$Zt, $Pg/z, [$Rn, $imm4]", "", []>, Sched<[]> {
4795   bits<5> Zt;
4796   bits<5> Rn;
4797   bits<3> Pg;
4798   bits<4> imm4;
4799   let Inst{31-25} = 0b1010010;
4800   let Inst{24-23} = sz;
4801   let Inst{22-20} = 0;
4802   let Inst{19-16} = imm4;
4803   let Inst{15-13} = 0b001;
4804   let Inst{12-10} = Pg;
4805   let Inst{9-5}   = Rn;
4806   let Inst{4-0}   = Zt;
4808   let mayLoad = 1;
4811 multiclass sve_mem_ldqr_si<bits<2> sz, string asm, RegisterOperand listty,
4812                            ZPRRegOp zprty> {
4813   def NAME : sve_mem_ldqr_si<sz, asm, listty>;
4814   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4815                   (!cast<Instruction>(NAME) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4816   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4817                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
4818   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm4]",
4819                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, simm4s16:$imm4), 0>;
4822 class sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand VecList,
4823                       RegisterOperand gprty>
4824 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4825   asm, "\t$Zt, $Pg/z, [$Rn, $Rm]", "", []>, Sched<[]> {
4826   bits<5> Zt;
4827   bits<3> Pg;
4828   bits<5> Rn;
4829   bits<5> Rm;
4830   let Inst{31-25} = 0b1010010;
4831   let Inst{24-23} = sz;
4832   let Inst{22-21} = 0;
4833   let Inst{20-16} = Rm;
4834   let Inst{15-13} = 0;
4835   let Inst{12-10} = Pg;
4836   let Inst{9-5}   = Rn;
4837   let Inst{4-0}   = Zt;
4839   let mayLoad = 1;
4842 multiclass sve_mem_ldqr_ss<bits<2> sz, string asm, RegisterOperand listty,
4843                            ZPRRegOp zprty, RegisterOperand gprty> {
4844   def NAME : sve_mem_ldqr_ss<sz, asm, listty, gprty>;
4846   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
4847                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4850 class sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
4851                      RegisterOperand VecList, Operand immtype>
4852 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6),
4853   asm, "\t$Zt, $Pg/z, [$Rn, $imm6]",
4854   "",
4855   []>, Sched<[]> {
4856   bits<3> Pg;
4857   bits<5> Rn;
4858   bits<5> Zt;
4859   bits<6> imm6;
4860   let Inst{31-25} = 0b1000010;
4861   let Inst{24-23} = dtypeh;
4862   let Inst{22}    = 1;
4863   let Inst{21-16} = imm6;
4864   let Inst{15}    = 0b1;
4865   let Inst{14-13} = dtypel;
4866   let Inst{12-10} = Pg;
4867   let Inst{9-5}   = Rn;
4868   let Inst{4-0}   = Zt;
4870   let mayLoad = 1;
4873 multiclass sve_mem_ld_dup<bits<2> dtypeh, bits<2> dtypel, string asm,
4874                           RegisterOperand zlistty, ZPRRegOp zprty, Operand immtype> {
4875   def NAME : sve_mem_ld_dup<dtypeh, dtypel, asm, zlistty, immtype>;
4877   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4878                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 0>;
4879   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $imm6]",
4880                   (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm6), 0>;
4881   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4882                   (!cast<Instruction>(NAME) zlistty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4885 class sve_mem_cld_ss_base<bits<4> dtype, bit ff, dag iops, string asm,
4886                           RegisterOperand VecList>
4887 : I<(outs VecList:$Zt), iops,
4888   asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
4889   "",
4890   []>, Sched<[]> {
4891   bits<5> Zt;
4892   bits<3> Pg;
4893   bits<5> Rm;
4894   bits<5> Rn;
4895   let Inst{31-25} = 0b1010010;
4896   let Inst{24-21} = dtype;
4897   let Inst{20-16} = Rm;
4898   let Inst{15-14} = 0b01;
4899   let Inst{13}    = ff;
4900   let Inst{12-10} = Pg;
4901   let Inst{9-5}   = Rn;
4902   let Inst{4-0}   = Zt;
4904   let mayLoad = 1;
4905   let Uses = !if(!eq(ff, 1), [FFR], []);
4906   let Defs = !if(!eq(ff, 1), [FFR], []);
4909 multiclass sve_mem_cld_ss<bits<4> dtype, string asm, RegisterOperand listty,
4910                           ZPRRegOp zprty, RegisterOperand gprty> {
4911   def "" : sve_mem_cld_ss_base<dtype, 0, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4912                                asm, listty>;
4914   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
4915                  (!cast<Instruction>(NAME) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4918 multiclass sve_mem_cldff_ss<bits<4> dtype, string asm, RegisterOperand listty,
4919                             ZPRRegOp zprty, RegisterOperand gprty> {
4920   def _REAL : sve_mem_cld_ss_base<dtype, 1, (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4921                                   asm, listty>;
4923   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Rm]",
4924                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm), 0>;
4926   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4927                  (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 1>;
4929   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4930                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 0>;
4933 multiclass sve_mem_cldnf_si<bits<4> dtype, string asm, RegisterOperand listty,
4934                             ZPRRegOp zprty>
4935 : sve_mem_cld_si_base<dtype, 1, asm, listty, zprty>;
4937 class sve_mem_eld_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
4938                      string asm, Operand immtype>
4939 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, immtype:$imm4),
4940   asm, "\t$Zt, $Pg/z, [$Rn, $imm4, mul vl]",
4941   "",
4942   []>, Sched<[]> {
4943   bits<5> Zt;
4944   bits<3> Pg;
4945   bits<5> Rn;
4946   bits<4> imm4;
4947   let Inst{31-25} = 0b1010010;
4948   let Inst{24-23} = sz;
4949   let Inst{22-21} = nregs;
4950   let Inst{20}    = 0;
4951   let Inst{19-16} = imm4;
4952   let Inst{15-13} = 0b111;
4953   let Inst{12-10} = Pg;
4954   let Inst{9-5}   = Rn;
4955   let Inst{4-0}   = Zt;
4957   let mayLoad = 1;
4960 multiclass sve_mem_eld_si<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
4961                           string asm, Operand immtype> {
4962   def NAME : sve_mem_eld_si<sz, nregs, VecList, asm, immtype>;
4964   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn]",
4965                   (!cast<Instruction>(NAME) VecList:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
4968 class sve_mem_eld_ss<bits<2> sz, bits<2> nregs, RegisterOperand VecList,
4969                      string asm, RegisterOperand gprty>
4970 : I<(outs VecList:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
4971   asm, "\t$Zt, $Pg/z, [$Rn, $Rm]",
4972   "",
4973   []>, Sched<[]> {
4974   bits<3> Pg;
4975   bits<5> Rm;
4976   bits<5> Rn;
4977   bits<5> Zt;
4978   let Inst{31-25} = 0b1010010;
4979   let Inst{24-23} = sz;
4980   let Inst{22-21} = nregs;
4981   let Inst{20-16} = Rm;
4982   let Inst{15-13} = 0b110;
4983   let Inst{12-10} = Pg;
4984   let Inst{9-5}   = Rn;
4985   let Inst{4-0}   = Zt;
4987   let mayLoad = 1;
4990 //===----------------------------------------------------------------------===//
4991 // SVE Memory - 32-bit Gather and Unsized Contiguous Group
4992 //===----------------------------------------------------------------------===//
4994 // bit xs      is '1' if offsets are signed
4995 // bit scaled  is '1' if the offsets are scaled
4996 class sve_mem_32b_gld_sv<bits<4> opc, bit xs, bit scaled, string asm,
4997                          RegisterOperand zprext>
4998 : I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
4999   asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
5000   "",
5001   []>, Sched<[]> {
5002   bits<3> Pg;
5003   bits<5> Rn;
5004   bits<5> Zm;
5005   bits<5> Zt;
5006   let Inst{31-25} = 0b1000010;
5007   let Inst{24-23} = opc{3-2};
5008   let Inst{22}    = xs;
5009   let Inst{21}    = scaled;
5010   let Inst{20-16} = Zm;
5011   let Inst{15}    = 0b0;
5012   let Inst{14-13} = opc{1-0};
5013   let Inst{12-10} = Pg;
5014   let Inst{9-5}   = Rn;
5015   let Inst{4-0}   = Zt;
5017   let mayLoad = 1;
5018   let Defs = !if(!eq(opc{0}, 1), [FFR], []);
5019   let Uses = !if(!eq(opc{0}, 1), [FFR], []);
5022 multiclass sve_mem_32b_gld_sv_32_scaled<bits<4> opc, string asm,
5023                                         RegisterOperand sxtw_opnd,
5024                                         RegisterOperand uxtw_opnd> {
5025   def _UXTW_SCALED_REAL : sve_mem_32b_gld_sv<opc, 0, 1, asm, uxtw_opnd>;
5026   def _SXTW_SCALED_REAL : sve_mem_32b_gld_sv<opc, 1, 1, asm, sxtw_opnd>;
5028   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5029                   (!cast<Instruction>(NAME # _UXTW_SCALED_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
5030   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5031                   (!cast<Instruction>(NAME # _SXTW_SCALED_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
5034 multiclass sve_mem_32b_gld_vs_32_unscaled<bits<4> opc, string asm,
5035                                           RegisterOperand sxtw_opnd,
5036                                           RegisterOperand uxtw_opnd> {
5037   def _UXTW_REAL : sve_mem_32b_gld_sv<opc, 0, 0, asm, uxtw_opnd>;
5038   def _SXTW_REAL : sve_mem_32b_gld_sv<opc, 1, 0, asm, sxtw_opnd>;
5040   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5041                   (!cast<Instruction>(NAME # _UXTW_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
5042   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5043                   (!cast<Instruction>(NAME # _SXTW_REAL) ZPR32:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
5047 class sve_mem_32b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
5048 : I<(outs Z_s:$Zt), (ins PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
5049   asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
5050   "",
5051   []>, Sched<[]> {
5052   bits<3> Pg;
5053   bits<5> Zn;
5054   bits<5> Zt;
5055   bits<5> imm5;
5056   let Inst{31-25} = 0b1000010;
5057   let Inst{24-23} = opc{3-2};
5058   let Inst{22-21} = 0b01;
5059   let Inst{20-16} = imm5;
5060   let Inst{15}    = 0b1;
5061   let Inst{14-13} = opc{1-0};
5062   let Inst{12-10} = Pg;
5063   let Inst{9-5}   = Zn;
5064   let Inst{4-0}   = Zt;
5066   let mayLoad = 1;
5067   let Defs = !if(!eq(opc{0}, 1), [FFR], []);
5068   let Uses = !if(!eq(opc{0}, 1), [FFR], []);
5071 multiclass sve_mem_32b_gld_vi_32_ptrs<bits<4> opc, string asm, Operand imm_ty> {
5072   def _IMM_REAL : sve_mem_32b_gld_vi<opc, asm, imm_ty>;
5074   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5075                   (!cast<Instruction>(NAME # _IMM_REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 0>;
5076   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
5077                   (!cast<Instruction>(NAME # _IMM_REAL) ZPR32:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5), 0>;
5078   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5079                   (!cast<Instruction>(NAME # _IMM_REAL) Z_s:$Zt, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
5082 class sve_mem_prfm_si<bits<2> msz, string asm>
5083 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, simm6s1:$imm6),
5084   asm, "\t$prfop, $Pg, [$Rn, $imm6, mul vl]",
5085   "",
5086   []>, Sched<[]> {
5087   bits<5> Rn;
5088   bits<3> Pg;
5089   bits<6> imm6;
5090   bits<4> prfop;
5091   let Inst{31-22} = 0b1000010111;
5092   let Inst{21-16} = imm6;
5093   let Inst{15}    = 0b0;
5094   let Inst{14-13} = msz;
5095   let Inst{12-10} = Pg;
5096   let Inst{9-5}   = Rn;
5097   let Inst{4}     = 0b0;
5098   let Inst{3-0}   = prfop;
5100   let hasSideEffects = 1;
5103 multiclass sve_mem_prfm_si<bits<2> msz, string asm> {
5104   def NAME : sve_mem_prfm_si<msz, asm>;
5106   def : InstAlias<asm # "\t$prfop, $Pg, [$Rn]",
5107                   (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, 0), 1>;
5110 class sve_mem_prfm_ss<bits<3> opc, string asm, RegisterOperand gprty>
5111 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, gprty:$Rm),
5112   asm, "\t$prfop, $Pg, [$Rn, $Rm]",
5113   "",
5114   []>, Sched<[]> {
5115   bits<5> Rm;
5116   bits<5> Rn;
5117   bits<3> Pg;
5118   bits<4> prfop;
5119   let Inst{31-25} = 0b1000010;
5120   let Inst{24-23} = opc{2-1};
5121   let Inst{22-21} = 0b00;
5122   let Inst{20-16} = Rm;
5123   let Inst{15}    = 0b1;
5124   let Inst{14}    = opc{0};
5125   let Inst{13}    = 0b0;
5126   let Inst{12-10} = Pg;
5127   let Inst{9-5}   = Rn;
5128   let Inst{4}     = 0b0;
5129   let Inst{3-0}   = prfop;
5131   let hasSideEffects = 1;
5134 class sve_mem_32b_prfm_sv<bits<2> msz, bit xs, string asm,
5135                           RegisterOperand zprext>
5136 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
5137   asm, "\t$prfop, $Pg, [$Rn, $Zm]",
5138   "",
5139   []>, Sched<[]> {
5140   bits<3> Pg;
5141   bits<5> Rn;
5142   bits<5> Zm;
5143   bits<4> prfop;
5144   let Inst{31-23} = 0b100001000;
5145   let Inst{22}    = xs;
5146   let Inst{21}    = 0b1;
5147   let Inst{20-16} = Zm;
5148   let Inst{15}    = 0b0;
5149   let Inst{14-13} = msz;
5150   let Inst{12-10} = Pg;
5151   let Inst{9-5}   = Rn;
5152   let Inst{4}     = 0b0;
5153   let Inst{3-0}   = prfop;
5155   let hasSideEffects = 1;
5158 multiclass sve_mem_32b_prfm_sv_scaled<bits<2> msz, string asm,
5159                                       RegisterOperand sxtw_opnd,
5160                                       RegisterOperand uxtw_opnd> {
5161   def _UXTW_SCALED : sve_mem_32b_prfm_sv<msz, 0, asm, uxtw_opnd>;
5162   def _SXTW_SCALED : sve_mem_32b_prfm_sv<msz, 1, asm, sxtw_opnd>;
5165 class sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
5166 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, imm_ty:$imm5),
5167   asm, "\t$prfop, $Pg, [$Zn, $imm5]",
5168   "",
5169   []>, Sched<[]> {
5170   bits<3> Pg;
5171   bits<5> Zn;
5172   bits<5> imm5;
5173   bits<4> prfop;
5174   let Inst{31-25} = 0b1000010;
5175   let Inst{24-23} = msz;
5176   let Inst{22-21} = 0b00;
5177   let Inst{20-16} = imm5;
5178   let Inst{15-13} = 0b111;
5179   let Inst{12-10} = Pg;
5180   let Inst{9-5}   = Zn;
5181   let Inst{4}     = 0b0;
5182   let Inst{3-0}   = prfop;
5185 multiclass sve_mem_32b_prfm_vi<bits<2> msz, string asm, Operand imm_ty> {
5186   def NAME : sve_mem_32b_prfm_vi<msz, asm, imm_ty>;
5188   def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
5189                   (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR32:$Zn, 0), 1>;
5192 class sve_mem_z_fill<string asm>
5193 : I<(outs ZPRAny:$Zt), (ins GPR64sp:$Rn, simm9:$imm9),
5194   asm, "\t$Zt, [$Rn, $imm9, mul vl]",
5195   "",
5196   []>, Sched<[]> {
5197   bits<5> Rn;
5198   bits<5> Zt;
5199   bits<9> imm9;
5200   let Inst{31-22} = 0b1000010110;
5201   let Inst{21-16} = imm9{8-3};
5202   let Inst{15-13} = 0b010;
5203   let Inst{12-10} = imm9{2-0};
5204   let Inst{9-5}   = Rn;
5205   let Inst{4-0}   = Zt;
5207   let mayLoad = 1;
5210 multiclass sve_mem_z_fill<string asm> {
5211   def NAME : sve_mem_z_fill<asm>;
5213   def : InstAlias<asm # "\t$Zt, [$Rn]",
5214                   (!cast<Instruction>(NAME) ZPRAny:$Zt, GPR64sp:$Rn, 0), 1>;
5217 class sve_mem_p_fill<string asm>
5218 : I<(outs PPRAny:$Pt), (ins GPR64sp:$Rn, simm9:$imm9),
5219   asm, "\t$Pt, [$Rn, $imm9, mul vl]",
5220   "",
5221   []>, Sched<[]> {
5222   bits<4> Pt;
5223   bits<5> Rn;
5224   bits<9> imm9;
5225   let Inst{31-22} = 0b1000010110;
5226   let Inst{21-16} = imm9{8-3};
5227   let Inst{15-13} = 0b000;
5228   let Inst{12-10} = imm9{2-0};
5229   let Inst{9-5}   = Rn;
5230   let Inst{4}     = 0b0;
5231   let Inst{3-0}   = Pt;
5233   let mayLoad = 1;
5236 multiclass sve_mem_p_fill<string asm> {
5237   def NAME : sve_mem_p_fill<asm>;
5239   def : InstAlias<asm # "\t$Pt, [$Rn]",
5240                   (!cast<Instruction>(NAME) PPRAny:$Pt, GPR64sp:$Rn, 0), 1>;
5243 class sve2_mem_gldnt_vs_base<bits<5> opc, dag iops, string asm,
5244                              RegisterOperand VecList>
5245 : I<(outs VecList:$Zt), iops,
5246   asm, "\t$Zt, $Pg/z, [$Zn, $Rm]",
5247   "",
5248   []>, Sched<[]> {
5249   bits<3> Pg;
5250   bits<5> Rm;
5251   bits<5> Zn;
5252   bits<5> Zt;
5253   let Inst{31}    = 0b1;
5254   let Inst{30}    = opc{4};
5255   let Inst{29-25} = 0b00010;
5256   let Inst{24-23} = opc{3-2};
5257   let Inst{22-21} = 0b00;
5258   let Inst{20-16} = Rm;
5259   let Inst{15}    = 0b1;
5260   let Inst{14-13} = opc{1-0};
5261   let Inst{12-10} = Pg;
5262   let Inst{9-5}   = Zn;
5263   let Inst{4-0}   = Zt;
5265   let mayLoad = 1;
5268 multiclass sve2_mem_gldnt_vs<bits<5> opc, string asm,
5269                              RegisterOperand listty, ZPRRegOp zprty> {
5270   def _REAL : sve2_mem_gldnt_vs_base<opc, (ins PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm),
5271                                      asm, listty>;
5273   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $Rm]",
5274                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, GPR64:$Rm), 0>;
5275   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5276                  (!cast<Instruction>(NAME # _REAL) zprty:$Zt, PPR3bAny:$Pg, zprty:$Zn, XZR), 0>;
5277   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5278                  (!cast<Instruction>(NAME # _REAL) listty:$Zt, PPR3bAny:$Pg, zprty:$Zn, XZR), 1>;
5281 //===----------------------------------------------------------------------===//
5282 // SVE Memory - 64-bit Gather Group
5283 //===----------------------------------------------------------------------===//
5285 // bit xs      is '1' if offsets are signed
5286 // bit scaled  is '1' if the offsets are scaled
5287 // bit lsl     is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
5288 class sve_mem_64b_gld_sv<bits<4> opc, bit xs, bit scaled, bit lsl, string asm,
5289                          RegisterOperand zprext>
5290 : I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
5291   asm, "\t$Zt, $Pg/z, [$Rn, $Zm]",
5292   "",
5293   []>, Sched<[]> {
5294   bits<3> Pg;
5295   bits<5> Rn;
5296   bits<5> Zm;
5297   bits<5> Zt;
5298   let Inst{31-25} = 0b1100010;
5299   let Inst{24-23} = opc{3-2};
5300   let Inst{22}    = xs;
5301   let Inst{21}    = scaled;
5302   let Inst{20-16} = Zm;
5303   let Inst{15}    = lsl;
5304   let Inst{14-13} = opc{1-0};
5305   let Inst{12-10} = Pg;
5306   let Inst{9-5}   = Rn;
5307   let Inst{4-0}   = Zt;
5309   let mayLoad = 1;
5310   let Defs = !if(!eq(opc{0}, 1), [FFR], []);
5311   let Uses = !if(!eq(opc{0}, 1), [FFR], []);
5314 multiclass sve_mem_64b_gld_sv_32_scaled<bits<4> opc, string asm,
5315                                         RegisterOperand sxtw_opnd,
5316                                         RegisterOperand uxtw_opnd> {
5317   def _UXTW_SCALED_REAL : sve_mem_64b_gld_sv<opc, 0, 1, 0, asm, uxtw_opnd>;
5318   def _SXTW_SCALED_REAL : sve_mem_64b_gld_sv<opc, 1, 1, 0, asm, sxtw_opnd>;
5320   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5321                   (!cast<Instruction>(NAME # _UXTW_SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
5322   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5323                   (!cast<Instruction>(NAME # _SXTW_SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
5326 multiclass sve_mem_64b_gld_vs_32_unscaled<bits<4> opc, string asm,
5327                                           RegisterOperand sxtw_opnd,
5328                                           RegisterOperand uxtw_opnd> {
5329   def _UXTW_REAL : sve_mem_64b_gld_sv<opc, 0, 0, 0, asm, uxtw_opnd>;
5330   def _SXTW_REAL : sve_mem_64b_gld_sv<opc, 1, 0, 0, asm, sxtw_opnd>;
5332   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5333                   (!cast<Instruction>(NAME # _UXTW_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, uxtw_opnd:$Zm), 0>;
5334   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5335                   (!cast<Instruction>(NAME # _SXTW_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, sxtw_opnd:$Zm), 0>;
5338 multiclass sve_mem_64b_gld_sv2_64_scaled<bits<4> opc, string asm,
5339                                          RegisterOperand zprext> {
5340   def _SCALED_REAL : sve_mem_64b_gld_sv<opc, 1, 1, 1, asm, zprext>;
5342   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5343                   (!cast<Instruction>(NAME # _SCALED_REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm), 0>;
5346 multiclass sve_mem_64b_gld_vs2_64_unscaled<bits<4> opc, string asm> {
5347   def _REAL : sve_mem_64b_gld_sv<opc, 1, 0, 1, asm, ZPR64ExtLSL8>;
5349   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Rn, $Zm]",
5350                   (!cast<Instruction>(NAME # _REAL) ZPR64:$Zt, PPR3bAny:$Pg, GPR64sp:$Rn, ZPR64ExtLSL8:$Zm), 0>;
5353 class sve_mem_64b_gld_vi<bits<4> opc, string asm, Operand imm_ty>
5354 : I<(outs Z_d:$Zt), (ins PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
5355   asm, "\t$Zt, $Pg/z, [$Zn, $imm5]",
5356   "",
5357   []>, Sched<[]> {
5358   bits<3> Pg;
5359   bits<5> Zn;
5360   bits<5> Zt;
5361   bits<5> imm5;
5362   let Inst{31-25} = 0b1100010;
5363   let Inst{24-23} = opc{3-2};
5364   let Inst{22-21} = 0b01;
5365   let Inst{20-16} = imm5;
5366   let Inst{15}    = 0b1;
5367   let Inst{14-13} = opc{1-0};
5368   let Inst{12-10} = Pg;
5369   let Inst{9-5}   = Zn;
5370   let Inst{4-0}   = Zt;
5372   let mayLoad = 1;
5373   let Defs = !if(!eq(opc{0}, 1), [FFR], []);
5374   let Uses = !if(!eq(opc{0}, 1), [FFR], []);
5377 multiclass sve_mem_64b_gld_vi_64_ptrs<bits<4> opc, string asm, Operand imm_ty> {
5378   def _IMM_REAL : sve_mem_64b_gld_vi<opc, asm, imm_ty>;
5380   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5381                   (!cast<Instruction>(NAME # _IMM_REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 0>;
5382   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn, $imm5]",
5383                  (!cast<Instruction>(NAME # _IMM_REAL) ZPR64:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5), 0>;
5384   def : InstAlias<asm # "\t$Zt, $Pg/z, [$Zn]",
5385                   (!cast<Instruction>(NAME # _IMM_REAL) Z_d:$Zt, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
5388 // bit lsl is '0' if the offsets are extended (uxtw/sxtw), '1' if shifted (lsl)
5389 class sve_mem_64b_prfm_sv<bits<2> msz, bit xs, bit lsl, string asm,
5390                           RegisterOperand zprext>
5391 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, GPR64sp:$Rn, zprext:$Zm),
5392   asm, "\t$prfop, $Pg, [$Rn, $Zm]",
5393   "",
5394   []>, Sched<[]> {
5395   bits<3> Pg;
5396   bits<5> Rn;
5397   bits<5> Zm;
5398   bits<4> prfop;
5399   let Inst{31-23} = 0b110001000;
5400   let Inst{22}    = xs;
5401   let Inst{21}    = 0b1;
5402   let Inst{20-16} = Zm;
5403   let Inst{15}    = lsl;
5404   let Inst{14-13} = msz;
5405   let Inst{12-10} = Pg;
5406   let Inst{9-5}   = Rn;
5407   let Inst{4}     = 0b0;
5408   let Inst{3-0}   = prfop;
5410   let hasSideEffects = 1;
5413 multiclass sve_mem_64b_prfm_sv_ext_scaled<bits<2> msz, string asm,
5414                                           RegisterOperand sxtw_opnd,
5415                                           RegisterOperand uxtw_opnd> {
5416   def _UXTW_SCALED : sve_mem_64b_prfm_sv<msz, 0, 0, asm, uxtw_opnd>;
5417   def _SXTW_SCALED : sve_mem_64b_prfm_sv<msz, 1, 0, asm, sxtw_opnd>;
5420 multiclass sve_mem_64b_prfm_sv_lsl_scaled<bits<2> msz, string asm,
5421                                           RegisterOperand zprext> {
5422   def NAME : sve_mem_64b_prfm_sv<msz, 1, 1, asm, zprext>;
5426 class sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty>
5427 : I<(outs), (ins sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, imm_ty:$imm5),
5428   asm, "\t$prfop, $Pg, [$Zn, $imm5]",
5429   "",
5430   []>, Sched<[]> {
5431   bits<3> Pg;
5432   bits<5> Zn;
5433   bits<5> imm5;
5434   bits<4> prfop;
5435   let Inst{31-25} = 0b1100010;
5436   let Inst{24-23} = msz;
5437   let Inst{22-21} = 0b00;
5438   let Inst{20-16} = imm5;
5439   let Inst{15-13} = 0b111;
5440   let Inst{12-10} = Pg;
5441   let Inst{9-5}   = Zn;
5442   let Inst{4}     = 0b0;
5443   let Inst{3-0}   = prfop;
5445   let hasSideEffects = 1;
5448 multiclass sve_mem_64b_prfm_vi<bits<2> msz, string asm, Operand imm_ty> {
5449   def NAME : sve_mem_64b_prfm_vi<msz, asm, imm_ty>;
5451   def : InstAlias<asm # "\t$prfop, $Pg, [$Zn]",
5452                   (!cast<Instruction>(NAME) sve_prfop:$prfop, PPR3bAny:$Pg, ZPR64:$Zn, 0), 1>;
5456 //===----------------------------------------------------------------------===//
5457 // SVE Compute Vector Address Group
5458 //===----------------------------------------------------------------------===//
5460 class sve_int_bin_cons_misc_0_a<bits<2> opc, bits<2> msz, string asm,
5461                                 ZPRRegOp zprty, RegisterOperand zprext>
5462 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprext:$Zm),
5463   asm, "\t$Zd, [$Zn, $Zm]",
5464   "",
5465   []>, Sched<[]> {
5466   bits<5> Zd;
5467   bits<5> Zn;
5468   bits<5> Zm;
5469   let Inst{31-24} = 0b00000100;
5470   let Inst{23-22} = opc;
5471   let Inst{21}    = 0b1;
5472   let Inst{20-16} = Zm;
5473   let Inst{15-12} = 0b1010;
5474   let Inst{11-10} = msz;
5475   let Inst{9-5}   = Zn;
5476   let Inst{4-0}   = Zd;
5479 multiclass sve_int_bin_cons_misc_0_a_uxtw<bits<2> opc, string asm> {
5480   def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtUXTW8>;
5481   def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtUXTW16>;
5482   def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtUXTW32>;
5483   def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtUXTW64>;
5486 multiclass sve_int_bin_cons_misc_0_a_sxtw<bits<2> opc, string asm> {
5487   def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtSXTW8>;
5488   def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtSXTW16>;
5489   def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtSXTW32>;
5490   def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtSXTW64>;
5493 multiclass sve_int_bin_cons_misc_0_a_32_lsl<bits<2> opc, string asm> {
5494   def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR32, ZPR32ExtLSL8>;
5495   def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR32, ZPR32ExtLSL16>;
5496   def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR32, ZPR32ExtLSL32>;
5497   def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR32, ZPR32ExtLSL64>;
5500 multiclass sve_int_bin_cons_misc_0_a_64_lsl<bits<2> opc, string asm> {
5501   def _0 : sve_int_bin_cons_misc_0_a<opc, 0b00, asm, ZPR64, ZPR64ExtLSL8>;
5502   def _1 : sve_int_bin_cons_misc_0_a<opc, 0b01, asm, ZPR64, ZPR64ExtLSL16>;
5503   def _2 : sve_int_bin_cons_misc_0_a<opc, 0b10, asm, ZPR64, ZPR64ExtLSL32>;
5504   def _3 : sve_int_bin_cons_misc_0_a<opc, 0b11, asm, ZPR64, ZPR64ExtLSL64>;
5508 //===----------------------------------------------------------------------===//
5509 // SVE Integer Misc - Unpredicated Group
5510 //===----------------------------------------------------------------------===//
5512 class sve_int_bin_cons_misc_0_b<bits<2> sz, string asm, ZPRRegOp zprty>
5513 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
5514   asm, "\t$Zd, $Zn, $Zm",
5515   "",
5516   []>, Sched<[]> {
5517   bits<5> Zd;
5518   bits<5> Zm;
5519   bits<5> Zn;
5520   let Inst{31-24} = 0b00000100;
5521   let Inst{23-22} = sz;
5522   let Inst{21}    = 0b1;
5523   let Inst{20-16} = Zm;
5524   let Inst{15-10} = 0b101100;
5525   let Inst{9-5}   = Zn;
5526   let Inst{4-0}   = Zd;
5529 multiclass sve_int_bin_cons_misc_0_b<string asm> {
5530   def _H : sve_int_bin_cons_misc_0_b<0b01, asm, ZPR16>;
5531   def _S : sve_int_bin_cons_misc_0_b<0b10, asm, ZPR32>;
5532   def _D : sve_int_bin_cons_misc_0_b<0b11, asm, ZPR64>;
5535 class sve_int_bin_cons_misc_0_c<bits<8> opc, string asm, ZPRRegOp zprty>
5536 : I<(outs zprty:$Zd), (ins zprty:$Zn),
5537   asm, "\t$Zd, $Zn",
5538   "",
5539   []>, Sched<[]> {
5540   bits<5> Zd;
5541   bits<5> Zn;
5542   let Inst{31-24} = 0b00000100;
5543   let Inst{23-22} = opc{7-6};
5544   let Inst{21}    = 0b1;
5545   let Inst{20-16} = opc{5-1};
5546   let Inst{15-11} = 0b10111;
5547   let Inst{10}    = opc{0};
5548   let Inst{9-5}   = Zn;
5549   let Inst{4-0}   = Zd;
5552 //===----------------------------------------------------------------------===//
5553 // SVE Integer Reduction Group
5554 //===----------------------------------------------------------------------===//
5556 class sve_int_reduce<bits<2> sz8_32, bits<2> fmt, bits<3> opc, string asm,
5557                      ZPRRegOp zprty, RegisterClass regtype>
5558 : I<(outs regtype:$Vd), (ins PPR3bAny:$Pg, zprty:$Zn),
5559   asm, "\t$Vd, $Pg, $Zn",
5560   "",
5561   []>, Sched<[]> {
5562   bits<3> Pg;
5563   bits<5> Vd;
5564   bits<5> Zn;
5565   let Inst{31-24} = 0b00000100;
5566   let Inst{23-22} = sz8_32;
5567   let Inst{21}    = 0b0;
5568   let Inst{20-19} = fmt;
5569   let Inst{18-16} = opc;
5570   let Inst{15-13} = 0b001;
5571   let Inst{12-10} = Pg;
5572   let Inst{9-5}   = Zn;
5573   let Inst{4-0}   = Vd;
5576 multiclass sve_int_reduce_0_saddv<bits<3> opc, string asm> {
5577   def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64>;
5578   def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64>;
5579   def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64>;
5582 multiclass sve_int_reduce_0_uaddv<bits<3> opc, string asm> {
5583   def _B : sve_int_reduce<0b00, 0b00, opc, asm, ZPR8, FPR64>;
5584   def _H : sve_int_reduce<0b01, 0b00, opc, asm, ZPR16, FPR64>;
5585   def _S : sve_int_reduce<0b10, 0b00, opc, asm, ZPR32, FPR64>;
5586   def _D : sve_int_reduce<0b11, 0b00, opc, asm, ZPR64, FPR64>;
5589 multiclass sve_int_reduce_1<bits<3> opc, string asm> {
5590   def _B : sve_int_reduce<0b00, 0b01, opc, asm, ZPR8, FPR8>;
5591   def _H : sve_int_reduce<0b01, 0b01, opc, asm, ZPR16, FPR16>;
5592   def _S : sve_int_reduce<0b10, 0b01, opc, asm, ZPR32, FPR32>;
5593   def _D : sve_int_reduce<0b11, 0b01, opc, asm, ZPR64, FPR64>;
5596 multiclass sve_int_reduce_2<bits<3> opc, string asm> {
5597   def _B : sve_int_reduce<0b00, 0b11, opc, asm, ZPR8, FPR8>;
5598   def _H : sve_int_reduce<0b01, 0b11, opc, asm, ZPR16, FPR16>;
5599   def _S : sve_int_reduce<0b10, 0b11, opc, asm, ZPR32, FPR32>;
5600   def _D : sve_int_reduce<0b11, 0b11, opc, asm, ZPR64, FPR64>;
5603 class sve_int_movprfx_pred<bits<2> sz8_32, bits<3> opc, string asm,
5604                            ZPRRegOp zprty, string pg_suffix, dag iops>
5605 : I<(outs zprty:$Zd), iops,
5606   asm, "\t$Zd, $Pg"#pg_suffix#", $Zn",
5607   "",
5608   []>, Sched<[]> {
5609   bits<3> Pg;
5610   bits<5> Zd;
5611   bits<5> Zn;
5612   let Inst{31-24} = 0b00000100;
5613   let Inst{23-22} = sz8_32;
5614   let Inst{21-19} = 0b010;
5615   let Inst{18-16} = opc;
5616   let Inst{15-13} = 0b001;
5617   let Inst{12-10} = Pg;
5618   let Inst{9-5}   = Zn;
5619   let Inst{4-0}   = Zd;
5621   let ElementSize = zprty.ElementSize;
5624 multiclass sve_int_movprfx_pred_merge<bits<3> opc, string asm> {
5625 let Constraints = "$Zd = $_Zd" in {
5626   def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/m",
5627                                 (ins ZPR8:$_Zd, PPR3bAny:$Pg, ZPR8:$Zn)>;
5628   def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/m",
5629                                 (ins ZPR16:$_Zd, PPR3bAny:$Pg, ZPR16:$Zn)>;
5630   def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/m",
5631                                 (ins ZPR32:$_Zd, PPR3bAny:$Pg, ZPR32:$Zn)>;
5632   def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/m",
5633                                 (ins ZPR64:$_Zd, PPR3bAny:$Pg, ZPR64:$Zn)>;
5637 multiclass sve_int_movprfx_pred_zero<bits<3> opc, string asm> {
5638   def _B : sve_int_movprfx_pred<0b00, opc, asm, ZPR8, "/z",
5639                                 (ins PPR3bAny:$Pg, ZPR8:$Zn)>;
5640   def _H : sve_int_movprfx_pred<0b01, opc, asm, ZPR16, "/z",
5641                                 (ins PPR3bAny:$Pg, ZPR16:$Zn)>;
5642   def _S : sve_int_movprfx_pred<0b10, opc, asm, ZPR32, "/z",
5643                                 (ins PPR3bAny:$Pg, ZPR32:$Zn)>;
5644   def _D : sve_int_movprfx_pred<0b11, opc, asm, ZPR64, "/z",
5645                                 (ins PPR3bAny:$Pg, ZPR64:$Zn)>;
5648 //===----------------------------------------------------------------------===//
5649 // SVE Propagate Break Group
5650 //===----------------------------------------------------------------------===//
5652 class sve_int_brkp<bits<2> opc, string asm>
5653 : I<(outs PPR8:$Pd), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$Pm),
5654   asm, "\t$Pd, $Pg/z, $Pn, $Pm",
5655   "",
5656   []>, Sched<[]> {
5657   bits<4> Pd;
5658   bits<4> Pg;
5659   bits<4> Pm;
5660   bits<4> Pn;
5661   let Inst{31-24} = 0b00100101;
5662   let Inst{23}    = 0b0;
5663   let Inst{22}    = opc{1};
5664   let Inst{21-20} = 0b00;
5665   let Inst{19-16} = Pm;
5666   let Inst{15-14} = 0b11;
5667   let Inst{13-10} = Pg;
5668   let Inst{9}     = 0b0;
5669   let Inst{8-5}   = Pn;
5670   let Inst{4}     = opc{0};
5671   let Inst{3-0}   = Pd;
5673   let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
5677 //===----------------------------------------------------------------------===//
5678 // SVE Partition Break Group
5679 //===----------------------------------------------------------------------===//
5681 class sve_int_brkn<bit S, string asm>
5682 : I<(outs PPR8:$Pdm), (ins PPRAny:$Pg, PPR8:$Pn, PPR8:$_Pdm),
5683   asm, "\t$Pdm, $Pg/z, $Pn, $_Pdm",
5684   "",
5685   []>, Sched<[]> {
5686   bits<4> Pdm;
5687   bits<4> Pg;
5688   bits<4> Pn;
5689   let Inst{31-23} = 0b001001010;
5690   let Inst{22}    = S;
5691   let Inst{21-14} = 0b01100001;
5692   let Inst{13-10} = Pg;
5693   let Inst{9}     = 0b0;
5694   let Inst{8-5}   = Pn;
5695   let Inst{4}     = 0b0;
5696   let Inst{3-0}   = Pdm;
5698   let Constraints = "$Pdm = $_Pdm";
5699   let Defs = !if(!eq (S, 0b1), [NZCV], []);
5702 class sve_int_break<bits<3> opc, string asm, string suffix, dag iops>
5703 : I<(outs PPR8:$Pd), iops,
5704   asm, "\t$Pd, $Pg"#suffix#", $Pn",
5705   "",
5706   []>, Sched<[]> {
5707   bits<4> Pd;
5708   bits<4> Pg;
5709   bits<4> Pn;
5710   let Inst{31-24} = 0b00100101;
5711   let Inst{23-22} = opc{2-1};
5712   let Inst{21-14} = 0b01000001;
5713   let Inst{13-10} = Pg;
5714   let Inst{9}     = 0b0;
5715   let Inst{8-5}   = Pn;
5716   let Inst{4}     = opc{0};
5717   let Inst{3-0}   = Pd;
5719   let Constraints = !if(!eq (opc{0}, 1), "$Pd = $_Pd", "");
5720   let Defs = !if(!eq (opc{1}, 1), [NZCV], []);
5724 multiclass sve_int_break_m<bits<3> opc, string asm> {
5725   def NAME : sve_int_break<opc, asm, "/m", (ins PPR8:$_Pd, PPRAny:$Pg, PPR8:$Pn)>;
5728 multiclass sve_int_break_z<bits<3> opc, string asm> {
5729   def NAME : sve_int_break<opc, asm, "/z", (ins PPRAny:$Pg, PPR8:$Pn)>;
5732 //===----------------------------------------------------------------------===//
5733 // SVE2 String Processing Group
5734 //===----------------------------------------------------------------------===//
5736 class sve2_char_match<bit sz, bit opc, string asm,
5737                       PPRRegOp pprty, ZPRRegOp zprty>
5738 : I<(outs pprty:$Pd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
5739   asm, "\t$Pd, $Pg/z, $Zn, $Zm",
5740   "",
5741   []>, Sched<[]> {
5742   bits<4> Pd;
5743   bits<3> Pg;
5744   bits<5> Zm;
5745   bits<5> Zn;
5746   let Inst{31-23} = 0b010001010;
5747   let Inst{22}    = sz;
5748   let Inst{21}    = 0b1;
5749   let Inst{20-16} = Zm;
5750   let Inst{15-13} = 0b100;
5751   let Inst{12-10} = Pg;
5752   let Inst{9-5}   = Zn;
5753   let Inst{4}     = opc;
5754   let Inst{3-0}   = Pd;
5756   let Defs = [NZCV];
5759 multiclass sve2_char_match<bit opc, string asm> {
5760   def _B : sve2_char_match<0b0, opc, asm, PPR8, ZPR8>;
5761   def _H : sve2_char_match<0b1, opc, asm, PPR16, ZPR16>;
5764 //===----------------------------------------------------------------------===//
5765 // SVE2 Histogram Computation - Segment Group
5766 //===----------------------------------------------------------------------===//
5768 class sve2_hist_gen_segment<string asm>
5769 : I<(outs ZPR8:$Zd), (ins ZPR8:$Zn, ZPR8:$Zm),
5770   asm, "\t$Zd, $Zn, $Zm",
5771   "",
5772   []>, Sched<[]> {
5773   bits<5> Zd;
5774   bits<5> Zn;
5775   bits<5> Zm;
5776   let Inst{31-21} = 0b01000101001;
5777   let Inst{20-16} = Zm;
5778   let Inst{15-10} = 0b101000;
5779   let Inst{9-5}   = Zn;
5780   let Inst{4-0}   = Zd;
5783 //===----------------------------------------------------------------------===//
5784 // SVE2 Histogram Computation - Vector Group
5785 //===----------------------------------------------------------------------===//
5787 class sve2_hist_gen_vector<bit sz, string asm, ZPRRegOp zprty>
5788 : I<(outs zprty:$Zd), (ins PPR3bAny:$Pg, zprty:$Zn, zprty:$Zm),
5789   asm, "\t$Zd, $Pg/z, $Zn, $Zm",
5790   "",
5791   []>, Sched<[]> {
5792   bits<5> Zd;
5793   bits<5> Zn;
5794   bits<3> Pg;
5795   bits<5> Zm;
5796   let Inst{31-23} = 0b010001011;
5797   let Inst{22}    = sz;
5798   let Inst{21}    = 0b1;
5799   let Inst{20-16} = Zm;
5800   let Inst{15-13} = 0b110;
5801   let Inst{12-10} = Pg;
5802   let Inst{9-5}   = Zn;
5803   let Inst{4-0}   = Zd;
5806 multiclass sve2_hist_gen_vector<string asm> {
5807   def _S : sve2_hist_gen_vector<0b0, asm, ZPR32>;
5808   def _D : sve2_hist_gen_vector<0b1, asm, ZPR64>;
5811 //===----------------------------------------------------------------------===//
5812 // SVE2 Crypto Extensions Group
5813 //===----------------------------------------------------------------------===//
5815 class sve2_crypto_cons_bin_op<bit opc, string asm, ZPRRegOp zprty>
5816 : I<(outs zprty:$Zd), (ins zprty:$Zn, zprty:$Zm),
5817   asm, "\t$Zd, $Zn, $Zm",
5818   "",
5819   []>, Sched<[]> {
5820   bits<5> Zd;
5821   bits<5> Zn;
5822   bits<5> Zm;
5823   let Inst{31-21} = 0b01000101001;
5824   let Inst{20-16} = Zm;
5825   let Inst{15-11} = 0b11110;
5826   let Inst{10}    = opc;
5827   let Inst{9-5}   = Zn;
5828   let Inst{4-0}   = Zd;
5831 class sve2_crypto_des_bin_op<bits<2> opc, string asm, ZPRRegOp zprty>
5832 : I<(outs zprty:$Zdn), (ins zprty:$_Zdn, zprty:$Zm),
5833   asm, "\t$Zdn, $_Zdn, $Zm",
5834   "",
5835   []>, Sched<[]> {
5836   bits<5> Zdn;
5837   bits<5> Zm;
5838   let Inst{31-17} = 0b010001010010001;
5839   let Inst{16}    = opc{1};
5840   let Inst{15-11} = 0b11100;
5841   let Inst{10}    = opc{0};
5842   let Inst{9-5}   = Zm;
5843   let Inst{4-0}   = Zdn;
5845   let Constraints = "$Zdn = $_Zdn";
5848 class sve2_crypto_unary_op<bit opc, string asm>
5849 : I<(outs ZPR8:$Zdn), (ins ZPR8:$_Zdn),
5850   asm, "\t$Zdn, $_Zdn",
5851   "",
5852   []>, Sched<[]> {
5853   bits<5> Zdn;
5854   let Inst{31-11} = 0b010001010010000011100;
5855   let Inst{10}    = opc;
5856   let Inst{9-5}   = 0b00000;
5857   let Inst{4-0}   = Zdn;
5859   let Constraints = "$Zdn = $_Zdn";