Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

machinst ABI: Allow back-end to define stack alignment #2345

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cranelift/codegen/src/isa/aarch64/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ impl ABIMachineSpec for AArch64MachineDeps {
64
}

/// Return required stack alignment in bytes.
fn stack_align(_call_conv: isa::CallConv) -> u32 {
16
}

fn compute_arg_locs(
call_conv: isa::CallConv,
params: &[ir::AbiParam],
Expand Down
5 changes: 5 additions & 0 deletions cranelift/codegen/src/isa/arm32/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ impl ABIMachineSpec for Arm32MachineDeps {
32
}

/// Return required stack alignment in bytes.
fn stack_align(_call_conv: isa::CallConv) -> u32 {
8
}

fn compute_arg_locs(
_call_conv: isa::CallConv,
params: &[ir::AbiParam],
Expand Down
5 changes: 5 additions & 0 deletions cranelift/codegen/src/isa/x64/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ impl ABIMachineSpec for X64ABIMachineSpec {
64
}

/// Return required stack alignment in bytes.
fn stack_align(_call_conv: isa::CallConv) -> u32 {
16
}

fn compute_arg_locs(
call_conv: isa::CallConv,
params: &[ir::AbiParam],
Expand Down
5 changes: 4 additions & 1 deletion cranelift/codegen/src/machinst/abi_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ pub trait ABIMachineSpec {
}
}

/// Returns required stack alignment in bytes.
fn stack_align(call_conv: isa::CallConv) -> u32;

/// Process a list of parameters or return values and allocate them to registers
/// and stack slots.
///
Expand Down Expand Up @@ -936,7 +939,7 @@ impl<M: ABIMachineSpec> ABICallee for ABICalleeImpl<M> {
);
total_stacksize += self.flags.baldrdash_prologue_words() as u32 * bytes;
}
let mask = 2 * bytes - 1;
let mask = M::stack_align(self.call_conv) - 1;
let total_stacksize = (total_stacksize + mask) & !mask; // 16-align the stack.

let mut fixed_frame_storage_size = 0;
Expand Down