[clang] ba4afe6 - [AIX] Change the default target CPU to power4 for AIX on Power

Steven Wan via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 3 10:50:33 PDT 2020


Author: Steven Wan
Date: 2020-06-03T13:50:26-04:00
New Revision: ba4afe6f7a8453b24ee0b664e40d157d15a54034

URL: https://github.com/llvm/llvm-project/commit/ba4afe6f7a8453b24ee0b664e40d157d15a54034
DIFF: https://github.com/llvm/llvm-project/commit/ba4afe6f7a8453b24ee0b664e40d157d15a54034.diff

LOG: [AIX] Change the default target CPU to power4 for AIX on Power

Summary: This patch changes the AIX default target CPU to power4 since this is the the lowest arch for the lowest OS level supported.

Reviewers: hubert.reinterpretcast, cebowleratibm, daltenty

Reviewed By: hubert.reinterpretcast

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80835

Added: 
    clang/test/Driver/aix-mcpu-default.c

Modified: 
    clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b2c984912154..0ddbfac81b33 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,14 +294,18 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T,
     std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
     // LLVM may default to generating code for the native CPU,
     // but, like gcc, we default to a more generic option for
-    // each architecture. (except on Darwin)
-    if (TargetCPUName.empty() && !T.isOSDarwin()) {
-      if (T.getArch() == llvm::Triple::ppc64)
-        TargetCPUName = "ppc64";
-      else if (T.getArch() == llvm::Triple::ppc64le)
-        TargetCPUName = "ppc64le";
-      else
-        TargetCPUName = "ppc";
+    // each architecture. (except on AIX or Darwin)
+    if (TargetCPUName.empty()) {
+      if (T.isOSAIX())
+        TargetCPUName = "pwr4";
+      else if (!T.isOSDarwin()) {
+        if (T.getArch() == llvm::Triple::ppc64)
+          TargetCPUName = "ppc64";
+        else if (T.getArch() == llvm::Triple::ppc64le)
+          TargetCPUName = "ppc64le";
+        else
+          TargetCPUName = "ppc";
+      }
     }
     return TargetCPUName;
   }

diff  --git a/clang/test/Driver/aix-mcpu-default.c b/clang/test/Driver/aix-mcpu-default.c
new file mode 100644
index 000000000000..10636abad304
--- /dev/null
+++ b/clang/test/Driver/aix-mcpu-default.c
@@ -0,0 +1,16 @@
+// Check that the target cpu defaults to power4 on AIX.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:        -target powerpc-ibm-aix \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
+// CHECK-MCPU-DEFAULT-NOT: warning:
+// CHECK-MCPU-DEFAULT:     {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT:     "-target-cpu" "pwr4"
+
+// Check that the user is able to overwrite the default with '-mcpu'.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:        -mcpu=pwr6 \
+// RUN:        -target powerpc-ibm-aix \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-USER %s
+// CHECK-MCPU-USER-NOT: warning:
+// CHECK-MCPU-USER:     {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-USER:     "-target-cpu" "pwr6"


        


More information about the cfe-commits mailing list