xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AArch64/SMEInstrFormats.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1fe6060f1SDimitry Andric//=-- SMEInstrFormats.td -  AArch64 SME Instruction classes -*- tablegen -*--=//
2fe6060f1SDimitry Andric//
3fe6060f1SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fe6060f1SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
5fe6060f1SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fe6060f1SDimitry Andric//
7fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
8fe6060f1SDimitry Andric//
9fe6060f1SDimitry Andric// AArch64 Scalable Matrix Extension (SME) Instruction Class Definitions.
10fe6060f1SDimitry Andric//
11fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
12fe6060f1SDimitry Andric
135f757f3fSDimitry Andricdef imm_to_tile8   : ComplexPattern<i32, 1, "ImmToReg<AArch64::ZAB0, 0>",  []>;
145f757f3fSDimitry Andricdef imm_to_tile16  : ComplexPattern<i32, 1, "ImmToReg<AArch64::ZAH0, 1>",  []>;
155f757f3fSDimitry Andricdef imm_to_tile32  : ComplexPattern<i32, 1, "ImmToReg<AArch64::ZAS0, 3>",  []>;
165f757f3fSDimitry Andricdef imm_to_tile64  : ComplexPattern<i32, 1, "ImmToReg<AArch64::ZAD0, 7>",  []>;
175f757f3fSDimitry Andricdef imm_to_tile128 : ComplexPattern<i32, 1, "ImmToReg<AArch64::ZAQ0, 15>", []>;
185f757f3fSDimitry Andricdef imm_to_zt      : ComplexPattern<i32, 1, "ImmToReg<AArch64::ZT0,  0>",  []>;
1981ad6265SDimitry Andric
20bdd1243dSDimitry Andricdef tileslice8   : ComplexPattern<i32 , 2, "SelectSMETileSlice<15, 1>", []>;
21bdd1243dSDimitry Andricdef tileslice16  : ComplexPattern<i32 , 2, "SelectSMETileSlice<7,  1>", []>;
22bdd1243dSDimitry Andricdef tileslice32  : ComplexPattern<i32 , 2, "SelectSMETileSlice<3,  1>", []>;
23bdd1243dSDimitry Andricdef tileslice64  : ComplexPattern<i32 , 2, "SelectSMETileSlice<1,  1>", []>;
24bdd1243dSDimitry Andricdef tileslice128 : ComplexPattern<i32 , 2, "SelectSMETileSlice<0,  1>", []>; // nop
25bdd1243dSDimitry Andric
26bdd1243dSDimitry Andricdef tileslicerange3s2 : ComplexPattern<i32, 2, "SelectSMETileSlice<14, 2>", []>;
27bdd1243dSDimitry Andricdef tileslicerange2s2 : ComplexPattern<i32, 2, "SelectSMETileSlice<6,  2>", []>;
2806c3fb27SDimitry Andricdef tileslicerange1s2 : ComplexPattern<i32, 2, "SelectSMETileSlice<2,  2>", []>;
2906c3fb27SDimitry Andricdef tileslicerange0s2 : ComplexPattern<i32, 2, "SelectSMETileSlice<0,  2>", []>;
3006c3fb27SDimitry Andric
3106c3fb27SDimitry Andricdef tileslicerange2s4 : ComplexPattern<i32, 2, "SelectSMETileSlice<12, 4>", []>;
3206c3fb27SDimitry Andricdef tileslicerange1s4 : ComplexPattern<i32, 2, "SelectSMETileSlice<4,  4>", []>;
3306c3fb27SDimitry Andricdef tileslicerange0s4 : ComplexPattern<i32, 2, "SelectSMETileSlice<0,  4>", []>;
3481ad6265SDimitry Andric
3581ad6265SDimitry Andricdef am_sme_indexed_b4 :ComplexPattern<iPTR, 2, "SelectAddrModeIndexedSVE<0,15>", [], [SDNPWantRoot]>;
3681ad6265SDimitry Andric
375f757f3fSDimitry Andricdef SDTZALoadStore : SDTypeProfile<0, 3, [SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisInt<2>]>;
385f757f3fSDimitry Andricdef AArch64SMELdr : SDNode<"AArch64ISD::SME_ZA_LDR", SDTZALoadStore,
395f757f3fSDimitry Andric                             [SDNPHasChain, SDNPSideEffect, SDNPMayLoad]>;
405f757f3fSDimitry Andricdef AArch64SMEStr : SDNode<"AArch64ISD::SME_ZA_STR", SDTZALoadStore,
415f757f3fSDimitry Andric                             [SDNPHasChain, SDNPSideEffect, SDNPMayStore]>;
425f757f3fSDimitry Andric
43fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
44bdd1243dSDimitry Andric// SME Pseudo Classes
45bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
46bdd1243dSDimitry Andric
47bdd1243dSDimitry Andricdef getSMEPseudoMap : InstrMapping {
48bdd1243dSDimitry Andric  let FilterClass = "SMEPseudo2Instr";
49bdd1243dSDimitry Andric  let RowFields = ["PseudoName"];
50bdd1243dSDimitry Andric  let ColFields = ["IsInstr"];
51bdd1243dSDimitry Andric  let KeyCol = ["0"];
52bdd1243dSDimitry Andric  let ValueCols = [["1"]];
53bdd1243dSDimitry Andric}
54bdd1243dSDimitry Andric
55bdd1243dSDimitry Andricclass SMEPseudo2Instr<string name, bit instr> {
56bdd1243dSDimitry Andric  string PseudoName = name;
57bdd1243dSDimitry Andric  bit IsInstr = instr;
58bdd1243dSDimitry Andric}
59bdd1243dSDimitry Andric
60bdd1243dSDimitry Andricclass sme_outer_product_pseudo<ZPRRegOp zpr_ty, SMEMatrixTypeEnum za_flag>
61bdd1243dSDimitry Andric    : Pseudo<(outs), (ins i32imm:$tile, PPR3bAny:$pn, PPR3bAny:$pm,
62bdd1243dSDimitry Andric                          zpr_ty:$zn, zpr_ty:$zm), []>,
63bdd1243dSDimitry Andric      Sched<[]> {
64bdd1243dSDimitry Andric  // Translated to the actual instructions in AArch64ISelLowering.cpp
65bdd1243dSDimitry Andric  let SMEMatrixType = za_flag;
66bdd1243dSDimitry Andric  let usesCustomInserter = 1;
67bdd1243dSDimitry Andric}
68bdd1243dSDimitry Andric
69bdd1243dSDimitry Andricclass sme2_za_array_2op_multi_single_pseudo<string name, Operand index_ty, RegisterOperand multi_vector_ty,
70bdd1243dSDimitry Andric                                            ZPRRegOp zpr_ty, SMEMatrixTypeEnum za_flag>
71bdd1243dSDimitry Andric    : SMEPseudo2Instr<name, 0>,
72bdd1243dSDimitry Andric      Pseudo<(outs), (ins MatrixIndexGPR32Op8_11:$Rv, index_ty:$imm3, multi_vector_ty:$Zn, zpr_ty:$Zm), []> {
73bdd1243dSDimitry Andric  let SMEMatrixType = za_flag;
74bdd1243dSDimitry Andric  let usesCustomInserter = 1;
75bdd1243dSDimitry Andric}
76bdd1243dSDimitry Andric
77bdd1243dSDimitry Andricclass sme2_za_array_2op_multi_multi_pseudo<string name, Operand index_ty, RegisterOperand multi_vector_ty,
78bdd1243dSDimitry Andric                                           SMEMatrixTypeEnum za_flag>
79bdd1243dSDimitry Andric    : SMEPseudo2Instr<name, 0>,
80bdd1243dSDimitry Andric      Pseudo<(outs), (ins MatrixIndexGPR32Op8_11:$Rv, index_ty:$imm3, multi_vector_ty:$Zn, multi_vector_ty:$Zm), []> {
81bdd1243dSDimitry Andric  let SMEMatrixType = za_flag;
82bdd1243dSDimitry Andric  let usesCustomInserter = 1;
83bdd1243dSDimitry Andric}
84bdd1243dSDimitry Andric
85bdd1243dSDimitry Andricclass sme2_za_array_2op_multi_index_pseudo<string name, Operand index_ty, RegisterOperand multi_vector_ty,
86bdd1243dSDimitry Andric                                           ZPRRegOp zpr_ty, Operand imm_ty, SMEMatrixTypeEnum za_flag>
87bdd1243dSDimitry Andric    : SMEPseudo2Instr<name, 0>,
88bdd1243dSDimitry Andric      Pseudo<(outs), (ins MatrixIndexGPR32Op8_11:$Rv, index_ty:$imm3, multi_vector_ty:$Zn, zpr_ty:$Zm, imm_ty:$i), []> {
89bdd1243dSDimitry Andric  let SMEMatrixType = za_flag;
90bdd1243dSDimitry Andric  let usesCustomInserter = 1;
91bdd1243dSDimitry Andric}
92bdd1243dSDimitry Andric
9306c3fb27SDimitry Andricclass sme2_move_to_za_pseudo<string name, Operand imm_ty, RegisterOperand multi_vector_ty, SMEMatrixTypeEnum za_flag>
9406c3fb27SDimitry Andric    : SMEPseudo2Instr<name, 0>,
9506c3fb27SDimitry Andric      Pseudo<(outs), (ins MatrixIndexGPR32Op8_11:$Rs, imm_ty:$imm, multi_vector_ty:$Zn), []> {
9606c3fb27SDimitry Andric  let SMEMatrixType = za_flag;
9706c3fb27SDimitry Andric  let usesCustomInserter = 1;
9806c3fb27SDimitry Andric}
9906c3fb27SDimitry Andric
10006c3fb27SDimitry Andricclass sme2_move_to_tile_pseudo<string name, Operand tile_imm, Operand imm_ty, RegisterOperand multi_vector_ty, SMEMatrixTypeEnum za_flag>
10106c3fb27SDimitry Andric    : SMEPseudo2Instr<name, 0>,
10206c3fb27SDimitry Andric      Pseudo<(outs), (ins tile_imm:$tile, MatrixIndexGPR32Op12_15:$Rs, imm_ty:$imm, multi_vector_ty:$Zn), []> {
10306c3fb27SDimitry Andric  let SMEMatrixType = za_flag;
10406c3fb27SDimitry Andric  let usesCustomInserter = 1;
10506c3fb27SDimitry Andric}
10606c3fb27SDimitry Andric
107*0fca6ea1SDimitry Andricclass sem2p1_zero_matrix_pseudo<string name, Operand index_ty, SMEMatrixTypeEnum za_flag>
108*0fca6ea1SDimitry Andric    : SMEPseudo2Instr<name, 0>,
109*0fca6ea1SDimitry Andric      Pseudo<(outs), (ins MatrixIndexGPR32Op8_11:$Rs, index_ty:$imm), []> {
110*0fca6ea1SDimitry Andric  let SMEMatrixType = za_flag;
111*0fca6ea1SDimitry Andric  let usesCustomInserter = 1;
112*0fca6ea1SDimitry Andric}
113*0fca6ea1SDimitry Andric
114*0fca6ea1SDimitry Andricclass sme2_movez_to_tile_pseudo<string name, Operand tile_imm, Operand imm_ty, RegisterOperand vector_ty, SMEMatrixTypeEnum za_flag>
115*0fca6ea1SDimitry Andric    : SMEPseudo2Instr<name, 0>,
116*0fca6ea1SDimitry Andric      Pseudo<(outs vector_ty:$Zn), (ins tile_imm:$tile, MatrixIndexGPR32Op12_15:$Rs, imm_ty:$imm), []> {
117*0fca6ea1SDimitry Andric  let SMEMatrixType = za_flag;
118*0fca6ea1SDimitry Andric  let usesCustomInserter = 1;
119*0fca6ea1SDimitry Andric}
120*0fca6ea1SDimitry Andric
121*0fca6ea1SDimitry Andricclass sme2_movaz_array_to_tile_pseudo<string name, Operand index_ty, RegisterOperand multi_vector_ty,
122*0fca6ea1SDimitry Andric                                      SMEMatrixTypeEnum za_flag>
123*0fca6ea1SDimitry Andric    : SMEPseudo2Instr<name, 0>,
124*0fca6ea1SDimitry Andric      Pseudo<(outs multi_vector_ty:$Zd), (ins MatrixIndexGPR32Op8_11:$Rv, index_ty:$imm3), []> {
125*0fca6ea1SDimitry Andric  let SMEMatrixType = za_flag;
126*0fca6ea1SDimitry Andric  let usesCustomInserter = 1;
127*0fca6ea1SDimitry Andric}
128*0fca6ea1SDimitry Andric
129bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
130bdd1243dSDimitry Andric// SME pattern match helpers.
131bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
132bdd1243dSDimitry Andric
133bdd1243dSDimitry Andricclass SME2_ZA_TwoOp_Multi_Single_Pat<string name, SDPatternOperator intrinsic, Operand index_ty, ZPRRegOp zpr_ty,
134bdd1243dSDimitry Andric                                     ValueType vt, ComplexPattern tileslice>
135bdd1243dSDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)), vt:$Zn, vt:$Zm),
136bdd1243dSDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset, vt:$Zn, zpr_ty:$Zm)>;
137bdd1243dSDimitry Andric
138bdd1243dSDimitry Andric
139bdd1243dSDimitry Andricclass SME2_ZA_TwoOp_VG2_Multi_Single_Pat<string name, SDPatternOperator intrinsic, Operand index_ty, ZPRRegOp zpr_ty,
140bdd1243dSDimitry Andric                                         ValueType vt, ComplexPattern tileslice>
141bdd1243dSDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)), vt:$Zn1, vt:$Zn2, vt:$Zm),
142bdd1243dSDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset, (REG_SEQUENCE ZPR2, vt:$Zn1, zsub0, vt:$Zn2, zsub1),
143bdd1243dSDimitry Andric                                              zpr_ty:$Zm)>;
144bdd1243dSDimitry Andricclass SME2_ZA_TwoOp_VG4_Multi_Single_Pat<string name, SDPatternOperator intrinsic, Operand index_ty, ZPRRegOp zpr_ty,
145bdd1243dSDimitry Andric                                         ValueType vt, ComplexPattern tileslice>
146bdd1243dSDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)),
147bdd1243dSDimitry Andric                     vt:$Zn1, vt:$Zn2, vt:$Zn3, vt:$Zn4, vt:$Zm),
148bdd1243dSDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset,
149bdd1243dSDimitry Andric                                              (REG_SEQUENCE ZPR4, vt:$Zn1, zsub0, vt:$Zn2, zsub1, vt:$Zn3, zsub2, vt:$Zn4, zsub3),
150bdd1243dSDimitry Andric                                              zpr_ty:$Zm)>;
151bdd1243dSDimitry Andric
152bdd1243dSDimitry Andricclass SME2_ZA_TwoOp_VG2_Multi_Multi_Pat<string name, SDPatternOperator intrinsic, Operand index_ty, ValueType vt, ComplexPattern tileslice>
153bdd1243dSDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)), vt:$Zn1, vt:$Zn2, vt:$Zm1, vt:$Zm2),
154bdd1243dSDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset,
155bdd1243dSDimitry Andric                                              (REG_SEQUENCE ZPR2Mul2, vt:$Zn1, zsub0, vt:$Zn2, zsub1),
156bdd1243dSDimitry Andric                                              (REG_SEQUENCE ZPR2Mul2, vt:$Zm1, zsub0, vt:$Zm2, zsub1))>;
157bdd1243dSDimitry Andric
158bdd1243dSDimitry Andricclass SME2_ZA_TwoOp_VG4_Multi_Multi_Pat<string name, SDPatternOperator intrinsic, Operand index_ty, ValueType vt, ComplexPattern tileslice>
159bdd1243dSDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)),
160bdd1243dSDimitry Andric                     vt:$Zn1, vt:$Zn2, vt:$Zn3, vt:$Zn4, vt:$Zm1, vt:$Zm2, vt:$Zm3, vt:$Zm4),
161bdd1243dSDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset,
162bdd1243dSDimitry Andric                                              (REG_SEQUENCE ZPR4Mul4, vt:$Zn1, zsub0, vt:$Zn2, zsub1, vt:$Zn3, zsub2, vt:$Zn4, zsub3),
163bdd1243dSDimitry Andric                                              (REG_SEQUENCE ZPR4Mul4, vt:$Zm1, zsub0, vt:$Zm2, zsub1, vt:$Zm3, zsub2, vt:$Zm4, zsub3))>;
164bdd1243dSDimitry Andric
165bdd1243dSDimitry Andricclass SME2_ZA_TwoOp_Multi_Index_Pat<string name, SDPatternOperator intrinsic, Operand index_ty, ZPRRegOp zpr_ty, ValueType vt,
166bdd1243dSDimitry Andric                                    Operand imm_ty, ComplexPattern tileslice>
167bdd1243dSDimitry Andric   : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)), vt:$Zn, vt:$Zm, (i32 imm_ty:$i)),
168bdd1243dSDimitry Andric         (!cast<Instruction>(name # _PSEUDO) $base, $offset, vt:$Zn, zpr_ty:$Zm, (i32 imm_ty:$i))>;
169bdd1243dSDimitry Andric
170bdd1243dSDimitry Andric
171bdd1243dSDimitry Andricclass SME2_ZA_TwoOp_VG2_Multi_Index_Pat<string name, SDPatternOperator intrinsic, Operand index_ty, ZPRRegOp zpr_ty, ValueType vt,
172bdd1243dSDimitry Andric                                        Operand imm_ty, ComplexPattern tileslice>
173bdd1243dSDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)), vt:$Zn1, vt:$Zn2, vt:$Zm, (i32 imm_ty:$i)),
174bdd1243dSDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset,
175bdd1243dSDimitry Andric                                              (REG_SEQUENCE ZPR2Mul2, vt:$Zn1, zsub0, vt:$Zn2, zsub1), zpr_ty:$Zm, imm_ty:$i)>;
176bdd1243dSDimitry Andric
177bdd1243dSDimitry Andricclass SME2_ZA_TwoOp_VG4_Multi_Index_Pat<string name, SDPatternOperator intrinsic, Operand index_ty, ZPRRegOp zpr_ty, ValueType vt,
178bdd1243dSDimitry Andric                                        Operand imm_ty, ComplexPattern tileslice>
179bdd1243dSDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)),
180bdd1243dSDimitry Andric                     vt:$Zn1, vt:$Zn2, vt:$Zn3, vt:$Zn4, vt:$Zm, (i32 imm_ty:$i)),
181bdd1243dSDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset,
182bdd1243dSDimitry Andric                                              (REG_SEQUENCE ZPR4Mul4, vt:$Zn1, zsub0, vt:$Zn2, zsub1, vt:$Zn3, zsub2, vt:$Zn4, zsub3),
183bdd1243dSDimitry Andric                                              zpr_ty:$Zm, imm_ty:$i)>;
184bdd1243dSDimitry Andric
18506c3fb27SDimitry Andricclass SME2_Sat_Shift_VG2_Pat<string name, SDPatternOperator intrinsic, ValueType out_vt, ValueType in_vt, Operand imm_ty>
18606c3fb27SDimitry Andric    : Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2, (i32 imm_ty:$i))),
18706c3fb27SDimitry Andric                  (!cast<Instruction>(name) (REG_SEQUENCE ZPR2Mul2, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1), imm_ty:$i)>;
18806c3fb27SDimitry Andric
18906c3fb27SDimitry Andricclass SME2_Sat_Shift_VG4_Pat<string name, SDPatternOperator intrinsic, ValueType out_vt, ValueType in_vt, Operand imm_ty>
19006c3fb27SDimitry Andric    : Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2, in_vt:$Zn3, in_vt:$Zn4, (i32 imm_ty:$i))),
19106c3fb27SDimitry Andric                  (!cast<Instruction>(name) (REG_SEQUENCE ZPR4Mul4, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1, in_vt:$Zn3, zsub2, in_vt:$Zn4, zsub3),
19206c3fb27SDimitry Andric                                            imm_ty:$i)>;
19306c3fb27SDimitry Andric
194bdd1243dSDimitry Andricclass SME2_Cvt_VG4_Pat<string name, SDPatternOperator intrinsic, ValueType out_vt, ValueType in_vt>
195bdd1243dSDimitry Andric    : Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2, in_vt:$Zn3, in_vt:$Zn4)),
196bdd1243dSDimitry Andric                  (!cast<Instruction>(name) (REG_SEQUENCE ZPR4Mul4, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1, in_vt:$Zn3, zsub2, in_vt:$Zn4, zsub3))>;
197bdd1243dSDimitry Andric
19806c3fb27SDimitry Andricclass SME2_ZA_VG1x2_Multi_Pat<string name, SDPatternOperator intrinsic, ValueType vt, Operand index_ty, ComplexPattern tileslice>
19906c3fb27SDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)), vt:$Zn1, vt:$Zn2),
20006c3fb27SDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset, (REG_SEQUENCE ZPR2Mul2, vt:$Zn1, zsub0, vt:$Zn2, zsub1))>;
20106c3fb27SDimitry Andric
20206c3fb27SDimitry Andricclass SME2_ZA_VG1x4_Multi_Pat<string name, SDPatternOperator intrinsic, ValueType vt, Operand index_ty, ComplexPattern tileslice>
20306c3fb27SDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, index_ty:$offset)), vt:$Zn1, vt:$Zn2, vt:$Zn3, vt:$Zn4),
20406c3fb27SDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $base, $offset, (REG_SEQUENCE ZPR4Mul4, vt:$Zn1, zsub0, vt:$Zn2, zsub1, vt:$Zn3, zsub2, vt:$Zn4, zsub3))>;
20506c3fb27SDimitry Andric
20606c3fb27SDimitry Andricclass SME2_Tile_VG2_Multi_Pat<string name, SDPatternOperator intrinsic, Operand tile_imm, ValueType vt, Operand index_ty, ComplexPattern tileslice>
20706c3fb27SDimitry Andric    : Pat<(intrinsic tile_imm:$tile, (i32 (tileslice MatrixIndexGPR32Op12_15:$base, index_ty:$offset)), vt:$Zn1, vt:$Zn2),
20806c3fb27SDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $tile, $base, $offset, (REG_SEQUENCE ZPR2Mul2, vt:$Zn1, zsub0, vt:$Zn2, zsub1))>;
20906c3fb27SDimitry Andric
21006c3fb27SDimitry Andricclass SME2_Tile_VG4_Multi_Pat<string name, SDPatternOperator intrinsic, Operand tile_imm, ValueType vt, Operand index_ty, ComplexPattern tileslice>
21106c3fb27SDimitry Andric    : Pat<(intrinsic tile_imm:$tile, (i32 (tileslice MatrixIndexGPR32Op12_15:$base, index_ty:$offset)), vt:$Zn1, vt:$Zn2, vt:$Zn3, vt:$Zn4),
21206c3fb27SDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $tile, $base, $offset, (REG_SEQUENCE ZPR4Mul4, vt:$Zn1, zsub0, vt:$Zn2, zsub1, vt:$Zn3, zsub2, vt:$Zn4, zsub3))>;
21306c3fb27SDimitry Andric
214*0fca6ea1SDimitry Andricclass SME2_Zero_Matrix_Pat<string name, SDPatternOperator intrinsic, Operand offset_ty, ComplexPattern tileslice>
215*0fca6ea1SDimitry Andric    : Pat<(intrinsic (i32 (tileslice MatrixIndexGPR32Op8_11:$base, offset_ty:$offset))),
216*0fca6ea1SDimitry Andric    (!cast<Instruction>(name) $base, $offset)>;
217*0fca6ea1SDimitry Andric
218*0fca6ea1SDimitry Andricclass SME2_Tile_Movaz_Pat<string name, SDPatternOperator intrinsic, ValueType out_vt, Operand tile_imm, Operand index_ty, ComplexPattern tileslice>
219*0fca6ea1SDimitry Andric    : Pat<(out_vt (intrinsic tile_imm:$tile, (i32 (tileslice MatrixIndexGPR32Op12_15:$base, index_ty:$offset)))),
220*0fca6ea1SDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $tile, $base, $offset)>;
221*0fca6ea1SDimitry Andric
22206c3fb27SDimitry Andric//===----------------------------------------------------------------------===//
22306c3fb27SDimitry Andric// SME pattern match helpers.
22406c3fb27SDimitry Andric//===----------------------------------------------------------------------===//
22506c3fb27SDimitry Andric
22606c3fb27SDimitry Andricclass SME_ZA_Tile_TwoPred_TwoVec_Pat<string name, SDPatternOperator intrinsic, Operand imm_ty, ValueType pg_ty, ValueType vt>
22706c3fb27SDimitry Andric    : Pat<(intrinsic imm_ty:$tile, (pg_ty PPR3bAny:$Pn), (pg_ty PPR3bAny:$Pm), vt:$Zn, vt:$Zm),
22806c3fb27SDimitry Andric          (!cast<Instruction>(name # _PSEUDO) $tile, $Pn, $Pm, $Zn, $Zm)>;
22906c3fb27SDimitry Andric
2305f757f3fSDimitry Andric
2315f757f3fSDimitry Andric//===----------------------------------------------------------------------===//
2325f757f3fSDimitry Andric// SME smstart/smstop
2335f757f3fSDimitry Andric//===----------------------------------------------------------------------===//
2345f757f3fSDimitry Andric
2355f757f3fSDimitry Andric// SME defines three pstate fields to set or clear PSTATE.SM, PSTATE.ZA, or
2365f757f3fSDimitry Andric// both fields:
2375f757f3fSDimitry Andric//
2385f757f3fSDimitry Andric//   MSR SVCRSM, #<imm1>
2395f757f3fSDimitry Andric//   MSR SVCRZA, #<imm1>
2405f757f3fSDimitry Andric//   MSR SVCRSMZA, #<imm1>
2415f757f3fSDimitry Andric//
2425f757f3fSDimitry Andric// It's tricky to using the existing pstate operand defined in
2435f757f3fSDimitry Andric// AArch64SystemOperands.td since it only encodes 5 bits including op1;op2,
2445f757f3fSDimitry Andric// when these fields are also encoded in CRm[3:1].
2455f757f3fSDimitry Andricdef MSRpstatesvcrImm1
2465f757f3fSDimitry Andric  : PstateWriteSimple<(ins svcr_op:$pstatefield, timm0_1:$imm), "msr",
2475f757f3fSDimitry Andric                      "\t$pstatefield, $imm">,
2485f757f3fSDimitry Andric    Sched<[WriteSys]> {
2495f757f3fSDimitry Andric  bits<3> pstatefield;
2505f757f3fSDimitry Andric  bit imm;
2515f757f3fSDimitry Andric  let Inst{18-16} = 0b011; // op1
2525f757f3fSDimitry Andric  let Inst{11-9} = pstatefield;
2535f757f3fSDimitry Andric  let Inst{8} = imm;
2545f757f3fSDimitry Andric  let Inst{7-5} = 0b011; // op2
2555f757f3fSDimitry Andric  let hasPostISelHook = 1;
2565f757f3fSDimitry Andric}
2575f757f3fSDimitry Andric
2585f757f3fSDimitry Andricdef : InstAlias<"smstart",    (MSRpstatesvcrImm1 0b011, 0b1)>;
2595f757f3fSDimitry Andricdef : InstAlias<"smstart sm", (MSRpstatesvcrImm1 0b001, 0b1)>;
2605f757f3fSDimitry Andricdef : InstAlias<"smstart za", (MSRpstatesvcrImm1 0b010, 0b1)>;
2615f757f3fSDimitry Andric
2625f757f3fSDimitry Andricdef : InstAlias<"smstop",     (MSRpstatesvcrImm1 0b011, 0b0)>;
2635f757f3fSDimitry Andricdef : InstAlias<"smstop sm",  (MSRpstatesvcrImm1 0b001, 0b0)>;
2645f757f3fSDimitry Andricdef : InstAlias<"smstop za",  (MSRpstatesvcrImm1 0b010, 0b0)>;
2655f757f3fSDimitry Andric
2665f757f3fSDimitry Andric
267bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
268fe6060f1SDimitry Andric// SME Outer Products
269fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
270fe6060f1SDimitry Andric
2715f757f3fSDimitry Andricclass sme_fp_outer_product_inst<bit S, bits<2> sz, bits<2> op, MatrixTileOperand za_ty,
272fe6060f1SDimitry Andric                                ZPRRegOp zpr_ty, string mnemonic>
273fe6060f1SDimitry Andric    : I<(outs za_ty:$ZAda),
27481ad6265SDimitry Andric      (ins za_ty:$_ZAda, PPR3bAny:$Pn, PPR3bAny:$Pm, zpr_ty:$Zn, zpr_ty:$Zm),
275fe6060f1SDimitry Andric        mnemonic, "\t$ZAda, $Pn/m, $Pm/m, $Zn, $Zm",
276fe6060f1SDimitry Andric        "", []>,
277fe6060f1SDimitry Andric      Sched<[]> {
278fe6060f1SDimitry Andric  bits<5> Zm;
279fe6060f1SDimitry Andric  bits<3> Pm;
280fe6060f1SDimitry Andric  bits<3> Pn;
281fe6060f1SDimitry Andric  bits<5> Zn;
282bdd1243dSDimitry Andric  let Inst{31-25} = 0b1000000;
2835f757f3fSDimitry Andric  let Inst{24}    = op{1};
284bdd1243dSDimitry Andric  let Inst{23}    = 0b1;
285bdd1243dSDimitry Andric  let Inst{22-21} = sz;
286fe6060f1SDimitry Andric  let Inst{20-16} = Zm;
287fe6060f1SDimitry Andric  let Inst{15-13} = Pm;
288fe6060f1SDimitry Andric  let Inst{12-10} = Pn;
289fe6060f1SDimitry Andric  let Inst{9-5}   = Zn;
290fe6060f1SDimitry Andric  let Inst{4}     = S;
2915f757f3fSDimitry Andric  let Inst{3}     = op{0};
29281ad6265SDimitry Andric
29381ad6265SDimitry Andric  let Constraints = "$ZAda = $_ZAda";
294fe6060f1SDimitry Andric}
295fe6060f1SDimitry Andric
2965f757f3fSDimitry Andricmulticlass sme_outer_product_fp32<bit S, bits<2> sz, ZPRRegOp zpr_ty, string mnemonic, SDPatternOperator op> {
2975f757f3fSDimitry Andric  def NAME : sme_fp_outer_product_inst<S, sz, 0b00, TileOp32, zpr_ty, mnemonic>, SMEPseudo2Instr<NAME, 1> {
298fe6060f1SDimitry Andric    bits<2> ZAda;
299fe6060f1SDimitry Andric    let Inst{1-0} = ZAda;
300fe6060f1SDimitry Andric    let Inst{2}   = 0b0;
301fe6060f1SDimitry Andric  }
302fe6060f1SDimitry Andric
3035f757f3fSDimitry Andric  def NAME # _PSEUDO : sme_outer_product_pseudo<zpr_ty, SMEMatrixTileS>, SMEPseudo2Instr<NAME, 0>;
30481ad6265SDimitry Andric
30506c3fb27SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, op, timm32_0_3, nxv4i1, nxv4f32>;
30681ad6265SDimitry Andric}
30781ad6265SDimitry Andric
30881ad6265SDimitry Andricmulticlass sme_outer_product_fp64<bit S, string mnemonic, SDPatternOperator op> {
3095f757f3fSDimitry Andric  def NAME : sme_fp_outer_product_inst<S, 0b10, 0b00, TileOp64, ZPR64, mnemonic>, SMEPseudo2Instr<NAME, 1> {
310fe6060f1SDimitry Andric    bits<3> ZAda;
311fe6060f1SDimitry Andric    let Inst{2-0} = ZAda;
312fe6060f1SDimitry Andric  }
313fe6060f1SDimitry Andric
314bdd1243dSDimitry Andric  def NAME # _PSEUDO : sme_outer_product_pseudo<ZPR64, SMEMatrixTileD>, SMEPseudo2Instr<NAME, 0>;
31581ad6265SDimitry Andric
31606c3fb27SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, op, timm32_0_7, nxv2i1, nxv2f64>;
31781ad6265SDimitry Andric}
31881ad6265SDimitry Andric
319*0fca6ea1SDimitry Andricmulticlass sme2p1_fmop_tile_f8f16<string mnemonic, bit bf, bit s, bits<2> op> {
320*0fca6ea1SDimitry Andric  def NAME : sme_fp_outer_product_inst<s, {0,bf}, op, TileOp16, ZPR8, mnemonic> {
321bdd1243dSDimitry Andric    bits<1> ZAda;
322bdd1243dSDimitry Andric    let Inst{2-1} = 0b00;
323bdd1243dSDimitry Andric    let Inst{0}   = ZAda;
324bdd1243dSDimitry Andric  }
325bdd1243dSDimitry Andric}
326bdd1243dSDimitry Andric
327*0fca6ea1SDimitry Andricmulticlass sme2p1_fmop_tile_fp16<string mnemonic, bit bf, bit s, ValueType vt, SDPatternOperator intrinsic = null_frag> {
328*0fca6ea1SDimitry Andric  def NAME : sme_fp_outer_product_inst<s, {0,bf}, 0b11, TileOp16, ZPR16, mnemonic>, SMEPseudo2Instr<NAME, 1> {
329*0fca6ea1SDimitry Andric    bits<1> ZAda;
330*0fca6ea1SDimitry Andric    let Inst{2-1} = 0b00;
331*0fca6ea1SDimitry Andric    let Inst{0}   = ZAda;
332*0fca6ea1SDimitry Andric  }
333*0fca6ea1SDimitry Andric
334*0fca6ea1SDimitry Andric  def NAME # _PSEUDO : sme_outer_product_pseudo<ZPR16, SMEMatrixTileH>, SMEPseudo2Instr<NAME, 0>;
335*0fca6ea1SDimitry Andric
336*0fca6ea1SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, intrinsic, timm32_0_1, nxv8i1, vt>;
337*0fca6ea1SDimitry Andric}
338*0fca6ea1SDimitry Andric
339bdd1243dSDimitry Andricclass sme_int_outer_product_inst<bits<3> opc, bit sz, bit sme2,
340fe6060f1SDimitry Andric                                 MatrixTileOperand za_ty, ZPRRegOp zpr_ty,
341fe6060f1SDimitry Andric                                 string mnemonic>
342fe6060f1SDimitry Andric    : I<(outs za_ty:$ZAda),
34381ad6265SDimitry Andric        (ins za_ty:$_ZAda, PPR3bAny:$Pn, PPR3bAny:$Pm, zpr_ty:$Zn, zpr_ty:$Zm),
344fe6060f1SDimitry Andric        mnemonic, "\t$ZAda, $Pn/m, $Pm/m, $Zn, $Zm",
345fe6060f1SDimitry Andric        "", []>,
346fe6060f1SDimitry Andric      Sched<[]> {
347fe6060f1SDimitry Andric  bits<5> Zm;
348fe6060f1SDimitry Andric  bits<3> Pm;
349fe6060f1SDimitry Andric  bits<3> Pn;
350fe6060f1SDimitry Andric  bits<5> Zn;
351fe6060f1SDimitry Andric  let Inst{31-25} = 0b1010000;
352bdd1243dSDimitry Andric  let Inst{24}    = opc{2}; // u0
353fe6060f1SDimitry Andric  let Inst{23}    = 0b1;
354fe6060f1SDimitry Andric  let Inst{22}    = sz;
355bdd1243dSDimitry Andric  let Inst{21}    = opc{1}; // u1
356fe6060f1SDimitry Andric  let Inst{20-16} = Zm;
357fe6060f1SDimitry Andric  let Inst{15-13} = Pm;
358fe6060f1SDimitry Andric  let Inst{12-10} = Pn;
359fe6060f1SDimitry Andric  let Inst{9-5}   = Zn;
360bdd1243dSDimitry Andric  let Inst{4}     = opc{0};  //S;
361bdd1243dSDimitry Andric  let Inst{3}     = sme2;
36281ad6265SDimitry Andric
36381ad6265SDimitry Andric  let Constraints = "$ZAda = $_ZAda";
364fe6060f1SDimitry Andric}
365fe6060f1SDimitry Andric
36681ad6265SDimitry Andricmulticlass sme_int_outer_product_i32<bits<3> opc, string mnemonic,
36781ad6265SDimitry Andric                                     SDPatternOperator op> {
368bdd1243dSDimitry Andric  def NAME : sme_int_outer_product_inst<opc, 0b0, 0b0,  TileOp32,
369bdd1243dSDimitry Andric                                        ZPR8, mnemonic>, SMEPseudo2Instr<NAME, 1> {
370fe6060f1SDimitry Andric    bits<2> ZAda;
371fe6060f1SDimitry Andric    let Inst{1-0} = ZAda;
372fe6060f1SDimitry Andric    let Inst{2}   = 0b0;
373fe6060f1SDimitry Andric  }
374fe6060f1SDimitry Andric
375bdd1243dSDimitry Andric  def NAME # _PSEUDO : sme_outer_product_pseudo<ZPR8, SMEMatrixTileS>, SMEPseudo2Instr<NAME, 0>;
37681ad6265SDimitry Andric
37706c3fb27SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, op, timm32_0_3, nxv16i1, nxv16i8>;
37881ad6265SDimitry Andric}
37981ad6265SDimitry Andric
38081ad6265SDimitry Andricmulticlass sme_int_outer_product_i64<bits<3> opc, string mnemonic,
38181ad6265SDimitry Andric                                     SDPatternOperator op> {
382bdd1243dSDimitry Andric  def NAME : sme_int_outer_product_inst<opc, 0b1, 0b0, TileOp64,
383bdd1243dSDimitry Andric                                        ZPR16, mnemonic>, SMEPseudo2Instr<NAME, 1> {
384fe6060f1SDimitry Andric    bits<3> ZAda;
385fe6060f1SDimitry Andric    let Inst{2-0} = ZAda;
386fe6060f1SDimitry Andric  }
387fe6060f1SDimitry Andric
388bdd1243dSDimitry Andric  def NAME # _PSEUDO : sme_outer_product_pseudo<ZPR16, SMEMatrixTileD>, SMEPseudo2Instr<NAME, 0>;
38981ad6265SDimitry Andric
39006c3fb27SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, op, timm32_0_7, nxv8i1, nxv8i16>;
39181ad6265SDimitry Andric}
39281ad6265SDimitry Andric
393bdd1243dSDimitry Andricclass sme_outer_product_widening_inst<bits<3> opc, ZPRRegOp zpr_ty, string mnemonic>
394fe6060f1SDimitry Andric    : I<(outs TileOp32:$ZAda),
395bdd1243dSDimitry Andric        (ins  TileOp32:$_ZAda, PPR3bAny:$Pn, PPR3bAny:$Pm, zpr_ty:$Zn, zpr_ty:$Zm),
396fe6060f1SDimitry Andric        mnemonic, "\t$ZAda, $Pn/m, $Pm/m, $Zn, $Zm",
397fe6060f1SDimitry Andric        "", []>,
398fe6060f1SDimitry Andric      Sched<[]> {
399fe6060f1SDimitry Andric  bits<5> Zm;
400fe6060f1SDimitry Andric  bits<3> Pm;
401fe6060f1SDimitry Andric  bits<3> Pn;
402fe6060f1SDimitry Andric  bits<5> Zn;
403fe6060f1SDimitry Andric  bits<2> ZAda;
404bdd1243dSDimitry Andric  let Inst{31-25} = 0b1000000;
405bdd1243dSDimitry Andric  let Inst{24}    = !if(opc{2}, 0, 1);
406bdd1243dSDimitry Andric  let Inst{23-22} = 0b10;
407bdd1243dSDimitry Andric  let Inst{21}    = opc{1};
408fe6060f1SDimitry Andric  let Inst{20-16} = Zm;
409fe6060f1SDimitry Andric  let Inst{15-13} = Pm;
410fe6060f1SDimitry Andric  let Inst{12-10} = Pn;
411fe6060f1SDimitry Andric  let Inst{9-5}   = Zn;
412bdd1243dSDimitry Andric  let Inst{4}     = opc{0};
413bdd1243dSDimitry Andric  let Inst{3}     = opc{2};
414bdd1243dSDimitry Andric  let Inst{2}     = 0b0;
415fe6060f1SDimitry Andric  let Inst{1-0}   = ZAda;
41681ad6265SDimitry Andric
41781ad6265SDimitry Andric  let Constraints = "$ZAda = $_ZAda";
418fe6060f1SDimitry Andric}
419fe6060f1SDimitry Andric
420bdd1243dSDimitry Andricmulticlass sme_bf16_outer_product<bits<3> opc, string mnemonic, SDPatternOperator op> {
421bdd1243dSDimitry Andric  def NAME : sme_outer_product_widening_inst<opc, ZPR16, mnemonic>, SMEPseudo2Instr<NAME, 1>;
42281ad6265SDimitry Andric
423bdd1243dSDimitry Andric  def NAME # _PSEUDO : sme_outer_product_pseudo<ZPR16, SMEMatrixTileS>, SMEPseudo2Instr<NAME, 0>;
42481ad6265SDimitry Andric
42506c3fb27SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, op, timm32_0_3, nxv8i1, nxv8bf16>;
426fe6060f1SDimitry Andric}
427fe6060f1SDimitry Andric
428bdd1243dSDimitry Andricmulticlass sme_f16_outer_product<bits<3> opc, string mnemonic, SDPatternOperator op> {
429bdd1243dSDimitry Andric  def NAME : sme_outer_product_widening_inst<opc, ZPR16, mnemonic>, SMEPseudo2Instr<NAME, 1>;
43081ad6265SDimitry Andric
431bdd1243dSDimitry Andric  def NAME # _PSEUDO : sme_outer_product_pseudo<ZPR16, SMEMatrixTileS>, SMEPseudo2Instr<NAME, 0>;
43281ad6265SDimitry Andric
43306c3fb27SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, op, timm32_0_3, nxv8i1, nxv8f16>;
434fe6060f1SDimitry Andric}
435fe6060f1SDimitry Andric
436fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
437fe6060f1SDimitry Andric// SME Add Vector to Tile
438fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
439fe6060f1SDimitry Andric
440fe6060f1SDimitry Andricclass sme_add_vector_to_tile_inst<bit op, bit V, MatrixTileOperand tile_ty,
441fe6060f1SDimitry Andric                                  ZPRRegOp zpr_ty, string mnemonic>
442fe6060f1SDimitry Andric    : I<(outs tile_ty:$ZAda),
44381ad6265SDimitry Andric        (ins tile_ty:$_ZAda, PPR3bAny:$Pn, PPR3bAny:$Pm, zpr_ty:$Zn),
444fe6060f1SDimitry Andric        mnemonic, "\t$ZAda, $Pn/m, $Pm/m, $Zn",
445fe6060f1SDimitry Andric        "", []>, Sched<[]> {
446fe6060f1SDimitry Andric  bits<3> Pm;
447fe6060f1SDimitry Andric  bits<3> Pn;
448fe6060f1SDimitry Andric  bits<5> Zn;
449fe6060f1SDimitry Andric  let Inst{31-23} = 0b110000001;
450fe6060f1SDimitry Andric  let Inst{22}    = op;
451fe6060f1SDimitry Andric  let Inst{21-17} = 0b01000;
452fe6060f1SDimitry Andric  let Inst{16}    = V;
453fe6060f1SDimitry Andric  let Inst{15-13} = Pm;
454fe6060f1SDimitry Andric  let Inst{12-10} = Pn;
455fe6060f1SDimitry Andric  let Inst{9-5}   = Zn;
456fe6060f1SDimitry Andric  let Inst{4-3}   = 0b00;
45781ad6265SDimitry Andric
45881ad6265SDimitry Andric  let Constraints = "$ZAda = $_ZAda";
459fe6060f1SDimitry Andric}
460fe6060f1SDimitry Andric
461bdd1243dSDimitry Andricclass sme_add_vector_to_tile_pseudo<ZPRRegOp zpr_ty, SMEMatrixTypeEnum za_flag>
462bdd1243dSDimitry Andric    : Pseudo<(outs),
463bdd1243dSDimitry Andric             (ins i32imm:$tile, PPR3bAny:$Pn, PPR3bAny:$Pm, zpr_ty:$Zn), []>,
464bdd1243dSDimitry Andric      Sched<[]> {
465bdd1243dSDimitry Andric  // Translated to the actual instructions in AArch64ISelLowering.cpp
466bdd1243dSDimitry Andric  let SMEMatrixType = za_flag;
467bdd1243dSDimitry Andric  let usesCustomInserter = 1;
468bdd1243dSDimitry Andric}
469bdd1243dSDimitry Andric
470bdd1243dSDimitry Andricmulticlass sme_add_vector_to_tile_u32<bit V, string mnemonic, SDPatternOperator op> {
471bdd1243dSDimitry Andric    def NAME : sme_add_vector_to_tile_inst<0b0, V, TileOp32, ZPR32, mnemonic>, SMEPseudo2Instr<NAME, 1> {
472fe6060f1SDimitry Andric  bits<2> ZAda;
473fe6060f1SDimitry Andric  let Inst{2}   = 0b0;
474fe6060f1SDimitry Andric  let Inst{1-0} = ZAda;
475fe6060f1SDimitry Andric  }
476fe6060f1SDimitry Andric
477bdd1243dSDimitry Andric  def _PSEUDO_S : sme_add_vector_to_tile_pseudo<ZPR32, SMEMatrixTileS>, SMEPseudo2Instr<NAME, 0>;
478bdd1243dSDimitry Andric
479bdd1243dSDimitry Andric  def : Pat<(op timm32_0_3:$tile, (nxv4i1 PPR3bAny:$pn), (nxv4i1 PPR3bAny:$pm),
480bdd1243dSDimitry Andric            (nxv4i32 ZPR32:$zn)),
481bdd1243dSDimitry Andric          (!cast<Instruction>(NAME # _PSEUDO_S) timm32_0_3:$tile, $pn, $pm, $zn)>;
482bdd1243dSDimitry Andric}
483bdd1243dSDimitry Andric
484bdd1243dSDimitry Andricmulticlass sme_add_vector_to_tile_u64<bit V, string mnemonic, SDPatternOperator op> {
485bdd1243dSDimitry Andric    def NAME : sme_add_vector_to_tile_inst<0b1, V, TileOp64, ZPR64, mnemonic>, SMEPseudo2Instr<NAME, 1> {
486fe6060f1SDimitry Andric  bits<3> ZAda;
487fe6060f1SDimitry Andric  let Inst{2-0} = ZAda;
488fe6060f1SDimitry Andric  }
489fe6060f1SDimitry Andric
490bdd1243dSDimitry Andric  def _PSEUDO_D : sme_add_vector_to_tile_pseudo<ZPR64, SMEMatrixTileD>, SMEPseudo2Instr<NAME, 0>;
491bdd1243dSDimitry Andric
492bdd1243dSDimitry Andric  let Predicates = [HasSMEI16I64] in {
493bdd1243dSDimitry Andric  def : Pat<(op timm32_0_7:$tile, (nxv2i1 PPR3bAny:$pn), (nxv2i1 PPR3bAny:$pm),
494bdd1243dSDimitry Andric                (nxv2i64 ZPR64:$zn)),
495bdd1243dSDimitry Andric            (!cast<Instruction>(NAME # _PSEUDO_D) timm32_0_7:$tile, $pn, $pm, $zn)>;
496753f127fSDimitry Andric  }
497753f127fSDimitry Andric}
498753f127fSDimitry Andric
499fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
500fe6060f1SDimitry Andric// SME Contiguous Loads
501fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
502fe6060f1SDimitry Andric
503fe6060f1SDimitry Andricclass sme_mem_ld_ss_base<bit Q, bit V, bits<2> msz, dag outs, dag ins,
504fe6060f1SDimitry Andric                         string mnemonic, string argstr>
505fe6060f1SDimitry Andric    : I<outs, ins, mnemonic, argstr, "", []>, Sched<[]> {
506fe6060f1SDimitry Andric  bits<5> Rm;
507fe6060f1SDimitry Andric  bits<2> Rv;
508fe6060f1SDimitry Andric  bits<3> Pg;
509fe6060f1SDimitry Andric  bits<5> Rn;
510fe6060f1SDimitry Andric  let Inst{31-25} = 0b1110000;
511fe6060f1SDimitry Andric  let Inst{24}    = Q;
512fe6060f1SDimitry Andric  let Inst{23-22} = msz;
513fe6060f1SDimitry Andric  let Inst{21}    = 0b0;
514fe6060f1SDimitry Andric  let Inst{20-16} = Rm;
515fe6060f1SDimitry Andric  let Inst{15}    = V;
516fe6060f1SDimitry Andric  let Inst{14-13} = Rv;
517fe6060f1SDimitry Andric  let Inst{12-10} = Pg;
518fe6060f1SDimitry Andric  let Inst{9-5}   = Rn;
519fe6060f1SDimitry Andric  let Inst{4}     = 0b0;
520fe6060f1SDimitry Andric
521fe6060f1SDimitry Andric  let mayLoad = 1;
522fe6060f1SDimitry Andric}
523fe6060f1SDimitry Andric
524349cc55cSDimitry Andricclass sme_mem_ld_ss_inst<bit Q, bits<2> msz, string mnemonic,
525fe6060f1SDimitry Andric                         MatrixTileVectorOperand tile_ty, bit is_col,
526fe6060f1SDimitry Andric                         Operand imm_ty, RegisterOperand gpr_ty>
527fe6060f1SDimitry Andric    : sme_mem_ld_ss_base<
528349cc55cSDimitry Andric        Q, is_col, msz, (outs tile_ty:$ZAt),
529fe6060f1SDimitry Andric        (ins MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm, PPR3bAny:$Pg, GPR64sp:$Rn,
530fe6060f1SDimitry Andric             gpr_ty:$Rm),
531fe6060f1SDimitry Andric        mnemonic, "\t\\{$ZAt[$Rv, $imm]\\}, $Pg/z, [$Rn, $Rm]">;
532fe6060f1SDimitry Andric
533349cc55cSDimitry Andricmulticlass sme_mem_ss_aliases_base<string mnemonic, Instruction inst,
534349cc55cSDimitry Andric                                   MatrixTileVectorOperand tile_ty,
535349cc55cSDimitry Andric                                   Operand imm_ty, RegisterOperand gpr_ty,
536fe6060f1SDimitry Andric                                   string pg_suffix=""> {
537fe6060f1SDimitry Andric  def : InstAlias<mnemonic # "\t$ZAt[$Rv, $imm], $Pg" # pg_suffix # ", [$Rn, $Rm]",
538fe6060f1SDimitry Andric                  (inst tile_ty:$ZAt, MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm, PPR3bAny:$Pg, GPR64sp:$Rn, gpr_ty:$Rm), 0>;
539fe6060f1SDimitry Andric  // Default XZR offset aliases
540fe6060f1SDimitry Andric  def : InstAlias<mnemonic # "\t\\{$ZAt[$Rv, $imm]\\}, $Pg" # pg_suffix # ", [$Rn]",
541fe6060f1SDimitry Andric                  (inst tile_ty:$ZAt, MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 1>;
542fe6060f1SDimitry Andric  def : InstAlias<mnemonic # "\t$ZAt[$Rv, $imm], $Pg" # pg_suffix # ", [$Rn]",
543fe6060f1SDimitry Andric                  (inst tile_ty:$ZAt, MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm, PPR3bAny:$Pg, GPR64sp:$Rn, XZR), 0>;
544fe6060f1SDimitry Andric}
545fe6060f1SDimitry Andric
546fe6060f1SDimitry Andricmulticlass sme_mem_ss_aliases<string mnemonic, string inst, bit is_col,
547fe6060f1SDimitry Andric                              string pg_suffix=""> {
548349cc55cSDimitry Andric  defm : sme_mem_ss_aliases_base<mnemonic # "b", !cast<Instruction>(inst # _B),
549fe6060f1SDimitry Andric                                 !if(is_col, TileVectorOpV8, TileVectorOpH8),
550349cc55cSDimitry Andric                                 sme_elm_idx0_15, GPR64shifted8, pg_suffix>;
551349cc55cSDimitry Andric  defm : sme_mem_ss_aliases_base<mnemonic # "h", !cast<Instruction>(inst # _H),
552fe6060f1SDimitry Andric                                 !if(is_col, TileVectorOpV16, TileVectorOpH16),
553349cc55cSDimitry Andric                                 sme_elm_idx0_7, GPR64shifted16, pg_suffix>;
554349cc55cSDimitry Andric  defm : sme_mem_ss_aliases_base<mnemonic # "w", !cast<Instruction>(inst # _S),
555fe6060f1SDimitry Andric                                 !if(is_col, TileVectorOpV32, TileVectorOpH32),
556349cc55cSDimitry Andric                                 sme_elm_idx0_3, GPR64shifted32, pg_suffix>;
557349cc55cSDimitry Andric  defm : sme_mem_ss_aliases_base<mnemonic # "d", !cast<Instruction>(inst # _D),
558fe6060f1SDimitry Andric                                 !if(is_col, TileVectorOpV64, TileVectorOpH64),
559349cc55cSDimitry Andric                                 sme_elm_idx0_1, GPR64shifted64, pg_suffix>;
560349cc55cSDimitry Andric  defm : sme_mem_ss_aliases_base<mnemonic # "q", !cast<Instruction>(inst # _Q),
561fe6060f1SDimitry Andric                                 !if(is_col, TileVectorOpV128, TileVectorOpH128),
562349cc55cSDimitry Andric                                 sme_elm_idx0_0, GPR64shifted128, pg_suffix>;
563fe6060f1SDimitry Andric}
564fe6060f1SDimitry Andric
565fe6060f1SDimitry Andricmulticlass sme_mem_ld_ss_aliases<string inst, bit is_col> {
566fe6060f1SDimitry Andric  defm NAME : sme_mem_ss_aliases<"ld1", inst, is_col, "/z">;
567fe6060f1SDimitry Andric}
568fe6060f1SDimitry Andric
56981ad6265SDimitry Andricmulticlass sme_mem_ld_ss_patterns<Instruction Inst, SDPatternOperator Load,
57081ad6265SDimitry Andric                                  Operand tile_ty, Operand offset_ty,
57181ad6265SDimitry Andric                                  ComplexPattern addr,
57281ad6265SDimitry Andric                                  ComplexPattern tileslice> {
57381ad6265SDimitry Andric  // base, tileslice
57481ad6265SDimitry Andric  def : Pat<(Load PPR3bAny:$pg, GPR64sp:$base, tile_ty:$tile,
57581ad6265SDimitry Andric                  (i32 (tileslice MatrixIndexGPR32Op12_15:$idx, offset_ty:$imm))),
57681ad6265SDimitry Andric            (Inst tile_ty:$tile, $idx, $imm, $pg, $base, XZR)>;
57781ad6265SDimitry Andric
57881ad6265SDimitry Andric  // reg + reg, tileslice
57981ad6265SDimitry Andric  let AddedComplexity = 1 in {
58081ad6265SDimitry Andric    def : Pat<(Load PPR3bAny:$pg, (addr GPR64sp:$base, GPR64:$offset),
58181ad6265SDimitry Andric                    tile_ty:$tile, (i32 (tileslice MatrixIndexGPR32Op12_15:$idx,
58281ad6265SDimitry Andric                                              offset_ty:$imm))),
58381ad6265SDimitry Andric              (Inst tile_ty:$tile, $idx, $imm, $pg, $base, $offset)>;
58481ad6265SDimitry Andric  }
58581ad6265SDimitry Andric}
58681ad6265SDimitry Andric
58781ad6265SDimitry Andricclass sme_load_pseudo
588bdd1243dSDimitry Andric    : Pseudo<(outs), (ins i32imm:$tile, MatrixIndexGPR32Op12_15:$idx,
589bdd1243dSDimitry Andric                          i32imm:$imm, PPR3bAny:$pg, GPR64sp:$base, GPR64:$offset), []>,
59081ad6265SDimitry Andric      Sched<[]> {
59181ad6265SDimitry Andric  // Translated to the actual instructions in AArch64ISelLowering.cpp
59281ad6265SDimitry Andric  let usesCustomInserter = 1;
59381ad6265SDimitry Andric  let mayLoad = 1;
59481ad6265SDimitry Andric}
59581ad6265SDimitry Andric
596fe6060f1SDimitry Andricmulticlass sme_mem_ld_v_ss<string mnemonic, bit is_col> {
597349cc55cSDimitry Andric  def _B : sme_mem_ld_ss_inst<0b0, 0b00, mnemonic # "b",
598349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV8, TileVectorOpH8),
599349cc55cSDimitry Andric                              is_col, sme_elm_idx0_15, GPR64shifted8> {
600fe6060f1SDimitry Andric    bits<4> imm;
601fe6060f1SDimitry Andric    let Inst{3-0} = imm;
602fe6060f1SDimitry Andric  }
603349cc55cSDimitry Andric  def _H : sme_mem_ld_ss_inst<0b0, 0b01, mnemonic # "h",
604349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV16, TileVectorOpH16),
605349cc55cSDimitry Andric                              is_col, sme_elm_idx0_7, GPR64shifted16> {
606fe6060f1SDimitry Andric    bits<1> ZAt;
607fe6060f1SDimitry Andric    bits<3> imm;
608fe6060f1SDimitry Andric    let Inst{3}   = ZAt;
609fe6060f1SDimitry Andric    let Inst{2-0} = imm;
610fe6060f1SDimitry Andric  }
611349cc55cSDimitry Andric  def _S : sme_mem_ld_ss_inst<0b0, 0b10, mnemonic # "w",
612349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV32, TileVectorOpH32),
613349cc55cSDimitry Andric                              is_col, sme_elm_idx0_3, GPR64shifted32> {
614fe6060f1SDimitry Andric    bits<2> ZAt;
615fe6060f1SDimitry Andric    bits<2> imm;
616fe6060f1SDimitry Andric    let Inst{3-2} = ZAt;
617fe6060f1SDimitry Andric    let Inst{1-0} = imm;
618fe6060f1SDimitry Andric  }
619349cc55cSDimitry Andric  def _D : sme_mem_ld_ss_inst<0b0, 0b11, mnemonic # "d",
620349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV64, TileVectorOpH64),
621349cc55cSDimitry Andric                              is_col, sme_elm_idx0_1, GPR64shifted64> {
622fe6060f1SDimitry Andric    bits<3> ZAt;
623fe6060f1SDimitry Andric    bits<1> imm;
624fe6060f1SDimitry Andric    let Inst{3-1} = ZAt;
625fe6060f1SDimitry Andric    let Inst{0}   = imm;
626fe6060f1SDimitry Andric  }
627349cc55cSDimitry Andric  def _Q : sme_mem_ld_ss_inst<0b1, 0b11, mnemonic # "q",
628349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV128, TileVectorOpH128),
629349cc55cSDimitry Andric                              is_col, sme_elm_idx0_0, GPR64shifted128> {
630fe6060f1SDimitry Andric    bits<4> ZAt;
631fe6060f1SDimitry Andric    let Inst{3-0} = ZAt;
632fe6060f1SDimitry Andric  }
633fe6060f1SDimitry Andric
634fe6060f1SDimitry Andric  defm : sme_mem_ld_ss_aliases<NAME, is_col>;
63581ad6265SDimitry Andric
63681ad6265SDimitry Andric  // Pseudo instructions for lowering intrinsics, using immediates instead of
63781ad6265SDimitry Andric  // tile registers.
63881ad6265SDimitry Andric  def _PSEUDO_B : sme_load_pseudo;
63981ad6265SDimitry Andric  def _PSEUDO_H : sme_load_pseudo;
64081ad6265SDimitry Andric  def _PSEUDO_S : sme_load_pseudo;
64181ad6265SDimitry Andric  def _PSEUDO_D : sme_load_pseudo;
64281ad6265SDimitry Andric  def _PSEUDO_Q : sme_load_pseudo;
64381ad6265SDimitry Andric
64481ad6265SDimitry Andric  defm : sme_mem_ld_ss_patterns<!cast<Instruction>(NAME # _PSEUDO_B),
64581ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_ld1b_vert,
64681ad6265SDimitry Andric                                            int_aarch64_sme_ld1b_horiz),
647bdd1243dSDimitry Andric                                sme_elm_idx0_0, timm32_0_15, am_sve_regreg_lsl0,
64881ad6265SDimitry Andric                                tileslice8>;
64981ad6265SDimitry Andric  defm : sme_mem_ld_ss_patterns<!cast<Instruction>(NAME # _PSEUDO_H),
65081ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_ld1h_vert,
65181ad6265SDimitry Andric                                            int_aarch64_sme_ld1h_horiz),
652bdd1243dSDimitry Andric                                timm32_0_1, timm32_0_7, am_sve_regreg_lsl1,
65381ad6265SDimitry Andric                                tileslice16>;
65481ad6265SDimitry Andric  defm : sme_mem_ld_ss_patterns<!cast<Instruction>(NAME # _PSEUDO_S),
65581ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_ld1w_vert,
65681ad6265SDimitry Andric                                            int_aarch64_sme_ld1w_horiz),
657bdd1243dSDimitry Andric                                timm32_0_3, timm32_0_3, am_sve_regreg_lsl2,
65881ad6265SDimitry Andric                                tileslice32>;
65981ad6265SDimitry Andric  defm : sme_mem_ld_ss_patterns<!cast<Instruction>(NAME # _PSEUDO_D),
66081ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_ld1d_vert,
66181ad6265SDimitry Andric                                            int_aarch64_sme_ld1d_horiz),
662bdd1243dSDimitry Andric                                timm32_0_7, timm32_0_1, am_sve_regreg_lsl3,
66381ad6265SDimitry Andric                                tileslice64>;
66481ad6265SDimitry Andric  defm : sme_mem_ld_ss_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
66581ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_ld1q_vert,
66681ad6265SDimitry Andric                                            int_aarch64_sme_ld1q_horiz),
667bdd1243dSDimitry Andric                                timm32_0_15, sme_elm_idx0_0, am_sve_regreg_lsl4,
66881ad6265SDimitry Andric                                tileslice128>;
669fe6060f1SDimitry Andric}
670fe6060f1SDimitry Andric
671fe6060f1SDimitry Andricmulticlass sme_mem_ld_ss<string mnemonic> {
672fe6060f1SDimitry Andric  defm _H : sme_mem_ld_v_ss<mnemonic, /*is_col=*/0b0>;
673fe6060f1SDimitry Andric  defm _V : sme_mem_ld_v_ss<mnemonic, /*is_col=*/0b1>;
674fe6060f1SDimitry Andric}
675fe6060f1SDimitry Andric
676fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
677fe6060f1SDimitry Andric// SME Contiguous Stores
678fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
679fe6060f1SDimitry Andric
680fe6060f1SDimitry Andricclass sme_mem_st_ss_base<bit Q, bit V, bits<2> msz, dag ins,
681fe6060f1SDimitry Andric                         string mnemonic, string argstr>
682fe6060f1SDimitry Andric    : I<(outs), ins, mnemonic, argstr, "", []>, Sched<[]> {
683fe6060f1SDimitry Andric  bits<5> Rm;
684fe6060f1SDimitry Andric  bits<2> Rv;
685fe6060f1SDimitry Andric  bits<3> Pg;
686fe6060f1SDimitry Andric  bits<5> Rn;
687fe6060f1SDimitry Andric  let Inst{31-25} = 0b1110000;
688fe6060f1SDimitry Andric  let Inst{24}    = Q;
689fe6060f1SDimitry Andric  let Inst{23-22} = msz;
690fe6060f1SDimitry Andric  let Inst{21}    = 0b1;
691fe6060f1SDimitry Andric  let Inst{20-16} = Rm;
692fe6060f1SDimitry Andric  let Inst{15}    = V;
693fe6060f1SDimitry Andric  let Inst{14-13} = Rv;
694fe6060f1SDimitry Andric  let Inst{12-10} = Pg;
695fe6060f1SDimitry Andric  let Inst{9-5}   = Rn;
696fe6060f1SDimitry Andric  let Inst{4}     = 0b0;
697fe6060f1SDimitry Andric
698fe6060f1SDimitry Andric  let mayStore = 1;
699fe6060f1SDimitry Andric  let hasSideEffects = 1;
700fe6060f1SDimitry Andric}
701fe6060f1SDimitry Andric
702349cc55cSDimitry Andricclass sme_mem_st_ss_inst<bit Q, bits<2> msz, string mnemonic,
703fe6060f1SDimitry Andric                         MatrixTileVectorOperand tile_ty, bit is_col,
704fe6060f1SDimitry Andric                         Operand imm_ty, RegisterOperand gpr_ty>
705fe6060f1SDimitry Andric    : sme_mem_st_ss_base<
706349cc55cSDimitry Andric        Q, is_col, msz,
707fe6060f1SDimitry Andric        (ins tile_ty:$ZAt, MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm, PPR3bAny:$Pg,
708fe6060f1SDimitry Andric             GPR64sp:$Rn, gpr_ty:$Rm),
709fe6060f1SDimitry Andric        mnemonic, "\t\\{$ZAt[$Rv, $imm]\\}, $Pg, [$Rn, $Rm]">;
710fe6060f1SDimitry Andric
711fe6060f1SDimitry Andricmulticlass sme_mem_st_ss_aliases<string inst, bit is_col> {
712fe6060f1SDimitry Andric  defm NAME : sme_mem_ss_aliases<"st1", inst, is_col>;
713fe6060f1SDimitry Andric}
714fe6060f1SDimitry Andric
71581ad6265SDimitry Andricmulticlass sme_mem_st_ss_patterns<Instruction Inst, SDPatternOperator Store,
71681ad6265SDimitry Andric                                  Operand offset_ty,
71781ad6265SDimitry Andric                                  ComplexPattern imm2tile,
71881ad6265SDimitry Andric                                  ComplexPattern addr,
71981ad6265SDimitry Andric                                  ComplexPattern tileslice> {
72081ad6265SDimitry Andric  // base, tileslice
72181ad6265SDimitry Andric  def : Pat<(Store PPR3bAny:$pg, GPR64sp:$base, (imm2tile untyped:$tile),
72281ad6265SDimitry Andric                   (i32 (tileslice MatrixIndexGPR32Op12_15:$idx, offset_ty:$imm))),
72381ad6265SDimitry Andric            (Inst $tile, $idx, $imm, $pg, $base, XZR)>;
72481ad6265SDimitry Andric
72581ad6265SDimitry Andric  // reg + reg, tileslice
72681ad6265SDimitry Andric  let AddedComplexity = 1 in {
72781ad6265SDimitry Andric    def : Pat<(Store PPR3bAny:$pg, (addr GPR64sp:$base, GPR64:$offset),
72881ad6265SDimitry Andric                     (imm2tile untyped:$tile),
72981ad6265SDimitry Andric                     (i32 (tileslice MatrixIndexGPR32Op12_15:$idx, offset_ty:$imm))),
73081ad6265SDimitry Andric              (Inst $tile, $idx, $imm, $pg, $base, $offset)>;
73181ad6265SDimitry Andric  }
73281ad6265SDimitry Andric}
73381ad6265SDimitry Andric
734fe6060f1SDimitry Andricmulticlass sme_mem_st_v_ss<string mnemonic, bit is_col> {
735349cc55cSDimitry Andric  def _B : sme_mem_st_ss_inst<0b0, 0b00, mnemonic # "b",
736349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV8, TileVectorOpH8),
737349cc55cSDimitry Andric                              is_col, sme_elm_idx0_15, GPR64shifted8> {
738fe6060f1SDimitry Andric    bits<4> imm;
739fe6060f1SDimitry Andric    let Inst{3-0} = imm;
740fe6060f1SDimitry Andric  }
741349cc55cSDimitry Andric  def _H : sme_mem_st_ss_inst<0b0, 0b01, mnemonic # "h",
742349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV16, TileVectorOpH16),
743349cc55cSDimitry Andric                              is_col, sme_elm_idx0_7, GPR64shifted16> {
744fe6060f1SDimitry Andric    bits<1> ZAt;
745fe6060f1SDimitry Andric    bits<3> imm;
746fe6060f1SDimitry Andric    let Inst{3}   = ZAt;
747fe6060f1SDimitry Andric    let Inst{2-0} = imm;
748fe6060f1SDimitry Andric  }
749349cc55cSDimitry Andric  def _S : sme_mem_st_ss_inst<0b0, 0b10, mnemonic # "w",
750349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV32, TileVectorOpH32),
751349cc55cSDimitry Andric                              is_col, sme_elm_idx0_3, GPR64shifted32> {
752fe6060f1SDimitry Andric    bits<2> ZAt;
753fe6060f1SDimitry Andric    bits<2> imm;
754fe6060f1SDimitry Andric    let Inst{3-2} = ZAt;
755fe6060f1SDimitry Andric    let Inst{1-0} = imm;
756fe6060f1SDimitry Andric  }
757349cc55cSDimitry Andric  def _D : sme_mem_st_ss_inst<0b0, 0b11, mnemonic # "d",
758349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV64, TileVectorOpH64),
759349cc55cSDimitry Andric                              is_col, sme_elm_idx0_1, GPR64shifted64> {
760fe6060f1SDimitry Andric    bits<3> ZAt;
761fe6060f1SDimitry Andric    bits<1> imm;
762fe6060f1SDimitry Andric    let Inst{3-1} = ZAt;
763fe6060f1SDimitry Andric    let Inst{0}   = imm;
764fe6060f1SDimitry Andric  }
765349cc55cSDimitry Andric  def _Q : sme_mem_st_ss_inst<0b1, 0b11, mnemonic # "q",
766349cc55cSDimitry Andric                              !if(is_col, TileVectorOpV128, TileVectorOpH128),
767349cc55cSDimitry Andric                              is_col, sme_elm_idx0_0, GPR64shifted128> {
768fe6060f1SDimitry Andric    bits<4> ZAt;
769fe6060f1SDimitry Andric    let Inst{3-0} = ZAt;
770fe6060f1SDimitry Andric  }
771fe6060f1SDimitry Andric
772fe6060f1SDimitry Andric  defm : sme_mem_st_ss_aliases<NAME, is_col>;
77381ad6265SDimitry Andric
77481ad6265SDimitry Andric  defm : sme_mem_st_ss_patterns<!cast<Instruction>(NAME # _B),
77581ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_st1b_vert,
77681ad6265SDimitry Andric                                            int_aarch64_sme_st1b_horiz),
777bdd1243dSDimitry Andric                                timm32_0_15, imm_to_tile8, am_sve_regreg_lsl0,
77881ad6265SDimitry Andric                                tileslice8>;
77981ad6265SDimitry Andric  defm : sme_mem_st_ss_patterns<!cast<Instruction>(NAME # _H),
78081ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_st1h_vert,
78181ad6265SDimitry Andric                                            int_aarch64_sme_st1h_horiz),
782bdd1243dSDimitry Andric                                timm32_0_7, imm_to_tile16, am_sve_regreg_lsl1,
78381ad6265SDimitry Andric                                tileslice16>;
78481ad6265SDimitry Andric  defm : sme_mem_st_ss_patterns<!cast<Instruction>(NAME # _S),
78581ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_st1w_vert,
78681ad6265SDimitry Andric                                            int_aarch64_sme_st1w_horiz),
787bdd1243dSDimitry Andric                                timm32_0_3, imm_to_tile32, am_sve_regreg_lsl2,
78881ad6265SDimitry Andric                                tileslice32>;
78981ad6265SDimitry Andric  defm : sme_mem_st_ss_patterns<!cast<Instruction>(NAME # _D),
79081ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_st1d_vert,
79181ad6265SDimitry Andric                                            int_aarch64_sme_st1d_horiz),
792bdd1243dSDimitry Andric                                timm32_0_1, imm_to_tile64, am_sve_regreg_lsl3,
79381ad6265SDimitry Andric                                tileslice64>;
79481ad6265SDimitry Andric  defm : sme_mem_st_ss_patterns<!cast<Instruction>(NAME # _Q),
79581ad6265SDimitry Andric                                !if(is_col, int_aarch64_sme_st1q_vert,
79681ad6265SDimitry Andric                                            int_aarch64_sme_st1q_horiz),
79781ad6265SDimitry Andric                                sme_elm_idx0_0, imm_to_tile128,
79881ad6265SDimitry Andric                                am_sve_regreg_lsl4, tileslice128>;
799fe6060f1SDimitry Andric}
800fe6060f1SDimitry Andric
801fe6060f1SDimitry Andricmulticlass sme_mem_st_ss<string mnemonic> {
802fe6060f1SDimitry Andric  defm _H : sme_mem_st_v_ss<mnemonic, /*is_col=*/0b0>;
803fe6060f1SDimitry Andric  defm _V : sme_mem_st_v_ss<mnemonic, /*is_col=*/0b1>;
804fe6060f1SDimitry Andric}
805fe6060f1SDimitry Andric
806fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
807fe6060f1SDimitry Andric// SME Save and Restore Array
808fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
809fe6060f1SDimitry Andric
81081ad6265SDimitry Andricclass sme_spill_fill_base<bit isStore, dag outs, dag ins, string opcodestr>
811fe6060f1SDimitry Andric    : I<outs, ins, opcodestr, "\t$ZAt[$Rv, $imm4], [$Rn, $offset, mul vl]", "",
812fe6060f1SDimitry Andric        []>,
813fe6060f1SDimitry Andric      Sched<[]> {
814fe6060f1SDimitry Andric  bits<2> Rv;
815fe6060f1SDimitry Andric  bits<5> Rn;
816fe6060f1SDimitry Andric  bits<4> imm4;
817fe6060f1SDimitry Andric  let Inst{31-22} = 0b1110000100;
818fe6060f1SDimitry Andric  let Inst{21}    = isStore;
819fe6060f1SDimitry Andric  let Inst{20-15} = 0b000000;
820fe6060f1SDimitry Andric  let Inst{14-13} = Rv;
821fe6060f1SDimitry Andric  let Inst{12-10} = 0b000;
822fe6060f1SDimitry Andric  let Inst{9-5}   = Rn;
823fe6060f1SDimitry Andric  let Inst{4}     = 0b0;
824fe6060f1SDimitry Andric  let Inst{3-0}   = imm4;
825fe6060f1SDimitry Andric}
826fe6060f1SDimitry Andric
82781ad6265SDimitry Andriclet mayStore = 1 in
82881ad6265SDimitry Andricclass sme_spill_inst<string opcodestr>
82981ad6265SDimitry Andric    : sme_spill_fill_base<0b1, (outs),
830fe6060f1SDimitry Andric                          (ins MatrixOp:$ZAt, MatrixIndexGPR32Op12_15:$Rv,
831349cc55cSDimitry Andric                               sme_elm_idx0_15:$imm4, GPR64sp:$Rn,
8325f757f3fSDimitry Andric                               imm32_0_15:$offset),
833fe6060f1SDimitry Andric                          opcodestr>;
83481ad6265SDimitry Andriclet mayLoad = 1 in
83581ad6265SDimitry Andricclass sme_fill_inst<string opcodestr>
83681ad6265SDimitry Andric    : sme_spill_fill_base<0b0, (outs MatrixOp:$ZAt),
837fe6060f1SDimitry Andric                          (ins MatrixIndexGPR32Op12_15:$Rv,
838349cc55cSDimitry Andric                               sme_elm_idx0_15:$imm4, GPR64sp:$Rn,
8395f757f3fSDimitry Andric                               imm32_0_15:$offset),
840fe6060f1SDimitry Andric                          opcodestr>;
84181ad6265SDimitry Andricmulticlass sme_spill<string opcodestr> {
84281ad6265SDimitry Andric  def NAME : sme_spill_inst<opcodestr>;
84381ad6265SDimitry Andric  def : InstAlias<opcodestr # "\t$ZAt[$Rv, $imm4], [$Rn]",
84481ad6265SDimitry Andric                  (!cast<Instruction>(NAME) MatrixOp:$ZAt,
84581ad6265SDimitry Andric                   MatrixIndexGPR32Op12_15:$Rv, sme_elm_idx0_15:$imm4, GPR64sp:$Rn, 0), 1>;
8465f757f3fSDimitry Andric
8475f757f3fSDimitry Andric  def : Pat<(AArch64SMEStr (i32 MatrixIndexGPR32Op12_15:$slice), (i64 GPR64sp:$base), (i32 sme_elm_idx0_15:$imm)),
8485f757f3fSDimitry Andric          (!cast<Instruction>(NAME) ZA, MatrixIndexGPR32Op12_15:$slice, sme_elm_idx0_15:$imm, GPR64sp:$base, imm32_0_15:$imm)>;
84981ad6265SDimitry Andric}
85081ad6265SDimitry Andric
85181ad6265SDimitry Andricmulticlass sme_fill<string opcodestr> {
85281ad6265SDimitry Andric  def NAME : sme_fill_inst<opcodestr>;
85381ad6265SDimitry Andric  def : InstAlias<opcodestr # "\t$ZAt[$Rv, $imm4], [$Rn]",
85481ad6265SDimitry Andric                  (!cast<Instruction>(NAME) MatrixOp:$ZAt,
85581ad6265SDimitry Andric                   MatrixIndexGPR32Op12_15:$Rv, sme_elm_idx0_15:$imm4, GPR64sp:$Rn, 0), 1>;
85681ad6265SDimitry Andric  def NAME # _PSEUDO
85781ad6265SDimitry Andric      : Pseudo<(outs),
8585f757f3fSDimitry Andric               (ins MatrixIndexGPR32Op12_15:$idx, sme_elm_idx0_15:$imm4,
85981ad6265SDimitry Andric                    GPR64sp:$base), []>,
86081ad6265SDimitry Andric        Sched<[]> {
86181ad6265SDimitry Andric    // Translated to actual instruction in AArch64ISelLowering.cpp
86281ad6265SDimitry Andric    let usesCustomInserter = 1;
86381ad6265SDimitry Andric    let mayLoad = 1;
86481ad6265SDimitry Andric  }
8655f757f3fSDimitry Andric  def : Pat<(AArch64SMELdr MatrixIndexGPR32Op12_15:$slice, GPR64sp:$base, sme_elm_idx0_15:$imm),
8665f757f3fSDimitry Andric          (!cast<Instruction>(NAME # _PSEUDO) MatrixIndexGPR32Op12_15:$slice, sme_elm_idx0_15:$imm, GPR64sp:$base)>;
867fe6060f1SDimitry Andric}
868fe6060f1SDimitry Andric
869fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
870fe6060f1SDimitry Andric// Move instructions
871fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
872fe6060f1SDimitry Andric
873fe6060f1SDimitry Andricclass sme_vector_to_tile_base<bit Q, bit V, bits<2> sz, dag outs, dag ins,
874fe6060f1SDimitry Andric                              string mnemonic, string argstr>
875fe6060f1SDimitry Andric    : I<outs, ins, mnemonic, argstr, "", []>, Sched<[]> {
876fe6060f1SDimitry Andric  bits<2> Rv;
877fe6060f1SDimitry Andric  bits<3> Pg;
878fe6060f1SDimitry Andric  bits<5> Zn;
879fe6060f1SDimitry Andric  let Inst{31-24} = 0b11000000;
880fe6060f1SDimitry Andric  let Inst{23-22} = sz;
881fe6060f1SDimitry Andric  let Inst{21-17} = 0b00000;
882fe6060f1SDimitry Andric  let Inst{16}    = Q;
883fe6060f1SDimitry Andric  let Inst{15}    = V;
884fe6060f1SDimitry Andric  let Inst{14-13} = Rv;
885fe6060f1SDimitry Andric  let Inst{12-10} = Pg;
886fe6060f1SDimitry Andric  let Inst{9-5}   = Zn;
887fe6060f1SDimitry Andric  let Inst{4}     = 0b0;
888fe6060f1SDimitry Andric}
889fe6060f1SDimitry Andric
890349cc55cSDimitry Andricclass sme_vector_to_tile_inst<bit Q, bits<2> sz, MatrixTileVectorOperand tile_ty,
891fe6060f1SDimitry Andric                              bit is_col, Operand imm_ty, ZPRRegOp zpr_ty,
892fe6060f1SDimitry Andric                              string mnemonic>
893349cc55cSDimitry Andric    : sme_vector_to_tile_base<Q, is_col, sz, (outs tile_ty:$ZAd),
89481ad6265SDimitry Andric        (ins tile_ty:$_ZAd, MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm, PPR3bAny:$Pg, zpr_ty:$Zn),
89581ad6265SDimitry Andric        mnemonic, "\t$ZAd[$Rv, $imm], $Pg/m, $Zn">{
89681ad6265SDimitry Andric
89781ad6265SDimitry Andric  let Constraints = "$ZAd = $_ZAd";
89881ad6265SDimitry Andric}
89981ad6265SDimitry Andric
900fe6060f1SDimitry Andric
901fe6060f1SDimitry Andricmulticlass sme_vector_to_tile_aliases<Instruction inst,
902fe6060f1SDimitry Andric                                      MatrixTileVectorOperand tile_ty,
903fe6060f1SDimitry Andric                                      ZPRRegOp zpr_ty, Operand imm_ty> {
904fe6060f1SDimitry Andric  def : InstAlias<"mov\t$ZAd[$Rv, $imm], $Pg/m, $Zn",
90569ade1e0SDimitry Andric                  (inst tile_ty:$ZAd, MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm, PPR3bAny:$Pg, zpr_ty:$Zn), 1>;
906fe6060f1SDimitry Andric}
907fe6060f1SDimitry Andric
90881ad6265SDimitry Andricmulticlass sme_vector_to_tile_patterns<Instruction inst, ValueType zpr_vt,
90981ad6265SDimitry Andric                                       ValueType ppr_vt, Operand imm_ty,
91081ad6265SDimitry Andric                                       Operand offset_ty,
91181ad6265SDimitry Andric                                       SDPatternOperator op,
91281ad6265SDimitry Andric                                       ComplexPattern tileslice> {
91381ad6265SDimitry Andric  def : Pat<(op imm_ty:$tile, (i32 (tileslice MatrixIndexGPR32Op12_15:$idx,
91481ad6265SDimitry Andric                                              offset_ty:$imm)),
91581ad6265SDimitry Andric                (ppr_vt PPR3bAny:$pg), (zpr_vt ZPRAny:$zn)),
91681ad6265SDimitry Andric            (inst imm_ty:$tile, $idx, $imm, $pg, $zn)>;
91781ad6265SDimitry Andric}
91881ad6265SDimitry Andric
919bdd1243dSDimitry Andricclass sme_mova_insert_pseudo<SMEMatrixTypeEnum za_flag>
920bdd1243dSDimitry Andric    : Pseudo<(outs), (ins i32imm:$tile, MatrixIndexGPR32Op12_15:$idx,
921bdd1243dSDimitry Andric                          i32imm:$imm, PPR3bAny:$pg, ZPRAny:$zn), []>,
92281ad6265SDimitry Andric      Sched<[]> {
92381ad6265SDimitry Andric  // Translated to the actual instructions in AArch64ISelLowering.cpp
924bdd1243dSDimitry Andric  let SMEMatrixType = za_flag;
92581ad6265SDimitry Andric  let usesCustomInserter = 1;
92681ad6265SDimitry Andric}
92781ad6265SDimitry Andric
928fe6060f1SDimitry Andricmulticlass sme_vector_v_to_tile<string mnemonic, bit is_col> {
929349cc55cSDimitry Andric  def _B : sme_vector_to_tile_inst<0b0, 0b00, !if(is_col, TileVectorOpV8,
930fe6060f1SDimitry Andric                                                          TileVectorOpH8),
931bdd1243dSDimitry Andric                                   is_col, sme_elm_idx0_15, ZPR8, mnemonic>,
932bdd1243dSDimitry Andric                                   SMEPseudo2Instr<NAME # _B, 1> {
933fe6060f1SDimitry Andric    bits<4> imm;
934fe6060f1SDimitry Andric    let Inst{3-0} = imm;
935fe6060f1SDimitry Andric  }
936349cc55cSDimitry Andric  def _H : sme_vector_to_tile_inst<0b0, 0b01, !if(is_col, TileVectorOpV16,
937fe6060f1SDimitry Andric                                                          TileVectorOpH16),
938bdd1243dSDimitry Andric                                   is_col, sme_elm_idx0_7, ZPR16, mnemonic>,
939bdd1243dSDimitry Andric                                   SMEPseudo2Instr<NAME # _H, 1> {
940fe6060f1SDimitry Andric    bits<1> ZAd;
941fe6060f1SDimitry Andric    bits<3> imm;
942fe6060f1SDimitry Andric    let Inst{3}   = ZAd;
943fe6060f1SDimitry Andric    let Inst{2-0} = imm;
944fe6060f1SDimitry Andric  }
945349cc55cSDimitry Andric  def _S : sme_vector_to_tile_inst<0b0, 0b10, !if(is_col, TileVectorOpV32,
946fe6060f1SDimitry Andric                                                          TileVectorOpH32),
947bdd1243dSDimitry Andric                                   is_col, sme_elm_idx0_3, ZPR32, mnemonic>,
948bdd1243dSDimitry Andric                                   SMEPseudo2Instr<NAME # _S, 1> {
949fe6060f1SDimitry Andric    bits<2> ZAd;
950fe6060f1SDimitry Andric    bits<2> imm;
951fe6060f1SDimitry Andric    let Inst{3-2} = ZAd;
952fe6060f1SDimitry Andric    let Inst{1-0} = imm;
953fe6060f1SDimitry Andric  }
954349cc55cSDimitry Andric  def _D : sme_vector_to_tile_inst<0b0, 0b11, !if(is_col, TileVectorOpV64,
955fe6060f1SDimitry Andric                                                          TileVectorOpH64),
956bdd1243dSDimitry Andric                                   is_col, sme_elm_idx0_1, ZPR64, mnemonic>,
957bdd1243dSDimitry Andric                                   SMEPseudo2Instr<NAME # _D, 1> {
958fe6060f1SDimitry Andric    bits<3> ZAd;
959fe6060f1SDimitry Andric    bits<1> imm;
960fe6060f1SDimitry Andric    let Inst{3-1} = ZAd;
961fe6060f1SDimitry Andric    let Inst{0}   = imm;
962fe6060f1SDimitry Andric  }
963349cc55cSDimitry Andric  def _Q : sme_vector_to_tile_inst<0b1, 0b11, !if(is_col, TileVectorOpV128,
964fe6060f1SDimitry Andric                                                          TileVectorOpH128),
965bdd1243dSDimitry Andric                                   is_col, sme_elm_idx0_0, ZPR128, mnemonic>,
966bdd1243dSDimitry Andric                                   SMEPseudo2Instr<NAME # _Q, 1> {
967fe6060f1SDimitry Andric    bits<4> ZAd;
968fe6060f1SDimitry Andric    bits<1> imm;
969fe6060f1SDimitry Andric    let Inst{3-0} = ZAd;
970fe6060f1SDimitry Andric  }
971fe6060f1SDimitry Andric
97281ad6265SDimitry Andric  // Pseudo instructions for lowering intrinsics, using immediates instead of
97381ad6265SDimitry Andric  // tile registers.
974bdd1243dSDimitry Andric  def _PSEUDO_B : sme_mova_insert_pseudo<SMEMatrixTileB>, SMEPseudo2Instr<NAME # _B, 0>;
975bdd1243dSDimitry Andric  def _PSEUDO_H : sme_mova_insert_pseudo<SMEMatrixTileH>, SMEPseudo2Instr<NAME # _H, 0>;
976bdd1243dSDimitry Andric  def _PSEUDO_S : sme_mova_insert_pseudo<SMEMatrixTileS>, SMEPseudo2Instr<NAME # _S, 0>;
977bdd1243dSDimitry Andric  def _PSEUDO_D : sme_mova_insert_pseudo<SMEMatrixTileD>, SMEPseudo2Instr<NAME # _D, 0>;
978bdd1243dSDimitry Andric  def _PSEUDO_Q : sme_mova_insert_pseudo<SMEMatrixTileQ>, SMEPseudo2Instr<NAME # _Q, 0>;
97981ad6265SDimitry Andric
980fe6060f1SDimitry Andric  defm : sme_vector_to_tile_aliases<!cast<Instruction>(NAME # _B),
981fe6060f1SDimitry Andric                                    !if(is_col, TileVectorOpV8,
982fe6060f1SDimitry Andric                                                TileVectorOpH8),
983349cc55cSDimitry Andric                                    ZPR8, sme_elm_idx0_15>;
984fe6060f1SDimitry Andric  defm : sme_vector_to_tile_aliases<!cast<Instruction>(NAME # _H),
985fe6060f1SDimitry Andric                                    !if(is_col, TileVectorOpV16,
986fe6060f1SDimitry Andric                                                TileVectorOpH16),
987349cc55cSDimitry Andric                                    ZPR16, sme_elm_idx0_7>;
988fe6060f1SDimitry Andric  defm : sme_vector_to_tile_aliases<!cast<Instruction>(NAME # _S),
989fe6060f1SDimitry Andric                                    !if(is_col, TileVectorOpV32,
990fe6060f1SDimitry Andric                                                TileVectorOpH32),
991349cc55cSDimitry Andric                                    ZPR32, sme_elm_idx0_3>;
992fe6060f1SDimitry Andric  defm : sme_vector_to_tile_aliases<!cast<Instruction>(NAME # _D),
993fe6060f1SDimitry Andric                                    !if(is_col, TileVectorOpV64,
994fe6060f1SDimitry Andric                                                TileVectorOpH64),
995349cc55cSDimitry Andric                                    ZPR64, sme_elm_idx0_1>;
996349cc55cSDimitry Andric  defm : sme_vector_to_tile_aliases<!cast<Instruction>(NAME # _Q),
997349cc55cSDimitry Andric                                    !if(is_col, TileVectorOpV128,
998349cc55cSDimitry Andric                                                TileVectorOpH128),
999349cc55cSDimitry Andric                                    ZPR128, sme_elm_idx0_0>;
100081ad6265SDimitry Andric
100181ad6265SDimitry Andric  defvar op = !if(is_col, int_aarch64_sme_write_vert,
100281ad6265SDimitry Andric                          int_aarch64_sme_write_horiz);
100381ad6265SDimitry Andric
100481ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_B),
1005bdd1243dSDimitry Andric                                     nxv16i8, nxv16i1, sme_elm_idx0_0, sme_elm_idx0_15,
100681ad6265SDimitry Andric                                     op, tileslice8>;
100781ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_H),
1008bdd1243dSDimitry Andric                                     nxv8i16, nxv8i1, sme_elm_idx0_1, sme_elm_idx0_7,
100981ad6265SDimitry Andric                                     op, tileslice16>;
101081ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_H),
1011bdd1243dSDimitry Andric                                     nxv8f16, nxv8i1, sme_elm_idx0_1, sme_elm_idx0_7,
101281ad6265SDimitry Andric                                     op, tileslice16>;
101381ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_H),
1014bdd1243dSDimitry Andric                                     nxv8bf16, nxv8i1, sme_elm_idx0_1, sme_elm_idx0_7,
101581ad6265SDimitry Andric                                     op, tileslice16>;
101681ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_S),
1017bdd1243dSDimitry Andric                                     nxv4i32, nxv4i1, sme_elm_idx0_3, sme_elm_idx0_3,
101881ad6265SDimitry Andric                                     op, tileslice32>;
101981ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_S),
1020bdd1243dSDimitry Andric                                     nxv4f32, nxv4i1, sme_elm_idx0_3, sme_elm_idx0_3,
102181ad6265SDimitry Andric                                     op, tileslice32>;
102281ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_D),
1023bdd1243dSDimitry Andric                                     nxv2i64, nxv2i1, sme_elm_idx0_7, sme_elm_idx0_1,
102481ad6265SDimitry Andric                                     op, tileslice64>;
102581ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_D),
1026bdd1243dSDimitry Andric                                     nxv2f64, nxv2i1, sme_elm_idx0_7, sme_elm_idx0_1,
102781ad6265SDimitry Andric                                     op, tileslice64>;
102881ad6265SDimitry Andric
102981ad6265SDimitry Andric  defvar opq = !if(is_col, int_aarch64_sme_writeq_vert,
103081ad6265SDimitry Andric                           int_aarch64_sme_writeq_horiz);
103181ad6265SDimitry Andric
103281ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
103381ad6265SDimitry Andric                                     nxv16i8, nxv16i1, sme_elm_idx0_15,
103481ad6265SDimitry Andric                                     sme_elm_idx0_0, opq, tileslice128>;
103581ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
103681ad6265SDimitry Andric                                     nxv8i16, nxv8i1, sme_elm_idx0_15,
103781ad6265SDimitry Andric                                     sme_elm_idx0_0, opq, tileslice128>;
103881ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
103981ad6265SDimitry Andric                                     nxv8f16, nxv8i1, sme_elm_idx0_15,
104081ad6265SDimitry Andric                                     sme_elm_idx0_0, opq, tileslice128>;
104181ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
104281ad6265SDimitry Andric                                     nxv8bf16, nxv8i1, sme_elm_idx0_15,
104381ad6265SDimitry Andric                                     sme_elm_idx0_0, opq, tileslice128>;
104481ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
104581ad6265SDimitry Andric                                     nxv4i32, nxv4i1, sme_elm_idx0_15,
104681ad6265SDimitry Andric                                     sme_elm_idx0_0, opq, tileslice128>;
104781ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
104881ad6265SDimitry Andric                                     nxv4f32, nxv4i1, sme_elm_idx0_15,
104981ad6265SDimitry Andric                                     sme_elm_idx0_0, opq, tileslice128>;
105081ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
105181ad6265SDimitry Andric                                     nxv2i64, nxv2i1, sme_elm_idx0_15,
105281ad6265SDimitry Andric                                     sme_elm_idx0_0, opq, tileslice128>;
105381ad6265SDimitry Andric  defm : sme_vector_to_tile_patterns<!cast<Instruction>(NAME # _PSEUDO_Q),
105481ad6265SDimitry Andric                                     nxv2f64, nxv2i1, sme_elm_idx0_15,
105581ad6265SDimitry Andric                                     sme_elm_idx0_0, opq, tileslice128>;
1056fe6060f1SDimitry Andric}
1057fe6060f1SDimitry Andric
1058fe6060f1SDimitry Andricmulticlass sme_vector_to_tile<string mnemonic> {
1059fe6060f1SDimitry Andric  defm _H : sme_vector_v_to_tile<mnemonic, /*is_col=*/0b0>;
1060fe6060f1SDimitry Andric  defm _V : sme_vector_v_to_tile<mnemonic, /*is_col=*/0b1>;
1061fe6060f1SDimitry Andric}
1062fe6060f1SDimitry Andric
1063fe6060f1SDimitry Andricclass sme_tile_to_vector_base<bit Q, bit V, bits<2> sz, dag outs, dag ins,
1064fe6060f1SDimitry Andric                              string mnemonic, string argstr>
1065fe6060f1SDimitry Andric    : I<outs, ins, mnemonic, argstr, "", []>, Sched<[]> {
1066fe6060f1SDimitry Andric  bits<2> Rv;
1067fe6060f1SDimitry Andric  bits<3> Pg;
1068fe6060f1SDimitry Andric  bits<5> Zd;
1069fe6060f1SDimitry Andric  let Inst{31-24} = 0b11000000;
1070fe6060f1SDimitry Andric  let Inst{23-22} = sz;
1071fe6060f1SDimitry Andric  let Inst{21-17} = 0b00001;
1072fe6060f1SDimitry Andric  let Inst{16}    = Q;
1073fe6060f1SDimitry Andric  let Inst{15}    = V;
1074fe6060f1SDimitry Andric  let Inst{14-13} = Rv;
1075fe6060f1SDimitry Andric  let Inst{12-10} = Pg;
1076fe6060f1SDimitry Andric  let Inst{9}     = 0b0;
1077fe6060f1SDimitry Andric  let Inst{4-0}   = Zd;
1078fe6060f1SDimitry Andric}
1079fe6060f1SDimitry Andric
1080349cc55cSDimitry Andricclass sme_tile_to_vector_inst<bit Q, bits<2> sz, ZPRRegOp zpr_ty,
1081fe6060f1SDimitry Andric                              MatrixTileVectorOperand tile_ty,
1082fe6060f1SDimitry Andric                              bit is_col, Operand imm_ty, string mnemonic>
1083349cc55cSDimitry Andric    : sme_tile_to_vector_base<Q, is_col, sz, (outs zpr_ty:$Zd),
108481ad6265SDimitry Andric        (ins zpr_ty:$_Zd, PPR3bAny:$Pg, tile_ty:$ZAn, MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm),
108581ad6265SDimitry Andric        mnemonic, "\t$Zd, $Pg/m, $ZAn[$Rv, $imm]"> {
108681ad6265SDimitry Andric
108781ad6265SDimitry Andric  let Constraints = "$Zd = $_Zd";
108881ad6265SDimitry Andric}
1089fe6060f1SDimitry Andric
1090fe6060f1SDimitry Andricmulticlass sme_tile_to_vector_aliases<Instruction inst, ZPRRegOp zpr_ty,
1091fe6060f1SDimitry Andric                                      MatrixTileVectorOperand tile_ty,
1092fe6060f1SDimitry Andric                                      Operand imm_ty > {
1093fe6060f1SDimitry Andric  def : InstAlias<"mov\t$Zd, $Pg/m, $ZAn[$Rv, $imm]",
1094fe6060f1SDimitry Andric                  (inst zpr_ty:$Zd, PPR3bAny:$Pg, tile_ty:$ZAn, MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm), 1>;
1095fe6060f1SDimitry Andric}
1096fe6060f1SDimitry Andric
109781ad6265SDimitry Andricmulticlass sme_tile_to_vector_patterns<Instruction inst, ValueType zpr_vt,
109881ad6265SDimitry Andric                                       ValueType ppr_vt, Operand offset_ty,
109981ad6265SDimitry Andric                                       ComplexPattern imm2tile,
110081ad6265SDimitry Andric                                       ComplexPattern tileslice,
110181ad6265SDimitry Andric                                       SDPatternOperator op> {
110281ad6265SDimitry Andric  def : Pat<(zpr_vt (op (zpr_vt ZPRAny:$passthru), (ppr_vt PPR3bAny:$pg),
110381ad6265SDimitry Andric                        (imm2tile untyped:$tile), MatrixIndexGPR32Op12_15:$idx)),
110481ad6265SDimitry Andric            (inst $passthru, $pg, $tile, $idx, 0)>;
110581ad6265SDimitry Andric  let AddedComplexity = 1 in {
110681ad6265SDimitry Andric    def : Pat<(zpr_vt (op (zpr_vt ZPRAny:$passthru), (ppr_vt PPR3bAny:$pg),
110781ad6265SDimitry Andric                          (imm2tile untyped:$tile),
110881ad6265SDimitry Andric                          (i32 (tileslice MatrixIndexGPR32Op12_15:$idx,
110981ad6265SDimitry Andric                                          offset_ty:$imm)))),
111081ad6265SDimitry Andric              (inst $passthru, $pg, $tile, $idx, $imm)>;
111181ad6265SDimitry Andric  }
111281ad6265SDimitry Andric}
111381ad6265SDimitry Andric
1114fe6060f1SDimitry Andricmulticlass sme_tile_to_vector_v<string mnemonic, bit is_col> {
1115349cc55cSDimitry Andric  def _B : sme_tile_to_vector_inst<0b0, 0b00, ZPR8, !if(is_col, TileVectorOpV8,
1116fe6060f1SDimitry Andric                                                                TileVectorOpH8),
1117349cc55cSDimitry Andric                                   is_col, sme_elm_idx0_15, mnemonic> {
1118fe6060f1SDimitry Andric    bits<4> imm;
1119fe6060f1SDimitry Andric    let Inst{8-5} = imm;
1120fe6060f1SDimitry Andric  }
1121349cc55cSDimitry Andric  def _H : sme_tile_to_vector_inst<0b0, 0b01, ZPR16, !if(is_col, TileVectorOpV16,
1122fe6060f1SDimitry Andric                                                                 TileVectorOpH16),
1123349cc55cSDimitry Andric                                   is_col, sme_elm_idx0_7, mnemonic> {
1124fe6060f1SDimitry Andric    bits<1> ZAn;
1125fe6060f1SDimitry Andric    bits<3> imm;
1126fe6060f1SDimitry Andric    let Inst{8}   = ZAn;
1127fe6060f1SDimitry Andric    let Inst{7-5} = imm;
1128fe6060f1SDimitry Andric  }
1129349cc55cSDimitry Andric  def _S : sme_tile_to_vector_inst<0b0, 0b10, ZPR32, !if(is_col, TileVectorOpV32,
1130fe6060f1SDimitry Andric                                                                 TileVectorOpH32),
1131349cc55cSDimitry Andric                                   is_col, sme_elm_idx0_3, mnemonic> {
1132fe6060f1SDimitry Andric    bits<2> ZAn;
1133fe6060f1SDimitry Andric    bits<2> imm;
1134fe6060f1SDimitry Andric    let Inst{8-7} = ZAn;
1135fe6060f1SDimitry Andric    let Inst{6-5} = imm;
1136fe6060f1SDimitry Andric  }
1137349cc55cSDimitry Andric  def _D : sme_tile_to_vector_inst<0b0, 0b11, ZPR64, !if(is_col, TileVectorOpV64,
1138fe6060f1SDimitry Andric                                                                 TileVectorOpH64),
1139349cc55cSDimitry Andric                                   is_col, sme_elm_idx0_1, mnemonic> {
1140fe6060f1SDimitry Andric    bits<3> ZAn;
1141fe6060f1SDimitry Andric    bits<1> imm;
1142fe6060f1SDimitry Andric    let Inst{8-6} = ZAn;
1143fe6060f1SDimitry Andric    let Inst{5}   = imm;
1144fe6060f1SDimitry Andric  }
1145349cc55cSDimitry Andric  def _Q : sme_tile_to_vector_inst<0b1, 0b11, ZPR128, !if(is_col, TileVectorOpV128,
1146fe6060f1SDimitry Andric                                                                  TileVectorOpH128),
1147349cc55cSDimitry Andric                                   is_col, sme_elm_idx0_0, mnemonic> {
1148fe6060f1SDimitry Andric    bits<4> ZAn;
1149fe6060f1SDimitry Andric    let Inst{8-5} = ZAn;
1150fe6060f1SDimitry Andric  }
1151fe6060f1SDimitry Andric
1152fe6060f1SDimitry Andric  defm : sme_tile_to_vector_aliases<!cast<Instruction>(NAME # _B), ZPR8,
1153fe6060f1SDimitry Andric                                    !if(is_col, TileVectorOpV8,
1154349cc55cSDimitry Andric                                                TileVectorOpH8), sme_elm_idx0_15>;
1155fe6060f1SDimitry Andric  defm : sme_tile_to_vector_aliases<!cast<Instruction>(NAME # _H), ZPR16,
1156fe6060f1SDimitry Andric                                    !if(is_col, TileVectorOpV16,
1157349cc55cSDimitry Andric                                                TileVectorOpH16), sme_elm_idx0_7>;
1158fe6060f1SDimitry Andric  defm : sme_tile_to_vector_aliases<!cast<Instruction>(NAME # _S), ZPR32,
1159fe6060f1SDimitry Andric                                    !if(is_col, TileVectorOpV32,
1160349cc55cSDimitry Andric                                                TileVectorOpH32), sme_elm_idx0_3>;
1161fe6060f1SDimitry Andric  defm : sme_tile_to_vector_aliases<!cast<Instruction>(NAME # _D), ZPR64,
1162fe6060f1SDimitry Andric                                    !if(is_col, TileVectorOpV64,
1163349cc55cSDimitry Andric                                                TileVectorOpH64), sme_elm_idx0_1>;
1164349cc55cSDimitry Andric  defm : sme_tile_to_vector_aliases<!cast<Instruction>(NAME # _Q), ZPR128,
1165349cc55cSDimitry Andric                                    !if(is_col, TileVectorOpV128,
1166349cc55cSDimitry Andric                                                TileVectorOpH128), sme_elm_idx0_0>;
116781ad6265SDimitry Andric
116881ad6265SDimitry Andric  defvar op = !if(is_col, int_aarch64_sme_read_vert,
116981ad6265SDimitry Andric                          int_aarch64_sme_read_horiz);
117081ad6265SDimitry Andric
117181ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _B),
1172bdd1243dSDimitry Andric                                     nxv16i8, nxv16i1, sme_elm_idx0_15,
117381ad6265SDimitry Andric                                     imm_to_tile8, tileslice8, op>;
117481ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _H),
1175bdd1243dSDimitry Andric                                     nxv8i16, nxv8i1, sme_elm_idx0_7,
117681ad6265SDimitry Andric                                     imm_to_tile16, tileslice16, op>;
117781ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _H),
1178bdd1243dSDimitry Andric                                     nxv8f16, nxv8i1, sme_elm_idx0_7,
117981ad6265SDimitry Andric                                     imm_to_tile16, tileslice16, op>;
118081ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _H),
1181bdd1243dSDimitry Andric                                     nxv8bf16, nxv8i1, sme_elm_idx0_7,
118281ad6265SDimitry Andric                                     imm_to_tile16, tileslice16, op>;
118381ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _S),
1184bdd1243dSDimitry Andric                                     nxv4i32, nxv4i1, sme_elm_idx0_3,
118581ad6265SDimitry Andric                                     imm_to_tile32, tileslice32, op>;
118681ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _S),
1187bdd1243dSDimitry Andric                                     nxv4f32, nxv4i1, sme_elm_idx0_3,
118881ad6265SDimitry Andric                                     imm_to_tile32, tileslice32, op>;
118981ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _D),
1190bdd1243dSDimitry Andric                                     nxv2i64, nxv2i1, sme_elm_idx0_1,
119181ad6265SDimitry Andric                                     imm_to_tile64, tileslice64, op>;
119281ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _D),
1193bdd1243dSDimitry Andric                                     nxv2f64, nxv2i1, sme_elm_idx0_1,
119481ad6265SDimitry Andric                                     imm_to_tile64, tileslice64, op>;
119581ad6265SDimitry Andric
119681ad6265SDimitry Andric  defvar opq = !if(is_col, int_aarch64_sme_readq_vert,
119781ad6265SDimitry Andric                           int_aarch64_sme_readq_horiz);
119881ad6265SDimitry Andric
119981ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _Q),
120081ad6265SDimitry Andric                                     nxv16i8, nxv16i1, sme_elm_idx0_0,
120181ad6265SDimitry Andric                                     imm_to_tile128, tileslice128, opq>;
120281ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _Q),
120381ad6265SDimitry Andric                                     nxv8i16, nxv8i1, sme_elm_idx0_0,
120481ad6265SDimitry Andric                                     imm_to_tile128, tileslice128, opq>;
120581ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _Q),
120681ad6265SDimitry Andric                                     nxv8f16, nxv8i1, sme_elm_idx0_0,
120781ad6265SDimitry Andric                                     imm_to_tile128, tileslice128, opq>;
120881ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _Q),
120981ad6265SDimitry Andric                                     nxv8bf16, nxv8i1, sme_elm_idx0_0,
121081ad6265SDimitry Andric                                     imm_to_tile128, tileslice128, opq>;
121181ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _Q),
121281ad6265SDimitry Andric                                     nxv4i32, nxv4i1, sme_elm_idx0_0,
121381ad6265SDimitry Andric                                     imm_to_tile128, tileslice128, opq>;
121481ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _Q),
121581ad6265SDimitry Andric                                     nxv4f32, nxv4i1, sme_elm_idx0_0,
121681ad6265SDimitry Andric                                     imm_to_tile128, tileslice128, opq>;
121781ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _Q),
121881ad6265SDimitry Andric                                     nxv2i64, nxv2i1, sme_elm_idx0_0,
121981ad6265SDimitry Andric                                     imm_to_tile128, tileslice128, opq>;
122081ad6265SDimitry Andric  defm : sme_tile_to_vector_patterns<!cast<Instruction>(NAME # _Q),
122181ad6265SDimitry Andric                                     nxv2f64, nxv2i1, sme_elm_idx0_0,
122281ad6265SDimitry Andric                                     imm_to_tile128, tileslice128, opq>;
1223fe6060f1SDimitry Andric}
1224fe6060f1SDimitry Andric
1225fe6060f1SDimitry Andricmulticlass sme_tile_to_vector<string mnemonic> {
1226fe6060f1SDimitry Andric  defm _H : sme_tile_to_vector_v<mnemonic, /*is_col=*/0b0>;
1227fe6060f1SDimitry Andric  defm _V : sme_tile_to_vector_v<mnemonic, /*is_col=*/0b1>;
1228fe6060f1SDimitry Andric}
1229fe6060f1SDimitry Andric
1230fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
1231fe6060f1SDimitry Andric// SME Zero
1232fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
1233fe6060f1SDimitry Andric
123481ad6265SDimitry Andric// NOTE: This definition isn't really correct because there are outputs, i.e.
123581ad6265SDimitry Andric// the tile registers being zeroed. We fix this up in a custom inserter that
123681ad6265SDimitry Andric// marks the appropriate registers as being implicitly defined.
1237fe6060f1SDimitry Andricclass sme_zero_inst<string mnemonic>
123881ad6265SDimitry Andric    : I<(outs), (ins MatrixTileList:$imm),
1239fe6060f1SDimitry Andric        mnemonic, "\t$imm", "", []>, Sched<[]> {
1240fe6060f1SDimitry Andric  bits<8> imm;
1241fe6060f1SDimitry Andric  let Inst{31-8} = 0b110000000000100000000000;
1242fe6060f1SDimitry Andric  let Inst{7-0}  = imm;
1243fe6060f1SDimitry Andric}
1244fe6060f1SDimitry Andric
1245fe6060f1SDimitry Andricmulticlass sme_zero<string mnemonic> {
1246fe6060f1SDimitry Andric  def NAME : sme_zero_inst<mnemonic>;
1247fe6060f1SDimitry Andric
1248fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za\\}", (!cast<Instruction>(NAME) 0b11111111), 1>;
1249fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za0.h\\}", (!cast<Instruction>(NAME) 0b01010101), 1>;
1250fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za1.h\\}", (!cast<Instruction>(NAME) 0b10101010), 1>;
1251fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za0.s\\}", (!cast<Instruction>(NAME) 0b00010001), 1>;
1252fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za1.s\\}", (!cast<Instruction>(NAME) 0b00100010), 1>;
1253fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za2.s\\}", (!cast<Instruction>(NAME) 0b01000100), 1>;
1254fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za3.s\\}", (!cast<Instruction>(NAME) 0b10001000), 1>;
1255fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za0.s,za1.s\\}", (!cast<Instruction>(NAME) 0b00110011), 1>;
1256fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za0.s,za3.s\\}", (!cast<Instruction>(NAME) 0b10011001), 1>;
1257fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za1.s,za2.s\\}", (!cast<Instruction>(NAME) 0b01100110), 1>;
1258fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za2.s,za3.s\\}", (!cast<Instruction>(NAME) 0b11001100), 1>;
1259fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za0.s,za1.s,za2.s\\}", (!cast<Instruction>(NAME) 0b01110111), 1>;
1260fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za0.s,za1.s,za3.s\\}", (!cast<Instruction>(NAME) 0b10111011), 1>;
1261fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za0.s,za2.s,za3.s\\}", (!cast<Instruction>(NAME) 0b11011101), 1>;
1262fe6060f1SDimitry Andric  def : InstAlias<"zero\t\\{za1.s,za2.s,za3.s\\}", (!cast<Instruction>(NAME) 0b11101110), 1>;
126381ad6265SDimitry Andric
1264bdd1243dSDimitry Andric  def NAME # _PSEUDO : Pseudo<(outs), (ins i32imm:$tilelist), []>,
126581ad6265SDimitry Andric      Sched<[]> {
126681ad6265SDimitry Andric    // Translated to the actual instructions in AArch64ISelLowering.cpp
126781ad6265SDimitry Andric    let usesCustomInserter = 1;
126881ad6265SDimitry Andric  }
126981ad6265SDimitry Andric
1270bdd1243dSDimitry Andric  def : Pat<(int_aarch64_sme_zero timm32_0_255:$imm),
1271bdd1243dSDimitry Andric            (!cast<Instruction>(NAME # _PSEUDO) timm32_0_255:$imm)>;
1272fe6060f1SDimitry Andric}
1273fe6060f1SDimitry Andric
1274fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
1275fe6060f1SDimitry Andric// SVE2 Instructions
1276fe6060f1SDimitry Andric//===----------------------------------------------------------------------===//
1277fe6060f1SDimitry Andric
1278fe6060f1SDimitry Andricclass sve2_int_perm_revd<string asm>
1279fe6060f1SDimitry Andric    : I<(outs ZPR128:$Zd), (ins ZPR128:$_Zd, PPR3bAny:$Pg, ZPR128:$Zn),
1280fe6060f1SDimitry Andric        asm, "\t$Zd, $Pg/m, $Zn", "", []>,
1281fe6060f1SDimitry Andric      Sched<[]> {
1282fe6060f1SDimitry Andric  bits<5> Zd;
1283fe6060f1SDimitry Andric  bits<3> Pg;
1284fe6060f1SDimitry Andric  bits<5> Zn;
1285fe6060f1SDimitry Andric  let Inst{31-24} = 0b00000101;
1286fe6060f1SDimitry Andric  let Inst{23-22} = 0b00; // size
1287fe6060f1SDimitry Andric  let Inst{21-13} = 0b101110100;
1288fe6060f1SDimitry Andric  let Inst{12-10} = Pg;
1289fe6060f1SDimitry Andric  let Inst{9-5}   = Zn;
1290fe6060f1SDimitry Andric  let Inst{4-0}   = Zd;
1291fe6060f1SDimitry Andric
1292fe6060f1SDimitry Andric  let Constraints = "$Zd = $_Zd";
1293fe6060f1SDimitry Andric  let DestructiveInstType = DestructiveUnary;
1294fe6060f1SDimitry Andric  let ElementSize = ZPR128.ElementSize;
1295fe6060f1SDimitry Andric}
1296fe6060f1SDimitry Andric
129781ad6265SDimitry Andricmulticlass sve2_int_perm_revd<string asm, SDPatternOperator op> {
129881ad6265SDimitry Andric  def NAME : sve2_int_perm_revd<asm>;
129981ad6265SDimitry Andric
130081ad6265SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv16i8, op, nxv16i1, nxv16i8, !cast<Instruction>(NAME)>;
130181ad6265SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8i16, op, nxv8i1,  nxv8i16, !cast<Instruction>(NAME)>;
130281ad6265SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4i32, op, nxv4i1,  nxv4i32, !cast<Instruction>(NAME)>;
130381ad6265SDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2i64, op, nxv2i1,  nxv2i64, !cast<Instruction>(NAME)>;
1304cb14a3feSDimitry Andric
1305cb14a3feSDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8bf16, op, nxv8i1, nxv8bf16, !cast<Instruction>(NAME)>;
1306cb14a3feSDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv8f16,  op, nxv8i1, nxv8f16,  !cast<Instruction>(NAME)>;
1307cb14a3feSDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv4f32,  op, nxv4i1, nxv4f32,  !cast<Instruction>(NAME)>;
1308cb14a3feSDimitry Andric  def : SVE_1_Op_Passthru_Pat<nxv2f64,  op, nxv2i1, nxv2f64,  !cast<Instruction>(NAME)>;
1309cb14a3feSDimitry Andric
131081ad6265SDimitry Andric}
131181ad6265SDimitry Andric
1312fe6060f1SDimitry Andricclass sve2_clamp<string asm, bits<2> sz, bit U, ZPRRegOp zpr_ty>
1313297eecfbSDimitry Andric    : I<(outs zpr_ty:$Zd), (ins zpr_ty:$_Zd, zpr_ty:$Zn, zpr_ty:$Zm),
1314fe6060f1SDimitry Andric        asm, "\t$Zd, $Zn, $Zm", "", []>,
1315fe6060f1SDimitry Andric      Sched<[]> {
1316fe6060f1SDimitry Andric  bits<5> Zm;
1317fe6060f1SDimitry Andric  bits<5> Zn;
1318fe6060f1SDimitry Andric  bits<5> Zd;
1319fe6060f1SDimitry Andric  let Inst{31-24} = 0b01000100;
1320fe6060f1SDimitry Andric  let Inst{23-22} = sz;
1321fe6060f1SDimitry Andric  let Inst{21}    = 0b0;
1322fe6060f1SDimitry Andric  let Inst{20-16} = Zm;
1323fe6060f1SDimitry Andric  let Inst{15-11} = 0b11000;
1324fe6060f1SDimitry Andric  let Inst{10}    = U;
1325fe6060f1SDimitry Andric  let Inst{9-5}   = Zn;
1326fe6060f1SDimitry Andric  let Inst{4-0}   = Zd;
1327fe6060f1SDimitry Andric
1328fe6060f1SDimitry Andric  let Constraints = "$Zd = $_Zd";
1329fe6060f1SDimitry Andric  let DestructiveInstType = DestructiveOther;
1330fe6060f1SDimitry Andric  let ElementSize = zpr_ty.ElementSize;
1331fe6060f1SDimitry Andric}
1332fe6060f1SDimitry Andric
133381ad6265SDimitry Andricmulticlass sve2_clamp<string asm, bit U, SDPatternOperator op> {
1334fe6060f1SDimitry Andric  def _B : sve2_clamp<asm, 0b00, U, ZPR8>;
1335fe6060f1SDimitry Andric  def _H : sve2_clamp<asm, 0b01, U, ZPR16>;
1336fe6060f1SDimitry Andric  def _S : sve2_clamp<asm, 0b10, U, ZPR32>;
1337fe6060f1SDimitry Andric  def _D : sve2_clamp<asm, 0b11, U, ZPR64>;
133881ad6265SDimitry Andric
133981ad6265SDimitry Andric  def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
134081ad6265SDimitry Andric  def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
134181ad6265SDimitry Andric  def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv4i32, nxv4i32, !cast<Instruction>(NAME # _S)>;
134281ad6265SDimitry Andric  def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv2i64, nxv2i64, !cast<Instruction>(NAME # _D)>;
1343fe6060f1SDimitry Andric}
1344fe6060f1SDimitry Andric
1345349cc55cSDimitry Andricclass sve2_int_perm_sel_p<string asm, PPRRegOp ppr_ty, Operand imm_ty>
1346*0fca6ea1SDimitry Andric    : I<(outs PPRorPNRAny:$Pd), (ins PPRorPNRAny:$Pn, ppr_ty:$Pm,
1347349cc55cSDimitry Andric                            MatrixIndexGPR32Op12_15:$Rv, imm_ty:$imm),
1348349cc55cSDimitry Andric        asm, "\t$Pd, $Pn, $Pm[$Rv, $imm]", "", []>,
1349fe6060f1SDimitry Andric      Sched<[]> {
1350349cc55cSDimitry Andric  bits<2> Rv;
1351fe6060f1SDimitry Andric  bits<4> Pn;
1352349cc55cSDimitry Andric  bits<4> Pm;
1353fe6060f1SDimitry Andric  bits<4> Pd;
1354fe6060f1SDimitry Andric  let Inst{31-24} = 0b00100101;
1355fe6060f1SDimitry Andric  let Inst{21}    = 0b1;
1356349cc55cSDimitry Andric  let Inst{17-16} = Rv;
1357fe6060f1SDimitry Andric  let Inst{15-14} = 0b01;
1358349cc55cSDimitry Andric  let Inst{13-10} = Pn;
1359fe6060f1SDimitry Andric  let Inst{9}     = 0b0;
1360349cc55cSDimitry Andric  let Inst{8-5}   = Pm;
1361fe6060f1SDimitry Andric  let Inst{4}     = 0b0;
1362fe6060f1SDimitry Andric  let Inst{3-0}   = Pd;
1363fe6060f1SDimitry Andric}
1364fe6060f1SDimitry Andric
136581ad6265SDimitry Andricmulticlass sve2_int_perm_sel_p<string asm, SDPatternOperator op> {
1366349cc55cSDimitry Andric  def _B : sve2_int_perm_sel_p<asm, PPR8, sme_elm_idx0_15> {
1367fe6060f1SDimitry Andric    bits<4> imm;
1368fe6060f1SDimitry Andric    let Inst{23-22} = imm{3-2};
1369fe6060f1SDimitry Andric    let Inst{20-19} = imm{1-0};
1370fe6060f1SDimitry Andric    let Inst{18}    = 0b1;
1371fe6060f1SDimitry Andric  }
1372349cc55cSDimitry Andric  def _H : sve2_int_perm_sel_p<asm, PPR16, sme_elm_idx0_7> {
1373fe6060f1SDimitry Andric    bits<3> imm;
1374fe6060f1SDimitry Andric    let Inst{23-22} = imm{2-1};
1375fe6060f1SDimitry Andric    let Inst{20}    = imm{0};
1376fe6060f1SDimitry Andric    let Inst{19-18} = 0b10;
1377fe6060f1SDimitry Andric  }
1378349cc55cSDimitry Andric  def _S : sve2_int_perm_sel_p<asm, PPR32, sme_elm_idx0_3> {
1379fe6060f1SDimitry Andric    bits<2> imm;
1380fe6060f1SDimitry Andric    let Inst{23-22} = imm{1-0};
1381fe6060f1SDimitry Andric    let Inst{20-18} = 0b100;
1382fe6060f1SDimitry Andric  }
1383349cc55cSDimitry Andric  def _D : sve2_int_perm_sel_p<asm, PPR64, sme_elm_idx0_1> {
1384fe6060f1SDimitry Andric    bits<1> imm;
1385fe6060f1SDimitry Andric    let Inst{23}    = imm;
1386fe6060f1SDimitry Andric    let Inst{22}    = 0b1;
1387fe6060f1SDimitry Andric    let Inst{20-18} = 0b000;
1388fe6060f1SDimitry Andric  }
138981ad6265SDimitry Andric
139006c3fb27SDimitry Andric  def : Pat<(nxv16i1 (op (nxv16i1 PPRAny:$Pn), (nxv16i1 PPR8:$Pm),
139181ad6265SDimitry Andric             MatrixIndexGPR32Op12_15:$idx)),
139281ad6265SDimitry Andric            (!cast<Instruction>(NAME # _B) $Pn, $Pm, $idx, 0)>;
139306c3fb27SDimitry Andric  def : Pat<(nxv16i1 (op (nxv16i1 PPRAny:$Pn), (nxv8i1 PPR16:$Pm),
139481ad6265SDimitry Andric             MatrixIndexGPR32Op12_15:$idx)),
139581ad6265SDimitry Andric            (!cast<Instruction>(NAME # _H) $Pn, $Pm, $idx, 0)>;
139606c3fb27SDimitry Andric  def : Pat<(nxv16i1 (op (nxv16i1 PPRAny:$Pn), (nxv4i1 PPR32:$Pm),
139781ad6265SDimitry Andric             MatrixIndexGPR32Op12_15:$idx)),
139881ad6265SDimitry Andric            (!cast<Instruction>(NAME # _S) $Pn, $Pm, $idx, 0)>;
139906c3fb27SDimitry Andric  def : Pat<(nxv16i1 (op (nxv16i1 PPRAny:$Pn), (nxv2i1 PPR64:$Pm),
140081ad6265SDimitry Andric             MatrixIndexGPR32Op12_15:$idx)),
140181ad6265SDimitry Andric            (!cast<Instruction>(NAME # _D) $Pn, $Pm, $idx, 0)>;
140281ad6265SDimitry Andric
140381ad6265SDimitry Andric  let AddedComplexity = 1 in {
140406c3fb27SDimitry Andric    def : Pat<(nxv16i1 (op (nxv16i1 PPRAny:$Pn), (nxv16i1 PPR8:$Pm),
140581ad6265SDimitry Andric               (i32 (tileslice8 MatrixIndexGPR32Op12_15:$idx, sme_elm_idx0_15:$imm)))),
140681ad6265SDimitry Andric              (!cast<Instruction>(NAME # _B) $Pn, $Pm, $idx, $imm)>;
140706c3fb27SDimitry Andric    def : Pat<(nxv16i1 (op (nxv16i1 PPRAny:$Pn), (nxv8i1 PPR16:$Pm),
140881ad6265SDimitry Andric               (i32 (tileslice16 MatrixIndexGPR32Op12_15:$idx, sme_elm_idx0_7:$imm)))),
140981ad6265SDimitry Andric              (!cast<Instruction>(NAME # _H) $Pn, $Pm, $idx, $imm)>;
141006c3fb27SDimitry Andric    def : Pat<(nxv16i1 (op (nxv16i1 PPRAny:$Pn), (nxv4i1 PPR32:$Pm),
141181ad6265SDimitry Andric               (i32 (tileslice32 MatrixIndexGPR32Op12_15:$idx, sme_elm_idx0_3:$imm)))),
141281ad6265SDimitry Andric              (!cast<Instruction>(NAME # _S) $Pn, $Pm, $idx, $imm)>;
141306c3fb27SDimitry Andric    def : Pat<(nxv16i1 (op (nxv16i1 PPRAny:$Pn), (nxv2i1 PPR64:$Pm),
141481ad6265SDimitry Andric               (i32 (tileslice64 MatrixIndexGPR32Op12_15:$idx, sme_elm_idx0_1:$imm)))),
141581ad6265SDimitry Andric              (!cast<Instruction>(NAME # _D) $Pn, $Pm, $idx, $imm)>;
141681ad6265SDimitry Andric  }
1417fe6060f1SDimitry Andric}
1418bdd1243dSDimitry Andric
1419bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
1420bdd1243dSDimitry Andric// SME2 Instructions
1421bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
1422bdd1243dSDimitry Andric
1423bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
1424bdd1243dSDimitry Andric// SME2 single-multi ternary int/fp, two/four registers
1425bdd1243dSDimitry Andric
1426bdd1243dSDimitry Andricclass sme2_dot_mla_add_sub_array_vg24_single<bits<7> op,
1427bdd1243dSDimitry Andric                                         MatrixOperand matrix_ty,
1428bdd1243dSDimitry Andric                                         RegisterOperand multi_vector_ty,
1429bdd1243dSDimitry Andric                                         ZPRRegOp zpr_ty,
1430bdd1243dSDimitry Andric                                         string mnemonic>
1431bdd1243dSDimitry Andric   : I<(outs matrix_ty:$ZAd),
1432bdd1243dSDimitry Andric       (ins  matrix_ty:$_ZAd, MatrixIndexGPR32Op8_11:$Rv,
1433bdd1243dSDimitry Andric       sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, zpr_ty:$Zm),
1434bdd1243dSDimitry Andric       mnemonic,"\t$ZAd[$Rv, $imm3, " # !if(op{5}, "vgx4", "vgx2") # "], $Zn, $Zm",
1435bdd1243dSDimitry Andric       "", []> , Sched<[]> {
1436bdd1243dSDimitry Andric  bits<4> Zm;
1437bdd1243dSDimitry Andric  bits<5> Zn;
1438bdd1243dSDimitry Andric  bits<2> Rv;
1439bdd1243dSDimitry Andric  bits<3> imm3;
1440bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000010;
1441bdd1243dSDimitry Andric  let Inst{22}    = op{6}; //sz
1442bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
1443bdd1243dSDimitry Andric  let Inst{20}    = op{5}; //vgx4
1444bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
1445bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
1446bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
1447bdd1243dSDimitry Andric  let Inst{12-10} = op{4-2};
1448bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
1449bdd1243dSDimitry Andric  let Inst{4-3}   = op{1-0};
1450bdd1243dSDimitry Andric  let Inst{2-0}   = imm3;
1451bdd1243dSDimitry Andric  let Constraints = "$ZAd = $_ZAd";
1452bdd1243dSDimitry Andric}
1453bdd1243dSDimitry Andric
1454bdd1243dSDimitry Andricmulticlass sme2_dot_mla_add_sub_array_vg24_single<string mnemonic, bits<7> op,
1455bdd1243dSDimitry Andric                                              MatrixOperand matrix_ty,
1456bdd1243dSDimitry Andric                                              RegisterOperand multi_vector_ty,
1457bdd1243dSDimitry Andric                                              ZPRRegOp zpr_ty>{
1458bdd1243dSDimitry Andric  def NAME: sme2_dot_mla_add_sub_array_vg24_single<op, matrix_ty, multi_vector_ty, zpr_ty, mnemonic>, SMEPseudo2Instr<NAME, 1>;
1459bdd1243dSDimitry Andric
1460bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAd[$Rv, $imm3], $Zn, $Zm",
1461bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAd,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, zpr_ty:$Zm), 0>;
1462bdd1243dSDimitry Andric}
1463bdd1243dSDimitry Andric
1464bdd1243dSDimitry Andricmulticlass sme2_dot_mla_add_sub_array_vg2_single<string mnemonic, bits<7> op,
1465bdd1243dSDimitry Andric                                              MatrixOperand matrix_ty,
1466bdd1243dSDimitry Andric                                              RegisterOperand multi_vector_ty,
1467bdd1243dSDimitry Andric                                              ZPRRegOp zpr_ty, ValueType vty, SDPatternOperator intrinsic>{
1468bdd1243dSDimitry Andric  def NAME: sme2_dot_mla_add_sub_array_vg24_single<op, matrix_ty, multi_vector_ty, zpr_ty, mnemonic>, SMEPseudo2Instr<NAME, 1>;
1469bdd1243dSDimitry Andric
1470bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAd[$Rv, $imm3], $Zn, $Zm",
1471bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAd,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, zpr_ty:$Zm), 0>;
1472bdd1243dSDimitry Andric
1473bdd1243dSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, zpr_ty, SMEMatrixArray>;
1474bdd1243dSDimitry Andric
1475bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Single_Pat<NAME, intrinsic, sme_elm_idx0_7, zpr_ty, vty, tileslice16>;
1476bdd1243dSDimitry Andric}
1477bdd1243dSDimitry Andric
1478bdd1243dSDimitry Andricmulticlass sme2_dot_mla_add_sub_array_vg4_single<string mnemonic, bits<7> op,
1479bdd1243dSDimitry Andric                                              MatrixOperand matrix_ty,
1480bdd1243dSDimitry Andric                                              RegisterOperand multi_vector_ty,
1481bdd1243dSDimitry Andric                                              ZPRRegOp zpr_ty, ValueType vty, SDPatternOperator intrinsic>{
1482bdd1243dSDimitry Andric  def NAME: sme2_dot_mla_add_sub_array_vg24_single<op, matrix_ty, multi_vector_ty, zpr_ty, mnemonic>, SMEPseudo2Instr<NAME, 1>;
1483bdd1243dSDimitry Andric
1484bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAd[$Rv, $imm3], $Zn, $Zm",
1485bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAd,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, zpr_ty:$Zm), 0>;
1486bdd1243dSDimitry Andric
1487bdd1243dSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, zpr_ty, SMEMatrixArray>;
1488bdd1243dSDimitry Andric
1489bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Single_Pat<NAME, intrinsic, sme_elm_idx0_7, zpr_ty, vty, tileslice16>;
1490bdd1243dSDimitry Andric}
1491bdd1243dSDimitry Andric
1492bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
1493bdd1243dSDimitry Andric// SME2 multiple vectors ternary INT/FP  two and four registers
14945f757f3fSDimitry Andricclass sme2_dot_mla_add_sub_array_vg2_multi<bits<7> op,
1495bdd1243dSDimitry Andric                                       MatrixOperand matrix_ty,
1496bdd1243dSDimitry Andric                                       RegisterOperand multi_vector_ty,
1497bdd1243dSDimitry Andric                                       string mnemonic>
1498bdd1243dSDimitry Andric   : I<(outs matrix_ty:$ZAd),
1499bdd1243dSDimitry Andric       (ins  matrix_ty:$_ZAd, MatrixIndexGPR32Op8_11:$Rv,
1500bdd1243dSDimitry Andric       sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, multi_vector_ty:$Zm),
1501bdd1243dSDimitry Andric       mnemonic, "\t$ZAd[$Rv, $imm3, vgx2], $Zn, $Zm",
1502bdd1243dSDimitry Andric       "", []>, Sched<[]>{
1503bdd1243dSDimitry Andric  bits<4> Zm;
1504bdd1243dSDimitry Andric  bits<4> Zn;
1505bdd1243dSDimitry Andric  bits<2> Rv;
1506bdd1243dSDimitry Andric  bits<3> imm3;
1507bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000011;
15085f757f3fSDimitry Andric  let Inst{22}    = op{6}; //sz
1509bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
1510bdd1243dSDimitry Andric  let Inst{20-17} = Zm;
1511bdd1243dSDimitry Andric  let Inst{16-15} = 0b00;
1512bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
15135f757f3fSDimitry Andric  let Inst{12-10} = op{5-3};
1514bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
15155f757f3fSDimitry Andric  let Inst{5-3}   = op{2-0};
1516bdd1243dSDimitry Andric  let Inst{2-0}   = imm3;
1517bdd1243dSDimitry Andric  let Constraints = "$ZAd = $_ZAd";
1518bdd1243dSDimitry Andric}
1519bdd1243dSDimitry Andric
15205f757f3fSDimitry Andricmulticlass sme2_dot_mla_add_sub_array_vg2_multi<string mnemonic, bits<7> op,
1521bdd1243dSDimitry Andric                                            MatrixOperand  matrix_ty,
1522bdd1243dSDimitry Andric                                            RegisterOperand multi_vector_ty, ValueType zpr_ty,
1523bdd1243dSDimitry Andric                                            SDPatternOperator intrinsic> {
1524bdd1243dSDimitry Andric  def NAME : sme2_dot_mla_add_sub_array_vg2_multi<op, matrix_ty, multi_vector_ty, mnemonic>, SMEPseudo2Instr<NAME, 1>;
1525bdd1243dSDimitry Andric
1526bdd1243dSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_multi_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, SMEMatrixArray>;
1527bdd1243dSDimitry Andric
1528bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Multi_Pat<NAME, intrinsic, sme_elm_idx0_7, zpr_ty, tileslice16>;
1529bdd1243dSDimitry Andric
1530bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAd[$Rv, $imm3], $Zn, $Zm",
1531bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) matrix_ty:$ZAd,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, multi_vector_ty:$Zm), 0>;
1532bdd1243dSDimitry Andric}
1533bdd1243dSDimitry Andric
15345f757f3fSDimitry Andricclass sme2_dot_mla_add_sub_array_vg4_multi<bits<7> op,
1535bdd1243dSDimitry Andric                                            MatrixOperand matrix_ty,
1536bdd1243dSDimitry Andric                                            RegisterOperand multi_vector_ty,
1537bdd1243dSDimitry Andric                                            string mnemonic>
1538bdd1243dSDimitry Andric   : I<(outs matrix_ty:$ZAd),
1539bdd1243dSDimitry Andric       (ins  matrix_ty:$_ZAd, MatrixIndexGPR32Op8_11:$Rv,
1540bdd1243dSDimitry Andric        sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, multi_vector_ty:$Zm),
1541bdd1243dSDimitry Andric        mnemonic, "\t$ZAd[$Rv, $imm3, vgx4], $Zn, $Zm",
1542bdd1243dSDimitry Andric        "", []>, Sched<[]>{
1543bdd1243dSDimitry Andric  bits<3> Zm;
1544bdd1243dSDimitry Andric  bits<3> Zn;
1545bdd1243dSDimitry Andric  bits<2> Rv;
1546bdd1243dSDimitry Andric  bits<3> imm3;
1547bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000011;
15485f757f3fSDimitry Andric  let Inst{22}    = op{6}; //sz
1549bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
1550bdd1243dSDimitry Andric  let Inst{20-18} = Zm;
1551bdd1243dSDimitry Andric  let Inst{17-15} = 0b010;
1552bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
15535f757f3fSDimitry Andric  let Inst{12-10} = op{5-3};
1554bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
15555f757f3fSDimitry Andric  let Inst{6}     = 0b0;
15565f757f3fSDimitry Andric  let Inst{5-3}   = op{2-0};
1557bdd1243dSDimitry Andric  let Inst{2-0}   = imm3;
1558bdd1243dSDimitry Andric  let Constraints = "$ZAd = $_ZAd";
1559bdd1243dSDimitry Andric}
1560bdd1243dSDimitry Andric
15615f757f3fSDimitry Andricmulticlass sme2_dot_mla_add_sub_array_vg4_multi<string mnemonic, bits<7> op,
1562bdd1243dSDimitry Andric                                            MatrixOperand  matrix_ty,
1563bdd1243dSDimitry Andric                                            RegisterOperand multi_vector_ty,
1564bdd1243dSDimitry Andric                                            ValueType zpr_ty, SDPatternOperator intrinsic>{
1565bdd1243dSDimitry Andric  def NAME : sme2_dot_mla_add_sub_array_vg4_multi<op, matrix_ty, multi_vector_ty, mnemonic>, SMEPseudo2Instr<NAME, 1>;
1566bdd1243dSDimitry Andric
1567bdd1243dSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_multi_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, SMEMatrixArray>;
1568bdd1243dSDimitry Andric
1569bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Multi_Pat<NAME, intrinsic, sme_elm_idx0_7, zpr_ty, tileslice16>;
1570bdd1243dSDimitry Andric
1571bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAd[$Rv, $imm3], $Zn, $Zm",
1572bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAd,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, multi_vector_ty:$Zm), 0>;
1573bdd1243dSDimitry Andric}
1574bdd1243dSDimitry Andric
1575bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
1576bdd1243dSDimitry Andric// SME2 multiple vectors binary two or four  registers
1577bdd1243dSDimitry Andric
1578bdd1243dSDimitry Andricclass sme2_multivec_accum_add_sub<string mnemonic, bit sz, bit vg4, bits<3> op,
1579bdd1243dSDimitry Andric                                  MatrixOperand matrix_ty,
1580bdd1243dSDimitry Andric                                  RegisterOperand vector_ty>
1581bdd1243dSDimitry Andric    : I<(outs matrix_ty:$ZAdn),
1582bdd1243dSDimitry Andric        (ins matrix_ty:$_ZAdn, MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3, vector_ty:$Zm),
1583bdd1243dSDimitry Andric        mnemonic, "\t$ZAdn[$Rv, $imm3, " # !if(vg4, "vgx4", "vgx2") # "], $Zm",
1584bdd1243dSDimitry Andric        "", []>, Sched<[]> {
1585bdd1243dSDimitry Andric  bits<2> Rv;
1586bdd1243dSDimitry Andric  bits<3> imm3;
1587bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000011;
1588bdd1243dSDimitry Andric  let Inst{22}    = sz;
1589bdd1243dSDimitry Andric  let Inst{21-19} = 0b100;
1590bdd1243dSDimitry Andric  let Inst{18}    = op{2};
1591bdd1243dSDimitry Andric  let Inst{17}    = 0b0;
1592bdd1243dSDimitry Andric  let Inst{16}    = vg4;
1593bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
1594bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
1595bdd1243dSDimitry Andric  let Inst{12-10} = 0b111;
1596bdd1243dSDimitry Andric  let Inst{5}     = 0b0;
1597bdd1243dSDimitry Andric  let Inst{4-3}   = op{1-0};
1598bdd1243dSDimitry Andric  let Inst{2-0}   = imm3;
1599bdd1243dSDimitry Andric
1600bdd1243dSDimitry Andric  let Constraints = "$ZAdn = $_ZAdn";
1601bdd1243dSDimitry Andric}
1602bdd1243dSDimitry Andric
1603bdd1243dSDimitry Andricclass sme2_multivec_accum_add_sub_vg2<string mnemonic, bit sz, bits<3> op,
1604bdd1243dSDimitry Andric                                      MatrixOperand matrix_ty,
1605bdd1243dSDimitry Andric                                      RegisterOperand vector_ty>
1606bdd1243dSDimitry Andric    : sme2_multivec_accum_add_sub<mnemonic, sz, 0b0, op, matrix_ty, vector_ty> {
1607bdd1243dSDimitry Andric  bits<4> Zm;
1608bdd1243dSDimitry Andric  let Inst{9-6} = Zm;
1609bdd1243dSDimitry Andric}
1610bdd1243dSDimitry Andric
1611bdd1243dSDimitry Andric
1612bdd1243dSDimitry Andricmulticlass sme2_multivec_accum_add_sub_vg2<string mnemonic, bits<4> op,
1613bdd1243dSDimitry Andric                                           MatrixOperand matrix_ty,
161406c3fb27SDimitry Andric                                           RegisterOperand vector_ty,
161506c3fb27SDimitry Andric                                           ValueType vty,
161606c3fb27SDimitry Andric                                           SDPatternOperator intrinsic> {
161706c3fb27SDimitry Andric  def NAME : sme2_multivec_accum_add_sub_vg2<mnemonic, op{3}, op{2-0}, matrix_ty, vector_ty>,
161806c3fb27SDimitry Andric                                             SMEPseudo2Instr<NAME, 1>;
1619bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAdn[$Rv, $imm3], $Zm",
1620bdd1243dSDimitry Andric  (!cast<Instruction>(NAME) matrix_ty:$ZAdn,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3, vector_ty:$Zm), 0>;
162106c3fb27SDimitry Andric
162206c3fb27SDimitry Andric  def _PSEUDO : sme2_move_to_za_pseudo<NAME, sme_elm_idx0_7, vector_ty, SMEMatrixArray>;
162306c3fb27SDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, vty, sme_elm_idx0_7, tileslice16>;
1624bdd1243dSDimitry Andric}
1625bdd1243dSDimitry Andric
1626bdd1243dSDimitry Andricclass sme2_multivec_accum_add_sub_vg4<string mnemonic, bit sz, bits<3> op,
1627bdd1243dSDimitry Andric                                      MatrixOperand matrix_ty,
1628bdd1243dSDimitry Andric                                      RegisterOperand vector_ty>
1629bdd1243dSDimitry Andric    : sme2_multivec_accum_add_sub<mnemonic, sz, 0b1, op, matrix_ty, vector_ty> {
1630bdd1243dSDimitry Andric  bits<3> Zm;
1631bdd1243dSDimitry Andric  let Inst{9-7} = Zm;
1632bdd1243dSDimitry Andric  let Inst{6}   = 0b0;
1633bdd1243dSDimitry Andric}
1634bdd1243dSDimitry Andric
1635bdd1243dSDimitry Andricmulticlass sme2_multivec_accum_add_sub_vg4<string mnemonic, bits<4> op,
1636bdd1243dSDimitry Andric                                           MatrixOperand matrix_ty,
163706c3fb27SDimitry Andric                                           RegisterOperand vector_ty,
163806c3fb27SDimitry Andric                                           ValueType vty,
163906c3fb27SDimitry Andric                                           SDPatternOperator intrinsic> {
164006c3fb27SDimitry Andric  def NAME : sme2_multivec_accum_add_sub_vg4<mnemonic, op{3}, op{2-0}, matrix_ty, vector_ty>,
164106c3fb27SDimitry Andric                                             SMEPseudo2Instr<NAME, 1>;
1642bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAdn[$Rv, $imm3], $Zm",
1643bdd1243dSDimitry Andric  (!cast<Instruction>(NAME) matrix_ty:$ZAdn,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3, vector_ty:$Zm), 0>;
164406c3fb27SDimitry Andric
164506c3fb27SDimitry Andric  def _PSEUDO : sme2_move_to_za_pseudo<NAME, sme_elm_idx0_7, vector_ty, SMEMatrixArray>;
164606c3fb27SDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, vty, sme_elm_idx0_7, tileslice16>;
1647bdd1243dSDimitry Andric}
1648bdd1243dSDimitry Andric
1649bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
1650bdd1243dSDimitry Andric// SME2 Multi-vector - Multiple and Single SVE Destructive
1651bdd1243dSDimitry Andric// Two and Four registers
1652bdd1243dSDimitry Andric
1653bdd1243dSDimitry Andricclass sme2_sve_destructive_vector_vg2_single<bits<2> sz, bits<7> op,
1654bdd1243dSDimitry Andric                                             RegisterOperand vector_ty,
1655bdd1243dSDimitry Andric                                             ZPRRegOp zpr_ty,
1656bdd1243dSDimitry Andric                                             string mnemonic>
1657bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zdn), (ins vector_ty:$_Zdn, zpr_ty:$Zm),
1658bdd1243dSDimitry Andric        mnemonic, "\t$Zdn, $_Zdn, $Zm",
1659bdd1243dSDimitry Andric        "", []>, Sched<[]> {
1660bdd1243dSDimitry Andric  bits<4> Zm;
1661bdd1243dSDimitry Andric  bits<4> Zdn;
1662bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
1663bdd1243dSDimitry Andric  let Inst{23-22} = sz;
1664bdd1243dSDimitry Andric  let Inst{21-20} = 0b10;
1665bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
1666bdd1243dSDimitry Andric  let Inst{15-11} = 0b10100;
1667bdd1243dSDimitry Andric  let Inst{10-5}  = op{6-1};
1668bdd1243dSDimitry Andric  let Inst{4-1}   = Zdn;
1669bdd1243dSDimitry Andric  let Inst{0}     = op{0};
1670bdd1243dSDimitry Andric
1671bdd1243dSDimitry Andric  let Constraints = "$Zdn = $_Zdn";
1672bdd1243dSDimitry Andric}
1673bdd1243dSDimitry Andric
1674bdd1243dSDimitry Andricmulticlass sme2_fp_sve_destructive_vector_vg2_single<string mnemonic, bits<7> op> {
1675bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg2_single<0b01, op, ZZ_h_mul_r, ZPR4b16, mnemonic>;
1676bdd1243dSDimitry Andric  def _S : sme2_sve_destructive_vector_vg2_single<0b10, op, ZZ_s_mul_r, ZPR4b32, mnemonic>;
1677bdd1243dSDimitry Andric  def _D : sme2_sve_destructive_vector_vg2_single<0b11, op, ZZ_d_mul_r, ZPR4b64, mnemonic>;
1678bdd1243dSDimitry Andric}
1679bdd1243dSDimitry Andric
1680bdd1243dSDimitry Andricmulticlass sme2_int_sve_destructive_vector_vg2_single<string mnemonic, bits<7> op> {
1681bdd1243dSDimitry Andric  def _B : sme2_sve_destructive_vector_vg2_single<0b00, op, ZZ_b_mul_r, ZPR4b8, mnemonic>;
1682bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg2_single<0b01, op, ZZ_h_mul_r, ZPR4b16, mnemonic>;
1683bdd1243dSDimitry Andric  def _S : sme2_sve_destructive_vector_vg2_single<0b10, op, ZZ_s_mul_r, ZPR4b32, mnemonic>;
1684bdd1243dSDimitry Andric  def _D : sme2_sve_destructive_vector_vg2_single<0b11, op, ZZ_d_mul_r, ZPR4b64, mnemonic>;
1685bdd1243dSDimitry Andric}
1686bdd1243dSDimitry Andric
1687bdd1243dSDimitry Andric// SME2.1 fmax/fmin instructions.
1688bdd1243dSDimitry Andricmulticlass sme2p1_bf_max_min_vector_vg2_single<string mnemonic, bits<7>op> {
1689bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg2_single<0b00, op, ZZ_h_mul_r,
1690bdd1243dSDimitry Andric                                                  ZPR4b16, mnemonic>;
1691bdd1243dSDimitry Andric}
1692bdd1243dSDimitry Andric
1693bdd1243dSDimitry Andricclass sme2_sve_destructive_vector_vg4_single<bits<2> sz, bits<7> op,
1694bdd1243dSDimitry Andric                                             RegisterOperand vector_ty,
1695bdd1243dSDimitry Andric                                             ZPRRegOp zpr_ty,
1696bdd1243dSDimitry Andric                                             string mnemonic>
1697bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zdn), (ins vector_ty:$_Zdn, zpr_ty:$Zm),
1698bdd1243dSDimitry Andric        mnemonic, "\t$Zdn, $_Zdn, $Zm",
1699bdd1243dSDimitry Andric        "", []>, Sched<[]> {
1700bdd1243dSDimitry Andric  bits<4> Zm;
1701bdd1243dSDimitry Andric  bits<3> Zdn;
1702bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
1703bdd1243dSDimitry Andric  let Inst{23-22} = sz;
1704bdd1243dSDimitry Andric  let Inst{21-20} = 0b10;
1705bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
1706bdd1243dSDimitry Andric  let Inst{15-11} = 0b10101;
1707bdd1243dSDimitry Andric  let Inst{10-5}  = op{6-1};
1708bdd1243dSDimitry Andric  let Inst{4-2}   = Zdn;
1709bdd1243dSDimitry Andric  let Inst{1}     = 0b0;
1710bdd1243dSDimitry Andric  let Inst{0}     = op{0};
1711bdd1243dSDimitry Andric
1712bdd1243dSDimitry Andric  let Constraints = "$Zdn = $_Zdn";
1713bdd1243dSDimitry Andric}
1714bdd1243dSDimitry Andric
1715bdd1243dSDimitry Andricmulticlass sme2_fp_sve_destructive_vector_vg4_single<string mnemonic, bits<7> op> {
1716bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg4_single<0b01, op, ZZZZ_h_mul_r, ZPR4b16, mnemonic>;
1717bdd1243dSDimitry Andric  def _S : sme2_sve_destructive_vector_vg4_single<0b10, op, ZZZZ_s_mul_r, ZPR4b32, mnemonic>;
1718bdd1243dSDimitry Andric  def _D : sme2_sve_destructive_vector_vg4_single<0b11, op, ZZZZ_d_mul_r, ZPR4b64, mnemonic>;
1719bdd1243dSDimitry Andric}
1720bdd1243dSDimitry Andric
1721bdd1243dSDimitry Andricmulticlass sme2_int_sve_destructive_vector_vg4_single<string mnemonic, bits<7> op> {
1722bdd1243dSDimitry Andric  def _B : sme2_sve_destructive_vector_vg4_single<0b00, op, ZZZZ_b_mul_r, ZPR4b8, mnemonic>;
1723bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg4_single<0b01, op, ZZZZ_h_mul_r, ZPR4b16, mnemonic>;
1724bdd1243dSDimitry Andric  def _S : sme2_sve_destructive_vector_vg4_single<0b10, op, ZZZZ_s_mul_r, ZPR4b32, mnemonic>;
1725bdd1243dSDimitry Andric  def _D : sme2_sve_destructive_vector_vg4_single<0b11, op, ZZZZ_d_mul_r, ZPR4b64, mnemonic>;
1726bdd1243dSDimitry Andric}
1727bdd1243dSDimitry Andric
1728bdd1243dSDimitry Andric// SME2.1 fmax/fmin instructions.
1729bdd1243dSDimitry Andricmulticlass sme2p1_bf_max_min_vector_vg4_single<string mnemonic, bits<7>op> {
1730bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg4_single<0b00, op, ZZZZ_h_mul_r,
1731bdd1243dSDimitry Andric                                                  ZPR4b16, mnemonic>;
1732bdd1243dSDimitry Andric}
1733bdd1243dSDimitry Andric
1734bdd1243dSDimitry Andricclass sme2_sve_destructive_vector_vg2_multi<bits<2> sz, bits<7> op,
1735bdd1243dSDimitry Andric                                            RegisterOperand vector_ty,
1736bdd1243dSDimitry Andric                                            string mnemonic>
1737bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zdn), (ins vector_ty:$_Zdn, vector_ty:$Zm),
1738bdd1243dSDimitry Andric        mnemonic, "\t$Zdn, $_Zdn, $Zm",
1739bdd1243dSDimitry Andric        "", []>, Sched<[]> {
1740bdd1243dSDimitry Andric  bits<4> Zm;
1741bdd1243dSDimitry Andric  bits<4> Zdn;
1742bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
1743bdd1243dSDimitry Andric  let Inst{23-22} = sz;
1744bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
1745bdd1243dSDimitry Andric  let Inst{20-17} = Zm;
1746bdd1243dSDimitry Andric  let Inst{16-11} = 0b010110;
1747bdd1243dSDimitry Andric  let Inst{10-5}  = op{6-1};
1748bdd1243dSDimitry Andric  let Inst{4-1}   = Zdn;
1749bdd1243dSDimitry Andric  let Inst{0}     = op{0};
1750bdd1243dSDimitry Andric
1751bdd1243dSDimitry Andric  let Constraints = "$Zdn = $_Zdn";
1752bdd1243dSDimitry Andric}
1753bdd1243dSDimitry Andric
1754bdd1243dSDimitry Andricmulticlass sme2_fp_sve_destructive_vector_vg2_multi<string mnemonic, bits<7> op> {
1755bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg2_multi<0b01, op, ZZ_h_mul_r, mnemonic>;
1756bdd1243dSDimitry Andric  def _S : sme2_sve_destructive_vector_vg2_multi<0b10, op, ZZ_s_mul_r, mnemonic>;
1757bdd1243dSDimitry Andric  def _D : sme2_sve_destructive_vector_vg2_multi<0b11, op, ZZ_d_mul_r, mnemonic>;
1758bdd1243dSDimitry Andric}
1759bdd1243dSDimitry Andric
1760bdd1243dSDimitry Andricmulticlass sme2_int_sve_destructive_vector_vg2_multi<string mnemonic, bits<7> op> {
1761bdd1243dSDimitry Andric  def _B : sme2_sve_destructive_vector_vg2_multi<0b00, op, ZZ_b_mul_r, mnemonic>;
1762bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg2_multi<0b01, op, ZZ_h_mul_r, mnemonic>;
1763bdd1243dSDimitry Andric  def _S : sme2_sve_destructive_vector_vg2_multi<0b10, op, ZZ_s_mul_r, mnemonic>;
1764bdd1243dSDimitry Andric  def _D : sme2_sve_destructive_vector_vg2_multi<0b11, op, ZZ_d_mul_r, mnemonic>;
1765bdd1243dSDimitry Andric}
1766bdd1243dSDimitry Andric
1767bdd1243dSDimitry Andric// SME2.1 fmax/fmin instructions.
1768bdd1243dSDimitry Andricmulticlass sme2p1_bf_max_min_vector_vg2_multi<string mnemonic, bits<7>op> {
1769bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg2_multi<0b00, op, ZZ_h_mul_r,
1770bdd1243dSDimitry Andric                                                 mnemonic>;
1771bdd1243dSDimitry Andric}
1772bdd1243dSDimitry Andric
1773bdd1243dSDimitry Andricclass sme2_sve_destructive_vector_vg4_multi<bits<2> sz, bits<7> op,
1774bdd1243dSDimitry Andric                                            RegisterOperand vector_ty,
1775bdd1243dSDimitry Andric                                            string mnemonic>
1776bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zdn), (ins vector_ty:$_Zdn, vector_ty:$Zm),
1777bdd1243dSDimitry Andric        mnemonic, "\t$Zdn, $_Zdn, $Zm",
1778bdd1243dSDimitry Andric        "", []>, Sched<[]> {
1779bdd1243dSDimitry Andric  bits<3> Zm;
1780bdd1243dSDimitry Andric  bits<3> Zdn;
1781bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
1782bdd1243dSDimitry Andric  let Inst{23-22} = sz;
1783bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
1784bdd1243dSDimitry Andric  let Inst{20-18} = Zm;
1785bdd1243dSDimitry Andric  let Inst{17-11} = 0b0010111;
1786bdd1243dSDimitry Andric  let Inst{10-5}  = op{6-1};
1787bdd1243dSDimitry Andric  let Inst{4-2}   = Zdn;
1788bdd1243dSDimitry Andric  let Inst{1}     = 0b0;
1789bdd1243dSDimitry Andric  let Inst{0}     = op{0};
1790bdd1243dSDimitry Andric
1791bdd1243dSDimitry Andric  let Constraints = "$Zdn = $_Zdn";
1792bdd1243dSDimitry Andric}
1793bdd1243dSDimitry Andric
1794bdd1243dSDimitry Andricmulticlass sme2_fp_sve_destructive_vector_vg4_multi<string mnemonic, bits<7> op> {
1795bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg4_multi<0b01, op, ZZZZ_h_mul_r, mnemonic>;
1796bdd1243dSDimitry Andric  def _S : sme2_sve_destructive_vector_vg4_multi<0b10, op, ZZZZ_s_mul_r, mnemonic>;
1797bdd1243dSDimitry Andric  def _D : sme2_sve_destructive_vector_vg4_multi<0b11, op, ZZZZ_d_mul_r, mnemonic>;
1798bdd1243dSDimitry Andric}
1799bdd1243dSDimitry Andric
1800bdd1243dSDimitry Andricmulticlass sme2_int_sve_destructive_vector_vg4_multi<string mnemonic, bits<7> op> {
1801bdd1243dSDimitry Andric  def _B : sme2_sve_destructive_vector_vg4_multi<0b00, op, ZZZZ_b_mul_r, mnemonic>;
1802bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg4_multi<0b01, op, ZZZZ_h_mul_r, mnemonic>;
1803bdd1243dSDimitry Andric  def _S : sme2_sve_destructive_vector_vg4_multi<0b10, op, ZZZZ_s_mul_r, mnemonic>;
1804bdd1243dSDimitry Andric  def _D : sme2_sve_destructive_vector_vg4_multi<0b11, op, ZZZZ_d_mul_r, mnemonic>;
1805bdd1243dSDimitry Andric}
1806bdd1243dSDimitry Andric
1807bdd1243dSDimitry Andric// SME2.1 fmax/fmin instructions.
1808bdd1243dSDimitry Andricmulticlass sme2p1_bf_max_min_vector_vg4_multi<string mnemonic, bits<7>op> {
1809bdd1243dSDimitry Andric  def _H : sme2_sve_destructive_vector_vg4_multi<0b00, op, ZZZZ_h_mul_r,
1810bdd1243dSDimitry Andric                                                 mnemonic>;
1811bdd1243dSDimitry Andric}
1812bdd1243dSDimitry Andric
1813bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
1814bdd1243dSDimitry Andric// SME2 Multi-vector - Index/Single/Multi Array Vectors FMA sources
1815bdd1243dSDimitry Andric
1816bdd1243dSDimitry Andricclass sme2_mla_long_array_index_base<bits<2> op0, bits<2> op, Operand index_ty,
1817bdd1243dSDimitry Andric                                     RegisterOperand multi_vector_ty,
1818bdd1243dSDimitry Andric                                     string mnemonic, string vg_acronym="">
1819bdd1243dSDimitry Andric    : I<(outs MatrixOp32:$ZAda),
1820bdd1243dSDimitry Andric        (ins MatrixOp32:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, index_ty:$imm, multi_vector_ty:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i3),
1821bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm" # !if(!eq(vg_acronym, ""), "", ", " # vg_acronym) # "], $Zn, $Zm$i3",
1822bdd1243dSDimitry Andric        "", []>, Sched<[]> {
1823bdd1243dSDimitry Andric  bits<4> Zm;
1824bdd1243dSDimitry Andric  bits<2> Rv;
1825bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
1826bdd1243dSDimitry Andric  let Inst{23-22} = op0;
1827bdd1243dSDimitry Andric  let Inst{21}    = 0b0;
1828bdd1243dSDimitry Andric  let Inst{20}    = !if(!eq(vg_acronym, ""), 0, 1);
1829bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
1830bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
1831bdd1243dSDimitry Andric  let Inst{12}    = 0b1;
1832bdd1243dSDimitry Andric  let Inst{4-3}   = op;
1833bdd1243dSDimitry Andric
1834bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
1835bdd1243dSDimitry Andric}
1836bdd1243dSDimitry Andric
1837bdd1243dSDimitry Andricmulticlass sme2_mla_long_array_index<string mnemonic, bits<2> op0, bits<2> op, ValueType zpr_ty, SDPatternOperator intrinsic> {
18385f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array_index_base<op0, op, uimm3s2range, ZPR16,
18395f757f3fSDimitry Andric                                          mnemonic>, SMEPseudo2Instr<NAME # _HtoS, 1> {
1840bdd1243dSDimitry Andric    bits<3> i3;
1841bdd1243dSDimitry Andric    bits<5> Zn;
1842bdd1243dSDimitry Andric    bits<3> imm;
1843bdd1243dSDimitry Andric    let Inst{15}    = i3{2};
1844bdd1243dSDimitry Andric    let Inst{11-10} = i3{1-0};
1845bdd1243dSDimitry Andric    let Inst{9-5}   = Zn;
1846bdd1243dSDimitry Andric    let Inst{2-0}   = imm;
1847bdd1243dSDimitry Andric  }
1848bdd1243dSDimitry Andric
18495f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME # _HtoS, uimm3s2range, ZPR16, ZPR4b16, VectorIndexH32b_timm, SMEMatrixArray>;
1850bdd1243dSDimitry Andric
18515f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_Multi_Index_Pat<NAME # _HtoS, intrinsic, uimm3s2range, ZPR4b16, zpr_ty, VectorIndexH32b_timm, tileslicerange3s2>;
1852bdd1243dSDimitry Andric}
1853bdd1243dSDimitry Andric
1854bdd1243dSDimitry Andricclass sme2_mla_long_array_vg2_index<string mnemonic, bits<2> op0, bits<2> op>
1855bdd1243dSDimitry Andric    : sme2_mla_long_array_index_base<op0, op, uimm2s2range, ZZ_h_mul_r,
1856bdd1243dSDimitry Andric                                     mnemonic, "vgx2"> {
1857bdd1243dSDimitry Andric  bits<3> i3;
1858bdd1243dSDimitry Andric  bits<4> Zn;
1859bdd1243dSDimitry Andric  bits<2> imm;
1860bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
1861bdd1243dSDimitry Andric  let Inst{11-10} = i3{2-1};
1862bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
1863bdd1243dSDimitry Andric  let Inst{5}     = 0b0;
1864bdd1243dSDimitry Andric  let Inst{2}     = i3{0};
1865bdd1243dSDimitry Andric  let Inst{1-0}   = imm;
1866bdd1243dSDimitry Andric}
1867bdd1243dSDimitry Andric
1868bdd1243dSDimitry Andricmulticlass sme2_fp_mla_long_array_vg2_index<string mnemonic, bits<2> op, ValueType zpr_ty, SDPatternOperator intrinsic> {
18695f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array_vg2_index<mnemonic, 0b10, op>, SMEPseudo2Instr<NAME # _HtoS, 1>;
1870bdd1243dSDimitry Andric
18715f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME # _HtoS, uimm2s2range, ZZ_h_mul_r, ZPR4b16, VectorIndexH32b_timm, SMEMatrixArray>;
1872bdd1243dSDimitry Andric
18735f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Index_Pat<NAME # _HtoS, intrinsic, uimm2s2range, ZPR4b16, zpr_ty, VectorIndexH32b_timm, tileslicerange2s2>;
1874bdd1243dSDimitry Andric
1875bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm$i3",
18765f757f3fSDimitry Andric                 (!cast<Instruction>(NAME #_HtoS) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm, ZZ_h_mul_r:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i3), 0>;
1877bdd1243dSDimitry Andric}
1878bdd1243dSDimitry Andric
1879bdd1243dSDimitry Andricmulticlass sme2_int_mla_long_array_vg2_index<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
1880bdd1243dSDimitry Andric  def _S : sme2_mla_long_array_vg2_index<mnemonic, 0b11, op>, SMEPseudo2Instr<NAME # _S, 1>;
1881bdd1243dSDimitry Andric
1882bdd1243dSDimitry Andric  def _S_PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME # _S, uimm2s2range, ZZ_h_mul_r, ZPR4b16, VectorIndexH32b_timm, SMEMatrixArray>;
1883bdd1243dSDimitry Andric
1884bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Index_Pat<NAME # _S, intrinsic, uimm2s2range, ZPR4b16, nxv8i16, VectorIndexH32b_timm, tileslicerange2s2>;
1885bdd1243dSDimitry Andric
1886bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm$i3",
1887bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME #_S) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm, ZZ_h_mul_r:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i3), 0>;
1888bdd1243dSDimitry Andric}
1889bdd1243dSDimitry Andric
1890bdd1243dSDimitry Andricclass sme2_mla_long_array_vg4_index<string mnemonic, bits<2> op0, bits<2> op>
1891bdd1243dSDimitry Andric    : sme2_mla_long_array_index_base<op0, op, uimm2s2range, ZZZZ_h_mul_r,
1892bdd1243dSDimitry Andric                                      mnemonic, "vgx4"> {
1893bdd1243dSDimitry Andric  bits<3> i3;
1894bdd1243dSDimitry Andric  bits<3> Zn;
1895bdd1243dSDimitry Andric  bits<2> imm;
1896bdd1243dSDimitry Andric  let Inst{15}    = 0b1;
1897bdd1243dSDimitry Andric  let Inst{11-10} = i3{2-1};
1898bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
1899bdd1243dSDimitry Andric  let Inst{6-5}   = 0b00;
1900bdd1243dSDimitry Andric  let Inst{2}     = i3{0};
1901bdd1243dSDimitry Andric  let Inst{1-0}   = imm;
1902bdd1243dSDimitry Andric}
1903bdd1243dSDimitry Andric
1904bdd1243dSDimitry Andricmulticlass sme2_fp_mla_long_array_vg4_index<string mnemonic, bits<2> op, ValueType zpr_ty, SDPatternOperator intrinsic> {
19055f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array_vg4_index<mnemonic, 0b10, op>, SMEPseudo2Instr<NAME # _HtoS, 1>;
1906bdd1243dSDimitry Andric
19075f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME # _HtoS, uimm2s2range, ZZZZ_h_mul_r, ZPR4b16, VectorIndexH32b_timm, SMEMatrixArray>;
1908bdd1243dSDimitry Andric
19095f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Index_Pat<NAME # _HtoS, intrinsic, uimm2s2range, ZPR4b16, zpr_ty, VectorIndexH32b_timm, tileslicerange2s2>;
1910bdd1243dSDimitry Andric
1911bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm$i3",
19125f757f3fSDimitry Andric                 (!cast<Instruction>(NAME #_HtoS) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm, ZZZZ_h_mul_r:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i3), 0>;
1913bdd1243dSDimitry Andric}
1914bdd1243dSDimitry Andric
1915bdd1243dSDimitry Andricmulticlass sme2_int_mla_long_array_vg4_index<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
19165f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array_vg4_index<mnemonic, 0b11, op>, SMEPseudo2Instr<NAME # _HtoS, 1>;
1917bdd1243dSDimitry Andric
19185f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME # _HtoS, uimm2s2range, ZZZZ_h_mul_r, ZPR4b16, VectorIndexH32b_timm, SMEMatrixArray>;
1919bdd1243dSDimitry Andric
19205f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Index_Pat<NAME # _HtoS, intrinsic, uimm2s2range, ZPR4b16, nxv8i16, VectorIndexH32b_timm, tileslicerange2s2>;
1921bdd1243dSDimitry Andric
1922bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm$i3",
19235f757f3fSDimitry Andric                 (!cast<Instruction>(NAME #_HtoS) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm, ZZZZ_h_mul_r:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i3), 0>;
1924bdd1243dSDimitry Andric}
1925bdd1243dSDimitry Andric
19265f757f3fSDimitry Andricclass sme2_mla_long_array<bits<2>op0, bits<2> op,
19275f757f3fSDimitry Andric                          MatrixOperand matrix_ty,
19285f757f3fSDimitry Andric                          Operand index_ty,
1929bdd1243dSDimitry Andric                          RegisterOperand first_vector_ty,
1930bdd1243dSDimitry Andric                          RegisterOperand second_vector_ty,
1931bdd1243dSDimitry Andric                          string mnemonic, string vg_acronym="">
19325f757f3fSDimitry Andric   : I<(outs matrix_ty:$ZAda),
19335f757f3fSDimitry Andric       (ins  matrix_ty:$_ZAda, MatrixIndexGPR32Op8_11:$Rv,
1934bdd1243dSDimitry Andric       index_ty:$imm, first_vector_ty:$Zn, second_vector_ty:$Zm),
1935bdd1243dSDimitry Andric       mnemonic,"\t$ZAda[$Rv, $imm" # !if(!eq(vg_acronym, ""), "", ", " # vg_acronym) # "], $Zn, $Zm",
1936bdd1243dSDimitry Andric       "", []> , Sched<[]> {
1937bdd1243dSDimitry Andric  bits<2> Rv;
1938bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
1939bdd1243dSDimitry Andric  let Inst{23-22} = op0;
1940bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
1941bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
1942bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
1943bdd1243dSDimitry Andric  let Inst{12-11} = 0b01;
1944bdd1243dSDimitry Andric  let Inst{10}    = !if(!eq(vg_acronym, ""), 1, 0);
1945bdd1243dSDimitry Andric  let Inst{4-3}   = op;
1946bdd1243dSDimitry Andric
1947bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
1948bdd1243dSDimitry Andric}
1949bdd1243dSDimitry Andric
1950bdd1243dSDimitry Andricmulticlass sme2_mla_long_array_single<string mnemonic, bits<2> op0, bits<2> op, ValueType zpr_ty, SDPatternOperator intrinsic> {
19515f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array<op0, op, MatrixOp32, uimm3s2range, ZPR16, ZPR4b16,
19525f757f3fSDimitry Andric                               mnemonic> , SMEPseudo2Instr<NAME # _HtoS, 1>{
1953bdd1243dSDimitry Andric    bits<4> Zm;
1954bdd1243dSDimitry Andric    bits<5> Zn;
1955bdd1243dSDimitry Andric    bits<3> imm;
1956bdd1243dSDimitry Andric    let Inst{20}    = 0b0;
1957bdd1243dSDimitry Andric    let Inst{19-16} = Zm;
1958bdd1243dSDimitry Andric    let Inst{9-5}   = Zn;
1959bdd1243dSDimitry Andric    let Inst{2-0}   = imm;
1960bdd1243dSDimitry Andric  }
1961bdd1243dSDimitry Andric
19625f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME # _HtoS, uimm3s2range, ZPR16, ZPR4b16, SMEMatrixArray>;
1963bdd1243dSDimitry Andric
19645f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_Multi_Single_Pat<NAME # _HtoS, intrinsic, uimm3s2range, ZPR4b16, zpr_ty, tileslicerange3s2>;
1965bdd1243dSDimitry Andric}
1966bdd1243dSDimitry Andric
19675f757f3fSDimitry Andricclass sme2_mla_long_array_single_16b<string mnemonic>
19685f757f3fSDimitry Andric    : sme2_mla_long_array<0b00, 0b00, MatrixOp16, uimm3s2range, ZPR8, ZPR4b8,  mnemonic> {
19695f757f3fSDimitry Andric    bits<4> Zm;
19705f757f3fSDimitry Andric    bits<5> Zn;
19715f757f3fSDimitry Andric    bits<3> imm;
19725f757f3fSDimitry Andric    let Inst{20}    = 0b1;
19735f757f3fSDimitry Andric    let Inst{19-16} = Zm;
19745f757f3fSDimitry Andric    let Inst{9-5}   = Zn;
19755f757f3fSDimitry Andric    let Inst{2-0}   = imm;
19765f757f3fSDimitry Andric}
19775f757f3fSDimitry Andric
19785f757f3fSDimitry Andricclass sme2_mla_long_array_vg24_single<bits<2> op0, bit vg4, bits<2> op, bit o2,
19795f757f3fSDimitry Andric                                      MatrixOperand matrix_ty, RegisterOperand multi_vector_ty,
19805f757f3fSDimitry Andric                                      ZPRRegOp zpr_ty, string mnemonic, string vg_acronym>
19815f757f3fSDimitry Andric    : sme2_mla_long_array<op0, op, matrix_ty, uimm2s2range, multi_vector_ty, zpr_ty,
1982bdd1243dSDimitry Andric                          mnemonic, vg_acronym> {
1983bdd1243dSDimitry Andric  bits<4> Zm;
1984bdd1243dSDimitry Andric  bits<5> Zn;
1985bdd1243dSDimitry Andric  bits<2> imm;
1986bdd1243dSDimitry Andric  let Inst{20}    = vg4;
1987bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
1988bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
19895f757f3fSDimitry Andric  let Inst{2}     = o2;
1990bdd1243dSDimitry Andric  let Inst{1-0}   = imm;
1991bdd1243dSDimitry Andric}
1992bdd1243dSDimitry Andric
19935f757f3fSDimitry Andricmulticlass sme2_fp_mla_long_array_vg2_single<string mnemonic, bits<3> op, MatrixOperand matrix_ty,
19945f757f3fSDimitry Andric                                             RegisterOperand multi_vector_ty, ZPRRegOp vector_ty,
19955f757f3fSDimitry Andric                                             ValueType zpr_ty, SDPatternOperator intrinsic> {
19965f757f3fSDimitry Andric  def NAME : sme2_mla_long_array_vg24_single<0b00, 0b0, op{2-1}, op{0}, matrix_ty,  multi_vector_ty,
19975f757f3fSDimitry Andric                                           vector_ty, mnemonic, "vgx2">, SMEPseudo2Instr<NAME, 1>;
1998bdd1243dSDimitry Andric
19995f757f3fSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME, uimm2s2range, multi_vector_ty,
20005f757f3fSDimitry Andric                                                        vector_ty, SMEMatrixArray>;
2001bdd1243dSDimitry Andric
20025f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Single_Pat<NAME, intrinsic, uimm2s2range, vector_ty, zpr_ty,
20035f757f3fSDimitry Andric                                           tileslicerange2s2>;
2004bdd1243dSDimitry Andric
2005bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm",
20065f757f3fSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAda,  MatrixIndexGPR32Op8_11:$Rv,
20075f757f3fSDimitry Andric                  uimm2s2range:$imm, multi_vector_ty:$Zn, vector_ty:$Zm), 0>;
2008bdd1243dSDimitry Andric}
2009bdd1243dSDimitry Andric
2010bdd1243dSDimitry Andricmulticlass sme2_int_mla_long_array_vg2_single<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
20115f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array_vg24_single<0b01, 0b0, op, 0b0, MatrixOp32, ZZ_h, ZPR4b16, mnemonic,
20125f757f3fSDimitry Andric                                             "vgx2">, SMEPseudo2Instr<NAME # _HtoS, 1>;
2013bdd1243dSDimitry Andric
20145f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME # _HtoS, uimm2s2range, ZZ_h, ZPR4b16, SMEMatrixArray>;
2015bdd1243dSDimitry Andric
20165f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Single_Pat<NAME # _HtoS, intrinsic, uimm2s2range, ZPR4b16, nxv8i16, tileslicerange2s2>;
2017bdd1243dSDimitry Andric
2018bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm",
20195f757f3fSDimitry Andric                 (!cast<Instruction>(NAME #_HtoS) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm, ZZ_h:$Zn, ZPR4b16:$Zm), 0>;
2020bdd1243dSDimitry Andric}
2021bdd1243dSDimitry Andric
20225f757f3fSDimitry Andricmulticlass sme2_fp_mla_long_array_vg4_single<string mnemonic, bits<3> op, MatrixOperand matrix_ty,
20235f757f3fSDimitry Andric                                             RegisterOperand multi_vector_ty, ZPRRegOp vector_ty,
20245f757f3fSDimitry Andric                                             ValueType zpr_ty, SDPatternOperator intrinsic> {
20255f757f3fSDimitry Andric  def NAME : sme2_mla_long_array_vg24_single<0b00, 0b1, op{2-1}, op{0}, matrix_ty, multi_vector_ty,
20265f757f3fSDimitry Andric                                             vector_ty, mnemonic, "vgx4">,
20275f757f3fSDimitry Andric                                             SMEPseudo2Instr<NAME, 1>;
2028bdd1243dSDimitry Andric
20295f757f3fSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME, uimm2s2range, multi_vector_ty, vector_ty,
20305f757f3fSDimitry Andric                                                      SMEMatrixArray>;
2031bdd1243dSDimitry Andric
20325f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Single_Pat<NAME, intrinsic, uimm2s2range, vector_ty, zpr_ty,
20335f757f3fSDimitry Andric                                           tileslicerange2s2>;
2034bdd1243dSDimitry Andric
2035bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm",
20365f757f3fSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAda, MatrixIndexGPR32Op8_11:$Rv,
20375f757f3fSDimitry Andric                  uimm2s2range:$imm, multi_vector_ty:$Zn, vector_ty:$Zm), 0>;
2038bdd1243dSDimitry Andric}
2039bdd1243dSDimitry Andric
2040bdd1243dSDimitry Andricmulticlass sme2_int_mla_long_array_vg4_single<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
20415f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array_vg24_single<0b01, 0b1, op, 0b0, MatrixOp32, ZZZZ_h, ZPR4b16,  mnemonic,
20425f757f3fSDimitry Andric                                           "vgx4">, SMEPseudo2Instr<NAME # _HtoS, 1>;
2043bdd1243dSDimitry Andric
20445f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME # _HtoS, uimm2s2range, ZZZZ_h, ZPR4b16, SMEMatrixArray>;
2045bdd1243dSDimitry Andric
20465f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Single_Pat<NAME # _HtoS, intrinsic, uimm2s2range, ZPR4b16, nxv8i16, tileslicerange2s2>;
2047bdd1243dSDimitry Andric
2048bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm",
20495f757f3fSDimitry Andric                 (!cast<Instruction>(NAME #_HtoS) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm, ZZZZ_h:$Zn, ZPR4b16:$Zm), 0>;
2050bdd1243dSDimitry Andric}
20515f757f3fSDimitry Andric
20525f757f3fSDimitry Andricclass sme2_mla_long_array_vg2_multi<string mnemonic, bits<2> op0, bits<3> op,
20535f757f3fSDimitry Andric                                    MatrixOperand matrix_ty, RegisterOperand multi_vector_ty>
20545f757f3fSDimitry Andric   : sme2_mla_long_array<op0, op{1-0},  matrix_ty, uimm2s2range, multi_vector_ty, multi_vector_ty,
20555f757f3fSDimitry Andric                        mnemonic, "vgx2"> {
2056bdd1243dSDimitry Andric  bits<4> Zm;
2057bdd1243dSDimitry Andric  bits<4> Zn;
2058bdd1243dSDimitry Andric  bits<2> imm;
2059bdd1243dSDimitry Andric  let Inst{20-17} = Zm;
2060bdd1243dSDimitry Andric  let Inst{16}    = 0b0;
2061bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
20625f757f3fSDimitry Andric  let Inst{5}     = op{2};  // fp8
2063bdd1243dSDimitry Andric  let Inst{2}     = 0b0;
2064bdd1243dSDimitry Andric  let Inst{1-0}   = imm;
2065bdd1243dSDimitry Andric}
2066bdd1243dSDimitry Andric
20675f757f3fSDimitry Andricmulticlass sme2_fp_mla_long_array_vg2_multi<string mnemonic, bits<3> op, MatrixOperand matrix_ty,
20685f757f3fSDimitry Andric                                            RegisterOperand multi_vector_ty,
20695f757f3fSDimitry Andric                                            ValueType zpr_ty, SDPatternOperator intrinsic> {
2070bdd1243dSDimitry Andric
20715f757f3fSDimitry Andric  def NAME : sme2_mla_long_array_vg2_multi<mnemonic, 0b10, op, matrix_ty, multi_vector_ty>,
20725f757f3fSDimitry Andric                                           SMEPseudo2Instr<NAME, 1>;
2073bdd1243dSDimitry Andric
20745f757f3fSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_multi_pseudo<NAME, uimm2s2range, multi_vector_ty, SMEMatrixArray>;
20755f757f3fSDimitry Andric
20765f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Multi_Pat<NAME, intrinsic, uimm2s2range, zpr_ty, tileslicerange2s2>;
2077bdd1243dSDimitry Andric
2078bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm",
20795f757f3fSDimitry Andric                  (!cast<Instruction>(NAME) matrix_ty:$ZAda,  MatrixIndexGPR32Op8_11:$Rv,
20805f757f3fSDimitry Andric                  uimm2s2range:$imm, multi_vector_ty:$Zn, multi_vector_ty:$Zm), 0>;
2081bdd1243dSDimitry Andric}
2082bdd1243dSDimitry Andric
2083bdd1243dSDimitry Andricmulticlass sme2_int_mla_long_array_vg2_multi<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
20845f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array_vg2_multi<mnemonic, 0b11, {0b0, op}, MatrixOp32, ZZ_h_mul_r>,
20855f757f3fSDimitry Andric                                         SMEPseudo2Instr<NAME # _HtoS, 1>;
2086bdd1243dSDimitry Andric
20875f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_multi_pseudo<NAME # _HtoS, uimm2s2range, ZZ_h_mul_r, SMEMatrixArray>;
2088bdd1243dSDimitry Andric
20895f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Multi_Pat<NAME # _HtoS, intrinsic, uimm2s2range, nxv8i16, tileslicerange2s2>;
2090bdd1243dSDimitry Andric
2091bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm2], $Zn, $Zm",
20925f757f3fSDimitry Andric                 (!cast<Instruction>(NAME #_HtoS) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm2, ZZ_h_mul_r:$Zn, ZZ_h_mul_r:$Zm), 0>;
2093bdd1243dSDimitry Andric}
2094bdd1243dSDimitry Andric
20955f757f3fSDimitry Andricclass sme2_mla_long_array_vg4_multi<string mnemonic, bits<2> op0, bits<3> op,
20965f757f3fSDimitry Andric                                    MatrixOperand matrix_ty,
20975f757f3fSDimitry Andric                                    RegisterOperand multi_vector_ty>
20985f757f3fSDimitry Andric   : sme2_mla_long_array<op0, op{1-0}, matrix_ty, uimm2s2range, multi_vector_ty, multi_vector_ty,
20995f757f3fSDimitry Andric                         mnemonic, "vgx4"> {
2100bdd1243dSDimitry Andric  bits<3> Zm;
2101bdd1243dSDimitry Andric  bits<3> Zn;
2102bdd1243dSDimitry Andric  bits<2> imm;
2103bdd1243dSDimitry Andric  let Inst{20-18} = Zm;
2104bdd1243dSDimitry Andric  let Inst{17}    = 0b0;
2105bdd1243dSDimitry Andric  let Inst{16}    = 0b1;
2106bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
21075f757f3fSDimitry Andric  let Inst{6}     = 0b0;
21085f757f3fSDimitry Andric  let Inst{5}     = op{2};  //fp8
2109bdd1243dSDimitry Andric  let Inst{2}     = 0b0;
2110bdd1243dSDimitry Andric  let Inst{1-0}   = imm;
2111bdd1243dSDimitry Andric}
2112bdd1243dSDimitry Andric
21135f757f3fSDimitry Andricmulticlass sme2_fp_mla_long_array_vg4_multi<string mnemonic, bits<3> op, MatrixOperand matrix_ty,
21145f757f3fSDimitry Andric                                            RegisterOperand multi_vector_ty, ValueType zpr_ty,
21155f757f3fSDimitry Andric                                            SDPatternOperator intrinsic> {
21165f757f3fSDimitry Andric  def NAME : sme2_mla_long_array_vg4_multi<mnemonic, 0b10, op, matrix_ty, multi_vector_ty>,
21175f757f3fSDimitry Andric                                           SMEPseudo2Instr<NAME, 1>;
2118bdd1243dSDimitry Andric
21195f757f3fSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_multi_pseudo<NAME, uimm2s2range, multi_vector_ty, SMEMatrixArray>;
2120bdd1243dSDimitry Andric
21215f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Multi_Pat<NAME, intrinsic, uimm2s2range, zpr_ty, tileslicerange2s2>;
2122bdd1243dSDimitry Andric
2123bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm",
21245f757f3fSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAda,  MatrixIndexGPR32Op8_11:$Rv,
21255f757f3fSDimitry Andric                  uimm2s2range:$imm, multi_vector_ty:$Zn, multi_vector_ty:$Zm), 0>;
2126bdd1243dSDimitry Andric}
2127bdd1243dSDimitry Andric
2128bdd1243dSDimitry Andricmulticlass sme2_int_mla_long_array_vg4_multi<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
21295f757f3fSDimitry Andric  def _HtoS : sme2_mla_long_array_vg4_multi<mnemonic, 0b11, {0b0, op}, MatrixOp32, ZZZZ_h_mul_r>,
21305f757f3fSDimitry Andric                                            SMEPseudo2Instr<NAME # _HtoS, 1>;
2131bdd1243dSDimitry Andric
21325f757f3fSDimitry Andric  def _HtoS_PSEUDO : sme2_za_array_2op_multi_multi_pseudo<NAME # _HtoS, uimm2s2range, ZZZZ_h_mul_r, SMEMatrixArray>;
2133bdd1243dSDimitry Andric
21345f757f3fSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Multi_Pat<NAME # _HtoS, intrinsic, uimm2s2range, nxv8i16, tileslicerange2s2>;
2135bdd1243dSDimitry Andric
2136bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm2], $Zn, $Zm",
21375f757f3fSDimitry Andric                 (!cast<Instruction>(NAME #_HtoS) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm2, ZZZZ_h_mul_r:$Zn, ZZZZ_h_mul_r:$Zm), 0>;
2138bdd1243dSDimitry Andric}
2139bdd1243dSDimitry Andric
2140bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
2141bdd1243dSDimitry Andricclass sme2_frint_cvt_vg2_multi<bits<2>sz, bits<5>op, RegisterOperand first_ty,
2142bdd1243dSDimitry Andric                               RegisterOperand second_ty, string mnemonic>
2143bdd1243dSDimitry Andric    : I<(outs first_ty:$Zd), (ins second_ty:$Zn),
2144bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn", "", []>, Sched<[]> {
2145bdd1243dSDimitry Andric  bits<4> Zn;
2146bdd1243dSDimitry Andric  bits<4> Zd;
2147bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
2148bdd1243dSDimitry Andric  let Inst{23-22} = sz;
2149bdd1243dSDimitry Andric  let Inst{21-20} = 0b10;
2150bdd1243dSDimitry Andric  let Inst{19-16} = op{4-1};
2151bdd1243dSDimitry Andric  let Inst{15-10} = 0b111000;
2152bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
2153bdd1243dSDimitry Andric  let Inst{5}     = op{0};
2154bdd1243dSDimitry Andric  let Inst{4-1}   = Zd;
2155bdd1243dSDimitry Andric  let Inst{0}     = 0b0;
2156bdd1243dSDimitry Andric}
2157bdd1243dSDimitry Andric
2158bdd1243dSDimitry Andric// SME2 multi-vec FP to int convert two registers
2159bdd1243dSDimitry Andric// SME2 multi-vec int to FP two registers
2160bdd1243dSDimitry Andricmulticlass sme2_fp_cvt_vg2_multi<string mnemonic, bits<5> op> {
2161bdd1243dSDimitry Andric  def NAME : sme2_frint_cvt_vg2_multi<0b00, op, ZZ_s_mul_r, ZZ_s_mul_r, mnemonic>;
2162bdd1243dSDimitry Andric}
2163bdd1243dSDimitry Andric
2164bdd1243dSDimitry Andric// SME2 multi-vec FRINT two registers
2165bdd1243dSDimitry Andricmulticlass sme2_frint_vector_vg2_multi<string mnemonic, bits<5> op> {
2166bdd1243dSDimitry Andric  def _S : sme2_frint_cvt_vg2_multi<0b10, op, ZZ_s_mul_r, ZZ_s_mul_r, mnemonic>;
2167bdd1243dSDimitry Andric}
2168bdd1243dSDimitry Andric
2169bdd1243dSDimitry Andricclass sme2_frint_zip_cvt_vg4_multi<bits<2>sz, bits<7>op, RegisterOperand first_ty,
2170bdd1243dSDimitry Andric                                   RegisterOperand second_ty, string mnemonic>
2171bdd1243dSDimitry Andric    : I<(outs first_ty:$Zd), (ins second_ty:$Zn),
2172bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn", "", []>, Sched<[]> {
2173bdd1243dSDimitry Andric  bits<3> Zn;
2174bdd1243dSDimitry Andric  bits<3> Zd;
2175bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
2176bdd1243dSDimitry Andric  let Inst{23-22} = sz;
2177bdd1243dSDimitry Andric  let Inst{21-20} = 0b11;
2178bdd1243dSDimitry Andric  let Inst{19-16} = op{6-3};
2179bdd1243dSDimitry Andric  let Inst{15-10} = 0b111000;
2180bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
2181bdd1243dSDimitry Andric  let Inst{6-5}   = op{2-1};
2182bdd1243dSDimitry Andric  let Inst{4-2}   = Zd;
2183bdd1243dSDimitry Andric  let Inst{1}     = op{0};
2184bdd1243dSDimitry Andric  let Inst{0}     = 0b0;
2185bdd1243dSDimitry Andric}
2186bdd1243dSDimitry Andric
2187bdd1243dSDimitry Andric// SME2 multi-vec FP to int convert four registers
2188bdd1243dSDimitry Andric// SME2 multi-vec int to FP four registers
2189bdd1243dSDimitry Andricmulticlass sme2_fp_cvt_vg4_multi<string mnemonic, bits<7> op> {
2190bdd1243dSDimitry Andric  def NAME : sme2_frint_zip_cvt_vg4_multi<0b00, op, ZZZZ_s_mul_r, ZZZZ_s_mul_r, mnemonic>;
2191bdd1243dSDimitry Andric}
2192bdd1243dSDimitry Andric
2193bdd1243dSDimitry Andric// SME2 multi-vec quadwords ZIP four registers
2194bdd1243dSDimitry Andricmulticlass sme2_zip_vector_vg4<string mnemonic, bits<7> op> {
2195bdd1243dSDimitry Andric  def _B : sme2_frint_zip_cvt_vg4_multi<0b00, op, ZZZZ_b_mul_r, ZZZZ_b_mul_r,
2196bdd1243dSDimitry Andric                                        mnemonic>;
2197bdd1243dSDimitry Andric  def _H : sme2_frint_zip_cvt_vg4_multi<0b01, op, ZZZZ_h_mul_r, ZZZZ_h_mul_r,
2198bdd1243dSDimitry Andric                                        mnemonic>;
2199bdd1243dSDimitry Andric  def _S : sme2_frint_zip_cvt_vg4_multi<0b10, op, ZZZZ_s_mul_r, ZZZZ_s_mul_r,
2200bdd1243dSDimitry Andric                                        mnemonic>;
2201bdd1243dSDimitry Andric  def _D : sme2_frint_zip_cvt_vg4_multi<0b11, op, ZZZZ_d_mul_r, ZZZZ_d_mul_r,
2202bdd1243dSDimitry Andric                                         mnemonic>;
2203bdd1243dSDimitry Andric}
2204bdd1243dSDimitry Andric
2205bdd1243dSDimitry Andric// SME2 multi-vec quadwords ZIP four registers
2206bdd1243dSDimitry Andricmulticlass sme2_zip_vector_vg4_Q<string mnemonic, bits<7> op> {
2207bdd1243dSDimitry Andric  def NAME: sme2_frint_zip_cvt_vg4_multi<0b00, op, ZZZZ_q_mul_r, ZZZZ_q_mul_r,
2208bdd1243dSDimitry Andric                                         mnemonic>;
2209bdd1243dSDimitry Andric}
2210bdd1243dSDimitry Andric
2211bdd1243dSDimitry Andric// SME2 multi-vec FRINT four registers
2212bdd1243dSDimitry Andricmulticlass sme2_frint_vector_vg4_multi<string mnemonic, bits<7> op> {
2213bdd1243dSDimitry Andric  def _S :  sme2_frint_zip_cvt_vg4_multi<0b10, op, ZZZZ_s_mul_r, ZZZZ_s_mul_r,
2214bdd1243dSDimitry Andric                                         mnemonic>;
2215bdd1243dSDimitry Andric}
2216bdd1243dSDimitry Andric
22175f757f3fSDimitry Andricclass sme2_cvt_vg2_single<string mnemonic, bits<5> op,
22185f757f3fSDimitry Andric                           RegisterOperand first_ty, RegisterOperand second_ty>
22195f757f3fSDimitry Andric    : I<(outs first_ty:$Zd), (ins second_ty:$Zn),
2220bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn", "", []>, Sched<[]> {
2221bdd1243dSDimitry Andric  bits<4> Zn;
2222bdd1243dSDimitry Andric  bits<5> Zd;
2223bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000010;
22245f757f3fSDimitry Andric  let Inst{22}    = op{4};
22255f757f3fSDimitry Andric  let Inst{21-19} = 0b100;
22265f757f3fSDimitry Andric  let Inst{18-16} = op{3-1};
2227bdd1243dSDimitry Andric  let Inst{15-10} = 0b111000;
2228bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
2229bdd1243dSDimitry Andric  let Inst{5}     = op{0};
2230bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
2231bdd1243dSDimitry Andric}
2232bdd1243dSDimitry Andric
2233bdd1243dSDimitry Andric// SME2 multi-vec FP down convert two registers
2234bdd1243dSDimitry Andric// SME2 multi-vec int down convert two registers
22355f757f3fSDimitry Andricmulticlass sme2_cvt_vg2_single<string mnemonic, bits<5> op, ValueType out_vt,
2236bdd1243dSDimitry Andric                               ValueType in_vt, SDPatternOperator intrinsic> {
22375f757f3fSDimitry Andric  def NAME :  sme2_cvt_vg2_single<mnemonic, op, ZPR16, ZZ_s_mul_r>;
2238bdd1243dSDimitry Andric  def : SVE2p1_Cvt_VG2_Pat<NAME, intrinsic, out_vt, in_vt>;
2239bdd1243dSDimitry Andric}
2240bdd1243dSDimitry Andric
22415f757f3fSDimitry Andric// SME2 multi-vec FP8 down convert two registers
22425f757f3fSDimitry Andricmulticlass sme2_fp8_cvt_vg2_single<string mnemonic, bit op> {
22435f757f3fSDimitry Andric  def NAME :  sme2_cvt_vg2_single<mnemonic, {op, 0b1000}, ZPR8, ZZ_h_mul_r>;
22445f757f3fSDimitry Andric}
22455f757f3fSDimitry Andric
2246bdd1243dSDimitry Andricclass sme2_cvt_unpk_vector_vg2<bits<2>sz, bits<3> op, bit u, RegisterOperand first_ty,
2247bdd1243dSDimitry Andric                           RegisterOperand second_ty, string mnemonic>
2248bdd1243dSDimitry Andric    : I<(outs first_ty:$Zd), (ins second_ty:$Zn),
2249bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn", "", []>, Sched<[]> {
2250bdd1243dSDimitry Andric  bits<5> Zn;
2251bdd1243dSDimitry Andric  bits<4> Zd;
2252bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
2253bdd1243dSDimitry Andric  let Inst{23-22} = sz;
2254bdd1243dSDimitry Andric  let Inst{21-19} = 0b100;
2255bdd1243dSDimitry Andric  let Inst{18-16} = op;
2256bdd1243dSDimitry Andric  let Inst{15-10} = 0b111000;
2257bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
2258bdd1243dSDimitry Andric  let Inst{4-1}   = Zd;
2259bdd1243dSDimitry Andric  let Inst{0}     = u;
2260bdd1243dSDimitry Andric}
2261bdd1243dSDimitry Andric
2262bdd1243dSDimitry Andric// SME2 multi-vec unpack two registers
2263bdd1243dSDimitry Andricmulticlass sme2_unpk_vector_vg2<string mnemonic, bit u> {
2264bdd1243dSDimitry Andric  def _H : sme2_cvt_unpk_vector_vg2<0b01, 0b101, u, ZZ_h_mul_r, ZPR8, mnemonic>;
2265bdd1243dSDimitry Andric  def _S : sme2_cvt_unpk_vector_vg2<0b10, 0b101, u, ZZ_s_mul_r, ZPR16, mnemonic>;
2266bdd1243dSDimitry Andric  def _D : sme2_cvt_unpk_vector_vg2<0b11, 0b101, u, ZZ_d_mul_r, ZPR32, mnemonic>;
2267bdd1243dSDimitry Andric}
2268bdd1243dSDimitry Andric
2269bdd1243dSDimitry Andric// SME2.1 multi-vec convert two registers
2270bdd1243dSDimitry Andricmulticlass sme2p1_fp_cvt_vector_vg2_single<string mnemonic, bit l> {
2271bdd1243dSDimitry Andric  def _S : sme2_cvt_unpk_vector_vg2<0b10, 0b000, l, ZZ_s_mul_r, ZPR16, mnemonic>;
2272bdd1243dSDimitry Andric}
2273bdd1243dSDimitry Andric
22745f757f3fSDimitry Andric// SME2 multi-vec FP8 up convert two registers
22755f757f3fSDimitry Andricmulticlass sme2p1_fp8_cvt_vector_vg2_single<string mnemonic, bits<2> opc, bit L> {
22765f757f3fSDimitry Andric  def _NAME : sme2_cvt_unpk_vector_vg2<opc, 0b110, L, ZZ_h_mul_r, ZPR8, mnemonic>;
22775f757f3fSDimitry Andric}
22785f757f3fSDimitry Andric
22795f757f3fSDimitry Andric
22805f757f3fSDimitry Andricclass sme2_cvt_vg4_single<bit sz, bits<3> op, bits<4>op2,  RegisterOperand first_ty,
2281bdd1243dSDimitry Andric                          RegisterOperand second_ty, string mnemonic>
2282bdd1243dSDimitry Andric    : I<(outs first_ty:$Zd), (ins second_ty:$Zn),
2283bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn", "", []>, Sched<[]> {
2284bdd1243dSDimitry Andric  bits<3> Zn;
2285bdd1243dSDimitry Andric  bits<5> Zd;
2286bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
2287bdd1243dSDimitry Andric  let Inst{23}    = sz;
2288bdd1243dSDimitry Andric  let Inst{22}    = op{2};
22895f757f3fSDimitry Andric  let Inst{21-20} = 0b11;
22905f757f3fSDimitry Andric  let Inst{19-16} = op2;
22915f757f3fSDimitry Andric  let Inst{15-10} = 0b111000;
2292bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
2293bdd1243dSDimitry Andric  let Inst{6-5}   = op{1-0};
2294bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
2295bdd1243dSDimitry Andric}
2296bdd1243dSDimitry Andric
2297bdd1243dSDimitry Andric// SME2 multi-vec int down convert four registers
2298bdd1243dSDimitry Andricmulticlass sme2_int_cvt_vg4_single<string mnemonic, bits<3> op, SDPatternOperator intrinsic> {
22995f757f3fSDimitry Andric  def _StoB : sme2_cvt_vg4_single<0, op, 0b0011, ZPR8, ZZZZ_s_mul_r, mnemonic>;
23005f757f3fSDimitry Andric  def _DtoH : sme2_cvt_vg4_single<1, op, 0b0011, ZPR16, ZZZZ_d_mul_r, mnemonic>;
2301bdd1243dSDimitry Andric
2302bdd1243dSDimitry Andric  def : SME2_Cvt_VG4_Pat<NAME # _StoB, intrinsic, nxv16i8, nxv4i32>;
2303bdd1243dSDimitry Andric  def : SME2_Cvt_VG4_Pat<NAME # _DtoH, intrinsic, nxv8i16, nxv2i64>;
2304bdd1243dSDimitry Andric}
2305bdd1243dSDimitry Andric
23065f757f3fSDimitry Andric//SME2 multi-vec FP8 down convert four registers
23075f757f3fSDimitry Andricmulticlass sme2_fp8_cvt_vg4_single<string mnemonic, bit N> {
23085f757f3fSDimitry Andric def _NAME : sme2_cvt_vg4_single<0b0, {0b00, N}, 0b0100, ZPR8, ZZZZ_s_mul_r, mnemonic>;
23095f757f3fSDimitry Andric}
23105f757f3fSDimitry Andric
2311bdd1243dSDimitry Andricclass sme2_unpk_vector_vg4<bits<2>sz, bit u, RegisterOperand first_ty,
2312bdd1243dSDimitry Andric                           RegisterOperand second_ty, string mnemonic>
2313bdd1243dSDimitry Andric    : I<(outs first_ty:$Zd), (ins second_ty:$Zn),
2314bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn", "", []>, Sched<[]> {
2315bdd1243dSDimitry Andric  bits<4> Zn;
2316bdd1243dSDimitry Andric  bits<3> Zd;
2317bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
2318bdd1243dSDimitry Andric  let Inst{23-22} = sz;
2319bdd1243dSDimitry Andric  let Inst{21-10} = 0b110101111000;
2320bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
2321bdd1243dSDimitry Andric  let Inst{5}     = 0b0;
2322bdd1243dSDimitry Andric  let Inst{4-2}   = Zd;
2323bdd1243dSDimitry Andric  let Inst{1}     = 0b0;
2324bdd1243dSDimitry Andric  let Inst{0}     = u;
2325bdd1243dSDimitry Andric}
2326bdd1243dSDimitry Andric
2327bdd1243dSDimitry Andric// SME2 multi-vec UNPK four registers
2328bdd1243dSDimitry Andricmulticlass sme2_unpk_vector_vg4<string mnemonic, bit u> {
2329bdd1243dSDimitry Andric  def _H : sme2_unpk_vector_vg4<0b01, u, ZZZZ_h_mul_r, ZZ_b_mul_r, mnemonic>;
2330bdd1243dSDimitry Andric  def _S : sme2_unpk_vector_vg4<0b10, u, ZZZZ_s_mul_r, ZZ_h_mul_r, mnemonic>;
2331bdd1243dSDimitry Andric  def _D : sme2_unpk_vector_vg4<0b11, u, ZZZZ_d_mul_r, ZZ_s_mul_r, mnemonic>;
2332bdd1243dSDimitry Andric}
2333bdd1243dSDimitry Andric
2334bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
2335bdd1243dSDimitry Andric// SME2 multi-vec CLAMP registers
2336bdd1243dSDimitry Andric
2337bdd1243dSDimitry Andricclass sme2_clamp_vector_vg24_multi<bits<2> sz, bits<3> op1, bit u,
2338bdd1243dSDimitry Andric                                   RegisterOperand multi_vector_ty,
2339bdd1243dSDimitry Andric                                   ZPRRegOp vector_ty, string mnemonic>
2340bdd1243dSDimitry Andric    : I<(outs multi_vector_ty:$Zd),
2341bdd1243dSDimitry Andric        (ins  multi_vector_ty:$_Zd, vector_ty:$Zn, vector_ty:$Zm),
2342bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn, $Zm",
2343bdd1243dSDimitry Andric        "", []>, Sched<[]>{
2344bdd1243dSDimitry Andric  bits<5> Zm;
2345bdd1243dSDimitry Andric  bits<5> Zn;
2346bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
2347bdd1243dSDimitry Andric  let Inst{23-22} = sz;
2348bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
2349bdd1243dSDimitry Andric  let Inst{20-16} = Zm;
2350bdd1243dSDimitry Andric  let Inst{15-13} = 0b110;
2351bdd1243dSDimitry Andric  let Inst{12-10} = op1;
2352bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
2353bdd1243dSDimitry Andric  let Inst{0}     = u;
2354bdd1243dSDimitry Andric
2355bdd1243dSDimitry Andric  let Constraints = "$Zd = $_Zd";
2356bdd1243dSDimitry Andric}
2357bdd1243dSDimitry Andric
2358bdd1243dSDimitry Andricclass sme2_clamp_vector_vg2_multi<bits<2> sz, bits<3> op1, bit u,
2359bdd1243dSDimitry Andric                                  RegisterOperand multi_vector_ty,
2360bdd1243dSDimitry Andric                                  ZPRRegOp vector_ty, string mnemonic>
2361bdd1243dSDimitry Andric    : sme2_clamp_vector_vg24_multi<sz, op1, u, multi_vector_ty, vector_ty,
2362bdd1243dSDimitry Andric                                   mnemonic>{
2363bdd1243dSDimitry Andric  bits<4> Zd;
2364bdd1243dSDimitry Andric  let Inst{4-1} = Zd;
2365bdd1243dSDimitry Andric}
2366bdd1243dSDimitry Andric
2367bdd1243dSDimitry Andricmulticlass sme2_fp_clamp_vector_vg2_multi<string mnemonic>{
2368bdd1243dSDimitry Andric  def _H : sme2_clamp_vector_vg2_multi<0b01, 0b000, 0b0, ZZ_h_mul_r, ZPR16, mnemonic>;
2369bdd1243dSDimitry Andric  def _S : sme2_clamp_vector_vg2_multi<0b10, 0b000, 0b0, ZZ_s_mul_r, ZPR32, mnemonic>;
2370bdd1243dSDimitry Andric  def _D : sme2_clamp_vector_vg2_multi<0b11, 0b000, 0b0, ZZ_d_mul_r, ZPR64, mnemonic>;
2371bdd1243dSDimitry Andric}
2372bdd1243dSDimitry Andric
2373bdd1243dSDimitry Andricmulticlass sme2_int_clamp_vector_vg2_multi<string mnemonic, bit u>{
2374bdd1243dSDimitry Andric  def _B : sme2_clamp_vector_vg2_multi<0b00, 0b001, u, ZZ_b_mul_r, ZPR8, mnemonic>;
2375bdd1243dSDimitry Andric  def _H : sme2_clamp_vector_vg2_multi<0b01, 0b001, u, ZZ_h_mul_r, ZPR16, mnemonic>;
2376bdd1243dSDimitry Andric  def _S : sme2_clamp_vector_vg2_multi<0b10, 0b001, u, ZZ_s_mul_r, ZPR32, mnemonic>;
2377bdd1243dSDimitry Andric  def _D : sme2_clamp_vector_vg2_multi<0b11, 0b001, u, ZZ_d_mul_r, ZPR64, mnemonic>;
2378bdd1243dSDimitry Andric}
2379bdd1243dSDimitry Andric
2380bdd1243dSDimitry Andric// SME2.1 multi-vec FCLAMP two registers
2381bdd1243dSDimitry Andricmulticlass sme2p1_bfclamp_vector_vg2_multi<string mnemonic> {
2382bdd1243dSDimitry Andric  def _H : sme2_clamp_vector_vg2_multi<0b00, 0b000, 0b0, ZZ_h_mul_r, ZPR16,
2383bdd1243dSDimitry Andric                                           mnemonic>;
2384bdd1243dSDimitry Andric}
2385bdd1243dSDimitry Andric
2386bdd1243dSDimitry Andricclass sme2_clamp_vector_vg4_multi<bits<2> sz, bits<3> op1, bit u,
2387bdd1243dSDimitry Andric                                  RegisterOperand multi_vector_ty,
2388bdd1243dSDimitry Andric                                  ZPRRegOp vector_ty, string mnemonic>
2389bdd1243dSDimitry Andric    : sme2_clamp_vector_vg24_multi<sz, op1, u,  multi_vector_ty, vector_ty,
2390bdd1243dSDimitry Andric                                   mnemonic>{
2391bdd1243dSDimitry Andric  bits<3> Zd;
2392bdd1243dSDimitry Andric  let Inst{4-2} = Zd;
2393bdd1243dSDimitry Andric  let Inst{1}   = 0b0;
2394bdd1243dSDimitry Andric}
2395bdd1243dSDimitry Andric
2396bdd1243dSDimitry Andricmulticlass sme2_fp_clamp_vector_vg4_multi<string mnemonic>{
2397bdd1243dSDimitry Andric  def _H : sme2_clamp_vector_vg4_multi<0b01, 0b010, 0b0, ZZZZ_h_mul_r, ZPR16, mnemonic>;
2398bdd1243dSDimitry Andric  def _S : sme2_clamp_vector_vg4_multi<0b10, 0b010, 0b0, ZZZZ_s_mul_r, ZPR32, mnemonic>;
2399bdd1243dSDimitry Andric  def _D : sme2_clamp_vector_vg4_multi<0b11, 0b010, 0b0, ZZZZ_d_mul_r, ZPR64, mnemonic>;
2400bdd1243dSDimitry Andric}
2401bdd1243dSDimitry Andric
2402bdd1243dSDimitry Andricmulticlass sme2_int_clamp_vector_vg4_multi<string mnemonic, bit u>{
2403bdd1243dSDimitry Andric  def _B : sme2_clamp_vector_vg4_multi<0b00, 0b011, u, ZZZZ_b_mul_r, ZPR8, mnemonic>;
2404bdd1243dSDimitry Andric  def _H : sme2_clamp_vector_vg4_multi<0b01, 0b011, u, ZZZZ_h_mul_r, ZPR16, mnemonic>;
2405bdd1243dSDimitry Andric  def _S : sme2_clamp_vector_vg4_multi<0b10, 0b011, u, ZZZZ_s_mul_r, ZPR32, mnemonic>;
2406bdd1243dSDimitry Andric  def _D : sme2_clamp_vector_vg4_multi<0b11, 0b011, u, ZZZZ_d_mul_r, ZPR64, mnemonic>;
2407bdd1243dSDimitry Andric}
2408bdd1243dSDimitry Andric
2409bdd1243dSDimitry Andric// SME2.1 multi-vec FCLAMP four registers
2410bdd1243dSDimitry Andricmulticlass sme2p1_bfclamp_vector_vg4_multi<string mnemonic> {
2411bdd1243dSDimitry Andric  def _H : sme2_clamp_vector_vg4_multi<0b00, 0b010, 0b0, ZZZZ_h_mul_r, ZPR16,
2412bdd1243dSDimitry Andric                                       mnemonic>;
2413bdd1243dSDimitry Andric}
2414bdd1243dSDimitry Andric
2415bdd1243dSDimitry Andric// SME2 multi-vec ZIP two registers
2416bdd1243dSDimitry Andricclass sme2_zip_vector_vg2<bits<2> sz, bit q, bit u,
2417bdd1243dSDimitry Andric                         RegisterOperand multi_vector_ty,
2418bdd1243dSDimitry Andric                         ZPRRegOp vector_ty, string mnemonic>
2419bdd1243dSDimitry Andric    : I<(outs multi_vector_ty:$Zd), (ins vector_ty:$Zn, vector_ty:$Zm),
2420bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn, $Zm",
2421bdd1243dSDimitry Andric        "", []>, Sched<[]>{
2422bdd1243dSDimitry Andric  bits<4> Zd;
2423bdd1243dSDimitry Andric  bits<5> Zm;
2424bdd1243dSDimitry Andric  bits<5> Zn;
2425bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
2426bdd1243dSDimitry Andric  let Inst{23-22} = sz;
2427bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
2428bdd1243dSDimitry Andric  let Inst{20-16} = Zm;
2429bdd1243dSDimitry Andric  let Inst{15-11} = 0b11010;
2430bdd1243dSDimitry Andric  let Inst{10}    = q;
2431bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
2432bdd1243dSDimitry Andric  let Inst{4-1}   = Zd;
2433bdd1243dSDimitry Andric  let Inst{0}     = u;
2434bdd1243dSDimitry Andric}
2435bdd1243dSDimitry Andric
2436bdd1243dSDimitry Andricmulticlass sme2_zip_vector_vg2<string mnemonic, bit op> {
2437bdd1243dSDimitry Andric  def _B : sme2_zip_vector_vg2<0b00, 0b0, op, ZZ_b_mul_r, ZPR8, mnemonic>;
2438bdd1243dSDimitry Andric  def _H : sme2_zip_vector_vg2<0b01, 0b0, op, ZZ_h_mul_r, ZPR16, mnemonic>;
2439bdd1243dSDimitry Andric  def _S : sme2_zip_vector_vg2<0b10, 0b0, op, ZZ_s_mul_r, ZPR32, mnemonic>;
2440bdd1243dSDimitry Andric  def _D : sme2_zip_vector_vg2<0b11, 0b0, op, ZZ_d_mul_r, ZPR64, mnemonic>;
2441bdd1243dSDimitry Andric  def _Q : sme2_zip_vector_vg2<0b00, 0b1, op, ZZ_q_mul_r, ZPR128, mnemonic>;
2442bdd1243dSDimitry Andric}
2443bdd1243dSDimitry Andric
2444bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
2445bdd1243dSDimitry Andric// SME2 Dot Products and MLA
24465f757f3fSDimitry Andricclass sme2_multi_vec_array_vg2_index<bits<2> sz, bits<6> op, MatrixOperand matrix_ty,
2447bdd1243dSDimitry Andric                                     RegisterOperand multi_vector_ty,
2448bdd1243dSDimitry Andric                                     ZPRRegOp vector_ty, Operand index_ty,
2449bdd1243dSDimitry Andric                                     string mnemonic>
2450bdd1243dSDimitry Andric    : I<(outs matrix_ty:$ZAda),
2451bdd1243dSDimitry Andric        (ins matrix_ty:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2452bdd1243dSDimitry Andric         multi_vector_ty:$Zn, vector_ty:$Zm, index_ty:$i),
2453bdd1243dSDimitry Andric         mnemonic, "\t$ZAda[$Rv, $imm3, vgx2], $Zn, $Zm$i",
2454bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2455bdd1243dSDimitry Andric  bits<4> Zm;
2456bdd1243dSDimitry Andric  bits<2> Rv;
2457bdd1243dSDimitry Andric  bits<4> Zn;
2458bdd1243dSDimitry Andric  bits<3> imm3;
24595f757f3fSDimitry Andric  let Inst{31-24} = 0b11000001;
24605f757f3fSDimitry Andric  let Inst{23-22} = sz;
2461bdd1243dSDimitry Andric  let Inst{21-20} = 0b01;
2462bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
2463bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
2464bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
2465bdd1243dSDimitry Andric  let Inst{12-10} = op{5-3};
2466bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
2467bdd1243dSDimitry Andric  let Inst{5-3}   = op{2-0};
2468bdd1243dSDimitry Andric  let Inst{2-0}   = imm3;
2469bdd1243dSDimitry Andric
2470bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
2471bdd1243dSDimitry Andric}
2472bdd1243dSDimitry Andric
2473bdd1243dSDimitry Andric// SME2 multi-vec ternary indexed two registers 32-bit
24745f757f3fSDimitry Andricmulticlass sme2_multi_vec_array_vg2_index_32b<string mnemonic, bits<2> sz, bits<4> op,
2475bdd1243dSDimitry Andric                                              RegisterOperand multi_vector_ty,
2476bdd1243dSDimitry Andric                                              ZPRRegOp vector_ty, ValueType vt,
2477bdd1243dSDimitry Andric                                              SDPatternOperator intrinsic> {
24785f757f3fSDimitry Andric  def NAME : sme2_multi_vec_array_vg2_index<sz, {op{3},?,?,op{2-0}}, MatrixOp32, multi_vector_ty, vector_ty,
2479bdd1243dSDimitry Andric                                             VectorIndexS32b_timm,  mnemonic>, SMEPseudo2Instr<NAME, 1> {
2480bdd1243dSDimitry Andric    bits<2> i;
2481bdd1243dSDimitry Andric    let Inst{11-10} = i;
2482bdd1243dSDimitry Andric  }
2483bdd1243dSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, vector_ty, VectorIndexS32b_timm, SMEMatrixArray>;
2484bdd1243dSDimitry Andric
2485bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Index_Pat<NAME, intrinsic, sme_elm_idx0_7, vector_ty, vt, VectorIndexS32b_timm, tileslice16>;
2486bdd1243dSDimitry Andric
2487bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i",
2488bdd1243dSDimitry Andric        (!cast<Instruction>(NAME) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2489bdd1243dSDimitry Andric        multi_vector_ty:$Zn, vector_ty:$Zm, VectorIndexS32b_timm:$i), 0>;
2490bdd1243dSDimitry Andric}
2491bdd1243dSDimitry Andric
2492bdd1243dSDimitry Andric// SME2.1 multi-vec ternary indexed two registers 16-bit
24935f757f3fSDimitry Andricmulticlass sme2p1_multi_vec_array_vg2_index_16b<string mnemonic, bits<2> sz, bits<3> op,
2494*0fca6ea1SDimitry Andric                                                RegisterOperand multi_vector_ty, ZPRRegOp vector_ty,
2495*0fca6ea1SDimitry Andric                                                ValueType vt, SDPatternOperator intrinsic> {
2496*0fca6ea1SDimitry Andric  def NAME : sme2_multi_vec_array_vg2_index<sz, {op{2},?,?,op{1-0},?}, MatrixOp16,
2497*0fca6ea1SDimitry Andric                                            multi_vector_ty, vector_ty,
2498*0fca6ea1SDimitry Andric                                            VectorIndexH, mnemonic>, SMEPseudo2Instr<NAME, 1> {
2499*0fca6ea1SDimitry Andric    bits<3> i;
2500*0fca6ea1SDimitry Andric    let Inst{11-10} = i{2-1};
2501*0fca6ea1SDimitry Andric    let Inst{3}     = i{0};
2502*0fca6ea1SDimitry Andric  }
2503*0fca6ea1SDimitry Andric
2504*0fca6ea1SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, vector_ty, VectorIndexH32b, SMEMatrixArray>;
2505*0fca6ea1SDimitry Andric
2506*0fca6ea1SDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Index_Pat<NAME, intrinsic, sme_elm_idx0_7, vector_ty, vt, VectorIndexH32b_timm, tileslice16>;
2507*0fca6ea1SDimitry Andric
2508*0fca6ea1SDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i",
2509*0fca6ea1SDimitry Andric        (!cast<Instruction>(NAME) MatrixOp16:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2510*0fca6ea1SDimitry Andric        multi_vector_ty:$Zn, vector_ty:$Zm, VectorIndexH:$i), 0>;
2511*0fca6ea1SDimitry Andric}
2512*0fca6ea1SDimitry Andric
2513*0fca6ea1SDimitry Andric// SME2 multi-vec indexed FP8 two-way dot product to FP16 two registers
2514*0fca6ea1SDimitry Andricmulticlass sme2p1_multi_vec_array_vg2_index_f8f16<string mnemonic, bits<2> sz, bits<3> op,
25155f757f3fSDimitry Andric                                                  RegisterOperand multi_vector_ty, ZPRRegOp zpr_ty> {
25165f757f3fSDimitry Andric  def NAME : sme2_multi_vec_array_vg2_index<sz, {op{2},?,?,op{1-0},?}, MatrixOp16,
25175f757f3fSDimitry Andric                                            multi_vector_ty, zpr_ty,
2518bdd1243dSDimitry Andric                                            VectorIndexH, mnemonic> {
2519bdd1243dSDimitry Andric    bits<3> i;
2520bdd1243dSDimitry Andric    let Inst{11-10} = i{2-1};
2521bdd1243dSDimitry Andric    let Inst{3}     = i{0};
2522bdd1243dSDimitry Andric  }
25235f757f3fSDimitry Andric
2524bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i",
2525bdd1243dSDimitry Andric        (!cast<Instruction>(NAME) MatrixOp16:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
25265f757f3fSDimitry Andric        multi_vector_ty:$Zn, zpr_ty:$Zm, VectorIndexH:$i), 0>;
25275f757f3fSDimitry Andric}
25285f757f3fSDimitry Andric
25295f757f3fSDimitry Andric// SME2 multi-vec indexed FP8 two-way vertical dot product to single precision
25305f757f3fSDimitry Andric// two registers
25315f757f3fSDimitry Andricclass sme2_fp8_multi_vec_array_vg4_index<string mnemonic, bit T>
25325f757f3fSDimitry Andric   : sme2_multi_vec_array_vg2_index<0b11, {0b01,?,0b0, T,?}, MatrixOp32,
25335f757f3fSDimitry Andric                                    ZZ_b_mul_r, ZPR4b8, VectorIndexS, mnemonic> {
25345f757f3fSDimitry Andric
25355f757f3fSDimitry Andric  bits<2> i;
25365f757f3fSDimitry Andric  let Inst{10} = i{1};
25375f757f3fSDimitry Andric  let Inst{3}  = i{0};
25385f757f3fSDimitry Andric  let AsmString = !strconcat(mnemonic, "{\t$ZAda[$Rv, $imm3, vgx4], $Zn, $Zm$i}");
2539bdd1243dSDimitry Andric}
2540bdd1243dSDimitry Andric
2541bdd1243dSDimitry Andric// SME2 multi-vec ternary indexed two registers 64-bit
2542bdd1243dSDimitry Andric
2543bdd1243dSDimitry Andricclass sme2_multi_vec_array_vg2_index_64b<bits<2> op,
2544bdd1243dSDimitry Andric                                         RegisterOperand multi_vector_ty,
2545bdd1243dSDimitry Andric                                         ZPRRegOp vector_ty,
2546bdd1243dSDimitry Andric                                         string mnemonic>
2547bdd1243dSDimitry Andric    : I<(outs MatrixOp64:$ZAda),
2548bdd1243dSDimitry Andric        (ins MatrixOp64:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2549bdd1243dSDimitry Andric         multi_vector_ty:$Zn, vector_ty:$Zm, VectorIndexD32b_timm:$i1),
2550bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm3, vgx2], $Zn, $Zm$i1",
2551bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2552bdd1243dSDimitry Andric  bits<4> Zm;
2553bdd1243dSDimitry Andric  bits<2> Rv;
2554bdd1243dSDimitry Andric  bits<1> i1;
2555bdd1243dSDimitry Andric  bits<4> Zn;
2556bdd1243dSDimitry Andric  bits<3> imm3;
2557bdd1243dSDimitry Andric  let Inst{31-20} = 0b110000011101;
2558bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
2559bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
2560bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
2561bdd1243dSDimitry Andric  let Inst{12-11} = 0b00;
2562bdd1243dSDimitry Andric  let Inst{10}    = i1;
2563bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
2564bdd1243dSDimitry Andric  let Inst{5}     = 0b0;
2565bdd1243dSDimitry Andric  let Inst{4-3}   = op;
2566bdd1243dSDimitry Andric  let Inst{2-0}   = imm3;
2567bdd1243dSDimitry Andric
2568bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
2569bdd1243dSDimitry Andric}
2570bdd1243dSDimitry Andric
2571bdd1243dSDimitry Andricmulticlass sme2_multi_vec_array_vg2_index_64b<string mnemonic, bits<2> op,
2572bdd1243dSDimitry Andric                                              RegisterOperand multi_vector_ty,
2573bdd1243dSDimitry Andric                                              ZPRRegOp vector_ty, ValueType vt,
2574bdd1243dSDimitry Andric                                              SDPatternOperator intrinsic> {
2575bdd1243dSDimitry Andric  def NAME : sme2_multi_vec_array_vg2_index_64b<op, multi_vector_ty, vector_ty,
2576bdd1243dSDimitry Andric                                                mnemonic>, SMEPseudo2Instr<NAME, 1>;
2577bdd1243dSDimitry Andric
2578bdd1243dSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, vector_ty, VectorIndexD32b_timm, SMEMatrixArray>;
2579bdd1243dSDimitry Andric
2580bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Index_Pat<NAME, intrinsic, sme_elm_idx0_7, vector_ty, vt, VectorIndexD32b_timm, tileslice16>;
2581bdd1243dSDimitry Andric
2582bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i1",
2583bdd1243dSDimitry Andric        (!cast<Instruction>(NAME) MatrixOp64:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2584bdd1243dSDimitry Andric        multi_vector_ty:$Zn, vector_ty:$Zm, VectorIndexD32b_timm:$i1), 0>;
2585bdd1243dSDimitry Andric}
2586bdd1243dSDimitry Andric
25875f757f3fSDimitry Andricclass sme2_multi_vec_array_vg4_index<bit sz, bits<7> op, MatrixOperand matrix_ty,
2588bdd1243dSDimitry Andric                                     RegisterOperand multi_vector_ty,
2589bdd1243dSDimitry Andric                                     ZPRRegOp vector_ty, Operand index_ty,
2590bdd1243dSDimitry Andric                                     string mnemonic>
2591bdd1243dSDimitry Andric    : I<(outs matrix_ty:$ZAda),
2592bdd1243dSDimitry Andric        (ins matrix_ty:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2593bdd1243dSDimitry Andric         multi_vector_ty:$Zn, vector_ty:$Zm, index_ty:$i),
2594bdd1243dSDimitry Andric         mnemonic, "\t$ZAda[$Rv, $imm3, vgx4], $Zn, $Zm$i",
2595bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2596bdd1243dSDimitry Andric  bits<4> Zm;
2597bdd1243dSDimitry Andric  bits<2> Rv;
2598bdd1243dSDimitry Andric  bits<3> Zn;
2599bdd1243dSDimitry Andric  bits<3> imm3;
2600bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000010;
2601bdd1243dSDimitry Andric  let Inst{22}    = sz;
2602bdd1243dSDimitry Andric  let Inst{21-20} = 0b01;
2603bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
2604bdd1243dSDimitry Andric  let Inst{15}    = 0b1;
2605bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
26065f757f3fSDimitry Andric  let Inst{12-10} = op{6-4};
2607bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
26085f757f3fSDimitry Andric  let Inst{6-3}   = op{3-0};
2609bdd1243dSDimitry Andric  let Inst{2-0}   = imm3;
2610bdd1243dSDimitry Andric
2611bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
2612bdd1243dSDimitry Andric}
2613bdd1243dSDimitry Andric
2614bdd1243dSDimitry Andric// SME2 multi-vec ternary indexed four registers 32-bit
2615bdd1243dSDimitry Andricmulticlass sme2_multi_vec_array_vg4_index_32b<string mnemonic, bits<4> op,
2616bdd1243dSDimitry Andric                                              RegisterOperand multi_vector_ty,
2617bdd1243dSDimitry Andric                                              ZPRRegOp vector_ty, ValueType vt,
2618bdd1243dSDimitry Andric                                              SDPatternOperator intrinsic> {
26195f757f3fSDimitry Andric  def NAME : sme2_multi_vec_array_vg4_index<0b1, {op{3},?,?,0b0, op{2-0}}, MatrixOp32,  multi_vector_ty,
2620bdd1243dSDimitry Andric                                            vector_ty, VectorIndexS32b_timm, mnemonic>, SMEPseudo2Instr<NAME, 1> {
2621bdd1243dSDimitry Andric   bits<2> i;
2622bdd1243dSDimitry Andric   let Inst{11-10} = i;
2623bdd1243dSDimitry Andric  }
2624bdd1243dSDimitry Andric
2625bdd1243dSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, vector_ty, VectorIndexS32b_timm, SMEMatrixArray>;
2626bdd1243dSDimitry Andric
2627bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Index_Pat<NAME, intrinsic, sme_elm_idx0_7, vector_ty, vt, VectorIndexS32b_timm, tileslice16>;
2628bdd1243dSDimitry Andric
2629bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i",
2630bdd1243dSDimitry Andric        (!cast<Instruction>(NAME) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2631bdd1243dSDimitry Andric        multi_vector_ty:$Zn, vector_ty:$Zm, VectorIndexS32b_timm:$i), 0>;
2632bdd1243dSDimitry Andric}
2633bdd1243dSDimitry Andric
2634*0fca6ea1SDimitry Andric// SME2.1 multi-vec ternary indexed four registers 16-bit (FP8)
2635*0fca6ea1SDimitry Andricmulticlass sme2p1_multi_vec_array_vg4_index_f8f16<string mnemonic, bits<3> op,
26365f757f3fSDimitry Andric                                                  RegisterOperand multi_vector_ty,
26375f757f3fSDimitry Andric                                                  ZPRRegOp zpr_ty> {
2638bdd1243dSDimitry Andric  def NAME : sme2_multi_vec_array_vg4_index<0b0,{0b1,?,?,op,?}, MatrixOp16,
26395f757f3fSDimitry Andric                                            multi_vector_ty, zpr_ty,
2640bdd1243dSDimitry Andric                                            VectorIndexH, mnemonic>{
2641bdd1243dSDimitry Andric    bits<3> i;
2642bdd1243dSDimitry Andric    let Inst{11-10} = i{2-1};
2643bdd1243dSDimitry Andric    let Inst{3}     = i{0};
2644bdd1243dSDimitry Andric  }
2645bdd1243dSDimitry Andric
2646bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i",
2647bdd1243dSDimitry Andric        (!cast<Instruction>(NAME) MatrixOp16:$ZAda,  MatrixIndexGPR32Op8_11:$Rv,
26485f757f3fSDimitry Andric        sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, zpr_ty:$Zm, VectorIndexH:$i), 0>;
2649bdd1243dSDimitry Andric}
2650bdd1243dSDimitry Andric
2651*0fca6ea1SDimitry Andric// SME2.1 multi-vec ternary indexed four registers 16-bit
2652*0fca6ea1SDimitry Andricmulticlass sme2p1_multi_vec_array_vg4_index_16b<string mnemonic, bits<3> op,
2653*0fca6ea1SDimitry Andric                                                RegisterOperand multi_vector_ty,
2654*0fca6ea1SDimitry Andric                                                ZPRRegOp vector_ty, ValueType vt,
2655*0fca6ea1SDimitry Andric                                                SDPatternOperator intrinsic> {
2656*0fca6ea1SDimitry Andric  def NAME : sme2_multi_vec_array_vg4_index<0b0,{0b1,?,?,op,?}, MatrixOp16,
2657*0fca6ea1SDimitry Andric                                            multi_vector_ty, vector_ty,
2658*0fca6ea1SDimitry Andric                                            VectorIndexH, mnemonic>, SMEPseudo2Instr<NAME, 1> {
2659*0fca6ea1SDimitry Andric    bits<3> i;
2660*0fca6ea1SDimitry Andric    let Inst{11-10} = i{2-1};
2661*0fca6ea1SDimitry Andric    let Inst{3}     = i{0};
2662*0fca6ea1SDimitry Andric  }
2663*0fca6ea1SDimitry Andric
2664*0fca6ea1SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, vector_ty, VectorIndexH32b_timm, SMEMatrixArray>;
2665*0fca6ea1SDimitry Andric
2666*0fca6ea1SDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Index_Pat<NAME, intrinsic, sme_elm_idx0_7, vector_ty, vt, VectorIndexH32b_timm, tileslice16>;
2667*0fca6ea1SDimitry Andric
2668*0fca6ea1SDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i",
2669*0fca6ea1SDimitry Andric        (!cast<Instruction>(NAME) MatrixOp16:$ZAda,  MatrixIndexGPR32Op8_11:$Rv,
2670*0fca6ea1SDimitry Andric        sme_elm_idx0_7:$imm3, multi_vector_ty:$Zn, vector_ty:$Zm, VectorIndexH:$i), 0>;
2671*0fca6ea1SDimitry Andric}
2672*0fca6ea1SDimitry Andric
2673bdd1243dSDimitry Andric// SME2 multi-vec ternary indexed four registers 64-bit
2674bdd1243dSDimitry Andricclass sme2_multi_vec_array_vg4_index_64b<bits<3> op,
2675bdd1243dSDimitry Andric                                         RegisterOperand multi_vector_ty,
2676bdd1243dSDimitry Andric                                         ZPRRegOp vector_ty,
2677bdd1243dSDimitry Andric                                         string mnemonic>
2678bdd1243dSDimitry Andric    : I<(outs MatrixOp64:$ZAda),
2679bdd1243dSDimitry Andric        (ins MatrixOp64:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2680bdd1243dSDimitry Andric         multi_vector_ty:$Zn, vector_ty:$Zm, VectorIndexD32b_timm:$i1),
2681bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm3, vgx4], $Zn, $Zm$i1",
2682bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2683bdd1243dSDimitry Andric  bits<4> Zm;
2684bdd1243dSDimitry Andric  bits<2> Rv;
2685bdd1243dSDimitry Andric  bits<1> i1;
2686bdd1243dSDimitry Andric  bits<3> Zn;
2687bdd1243dSDimitry Andric  bits<3> imm3;
2688bdd1243dSDimitry Andric  let Inst{31-20} = 0b110000011101;
2689bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
2690bdd1243dSDimitry Andric  let Inst{15}    = 0b1;
2691bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
2692bdd1243dSDimitry Andric  let Inst{12}    = 0b0;
2693bdd1243dSDimitry Andric  let Inst{11}    = op{2};
2694bdd1243dSDimitry Andric  let Inst{10}    = i1;
2695bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
2696bdd1243dSDimitry Andric  let Inst{6-5}   = 0b00;
2697bdd1243dSDimitry Andric  let Inst{4-3}   = op{1-0};
2698bdd1243dSDimitry Andric  let Inst{2-0}   = imm3;
2699bdd1243dSDimitry Andric
2700bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
2701bdd1243dSDimitry Andric}
2702bdd1243dSDimitry Andric
2703bdd1243dSDimitry Andricmulticlass sme2_multi_vec_array_vg4_index_64b<string mnemonic, bits<3> op,
2704bdd1243dSDimitry Andric                                              RegisterOperand multi_vector_ty,
2705bdd1243dSDimitry Andric                                              ZPRRegOp vector_ty, ValueType vty,
2706bdd1243dSDimitry Andric                                              SDPatternOperator intrinsic> {
2707bdd1243dSDimitry Andric  def NAME : sme2_multi_vec_array_vg4_index_64b<op, multi_vector_ty, vector_ty,
2708bdd1243dSDimitry Andric                                                mnemonic>, SMEPseudo2Instr<NAME, 1>;
2709bdd1243dSDimitry Andric
2710bdd1243dSDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, sme_elm_idx0_7, multi_vector_ty, vector_ty, VectorIndexD32b_timm, SMEMatrixArray>;
2711bdd1243dSDimitry Andric
2712bdd1243dSDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Index_Pat<NAME, intrinsic, sme_elm_idx0_7, vector_ty, vty, VectorIndexD32b_timm, tileslice16>;
2713bdd1243dSDimitry Andric
2714bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i1",
2715bdd1243dSDimitry Andric        (!cast<Instruction>(NAME) MatrixOp64:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, sme_elm_idx0_7:$imm3,
2716bdd1243dSDimitry Andric        multi_vector_ty:$Zn, vector_ty:$Zm, VectorIndexD32b_timm:$i1), 0>;
2717bdd1243dSDimitry Andric}
27185f757f3fSDimitry Andric
27195f757f3fSDimitry Andric// FMLAL (multiple and indexed vector, FP8 to FP16)
27205f757f3fSDimitry Andricclass sme2_multi_vec_array_vg24_index_16b<bits<2> sz, bit vg4, bits<3> op,
27215f757f3fSDimitry Andric                                          RegisterOperand multi_vector_ty, string mnemonic>
27225f757f3fSDimitry Andric    : I<(outs MatrixOp16:$ZAda),
27235f757f3fSDimitry Andric        (ins MatrixOp16:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm2s2range:$imm2,
27245f757f3fSDimitry Andric         multi_vector_ty:$Zn, ZPR4b8:$Zm, VectorIndexB:$i),
27255f757f3fSDimitry Andric         mnemonic, "\t$ZAda[$Rv, $imm2, " # !if(vg4, "vgx4", "vgx2") # "], $Zn, $Zm$i",
27265f757f3fSDimitry Andric         "", []>, Sched<[]> {
27275f757f3fSDimitry Andric  bits<4> Zm;
27285f757f3fSDimitry Andric  bits<2> Rv;
27295f757f3fSDimitry Andric  bits<4> i;
27305f757f3fSDimitry Andric  bits<2> imm2;
27315f757f3fSDimitry Andric  let Inst{31-24} = 0b11000001;
27325f757f3fSDimitry Andric  let Inst{23-22} = sz;
27335f757f3fSDimitry Andric  let Inst{21-20} = 0b01;
27345f757f3fSDimitry Andric  let Inst{19-16} = Zm;
27355f757f3fSDimitry Andric  let Inst{15}    = vg4;
27365f757f3fSDimitry Andric  let Inst{14-13} = Rv;
27375f757f3fSDimitry Andric  let Inst{12}    = op{2};
27385f757f3fSDimitry Andric  let Inst{11-10} = i{3-2};
27395f757f3fSDimitry Andric  let Inst{5-4}   = op{1-0};
27405f757f3fSDimitry Andric  let Inst{3-2}   = i{1-0};
27415f757f3fSDimitry Andric  let Inst{1-0}   = imm2;
27425f757f3fSDimitry Andric
27435f757f3fSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
27445f757f3fSDimitry Andric}
27455f757f3fSDimitry Andric
27465f757f3fSDimitry Andricmulticlass sme2_multi_vec_array_vg2_index_16b<string mnemonic, bits<2> sz, bits<3>op> {
27475f757f3fSDimitry Andric  def NAME : sme2_multi_vec_array_vg24_index_16b<sz, 0b0, op, ZZ_b_mul_r, mnemonic> {
27485f757f3fSDimitry Andric    bits<4> Zn;
27495f757f3fSDimitry Andric    let Inst{9-6} = Zn;
27505f757f3fSDimitry Andric }
27515f757f3fSDimitry Andric def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm2], $Zn, $Zm$i",
27525f757f3fSDimitry Andric                 (!cast<Instruction>(NAME) MatrixOp16:$ZAda,  MatrixIndexGPR32Op8_11:$Rv,
27535f757f3fSDimitry Andric                  uimm2s2range:$imm2, ZZ_b_mul_r:$Zn, ZPR4b8:$Zm, VectorIndexB:$i), 0>;
27545f757f3fSDimitry Andric}
27555f757f3fSDimitry Andric
27565f757f3fSDimitry Andricmulticlass sme2_multi_vec_array_vg4_index_16b<string mnemonic, bits<2>sz, bits<3>op> {
27575f757f3fSDimitry Andric  def NAME: sme2_multi_vec_array_vg24_index_16b<sz, 0b1, op, ZZZZ_b_mul_r, mnemonic> {
27585f757f3fSDimitry Andric    bits<3> Zn;
27595f757f3fSDimitry Andric    let Inst{9-7} = Zn;
27605f757f3fSDimitry Andric    let Inst{6}   = 0b0;
27615f757f3fSDimitry Andric  }
27625f757f3fSDimitry Andric def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm2], $Zn, $Zm$i",
27635f757f3fSDimitry Andric                 (!cast<Instruction>(NAME) MatrixOp16:$ZAda,  MatrixIndexGPR32Op8_11:$Rv,
27645f757f3fSDimitry Andric                  uimm2s2range:$imm2, ZZZZ_b_mul_r:$Zn, ZPR4b8:$Zm, VectorIndexB:$i), 0>;
27655f757f3fSDimitry Andric}
27665f757f3fSDimitry Andric
2767bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
27685f757f3fSDimitry Andric// SME2 multi-vec indexed long long MLA one source 16-bit
27695f757f3fSDimitry Andricclass sme2_mla_ll_array_index_16b<string mnemonic, bits<2> sz,bits<2> op>
27705f757f3fSDimitry Andric    : I<(outs MatrixOp16:$ZAda),
27715f757f3fSDimitry Andric        (ins MatrixOp16:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm3s2range:$imm3, ZPR8:$Zn, ZPR4b8:$Zm, VectorIndexB32b_timm:$i),
27725f757f3fSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm3], $Zn, $Zm$i",
27735f757f3fSDimitry Andric        "", []>, Sched<[]> {
27745f757f3fSDimitry Andric  bits<4> Zm;
27755f757f3fSDimitry Andric  bits<2> Rv;
27765f757f3fSDimitry Andric  bits<4> i;
27775f757f3fSDimitry Andric  bits<5> Zn;
27785f757f3fSDimitry Andric  bits<3> imm3;
27795f757f3fSDimitry Andric  let Inst{31-24} = 0b11000001;
27805f757f3fSDimitry Andric  let Inst{23-22} = sz;
27815f757f3fSDimitry Andric  let Inst{21-20} = 0b00;
27825f757f3fSDimitry Andric  let Inst{19-16} = Zm;
27835f757f3fSDimitry Andric  let Inst{15}    = i{3};
27845f757f3fSDimitry Andric  let Inst{14-13} = Rv;
27855f757f3fSDimitry Andric  let Inst{12}    = op{1};
27865f757f3fSDimitry Andric  let Inst{11-10} = i{2-1};
27875f757f3fSDimitry Andric  let Inst{9-5}   = Zn;
27885f757f3fSDimitry Andric  let Inst{4}     = op{0};
27895f757f3fSDimitry Andric  let Inst{3}     = i{0};
27905f757f3fSDimitry Andric  let Inst{2-0}   = imm3;
27915f757f3fSDimitry Andric
27925f757f3fSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
27935f757f3fSDimitry Andric}
27945f757f3fSDimitry Andric
2795bdd1243dSDimitry Andric// SME2 multi-vec indexed long long MLA one source 32-bit
27965f757f3fSDimitry Andricclass sme2_mla_ll_array_index_32b<string mnemonic, bits<2> sz, bits<3> op>
2797bdd1243dSDimitry Andric    : I<(outs MatrixOp32:$ZAda),
279806c3fb27SDimitry Andric        (ins MatrixOp32:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm2s4range:$imm2, ZPR8:$Zn, ZPR4b8:$Zm, VectorIndexB32b_timm:$i),
2799bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm2], $Zn, $Zm$i",
2800bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2801bdd1243dSDimitry Andric  bits<4> Zm;
2802bdd1243dSDimitry Andric  bits<2> Rv;
2803bdd1243dSDimitry Andric  bits<4> i;
2804bdd1243dSDimitry Andric  bits<5> Zn;
2805bdd1243dSDimitry Andric  bits<2> imm2;
28065f757f3fSDimitry Andric  let Inst{31-24} = 0b11000001;
28075f757f3fSDimitry Andric  let Inst{23-22} = sz;
28085f757f3fSDimitry Andric  let Inst{21-20} = 0b00;
2809bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
2810bdd1243dSDimitry Andric  let Inst{15}    = i{3};
2811bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
2812bdd1243dSDimitry Andric  let Inst{12-10} = i{2-0};
2813bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
2814bdd1243dSDimitry Andric  let Inst{4-2}   = op;
2815bdd1243dSDimitry Andric  let Inst{1-0}   = imm2;
2816bdd1243dSDimitry Andric
2817bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
2818bdd1243dSDimitry Andric}
2819bdd1243dSDimitry Andric
28205f757f3fSDimitry Andricmulticlass sme2_mla_ll_array_index_32b<string mnemonic, bits<2> sz, bits<3> op, SDPatternOperator intrinsic> {
28215f757f3fSDimitry Andric  def NAME : sme2_mla_ll_array_index_32b<mnemonic, sz, op>, SMEPseudo2Instr<NAME, 1>;
282206c3fb27SDimitry Andric
282306c3fb27SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, uimm2s4range, ZPR8, ZPR4b8, VectorIndexB32b_timm, SMEMatrixArray>;
282406c3fb27SDimitry Andric
282506c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_Multi_Index_Pat<NAME, intrinsic, uimm2s4range, ZPR4b8, nxv16i8, VectorIndexB32b_timm, tileslicerange2s4>;
282606c3fb27SDimitry Andric}
282706c3fb27SDimitry Andric
2828bdd1243dSDimitry Andric// SME2 multi-vec indexed long long MLA one source 64-bit
2829bdd1243dSDimitry Andric
2830bdd1243dSDimitry Andricclass sme2_mla_ll_array_index_64b<string mnemonic, bits<2> op>
2831bdd1243dSDimitry Andric    : I<(outs MatrixOp64:$ZAda),
283206c3fb27SDimitry Andric        (ins MatrixOp64:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm2s4range:$imm2, ZPR16:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i),
2833bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm2], $Zn, $Zm$i",
2834bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2835bdd1243dSDimitry Andric  bits<4> Zm;
2836bdd1243dSDimitry Andric  bits<2> Rv;
2837bdd1243dSDimitry Andric  bits<3> i;
2838bdd1243dSDimitry Andric  bits<5> Zn;
2839bdd1243dSDimitry Andric  bits<2> imm2;
2840bdd1243dSDimitry Andric  let Inst{31-20} = 0b110000011000;
2841bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
2842bdd1243dSDimitry Andric  let Inst{15}    = i{2};
2843bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
2844bdd1243dSDimitry Andric  let Inst{12}    = 0b0;
2845bdd1243dSDimitry Andric  let Inst{11-10} = i{1-0};
2846bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
2847bdd1243dSDimitry Andric  let Inst{4-3}   = op;
2848bdd1243dSDimitry Andric  let Inst{2}     = 0b0;
2849bdd1243dSDimitry Andric  let Inst{1-0}   = imm2;
2850bdd1243dSDimitry Andric
2851bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
2852bdd1243dSDimitry Andric}
2853bdd1243dSDimitry Andric
285406c3fb27SDimitry Andricmulticlass sme2_mla_ll_array_index_64b<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
285506c3fb27SDimitry Andric  def NAME : sme2_mla_ll_array_index_64b<mnemonic, op>, SMEPseudo2Instr<NAME, 1>;
285606c3fb27SDimitry Andric
285706c3fb27SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, uimm2s4range, ZPR16, ZPR4b16, VectorIndexH32b_timm, SMEMatrixArray>;
285806c3fb27SDimitry Andric
285906c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_Multi_Index_Pat<NAME, intrinsic, uimm2s4range, ZPR4b16, nxv8i16, VectorIndexH32b_timm, tileslicerange2s4>;
286006c3fb27SDimitry Andric}
286106c3fb27SDimitry Andric
28625f757f3fSDimitry Andricclass sme2_mla_ll_array_vg24_index_32b<bits<2> sz, bit vg4, bits<3> op,
2863bdd1243dSDimitry Andric                                       RegisterOperand vector_ty,
2864bdd1243dSDimitry Andric                                       string mnemonic>
2865bdd1243dSDimitry Andric    : I<(outs MatrixOp32:$ZAda),
2866bdd1243dSDimitry Andric        (ins MatrixOp32:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm,
286706c3fb27SDimitry Andric             vector_ty:$Zn, ZPR4b8:$Zm, VectorIndexB32b_timm:$i),
2868bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm, " # !if(vg4, "vgx4", "vgx2") # "], $Zn, $Zm$i",
2869bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2870bdd1243dSDimitry Andric  bits<4> Zm;
2871bdd1243dSDimitry Andric  bits<2> Rv;
2872bdd1243dSDimitry Andric  bits<4> i;
2873bdd1243dSDimitry Andric  bit     imm;
28745f757f3fSDimitry Andric  let Inst{31-24} = 0b11000001;
28755f757f3fSDimitry Andric  let Inst{23-22} = sz;
28765f757f3fSDimitry Andric  let Inst{21-20} = 0b01;
2877bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
2878bdd1243dSDimitry Andric  let Inst{15}    = vg4;
2879bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
2880bdd1243dSDimitry Andric  let Inst{12}    = 0b0;
2881bdd1243dSDimitry Andric  let Inst{11-10} = i{3-2};
2882bdd1243dSDimitry Andric  let Inst{5-3}   = op;
2883bdd1243dSDimitry Andric  let Inst{2-1}   = i{1-0};
2884bdd1243dSDimitry Andric  let Inst{0}     = imm;
2885bdd1243dSDimitry Andric
2886bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
2887bdd1243dSDimitry Andric}
2888bdd1243dSDimitry Andric
2889bdd1243dSDimitry Andric//SME2 multi-vec indexed long long MLA two sources 32-bit
2890bdd1243dSDimitry Andric
28915f757f3fSDimitry Andricmulticlass sme2_mla_ll_array_vg2_index_32b<string mnemonic, bits<2> sz, bits<3> op, SDPatternOperator intrinsic> {
28925f757f3fSDimitry Andric  def NAME: sme2_mla_ll_array_vg24_index_32b<sz, 0b0, op, ZZ_b_mul_r, mnemonic>, SMEPseudo2Instr<NAME, 1> {
2893bdd1243dSDimitry Andric   bits<4> Zn;
2894bdd1243dSDimitry Andric   let Inst{9-6} = Zn;
2895bdd1243dSDimitry Andric  }
2896bdd1243dSDimitry Andric
289706c3fb27SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, uimm1s4range, ZZ_b_mul_r, ZPR4b8, VectorIndexB32b_timm, SMEMatrixArray>;
289806c3fb27SDimitry Andric
289906c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Index_Pat<NAME, intrinsic, uimm1s4range, ZPR4b8, nxv16i8, VectorIndexB32b_timm, tileslicerange1s4>;
290006c3fb27SDimitry Andric
2901bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm$i",
290206c3fb27SDimitry Andric                 (!cast<Instruction>(NAME) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm, ZZ_b_mul_r:$Zn, ZPR4b8:$Zm, VectorIndexB32b_timm:$i), 0>;
2903bdd1243dSDimitry Andric}
2904bdd1243dSDimitry Andric
2905bdd1243dSDimitry Andric// SME2 multi-vec indexed long long MLA four sources 32-bit
2906bdd1243dSDimitry Andric
29075f757f3fSDimitry Andricmulticlass sme2_mla_ll_array_vg4_index_32b<string mnemonic, bits<2> sz, bits<4> op, SDPatternOperator intrinsic> {
29085f757f3fSDimitry Andric  def NAME: sme2_mla_ll_array_vg24_index_32b<sz, 0b1, op{2-0}, ZZZZ_b_mul_r, mnemonic>, SMEPseudo2Instr<NAME, 1> {
2909bdd1243dSDimitry Andric   bits<3> Zn;
2910bdd1243dSDimitry Andric   let Inst{9-7} = Zn;
29115f757f3fSDimitry Andric   let Inst{6}   = op{3};
2912bdd1243dSDimitry Andric  }
2913bdd1243dSDimitry Andric
291406c3fb27SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, uimm1s4range, ZZZZ_b_mul_r, ZPR4b8, VectorIndexB32b_timm, SMEMatrixArray>;
291506c3fb27SDimitry Andric
291606c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Index_Pat<NAME, intrinsic, uimm1s4range, ZPR4b8, nxv16i8, VectorIndexB32b_timm, tileslicerange1s4>;
291706c3fb27SDimitry Andric
2918bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm$i",
291906c3fb27SDimitry Andric                 (!cast<Instruction>(NAME) MatrixOp32:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm, ZZZZ_b_mul_r:$Zn, ZPR4b8:$Zm, VectorIndexB32b_timm:$i), 0>;
2920bdd1243dSDimitry Andric}
2921bdd1243dSDimitry Andricclass sme2_mla_ll_array_vg24_index_64b<bit vg4,  bits<2> op,
2922bdd1243dSDimitry Andric                                       RegisterOperand vector_ty,
2923bdd1243dSDimitry Andric                                       string mnemonic>
2924bdd1243dSDimitry Andric    : I<(outs MatrixOp64:$ZAda),
2925bdd1243dSDimitry Andric        (ins MatrixOp64:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm,
292606c3fb27SDimitry Andric             vector_ty:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i),
2927bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm, " # !if(vg4, "vgx4", "vgx2") # "], $Zn, $Zm$i",
2928bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2929bdd1243dSDimitry Andric  bits<4> Zm;
2930bdd1243dSDimitry Andric  bits<2> Rv;
2931bdd1243dSDimitry Andric  bits<3> i;
2932bdd1243dSDimitry Andric  bit     imm;
2933bdd1243dSDimitry Andric  let Inst{31-20} = 0b110000011001;
2934bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
2935bdd1243dSDimitry Andric  let Inst{15}    = vg4;
2936bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
2937bdd1243dSDimitry Andric  let Inst{12-11} = 0b00;
2938bdd1243dSDimitry Andric  let Inst{10}    = i{2};
2939bdd1243dSDimitry Andric  let Inst{5}     = 0b0;
2940bdd1243dSDimitry Andric  let Inst{4-3}   = op;
2941bdd1243dSDimitry Andric  let Inst{2-1}   = i{1-0};
2942bdd1243dSDimitry Andric  let Inst{0}     = imm;
2943bdd1243dSDimitry Andric
2944bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
2945bdd1243dSDimitry Andric}
2946bdd1243dSDimitry Andric
2947bdd1243dSDimitry Andric// SME2 multi-vec indexed long long MLA two sources 64-bit
2948bdd1243dSDimitry Andric
294906c3fb27SDimitry Andricmulticlass sme2_mla_ll_array_vg2_index_64b<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
295006c3fb27SDimitry Andric  def NAME: sme2_mla_ll_array_vg24_index_64b<0b0, op, ZZ_h_mul_r, mnemonic>, SMEPseudo2Instr<NAME, 1> {
2951bdd1243dSDimitry Andric    bits<4> Zn;
2952bdd1243dSDimitry Andric    let Inst{9-6} = Zn;
2953bdd1243dSDimitry Andric  }
2954bdd1243dSDimitry Andric
295506c3fb27SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, uimm1s4range, ZZ_h_mul_r, ZPR4b16, VectorIndexH32b_timm, SMEMatrixArray>;
295606c3fb27SDimitry Andric
295706c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Index_Pat<NAME, intrinsic, uimm1s4range, ZPR4b16, nxv8i16, VectorIndexH32b_timm, tileslicerange1s4>;
295806c3fb27SDimitry Andric
2959bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm$i",
296006c3fb27SDimitry Andric                 (!cast<Instruction>(NAME) MatrixOp64:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm, ZZ_h_mul_r:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i), 0>;
2961bdd1243dSDimitry Andric}
2962bdd1243dSDimitry Andric
2963bdd1243dSDimitry Andric// SME2 multi-vec indexed long long MLA four sources 64-bit
2964bdd1243dSDimitry Andric
296506c3fb27SDimitry Andricmulticlass sme2_mla_ll_array_vg4_index_64b<string mnemonic, bits<2> op, SDPatternOperator intrinsic> {
296606c3fb27SDimitry Andric  def NAME: sme2_mla_ll_array_vg24_index_64b<0b1, op, ZZZZ_h_mul_r,  mnemonic>, SMEPseudo2Instr<NAME, 1> {
2967bdd1243dSDimitry Andric    bits<3> Zn;
2968bdd1243dSDimitry Andric    let Inst{9-7} = Zn;
2969bdd1243dSDimitry Andric    let Inst{6}   = 0b0;
2970bdd1243dSDimitry Andric  }
2971bdd1243dSDimitry Andric
297206c3fb27SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo<NAME, uimm1s4range, ZZZZ_h_mul_r, ZPR4b16, VectorIndexH32b_timm, SMEMatrixArray>;
297306c3fb27SDimitry Andric
297406c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Index_Pat<NAME, intrinsic, uimm1s4range, ZPR4b16, nxv8i16, VectorIndexH32b_timm, tileslicerange1s4>;
297506c3fb27SDimitry Andric
2976bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm$i",
297706c3fb27SDimitry Andric                 (!cast<Instruction>(NAME) MatrixOp64:$ZAda,  MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm, ZZZZ_h_mul_r:$Zn, ZPR4b16:$Zm, VectorIndexH32b_timm:$i), 0>;
2978bdd1243dSDimitry Andric}
2979bdd1243dSDimitry Andric
2980bdd1243dSDimitry Andric
2981bdd1243dSDimitry Andric//SME2 multiple and single vector long long FMA one source
2982bdd1243dSDimitry Andric
29835f757f3fSDimitry Andricclass sme2_mla_ll_array_single<string mnemonic, bits<5> op,
2984bdd1243dSDimitry Andric                               MatrixOperand matrix_ty, ZPRRegOp vector_ty,
2985bdd1243dSDimitry Andric                               ZPRRegOp zpr_ty>
2986bdd1243dSDimitry Andric    : I<(outs matrix_ty:$ZAda),
2987bdd1243dSDimitry Andric        (ins matrix_ty:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm2s4range:$imm,
2988bdd1243dSDimitry Andric             vector_ty:$Zn, zpr_ty:$Zm),
2989bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm], $Zn, $Zm",
2990bdd1243dSDimitry Andric        "", []>, Sched<[]> {
2991bdd1243dSDimitry Andric  bits<4> Zm;
2992bdd1243dSDimitry Andric  bits<2> Rv;
2993bdd1243dSDimitry Andric  bits<5> Zn;
2994bdd1243dSDimitry Andric  bits<2> imm;
2995bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000010;
29965f757f3fSDimitry Andric  let Inst{22}    = op{4}; //sz
29975f757f3fSDimitry Andric  let Inst{21}    = 0b1;
29985f757f3fSDimitry Andric  let Inst{20}    = op{3}; //fp8
2999bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
3000bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
3001bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
3002bdd1243dSDimitry Andric  let Inst{12-10} = 0b001;
3003bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
3004bdd1243dSDimitry Andric  let Inst{4-2}   = op{2-0};
3005bdd1243dSDimitry Andric  let Inst{1-0}   = imm;
3006bdd1243dSDimitry Andric
3007bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
3008bdd1243dSDimitry Andric}
3009bdd1243dSDimitry Andric
30105f757f3fSDimitry Andricmulticlass sme2_mla_ll_array_single<string mnemonic, bits<5> op,
301106c3fb27SDimitry Andric                                    MatrixOperand matrix_ty, ZPRRegOp vector_ty,
301206c3fb27SDimitry Andric                                    ZPRRegOp zpr_ty, ValueType vt, SDPatternOperator intrinsic> {
301306c3fb27SDimitry Andric  def NAME : sme2_mla_ll_array_single<mnemonic, op, matrix_ty, vector_ty, zpr_ty>, SMEPseudo2Instr<NAME, 1>;
301406c3fb27SDimitry Andric
301506c3fb27SDimitry Andric  def NAME # _PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME, uimm2s4range, vector_ty, zpr_ty, SMEMatrixArray>;
301606c3fb27SDimitry Andric
301706c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_Multi_Single_Pat<NAME, intrinsic, uimm2s4range, zpr_ty, vt, tileslicerange2s4>;
301806c3fb27SDimitry Andric}
301906c3fb27SDimitry Andric
30205f757f3fSDimitry Andricclass sme2_mla_ll_array_vg24_single<bits<6> op, MatrixOperand matrix_ty,
3021bdd1243dSDimitry Andric                                    RegisterOperand vector_ty, ZPRRegOp zpr_ty,
3022bdd1243dSDimitry Andric                                    string mnemonic>
3023bdd1243dSDimitry Andric    : I<(outs matrix_ty:$ZAda),
3024bdd1243dSDimitry Andric        (ins matrix_ty:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm,
3025bdd1243dSDimitry Andric             vector_ty:$Zn, zpr_ty:$Zm),
30265f757f3fSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm,  " # !if(op{4}, "vgx4", "vgx2") # "], $Zn, $Zm",
3027bdd1243dSDimitry Andric        "", []>, Sched<[]> {
3028bdd1243dSDimitry Andric  bits<4> Zm;
3029bdd1243dSDimitry Andric  bits<2> Rv;
3030bdd1243dSDimitry Andric  bits<5> Zn;
3031bdd1243dSDimitry Andric  bit     imm;
3032bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000010;
30335f757f3fSDimitry Andric  let Inst{22}    = op{5}; //sz
3034bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
30355f757f3fSDimitry Andric  let Inst{20}    = op{4}; //vg4
3036bdd1243dSDimitry Andric  let Inst{19-16} = Zm;
3037bdd1243dSDimitry Andric  let Inst{15}    = 0b0;
3038bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
3039bdd1243dSDimitry Andric  let Inst{12-10} = 0b000;
3040bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
30415f757f3fSDimitry Andric  let Inst{4-1}   = op{3-0};
3042bdd1243dSDimitry Andric  let Inst{0}     = imm;
3043bdd1243dSDimitry Andric
3044bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
3045bdd1243dSDimitry Andric}
3046bdd1243dSDimitry Andric
3047bdd1243dSDimitry Andric//SME2 single-multi long long MLA two and four sources
3048bdd1243dSDimitry Andric
30495f757f3fSDimitry Andricmulticlass sme2_mla_ll_array_vg24_single<string mnemonic, bits<6> op,
3050bdd1243dSDimitry Andric                                          MatrixOperand matrix_ty,
3051bdd1243dSDimitry Andric                                          RegisterOperand multi_vector_ty,
3052bdd1243dSDimitry Andric                                          ZPRRegOp zpr_ty> {
3053bdd1243dSDimitry Andric  def NAME: sme2_mla_ll_array_vg24_single<op, matrix_ty, multi_vector_ty,
305406c3fb27SDimitry Andric                                          zpr_ty, mnemonic>, SMEPseudo2Instr<NAME, 1>;
305506c3fb27SDimitry Andric
305606c3fb27SDimitry Andric  def NAME # _PSEUDO : sme2_za_array_2op_multi_single_pseudo<NAME, uimm1s4range, multi_vector_ty, zpr_ty, SMEMatrixArray>;
3057bdd1243dSDimitry Andric
3058bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAd[$Rv, $imm], $Zn, $Zm",
3059bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAd,  MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm, multi_vector_ty:$Zn, zpr_ty:$Zm), 0>;
3060bdd1243dSDimitry Andric}
3061bdd1243dSDimitry Andric
306206c3fb27SDimitry Andricmulticlass sme2_mla_ll_array_vg2_single<string mnemonic, bits<5> op,
306306c3fb27SDimitry Andric                                        MatrixOperand matrix_ty,
306406c3fb27SDimitry Andric                                        RegisterOperand multi_vector_ty,
306506c3fb27SDimitry Andric                                        ZPRRegOp zpr_ty, ValueType vt, SDPatternOperator intrinsic> {
306606c3fb27SDimitry Andric
30675f757f3fSDimitry Andric  defm NAME: sme2_mla_ll_array_vg24_single<mnemonic, {op, 0b0}, matrix_ty, multi_vector_ty, zpr_ty>;
306806c3fb27SDimitry Andric
306906c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Single_Pat<NAME, intrinsic, uimm1s4range, zpr_ty, vt, tileslicerange1s4>;
307006c3fb27SDimitry Andric}
307106c3fb27SDimitry Andric
307206c3fb27SDimitry Andricmulticlass sme2_mla_ll_array_vg4_single<string mnemonic, bits<5> op,
307306c3fb27SDimitry Andric                                        MatrixOperand matrix_ty,
307406c3fb27SDimitry Andric                                        RegisterOperand multi_vector_ty,
307506c3fb27SDimitry Andric                                        ZPRRegOp zpr_ty, ValueType vt, SDPatternOperator intrinsic> {
30765f757f3fSDimitry Andric  defm NAME: sme2_mla_ll_array_vg24_single<mnemonic, {op, 0b0}, matrix_ty, multi_vector_ty, zpr_ty>;
307706c3fb27SDimitry Andric
307806c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Single_Pat<NAME, intrinsic, uimm1s4range, zpr_ty, vt, tileslicerange1s4>;
307906c3fb27SDimitry Andric}
308006c3fb27SDimitry Andric
3081bdd1243dSDimitry Andric// SME2 multiple vectors long long MLA two sources
3082bdd1243dSDimitry Andric
30835f757f3fSDimitry Andricclass sme2_mla_ll_array_vg2_multi<bits<5> op, MatrixOperand matrix_ty,
3084bdd1243dSDimitry Andric                                  RegisterOperand vector_ty,string mnemonic>
3085bdd1243dSDimitry Andric    : I<(outs matrix_ty:$ZAda),
3086bdd1243dSDimitry Andric        (ins matrix_ty:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm,
3087bdd1243dSDimitry Andric             vector_ty:$Zn, vector_ty:$Zm),
3088bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm, vgx2], $Zn, $Zm",
3089bdd1243dSDimitry Andric        "", []>, Sched<[]> {
3090bdd1243dSDimitry Andric  bits<4> Zm;
3091bdd1243dSDimitry Andric  bits<2> Rv;
3092bdd1243dSDimitry Andric  bits<4> Zn;
3093bdd1243dSDimitry Andric  bit     imm;
3094bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000011;
30955f757f3fSDimitry Andric  let Inst{22}    = op{4};  // sz
3096bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
3097bdd1243dSDimitry Andric  let Inst{20-17} = Zm;
3098bdd1243dSDimitry Andric  let Inst{16-15} = 0b00;
3099bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
3100bdd1243dSDimitry Andric  let Inst{12-10} = 0b000;
3101bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
31025f757f3fSDimitry Andric  let Inst{5-2}   = op{3-0};
3103bdd1243dSDimitry Andric  let Inst{1}     = 0b0;
3104bdd1243dSDimitry Andric  let Inst{0}     = imm;
3105bdd1243dSDimitry Andric
3106bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
3107bdd1243dSDimitry Andric}
3108bdd1243dSDimitry Andric
31095f757f3fSDimitry Andricmulticlass sme2_mla_ll_array_vg2_multi<string mnemonic, bits<5> op,
3110bdd1243dSDimitry Andric                                       MatrixOperand matrix_ty,
311106c3fb27SDimitry Andric                                       RegisterOperand vector_ty,
311206c3fb27SDimitry Andric                                       ValueType vt, SDPatternOperator intrinsic> {
311306c3fb27SDimitry Andric  def NAME : sme2_mla_ll_array_vg2_multi<op, matrix_ty, vector_ty, mnemonic>, SMEPseudo2Instr<NAME, 1>;
311406c3fb27SDimitry Andric
311506c3fb27SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_multi_pseudo<NAME, uimm1s4range, vector_ty, SMEMatrixArray>;
311606c3fb27SDimitry Andric
311706c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_VG2_Multi_Multi_Pat<NAME, intrinsic, uimm1s4range, vt, tileslicerange1s4>;
3118bdd1243dSDimitry Andric
3119bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm",
3120bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm, vector_ty:$Zn, vector_ty:$Zm), 0>;
3121bdd1243dSDimitry Andric}
3122bdd1243dSDimitry Andric
3123bdd1243dSDimitry Andric// SME2 multiple vectors long long MLA four sources
3124bdd1243dSDimitry Andric
31255f757f3fSDimitry Andricclass sme2_mla_ll_array_vg4_multi<bits<5> op,MatrixOperand matrix_ty,
3126bdd1243dSDimitry Andric                                  RegisterOperand vector_ty,
3127bdd1243dSDimitry Andric                                  string mnemonic>
3128bdd1243dSDimitry Andric    : I<(outs matrix_ty:$ZAda),
3129bdd1243dSDimitry Andric        (ins matrix_ty:$_ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm,
3130bdd1243dSDimitry Andric             vector_ty:$Zn, vector_ty:$Zm),
3131bdd1243dSDimitry Andric        mnemonic, "\t$ZAda[$Rv, $imm, vgx4], $Zn, $Zm",
3132bdd1243dSDimitry Andric        "", []>, Sched<[]> {
3133bdd1243dSDimitry Andric  bits<3> Zm;
3134bdd1243dSDimitry Andric  bits<2> Rv;
3135bdd1243dSDimitry Andric  bits<3> Zn;
3136bdd1243dSDimitry Andric  bit     imm;
3137bdd1243dSDimitry Andric  let Inst{31-23} = 0b110000011;
31385f757f3fSDimitry Andric  let Inst{22}    = op{4}; // sz
3139bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
3140bdd1243dSDimitry Andric  let Inst{20-18} = Zm;
3141bdd1243dSDimitry Andric  let Inst{17-15} = 0b010;
3142bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
3143bdd1243dSDimitry Andric  let Inst{12-10} = 0b000;
3144bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
31455f757f3fSDimitry Andric  let Inst{6}     = 0b0;
31465f757f3fSDimitry Andric  let Inst{5-2}   = op{3-0};
3147bdd1243dSDimitry Andric  let Inst{1}     = 0b0;
3148bdd1243dSDimitry Andric  let Inst{0}     = imm;
3149bdd1243dSDimitry Andric
3150bdd1243dSDimitry Andric  let Constraints = "$ZAda = $_ZAda";
3151bdd1243dSDimitry Andric}
3152bdd1243dSDimitry Andric
31535f757f3fSDimitry Andricmulticlass sme2_mla_ll_array_vg4_multi<string mnemonic, bits<5> op,
3154bdd1243dSDimitry Andric                                       MatrixOperand matrix_ty,
315506c3fb27SDimitry Andric                                       RegisterOperand vector_ty,
315606c3fb27SDimitry Andric                                       ValueType vt, SDPatternOperator intrinsic> {
315706c3fb27SDimitry Andric  def NAME : sme2_mla_ll_array_vg4_multi<op, matrix_ty, vector_ty, mnemonic>, SMEPseudo2Instr<NAME, 1>;
315806c3fb27SDimitry Andric
315906c3fb27SDimitry Andric  def _PSEUDO : sme2_za_array_2op_multi_multi_pseudo<NAME, uimm1s4range, vector_ty, SMEMatrixArray>;
316006c3fb27SDimitry Andric
316106c3fb27SDimitry Andric  def : SME2_ZA_TwoOp_VG4_Multi_Multi_Pat<NAME, intrinsic, uimm1s4range, vt, tileslicerange1s4>;
3162bdd1243dSDimitry Andric
3163bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAda[$Rv, $imm], $Zn, $Zm",
3164bdd1243dSDimitry Andric                 (!cast<Instruction>(NAME) matrix_ty:$ZAda, MatrixIndexGPR32Op8_11:$Rv, uimm1s4range:$imm, vector_ty:$Zn, vector_ty:$Zm), 0>;
3165bdd1243dSDimitry Andric}
3166bdd1243dSDimitry Andric
3167bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
3168bdd1243dSDimitry Andric// SME2 Outer Product and Accumulate
3169bdd1243dSDimitry Andric
317006c3fb27SDimitry Andricmulticlass sme2_int_mopx_tile<string mnemonic, bits<3> op, SDPatternOperator intrinsic> {
317106c3fb27SDimitry Andric  def NAME : sme_int_outer_product_inst<op, 0b0, 0b1, TileOp32, ZPR16, mnemonic>, SMEPseudo2Instr<NAME, 1> {
3172bdd1243dSDimitry Andric    bits<2> ZAda;
3173bdd1243dSDimitry Andric    let Inst{1-0} = ZAda;
3174bdd1243dSDimitry Andric    let Inst{2}   = 0b0;
3175bdd1243dSDimitry Andric  }
317606c3fb27SDimitry Andric
317706c3fb27SDimitry Andric  def _PSEUDO : sme_outer_product_pseudo<ZPR16, SMEMatrixTileS>, SMEPseudo2Instr<NAME, 0>;
317806c3fb27SDimitry Andric
317906c3fb27SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, intrinsic, timm32_0_3, nxv8i1, nxv8i16>;
3180bdd1243dSDimitry Andric}
3181bdd1243dSDimitry Andric
318206c3fb27SDimitry Andricmulticlass  sme2_int_bmopx_tile<string mnemonic, bits<3> op, SDPatternOperator intrinsic> {
318306c3fb27SDimitry Andric  def NAME : sme_outer_product_widening_inst<op, ZPR32, mnemonic>, SMEPseudo2Instr<NAME, 1>;
318406c3fb27SDimitry Andric
318506c3fb27SDimitry Andric  def _PSEUDO : sme_outer_product_pseudo<ZPR32, SMEMatrixTileS>, SMEPseudo2Instr<NAME, 0>;
318606c3fb27SDimitry Andric
318706c3fb27SDimitry Andric  def : SME_ZA_Tile_TwoPred_TwoVec_Pat<NAME, intrinsic, timm32_0_3, nxv4i1, nxv4i32>;
3188bdd1243dSDimitry Andric}
3189bdd1243dSDimitry Andric
3190bdd1243dSDimitry Andric//===----------------------------------------------------------------------===///
3191bdd1243dSDimitry Andric// SME2 Zero Lookup Table.
3192bdd1243dSDimitry Andricclass sme2_zero_zt<string mnemonic, bits<4> opc>
3193bdd1243dSDimitry Andric    : I<(outs ZTR:$ZT), (ins ),
3194bdd1243dSDimitry Andric         mnemonic, "\t\\{ $ZT \\}",
3195bdd1243dSDimitry Andric         "", []>, Sched<[]> {
3196bdd1243dSDimitry Andric  let Inst{31-4} = 0b1100000001001000000000000000;
3197bdd1243dSDimitry Andric  let Inst{3-0}  = opc;
3198bdd1243dSDimitry Andric}
3199bdd1243dSDimitry Andric
32005f757f3fSDimitry Andricmulticlass sme2_zero_zt<string mnemonic, bits<4> opc> {
32015f757f3fSDimitry Andric  def NAME : sme2_zero_zt<mnemonic, opc>;
32025f757f3fSDimitry Andric  def NAME # _PSEUDO
32035f757f3fSDimitry Andric        : Pseudo<(outs), (ins ZTR:$ZT), []>, Sched<[]> {
32045f757f3fSDimitry Andric    // Translated to actual instruction in AArch64ISelLowering.cpp
32055f757f3fSDimitry Andric    let usesCustomInserter = 1;
32065f757f3fSDimitry Andric  }
32075f757f3fSDimitry Andric  def : Pat<(int_aarch64_sme_zero_zt (imm_to_zt untyped:$zt)),
32085f757f3fSDimitry Andric          (!cast<Instruction>(NAME # _PSEUDO) $zt)>;
32095f757f3fSDimitry Andric}
32105f757f3fSDimitry Andric
3211bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
3212bdd1243dSDimitry Andric// SME2 lookup table load/store
3213bdd1243dSDimitry Andricclass sme2_spill_fill_vector<string mnemonic, bits<8> opc>
3214bdd1243dSDimitry Andric    : I<!if(opc{7}, (outs ), (outs ZTR:$ZTt)),
3215bdd1243dSDimitry Andric        !if(opc{7}, (ins ZTR:$ZTt, GPR64sp:$Rn), (ins GPR64sp:$Rn)),
3216bdd1243dSDimitry Andric        mnemonic, "\t$ZTt, [$Rn]",
3217bdd1243dSDimitry Andric        "", []>, Sched<[]> {
3218bdd1243dSDimitry Andric  bits<5> Rn;
3219bdd1243dSDimitry Andric  let Inst{31-22} = 0b1110000100;
3220bdd1243dSDimitry Andric  let Inst{21-16} = opc{7-2};
3221bdd1243dSDimitry Andric  let Inst{15-10} = 0b100000;
3222bdd1243dSDimitry Andric  let Inst{9-5}   = Rn;
3223bdd1243dSDimitry Andric  let Inst{4-2}   = 0b000;
3224bdd1243dSDimitry Andric  let Inst{1-0}   = opc{1-0};
3225bdd1243dSDimitry Andric
3226bdd1243dSDimitry Andric  let mayLoad     = !not(opc{7});
3227bdd1243dSDimitry Andric  let mayStore    = opc{7};
3228bdd1243dSDimitry Andric}
3229bdd1243dSDimitry Andric
32305f757f3fSDimitry Andric
32315f757f3fSDimitry Andricmulticlass sme2_spill_fill_vector<string mnemonic, bits<8> opc, SDPatternOperator op> {
32325f757f3fSDimitry Andric  def NAME : sme2_spill_fill_vector<mnemonic, opc>;
32335f757f3fSDimitry Andric  def NAME # _PSEUDO
32345f757f3fSDimitry Andric      : Pseudo<(outs), (ins ZTR:$ZTt, GPR64sp:$base), []>, Sched<[]> {
32355f757f3fSDimitry Andric    // Translated to actual instruction in AArch64ISelLowering.cpp
32365f757f3fSDimitry Andric    let usesCustomInserter = 1;
32375f757f3fSDimitry Andric  }
32385f757f3fSDimitry Andric  def : Pat<(op (imm_to_zt untyped:$tile), GPR64sp:$base),
32395f757f3fSDimitry Andric            (!cast<Instruction>(NAME # _PSEUDO) $tile, $base)>;
32405f757f3fSDimitry Andric}
32415f757f3fSDimitry Andric
3242bdd1243dSDimitry Andric//===----------------------------------------------------------------------===///
3243bdd1243dSDimitry Andric// SME2 move to/from lookup table
3244bdd1243dSDimitry Andricclass sme2_movt_zt_to_scalar<string mnemonic, bits<7> opc>
3245bdd1243dSDimitry Andric    : I<(outs GPR64:$Rt), (ins ZTR:$ZTt, uimm3s8:$imm3),
32465f757f3fSDimitry Andric         mnemonic, "\t$Rt, $ZTt[$imm3]",
3247bdd1243dSDimitry Andric         "", []>, Sched<[]> {
3248bdd1243dSDimitry Andric  bits<3> imm3;
3249bdd1243dSDimitry Andric  bits<5> Rt;
3250bdd1243dSDimitry Andric  let Inst{31-15} = 0b11000000010011000;
3251bdd1243dSDimitry Andric  let Inst{14-12} = imm3;
3252bdd1243dSDimitry Andric  let Inst{11-5}  = opc;
3253bdd1243dSDimitry Andric  let Inst{4-0}   = Rt;
3254bdd1243dSDimitry Andric}
3255bdd1243dSDimitry Andric
3256bdd1243dSDimitry Andricclass sme2_movt_scalar_to_zt<string mnemonic, bits<7> opc>
3257bdd1243dSDimitry Andric    : I<(outs ZTR:$ZTt), (ins uimm3s8:$imm3, GPR64:$Rt),
32585f757f3fSDimitry Andric         mnemonic, "\t$ZTt[$imm3], $Rt",
3259bdd1243dSDimitry Andric         "", []>, Sched<[]> {
3260bdd1243dSDimitry Andric  bits<3> imm3;
3261bdd1243dSDimitry Andric  bits<5> Rt;
3262bdd1243dSDimitry Andric  let Inst{31-15} = 0b11000000010011100;
3263bdd1243dSDimitry Andric  let Inst{14-12} = imm3;
3264bdd1243dSDimitry Andric  let Inst{11-5}  = opc;
3265bdd1243dSDimitry Andric  let Inst{4-0}   = Rt;
3266bdd1243dSDimitry Andric}
3267bdd1243dSDimitry Andric
32685f757f3fSDimitry Andric// SME2 move vector to lookup table
32695f757f3fSDimitry Andricclass sme2_movt_zt_to_zt<string mnemonic, bits<7> opc>
32705f757f3fSDimitry Andric   : I<(outs ZTR:$ZTt), (ins sme_elm_idx0_3:$off2, ZPRAny:$Zt),
32715f757f3fSDimitry Andric        mnemonic, "\t$ZTt[$off2, mul vl], $Zt",
32725f757f3fSDimitry Andric        "", []>, Sched<[]> {
32735f757f3fSDimitry Andric  bits<5> Zt;
32745f757f3fSDimitry Andric  bits<2> off2;
32755f757f3fSDimitry Andric  let Inst{31-14} = 0b110000000100111100;
32765f757f3fSDimitry Andric  let Inst{13-12} = off2;
32775f757f3fSDimitry Andric  let Inst{11-5}  = opc;
32785f757f3fSDimitry Andric  let Inst{4-0}   = Zt;
32795f757f3fSDimitry Andric}
32805f757f3fSDimitry Andric
32815f757f3fSDimitry Andricmulticlass sme2_movt_zt_to_zt<string mnemonic, bits<7> opc> {
32825f757f3fSDimitry Andric  def NAME : sme2_movt_zt_to_zt<mnemonic, opc>;
32835f757f3fSDimitry Andric  def : InstAlias<mnemonic # "\t$ZTt, $Zt",
32845f757f3fSDimitry Andric                 (!cast<Instruction>(NAME) ZTR:$ZTt, 0, ZPRAny:$Zt), 1>;
32855f757f3fSDimitry Andric}
32865f757f3fSDimitry Andric
3287bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
3288bdd1243dSDimitry Andric// SME2 lookup table expand one register
3289bdd1243dSDimitry Andricclass sme2_luti_vector_index<bits<2> sz, bits<7> opc, RegisterOperand vector_ty,
3290bdd1243dSDimitry Andric                             AsmVectorIndexOpnd index_ty, string mnemonic>
3291bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zd),
3292bdd1243dSDimitry Andric        (ins ZTR:$ZTt, ZPRAny:$Zn, index_ty:$i),
3293bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $ZTt, $Zn$i",
3294bdd1243dSDimitry Andric        "", []>, Sched<[]> {
3295bdd1243dSDimitry Andric  bits<5> Zn;
3296bdd1243dSDimitry Andric  bits<5> Zd;
3297bdd1243dSDimitry Andric  let Inst{31-19} = 0b1100000011001;
3298bdd1243dSDimitry Andric  let Inst{18-14} = opc{6-2};
3299bdd1243dSDimitry Andric  let Inst{13-12} = sz;
3300bdd1243dSDimitry Andric  let Inst{11-10} = opc{1-0};
3301bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
3302bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
3303bdd1243dSDimitry Andric}
3304bdd1243dSDimitry Andric
3305bdd1243dSDimitry Andricclass sme2_luti2_vector_index<bits<2> sz, RegisterOperand vector_ty,
3306bdd1243dSDimitry Andric                              string mnemonic>
33075f757f3fSDimitry Andric    : sme2_luti_vector_index<sz, {1,?,?,?,?,0,0}, vector_ty, VectorIndexB32b_timm, mnemonic> {
3308bdd1243dSDimitry Andric  bits<4> i;
3309bdd1243dSDimitry Andric  let Inst{17-14} = i;
3310bdd1243dSDimitry Andric}
3311bdd1243dSDimitry Andric
33125f757f3fSDimitry Andricmulticlass sme2_luti2_vector_index<string mnemonic, SDPatternOperator intrinsic> {
3313bdd1243dSDimitry Andric  def _B : sme2_luti2_vector_index<0b00, ZPR8, mnemonic>;
3314bdd1243dSDimitry Andric  def _H : sme2_luti2_vector_index<0b01, ZPR16, mnemonic>;
3315bdd1243dSDimitry Andric  def _S : sme2_luti2_vector_index<0b10, ZPR32, mnemonic>;
33165f757f3fSDimitry Andric
33175f757f3fSDimitry Andric  def : Pat<(nxv16i8 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))),
33185f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _B) $zt, nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))>;
33195f757f3fSDimitry Andric  def : Pat<(nxv8i16 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))),
33205f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _H) $zt, nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))>;
33215f757f3fSDimitry Andric  def : Pat<(nxv4i32 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))),
33225f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _S) $zt, nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))>;
33235f757f3fSDimitry Andric  def : Pat<(nxv8f16 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))),
33245f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _H) $zt, nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))>;
33255f757f3fSDimitry Andric  def : Pat<(nxv8bf16 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))),
33265f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _H) $zt, nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))>;
33275f757f3fSDimitry Andric  def : Pat<(nxv4f32 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))),
33285f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _S) $zt, nxv16i8:$zn, (i32 VectorIndexB32b_timm:$imm))>;
3329bdd1243dSDimitry Andric}
3330bdd1243dSDimitry Andric
3331bdd1243dSDimitry Andricclass sme2_luti4_vector_index<bits<2> sz, RegisterOperand vector_ty,
3332bdd1243dSDimitry Andric                              string mnemonic>
33335f757f3fSDimitry Andric    : sme2_luti_vector_index<sz, {0,1,?,?,?,0,0}, vector_ty, VectorIndexH32b_timm, mnemonic> {
3334bdd1243dSDimitry Andric  bits<3> i;
3335bdd1243dSDimitry Andric  let Inst{16-14} = i;
3336bdd1243dSDimitry Andric}
3337bdd1243dSDimitry Andric
33385f757f3fSDimitry Andricmulticlass sme2_luti4_vector_index<string mnemonic, SDPatternOperator intrinsic> {
3339bdd1243dSDimitry Andric  def _B : sme2_luti4_vector_index<0b00, ZPR8, mnemonic>;
3340bdd1243dSDimitry Andric  def _H : sme2_luti4_vector_index<0b01, ZPR16, mnemonic>;
3341bdd1243dSDimitry Andric  def _S : sme2_luti4_vector_index<0b10, ZPR32, mnemonic>;
33425f757f3fSDimitry Andric
33435f757f3fSDimitry Andric  def : Pat<(nxv16i8 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))),
33445f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _B) $zt, nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))>;
33455f757f3fSDimitry Andric  def : Pat<(nxv8i16 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))),
33465f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _H) $zt, nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))>;
33475f757f3fSDimitry Andric  def : Pat<(nxv4i32 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))),
33485f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _S) $zt, nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))>;
33495f757f3fSDimitry Andric  def : Pat<(nxv8f16 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))),
33505f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _H) $zt, nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))>;
33515f757f3fSDimitry Andric  def : Pat<(nxv8bf16 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))),
33525f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _H) $zt, nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))>;
33535f757f3fSDimitry Andric  def : Pat<(nxv4f32 (intrinsic (imm_to_zt untyped:$zt), nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))),
33545f757f3fSDimitry Andric             (!cast<Instruction>(NAME # _S) $zt, nxv16i8:$zn, (i32 VectorIndexH32b_timm:$imm))>;
3355bdd1243dSDimitry Andric}
3356bdd1243dSDimitry Andric
3357bdd1243dSDimitry Andric// SME2 lookup table expand two contiguous registers
3358bdd1243dSDimitry Andricclass sme2_luti_vector_vg2_index<bits<2> sz, bits<6> opc, RegisterOperand vector_ty,
3359bdd1243dSDimitry Andric                                 AsmVectorIndexOpnd index_ty, string mnemonic>
3360bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zd),
3361bdd1243dSDimitry Andric        (ins ZTR:$ZTt, ZPRAny:$Zn, index_ty:$i),
3362bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $ZTt, $Zn$i",
3363bdd1243dSDimitry Andric        "", []>, Sched<[]> {
3364bdd1243dSDimitry Andric  bits<5> Zn;
3365bdd1243dSDimitry Andric  bits<4> Zd;
3366bdd1243dSDimitry Andric  let Inst{31-19} = 0b1100000010001;
3367bdd1243dSDimitry Andric  let Inst{18-15} = opc{5-2};
3368bdd1243dSDimitry Andric  let Inst{14}    = 0b1;
3369bdd1243dSDimitry Andric  let Inst{13-12} = sz;
3370bdd1243dSDimitry Andric  let Inst{11-10} = opc{1-0};
3371bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
3372bdd1243dSDimitry Andric  let Inst{4-1}   = Zd;
3373bdd1243dSDimitry Andric  let Inst{0}     = 0b0;
3374bdd1243dSDimitry Andric}
3375bdd1243dSDimitry Andric
3376bdd1243dSDimitry Andricclass sme2_luti2_vector_vg2_index<bits<2> sz, RegisterOperand vector_ty,
3377bdd1243dSDimitry Andric                                  string mnemonic>
3378bdd1243dSDimitry Andric    : sme2_luti_vector_vg2_index<sz, {1,?,?,?,0,0}, vector_ty, VectorIndexH, mnemonic> {
3379bdd1243dSDimitry Andric  bits<3> i;
3380bdd1243dSDimitry Andric  let Inst{17-15} = i;
3381bdd1243dSDimitry Andric}
3382bdd1243dSDimitry Andric
3383bdd1243dSDimitry Andricmulticlass sme2_luti2_vector_vg2_index<string mnemonic> {
3384bdd1243dSDimitry Andric  def _B : sme2_luti2_vector_vg2_index<0b00, ZZ_b_mul_r, mnemonic>;
3385bdd1243dSDimitry Andric  def _H : sme2_luti2_vector_vg2_index<0b01, ZZ_h_mul_r, mnemonic>;
3386bdd1243dSDimitry Andric  def _S : sme2_luti2_vector_vg2_index<0b10, ZZ_s_mul_r, mnemonic>;
3387bdd1243dSDimitry Andric}
3388bdd1243dSDimitry Andric
3389bdd1243dSDimitry Andricclass sme2_luti4_vector_vg2_index<bits<2> sz, RegisterOperand vector_ty,
3390bdd1243dSDimitry Andric                                 string mnemonic>
3391bdd1243dSDimitry Andric    : sme2_luti_vector_vg2_index<sz, {0,1,?,?,0,0}, vector_ty, VectorIndexS, mnemonic> {
3392bdd1243dSDimitry Andric  bits<2> i;
3393bdd1243dSDimitry Andric  let Inst{16-15} = i;
3394bdd1243dSDimitry Andric}
3395bdd1243dSDimitry Andric
3396bdd1243dSDimitry Andricmulticlass sme2_luti4_vector_vg2_index<string mnemonic> {
3397bdd1243dSDimitry Andric  def _B : sme2_luti4_vector_vg2_index<0b00, ZZ_b_mul_r, mnemonic>;
3398bdd1243dSDimitry Andric  def _H : sme2_luti4_vector_vg2_index<0b01, ZZ_h_mul_r, mnemonic>;
3399bdd1243dSDimitry Andric  def _S : sme2_luti4_vector_vg2_index<0b10, ZZ_s_mul_r, mnemonic>;
3400bdd1243dSDimitry Andric}
3401bdd1243dSDimitry Andric
3402bdd1243dSDimitry Andric// SME2 lookup table expand four contiguous registers
3403bdd1243dSDimitry Andricclass sme2_luti_vector_vg4_index<bits<2> sz, bits<5>opc, RegisterOperand vector_ty,
3404bdd1243dSDimitry Andric                                 AsmVectorIndexOpnd index_ty, string mnemonic>
3405bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zd),
3406bdd1243dSDimitry Andric        (ins ZTR:$ZTt, ZPRAny:$Zn, index_ty:$i),
3407bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $ZTt, $Zn$i",
3408bdd1243dSDimitry Andric        "", []>, Sched<[]> {
3409bdd1243dSDimitry Andric  bits<5> Zn;
3410bdd1243dSDimitry Andric  bits<3> Zd;
3411bdd1243dSDimitry Andric  let Inst{31-19} = 0b1100000010001;
3412bdd1243dSDimitry Andric  let Inst{18-16} = opc{4-2};
3413bdd1243dSDimitry Andric  let Inst{15-14} = 0b10;
3414bdd1243dSDimitry Andric  let Inst{13-12} = sz;
3415bdd1243dSDimitry Andric  let Inst{11-10} = opc{1-0};
3416bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
3417bdd1243dSDimitry Andric  let Inst{4-2}   = Zd;
3418bdd1243dSDimitry Andric  let Inst{1-0}   = 0b00;
3419bdd1243dSDimitry Andric}
3420bdd1243dSDimitry Andric
3421bdd1243dSDimitry Andricclass sme2_luti2_vector_vg4_index<bits<2> sz, RegisterOperand vector_ty,
3422bdd1243dSDimitry Andric                                  string mnemonic>
3423bdd1243dSDimitry Andric    : sme2_luti_vector_vg4_index<sz, {1,?,?,0,0}, vector_ty, VectorIndexS, mnemonic> {
3424bdd1243dSDimitry Andric  bits<2> i;
3425bdd1243dSDimitry Andric  let Inst{17-16} = i;
3426bdd1243dSDimitry Andric}
3427bdd1243dSDimitry Andric
3428bdd1243dSDimitry Andricmulticlass sme2_luti2_vector_vg4_index<string mnemonic> {
3429bdd1243dSDimitry Andric  def _B : sme2_luti2_vector_vg4_index<0b00, ZZZZ_b_mul_r, mnemonic>;
3430bdd1243dSDimitry Andric  def _H : sme2_luti2_vector_vg4_index<0b01, ZZZZ_h_mul_r, mnemonic>;
3431bdd1243dSDimitry Andric  def _S : sme2_luti2_vector_vg4_index<0b10, ZZZZ_s_mul_r, mnemonic>;
3432bdd1243dSDimitry Andric}
3433bdd1243dSDimitry Andric
3434bdd1243dSDimitry Andricclass sme2_luti4_vector_vg4_index<bits<2> sz, RegisterOperand vector_ty,
3435bdd1243dSDimitry Andric                                  string mnemonic>
3436bdd1243dSDimitry Andric    : sme2_luti_vector_vg4_index<sz, {0,1,?,0,0}, vector_ty, VectorIndexD, mnemonic> {
3437bdd1243dSDimitry Andric  bits<1> i;
3438bdd1243dSDimitry Andric  let Inst{16}    = i;
3439bdd1243dSDimitry Andric}
3440bdd1243dSDimitry Andric
3441bdd1243dSDimitry Andricmulticlass sme2_luti4_vector_vg4_index<string mnemonic> {
3442bdd1243dSDimitry Andric  def _H : sme2_luti4_vector_vg4_index<0b01, ZZZZ_h_mul_r, mnemonic>;
3443bdd1243dSDimitry Andric  def _S : sme2_luti4_vector_vg4_index<0b10, ZZZZ_s_mul_r, mnemonic>;
3444bdd1243dSDimitry Andric}
3445bdd1243dSDimitry Andric
3446bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
3447bdd1243dSDimitry Andric// SME2 MOV
3448bdd1243dSDimitry Andricclass sme2_mova_vec_to_tile_vg2_multi_base<bits<2> sz, bit v,
3449bdd1243dSDimitry Andric                                           RegisterOperand tile_ty,
3450bdd1243dSDimitry Andric                                           Operand index_ty,
3451bdd1243dSDimitry Andric                                           RegisterOperand vector_ty,
3452bdd1243dSDimitry Andric                                           string mnemonic>
3453bdd1243dSDimitry Andric   : I<(outs tile_ty:$ZAd),
3454bdd1243dSDimitry Andric       (ins tile_ty:$_ZAd, MatrixIndexGPR32Op12_15:$Rs, index_ty:$imm, vector_ty:$Zn),
3455bdd1243dSDimitry Andric       mnemonic, "\t$ZAd[$Rs, $imm], $Zn",
3456bdd1243dSDimitry Andric       "", []>, Sched<[]> {
3457bdd1243dSDimitry Andric  bits<2> Rs;
3458bdd1243dSDimitry Andric  bits<4> Zn;
3459bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000000;
3460bdd1243dSDimitry Andric  let Inst{23-22} = sz;
3461bdd1243dSDimitry Andric  let Inst{21-16} = 0b000100;
3462bdd1243dSDimitry Andric  let Inst{15}    = v;
3463bdd1243dSDimitry Andric  let Inst{14-13} = Rs;
3464bdd1243dSDimitry Andric  let Inst{12-10} = 0b000;
3465bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
3466bdd1243dSDimitry Andric  let Inst{5-3}   = 0b000;
3467bdd1243dSDimitry Andric
3468bdd1243dSDimitry Andric  let Constraints = "$ZAd = $_ZAd";
3469bdd1243dSDimitry Andric}
3470bdd1243dSDimitry Andric
3471bdd1243dSDimitry Andricmulticlass sme2_mova_vec_to_tile_or_array_aliases<int prefer, Instruction inst,
3472bdd1243dSDimitry Andric                                                  RegisterOperand tile_or_array_ty,
3473bdd1243dSDimitry Andric                                                  RegisterOperand  rv_ty,
3474bdd1243dSDimitry Andric                                                  Operand index_ty,
3475bdd1243dSDimitry Andric                                                  RegisterOperand vector_ty,
3476bdd1243dSDimitry Andric                                                  string mnemonic,
3477bdd1243dSDimitry Andric                                                  string vg_acronym=""> {
3478bdd1243dSDimitry Andric  def : InstAlias<mnemonic # "\t$ZAd[$Rs, $imm" # !if(!eq(vg_acronym, ""), "", ", " # vg_acronym) # "], $Zn",
3479bdd1243dSDimitry Andric                  (inst tile_or_array_ty:$ZAd, rv_ty:$Rs, index_ty:$imm, vector_ty:$Zn), prefer>;
3480bdd1243dSDimitry Andric
3481bdd1243dSDimitry Andric}
3482bdd1243dSDimitry Andric
3483bdd1243dSDimitry Andric// SME2 move vector to tile, two registers
348406c3fb27SDimitry Andricmulticlass sme2_mova_vec_to_tile_vg2_multi_base<bit v, string mnemonic, SDPatternOperator intrinsic> {
3485bdd1243dSDimitry Andric
3486bdd1243dSDimitry Andric  def _B : sme2_mova_vec_to_tile_vg2_multi_base<0b00, v,
3487bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
3488bdd1243dSDimitry Andric                                                       TileVectorOpH8),
3489bdd1243dSDimitry Andric                                                uimm3s2range,  ZZ_b_mul_r,
349006c3fb27SDimitry Andric                                                mnemonic>, SMEPseudo2Instr<NAME # _B, 1> {
3491bdd1243dSDimitry Andric    bits<3> imm;
3492bdd1243dSDimitry Andric    let Inst{2-0} = imm;
3493bdd1243dSDimitry Andric  }
3494bdd1243dSDimitry Andric
3495bdd1243dSDimitry Andric  def _H : sme2_mova_vec_to_tile_vg2_multi_base<0b01, v,
3496bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
3497bdd1243dSDimitry Andric                                                       TileVectorOpH16),
3498bdd1243dSDimitry Andric                                                uimm2s2range, ZZ_h_mul_r,
349906c3fb27SDimitry Andric                                                mnemonic>, SMEPseudo2Instr<NAME # _H, 1> {
3500bdd1243dSDimitry Andric    bits<1> ZAd;
3501bdd1243dSDimitry Andric    bits<2> imm;
3502bdd1243dSDimitry Andric    let Inst{2}   = ZAd;
3503bdd1243dSDimitry Andric    let Inst{1-0} = imm;
3504bdd1243dSDimitry Andric  }
3505bdd1243dSDimitry Andric
3506bdd1243dSDimitry Andric  def _S : sme2_mova_vec_to_tile_vg2_multi_base<0b10, v,
3507bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
3508bdd1243dSDimitry Andric                                                       TileVectorOpH32),
3509bdd1243dSDimitry Andric                                                 uimm1s2range, ZZ_s_mul_r,
351006c3fb27SDimitry Andric                                                 mnemonic>, SMEPseudo2Instr<NAME # _S, 1> {
3511bdd1243dSDimitry Andric    bits<2> ZAd;
3512bdd1243dSDimitry Andric    bits<1> imm;
3513bdd1243dSDimitry Andric    let Inst{2-1} = ZAd;
3514bdd1243dSDimitry Andric    let Inst{0}   = imm;
3515bdd1243dSDimitry Andric  }
3516bdd1243dSDimitry Andric
3517bdd1243dSDimitry Andric  def _D : sme2_mova_vec_to_tile_vg2_multi_base<0b11, v,
3518bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
3519bdd1243dSDimitry Andric                                                       TileVectorOpH64),
3520bdd1243dSDimitry Andric                                                uimm0s2range, ZZ_d_mul_r,
352106c3fb27SDimitry Andric                                                mnemonic>, SMEPseudo2Instr<NAME # _D, 1> {
3522bdd1243dSDimitry Andric    bits<3> ZAd;
3523bdd1243dSDimitry Andric    let Inst{2-0} = ZAd;
3524bdd1243dSDimitry Andric   }
3525bdd1243dSDimitry Andric
352606c3fb27SDimitry Andric  def NAME # _B_PSEUDO : sme2_move_to_tile_pseudo<NAME # _B, sme_elm_idx0_0, uimm3s2range, ZZ_b_mul_r, SMEMatrixTileB>;
352706c3fb27SDimitry Andric  def NAME # _H_PSEUDO : sme2_move_to_tile_pseudo<NAME # _H, sme_elm_idx0_1, uimm2s2range, ZZ_h_mul_r, SMEMatrixTileH>;
352806c3fb27SDimitry Andric  def NAME # _S_PSEUDO : sme2_move_to_tile_pseudo<NAME # _S, sme_elm_idx0_3, uimm1s2range, ZZ_s_mul_r, SMEMatrixTileS>;
352906c3fb27SDimitry Andric  def NAME # _D_PSEUDO : sme2_move_to_tile_pseudo<NAME # _D, sme_elm_idx0_7, uimm0s2range, ZZ_d_mul_r, SMEMatrixTileD>;
353006c3fb27SDimitry Andric
353106c3fb27SDimitry Andric  def : SME2_Tile_VG2_Multi_Pat<NAME # _B, intrinsic, sme_elm_idx0_0, nxv16i8, uimm3s2range, tileslicerange3s2>;
353206c3fb27SDimitry Andric  def : SME2_Tile_VG2_Multi_Pat<NAME # _H, intrinsic, sme_elm_idx0_1, nxv8i16, uimm2s2range, tileslicerange2s2>;
353306c3fb27SDimitry Andric  def : SME2_Tile_VG2_Multi_Pat<NAME # _H, intrinsic, sme_elm_idx0_1, nxv8f16, uimm2s2range, tileslicerange2s2>;
353406c3fb27SDimitry Andric  def : SME2_Tile_VG2_Multi_Pat<NAME # _H, intrinsic, sme_elm_idx0_1, nxv8bf16, uimm2s2range, tileslicerange2s2>;
353506c3fb27SDimitry Andric  def : SME2_Tile_VG2_Multi_Pat<NAME # _S, intrinsic, sme_elm_idx0_3, nxv4i32, uimm1s2range, tileslicerange1s2>;
353606c3fb27SDimitry Andric  def : SME2_Tile_VG2_Multi_Pat<NAME # _S, intrinsic, sme_elm_idx0_3, nxv4f32, uimm1s2range, tileslicerange1s2>;
353706c3fb27SDimitry Andric  def : SME2_Tile_VG2_Multi_Pat<NAME # _D, intrinsic, sme_elm_idx0_7, nxv2i64, uimm0s2range, tileslicerange0s2>;
353806c3fb27SDimitry Andric  def : SME2_Tile_VG2_Multi_Pat<NAME # _D, intrinsic, sme_elm_idx0_7, nxv2f64, uimm0s2range, tileslicerange0s2>;
353906c3fb27SDimitry Andric
3540bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME # _B),
3541bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
3542bdd1243dSDimitry Andric                                                       TileVectorOpH8),
3543bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3544bdd1243dSDimitry Andric                                                uimm3s2range,  ZZ_b_mul_r,
3545bdd1243dSDimitry Andric                                                "mov">;
3546bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME # _H),
3547bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
3548bdd1243dSDimitry Andric                                                       TileVectorOpH16),
3549bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3550bdd1243dSDimitry Andric                                                uimm2s2range,  ZZ_h_mul_r,
3551bdd1243dSDimitry Andric                                                "mov">;
3552bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME # _S),
3553bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
3554bdd1243dSDimitry Andric                                                       TileVectorOpH32),
3555bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3556bdd1243dSDimitry Andric                                                uimm1s2range,  ZZ_s_mul_r,
3557bdd1243dSDimitry Andric                                                "mov">;
3558bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME # _D),
3559bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
3560bdd1243dSDimitry Andric                                                       TileVectorOpH64),
3561bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3562bdd1243dSDimitry Andric                                                uimm0s2range,  ZZ_d_mul_r,
3563bdd1243dSDimitry Andric                                                "mov">;
3564bdd1243dSDimitry Andric
3565bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _B),
3566bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
3567bdd1243dSDimitry Andric                                                       TileVectorOpH8),
3568bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3569bdd1243dSDimitry Andric                                                uimm3s2range,  ZZ_b_mul_r,
3570bdd1243dSDimitry Andric                                                "mova">;
3571bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _H),
3572bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
3573bdd1243dSDimitry Andric                                                       TileVectorOpH16),
3574bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3575bdd1243dSDimitry Andric                                                uimm2s2range,  ZZ_h_mul_r,
3576bdd1243dSDimitry Andric                                                "mova">;
3577bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _S),
3578bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
3579bdd1243dSDimitry Andric                                                       TileVectorOpH32),
3580bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3581bdd1243dSDimitry Andric                                                uimm1s2range,  ZZ_s_mul_r,
3582bdd1243dSDimitry Andric                                                "mova">;
3583bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _D),
3584bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
3585bdd1243dSDimitry Andric                                                       TileVectorOpH64),
3586bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3587bdd1243dSDimitry Andric                                                uimm0s2range,  ZZ_d_mul_r,
3588bdd1243dSDimitry Andric                                                "mova">;
3589bdd1243dSDimitry Andric
3590bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _B),
3591bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
3592bdd1243dSDimitry Andric                                                       TileVectorOpH8),
3593bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3594bdd1243dSDimitry Andric                                                uimm3s2range,  ZZ_b_mul_r,
3595bdd1243dSDimitry Andric                                                "mova">;
3596bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _H),
3597bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
3598bdd1243dSDimitry Andric                                                       TileVectorOpH16),
3599bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3600bdd1243dSDimitry Andric                                                uimm2s2range,  ZZ_h_mul_r,
3601bdd1243dSDimitry Andric                                                "mova">;
3602bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _S),
3603bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
3604bdd1243dSDimitry Andric                                                       TileVectorOpH32),
3605bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3606bdd1243dSDimitry Andric                                                uimm1s2range,  ZZ_s_mul_r,
3607bdd1243dSDimitry Andric                                                "mova">;
3608bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _D),
3609bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
3610bdd1243dSDimitry Andric                                                       TileVectorOpH64),
3611bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3612bdd1243dSDimitry Andric                                                uimm0s2range,  ZZ_d_mul_r,
3613bdd1243dSDimitry Andric                                                "mova">;
3614bdd1243dSDimitry Andric}
3615bdd1243dSDimitry Andric
361606c3fb27SDimitry Andricmulticlass sme2_mova_vec_to_tile_vg2_multi<string mnemonic,
361706c3fb27SDimitry Andric                                           SDPatternOperator int_h, SDPatternOperator int_v>{
361806c3fb27SDimitry Andric defm _H : sme2_mova_vec_to_tile_vg2_multi_base<0b0, mnemonic, int_h>;
361906c3fb27SDimitry Andric defm _V : sme2_mova_vec_to_tile_vg2_multi_base<0b1, mnemonic, int_v>;
3620bdd1243dSDimitry Andric}
3621bdd1243dSDimitry Andric
3622bdd1243dSDimitry Andricclass sme2_mova_vec_to_tile_vg4_multi_base<bits<2> sz, bit v, bits<3> op,
3623bdd1243dSDimitry Andric                                           RegisterOperand tile_ty,
3624bdd1243dSDimitry Andric                                           Operand index_ty,
3625bdd1243dSDimitry Andric                                           RegisterOperand vector_ty,
3626bdd1243dSDimitry Andric                                           string mnemonic>
3627bdd1243dSDimitry Andric   : I<(outs tile_ty:$ZAd),
3628bdd1243dSDimitry Andric       (ins tile_ty:$_ZAd, MatrixIndexGPR32Op12_15:$Rs, index_ty:$imm,
3629bdd1243dSDimitry Andric            vector_ty:$Zn),
3630bdd1243dSDimitry Andric       mnemonic,
3631bdd1243dSDimitry Andric       "\t$ZAd[$Rs, $imm], $Zn",
3632bdd1243dSDimitry Andric       "", []>, Sched<[]> {
3633bdd1243dSDimitry Andric  bits<2> Rs;
3634bdd1243dSDimitry Andric  bits<3> Zn;
3635bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000000;
3636bdd1243dSDimitry Andric  let Inst{23-22} = sz;
3637bdd1243dSDimitry Andric  let Inst{21-16} = 0b000100;
3638bdd1243dSDimitry Andric  let Inst{15}    = v;
3639bdd1243dSDimitry Andric  let Inst{14-13} = Rs;
3640bdd1243dSDimitry Andric  let Inst{12-10} = 0b001;
3641bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
3642bdd1243dSDimitry Andric  let Inst{6-3}   = 0b0000;
3643bdd1243dSDimitry Andric  let Inst{2-0}   = op;
3644bdd1243dSDimitry Andric  let Constraints = "$ZAd = $_ZAd";
3645bdd1243dSDimitry Andric}
3646bdd1243dSDimitry Andric
3647bdd1243dSDimitry Andric// SME2 move vector to tile, four registers
364806c3fb27SDimitry Andricmulticlass sme2_mova_vec_to_tile_vg4_multi_base<bit v, string mnemonic, SDPatternOperator intrinsic> {
3649bdd1243dSDimitry Andric
3650bdd1243dSDimitry Andric  def _B : sme2_mova_vec_to_tile_vg4_multi_base<0b00, v, {0,?,?},
3651bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
3652bdd1243dSDimitry Andric                                                       TileVectorOpH8),
3653bdd1243dSDimitry Andric                                                uimm2s4range, ZZZZ_b_mul_r,
365406c3fb27SDimitry Andric                                                mnemonic>, SMEPseudo2Instr<NAME # _B, 1> {
3655bdd1243dSDimitry Andric    bits<2> imm;
3656bdd1243dSDimitry Andric    let Inst{1-0} = imm;
3657bdd1243dSDimitry Andric  }
3658bdd1243dSDimitry Andric
3659bdd1243dSDimitry Andric  def _H : sme2_mova_vec_to_tile_vg4_multi_base<0b01, v, {0,?,?},
3660bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
3661bdd1243dSDimitry Andric                                                       TileVectorOpH16),
3662bdd1243dSDimitry Andric                                                uimm1s4range, ZZZZ_h_mul_r,
366306c3fb27SDimitry Andric                                                mnemonic>, SMEPseudo2Instr<NAME # _H, 1> {
3664bdd1243dSDimitry Andric    bits<1> ZAd;
3665bdd1243dSDimitry Andric    bits<1> imm;
3666bdd1243dSDimitry Andric    let Inst{1}   = ZAd;
3667bdd1243dSDimitry Andric    let Inst{0}   = imm;
3668bdd1243dSDimitry Andric  }
3669bdd1243dSDimitry Andric
3670bdd1243dSDimitry Andric  def _S : sme2_mova_vec_to_tile_vg4_multi_base<0b10, v, {0,?,?},
3671bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
3672bdd1243dSDimitry Andric                                                       TileVectorOpH32),
3673bdd1243dSDimitry Andric                                                 uimm0s4range, ZZZZ_s_mul_r,
367406c3fb27SDimitry Andric                                                 mnemonic>, SMEPseudo2Instr<NAME # _S, 1> {
3675bdd1243dSDimitry Andric    bits<2> ZAd;
3676bdd1243dSDimitry Andric    let Inst{1-0} = ZAd;
3677bdd1243dSDimitry Andric  }
3678bdd1243dSDimitry Andric
3679bdd1243dSDimitry Andric  def _D : sme2_mova_vec_to_tile_vg4_multi_base<0b11, v, {?,?,?},
3680bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
3681bdd1243dSDimitry Andric                                                       TileVectorOpH64),
3682bdd1243dSDimitry Andric                                                uimm0s4range, ZZZZ_d_mul_r,
368306c3fb27SDimitry Andric                                                mnemonic>, SMEPseudo2Instr<NAME # _D, 1> {
3684bdd1243dSDimitry Andric    bits<3> ZAd;
3685bdd1243dSDimitry Andric    let Inst{2-0} = ZAd;
3686bdd1243dSDimitry Andric  }
3687bdd1243dSDimitry Andric
368806c3fb27SDimitry Andric  def NAME # _B_PSEUDO : sme2_move_to_tile_pseudo<NAME # _B, sme_elm_idx0_0, uimm2s4range, ZZZZ_b_mul_r, SMEMatrixTileB>;
368906c3fb27SDimitry Andric  def NAME # _H_PSEUDO : sme2_move_to_tile_pseudo<NAME # _H, sme_elm_idx0_1, uimm1s4range, ZZZZ_h_mul_r, SMEMatrixTileH>;
369006c3fb27SDimitry Andric  def NAME # _S_PSEUDO : sme2_move_to_tile_pseudo<NAME # _S, sme_elm_idx0_3, uimm0s4range, ZZZZ_s_mul_r, SMEMatrixTileS>;
369106c3fb27SDimitry Andric  def NAME # _D_PSEUDO : sme2_move_to_tile_pseudo<NAME # _D, sme_elm_idx0_7, uimm0s4range, ZZZZ_d_mul_r, SMEMatrixTileD>;
369206c3fb27SDimitry Andric
369306c3fb27SDimitry Andric  def : SME2_Tile_VG4_Multi_Pat<NAME # _B, intrinsic, sme_elm_idx0_0, nxv16i8, uimm2s4range, tileslicerange2s4>;
369406c3fb27SDimitry Andric  def : SME2_Tile_VG4_Multi_Pat<NAME # _H, intrinsic, sme_elm_idx0_1, nxv8i16, uimm1s4range, tileslicerange1s4>;
369506c3fb27SDimitry Andric  def : SME2_Tile_VG4_Multi_Pat<NAME # _H, intrinsic, sme_elm_idx0_1, nxv8f16, uimm1s4range, tileslicerange1s4>;
369606c3fb27SDimitry Andric  def : SME2_Tile_VG4_Multi_Pat<NAME # _H, intrinsic, sme_elm_idx0_1, nxv8bf16, uimm1s4range, tileslicerange1s4>;
369706c3fb27SDimitry Andric  def : SME2_Tile_VG4_Multi_Pat<NAME # _S, intrinsic, sme_elm_idx0_3, nxv4i32, uimm0s4range, tileslicerange0s4>;
369806c3fb27SDimitry Andric  def : SME2_Tile_VG4_Multi_Pat<NAME # _S, intrinsic, sme_elm_idx0_3, nxv4f32, uimm0s4range, tileslicerange0s4>;
369906c3fb27SDimitry Andric  def : SME2_Tile_VG4_Multi_Pat<NAME # _D, intrinsic, sme_elm_idx0_7, nxv2i64, uimm0s4range, tileslicerange0s4>;
370006c3fb27SDimitry Andric  def : SME2_Tile_VG4_Multi_Pat<NAME # _D, intrinsic, sme_elm_idx0_7, nxv2f64, uimm0s4range, tileslicerange0s4>;
370106c3fb27SDimitry Andric
3702bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME # _B),
3703bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
3704bdd1243dSDimitry Andric                                                       TileVectorOpH8),
3705bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3706bdd1243dSDimitry Andric                                                uimm2s4range, ZZZZ_b_mul_r,
3707bdd1243dSDimitry Andric                                                "mov">;
3708bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME # _H),
3709bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
3710bdd1243dSDimitry Andric                                                       TileVectorOpH16),
3711bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3712bdd1243dSDimitry Andric                                                uimm1s4range, ZZZZ_h_mul_r,
3713bdd1243dSDimitry Andric                                                "mov">;
3714bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME # _S),
3715bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
3716bdd1243dSDimitry Andric                                                       TileVectorOpH32),
3717bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3718bdd1243dSDimitry Andric                                                uimm0s4range, ZZZZ_s_mul_r,
3719bdd1243dSDimitry Andric                                                "mov">;
3720bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME # _D),
3721bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
3722bdd1243dSDimitry Andric                                                       TileVectorOpH64),
3723bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3724bdd1243dSDimitry Andric                                                uimm0s4range, ZZZZ_d_mul_r,
3725bdd1243dSDimitry Andric                                                "mov">;
3726bdd1243dSDimitry Andric
3727bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _B),
3728bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
3729bdd1243dSDimitry Andric                                                       TileVectorOpH8),
3730bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3731bdd1243dSDimitry Andric                                                uimm2s4range, ZZZZ_b_mul_r,
3732bdd1243dSDimitry Andric                                                "mova">;
3733bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _H),
3734bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
3735bdd1243dSDimitry Andric                                                       TileVectorOpH16),
3736bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3737bdd1243dSDimitry Andric                                                uimm1s4range, ZZZZ_h_mul_r,
3738bdd1243dSDimitry Andric                                                "mova">;
3739bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _S),
3740bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
3741bdd1243dSDimitry Andric                                                       TileVectorOpH32),
3742bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3743bdd1243dSDimitry Andric                                                uimm0s4range, ZZZZ_s_mul_r,
3744bdd1243dSDimitry Andric                                                "mova">;
3745bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME # _D),
3746bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
3747bdd1243dSDimitry Andric                                                       TileVectorOpH64),
3748bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
3749bdd1243dSDimitry Andric                                                uimm0s4range, ZZZZ_d_mul_r,
3750bdd1243dSDimitry Andric                                                "mova">;
3751bdd1243dSDimitry Andric
3752bdd1243dSDimitry Andric}
3753bdd1243dSDimitry Andric
375406c3fb27SDimitry Andricmulticlass sme2_mova_vec_to_tile_vg4_multi<string mnemonic,
375506c3fb27SDimitry Andric                                           SDPatternOperator int_h, SDPatternOperator int_v>{
375606c3fb27SDimitry Andric defm _H : sme2_mova_vec_to_tile_vg4_multi_base<0b0, mnemonic, int_h>;
375706c3fb27SDimitry Andric defm _V : sme2_mova_vec_to_tile_vg4_multi_base<0b1, mnemonic, int_v>;
3758bdd1243dSDimitry Andric}
3759bdd1243dSDimitry Andric
3760bdd1243dSDimitry Andric// SME Move into Array
3761bdd1243dSDimitry Andricclass sme2_mova_vec_to_array_vg24_multi< bits<5> op, RegisterOperand array_ty,
3762bdd1243dSDimitry Andric                                        RegisterOperand vector_ty,
3763bdd1243dSDimitry Andric                                        string mnemonic,
3764bdd1243dSDimitry Andric                                        string vg_acronym="">
3765bdd1243dSDimitry Andric   : I<(outs array_ty:$ZAd),
3766bdd1243dSDimitry Andric       (ins array_ty:$_ZAd, MatrixIndexGPR32Op8_11:$Rs, sme_elm_idx0_7:$imm,
3767bdd1243dSDimitry Andric            vector_ty:$Zn),
3768bdd1243dSDimitry Andric       mnemonic, "\t$ZAd[$Rs, $imm, " # vg_acronym # "], $Zn",
3769bdd1243dSDimitry Andric       "", []>, Sched<[]> {
3770bdd1243dSDimitry Andric  bits<2> Rs;
3771bdd1243dSDimitry Andric  bits<3> imm;
3772bdd1243dSDimitry Andric  let Inst{31-15} = 0b11000000000001000;
3773bdd1243dSDimitry Andric  let Inst{14-13} = Rs;
3774bdd1243dSDimitry Andric  let Inst{12-11} = 0b01;
3775bdd1243dSDimitry Andric  let Inst{10-6}  = op;
3776bdd1243dSDimitry Andric  let Inst{5-3}   = 0b000;
3777bdd1243dSDimitry Andric  let Inst{2-0}   = imm;
3778bdd1243dSDimitry Andric
3779bdd1243dSDimitry Andric  let Constraints = "$ZAd = $_ZAd";
3780bdd1243dSDimitry Andric}
3781bdd1243dSDimitry Andric
3782bdd1243dSDimitry Andric// MOVA (vector to array, two registers)
378306c3fb27SDimitry Andricmulticlass sme2_mova_vec_to_array_vg2_multi<string mnemonic, SDPatternOperator intrinsic> {
3784bdd1243dSDimitry Andric  def NAME : sme2_mova_vec_to_array_vg24_multi<{0,?,?,?,?}, MatrixOp64,
378506c3fb27SDimitry Andric                                               ZZ_d_mul_r, mnemonic, "vgx2">, SMEPseudo2Instr<NAME, 1> {
3786bdd1243dSDimitry Andric   bits<4> Zn;
3787bdd1243dSDimitry Andric   let Inst{9-6} = Zn;
3788bdd1243dSDimitry Andric  }
3789bdd1243dSDimitry Andric
379006c3fb27SDimitry Andric  def NAME # _PSEUDO : sme2_move_to_za_pseudo<NAME, sme_elm_idx0_7, ZZ_d_mul_r, SMEMatrixArray>;
379106c3fb27SDimitry Andric
3792cb14a3feSDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, nxv16i8,  sme_elm_idx0_7, tileslice16>;
3793cb14a3feSDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, nxv8i16,  sme_elm_idx0_7, tileslice16>;
3794cb14a3feSDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, nxv8f16,  sme_elm_idx0_7, tileslice16>;
3795cb14a3feSDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, nxv8bf16, sme_elm_idx0_7, tileslice16>;
3796cb14a3feSDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, nxv4i32,  sme_elm_idx0_7, tileslice16>;
3797cb14a3feSDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, nxv4f32,  sme_elm_idx0_7, tileslice16>;
379806c3fb27SDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, nxv2i64,  sme_elm_idx0_7, tileslice16>;
379906c3fb27SDimitry Andric  def : SME2_ZA_VG1x2_Multi_Pat<NAME, intrinsic, nxv2f64,  sme_elm_idx0_7, tileslice16>;
380006c3fb27SDimitry Andric
3801bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3802bdd1243dSDimitry Andric                                                MatrixOp8,
3803bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3804bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_b_mul_r,
3805bdd1243dSDimitry Andric                                                "mova">;
3806bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3807bdd1243dSDimitry Andric                                                MatrixOp16,
3808bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3809bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_h_mul_r,
3810bdd1243dSDimitry Andric                                                "mova">;
3811bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3812bdd1243dSDimitry Andric                                                MatrixOp32,
3813bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3814bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_s_mul_r,
3815bdd1243dSDimitry Andric                                                "mova">;
3816bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3817bdd1243dSDimitry Andric                                                MatrixOp64,
3818bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3819bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_d_mul_r,
3820bdd1243dSDimitry Andric                                                "mova">;
3821bdd1243dSDimitry Andric
3822bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3823bdd1243dSDimitry Andric                                                MatrixOp8,
3824bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3825bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_b_mul_r,
3826bdd1243dSDimitry Andric                                                "mova", "vgx2">;
3827bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3828bdd1243dSDimitry Andric                                                MatrixOp16,
3829bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3830bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_h_mul_r,
3831bdd1243dSDimitry Andric                                                "mova", "vgx2">;
3832bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3833bdd1243dSDimitry Andric                                                MatrixOp32,
3834bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3835bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_s_mul_r,
3836bdd1243dSDimitry Andric                                                "mova", "vgx2">;
3837bdd1243dSDimitry Andric
3838bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3839bdd1243dSDimitry Andric                                                MatrixOp8,
3840bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3841bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_b_mul_r,
3842bdd1243dSDimitry Andric                                                "mov">;
3843bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3844bdd1243dSDimitry Andric                                                MatrixOp16,
3845bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3846bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_h_mul_r,
3847bdd1243dSDimitry Andric                                                "mov">;
3848bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3849bdd1243dSDimitry Andric                                                MatrixOp32,
3850bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3851bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_s_mul_r,
3852bdd1243dSDimitry Andric                                                "mov">;
3853bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3854bdd1243dSDimitry Andric                                                MatrixOp64,
3855bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3856bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_d_mul_r,
3857bdd1243dSDimitry Andric                                                "mov">;
3858bdd1243dSDimitry Andric
3859bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3860bdd1243dSDimitry Andric                                                MatrixOp8,
3861bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3862bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_b_mul_r,
3863bdd1243dSDimitry Andric                                                "mov", "vgx2">;
3864bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3865bdd1243dSDimitry Andric                                                MatrixOp16,
3866bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3867bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_h_mul_r,
3868bdd1243dSDimitry Andric                                                "mov", "vgx2">;
3869bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3870bdd1243dSDimitry Andric                                                MatrixOp32,
3871bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3872bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_s_mul_r,
3873bdd1243dSDimitry Andric                                                "mov", "vgx2">;
3874bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME),
3875bdd1243dSDimitry Andric                                                MatrixOp64,
3876bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3877bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZ_d_mul_r,
3878bdd1243dSDimitry Andric                                                "mov", "vgx2">;
3879bdd1243dSDimitry Andric}
3880bdd1243dSDimitry Andric
3881bdd1243dSDimitry Andric// MOVA (vector to array, four registers)
388206c3fb27SDimitry Andricmulticlass sme2_mova_vec_to_array_vg4_multi<string mnemonic, SDPatternOperator intrinsic> {
3883bdd1243dSDimitry Andric  def NAME : sme2_mova_vec_to_array_vg24_multi<{1,?,?,?,0}, MatrixOp64,
388406c3fb27SDimitry Andric                                               ZZZZ_d_mul_r, mnemonic, "vgx4">, SMEPseudo2Instr<NAME, 1> {
3885bdd1243dSDimitry Andric    bits<3> Zn;
3886bdd1243dSDimitry Andric    let Inst{9-7} = Zn;
3887bdd1243dSDimitry Andric  }
3888bdd1243dSDimitry Andric
388906c3fb27SDimitry Andric  def NAME # _PSEUDO : sme2_move_to_za_pseudo<NAME, sme_elm_idx0_7, ZZZZ_d_mul_r, SMEMatrixArray>;
389006c3fb27SDimitry Andric
3891cb14a3feSDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, nxv16i8,  sme_elm_idx0_7, tileslice16>;
3892cb14a3feSDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, nxv8i16,  sme_elm_idx0_7, tileslice16>;
3893cb14a3feSDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, nxv8f16,  sme_elm_idx0_7, tileslice16>;
3894cb14a3feSDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, nxv8bf16, sme_elm_idx0_7, tileslice16>;
3895cb14a3feSDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, nxv4i32,  sme_elm_idx0_7, tileslice16>;
3896cb14a3feSDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, nxv4f32,  sme_elm_idx0_7, tileslice16>;
389706c3fb27SDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, nxv2i64,  sme_elm_idx0_7, tileslice16>;
389806c3fb27SDimitry Andric  def : SME2_ZA_VG1x4_Multi_Pat<NAME, intrinsic, nxv2f64,  sme_elm_idx0_7, tileslice16>;
389906c3fb27SDimitry Andric
3900bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3901bdd1243dSDimitry Andric                                                MatrixOp8,
3902bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3903bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_b_mul_r,
3904bdd1243dSDimitry Andric                                                "mova">;
3905bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3906bdd1243dSDimitry Andric                                                MatrixOp16,
3907bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3908bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_h_mul_r,
3909bdd1243dSDimitry Andric                                                "mova">;
3910bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3911bdd1243dSDimitry Andric                                                MatrixOp32,
3912bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3913bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_s_mul_r,
3914bdd1243dSDimitry Andric                                                "mova">;
3915bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3916bdd1243dSDimitry Andric                                                MatrixOp64,
3917bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3918bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_d_mul_r,
3919bdd1243dSDimitry Andric                                                "mova">;
3920bdd1243dSDimitry Andric
3921bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3922bdd1243dSDimitry Andric                                                MatrixOp8,
3923bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3924bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_b_mul_r,
3925bdd1243dSDimitry Andric                                                "mova", "vgx4">;
3926bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3927bdd1243dSDimitry Andric                                                MatrixOp16,
3928bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3929bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_h_mul_r,
3930bdd1243dSDimitry Andric                                                "mova", "vgx4">;
3931bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3932bdd1243dSDimitry Andric                                                MatrixOp32,
3933bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3934bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_s_mul_r,
3935bdd1243dSDimitry Andric                                                "mova", "vgx4">;
3936bdd1243dSDimitry Andric
3937bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3938bdd1243dSDimitry Andric                                                MatrixOp8,
3939bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3940bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_b_mul_r,
3941bdd1243dSDimitry Andric                                                "mov">;
3942bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3943bdd1243dSDimitry Andric                                                MatrixOp16,
3944bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3945bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_h_mul_r,
3946bdd1243dSDimitry Andric                                                "mov">;
3947bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3948bdd1243dSDimitry Andric                                                MatrixOp32,
3949bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3950bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_s_mul_r,
3951bdd1243dSDimitry Andric                                                "mov">;
3952bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3953bdd1243dSDimitry Andric                                                MatrixOp64,
3954bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3955bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_d_mul_r,
3956bdd1243dSDimitry Andric                                                "mov">;
3957bdd1243dSDimitry Andric
3958bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3959bdd1243dSDimitry Andric                                                MatrixOp8,
3960bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3961bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_b_mul_r,
3962bdd1243dSDimitry Andric                                                "mov", "vgx4">;
3963bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3964bdd1243dSDimitry Andric                                                MatrixOp16,
3965bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3966bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_h_mul_r,
3967bdd1243dSDimitry Andric                                                "mov", "vgx4">;
3968bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<0, !cast<Instruction>(NAME),
3969bdd1243dSDimitry Andric                                                MatrixOp32,
3970bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3971bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_s_mul_r,
3972bdd1243dSDimitry Andric                                                "mov", "vgx4">;
3973bdd1243dSDimitry Andric  defm : sme2_mova_vec_to_tile_or_array_aliases<1, !cast<Instruction>(NAME),
3974bdd1243dSDimitry Andric                                                MatrixOp64,
3975bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
3976bdd1243dSDimitry Andric                                                sme_elm_idx0_7, ZZZZ_d_mul_r,
3977bdd1243dSDimitry Andric                                                "mov", "vgx4">;
3978bdd1243dSDimitry Andric
3979bdd1243dSDimitry Andric}
3980bdd1243dSDimitry Andric
3981bdd1243dSDimitry Andricclass sme2_mova_tile_to_vec_vg2_multi_base<bits<2> sz, bit v, bits<3> op,
3982bdd1243dSDimitry Andric                                           RegisterOperand vector_ty,
3983bdd1243dSDimitry Andric                                           RegisterOperand tile_ty,
3984bdd1243dSDimitry Andric                                           Operand index_ty,
3985bdd1243dSDimitry Andric                                           string mnemonic>
3986bdd1243dSDimitry Andric   : I<!if(op{1}, (outs vector_ty:$Zd, tile_ty:$_ZAn), (outs vector_ty:$Zd)),
3987bdd1243dSDimitry Andric       (ins tile_ty:$ZAn, MatrixIndexGPR32Op12_15:$Rs, index_ty:$imm),
3988bdd1243dSDimitry Andric       mnemonic,
3989bdd1243dSDimitry Andric       "\t$Zd, $ZAn[$Rs, $imm]",
3990bdd1243dSDimitry Andric       "", []>, Sched<[]> {
3991bdd1243dSDimitry Andric  bits<4> Zd;
3992bdd1243dSDimitry Andric  bits<2> Rs;
3993bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000000;
3994bdd1243dSDimitry Andric  let Inst{23-22} = sz;
3995bdd1243dSDimitry Andric  let Inst{21-16} = 0b000110;
3996bdd1243dSDimitry Andric  let Inst{15}    = v;
3997bdd1243dSDimitry Andric  let Inst{14-13} = Rs;
3998bdd1243dSDimitry Andric  let Inst{12-11} = 0b00;
3999bdd1243dSDimitry Andric  let Inst{10-8}  = op;
4000bdd1243dSDimitry Andric  let Inst{4-1}   = Zd;
4001bdd1243dSDimitry Andric  let Inst{0}     = 0b0;
4002bdd1243dSDimitry Andric
4003bdd1243dSDimitry Andric  let Constraints = !if(op{1}, "$ZAn = $_ZAn", "");
4004bdd1243dSDimitry Andric}
4005bdd1243dSDimitry Andric
4006bdd1243dSDimitry Andricmulticlass sme2_mova_tile_or_array_to_vec_aliases<int op, Instruction inst,
4007bdd1243dSDimitry Andric                                                  RegisterOperand vector_ty,
4008bdd1243dSDimitry Andric                                                  RegisterOperand tile_or_array_ty,
4009bdd1243dSDimitry Andric                                                  RegisterOperand rv_ty,
4010bdd1243dSDimitry Andric                                                  Operand index_ty,
4011bdd1243dSDimitry Andric                                                  string mnemonic,
4012bdd1243dSDimitry Andric                                                  string vg_acronym=""> {
4013bdd1243dSDimitry Andricdef : InstAlias<mnemonic # "\t$Zd, $ZAn[$Rs, $imm" # !if(!eq(vg_acronym, ""), "", ", " # vg_acronym) # "]",
4014bdd1243dSDimitry Andric                  (inst vector_ty:$Zd, tile_or_array_ty:$ZAn, rv_ty:$Rs, index_ty:$imm), op>;
4015bdd1243dSDimitry Andric
4016bdd1243dSDimitry Andric}
4017bdd1243dSDimitry Andric
4018bdd1243dSDimitry Andricmulticlass sme2_mova_tile_to_vec_vg2_multi_inst<bit v, bits<3> opc, string mnemonic> {
4019bdd1243dSDimitry Andric
4020bdd1243dSDimitry Andric  def _B : sme2_mova_tile_to_vec_vg2_multi_base<0b00, v, opc, ZZ_b_mul_r,
4021bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
4022bdd1243dSDimitry Andric                                                       TileVectorOpH8),
4023*0fca6ea1SDimitry Andric                                                 uimm3s2range, mnemonic>, SMEPseudo2Instr<NAME # _B, 1> {
4024bdd1243dSDimitry Andric    bits<3> imm;
4025bdd1243dSDimitry Andric    let Inst{7-5} = imm;
4026bdd1243dSDimitry Andric  }
4027bdd1243dSDimitry Andric
4028bdd1243dSDimitry Andric  def _H : sme2_mova_tile_to_vec_vg2_multi_base<0b01, v, opc, ZZ_h_mul_r,
4029bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
4030bdd1243dSDimitry Andric                                                       TileVectorOpH16),
4031*0fca6ea1SDimitry Andric                                                 uimm2s2range, mnemonic>, SMEPseudo2Instr<NAME # _H, 1> {
4032bdd1243dSDimitry Andric    bits<1> ZAn;
4033bdd1243dSDimitry Andric    bits<2> imm;
4034bdd1243dSDimitry Andric    let Inst{7}   = ZAn;
4035bdd1243dSDimitry Andric    let Inst{6-5} = imm;
4036bdd1243dSDimitry Andric  }
4037bdd1243dSDimitry Andric
4038bdd1243dSDimitry Andric  def _S : sme2_mova_tile_to_vec_vg2_multi_base<0b10, v, opc, ZZ_s_mul_r,
4039bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
4040bdd1243dSDimitry Andric                                                       TileVectorOpH32),
4041*0fca6ea1SDimitry Andric                                                 uimm1s2range, mnemonic>, SMEPseudo2Instr<NAME # _S, 1> {
4042bdd1243dSDimitry Andric    bits<2> ZAn;
4043bdd1243dSDimitry Andric    bits<1> imm;
4044bdd1243dSDimitry Andric    let Inst{7-6} = ZAn;
4045bdd1243dSDimitry Andric    let Inst{5}   = imm;
4046bdd1243dSDimitry Andric  }
4047bdd1243dSDimitry Andric
4048bdd1243dSDimitry Andric  def _D : sme2_mova_tile_to_vec_vg2_multi_base<0b11, v, opc, ZZ_d_mul_r,
4049bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
4050bdd1243dSDimitry Andric                                                       TileVectorOpH64),
4051*0fca6ea1SDimitry Andric                                                uimm0s2range, mnemonic>, SMEPseudo2Instr<NAME # _D, 1> {
4052bdd1243dSDimitry Andric    bits<3> ZAn;
4053bdd1243dSDimitry Andric    let Inst{7-5} = ZAn;
4054bdd1243dSDimitry Andric  }
4055bdd1243dSDimitry Andric
4056bdd1243dSDimitry Andric  if !eq(mnemonic, "mova") then {
4057bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1,!cast<Instruction>(NAME # _B),
4058bdd1243dSDimitry Andric                                                ZZ_b_mul_r,
4059bdd1243dSDimitry Andric                                               !if(v, TileVectorOpV8,
4060bdd1243dSDimitry Andric                                                      TileVectorOpH8),
4061bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4062bdd1243dSDimitry Andric                                                uimm3s2range, "mov">;
4063bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1,!cast<Instruction>(NAME # _H),
4064bdd1243dSDimitry Andric                                                ZZ_h_mul_r,
4065bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
4066bdd1243dSDimitry Andric                                                       TileVectorOpH16),
4067bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4068bdd1243dSDimitry Andric                                                uimm2s2range, "mov">;
4069bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1, !cast<Instruction>(NAME # _S),
4070bdd1243dSDimitry Andric                                                ZZ_s_mul_r,
4071bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
4072bdd1243dSDimitry Andric                                                       TileVectorOpH32),
4073bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4074bdd1243dSDimitry Andric                                                uimm1s2range, "mov">;
4075bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1, !cast<Instruction>(NAME # _D),
4076bdd1243dSDimitry Andric                                                ZZ_d_mul_r,
4077bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
4078bdd1243dSDimitry Andric                                                       TileVectorOpH64),
4079bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4080bdd1243dSDimitry Andric                                                uimm0s2range, "mov">;
4081bdd1243dSDimitry Andric  }
4082bdd1243dSDimitry Andric
4083bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0,!cast<Instruction>(NAME # _B),
4084bdd1243dSDimitry Andric                                                ZZ_b_mul_r,
4085bdd1243dSDimitry Andric                                               !if(v, TileVectorOpV8,
4086bdd1243dSDimitry Andric                                                      TileVectorOpH8),
4087bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4088bdd1243dSDimitry Andric                                                uimm3s2range, mnemonic>;
4089bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0,!cast<Instruction>(NAME # _H),
4090bdd1243dSDimitry Andric                                                ZZ_h_mul_r,
4091bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
4092bdd1243dSDimitry Andric                                                       TileVectorOpH16),
4093bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4094bdd1243dSDimitry Andric                                                uimm2s2range, mnemonic>;
4095bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME # _S),
4096bdd1243dSDimitry Andric                                                ZZ_s_mul_r,
4097bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
4098bdd1243dSDimitry Andric                                                       TileVectorOpH32),
4099bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4100bdd1243dSDimitry Andric                                                uimm1s2range, mnemonic>;
4101bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME # _D),
4102bdd1243dSDimitry Andric                                                ZZ_d_mul_r,
4103bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
4104bdd1243dSDimitry Andric                                                       TileVectorOpH64),
4105bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4106bdd1243dSDimitry Andric                                                uimm0s2range, mnemonic>;
4107bdd1243dSDimitry Andric
4108bdd1243dSDimitry Andric}
4109bdd1243dSDimitry Andric
4110bdd1243dSDimitry Andric// SME2 move tile to vector, two registers
4111bdd1243dSDimitry Andricmulticlass sme2_mova_tile_to_vec_vg2_multi<string mnemonic>{
4112bdd1243dSDimitry Andric defm _H : sme2_mova_tile_to_vec_vg2_multi_inst<0b0, 0b000, mnemonic>;
4113bdd1243dSDimitry Andric defm _V : sme2_mova_tile_to_vec_vg2_multi_inst<0b1, 0b000, mnemonic>;
4114bdd1243dSDimitry Andric}
4115bdd1243dSDimitry Andric
4116*0fca6ea1SDimitry Andric
4117bdd1243dSDimitry Andric// SME2p1 move tile to vector and zero tile, two registers
4118bdd1243dSDimitry Andricmulticlass sme2p1_movaz_tile_to_vec_vg2<string mnemonic>{
4119bdd1243dSDimitry Andric defm _H : sme2_mova_tile_to_vec_vg2_multi_inst<0b0, 0b010, mnemonic>;
4120bdd1243dSDimitry Andric defm _V : sme2_mova_tile_to_vec_vg2_multi_inst<0b1, 0b010, mnemonic>;
4121*0fca6ea1SDimitry Andric
4122*0fca6ea1SDimitry Andric
4123*0fca6ea1SDimitry Andric def NAME # _H_B_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_B, sme_elm_idx0_0, uimm3s2range, ZZ_b_mul_r, SMEMatrixTileB>;
4124*0fca6ea1SDimitry Andric def NAME # _H_H_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_H, sme_elm_idx0_1, uimm2s2range, ZZ_h_mul_r, SMEMatrixTileH>;
4125*0fca6ea1SDimitry Andric def NAME # _H_S_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_S, sme_elm_idx0_3, uimm1s2range, ZZ_s_mul_r, SMEMatrixTileS>;
4126*0fca6ea1SDimitry Andric def NAME # _H_D_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_D, sme_elm_idx0_7, uimm0s2range, ZZ_d_mul_r, SMEMatrixTileD>;
4127*0fca6ea1SDimitry Andric
4128*0fca6ea1SDimitry Andric def NAME # _V_B_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_B, sme_elm_idx0_0, uimm3s2range, ZZ_b_mul_r, SMEMatrixTileB>;
4129*0fca6ea1SDimitry Andric def NAME # _V_H_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_H, sme_elm_idx0_1, uimm2s2range, ZZ_h_mul_r, SMEMatrixTileH>;
4130*0fca6ea1SDimitry Andric def NAME # _V_S_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_S, sme_elm_idx0_3, uimm1s2range, ZZ_s_mul_r, SMEMatrixTileS>;
4131*0fca6ea1SDimitry Andric def NAME # _V_D_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_D, sme_elm_idx0_7, uimm0s2range, ZZ_d_mul_r, SMEMatrixTileD>;
4132bdd1243dSDimitry Andric}
4133bdd1243dSDimitry Andric
4134bdd1243dSDimitry Andricclass sme2_mova_tile_to_vec_vg4_multi_base<bits<2> sz, bit v, bits<6> op,
4135bdd1243dSDimitry Andric                                           RegisterOperand vector_ty,
4136bdd1243dSDimitry Andric                                           RegisterOperand tile_ty,
4137bdd1243dSDimitry Andric                                           Operand index_ty,
4138bdd1243dSDimitry Andric                                           string mnemonic>
4139bdd1243dSDimitry Andric   : I<!if(op{4}, (outs vector_ty:$Zd, tile_ty:$_ZAn), (outs vector_ty:$Zd)),
4140bdd1243dSDimitry Andric       (ins tile_ty:$ZAn, MatrixIndexGPR32Op12_15:$Rs, index_ty:$imm),
4141bdd1243dSDimitry Andric       mnemonic,
4142bdd1243dSDimitry Andric       "\t$Zd, $ZAn[$Rs, $imm]",
4143bdd1243dSDimitry Andric       "", []>, Sched<[]> {
4144bdd1243dSDimitry Andric  bits<3> Zd;
4145bdd1243dSDimitry Andric  bits<2> Rs;
4146bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000000;
4147bdd1243dSDimitry Andric  let Inst{23-22} = sz;
4148bdd1243dSDimitry Andric  let Inst{21-16} = 0b000110;
4149bdd1243dSDimitry Andric  let Inst{15}    = v;
4150bdd1243dSDimitry Andric  let Inst{14-13} = Rs;
4151bdd1243dSDimitry Andric  let Inst{12-11} = 0b00;
4152bdd1243dSDimitry Andric  let Inst{10-5}  = op{5-0};
4153bdd1243dSDimitry Andric  let Inst{4-2}   = Zd;
4154bdd1243dSDimitry Andric  let Inst{1-0}   = 0b00;
4155bdd1243dSDimitry Andric
4156bdd1243dSDimitry Andric  let Constraints = !if(op{4}, "$ZAn = $_ZAn", "");
4157bdd1243dSDimitry Andric}
4158bdd1243dSDimitry Andric
4159bdd1243dSDimitry Andricmulticlass sme2_mova_tile_to_vec_vg4_multi_base<bit v, bits<3> opc, string mnemonic> {
4160bdd1243dSDimitry Andric
4161bdd1243dSDimitry Andric  def _B : sme2_mova_tile_to_vec_vg4_multi_base<0b00, v, {opc,0,?,?},
4162bdd1243dSDimitry Andric                                                ZZZZ_b_mul_r,
4163bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
4164bdd1243dSDimitry Andric                                                       TileVectorOpH8),
4165*0fca6ea1SDimitry Andric                                                uimm2s4range, mnemonic>, SMEPseudo2Instr<NAME # _B, 1> {
4166bdd1243dSDimitry Andric    bits<2> imm;
4167bdd1243dSDimitry Andric    let Inst{6-5} = imm;
4168bdd1243dSDimitry Andric  }
4169bdd1243dSDimitry Andric
4170bdd1243dSDimitry Andric  def _H : sme2_mova_tile_to_vec_vg4_multi_base<0b01, v, {opc,0,?,?},
4171bdd1243dSDimitry Andric                                                ZZZZ_h_mul_r,
4172bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
4173bdd1243dSDimitry Andric                                                       TileVectorOpH16),
4174*0fca6ea1SDimitry Andric                                                uimm1s4range, mnemonic>, SMEPseudo2Instr<NAME # _H, 1> {
4175bdd1243dSDimitry Andric    bits<1> ZAn;
4176bdd1243dSDimitry Andric    bits<1> imm;
4177bdd1243dSDimitry Andric    let Inst{6}   = ZAn;
4178bdd1243dSDimitry Andric    let Inst{5}   = imm;
4179bdd1243dSDimitry Andric  }
4180bdd1243dSDimitry Andric
4181bdd1243dSDimitry Andric  def _S : sme2_mova_tile_to_vec_vg4_multi_base<0b10, v, {opc,0,?,?},
4182bdd1243dSDimitry Andric                                                ZZZZ_s_mul_r,
4183bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
4184bdd1243dSDimitry Andric                                                       TileVectorOpH32),
4185*0fca6ea1SDimitry Andric                                                 uimm0s4range, mnemonic>, SMEPseudo2Instr<NAME # _S, 1> {
4186bdd1243dSDimitry Andric    bits<2> ZAn;
4187bdd1243dSDimitry Andric    let Inst{6-5} = ZAn;
4188bdd1243dSDimitry Andric  }
4189bdd1243dSDimitry Andric
4190bdd1243dSDimitry Andric  def _D : sme2_mova_tile_to_vec_vg4_multi_base<0b11, v, {opc,?,?,?},
4191bdd1243dSDimitry Andric                                                ZZZZ_d_mul_r,
4192bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
4193bdd1243dSDimitry Andric                                                       TileVectorOpH64),
4194*0fca6ea1SDimitry Andric                                                uimm0s4range, mnemonic>, SMEPseudo2Instr<NAME # _D, 1> {
4195bdd1243dSDimitry Andric    bits<3> ZAn;
4196bdd1243dSDimitry Andric    let Inst{7-5} = ZAn;
4197bdd1243dSDimitry Andric  }
4198bdd1243dSDimitry Andric
4199bdd1243dSDimitry Andric  if !eq(mnemonic, "mova") then {
4200bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1, !cast<Instruction>(NAME # _B),
4201bdd1243dSDimitry Andric                                                ZZZZ_b_mul_r,
4202bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
4203bdd1243dSDimitry Andric                                                      TileVectorOpH8),
4204bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4205bdd1243dSDimitry Andric                                                uimm2s4range, "mov">;
4206bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1, !cast<Instruction>(NAME # _H),
4207bdd1243dSDimitry Andric                                                ZZZZ_h_mul_r,
4208bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
4209bdd1243dSDimitry Andric                                                       TileVectorOpH16),
4210bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4211bdd1243dSDimitry Andric                                                uimm1s4range, "mov">;
4212bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1, !cast<Instruction>(NAME # _S),
4213bdd1243dSDimitry Andric                                                ZZZZ_s_mul_r,
4214bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
4215bdd1243dSDimitry Andric                                                      TileVectorOpH32),
4216bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4217bdd1243dSDimitry Andric                                                uimm0s4range, "mov">;
4218bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1, !cast<Instruction>(NAME # _D),
4219bdd1243dSDimitry Andric                                                ZZZZ_d_mul_r,
4220bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
4221bdd1243dSDimitry Andric                                                       TileVectorOpH64),
4222bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4223bdd1243dSDimitry Andric                                                uimm0s4range, "mov">;
4224bdd1243dSDimitry Andric  }
4225bdd1243dSDimitry Andric
4226bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME # _B),
4227bdd1243dSDimitry Andric                                                ZZZZ_b_mul_r,
4228bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV8,
4229bdd1243dSDimitry Andric                                                       TileVectorOpH8),
4230bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4231bdd1243dSDimitry Andric                                                uimm2s4range, mnemonic>;
4232bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME # _H),
4233bdd1243dSDimitry Andric                                                ZZZZ_h_mul_r,
4234bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV16,
4235bdd1243dSDimitry Andric                                                       TileVectorOpH16),
4236bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4237bdd1243dSDimitry Andric                                                uimm1s4range, mnemonic>;
4238bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME # _S),
4239bdd1243dSDimitry Andric                                                ZZZZ_s_mul_r,
4240bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV32,
4241bdd1243dSDimitry Andric                                                      TileVectorOpH32),
4242bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4243bdd1243dSDimitry Andric                                                uimm0s4range, mnemonic>;
4244bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME # _D),
4245bdd1243dSDimitry Andric                                                ZZZZ_d_mul_r,
4246bdd1243dSDimitry Andric                                                !if(v, TileVectorOpV64,
4247bdd1243dSDimitry Andric                                                       TileVectorOpH64),
4248bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op12_15,
4249bdd1243dSDimitry Andric                                                uimm0s4range, mnemonic>;
4250bdd1243dSDimitry Andric
4251bdd1243dSDimitry Andric}
4252bdd1243dSDimitry Andric
4253bdd1243dSDimitry Andric// SME2 move tile to vector, four registers
4254bdd1243dSDimitry Andricmulticlass sme2_mova_tile_to_vec_vg4_multi<string mnemonic>{
4255bdd1243dSDimitry Andric defm _H : sme2_mova_tile_to_vec_vg4_multi_base<0b0, 0b100, mnemonic>;
4256bdd1243dSDimitry Andric defm _V : sme2_mova_tile_to_vec_vg4_multi_base<0b1, 0b100, mnemonic>;
4257bdd1243dSDimitry Andric}
4258bdd1243dSDimitry Andric
4259bdd1243dSDimitry Andric// SME2p1 move tile to vector and zero tile, four registers
4260bdd1243dSDimitry Andricmulticlass sme2p1_movaz_tile_to_vec_vg4<string mnemonic>{
4261bdd1243dSDimitry Andric defm _H : sme2_mova_tile_to_vec_vg4_multi_base<0b0, 0b110, mnemonic>;
4262bdd1243dSDimitry Andric defm _V : sme2_mova_tile_to_vec_vg4_multi_base<0b1, 0b110, mnemonic>;
4263*0fca6ea1SDimitry Andric
4264*0fca6ea1SDimitry Andric def NAME # _H_B_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_B, sme_elm_idx0_0, uimm2s4range, ZZZZ_b_mul_r, SMEMatrixTileB>;
4265*0fca6ea1SDimitry Andric def NAME # _H_H_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_H, sme_elm_idx0_1, uimm1s4range, ZZZZ_h_mul_r, SMEMatrixTileH>;
4266*0fca6ea1SDimitry Andric def NAME # _H_S_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_S, sme_elm_idx0_3, uimm0s4range, ZZZZ_s_mul_r, SMEMatrixTileS>;
4267*0fca6ea1SDimitry Andric def NAME # _H_D_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_D, sme_elm_idx0_7, uimm0s4range, ZZZZ_d_mul_r, SMEMatrixTileD>;
4268*0fca6ea1SDimitry Andric
4269*0fca6ea1SDimitry Andric def NAME # _V_B_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_B, sme_elm_idx0_0, uimm2s4range, ZZZZ_b_mul_r, SMEMatrixTileB>;
4270*0fca6ea1SDimitry Andric def NAME # _V_H_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_H, sme_elm_idx0_1, uimm1s4range, ZZZZ_h_mul_r, SMEMatrixTileH>;
4271*0fca6ea1SDimitry Andric def NAME # _V_S_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_S, sme_elm_idx0_3, uimm0s4range, ZZZZ_s_mul_r, SMEMatrixTileS>;
4272*0fca6ea1SDimitry Andric def NAME # _V_D_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_D, sme_elm_idx0_7, uimm0s4range, ZZZZ_d_mul_r, SMEMatrixTileD>;
4273bdd1243dSDimitry Andric}
4274bdd1243dSDimitry Andric
4275bdd1243dSDimitry Andric
4276bdd1243dSDimitry Andricclass sme2_mova_array_to_vec_vg24_multi<bits<4>op, RegisterOperand vector_ty,
4277bdd1243dSDimitry Andric                                        RegisterOperand array_ty,
4278bdd1243dSDimitry Andric                                        string mnemonic, string vg_acronym>
4279bdd1243dSDimitry Andric   : I<!if(op{2}, (outs vector_ty:$Zd, array_ty:$_ZAn), (outs vector_ty:$Zd)),
4280bdd1243dSDimitry Andric       (ins array_ty:$ZAn, MatrixIndexGPR32Op8_11:$Rs, sme_elm_idx0_7:$imm),
4281bdd1243dSDimitry Andric       mnemonic,
4282bdd1243dSDimitry Andric       "\t$Zd, $ZAn[$Rs, $imm, " # vg_acronym # "]",
4283bdd1243dSDimitry Andric       "", []>, Sched<[]> {
4284bdd1243dSDimitry Andric  bits<2> Rs;
4285bdd1243dSDimitry Andric  bits<3> imm;
4286bdd1243dSDimitry Andric  let Inst{31-15} = 0b11000000000001100;
4287bdd1243dSDimitry Andric  let Inst{14-13} = Rs;
4288bdd1243dSDimitry Andric  let Inst{12-11} = 0b01;
4289bdd1243dSDimitry Andric  let Inst{10-8}  = op{3-1};
4290bdd1243dSDimitry Andric  let Inst{7-5}   = imm;
4291bdd1243dSDimitry Andric  let Inst{1}     = op{0};
4292bdd1243dSDimitry Andric  let Inst{0}     = 0b0;
4293bdd1243dSDimitry Andric  let Constraints = !if(op{2}, "$ZAn = $_ZAn", "");
4294bdd1243dSDimitry Andric}
4295bdd1243dSDimitry Andric
4296bdd1243dSDimitry Andric// move array to vector, two registers.
4297bdd1243dSDimitry Andricmulticlass sme2_mova_array_to_vec_vg2_multi<bits<3> opc, string mnemonic> {
4298bdd1243dSDimitry Andric  def NAME : sme2_mova_array_to_vec_vg24_multi<{opc,?}, ZZ_d_mul_r, MatrixOp64,
4299*0fca6ea1SDimitry Andric                                               mnemonic, "vgx2">, SMEPseudo2Instr<NAME, 1>{
4300bdd1243dSDimitry Andric    bits<4> Zd;
4301bdd1243dSDimitry Andric    let Inst{4-1} = Zd;
4302bdd1243dSDimitry Andric  }
4303bdd1243dSDimitry Andric
4304bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4305bdd1243dSDimitry Andric                                                ZZ_b_mul_r, MatrixOp8,
4306bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4307bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic>;
4308bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4309bdd1243dSDimitry Andric                                                ZZ_h_mul_r, MatrixOp16,
4310bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4311bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic>;
4312bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4313bdd1243dSDimitry Andric                                                ZZ_s_mul_r, MatrixOp32,
4314bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4315bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic>;
4316bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4317bdd1243dSDimitry Andric                                                ZZ_d_mul_r,  MatrixOp64,
4318bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4319bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic>;
4320bdd1243dSDimitry Andric
4321bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4322bdd1243dSDimitry Andric                                                ZZ_b_mul_r, MatrixOp8,
4323bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4324bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic, "vgx2">;
4325bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4326bdd1243dSDimitry Andric                                                ZZ_h_mul_r, MatrixOp16,
4327bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4328bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic, "vgx2">;
4329bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4330bdd1243dSDimitry Andric                                                ZZ_s_mul_r, MatrixOp32,
4331bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4332bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic, "vgx2">;
4333bdd1243dSDimitry Andric
4334bdd1243dSDimitry Andric  if !eq(mnemonic, "mova") then {
4335bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4336bdd1243dSDimitry Andric                                                ZZ_b_mul_r, MatrixOp8,
4337bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4338bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov">;
4339bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4340bdd1243dSDimitry Andric                                                ZZ_h_mul_r, MatrixOp16,
4341bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4342bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov">;
4343bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4344bdd1243dSDimitry Andric                                                ZZ_s_mul_r, MatrixOp32,
4345bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4346bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov">;
4347bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4348bdd1243dSDimitry Andric                                                ZZ_d_mul_r,  MatrixOp64,
4349bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4350bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov">;
4351bdd1243dSDimitry Andric
4352bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4353bdd1243dSDimitry Andric                                                ZZ_b_mul_r, MatrixOp8,
4354bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4355bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov", "vgx2">;
4356bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4357bdd1243dSDimitry Andric                                                ZZ_h_mul_r, MatrixOp16,
4358bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4359bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov", "vgx2">;
4360bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4361bdd1243dSDimitry Andric                                                ZZ_s_mul_r, MatrixOp32,
4362bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4363bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov", "vgx2">;
4364bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1, !cast<Instruction>(NAME),
4365bdd1243dSDimitry Andric                                                ZZ_d_mul_r,  MatrixOp64,
4366bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4367bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov", "vgx2">;
4368bdd1243dSDimitry Andric  }
4369bdd1243dSDimitry Andric}
4370bdd1243dSDimitry Andric
4371*0fca6ea1SDimitry Andricmulticlass sme2_movaz_array_to_vec_vg2_multi<string mnemonic> {
4372*0fca6ea1SDimitry Andric  defm NAME : sme2_mova_array_to_vec_vg2_multi<0b010, mnemonic>;
4373*0fca6ea1SDimitry Andric  def NAME # _PSEUDO : sme2_movaz_array_to_tile_pseudo<NAME, sme_elm_idx0_7, ZZ_d_mul_r, SMEMatrixArray>;
4374*0fca6ea1SDimitry Andric}
4375*0fca6ea1SDimitry Andric
4376bdd1243dSDimitry Andric// move array to vector, four registers
4377bdd1243dSDimitry Andricmulticlass sme2_mova_array_to_vec_vg4_multi<bits<4> opc, string mnemonic> {
4378bdd1243dSDimitry Andric  def NAME : sme2_mova_array_to_vec_vg24_multi<opc, ZZZZ_d_mul_r, MatrixOp64,
4379*0fca6ea1SDimitry Andric                                               mnemonic, "vgx4">, SMEPseudo2Instr<NAME, 1> {
4380bdd1243dSDimitry Andric    bits<3> Zd;
4381bdd1243dSDimitry Andric    let Inst{4-2} = Zd;
4382bdd1243dSDimitry Andric  }
4383bdd1243dSDimitry Andric
4384bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4385bdd1243dSDimitry Andric                                                ZZZZ_b_mul_r, MatrixOp8,
4386bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4387bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic>;
4388bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4389bdd1243dSDimitry Andric                                                ZZZZ_h_mul_r, MatrixOp16,
4390bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4391bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic>;
4392bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4393bdd1243dSDimitry Andric                                                ZZZZ_s_mul_r, MatrixOp32,
4394bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4395bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic>;
4396bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4397bdd1243dSDimitry Andric                                                ZZZZ_d_mul_r, MatrixOp64,
4398bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4399bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic>;
4400bdd1243dSDimitry Andric
4401bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4402bdd1243dSDimitry Andric                                                ZZZZ_b_mul_r, MatrixOp8,
4403bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4404bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic, "vgx4">;
4405bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4406bdd1243dSDimitry Andric                                                ZZZZ_h_mul_r, MatrixOp16,
4407bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4408bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic, "vgx4">;
4409bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4410bdd1243dSDimitry Andric                                                ZZZZ_s_mul_r, MatrixOp32,
4411bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4412bdd1243dSDimitry Andric                                                sme_elm_idx0_7, mnemonic, "vgx4">;
4413bdd1243dSDimitry Andric
4414bdd1243dSDimitry Andric  if !eq(mnemonic, "mova") then {
4415bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4416bdd1243dSDimitry Andric                                                ZZZZ_b_mul_r, MatrixOp8,
4417bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4418bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov">;
4419bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4420bdd1243dSDimitry Andric                                                ZZZZ_h_mul_r, MatrixOp16,
4421bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4422bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov">;
4423bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4424bdd1243dSDimitry Andric                                                ZZZZ_s_mul_r, MatrixOp32,
4425bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4426bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov">;
4427bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4428bdd1243dSDimitry Andric                                                ZZZZ_d_mul_r, MatrixOp64,
4429bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4430bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov">;
4431bdd1243dSDimitry Andric
4432bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4433bdd1243dSDimitry Andric                                                ZZZZ_b_mul_r, MatrixOp8,
4434bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4435bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov", "vgx4">;
4436bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4437bdd1243dSDimitry Andric                                                ZZZZ_h_mul_r, MatrixOp16,
4438bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4439bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov", "vgx4">;
4440bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<0, !cast<Instruction>(NAME),
4441bdd1243dSDimitry Andric                                                ZZZZ_s_mul_r, MatrixOp32,
4442bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4443bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov", "vgx4">;
4444bdd1243dSDimitry Andric  defm : sme2_mova_tile_or_array_to_vec_aliases<1, !cast<Instruction>(NAME),
4445bdd1243dSDimitry Andric                                                ZZZZ_d_mul_r, MatrixOp64,
4446bdd1243dSDimitry Andric                                                MatrixIndexGPR32Op8_11,
4447bdd1243dSDimitry Andric                                                sme_elm_idx0_7, "mov", "vgx4">;
4448bdd1243dSDimitry Andric  }
4449bdd1243dSDimitry Andric}
4450bdd1243dSDimitry Andric
4451*0fca6ea1SDimitry Andricmulticlass sme2_movaz_array_to_vec_vg4_multi<string mnemonic> {
4452*0fca6ea1SDimitry Andric  defm NAME : sme2_mova_array_to_vec_vg4_multi<0b1100, mnemonic>;
4453*0fca6ea1SDimitry Andric  def NAME # _PSEUDO : sme2_movaz_array_to_tile_pseudo<NAME, sme_elm_idx0_7, ZZZZ_d_mul_r, SMEMatrixArray>;
4454*0fca6ea1SDimitry Andric}
4455*0fca6ea1SDimitry Andric
4456bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
4457bdd1243dSDimitry Andric// SME2 multi-vec saturating shift right narrow
4458bdd1243dSDimitry Andricclass sme2_sat_shift_vector_vg2<string mnemonic, bit op, bit u>
445906c3fb27SDimitry Andric    : I<(outs ZPR16:$Zd), (ins ZZ_s_mul_r:$Zn, tvecshiftR16:$imm4),
4460bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn, $imm4",
4461bdd1243dSDimitry Andric        "", []>, Sched<[]> {
4462bdd1243dSDimitry Andric  bits<4> imm4;
4463bdd1243dSDimitry Andric  bits<4> Zn;
4464bdd1243dSDimitry Andric  bits<5> Zd;
4465bdd1243dSDimitry Andric  let Inst{31-21} = 0b11000001111;
4466bdd1243dSDimitry Andric  let Inst{20}    = op;
4467bdd1243dSDimitry Andric  let Inst{19-16} = imm4;
4468bdd1243dSDimitry Andric  let Inst{15-10} = 0b110101;
4469bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
4470bdd1243dSDimitry Andric  let Inst{5}     = u;
4471bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
4472bdd1243dSDimitry Andric}
4473bdd1243dSDimitry Andric
447406c3fb27SDimitry Andricmulticlass sme2_sat_shift_vector_vg2<string mnemonic, bit op, bit u, SDPatternOperator intrinsic> {
4475bdd1243dSDimitry Andric  def _H : sme2_sat_shift_vector_vg2<mnemonic, op, u>;
447606c3fb27SDimitry Andric
447706c3fb27SDimitry Andric  def : SME2_Sat_Shift_VG2_Pat<NAME # _H, intrinsic, nxv8i16, nxv4i32, tvecshiftR16>;
4478bdd1243dSDimitry Andric}
4479bdd1243dSDimitry Andric
4480bdd1243dSDimitry Andricclass sme2_sat_shift_vector_vg4<bits<2> sz, bits<3> op, ZPRRegOp zpr_ty,
4481bdd1243dSDimitry Andric                                RegisterOperand vector_ty, Operand imm_ty,
4482bdd1243dSDimitry Andric                                string mnemonic>
4483bdd1243dSDimitry Andric    : I<(outs zpr_ty:$Zd), (ins vector_ty:$Zn, imm_ty:$imm),
4484bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $Zn, $imm",
4485bdd1243dSDimitry Andric        "", []>, Sched<[]> {
4486bdd1243dSDimitry Andric  bits<3> Zn;
4487bdd1243dSDimitry Andric  bits<5> Zd;
4488bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
4489bdd1243dSDimitry Andric  let Inst{23-22} = sz;
4490bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
4491bdd1243dSDimitry Andric  //  Inst{20-16} = imm5;
4492bdd1243dSDimitry Andric  let Inst{15-11} = 0b11011;
4493bdd1243dSDimitry Andric  let Inst{10}    = op{2};
4494bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
4495bdd1243dSDimitry Andric  let Inst{6-5}   = op{1-0};
4496bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
4497bdd1243dSDimitry Andric}
4498bdd1243dSDimitry Andric
449906c3fb27SDimitry Andricmulticlass sme2_sat_shift_vector_vg4<string mnemonic, bits<3> op, SDPatternOperator intrinsic> {
450006c3fb27SDimitry Andric  def _B : sme2_sat_shift_vector_vg4<{0,1}, op, ZPR8, ZZZZ_s_mul_r, tvecshiftR32,
4501bdd1243dSDimitry Andric                                     mnemonic>{
4502bdd1243dSDimitry Andric    bits<5> imm;
4503bdd1243dSDimitry Andric    let Inst{20-16} = imm;
4504bdd1243dSDimitry Andric  }
450506c3fb27SDimitry Andric  def _H : sme2_sat_shift_vector_vg4<{1,?}, op, ZPR16, ZZZZ_d_mul_r, tvecshiftR64,
4506bdd1243dSDimitry Andric                                      mnemonic> {
4507bdd1243dSDimitry Andric    bits<6> imm;
4508bdd1243dSDimitry Andric    let Inst{22}    = imm{5};
4509bdd1243dSDimitry Andric    let Inst{20-16} = imm{4-0};
4510bdd1243dSDimitry Andric  }
451106c3fb27SDimitry Andric
451206c3fb27SDimitry Andric  def : SME2_Sat_Shift_VG4_Pat<NAME # _B, intrinsic, nxv16i8, nxv4i32, tvecshiftR32>;
451306c3fb27SDimitry Andric  def : SME2_Sat_Shift_VG4_Pat<NAME # _H, intrinsic, nxv8i16, nxv2i64, tvecshiftR64>;
4514bdd1243dSDimitry Andric}
4515bdd1243dSDimitry Andric
4516bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
4517bdd1243dSDimitry Andric// SME2 Multi-vector - SVE Select
4518bdd1243dSDimitry Andricclass sme2_sel_vector_vg24<bits<2> sz, bits<4> op, RegisterOperand vector_ty,
4519bdd1243dSDimitry Andric                           string mnemonic>
4520bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zd),
4521bdd1243dSDimitry Andric        (ins PNRAny_p8to15:$PNg, vector_ty:$Zn, vector_ty:$Zm),
4522bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $PNg, $Zn, $Zm",
4523bdd1243dSDimitry Andric        "", []>, Sched<[]> {
4524bdd1243dSDimitry Andric  bits<3> PNg;
4525bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000001;
4526bdd1243dSDimitry Andric  let Inst{23-22} = sz;
4527bdd1243dSDimitry Andric  let Inst{21}    = 0b1;
4528bdd1243dSDimitry Andric  let Inst{17-16} = op{3-2};
4529bdd1243dSDimitry Andric  let Inst{15-13} = 0b100;
4530bdd1243dSDimitry Andric  let Inst{12-10} = PNg;
4531bdd1243dSDimitry Andric  let Inst{6}     = op{1};
4532bdd1243dSDimitry Andric  let Inst{5}     = 0b0;
4533bdd1243dSDimitry Andric  let Inst{1}     = op{0};
4534bdd1243dSDimitry Andric  let Inst{0}     = 0b0;
4535bdd1243dSDimitry Andric}
4536bdd1243dSDimitry Andric
4537bdd1243dSDimitry Andricclass sme2_sel_vector_vg2<bits<2> sz, RegisterOperand vector_ty,
4538bdd1243dSDimitry Andric                          string mnemonic>
4539bdd1243dSDimitry Andric     : sme2_sel_vector_vg24<sz, {?,0,?,?}, vector_ty, mnemonic> {
4540bdd1243dSDimitry Andric  bits<4> Zm;
4541bdd1243dSDimitry Andric  bits<4> Zn;
4542bdd1243dSDimitry Andric  bits<4> Zd;
4543bdd1243dSDimitry Andric  let Inst{20-17} = Zm;
4544bdd1243dSDimitry Andric  let Inst{9-6}   = Zn;
4545bdd1243dSDimitry Andric  let Inst{4-1}   = Zd;
4546bdd1243dSDimitry Andric}
4547bdd1243dSDimitry Andric
4548bdd1243dSDimitry Andricmulticlass sme2_sel_vector_vg2<string mnemonic>{
4549bdd1243dSDimitry Andric  def _B : sme2_sel_vector_vg2<0b00, ZZ_b_mul_r, mnemonic>;
4550bdd1243dSDimitry Andric  def _H : sme2_sel_vector_vg2<0b01, ZZ_h_mul_r, mnemonic>;
4551bdd1243dSDimitry Andric  def _S : sme2_sel_vector_vg2<0b10, ZZ_s_mul_r, mnemonic>;
4552bdd1243dSDimitry Andric  def _D : sme2_sel_vector_vg2<0b11, ZZ_d_mul_r, mnemonic>;
4553bdd1243dSDimitry Andric}
4554bdd1243dSDimitry Andricclass sme2_sel_vector_vg4<bits<2> sz, RegisterOperand vector_ty,
4555bdd1243dSDimitry Andric                          string mnemonic>
4556bdd1243dSDimitry Andric     : sme2_sel_vector_vg24<sz, 0b0100, vector_ty, mnemonic> {
4557bdd1243dSDimitry Andric  bits<3> Zm;
4558bdd1243dSDimitry Andric  bits<3> Zn;
4559bdd1243dSDimitry Andric  bits<3> Zd;
4560bdd1243dSDimitry Andric  let Inst{20-18} = Zm;
4561bdd1243dSDimitry Andric  let Inst{9-7}   = Zn;
4562bdd1243dSDimitry Andric  let Inst{4-2}   = Zd;
4563bdd1243dSDimitry Andric}
4564bdd1243dSDimitry Andricmulticlass sme2_sel_vector_vg4<string mnemonic> {
4565bdd1243dSDimitry Andric  def _B : sme2_sel_vector_vg4<0b00, ZZZZ_b_mul_r, mnemonic>;
4566bdd1243dSDimitry Andric  def _H : sme2_sel_vector_vg4<0b01, ZZZZ_h_mul_r, mnemonic>;
4567bdd1243dSDimitry Andric  def _S : sme2_sel_vector_vg4<0b10, ZZZZ_s_mul_r, mnemonic>;
4568bdd1243dSDimitry Andric  def _D : sme2_sel_vector_vg4<0b11, ZZZZ_d_mul_r, mnemonic>;
4569bdd1243dSDimitry Andric}
4570bdd1243dSDimitry Andric
4571bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
4572bdd1243dSDimitry Andric// Non contiguous Load and Store
4573bdd1243dSDimitry Andric
4574bdd1243dSDimitry Andricclass sme2_ld_vector_vg2_multi_scalar_scalar<bits<2> msz, bit n,
4575bdd1243dSDimitry Andric                                             RegisterOperand multi_vector_ty,
4576bdd1243dSDimitry Andric                                             RegisterOperand gpr_ty,
4577bdd1243dSDimitry Andric                                             string mnemonic>
4578bdd1243dSDimitry Andric   : I<(outs multi_vector_ty:$Zt),
4579bdd1243dSDimitry Andric       (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
4580bdd1243dSDimitry Andric       mnemonic, "\t$Zt, $PNg/z, [$Rn, $Rm]",
4581bdd1243dSDimitry Andric       "", []>, Sched<[]> {
4582bdd1243dSDimitry Andric   bits<5> Rm;
4583bdd1243dSDimitry Andric   bits<3> PNg;
4584bdd1243dSDimitry Andric   bits<5> Rn;
4585bdd1243dSDimitry Andric   bits<4> Zt;
4586bdd1243dSDimitry Andric   let Inst{31-21} = 0b10100001000;
4587bdd1243dSDimitry Andric   let Inst{20-16} = Rm;
4588bdd1243dSDimitry Andric   let Inst{15}    = 0b0;
4589bdd1243dSDimitry Andric   let Inst{14-13} = msz;
4590bdd1243dSDimitry Andric   let Inst{12-10} = PNg;
4591bdd1243dSDimitry Andric   let Inst{9-5}   = Rn;
4592bdd1243dSDimitry Andric   let Inst{4}     = Zt{3};
4593bdd1243dSDimitry Andric   let Inst{3}     = n;
4594bdd1243dSDimitry Andric   let Inst{2-0}   = Zt{2-0};
4595bdd1243dSDimitry Andric
4596bdd1243dSDimitry Andric   let mayLoad = 1;
4597bdd1243dSDimitry Andric}
4598bdd1243dSDimitry Andric
4599bdd1243dSDimitry Andricclass sme2_ld_vector_vg4_multi_scalar_scalar<bits<2> msz, bit n,
4600bdd1243dSDimitry Andric                                             RegisterOperand multi_vector_ty,
4601bdd1243dSDimitry Andric                                             RegisterOperand gpr_ty,
4602bdd1243dSDimitry Andric                                             string mnemonic>
4603bdd1243dSDimitry Andric   : I<(outs multi_vector_ty:$Zt),
4604bdd1243dSDimitry Andric       (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
4605bdd1243dSDimitry Andric       mnemonic, "\t$Zt, $PNg/z, [$Rn, $Rm]",
4606bdd1243dSDimitry Andric       "", []>, Sched<[]> {
4607bdd1243dSDimitry Andric   bits<5> Rm;
4608bdd1243dSDimitry Andric   bits<3> PNg;
4609bdd1243dSDimitry Andric   bits<5> Rn;
4610bdd1243dSDimitry Andric   bits<3> Zt;
4611bdd1243dSDimitry Andric   let Inst{31-21} = 0b10100001000;
4612bdd1243dSDimitry Andric   let Inst{20-16} = Rm;
4613bdd1243dSDimitry Andric   let Inst{15}    = 0b1;
4614bdd1243dSDimitry Andric   let Inst{14-13} = msz;
4615bdd1243dSDimitry Andric   let Inst{12-10} = PNg;
4616bdd1243dSDimitry Andric   let Inst{9-5}   = Rn;
4617bdd1243dSDimitry Andric   let Inst{4}     = Zt{2};
4618bdd1243dSDimitry Andric   let Inst{3}     = n;
4619bdd1243dSDimitry Andric   let Inst{2}     = 0b0;
4620bdd1243dSDimitry Andric   let Inst{1-0}   = Zt{1-0};
4621bdd1243dSDimitry Andric
4622bdd1243dSDimitry Andric   let mayLoad = 1;
4623bdd1243dSDimitry Andric}
4624bdd1243dSDimitry Andric
4625bdd1243dSDimitry Andricclass sme2_ld_vector_vg24_multi_scalar_immediate<bits<2> msz, bit n, bits<2> op,
4626bdd1243dSDimitry Andric                                                 RegisterOperand multi_vector_ty,
4627bdd1243dSDimitry Andric                                                 Operand index_ty,
4628bdd1243dSDimitry Andric                                                 string mnemonic>
4629bdd1243dSDimitry Andric    : I<(outs multi_vector_ty:$Zt),
4630bdd1243dSDimitry Andric        (ins PNRAny_p8to15:$PNg, GPR64sp:$Rn, index_ty:$imm4),
4631bdd1243dSDimitry Andric        mnemonic,  "\t$Zt, $PNg/z, [$Rn, $imm4, mul vl]",
4632bdd1243dSDimitry Andric        "", []>, Sched<[]> {
4633bdd1243dSDimitry Andric   bits<4> imm4;
4634bdd1243dSDimitry Andric   bits<3> PNg;
4635bdd1243dSDimitry Andric   bits<5> Rn;
4636bdd1243dSDimitry Andric   let Inst{31-20} = 0b101000010100;
4637bdd1243dSDimitry Andric   let Inst{19-16} = imm4;
4638bdd1243dSDimitry Andric   let Inst{15}    = op{1};
4639bdd1243dSDimitry Andric   let Inst{14-13} = msz;
4640bdd1243dSDimitry Andric   let Inst{12-10} = PNg;
4641bdd1243dSDimitry Andric   let Inst{9-5}   = Rn;
4642bdd1243dSDimitry Andric   let Inst{3}     = n;
4643bdd1243dSDimitry Andric   let Inst{2}     = op{0};
4644bdd1243dSDimitry Andric
4645bdd1243dSDimitry Andric   let mayLoad = 1;
4646bdd1243dSDimitry Andric}
4647bdd1243dSDimitry Andric
4648bdd1243dSDimitry Andricmulticlass sme2_ld_vector_vg2_multi_scalar_immediate<bits<2> msz, bit n,
4649bdd1243dSDimitry Andric                                                     RegisterOperand multi_vector_ty,
4650bdd1243dSDimitry Andric                                                     Operand index_ty,
4651bdd1243dSDimitry Andric                                                     string mnemonic>{
4652bdd1243dSDimitry Andric  def NAME : sme2_ld_vector_vg24_multi_scalar_immediate<msz, n, {0,?},
4653bdd1243dSDimitry Andric                                                        multi_vector_ty,
4654bdd1243dSDimitry Andric                                                        index_ty, mnemonic> {
4655bdd1243dSDimitry Andric    bits<4> Zt;
4656bdd1243dSDimitry Andric    let Inst{4} = Zt{3};
4657bdd1243dSDimitry Andric    let Inst{2-0} = Zt{2-0};
4658bdd1243dSDimitry Andric  }
4659bdd1243dSDimitry Andric
4660bdd1243dSDimitry Andric   def : InstAlias<mnemonic # "\t$Zt, $PNg/z, [$Rn]",
4661bdd1243dSDimitry Andric                  (!cast<Instruction>(NAME) multi_vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, 0), 1>;
4662bdd1243dSDimitry Andric}
4663bdd1243dSDimitry Andric
4664bdd1243dSDimitry Andricmulticlass sme2_ld_vector_vg4_multi_scalar_immediate<bits<2> msz, bit n,
4665bdd1243dSDimitry Andric                                                     RegisterOperand multi_vector_ty,
4666bdd1243dSDimitry Andric                                                     Operand index_ty,
4667bdd1243dSDimitry Andric                                                     string mnemonic> {
4668bdd1243dSDimitry Andric  def NAME : sme2_ld_vector_vg24_multi_scalar_immediate<msz, n, 0b10,
4669bdd1243dSDimitry Andric                                                        multi_vector_ty,
4670bdd1243dSDimitry Andric                                                        index_ty, mnemonic> {
4671bdd1243dSDimitry Andric    bits<3> Zt;
4672bdd1243dSDimitry Andric    let Inst{4} = Zt{2};
4673bdd1243dSDimitry Andric    let Inst{1-0} = Zt{1-0};
4674bdd1243dSDimitry Andric  }
4675bdd1243dSDimitry Andric
4676bdd1243dSDimitry Andric   def : InstAlias<mnemonic # "\t$Zt, $PNg/z, [$Rn]",
4677bdd1243dSDimitry Andric                   (!cast<Instruction>(NAME) multi_vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, 0), 1>;
4678bdd1243dSDimitry Andric}
4679bdd1243dSDimitry Andric
4680bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
4681bdd1243dSDimitry Andric// SME2 Non-Contiguous Store
4682bdd1243dSDimitry Andricclass sme2_st_vector_vg2_multi_scalar_scalar<bits<2> msz, bit n,
4683bdd1243dSDimitry Andric                                             RegisterOperand multi_vector_ty,
4684bdd1243dSDimitry Andric                                             RegisterOperand gpr_ty,
4685bdd1243dSDimitry Andric                                             string mnemonic>
4686bdd1243dSDimitry Andric   : I<(outs ),
4687bdd1243dSDimitry Andric       (ins multi_vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
4688bdd1243dSDimitry Andric       mnemonic, "\t$Zt, $PNg, [$Rn, $Rm]",
4689bdd1243dSDimitry Andric       "", []>, Sched<[]> {
4690bdd1243dSDimitry Andric   bits<5> Rm;
4691bdd1243dSDimitry Andric   bits<3> PNg;
4692bdd1243dSDimitry Andric   bits<5> Rn;
4693bdd1243dSDimitry Andric   bits<4> Zt;
4694bdd1243dSDimitry Andric   let Inst{31-21} = 0b10100001001;
4695bdd1243dSDimitry Andric   let Inst{20-16} = Rm;
4696bdd1243dSDimitry Andric   let Inst{15}    = 0b0;
4697bdd1243dSDimitry Andric   let Inst{14-13} = msz;
4698bdd1243dSDimitry Andric   let Inst{12-10} = PNg;
4699bdd1243dSDimitry Andric   let Inst{9-5}   = Rn;
4700bdd1243dSDimitry Andric   let Inst{4}     = Zt{3};
4701bdd1243dSDimitry Andric   let Inst{3}     = n;
4702bdd1243dSDimitry Andric   let Inst{2-0}   = Zt{2-0};
4703bdd1243dSDimitry Andric
4704bdd1243dSDimitry Andric   let mayStore    = 1;
4705bdd1243dSDimitry Andric}
4706bdd1243dSDimitry Andric
4707bdd1243dSDimitry Andricclass sme2_st_vector_vg4_multi_scalar_scalar<bits<2> msz, bit n,
4708bdd1243dSDimitry Andric                                             RegisterOperand multi_vector_ty,
4709bdd1243dSDimitry Andric                                             RegisterOperand gpr_ty,
4710bdd1243dSDimitry Andric                                             string mnemonic>
4711bdd1243dSDimitry Andric   : I<(outs ),
4712bdd1243dSDimitry Andric       (ins multi_vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, gpr_ty:$Rm),
4713bdd1243dSDimitry Andric       mnemonic, "\t$Zt, $PNg, [$Rn, $Rm]",
4714bdd1243dSDimitry Andric       "", []>, Sched<[]> {
4715bdd1243dSDimitry Andric   bits<5> Rm;
4716bdd1243dSDimitry Andric   bits<3> PNg;
4717bdd1243dSDimitry Andric   bits<5> Rn;
4718bdd1243dSDimitry Andric   bits<3> Zt;
4719bdd1243dSDimitry Andric   let Inst{31-21} = 0b10100001001;
4720bdd1243dSDimitry Andric   let Inst{20-16} = Rm;
4721bdd1243dSDimitry Andric   let Inst{15}     = 0b1;
4722bdd1243dSDimitry Andric   let Inst{14-13} = msz;
4723bdd1243dSDimitry Andric   let Inst{12-10} = PNg;
4724bdd1243dSDimitry Andric   let Inst{9-5}   = Rn;
4725bdd1243dSDimitry Andric   let Inst{4}     = Zt{2};
4726bdd1243dSDimitry Andric   let Inst{3}     = n;
4727bdd1243dSDimitry Andric   let Inst{2}     = 0b0;
4728bdd1243dSDimitry Andric   let Inst{1-0}   = Zt{1-0};
4729bdd1243dSDimitry Andric
4730bdd1243dSDimitry Andric   let mayStore    = 1;
4731bdd1243dSDimitry Andric}
4732bdd1243dSDimitry Andric
4733bdd1243dSDimitry Andricclass sme2_st_vector_vg24_multi_scalar_immediate<bits<2> msz, bit n, bits<2> op,
4734bdd1243dSDimitry Andric                                                 RegisterOperand multi_vector_ty,
4735bdd1243dSDimitry Andric                                                 Operand index_ty,
4736bdd1243dSDimitry Andric                                                 string mnemonic>
4737bdd1243dSDimitry Andric    : I<(outs ),
4738bdd1243dSDimitry Andric        (ins multi_vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn, index_ty:$imm4),
4739bdd1243dSDimitry Andric        mnemonic,  "\t$Zt, $PNg, [$Rn, $imm4, mul vl]",
4740bdd1243dSDimitry Andric        "", []>, Sched<[]> {
4741bdd1243dSDimitry Andric   bits<4> imm4;
4742bdd1243dSDimitry Andric   bits<3> PNg;
4743bdd1243dSDimitry Andric   bits<5> Rn;
4744bdd1243dSDimitry Andric   let Inst{31-20} = 0b101000010110;
4745bdd1243dSDimitry Andric   let Inst{19-16} = imm4;
4746bdd1243dSDimitry Andric   let Inst{15}    = op{1};
4747bdd1243dSDimitry Andric   let Inst{14-13} = msz;
4748bdd1243dSDimitry Andric   let Inst{12-10} = PNg;
4749bdd1243dSDimitry Andric   let Inst{9-5}   = Rn;
4750bdd1243dSDimitry Andric   let Inst{3}     = n;
4751bdd1243dSDimitry Andric   let Inst{2}     = op{0};
4752bdd1243dSDimitry Andric
4753bdd1243dSDimitry Andric   let mayStore    = 1;
4754bdd1243dSDimitry Andric}
4755bdd1243dSDimitry Andric
4756bdd1243dSDimitry Andric
4757bdd1243dSDimitry Andricmulticlass sme2_st_vector_vg2_multi_scalar_immediate<bits<2> msz, bit n,
4758bdd1243dSDimitry Andric                                                     RegisterOperand multi_vector_ty,
4759bdd1243dSDimitry Andric                                                     Operand index_ty,
4760bdd1243dSDimitry Andric                                                     string mnemonic> {
4761bdd1243dSDimitry Andric  def NAME: sme2_st_vector_vg24_multi_scalar_immediate<msz, n, {0,?},
4762bdd1243dSDimitry Andric                                                       multi_vector_ty,
4763bdd1243dSDimitry Andric                                                       index_ty, mnemonic> {
4764bdd1243dSDimitry Andric    bits<4> Zt;
4765bdd1243dSDimitry Andric    let Inst{4}   = Zt{3};
4766bdd1243dSDimitry Andric    let Inst{2-0} = Zt{2-0};
4767bdd1243dSDimitry Andric  }
4768bdd1243dSDimitry Andric
4769bdd1243dSDimitry Andric    def : InstAlias<mnemonic # "\t$Zt, $PNg, [$Rn]",
4770bdd1243dSDimitry Andric                   (!cast<Instruction>(NAME) multi_vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn,0), 1>;
4771bdd1243dSDimitry Andric}
4772bdd1243dSDimitry Andric
4773bdd1243dSDimitry Andricmulticlass sme2_st_vector_vg4_multi_scalar_immediate<bits<2> msz, bit n,
4774bdd1243dSDimitry Andric                                                     RegisterOperand multi_vector_ty,
4775bdd1243dSDimitry Andric                                                     Operand index_ty,
4776bdd1243dSDimitry Andric                                                     string mnemonic> {
4777bdd1243dSDimitry Andric  def NAME : sme2_st_vector_vg24_multi_scalar_immediate<msz, n, 0b10,
4778bdd1243dSDimitry Andric                                                        multi_vector_ty,
4779bdd1243dSDimitry Andric                                                        index_ty, mnemonic> {
4780bdd1243dSDimitry Andric    bits<3> Zt;
4781bdd1243dSDimitry Andric    let Inst{4}   = Zt{2};
4782bdd1243dSDimitry Andric    let Inst{1-0} = Zt{1-0};
4783bdd1243dSDimitry Andric  }
4784bdd1243dSDimitry Andric
4785bdd1243dSDimitry Andric    def : InstAlias<mnemonic # "\t$Zt, $PNg, [$Rn]",
4786bdd1243dSDimitry Andric                   (!cast<Instruction>(NAME) multi_vector_ty:$Zt, PNRAny_p8to15:$PNg, GPR64sp:$Rn,0), 1>;
4787bdd1243dSDimitry Andric}
4788bdd1243dSDimitry Andric
4789bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
4790bdd1243dSDimitry Andric// SME2.1
4791bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
4792bdd1243dSDimitry Andric// SME zeroing move array to vector
4793bdd1243dSDimitry Andricclass sme2p1_movaz_tile_to_vec_base<bits<2> sz, bit q, bit v, ZPRRegOp vector_ty,
4794bdd1243dSDimitry Andric                                    RegisterOperand tile_ty, Operand index_ty,
4795bdd1243dSDimitry Andric                                    string mnemonic>
4796bdd1243dSDimitry Andric    : I<(outs vector_ty:$Zd, tile_ty:$ZAn),
4797bdd1243dSDimitry Andric        (ins tile_ty:$_ZAn, MatrixIndexGPR32Op12_15:$Rs, index_ty:$imm),
4798bdd1243dSDimitry Andric        mnemonic, "\t$Zd, $ZAn[$Rs, $imm]",
4799bdd1243dSDimitry Andric        "", []>, Sched<[]> {
4800bdd1243dSDimitry Andric  bits<2> Rs;
4801bdd1243dSDimitry Andric  bits<5> Zd;
4802bdd1243dSDimitry Andric  let Inst{31-24} = 0b11000000;
4803bdd1243dSDimitry Andric  let Inst{23-22} = sz;
4804bdd1243dSDimitry Andric  let Inst{21-17} = 0b00001;
4805bdd1243dSDimitry Andric  let Inst{16}    = q;
4806bdd1243dSDimitry Andric  let Inst{15}    = v;
4807bdd1243dSDimitry Andric  let Inst{14-13} = Rs;
4808bdd1243dSDimitry Andric  let Inst{12-9}  = 0b0001;
4809bdd1243dSDimitry Andric  let Inst{4-0}   = Zd;
4810bdd1243dSDimitry Andric  let Constraints = "$ZAn = $_ZAn";
4811bdd1243dSDimitry Andric}
4812bdd1243dSDimitry Andric
4813bdd1243dSDimitry Andricmulticlass sme2p1_movaz_tile_to_vec_base<bit v, string mnemonic> {
4814bdd1243dSDimitry Andric  def _B : sme2p1_movaz_tile_to_vec_base<0b00, 0b0, v, ZPR8,
4815bdd1243dSDimitry Andric                                    !if(v, TileVectorOpV8, TileVectorOpH8),
4816*0fca6ea1SDimitry Andric                                    sme_elm_idx0_15, mnemonic>, SMEPseudo2Instr<NAME # _B, 1> {
4817bdd1243dSDimitry Andric    bits<4> imm;
4818bdd1243dSDimitry Andric    let Inst{8-5} = imm;
4819bdd1243dSDimitry Andric  }
4820bdd1243dSDimitry Andric
4821bdd1243dSDimitry Andric  def _H : sme2p1_movaz_tile_to_vec_base<0b01, 0b0, v, ZPR16,
4822bdd1243dSDimitry Andric                                    !if(v, TileVectorOpV16, TileVectorOpH16),
4823*0fca6ea1SDimitry Andric                                    sme_elm_idx0_7, mnemonic>, SMEPseudo2Instr<NAME # _H, 1> {
4824bdd1243dSDimitry Andric    bits<1> ZAn;
4825bdd1243dSDimitry Andric    bits<3> imm;
4826bdd1243dSDimitry Andric    let Inst{8}   = ZAn;
4827bdd1243dSDimitry Andric    let Inst{7-5} = imm;
4828bdd1243dSDimitry Andric  }
4829bdd1243dSDimitry Andric
4830bdd1243dSDimitry Andric  def _S : sme2p1_movaz_tile_to_vec_base<0b10, 0b0, v, ZPR32,
4831bdd1243dSDimitry Andric                                    !if(v, TileVectorOpV32, TileVectorOpH32),
4832*0fca6ea1SDimitry Andric                                    sme_elm_idx0_3, mnemonic>, SMEPseudo2Instr<NAME # _S, 1> {
4833bdd1243dSDimitry Andric    bits<2> ZAn;
4834bdd1243dSDimitry Andric    bits<2> imm;
4835bdd1243dSDimitry Andric    let Inst{8-7} = ZAn;
4836bdd1243dSDimitry Andric    let Inst{6-5} = imm;
4837bdd1243dSDimitry Andric  }
4838bdd1243dSDimitry Andric
4839bdd1243dSDimitry Andric  def _D : sme2p1_movaz_tile_to_vec_base<0b11, 0b0, v, ZPR64,
4840bdd1243dSDimitry Andric                                    !if(v, TileVectorOpV64, TileVectorOpH64),
4841*0fca6ea1SDimitry Andric                                    sme_elm_idx0_1, mnemonic>, SMEPseudo2Instr<NAME # _D, 1> {
4842bdd1243dSDimitry Andric    bits<3> ZAn;
4843bdd1243dSDimitry Andric    bits<1> imm;
4844bdd1243dSDimitry Andric    let Inst{8-6} = ZAn;
4845bdd1243dSDimitry Andric    let Inst{5}   = imm;
4846bdd1243dSDimitry Andric  }
4847bdd1243dSDimitry Andric
4848bdd1243dSDimitry Andric  def _Q : sme2p1_movaz_tile_to_vec_base<0b11, 0b1, v, ZPR128,
4849bdd1243dSDimitry Andric                                    !if(v, TileVectorOpV128, TileVectorOpH128),
4850*0fca6ea1SDimitry Andric                                    sme_elm_idx0_0, mnemonic>, SMEPseudo2Instr<NAME # _Q, 1> {
4851bdd1243dSDimitry Andric    bits<4> ZAn;
4852bdd1243dSDimitry Andric    let Inst{8-5} = ZAn;
4853bdd1243dSDimitry Andric  }
4854bdd1243dSDimitry Andric}
4855bdd1243dSDimitry Andric
4856*0fca6ea1SDimitry Andricmulticlass sme2p1_movaz_tile_to_vec<string mnemonic, SDPatternOperator intrinsic_horiz, SDPatternOperator intrinsic_vert,
4857*0fca6ea1SDimitry Andric                                    SDPatternOperator intrinsic_horiz_q, SDPatternOperator intrinsic_vert_q>{
4858bdd1243dSDimitry Andric defm _H : sme2p1_movaz_tile_to_vec_base<0b0, mnemonic>;
4859bdd1243dSDimitry Andric defm _V : sme2p1_movaz_tile_to_vec_base<0b1, mnemonic>;
4860*0fca6ea1SDimitry Andric
4861*0fca6ea1SDimitry Andric def NAME # _H_B_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_B, sme_elm_idx0_0,  sme_elm_idx0_15, ZPR8,   SMEMatrixTileB>;
4862*0fca6ea1SDimitry Andric def NAME # _H_H_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_H, sme_elm_idx0_1,  sme_elm_idx0_7,  ZPR16,  SMEMatrixTileH>;
4863*0fca6ea1SDimitry Andric def NAME # _H_S_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_S, sme_elm_idx0_3,  sme_elm_idx0_3,  ZPR32,  SMEMatrixTileS>;
4864*0fca6ea1SDimitry Andric def NAME # _H_D_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_D, sme_elm_idx0_7,  sme_elm_idx0_1,  ZPR64,  SMEMatrixTileD>;
4865*0fca6ea1SDimitry Andric def NAME # _H_Q_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _H_Q, sme_elm_idx0_15, sme_elm_idx0_0,  ZPR128, SMEMatrixTileQ>;
4866*0fca6ea1SDimitry Andric
4867*0fca6ea1SDimitry Andric def NAME # _V_B_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_B, sme_elm_idx0_0, sme_elm_idx0_15, ZPR8, SMEMatrixTileB>;
4868*0fca6ea1SDimitry Andric def NAME # _V_H_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_H, sme_elm_idx0_1, sme_elm_idx0_7, ZPR16, SMEMatrixTileH>;
4869*0fca6ea1SDimitry Andric def NAME # _V_S_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_S, sme_elm_idx0_3, sme_elm_idx0_3, ZPR32, SMEMatrixTileS>;
4870*0fca6ea1SDimitry Andric def NAME # _V_D_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_D, sme_elm_idx0_7, sme_elm_idx0_1, ZPR64, SMEMatrixTileD>;
4871*0fca6ea1SDimitry Andric def NAME # _V_Q_PSEUDO : sme2_movez_to_tile_pseudo<NAME # _V_Q, sme_elm_idx0_15, sme_elm_idx0_0, ZPR128, SMEMatrixTileQ>;
4872*0fca6ea1SDimitry Andric
4873*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_B, intrinsic_horiz, nxv16i8,sme_elm_idx0_0,  sme_elm_idx0_15, tileslice8>;
4874*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_H, intrinsic_horiz, nxv8i16, sme_elm_idx0_1, sme_elm_idx0_7, tileslice16>;
4875*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_S, intrinsic_horiz, nxv4i32, sme_elm_idx0_3, sme_elm_idx0_3, tileslice32>;
4876*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_D, intrinsic_horiz, nxv2i64, sme_elm_idx0_7, sme_elm_idx0_1, tileslice64>;
4877*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_H, intrinsic_horiz, nxv8bf16, sme_elm_idx0_1, sme_elm_idx0_7, tileslice16>;
4878*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_H, intrinsic_horiz, nxv8f16, sme_elm_idx0_1, sme_elm_idx0_7, tileslice16>;
4879*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_S, intrinsic_horiz, nxv4f32, sme_elm_idx0_3, sme_elm_idx0_3, tileslice32>;
4880*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_D, intrinsic_horiz, nxv2f64, sme_elm_idx0_7, sme_elm_idx0_1, tileslice64>;
4881*0fca6ea1SDimitry Andric
4882*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_B, intrinsic_vert, nxv16i8, sme_elm_idx0_0, sme_elm_idx0_15, tileslice8>;
4883*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_H, intrinsic_vert, nxv8i16, sme_elm_idx0_1, sme_elm_idx0_7, tileslice16>;
4884*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_S, intrinsic_vert, nxv4i32, sme_elm_idx0_3, sme_elm_idx0_3, tileslice32>;
4885*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_D, intrinsic_vert, nxv2i64, sme_elm_idx0_7, sme_elm_idx0_1, tileslice64>;
4886*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_H, intrinsic_vert, nxv8bf16, sme_elm_idx0_1, sme_elm_idx0_7, tileslice16>;
4887*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_H, intrinsic_vert, nxv8f16, sme_elm_idx0_1, sme_elm_idx0_7, tileslice16>;
4888*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_S, intrinsic_vert, nxv4f32, sme_elm_idx0_3, sme_elm_idx0_3, tileslice32>;
4889*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_D, intrinsic_vert, nxv2f64, sme_elm_idx0_7, sme_elm_idx0_1, tileslice64>;
4890*0fca6ea1SDimitry Andric
4891*0fca6ea1SDimitry Andric // H_Q
4892*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_Q, intrinsic_horiz_q, nxv16i8, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4893*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_Q, intrinsic_horiz_q, nxv8i16, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4894*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_Q, intrinsic_horiz_q, nxv4i32, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4895*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_Q, intrinsic_horiz_q, nxv2i64, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4896*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_Q, intrinsic_horiz_q, nxv8bf16, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4897*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_Q, intrinsic_horiz_q, nxv8f16, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4898*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_Q, intrinsic_horiz_q, nxv4f32, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4899*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _H_Q, intrinsic_horiz_q, nxv2f64, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4900*0fca6ea1SDimitry Andric
4901*0fca6ea1SDimitry Andric // _V_Q
4902*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_Q, intrinsic_vert_q, nxv16i8, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4903*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_Q, intrinsic_vert_q, nxv8i16, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4904*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_Q, intrinsic_vert_q, nxv4i32, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4905*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_Q, intrinsic_vert_q, nxv2i64, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4906*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_Q, intrinsic_vert_q, nxv8bf16, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4907*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_Q, intrinsic_vert_q, nxv8f16, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4908*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_Q, intrinsic_vert_q, nxv4f32, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4909*0fca6ea1SDimitry Andric def : SME2_Tile_Movaz_Pat<NAME # _V_Q, intrinsic_vert_q, nxv2f64, sme_elm_idx0_15, sme_elm_idx0_0, tileslice128>;
4910bdd1243dSDimitry Andric}
4911bdd1243dSDimitry Andric
4912bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
4913bdd1243dSDimitry Andric// SME2.1 multiple vectors zero array
4914bdd1243dSDimitry Andric
4915bdd1243dSDimitry Andricclass sme2p1_zero_matrix<bits<6> opc, Operand index_ty, string mnemonic,
4916bdd1243dSDimitry Andric                         string vg_acronym="">
4917bdd1243dSDimitry Andric    : I<(outs MatrixOp64:$ZAd),
4918bdd1243dSDimitry Andric        (ins MatrixOp64:$_ZAd, MatrixIndexGPR32Op8_11:$Rv, index_ty:$imm),
4919bdd1243dSDimitry Andric        mnemonic, "\t$ZAd[$Rv, $imm" # !if(!eq(vg_acronym, ""), "", ", " # vg_acronym) # "]",
4920bdd1243dSDimitry Andric        "", []>, Sched<[]> {
4921bdd1243dSDimitry Andric  bits <2> Rv;
4922bdd1243dSDimitry Andric  let Inst{31-18} = 0b11000000000011;
4923bdd1243dSDimitry Andric  let Inst{17-15} = opc{5-3};
4924bdd1243dSDimitry Andric  let Inst{14-13} = Rv;
4925bdd1243dSDimitry Andric  let Inst{12-3} = 0b0000000000;
4926bdd1243dSDimitry Andric  let Inst{2-0}  = opc{2-0};
4927bdd1243dSDimitry Andric  let Constraints = "$ZAd = $_ZAd";
4928bdd1243dSDimitry Andric}
4929bdd1243dSDimitry Andric
4930bdd1243dSDimitry Andricmulticlass sme2p1_zero_matrix<string mnemonic> {
4931*0fca6ea1SDimitry Andric  def _VG2_Z : sme2p1_zero_matrix<{0b000,?,?,?}, sme_elm_idx0_7, mnemonic, "vgx2">, SMEPseudo2Instr<NAME # _VG2_Z , 1> {
4932bdd1243dSDimitry Andric    bits<3> imm;
4933bdd1243dSDimitry Andric    let Inst{2-0} = imm;
4934bdd1243dSDimitry Andric  }
4935*0fca6ea1SDimitry Andric  def _2Z : sme2p1_zero_matrix<{0b001,?,?,?}, uimm3s2range, mnemonic>, SMEPseudo2Instr<NAME # _2Z, 1> {
4936bdd1243dSDimitry Andric    bits<3> imm;
4937bdd1243dSDimitry Andric    let Inst{2-0} = imm;
4938bdd1243dSDimitry Andric  }
4939*0fca6ea1SDimitry Andric  def _VG2_2Z : sme2p1_zero_matrix<{0b0100,?,?}, uimm2s2range, mnemonic, "vgx2">, SMEPseudo2Instr<NAME # _VG2_2Z, 1> {
4940bdd1243dSDimitry Andric    bits<2> imm;
4941bdd1243dSDimitry Andric    let Inst{1-0} = imm;
4942bdd1243dSDimitry Andric  }
4943*0fca6ea1SDimitry Andric  def _VG4_2Z : sme2p1_zero_matrix<{0b0110,?,?}, uimm2s2range, mnemonic, "vgx4">, SMEPseudo2Instr<NAME # _VG4_2Z, 1> {
4944bdd1243dSDimitry Andric    bits<2> imm;
4945bdd1243dSDimitry Andric    let Inst{1-0} = imm;
4946bdd1243dSDimitry Andric  }
4947*0fca6ea1SDimitry Andric  def _VG4_Z : sme2p1_zero_matrix<{0b100,?,?,?}, sme_elm_idx0_7, mnemonic, "vgx4">, SMEPseudo2Instr<NAME # _VG4_Z, 1> {
4948bdd1243dSDimitry Andric    bits<3> imm;
4949bdd1243dSDimitry Andric    let Inst{2-0} = imm;
4950bdd1243dSDimitry Andric  }
4951*0fca6ea1SDimitry Andric  def _4Z : sme2p1_zero_matrix<{0b1010,?,?}, uimm2s4range, mnemonic>, SMEPseudo2Instr<NAME # _4Z, 1> {
4952bdd1243dSDimitry Andric    bits<2> imm;
4953bdd1243dSDimitry Andric    let Inst{1-0} = imm;
4954bdd1243dSDimitry Andric  }
4955*0fca6ea1SDimitry Andric  def _VG2_4Z : sme2p1_zero_matrix<{0b11000,?}, uimm1s4range, mnemonic, "vgx2">, SMEPseudo2Instr<NAME # _VG2_4Z, 1> {
4956bdd1243dSDimitry Andric    bits<1> imm;
4957bdd1243dSDimitry Andric    let Inst{0}   = imm;
4958bdd1243dSDimitry Andric  }
4959*0fca6ea1SDimitry Andric  def _VG4_4Z : sme2p1_zero_matrix<{0b11100,?}, uimm1s4range, mnemonic, "vgx4">, SMEPseudo2Instr<NAME # _VG4_4Z, 1> {
4960bdd1243dSDimitry Andric    bits<1> imm;
4961bdd1243dSDimitry Andric    let Inst{0}   = imm;
4962bdd1243dSDimitry Andric  }
4963*0fca6ea1SDimitry Andric
4964*0fca6ea1SDimitry Andric  def NAME # _VG2_Z_PSEUDO : sem2p1_zero_matrix_pseudo<NAME # _VG2_Z, sme_elm_idx0_7, SMEMatrixArray>;
4965*0fca6ea1SDimitry Andric  def NAME # _VG4_Z_PSEUDO : sem2p1_zero_matrix_pseudo<NAME # _VG4_Z, sme_elm_idx0_7, SMEMatrixArray>;
4966*0fca6ea1SDimitry Andric  def NAME # _2Z_PSEUDO : sem2p1_zero_matrix_pseudo<NAME # _2Z, uimm2s2range, SMEMatrixArray>;
4967*0fca6ea1SDimitry Andric  def NAME # _VG2_2Z_PSEUDO : sem2p1_zero_matrix_pseudo<NAME # _VG2_2Z, uimm1s2range, SMEMatrixArray>;
4968*0fca6ea1SDimitry Andric  def NAME # _VG4_2Z_PSEUDO : sem2p1_zero_matrix_pseudo<NAME # _VG4_2Z, uimm1s2range, SMEMatrixArray>;
4969*0fca6ea1SDimitry Andric  def NAME # _4Z_PSEUDO : sem2p1_zero_matrix_pseudo<NAME # _4Z, uimm1s4range, SMEMatrixArray>;
4970*0fca6ea1SDimitry Andric  def NAME # _VG2_4Z_PSEUDO : sem2p1_zero_matrix_pseudo<NAME # _VG2_4Z, uimm0s4range, SMEMatrixArray>;
4971*0fca6ea1SDimitry Andric  def NAME # _VG4_4Z_PSEUDO : sem2p1_zero_matrix_pseudo<NAME # _VG4_4Z, uimm0s4range, SMEMatrixArray>;
4972*0fca6ea1SDimitry Andric
4973*0fca6ea1SDimitry Andric  def : SME2_Zero_Matrix_Pat<NAME # _VG2_Z_PSEUDO, int_aarch64_sme_zero_za64_vg1x2, sme_elm_idx0_7, tileslice16>;
4974*0fca6ea1SDimitry Andric  def : SME2_Zero_Matrix_Pat<NAME # _VG4_Z_PSEUDO, int_aarch64_sme_zero_za64_vg1x4, sme_elm_idx0_7, tileslice16>;
4975*0fca6ea1SDimitry Andric  def : SME2_Zero_Matrix_Pat<NAME # _2Z_PSEUDO, int_aarch64_sme_zero_za64_vg2x1, uimm2s2range, tileslicerange2s2>;
4976*0fca6ea1SDimitry Andric  def : SME2_Zero_Matrix_Pat<NAME # _VG2_2Z_PSEUDO, int_aarch64_sme_zero_za64_vg2x2, uimm1s2range, tileslicerange1s2>;
4977*0fca6ea1SDimitry Andric  def : SME2_Zero_Matrix_Pat<NAME # _VG4_2Z_PSEUDO, int_aarch64_sme_zero_za64_vg2x4, uimm1s2range, tileslicerange1s2>;
4978*0fca6ea1SDimitry Andric  def : SME2_Zero_Matrix_Pat<NAME # _4Z_PSEUDO, int_aarch64_sme_zero_za64_vg4x1, uimm1s4range, tileslicerange1s4>;
4979*0fca6ea1SDimitry Andric  def : SME2_Zero_Matrix_Pat<NAME # _VG2_4Z_PSEUDO, int_aarch64_sme_zero_za64_vg4x2, uimm0s4range, tileslicerange0s4>;
4980*0fca6ea1SDimitry Andric  def : SME2_Zero_Matrix_Pat<NAME # _VG4_4Z_PSEUDO, int_aarch64_sme_zero_za64_vg4x4, uimm0s4range, tileslicerange0s4>;
4981bdd1243dSDimitry Andric}
4982bdd1243dSDimitry Andric
4983bdd1243dSDimitry Andric//===----------------------------------------------------------------------===//
4984bdd1243dSDimitry Andric// SME2.1 lookup table expand two non-contiguous registers
4985bdd1243dSDimitry Andric
4986bdd1243dSDimitry Andricclass sme2p1_luti_vector_vg2_index<bits<4> op, bits<2> sz, RegisterOperand vector_ty,
4987bdd1243dSDimitry Andric                                   AsmVectorIndexOpnd index_ty,
4988bdd1243dSDimitry Andric                                   string mnemonic>
4989bdd1243dSDimitry Andric    :  I<(outs vector_ty:$Zd), (ins ZTR:$ZTt, ZPRAny:$Zn, index_ty:$i),
4990bdd1243dSDimitry Andric          mnemonic, "\t$Zd, $ZTt, $Zn$i",
4991bdd1243dSDimitry Andric          "", []>, Sched<[]> {
4992bdd1243dSDimitry Andric  bits<5> Zn;
4993bdd1243dSDimitry Andric  bits<4> Zd;
4994bdd1243dSDimitry Andric  let Inst{31-19} = 0b1100000010011;
4995bdd1243dSDimitry Andric  let Inst{18-15} = op;
4996bdd1243dSDimitry Andric  let Inst{14}    = 0b1;
4997bdd1243dSDimitry Andric  let Inst{13-12} = sz;
4998bdd1243dSDimitry Andric  let Inst{11-10} = 0b00;
4999bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
5000bdd1243dSDimitry Andric  let Inst{4}     = Zd{3};
5001bdd1243dSDimitry Andric  let Inst{3}     = 0b0;
5002bdd1243dSDimitry Andric  let Inst{2-0}   = Zd{2-0};
5003bdd1243dSDimitry Andric}
5004bdd1243dSDimitry Andric
5005bdd1243dSDimitry Andricclass sme2p1_luti2_vector_vg2_index<bits<2> sz, RegisterOperand vector_ty,
5006bdd1243dSDimitry Andric                                    AsmVectorIndexOpnd index_ty,
5007bdd1243dSDimitry Andric                                    string mnemonic>
5008bdd1243dSDimitry Andric  : sme2p1_luti_vector_vg2_index<{1,?,?,?}, sz, vector_ty, index_ty, mnemonic> {
5009bdd1243dSDimitry Andric  bits<3> i;
5010bdd1243dSDimitry Andric  let Inst{17-15} = i;
5011bdd1243dSDimitry Andric}
5012bdd1243dSDimitry Andric
5013bdd1243dSDimitry Andricmulticlass sme2p1_luti2_vector_vg2_index<string mnemonic> {
5014bdd1243dSDimitry Andric  def _B : sme2p1_luti2_vector_vg2_index<0b00, ZZ_b_strided, VectorIndexH,
5015bdd1243dSDimitry Andric                                         mnemonic>;
5016bdd1243dSDimitry Andric  def _H : sme2p1_luti2_vector_vg2_index<0b01, ZZ_h_strided, VectorIndexH,
5017bdd1243dSDimitry Andric                                         mnemonic>;
5018bdd1243dSDimitry Andric}
5019bdd1243dSDimitry Andric
5020bdd1243dSDimitry Andricclass sme2p1_luti4_vector_vg2_index<bits<2> sz, RegisterOperand vector_ty,
5021bdd1243dSDimitry Andric                                    AsmVectorIndexOpnd index_ty,
5022bdd1243dSDimitry Andric                                    string mnemonic>
5023bdd1243dSDimitry Andric  : sme2p1_luti_vector_vg2_index<{0b01,?,?}, sz, vector_ty, index_ty, mnemonic> {
5024bdd1243dSDimitry Andric  bits<2> i;
5025bdd1243dSDimitry Andric  let Inst{16-15} = i;
5026bdd1243dSDimitry Andric}
5027bdd1243dSDimitry Andricmulticlass sme2p1_luti4_vector_vg2_index<string mnemonic> {
5028bdd1243dSDimitry Andric  def _B : sme2p1_luti4_vector_vg2_index<0b00, ZZ_b_strided, VectorIndexS,
5029bdd1243dSDimitry Andric                                         mnemonic>;
5030bdd1243dSDimitry Andric  def _H : sme2p1_luti4_vector_vg2_index<0b01, ZZ_h_strided, VectorIndexS,
5031bdd1243dSDimitry Andric                                         mnemonic>;
5032bdd1243dSDimitry Andric}
5033bdd1243dSDimitry Andric
5034bdd1243dSDimitry Andric// SME2.1 lookup table expand four non-contiguous registers
5035bdd1243dSDimitry Andricclass sme2p1_luti_vector_vg4_index<bits<3> op, bits<2> sz, RegisterOperand vector_ty,
5036bdd1243dSDimitry Andric                                   AsmVectorIndexOpnd index_ty,
5037bdd1243dSDimitry Andric                                   string mnemonic>
5038bdd1243dSDimitry Andric    :  I<(outs vector_ty:$Zd), (ins ZTR:$ZTt, ZPRAny:$Zn, index_ty:$i),
5039bdd1243dSDimitry Andric          mnemonic, "\t$Zd, $ZTt, $Zn$i",
5040bdd1243dSDimitry Andric          "", []>, Sched<[]> {
5041bdd1243dSDimitry Andric  bits<5> Zn;
5042bdd1243dSDimitry Andric  bits<3> Zd;
5043bdd1243dSDimitry Andric  let Inst{31-19} = 0b1100000010011;
5044bdd1243dSDimitry Andric  let Inst{18-16} = op;
5045bdd1243dSDimitry Andric  let Inst{15-14} = 0b10;
5046bdd1243dSDimitry Andric  let Inst{13-12} = sz;
5047bdd1243dSDimitry Andric  let Inst{11-10} = 0b00;
5048bdd1243dSDimitry Andric  let Inst{9-5}   = Zn;
5049bdd1243dSDimitry Andric  let Inst{4}     = Zd{2};
5050bdd1243dSDimitry Andric  let Inst{3-2}   = 0b00;
5051bdd1243dSDimitry Andric  let Inst{1-0}   = Zd{1-0};
5052bdd1243dSDimitry Andric}
5053bdd1243dSDimitry Andric
5054bdd1243dSDimitry Andricclass sme2p1_luti2_vector_vg4_index<bits<2> sz, RegisterOperand vector_ty,
5055bdd1243dSDimitry Andric                                    AsmVectorIndexOpnd index_ty,
5056bdd1243dSDimitry Andric                                    string mnemonic>
5057bdd1243dSDimitry Andric  : sme2p1_luti_vector_vg4_index<{1,?,?}, sz, vector_ty, index_ty, mnemonic> {
5058bdd1243dSDimitry Andric  bits<2> i;
5059bdd1243dSDimitry Andric  let Inst{17-16} = i;
5060bdd1243dSDimitry Andric}
5061bdd1243dSDimitry Andric
5062bdd1243dSDimitry Andricmulticlass sme2p1_luti2_vector_vg4_index<string mnemonic> {
5063bdd1243dSDimitry Andric  def _B : sme2p1_luti2_vector_vg4_index<0b00, ZZZZ_b_strided, VectorIndexS,
5064bdd1243dSDimitry Andric                                         mnemonic>;
5065bdd1243dSDimitry Andric  def _H : sme2p1_luti2_vector_vg4_index<0b01, ZZZZ_h_strided, VectorIndexS,
5066bdd1243dSDimitry Andric                                         mnemonic>;
5067bdd1243dSDimitry Andric}
5068bdd1243dSDimitry Andric
5069bdd1243dSDimitry Andricclass sme2p1_luti4_vector_vg4_index<bits<2> sz, RegisterOperand vector_ty,
5070bdd1243dSDimitry Andric                                    AsmVectorIndexOpnd index_ty,
5071bdd1243dSDimitry Andric                                    string mnemonic>
5072bdd1243dSDimitry Andric  : sme2p1_luti_vector_vg4_index<{0b01,?}, sz, vector_ty, index_ty, mnemonic> {
5073bdd1243dSDimitry Andric  bit i;
5074bdd1243dSDimitry Andric  let Inst{16}    = i;
5075bdd1243dSDimitry Andric}
5076bdd1243dSDimitry Andric
5077bdd1243dSDimitry Andricmulticlass sme2p1_luti4_vector_vg4_index<string mnemonic> {
5078bdd1243dSDimitry Andric  def _H: sme2p1_luti4_vector_vg4_index<0b01, ZZZZ_h_strided, VectorIndexD, mnemonic>;
5079bdd1243dSDimitry Andric}
50805f757f3fSDimitry Andric
50815f757f3fSDimitry Andric// SME2 lookup table two source registers expand to four contiguous destination registers
50825f757f3fSDimitry Andricclass sme2_luti4_vector_vg4<bits<2> sz, bits<2> op, string mnemonic>
50835f757f3fSDimitry Andric  : I<(outs ZZZZ_b_mul_r:$Zd), (ins ZTR:$ZTt, ZZ_mul_r:$Zn),
50845f757f3fSDimitry Andric       mnemonic, "\t$Zd, $ZTt, $Zn",
50855f757f3fSDimitry Andric       "", []>, Sched<[]> {
50865f757f3fSDimitry Andric  bits<4> Zn;
50875f757f3fSDimitry Andric  bits<3> Zd;
50885f757f3fSDimitry Andric  let Inst{31-14} = 0b110000001000101100;
50895f757f3fSDimitry Andric  let Inst{13-12} = sz;
50905f757f3fSDimitry Andric  let Inst{11-10} = op;
50915f757f3fSDimitry Andric  let Inst{9-6}   = Zn;
50925f757f3fSDimitry Andric  let Inst{5}     = 0b0;
50935f757f3fSDimitry Andric  let Inst{4-2}   = Zd;
50945f757f3fSDimitry Andric  let Inst{1-0}   = 0b00;
50955f757f3fSDimitry Andric}
50965f757f3fSDimitry Andric
50975f757f3fSDimitry Andric// SME2 lookup table two source registers expand to four non-contiguous destination registers
50985f757f3fSDimitry Andricclass sme2_luti4_vector_vg4_strided<bits<2> sz, bits<2> op, string mnemonic>
50995f757f3fSDimitry Andric   : I<(outs ZZZZ_b_strided:$Zd), (ins ZTR:$ZTt, ZZ_mul_r:$Zn),
51005f757f3fSDimitry Andric        mnemonic, "\t$Zd, $ZTt, $Zn",
51015f757f3fSDimitry Andric        "", []>, Sched<[]> {
51025f757f3fSDimitry Andric  bits<4> Zn;
51035f757f3fSDimitry Andric  bits<3> Zd;
51045f757f3fSDimitry Andric  let Inst{31-14} = 0b110000001001101100;
51055f757f3fSDimitry Andric  let Inst{13-12} = sz;
51065f757f3fSDimitry Andric  let Inst{11-10} = op;
51075f757f3fSDimitry Andric  let Inst{9-6}   = Zn;
51085f757f3fSDimitry Andric  let Inst{5}     = 0b0;
51095f757f3fSDimitry Andric  let Inst{4}     = Zd{2};
51105f757f3fSDimitry Andric  let Inst{3-2}   = 0b00;
51115f757f3fSDimitry Andric  let Inst{1-0}   = Zd{1-0};
51125f757f3fSDimitry Andric}
5113