[llvm] [llvm][unittests] Put human-readable names on TargetParserTests. NFC (PR #80749)
Jon Roelofs via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 08:37:26 PST 2024
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/80749
>From b4f3ed4eb94cc5db405eac0669280dd7d0f8a730 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Mon, 5 Feb 2024 12:30:42 -0800
Subject: [PATCH 1/2] [llvm][unittests] Put human-readable names on some of the
TargetParserTests. NFC
---
.../TargetParser/TargetParserTest.cpp | 20 ++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp b/llvm/unittests/TargetParser/TargetParserTest.cpp
index cbd8fe18cd181..b80a0de14ac0b 100644
--- a/llvm/unittests/TargetParser/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -163,6 +163,17 @@ template <typename T> struct ARMCPUTestParams {
return os;
}
+ static std::function<std::string(const testing::TestParamInfo<ARMCPUTestParams<T>>& Info)>
+ PrintToStringParamName() {
+ return [](const testing::TestParamInfo<ARMCPUTestParams<T>>& Info) {
+ std::string Name = Info.param.CPUName.str();
+ for (char &C : Name)
+ if (!std::isalnum(C))
+ C = '_';
+ return Name;
+ };
+ }
+
StringRef CPUName;
StringRef ExpectedArch;
StringRef ExpectedFPU;
@@ -263,7 +274,8 @@ INSTANTIATE_TEST_SUITE_P(
ARM::AEK_SEC | ARM::AEK_VIRT | ARM::AEK_DSP,
"7-A"),
ARMCPUTestParams<uint64_t>("cortex-a8", "armv7-a", "neon",
- ARM::AEK_SEC | ARM::AEK_DSP, "7-A")));
+ ARM::AEK_SEC | ARM::AEK_DSP, "7-A")),
+ ARMCPUTestParams<uint64_t>::PrintToStringParamName());
// gtest in llvm has a limit of 50 test cases when using ::Values so we split
// them into 2 blocks
@@ -483,7 +495,8 @@ INSTANTIATE_TEST_SUITE_P(
ARMCPUTestParams<uint64_t>("xscale", "xscale", "none", ARM::AEK_NONE, "xscale"),
ARMCPUTestParams<uint64_t>("swift", "armv7s", "neon-vfpv4",
ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
- "7-S")));
+ "7-S")),
+ ARMCPUTestParams<uint64_t>::PrintToStringParamName());
static constexpr unsigned NumARMCPUArchs = 90;
@@ -1660,7 +1673,8 @@ INSTANTIATE_TEST_SUITE_P(
{AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_FP16,
AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_RDM})),
- "8.2-A")));
+ "8.2-A")),
+ ARMCPUTestParams<AArch64::ExtensionBitset>::PrintToStringParamName());
// Note: number of CPUs includes aliases.
static constexpr unsigned NumAArch64CPUArchs = 68;
>From db3d0c4b81ff56f8f8e14681818b8cf97398dbb6 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Tue, 6 Feb 2024 08:30:11 -0800
Subject: [PATCH 2/2] remove layer of std::function indirection
---
.../TargetParser/TargetParserTest.cpp | 22 +++++++++----------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp b/llvm/unittests/TargetParser/TargetParserTest.cpp
index b80a0de14ac0b..76f7b8f35aa53 100644
--- a/llvm/unittests/TargetParser/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -163,15 +163,13 @@ template <typename T> struct ARMCPUTestParams {
return os;
}
- static std::function<std::string(const testing::TestParamInfo<ARMCPUTestParams<T>>& Info)>
- PrintToStringParamName() {
- return [](const testing::TestParamInfo<ARMCPUTestParams<T>>& Info) {
- std::string Name = Info.param.CPUName.str();
- for (char &C : Name)
- if (!std::isalnum(C))
- C = '_';
- return Name;
- };
+ static std::string
+ PrintToStringParamName(const testing::TestParamInfo<ARMCPUTestParams<T>>& Info) {
+ std::string Name = Info.param.CPUName.str();
+ for (char &C : Name)
+ if (!std::isalnum(C))
+ C = '_';
+ return Name;
}
StringRef CPUName;
@@ -275,7 +273,7 @@ INSTANTIATE_TEST_SUITE_P(
"7-A"),
ARMCPUTestParams<uint64_t>("cortex-a8", "armv7-a", "neon",
ARM::AEK_SEC | ARM::AEK_DSP, "7-A")),
- ARMCPUTestParams<uint64_t>::PrintToStringParamName());
+ ARMCPUTestParams<uint64_t>::PrintToStringParamName);
// gtest in llvm has a limit of 50 test cases when using ::Values so we split
// them into 2 blocks
@@ -496,7 +494,7 @@ INSTANTIATE_TEST_SUITE_P(
ARMCPUTestParams<uint64_t>("swift", "armv7s", "neon-vfpv4",
ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
"7-S")),
- ARMCPUTestParams<uint64_t>::PrintToStringParamName());
+ ARMCPUTestParams<uint64_t>::PrintToStringParamName);
static constexpr unsigned NumARMCPUArchs = 90;
@@ -1674,7 +1672,7 @@ INSTANTIATE_TEST_SUITE_P(
AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_FP16,
AArch64::AEK_RAS, AArch64::AEK_LSE, AArch64::AEK_RDM})),
"8.2-A")),
- ARMCPUTestParams<AArch64::ExtensionBitset>::PrintToStringParamName());
+ ARMCPUTestParams<AArch64::ExtensionBitset>::PrintToStringParamName);
// Note: number of CPUs includes aliases.
static constexpr unsigned NumAArch64CPUArchs = 68;
More information about the llvm-commits
mailing list