diff options
author | Chris Bieneman <chris.bieneman@me.com> | 2019-10-30 12:50:04 -0700 |
---|---|---|
committer | Chris Bieneman <chris.bieneman@me.com> | 2019-11-05 17:49:16 -0800 |
commit | 34688fafea813f826b71f814edd6389adbf98ca7 (patch) | |
tree | 499cf332760a62292683870614f25faa3e647bb0 | |
parent | bcbb121ff6c8440382abfce8f2911a095f14602b (diff) | |
download | bcm5719-llvm-34688fafea813f826b71f814edd6389adbf98ca7.tar.gz bcm5719-llvm-34688fafea813f826b71f814edd6389adbf98ca7.zip |
Implement `sys::getHostCPUName()` for Darwin ARM
Summary: Currently there is no implementation of `sys::getHostCPUName()` for Darwin ARM targets. This patch makes it so that LLVM running on ARM makes reasonable guesses about the CPU features of the host CPU.
Reviewers: t.p.northover, lhames, efriedma
Reviewed By: efriedma
Subscribers: rjmccall, efriedma, kristof.beyls, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69597
-rw-r--r-- | llvm/lib/Support/Host.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp index b57250894f3..a4ab6530d7f 100644 --- a/llvm/lib/Support/Host.cpp +++ b/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> @@ -1220,6 +1220,33 @@ StringRef sys::getHostCPUName() { StringRef Content = P ? P->getBuffer() : ""; return detail::getHostCPUNameForS390x(Content); } +#elif defined(__APPLE__) && defined(__aarch64__) +StringRef sys::getHostCPUName() { + return "cyclone"; +} +#elif defined(__APPLE__) && defined(__arm__) +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) { + assert(false && "CPUType not equal to ARM should not be possible on ARM"); + return "generic"; + } + switch (hostInfo.cpu_subtype) { + case CPU_SUBTYPE_ARM_V7S: + return "swift"; + default:; + } + + return "generic"; +} #else StringRef sys::getHostCPUName() { return "generic"; } #endif |