tooling: refuse VOPC SDWA scalar codes 209-234 in disasm_rdna2 #1028

Manually merged
github merged 1 commit from gh-pr/1028/head into gh-pr/1028/base 2026-11-26 22:36:06 +00:00
Owner

@⁠MasterDomino on GitHub · 2026-11-23 22:09 UTC · original
MasterDomino:tooling/disasm-sdwa-scalar-subset → main · +81 −0 · 2 files · 1 commits · merged 2026-11-23 22:27 UTC

Refs #938

Summary

The GFX10 VOPC/VOPCX SDWA decoder added in #980 refused only scalar source codes 249, 250 and 255. For codes 209-234 decode_s_reg fell back to s{n}, so records such as f904007cd1008606 printed v_cmp_f_f32_sdwa vcc_lo, s209, v2 ..., which names no register. LLVM 15.0.7 refuses every such record. The #938 sweep found 20,129 of them across all 124 VOPC SDWA opcodes, as src0 and as src1, with and without input modifiers.

This change refuses those records as 8-byte vopc_sdwa records with the comment VOPC SDWA scalar operand outside the supported LLVM 15 decoder subset. The range is labelled as the supported LLVM 15 decoder subset, as requested, and not as an ISA claim. The record length and the next offset do not change, and the following instruction still decodes at offset 8. Codes 208 (-16) and 235 (src_shared_base) still decode.

Files: tools/disasm_rdna2.py (+8), tests/rdna2_tools_check.py (+73).

Tests

New tests are in tests/rdna2_tools_check.py, which is already registered in CMake and both CI jobs:

  • test_vopc_sdwa_scalar_codes_outside_llvm15_subset decodes six accepted boundary records followed by v_mov_b32_e32 v3, v4 (0403067e). They cover codes 208 and 235, src0 and src1, VOPC with vcc_lo and s6, and VOPCX. The bytes come from llvm-mc 15.0.7 (-triple=amdgcn--amdpal -mcpu=gfx1013 -mattr=+wavefrontsize32). The test checks (offset, length, opcode, text) for both records. It then checks six refused records with the same layout (codes 209 and 234, src0 and src1, f32, u32 and VOPCX): vopc_sdwa at offset 0 with length 8 and the new comment, and v_mov_b32_e32 v3, v4 at offset 8. Finally it loops over every code from 209 to 234 as src0 and as src1, with and without neg. No assembler spelling exists for these codes, so those records are built from the accepted ones.
  • test_vopc_sdwa_scalar_subset_matches_llvm runs only when LLVM_LIB is set. LLVM 15 must decode the accepted records with the same text and next offset, and must refuse each refused record at byte 0.
# LLVM_LIB="C:\Program Files\LLVM\bin\LLVM-C.dll", LLVM_MC / LLVM_OBJCOPY = LLVM 15.0.7 llvm-mc / llvm-objcopy
python -B tests/rdna2_tools_check.py      -> Ran 92 tests ... OK
python -B tests/rdna2_tools_check.py      (no LLVM env) -> Ran 92 tests ... OK (skipped=6)
python -B tests/shader_census_check.py    -> exit 0
python -B tests/shader_probe_check.py     -> exit 0
python -B tests/form_coverage_check.py    -> exit 0 ("form coverage checks passed")
python -B tests/docs_links_check.py       -> exit 0 ("Checked 13 Markdown files and 221 links.")

Environment: Windows 11, Python 3.13.1, LLVM 15.0.7 (LLVM-C.dll, llvm-mc, llvm-objcopy), commit b2fa797 on upstream/main 64ecc87 (measured at 09e21a4 on cd87907; tools/disasm_rdna2.py and its tests are unchanged between the two bases, and rdna2_tools_check, shader_census_check, form_coverage_check and docs_links_check were rerun after the rebase).

Sweep before and after

I ran the independent #938 sweep script (sweep_980.py: 869,888 VOPC SDWA records, each followed by v_mov_b32_e32 v3, v4; s_endpgm, all compared against LLVM 15.0.7) on this commit. Each record is compared with the original #938 run:

category before after
llvm_refuses_disasm_decodes 20,129 0
both_refuse 636,138 656,267
both_decode_match 200,243 200,243
text_mismatch (neg on inline constant, i16/u16 spelling; separate changes) 13,006 13,006
llvm_fault (LLVM 15 selector-7 crash) 372 372
total deltas 33,135 13,006

