Winch writes the first result to the highest offset, so we need to iterate through the args and adjust the offsets down.
(mut args: ArgsAccumulator, next_stack: u32, uses_extension: bool)
| 3 | // Winch writes the first result to the highest offset, so we need to iterate through the |
| 4 | // args and adjust the offsets down. |
| 5 | pub(super) fn reverse_stack(mut args: ArgsAccumulator, next_stack: u32, uses_extension: bool) { |
| 6 | for arg in args.args_mut() { |
| 7 | if let ABIArg::Slots { slots, .. } = arg { |
| 8 | for slot in slots.iter_mut() { |
| 9 | if let ABIArgSlot::Stack { offset, ty, .. } = slot { |
| 10 | let size = if uses_extension { |
| 11 | i64::from(core::cmp::max(ty.bytes(), 8)) |
| 12 | } else { |
| 13 | i64::from(ty.bytes()) |
| 14 | }; |
| 15 | *offset = i64::from(next_stack) - *offset - size; |
| 16 | } |
| 17 | } |
| 18 | } else { |
| 19 | unreachable!("Winch cannot handle {arg:?}"); |
| 20 | } |
| 21 | } |
| 22 | } |