summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-03-31 16:34:41 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-03-31 16:34:41 +0000
commit28b82bc39ef076527c07718724913f70b5d60b69 (patch)
tree3f9a60d2957076f11d17d293b7dc04d0536d4235
parent7b4f7d220684b5fff1142003461de689e2dc4f52 (diff)
downloadbcm5719-llvm-28b82bc39ef076527c07718724913f70b5d60b69.tar.gz
bcm5719-llvm-28b82bc39ef076527c07718724913f70b5d60b69.zip
Support: generalise object type handling for Windows
This generalises the object file type parsing to all Windows environments. This is used by cygwin as well as MSVC environments for MCJIT. This also makes the triple more similar to Chandler's suggestion of a separate field for the object file format. llvm-svn: 205219
-rw-r--r--llvm/lib/Support/Triple.cpp22
-rw-r--r--llvm/unittests/ADT/TripleTest.cpp22
2 files changed, 32 insertions, 12 deletions
diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index 1dc279a0db4..71abb9d1657 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -547,24 +547,27 @@ std::string Triple::normalize(StringRef Str) {
Components.resize(4);
Components[2] = "windows";
if (Environment == UnknownEnvironment) {
- if (ObjectFormat == UnknownObjectFormat)
+ if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
Components[3] = "msvc";
else
Components[3] = getObjectFormatTypeName(ObjectFormat);
- } else if (ObjectFormat != UnknownObjectFormat &&
- ObjectFormat != Triple::COFF) {
- Components.resize(5);
- Components[4] = getObjectFormatTypeName(ObjectFormat);
}
} else if (OS == Triple::MinGW32) {
Components.resize(4);
Components[2] = "windows";
- Components[3] = (ObjectFormat == Triple::ELF) ? "gnuelf" : "gnu";
+ Components[3] = "gnu";
} else if (OS == Triple::Cygwin) {
Components.resize(4);
Components[2] = "windows";
Components[3] = "cygnus";
}
+ if (OS == Triple::MinGW32 || OS == Triple::Cygwin ||
+ (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
+ if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
+ Components.resize(5);
+ Components[4] = getObjectFormatTypeName(ObjectFormat);
+ }
+ }
// Stick the corrected components back together to form the normalized string.
std::string Normalized;
@@ -726,7 +729,12 @@ void Triple::setEnvironment(EnvironmentType Kind) {
}
void Triple::setObjectFormat(ObjectFormatType Kind) {
- setEnvironmentName(getObjectFormatTypeName(Kind));
+ if (Environment == UnknownEnvironment)
+ return setEnvironmentName(getObjectFormatTypeName(Kind));
+
+ Twine Env = getEnvironmentTypeName(Environment) + Twine("-") +
+ getObjectFormatTypeName(Kind);
+ setEnvironmentName(Env.str());
}
void Triple::setArchName(StringRef Str) {
diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp
index 7beddb93c77..2e9d585b5dc 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/ADT/TripleTest.cpp
@@ -510,11 +510,19 @@ TEST(TripleTest, FileFormat) {
EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
+ EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
- {
- Triple Normalized(Triple::normalize("i686-pc-windows-msvc-elf"));
- EXPECT_EQ(Triple::ELF, Normalized.getObjectFormat());
- }
+ Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
+ EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
+
+ Triple GNUWindowsNormalized(Triple::normalize("i686-pc-windows-gnu-elf"));
+ EXPECT_EQ(Triple::ELF, GNUWindowsNormalized.getObjectFormat());
+
+ Triple CygnusNormalised(Triple::normalize("i686-pc-windows-cygnus-elf"));
+ EXPECT_EQ(Triple::ELF, CygnusNormalised.getObjectFormat());
+
+ Triple CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf"));
+ EXPECT_EQ(Triple::ELF, CygwinNormalized.getObjectFormat());
Triple T = Triple("");
T.setObjectFormat(Triple::ELF);
@@ -548,8 +556,12 @@ TEST(TripleTest, NormalizeWindows) {
EXPECT_EQ("x86_64-pc-windows-macho", Triple::normalize("x86_64-pc-win32-macho"));
EXPECT_EQ("x86_64--windows-macho", Triple::normalize("x86_64-win32-macho"));
+ EXPECT_EQ("i686-pc-windows-cygnus",
+ Triple::normalize("i686-pc-windows-cygnus"));
+ EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-windows-gnu"));
EXPECT_EQ("i686-pc-windows-itanium", Triple::normalize("i686-pc-windows-itanium"));
-
EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
+
+ EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-windows-elf-elf"));
}
}
OpenPOWER on IntegriCloud