[llvm] r343897 - [AArch64] -mcpu=native CPU detection for Cavium processors
Joel Jones via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 5 15:23:21 PDT 2018
Author: joel_k_jones
Date: Fri Oct 5 15:23:21 2018
New Revision: 343897
URL: http://llvm.org/viewvc/llvm-project?rev=343897&view=rev
Log:
[AArch64] -mcpu=native CPU detection for Cavium processors
This small patch updates the CPU detection for Cavium processors when
-mcpu=native is passed on compile-line.
Patch by Stefan Teleman
Differential Revision: https://reviews.llvm.org/D51939
Modified:
llvm/trunk/lib/Support/Host.cpp
llvm/trunk/unittests/Support/Host.cpp
Modified: llvm/trunk/lib/Support/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=343897&r1=343896&r2=343897&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Host.cpp (original)
+++ llvm/trunk/lib/Support/Host.cpp Fri Oct 5 15:23:21 2018
@@ -196,6 +196,21 @@ StringRef sys::detail::getHostCPUNameFor
.Default("generic");
}
+ if (Implementer == "0x42" || Implementer == "0x43") { // Broadcom | Cavium.
+ for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
+ if (Lines[I].startswith("CPU part")) {
+ return StringSwitch<const char *>(Lines[I].substr(8).ltrim("\t :"))
+ .Case("0x516", "thunderx2t99")
+ .Case("0x0516", "thunderx2t99")
+ .Case("0xaf", "thunderx2t99")
+ .Case("0x0af", "thunderx2t99")
+ .Case("0xa1", "thunderxt88")
+ .Case("0x0a1", "thunderxt88")
+ .Default("generic");
+ }
+ }
+ }
+
if (Implementer == "0x51") // Qualcomm Technologies, Inc.
// Look for the CPU part line.
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
Modified: llvm/trunk/unittests/Support/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Host.cpp?rev=343897&r1=343896&r2=343897&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Host.cpp (original)
+++ llvm/trunk/unittests/Support/Host.cpp Fri Oct 5 15:23:21 2018
@@ -170,6 +170,78 @@ CPU architecture: 8
"CPU variant : 0x4\n"
"CPU part : 0x001"),
"exynos-m2");
+
+ const std::string ThunderX2T99ProcCpuInfo = R"(
+processor : 0
+BogoMIPS : 400.00
+Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics
+CPU implementer : 0x43
+CPU architecture: 8
+CPU variant : 0x1
+CPU part : 0x0af
+)";
+
+ // Verify different versions of ThunderX2T99.
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderX2T99ProcCpuInfo +
+ "CPU implementer : 0x42\n"
+ "CPU part : 0x516"),
+ "thunderx2t99");
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderX2T99ProcCpuInfo +
+ "CPU implementer : 0x42\n"
+ "CPU part : 0x0516"),
+ "thunderx2t99");
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderX2T99ProcCpuInfo +
+ "CPU implementer : 0x43\n"
+ "CPU part : 0x516"),
+ "thunderx2t99");
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderX2T99ProcCpuInfo +
+ "CPU implementer : 0x43\n"
+ "CPU part : 0x0516"),
+ "thunderx2t99");
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderX2T99ProcCpuInfo +
+ "CPU implementer : 0x42\n"
+ "CPU part : 0xaf"),
+ "thunderx2t99");
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderX2T99ProcCpuInfo +
+ "CPU implementer : 0x42\n"
+ "CPU part : 0x0af"),
+ "thunderx2t99");
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderX2T99ProcCpuInfo +
+ "CPU implementer : 0x43\n"
+ "CPU part : 0xaf"),
+ "thunderx2t99");
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderX2T99ProcCpuInfo +
+ "CPU implementer : 0x43\n"
+ "CPU part : 0x0af"),
+ "thunderx2t99");
+
+ // Verify ThunderXT88.
+ const std::string ThunderXT88ProcCpuInfo = R"(
+processor : 0
+BogoMIPS : 200.00
+Features : fp asimd evtstrm aes pmull sha1 sha2 crc32
+CPU implementer : 0x43
+CPU architecture: 8
+CPU variant : 0x1
+CPU part : 0x0a1
+)";
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderXT88ProcCpuInfo +
+ "CPU implementer : 0x43\n"
+ "CPU part : 0x0a1"),
+ "thunderxt88");
+
+ EXPECT_EQ(sys::detail::getHostCPUNameForARM(ThunderXT88ProcCpuInfo +
+ "CPU implementer : 0x43\n"
+ "CPU part : 0xa1"),
+ "thunderxt88");
}
#if defined(__APPLE__)
More information about the llvm-commits
mailing list