tooling: decode the VOP1 rounding, frexp and operand-free opcodes in disasm_rdna2 #1654

Merged
vladbondarenko97 merged 1 commit from upstream-pr/1661 into main 2026-11-24 17:40:44 +00:00
vladbondarenko97 commented 2026-11-24 16:40:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by vladbondarenko97 on 2026-11-24T16:40:50Z.


Change

Eleven VOP1 opcodes (0x17-0x1b, 0x3c-0x41) printed as v_vop1_NN in the e32 and VOP3 spellings: v_trunc_f64, v_ceil_f64, v_rndne_f64, v_floor_f64, v_fract_f64, v_frexp_exp_i32_f64, v_frexp_mant_f64, v_frexp_exp_i32_f32, v_frexp_mant_f32, v_pipeflush, v_clrexcp. They now decode as llvm-mc prints them for gfx1013. The binary64 and operand-free forms have no SDWA or DPP spelling and stay eight-byte refusals; v_pipeflush and v_clrexcp print bare and take no literal. The scanner recognizes the three names it did not know. Decoding and recognition only. Follows #1593 (v_frexp_exp_i32_f64 uses its one-register result). Refs #938.

Verification

Commit 1ca92d57 on main c864f138, macOS, Python 3.14.

  • python -B tests/rdna2_tools_check.py: Ran 147, OK (skipped=18).
  • The two new tests against tools/ without this commit: decode test FAILED (failures=23), scan test FAILED (failures=1).
  • 3,000 random e32/e64 words over the 11 opcodes compared with llvm-mc 23.1.6: only the difference classes the existing v_rcp_f64/v_rsq_f64/v_sqrt_f64 already have.

Not run: the Windows ctest, and LLVM 15 (the new tests are golden strings and need no LLVM).

Evidence and follow-up

