Skip to content

Commit 76de8a6

Browse files
authored
Rollup merge of rust-lang#68452 - msizanoen1:riscv-abi, r=nagisa,eddyb
Implement proper C ABI lowering for RISC-V This is necessary for full RISC-V psABI compliance when passing argument across C FFI boundary. cc @lenary
2 parents 6cad754 + 3963387 commit 76de8a6

File tree

8 files changed

+1162
-16
lines changed

8 files changed

+1162
-16
lines changed

src/librustc/ty/layout.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,7 @@ where
26512651
.map(|(i, ty)| arg_of(ty, Some(i)))
26522652
.collect(),
26532653
c_variadic: sig.c_variadic,
2654+
fixed_count: inputs.len(),
26542655
conv,
26552656
};
26562657
fn_abi.adjust_for_abi(cx, sig.abi);

src/librustc_target/abi/call/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ impl Reg {
120120
reg_ctor!(i16, Integer, 16);
121121
reg_ctor!(i32, Integer, 32);
122122
reg_ctor!(i64, Integer, 64);
123+
reg_ctor!(i128, Integer, 128);
123124

124125
reg_ctor!(f32, Float, 32);
125126
reg_ctor!(f64, Float, 64);
@@ -493,6 +494,12 @@ pub struct FnAbi<'a, Ty> {
493494

494495
pub c_variadic: bool,
495496

497+
/// The count of non-variadic arguments.
498+
///
499+
/// Should only be different from args.len() when c_variadic is true.
500+
/// This can be used to know wether an argument is variadic or not.
501+
pub fixed_count: usize,
502+
496503
pub conv: Conv,
497504
}
498505

@@ -534,8 +541,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
534541
"nvptx" => nvptx::compute_abi_info(self),
535542
"nvptx64" => nvptx64::compute_abi_info(self),
536543
"hexagon" => hexagon::compute_abi_info(self),
537-
"riscv32" => riscv::compute_abi_info(self, 32),
538-
"riscv64" => riscv::compute_abi_info(self, 64),
544+
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
539545
"wasm32" if cx.target_spec().target_os != "emscripten" => {
540546
wasm32_bindgen_compat::compute_abi_info(self)
541547
}

0 commit comments

Comments
 (0)