Skip to content

Commit 7d27ceb

Browse files
committed
Add AIX Calling Convention
1 parent f7c8928 commit 7d27ceb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

compiler/rustc_target/src/abi/call/powerpc64.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::spec::HasTargetSpec;
1010
enum ABI {
1111
ELFv1, // original ABI used for powerpc64 (big-endian)
1212
ELFv2, // newer ABI used for powerpc64le and musl (both endians)
13+
AIX, // used by AIX OS, big-endian only
1314
}
1415
use ABI::*;
1516

@@ -23,9 +24,9 @@ where
2324
C: HasDataLayout,
2425
{
2526
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
26-
// ELFv1 only passes one-member aggregates transparently.
27+
// ELFv1 and AIX only passes one-member aggregates transparently.
2728
// ELFv2 passes up to eight uniquely addressable members.
28-
if (abi == ELFv1 && arg.layout.size > unit.size)
29+
if ((abi == ELFv1 || abi == AIX) && arg.layout.size > unit.size)
2930
|| arg.layout.size > unit.size.checked_mul(8, cx).unwrap()
3031
{
3132
return None;
@@ -55,8 +56,14 @@ where
5556
return;
5657
}
5758

59+
// See https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/Targets/PPC.cpp.
60+
if !is_ret && abi == AIX {
61+
arg.make_indirect_byval(None);
62+
return;
63+
}
64+
5865
// The ELFv1 ABI doesn't return aggregates in registers
59-
if is_ret && abi == ELFv1 {
66+
if is_ret && (abi == ELFv1 || abi == AIX) {
6067
arg.make_indirect();
6168
return;
6269
}
@@ -93,6 +100,8 @@ where
93100
{
94101
let abi = if cx.target_spec().env == "musl" {
95102
ELFv2
103+
} else if cx.target_spec().os == "aix" {
104+
AIX
96105
} else {
97106
match cx.data_layout().endian {
98107
Endian::Big => ELFv1,

0 commit comments

Comments
 (0)