Skip to content

Commit c5d9f85

Browse files
LucasStec410-f3r
authored andcommitted
[SOL] Update SBF call ABI (rust-lang#91)
1 parent 4ad41e6 commit c5d9f85

File tree

1 file changed

+21
-11
lines changed
  • compiler/rustc_target/src/abi/call

1 file changed

+21
-11
lines changed

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

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
// see https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/BPF/BPFCallingConv.td
2-
use crate::abi::call::{ArgAbi, FnAbi};
2+
use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
33

44
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
5-
if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 {
6-
if ret.layout.size.bits() != 128 {
7-
ret.make_indirect();
8-
}
9-
} else {
5+
let size = ret.layout.size;
6+
let bits = size.bits();
7+
if !ret.layout.is_aggregate() && bits <= 64 {
108
ret.extend_integer_width_to(64);
9+
return;
10+
}
11+
12+
if bits <= 128 {
13+
ret.cast_to(Uniform {unit: Reg::i64(), total: size});
14+
} else {
15+
ret.make_indirect();
1116
}
1217
}
1318

1419
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
15-
if arg.layout.is_aggregate() || arg.layout.size.bits() > 64 {
16-
if arg.layout.size.bits() != 128 {
17-
arg.make_indirect();
18-
}
19-
} else {
20+
let size = arg.layout.size;
21+
let bits = size.bits();
22+
if !arg.layout.is_aggregate() && bits <= 64 {
2023
arg.extend_integer_width_to(64);
24+
return;
25+
}
26+
27+
if bits <= 128 {
28+
arg.cast_to(Uniform {unit: Reg::i64(), total: size});
29+
} else {
30+
arg.make_indirect();
2131
}
2232
}
2333

0 commit comments

Comments
 (0)