tooling: decode v_permlane16_b32 and v_permlanex16_b32 in disasm_rdna2 #1315

Merged
MasterDomino merged 1 commit from upstream-pr/1322 into main 2026-11-24 08:14:02 +00:00
MasterDomino commented 2026-11-24 08:00:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T08:00:09Z.


Fixes #1298

tools/disasm_rdna2.py printed VOP3 0x377 and 0x378 as v_vop3_377 / v_vop3_378. It now decodes them as v_permlane16_b32 and v_permlanex16_b32. Decoder only: the scanner and translators are unchanged.

Behaviour

Following the scope on #1298:

  • Operand profile as LLVM 15 prints it: vdst, src0, src1, src2 with a two-element op_sel:[fi,bound_ctrl] (w0 bits 11 and 12), printed only when a flag is set.
  • Only the forms the LLVM 15 gfx1013 assembler accepts are decoded: a VGPR src0, and SGPRs, vcc, ttmp, m0, null, exec, the special sources and inline constants in the lane selects.
  • All other words become v_permlane{,x}16_b32_unsupported with <unsupported VOP3A encoding> and keep their record length, 12 bytes with a literal. That covers abs, neg, op_sel[2:3], clamp, omod, a non-VGPR src0, a VGPR lane select, the reserved codes 209–234, 249, 250, LDS direct and a literal. LLVM 15's disassembler prints some of these words but silently drops the modifier bits, or uses operands the assembler rejects.

Tests (tests/rdna2_tools_check.py)

  • test_vop3_permlane_golden_vectors: 14 llvm-mc 15.0.7 encodings: both plain opcodes, v255/s105, vcc_lo/vcc_hi/exec_lo/exec_hi/m0/null/ttmp0, integer and float inline constants, op_sel:[1,0], [0,1], [1,1].
  • test_vop3_permlane_llvm_round_trip: assembling the vectors gives the same bytes, LLVM disassembles them to the same strings as this decoder, and the decoded text reassembles to the same bytes.
  • test_vop3_permlane_fields_and_neighbours_differ: flipping the opcode, vdst, fi or bound_ctrl bit changes the text; 0x376 and 0x379 keep their names.
  • test_vop3_permlane_refuses_forms_the_llvm_15_assembler_cannot_produce: 16 refused forms plus both literal lane selects. Each is followed by s_endpgm to check the 8- or 12-byte boundary, plus a truncated literal.
  • test_vop3_permlane_modifier_and_source_grid_matches_the_llvm_15_assembler: each w0 bit 8–15 combined with each w1 bit 27–31 on both opcodes. Only fi/bound_ctrl alone decode, and they decode as LLVM prints them. Where LLVM still prints a refused word, its text is the word with abs/neg/op_sel[2:3] removed.
LLVM_LIB=<LLVM-C.dll 15.0.7> LLVM_MC=<llvm-mc 15.0.7> LLVM_OBJCOPY=<llvm-objcopy> python -B tests/rdna2_tools_check.py
Ran 138 tests ... OK (skipped=1)        # the existing buffer_load skip
python -B tests/rdna2_tools_check.py    # without LLVM
OK (skipped=18)

form_coverage_check, shader_census_check, shader_corpus_report_check, shader_probe_check, pso_readiness_check, docs_links_check and bidi_controls_check also pass.

Negative control: with tools/disasm_rdna2.py restored to main, all five new tests fail (131 subtest failures), showing the v_vop3_377 / v_vop3_378 placeholders and the three-element op_sel:[1,0,0].

Sweep (local script, not committed): 23,108 synthetic words over both opcodes: every value of each source field, every modifier bit, and 20,000 random words.

  • 1,423 decoded words: each equals LLVM 15's disassembly, and llvm-mc reassembles all 1,423 to the same bytes.
  • 21,685 refused words: LLVM refuses 18,061 of them outright. Of the 3,047 it prints without an "invalid" marker, llvm-mc rejects 2,805, and the other 242 assemble to different bytes (the dropped bits). So no refused word round-trips.

Inventory change, recognition only

