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

Open
github-bot wants to merge 1 commit from github-bot/gh-1524 into main AGit
Owner

@⁠jarvixaiassistant-glitch on GitHub · 2026-11-25 03:25 UTC · original
jarvixaiassistant-glitch:fix/decode-ds-llvm-parity → main · +54 −3 · 2 files · 1 commits · open

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.)
**@⁠jarvixaiassistant-glitch** on GitHub · 2026-11-25 03:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1524) `jarvixaiassistant-glitch:fix/decode-ds-llvm-parity` → `main` · +54 −3 · 2 files · 1 commits · open 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.)*
Fixes all 19 remaining mismatches against LLVM 21.1.8 gfx10_ds.txt (1,708/1,708
decoded vectors exact):
- ds_condxchg32_rtn_b64 (6 vectors): checking '2_ in name' falsely matched
  '32_', printing offset0/offset1 instead of a single 16-bit offset. Restrict
  2-address detection to ds_read2 / ds_write2 / ds_wrxchg2 prefixes.
- ds_swizzle_b32 (13 vectors): match LLVM AMDGPUInstPrinter::printSwizzle by
  omitting offset: when offset16 == 0, printing offset:swizzle(ROTATE,dir,size)
  for 0xC000..0xDFFF, and printing offset:swizzle(FFT,mask) for 0xE000..0xFFFF.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:55:19 +00:00
Author
Owner

@⁠ytsodacan on GitHub · 2026-11-25 03:34 UTC · original · edited 2026-11-25 03:45 UTC

[KEEP]

  • Change looks correct and tightly scoped: tools/rdna2_decode.py narrows dual-offset detection to ds_read2/ds_write2/ds_wrxchg2 (fixing the 32_ false match on ds_condxchg32_rtn_b64) and _format_ds_swizzle gains the zero/ROTATE/FFT cases, with targeted tests in tests/test_rdna2_decode.py.
  • Checks (windows, macos, linux-gpu-tools, no-game-data, change-scope) were all still pending when triaged; merge once they report green.
  • Other open PRs also edit tools/rdna2_decode.py (#633, #637, #1525), so a rebase may be needed depending on merge order; no conflicts are reported right now.
  • The 1,708/1,708 LLVM parity claim could not be verified from the diff since llvm-mc was not available to the author.
**@⁠ytsodacan** on GitHub · 2026-11-25 03:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1524#issuecomment-7152033514) · edited 2026-11-25 03:45 UTC **[KEEP]** - Change looks correct and tightly scoped: `tools/rdna2_decode.py` narrows dual-offset detection to `ds_read2/ds_write2/ds_wrxchg2` (fixing the `32_` false match on `ds_condxchg32_rtn_b64`) and `_format_ds_swizzle` gains the zero/ROTATE/FFT cases, with targeted tests in `tests/test_rdna2_decode.py`. - Checks (windows, macos, linux-gpu-tools, no-game-data, change-scope) were all still pending when triaged; merge once they report green. - Other open PRs also edit `tools/rdna2_decode.py` (#633, #637, #1525), so a rebase may be needed depending on merge order; no conflicts are reported right now. - The 1,708/1,708 LLVM parity claim could not be verified from the diff since `llvm-mc` was not available to the author.
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 03:52 UTC · original · approved these changes

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Checked against LLVM's ds_swizzle encoding: FFT is 0xE000 | n, ROTATE is 0xC000 | dir << 10 | size << 5, and offset 0 prints nothing; the two-address test now matches ds_read2/ds_write2/ds_wrxchg2 by prefix instead of any "2_" in the name.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 03:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1524#pullrequestreview-6051613378) · **approved these changes** Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Checked against LLVM's ds_swizzle encoding: FFT is 0xE000 | n, ROTATE is 0xC000 | dir << 10 | size << 5, and offset 0 prints nothing; the two-address test now matches ds_read2/ds_write2/ds_wrxchg2 by prefix instead of any "2_" in the name. AI-assisted (Claude).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1524/head:github-bot/gh-1524'
git switch 'github-bot/gh-1524'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1524'
git switch 'github-bot/gh-1524'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1524'
git switch 'github-bot/gh-1524'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1524'
git switch 'main'
git merge --squash 'github-bot/gh-1524'
git switch 'main'
git merge --ff-only 'github-bot/gh-1524'
git switch 'main'
git merge 'github-bot/gh-1524'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.