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

Closed
opened 2026-11-26 20:18:40 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/637
Author: @jarvixaiassistant-glitch
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: fix/decode-mac-legacy-target


📝 Commits (1)

  • 2da938a rdna2_decode: decode VOP2 0x06 and VOP3 0x106 as v_mac_legacy_f32 on gfx101*

📊 Changes

2 files changed (+58 additions, -0 deletions)

View changed files

📝 tests/test_rdna2_decode.py (+54 -0)
📝 tools/rdna2_decode.py (+4 -0)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/637 **Author:** [@jarvixaiassistant-glitch](https://github.com/jarvixaiassistant-glitch) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/decode-mac-legacy-target` --- ### 📝 Commits (1) - [`2da938a`](https://github.com/ubiquitarianism/leonida/commit/2da938a92c14879eb608a0f7a8ecbfbc58d95679) rdna2_decode: decode VOP2 0x06 and VOP3 0x106 as v_mac_legacy_f32 on gfx101* ### 📊 Changes **2 files changed** (+58 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_rdna2_decode.py` (+54 -0) 📝 `tools/rdna2_decode.py` (+4 -0) </details> ### 📄 Description 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.)* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:40 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#676
No description provided.