]> granicus.if.org Git - clang/commitdiff
MIPS: Factor out the code converting command line options to target features.
authorSimon Atanasyan <satanasyan@mips.com>
Thu, 5 Jul 2012 18:51:43 +0000 (18:51 +0000)
committerSimon Atanasyan <satanasyan@mips.com>
Thu, 5 Jul 2012 18:51:43 +0000 (18:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159767 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp

index 1be4659f61437f8244498a4ee10fc67abe706cf2..a4153515de5573eb08a1893cb566b321683ce7b8 100644 (file)
@@ -880,6 +880,20 @@ static StringRef getMipsFloatABI(const Driver &D, const ArgList &Args) {
   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 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args,
     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.