From c50c6907aa1f2294f5fa80a9cc72f48b1cd7da52 Mon Sep 17 00:00:00 2001 From: Michael Kuperstein Date: Sun, 25 Oct 2015 08:07:37 +0000 Subject: [PATCH] [X86] Add support for elfiamcu triple This adds support for the i?86-*-elfiamcu triple, which indicates the IAMCU psABI is used. Differential Revision: http://reviews.llvm.org/D13977 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251222 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/Triple.h | 7 ++++++- lib/Support/Triple.cpp | 2 ++ lib/Target/X86/X86Subtarget.h | 1 + unittests/ADT/TripleTest.cpp | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index e523e3b0309..bb0e05c0deb 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -174,7 +174,8 @@ public: Cygnus, AMDOpenCL, CoreCLR, - LastEnvironmentType = CoreCLR + ELFIAMCU, + LastEnvironmentType = ELFIAMCU }; enum ObjectFormatType { UnknownObjectFormat, @@ -431,6 +432,10 @@ public: return getOS() == Triple::Bitrig; } + bool isEnvironmentIAMCU() const { + return getEnvironment() == Triple::ELFIAMCU; + } + bool isWindowsMSVCEnvironment() const { return getOS() == Triple::Win32 && (getEnvironment() == Triple::UnknownEnvironment || diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index 8e2cbaddef4..f3b3de7af3f 100644 --- a/lib/Support/Triple.cpp +++ b/lib/Support/Triple.cpp @@ -202,6 +202,7 @@ 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!"); @@ -453,6 +454,7 @@ 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); } diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index bca31c00398..c1842e1a5fd 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -418,6 +418,7 @@ public: 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 isTargetWindowsMSVC() const { return TargetTriple.isWindowsMSVCEnvironment(); diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp index 71072932bed..015eb853e5b 100644 --- a/unittests/ADT/TripleTest.cpp +++ b/unittests/ADT/TripleTest.cpp @@ -81,6 +81,12 @@ TEST(TripleTest, ParsedIDs) { EXPECT_EQ(Triple::Darwin, T.getOS()); EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("i386-pc-linux-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()); + T = Triple("x86_64-pc-linux-gnu"); EXPECT_EQ(Triple::x86_64, T.getArch()); EXPECT_EQ(Triple::PC, T.getVendor()); -- 2.34.1