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: http://review.tizen.org/git/?a=commitdiff_plain;h=a42a84e44c0fa729674659539afdb1aea5278dc6;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 35affab..acb16bf 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/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/clang/test/Driver/mips-abi.c b/clang/test/Driver/mips-abi.c index ac86abe..8858e2b 100644 --- a/clang/test/Driver/mips-abi.c +++ b/clang/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"