One local input (12,101 PS records, the same population as #711), scanned with tools/scan_unsupported_shaders.py --llvm <LLVM-C.dll>. Base f5d83c31 against this branch on the same base. The rebase onto 4d7509aa changes none of the decoder, scanner or translator files.

base branch
records with unsupported opcodes 1,540 214
opcodes recognized, translator rejected 10,561 11,887
unique unsupported opcodes 46 45
translator accepted 0 0

All 3,185 v_vop3_378 occurrences, in 1,361 records, now decode as v_permlanex16_b32. None is refused. The input has no 0x377. The translator verdict and its reason are identical for all 12,101 records, because pixel_aot does not lower either instruction.

Environment

Windows 11 26H2 (build 26300.9974), Python 3.13.1, LLVM 15.0.7 (LLVM-C.dll, llvm-mc, llvm-objcopy).

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6577289985 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1322). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T08:00:09Z. --- Fixes #1298 `tools/disasm_rdna2.py` printed VOP3 0x377 and 0x378 as `v_vop3_377` / `v_vop3_378`. It now decodes them as `v_permlane16_b32` and `v_permlanex16_b32`. Decoder only: the scanner and translators are unchanged. ## Behaviour Following the scope on #1298: - Operand profile as LLVM 15 prints it: `vdst, src0, src1, src2` with a two-element `op_sel:[fi,bound_ctrl]` (w0 bits 11 and 12), printed only when a flag is set. - Only the forms the LLVM 15 gfx1013 **assembler** accepts are decoded: a VGPR `src0`, and SGPRs, `vcc`, `ttmp`, `m0`, `null`, `exec`, the special sources and inline constants in the lane selects. - All other words become `v_permlane{,x}16_b32_unsupported` with `<unsupported VOP3A encoding>` and keep their record length, 12 bytes with a literal. That covers abs, neg, `op_sel[2:3]`, clamp, omod, a non-VGPR `src0`, a VGPR lane select, the reserved codes 209–234, 249, 250, LDS direct and a literal. LLVM 15's disassembler prints some of these words but silently drops the modifier bits, or uses operands the assembler rejects. ## Tests (`tests/rdna2_tools_check.py`) - `test_vop3_permlane_golden_vectors`: 14 llvm-mc 15.0.7 encodings: both plain opcodes, `v255`/`s105`, `vcc_lo`/`vcc_hi`/`exec_lo`/`exec_hi`/`m0`/`null`/`ttmp0`, integer and float inline constants, `op_sel:[1,0]`, `[0,1]`, `[1,1]`. - `test_vop3_permlane_llvm_round_trip`: assembling the vectors gives the same bytes, LLVM disassembles them to the same strings as this decoder, and the decoded text reassembles to the same bytes. - `test_vop3_permlane_fields_and_neighbours_differ`: flipping the opcode, vdst, fi or bound_ctrl bit changes the text; 0x376 and 0x379 keep their names. - `test_vop3_permlane_refuses_forms_the_llvm_15_assembler_cannot_produce`: 16 refused forms plus both literal lane selects. Each is followed by `s_endpgm` to check the 8- or 12-byte boundary, plus a truncated literal. - `test_vop3_permlane_modifier_and_source_grid_matches_the_llvm_15_assembler`: each w0 bit 8–15 combined with each w1 bit 27–31 on both opcodes. Only fi/bound_ctrl alone decode, and they decode as LLVM prints them. Where LLVM still prints a refused word, its text is the word with abs/neg/`op_sel[2:3]` removed. ``` LLVM_LIB=<LLVM-C.dll 15.0.7> LLVM_MC=<llvm-mc 15.0.7> LLVM_OBJCOPY=<llvm-objcopy> python -B tests/rdna2_tools_check.py Ran 138 tests ... OK (skipped=1) # the existing buffer_load skip python -B tests/rdna2_tools_check.py # without LLVM OK (skipped=18) ``` `form_coverage_check`, `shader_census_check`, `shader_corpus_report_check`, `shader_probe_check`, `pso_readiness_check`, `docs_links_check` and `bidi_controls_check` also pass. **Negative control:** with `tools/disasm_rdna2.py` restored to main, all five new tests fail (131 subtest failures), showing the `v_vop3_377` / `v_vop3_378` placeholders and the three-element `op_sel:[1,0,0]`. **Sweep** (local script, not committed): 23,108 synthetic words over both opcodes: every value of each source field, every modifier bit, and 20,000 random words. - **1,423 decoded words:** each equals LLVM 15's disassembly, and llvm-mc reassembles all 1,423 to the same bytes. - **21,685 refused words:** LLVM refuses 18,061 of them outright. Of the 3,047 it prints without an "invalid" marker, llvm-mc rejects 2,805, and the other 242 assemble to *different* bytes (the dropped bits). So no refused word round-trips. ## Inventory change, recognition only One local input (12,101 PS records, the same population as #711), scanned with `tools/scan_unsupported_shaders.py --llvm <LLVM-C.dll>`. Base `f5d83c31` against this branch on the same base. The rebase onto `4d7509aa` changes none of the decoder, scanner or translator files. | | base | branch | |---|---:|---:| | records with unsupported opcodes | 1,540 | 214 | | opcodes recognized, translator rejected | 10,561 | 11,887 | | unique unsupported opcodes | 46 | 45 | | translator accepted | 0 | 0 | All 3,185 `v_vop3_378` occurrences, in 1,361 records, now decode as `v_permlanex16_b32`. None is refused. The input has no 0x377. The translator verdict and its reason are identical for all 12,101 records, because `pixel_aot` does not lower either instruction. ## Environment Windows 11 26H2 (build 26300.9974), Python 3.13.1, LLVM 15.0.7 (`LLVM-C.dll`, `llvm-mc`, `llvm-objcopy`). AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 09:04:29 +00:00
tedin7 commented 2026-11-24 09:04:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:07:16Z.

