Skip to content

Commit 9e42675

Browse files
committed
[AArch64] Add target features for Armv9-A Scalable Matrix Extension (SME)
First patch in a series adding MC layer support for the Arm Scalable Matrix Extension. This patch adds the following features: sme, sme-i64, sme-f64 The sme-i64 and sme-f64 flags are for the optional I16I64 and F64F64 features. If a target supports I16I64 then the following instructions are implemented: * 64-bit integer ADDHA and ADDVA variants (D105570). * SMOPA, SMOPS, SUMOPA, SUMOPS, UMOPA, UMOPS, USMOPA, and USMOPS instructions that accumulate 16-bit integer outer products into 64-bit integer tiles. If a target supports F64F64 then the FMOPA and FMOPS instructions that accumulate double-precision floating-point outer products into double-precision tiles are implemented. Outer products are implemented in D105571. The reference can be found here: https://developer.arm.com/documentation/ddi0602/2021-06 Reviewed By: CarolineConcatto Differential Revision: https://reviews.llvm.org/D105569
1 parent 8253fa2 commit 9e42675

18 files changed

+83
-11
lines changed

llvm/include/llvm/Support/AArch64TargetParser.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ AARCH64_ARCH_EXT_NAME("ls64", AArch64::AEK_LS64, "+ls64", "-ls64
110110
AARCH64_ARCH_EXT_NAME("brbe", AArch64::AEK_BRBE, "+brbe", "-brbe")
111111
AARCH64_ARCH_EXT_NAME("pauth", AArch64::AEK_PAUTH, "+pauth", "-pauth")
112112
AARCH64_ARCH_EXT_NAME("flagm", AArch64::AEK_FLAGM, "+flagm", "-flagm")
113+
AARCH64_ARCH_EXT_NAME("sme", AArch64::AEK_SME, "+sme", "-sme")
114+
AARCH64_ARCH_EXT_NAME("sme-f64", AArch64::AEK_SMEF64, "+sme-f64", "-sme-f64")
115+
AARCH64_ARCH_EXT_NAME("sme-i64", AArch64::AEK_SMEI64, "+sme-i64", "-sme-i64")
113116
#undef AARCH64_ARCH_EXT_NAME
114117

115118
#ifndef AARCH64_CPU_NAME

llvm/include/llvm/Support/AArch64TargetParser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ enum ArchExtKind : uint64_t {
6666
AEK_BRBE = 1ULL << 34,
6767
AEK_PAUTH = 1ULL << 35,
6868
AEK_FLAGM = 1ULL << 36,
69+
AEK_SME = 1ULL << 37,
70+
AEK_SMEF64 = 1ULL << 38,
71+
AEK_SMEI64 = 1ULL << 39,
6972
};
7073

7174
enum class ArchKind {

llvm/lib/Support/AArch64TargetParser.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ bool AArch64::getExtensionFeatures(uint64_t Extensions,
106106
Features.push_back("+pauth");
107107
if (Extensions & AEK_FLAGM)
108108
Features.push_back("+flagm");
109+
if (Extensions & AArch64::AEK_SME)
110+
Features.push_back("+sme");
111+
if (Extensions & AArch64::AEK_SMEF64)
112+
Features.push_back("+sme-f64");
113+
if (Extensions & AArch64::AEK_SMEI64)
114+
Features.push_back("+sme-i64");
109115

110116
return true;
111117
}

llvm/lib/Target/AArch64/AArch64.td

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,17 @@ def FeatureEnhancedCounterVirtualization :
429429
def FeatureRME : SubtargetFeature<"rme", "HasRME",
430430
"true", "Enable Realm Management Extension">;
431431

432+
// FIXME: SME should only imply the subset of SVE(2) instructions that are
433+
// legal in streaming mode.
434+
def FeatureSME : SubtargetFeature<"sme", "HasSME", "true",
435+
"Enable Scalable Matrix Extension (SME)", [FeatureSVE2, FeatureBF16]>;
436+
437+
def FeatureSMEF64 : SubtargetFeature<"sme-f64", "HasSMEF64", "true",
438+
"Enable Scalable Matrix Extension (SME) F64F64 instructions", [FeatureSME]>;
439+
440+
def FeatureSMEI64 : SubtargetFeature<"sme-i64", "HasSMEI64", "true",
441+
"Enable Scalable Matrix Extension (SME) I16I64 instructions", [FeatureSME]>;
442+
432443
//===----------------------------------------------------------------------===//
433444
// Architectures.
434445
//
@@ -549,6 +560,10 @@ def PAUnsupported : AArch64Unsupported {
549560
let F = [HasPAuth];
550561
}
551562

563+
def SMEUnsupported : AArch64Unsupported {
564+
let F = [HasSME, HasSMEF64, HasSMEI64];
565+
}
566+
552567
include "AArch64SchedA53.td"
553568
include "AArch64SchedA55.td"
554569
include "AArch64SchedA57.td"

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ def HasSVE2SHA3 : Predicate<"Subtarget->hasSVE2SHA3()">,
122122
AssemblerPredicate<(all_of FeatureSVE2SHA3), "sve2-sha3">;
123123
def HasSVE2BitPerm : Predicate<"Subtarget->hasSVE2BitPerm()">,
124124
AssemblerPredicate<(all_of FeatureSVE2BitPerm), "sve2-bitperm">;
125+
def HasSME : Predicate<"Subtarget->hasSME()">,
126+
AssemblerPredicate<(all_of FeatureSME), "sme">;
127+
def HasSMEF64 : Predicate<"Subtarget->hasSMEF64()">,
128+
AssemblerPredicate<(all_of FeatureSMEF64), "sme-f64">;
129+
def HasSMEI64 : Predicate<"Subtarget->hasSMEI64()">,
130+
AssemblerPredicate<(all_of FeatureSMEI64), "sme-i64">;
125131
def HasRCPC : Predicate<"Subtarget->hasRCPC()">,
126132
AssemblerPredicate<(all_of FeatureRCPC), "rcpc">;
127133
def HasAltNZCV : Predicate<"Subtarget->hasAlternativeNZCV()">,

llvm/lib/Target/AArch64/AArch64SchedA53.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def CortexA53Model : SchedMachineModel {
2727
let CompleteModel = 1;
2828

2929
list<Predicate> UnsupportedFeatures = !listconcat(SVEUnsupported.F,
30-
PAUnsupported.F);
30+
PAUnsupported.F,
31+
SMEUnsupported.F);
3132
}
3233

3334

llvm/lib/Target/AArch64/AArch64SchedA57.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def CortexA57Model : SchedMachineModel {
3232
let CompleteModel = 1;
3333

3434
list<Predicate> UnsupportedFeatures = !listconcat(SVEUnsupported.F,
35-
PAUnsupported.F);
35+
PAUnsupported.F,
36+
SMEUnsupported.F);
3637
}
3738

