Skip to content

Commit

Permalink
Add AIX Version Macros
Browse files Browse the repository at this point in the history
Summary:
- This patch checks the AIX version and defines the appropriate macros.
- Follow up to a comment on D59048.

Author: andusy

Reviewers: hubert.reinterpretcast, jasonliu, sfertile, xingxue

Reviewed By: sfertile

Subscribers: jsji, cfe-commits

Tags: #clang

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

llvm-svn: 360900
  • Loading branch information
xingxue-ibm authored and MrSidims committed May 24, 2019
1 parent b9a502f commit 57700f7
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 1 deletion.
18 changes: 17 additions & 1 deletion clang/lib/Basic/Targets/OSTargets.h
Expand Up @@ -654,9 +654,25 @@ class AIXTargetInfo : public OSTargetInfo<Target> {
Builder.defineMacro("_IBMR2");
Builder.defineMacro("_POWER");

// FIXME: Define AIX OS-Version Macros.
Builder.defineMacro("_AIX");

unsigned Major, Minor, Micro;
Triple.getOSVersion(Major, Minor, Micro);

// Define AIX OS-Version Macros.
// Includes logic for legacy versions of AIX; no specific intent to support.
std::pair<int, int> OsVersion = {Major, Minor};
if (OsVersion >= std::make_pair(3, 2)) Builder.defineMacro("_AIX32");
if (OsVersion >= std::make_pair(4, 1)) Builder.defineMacro("_AIX41");
if (OsVersion >= std::make_pair(4, 3)) Builder.defineMacro("_AIX43");
if (OsVersion >= std::make_pair(5, 0)) Builder.defineMacro("_AIX50");
if (OsVersion >= std::make_pair(5, 1)) Builder.defineMacro("_AIX51");
if (OsVersion >= std::make_pair(5, 2)) Builder.defineMacro("_AIX52");
if (OsVersion >= std::make_pair(5, 3)) Builder.defineMacro("_AIX53");
if (OsVersion >= std::make_pair(6, 1)) Builder.defineMacro("_AIX61");
if (OsVersion >= std::make_pair(7, 1)) Builder.defineMacro("_AIX71");
if (OsVersion >= std::make_pair(7, 2)) Builder.defineMacro("_AIX72");

// FIXME: Do not define _LONG_LONG when -fno-long-long is specified.
Builder.defineMacro("_LONG_LONG");

Expand Down
123 changes: 123 additions & 0 deletions clang/test/Preprocessor/init.c
Expand Up @@ -7243,6 +7243,129 @@
// PPC-AIX:#define __powerpc__ 1
// PPC-AIX:#define __ppc__ 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX72 %s
//
// PPC-AIX72:#define _AIX32 1
// PPC-AIX72:#define _AIX41 1
// PPC-AIX72:#define _AIX43 1
// PPC-AIX72:#define _AIX50 1
// PPC-AIX72:#define _AIX51 1
// PPC-AIX72:#define _AIX52 1
// PPC-AIX72:#define _AIX53 1
// PPC-AIX72:#define _AIX61 1
// PPC-AIX72:#define _AIX71 1
// PPC-AIX72:#define _AIX72 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX71 %s
//
// PPC-AIX71:#define _AIX32 1
// PPC-AIX71:#define _AIX41 1
// PPC-AIX71:#define _AIX43 1
// PPC-AIX71:#define _AIX50 1
// PPC-AIX71:#define _AIX51 1
// PPC-AIX71:#define _AIX52 1
// PPC-AIX71:#define _AIX53 1
// PPC-AIX71:#define _AIX61 1
// PPC-AIX71:#define _AIX71 1
// PPC-AIX71-NOT:#define _AIX72 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix6.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX61 %s
//
// PPC-AIX61:#define _AIX32 1
// PPC-AIX61:#define _AIX41 1
// PPC-AIX61:#define _AIX43 1
// PPC-AIX61:#define _AIX50 1
// PPC-AIX61:#define _AIX51 1
// PPC-AIX61:#define _AIX52 1
// PPC-AIX61:#define _AIX53 1
// PPC-AIX61:#define _AIX61 1
// PPC-AIX61-NOT:#define _AIX71 1
// PPC-AIX61-NOT:#define _AIX72 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.3.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX53 %s
// PPC-AIX53:#define _AIX32 1
// PPC-AIX53:#define _AIX41 1
// PPC-AIX53:#define _AIX43 1
// PPC-AIX53:#define _AIX50 1
// PPC-AIX53:#define _AIX51 1
// PPC-AIX53:#define _AIX52 1
// PPC-AIX53:#define _AIX53 1
// PPC-AIX53-NOT:#define _AIX61 1
// PPC-AIX53-NOT:#define _AIX71 1
// PPC-AIX53-NOT:#define _AIX72 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX52 %s
// PPC-AIX52:#define _AIX32 1
// PPC-AIX52:#define _AIX41 1
// PPC-AIX52:#define _AIX43 1
// PPC-AIX52:#define _AIX50 1
// PPC-AIX52:#define _AIX51 1
// PPC-AIX52:#define _AIX52 1
// PPC-AIX52-NOT:#define _AIX53 1
// PPC-AIX52-NOT:#define _AIX61 1
// PPC-AIX52-NOT:#define _AIX71 1
// PPC-AIX52-NOT:#define _AIX72 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX51 %s
// PPC-AIX51:#define _AIX32 1
// PPC-AIX51:#define _AIX41 1
// PPC-AIX51:#define _AIX43 1
// PPC-AIX51:#define _AIX50 1
// PPC-AIX51:#define _AIX51 1
// PPC-AIX51-NOT:#define _AIX52 1
// PPC-AIX51-NOT:#define _AIX53 1
// PPC-AIX51-NOT:#define _AIX61 1
// PPC-AIX51-NOT:#define _AIX71 1
// PPC-AIX51-NOT:#define _AIX72 1
//
//RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.0.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX50 %s
// PPC-AIX50:#define _AIX32 1
// PPC-AIX50:#define _AIX41 1
// PPC-AIX50:#define _AIX43 1
// PPC-AIX50:#define _AIX50 1
// PPC-AIX50-NOT:#define _AIX51 1
// PPC-AIX50-NOT:#define _AIX52 1
// PPC-AIX50-NOT:#define _AIX53 1
// PPC-AIX50-NOT:#define _AIX61 1
// PPC-AIX50-NOT:#define _AIX71 1
// PPC-AIX50-NOT:#define _AIX72 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix4.3.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX43 %s
// PPC-AIX43:#define _AIX32 1
// PPC-AIX43:#define _AIX41 1
// PPC-AIX43:#define _AIX43 1
// PPC-AIX43-NOT:#define _AIX50 1
// PPC-AIX43-NOT:#define _AIX51 1
// PPC-AIX43-NOT:#define _AIX52 1
// PPC-AIX43-NOT:#define _AIX53 1
// PPC-AIX43-NOT:#define _AIX61 1
// PPC-AIX43-NOT:#define _AIX71 1
// PPC-AIX43-NOT:#define _AIX72 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix4.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX41 %s
// PPC-AIX41:#define _AIX32 1
// PPC-AIX41:#define _AIX41 1
// PPC-AIX41-NOT:#define _AIX43 1
// PPC-AIX41-NOT:#define _AIX50 1
// PPC-AIX41-NOT:#define _AIX51 1
// PPC-AIX41-NOT:#define _AIX52 1
// PPC-AIX41-NOT:#define _AIX53 1
// PPC-AIX41-NOT:#define _AIX61 1
// PPC-AIX41-NOT:#define _AIX71 1
// PPC-AIX41-NOT:#define _AIX72 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix3.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX32 %s
// PPC-AIX32:#define _AIX32 1
// PPC-AIX32-NOT:#define _AIX41 1
// PPC-AIX32-NOT:#define _AIX43 1
// PPC-AIX32-NOT:#define _AIX50 1
// PPC-AIX32-NOT:#define _AIX51 1
// PPC-AIX32-NOT:#define _AIX52 1
// PPC-AIX32-NOT:#define _AIX53 1
// PPC-AIX32-NOT:#define _AIX61 1
// PPC-AIX32-NOT:#define _AIX71 1
// PPC-AIX32-NOT:#define _AIX72 1
//
// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-CXX %s
//
// PPC-AIX-CXX:#define _WCHAR_T 1
Expand Down

0 comments on commit 57700f7

Please sign in to comment.