[Driver][Mips] If ABI name is not provided deduce it from the target triple

not from the CPU name. This approach is closer to the method used by gcc driver.

llvm-svn: 212176
This commit is contained in:
Simon Atanasyan 2014-07-02 13:20:36 +00:00
parent 3acd6bd0b6
commit a42a84e44c
2 changed files with 50 additions and 10 deletions

View File

@ -947,22 +947,22 @@ static void getMipsCPUAndABI(const ArgList &Args,
}
}
if (!ABIName.empty()) {
if (ABIName.empty()) {
// Deduce ABI name from the target triple.
if (Triple.getArch() == llvm::Triple::mips ||
Triple.getArch() == llvm::Triple::mipsel)
ABIName = "o32";
else
ABIName = "n64";
}
if (CPUName.empty()) {
// Deduce CPU name from ABI name.
CPUName = llvm::StringSwitch<const char *>(ABIName)
.Cases("o32", "eabi", DefMips32CPU)
.Cases("n32", "n64", DefMips64CPU)
.Default("");
}
else if (!CPUName.empty()) {
// Deduce ABI name from CPU name.
ABIName = llvm::StringSwitch<const char *>(CPUName)
.Cases("mips32", "mips32r2", "o32")
.Cases("mips64", "mips64r2", "n64")
.Default("");
}
// FIXME: Warn on inconsistent cpu and abi usage.
}
// Convert ABI name to the GNU tools acceptable variant.

View File

@ -1,5 +1,15 @@
// Check passing Mips ABI options to the backend.
//
// RUN: %clang -target mips-linux-gnu -### -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-DEF %s
// MIPS-DEF: "-target-cpu" "mips32r2"
// 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: %clang -target mips-linux-gnu -### -c %s \
// RUN: -mabi=32 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-ABI-32 %s
@ -45,3 +55,33 @@
// RUN: -mabi=unknown 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-ABI-UNKNOWN %s
// MIPS-ABI-UNKNOWN: error: unknown target ABI 'unknown'
//
// RUN: %clang -target mips-linux-gnu -### -c %s \
// RUN: -march=mips32 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-ARCH-32 %s
// MIPS-ARCH-32: "-target-cpu" "mips32"
// MIPS-ARCH-32: "-target-abi" "o32"
//
// RUN: %clang -target mips-linux-gnu -### -c %s \
// RUN: -march=mips32r2 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-ARCH-32R2 %s
// MIPS-ARCH-32R2: "-target-cpu" "mips32r2"
// MIPS-ARCH-32R2: "-target-abi" "o32"
//
// RUN: %clang -target mips-linux-gnu -### -c %s \
// RUN: -march=mips64 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-ARCH-3264 %s
// MIPS-ARCH-3264: "-target-cpu" "mips64"
// MIPS-ARCH-3264: "-target-abi" "o32"
//
// RUN: %clang -target mips64-linux-gnu -### -c %s \
// RUN: -march=mips64 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-ARCH-64 %s
// MIPS-ARCH-64: "-target-cpu" "mips64"
// MIPS-ARCH-64: "-target-abi" "n64"
//
// RUN: %clang -target mips64-linux-gnu -### -c %s \
// RUN: -march=mips64r2 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-ARCH-64R2 %s
// MIPS-ARCH-64R2: "-target-cpu" "mips64r2"
// MIPS-ARCH-64R2: "-target-abi" "n64"