Index: clang/test/Driver/aarch64-perfmon.c =================================================================== --- /dev/null +++ clang/test/Driver/aarch64-perfmon.c @@ -0,0 +1,13 @@ +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+pmuv3p4 %s 2>&1 | FileCheck --check-prefix=CHECK-PERFMON %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.2a+pmuv3p4 %s 2>&1 | FileCheck --check-prefix=CHECK-PERFMON %s +// CHECK-PERFMON: "-target-feature" "+perfmon" + +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+nopmuv3p4 %s 2>&1 | FileCheck --check-prefix=CHECK-NOPERFMON %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.2a+nopmuv3p4 %s 2>&1 | FileCheck --check-prefix=CHECK-NOPERFMON %s +// CHECK-NOPERFMON: "-target-feature" "-perfmon" + +// RUN: %clang -### -target aarch64-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENTPERFMON +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a %s 2>&1 | FileCheck %s --check-prefix=ABSENTPERFMON +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.2a %s 2>&1 | FileCheck %s --check-prefix=ABSENTPERFMON +// ABSENTPERFMON-NOT: "-target-feature" "+perfmon" +// ABSENTPERFMON-NOT: "-target-feature" "-perfmon" \ No newline at end of file Index: clang/test/Driver/arm-perfmon.c =================================================================== --- /dev/null +++ clang/test/Driver/arm-perfmon.c @@ -0,0 +1,13 @@ +// RUN: %clang -### -target arm-none-none-eabi -march=armv8.4a+pmuv3p4 %s 2>&1 | FileCheck --check-prefix=CHECK-PERFMON %s +// RUN: %clang -### -target arm-none-none-eabi -march=armv8.2a+pmuv3p4 %s 2>&1 | FileCheck --check-prefix=CHECK-PERFMON %s +// CHECK-PERFMON: "-target-feature" "+perfmon" + +// RUN: %clang -### -target arm-none-none-eabi -march=armv8.4a+nopmuv3p4 %s 2>&1 | FileCheck --check-prefix=CHECK-NOPERFMON %s +// RUN: %clang -### -target arm-none-none-eabi -march=armv8.2a+nopmuv3p4 %s 2>&1 | FileCheck --check-prefix=CHECK-NOPERFMON %s +// CHECK-NOPERFMON: "-target-feature" "-perfmon" + +// RUN: %clang -### -target arm-none-none-eabi %s 2>&1 | FileCheck %s --check-prefix=ABSENTPERFMON +// RUN: %clang -### -target arm-none-none-eabi -march=armv8.4a %s 2>&1 | FileCheck %s --check-prefix=ABSENTPERFMON +// RUN: %clang -### -target arm-none-none-eabi -march=armv8.2a %s 2>&1 | FileCheck %s --check-prefix=ABSENTPERFMON +// ABSENTPERFMON-NOT: "-target-feature" "+perfmon" +// ABSENTPERFMON-NOT: "-target-feature" "-perfmon" \ No newline at end of file Index: llvm/include/llvm/Support/AArch64TargetParser.h =================================================================== --- llvm/include/llvm/Support/AArch64TargetParser.h +++ llvm/include/llvm/Support/AArch64TargetParser.h @@ -69,6 +69,7 @@ AEK_SME = 1ULL << 37, AEK_SMEF64 = 1ULL << 38, AEK_SMEI64 = 1ULL << 39, + AEK_PERFMON = 1ULL << 40, }; enum class ArchKind { Index: llvm/include/llvm/Support/AArch64TargetParser.def =================================================================== --- llvm/include/llvm/Support/AArch64TargetParser.def +++ llvm/include/llvm/Support/AArch64TargetParser.def @@ -144,6 +144,7 @@ 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("pmuv3p4", AArch64::AEK_PERFMON, "+perfmon", "-perfmon") #undef AARCH64_ARCH_EXT_NAME #ifndef AARCH64_CPU_NAME Index: llvm/include/llvm/Support/ARMTargetParser.h =================================================================== --- llvm/include/llvm/Support/ARMTargetParser.h +++ llvm/include/llvm/Support/ARMTargetParser.h @@ -60,6 +60,7 @@ AEK_CDECP6 = 1 << 28, AEK_CDECP7 = 1 << 29, AEK_PACBTI = 1 << 30, + AEK_PERFMON = 1ULL << 31, // Unsupported extensions. AEK_OS = 1ULL << 59, AEK_IWMMXT = 1ULL << 60, Index: llvm/include/llvm/Support/ARMTargetParser.def =================================================================== --- llvm/include/llvm/Support/ARMTargetParser.def +++ llvm/include/llvm/Support/ARMTargetParser.def @@ -213,6 +213,7 @@ ARM_ARCH_EXT_NAME("cdecp6", ARM::AEK_CDECP6, "+cdecp6", "-cdecp6") ARM_ARCH_EXT_NAME("cdecp7", ARM::AEK_CDECP7, "+cdecp7", "-cdecp7") ARM_ARCH_EXT_NAME("pacbti", ARM::AEK_PACBTI, "+pacbti", "-pacbti") +ARM_ARCH_EXT_NAME("pmuv3p4", ARM::AEK_PERFMON, "+perfmon", "-perfmon") #undef ARM_ARCH_EXT_NAME #ifndef ARM_HW_DIV_NAME Index: llvm/lib/Support/AArch64TargetParser.cpp =================================================================== --- llvm/lib/Support/AArch64TargetParser.cpp +++ llvm/lib/Support/AArch64TargetParser.cpp @@ -114,6 +114,8 @@ Features.push_back("+sme-f64"); if (Extensions & AArch64::AEK_SMEI64) Features.push_back("+sme-i64"); + if (Extensions & AArch64::AEK_PERFMON) + Features.push_back("+perfmon"); return true; } Index: llvm/unittests/Support/TargetParserTest.cpp =================================================================== --- llvm/unittests/Support/TargetParserTest.cpp +++ llvm/unittests/Support/TargetParserTest.cpp @@ -728,7 +728,8 @@ {"sb", "nosb", "+sb", "-sb"}, {"i8mm", "noi8mm", "+i8mm", "-i8mm"}, {"mve", "nomve", "+mve", "-mve"}, - {"mve.fp", "nomve.fp", "+mve.fp", "-mve.fp"}}; + {"mve.fp", "nomve.fp", "+mve.fp", "-mve.fp"}, + {"pmuv3p4", "nopmuv3p4", "+perfmon", "-perfmon"}}; for (unsigned i = 0; i < array_lengthof(ArchExt); i++) { EXPECT_EQ(StringRef(ArchExt[i][2]), ARM::getArchExtFeature(ArchExt[i][0])); @@ -1438,7 +1439,7 @@ AArch64::AEK_SVE2SHA3, AArch64::AEK_SVE2BITPERM, AArch64::AEK_RCPC, AArch64::AEK_FP16FML, AArch64::AEK_SME, AArch64::AEK_SMEF64, - AArch64::AEK_SMEI64 }; + AArch64::AEK_SMEI64, AArch64::AEK_PERFMON}; std::vector Features; @@ -1473,6 +1474,7 @@ EXPECT_TRUE(llvm::is_contained(Features, "+sme")); EXPECT_TRUE(llvm::is_contained(Features, "+sme-f64")); EXPECT_TRUE(llvm::is_contained(Features, "+sme-i64")); + EXPECT_TRUE(llvm::is_contained(Features, "+perfmon")); } TEST(TargetParserTest, AArch64ArchFeatures) { @@ -1521,6 +1523,7 @@ {"sme", "nosme", "+sme", "-sme"}, {"sme-f64", "nosme-f64", "+sme-f64", "-sme-f64"}, {"sme-i64", "nosme-i64", "+sme-i64", "-sme-i64"}, + {"pmuv3p4", "nopmuv3p4", "+perfmon", "-perfmon"}, }; for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {