[cfe-commits] r159767 - /cfe/trunk/lib/Driver/Tools.cpp
Simon Atanasyan
satanasyan at mips.com
Thu Jul 5 11:51:43 PDT 2012
Author: atanasyan
Date: Thu Jul 5 13:51:43 2012
New Revision: 159767
URL: http://llvm.org/viewvc/llvm-project?rev=159767&view=rev
Log:
MIPS: Factor out the code converting command line options to target features.
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=159767&r1=159766&r2=159767&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jul 5 13:51:43 2012
@@ -880,6 +880,20 @@
return FloatABI;
}
+static void AddTargetFeature(const ArgList &Args,
+ ArgStringList &CmdArgs,
+ OptSpecifier OnOpt,
+ OptSpecifier OffOpt,
+ StringRef FeatureName) {
+ if (Arg *A = Args.getLastArg(OnOpt, OffOpt)) {
+ CmdArgs.push_back("-target-feature");
+ if (A->getOption().matches(OnOpt))
+ CmdArgs.push_back(Args.MakeArgString("+" + FeatureName));
+ else
+ CmdArgs.push_back(Args.MakeArgString("-" + FeatureName));
+ }
+}
+
void Clang::AddMIPSTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
const Driver &D = getToolChain().getDriver();
@@ -920,14 +934,9 @@
CmdArgs.push_back("hard");
}
- if (Arg *A = Args.getLastArg(options::OPT_mips16,
- options::OPT_mno_mips16)) {
- CmdArgs.push_back("-target-feature");
- if (A->getOption().matches(options::OPT_mips16))
- CmdArgs.push_back("+mips16");
- else
- CmdArgs.push_back("-mips16");
- }
+ AddTargetFeature(Args, CmdArgs,
+ options::OPT_mips16, options::OPT_mno_mips16,
+ "mips16");
}
/// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting.
More information about the cfe-commits
mailing list