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

Closed
github-bot wants to merge 1 commit from gh-pr/972/head into gh-pr/972/base
Owner

@⁠Batushn on GitHub · 2026-11-23 19:21 UTC · original
Batushn:disasm/vop3-interp-f16 → main · +147 −0 · 2 files · 1 commits · closed without merging

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

**@⁠Batushn** on GitHub · 2026-11-23 19:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/972) `Batushn:disasm/vop3-interp-f16` → `main` · +147 −0 · 2 files · 1 commits · closed without merging ## 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:32:10 +00:00
github-bot closed this pull request 2026-11-26 22:32:10 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 19:34 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-23 19:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/972#issuecomment-7111800460) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.