tooling: decode VOP2 carry ops and GFX10 MIMG image_atomic_* in disasm_rdna2 #977

Manually merged
github merged 2 commits from gh-pr/977/head into gh-pr/977/base 2026-11-26 22:32:29 +00:00
Owner

@⁠Batushn on GitHub · 2026-11-23 19:25 UTC · original
Batushn:disasm/vop2-carry-and-mimg-atomics → main · +154 −0 · 2 files · 2 commits · merged 2026-11-23 19:57 UTC

Summary

Implements the VOP2 carry and MIMG image_atomic_* part of step 3 in #938 (leaving SDWA VOPC separate so each change stays small and easy to review):

  • tools/disasm_rdna2.py:
    • Added GFX10 VOP2 carry opcodes 0x28 (v_add_co_ci_u32_e32), 0x29 (v_sub_co_ci_u32_e32), and 0x2a (v_subrev_co_ci_u32_e32) to VOP2_OPS and formatted them with LLVM 15's wave32 implicit carry operands (v{vdst}, vcc_lo, {src0}, v{vsrc1}, vcc_lo), matching v_cndmask_b32_e32. Previously these fell through to v_vop2_28/29/2a and were falsely reported as unsupported even though pixel_aot already accepts them.
    • Added all 16 GFX10 MIMG image_atomic_* opcodes (0x0f..0x12, 0x14..0x1f: swap, cmpswap, add, sub, smin, umin, smax, umax, and, or, xor, inc, dec, fcmpswap, fmin, fmax) to MIMG_OPS, matching LLVM 15.0.7 MIMGInstructions.td.
  • tests/rdna2_tools_check.py:
    • Added test_vop2_carry_and_mimg_atomic_encodings: 22 golden LLVM 15.0.7 encodings (gfx10_asm_vop2.s & gfx10_asm_mimg.s) covering all 3 VOP2 carry ops (VGPR, inline constants, 32-bit literal) and all 16 GFX10 image_atomic_* opcodes (including cmpswap/fcmpswap 2-dword vdata and NSA address tuples), plus vop2_truncated and mimg_truncated controls.
    • Added test_vop2_carry_and_mimg_atomic_llvm_round_trip: assembles all 3 VOP2 carry ops and all 16 image_atomic_* ops with llvm-mc, checks exact equality with llvm_disassemble and disasm_rdna2, and re-assembles disasm_rdna2's output back to identical bytes (runs in Ubuntu LLVM 15 CI).
    • Added test_binary_scan_recognizes_vop2_carry_and_image_atomics: proves binary scanning now marks decoded VOP2 carry ops as both recognized and supported (4/4 supported, 0 unsupported) while keeping image_atomic_umax recognized (opcodes_recognized=True) yet unlowered (opcode_recognized_translator_rejected), with negative controls on the old v_vop2_28/29/2a names.

Refs #938

Verification

  • python -B tests/rdna2_tools_check.py on Windows 11 (Python 3.12.10, synthetic inputs, no game files): Ran 83 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:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/977) `Batushn:disasm/vop2-carry-and-mimg-atomics` → `main` · +154 −0 · 2 files · 2 commits · merged 2026-11-23 19:57 UTC ## Summary Implements the VOP2 carry and MIMG `image_atomic_*` part of step 3 in #938 (leaving SDWA VOPC separate so each change stays small and easy to review): - **`tools/disasm_rdna2.py`:** - Added GFX10 VOP2 carry opcodes `0x28` (`v_add_co_ci_u32_e32`), `0x29` (`v_sub_co_ci_u32_e32`), and `0x2a` (`v_subrev_co_ci_u32_e32`) to `VOP2_OPS` and formatted them with LLVM 15's wave32 implicit carry operands (`v{vdst}, vcc_lo, {src0}, v{vsrc1}, vcc_lo`), matching `v_cndmask_b32_e32`. Previously these fell through to `v_vop2_28`/`29`/`2a` and were falsely reported as unsupported even though `pixel_aot` already accepts them. - Added all 16 GFX10 MIMG `image_atomic_*` opcodes (`0x0f`..`0x12`, `0x14`..`0x1f`: `swap`, `cmpswap`, `add`, `sub`, `smin`, `umin`, `smax`, `umax`, `and`, `or`, `xor`, `inc`, `dec`, `fcmpswap`, `fmin`, `fmax`) to `MIMG_OPS`, matching LLVM 15.0.7 `MIMGInstructions.td`. - **`tests/rdna2_tools_check.py`:** - Added `test_vop2_carry_and_mimg_atomic_encodings`: 22 golden LLVM 15.0.7 encodings (`gfx10_asm_vop2.s` & `gfx10_asm_mimg.s`) covering all 3 VOP2 carry ops (VGPR, inline constants, 32-bit literal) and all 16 GFX10 `image_atomic_*` opcodes (including `cmpswap`/`fcmpswap` 2-dword `vdata` and NSA address tuples), plus `vop2_truncated` and `mimg_truncated` controls. - Added `test_vop2_carry_and_mimg_atomic_llvm_round_trip`: assembles all 3 VOP2 carry ops and all 16 `image_atomic_*` ops with `llvm-mc`, checks exact equality with `llvm_disassemble` and `disasm_rdna2`, and re-assembles `disasm_rdna2`'s output back to identical bytes (runs in Ubuntu LLVM 15 CI). - Added `test_binary_scan_recognizes_vop2_carry_and_image_atomics`: proves binary scanning now marks decoded VOP2 carry ops as both recognized and supported (`4/4` supported, `0` unsupported) while keeping `image_atomic_umax` recognized (`opcodes_recognized=True`) yet unlowered (`opcode_recognized_translator_rejected`), with negative controls on the old `v_vop2_28`/`29`/`2a` names. Refs #938 ## Verification - `python -B tests/rdna2_tools_check.py` on Windows 11 (Python 3.12.10, synthetic inputs, no game files): `Ran 83 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:27 +00:00
github manually merged commit 778101b614 into gh-pr/977/base 2026-11-26 22:32:29 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.