Index: lib/Basic/Targets/Mips.h =================================================================== --- lib/Basic/Targets/Mips.h +++ lib/Basic/Targets/Mips.h @@ -69,7 +69,10 @@ UseIndirectJumpHazard(false), HasFP64(false) { TheCXXABI.set(TargetCXXABI::GenericMIPS); - setABI(getTriple().isMIPS32() ? "o32" : "n64"); + std::string Mips64Abi = + (getTriple().getEnvironment() == llvm::Triple::GNUABIN32) ? "n32" + : "n64"; + setABI(getTriple().isMIPS32() ? "o32" : Mips64Abi); CPU = ABI == "o32" ? "mips32r2" : "mips64r2"; Index: lib/Driver/ToolChains/Arch/Mips.cpp =================================================================== --- lib/Driver/ToolChains/Arch/Mips.cpp +++ lib/Driver/ToolChains/Arch/Mips.cpp @@ -106,6 +106,9 @@ .Default(""); } + if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32)) + ABIName = "n32"; + if (ABIName.empty()) { // Deduce ABI name from the target triple. ABIName = Triple.isMIPS32() ? "o32" : "n64"; Index: lib/Driver/ToolChains/Gnu.cpp =================================================================== --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -1861,6 +1861,10 @@ "mips64el-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu", "mips64el-linux-gnuabi64"}; + static const char *const MIPSN32LibDirs[] = {"/lib32"}; + static const char *const MIPSN32Triples[] = {"mips64-linux-gnuabin32"}; + static const char *const MIPSN32ELLibDirs[] = {"/lib32"}; + static const char *const MIPSN32ELTriples[] = {"mips64el-linux-gnuabin32"}; static const char *const PPCLibDirs[] = {"/lib32", "/lib"}; static const char *const PPCTriples[] = { @@ -2057,6 +2061,8 @@ TripleAliases.append(begin(MIPSTriples), end(MIPSTriples)); BiarchLibDirs.append(begin(MIPS64LibDirs), end(MIPS64LibDirs)); BiarchTripleAliases.append(begin(MIPS64Triples), end(MIPS64Triples)); + BiarchLibDirs.append(begin(MIPSN32LibDirs), end(MIPSN32LibDirs)); + BiarchTripleAliases.append(begin(MIPSN32Triples), end(MIPSN32Triples)); break; case llvm::Triple::mipsel: LibDirs.append(begin(MIPSELLibDirs), end(MIPSELLibDirs)); @@ -2064,19 +2070,24 @@ TripleAliases.append(begin(MIPSTriples), end(MIPSTriples)); BiarchLibDirs.append(begin(MIPS64ELLibDirs), end(MIPS64ELLibDirs)); BiarchTripleAliases.append(begin(MIPS64ELTriples), end(MIPS64ELTriples)); + BiarchLibDirs.append(begin(MIPSN32ELLibDirs), end(MIPSN32ELLibDirs)); + BiarchTripleAliases.append(begin(MIPSN32ELTriples), end(MIPSN32ELTriples)); break; case llvm::Triple::mips64: LibDirs.append(begin(MIPS64LibDirs), end(MIPS64LibDirs)); TripleAliases.append(begin(MIPS64Triples), end(MIPS64Triples)); BiarchLibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs)); BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples)); + BiarchLibDirs.append(begin(MIPSN32LibDirs), end(MIPSN32LibDirs)); + BiarchTripleAliases.append(begin(MIPSN32Triples), end(MIPSN32Triples)); break; case llvm::Triple::mips64el: LibDirs.append(begin(MIPS64ELLibDirs), end(MIPS64ELLibDirs)); TripleAliases.append(begin(MIPS64ELTriples), end(MIPS64ELTriples)); BiarchLibDirs.append(begin(MIPSELLibDirs), end(MIPSELLibDirs)); BiarchTripleAliases.append(begin(MIPSELTriples), end(MIPSELTriples)); - BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples)); + BiarchLibDirs.append(begin(MIPSN32ELLibDirs), end(MIPSN32ELLibDirs)); + BiarchTripleAliases.append(begin(MIPSN32ELTriples), end(MIPSN32ELTriples)); break; case llvm::Triple::ppc: LibDirs.append(begin(PPCLibDirs), end(PPCLibDirs)); @@ -2419,8 +2430,8 @@ // can precisely identify the ABI in use (Debian) or only use N64 for MIPS64 // (Android). Other targets are unable to distinguish N32 from N64. if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 || - getTriple().isAndroid() || - getTriple().isOSFreeBSD() || + getTriple().getEnvironment() == llvm::Triple::GNUABIN32 || + getTriple().isAndroid() || getTriple().isOSFreeBSD() || getTriple().isOSOpenBSD()) return true; return false; Index: lib/Driver/ToolChains/Linux.cpp =================================================================== --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -44,6 +44,9 @@ llvm::Triple::EnvironmentType TargetEnvironment = TargetTriple.getEnvironment(); bool IsAndroid = TargetTriple.isAndroid(); + std::string MipsCpu = "", Mips64Abi = "gnuabi64"; + if (TargetEnvironment == llvm::Triple::GNUABIN32) + Mips64Abi = "gnuabin32"; // For most architectures, just use whatever we have rather than trying to be // clever. @@ -114,16 +117,16 @@ case llvm::Triple::mips64: if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu")) return "mips64-linux-gnu"; - if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnuabi64")) - return "mips64-linux-gnuabi64"; + if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-" + Mips64Abi)) + return "mips64-linux-" + Mips64Abi; break; case llvm::Triple::mips64el: if (IsAndroid) return "mips64el-linux-android"; if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnu")) return "mips64el-linux-gnu"; - if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnuabi64")) - return "mips64el-linux-gnuabi64"; + if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-" + Mips64Abi)) + return "mips64el-linux-" + Mips64Abi; break; case llvm::Triple::ppc: if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnuspe")) @@ -699,6 +702,10 @@ const StringRef MIPS64ELMultiarchIncludeDirs[] = { "/usr/include/mips64el-linux-gnu", "/usr/include/mips64el-linux-gnuabi64"}; + const StringRef MIPSN32MultiarchIncludeDirs[] = { + "/usr/include/mips64-linux-gnuabin32"}; + const StringRef MIPSN32ELMultiarchIncludeDirs[] = { + "/usr/include/mips64el-linux-gnuabin32"}; const StringRef PPCMultiarchIncludeDirs[] = { "/usr/include/powerpc-linux-gnu"}; const StringRef PPC64MultiarchIncludeDirs[] = { @@ -744,10 +751,16 @@ MultiarchIncludeDirs = MIPSELMultiarchIncludeDirs; break; case llvm::Triple::mips64: - MultiarchIncludeDirs = MIPS64MultiarchIncludeDirs; + if (getTriple().getEnvironment() == llvm::Triple::GNUABIN32) + MultiarchIncludeDirs = MIPSN32MultiarchIncludeDirs; + else + MultiarchIncludeDirs = MIPS64MultiarchIncludeDirs; break; case llvm::Triple::mips64el: - MultiarchIncludeDirs = MIPS64ELMultiarchIncludeDirs; + if (getTriple().getEnvironment() == llvm::Triple::GNUABIN32) + MultiarchIncludeDirs = MIPSN32ELMultiarchIncludeDirs; + else + MultiarchIncludeDirs = MIPS64ELMultiarchIncludeDirs; break; case llvm::Triple::ppc: MultiarchIncludeDirs = PPCMultiarchIncludeDirs; Index: test/CodeGen/atomics-inlining.c =================================================================== --- test/CodeGen/atomics-inlining.c +++ test/CodeGen/atomics-inlining.c @@ -3,6 +3,7 @@ // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC64 // RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS32 // RUN: %clang_cc1 -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64 +// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64 // RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV8 -check-prefix=SPARC // RUN: %clang_cc1 -triple sparcv9-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV9 -check-prefix=SPARC Index: test/CodeGen/mips-zero-sized-struct.c =================================================================== --- test/CodeGen/mips-zero-sized-struct.c +++ test/CodeGen/mips-zero-sized-struct.c @@ -2,8 +2,12 @@ // RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s // RUN: %clang_cc1 -triple mips64-unknown-linux-gnu -S -emit-llvm -o - %s -target-abi n32 | FileCheck -check-prefix=N32 %s // RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s -target-abi n32 | FileCheck -check-prefix=N32 %s +// RUN: %clang_cc1 -triple mips64-unknown-linux-gnuabin32 -S -emit-llvm -o - %s | FileCheck -check-prefix=N32 %s +// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnuabin32 -S -emit-llvm -o - %s | FileCheck -check-prefix=N32 %s // RUN: %clang_cc1 -triple mips64-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s // RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s +// RUN: %clang_cc1 -triple mips64-unknown-linux-gnuabi64 -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s +// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnuabi64 -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s // O32: define void @fn28(%struct.T2* noalias sret %agg.result, i8 signext %arg0) // N32: define void @fn28(i8 signext %arg0) Index: test/CodeGen/target-data.c =================================================================== --- test/CodeGen/target-data.c +++ test/CodeGen/target-data.c @@ -42,18 +42,34 @@ // RUN: FileCheck %s -check-prefix=MIPS-64EL // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128" +// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \ +// RUN: FileCheck %s -check-prefix=MIPS-64EL +// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128" + // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \ // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128" +// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \ +// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32 +// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128" + // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=MIPS-64EB // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128" +// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \ +// RUN: FileCheck %s -check-prefix=MIPS-64EB +// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128" + // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \ // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128" +// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \ +// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32 +// MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128" + // RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=PS3 // PS3: target datalayout = "E-m:e-p:32:32-i64:64-n32:64" Index: test/CodeGen/xray-attributes-supported.cpp =================================================================== --- test/CodeGen/xray-attributes-supported.cpp +++ test/CodeGen/xray-attributes-supported.cpp @@ -4,6 +4,10 @@ // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mipsel-unknown-linux-gnu | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnu | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnu | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnuabi64 | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnuabin32 | FileCheck %s +// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple powerpc64le-unknown-linux-gnu | FileCheck %s // Make sure that the LLVM attribute for XRay-annotated functions do show up. Index: test/Driver/clang-translation.c =================================================================== --- test/Driver/clang-translation.c +++ test/Driver/clang-translation.c @@ -330,6 +330,38 @@ // MIPS64EL: "-target-cpu" "mips64r2" // MIPS64EL: "-mfloat-abi" "hard" +// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s +// MIPS64-GNUABI64: clang +// MIPS64-GNUABI64: "-cc1" +// MIPS64-GNUABI64: "-target-cpu" "mips64r2" +// MIPS64-GNUABI64: "-target-abi" "n64" +// MIPS64-GNUABI64: "-mfloat-abi" "hard" + +// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s +// MIPS64EL-GNUABI64: clang +// MIPS64EL-GNUABI64: "-cc1" +// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2" +// MIPS64EL-GNUABI64: "-target-abi" "n64" +// MIPS64EL-GNUABI64: "-mfloat-abi" "hard" + +// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPSN32 %s +// MIPSN32: clang +// MIPSN32: "-cc1" +// MIPSN32: "-target-cpu" "mips64r2" +// MIPSN32: "-target-abi" "n32" +// MIPSN32: "-mfloat-abi" "hard" + +// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \ +// RUN: FileCheck -check-prefix=MIPSN32EL %s +// MIPSN32EL: clang +// MIPSN32EL: "-cc1" +// MIPSN32EL: "-target-cpu" "mips64r2" +// MIPSN32EL: "-target-abi" "n32" +// MIPSN32EL: "-mfloat-abi" "hard" + // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \ // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s // MIPS64EL-ANDROID: clang