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

Merged
jarvixaiassistant-glitch merged 1 commit from upstream-pr/637 into main 2026-11-25 21:22:04 +00:00
jarvixaiassistant-glitch commented 2026-11-24 10:40:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by jarvixaiassistant-glitch on 2026-11-24T10:40:31Z.


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.)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5470580468 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/637). Originally posted by [jarvixaiassistant-glitch](https://github.com/jarvixaiassistant-glitch) on 2026-11-24T10:40:31Z. --- 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.)*
qhukz13 commented 2026-11-24 11:50:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-24T11:50:58Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6038671476 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/637#pullrequestreview-6038671476). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-24T11:50:58Z. **Review:** COMMENTED --- 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.
aslan2142 commented 2026-11-25 21:22:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T21:22:07Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7174982509 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/637#issuecomment-7174982509). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T21:22:07Z. --- 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).
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
ProjectLeonida/mandy!637
No description provided.