From: Simon Atanasyan Date: Thu, 27 Sep 2018 08:51:18 +0000 (+0000) Subject: [mips] Add support MIPS r6 Debian triples X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e58c45a695f39004710b6ce940d489fee800dbd3;p=platform%2Fupstream%2Fllvm.git [mips] Add support MIPS r6 Debian triples Debian uses different triples for MIPS r6 and paths. Here we use SubArch to determine whether it is r6, if we found `r6' in CPU section of triple. These new triples include: mipsisa32r6-linux-gnu mipsisa32r6el-linux-gnu mipsisa64r6-linux-gnuabi64 mipsisa64r6el-linux-gnuabi64 mipsisa64r6-linux-gnuabin32 mipsisa64r6el-linux-gnuabin32 Patch by YunQiang Su. Differential revision: https://reviews.llvm.org/D50857 llvm-svn: 343185 --- diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index ed65dee..fe78f78 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -55,10 +55,10 @@ public: bpfel, // eBPF or extended BPF or 64-bit BPF (little endian) bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian) hexagon, // Hexagon: hexagon - mips, // MIPS: mips, mipsallegrex - mipsel, // MIPSEL: mipsel, mipsallegrexe - mips64, // MIPS64: mips64, mipsn32 - mips64el, // MIPS64EL: mips64el, mipsn32el + mips, // MIPS: mips, mipsallegrex, mipsr6 + mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el + mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6 + mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el msp430, // MSP430: msp430 nios2, // NIOSII: nios2 ppc, // PPC: powerpc @@ -126,7 +126,9 @@ public: KalimbaSubArch_v3, KalimbaSubArch_v4, - KalimbaSubArch_v5 + KalimbaSubArch_v5, + + MipsSubArch_r6 }; enum VendorType { UnknownVendor, diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 38f72c9..c53c878 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -399,10 +399,14 @@ static Triple::ArchType parseArch(StringRef ArchName) { .Case("thumbeb", Triple::thumbeb) .Case("avr", Triple::avr) .Case("msp430", Triple::msp430) - .Cases("mips", "mipseb", "mipsallegrex", Triple::mips) - .Cases("mipsel", "mipsallegrexel", Triple::mipsel) - .Cases("mips64", "mips64eb", "mipsn32", Triple::mips64) - .Cases("mips64el", "mipsn32el", Triple::mips64el) + .Cases("mips", "mipseb", "mipsallegrex", "mipsisa32r6", + "mipsr6", Triple::mips) + .Cases("mipsel", "mipsallegrexel", "mipsisa32r6el", "mipsr6el", + Triple::mipsel) + .Cases("mips64", "mips64eb", "mipsn32", "mipsisa64r6", + "mips64r6", "mipsn32r6", Triple::mips64) + .Cases("mips64el", "mipsn32el", "mipsisa64r6el", "mips64r6el", + "mipsn32r6el", Triple::mips64el) .Case("nios2", Triple::nios2) .Case("r600", Triple::r600) .Case("amdgcn", Triple::amdgcn) @@ -540,6 +544,10 @@ static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) { } static Triple::SubArchType parseSubArch(StringRef SubArchName) { + if (SubArchName.startswith("mips") && + (SubArchName.endswith("r6el") || SubArchName.endswith("r6"))) + return Triple::MipsSubArch_r6; + StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName); // For now, this is the small part. Early return. @@ -714,13 +722,14 @@ Triple::Triple(const Twine &Str) } } } else { - Environment = StringSwitch(Components[0]) - .StartsWith("mipsn32", Triple::GNUABIN32) - .StartsWith("mips64", Triple::GNUABI64) - .StartsWith("mipsisa64", Triple::GNUABI64) - .StartsWith("mipsisa32", Triple::GNU) - .Cases("mips", "mipsel", Triple::GNU) - .Default(UnknownEnvironment); + Environment = + StringSwitch(Components[0]) + .StartsWith("mipsn32", Triple::GNUABIN32) + .StartsWith("mips64", Triple::GNUABI64) + .StartsWith("mipsisa64", Triple::GNUABI64) + .StartsWith("mipsisa32", Triple::GNU) + .Cases("mips", "mipsel", "mipsr6", "mipsr6el", Triple::GNU) + .Default(UnknownEnvironment); } } if (ObjectFormat == UnknownObjectFormat) diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp index ce208b7..a8cd7b0 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -47,10 +47,17 @@ using namespace llvm; /// FIXME: Merge with the copy in MipsSubtarget.cpp StringRef MIPS_MC::selectMipsCPU(const Triple &TT, StringRef CPU) { if (CPU.empty() || CPU == "generic") { - if (TT.isMIPS32()) - CPU = "mips32"; - else - CPU = "mips64"; + if (TT.getSubArch() == llvm::Triple::MipsSubArch_r6) { + if (TT.isMIPS32()) + CPU = "mips32r6"; + else + CPU = "mips64r6"; + } else { + if (TT.isMIPS32()) + CPU = "mips32"; + else + CPU = "mips64"; + } } return CPU; } diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp index 7991f2a..71a922a 100644 --- a/llvm/unittests/ADT/TripleTest.cpp +++ b/llvm/unittests/ADT/TripleTest.cpp @@ -366,59 +366,163 @@ TEST(TripleTest, ParsedIDs) { EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mips64el"); EXPECT_EQ(Triple::mips64el, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mips64-unknown-linux-gnuabi64"); EXPECT_EQ(Triple::mips64, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mips64"); EXPECT_EQ(Triple::mips64, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); + + T = Triple("mipsisa64r6el-unknown-linux-gnuabi64"); + EXPECT_EQ(Triple::mips64el, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mips64r6el"); + EXPECT_EQ(Triple::mips64el, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mipsisa64r6el"); + EXPECT_EQ(Triple::mips64el, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + + T = Triple("mipsisa64r6-unknown-linux-gnuabi64"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mips64r6"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mipsisa64r6"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); T = Triple("mips64el-unknown-linux-gnuabin32"); EXPECT_EQ(Triple::mips64el, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mipsn32el"); EXPECT_EQ(Triple::mips64el, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mips64-unknown-linux-gnuabin32"); EXPECT_EQ(Triple::mips64, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mipsn32"); EXPECT_EQ(Triple::mips64, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); + + T = Triple("mipsisa64r6el-unknown-linux-gnuabin32"); + EXPECT_EQ(Triple::mips64el, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mipsn32r6el"); + EXPECT_EQ(Triple::mips64el, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + + T = Triple("mipsisa64r6-unknown-linux-gnuabin32"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mipsn32r6"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); T = Triple("mipsel-unknown-linux-gnu"); EXPECT_EQ(Triple::mipsel, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mipsel"); EXPECT_EQ(Triple::mipsel, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mips-unknown-linux-gnu"); EXPECT_EQ(Triple::mips, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); T = Triple("mips"); EXPECT_EQ(Triple::mips, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::NoSubArch, T.getSubArch()); + + T = Triple("mipsisa32r6el-unknown-linux-gnu"); + EXPECT_EQ(Triple::mipsel, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mipsr6el"); + EXPECT_EQ(Triple::mipsel, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mipsisa32r6el"); + EXPECT_EQ(Triple::mipsel, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + + T = Triple("mipsisa32r6-unknown-linux-gnu"); + EXPECT_EQ(Triple::mips, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mipsr6"); + EXPECT_EQ(Triple::mips, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); + T = Triple("mipsisa32r6"); + EXPECT_EQ(Triple::mips, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch()); T = Triple("arm-oe-linux-gnueabi"); EXPECT_EQ(Triple::arm, T.getArch());