Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1221,6 +1221,30 @@ } } + if (ABIName.empty() && + (Triple.getVendor() == llvm::Triple::MipsTechnologies || + Triple.getVendor() == llvm::Triple::ImaginationTechnologies)) { + ABIName = llvm::StringSwitch(CPUName) + .Case("mips1", "o32") + .Case("mips2", "o32") + .Case("mips3", "n64") + .Case("mips4", "n64") + .Case("mips5", "n64") + .Case("mips32", "o32") + .Case("mips32r2", "o32") + .Case("mips32r3", "o32") + .Case("mips32r5", "o32") + .Case("mips32r6", "o32") + .Case("mips64", "n64") + .Case("mips64r2", "n64") + .Case("mips64r3", "n64") + .Case("mips64r5", "n64") + .Case("mips64r6", "n64") + .Case("octeon", "n64") + .Case("p5600", "o32") + .Default(""); + } + if (ABIName.empty()) { // Deduce ABI name from the target triple. if (Triple.getArch() == llvm::Triple::mips || Index: test/Driver/mips-abi.c =================================================================== --- test/Driver/mips-abi.c +++ test/Driver/mips-abi.c @@ -6,9 +6,22 @@ // MIPS-DEF: "-target-abi" "o32" // // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix=MIPS64-DEF %s -// MIPS64-DEF: "-target-cpu" "mips64r2" -// MIPS64-DEF: "-target-abi" "n64" +// RUN: | FileCheck -check-prefix=MIPS64R2-N64 %s +// RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS64R2-N64 %s +// RUN: %clang -target mips-mti-linux-gnu -mips64r2 -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS64R2-N64 %s +// MIPS64R2-N64: "-target-cpu" "mips64r2" +// MIPS64R2-N64: "-target-abi" "n64" +// +// RUN: %clang -target mips64-linux-gnu -### -mips64r3 -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS64R3-N64 %s +// RUN: %clang -target mips-img-linux-gnu -mips64r3 -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS64R3-N64 %s +// RUN: %clang -target mips-mti-linux-gnu -mips64r3 -### -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS64R3-N64 %s +// MIPS64R3-N64: "-target-cpu" "mips64r3" +// MIPS64R3-N64: "-target-abi" "n64" // // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mabi=32 2>&1 \