Skip to content

Commit e590164

Browse files
committed
Implement proper C ABI lowering for RISC-V
1 parent 0d34a87 commit e590164

File tree

3 files changed

+331
-15
lines changed

3 files changed

+331
-15
lines changed

Diff for: src/librustc/ty/layout.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2650,6 +2650,7 @@ where
26502650
.map(|(i, ty)| arg_of(ty, Some(i)))
26512651
.collect(),
26522652
c_variadic: sig.c_variadic,
2653+
fixed_count: inputs.len(),
26532654
conv,
26542655
};
26552656
fn_abi.adjust_for_abi(cx, sig.abi);

Diff for: src/librustc_target/abi/call/mod.rs

+8-2
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)