Skip to content

Commit

Permalink
Add AIX Calling Convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Jiang committed Oct 3, 2024
1 parent f7c8928 commit 7d27ceb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions compiler/rustc_target/src/abi/call/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::spec::HasTargetSpec;
enum ABI {
ELFv1, // original ABI used for powerpc64 (big-endian)
ELFv2, // newer ABI used for powerpc64le and musl (both endians)
AIX, // used by AIX OS, big-endian only
}
use ABI::*;

Expand All @@ -23,9 +24,9 @@ where
C: HasDataLayout,
{
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
// ELFv1 only passes one-member aggregates transparently.
// ELFv1 and AIX only passes one-member aggregates transparently.
// ELFv2 passes up to eight uniquely addressable members.
if (abi == ELFv1 && arg.layout.size > unit.size)
if ((abi == ELFv1 || abi == AIX) && arg.layout.size > unit.size)
|| arg.layout.size > unit.size.checked_mul(8, cx).unwrap()
{
return None;
Expand Down Expand Up @@ -55,8 +56,14 @@ where
return;
}

// See https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/Targets/PPC.cpp.
if !is_ret && abi == AIX {
arg.make_indirect_byval(None);
return;
}

// The ELFv1 ABI doesn't return aggregates in registers
if is_ret && abi == ELFv1 {
if is_ret && (abi == ELFv1 || abi == AIX) {
arg.make_indirect();
return;
}
Expand Down Expand Up @@ -93,6 +100,8 @@ where
{
let abi = if cx.target_spec().env == "musl" {
ELFv2
} else if cx.target_spec().os == "aix" {
AIX
} else {
match cx.data_layout().endian {
Endian::Big => ELFv1,
Expand Down

0 comments on commit 7d27ceb

Please sign in to comment.