Skip to content

Commit 2617023

Browse files
authored
[clang][AArch64] Add SME2.1 feature macros (llvm#105657)
1 parent b084111 commit 2617023

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,23 +471,25 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
471471
if (HasSVE2 && HasSVE2SM4)
472472
Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
473473

474+
if (HasSVEB16B16)
475+
Builder.defineMacro("__ARM_FEATURE_SVE_B16B16", "1");
476+
474477
if (HasSME) {
475478
Builder.defineMacro("__ARM_FEATURE_SME");
476479
Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
477480
}
478481

479-
if (HasSME2) {
480-
Builder.defineMacro("__ARM_FEATURE_SME", "1");
482+
if (HasSME2)
481483
Builder.defineMacro("__ARM_FEATURE_SME2", "1");
482-
Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
483-
}
484484

485-
if (HasSME2p1) {
486-
Builder.defineMacro("__ARM_FEATURE_SME", "1");
487-
Builder.defineMacro("__ARM_FEATURE_SME2", "1");
485+
if (HasSME2p1)
488486
Builder.defineMacro("__ARM_FEATURE_SME2p1", "1");
489-
Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
490-
}
487+
488+
if (HasSMEF16F16)
489+
Builder.defineMacro("__ARM_FEATURE_SME_F16F16", "1");
490+
491+
if (HasSMEB16B16)
492+
Builder.defineMacro("__ARM_FEATURE_SME_B16B16", "1");
491493

492494
if (HasCRC)
493495
Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
@@ -749,6 +751,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
749751
.Case("sve", FPU & SveMode)
750752
.Case("sve-bf16", FPU & SveMode && HasBFloat16)
751753
.Case("sve-i8mm", FPU & SveMode && HasMatMul)
754+
.Case("sve-b16b16", HasSVEB16B16)
752755
.Case("f32mm", FPU & SveMode && HasMatmulFP32)
753756
.Case("f64mm", FPU & SveMode && HasMatmulFP64)
754757
.Case("sve2", FPU & SveMode && HasSVE2)
@@ -763,6 +766,8 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
763766
.Case("sme-f64f64", HasSMEF64F64)
764767
.Case("sme-i16i64", HasSMEI16I64)
765768
.Case("sme-fa64", HasSMEFA64)
769+
.Case("sme-f16f16", HasSMEF16F16)
770+
.Case("sme-b16b16", HasSMEB16B16)
766771
.Cases("memtag", "memtag2", HasMTE)
767772
.Case("sb", HasSB)
768773
.Case("predres", HasPredRes)
@@ -863,6 +868,8 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
863868
HasSVE2 = true;
864869
HasSVE2SM4 = true;
865870
}
871+
if (Feature == "+sve-b16b16")
872+
HasSVEB16B16 = true;
866873
if (Feature == "+sve2-bitperm") {
867874
FPU |= NeonMode;
868875
FPU |= SveMode;
@@ -919,6 +926,21 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
919926
HasSVE2 = true;
920927
HasSMEFA64 = true;
921928
}
929+
if (Feature == "+sme-f16f16") {
930+
HasSME = true;
931+
HasSME2 = true;
932+
HasBFloat16 = true;
933+
HasFullFP16 = true;
934+
HasSMEF16F16 = true;
935+
}
936+
if (Feature == "+sme-b16b16") {
937+
HasSME = true;
938+
HasSME2 = true;
939+
HasBFloat16 = true;
940+
HasFullFP16 = true;
941+
HasSVEB16B16 = true;
942+
HasSMEB16B16 = true;
943+
}
922944
if (Feature == "+sb")
923945
HasSB = true;
924946
if (Feature == "+predres")

clang/lib/Basic/Targets/AArch64.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
5353
bool HasSVE2AES = false;
5454
bool HasSVE2SHA3 = false;
5555
bool HasSVE2SM4 = false;
56+
bool HasSVEB16B16 = false;
5657
bool HasSVE2BitPerm = false;
5758
bool HasMatmulFP64 = false;
5859
bool HasMatmulFP32 = false;
@@ -71,6 +72,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
7172
bool HasSME2 = false;
7273
bool HasSMEF64F64 = false;
7374
bool HasSMEI16I64 = false;
75+
bool HasSMEF16F16 = false;
76+
bool HasSMEB16B16 = false;
7477
bool HasSME2p1 = false;
7578
bool HasSB = false;
7679
bool HasPredRes = false;

clang/test/Preprocessor/aarch64-target-features.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,3 +709,19 @@
709709
// CHECK-SME2p1: __ARM_FEATURE_SME 1
710710
// CHECK-SME2p1: __ARM_FEATURE_SME2 1
711711
// CHECK-SME2p1: __ARM_FEATURE_SME2p1 1
712+
713+
// RUN: %clang --target=aarch64 -march=armv9-a+sve-b16b16 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVEB16B16 %s
714+
// CHECK-SVEB16B16: __ARM_FEATURE_SVE_B16B16 1
715+
716+
// RUN: %clang --target=aarch64 -march=armv9-a+sme-f16f16 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SMEF16F16 %s
717+
// CHECK-SMEF16F16: __ARM_FEATURE_LOCALLY_STREAMING 1
718+
// CHECK-SMEF16F16: __ARM_FEATURE_SME 1
719+
// CHECK-SMEF16F16: __ARM_FEATURE_SME2 1
720+
// CHECK-SMEF16F16: __ARM_FEATURE_SME_F16F16 1
721+
722+
// RUN: %clang --target=aarch64 -march=armv9-a+sme-b16b16 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SMEB16B16 %s
723+
// CHECK-SMEB16B16: __ARM_FEATURE_LOCALLY_STREAMING 1
724+
// CHECK-SMEB16B16: __ARM_FEATURE_SME 1
725+
// CHECK-SMEB16B16: __ARM_FEATURE_SME2 1
726+
// CHECK-SMEB16B16: __ARM_FEATURE_SME_B16B16 1
727+
// CHECK-SMEB16B16: __ARM_FEATURE_SVE_B16B16 1

0 commit comments

Comments
 (0)