[PATCH] D69597: Implement `sys::getHostCPUName()` for Darwin ARM
Chris Bieneman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 18:14:31 PDT 2019
beanz created this revision.
beanz added reviewers: t.p.northover, lhames.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: LLVM.
Currently there is no implementation of `sys::getHostCPUName()` for Darwin ARM targets. This makes it so that LLVM running on ARM doesn't make reasonable guesses about the CPU features of the host CPU.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69597
Files:
llvm/lib/Support/Host.cpp
Index: llvm/lib/Support/Host.cpp
===================================================================
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -35,7 +35,7 @@
#ifdef _MSC_VER
#include <intrin.h>
#endif
-#if defined(__APPLE__) && (defined(__ppc__) || defined(__powerpc__))
+#if defined(__APPLE__) && (!defined(__x86_64__))
#include <mach/host_info.h>
#include <mach/mach.h>
#include <mach/mach_host.h>
@@ -1222,6 +1222,40 @@
StringRef Content = P ? P->getBuffer() : "";
return detail::getHostCPUNameForS390x(Content);
}
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+StringRef sys::getHostCPUName() {
+ host_basic_info_data_t hostInfo;
+ mach_msg_type_number_t infoCount;
+
+ infoCount = HOST_BASIC_INFO_COUNT;
+ mach_port_t hostPort = mach_host_self();
+ host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
+ &infoCount);
+ mach_port_deallocate(mach_task_self(), hostPort);
+
+ if (hostInfo.cpu_type == CPU_TYPE_ARM) {
+ switch (hostInfo.cpu_subtype) {
+ case CPU_SUBTYPE_ARM_V7S:
+ return "swift";
+ default:
+ return "generic";
+ }
+ }
+ if (hostInfo.cpu_type == CPU_TYPE_ARM64) {
+ switch (hostInfo.cpu_subtype) {
+ default:
+ return "cyclone";
+ }
+ }
+ if (hostInfo.cpu_type == CPU_TYPE_ARM64_32) {
+ switch (hostInfo.cpu_subtype) {
+ default:
+ return "cyclone";
+ }
+ }
+
+ return "generic";
+}
#else
StringRef sys::getHostCPUName() { return "generic"; }
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69597.227008.patch
Type: text/x-patch
Size: 1512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191030/917c30cc/attachment.bin>
More information about the llvm-commits
mailing list