rdna2_decode: decode VOP2 0x06 and VOP3 0x106 as v_mac_legacy_f32 on gfx101* (DECODE-MAC-LEGACY-TARGET) #637

Manually merged
github merged 1 commit from gh-pr/637/head into gh-pr/637/base 2026-11-26 09:13:07 +00:00
Owner

@⁠jarvixaiassistant-glitch on GitHub · 2026-11-24 10:40 UTC · original
jarvixaiassistant-glitch:fix/decode-mac-legacy-target → main · +58 −0 · 2 files · 1 commits · merged 2026-11-25 21:22 UTC

Claimed in the coordination issue as: DECODE-MAC-LEGACY-TARGET

What and why

tools/rdna2_decode.py already maps VOP3 0x140 to v_mad_legacy_f32 on gfx101* and v_fma_legacy_f32 on gfx103*, but left VOP2 0x06 and VOP3 0x106 unconditionally mapped to v_fmac_legacy_f32 even for the default mcpu="gfx1013" console target.

Per docs/design.md (GFX10.1/GFX10.3 opcode differences) and LLVM 21 VOP2Instructions.td:

  • On gfx101* (including console gfx1013), VOP2 0x06 and VOP3 0x106 are v_mac_legacy_f32 (_e32 / _e64), which tools/rdna2spirv.py translates.
  • On gfx103* (gfx1030/gfx1036), the same encodings are the fused v_fmac_legacy_f32, which tools/rdna2spirv.py intentionally rejects with Unsupported("v_fmac_legacy_f32").

Because tools/rdna2_decode.py emitted v_fmac_legacy_f32_e32 / v_fmac_legacy_f32_e64 on gfx1013, translating any console shader containing VOP2 0x06 or VOP3 0x106 through shader_disasm.py --backend python failed loudly with Unsupported: v_fmac_legacy_f32.

This PR:

  1. Renames VOP2 0x06 and VOP3 0x106 to v_mac_legacy_f32 when mcpu.startswith("gfx101"), keeping v_fmac_legacy_f32 for gfx103* (mirroring VOP3 0x140).
  2. Adds test_vop2_and_vop3_legacy_mac_fmac_target_and_roundtrip in tests/test_rdna2_decode.py verifying both VOP2 0x06 and VOP3 0x106 across gfx1013 and gfx1030, plus an end-to-end binary → shader_disasm.disasm(..., backend="python") → rdna2spirv.translate → spirv_mini_interp test (2.0 * 2.0 + 4.0 = 8.0).

Tested

All synthetic CPU/stdlib/docs/CI checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files, no llvm-mc installed locally):

  • Before fix: end-to-end gfx1013 binary with VOP2 0x06 decoded as v_fmac_legacy_f32_e32 and raised Unsupported: v_fmac_legacy_f32 in rdna2spirv.translate().
  • After fix:
    • python -I tests/test_rdna2_decode.py -v — 20/20 passed (1 skipped: llvm-mc not installed)
    • Cross-check against upstream LLVM GFX10 disassembler test vectors:
      • gfx10_vop2.txt: 725/725 PASS (was 707/725, 18 mismatches)
      • gfx10_vop3.txt: 6,209/6,209 PASS (was 6,171/6,209, 38 mismatches)
      • Total: 6,934/6,934 PASS (56 mismatches → 0 mismatches)
    • python -I tests/test_ci_registration.py — 15/15 passed
    • python -I tests/test_runtime_paths.py — 5/5 passed
    • python -I scripts/check_no_game_data.py — passed (0 forbidden tracked extensions)
    • python -m compileall -q make_game.py tools tests — passed
    • python -I tests/test_text_write_line_endings.py, tests/test_report_paths.py, tests/test_i18n_index.py, and all tests/test_docs_*.py — passed
    • node --test tests/test_viewer_streaming.cjs — passed

GPUs tested: n/a (pure-Python ISA binary decoder + CPU SPIR-V interpreter round-trip only)

AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek V4 Flash + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B)

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 — binary ISA decoder target-mnemonic parity with existing docs/design.md contract row; no translator rule changed.)
**@⁠jarvixaiassistant-glitch** on GitHub · 2026-11-24 10:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/637) `jarvixaiassistant-glitch:fix/decode-mac-legacy-target` → `main` · +58 −0 · 2 files · 1 commits · merged 2026-11-25 21:22 UTC Claimed in the coordination issue as: DECODE-MAC-LEGACY-TARGET ### What and why `tools/rdna2_decode.py` already maps VOP3 `0x140` to `v_mad_legacy_f32` on `gfx101*` and `v_fma_legacy_f32` on `gfx103*`, but left VOP2 `0x06` and VOP3 `0x106` unconditionally mapped to `v_fmac_legacy_f32` even for the default `mcpu="gfx1013"` console target. Per `docs/design.md` (GFX10.1/GFX10.3 opcode differences) and LLVM 21 `VOP2Instructions.td`: - On `gfx101*` (including console `gfx1013`), VOP2 `0x06` and VOP3 `0x106` are **`v_mac_legacy_f32`** (`_e32` / `_e64`), which `tools/rdna2spirv.py` translates. - On `gfx103*` (`gfx1030`/`gfx1036`), the same encodings are the fused **`v_fmac_legacy_f32`**, which `tools/rdna2spirv.py` intentionally rejects with `Unsupported("v_fmac_legacy_f32")`. Because `tools/rdna2_decode.py` emitted `v_fmac_legacy_f32_e32` / `v_fmac_legacy_f32_e64` on `gfx1013`, translating any console shader containing VOP2 `0x06` or VOP3 `0x106` through `shader_disasm.py --backend python` failed loudly with `Unsupported: v_fmac_legacy_f32`. This PR: 1. Renames VOP2 `0x06` and VOP3 `0x106` to `v_mac_legacy_f32` when `mcpu.startswith("gfx101")`, keeping `v_fmac_legacy_f32` for `gfx103*` (mirroring VOP3 `0x140`). 2. Adds `test_vop2_and_vop3_legacy_mac_fmac_target_and_roundtrip` in `tests/test_rdna2_decode.py` verifying both VOP2 `0x06` and VOP3 `0x106` across `gfx1013` and `gfx1030`, plus an end-to-end binary → `shader_disasm.disasm(..., backend="python")` → `rdna2spirv.translate` → `spirv_mini_interp` test (`2.0 * 2.0 + 4.0 = 8.0`). ### Tested All synthetic CPU/stdlib/docs/CI checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files, no `llvm-mc` installed locally): - Before fix: end-to-end `gfx1013` binary with VOP2 `0x06` decoded as `v_fmac_legacy_f32_e32` and raised `Unsupported: v_fmac_legacy_f32` in `rdna2spirv.translate()`. - After fix: - `python -I tests/test_rdna2_decode.py -v` — 20/20 passed (1 skipped: `llvm-mc` not installed) - Cross-check against upstream LLVM GFX10 disassembler test vectors: - `gfx10_vop2.txt`: 725/725 PASS (was 707/725, 18 mismatches) - `gfx10_vop3.txt`: 6,209/6,209 PASS (was 6,171/6,209, 38 mismatches) - **Total: 6,934/6,934 PASS (56 mismatches → 0 mismatches)** - `python -I tests/test_ci_registration.py` — 15/15 passed - `python -I tests/test_runtime_paths.py` — 5/5 passed - `python -I scripts/check_no_game_data.py` — passed (0 forbidden tracked extensions) - `python -m compileall -q make_game.py tools tests` — passed - `python -I tests/test_text_write_line_endings.py`, `tests/test_report_paths.py`, `tests/test_i18n_index.py`, and all `tests/test_docs_*.py` — passed - `node --test tests/test_viewer_streaming.cjs` — passed GPUs tested: n/a (pure-Python ISA binary decoder + CPU SPIR-V interpreter round-trip only) AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek V4 Flash + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B) ### 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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. *(N/A — binary ISA decoder target-mnemonic parity with existing `docs/design.md` contract row; no translator rule changed.)*
tools/rdna2_decode.py already renamed VOP3 0x140 from v_fma_legacy_f32 to
v_mad_legacy_f32 when mcpu starts with gfx101, but left VOP2 0x06 and VOP3
0x106 unconditionally named v_fmac_legacy_f32 even for the default gfx1013
console target.

Per LLVM 21 VOP2Instructions.td and docs/design.md, VOP2 0x06 and VOP3 0x106
are v_mac_legacy_f32 on gfx101* (translated by rdna2spirv.py) and
v_fmac_legacy_f32 on gfx103* (intentionally rejected as Unsupported).
Decoding them as v_fmac_legacy_f32 on gfx1013 broke end-to-end python
disassembly -> rdna2spirv translation and caused 56 mismatches across LLVM's
gfx10_vop2.txt (18) and gfx10_vop3.txt (38).

