Reduce sig data size by changing sized spaces (#5402)

* Reduce sig sizes

* Fix test

* Change compute_args_loc to return u32
This commit is contained in:
Timothy Chen
2022-12-12 07:32:30 +08:00
committed by GitHub
parent 244dce93f6
commit 8035945502
5 changed files with 43 additions and 41 deletions

View File

@@ -400,7 +400,7 @@ pub trait ABIMachineSpec {
args_or_rets: ArgsOrRets,
add_ret_area_ptr: bool,
args: ArgsAccumulator<'_>,
) -> CodegenResult<(i64, Option<usize>)>
) -> CodegenResult<(u32, Option<usize>)>
where
I: IntoIterator<Item = &'a ir::AbiParam>;
@@ -643,11 +643,13 @@ pub struct SigData {
/// This is a index into the `SigSet::abi_args`.
rets_end: u32,
/// Space on stack used to store arguments.
sized_stack_arg_space: i64,
/// Space on stack used to store arguments. We're storing the size in u32 to
/// reduce the size of the struct.
sized_stack_arg_space: u32,
/// Space on stack used to store return values.
sized_stack_ret_space: i64,
/// Space on stack used to store return values. We're storing the size in u32 to
/// reduce the size of the struct.
sized_stack_ret_space: u32,
/// Index in `args` of the stack-return-value-area argument.
stack_ret_arg: Option<u16>,
@@ -659,12 +661,12 @@ pub struct SigData {
impl SigData {
/// Get total stack space required for arguments.
pub fn sized_stack_arg_space(&self) -> i64 {
self.sized_stack_arg_space
self.sized_stack_arg_space.into()
}
/// Get total stack space required for return values.
pub fn sized_stack_ret_space(&self) -> i64 {
self.sized_stack_ret_space
self.sized_stack_ret_space.into()
}
/// Get calling convention used.
@@ -1920,7 +1922,7 @@ impl<M: ABIMachineSpec> Callee<M> {
/// Returns the size of arguments expected on the stack.
pub fn stack_args_size(&self, sigs: &SigSet) -> u32 {
sigs[self.sig].sized_stack_arg_space as u32
sigs[self.sig].sized_stack_arg_space
}
/// Get the spill-slot size.
@@ -2324,7 +2326,7 @@ impl<M: ABIMachineSpec> Caller<M> {
});
}
&ABIArgSlot::Stack { offset, ty, .. } => {
let ret_area_base = ctx.sigs()[self.sig].sized_stack_arg_space;
let ret_area_base = ctx.sigs()[self.sig].sized_stack_arg_space();
insts.push(M::gen_load_stack(
StackAMode::SPOffset(offset + ret_area_base, ty),
*into_reg,
@@ -2361,7 +2363,7 @@ impl<M: ABIMachineSpec> Caller<M> {
let word_type = M::word_type();
if let Some(i) = ctx.sigs()[self.sig].stack_ret_arg {
let rd = ctx.alloc_tmp(word_type).only_reg().unwrap();
let ret_area_base = ctx.sigs()[self.sig].sized_stack_arg_space;
let ret_area_base = ctx.sigs()[self.sig].sized_stack_arg_space();
ctx.emit(M::gen_get_stack_addr(
StackAMode::SPOffset(ret_area_base, I8),
rd,
@@ -2403,6 +2405,6 @@ mod tests {
fn sig_data_size() {
// The size of `SigData` is performance sensitive, so make sure
// we don't regress it unintentionally.
assert_eq!(std::mem::size_of::<SigData>(), 32);
assert_eq!(std::mem::size_of::<SigData>(), 24);
}
}