rdna2_decode: permlane16 op_sel and exp null match llvm-mc and shader_ir (DECODE-LLVM-PARITY) #556

Manually merged
github merged 1 commit from gh-pr/556/head into gh-pr/556/base 2026-11-26 09:08:21 +00:00
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-24 08:00 UTC · original
quartz-heron-58:decode-permlane-opsel → main · +43 −2 · 2 files · 1 commits · merged 2026-11-24 08:54 UTC

Claimed in the coordination issue as: DECODE-LLVM-PARITY (#14)

What and why

tests/test_rdna2_decode.py test_parity_with_llvm_mc_on_shader_fixtures compares rdna2_decode.decode_bytes with llvm-mc over every runtime/test/shaders/*.asm. On main 1c93c869 with llvm-mc 21.1.8 it fails. It is red in CI on main as well: fiestorra found the same assertion in main's own stdlib-tests-linux job (run 45320704311, head ece4ba5b3; finding in #14), and that run's check and macos-python jobs are failures too.

Correction (edited): this description first said CI skips the test because those jobs have no llvm-mc. That was wrong, a conclusion I drew from reading ci.yml without looking at a run.

Two decoder mismatches, the second hidden behind the first:

  1. v_permlane16_b32 / v_permlanex16_b32 (cs_w32_permlane_fi.asm). These use op_sel bits 0 and 1 as FI and BOUND_CTRL. llvm-mc prints op_sel:[FI,BOUND_CTRL], and nothing when both are 0, whatever bits 2 and 3 hold. The decoder printed the generic [s0,s1,s2,dst] list, e.g. op_sel:[0,1,0,0] for op_sel:[0,1].
  2. exp null (ps_w64_a_discard.asm). shader_ir.parse_line reads the null export target as the special register (core not in ("null",) in its target rule). decode_bytes gave {"k": "target", "t": "null"}, so a decoded exp null did not equal its own printed line parsed back. It now gives the special register for null and a target for every other name.

No translator output changes that I can find: Gen.opsel_bits(mods, 2) reads the first two values either way, and the python disassembly backend goes through disasm_bytes text and shader_ir.parse_line. No contract-table row: no translation rule changes.

Tested

Windows 11 Home build 26300, Python 3.12.10, llvm-mc 21.1.8 (built by scripts\build_llvm_mc.ps1), SPIRV-Tools v2026.4. No game files.

  • python -I tests/test_rdna2_decode.py with LLVM_MC set: 19 tests OK (17 on main, 1 failing). Without LLVM_MC and with no llvm-mc on PATH: 19 OK, 1 skipped.
  • New test_permlane16_opsel_is_the_fi_bound_ctrl_pair: ten op_sel values for each of the two ops, hand-assembled words. Fails on main's decoder. Each expectation was also compared with llvm-mc -disassemble -mcpu=gfx1013 by hand: 20 of 20 equal.
  • New test_exp_null_target_matches_the_parsed_line: exp null and exp mrt0 words from llvm-mc's own encoding.
  • The 22 other standalone test files that import rdna2_decode or shader_disasm: all OK.
  • python -I scripts/run_semantic_tests.py tests/semantic: 465 files, 6107 tests, 1 file failed, test_image_cube_store_glc (FileNotFoundError in its llvm-mc round trip). It fails the same way on main without this change; #419 covers it.
  • python -m compileall -q make_game.py tools tests: exit 0. scripts/check_no_game_data.py on both files: exit 0.
  • Not tested: an llvm-mc other than 21.1.8. The parity check was not run against the llvm-mc the Linux CI job uses.

GPUs tested: n/a

AI-assisted: yes (Claude Code found the failure, wrote the change and ran the tests)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator rule)

🤖 Generated with Claude Code

**@⁠quartz-heron-58** on GitHub · 2026-11-24 08:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/556) `quartz-heron-58:decode-permlane-opsel` → `main` · +43 −2 · 2 files · 1 commits · merged 2026-11-24 08:54 UTC Claimed in the coordination issue as: DECODE-LLVM-PARITY (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why `tests/test_rdna2_decode.py` `test_parity_with_llvm_mc_on_shader_fixtures` compares `rdna2_decode.decode_bytes` with llvm-mc over every `runtime/test/shaders/*.asm`. On main 1c93c869 with llvm-mc 21.1.8 it fails. It is red in CI on main as well: `fiestorra` found the same assertion in main's own `stdlib-tests-linux` job (run 45320704311, head ece4ba5b3; [finding in #14](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)), and that run's `check` and `macos-python` jobs are failures too. *Correction (edited): this description first said CI skips the test because those jobs have no llvm-mc. That was wrong, a conclusion I drew from reading `ci.yml` without looking at a run.* Two decoder mismatches, the second hidden behind the first: 1. **`v_permlane16_b32` / `v_permlanex16_b32`** (`cs_w32_permlane_fi.asm`). These use `op_sel` bits 0 and 1 as FI and BOUND_CTRL. llvm-mc prints `op_sel:[FI,BOUND_CTRL]`, and nothing when both are 0, whatever bits 2 and 3 hold. The decoder printed the generic `[s0,s1,s2,dst]` list, e.g. `op_sel:[0,1,0,0]` for `op_sel:[0,1]`. 2. **`exp null`** (`ps_w64_a_discard.asm`). `shader_ir.parse_line` reads the `null` export target as the special register (`core not in ("null",)` in its target rule). `decode_bytes` gave `{"k": "target", "t": "null"}`, so a decoded `exp null` did not equal its own printed line parsed back. It now gives the special register for `null` and a target for every other name. No translator output changes that I can find: `Gen.opsel_bits(mods, 2)` reads the first two values either way, and the `python` disassembly backend goes through `disasm_bytes` text and `shader_ir.parse_line`. No contract-table row: no translation rule changes. ### Tested Windows 11 Home build 26300, Python 3.12.10, llvm-mc 21.1.8 (built by `scripts\build_llvm_mc.ps1`), SPIRV-Tools v2026.4. No game files. - `python -I tests/test_rdna2_decode.py` with `LLVM_MC` set: 19 tests OK (17 on main, 1 failing). Without `LLVM_MC` and with no llvm-mc on PATH: 19 OK, 1 skipped. - New `test_permlane16_opsel_is_the_fi_bound_ctrl_pair`: ten `op_sel` values for each of the two ops, hand-assembled words. Fails on main's decoder. Each expectation was also compared with `llvm-mc -disassemble -mcpu=gfx1013` by hand: 20 of 20 equal. - New `test_exp_null_target_matches_the_parsed_line`: `exp null` and `exp mrt0` words from llvm-mc's own encoding. - The 22 other standalone test files that import `rdna2_decode` or `shader_disasm`: all OK. - `python -I scripts/run_semantic_tests.py tests/semantic`: 465 files, 6107 tests, 1 file failed, `test_image_cube_store_glc` (`FileNotFoundError` in its llvm-mc round trip). It fails the same way on main without this change; #419 covers it. - `python -m compileall -q make_game.py tools tests`: exit 0. `scripts/check_no_game_data.py` on both files: exit 0. - Not tested: an llvm-mc other than 21.1.8. The parity check was not run against the llvm-mc the Linux CI job uses. GPUs tested: n/a AI-assisted: yes (Claude Code found the failure, wrote the change and ran the tests) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
test_parity_with_llvm_mc_on_shader_fixtures fails with llvm-mc 21.1.8
on two fixtures. CI does not see it: the jobs that run this file have
no llvm-mc, so the test skips.

- v_permlane16_b32 and v_permlanex16_b32 use op_sel bits 0 and 1 as FI
  and BOUND_CTRL. llvm-mc prints op_sel:[FI,BOUND_CTRL], and nothing
  when both are 0, whatever bits 2 and 3 hold. The decoder printed the
  generic [s0,s1,s2,dst] list (cs_w32_permlane_fi.asm).
- shader_ir.parse_line reads the `null` export target as the special
  register. decode_bytes gave it as a target, so a decoded `exp null`
  did not equal its own printed line parsed back (ps_w64_a_discard.asm).

Two unit tests pin both with hand-assembled words, so they run without
llvm-mc too.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:08:20 +00:00
github manually merged commit 86da7be469 into gh-pr/556/base 2026-11-26 09:08:21 +00:00
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 08:53 UTC · original

Merging. Why merged: permlane16 op_sel and the exp null target now decode the same way as llvm-mc and shader_ir, fixing main's known decode-parity failure.
Why it's good: rdna2_decode is already a listed translator input; on main 1c93c86 the decode tests go from 16 passed (+1 parity failure with LLVM_MC set) to 18 passed / 0 failed (517 subtests); repo-consistency set 563/563.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 08:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/556#issuecomment-7126701617) Merging. Why merged: permlane16 op_sel and the exp null target now decode the same way as llvm-mc and shader_ir, fixing main's known decode-parity failure. Why it's good: rdna2_decode is already a listed translator input; on main 1c93c86 the decode tests go from 16 passed (+1 parity failure with LLVM_MC set) to 18 passed / 0 failed (517 subtests); repo-consistency set 563/563. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.