Skip to content

Commit

Permalink
Merge pull request rust-lang#3 from 0ndorio/fix/register_calculation
Browse files Browse the repository at this point in the history
Fix argument register calculation.

Co-authored-by: rnd <[email protected]>
  • Loading branch information
2 people authored and Gasper committed Apr 4, 2020
1 parent f03b681 commit 16c5e85
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/librustc_target/abi/call/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@ fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>, xlen: u64, remaining_gpr: &mut
// according to the ABI. 2*XLen-aligned varargs are passed in "aligned"
// register pairs, so may consume 3 registers.

let mut stack_required = false;
let arg_size = arg.layout.size;
let alignment = arg.layout.details.align.abi;

if arg_size.bits() > MAX_ARG_IN_REGS_SIZE {
arg.make_indirect();
return;
}

let alignment = arg.layout.details.align.abi;
let mut required_gpr = 1u64; // at least one per arg

if alignment.bits() == 2 * xlen {
required_gpr = 2 + (*remaining_gpr % 2);
} else if arg_size.bits() > xlen && arg_size.bits() <= MAX_ARG_IN_REGS_SIZE {
required_gpr = arg_size.bits() + (xlen - 1) / xlen;
required_gpr = (arg_size.bits() + (xlen - 1)) / xlen;
}

let mut stack_required = false;
if required_gpr > *remaining_gpr {
stack_required = true;
required_gpr = *remaining_gpr;
Expand Down

0 comments on commit 16c5e85

Please sign in to comment.