Skip to content

Commit 9807f91

Browse files
jakeeganmemfrob
authored andcommitted
[AIX][PowerPC] Define __powerpc and __PPC macros
%%% This patch defines the macros __powerpc and __PPC on AIX to be consistent with XL for AIX. See: https://www.ibm.com/docs/en/xl-c-and-cpp-aix/13.1.0?topic=macros-related-platform Note: GCC does not currently define __powerpc and __PPC so users should prefer the __powerpc__ and __PPC__ forms. %%% Reviewed By: cebowleratibm Differential Revision: https://reviews.llvm.org/D108917
1 parent 2aa627d commit 9807f91

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
264264
}
265265
if (getTriple().isOSAIX()) {
266266
Builder.defineMacro("__THW_PPC__");
267+
// Define __PPC and __powerpc for AIX XL C/C++ compatibility
268+
Builder.defineMacro("__PPC");
269+
Builder.defineMacro("__powerpc");
267270
}
268271

269272
// Target properties.

clang/test/Preprocessor/init-ppc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
// PPC:#define __NATURAL_ALIGNMENT__ 1
323323
// PPC:#define __POINTER_WIDTH__ 32
324324
// PPC:#define __POWERPC__ 1
325+
// PPC-NOT:#define __PPC 1
325326
// PPC:#define __PPC__ 1
326327
// PPC:#define __PTRDIFF_TYPE__ long int
327328
// PPC:#define __PTRDIFF_WIDTH__ 32
@@ -386,6 +387,7 @@
386387
// PPC:#define __WCHAR_WIDTH__ 32
387388
// PPC:#define __WINT_TYPE__ int
388389
// PPC:#define __WINT_WIDTH__ 32
390+
// PPC-NOT:#define __powerpc 1
389391
// PPC:#define __ppc__ 1
390392

391393
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX %s
@@ -520,6 +522,7 @@
520522
// PPC-AIX-NOT:#define __NATURAL_ALIGNMENT__ 1
521523
// PPC-AIX:#define __POINTER_WIDTH__ 32
522524
// PPC-AIX:#define __POWERPC__ 1
525+
// PPC-AIX:#define __PPC 1
523526
// PPC-AIX:#define __PPC__ 1
524527
// PPC-AIX:#define __PTRDIFF_TYPE__ long int
525528
// PPC-AIX:#define __PTRDIFF_WIDTH__ 32
@@ -587,6 +590,7 @@
587590
// PPC-AIX:#define __WCHAR_WIDTH__ 16
588591
// PPC-AIX:#define __WINT_TYPE__ int
589592
// PPC-AIX:#define __WINT_WIDTH__ 32
593+
// PPC-AIX:#define __powerpc 1
590594
// PPC-AIX:#define __powerpc__ 1
591595
// PPC-AIX:#define __ppc__ 1
592596

0 commit comments

Comments
 (0)