- multi-value returns containing floats crashed the compiler: the FPx
return slots were routed through the int-register store path (passing
a -1 register number), and float forwarding ("return multi(...)") threw
"unexpected FP return register". Route FPx through the float path and
handle them in the generic load/store forwarding.
- the fp0 float staging register is also the first float return slot, so
storing later float return values clobbered an already-written fp0.
Defer the FP0-targeted float store until all other return stores are done.
- per-subroutine vreg renumbering compacted ints and floats into the same
numbers, and the A5 frame spill slots are keyed by number only, so an
int vreg and a float vreg could share one frame slot. Renumber floats
into a range disjoint from the ints.
- m68k codegen: multi-value returns were corrupted because the caller's
capture moves and the callee's epilogue both clobbered the return
registers d2-d4. Record the hardware return slots on the call site,
force-spill the transfer temporaries on both sides, and exclude a
subroutine's own return registers from its save set.
Replace the register allocator constraint that kept argument source vregs
out of other arguments' target slots with a proper move scheduler in
translateCall. Moves are emitted once their destination no longer holds a
pending source; cycles are broken by staging a source through a D0/D1
scratch register, falling back to an aligned stack temporary when both are
call arguments.
This makes hardware-register argument passing correct regardless of the
allocator's choices. Adds tests covering a D3/D2 swap and the stack-temp
fallback, and drops the now-obsolete allocator test and TODO entry.
Remove caller-demand pruning of callee save sets in
M68kRegisterAllocator: a callee now always saves every
allocated register it uses (d2-d6/a2-a4/fp2-fp7), instead of
only what known callers hold live. This was unsound for nested
calls and unknown entries (fn pointers, raw asm, tail calls)
and clobbered e.g. D6 across bsr. Subs using those registers
now correctly keep link/unlk + movem prologues.
Tests: add allocator regression for a callee with no caller
values live; update TestStackFrameLocals frame-pointer
expectations.
When a pointer argument staged through a data register shared that
register with another argument's slot, the slot transfer was emitted
in argument order with no liveness protection, so an earlier-indexed
data load destroyed the staged value first (e.g. a screen pointer
staged in D2 bound for A1, with x2's slot also D2: x2's load landed
first and movea.l d2,a1 read garbage). Every affected call drew
through a corrupt address register.
Hoist such transfers ahead of the data-slot loads in translateCall
when no later argument reads the transfer target; hoisted moves only
write their own slot and movea leaves CCR alone. Adds a regression
test mirroring blitter.line_draw(x1,y1,x2,y2,screen_ptr,erase,fill)
calls with a D2-staged pointer.
Fixes:
- M68K optimizer: prove index-register liveness before deleting scale
instructions in optimizeIndexedPointerLea.
- M68K optimizer: reject staged-add pair fold when the staged register is
also the add destination.
- M68K optimizer: prove removed flag-setting moves are dead before folding
staged adds or replacing pushes with pea.
- M68K optimizer: only treat full .l writes as redefinitions in the deadness
proof; byte/word partial writes keep the staged value live.
- M68K optimizer: treat add/sub/addq/subq to address registers as flag-
preserving (ADDA/SUBA semantics).
- M68K FPO: reject subroutines whose inline assembly mentions A5 (reads as
well as writes) and subroutines containing PUSH/POP/PUSHST/POPST.
- ADPCM wavc example: stop byte-swapping already-native m68k decoder output;
add deinterleave_16bit_stereo_be helper.
- M68K/new6502 backends and IR codec: preserve ImmediateOperand.SymbolAddress
offsets instead of dropping them; fix codec round-trip with type suffix.
- Clean up M68kMnemonics allFlagOverwriters classification for address-register
arithmetic.
- Remove unnecessary d1-d2 register saves in deinterleave_16bit_stereo_be.