Skip to content

Commit

Permalink
[SOL] Update SBF call ABI (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte authored Mar 13, 2024
1 parent 6cc5efc commit 696ef74
Showing 1 changed file with 21 additions and 11 deletions.
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

0 comments on commit 696ef74

Please sign in to comment.