[PR #1525] rdna2_decode: decode 16-bit integer inline constants 240..248 as binary16 hex (DECODE-VOP16-INT-INLINE) #1553

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/1525
Author: @jarvixaiassistant-glitch
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/decode-vop16-int-inline


📝 Commits (1)

  • bf0ba2f rdna2_decode: decode 16-bit integer inline constants 240..248 as binary16 hex (DECODE-VOP16-INT-INLINE)

📊 Changes

2 files changed (+172 additions, -7 deletions)

View changed files

📝 tests/test_rdna2_decode.py (+102 -0)
📝 tools/rdna2_decode.py (+70 -7)

📄 Description

Claimed in the coordination issue as: DECODE-VOP16-INT-INLINE

What and why

On RDNA2, inline constant codes 240..248 (0.5, -0.5, 1.0, -1.0, 2.0, -2.0, 4.0, -4.0, 1/(2*pi)) on scalar 16-bit integer operands (LLVM OPERAND_REG_IMM_INT16 / OPERAND_REG_INLINE_C_INT16) deliver the 16-bit binary16 bit patterns (0x3800, 0xB800, 0x3C00, 0xBC00, 0x4000, 0xC000, 0x4400, 0xC400, 0x3118), which LLVM prints as hex integer immediates rather than float literals.

Previously tools/rdna2_decode.py:_src() unconditionally emitted {k: fimm, ...} for codes 240..248 even on 16-bit integer VOP1/VOPC/VOP3 instructions, causing 126 mismatches against LLVM 21.1.8's GFX10 disassembler test vectors and producing wrong 32-bit float bit patterns if translated through --backend python.

This PR:

  1. Adds _INLINE_INT16, _INT16_ALL_SRCS, _INT16_SRC01_ONLY, and _src_is_int16(name, src_idx) in tools/rdna2_decode.py, emitting {k: imm, v: _INLINE_INT16[code]} on 16-bit integer VOP1/VOPC/VOP3 sources while carefully preserving:
    • Mixed-width v_mad_i32_i16 / v_mad_u32_u16 SRC2 (32-bit, stays fimm).
    • v_sat_pk_u8_i16 and VOP3P V2INT16 operands.
    • Hardware-verified SDWA 16-bit ops (ps_sdwa_f16_const.asm), which take 32-bit float bits on RDNA2 and remain fimm.
  2. Adds targeted unit tests + an end-to-end rdna2_decode -> rdna2spirv -> spirv_mini_interp test in tests/test_rdna2_decode.py.

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 disassembler vectors: 126 mismatches -> 0 (including gfx10_vopc.txt 1,438/1,438 exact)

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)

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 ISA decoder inline-constant 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/1525 **Author:** [@jarvixaiassistant-glitch](https://github.com/jarvixaiassistant-glitch) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/decode-vop16-int-inline` --- ### 📝 Commits (1) - [`bf0ba2f`](https://github.com/ubiquitarianism/leonida/commit/bf0ba2f5c5e27c69378e02c30b3bc9bab7ad11ad) rdna2_decode: decode 16-bit integer inline constants 240..248 as binary16 hex (DECODE-VOP16-INT-INLINE) ### 📊 Changes **2 files changed** (+172 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_rdna2_decode.py` (+102 -0) 📝 `tools/rdna2_decode.py` (+70 -7) </details> ### 📄 Description Claimed in the coordination issue as: DECODE-VOP16-INT-INLINE ### What and why On RDNA2, inline constant codes `240..248` (`0.5`, `-0.5`, `1.0`, `-1.0`, `2.0`, `-2.0`, `4.0`, `-4.0`, `1/(2*pi)`) on scalar 16-bit integer operands (LLVM `OPERAND_REG_IMM_INT16` / `OPERAND_REG_INLINE_C_INT16`) deliver the 16-bit binary16 bit patterns (`0x3800`, `0xB800`, `0x3C00`, `0xBC00`, `0x4000`, `0xC000`, `0x4400`, `0xC400`, `0x3118`), which LLVM prints as hex integer immediates rather than float literals. Previously `tools/rdna2_decode.py:_src()` unconditionally emitted `{k: fimm, ...}` for codes `240..248` even on 16-bit integer VOP1/VOPC/VOP3 instructions, causing **126 mismatches** against LLVM 21.1.8's GFX10 disassembler test vectors and producing wrong 32-bit float bit patterns if translated through `--backend python`. This PR: 1. Adds `_INLINE_INT16`, `_INT16_ALL_SRCS`, `_INT16_SRC01_ONLY`, and `_src_is_int16(name, src_idx)` in `tools/rdna2_decode.py`, emitting `{k: imm, v: _INLINE_INT16[code]}` on 16-bit integer VOP1/VOPC/VOP3 sources while carefully preserving: - Mixed-width `v_mad_i32_i16` / `v_mad_u32_u16` `SRC2` (32-bit, stays `fimm`). - `v_sat_pk_u8_i16` and VOP3P `V2INT16` operands. - Hardware-verified `SDWA` 16-bit ops (`ps_sdwa_f16_const.asm`), which take 32-bit float bits on RDNA2 and remain `fimm`. 2. Adds targeted unit tests + an end-to-end `rdna2_decode -> rdna2spirv -> spirv_mini_interp` test in `tests/test_rdna2_decode.py`. ### 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 disassembler vectors: **126 mismatches -> 0** (including `gfx10_vopc.txt` **1,438/1,438 exact**) 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) ### 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 ISA decoder inline-constant 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#1553
No description provided.