[PR #1632] rdna2spirv: support vcc and null destinations on s_getpc_b64 and reject odd pairs #1647

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1632
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: feat/s-getpc-b64-destinations


📝 Commits (2)

  • 3966cb6 rdna2spirv: support vcc, 2-slot slist, and null destinations on s_getpc_b64
  • 39f3139 rdna2spirv: reject odd SGPR pairs on s_getpc_b64 and add dual-disassembler raw-byte test

📊 Changes

5 files changed (+720 additions, -17 deletions)

View changed files

📝 docs/design.md (+1 -0)
➕ tests/semantic/test_s_getpc_destinations.py (+640 -0)
📝 tools/lane_masks.py (+3 -0)
📝 tools/rdna2spirv.py (+66 -13)
📝 tools/wave64_emulate_opt.py (+10 -4)

📄 Description

Item ID: SHADER-GETPC-DESTINATIONS
Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154632603
Addresses the s_getpc_b64 destinations item from https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154337920 and review feedback on odd-aligned pairs ([s105,vcc_lo], s[1:2]).

Summary

  • tools/rdna2spirv.py (s_getpc_b64 lowering): accept even-aligned 2-SGPR pairs (s[0:1]..s[104:105]), vcc (s[106:107] -> %vcc / %vcc_hi), and null (sdst=125, discarded without setting uses_codebase, while still requiring ; encoding: bytes). Keep odd-aligned SGPR pairs (s[1:2], s[105:106]) and slist ([s105,vcc_lo] from raw SDST 105) Unsupported per AMD RDNA 2 ISA §§3.2 and 3.6.3 so both disassembler paths agree in refusing them.
  • tools/rdna2spirv.py (translate wave-size detection): exclude s_getpc_b64, s_setpc_b64, and s_swappc_b64 from code_w64 since PC is 64-bit in wave32 too.
  • tools/rdna2spirv.py (Gen.global_address): accept vcc as a 64-bit saddr (refusing an emulated wave64 lane-mask pointer, matching s_load_*).
  • tools/rdna2spirv.py (fold_far_branches): fold s_getpc_b64..s_setpc_b64 far branches using even-aligned 2-SGPR pairs or vcc (leaving odd pairs unfolded).
  • tools/lane_masks.py: clear wave32 vcc_hi mask state when s_getpc_b64 vcc / s_load_dwordx2 vcc / s_buffer_load_dwordx2 vcc writes raw 64-bit data into vcc.
  • tools/wave64_emulate_opt.py: mark s_getpc_b64 vcc as raw VCC data in mark_vcc_data_moves() and preserve raw-VCC tracking across s_add_u32/s_addc_u32/s_sub_u32/s_subb_u32 updates to vcc_lo/vcc_hi.
  • docs/design.md: document the s_getpc_b64 destination contract row.
  • tests/semantic/test_s_getpc_destinations.py: 12 synthetic semantic tests across wave32, wave64, and --wave64-emulate, including raw-byte regressions covering both tools/rdna2_decode.py and the LLVM + check_printed_encodings path (plus live llvm-mc when installed).

Verification

  • python3 -W error -I tests/semantic/test_s_getpc_destinations.py -v: 12 passed, 0 failed (0.942s).
  • Mutation check against unpatched main (42537e7b6): 14 failed, 25 errors; against prior PR head 3966cb6a1: 17 failed (confirming odd-pair/raw-byte regressions catch the old acceptance).
  • python3 -I scripts/run_semantic_tests.py tests/semantic: 488 files, 6291 tests, 0 files failed (132s).
  • python3 -m pytest tests/test_shader_meta.py tests/test_rdna2_decode.py tests/test_pc_tail_ubo.py -q: 48 passed, 8 skipped, 653 subtests passed.
  • python3 -m compileall -q tools tests, python3 -I tests/test_text_write_line_endings.py, python3 -I scripts/check_no_game_data.py: all pass.
  • Prior GPU check by @ecox982745 on RTX 4090 (NVIDIA 616.64, LLVM 23.1.6) passed s[104:105], vcc, and null in wave32 and emulated wave64.

AI-assisted: yes
GPUs tested: none locally (CPU interpreter + synthetic fixtures only; vcc/null/s[104:105] checked on RTX 4090 by @ecox982745 in review; no game data)


🔄 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/1632 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/s-getpc-b64-destinations` --- ### 📝 Commits (2) - [`3966cb6`](https://github.com/ubiquitarianism/leonida/commit/3966cb6a168bba367320ed198c5a15cf2096760b) rdna2spirv: support vcc, 2-slot slist, and null destinations on s_getpc_b64 - [`39f3139`](https://github.com/ubiquitarianism/leonida/commit/39f3139da1cd1aea4e3709c85b65fb5f20bbcfe6) rdna2spirv: reject odd SGPR pairs on s_getpc_b64 and add dual-disassembler raw-byte test ### 📊 Changes **5 files changed** (+720 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) ➕ `tests/semantic/test_s_getpc_destinations.py` (+640 -0) 📝 `tools/lane_masks.py` (+3 -0) 📝 `tools/rdna2spirv.py` (+66 -13) 📝 `tools/wave64_emulate_opt.py` (+10 -4) </details> ### 📄 Description Item ID: `SHADER-GETPC-DESTINATIONS` Claim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154632603 Addresses the `s_getpc_b64 destinations` item from https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154337920 and review feedback on odd-aligned pairs (`[s105,vcc_lo]`, `s[1:2]`). ## Summary - **`tools/rdna2spirv.py` (`s_getpc_b64` lowering)**: accept even-aligned 2-SGPR pairs (`s[0:1]`..`s[104:105]`), `vcc` (`s[106:107]` -> `%vcc` / `%vcc_hi`), and `null` (`sdst=125`, discarded without setting `uses_codebase`, while still requiring `; encoding:` bytes). Keep odd-aligned SGPR pairs (`s[1:2]`, `s[105:106]`) and `slist` (`[s105,vcc_lo]` from raw SDST 105) `Unsupported` per AMD RDNA 2 ISA §§3.2 and 3.6.3 so both disassembler paths agree in refusing them. - **`tools/rdna2spirv.py` (`translate` wave-size detection)**: exclude `s_getpc_b64`, `s_setpc_b64`, and `s_swappc_b64` from `code_w64` since PC is 64-bit in wave32 too. - **`tools/rdna2spirv.py` (`Gen.global_address`)**: accept `vcc` as a 64-bit `saddr` (refusing an emulated wave64 lane-mask pointer, matching `s_load_*`). - **`tools/rdna2spirv.py` (`fold_far_branches`)**: fold `s_getpc_b64`..`s_setpc_b64` far branches using even-aligned 2-SGPR pairs or `vcc` (leaving odd pairs unfolded). - **`tools/lane_masks.py`**: clear wave32 `vcc_hi` mask state when `s_getpc_b64 vcc` / `s_load_dwordx2 vcc` / `s_buffer_load_dwordx2 vcc` writes raw 64-bit data into `vcc`. - **`tools/wave64_emulate_opt.py`**: mark `s_getpc_b64 vcc` as raw VCC data in `mark_vcc_data_moves()` and preserve raw-VCC tracking across `s_add_u32`/`s_addc_u32`/`s_sub_u32`/`s_subb_u32` updates to `vcc_lo`/`vcc_hi`. - **`docs/design.md`**: document the `s_getpc_b64` destination contract row. - **`tests/semantic/test_s_getpc_destinations.py`**: 12 synthetic semantic tests across wave32, wave64, and `--wave64-emulate`, including raw-byte regressions covering both `tools/rdna2_decode.py` and the LLVM + `check_printed_encodings` path (plus live `llvm-mc` when installed). ## Verification - `python3 -W error -I tests/semantic/test_s_getpc_destinations.py -v`: **12 passed, 0 failed** (0.942s). - Mutation check against unpatched `main` (`42537e7b6`): **14 failed, 25 errors**; against prior PR head `3966cb6a1`: **17 failed** (confirming odd-pair/raw-byte regressions catch the old acceptance). - `python3 -I scripts/run_semantic_tests.py tests/semantic`: **488 files, 6291 tests, 0 files failed** (132s). - `python3 -m pytest tests/test_shader_meta.py tests/test_rdna2_decode.py tests/test_pc_tail_ubo.py -q`: **48 passed, 8 skipped, 653 subtests passed**. - `python3 -m compileall -q tools tests`, `python3 -I tests/test_text_write_line_endings.py`, `python3 -I scripts/check_no_game_data.py`: all pass. - Prior GPU check by @ecox982745 on RTX 4090 (NVIDIA 616.64, LLVM 23.1.6) passed `s[104:105]`, `vcc`, and `null` in wave32 and emulated wave64. AI-assisted: yes GPUs tested: none locally (CPU interpreter + synthetic fixtures only; `vcc`/`null`/`s[104:105]` checked on RTX 4090 by @ecox982745 in review; no game data) --- <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#1647
No description provided.