Skip to content

Commit

Permalink
Remove hardcoded alignment and addend
Browse files Browse the repository at this point in the history
  • Loading branch information
saulecabrera committed May 16, 2023
1 parent e9fecc4 commit 0eff833
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 6 additions & 2 deletions winch/codegen/src/codegen/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ impl<'a> FnCall<'a> {
masm: &mut M,
context: &mut CodeGenContext,
callee: FuncIndex,
alignment: u32,
addend: u32,
) {
let reserved_stack = masm.call(16, 16, self.arg_stack_space, |masm| {
let reserved_stack = masm.call(alignment, addend, self.arg_stack_space, |masm| {
self.assign_args(context, masm, <A as ABI>::scratch_reg());
CalleeKind::Direct(callee.as_u32())
});
Expand All @@ -161,8 +163,10 @@ impl<'a> FnCall<'a> {
masm: &mut M,
context: &mut CodeGenContext,
addr: M::Address,
alignment: u32,
addend: u32,
) {
let reserved_stack = masm.call(16, 16, self.arg_stack_space, |masm| {
let reserved_stack = masm.call(alignment, addend, self.arg_stack_space, |masm| {
let scratch = <A as ABI>::scratch_reg();
self.assign_args(context, masm, scratch);
masm.load(addr, scratch, OperandSize::S64);
Expand Down
19 changes: 16 additions & 3 deletions winch/codegen/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,24 @@ where
};

let fncall = FnCall::new::<A, M>(&sig, &mut self.context, self.masm);

let alignment = self.abi.call_stack_align();
let addend = self.abi.arg_base_offset();
if let Some(addr) = callee_addr {
fncall.indirect::<M, A>(self.masm, &mut self.context, addr);
fncall.indirect::<M, A>(
self.masm,
&mut self.context,
addr,
alignment.into(),
addend.into(),
);
} else {
fncall.direct::<M, A>(self.masm, &mut self.context, index);
fncall.direct::<M, A>(
self.masm,
&mut self.context,
index,
alignment.into(),
addend.into(),
);
}
}

Expand Down

0 comments on commit 0eff833

Please sign in to comment.