All 20,129 records moved from llvm_refuses_disasm_decodes to both_refuse. No other record changed category or decoder text. Truncated-tail checks: 0 unexpected. Scanner mismatches: 0. The sweep's three in-memory negative controls still report their injected defects with 0 deltas outside the expected scope. Before this change, 3,329 distinct s209..s234 decoder texts passed the scanner's per-line check and then failed pixel_aot.lower with KeyError. After it, none do.

Negative control

I reverted tools/disasm_rdna2.py to upstream/main and kept the new tests. test_vopc_sdwa_scalar_codes_outside_llvm15_subset then fails:

AssertionError: Lists differ: [(0, 8, 'v_cmp_lt_f32_sdwa'), (8, 4, 'v_mov_b32_e32')] != [(0, 8, 'vopc_sdwa'), (8, 4, 'v_mov_b32_e32')]
 : f904027cd1008606

The LLVM-gated test still passes, because it checks LLVM rather than the decoder. With the change restored, both tests pass.

Limits

  • The refusal records LLVM 15.0.7's decoder behaviour. It does not claim what the hardware does with these codes.
  • Only the VOPC SDWA path changes. decode_s_reg still prints s{n} for 209-234 elsewhere, for example in VOP3. Those paths were not swept here.
  • The existing tests needed no changes. The branch merges cleanly with the companion neg(c) branch (git merge-tree).

AI-assisted.

🤖 Generated with Claude Code

