[Patch/RFC PPC64] handle Power8 as a target

Will Schmidt will_schmidt at vnet.ibm.com
Wed Jun 25 11:34:20 PDT 2014


[Apologies for the noise.  re-posting to the correct list ;-) ]

Assorted changes to handle PPC64/Power8 as a target.
(This is a consolidation of previously posted parts 3,4,5, no other
changes).

Thanks, 
-Will


commit 91722ea64febeb1dd11e5145534c8f8422d0d0b0
Author: Will Schmidt <will_schmidt at vnet.ibm.com>
Date:   Wed Jun 25 09:19:15 2014 -0500

    Add the power8/pwr8 keyword target

diff --git a/tools/clang/lib/Basic/Targets.cpp b/tools/clang/lib/Basic/Targets.cpp
index 4fdbc24..d54e8bd 100644
--- a/tools/clang/lib/Basic/Targets.cpp
+++ b/tools/clang/lib/Basic/Targets.cpp
@@ -706,8 +706,9 @@ public:
     ArchDefinePwr6  = 1 << 9,
     ArchDefinePwr6x = 1 << 10,
     ArchDefinePwr7  = 1 << 11,
-    ArchDefineA2    = 1 << 12,
-    ArchDefineA2q   = 1 << 13
+    ArchDefinePwr8  = 1 << 12,
+    ArchDefineA2    = 1 << 13,
+    ArchDefineA2q   = 1 << 14
   } ArchDefineTypes;
 
   // Note: GCC recognizes the following additional cpus:
@@ -754,6 +755,8 @@ public:
       .Case("pwr6x", true)
       .Case("power7", true)
       .Case("pwr7", true)
+      .Case("power8", true)
+      .Case("pwr8", true)
       .Case("powerpc", true)
       .Case("ppc", true)
       .Case("powerpc64", true)
