feat(nanz): declared @extern clobbers + working extern ABI (P9) - #66
Merged
Merged
Conversation
PR tests: 🟢 passCommit:
The external CZECH and full Zork I stories are not part of this PR gate. |
Carry explicit physical clobber contracts through HIR and MIR2 and preserve live callers using Z80 register overlap. Keep unknown calls conservative, retain external parameter/return ABIs, and account for caller setup and result pickup writes. Document contracts and corpus findings, with assembly judges and mutation-verified regressions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo
Require unique callee names and bodyless externs before narrowing caller saves. Reject extern/body collisions and conflicting extern ABIs, improve attribute errors, and document untracked registers. Add regression judges and record FIX1 validation in the dated report. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo
Deduplicate identical bodyless extern declarations after imports merge and compare clobber contracts as sets. Reject colliding emitted Z80 symbols and ambiguous calls instead of dropping argument, return, and address contracts. Add executable regression tests and record critic, mutation, corpus, and gate results, including the unresolved-extern compatibility limitation. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo
Transfer adopted Frill helpers into one declaration and retain first import bindings. Reserve runtime and generated Z80 symbols, and propagate collision errors through codegen, pipelines, and VIR's PBQP fallback. Add regression tests and document cross-frontend extern ABI effects and the complete corpus audit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo
…param collisions Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo
Owner
Author
|
Rebased onto main with #65 (J2a). Re-ran gates: Go build/tests green; |
oisee
force-pushed
the
feat/P9-extern-clobbers
branch
from
October 2, 2026 14:29
95edba5 to
170344d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P9: declared clobbers for
@externcalls, and a working extern ABISince #62, every call to a callee without a known body has been treated as clobbering every register. That is safe but costs bytes. This PR lets the author of an external routine declare what it clobbers:
Caller-saves are narrowed only when the call resolves to a single extern with no body. Everything else stays conservative, as before:
Unknown register names are a compile error. AF' is rejected. The docs explain that EXX shadows, I and R are not tracked.
The extern ABI on main was broken, and this PR fixes it
On origin/main, extern calls never received their arguments in the ABI registers, and
POP AFoverwrote the result. The critic's probe returns 25 on main and 55 here, andps1returns 3 on main and 6 here.hir/lower.gonow gives externs a parameter and return contract.Known gap (follow-up): if a signature has several parameters of the same class, they map to the same register, e.g.
(u16,u16,u16)becomes HL, DE, DE, so an argument is lost. Main lost all of them, so this is not a regression. It is documented in the report.Safety hardening, found by the critics
@externdeclarations: identical redeclarations (repeated or diamond imports) are merged into one. Conflicting ones are a compile error, as is an@externthat shares its name with a function body.f→v_f), and runtime labels such as__mul8are reserved. A collision is a compile error. Before this, the second label was silently dropped.Z80Codegennow returns(string, error)instead of panicking.Numbers (vs origin/main 05402e1)
--asserts-force z80checks: 682 critic checks (nanz + frill) and 3,737 worker checks, 0 newly failing.Gate
-shortpipeline and c89.pkg/vir(offline oracle): the same 11 failures as on main.Report:
reports/2026-10-02-P9-Extern-Clobbers.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01Wrwo36SzxKRZYTgpDo7hzo