r178227 - Add support for gcc-compatible -mmfcrf -mno-mfcrf PPC options

Hal Finkel hfinkel at anl.gov
Thu Mar 28 01:38:53 PDT 2013


Author: hfinkel
Date: Thu Mar 28 03:38:53 2013
New Revision: 178227

URL: http://llvm.org/viewvc/llvm-project?rev=178227&view=rev
Log:
Add support for gcc-compatible -mmfcrf -mno-mfcrf PPC options

gcc provides -mmfcrf and -mno-mfcrf for controlling what we call
the mfocrf target feature. Also, PPC is now making use of the
static function AddTargetFeature used by the Mips Driver code.

Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/ppc-features.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=178227&r1=178226&r2=178227&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Mar 28 03:38:53 2013
@@ -832,6 +832,8 @@ def mabi_EQ : Joined<["-"], "mabi=">, Gr
 def march_EQ : Joined<["-"], "march=">, Group<m_Group>;
 def maltivec : Flag<["-"], "maltivec">, Alias<faltivec>;
 def mno_altivec : Flag<["-"], "mno-altivec">, Alias<fno_altivec>;
+def mmfcrf : Flag<["-"], "mmfcrf">, Group<m_Group>;
+def mno_mfcrf : Flag<["-"], "mno-mfcrf">, Group<m_Group>;
 def mqpx : Flag<["-"], "mqpx">, Group<m_Group>;
 def mno_qpx : Flag<["-"], "mno-qpx">, Group<m_Group>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=178227&r1=178226&r2=178227&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Mar 28 03:38:53 2013
@@ -1029,7 +1029,7 @@ void PPCTargetInfo::getDefaultFeatures(l
 bool PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
                                          StringRef Name,
                                          bool Enabled) const {
-  if (Name == "altivec" || Name == "qpx") {
+  if (Name == "altivec" || Name == "mfocrf" || Name == "qpx") {
     Features[Name] = Enabled;
     return true;
   }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=178227&r1=178226&r2=178227&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Mar 28 03:38:53 2013
@@ -1097,11 +1097,17 @@ void Clang::AddPPCTargetArgs(const ArgLi
   }
 
   // Allow override of the Altivec feature.
-  if (Args.hasFlag(options::OPT_fno_altivec, options::OPT_faltivec, false)) {
-    CmdArgs.push_back("-target-feature");
-    CmdArgs.push_back("-altivec");
-  }
+  AddTargetFeature(Args, CmdArgs,
+                   options::OPT_faltivec, options::OPT_fno_altivec,
+                   "altivec");
+
+  // Note that gcc calls this mfcrf and LLVM calls this mfocrf.
+  AddTargetFeature(Args, CmdArgs,
+                   options::OPT_mmfcrf, options::OPT_mno_mfcrf,
+                   "mfocrf");
 
+  // It is really only possible to turn qpx off because turning qpx on is tied
+  // to using the a2q CPU.
   if (Args.hasFlag(options::OPT_mno_qpx, options::OPT_mqpx, false)) {
     CmdArgs.push_back("-target-feature");
     CmdArgs.push_back("-qpx");

Modified: cfe/trunk/test/Driver/ppc-features.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-features.cpp?rev=178227&r1=178226&r2=178227&view=diff
==============================================================================
--- cfe/trunk/test/Driver/ppc-features.cpp (original)
+++ cfe/trunk/test/Driver/ppc-features.cpp Thu Mar 28 03:38:53 2013
@@ -68,3 +68,9 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-qpx -mqpx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-QPX %s
 // CHECK-QPX-NOT: "-target-feature" "-qpx"
 
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-mfcrf -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOMFCRF %s
+// CHECK-NOMFCRF: "-target-feature" "-mfocrf"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-mfcrf -mmfcrf -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-MFCRF %s
+// CHECK-MFCRF: "-target-feature" "+mfocrf"
+





More information about the cfe-commits mailing list