Skip to content
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

[SOL] Update SBF call ABI #91

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions compiler/rustc_target/src/abi/call/sbf.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
// see https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/BPF/BPFCallingConv.td
use crate::abi::call::{ArgAbi, FnAbi};
use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};

fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 {
if ret.layout.size.bits() != 128 {
ret.make_indirect();
}
} else {
let size = ret.layout.size;
let bits = size.bits();
if !ret.layout.is_aggregate() && bits <= 64 {
ret.extend_integer_width_to(64);
return;
}

if bits <= 128 {
ret.cast_to(Uniform {unit: Reg::i64(), total: size});
} else {
ret.make_indirect();
}
}

fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
if arg.layout.is_aggregate() || arg.layout.size.bits() > 64 {
if arg.layout.size.bits() != 128 {
arg.make_indirect();
}
} else {
let size = arg.layout.size;
let bits = size.bits();
if !arg.layout.is_aggregate() && bits <= 64 {
arg.extend_integer_width_to(64);
return;
}

if bits <= 128 {
arg.cast_to(Uniform {unit: Reg::i64(), total: size});
} else {
arg.make_indirect();
}
}

Expand Down
Loading