226 Commits
Author SHA1 Message Date
Irmen de Jong c883b460a8 amiga: tweak beachball sprite examples
m68k: better describe role of D7 loop counter register
2026-11-17 23:36:28 +01:00
Irmen de Jong 16c34f9fbb m68k: fix missing alignments 2026-11-17 03:30:55 +01:00
Irmen de Jong 973e180108 m68k: struct defs now as RS blocks in the .asm instead of hand calculated EQUS 2026-11-15 21:57:32 +01:00
Irmen de Jong 7f22c91674 amiga: add 'mobs' library for sprite/bob base structures and helper routines 2026-11-15 18:54:14 +01:00
Irmen de Jong 70c4921a3b some error message cleaned up 2026-11-14 15:10:01 +01:00
Irmen de Jong fec84d50bd m68k: fix mixed float multi-return returns and frame slot collision
- 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.
2026-11-14 14:55:13 +01:00
Irmen de Jong 0d0b565d28 m68k: fix multi-return value corruption; optimize lineclip
- 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.
2026-11-14 14:37:46 +01:00
Irmen de Jong 72b4320403 lib update 2026-11-14 09:48:07 +01:00
Irmen de Jong 37546f8e76 m68k: schedule hardware-register call argument moves
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.
2026-11-11 18:49:07 +01:00
Irmen de Jong d0391a3dbf Test duplicate BSS entries for inline struct-array elements 2026-11-11 00:33:37 +01:00
Irmen de Jong 2efa8ea03f Avoid duplicate struct-array instances in M68k output
related to ee2aa9e215
2026-11-10 23:15:54 +01:00
Irmen de Jong 686a1f2423 m68k: fix memcopy loop count off by 1 2026-11-10 02:38:30 +01:00
Irmen de Jong a7d76c7747 Fix m68k callee-saved register clobber across calls
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.
2026-11-09 23:19:47 +01:00
Irmen de Jong 2cac146548 Fix M68K callee-save tracking for fixed-register calls 2026-11-07 20:21:15 +01:00
Irmen de Jong cd68356e02 m68k: fix call-site clobber of address-slot args staged in Dx
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.
2026-11-07 18:07:19 +01:00
Irmen de Jong 4772644056 Address codegen bug review findings
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.
2026-11-07 14:30:37 +01:00
Irmen de Jong e88bb6bc2e m68k: fix deadness proof and finish branch-chain retargeting 2026-11-07 13:30:33 +01:00
Irmen de Jong eba89ecd3d m68k: source staging before a store (A.3) 2026-11-07 13:01:12 +01:00
Irmen de Jong f3cacf7653 m68k: branch-aware deadness (A.1) 2026-11-07 12:55:11 +01:00
Irmen de Jong 01e485096c m68k: dead zero-extend writeback removal (A.2) and pea folding for stack args (A.4) 2026-11-07 12:47:29 +01:00
Irmen de Jong 8d977da044 m68k: fold pointer-indexed addressing into indexed lea 2026-11-07 12:46:08 +01:00
Irmen de Jong 888e0d092c m68k: collapse pointer-stage/D0-bounce trio and drop dead An stagings in AsmOptimizer 2026-11-06 19:29:51 +01:00
Irmen de Jong 5f9446499e m68k: implement phase 1 of frame-pointer omission (functional but phase 2 remains tbd) 2026-11-06 17:34:08 +01:00
Irmen de Jong c669246a73 ir: pass immediates directly into call hardware register slots 2026-11-06 14:42:46 +01:00
Irmen de Jong bc121bc4c6 m68k: eliminate dead extends before left shifts 2026-11-06 03:35:56 +01:00
Irmen de Jong 326d21ed9e m68k: emit moveq+move.b for zero-extends, 2026-11-06 03:17:27 +01:00
Irmen de Jong c8f3453675 remove mordant library JNI/CFF layers 2026-11-05 18:39:06 +01:00
Irmen de Jong c1bedc6176 m68k: faster codegen, faster horizontal blitter lines, added math.mul32 2026-11-05 04:48:48 +01:00
Irmen de Jong 9553d91990 various things 2026-11-04 22:32:43 +01:00
Irmen de Jong aaef40baa6 added missing file and fix a constant pointer deref compiler crash 2026-11-04 15:14:42 +01:00
Irmen de Jong dfdaadfc01 m68k: rewrite cmp #0,d0 into tst d0 2026-11-04 01:24:25 +01:00
Irmen de Jong 2a0d3445d6 m68k: rewrite cmp #0,d0 into tst d0 2026-11-03 23:43:48 +01:00
Irmen de Jong b8cbb5c052 Revert "m68k: add A5 frame-slot round-trip peephole fallback"
This reverts commit d6f512cf5c.
2026-11-03 23:07:37 +01:00
Irmen de Jong f4635d93d6 m68k: don't fold memory loads into lea, fixes error from e845e789f 2026-11-03 21:44:19 +01:00
Irmen de Jong d6f512cf5c m68k: add A5 frame-slot round-trip peephole fallback 2026-11-03 20:42:17 +01:00
Irmen de Jong 2508b0a9f4 if-expressions are now const folded too
fix invalid a0 instruction
2026-11-03 20:17:52 +01:00
Irmen de Jong fbf23a56b7 cleanups 2026-11-03 18:29:52 +01:00
Irmen de Jong 7abeec2c68 m68k: fold load-const-then-operate into immediate forms 2026-11-03 17:48:03 +01:00
Irmen de Jong 8e0a6236cf Use 68020 scaled indexing directly 2026-11-03 17:23:42 +01:00
Irmen de Jong e845e789fd m68k: extend store-reload to frame slots 2026-11-03 17:11:59 +01:00
Irmen de Jong 3cae5cfe4d m68k: drop redundant duplicate and mirrored moves in peephole 2026-11-03 17:05:09 +01:00
Irmen de Jong 1c0fbc7edc m68k: extend redundant-tst removal to data regs and flag-identical ops 2026-11-03 17:00:04 +01:00
Irmen de Jong e8df5ac1b6 m68k libs: hand-apply moveq/lea optimizations the peephole found 2026-11-03 16:54:42 +01:00
Irmen de Jong 78fbb6b7af m68k: Redundant lea reload optimized 2026-11-03 16:40:07 +01:00
Irmen de Jong 23218356f3 m68k: emit bra instead of jmp for branches to labels leaving the subroutine 2026-11-03 16:33:09 +01:00
Irmen de Jong d70bfce33a m68k: moveq for long immediates, addq/subq for small immediates, extb.l for sign extension 2026-11-03 16:22:50 +01:00
Irmen de Jong 5f3239d811 default no longer include all IR debug lines into the m68k asm file 2026-11-03 15:30:30 +01:00
Irmen de Jong acf72da57a m68k: normalize asm whitespaces 2026-11-03 15:17:49 +01:00
Irmen de Jong 1e19fd212a m68k: moveq for zeroing data regs, move instead of clr on IO addresses because of dummy read 2026-11-03 15:12:28 +01:00
Irmen de Jong 52bd103295 emit .binary / incbin for %asmbinary blobs instead of dumping the actual bytes into the asm 2026-11-01 15:46:29 +01:00