llvm.org GIT mirror llvm / 5f4e285
Make naming in Host.h in line with coding standards. Based on post-commit review comments by Chandler Carruth on https://reviews.llvm.org/D31236. Thanks! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299211 91177308-0d34-0410-b5e6-96231b3b80d8 Kristof Beyls 3 years ago
5 changed file(s) with 29 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
7676 /// Returns -1 if unknown for the current host system.
7777 int getHostNumPhysicalCores();
7878
79 /// helper functions to extract HostCPUName from /proc/cpuinfo on linux.
80 namespace LinuxReadCpuInfo {
81 StringRef getHostCPUName_powerpc(const StringRef &ProcCpuinfoContent);
82 StringRef getHostCPUName_arm(const StringRef &ProcCpuinfoContent);
83 StringRef getHostCPUName_s390x(const StringRef &ProcCpuinfoContent);
79 namespace detail {
80 /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
81 StringRef getHostCPUNameForPowerPC(const StringRef &ProcCpuinfoContent);
82 StringRef getHostCPUNameForARM(const StringRef &ProcCpuinfoContent);
83 StringRef getHostCPUNameForS390x(const StringRef &ProcCpuinfoContent);
8484 }
8585 }
8686 }
111111 static_assert(std::numeric_limits::is_integer &&
112112 !std::numeric_limits::is_signed,
113113 "Only unsigned integral types are allowed.");
114 return detail::TrailingZerosCounter::count(Val, ZB);
114 return llvm::detail::TrailingZerosCounter::count(Val, ZB);
115115 }
116116
117117 namespace detail {
180180 static_assert(std::numeric_limits::is_integer &&
181181 !std::numeric_limits::is_signed,
182182 "Only unsigned integral types are allowed.");
183 return detail::LeadingZerosCounter::count(Val, ZB);
183 return llvm::detail::LeadingZerosCounter::count(Val, ZB);
184184 }
185185
186186 /// \brief Get the index of the first set bit starting from the least
1515
1616 using namespace sys;
1717
18 const char detail::unit>::value[] = "h";
19 const char detail::unit>::value[] = "m";
20 const char detail::unit>::value[] = "s";
21 const char detail::unit::value[] = "ms";
22 const char detail::unit::value[] = "us";
23 const char detail::unit::value[] = "ns";
18 const char llvm::detail::unit>::value[] = "h";
19 const char llvm::detail::unit>::value[] = "m";
20 const char llvm::detail::unit>::value[] = "s";
21 const char llvm::detail::unit::value[] = "ms";
22 const char llvm::detail::unit::value[] = "us";
23 const char llvm::detail::unit::value[] = "ns";
2424
2525 static inline struct tm getStructTM(TimePoint<> TP) {
2626 struct tm Storage;
6363 return std::move(*Text);
6464 }
6565
66 StringRef sys::LinuxReadCpuInfo::getHostCPUName_powerpc(
66 StringRef sys::detail::getHostCPUNameForPowerPC(
6767 const StringRef &ProcCpuinfoContent) {
6868 // Access to the Processor Version Register (PVR) on PowerPC is privileged,
6969 // and so we must use an operating-system interface to determine the current
143143 .Default(generic);
144144 }
145145
146 StringRef sys::LinuxReadCpuInfo::getHostCPUName_arm(
146 StringRef sys::detail::getHostCPUNameForARM(
147147 const StringRef &ProcCpuinfoContent) {
148148 // The cpuid register on arm is not accessible from user space. On Linux,
149149 // it is exposed through the /proc/cpuinfo file.
194194 return "generic";
195195 }
196196
197 StringRef sys::LinuxReadCpuInfo::getHostCPUName_s390x(
197 StringRef sys::detail::getHostCPUNameForS390x(
198198 const StringRef &ProcCpuinfoContent) {
199199 // STIDP is a privileged operation, so use /proc/cpuinfo instead.
200200
11961196 StringRef sys::getHostCPUName() {
11971197 std::unique_ptr P = getProcCpuinfoContent();
11981198 const StringRef& Content = P ? P->getBuffer() : "";
1199 return LinuxReadCpuInfo::getHostCPUName_powerpc(Content);
1199 return detail::getHostCPUNameForPowerPC(Content);
12001200 }
12011201 #elif defined(__linux__) && defined(__arm__)
12021202 StringRef sys::getHostCPUName() {
12031203 std::unique_ptr P = getProcCpuinfoContent();
12041204 const StringRef& Content = P ? P->getBuffer() : "";
1205 return LinuxReadCpuInfo::getHostCPUName_arm(Content);
1205 return detail::getHostCPUNameForARM(Content);
12061206 }
12071207 #elif defined(__linux__) && defined(__s390x__)
12081208 StringRef sys::getHostCPUName() {
12091209 std::unique_ptr P = getProcCpuinfoContent();
12101210 const StringRef& Content = P ? P->getBuffer() : "";
1211 return LinuxReadCpuInfo::getHostCPUName_s390x(Content);
1211 return detail::getHostCPUNameForS390x(Content);
12121212 }
12131213 #else
12141214 StringRef sys::getHostCPUName() { return "generic"; }
6565 Serial : 0000000000000000
6666 )";
6767
68 EXPECT_EQ(sys::LinuxReadCpuInfo::getHostCPUName_arm(CortexA9ProcCpuinfo),
68 EXPECT_EQ(sys::detail::getHostCPUNameForARM(CortexA9ProcCpuinfo),
6969 "cortex-a9");
70 EXPECT_EQ(
71 sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x41\n"
72 "CPU part : 0xc0f"),
73 "cortex-a15");
70 EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x41\n"
71 "CPU part : 0xc0f"),
72 "cortex-a15");
7473 // Verify that both CPU implementer and CPU part are checked:
75 EXPECT_EQ(
76 sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x40\n"
77 "CPU part : 0xc0f"),
78 "generic");
79 EXPECT_EQ(
80 sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x51\n"
81 "CPU part : 0x06f"),
82 "krait");
74 EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x40\n"
75 "CPU part : 0xc0f"),
76 "generic");
77 EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x51\n"
78 "CPU part : 0x06f"),
79 "krait");
8380 }