**@⁠MasterDomino** on GitHub · 2026-11-23 22:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1028) `MasterDomino:tooling/disasm-sdwa-scalar-subset` → `main` · +81 −0 · 2 files · 1 commits · merged 2026-11-23 22:27 UTC Refs #938 ## Summary The GFX10 VOPC/VOPCX SDWA decoder added in #980 refused only scalar source codes 249, 250 and 255. For codes 209-234 `decode_s_reg` fell back to `s{n}`, so records such as `f904007cd1008606` printed `v_cmp_f_f32_sdwa vcc_lo, s209, v2 ...`, which names no register. LLVM 15.0.7 refuses every such record. The #938 sweep found 20,129 of them across all 124 VOPC SDWA opcodes, as src0 and as src1, with and without input modifiers. This change refuses those records as 8-byte `vopc_sdwa` records with the comment `VOPC SDWA scalar operand outside the supported LLVM 15 decoder subset`. The range is labelled as the supported LLVM 15 decoder subset, as requested, and not as an ISA claim. The record length and the next offset do not change, and the following instruction still decodes at offset 8. Codes 208 (`-16`) and 235 (`src_shared_base`) still decode. Files: `tools/disasm_rdna2.py` (+8), `tests/rdna2_tools_check.py` (+73). ## Tests New tests are in `tests/rdna2_tools_check.py`, which is already registered in CMake and both CI jobs: - `test_vopc_sdwa_scalar_codes_outside_llvm15_subset` decodes six accepted boundary records followed by `v_mov_b32_e32 v3, v4` (`0403067e`). They cover codes 208 and 235, src0 and src1, VOPC with `vcc_lo` and `s6`, and VOPCX. The bytes come from llvm-mc 15.0.7 (`-triple=amdgcn--amdpal -mcpu=gfx1013 -mattr=+wavefrontsize32`). The test checks `(offset, length, opcode, text)` for both records. It then checks six refused records with the same layout (codes 209 and 234, src0 and src1, f32, u32 and VOPCX): `vopc_sdwa` at offset 0 with length 8 and the new comment, and `v_mov_b32_e32 v3, v4` at offset 8. Finally it loops over every code from 209 to 234 as src0 and as src1, with and without neg. No assembler spelling exists for these codes, so those records are built from the accepted ones. - `test_vopc_sdwa_scalar_subset_matches_llvm` runs only when `LLVM_LIB` is set. LLVM 15 must decode the accepted records with the same text and next offset, and must refuse each refused record at byte 0. ``` # LLVM_LIB="C:\Program Files\LLVM\bin\LLVM-C.dll", LLVM_MC / LLVM_OBJCOPY = LLVM 15.0.7 llvm-mc / llvm-objcopy python -B tests/rdna2_tools_check.py -> Ran 92 tests ... OK python -B tests/rdna2_tools_check.py (no LLVM env) -> Ran 92 tests ... OK (skipped=6) python -B tests/shader_census_check.py -> exit 0 python -B tests/shader_probe_check.py -> exit 0 python -B tests/form_coverage_check.py -> exit 0 ("form coverage checks passed") python -B tests/docs_links_check.py -> exit 0 ("Checked 13 Markdown files and 221 links.") ``` Environment: Windows 11, Python 3.13.1, LLVM 15.0.7 (`LLVM-C.dll`, `llvm-mc`, `llvm-objcopy`), commit `b2fa797` on upstream/main `64ecc87` (measured at `09e21a4` on `cd87907`; `tools/disasm_rdna2.py` and its tests are unchanged between the two bases, and `rdna2_tools_check`, `shader_census_check`, `form_coverage_check` and `docs_links_check` were rerun after the rebase). ## Sweep before and after I ran the independent #938 sweep script (`sweep_980.py`: 869,888 VOPC SDWA records, each followed by `v_mov_b32_e32 v3, v4; s_endpgm`, all compared against LLVM 15.0.7) on this commit. Each record is compared with the original #938 run: | category | before | after | |---|---:|---:| | llvm_refuses_disasm_decodes | 20,129 | **0** | | both_refuse | 636,138 | 656,267 | | both_decode_match | 200,243 | 200,243 | | text_mismatch (neg on inline constant, i16/u16 spelling; separate changes) | 13,006 | 13,006 | | llvm_fault (LLVM 15 selector-7 crash) | 372 | 372 | | total deltas | 33,135 | 13,006 | All 20,129 records moved from `llvm_refuses_disasm_decodes` to `both_refuse`. No other record changed category or decoder text. Truncated-tail checks: 0 unexpected. Scanner mismatches: 0. The sweep's three in-memory negative controls still report their injected defects with 0 deltas outside the expected scope. Before this change, 3,329 distinct `s209`..`s234` decoder texts passed the scanner's per-line check and then failed `pixel_aot.lower` with `KeyError`. After it, none do. ## Negative control I reverted `tools/disasm_rdna2.py` to upstream/main and kept the new tests. `test_vopc_sdwa_scalar_codes_outside_llvm15_subset` then fails: ``` AssertionError: Lists differ: [(0, 8, 'v_cmp_lt_f32_sdwa'), (8, 4, 'v_mov_b32_e32')] != [(0, 8, 'vopc_sdwa'), (8, 4, 'v_mov_b32_e32')] : f904027cd1008606 ``` The LLVM-gated test still passes, because it checks LLVM rather than the decoder. With the change restored, both tests pass. ## Limits - The refusal records LLVM 15.0.7's decoder behaviour. It does not claim what the hardware does with these codes. - Only the VOPC SDWA path changes. `decode_s_reg` still prints `s{n}` for 209-234 elsewhere, for example in VOP3. Those paths were not swept here. - The existing tests needed no changes. The branch merges cleanly with the companion neg(c) branch (`git merge-tree`). AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The VOPC SDWA decoder refused only scalar source codes 249, 250 and 255,
and decode_s_reg printed codes 209-234 as s209..s234, which name no
register. LLVM 15.0.7 refuses every such record: the #938 sweep found
20,129 records across all 124 VOPC SDWA opcodes, as src0 and as src1,
that LLVM refuses and disasm_rdna2 decoded.

Refuse these codes as an 8-byte vopc_sdwa record with the comment
"VOPC SDWA scalar operand outside the supported LLVM 15 decoder subset".
The range is labelled as the supported LLVM 15 decoder subset, not as an
ISA claim. The next record still starts at offset 8.

The new tests decode llvm-mc-assembled boundary records (codes 208 and
235, src0 and src1, VOPC and VOPCX) and refused 209/234 records, each
followed by v_mov_b32_e32 v3, v4, and check the classification and the
next record offset; an LLVM_LIB-gated test checks that LLVM 15 decodes
the boundary records identically and refuses the others at byte 0.

Refs #938

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:36:03 +00:00
github manually merged commit b2fa797310 into gh-pr/1028/base 2026-11-26 22:36:06 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.