@@ -1016,7 +1019,10 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
                      | ArchDefinePpcsq)
     .Case("pwr7",  ArchDefineName | ArchDefinePwr6x | ArchDefinePwr6
                      | ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4
-                     | ArchDefinePwr6 | ArchDefinePpcgr | ArchDefinePpcsq)
+                     | ArchDefinePpcgr | ArchDefinePpcsq)
+    .Case("pwr8",  ArchDefineName | ArchDefinePwr7 | ArchDefinePwr6x
+                     | ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5
+                     | ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
     .Case("power3",  ArchDefinePpcgr)
     .Case("power4",  ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
     .Case("power5",  ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr
@@ -1030,7 +1036,10 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
                        | ArchDefinePpcsq)
     .Case("power7",  ArchDefinePwr7 | ArchDefinePwr6x | ArchDefinePwr6
                        | ArchDefinePwr5x | ArchDefinePwr5 | ArchDefinePwr4
-                       | ArchDefinePwr6 | ArchDefinePpcgr | ArchDefinePpcsq)
+                       | ArchDefinePpcgr | ArchDefinePpcsq)
+    .Case("power8",  ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6x
+                       | ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5
+                       | ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
     .Default(ArchDefineNone);
 
   if (defs & ArchDefineName)
@@ -1057,6 +1066,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
     Builder.defineMacro("_ARCH_PWR6X");
   if (defs & ArchDefinePwr7)
     Builder.defineMacro("_ARCH_PWR7");
+  if (defs & ArchDefinePwr8)
+    Builder.defineMacro("_ARCH_PWR8");
   if (defs & ArchDefineA2)
     Builder.defineMacro("_ARCH_A2");
   if (defs & ArchDefineA2q) {
@@ -1105,6 +1116,7 @@ void PPCTargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
     .Case("g5", true)
     .Case("pwr6", true)
     .Case("pwr7", true)
+    .Case("pwr8", true)
     .Case("ppc64", true)
     .Case("ppc64le", true)
     .Default(false);
diff --git a/tools/clang/lib/Driver/Tools.cpp b/tools/clang/lib/Driver/Tools.cpp
index de03ce6..d353069 100644
--- a/tools/clang/lib/Driver/Tools.cpp
+++ b/tools/clang/lib/Driver/Tools.cpp
@@ -1156,6 +1156,7 @@ static std::string getPPCTargetCPU(const ArgList &Args) {
       .Case("power6", "pwr6")
       .Case("power6x", "pwr6x")
       .Case("power7", "pwr7")
+      .Case("power8", "pwr8")
       .Case("pwr3", "pwr3")
       .Case("pwr4", "pwr4")
       .Case("pwr5", "pwr5")
@@ -1163,6 +1164,7 @@ static std::string getPPCTargetCPU(const ArgList &Args) {
       .Case("pwr6", "pwr6")
       .Case("pwr6x", "pwr6x")
       .Case("pwr7", "pwr7")
+      .Case("pwr8", "pwr8")
       .Case("powerpc", "ppc")
       .Case("powerpc64", "ppc64")
       .Case("powerpc64le", "ppc64le")
diff --git a/tools/clang/test/Driver/clang-translation.c b/tools/clang/test/Driver/clang-translation.c
index 54e5bbe..a525b7f 100644
--- a/tools/clang/test/Driver/clang-translation.c
+++ b/tools/clang/test/Driver/clang-translation.c
@@ -71,6 +71,12 @@
 // PPCPWR7: "-target-cpu" "pwr7"
 
 // RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=power8 2>&1 | FileCheck -check-prefix=PPCPWR8 %s
+// PPCPWR8: clang
+// PPCPWR8: "-cc1"
+// PPCPWR8: "-target-cpu" "pwr8"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
 // RUN: -### -S %s -mcpu=a2q 2>&1 | FileCheck -check-prefix=PPCA2Q %s
 // PPCA2Q: clang
 // PPCA2Q: "-cc1"
diff --git a/tools/clang/test/Driver/ppc-features.cpp b/tools/clang/test/Driver/ppc-features.cpp
index a7ccedf..fa9a7ec 100644
--- a/tools/clang/test/Driver/ppc-features.cpp
+++ b/tools/clang/test/Driver/ppc-features.cpp
@@ -59,9 +59,12 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=pwr7 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-14 %s
 // CHECK-14: "-target-feature" "-altivec"
 
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=ppc64 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-15 %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=pwr8 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-15 %s
 // CHECK-15: "-target-feature" "-altivec"
 
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=ppc64 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-16 %s
+// CHECK-16: "-target-feature" "-altivec"
+
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-qpx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOQPX %s
 // CHECK-NOQPX: "-target-feature" "-qpx"
 
diff --git a/tools/clang/test/Preprocessor/init.c b/tools/clang/test/Preprocessor/init.c
index ed08854..2db4183 100644
--- a/tools/clang/test/Preprocessor/init.c
+++ b/tools/clang/test/Preprocessor/init.c
@@ -2835,6 +2835,34 @@
 // PPCPOWER7:#define _ARCH_PWR6X 1
 // PPCPOWER7:#define _ARCH_PWR7 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr8 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPWR8 %s
+//
+// PPCPWR8:#define _ARCH_PPC 1
+// PPCPWR8:#define _ARCH_PPC64 1
+// PPCPWR8:#define _ARCH_PPCGR 1
+// PPCPWR8:#define _ARCH_PPCSQ 1
+// PPCPWR8:#define _ARCH_PWR4 1
+// PPCPWR8:#define _ARCH_PWR5 1
+// PPCPWR8:#define _ARCH_PWR5X 1
+// PPCPWR8:#define _ARCH_PWR6 1
+// PPCPWR8:#define _ARCH_PWR6X 1
+// PPCPWR8:#define _ARCH_PWR7 1
+// PPCPWR8:#define _ARCH_PWR8 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power8 -fno-signed-char < /dev/null | FileCheck -check-prefix PPCPOWER8 %s
+//
+// PPCPOWER8:#define _ARCH_PPC 1
+// PPCPOWER8:#define _ARCH_PPC64 1
+// PPCPOWER8:#define _ARCH_PPCGR 1
+// PPCPOWER8:#define _ARCH_PPCSQ 1
+// PPCPOWER8:#define _ARCH_PWR4 1
+// PPCPOWER8:#define _ARCH_PWR5 1
+// PPCPOWER8:#define _ARCH_PWR5X 1
+// PPCPOWER8:#define _ARCH_PWR6 1
+// PPCPOWER8:#define _ARCH_PWR6X 1
+// PPCPOWER8:#define _ARCH_PWR7 1
+// PPCPOWER8:#define _ARCH_PWR8 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64-LINUX %s
 //
 // PPC64-LINUX:#define _ARCH_PPC 1





More information about the cfe-commits mailing list