Review: COMMENTED


Reviewed and verified PR #1322 at commit 3437253a51d8d5dc5bc355b44f06c24000beaa3f (looks good; no blockers).

Linux Checks (/tmp/rev-x2w-1322)

  • git diff --check origin/main...HEAD: passed
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (16 Markdown files, 290 links)
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (1094 tracked files)
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py: 138 tests ran, OK (skipped=18 without LLVM_LIB, since only llvm-19 is installed on this host while the suite's round-trip/grid tests target LLVM 15).

Windows Server 2025 (Build 26100)

  • Python checks: tests/rdna2_tools_check.py passed (4.11s, no C++ build needed).

Notes

  • tools/disasm_rdna2.py decodes v_permlane16_b32 (0x377) and v_permlanex16_b32 (0x378) with op_sel:[fi,bound_ctrl] (w0[11:12]), refuses unsupported modifier/operand combinations, and preserves 12-byte record length (and vop3_truncated on short input) when a literal (255) appears in src0/src1/src2 so downstream instruction alignment is maintained.
  • tests/rdna2_tools_check.py covers golden vectors, field/neighbour negative controls (0x376–0x379), refused forms, and truncation.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6035671315 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1322#pullrequestreview-6035671315). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T08:07:16Z. **Review:** COMMENTED --- Reviewed and verified PR #1322 at commit `3437253a51d8d5dc5bc355b44f06c24000beaa3f` (looks good; no blockers). ### Linux Checks (`/tmp/rev-x2w-1322`) - `git diff --check origin/main...HEAD`: passed - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: passed (16 Markdown files, 290 links) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: passed (1094 tracked files) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py`: **138 tests ran, OK** (`skipped=18` without `LLVM_LIB`, since only `llvm-19` is installed on this host while the suite's round-trip/grid tests target LLVM 15). ### Windows Server 2025 (Build 26100) - **Python checks**: `tests/rdna2_tools_check.py` passed (`4.11s`, no C++ build needed). ### Notes - `tools/disasm_rdna2.py` decodes `v_permlane16_b32` (`0x377`) and `v_permlanex16_b32` (`0x378`) with `op_sel:[fi,bound_ctrl]` (`w0[11:12]`), refuses unsupported modifier/operand combinations, and preserves 12-byte record length (and `vop3_truncated` on short input) when a literal (`255`) appears in `src0`/`src1`/`src2` so downstream instruction alignment is maintained. - `tests/rdna2_tools_check.py` covers golden vectors, field/neighbour negative controls (`0x376`–`0x379`), refused forms, and truncation.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
R0Y00/Xbox2Windows!1315
No description provided.