No lowering, no readback. The decoder does not check that VDST is zero for v_pipeflush/v_clrexcp (llvm-mc refuses a non-zero VDST; v_nop has the same gap). Still v_vop1_NN: the f16 transcendentals 0x54-0x5a, 0x60, 0x61 (#938 shows an earlier f16 claim, so I left them). Fixtures are hand-assembled words and llvm-mc output, no game data.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI use: Claude Code. Claude Sonnet 5.5 wrote the change, the tests and the llvm-mc sweep; Claude Opus 5.5 rebased it, reran the suite and reviewed the diff. I reviewed it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6586744499 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1661). Originally posted by [vladbondarenko97](https://github.com/vladbondarenko97) on 2026-11-24T16:40:50Z. --- ## Change Eleven VOP1 opcodes (0x17-0x1b, 0x3c-0x41) printed as `v_vop1_NN` in the e32 and VOP3 spellings: `v_trunc_f64`, `v_ceil_f64`, `v_rndne_f64`, `v_floor_f64`, `v_fract_f64`, `v_frexp_exp_i32_f64`, `v_frexp_mant_f64`, `v_frexp_exp_i32_f32`, `v_frexp_mant_f32`, `v_pipeflush`, `v_clrexcp`. They now decode as llvm-mc prints them for gfx1013. The binary64 and operand-free forms have no SDWA or DPP spelling and stay eight-byte refusals; `v_pipeflush` and `v_clrexcp` print bare and take no literal. The scanner recognizes the three names it did not know. Decoding and recognition only. Follows #1593 (`v_frexp_exp_i32_f64` uses its one-register result). Refs #938. ## Verification Commit 1ca92d57 on main c864f138, macOS, Python 3.14. - `python -B tests/rdna2_tools_check.py`: Ran 147, OK (skipped=18). - The two new tests against `tools/` without this commit: decode test FAILED (failures=23), scan test FAILED (failures=1). - 3,000 random e32/e64 words over the 11 opcodes compared with llvm-mc 23.1.6: only the difference classes the existing `v_rcp_f64`/`v_rsq_f64`/`v_sqrt_f64` already have. Not run: the Windows ctest, and LLVM 15 (the new tests are golden strings and need no LLVM). ## Evidence and follow-up No lowering, no readback. The decoder does not check that VDST is zero for `v_pipeflush`/`v_clrexcp` (llvm-mc refuses a non-zero VDST; `v_nop` has the same gap). Still `v_vop1_NN`: the f16 transcendentals 0x54-0x5a, 0x60, 0x61 (#938 shows an earlier f16 claim, so I left them). Fixtures are hand-assembled words and llvm-mc output, no game data. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI use: Claude Code. Claude Sonnet 5.5 wrote the change, the tests and the llvm-mc sweep; Claude Opus 5.5 rebased it, reran the suite and reviewed the diff. I reviewed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tedin7 commented 2026-11-24 17:01:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:47:24Z.

Review: COMMENTED


Peer review at head_sha: 1ca92d57f04e2d6c20f3e457d39eff5d108a5900

Findings

No defects found.

  • tools/disasm_rdna2.py: adds the 11 VOP1 opcodes (0x17..0x1b, 0x3c..0x41), handles VOP1_NO_OPERAND_OPS (v_pipeflush, v_clrexcp) in both _e32 (4-byte, no literal dword even with SRC0=255) and _e64 (8-byte, 0-arity), and adds v_frexp_exp_i32_f64 to narrow_dst so its destination is a single VGPR.
  • tools/scan_unsupported_shaders.py: adds v_pipeflush, v_clrexcp, and v_frexp_exp_i32_f32 to KNOWN_RDNA2_BASE_OPCODES for recognition.
  • tests/rdna2_tools_check.py, docs/experiments.md: comprehensive unit tests covering _e32, _e64, SDWA/DPP forms and refusals, and scanner recognition; 100% title-neutral.

Verification

  • Linux:
    • python3 -B tests/rdna2_tools_check.py: 147 tests ran, OK (skipped=18) (2.839s, exit 0).
    • Local mutation check: temporarily replaced if op_name in VOP1_NO_OPERAND_OPS: with if False: in tools/disasm_rdna2.py and ran python3 -B tests/rdna2_tools_check.py — failed as expected (5 failures in test_vop1_rounding_frexp_and_no_operand_opcodes, exit 1); restored cleanly (git status --short clean).
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): cmake --build --preset dev --target offscreen_check -- -j 6 (10.33s); ctest --preset dev -R '^rdna2_tools_check$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (5.31s).
    • Release /O2 (--preset release): cmake --build --preset release --target offscreen_check -- -j 6 (8.03s); ctest --preset release -R '^rdna2_tools_check$' --parallel 4 --no-tests=error --output-on-failure: 1/1 passed (5.25s).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043548746 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1661#pullrequestreview-6043548746). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:47:24Z. **Review:** COMMENTED --- Peer review at `head_sha`: `1ca92d57f04e2d6c20f3e457d39eff5d108a5900` ### Findings No defects found. - `tools/disasm_rdna2.py`: adds the 11 VOP1 opcodes (`0x17..0x1b`, `0x3c..0x41`), handles `VOP1_NO_OPERAND_OPS` (`v_pipeflush`, `v_clrexcp`) in both `_e32` (4-byte, no literal dword even with `SRC0=255`) and `_e64` (8-byte, 0-arity), and adds `v_frexp_exp_i32_f64` to `narrow_dst` so its destination is a single VGPR. - `tools/scan_unsupported_shaders.py`: adds `v_pipeflush`, `v_clrexcp`, and `v_frexp_exp_i32_f32` to `KNOWN_RDNA2_BASE_OPCODES` for recognition. - `tests/rdna2_tools_check.py`, `docs/experiments.md`: comprehensive unit tests covering `_e32`, `_e64`, SDWA/DPP forms and refusals, and scanner recognition; 100% title-neutral. ### Verification - **Linux**: - `python3 -B tests/rdna2_tools_check.py`: **147 tests ran, OK (skipped=18)** (`2.839s`, exit 0). - **Local mutation check**: temporarily replaced `if op_name in VOP1_NO_OPERAND_OPS:` with `if False:` in `tools/disasm_rdna2.py` and ran `python3 -B tests/rdna2_tools_check.py` — failed as expected (`5` failures in `test_vop1_rounding_frexp_and_no_operand_opcodes`, exit 1); restored cleanly (`git status --short` clean). - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - **Debug (`--preset dev`)**: `cmake --build --preset dev --target offscreen_check -- -j 6` (`10.33s`); `ctest --preset dev -R '^rdna2_tools_check$' --parallel 4 --no-tests=error --output-on-failure`: **1/1 passed** (`5.31s`). - **Release `/O2` (`--preset release`)**: `cmake --build --preset release --target offscreen_check -- -j 6` (`8.03s`); `ctest --preset release -R '^rdna2_tools_check$' --parallel 4 --no-tests=error --output-on-failure`: **1/1 passed** (`5.25s`). AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 18:02:23 +00:00
ChazY11 commented 2026-11-24 18:02:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T17:29:58Z.


Ran this at 1ca92d57. The decoder changes hold up against the unit expectations, but the strongest check in this suite is not running here, and for a table of opcode names that matters.

out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py
Ran 147 tests in 6.014s
OK (skipped=18)

Mutation evidence that the new entries are exercised

I removed or changed three things the patch adds, and restored the file each time:

change result
v_clrexcp dropped from VOP1_NO_OPERAND_OPS caught
0x3f renamed from v_frexp_exp_i32_f32_e32 to v_frexp_mant_f32_e32 caught
the no-operand return width changed from 4 to 8 bytes caught

