[AIX] Define _ARCH_PPC64 macro for 32-bit
authorJake Egan <Jake.Egan@ibm.com>
Fri, 6 Aug 2021 14:42:18 +0000 (10:42 -0400)
committerJake Egan <Jake.Egan@ibm.com>
Fri, 6 Aug 2021 14:42:44 +0000 (10:42 -0400)
%%%
The macro _ARCH_PPC64 is already defined for 64-bit, but this patch defines it for 32-bit on AIX to follow xlc. See: https://www.ibm.com/docs/en/xl-c-and-cpp-aix/13.1.0?topic=features-macros-related-architecture-settings

Note: This change creates a discrepancy between GCC, which defines _ARCH_PPC64 only for 64-bit mode.

Tested with SPEC.
%%%

Reviewed By: cebowleratibm

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

clang/lib/Basic/Targets/PPC.cpp
clang/test/Preprocessor/init-ppc.c

index 4ee7282..711ba28 100644 (file)
@@ -257,6 +257,9 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
     Builder.defineMacro("__powerpc64__");
     Builder.defineMacro("__ppc64__");
     Builder.defineMacro("__PPC64__");
+  } else if (getTriple().isOSAIX()) {
+    // The XL compilers on AIX define _ARCH_PPC64 for both 32 and 64-bit modes.
+    Builder.defineMacro("_ARCH_PPC64");
   }
   if (getTriple().isOSAIX()) {
     Builder.defineMacro("__THW_PPC__");
index abf2e91..fedc1b6 100644 (file)
 // PPC-AIX-NOT:#define __64BIT__ 1
 // PPC-AIX:#define _AIX 1
 // PPC-AIX:#define _ARCH_PPC 1
+// PPC-AIX:#define _ARCH_PPC64 1
 // PPC-AIX:#define _BIG_ENDIAN 1
 // PPC-AIX:#define _IBMR2 1
 // PPC-AIX:#define _LONG_LONG 1