machinst ABI: Allow back-end to define stack alignment
The common gen_prologue code currently assumes that the stack pointer has to be aligned to twice the word size. While this is true for many ABIs, it does not hold universally. This patch adds a new callback stack_align that back-ends can provide to define the specific stack alignment required by the ABI on that platform.
This commit is contained in:
@@ -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.
|
||||
///
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user