Skip to content

Commit 2657c79

Browse files
authored
[AArch64][llvm] (NFC) Refactor sve_intx_dot class and delete sve2p1_two_way_dot_vv (#160103)
`sve_intx_dot` and `sve2p1_two_way_dot_vv` are both very similar, encoding for `SDOT` instructions. Refactor the `sve_intx_dot` class so it is more flexible, and delete the `sve2p1_two_way_dot_vv` class. Making this change now, to accommodate future SDOT instructions.
1 parent 4d4df2b commit 2657c79

File tree

1 file changed

+13
-33
lines changed

1 file changed

+13
-33
lines changed

llvm/lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3748,18 +3748,18 @@ multiclass sve2_int_mla_long_by_indexed_elem<bits<4> opc, string asm,
37483748
// SVE Integer Dot Product Group
37493749
//===----------------------------------------------------------------------===//
37503750

3751-
class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
3752-
ZPRRegOp zprty2>
3751+
class sve_intx_dot<bits<2> sz, bits<5> op5, bit U, string asm,
3752+
ZPRRegOp zprty1, ZPRRegOp zprty2>
37533753
: I<(outs zprty1:$Zda), (ins zprty1:$_Zda, zprty2:$Zn, zprty2:$Zm), asm,
37543754
"\t$Zda, $Zn, $Zm", "", []>, Sched<[]> {
37553755
bits<5> Zda;
37563756
bits<5> Zn;
37573757
bits<5> Zm;
3758-
let Inst{31-23} = 0b010001001;
3759-
let Inst{22} = sz;
3758+
let Inst{31-24} = 0b01000100;
3759+
let Inst{23-22} = sz;
37603760
let Inst{21} = 0;
37613761
let Inst{20-16} = Zm;
3762-
let Inst{15-11} = 0;
3762+
let Inst{15-11} = op5;
37633763
let Inst{10} = U;
37643764
let Inst{9-5} = Zn;
37653765
let Inst{4-0} = Zda;
@@ -3770,13 +3770,19 @@ class sve_intx_dot<bit sz, bit U, string asm, ZPRRegOp zprty1,
37703770
}
37713771

37723772
multiclass sve_intx_dot<bit opc, string asm, SDPatternOperator op> {
3773-
def _BtoS : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>;
3774-
def _HtoD : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>;
3773+
def _BtoS : sve_intx_dot<0b10, 0b00000, opc, asm, ZPR32, ZPR8>;
3774+
def _HtoD : sve_intx_dot<0b11, 0b00000, opc, asm, ZPR64, ZPR16>;
37753775

37763776
def : SVE_3_Op_Pat<nxv4i32, op, nxv4i32, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _BtoS)>;
37773777
def : SVE_3_Op_Pat<nxv2i64, op, nxv2i64, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _HtoD)>;
37783778
}
37793779

3780+
multiclass sve2p1_two_way_dot_vv<string mnemonic, bit u, SDPatternOperator intrinsic> {
3781+
def NAME : sve_intx_dot<0b00, 0b11001, u, mnemonic, ZPR32, ZPR16>;
3782+
3783+
def : SVE_3_Op_Pat<nxv4i32, intrinsic, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
3784+
}
3785+
37803786
//===----------------------------------------------------------------------===//
37813787
// SVE Integer Dot Product Group - Indexed Group
37823788
//===----------------------------------------------------------------------===//
@@ -9893,32 +9899,6 @@ multiclass sve_fp_clamp_bfloat<string asm, SDPatternOperator op> {
98939899
def : SVE_3_Op_Pat<nxv8bf16, op, nxv8bf16, nxv8bf16, nxv8bf16, !cast<Instruction>(NAME)>;
98949900
}
98959901

9896-
// SVE two-way dot product
9897-
class sve2p1_two_way_dot_vv<string mnemonic, bit u>
9898-
: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR16:$Zm),
9899-
mnemonic, "\t$Zda, $Zn, $Zm",
9900-
"", []>, Sched<[]> {
9901-
bits<5> Zda;
9902-
bits<5> Zn;
9903-
bits<5> Zm;
9904-
let Inst{31-21} = 0b01000100000;
9905-
let Inst{20-16} = Zm;
9906-
let Inst{15-11} = 0b11001;
9907-
let Inst{10} = u;
9908-
let Inst{9-5} = Zn;
9909-
let Inst{4-0} = Zda;
9910-
9911-
let Constraints = "$Zda = $_Zda";
9912-
let DestructiveInstType = DestructiveOther;
9913-
let hasSideEffects = 0;
9914-
}
9915-
9916-
multiclass sve2p1_two_way_dot_vv<string mnemonic, bit u, SDPatternOperator intrinsic> {
9917-
def NAME : sve2p1_two_way_dot_vv<mnemonic, u>;
9918-
9919-
def : SVE_3_Op_Pat<nxv4i32, intrinsic, nxv4i32, nxv8i16, nxv8i16, !cast<Instruction>(NAME)>;
9920-
}
9921-
99229902
// SVE two-way dot product (indexed)
99239903
class sve2p1_two_way_dot_vvi<string mnemonic, bit u>
99249904
: I<(outs ZPR32:$Zda), (ins ZPR32:$_Zda, ZPR16:$Zn, ZPR3b16:$Zm, VectorIndexS32b:$i2),

0 commit comments

Comments
 (0)