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

Merged
Batushn merged 2 commits from upstream-pr/977 into main 2026-11-23 19:57:11 +00:00
Batushn commented 2026-11-23 19:25:47 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6567097211 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/977). Originally posted by [Batushn](https://github.com/Batushn) on 2026-11-23T19:25:47Z. --- ## 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
upstream-sync closed this pull request 2026-11-24 06:45:40 +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!970
No description provided.