tooling: decode VOP3_INTERP f16 instructions in disasm_rdna2 as LLVM 15 does #965

Closed
Batushn wants to merge 1 commit from upstream-pr/972 into main
Batushn commented 2026-11-23 19:21:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Batushn on 2026-11-23T19:21:51Z.


Summary

Implements step 2 of #938: decode the GFX10 VOP3_INTERP 16-bit interpolation instructions (v_interp_p1ll_f16, v_interp_p1lv_f16, and v_interp_p2_f16) in tools/disasm_rdna2.py with LLVM 15's exact operand syntax instead of falling through to v_vop3_342 / v_vop3_343 / v_vop3_35a.

  • tools/disasm_rdna2.py:
    • Added VOP3_INTERP16_OPS (0x342 v_interp_p1ll_f16, 0x343 v_interp_p1lv_f16, 0x35a v_interp_p2_f16).
    • Decoded VOP3Interp_gfx10 fields matching LLVM 15.0.7 (VOPInstructions.td / VOP3Instructions.td): attr (w1[5:0]), attrchan (w1[7:6]), high (w1[8]), src0 (w1[17:9], abs=w0[9], neg=w1[30]), optional src2 (w1[26:18], abs=w0[10], neg=w1[31]), clamp (w0[15]), and omod (w1[28:27] for f32-destination p1ll/p1lv only; omitted on p2_f16).
  • tests/rdna2_tools_check.py:
    • Added test_vop3_interp_f16_encodings: 26 golden GFX10 encodings verified against LLVM 15.0.7 test/MC/AMDGPU/gfx10_asm_vop3.s, covering all 3 opcodes, attr/attrchan, -/|...|/-|...|, high, clamp, mul:2/mul:4/div:2, 8-byte stream alignment with s_endpgm, and 4-byte vop3_truncated handling.
    • Added test_vop3_interp_f16_llvm_round_trip: assembles 11 single-field and combined v_interp_*_f16 cases with llvm-mc, checks exact equality against llvm_disassemble, and re-assembles disasm_rdna2's output back to identical bytes (runs in Ubuntu LLVM 15 CI).
    • Added test_binary_scan_recognizes_vop3_interp_f16: verifies scan_unsupported_shaders.py now recognizes the decoded opcodes (opcodes_recognized=True, unsupported_opcodes={}) while keeping them unlowered (translator_accepted=False, compatibility_category="opcode_recognized_translator_rejected"), with negative control on the old v_vop3_342/343/35a names.

Refs #938

Verification

  • python -B tests/rdna2_tools_check.py on Windows 11 (Python 3.12.10, synthetic inputs, no game files): Ran 81 tests ... OK (skipped=3) (the 3 skipped tests require llvm-mc/llvm-objcopy and will run in Ubuntu CI).

AI-assisted: yes

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6567028668 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/972). Originally posted by [Batushn](https://github.com/Batushn) on 2026-11-23T19:21:51Z. --- ## Summary Implements step 2 of #938: decode the GFX10 `VOP3_INTERP` 16-bit interpolation instructions (`v_interp_p1ll_f16`, `v_interp_p1lv_f16`, and `v_interp_p2_f16`) in `tools/disasm_rdna2.py` with LLVM 15's exact operand syntax instead of falling through to `v_vop3_342` / `v_vop3_343` / `v_vop3_35a`. - **`tools/disasm_rdna2.py`:** - Added `VOP3_INTERP16_OPS` (`0x342` `v_interp_p1ll_f16`, `0x343` `v_interp_p1lv_f16`, `0x35a` `v_interp_p2_f16`). - Decoded `VOP3Interp_gfx10` fields matching LLVM 15.0.7 (`VOPInstructions.td` / `VOP3Instructions.td`): `attr` (`w1[5:0]`), `attrchan` (`w1[7:6]`), `high` (`w1[8]`), `src0` (`w1[17:9]`, `abs=w0[9]`, `neg=w1[30]`), optional `src2` (`w1[26:18]`, `abs=w0[10]`, `neg=w1[31]`), `clamp` (`w0[15]`), and `omod` (`w1[28:27]` for `f32`-destination `p1ll`/`p1lv` only; omitted on `p2_f16`). - **`tests/rdna2_tools_check.py`:** - Added `test_vop3_interp_f16_encodings`: 26 golden GFX10 encodings verified against LLVM 15.0.7 `test/MC/AMDGPU/gfx10_asm_vop3.s`, covering all 3 opcodes, `attr`/`attrchan`, `-`/`|...|`/`-|...|`, `high`, `clamp`, `mul:2`/`mul:4`/`div:2`, 8-byte stream alignment with `s_endpgm`, and 4-byte `vop3_truncated` handling. - Added `test_vop3_interp_f16_llvm_round_trip`: assembles 11 single-field and combined `v_interp_*_f16` cases with `llvm-mc`, checks exact equality against `llvm_disassemble`, and re-assembles `disasm_rdna2`'s output back to identical bytes (runs in Ubuntu LLVM 15 CI). - Added `test_binary_scan_recognizes_vop3_interp_f16`: verifies `scan_unsupported_shaders.py` now recognizes the decoded opcodes (`opcodes_recognized=True`, `unsupported_opcodes={}`) while keeping them unlowered (`translator_accepted=False`, `compatibility_category="opcode_recognized_translator_rejected"`), with negative control on the old `v_vop3_342`/`343`/`35a` names. Refs #938 ## Verification - `python -B tests/rdna2_tools_check.py` on Windows 11 (Python 3.12.10, synthetic inputs, no game files): `Ran 81 tests ... OK (skipped=3)` (the 3 skipped tests require `llvm-mc`/`llvm-objcopy` and will run in Ubuntu CI). AI-assisted: yes
upstream-sync closed this pull request 2026-11-24 06:45:39 +00:00
R0Y00 commented 2026-11-24 06:49:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T19:34:39Z.


Thanks for the independent LLVM 15 comparison and the single-field controls. #970 has now landed the same three opcodes and scan classification. It also distinguishes encodings LLVM 15 refuses, such as an output modifier on P2 or an attribute modifier, so both implementations would compete for the same decode path. Closing this duplicate; any golden vector that exposes a difference against current main is welcome as a separate test or fix under #938. #977 continues as its own review for carry and image atomic names.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7111800460 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/972#issuecomment-7111800460). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T19:34:39Z. --- Thanks for the independent LLVM 15 comparison and the single-field controls. #970 has now landed the same three opcodes and scan classification. It also distinguishes encodings LLVM 15 refuses, such as an output modifier on P2 or an attribute modifier, so both implementations would compete for the same decode path. Closing this duplicate; any golden vector that exposes a difference against current main is welcome as a separate test or fix under #938. #977 continues as its own review for carry and image atomic names.

Pull request closed

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!965
No description provided.