So the table is not dead weight: a wrong name, a wrong membership or a wrong instruction width each fails the suite.

What is not running, and why I am raising it

All 18 skips are the same kind:

... skipped 'LLVM_LIB environment variable not set; verification against LLVM is skipped'
test_vop1_vop2_e32_llvm_round_trip   skipped  'LLVM_LIB ...'
Issue #1298: the vectors assemble to these bytes and LLVM 15 disassembles them to the same strings   skipped

That is exactly the mechanism that would independently confirm the names in this patch — v_frexp_exp_i32_f32_e32 versus v_frexp_mant_f32_e32 is a claim about what LLVM prints, and with LLVM_LIB unset nothing here compares against LLVM. My mutant caught the swap only because the expected string in the test is hand-written from the same source as the table, which is correlation, not confirmation.

Two questions, both cheap to answer in the PR body:

  1. Were the new entries compared against an actual llvm-mc/llvm-objdump run with gfx1013 support? If so, a line with the version and the two printed mnemonics (v_frexp_exp_i32_f32_e32, v_frexp_mant_f32_e32) would make the claim checkable for everyone else.
  2. Are the byte widths of v_pipeflush and v_clrexcp (the 4-versus-8 distinction, which the no-operand path decides) taken from LLVM or from the ISA table? The patch asserts LLVM prints the bare mnemonic and takes no literal dword "even when SRC0 is 255" — that is a specific behaviour worth citing where it was observed.

Neither blocks the change. If the comparison was done outside CI, recording it in the PR body is all I would ask; otherwise a reader has to take the mnemonics on trust, which is the one thing this repository is careful about everywhere else.

Otherwise

docs/experiments.md and the two tools move together, and the scanner picks up the new no-operand classification. Nothing else stood out.

Verdict

Reviewed 1ca92d57. Decoding is exercised by the suite (three mutations caught); the LLVM cross-check for the new names is skipped in this environment and should be recorded explicitly.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139285450 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1661#issuecomment-7139285450). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T17:29:58Z. --- Ran this at `1ca92d57`. The decoder changes hold up against the unit expectations, but the strongest check in this suite is not running here, and for a table of opcode names that matters. ```powershell out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py ``` ```text Ran 147 tests in 6.014s OK (skipped=18) ``` ## Mutation evidence that the new entries are exercised I removed or changed three things the patch adds, and restored the file each time: | change | result | |---|---| | `v_clrexcp` dropped from `VOP1_NO_OPERAND_OPS` | **caught** | | `0x3f` renamed from `v_frexp_exp_i32_f32_e32` to `v_frexp_mant_f32_e32` | **caught** | | the no-operand return width changed from 4 to 8 bytes | **caught** | So the table is not dead weight: a wrong name, a wrong membership or a wrong instruction width each fails the suite. ## What is not running, and why I am raising it All 18 skips are the same kind: ```text ... skipped 'LLVM_LIB environment variable not set; verification against LLVM is skipped' test_vop1_vop2_e32_llvm_round_trip skipped 'LLVM_LIB ...' Issue #1298: the vectors assemble to these bytes and LLVM 15 disassembles them to the same strings skipped ``` That is exactly the mechanism that would independently confirm the *names* in this patch — `v_frexp_exp_i32_f32_e32` versus `v_frexp_mant_f32_e32` is a claim about what LLVM prints, and with `LLVM_LIB` unset nothing here compares against LLVM. My mutant caught the swap only because the expected string in the test is hand-written from the same source as the table, which is correlation, not confirmation. Two questions, both cheap to answer in the PR body: 1. Were the new entries compared against an actual `llvm-mc`/`llvm-objdump` run with gfx1013 support? If so, a line with the version and the two printed mnemonics (`v_frexp_exp_i32_f32_e32`, `v_frexp_mant_f32_e32`) would make the claim checkable for everyone else. 2. Are the byte widths of `v_pipeflush` and `v_clrexcp` (the 4-versus-8 distinction, which the no-operand path decides) taken from LLVM or from the ISA table? The patch asserts LLVM prints the bare mnemonic and takes no literal dword "even when SRC0 is 255" — that is a specific behaviour worth citing where it was observed. Neither blocks the change. If the comparison was done outside CI, recording it in the PR body is all I would ask; otherwise a reader has to take the mnemonics on trust, which is the one thing this repository is careful about everywhere else. ## Otherwise `docs/experiments.md` and the two tools move together, and the scanner picks up the new no-operand classification. Nothing else stood out. ## Verdict Reviewed `1ca92d57`. Decoding is exercised by the suite (three mutations caught); the LLVM cross-check for the new names is skipped in this environment and should be recorded explicitly.
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!1654
No description provided.