Skip to content

refactor(mir2): split Z80 codegen into thematic files (C1, pure move) - #63

Merged
oisee merged 1 commit into
mainfrom
refactor/C1-split-z80codegen
Oct 2, 2026
Merged

oisee merged 1 commit into
mainfrom
refactor/C1-split-z80codegen

Conversation

@oisee

@oisee oisee commented Oct 2, 2026

Copy link
Copy Markdown
Owner

C1: split pkg/mir2/z80codegen.go into thematic files (pure move)

Why. Nearly every production fix touches this one ~9.3k-line file, so parallel work had to merge one change at a time. This is a pure move inside package mir2, with zero logic change.

Result: 11 files, the largest 1,166 lines

File Contents
z80codegen.go driver, state, module/function/block
_alu.go ALU
_call.go calls, arguments, results, clobbers
_cmp.go compares, flags, bool
_copy.go parallel copies
_inst.go instruction dispatcher
_move.go moves, spills, conversions, TSMC
_muldiv.go mul/div/mod
_patterns.go LUT, bit, global-field, pointer scans
_peephole.go asm text peepholes
_term.go terminators, DJNZ

Proof

  1. AST identity. A go/parser + go/printer comparison against origin/main shows identical multisets on every axis: 154 top-level declarations including doc and body comments, 2,026 comment texts, the import union, and 201 selector uses. Re-run independently by the manager against a fresh archive of origin/main: all true.
  2. Output identity. The worker compiled all 979 tracked sources across every frontend (.abap .c .frl .lanz .lizp .m .minz .nanz .pas .plm) with --asserts none and SOURCE_DATE_EPOCH=0. Results: 499 byte-identical .a80, 480 identical failures, 0 mismatches. An independent manager sample of 183 files also gave 0 differences.
  3. go vet ./pkg/mir2 and gofmt -l are clean, and the mir2/hir/pipeline/c89/nanz gates are green.

No critic round: the change is mechanical and its correctness is established by the two independent identity proofs above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo

Move whole top-level declarations into focused files for arithmetic,
comparisons, calls, copies, moves, terminators, patterns and peepholes.
Keep the instruction dispatcher intact in its own file.

Verify all 154 declarations and comments with go/parser and go/printer.
Compare both compilers across 979 tracked frontend sources: 499 identical
assembly outputs and 480 identical failures. All required gates pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

PR tests: 🟢 pass

Commit: 237da6c4 · Full test log

Check Result
Build mz, mza, mze, mzv 🟢 pass
Stable Go package tests 🟢 pass
Fibonacci compile + assemble 🟢 pass
Nanz language regressions 🟢 pass
Z3 West of House demo 🟢 pass
Z3 small conformance fixtures 🟢 pass

The external CZECH and full Zork I stories are not part of this PR gate.

@oisee
oisee merged commit 6b8fc39 into main Oct 2, 2026
2 checks passed
@oisee
oisee deleted the refactor/C1-split-z80codegen branch October 2, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant