From: Simon Atanasyan Date: Wed, 2 Jul 2014 13:20:36 +0000 (+0000) Subject: [Driver][Mips] If ABI name is not provided deduce it from the target triple X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=482e10336bb0d64d5e4a4defd6b6b1e8870dfb4f;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212176 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 35affabd5c..acb16bf842 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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(ABIName) .Cases("o32", "eabi", DefMips32CPU) .Cases("n32", "n64", DefMips64CPU) .Default(""); } - else if (!CPUName.empty()) { - // Deduce ABI name from CPU name. - ABIName = llvm::StringSwitch(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. diff --git a/test/Driver/mips-abi.c b/test/Driver/mips-abi.c index ac86abe6c1..8858e2ba6e 100644 --- a/test/Driver/mips-abi.c +++ b/test/Driver/mips-abi.c @@ -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"