r213143 - [Driver][Mips] Reduce code duplication - use existing function
Simon Atanasyan
simon at atanasyan.com
Wed Jul 16 05:29:27 PDT 2014
Author: atanasyan
Date: Wed Jul 16 07:29:22 2014
New Revision: 213143
URL: http://llvm.org/viewvc/llvm-project?rev=213143&view=rev
Log:
[Driver][Mips] Reduce code duplication - use existing function
getMipsCPUAndABI() to get MIPS ABI name during multi-library selection.
No functional changes.
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=213143&r1=213142&r2=213143&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Jul 16 07:29:22 2014
@@ -1626,10 +1626,6 @@ static bool isMipsEL(llvm::Triple::ArchT
return Arch == llvm::Triple::mipsel || Arch == llvm::Triple::mips64el;
}
-static bool isMipsEB(llvm::Triple::ArchType Arch) {
- return Arch == llvm::Triple::mips || Arch == llvm::Triple::mips64;
-}
-
static bool isMips16(const ArgList &Args) {
Arg *A = Args.getLastArg(options::OPT_mips16,
options::OPT_mno_mips16);
@@ -1744,7 +1740,7 @@ static bool findMIPSMultilibs(const llvm
.gccSuffix("/64")
.osSuffix("/64")
.includeSuffix("/64")
- .flag("+mabi=64").flag("-mabi=n32").flag("-m32");
+ .flag("+mabi=n64").flag("-mabi=n32").flag("-m32");
Multilib BigEndian = Multilib()
.flag("+EB").flag("-EL");
@@ -1840,7 +1836,7 @@ static bool findMIPSMultilibs(const llvm
Multilib MAbi64 = Multilib()
.gccSuffix("/64")
.includeSuffix("/64")
- .flag("+mabi=64").flag("-mabi=n32").flag("-m32");
+ .flag("+mabi=n64").flag("-mabi=n32").flag("-m32");
CSMipsMultilibs = MultilibSet()
.Either(MArchMips16, MArchMicroMips, MArchDefault)
@@ -1896,7 +1892,7 @@ static bool findMIPSMultilibs(const llvm
.gccSuffix("/64")
.osSuffix("/64")
.includeSuffix("/64")
- .flag("+mabi=64").flag("-mabi=n32").flag("-m32");
+ .flag("+mabi=n64").flag("-mabi=n32").flag("-m32");
ImgMultilibs = MultilibSet()
.Maybe(Mips64r6)
@@ -1905,6 +1901,10 @@ static bool findMIPSMultilibs(const llvm
.FilterOut(NonExistent);
}
+ StringRef CPUName;
+ StringRef ABIName;
+ tools::mips::getMipsCPUAndABI(Args, TargetTriple, CPUName, ABIName);
+
llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
Multilib::flags_list Flags;
@@ -1918,16 +1918,12 @@ static bool findMIPSMultilibs(const llvm
addMultilibFlag(!isMipsFP64(Args), "mfp32", Flags);
addMultilibFlag(tools::mips::isNaN2008(Args, TargetTriple), "mnan=2008",
Flags);
- addMultilibFlag(tools::mips::hasMipsAbiArg(Args, "n32"), "mabi=n32", Flags);
- // Default is to assume mabi=64
- bool IsMABI64 =
- tools::mips::hasMipsAbiArg(Args, "64") ||
- (!tools::mips::hasMipsAbiArg(Args, "n32") && isMips64(TargetArch));
- addMultilibFlag(IsMABI64, "mabi=64", Flags);
+ addMultilibFlag(ABIName == "n32", "mabi=n32", Flags);
+ addMultilibFlag(ABIName == "n64", "mabi=n64", Flags);
addMultilibFlag(isSoftFloatABI(Args), "msoft-float", Flags);
addMultilibFlag(!isSoftFloatABI(Args), "mhard-float", Flags);
addMultilibFlag(isMipsEL(TargetArch), "EL", Flags);
- addMultilibFlag(isMipsEB(TargetArch), "EB", Flags);
+ addMultilibFlag(!isMipsEL(TargetArch), "EB", Flags);
if (TargetTriple.getEnvironment() == llvm::Triple::Android) {
// Select Android toolchain. It's the only choice in that case.
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=213143&r1=213142&r2=213143&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 16 07:29:22 2014
@@ -909,10 +909,10 @@ void Clang::AddAArch64TargetArgs(const A
// Get CPU and ABI names. They are not independent
// so we have to calculate them together.
-static void getMipsCPUAndABI(const ArgList &Args,
- const llvm::Triple &Triple,
- StringRef &CPUName,
- StringRef &ABIName) {
+void mips::getMipsCPUAndABI(const ArgList &Args,
+ const llvm::Triple &Triple,
+ StringRef &CPUName,
+ StringRef &ABIName) {
const char *DefMips32CPU = "mips32r2";
const char *DefMips64CPU = "mips64r2";
@@ -1028,7 +1028,7 @@ static void getMIPSTargetFeatures(const
std::vector<const char *> &Features) {
StringRef CPUName;
StringRef ABIName;
- getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
ABIName = getGnuCompatibleMipsABIName(ABIName);
StringRef FloatABI = getMipsFloatABI(D, Args);
@@ -1089,7 +1089,7 @@ void Clang::AddMIPSTargetArgs(const ArgL
StringRef CPUName;
StringRef ABIName;
const llvm::Triple &Triple = getToolChain().getTriple();
- getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
CmdArgs.push_back("-target-abi");
CmdArgs.push_back(ABIName.data());
@@ -1383,7 +1383,7 @@ static std::string getCPUName(const ArgL
case llvm::Triple::mips64el: {
StringRef CPUName;
StringRef ABIName;
- getMipsCPUAndABI(Args, T, CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, T, CPUName, ABIName);
return CPUName;
}
@@ -6040,7 +6040,7 @@ void openbsd::Assemble::ConstructJob(Com
case llvm::Triple::mips64el: {
StringRef CPUName;
StringRef ABIName;
- getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
CmdArgs.push_back("-mabi");
CmdArgs.push_back(getGnuCompatibleMipsABIName(ABIName).data());
@@ -6362,7 +6362,7 @@ void freebsd::Assemble::ConstructJob(Com
getToolChain().getArch() == llvm::Triple::mips64el) {
StringRef CPUName;
StringRef ABIName;
- getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
CmdArgs.push_back("-march");
CmdArgs.push_back(CPUName.data());
@@ -6635,7 +6635,7 @@ void netbsd::Assemble::ConstructJob(Comp
case llvm::Triple::mips64el: {
StringRef CPUName;
StringRef ABIName;
- getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
CmdArgs.push_back("-march");
CmdArgs.push_back(CPUName.data());
@@ -6929,7 +6929,7 @@ void gnutools::Assemble::ConstructJob(Co
getToolChain().getArch() == llvm::Triple::mips64el) {
StringRef CPUName;
StringRef ABIName;
- getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
ABIName = getGnuCompatibleMipsABIName(ABIName);
CmdArgs.push_back("-march");
Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=213143&r1=213142&r2=213143&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Wed Jul 16 07:29:22 2014
@@ -217,6 +217,9 @@ namespace arm {
}
namespace mips {
+ void getMipsCPUAndABI(const llvm::opt::ArgList &Args,
+ const llvm::Triple &Triple, StringRef &CPUName,
+ StringRef &ABIName);
bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
bool isNaN2008(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
More information about the cfe-commits
mailing list