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;
}
--- /dev/null
+// 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"