Cranelift: pass iterators to ABIMachineSpec::compute_arg_locs (#5095)
Instead of slices. This gives us more flexibility to pass custom sequences without needing to allocate a `Vec` to hold them and pass in as a slice.
This commit is contained in:
@@ -87,13 +87,16 @@ impl ABIMachineSpec for AArch64MachineDeps {
|
|||||||
16
|
16
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_arg_locs(
|
fn compute_arg_locs<'a, I>(
|
||||||
call_conv: isa::CallConv,
|
call_conv: isa::CallConv,
|
||||||
_flags: &settings::Flags,
|
_flags: &settings::Flags,
|
||||||
params: &[ir::AbiParam],
|
params: I,
|
||||||
args_or_rets: ArgsOrRets,
|
args_or_rets: ArgsOrRets,
|
||||||
add_ret_area_ptr: bool,
|
add_ret_area_ptr: bool,
|
||||||
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)> {
|
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = &'a ir::AbiParam>,
|
||||||
|
{
|
||||||
let is_apple_cc = call_conv.extends_apple_aarch64();
|
let is_apple_cc = call_conv.extends_apple_aarch64();
|
||||||
|
|
||||||
// See AArch64 ABI (https://github.com/ARM-software/abi-aa/blob/2021Q1/aapcs64/aapcs64.rst#64parameter-passing), sections 6.4.
|
// See AArch64 ABI (https://github.com/ARM-software/abi-aa/blob/2021Q1/aapcs64/aapcs64.rst#64parameter-passing), sections 6.4.
|
||||||
|
|||||||
@@ -56,13 +56,16 @@ impl ABIMachineSpec for Riscv64MachineDeps {
|
|||||||
16
|
16
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_arg_locs(
|
fn compute_arg_locs<'a, I>(
|
||||||
call_conv: isa::CallConv,
|
call_conv: isa::CallConv,
|
||||||
_flags: &settings::Flags,
|
_flags: &settings::Flags,
|
||||||
params: &[ir::AbiParam],
|
params: I,
|
||||||
args_or_rets: ArgsOrRets,
|
args_or_rets: ArgsOrRets,
|
||||||
add_ret_area_ptr: bool,
|
add_ret_area_ptr: bool,
|
||||||
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)> {
|
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = &'a ir::AbiParam>,
|
||||||
|
{
|
||||||
// All registers that can be used as parameters or rets.
|
// All registers that can be used as parameters or rets.
|
||||||
// both start and end are included.
|
// both start and end are included.
|
||||||
let (x_start, x_end, f_start, f_end) = if args_or_rets == ArgsOrRets::Args {
|
let (x_start, x_end, f_start, f_end) = if args_or_rets == ArgsOrRets::Args {
|
||||||
|
|||||||
@@ -221,13 +221,16 @@ impl ABIMachineSpec for S390xMachineDeps {
|
|||||||
8
|
8
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_arg_locs(
|
fn compute_arg_locs<'a, I>(
|
||||||
call_conv: isa::CallConv,
|
call_conv: isa::CallConv,
|
||||||
_flags: &settings::Flags,
|
_flags: &settings::Flags,
|
||||||
params: &[ir::AbiParam],
|
params: I,
|
||||||
args_or_rets: ArgsOrRets,
|
args_or_rets: ArgsOrRets,
|
||||||
add_ret_area_ptr: bool,
|
add_ret_area_ptr: bool,
|
||||||
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)> {
|
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = &'a ir::AbiParam>,
|
||||||
|
{
|
||||||
let mut next_gpr = 0;
|
let mut next_gpr = 0;
|
||||||
let mut next_fpr = 0;
|
let mut next_fpr = 0;
|
||||||
let mut next_vr = 0;
|
let mut next_vr = 0;
|
||||||
@@ -245,7 +248,7 @@ impl ABIMachineSpec for S390xMachineDeps {
|
|||||||
next_gpr += 1;
|
next_gpr += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, mut param) in params.iter().copied().enumerate() {
|
for (i, mut param) in params.into_iter().copied().enumerate() {
|
||||||
let intreg = in_int_reg(param.value_type);
|
let intreg = in_int_reg(param.value_type);
|
||||||
let fltreg = in_flt_reg(param.value_type);
|
let fltreg = in_flt_reg(param.value_type);
|
||||||
let vecreg = in_vec_reg(param.value_type);
|
let vecreg = in_vec_reg(param.value_type);
|
||||||
|
|||||||
@@ -81,13 +81,16 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
|||||||
16
|
16
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_arg_locs(
|
fn compute_arg_locs<'a, I>(
|
||||||
call_conv: isa::CallConv,
|
call_conv: isa::CallConv,
|
||||||
flags: &settings::Flags,
|
flags: &settings::Flags,
|
||||||
params: &[ir::AbiParam],
|
params: I,
|
||||||
args_or_rets: ArgsOrRets,
|
args_or_rets: ArgsOrRets,
|
||||||
add_ret_area_ptr: bool,
|
add_ret_area_ptr: bool,
|
||||||
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)> {
|
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = &'a ir::AbiParam>,
|
||||||
|
{
|
||||||
let is_fastcall = call_conv.extends_windows_fastcall();
|
let is_fastcall = call_conv.extends_windows_fastcall();
|
||||||
|
|
||||||
let mut next_gpr = 0;
|
let mut next_gpr = 0;
|
||||||
|
|||||||
@@ -345,13 +345,15 @@ pub trait ABIMachineSpec {
|
|||||||
/// Returns the list of argument locations, the stack-space used (rounded up
|
/// Returns the list of argument locations, the stack-space used (rounded up
|
||||||
/// to as alignment requires), and if `add_ret_area_ptr` was passed, the
|
/// to as alignment requires), and if `add_ret_area_ptr` was passed, the
|
||||||
/// index of the extra synthetic arg that was added.
|
/// index of the extra synthetic arg that was added.
|
||||||
fn compute_arg_locs(
|
fn compute_arg_locs<'a, I>(
|
||||||
call_conv: isa::CallConv,
|
call_conv: isa::CallConv,
|
||||||
flags: &settings::Flags,
|
flags: &settings::Flags,
|
||||||
params: &[ir::AbiParam],
|
params: I,
|
||||||
args_or_rets: ArgsOrRets,
|
args_or_rets: ArgsOrRets,
|
||||||
add_ret_area_ptr: bool,
|
add_ret_area_ptr: bool,
|
||||||
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)>;
|
) -> CodegenResult<(ABIArgVec, i64, Option<usize>)>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = &'a ir::AbiParam>;
|
||||||
|
|
||||||
/// Returns the offset from FP to the argument area, i.e., jumping over the saved FP, return
|
/// Returns the offset from FP to the argument area, i.e., jumping over the saved FP, return
|
||||||
/// address, and maybe other standard elements depending on ABI (e.g. Wasm TLS reg).
|
/// address, and maybe other standard elements depending on ABI (e.g. Wasm TLS reg).
|
||||||
|
|||||||
Reference in New Issue
Block a user