]> granicus.if.org Git - clang/commitdiff
MIPS: Add -mips16 / -mno-mips16 command line support.
authorSimon Atanasyan <satanasyan@mips.com>
Thu, 5 Jul 2012 14:19:39 +0000 (14:19 +0000)
committerSimon Atanasyan <satanasyan@mips.com>
Thu, 5 Jul 2012 14:19:39 +0000 (14:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159747 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.td
lib/Basic/Targets.cpp
lib/Driver/Tools.cpp
test/Driver/mips-features.c [new file with mode: 0644]

index 6a99b5a644991b570a367f092c529a1f99e80a20..496683307ba0f432f006b9524b561c57cd970e1c 100644 (file)
@@ -846,6 +846,8 @@ def mbmi : Flag<"-mbmi">, Group<m_x86_Features_Group>;
 def mbmi2 : Flag<"-mbmi2">, Group<m_x86_Features_Group>;
 def mpopcnt : Flag<"-mpopcnt">, Group<m_x86_Features_Group>;
 def mfma4 : Flag<"-mfma4">, Group<m_x86_Features_Group>;
+def mips16 : Flag<"-mips16">, Group<m_Group>;
+def mno_mips16 : Flag<"-mno-mips16">, Group<m_Group>;
 def mthumb : Flag<"-mthumb">, Group<m_Group>;
 def mtune_EQ : Joined<"-mtune=">, Group<m_Group>;
 def multi__module : Flag<"-multi_module">;
index f094784c7278b9792e757cc83477b241c803ac11..5d29417cb414a40e9ecfe8f149a90fb109958ce1 100644 (file)
@@ -3708,7 +3708,8 @@ public:
     if (Name == "soft-float" || Name == "single-float" ||
         Name == "o32" || Name == "n32" || Name == "n64" || Name == "eabi" ||
         Name == "mips32" || Name == "mips32r2" ||
-        Name == "mips64" || Name == "mips64r2") {
+        Name == "mips64" || Name == "mips64r2" ||
+        Name == "mips16") {
       Features[Name] = Enabled;
       return true;
     }
index a5e2e401e2272bc1600707d4bf5f0f383e707272..1be4659f61437f8244498a4ee10fc67abe706cf2 100644 (file)
@@ -919,6 +919,15 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args,
     CmdArgs.push_back("-mfloat-abi");
     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");
+  }
 }
 
 /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting.
diff --git a/test/Driver/mips-features.c b/test/Driver/mips-features.c
new file mode 100644 (file)
index 0000000..038b718
--- /dev/null
@@ -0,0 +1,13 @@
+// Check handling MIPS specific features options.
+//
+// -mips16
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:     -mno-mips16 -mips16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS16 %s
+// CHECK-MIPS16: "-target-feature" "+mips16"
+//
+// -mno-mips16
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:     -mips16 -mno-mips16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOMIPS16 %s
+// CHECK-NOMIPS16: "-target-feature" "-mips16"