]> granicus.if.org Git - clang/commitdiff
[PowerPC] Add feature for Power8 vector extensions
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Fri, 10 Oct 2014 15:09:43 +0000 (15:09 +0000)
committerBill Schmidt <wschmidt@linux.vnet.ibm.com>
Fri, 10 Oct 2014 15:09:43 +0000 (15:09 +0000)
The current VSX feature for PowerPC specifies availability of the VSX
instructions added with the 2.06 architecture version.  With 2.07, the
architecture adds new instructions to both the Category:Vector and
Category:VSX instruction sets.  Additionally, unaligned vector storage
operations have improved performance.

This patch adds a feature to provide access to the new instructions
and performance capabilities of Power8.  For compatibility with GCC,
the feature is controlled via a new -mpower8-vector switch, and the
feature causes the __POWER8_VECTOR__ builtin define to be generated by
the preprocessor.

There is a companion patch for llvm being committed at the same time.

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

include/clang/Driver/Options.td
lib/Basic/Targets.cpp
test/Driver/ppc-features.cpp
test/Preprocessor/predefined-arch-macros.c

index b24d16ba068b11dd6dab71346bdcaeceeeef5664..d1f776c11b647876b4baf1cf712fd71aa4a6a8ee 100644 (file)
@@ -1171,6 +1171,10 @@ def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group<m_aarch64_Feat
 
 def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group<m_ppc_Features_Group>;
+def mpower8_vector : Flag<["-"], "mpower8-vector">,
+    Group<m_ppc_Features_Group>;
+def mno_power8_vector : Flag<["-"], "mno-power8-vector">,
+    Group<m_ppc_Features_Group>;
 def mfprnd : Flag<["-"], "mfprnd">, Group<m_ppc_Features_Group>;
 def mno_fprnd : Flag<["-"], "mno-fprnd">, Group<m_ppc_Features_Group>;
 def mmfcrf : Flag<["-"], "mmfcrf">, Group<m_ppc_Features_Group>;
index 0df01df77fb54ea4df20872cb592c8e41170c134..902f1c3c610206f7791478b36946a84db41da65d 100644 (file)
@@ -672,13 +672,14 @@ class PPCTargetInfo : public TargetInfo {
 
   // Target cpu features.
   bool HasVSX;
+  bool HasPower8Vector;
 
 protected:
   std::string ABI;
 
 public:
   PPCTargetInfo(const llvm::Triple &Triple)
-      : TargetInfo(Triple), HasVSX(false) {
+    : TargetInfo(Triple), HasVSX(false), HasPower8Vector(false) {
     BigEndian = (Triple.getArch() != llvm::Triple::ppc64le);
     LongDoubleWidth = LongDoubleAlign = 128;
     LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
@@ -934,6 +935,11 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       continue;
     }
 
+    if (Feature == "power8-vector") {
+      HasPower8Vector = true;
+      continue;
+    }
+
     // TODO: Finish this list and add an assert that we've handled them
     // all.
   }
@@ -1084,6 +1090,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
 
   if (HasVSX)
     Builder.defineMacro("__VSX__");
+  if (HasPower8Vector)
+    Builder.defineMacro("__POWER8_VECTOR__");
 
   // FIXME: The following are not yet generated here by Clang, but are
   //        generated by GCC:
index c7b59cc7aaa21f0c74760c1fdd78924ad530eeba..c62f5b969736b0443ff588db4aeb5c12509c35db 100644 (file)
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-vsx -mvsx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-VSX %s
 // CHECK-VSX: "-target-feature" "+vsx"
 
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power8-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOP8VECTOR %s
+// CHECK-NOP8VECTOR: "-target-feature" "-power8-vector"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power8-vector -mpower8-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-P8VECTOR %s
+// CHECK-P8VECTOR: "-target-feature" "+power8-vector"
+
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-crbits -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s
 // CHECK-NOCRBITS: "-target-feature" "-crbits"
 
index 5f5380926dcacc10388ec937bfbe87a6e6950260..8b58c9ce01f3af2878c3c32c3ad20737e944439e 100644 (file)
 // RUN:   | FileCheck %s -check-prefix=CHECK_PPC_VSX_M64
 //
 // CHECK_PPC_VSX_M64: #define __VSX__
+//
+// RUN: %clang -mpower8-vector -E -dM %s -o - 2>&1 \
+// RUN:     -target powerpc64-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_PPC_POWER8_VECTOR_M64
+//
+// CHECK_PPC_POWER8_VECTOR_M64: #define __POWER8_VECTOR__
+//