Rename VOP2 0x06 and VOP3 0x106 to v_mac_legacy_f32 on gfx101* and add unit
plus end-to-end gfx1013 (translates and evaluates to 8.0) and gfx1030
(rejected as Unsupported) tests in tests/test_rdna2_decode.py.

AI-assisted: yes (JARVIX: Antigravity + DeepSeek V4 Flash + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:13:04 +00:00
github manually merged commit 2da938a92c into gh-pr/637/base 2026-11-26 09:13:07 +00:00
Author
Owner

@⁠qhukz13 on GitHub · 2026-11-24 11:50 UTC · original · reviewed

Reviewed on head 2da938a92 (Linux, no GPU, no llvm-mc: CPU only). Merges cleanly with current main (21625bca8).

Checked:

  • The renames match the GFX10.1 / GFX10.3 opcode-differences row in docs/design.md: on gfx1013 VOP2 0x06 and VOP3 0x106 are v_mac_legacy_f32, on gfx103x the fused v_fmac_legacy_f32. Same shape as the existing VOP3 0x140 rename; the _e64 suffix for 0x106 is already forced at line 954, and rdna2spirv translates v_mac_legacy_f32 with the destination as the addend.
  • Pass: tests/test_rdna2_decode.py (1 skipped, no llvm-mc), tests/test_shader_disasm.py.
  • Four hand-written mutations of tools/rdna2_decode.py, run on a full copy of the checkout, all caught: removing the VOP2 rename (1 failure, 1 error), removing the VOP3 rename (1 failure), and widening either rename to startswith("gfx10") (2 and 1 failures; the gfx1030 subtests catch them).

Not checked here: the LLVM disassembler test-vector counts in the description, and how the DPP/SDWA forms of VOP2 0x06 print on gfx101* (the rename also applies to them); both need llvm-mc.

Side note, not for this PR: tests/test_rdna2_decode.py always imports from the repository's tools/ and ignores LEONIDA_TOOLS_DIR, unlike the tests/semantic files, so a mutation run that points LEONIDA_TOOLS_DIR at a mutated copy reports every mutant as surviving for this file.

Looks good to me.

**@⁠qhukz13** on GitHub · 2026-11-24 11:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/637#pullrequestreview-6038671476) · **reviewed** Reviewed on head 2da938a92 (Linux, no GPU, no llvm-mc: CPU only). Merges cleanly with current `main` (21625bca8). Checked: - The renames match the GFX10.1 / GFX10.3 opcode-differences row in `docs/design.md`: on gfx1013 VOP2 0x06 and VOP3 0x106 are `v_mac_legacy_f32`, on gfx103x the fused `v_fmac_legacy_f32`. Same shape as the existing VOP3 0x140 rename; the `_e64` suffix for 0x106 is already forced at line 954, and `rdna2spirv` translates `v_mac_legacy_f32` with the destination as the addend. - Pass: `tests/test_rdna2_decode.py` (1 skipped, no llvm-mc), `tests/test_shader_disasm.py`. - Four hand-written mutations of `tools/rdna2_decode.py`, run on a full copy of the checkout, all caught: removing the VOP2 rename (1 failure, 1 error), removing the VOP3 rename (1 failure), and widening either rename to `startswith("gfx10")` (2 and 1 failures; the gfx1030 subtests catch them). Not checked here: the LLVM disassembler test-vector counts in the description, and how the DPP/SDWA forms of VOP2 0x06 print on gfx101* (the rename also applies to them); both need llvm-mc. Side note, not for this PR: `tests/test_rdna2_decode.py` always imports from the repository's `tools/` and ignores `LEONIDA_TOOLS_DIR`, unlike the `tests/semantic` files, so a mutation run that points `LEONIDA_TOOLS_DIR` at a mutated copy reports every mutant as surviving for this file. Looks good to me.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 21:22 UTC · original

Merged, thanks! The new test fails on main and passes with this. Together with #633 (same file), the translator suite passes.

  • Checked on main 2bfcb4fe7 + 2da938a92: the semantic suite passes (491 files, 6,312 tests, 0 files failed); test_rdna2_decode pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

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

**@⁠aslan2142** on GitHub · 2026-11-25 21:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/637#issuecomment-7174982509) Merged, thanks! The new test fails on `main` and passes with this. Together with #633 (same file), the translator suite passes. - **Checked on `main` `2bfcb4fe7` + `2da938a92`:** the semantic suite passes (491 files, 6,312 tests, 0 files failed); `test_rdna2_decode` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.