tooling: disasm_rdna2 leaves v_permlane16_b32 and v_permlanex16_b32 unnamed #1291

Closed
opened 2026-11-24 07:13:27 +00:00 by MasterDomino · 3 comments
MasterDomino commented 2026-11-24 07:13:27 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T07:13:27Z.


tools/disasm_rdna2.py has no names for the gfx10 VOP3 opcodes 0x377 (v_permlane16_b32) and 0x378 (v_permlanex16_b32). It prints them as v_vop3_377 / v_vop3_378, so tools/scan_unsupported_shaders.py counts them as unsupported opcodes, although its known-opcode list already contains both names. This follows up the observation in #938 (comment), re-measured on current main. #938 is closed, so I am opening a separate issue.

Setup

  • upstream/main at 9c4442fd, Windows 11 (build 26300), Python 3.13.1.
  • llvm-mc 15.0.7 (-arch=amdgcn -mcpu=gfx1013) and LLVM-C.dll from LLVM 15.0.7.

Current decoder output

python -B tools/disasm_rdna2.py --hex 000078d701050c00
+0x0000  000078d701050c00   v_vop3_378 v0, v1, s2, s3                  // Unknown VOP3 opcode 0x378
python -B tools/disasm_rdna2.py --hex 000877d701050c00
+0x0000  000877d701050c00   v_vop3_377 v0, v1, s2, s3 op_sel:[1,0,0]   // Unknown VOP3 opcode 0x377

LLVM 15 reference (synthetic encodings)

Assembly (llvm-mc 15) Encoding
v_permlane16_b32 v0, v1, s2, s3 [0x00,0x00,0x77,0xd7,0x01,0x05,0x0c,0x00]
v_permlanex16_b32 v0, v1, s2, s3 [0x00,0x00,0x78,0xd7,0x01,0x05,0x0c,0x00]
v_permlane16_b32 v0, v1, s2, s3 op_sel:[1,0] [0x00,0x08,0x77,0xd7,0x01,0x05,0x0c,0x00]
v_permlanex16_b32 v0, v1, s2, s3 op_sel:[0,1] [0x00,0x10,0x78,0xd7,0x01,0x05,0x0c,0x00]
v_permlanex16_b32 v0, v1, s2, s3 op_sel:[1,1] [0x00,0x18,0x78,0xd7,0x01,0x05,0x0c,0x00]
v_permlane16_b32 v0, v1, vcc_lo, exec_hi [0x00,0x00,0x77,0xd7,0x01,0xd5,0xfc,0x01]
  • These opcodes use op_sel[0] (w0 bit 11) for fi and op_sel[1] (bit 12) for bound_ctrl. LLVM 15 prints them as a two-element op_sel:[fi,bound_ctrl]. The generic VOP3 path in our decoder prints three elements (op_sel:[1,0,0]).
  • Disassembling with llvm-mc 15: words with op_sel[2] or op_sel[3] (bits 13 and 14), abs or neg set decode to the same text, with those bits silently dropped. Words with clamp or omod set are refused as invalid encodings. Our decoder currently prints |v1| and clamp for such words.
  • The assembler and disassembler differ: llvm-mc 15 refuses a literal src1 when assembling, but disassembles [0x00,0x00,0x77,0xd7,0x01,0xff,0x0d,0x00,0x78,0x56,0x34,0x12] as v_permlane16_b32 v0, v1, 0x12345678, s3. An SGPR src0 also disassembles (v_permlanex16_b32 v0, s1, s2, s3).

One local input, aggregates only

The input is one local input (12,101 PS records, the same population as #711), re-extracted at 9c4442fd with tools/extract_shaders.py --stage pixel --format native and scanned with tools/scan_unsupported_shaders.py --llvm <LLVM-C.dll>.

  • The scanner summary is identical to the one I posted for 908c34bf: 10,561 opcodes recognized but rejected by the translator, 1,540 unsupported opcodes, 46 unique unsupported opcodes, 0 accepted.
  • v_vop3_378 is still the most frequent unsupported placeholder: 3,185 occurrences in 1,361 records. 614 of these occurrences come after the first s_endpgm in byte order.
  • 1,326 of those 1,361 records have v_vop3_378 as their only unsupported opcode. The other 35 also contain v_vop2_00 (35 records) and/or .long (29 records).
  • All 3,185 occurrences are 8-byte words with op_sel, abs, neg, clamp and omod all zero. They form 6 distinct encodings, and llvm-mc 15 disassembles all 6 as v_permlanex16_b32 without modifiers.
  • v_vop3_377 (v_permlane16_b32) does not occur in this input. Coverage for it would come from LLVM 15 encodings only.

The 258 records in my #938 comment were only the records that moved because of code after the first exit (#1055). 1,326 is the total count of records blocked by this opcode alone.

Expected but not measured: once both opcodes are named, the 1,326 records should move from "unsupported opcodes" to "opcodes recognized, translator rejected" (1,540 to 214), and the unique count should drop from 46 to 45. The translator verdict should not change, since pixel_aot does not lower either instruction. #531 proposes rejecting both names in pixel_aot explicitly and does not touch the decoder.

Proposed scope

Decoding and naming only. No translator lowering and no scanner change.

  1. Name 0x377 and 0x378 in the VOP3 table, with a modifier grammar matching LLVM 15: a two-element op_sel:[fi,bound_ctrl], clamp and omod words refused like LLVM refuses them (similar to VOP3_RESTRICTED_MODIFIERS).
  2. Tests in tests/rdna2_tools_check.py against the LLVM 15 golden encodings above, including the fi, bound_ctrl and both-set variants and special SGPR sources, plus an LLVM_MC round trip when the tools are available.
  3. Negative controls: clamp and omod words must not decode as permlane instructions. Without the new table entries, the tests must fail with the v_vop3_37x placeholders.

Open question: should the bits LLVM 15 decodes and drops (abs, neg, op_sel[2], op_sel[3]) be printed the way LLVM prints them, or refused? Matching LLVM keeps the scanner comparable with the LLVM walk, but a later translator would then never see those bits.

@R0Y00, do you want this? If so, I can take it as one small PR once you confirm the scope.

Limits

  • One local input and one LLVM version (15.0.7). Newer LLVM may spell the fi / bound_ctrl bits differently.
  • "After the first s_endpgm" means byte order only. Reachability was not analysed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6576647010 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1298). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T07:13:27Z. --- `tools/disasm_rdna2.py` has no names for the gfx10 VOP3 opcodes `0x377` (`v_permlane16_b32`) and `0x378` (`v_permlanex16_b32`). It prints them as `v_vop3_377` / `v_vop3_378`, so `tools/scan_unsupported_shaders.py` counts them as unsupported opcodes, although its known-opcode list already contains both names. This follows up the observation in [#938 (comment)](https://github.com/R0Y00/Xbox2Windows/issues/938#issuecomment-7122825345), re-measured on current main. #938 is closed, so I am opening a separate issue. ## Setup - `upstream/main` at `9c4442fd`, Windows 11 (build 26300), Python 3.13.1. - llvm-mc 15.0.7 (`-arch=amdgcn -mcpu=gfx1013`) and `LLVM-C.dll` from LLVM 15.0.7. ## Current decoder output ```text python -B tools/disasm_rdna2.py --hex 000078d701050c00 +0x0000 000078d701050c00 v_vop3_378 v0, v1, s2, s3 // Unknown VOP3 opcode 0x378 python -B tools/disasm_rdna2.py --hex 000877d701050c00 +0x0000 000877d701050c00 v_vop3_377 v0, v1, s2, s3 op_sel:[1,0,0] // Unknown VOP3 opcode 0x377 ``` ## LLVM 15 reference (synthetic encodings) | Assembly (llvm-mc 15) | Encoding | |---|---| | `v_permlane16_b32 v0, v1, s2, s3` | `[0x00,0x00,0x77,0xd7,0x01,0x05,0x0c,0x00]` | | `v_permlanex16_b32 v0, v1, s2, s3` | `[0x00,0x00,0x78,0xd7,0x01,0x05,0x0c,0x00]` | | `v_permlane16_b32 v0, v1, s2, s3 op_sel:[1,0]` | `[0x00,0x08,0x77,0xd7,0x01,0x05,0x0c,0x00]` | | `v_permlanex16_b32 v0, v1, s2, s3 op_sel:[0,1]` | `[0x00,0x10,0x78,0xd7,0x01,0x05,0x0c,0x00]` | | `v_permlanex16_b32 v0, v1, s2, s3 op_sel:[1,1]` | `[0x00,0x18,0x78,0xd7,0x01,0x05,0x0c,0x00]` | | `v_permlane16_b32 v0, v1, vcc_lo, exec_hi` | `[0x00,0x00,0x77,0xd7,0x01,0xd5,0xfc,0x01]` | - These opcodes use `op_sel[0]` (w0 bit 11) for `fi` and `op_sel[1]` (bit 12) for `bound_ctrl`. LLVM 15 prints them as a two-element `op_sel:[fi,bound_ctrl]`. The generic VOP3 path in our decoder prints three elements (`op_sel:[1,0,0]`). - Disassembling with llvm-mc 15: words with `op_sel[2]` or `op_sel[3]` (bits 13 and 14), `abs` or `neg` set decode to the same text, with those bits silently dropped. Words with `clamp` or `omod` set are refused as invalid encodings. Our decoder currently prints `|v1|` and `clamp` for such words. - The assembler and disassembler differ: llvm-mc 15 refuses a literal `src1` when assembling, but disassembles `[0x00,0x00,0x77,0xd7,0x01,0xff,0x0d,0x00,0x78,0x56,0x34,0x12]` as `v_permlane16_b32 v0, v1, 0x12345678, s3`. An SGPR `src0` also disassembles (`v_permlanex16_b32 v0, s1, s2, s3`). ## One local input, aggregates only The input is one local input (12,101 PS records, the same population as #711), re-extracted at `9c4442fd` with `tools/extract_shaders.py --stage pixel --format native` and scanned with `tools/scan_unsupported_shaders.py --llvm <LLVM-C.dll>`. - The scanner summary is identical to the one I posted for `908c34bf`: 10,561 opcodes recognized but rejected by the translator, 1,540 unsupported opcodes, 46 unique unsupported opcodes, 0 accepted. - `v_vop3_378` is still the most frequent unsupported placeholder: 3,185 occurrences in 1,361 records. 614 of these occurrences come after the first `s_endpgm` in byte order. - 1,326 of those 1,361 records have `v_vop3_378` as their only unsupported opcode. The other 35 also contain `v_vop2_00` (35 records) and/or `.long` (29 records). - All 3,185 occurrences are 8-byte words with `op_sel`, `abs`, `neg`, `clamp` and `omod` all zero. They form 6 distinct encodings, and llvm-mc 15 disassembles all 6 as `v_permlanex16_b32` without modifiers. - `v_vop3_377` (`v_permlane16_b32`) does not occur in this input. Coverage for it would come from LLVM 15 encodings only. The 258 records in my #938 comment were only the records that moved because of code after the first exit (#1055). 1,326 is the total count of records blocked by this opcode alone. Expected but not measured: once both opcodes are named, the 1,326 records should move from "unsupported opcodes" to "opcodes recognized, translator rejected" (1,540 to 214), and the unique count should drop from 46 to 45. The translator verdict should not change, since `pixel_aot` does not lower either instruction. #531 proposes rejecting both names in `pixel_aot` explicitly and does not touch the decoder. ## Proposed scope Decoding and naming only. No translator lowering and no scanner change. 1. Name `0x377` and `0x378` in the VOP3 table, with a modifier grammar matching LLVM 15: a two-element `op_sel:[fi,bound_ctrl]`, `clamp` and `omod` words refused like LLVM refuses them (similar to `VOP3_RESTRICTED_MODIFIERS`). 2. Tests in `tests/rdna2_tools_check.py` against the LLVM 15 golden encodings above, including the `fi`, `bound_ctrl` and both-set variants and special SGPR sources, plus an `LLVM_MC` round trip when the tools are available. 3. Negative controls: `clamp` and `omod` words must not decode as permlane instructions. Without the new table entries, the tests must fail with the `v_vop3_37x` placeholders. Open question: should the bits LLVM 15 decodes and drops (`abs`, `neg`, `op_sel[2]`, `op_sel[3]`) be printed the way LLVM prints them, or refused? Matching LLVM keeps the scanner comparable with the LLVM walk, but a later translator would then never see those bits. @R0Y00, do you want this? If so, I can take it as one small PR once you confirm the scope. ## Limits - One local input and one LLVM version (15.0.7). Newer LLVM may spell the `fi` / `bound_ctrl` bits differently. - "After the first `s_endpgm`" means byte order only. Reachability was not analysed. AI-assisted.
R0Y00 commented 2026-11-24 08:01:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T07:42:37Z.


Yes, please take the decoder-only change. Keep the two-element op_sel:[fi,bound_ctrl] for the LLVM 15 forms and preserve the record length. For this change, report an unsupported encoding when abs, neg, the upper op_sel bits, clamp or omod are set. That keeps the ambiguous words visible until there is independent evidence of their meaning. Please include the assembler round trip, both plain opcodes and the special-SGPR case. Leave the scanner and translators alone, and report any inventory change as recognition only.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125285215 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1298#issuecomment-7125285215). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T07:42:37Z. --- Yes, please take the decoder-only change. Keep the two-element `op_sel:[fi,bound_ctrl]` for the LLVM 15 forms and preserve the record length. For this change, report an unsupported encoding when abs, neg, the upper op_sel bits, clamp or omod are set. That keeps the ambiguous words visible until there is independent evidence of their meaning. Please include the assembler round trip, both plain opcodes and the special-SGPR case. Leave the scanner and translators alone, and report any inventory change as recognition only.
MasterDomino commented 2026-11-24 08:01:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T07:45:12Z.


Claiming the decoder-only change: v_permlane16_b32 / v_permlanex16_b32 in tools/disasm_rdna2.py, two-element op_sel:[fi,bound_ctrl], record length preserved, abs/neg/upper op_sel/clamp/omod reported as unsupported encodings. Tests: both plain opcodes, the special-SGPR case and the LLVM 15 assembler round trip. Scanner and translators untouched; any inventory change reported as recognition only. I'll link the PR here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125333344 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1298#issuecomment-7125333344). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T07:45:12Z. --- Claiming the decoder-only change: `v_permlane16_b32` / `v_permlanex16_b32` in `tools/disasm_rdna2.py`, two-element `op_sel:[fi,bound_ctrl]`, record length preserved, abs/neg/upper op_sel/clamp/omod reported as unsupported encodings. Tests: both plain opcodes, the special-SGPR case and the LLVM 15 assembler round trip. Scanner and translators untouched; any inventory change reported as recognition only. I'll link the PR here. AI-assisted.
MasterDomino commented 2026-11-24 08:01:41 +00:00 (Migrated from github.com)
Author
Contributor

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


PR: https://github.com/R0Y00/Xbox2Windows/pull/1322. Scanner and translators untouched; on the local input the change is recognition only (unsupported-opcode records 1,540 → 214, translator verdict identical for all 12,101).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7125610657 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1298#issuecomment-7125610657). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T08:00:11Z. --- PR: https://github.com/R0Y00/Xbox2Windows/pull/1322. Scanner and translators untouched; on the local input the change is recognition only (unsupported-opcode records 1,540 → 214, translator verdict identical for all 12,101). AI-assisted.
Sign in to join this conversation.
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#1291
No description provided.