From: Simon Atanasyan Date: Wed, 27 Feb 2013 14:55:49 +0000 (+0000) Subject: [Mips] Add two new aliases for MIPS ABI names 32 (means o32 abi) and 64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9616a4972a4c2fdc28128c057f21d7a79516c86;p=clang [Mips] Add two new aliases for MIPS ABI names 32 (means o32 abi) and 64 (means n64 abi) to improve compatibility with GNU tools. Patch by Jia Liu . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176187 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index ec57ca3609..24a69ee22b 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -4411,6 +4411,12 @@ public: Name == "mips16" || Name == "dsp" || Name == "dspr2") { Features[Name] = Enabled; return true; + } else if (Name == "32") { + Features["o32"] = Enabled; + return true; + } else if (Name == "64") { + Features["n64"] = Enabled; + return true; } return false; } @@ -4467,6 +4473,9 @@ public: if ((Name == "o32") || (Name == "eabi")) { ABI = Name; return true; + } else if (Name == "32") { + ABI = "o32"; + return true; } else return false; } @@ -4571,18 +4580,19 @@ public: } virtual bool setABI(const std::string &Name) { SetDescriptionString(Name); - - if (Name != "n32" && Name != "n64") - return false; - - ABI = Name; - if (Name == "n32") { LongWidth = LongAlign = 32; PointerWidth = PointerAlign = 32; - } - - return true; + ABI = Name; + return true; + } else if (Name == "n64") { + ABI = Name; + return true; + } else if (Name == "64") { + ABI = "n64"; + return true; + } else + return false; } virtual void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index c24878d70f..eac4bc600f 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -870,8 +870,8 @@ static void getMipsCPUAndABI(const ArgList &Args, if (!ABIName.empty()) { // Deduce CPU name from ABI name. CPUName = llvm::StringSwitch(ABIName) - .Cases("o32", "eabi", DefMips32CPU) - .Cases("n32", "n64", DefMips64CPU) + .Cases("32", "o32", "eabi", DefMips32CPU) + .Cases("n32", "n64", "64", DefMips64CPU) .Default(""); } else if (!CPUName.empty()) { @@ -885,6 +885,14 @@ static void getMipsCPUAndABI(const ArgList &Args, // FIXME: Warn on inconsistent cpu and abi usage. } +// Convert ABI name to the GNU tools acceptable variant. +static StringRef getGnuCompatibleMipsABIName(StringRef ABI) { + return llvm::StringSwitch(ABI) + .Case("o32", "32") + .Case("n64", "64") + .Default(ABI); +} + // Select the MIPS float ABI as determined by -msoft-float, -mhard-float, // and -mfloat-abi=. static StringRef getMipsFloatABI(const Driver &D, const ArgList &Args) { @@ -5160,14 +5168,8 @@ void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, 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()); + CmdArgs.push_back(getGnuCompatibleMipsABIName(ABIName).data()); if (getToolChain().getArch() == llvm::Triple::mips || getToolChain().getArch() == llvm::Triple::mips64) @@ -5585,14 +5587,8 @@ void linuxtools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, 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()); + CmdArgs.push_back(getGnuCompatibleMipsABIName(ABIName).data()); if (getToolChain().getArch() == llvm::Triple::mips || getToolChain().getArch() == llvm::Triple::mips64) diff --git a/test/Driver/freebsd-mips-as.c b/test/Driver/freebsd-mips-as.c index 54ff187515..508debae7f 100644 --- a/test/Driver/freebsd-mips-as.c +++ b/test/Driver/freebsd-mips-as.c @@ -32,8 +32,8 @@ // // RUN: %clang -target mipsel-unknown-freebsd -### \ // RUN: -no-integrated-as -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s -// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" +// RUN: | FileCheck -check-prefix=MIPS32-DEF-EL-AS %s +// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" // // RUN: %clang -target mips64-unknown-freebsd -### \ // RUN: -no-integrated-as -c %s 2>&1 \ @@ -42,8 +42,8 @@ // // RUN: %clang -target mips64el-unknown-freebsd -### \ // RUN: -no-integrated-as -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s -// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" +// RUN: | FileCheck -check-prefix=MIPS64-DEF-EL-AS %s +// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" // // RUN: %clang -target mips-unknown-freebsd -mabi=eabi -### \ // RUN: -no-integrated-as -c %s 2>&1 \ @@ -55,6 +55,16 @@ // RUN: | FileCheck -check-prefix=MIPS-N32 %s // MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB" // +// RUN: %clang -target mipsel-unknown-freebsd -mabi=32 -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s +// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" +// +// RUN: %clang -target mips64el-unknown-freebsd -mabi=64 -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s +// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" +// // RUN: %clang -target mips-linux-freebsd -march=mips32r2 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-32R2 %s diff --git a/test/Driver/mips-as.c b/test/Driver/mips-as.c index fbaf62fdad..146b1930c6 100644 --- a/test/Driver/mips-as.c +++ b/test/Driver/mips-as.c @@ -16,8 +16,8 @@ // // RUN: %clang -target mipsel-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s -// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" +// RUN: | FileCheck -check-prefix=MIPS32-DEF-EL-AS %s +// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" // // RUN: %clang -target mips64-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ @@ -26,8 +26,8 @@ // // RUN: %clang -target mips64el-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s -// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" +// RUN: | FileCheck -check-prefix=MIPS64-DEF-EL-AS %s +// MIPS64-DEF-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 \ @@ -39,6 +39,16 @@ // RUN: | FileCheck -check-prefix=MIPS-N32 %s // MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB" // +// RUN: %clang -target mipsel-linux-gnu -mabi=32 -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s +// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" +// +// RUN: %clang -target mips64el-linux-gnu -mabi=64 -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s +// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" +// // RUN: %clang -target mips-linux-gnu -march=mips32r2 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-32R2 %s