Index: include/llvm/ADT/Triple.h =================================================================== --- include/llvm/ADT/Triple.h +++ include/llvm/ADT/Triple.h @@ -56,9 +56,9 @@ bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian) hexagon, // Hexagon: hexagon mips, // MIPS: mips, mipsallegrex - mipsel, // MIPSEL: mipsel, mipsallegrexel - mips64, // MIPS64: mips64 - mips64el, // MIPS64EL: mips64el + mipsel, // MIPSEL: mipsel, mipsallegrexe + mips64, // MIPS64: mips64, mipsn32 + mips64el, // MIPS64EL: mips64el, mipsn32el msp430, // MSP430: msp430 nios2, // NIOSII: nios2 ppc, // PPC: powerpc Index: lib/Support/Triple.cpp =================================================================== --- lib/Support/Triple.cpp +++ lib/Support/Triple.cpp @@ -400,8 +400,8 @@ .Case("msp430", Triple::msp430) .Cases("mips", "mipseb", "mipsallegrex", Triple::mips) .Cases("mipsel", "mipsallegrexel", Triple::mipsel) - .Cases("mips64", "mips64eb", Triple::mips64) - .Case("mips64el", Triple::mips64el) + .Cases("mips64", "mips64eb", "mipsn32", Triple::mips64) + .Cases("mips64el", "mipsn32el", Triple::mips64el) .Case("nios2", Triple::nios2) .Case("r600", Triple::r600) .Case("amdgcn", Triple::amdgcn) @@ -709,6 +709,14 @@ ObjectFormat = parseFormat(Components[3]); } } + } 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); } } if (ObjectFormat == UnknownObjectFormat) Index: lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp +++ lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp @@ -55,6 +55,8 @@ return MipsABIInfo::N32(); if (Options.getABIName().startswith("n64")) return MipsABIInfo::N64(); + if (TT.getEnvironment() == llvm::Triple::GNUABIN32) + return MipsABIInfo::N32(); assert(Options.getABIName().empty() && "Unknown ABI option for MIPS"); if (TT.isMIPS64()) Index: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp +++ lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp @@ -572,6 +572,13 @@ const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) { - return new MipsAsmBackend(T, MRI, STI.getTargetTriple(), STI.getCPU(), - Options.ABIName == "n32"); + bool n32; + if (Options.ABIName == "n32") + n32 = true; + else if (Options.ABIName.empty() && + STI.getTargetTriple().getEnvironment() == Triple::GNUABIN32) + n32 = true; + else + n32 = false; + return new MipsAsmBackend(T, MRI, STI.getTargetTriple(), STI.getCPU(), n32); } Index: lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp +++ lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp @@ -59,6 +59,10 @@ if (TheTriple.getEnvironment() == Triple::GNUABI64) UseIntegratedAssembler = true; + // Enable IAS by default for Debian mipsn32/mipsn32el. + if (TheTriple.getEnvironment() == Triple::GNUABIN32) + UseIntegratedAssembler = true; + // Enable IAS by default for Android mips64el that uses N64 ABI. if (TheTriple.getArch() == Triple::mips64el && TheTriple.isAndroid()) UseIntegratedAssembler = true; Index: test/MC/Mips/elf-N32.s =================================================================== --- test/MC/Mips/elf-N32.s +++ test/MC/Mips/elf-N32.s @@ -2,6 +2,10 @@ // RUN: llvm-mc -filetype=obj -triple=mips64-linux-gnu -mcpu=mips3 \ // RUN: -target-abi=n32 %s -o - | llvm-readobj -r | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=mips64-linux-gnuabin32 -mcpu=mips3 \ +// RUN: %s -o - | llvm-readobj -r | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=mipsn32 -mcpu=mips3 \ +// RUN: %s -o - | llvm-readobj -r | FileCheck %s // CHECK: Relocations [ // CHECK-NEXT: Section (3) .rela.text { Index: unittests/ADT/TripleTest.cpp =================================================================== --- unittests/ADT/TripleTest.cpp +++ unittests/ADT/TripleTest.cpp @@ -360,6 +360,59 @@ EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + T = Triple("mips64el"); + EXPECT_EQ(Triple::mips64el, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + + 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()); + T = Triple("mips64"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABI64, T.getEnvironment()); + + 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()); + T = Triple("mipsn32el"); + EXPECT_EQ(Triple::mips64el, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + + 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()); + T = Triple("mipsn32"); + EXPECT_EQ(Triple::mips64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment()); + + 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()); + T = Triple("mipsel"); + EXPECT_EQ(Triple::mipsel, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); + + T = Triple("mips-unknown-linux-gnu"); + EXPECT_EQ(Triple::mips, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); + T = Triple("mips"); + EXPECT_EQ(Triple::mips, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::GNU, T.getEnvironment()); T = Triple("arm-oe-linux-gnueabi"); EXPECT_EQ(Triple::arm, T.getArch());