Skip to content

Commit

Permalink
Auto merge of rust-lang#68452 - msizanoen1:riscv-abi, r=nagisa,eddyb
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Feb 8, 2020
2 parents 85ffd44 + 3963387 commit 07a34df
Show file tree
Hide file tree
Showing 8 changed files with 1,162 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2651,6 +2651,7 @@ where
.map(|(i, ty)| arg_of(ty, Some(i)))
.collect(),
c_variadic: sig.c_variadic,
fixed_count: inputs.len(),
conv,
};
fn_abi.adjust_for_abi(cx, sig.abi);
Expand Down
10 changes: 8 additions & 2 deletions src/librustc_target/abi/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl Reg {
reg_ctor!(i16, Integer, 16);
reg_ctor!(i32, Integer, 32);
reg_ctor!(i64, Integer, 64);
reg_ctor!(i128, Integer, 128);

reg_ctor!(f32, Float, 32);
reg_ctor!(f64, Float, 64);
Expand Down Expand Up @@ -538,6 +539,12 @@ pub struct FnAbi<'a, Ty> {

pub c_variadic: bool,

/// The count of non-variadic arguments.
///
/// Should only be different from args.len() when c_variadic is true.
/// This can be used to know wether an argument is variadic or not.
pub fixed_count: usize,

pub conv: Conv,
}

Expand Down Expand Up @@ -579,8 +586,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
"nvptx" => nvptx::compute_abi_info(self),
"nvptx64" => nvptx64::compute_abi_info(self),
"hexagon" => hexagon::compute_abi_info(self),
"riscv32" => riscv::compute_abi_info(self, 32),
"riscv64" => riscv::compute_abi_info(self, 64),
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
"wasm32" if cx.target_spec().target_os != "emscripten" => {
wasm32_bindgen_compat::compute_abi_info(self)
}
Expand Down
Loading

0 comments on commit 07a34df

Please sign in to comment.