Skip to content

Commit 07a34df

Browse files
committed
Auto merge of #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 85ffd44 + 3963387 commit 07a34df

File tree

8 files changed

+1162
-16
lines changed

8 files changed

+1162
-16
lines changed

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

+1
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);

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);
@@ -538,6 +539,12 @@ pub struct FnAbi<'a, Ty> {
538539

539540
pub c_variadic: bool,
540541

542+
/// The count of non-variadic arguments.
543+
///
544+
/// Should only be different from args.len() when c_variadic is true.
545+
/// This can be used to know wether an argument is variadic or not.
546+
pub fixed_count: usize,
547+
541548
pub conv: Conv,
542549
}
543550

@@ -579,8 +586,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
579586
"nvptx" => nvptx::compute_abi_info(self),
580587
"nvptx64" => nvptx64::compute_abi_info(self),
581588
"hexagon" => hexagon::compute_abi_info(self),
582-
"riscv32" => riscv::compute_abi_info(self, 32),
583-
"riscv64" => riscv::compute_abi_info(self, 64),
589+
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
584590
"wasm32" if cx.target_spec().target_os != "emscripten" => {
585591
wasm32_bindgen_compat::compute_abi_info(self)
586592
}

0 commit comments

Comments
 (0)