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,7 @@ bool HasMatmulFP32; bool HasLSE; bool HasFlagM; + bool HasHBC; 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,7 @@ HasMatmulFP64 = false; HasMatmulFP32 = false; HasLSE = false; + HasHBC = false; ArchKind = llvm::AArch64::ArchKind::INVALID; @@ -658,6 +659,19 @@ HasRandGen = true; if (Feature == "+flagm") HasFlagM = true; + if (Feature == "+hbc") + HasHBC = true; + } + + HasHBC |= 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; } 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 @@ -70,6 +70,7 @@ AEK_SMEF64 = 1ULL << 38, AEK_SMEI64 = 1ULL << 39, AEK_PERFMON = 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 @@ -145,6 +145,7 @@ 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("pmuv3p4", AArch64::AEK_PERFMON, "+perfmon", "-perfmon") +AARCH64_ARCH_EXT_NAME("hbc", AArch64::AEK_HBC, "+hbc", "-hbc") #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 @@ -116,6 +116,8 @@ Features.push_back("+sme-i64"); if (Extensions & AArch64::AEK_PERFMON) Features.push_back("+perfmon"); + if (Extensions & AArch64::AEK_HBC) + Features.push_back("+hbc"); 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 @@ -1518,6 +1518,7 @@ {"sme-f64", "nosme-f64", "+sme-f64", "-sme-f64"}, {"sme-i64", "nosme-i64", "+sme-i64", "-sme-i64"}, {"pmuv3p4", "nopmuv3p4", "+perfmon", "-perfmon"}, + {"hbc", "nohbc", "+hbc", "-hbc"}, }; for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {