summaryrefslogtreecommitdiffstats
path: root/lib/Driver
diff options
context:
space:
mode:
authorSimon Atanasyan <satanasyan@mips.com>2012-04-07 22:09:23 +0000
committerSimon Atanasyan <satanasyan@mips.com>2012-04-07 22:09:23 +0000
commita2768be144256f9eb721bef8b751e56e0b64fa0b (patch)
treecf484da87ee92c9675e1582daf6233159ea7409a /lib/Driver
parent3be55cdbb5fda326dc55eb01c92d6645a2304309 (diff)
MIPS: Move code calculates CPU and ABI names to the separate function to reuse this function later.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154269 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver')
-rw-r--r--lib/Driver/Tools.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index ae9c1a54f1..db336676b7 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -787,38 +787,46 @@ static const char* getMipsABIFromArch(StringRef ArchName) {
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=.