startup: reassemble the NGG slice cases with llvm-mc in a binary mode #1993

Merged
NiiRoZz merged 1 commit from upstream-pr/2000 into main 2026-11-24 23:23:04 +00:00
NiiRoZz commented 2026-11-24 22:54:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-24T22:54:02Z.


Change

Follow-up to #1961, which merged before this commit was pushed: tests/startup_ngg_slice_check.py gains an optional binary <llvm-mc> mode. It converts the fixture's six NGG programs to LLVM assembly text, assembles them with LLVM 15 llvm-mc (gfx1013, wave64) and requires word-for-word identity with the fixture's own encoder. A deliberately wrong encoder word must be reported as a mismatch.

The mode is added to the Linux LLVM job, next to the sibling binary checks. The pure-Python mode is unchanged. The docs section now gives the command instead of saying the words are not reassembled.

Test only. Refs #1723. AI-assisted (Claude Code).

Verification

On this branch (one commit on main), with LLVM 15.0.7:

  • python -B tests/startup_ngg_slice_check.py prints 6 cases decoded, anchored and separated under 3 interpretations; 6 planted model faults detected.
  • python -B tests/startup_ngg_slice_check.py binary <llvm-mc> prints that line and 342 instructions of 6 programs match llvm-mc; a wrong encoder word is reported.
  • python -B tests/docs_links_check.py passes.

Not run locally: the Linux job itself (it uses llvm-mc-15 from the Ubuntu package, as the sibling checks do).

Evidence and follow-up

  • The comparison covers every instruction form the fixture uses that had no golden vector in rdna2_tools_check: the VOP3 v_mbcnt_* and v_lshl_or_b32 forms, the VOPC v_cmpx/v_cmp forms, exp prim and exp param0, s_sendmsg sendmsg(MSG_GS_ALLOC_REQ), s_barrier, and ds_write_b32/ds_read_b32 with offsets.
  • The repository disassembler's text differs from LLVM's in five spellings (the barrier and sendmsg operands, the prim export target, vcc in wave64, branch labels); the mode converts those before assembling.
  • A missing tool raises, as in startup_smem_address_check.py binary.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593039000 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2000). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-24T22:54:02Z. --- ## Change Follow-up to #1961, which merged before this commit was pushed: `tests/startup_ngg_slice_check.py` gains an optional `binary <llvm-mc>` mode. It converts the fixture's six NGG programs to LLVM assembly text, assembles them with LLVM 15 `llvm-mc` (gfx1013, wave64) and requires word-for-word identity with the fixture's own encoder. A deliberately wrong encoder word must be reported as a mismatch. The mode is added to the Linux LLVM job, next to the sibling `binary` checks. The pure-Python mode is unchanged. The docs section now gives the command instead of saying the words are not reassembled. Test only. Refs #1723. AI-assisted (Claude Code). ## Verification On this branch (one commit on `main`), with LLVM 15.0.7: - `python -B tests/startup_ngg_slice_check.py` prints `6 cases decoded, anchored and separated under 3 interpretations; 6 planted model faults detected`. - `python -B tests/startup_ngg_slice_check.py binary <llvm-mc>` prints that line and `342 instructions of 6 programs match llvm-mc; a wrong encoder word is reported`. - `python -B tests/docs_links_check.py` passes. Not run locally: the Linux job itself (it uses `llvm-mc-15` from the Ubuntu package, as the sibling checks do). ## Evidence and follow-up - The comparison covers every instruction form the fixture uses that had no golden vector in `rdna2_tools_check`: the VOP3 `v_mbcnt_*` and `v_lshl_or_b32` forms, the VOPC `v_cmpx`/`v_cmp` forms, `exp prim` and `exp param0`, `s_sendmsg sendmsg(MSG_GS_ALLOC_REQ)`, `s_barrier`, and `ds_write_b32`/`ds_read_b32` with offsets. - The repository disassembler's text differs from LLVM's in five spellings (the barrier and sendmsg operands, the `prim` export target, `vcc` in wave64, branch labels); the mode converts those before assembling. - A missing tool raises, as in `startup_smem_address_check.py binary`. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ChazY11 commented 2026-11-24 23:03:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:01:14Z.


What I could run here, and what I could not

Windows 11 build 26300.9974, no LLVM on this machine — so the reassembly itself is unverified by me and I am not claiming otherwise.

out/pe-env/Scripts/python.exe -B tests/startup_ngg_slice_check.py
6 cases decoded, anchored and separated under 3 interpretations; 6 planted model faults detected      exit 0

out/pe-env/Scripts/python.exe -B tests/startup_ngg_slice_check.py binary
<docstring usage>                                                                                     exit 1

Two things that check out from that:

  • the pure-Python mode is unchanged and green, as the description says;
  • without llvm-mc the new mode refuses with the usage text instead of silently passing, which is the failure mode that matters
    for a binary subcommand.

The negative control is sound, and I checked why

