Skip to content

Commit a60fef0

Browse files
committed
[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.
1 parent b2b3a52 commit a60fef0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,10 +1326,21 @@ void CompilerInvocation::setDefaultPredefinitions() {
13261326
Fortran::common::setOpenMPMacro(getLangOpts().OpenMPVersion,
13271327
fortranOptions.predefinitions);
13281328
}
1329+
13291330
llvm::Triple targetTriple{llvm::Triple(this->targetOpts.triple)};
1330-
if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
1331+
switch (targetTriple.getArch()) {
1332+
default:
1333+
break;
1334+
case llvm::Triple::ArchType::x86_64:
13311335
fortranOptions.predefinitions.emplace_back("__x86_64__", "1");
13321336
fortranOptions.predefinitions.emplace_back("__x86_64", "1");
1337+
break;
1338+
case llvm::Triple::ArchType::ppc:
1339+
case llvm::Triple::ArchType::ppcle:
1340+
case llvm::Triple::ArchType::ppc64:
1341+
case llvm::Triple::ArchType::ppc64le:
1342+
fortranOptions.predefinitions.emplace_back("__powerpc__", "1");
1343+
break;
13331344
}
13341345
}
13351346

flang/module/iso_c_binding.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ module iso_c_binding
4747
c_long_long = c_int64_t, &
4848
c_signed_char = c_int8_t, &
4949
c_size_t = kind(c_sizeof(1)), &
50+
#if __powerpc__
51+
c_intmax_t = c_int64_t, &
52+
#else
5053
c_intmax_t = c_int128_t, &
54+
#endif
5155
c_intptr_t = c_size_t, &
5256
c_ptrdiff_t = c_size_t
5357
integer, parameter, public :: &

0 commit comments

Comments
 (0)