[PR #1524] rdna2_decode: align DS single-offset and ds_swizzle_b32 ROTATE/FFT formatting with LLVM (DECODE-DS-PARITY) #1554

Open
opened 2026-11-26 20:21:39 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1524
Author: @jarvixaiassistant-glitch
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/decode-ds-llvm-parity


📝 Commits (1)

  • ee6b6f9 rdna2_decode: align DS single-offset and ds_swizzle_b32 ROTATE/FFT formatting with LLVM

📊 Changes

2 files changed (+54 additions, -3 deletions)

View changed files

📝 tests/test_rdna2_decode.py (+41 -0)
📝 tools/rdna2_decode.py (+13 -3)

📄 Description

Claimed in the coordination issue as: DECODE-DS-PARITY

What and why

Closes all 19 remaining mismatches in tools/rdna2_decode.py against LLVM 21.1.8's gfx10_ds.txt DS disassembler test vectors (bringing DS parity to 1,708/1,708 exact):

  1. ds_condxchg32_rtn_b64 single-offset formatting (6 vectors): _decode_one checked 2_ in name or 2st64_ in name to detect dual-offset DS instructions, which falsely matched 32_ in ds_condxchg32_rtn_b64 and emitted offset0: / offset1: instead of a single 16-bit offset:. Restricted dual-offset detection to name.startswith((ds_read2, ds_write2, ds_wrxchg2)).
  2. ds_swizzle_b32 swizzle formatting (13 vectors): Updated _format_ds_swizzle to match LLVM AMDGPUInstPrinter::printSwizzle:
    • offset16 == 0: omit the offset: modifier entirely (instead of emitting offset:swizzle(BITMASK_PERM,00000)).
    • 0xC000..0xDFFF: emit offset:swizzle(ROTATE,dir,size) where dir = (offset16 >> 10) & 1 and size = (offset16 >> 5) & 0x1F.
    • 0xE000..0xFFFF: emit offset:swizzle(FFT,mask) where mask = offset16 & 0x1F.
  3. Adds targeted unit tests in tests/test_rdna2_decode.py covering ds_condxchg32_rtn_b64 single 16-bit offset, ds_swizzle_b32 zero/ROTATE/FFT/existing bitmask modes, and preservation of ds_read2_b32 / ds_write2st64_b64 dual-offset printing.

Tested

All synthetic CPU/stdlib/docs/CI checks on Windows 11 x64, Python 3.12.14, Khronos SPIRV-Tools (LEONIDA_REQUIRE_SPIRV_TOOLS=1), no game data, no llvm-mc installed locally:

  • python -I tests/test_rdna2_decode.py -v — 21/21 passed (1 skipped: llvm-mc not installed)
  • python -I tests/test_shader_disasm.py — 31/31 passed
  • python -I tests/test_ci_registration.py — 16/16 passed
  • python -I scripts/check_no_game_data.py — passed
  • python -m compileall -q tools/rdna2_decode.py tests/test_rdna2_decode.py — passed
  • Cross-check against LLVM 21.1.8 gfx10_ds.txt vectors: 1,708/1,708 exact (was 19 mismatches)

GPUs tested: n/a (pure-Python ISA binary decoder 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 (1cfc29af7) and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A — pure-Python DS disassembler formatting parity with LLVM; 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/1524 **Author:** [@jarvixaiassistant-glitch](https://github.com/jarvixaiassistant-glitch) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/decode-ds-llvm-parity` --- ### 📝 Commits (1) - [`ee6b6f9`](https://github.com/ubiquitarianism/leonida/commit/ee6b6f9b050d778d5aeb00fe238526acb7e015d8) rdna2_decode: align DS single-offset and ds_swizzle_b32 ROTATE/FFT formatting with LLVM ### 📊 Changes **2 files changed** (+54 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_rdna2_decode.py` (+41 -0) 📝 `tools/rdna2_decode.py` (+13 -3) </details> ### 📄 Description Claimed in the coordination issue as: DECODE-DS-PARITY ### What and why Closes all 19 remaining mismatches in `tools/rdna2_decode.py` against LLVM 21.1.8's `gfx10_ds.txt` DS disassembler test vectors (bringing DS parity to **1,708/1,708 exact**): 1. **`ds_condxchg32_rtn_b64` single-offset formatting (6 vectors):** `_decode_one` checked `2_ in name or 2st64_ in name` to detect dual-offset DS instructions, which falsely matched `32_` in `ds_condxchg32_rtn_b64` and emitted `offset0:` / `offset1:` instead of a single 16-bit `offset:`. Restricted dual-offset detection to `name.startswith((ds_read2, ds_write2, ds_wrxchg2))`. 2. **`ds_swizzle_b32` swizzle formatting (13 vectors):** Updated `_format_ds_swizzle` to match LLVM `AMDGPUInstPrinter::printSwizzle`: - `offset16 == 0`: omit the `offset:` modifier entirely (instead of emitting `offset:swizzle(BITMASK_PERM,00000)`). - `0xC000..0xDFFF`: emit `offset:swizzle(ROTATE,dir,size)` where `dir = (offset16 >> 10) & 1` and `size = (offset16 >> 5) & 0x1F`. - `0xE000..0xFFFF`: emit `offset:swizzle(FFT,mask)` where `mask = offset16 & 0x1F`. 3. Adds targeted unit tests in `tests/test_rdna2_decode.py` covering `ds_condxchg32_rtn_b64` single 16-bit offset, `ds_swizzle_b32` zero/ROTATE/FFT/existing bitmask modes, and preservation of `ds_read2_b32` / `ds_write2st64_b64` dual-offset printing. ### Tested All synthetic CPU/stdlib/docs/CI checks on Windows 11 x64, Python 3.12.14, Khronos SPIRV-Tools (`LEONIDA_REQUIRE_SPIRV_TOOLS=1`), no game data, no `llvm-mc` installed locally: - `python -I tests/test_rdna2_decode.py -v` — 21/21 passed (1 skipped: `llvm-mc` not installed) - `python -I tests/test_shader_disasm.py` — 31/31 passed - `python -I tests/test_ci_registration.py` — 16/16 passed - `python -I scripts/check_no_game_data.py` — passed - `python -m compileall -q tools/rdna2_decode.py tests/test_rdna2_decode.py` — passed - Cross-check against LLVM 21.1.8 `gfx10_ds.txt` vectors: **1,708/1,708 exact** (was 19 mismatches) GPUs tested: n/a (pure-Python ISA binary decoder 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` (`1cfc29af7`) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md). - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. *(N/A — pure-Python DS disassembler formatting parity with LLVM; no translator rule changed.)* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1554
No description provided.