-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[flang][AIX] Predefine __64BIT__ and _AIX macros #138591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kkwli
wants to merge
1
commit into
llvm:main
Choose a base branch
from
kkwli:32b-macros
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-flang-driver Author: Kelvin Li (kkwli) ChangesFull diff: https://github.com/llvm/llvm-project/pull/138591.diff 2 Files Affected:
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 6f87a18d69c3d..c3e6471fa9a0f 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1612,13 +1612,10 @@ void CompilerInvocation::setDefaultPredefinitions() {
}
llvm::Triple targetTriple{llvm::Triple(this->targetOpts.triple)};
- if (targetTriple.isPPC()) {
- // '__powerpc__' is a generic macro for any PowerPC cases. e.g. Max integer
- // size.
- fortranOptions.predefinitions.emplace_back("__powerpc__", "1");
- }
if (targetTriple.isOSLinux()) {
fortranOptions.predefinitions.emplace_back("__linux__", "1");
+ } else if (targetTriple.isOSAIX()) {
+ fortranOptions.predefinitions.emplace_back("_AIX", "1");
}
switch (targetTriple.getArch()) {
@@ -1628,6 +1625,16 @@ void CompilerInvocation::setDefaultPredefinitions() {
fortranOptions.predefinitions.emplace_back("__x86_64__", "1");
fortranOptions.predefinitions.emplace_back("__x86_64", "1");
break;
+ case llvm::Triple::ArchType::ppc:
+ case llvm::Triple::ArchType::ppc64:
+ case llvm::Triple::ArchType::ppcle:
+ case llvm::Triple::ArchType::ppc64le:
+ // '__powerpc__' is a generic macro for any PowerPC.
+ fortranOptions.predefinitions.emplace_back("__powerpc__", "1");
+ if (targetTriple.isOSAIX() && targetTriple.isArch64Bit()) {
+ fortranOptions.predefinitions.emplace_back("__64BIT__", "1");
+ }
+ break;
}
}
diff --git a/flang/test/Driver/predefined-macros-powerpc2.f90 b/flang/test/Driver/predefined-macros-powerpc2.f90
index 6e10235e21f86..6d235afcf8c3b 100644
--- a/flang/test/Driver/predefined-macros-powerpc2.f90
+++ b/flang/test/Driver/predefined-macros-powerpc2.f90
@@ -1,13 +1,25 @@
! Test predefined macro for PowerPC architecture
-! RUN: %flang_fc1 -triple ppc64le-unknown-linux -cpp -E %s | FileCheck %s
+! RUN: %flang_fc1 -triple ppc64le-unknown-linux -cpp -E %s | FileCheck %s -check-prefix=CHECK-LINUX
+! RUN: %flang_fc1 -triple powerpc-unknown-aix -cpp -E %s | FileCheck %s -check-prefix=CHECK-AIX32
+! RUN: %flang_fc1 -triple powerpc64-unknown-aix -cpp -E %s | FileCheck %s -check-prefix=CHECK-AIX64
! REQUIRES: target=powerpc{{.*}}
-! CHECK: integer :: var1 = 1
-! CHECK: integer :: var2 = 1
+! CHECK-LINUX: integer :: var1 = 1
+! CHECK-LINUX: integer :: var2 = 1
+! CHECK-AIX32: integer :: var1 = 1
+! CHECK-AIX32: integer :: var2 = 1
+! CHECK-AIX32: integer :: var3 = __64BIT__
+! CHECK-AIX64: integer :: var1 = 1
+! CHECK-AIX64: integer :: var2 = 1
+! CHECK-AIX64: integer :: var3 = 1
#if defined(__linux__) && defined(__powerpc__)
integer :: var1 = __powerpc__
integer :: var2 = __linux__
+#elif defined(_AIX) && defined(__powerpc__)
+ integer :: var1 = __powerpc__
+ integer :: var2 = _AIX
+ integer :: var3 = __64BIT__
#endif
end program
|
madanial0
approved these changes
May 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! thanks!
DanielCChen
reviewed
May 6, 2025
klausler
approved these changes
May 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.