Skip to content

Commit

Permalink
[X86] Make elfiamcu an OS, not an environment.
Browse files Browse the repository at this point in the history
GNU tools require elfiamcu to take up the entire OS field, so, e.g.
i?86-*-linux-elfiamcu is not considered a legal triple.
Make us compatible.

Differential Revision: http://reviews.llvm.org/D14081

llvm-svn: 251390
  • Loading branch information
Michael Kuperstein committed Oct 27, 2015
1 parent 99af5b2 commit e1194bd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions llvm/include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class Triple {
NVCL, // NVIDIA OpenCL
AMDHSA, // AMD HSA Runtime
PS4,
LastOSType = PS4
ELFIAMCU,
LastOSType = ELFIAMCU
};
enum EnvironmentType {
UnknownEnvironment,
Expand All @@ -174,8 +175,7 @@ class Triple {
Cygnus,
AMDOpenCL,
CoreCLR,
ELFIAMCU,
LastEnvironmentType = ELFIAMCU
LastEnvironmentType = CoreCLR
};
enum ObjectFormatType {
UnknownObjectFormat,
Expand Down Expand Up @@ -432,8 +432,8 @@ class Triple {
return getOS() == Triple::Bitrig;
}

bool isEnvironmentIAMCU() const {
return getEnvironment() == Triple::ELFIAMCU;
bool isOSIAMCU() const {
return getOS() == Triple::ELFIAMCU;
}

bool isWindowsMSVCEnvironment() const {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Support/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const char *Triple::getOSTypeName(OSType Kind) {
case NVCL: return "nvcl";
case AMDHSA: return "amdhsa";
case PS4: return "ps4";
case ELFIAMCU: return "elfiamcu";
}

llvm_unreachable("Invalid OSType");
Expand All @@ -202,7 +203,6 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
case Cygnus: return "cygnus";
case AMDOpenCL: return "amdopencl";
case CoreCLR: return "coreclr";
case ELFIAMCU: return "elfiamcu";
}

llvm_unreachable("Invalid EnvironmentType!");
Expand Down Expand Up @@ -436,6 +436,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("nvcl", Triple::NVCL)
.StartsWith("amdhsa", Triple::AMDHSA)
.StartsWith("ps4", Triple::PS4)
.StartsWith("elfiamcu", Triple::ELFIAMCU)
.Default(Triple::UnknownOS);
}

Expand All @@ -454,7 +455,6 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
.StartsWith("cygnus", Triple::Cygnus)
.StartsWith("amdopencl", Triple::AMDOpenCL)
.StartsWith("coreclr", Triple::CoreCLR)
.StartsWith("elfiamcu", Triple::ELFIAMCU)
.Default(Triple::UnknownEnvironment);
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/X86Subtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class X86Subtarget final : public X86GenSubtargetInfo {
bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); }
bool isTargetMCU() const { return TargetTriple.isEnvironmentIAMCU(); }
bool isTargetMCU() const { return TargetTriple.isOSIAMCU(); }

bool isTargetWindowsMSVC() const {
return TargetTriple.isWindowsMSVCEnvironment();
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/mcu-abi.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llc < %s -mtriple=i686-pc-linux-elfiamcu | FileCheck %s
; RUN: llc < %s -mtriple=i686-pc-elfiamcu | FileCheck %s

; CHECK-LABEL: test_lib_args:
; CHECK: movl %edx, %eax
Expand Down
6 changes: 3 additions & 3 deletions llvm/unittests/ADT/TripleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Darwin, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("i386-pc-linux-elfiamcu");
T = Triple("i386-pc-elfiamcu");
EXPECT_EQ(Triple::x86, T.getArch());
EXPECT_EQ(Triple::PC, T.getVendor());
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::ELFIAMCU, T.getEnvironment());
EXPECT_EQ(Triple::ELFIAMCU, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("x86_64-pc-linux-gnu");
EXPECT_EQ(Triple::x86_64, T.getArch());
Expand Down

0 comments on commit e1194bd

Please sign in to comment.