3839
//===----------------------------------------------------------------------===//

llvm/lib/Target/AArch64/AArch64SchedCyclone.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def CycloneModel : SchedMachineModel {
1919
let CompleteModel = 1;
2020

2121
list<Predicate> UnsupportedFeatures = !listconcat(SVEUnsupported.F,
22-
PAUnsupported.F);
22+
PAUnsupported.F,
23+
SMEUnsupported.F);
2324
}
2425

2526
//===----------------------------------------------------------------------===//

llvm/lib/Target/AArch64/AArch64SchedExynosM3.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def ExynosM3Model : SchedMachineModel {
2525
let CompleteModel = 1; // Use the default model otherwise.
2626

2727
list<Predicate> UnsupportedFeatures = !listconcat(SVEUnsupported.F,
28-
PAUnsupported.F);
28+
PAUnsupported.F,
29+
SMEUnsupported.F);
2930
}
3031

3132
//===----------------------------------------------------------------------===//

llvm/lib/Target/AArch64/AArch64SchedExynosM4.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def ExynosM4Model : SchedMachineModel {
2525
let CompleteModel = 1; // Use the default model otherwise.
2626

2727
list<Predicate> UnsupportedFeatures = !listconcat(SVEUnsupported.F,
28-
PAUnsupported.F);
28+
PAUnsupported.F,
29+
SMEUnsupported.F);
2930
}
3031

3132
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)