[cfe-commits] r154269 - /cfe/trunk/lib/Driver/Tools.cpp
Simon Atanasyan
satanasyan at mips.com
Sat Apr 7 15:09:23 PDT 2012
Author: atanasyan
Date: Sat Apr 7 17:09:23 2012
New Revision: 154269
URL: http://llvm.org/viewvc/llvm-project?rev=154269&view=rev
Log:
MIPS: Move code calculates CPU and ABI names to the separate function to reuse this function later.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=154269&r1=154268&r2=154269&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Apr 7 17:09:23 2012
@@ -787,38 +787,46 @@
return "n64";
}
-void Clang::AddMIPSTargetArgs(const ArgList &Args,
- ArgStringList &CmdArgs) const {
- const Driver &D = getToolChain().getDriver();
-
+// Get CPU and ABI names. They are not independent
+// so we have to calculate them together.
+static void getMipsCPUAndABI(const ArgList &Args,
+ const ToolChain &TC,
+ StringRef &CPUName,
+ StringRef &ABIName) {
StringRef ArchName;
- const char *CPUName;
- // Set target cpu and architecture.
+ // Select target cpu and architecture.
if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
CPUName = A->getValue(Args);
ArchName = getMipsArchFromCPU(CPUName);
}
else {
- ArchName = Args.MakeArgString(getToolChain().getArchName());
+ ArchName = Args.MakeArgString(TC.getArchName());
if (!checkMipsArchName(ArchName))
- D.Diag(diag::err_drv_invalid_arch_name) << ArchName;
+ TC.getDriver().Diag(diag::err_drv_invalid_arch_name) << ArchName;
else
CPUName = getMipsCPUFromArch(ArchName);
}
-
- CmdArgs.push_back("-target-cpu");
- CmdArgs.push_back(CPUName);
// Select the ABI to use.
- const char *ABIName = 0;
if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
ABIName = A->getValue(Args);
else
ABIName = getMipsABIFromArch(ArchName);
+}
+
+void Clang::AddMIPSTargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ const Driver &D = getToolChain().getDriver();
+ StringRef CPUName;
+ StringRef ABIName;
+ getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName);
+
+ CmdArgs.push_back("-target-cpu");
+ CmdArgs.push_back(CPUName.data());
CmdArgs.push_back("-target-abi");
- CmdArgs.push_back(ABIName);
+ CmdArgs.push_back(ABIName.data());
// Select the float ABI as determined by -msoft-float, -mhard-float,
// and -mfloat-abi=.
More information about the cfe-commits
mailing list