diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-10-15 02:10:06 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-10-15 02:10:06 +0000 |
commit | 559b8f2ae9d77a262a01af1051f363dd2822d153 (patch) | |
tree | 7d7294ad2288652c5d66ec7eb76090586695a685 /llvm/lib/Support | |
parent | 3d19eefd4e43833d78c6a368f890353f4f466d7e (diff) | |
download | bcm5719-llvm-559b8f2ae9d77a262a01af1051f363dd2822d153.tar.gz bcm5719-llvm-559b8f2ae9d77a262a01af1051f363dd2822d153.zip |
Fix for llvm::sys::getHostTriple on Windows. Instead of relying on the triple
from config.h, it discovers the triple based on the execution environment.
Patch by Aaron Ballman <aaron@aaronballman.com>
llvm-svn: 142046
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/Windows/Host.inc | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/llvm/lib/Support/Windows/Host.inc b/llvm/lib/Support/Windows/Host.inc index 733830e82f0..6d4803f3b8d 100644 --- a/llvm/lib/Support/Windows/Host.inc +++ b/llvm/lib/Support/Windows/Host.inc @@ -12,12 +12,44 @@ //===----------------------------------------------------------------------===// #include "Windows.h" -#include <cstdio> -#include <string> +#include "llvm/ADT/Twine.h" using namespace llvm; std::string sys::getHostTriple() { - // FIXME: Adapt to running version. - return LLVM_HOSTTRIPLE; + // Get the execution environment, not the native environment. + SYSTEM_INFO info; + ::GetSystemInfo(&info); + + Twine ret; + switch (info.wProcessorArchitecture) { + // If we don't know what the processor architecture is, or it is not one + // we currently support, then we should fall back on something reasonable. + case PROCESSOR_ARCHITECTURE_IA64: + default: return LLVM_HOSTTRIPLE; + + case PROCESSOR_ARCHITECTURE_INTEL: + // We need to figure out what kind of x86 it is (possible values are + // i386 through i986). + ret = Twine("i").concat(Twine(info.wProcessorLevel)).concat("86"); + break; + case PROCESSOR_ARCHITECTURE_AMD64: + ret = "amd64"; + break; + case PROCESSOR_ARCHITECTURE_MIPS: + ret = "mips"; + break; + case PROCESSOR_ARCHITECTURE_ARM: + ret = "arm"; + break; + case PROCESSOR_ARCHITECTURE_PPC: + ret = "ppc"; + break; + case PROCESSOR_ARCHITECTURE_ALPHA: + ret = "alpha"; + break; + } + + // Since we're on Windows, we're always on pc-win32. + return ret.concat("-pc-win32").str(); } |