diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -53,6 +53,8 @@ bool HasMatmulFP32; bool HasLSE; bool HasFlagM; + bool HasHBC; + bool HasMOPS; llvm::AArch64::ArchKind ArchKind; diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -543,6 +543,8 @@ HasMatmulFP64 = false; HasMatmulFP32 = false; HasLSE = false; + HasHBC = false; + HasMOPS = false; ArchKind = llvm::AArch64::ArchKind::INVALID; @@ -658,6 +660,26 @@ HasRandGen = true; if (Feature == "+flagm") HasFlagM = true; + if (Feature == "+hbc") + HasHBC = true; + if (Feature == "+mops") + HasMOPS = true; + } + + HasHBC |= ArchKind == llvm::AArch64::ArchKind::ARMV8_8A || + ArchKind == llvm::AArch64::ArchKind::ARMV9_3A; + + HasMOPS |= ArchKind == llvm::AArch64::ArchKind::ARMV8_8A || + ArchKind == llvm::AArch64::ArchKind::ARMV9_3A; + + // Check features that are manually disabled by command line options. + // This needs to be checked after architecture-related features are handled, + // making sure they are properly disabled when required. + for (const auto &Feature : Features) { + if (Feature == "-hbc") + HasHBC = false; + if (Feature == "-mops") + HasMOPS = false; } setDataLayout(); diff --git a/clang/test/Driver/aarch64-hbc.c b/clang/test/Driver/aarch64-hbc.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/aarch64-hbc.c @@ -0,0 +1,12 @@ +// Test that target feature hbc is implemented and available correctly +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+hbc %s 2>&1 | FileCheck %s +// CHECK: "-target-feature" "+hbc" + +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+nohbc %s 2>&1 | FileCheck %s --check-prefix=NO_HBC +// NO_HBC: "-target-feature" "-hbc" + +// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENT_HBC +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a %s 2>&1 | FileCheck %s --check-prefix=ABSENT_HBC +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a %s 2>&1 | FileCheck %s --check-prefix=ABSENT_HBC +// ABSENT_HBC-NOT: "-target-feature" "+hbc" +// ABSENT_HBC-NOT: "-target-feature" "-hbc" diff --git a/llvm/include/llvm/Support/AArch64TargetParser.h b/llvm/include/llvm/Support/AArch64TargetParser.h --- a/llvm/include/llvm/Support/AArch64TargetParser.h +++ b/llvm/include/llvm/Support/AArch64TargetParser.h @@ -69,6 +69,8 @@ AEK_SME = 1ULL << 37, AEK_SMEF64 = 1ULL << 38, AEK_SMEI64 = 1ULL << 39, + AEK_MOPS = 1ULL << 40, + AEK_HBC = 1ULL << 41, }; enum class ArchKind { diff --git a/llvm/include/llvm/Support/AArch64TargetParser.def b/llvm/include/llvm/Support/AArch64TargetParser.def --- a/llvm/include/llvm/Support/AArch64TargetParser.def +++ b/llvm/include/llvm/Support/AArch64TargetParser.def @@ -144,6 +144,8 @@ AARCH64_ARCH_EXT_NAME("sme", AArch64::AEK_SME, "+sme", "-sme") AARCH64_ARCH_EXT_NAME("sme-f64", AArch64::AEK_SMEF64, "+sme-f64", "-sme-f64") AARCH64_ARCH_EXT_NAME("sme-i64", AArch64::AEK_SMEI64, "+sme-i64", "-sme-i64") +AARCH64_ARCH_EXT_NAME("hbc", AArch64::AEK_HBC, "+hbc", "-hbc") +AARCH64_ARCH_EXT_NAME("mops", AArch64::AEK_MOPS, "+mops", "-mops") #undef AARCH64_ARCH_EXT_NAME #ifndef AARCH64_CPU_NAME diff --git a/llvm/lib/Support/AArch64TargetParser.cpp b/llvm/lib/Support/AArch64TargetParser.cpp --- a/llvm/lib/Support/AArch64TargetParser.cpp +++ b/llvm/lib/Support/AArch64TargetParser.cpp @@ -114,6 +114,10 @@ Features.push_back("+sme-f64"); if (Extensions & AArch64::AEK_SMEI64) Features.push_back("+sme-i64"); + if (Extensions & AArch64::AEK_HBC) + Features.push_back("+hbc"); + if (Extensions & AArch64::AEK_MOPS) + Features.push_back("+mops"); return true; } diff --git a/llvm/unittests/Support/TargetParserTest.cpp b/llvm/unittests/Support/TargetParserTest.cpp --- a/llvm/unittests/Support/TargetParserTest.cpp +++ b/llvm/unittests/Support/TargetParserTest.cpp @@ -1521,6 +1521,8 @@ {"sme", "nosme", "+sme", "-sme"}, {"sme-f64", "nosme-f64", "+sme-f64", "-sme-f64"}, {"sme-i64", "nosme-i64", "+sme-i64", "-sme-i64"}, + {"hbc", "nohbc", "+hbc", "-hbc"}, + {"mops", "nomops", "+mops", "-mops"}, }; for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {