]> granicus.if.org Git - clang/commitdiff
Add four new command line options for MIPS CPU selection:
authorSimon Atanasyan <satanasyan@mips.com>
Fri, 21 Sep 2012 20:19:32 +0000 (20:19 +0000)
committerSimon Atanasyan <satanasyan@mips.com>
Fri, 21 Sep 2012 20:19:32 +0000 (20:19 +0000)
-mips32, -mips32r2, -mips64, -mips64r2.

The patch reviewed by Eric Christopher.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164410 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.td
lib/Driver/Tools.cpp
test/Driver/freebsd-mips-as.c
test/Driver/mips-as.c

index b13c45bb3c9b88f5c0016bb04a4581245abeeb34..8a7d1135cf9bb33e427157bacdfdadebea40bee7 100644 (file)
@@ -41,6 +41,8 @@ def m_x86_Features_Group  : OptionGroup<"<m x86 features group>">, Group<m_Group
 def m_hexagon_Features_Group  : OptionGroup<"<m hexagon features group>">, Group<m_Group>;
 def opencl_Group          : OptionGroup<"<opencl group>">;
 def u_Group               : OptionGroup<"<u group>">;
+def mips_CPUs_Group       : OptionGroup<"<MIPS CPU aliases group>">,
+  Group<CompileOnly_Group>;
 
 def pedantic_Group        : OptionGroup<"<pedantic group>">,
   Group<CompileOnly_Group>;
@@ -869,6 +871,14 @@ def mdsp : Flag<"-mdsp">, Group<m_Group>;
 def mno_dsp : Flag<"-mno-dsp">, Group<m_Group>;
 def mdspr2 : Flag<"-mdspr2">, Group<m_Group>;
 def mno_dspr2 : Flag<"-mno-dspr2">, Group<m_Group>;
+def mips32 : Flag<"-mips32">, Group<mips_CPUs_Group>,
+  HelpText<"Equivalent to -march=mips32">;
+def mips32r2 : Flag<"-mips32r2">, Group<mips_CPUs_Group>,
+  HelpText<"Equivalent to -march=mips32r2">;
+def mips64 : Flag<"-mips64">, Group<mips_CPUs_Group>,
+  HelpText<"Equivalent to -march=mips64">;
+def mips64r2 : Flag<"-mips64r2">, Group<mips_CPUs_Group>,
+  HelpText<"Equivalent to -march=mips64r2">;
 def mthumb : Flag<"-mthumb">, Group<m_Group>;
 def mtune_EQ : Joined<"-mtune=">, Group<m_Group>;
 def multi__module : Flag<"-multi_module">;
index 960ffde228f3bb5a13048a5b3fe00923b4f8f784..0866c0165765ebb77788f6c956fceb531cfd7b7f 100644 (file)
@@ -778,6 +778,20 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
     CmdArgs.push_back("-no-implicit-float");
 }
 
+// Translate MIPS CPU name alias option to CPU name.
+static StringRef getMipsCPUFromAlias(const Arg &A) {
+  if (A.getOption().matches(options::OPT_mips32))
+    return "mips32";
+  if (A.getOption().matches(options::OPT_mips32r2))
+    return "mips32r2";
+  if (A.getOption().matches(options::OPT_mips64))
+    return "mips64";
+  if (A.getOption().matches(options::OPT_mips64r2))
+    return "mips64r2";
+  llvm_unreachable("Unexpected option");
+  return "";
+}
+
 // Get CPU and ABI names. They are not independent
 // so we have to calculate them together.
 static void getMipsCPUAndABI(const ArgList &Args,
@@ -788,8 +802,13 @@ static void getMipsCPUAndABI(const ArgList &Args,
   const char *DefMips64CPU = "mips64";
 
   if (Arg *A = Args.getLastArg(options::OPT_march_EQ,
-                               options::OPT_mcpu_EQ))
-    CPUName = A->getValue(Args);
+                               options::OPT_mcpu_EQ,
+                               options::OPT_mips_CPUs_Group)) {
+    if (A->getOption().matches(options::OPT_mips_CPUs_Group))
+      CPUName = getMipsCPUFromAlias(*A);
+    else
+      CPUName = A->getValue(Args);
+  }
 
   if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
     ABIName = A->getValue(Args);
index 4131caba7e9feca43c56d6dfca834d1ce9f80f21..54ff1875155bf2ab1b4381fa36aa32e935e6a4a1 100644 (file)
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-32R2 %s
 // MIPS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+//
+// RUN: %clang -target mips-unknown-freebsd -mips32 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-32 %s
+// MIPS-ALIAS-32: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
+//
+// RUN: %clang -target mips-unknown-freebsd -mips32r2 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-32R2 %s
+// MIPS-ALIAS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+//
+// RUN: %clang -target mips-unknown-freebsd -mips64 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64 %s
+// MIPS-ALIAS-64: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
+//
+// RUN: %clang -target mips-unknown-freebsd -mips64r2 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R2 %s
+// MIPS-ALIAS-64R2: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
index 95b93b791c742473d461d0e601aee0bd94aa5644..fbaf62fdadd5451448bab8036498796089b79b91 100644 (file)
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-32R2 %s
 // MIPS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+//
+// RUN: %clang -target mips-linux-gnu -mips32 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-32 %s
+// MIPS-ALIAS-32: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
+//
+// RUN: %clang -target mips-linux-gnu -mips32r2 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-32R2 %s
+// MIPS-ALIAS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+//
+// RUN: %clang -target mips-linux-gnu -mips64 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64 %s
+// MIPS-ALIAS-64: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
+//
+// RUN: %clang -target mips-linux-gnu -mips64r2 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R2 %s
+// MIPS-ALIAS-64R2: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"