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+pmuv3 %s 2>&1 | FileCheck --check-prefix=CHECK-PERFMON %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.2a+pmuv3 %s 2>&1 | FileCheck --check-prefix=CHECK-PERFMON %s +// CHECK-PERFMON: "-target-feature" "+perfmon" + +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.4a+nopmuv3 %s 2>&1 | FileCheck --check-prefix=CHECK-NOPERFMON %s +// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.2a+nopmuv3 %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: 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("pmuv3", AArch64::AEK_PERFMON, "+perfmon", "-perfmon") #undef AARCH64_ARCH_EXT_NAME #ifndef AARCH64_CPU_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 @@ -1428,17 +1428,14 @@ TEST(TargetParserTest, AArch64ExtensionFeatures) { std::vector Extensions = { - AArch64::AEK_CRC, AArch64::AEK_CRYPTO, - AArch64::AEK_FP, AArch64::AEK_SIMD, - AArch64::AEK_FP16, AArch64::AEK_PROFILE, - AArch64::AEK_RAS, AArch64::AEK_LSE, - AArch64::AEK_RDM, AArch64::AEK_DOTPROD, - AArch64::AEK_SVE, AArch64::AEK_SVE2, - AArch64::AEK_SVE2AES, AArch64::AEK_SVE2SM4, - AArch64::AEK_SVE2SHA3, AArch64::AEK_SVE2BITPERM, - AArch64::AEK_RCPC, AArch64::AEK_FP16FML, - AArch64::AEK_SME, AArch64::AEK_SMEF64, - AArch64::AEK_SMEI64 }; + AArch64::AEK_CRC, AArch64::AEK_CRYPTO, AArch64::AEK_FP, + AArch64::AEK_SIMD, AArch64::AEK_FP16, AArch64::AEK_PROFILE, + AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_RDM, + AArch64::AEK_DOTPROD, AArch64::AEK_SVE, AArch64::AEK_SVE2, + AArch64::AEK_SVE2AES, AArch64::AEK_SVE2SM4, AArch64::AEK_SVE2SHA3, + AArch64::AEK_SVE2BITPERM, AArch64::AEK_RCPC, AArch64::AEK_FP16FML, + AArch64::AEK_SME, AArch64::AEK_SMEF64, AArch64::AEK_SMEI64, + AArch64::AEK_PERFMON}; std::vector Features; @@ -1473,6 +1470,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) { @@ -1485,43 +1483,41 @@ } TEST(TargetParserTest, AArch64ArchExtFeature) { - const char *ArchExt[][4] = {{"crc", "nocrc", "+crc", "-crc"}, - {"crypto", "nocrypto", "+crypto", "-crypto"}, - {"flagm", "noflagm", "+flagm", "-flagm"}, - {"fp", "nofp", "+fp-armv8", "-fp-armv8"}, - {"simd", "nosimd", "+neon", "-neon"}, - {"fp16", "nofp16", "+fullfp16", "-fullfp16"}, - {"fp16fml", "nofp16fml", "+fp16fml", "-fp16fml"}, - {"profile", "noprofile", "+spe", "-spe"}, - {"ras", "noras", "+ras", "-ras"}, - {"lse", "nolse", "+lse", "-lse"}, - {"rdm", "nordm", "+rdm", "-rdm"}, - {"sve", "nosve", "+sve", "-sve"}, - {"sve2", "nosve2", "+sve2", "-sve2"}, - {"sve2-aes", "nosve2-aes", "+sve2-aes", - "-sve2-aes"}, - {"sve2-sm4", "nosve2-sm4", "+sve2-sm4", - "-sve2-sm4"}, - {"sve2-sha3", "nosve2-sha3", "+sve2-sha3", - "-sve2-sha3"}, - {"sve2-bitperm", "nosve2-bitperm", - "+sve2-bitperm", "-sve2-bitperm"}, - {"dotprod", "nodotprod", "+dotprod", "-dotprod"}, - {"rcpc", "norcpc", "+rcpc", "-rcpc" }, - {"rng", "norng", "+rand", "-rand"}, - {"memtag", "nomemtag", "+mte", "-mte"}, - {"tme", "notme", "+tme", "-tme"}, - {"pauth", "nopauth", "+pauth", "-pauth"}, - {"ssbs", "nossbs", "+ssbs", "-ssbs"}, - {"sb", "nosb", "+sb", "-sb"}, - {"predres", "nopredres", "+predres", "-predres"}, - {"i8mm", "noi8mm", "+i8mm", "-i8mm"}, - {"f32mm", "nof32mm", "+f32mm", "-f32mm"}, - {"f64mm", "nof64mm", "+f64mm", "-f64mm"}, - {"sme", "nosme", "+sme", "-sme"}, - {"sme-f64", "nosme-f64", "+sme-f64", "-sme-f64"}, - {"sme-i64", "nosme-i64", "+sme-i64", "-sme-i64"}, -}; + const char *ArchExt[][4] = { + {"crc", "nocrc", "+crc", "-crc"}, + {"crypto", "nocrypto", "+crypto", "-crypto"}, + {"flagm", "noflagm", "+flagm", "-flagm"}, + {"fp", "nofp", "+fp-armv8", "-fp-armv8"}, + {"simd", "nosimd", "+neon", "-neon"}, + {"fp16", "nofp16", "+fullfp16", "-fullfp16"}, + {"fp16fml", "nofp16fml", "+fp16fml", "-fp16fml"}, + {"profile", "noprofile", "+spe", "-spe"}, + {"ras", "noras", "+ras", "-ras"}, + {"lse", "nolse", "+lse", "-lse"}, + {"rdm", "nordm", "+rdm", "-rdm"}, + {"sve", "nosve", "+sve", "-sve"}, + {"sve2", "nosve2", "+sve2", "-sve2"}, + {"sve2-aes", "nosve2-aes", "+sve2-aes", "-sve2-aes"}, + {"sve2-sm4", "nosve2-sm4", "+sve2-sm4", "-sve2-sm4"}, + {"sve2-sha3", "nosve2-sha3", "+sve2-sha3", "-sve2-sha3"}, + {"sve2-bitperm", "nosve2-bitperm", "+sve2-bitperm", "-sve2-bitperm"}, + {"dotprod", "nodotprod", "+dotprod", "-dotprod"}, + {"rcpc", "norcpc", "+rcpc", "-rcpc"}, + {"rng", "norng", "+rand", "-rand"}, + {"memtag", "nomemtag", "+mte", "-mte"}, + {"tme", "notme", "+tme", "-tme"}, + {"pauth", "nopauth", "+pauth", "-pauth"}, + {"ssbs", "nossbs", "+ssbs", "-ssbs"}, + {"sb", "nosb", "+sb", "-sb"}, + {"predres", "nopredres", "+predres", "-predres"}, + {"i8mm", "noi8mm", "+i8mm", "-i8mm"}, + {"f32mm", "nof32mm", "+f32mm", "-f32mm"}, + {"f64mm", "nof64mm", "+f64mm", "-f64mm"}, + {"sme", "nosme", "+sme", "-sme"}, + {"sme-f64", "nosme-f64", "+sme-f64", "-sme-f64"}, + {"sme-i64", "nosme-i64", "+sme-i64", "-sme-i64"}, + {"pmuv3", "nopmuv3", "+perfmon", "-perfmon"}, + }; for (unsigned i = 0; i < array_lengthof(ArchExt); i++) { EXPECT_EQ(StringRef(ArchExt[i][2]),