Index: include/llvm/ADT/Triple.h =================================================================== --- include/llvm/ADT/Triple.h +++ include/llvm/ADT/Triple.h @@ -186,8 +186,6 @@ UnknownEnvironment, GNU, - GNUABIN32, - GNUABI64, GNUEABI, GNUEABIHF, GNUX32, @@ -215,6 +213,11 @@ MachO, Wasm, }; + enum MipsABI { + O32, + N32, + N64, + }; private: std::string Data; @@ -346,6 +349,9 @@ void getWatchOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const; + /// getMipsABI - Parse environment component to retrieve MIPS ABI name. + MipsABI getMipsABI() const; + /// @} /// @name Direct Component Access /// @{ @@ -498,8 +504,7 @@ bool isGNUEnvironment() const { EnvironmentType Env = getEnvironment(); - return Env == Triple::GNU || Env == Triple::GNUABIN32 || - Env == Triple::GNUABI64 || Env == Triple::GNUEABI || + return Env == Triple::GNU || Env == Triple::GNUEABI || Env == Triple::GNUEABIHF || Env == Triple::GNUX32; } Index: lib/Support/Triple.cpp =================================================================== --- lib/Support/Triple.cpp +++ lib/Support/Triple.cpp @@ -217,8 +217,6 @@ switch (Kind) { case UnknownEnvironment: return "unknown"; case GNU: return "gnu"; - case GNUABIN32: return "gnuabin32"; - case GNUABI64: return "gnuabi64"; case GNUEABIHF: return "gnueabihf"; case GNUEABI: return "gnueabi"; case GNUX32: return "gnux32"; @@ -508,8 +506,6 @@ return StringSwitch(EnvironmentName) .StartsWith("eabihf", Triple::EABIHF) .StartsWith("eabi", Triple::EABI) - .StartsWith("gnuabin32", Triple::GNUABIN32) - .StartsWith("gnuabi64", Triple::GNUABI64) .StartsWith("gnueabihf", Triple::GNUEABIHF) .StartsWith("gnueabi", Triple::GNUEABI) .StartsWith("gnux32", Triple::GNUX32) @@ -1604,3 +1600,20 @@ llvm_unreachable("invalid arch name"); } + +Triple::MipsABI Triple::getMipsABI() const { + if (getEnvironmentName().endswith("abin32")) + return N32; + if (getEnvironmentName().endswith("abi64")) + return N64; + switch (getArch()) { + case mips: + case mipsel: + return O32; + case mips64: + case mips64el: + return N64; + default: + llvm_unreachable("non-MIPS arch name"); + } +} Index: lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp +++ lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp @@ -53,16 +53,7 @@ DwarfRegNumForCFI = true; HasMipsExpressions = true; - // Enable IAS by default for O32. - if (TheTriple.getArch() == Triple::mips || - TheTriple.getArch() == Triple::mipsel) - UseIntegratedAssembler = true; - - // Enable IAS by default for Debian mips64/mips64el. - if (TheTriple.getEnvironment() == Triple::GNUABI64) - UseIntegratedAssembler = true; - - // Enable IAS by default for Android mips64el that uses N64 ABI. - if (TheTriple.getArch() == Triple::mips64el && TheTriple.isAndroid()) - UseIntegratedAssembler = true; + // Enable IAS by default for O32 and N64 ABI. + UseIntegratedAssembler = TheTriple.getMipsABI() == Triple::O32 || + TheTriple.getMipsABI() == Triple::N64; } Index: unittests/ADT/TripleTest.cpp =================================================================== --- unittests/ADT/TripleTest.cpp +++ unittests/ADT/TripleTest.cpp @@ -338,18 +338,6 @@ EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNU, T.getEnvironment()); - T = Triple("mips64el-img-linux-gnuabin32"); - EXPECT_EQ(Triple::mips64el, T.getArch()); - EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor()); - EXPECT_EQ(Triple::Linux, T.getOS()); - EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); - - T = Triple("mips64el-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()); - T = Triple("huh"); EXPECT_EQ(Triple::UnknownArch, T.getArch()); } @@ -1195,4 +1183,41 @@ EXPECT_EQ(Triple::aarch64_be, T.getArch()); } } + +TEST(TripleTest, ParseMipsABI) { + Triple T = Triple("mips-img-linux"); + EXPECT_EQ(Triple::mips, T.getArch()); + EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + EXPECT_EQ(Triple::O32, T.getMipsABI()); + + T = Triple("mips64-img-linux"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + EXPECT_EQ(Triple::N64, T.getMipsABI()); + + T = Triple("mips64--linux-android"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::Android, T.getEnvironment()); + EXPECT_EQ(Triple::N64, T.getMipsABI()); + + T = Triple("mips64-img-linux-gnuabin32"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::ImaginationTechnologies, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::N32, T.getMipsABI()); + + 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::GNU, T.getEnvironment()); + EXPECT_EQ(Triple::N64, T.getMipsABI()); +} } // end anonymous namespace