Skip to content

Commit e4e02e3

Browse files
[AArch64][NFC] Refactor NEON, SVE and SME classes and multiclasses fo… (#68800)
…r the assembly disassembly This NFC patch refactors the assembly/disassembly class and multiclass in the AArch64 backend to receive a new 2023/09 AArch64[1] ISA release. The encoding for the 2023 instructions re-uses encoding blocks from previous assembly/disassembly instructions. The refactoring makes the class and multiclass for assembly/disassembly generic so it can be used to describe the instructions for the new ISA. [1]https://developer.arm.com/documentation/ddi0602/2023-09
1 parent 3f4bf99 commit e4e02e3

File tree

9 files changed

+363
-317
lines changed

9 files changed

+363
-317
lines changed

llvm/lib/Target/AArch64/AArch64InstrFormats.td

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ def UImm3s8Operand : UImmScaledMemoryIndexed<3, 8>;
15171517

15181518
def uimm3s8 : Operand<i64>, ImmLeaf<i64,
15191519
[{ return Imm >= 0 && Imm <= 56 && ((Imm % 8) == 0); }], UImmS8XForm> {
1520-
let PrintMethod = "printVectorIndex<8>";
1520+
let PrintMethod = "printMatrixIndex<8>";
15211521
let ParserMatchClass = UImm3s8Operand;
15221522
}
15231523

@@ -6011,11 +6011,11 @@ multiclass SIMDLogicalThreeVectorTied<bit U, bits<2> size,
60116011

60126012
// ARMv8.2-A Dot Product Instructions (Vector): These instructions extract
60136013
// bytes from S-sized elements.
6014-
class BaseSIMDThreeSameVectorDot<bit Q, bit U, bit Mixed, string asm, string kind1,
6015-
string kind2, RegisterOperand RegType,
6014+
class BaseSIMDThreeSameVectorDot<bit Q, bit U, bits<2> sz, bits<4> opc, string asm,
6015+
string kind1, string kind2, RegisterOperand RegType,
60166016
ValueType AccumType, ValueType InputType,
60176017
SDPatternOperator OpNode> :
6018-
BaseSIMDThreeSameVectorTied<Q, U, 0b100, {0b1001, Mixed}, RegType, asm, kind1,
6018+
BaseSIMDThreeSameVectorTied<Q, U, {sz, 0b0}, {0b1, opc}, RegType, asm, kind1,
60196019
[(set (AccumType RegType:$dst),
60206020
(OpNode (AccumType RegType:$Rd),
60216021
(InputType RegType:$Rn),
@@ -6024,9 +6024,9 @@ class BaseSIMDThreeSameVectorDot<bit Q, bit U, bit Mixed, string asm, string kin
60246024
}
60256025

60266026
multiclass SIMDThreeSameVectorDot<bit U, bit Mixed, string asm, SDPatternOperator OpNode> {
6027-
def v8i8 : BaseSIMDThreeSameVectorDot<0, U, Mixed, asm, ".2s", ".8b", V64,
6027+
def v8i8 : BaseSIMDThreeSameVectorDot<0, U, 0b10, {0b001, Mixed}, asm, ".2s", ".8b", V64,
60286028
v2i32, v8i8, OpNode>;
6029-
def v16i8 : BaseSIMDThreeSameVectorDot<1, U, Mixed, asm, ".4s", ".16b", V128,
6029+
def v16i8 : BaseSIMDThreeSameVectorDot<1, U, 0b10, {0b001, Mixed}, asm, ".4s", ".16b", V128,
60306030
v4i32, v16i8, OpNode>;
60316031
}
60326032

@@ -8482,12 +8482,12 @@ class SIMDThreeSameVectorMatMul<bit B, bit U, string asm, SDPatternOperator OpNo
84828482

84838483
//----------------------------------------------------------------------------
84848484
// ARMv8.2-A Dot Product Instructions (Indexed)
8485-
class BaseSIMDThreeSameVectorDotIndex<bit Q, bit U, bit Mixed, bits<2> size, string asm,
8485+
class BaseSIMDThreeSameVectorIndexS<bit Q, bit U, bits<2> size, bits<4> opc, string asm,
84868486
string dst_kind, string lhs_kind, string rhs_kind,
84878487
RegisterOperand RegType,
84888488
ValueType AccumType, ValueType InputType,
84898489
SDPatternOperator OpNode> :
8490-
BaseSIMDIndexedTied<Q, U, 0b0, size, {0b111, Mixed}, RegType, RegType, V128,
8490+
BaseSIMDIndexedTied<Q, U, 0b0, size, opc, RegType, RegType, V128,
84918491
VectorIndexS, asm, "", dst_kind, lhs_kind, rhs_kind,
84928492
[(set (AccumType RegType:$dst),
84938493
(AccumType (OpNode (AccumType RegType:$Rd),
@@ -8502,20 +8502,20 @@ class BaseSIMDThreeSameVectorDotIndex<bit Q, bit U, bit Mixed, bits<2> size, str
85028502

85038503
multiclass SIMDThreeSameVectorDotIndex<bit U, bit Mixed, bits<2> size, string asm,
85048504
SDPatternOperator OpNode> {
8505-
def v8i8 : BaseSIMDThreeSameVectorDotIndex<0, U, Mixed, size, asm, ".2s", ".8b", ".4b",
8505+
def v8i8 : BaseSIMDThreeSameVectorIndexS<0, U, size, {0b111, Mixed}, asm, ".2s", ".8b", ".4b",
85068506
V64, v2i32, v8i8, OpNode>;
8507-
def v16i8 : BaseSIMDThreeSameVectorDotIndex<1, U, Mixed, size, asm, ".4s", ".16b", ".4b",
8507+
def v16i8 : BaseSIMDThreeSameVectorIndexS<1, U, size, {0b111, Mixed}, asm, ".4s", ".16b", ".4b",
85088508
V128, v4i32, v16i8, OpNode>;
85098509
}
85108510

85118511
// ARMv8.2-A Fused Multiply Add-Long Instructions (Indexed)
85128512
let mayRaiseFPException = 1, Uses = [FPCR] in
8513-
class BaseSIMDThreeSameVectorFMLIndex<bit Q, bit U, bits<4> opc, string asm,
8513+
class BaseSIMDThreeSameVectorIndexH<bit Q, bit U, bits<2> sz, bits<4> opc, string asm,
85148514
string dst_kind, string lhs_kind,
85158515
string rhs_kind, RegisterOperand RegType,
8516-
ValueType AccumType, ValueType InputType,
8517-
SDPatternOperator OpNode> :
8518-
BaseSIMDIndexedTied<Q, U, 0, 0b10, opc, RegType, RegType, V128_lo,
8516+
RegisterOperand RegType_lo, ValueType AccumType,
8517+
ValueType InputType, SDPatternOperator OpNode> :
8518+
BaseSIMDIndexedTied<Q, U, 0, sz, opc, RegType, RegType, RegType_lo,
85198519
VectorIndexH, asm, "", dst_kind, lhs_kind, rhs_kind,
85208520
[(set (AccumType RegType:$dst),
85218521
(AccumType (OpNode (AccumType RegType:$Rd),
@@ -8531,10 +8531,10 @@ class BaseSIMDThreeSameVectorFMLIndex<bit Q, bit U, bits<4> opc, string asm,
85318531

85328532
multiclass SIMDThreeSameVectorFMLIndex<bit U, bits<4> opc, string asm,
85338533
SDPatternOperator OpNode> {
8534-
def v4f16 : BaseSIMDThreeSameVectorFMLIndex<0, U, opc, asm, ".2s", ".2h", ".h",
8535-
V64, v2f32, v4f16, OpNode>;
8536-
def v8f16 : BaseSIMDThreeSameVectorFMLIndex<1, U, opc, asm, ".4s", ".4h", ".h",
8537-
V128, v4f32, v8f16, OpNode>;
8534+
def v4f16 : BaseSIMDThreeSameVectorIndexH<0, U, 0b10, opc, asm, ".2s", ".2h", ".h",
8535+
V64, V128_lo, v2f32, v4f16, OpNode>;
8536+
def v8f16 : BaseSIMDThreeSameVectorIndexH<1, U, 0b10, opc, asm, ".4s", ".4h", ".h",
8537+
V128, V128_lo, v4f32, v8f16, OpNode>;
85388538
}
85398539

85408540
multiclass SIMDFPIndexed<bit U, bits<4> opc, string asm,

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ defm USDOTlane : SIMDThreeSameVectorDotIndex<0, 1, 0b10, "usdot", int_aarch64_ne
12061206
class BaseSIMDSUDOTIndex<bit Q, string dst_kind, string lhs_kind,
12071207
string rhs_kind, RegisterOperand RegType,
12081208
ValueType AccumType, ValueType InputType>
1209-
: BaseSIMDThreeSameVectorDotIndex<Q, 0, 1, 0b00, "sudot", dst_kind,
1209+
: BaseSIMDThreeSameVectorIndexS<Q, 0, 0b00, 0b1111, "sudot", dst_kind,
12101210
lhs_kind, rhs_kind, RegType, AccumType,
12111211
InputType, null_frag> {
12121212
let Pattern = [(set (AccumType RegType:$dst),

0 commit comments

Comments
 (0)