machinst ABI: Support for accumulating outgoing args
When performing a function call, the platform ABI may require space on the stack to hold outgoing arguments and/or return values. Currently, this is supported via decrementing the stack pointer before the call and incrementing it afterwards, using the emit_stack_pre_adjust and emit_stack_post_adjust methods of ABICaller. However, on some platforms it would be preferable to just allocate enough space for any call done in the function in the caller's prologue instead. This patch adds support to allow back-ends to choose that method. Instead of calling emit_stack_pre/post_adjust around a call, they simply call a new accumulate_outgoing_args_size method of ABICaller instead. This will pass on the required size to the ABICallee structure of the calling function, which will accumulate the maximum size required for all function calls. That accumulated size is then passed to the gen_clobber_save and gen_clobber_restore functions so they can include the size in the stack allocation / deallocation that already happens in the prologue / epilogue code.
This commit is contained in:
@@ -513,6 +513,7 @@ impl ABIMachineSpec for AArch64MachineDeps {
|
||||
_: &settings::Flags,
|
||||
clobbers: &Set<Writable<RealReg>>,
|
||||
fixed_frame_storage_size: u32,
|
||||
_outgoing_args_size: u32,
|
||||
) -> (u64, SmallVec<[Inst; 16]>) {
|
||||
let mut insts = SmallVec::new();
|
||||
let (clobbered_int, clobbered_vec) = get_regs_saved_in_prologue(call_conv, clobbers);
|
||||
@@ -565,6 +566,7 @@ impl ABIMachineSpec for AArch64MachineDeps {
|
||||
flags: &settings::Flags,
|
||||
clobbers: &Set<Writable<RealReg>>,
|
||||
_fixed_frame_storage_size: u32,
|
||||
_outgoing_args_size: u32,
|
||||
) -> SmallVec<[Inst; 16]> {
|
||||
let mut insts = SmallVec::new();
|
||||
let (clobbered_int, clobbered_vec) = get_regs_saved_in_prologue(call_conv, clobbers);
|
||||
|
||||
Reference in New Issue
Block a user