wrong = program(None)
wrong[1][1] = sop1('s_mov_b64', 's10', 'exec')  # encoder word for s[10:11] under the text for s[8:9]
if len(llvm_words(llvm_mc, wrong)) != 1:
    raise AssertionError('a wrong encoder word was not reported by the llvm-mc comparison')
  • program() builds a fresh list on every call (no memoisation), so mutating wrong[1][1] after the per-case loop cannot corrupt the
    fixture — I looked, because a cached list here would have made the control flaky rather than wrong.
  • The control leaves the text alone and changes only the word, so the comparison is proven sensitive to the encoder side.
  • != 1 rather than > 0 also pins that llvm_words() returns only the mismatching entries — a version that returned everything would
    fail this control.

One gap in that control

It proves the comparison notices a wrong word. It does not prove the text side is exercised at all: if llvm_text() produced a line
llvm-mc cannot parse, subprocess.run(..., check=True) raises CalledProcessError, and the run ends with a traceback rather than the
fixture's own message. Two small changes would close both:

# 1. a broken line should be reported as a fixture failure, not a traceback
proc = subprocess.run(..., check=False)
if proc.returncode:
    raise AssertionError('llvm-mc rejected the translated line: %s' % proc.stderr.strip()[:300])

# 2. a second control: wrong text, right word
bad_text = program(None)
bad_text[1] = ('s_mov_b64 s[99:100], exec', bad_text[1][1])
if not any(... for ... in llvm_words(...)):   # or expect the AssertionError above
    raise AssertionError('a wrong assembly line was not reported')

The first is the one I would insist on: the whole point of the mode is to compare the fixture's encoder against LLVM, and today a bad
translation of the text fails in a way that looks like an infrastructure error.

What the mode does not establish

gfx1013 + wave64 via -mattr=+wavefrontsize64,-wavefrontsize32 is the right invocation for these six programs, but the mode is a
reassembly check: it says the encoder and LLVM agree on the bytes, not that the bytes mean what ANCHORS claims. The pure-Python mode
and the rdna2_tools_check golden vectors carry that half, and both are unchanged here.

Notes

  • AI-assisted review. The binary mode was not executed; everything under "verified" above is the pure-Python mode and the no-LLVM refusal.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146916911 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2000#issuecomment-7146916911). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T23:01:14Z. --- ## What I could run here, and what I could not Windows 11 build 26300.9974, **no LLVM on this machine** — so the reassembly itself is unverified by me and I am not claiming otherwise. ```powershell out/pe-env/Scripts/python.exe -B tests/startup_ngg_slice_check.py 6 cases decoded, anchored and separated under 3 interpretations; 6 planted model faults detected exit 0 out/pe-env/Scripts/python.exe -B tests/startup_ngg_slice_check.py binary <docstring usage> exit 1 ``` Two things that check out from that: - the pure-Python mode is unchanged and green, as the description says; - without `llvm-mc` the new mode **refuses with the usage text instead of silently passing**, which is the failure mode that matters for a `binary` subcommand. ## The negative control is sound, and I checked why ```python wrong = program(None) wrong[1][1] = sop1('s_mov_b64', 's10', 'exec') # encoder word for s[10:11] under the text for s[8:9] if len(llvm_words(llvm_mc, wrong)) != 1: raise AssertionError('a wrong encoder word was not reported by the llvm-mc comparison') ``` - `program()` builds a **fresh** list on every call (no memoisation), so mutating `wrong[1][1]` after the per-case loop cannot corrupt the fixture — I looked, because a cached list here would have made the control flaky rather than wrong. - The control leaves the **text** alone and changes only the word, so the comparison is proven sensitive to the encoder side. - `!= 1` rather than `> 0` also pins that `llvm_words()` returns only the mismatching entries — a version that returned everything would fail this control. ## One gap in that control It proves the comparison notices a wrong **word**. It does not prove the text side is exercised at all: if `llvm_text()` produced a line `llvm-mc` cannot parse, `subprocess.run(..., check=True)` raises `CalledProcessError`, and the run ends with a traceback rather than the fixture's own message. Two small changes would close both: ```python # 1. a broken line should be reported as a fixture failure, not a traceback proc = subprocess.run(..., check=False) if proc.returncode: raise AssertionError('llvm-mc rejected the translated line: %s' % proc.stderr.strip()[:300]) # 2. a second control: wrong text, right word bad_text = program(None) bad_text[1] = ('s_mov_b64 s[99:100], exec', bad_text[1][1]) if not any(... for ... in llvm_words(...)): # or expect the AssertionError above raise AssertionError('a wrong assembly line was not reported') ``` The first is the one I would insist on: the whole point of the mode is to compare the fixture's encoder against LLVM, and today a bad translation of the text fails in a way that looks like an infrastructure error. ## What the mode does not establish `gfx1013` + `wave64` via `-mattr=+wavefrontsize64,-wavefrontsize32` is the right invocation for these six programs, but the mode is a **reassembly** check: it says the encoder and LLVM agree on the bytes, not that the bytes mean what `ANCHORS` claims. The pure-Python mode and the `rdna2_tools_check` golden vectors carry that half, and both are unchanged here. ## Notes - AI-assisted review. The `binary` mode was not executed; everything under "verified" above is the pure-Python mode and the no-LLVM refusal.
upstream-sync closed this pull request 2026-11-25 00:04:50 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1993
No description provided.