summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-03-27 22:50:05 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-03-27 22:50:05 +0000
commit2ea701e67a136b834f059d87e389060d60cba05a (patch)
tree010278d331460d2848d512816bf09e8624b4e654 /lib
parentbe77894aef60c9aa1f84110090102b437a6e885b (diff)
downloadllvm-2ea701e67a136b834f059d87e389060d60cba05a.tar.gz
llvm-2ea701e67a136b834f059d87e389060d60cba05a.tar.bz2
llvm-2ea701e67a136b834f059d87e389060d60cba05a.tar.xz
Canonicalise Windows target triple spellings
Construct a uniform Windows target triple nomenclature which is congruent to the Linux counterpart. The old triples are normalised to the new canonical form. This cleans up the long-standing issue of odd naming for various Windows environments. There are four different environments on Windows: MSVC: The MS ABI, MSVCRT environment as defined by Microsoft GNU: The MinGW32/MinGW32-W64 environment which uses MSVCRT and auxiliary libraries Itanium: The MSVCRT environment + libc++ built with Itanium ABI Cygnus: The Cygwin environment which uses custom libraries for everything The following spellings are now written as: i686-pc-win32 => i686-pc-windows-msvc i686-pc-mingw32 => i686-pc-windows-gnu i686-pc-cygwin => i686-pc-windows-cygnus This should be sufficiently flexible to allow us to target other windows environments in the future as necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp2
-rw-r--r--lib/MC/MCObjectFileInfo.cpp4
-rw-r--r--lib/Support/Triple.cpp24
-rw-r--r--lib/Target/TargetLibraryInfo.cpp2
-rw-r--r--lib/Target/X86/X86Subtarget.h11
5 files changed, 35 insertions, 8 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 086b08173e..c3afc8ba8c 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -223,7 +223,7 @@ bool AsmPrinter::doInitialization(Module &M) {
}
if (MAI->doesSupportDebugInformation()) {
- if (Triple(TM.getTargetTriple()).getOS() == Triple::Win32) {
+ if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment()) {
Handlers.push_back(HandlerInfo(new WinCodeViewLineTables(this),
DbgTimerName,
CodeViewLineTablesGroupName));
diff --git a/lib/MC/MCObjectFileInfo.cpp b/lib/MC/MCObjectFileInfo.cpp
index c27b88b968..87ff0d359d 100644
--- a/lib/MC/MCObjectFileInfo.cpp
+++ b/lib/MC/MCObjectFileInfo.cpp
@@ -566,7 +566,7 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ,
SectionKind::getReadOnly());
- if (T.getOS() == Triple::Win32) {
+ if (T.isKnownWindowsMSVCEnvironment()) {
StaticCtorSection =
Ctx->getCOFFSection(".CRT$XCU",
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
@@ -582,7 +582,7 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
}
- if (T.getOS() == Triple::Win32) {
+ if (T.isKnownWindowsMSVCEnvironment()) {
StaticDtorSection =
Ctx->getCOFFSection(".CRT$XTX",
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
index 0b8e9a6685..85a3422bb7 100644
--- a/lib/Support/Triple.cpp
+++ b/lib/Support/Triple.cpp
@@ -129,7 +129,7 @@ const char *Triple::getOSTypeName(OSType Kind) {
case NetBSD: return "netbsd";
case OpenBSD: return "openbsd";
case Solaris: return "solaris";
- case Win32: return "win32";
+ case Win32: return "windows";
case Haiku: return "haiku";
case Minix: return "minix";
case RTEMS: return "rtems";
@@ -155,6 +155,9 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
case EABI: return "eabi";
case EABIHF: return "eabihf";
case Android: return "android";
+ case MSVC: return "msvc";
+ case Itanium: return "itanium";
+ case Cygnus: return "cygnus";
}
llvm_unreachable("Invalid EnvironmentType!");
@@ -287,6 +290,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("openbsd", Triple::OpenBSD)
.StartsWith("solaris", Triple::Solaris)
.StartsWith("win32", Triple::Win32)
+ .StartsWith("windows", Triple::Win32)
.StartsWith("haiku", Triple::Haiku)
.StartsWith("minix", Triple::Minix)
.StartsWith("rtems", Triple::RTEMS)
@@ -309,6 +313,9 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
.StartsWith("code16", Triple::CODE16)
.StartsWith("gnu", Triple::GNU)
.StartsWith("android", Triple::Android)
+ .StartsWith("msvc", Triple::MSVC)
+ .StartsWith("itanium", Triple::Itanium)
+ .StartsWith("cygnus", Triple::Cygnus)
.Default(Triple::UnknownEnvironment);
}
@@ -516,6 +523,21 @@ std::string Triple::normalize(StringRef Str) {
// Special case logic goes here. At this point Arch, Vendor and OS have the
// correct values for the computed components.
+ if (OS == Triple::Win32) {
+ Components.resize(4);
+ Components[2] = "windows";
+ if (Environment == UnknownEnvironment && ObjectFormat == UnknownObjectFormat)
+ Components[3] = "msvc";
+ } else if (OS == Triple::MinGW32) {
+ Components.resize(4);
+ Components[2] = "windows";
+ Components[3] = (ObjectFormat == Triple::ELF) ? "gnuelf" : "gnu";
+ } else if (OS == Triple::Cygwin) {
+ Components.resize(4);
+ Components[2] = "windows";
+ Components[3] = "cygnus";
+ }
+
// Stick the corrected components back together to form the normalized string.
std::string Normalized;
for (unsigned i = 0, e = Components.size(); i != e; ++i) {
diff --git a/lib/Target/TargetLibraryInfo.cpp b/lib/Target/TargetLibraryInfo.cpp
index 063151601b..7f8919772f 100644
--- a/lib/Target/TargetLibraryInfo.cpp
+++ b/lib/Target/TargetLibraryInfo.cpp
@@ -417,7 +417,7 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T,
TLI.setUnavailable(LibFunc::fiprintf);
}
- if (T.getOS() == Triple::Win32) {
+ if (T.isKnownWindowsMSVCEnvironment()) {
// Win32 does not support long double
TLI.setUnavailable(LibFunc::acosl);
TLI.setUnavailable(LibFunc::asinl);
diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h
index 51b2e51d20..d66d859505 100644
--- a/lib/Target/X86/X86Subtarget.h
+++ b/lib/Target/X86/X86Subtarget.h
@@ -343,9 +343,14 @@ public:
bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); }
- bool isTargetWindows() const { return TargetTriple.getOS() == Triple::Win32; }
- bool isTargetMingw() const { return TargetTriple.getOS() == Triple::MinGW32; }
- bool isTargetCygwin() const { return TargetTriple.getOS() == Triple::Cygwin; }
+ bool isTargetWindows() const {
+ return TargetTriple.isOSWindows() &&
+ !TargetTriple.isWindowsGNUEnvironment();
+ }
+ bool isTargetMingw() const { return TargetTriple.isWindowsGNUEnvironment(); }
+ bool isTargetCygwin() const {
+ return TargetTriple.isWindowsCygwinEnvironment();
+ }
bool isTargetCygMing() const { return TargetTriple.isOSCygMing(); }
bool isOSWindows() const { return TargetTriple.isOSWindows(); }