-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[Flang] Add __powerpc__ macro to set c_intmax_t to c_int64_t rather than c_int128_t as PowerPC only supports up to c_int64_t. #81222
Conversation
@llvm/pr-subscribers-flang-driver Author: Daniel Chen (DanielCChen) ChangesPowerPC only supports up to Full diff: https://github.com/llvm/llvm-project/pull/81222.diff 2 Files Affected:
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index ffde7f50087e52..d49e8e283e0d40 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1326,10 +1326,21 @@ void CompilerInvocation::setDefaultPredefinitions() {
Fortran::common::setOpenMPMacro(getLangOpts().OpenMPVersion,
fortranOptions.predefinitions);
}
+
llvm::Triple targetTriple{llvm::Triple(this->targetOpts.triple)};
- if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
+ switch (targetTriple.getArch()) {
+ default:
+ break;
+ case llvm::Triple::ArchType::x86_64:
fortranOptions.predefinitions.emplace_back("__x86_64__", "1");
fortranOptions.predefinitions.emplace_back("__x86_64", "1");
+ break;
+ case llvm::Triple::ArchType::ppc:
+ case llvm::Triple::ArchType::ppcle:
+ case llvm::Triple::ArchType::ppc64:
+ case llvm::Triple::ArchType::ppc64le:
+ fortranOptions.predefinitions.emplace_back("__powerpc__", "1");
+ break;
}
}
diff --git a/flang/module/iso_c_binding.f90 b/flang/module/iso_c_binding.f90
index 9a7e68f3314463..1661fd5a6dcf6a 100644
--- a/flang/module/iso_c_binding.f90
+++ b/flang/module/iso_c_binding.f90
@@ -47,7 +47,11 @@ module iso_c_binding
c_long_long = c_int64_t, &
c_signed_char = c_int8_t, &
c_size_t = kind(c_sizeof(1)), &
+#if __powerpc__
+ c_intmax_t = c_int64_t, &
+#else
c_intmax_t = c_int128_t, &
+#endif
c_intptr_t = c_size_t, &
c_ptrdiff_t = c_size_t
integer, parameter, public :: &
|
8ce11c2
to
f24f928
Compare
The x86 build failure seems on and off to me. This PR passed the x86 build before I rebased the branch. |
a60fef0
to
5a529e5
Compare
Need to add a test like |
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
…han c_int128_t as PowerPC only supports up to c_int64_t.
… to indicate that this macro is generic for PowerPC.
ae28834
to
74c9504
Compare
PowerPC only supports up to
c_int64_t
. Add macro__powerpc__
and preprocess it for settingc_intmax_t
iniso_c_binding
intrinsic module.