MIPS: Pass -mabi option to the assmbler when compile MIPS targets.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154270 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index db33667..fd064d5 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -5029,17 +5029,21 @@
getToolChain().getArch() == llvm::Triple::mipsel ||
getToolChain().getArch() == llvm::Triple::mips64 ||
getToolChain().getArch() == llvm::Triple::mips64el) {
- // Get Mips CPU name and pass it to 'as'.
- const char *CPUName;
- if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
- CPUName = A->getValue(Args);
- else
- CPUName = getMipsCPUFromArch(getToolChain().getArchName());
+ StringRef CPUName;
+ StringRef ABIName;
+ getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName);
- if (CPUName) {
- CmdArgs.push_back("-march");
- CmdArgs.push_back(CPUName);
- }
+ CmdArgs.push_back("-march");
+ CmdArgs.push_back(CPUName.data());
+
+ // Convert ABI name to the GNU tools acceptable variant.
+ if (ABIName == "o32")
+ ABIName = "32";
+ else if (ABIName == "n64")
+ ABIName = "64";
+
+ CmdArgs.push_back("-mabi");
+ CmdArgs.push_back(ABIName.data());
if (getToolChain().getArch() == llvm::Triple::mips ||
getToolChain().getArch() == llvm::Triple::mips64)
diff --git a/test/Driver/mips-as.c b/test/Driver/mips-as.c
index d6282d7..44b8d8d 100644
--- a/test/Driver/mips-as.c
+++ b/test/Driver/mips-as.c
@@ -3,19 +3,29 @@
// RUN: %clang -target mips-linux-gnu -### \
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS32-EB-AS %s
-// CHECK-MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-EB"
+// CHECK-MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
//
// RUN: %clang -target mipsel-linux-gnu -### \
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s
-// CHECK-MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-EL"
+// CHECK-MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
//
// RUN: %clang -target mips64-linux-gnu -### \
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS64-EB-AS %s
-// CHECK-MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-EB"
+// CHECK-MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
//
// RUN: %clang -target mips64el-linux-gnu -### \
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s
-// CHECK-MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-EL"
+// CHECK-MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+//
+// RUN: %clang -target mips-linux-gnu -mabi=eabi -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS-EABI %s
+// CHECK-MIPS-EABI: as{{(.exe)?}}" "-march" "mips32" "-mabi" "eabi" "-EB"
+//
+// RUN: %clang -target mips64-linux-gnu -mabi=n32 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS-N32 %s
+// CHECK-MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB"