tooling: decode v_mqsad_u32_u8 in the RDNA2 disassembler #1363

Merged
tedin7 merged 2 commits from upstream-pr/1370 into main 2026-11-24 10:31:44 +00:00
tedin7 commented 2026-11-24 09:27:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:27:03Z.


What

  • tools/disasm_rdna2.py: adds VOP3 opcode 0x175, v_mqsad_u32_u8. Before this it decoded as v_vop3_175 v0, v4, v6, v8 ("Unknown VOP3 opcode 0x175"). It now prints v_mqsad_u32_u8 v[0:3], v[4:5], v6, v[8:11]: a four-register destination and accumulator (src2), a register-pair src0 and a one-register src1.
  • VOP3_RESTRICTED_MODIFIERS["v_mqsad_u32_u8"] = (True, False): clamp is accepted; abs, neg and omod are refused (llvm-mc 19 rejects them; the assembler also rejects an SGPR, constant or special-register src2, so the decoder refuses those words too).
  • A destination or accumulator quad past v255 prints <invalid VGPR quad>, the way a pair past v255 already prints <invalid VGPR pair>. The two duplicated destination formatters in the VOP3 path now share one helper.
  • tests/rdna2_tools_check.py: ten golden vectors encoded by llvm-mc 19.1.7 (clamp, vcc, s[2:3], exec/m0, literal, inline constants, null, ttmp pair, v[252:255] quad) join the existing golden/round-trip tests; 0x175 joins the neighbour-name test and the llvm modifier grid; new refused forms (abs, neg, omod, SGPR and inline-constant accumulator); a test that the quad stops at v255; the binary-scan test lists the mnemonic. Two existing tests used 0x175 as an "unknown opcode" example, so they now use 0x179, and the table-driven synthetic-forms test handles four-register widths.
  • docs/experiments.md: one paragraph next to the existing disassembler note.

Why

The disassembler is the oracle for shader tracing. An opcode that prints as v_vop3_175 with single registers hides both the instruction and its operand widths. The sibling forms 0x172 and 0x173 were added the same way.

Tested

Windows: ctest --test-dir <build> -C Release -R "^rdna2_tools_check$" --output-on-failure (the CMake test rdna2_tools_check runs python -B tests/rdna2_tools_check.py; CI sets LLVM_LIB=libLLVM-15 for it).

Run on Linux (only llvm-mc 19.1.7 is installed here; LLVM 15 was not run):

  • LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so LLVM_MC=llvm-mc-19 LLVM_OBJCOPY=llvm-objcopy-19 python3 -B tests/rdna2_tools_check.py: 139 tests; the new and changed tests pass. Six tests fail identically on unmodified origin/main with LLVM 19 (test_llvm_comparison, test_source_built_records_after_s_endpgm, test_interp_f16_llvm_round_trip, test_vop1_vop2_sdwa_llvm_round_trip, test_vop1_vop2_dpp_llvm_round_trip): LLVM 19 versus 15 differences, unrelated.
  • Without LLVM_LIB: OK (skipped=18).
  • Mutations: removing the 0x175 table entry fails the golden, round-trip, grid, refuse, neighbour, scan and quad tests; changing the destination width to 2 fails 20 tests.
  • py_compile, tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check: clean.

Not covered: tools/pixel_aot.py does not lower v_mqsad_u32_u8 (unchanged, and docs/experiments.md already says so). Known gap left alone: odd SGPR src0 encodings (llvm prints the aligned pair) and a few reserved src codes print differently from llvm for every pair-source VOP3 op; this is shared decode code and not specific to this opcode.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6578680899 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1370). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T09:27:03Z. --- ## What - `tools/disasm_rdna2.py`: adds VOP3 opcode 0x175, `v_mqsad_u32_u8`. Before this it decoded as `v_vop3_175 v0, v4, v6, v8` ("Unknown VOP3 opcode 0x175"). It now prints `v_mqsad_u32_u8 v[0:3], v[4:5], v6, v[8:11]`: a four-register destination and accumulator (src2), a register-pair src0 and a one-register src1. - `VOP3_RESTRICTED_MODIFIERS["v_mqsad_u32_u8"] = (True, False)`: clamp is accepted; abs, neg and omod are refused (llvm-mc 19 rejects them; the assembler also rejects an SGPR, constant or special-register src2, so the decoder refuses those words too). - A destination or accumulator quad past v255 prints `<invalid VGPR quad>`, the way a pair past v255 already prints `<invalid VGPR pair>`. The two duplicated destination formatters in the VOP3 path now share one helper. - `tests/rdna2_tools_check.py`: ten golden vectors encoded by llvm-mc 19.1.7 (clamp, vcc, s[2:3], exec/m0, literal, inline constants, null, ttmp pair, v[252:255] quad) join the existing golden/round-trip tests; 0x175 joins the neighbour-name test and the llvm modifier grid; new refused forms (abs, neg, omod, SGPR and inline-constant accumulator); a test that the quad stops at v255; the binary-scan test lists the mnemonic. Two existing tests used 0x175 as an "unknown opcode" example, so they now use 0x179, and the table-driven synthetic-forms test handles four-register widths. - `docs/experiments.md`: one paragraph next to the existing disassembler note. ## Why The disassembler is the oracle for shader tracing. An opcode that prints as `v_vop3_175` with single registers hides both the instruction and its operand widths. The sibling forms 0x172 and 0x173 were added the same way. ## Tested Windows: `ctest --test-dir <build> -C Release -R "^rdna2_tools_check$" --output-on-failure` (the CMake test `rdna2_tools_check` runs `python -B tests/rdna2_tools_check.py`; CI sets LLVM_LIB=libLLVM-15 for it). Run on Linux (only llvm-mc 19.1.7 is installed here; LLVM 15 was not run): - `LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so LLVM_MC=llvm-mc-19 LLVM_OBJCOPY=llvm-objcopy-19 python3 -B tests/rdna2_tools_check.py`: 139 tests; the new and changed tests pass. Six tests fail identically on unmodified origin/main with LLVM 19 (test_llvm_comparison, test_source_built_records_after_s_endpgm, test_interp_f16_llvm_round_trip, test_vop1_vop2_sdwa_llvm_round_trip, test_vop1_vop2_dpp_llvm_round_trip): LLVM 19 versus 15 differences, unrelated. - Without LLVM_LIB: OK (skipped=18). - Mutations: removing the 0x175 table entry fails the golden, round-trip, grid, refuse, neighbour, scan and quad tests; changing the destination width to 2 fails 20 tests. - py_compile, tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check: clean. Not covered: `tools/pixel_aot.py` does not lower v_mqsad_u32_u8 (unchanged, and docs/experiments.md already says so). Known gap left alone: odd SGPR src0 encodings (llvm prints the aligned pair) and a few reserved src codes print differently from llvm for every pair-source VOP3 op; this is shared decode code and not specific to this opcode.
tedin7 commented 2026-11-24 10:02:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:34:58Z.


Verified on Windows Server 2025 (Build 26100) at commit b70f516a668a0255e3d1640cc18cb277815a0d83:

  • Windows Python checks: tests/rdna2_tools_check.py ok (4.19s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7127611837 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1370#issuecomment-7127611837). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T09:34:58Z. --- Verified on Windows Server 2025 (Build 26100) at commit `b70f516a668a0255e3d1640cc18cb277815a0d83`: - **Windows Python checks**: `tests/rdna2_tools_check.py` ok (`4.19s`)
chatgpt-codex-connector[bot commented 2026-11-24 10:02:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T09:35:11Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T09:39:28.870273Z b70f516 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7127616469 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1370#issuecomment-7127616469). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T09:35:11Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"b70f516a668a0255e3d1640cc18cb277815a0d83","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T09:39:28.870273Z">2026-11-24T09:39:28.870273Z</relative-time> | `b70f516` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
upstream-sync closed this pull request 2026-11-24 11:02:38 +00:00
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!1363
No description provided.