disasm_rdna2: decode GFX10 VOP3P packed instructions and sync scanner #537

Manually merged
github merged 2 commits from gh-pr/537/head into gh-pr/537/base 2026-11-26 21:59:49 +00:00
Owner

@⁠Holastor on GitHub · 2026-11-22 10:04 UTC · original
Holastor:tools/vop3p-disasm-and-scanner → main · +276 −2 · 4 files · 2 commits · merged 2026-11-22 11:23 UTC

Description

Following the addition of packed binary16, integer16, dot products, and mixed-precision FMAs to pixel_aot.py (via PRs #376, #389, #391, and #397), this PR updates the standalone RDNA 2 disassembler tools/disasm_rdna2.py and the static instruction scanner tools/scan_unsupported_shaders.py so they decode and track these instructions without requiring libLLVM.

Summary of Changes

  1. tools/disasm_rdna2.py:

    • Added table VOP3P_OPS and set VOP3P_3SRC covering all 29 GFX10 VOP3P instructions:
      • Packed float16: v_pk_add_f16, v_pk_mul_f16, v_pk_min_f16, v_pk_max_f16, v_pk_fma_f16.
      • Packed integer16: v_pk_add_i16, v_pk_add_u16, v_pk_sub_i16, v_pk_sub_u16, v_pk_min_i16, v_pk_min_u16, v_pk_max_i16, v_pk_max_u16, v_pk_mul_lo_u16, v_pk_mad_i16, v_pk_mad_u16, v_pk_lshlrev_b16, v_pk_lshrrev_b16, v_pk_ashrrev_i16.
      • Dot products: v_dot2_f32_f16, v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_i32_i8, v_dot4_u32_u8, v_dot8_i32_i4, v_dot8_u32_u4.
      • Mixed-precision FMAs: v_fma_mix_f32, v_fma_mixlo_f16, v_fma_mixhi_f16.
    • Added decoding logic for 64-bit VOP3P instructions ((w0 & 0xff800000) == 0xcc000000), unpacking vdst, op, clamp, src0, src1, src2, handling 2-source vs 3-source assembly, and supporting optional 32-bit literal constants (length 12 bytes).
    • Added missing GFX10 VOP1 float math opcodes to VOP1_OPS: 0x22 (v_ceil_f32_e32), 0x23 (v_floor_f32_e32), 0x24 (v_rndne_f32_e32), 0x2b (v_fract_f32_e32), 0x2c (v_trunc_f32_e32), and 0x34 (v_frexp_mant_f32_e32).
  2. tools/scan_unsupported_shaders.py:

    • Added VOP3P opcodes to KNOWN_RDNA2_BASE_OPCODES (both statically and synchronized with pixel_aot).
    • Added VOP3P (Vector Packed / Mixed-Precision) classification to classify_isa_category(opcode).
    • Added supported regexes in SUPPORTED_INSTRUCTIONS_REGEX matching the lowered VOP3P instructions.
  3. tests/rdna2_tools_check.py:

    • Added golden test vectors for new VOP1 and VOP3P instructions (v_floor_f32_e32, v_fract_f32_e32, v_trunc_f32_e32, v_ceil_f32_e32, v_pk_add_u16, v_pk_max_f16 clamp, v_dot2_f32_f16, v_fma_mix_f32).
    • Added synthetic test test_vop3p_opcode_table_synthetic_forms verifying all 29 opcodes, truncation, and 32-bit literal offsets.
    • Added test_vop3p_classification asserting classify_isa_category assigns "VOP3P (Vector Packed / Mixed-Precision)".
  4. tests/pso_readiness_check.py:

    • Extended check_scanner_tracks_pixel_aot() to assert is_opcode_recognized and is_instruction_supported for VOP3P_F16, VOP3P_INT16, v_fma_mix*, and all 7 v_dot* instructions.

Evidence & Verification

All pure-Python checks passed without skips or errors:

$ python -B tests/rdna2_tools_check.py
Ran 35 tests in 0.469s
OK (skipped=1)

$ python -B tests/pso_readiness_check.py
PSO census, evidence states, and native hash control passed

$ python -B tests/shader_probe_check.py
OK

$ python -B tests/dxil_retarget_check.py
pure-python dxil_retarget controls: ok

$ python -B tests/bidi_controls_check.py
Checked 504 tracked source, script and build/CI files: no bidirectional controls.

$ python -B tests/docs_links_check.py
Checked 10 Markdown files and 112 links.
**@⁠Holastor** on GitHub · 2026-11-22 10:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/537) `Holastor:tools/vop3p-disasm-and-scanner` → `main` · +276 −2 · 4 files · 2 commits · merged 2026-11-22 11:23 UTC ## Description Following the addition of packed binary16, integer16, dot products, and mixed-precision FMAs to `pixel_aot.py` (via PRs #376, #389, #391, and #397), this PR updates the standalone RDNA 2 disassembler `tools/disasm_rdna2.py` and the static instruction scanner `tools/scan_unsupported_shaders.py` so they decode and track these instructions without requiring `libLLVM`. ### Summary of Changes 1. **`tools/disasm_rdna2.py`**: - Added table `VOP3P_OPS` and set `VOP3P_3SRC` covering all 29 GFX10 VOP3P instructions: - Packed float16: `v_pk_add_f16`, `v_pk_mul_f16`, `v_pk_min_f16`, `v_pk_max_f16`, `v_pk_fma_f16`. - Packed integer16: `v_pk_add_i16`, `v_pk_add_u16`, `v_pk_sub_i16`, `v_pk_sub_u16`, `v_pk_min_i16`, `v_pk_min_u16`, `v_pk_max_i16`, `v_pk_max_u16`, `v_pk_mul_lo_u16`, `v_pk_mad_i16`, `v_pk_mad_u16`, `v_pk_lshlrev_b16`, `v_pk_lshrrev_b16`, `v_pk_ashrrev_i16`. - Dot products: `v_dot2_f32_f16`, `v_dot2_i32_i16`, `v_dot2_u32_u16`, `v_dot4_i32_i8`, `v_dot4_u32_u8`, `v_dot8_i32_i4`, `v_dot8_u32_u4`. - Mixed-precision FMAs: `v_fma_mix_f32`, `v_fma_mixlo_f16`, `v_fma_mixhi_f16`. - Added decoding logic for 64-bit VOP3P instructions (`(w0 & 0xff800000) == 0xcc000000`), unpacking `vdst`, `op`, `clamp`, `src0`, `src1`, `src2`, handling 2-source vs 3-source assembly, and supporting optional 32-bit literal constants (length 12 bytes). - Added missing GFX10 VOP1 float math opcodes to `VOP1_OPS`: `0x22` (`v_ceil_f32_e32`), `0x23` (`v_floor_f32_e32`), `0x24` (`v_rndne_f32_e32`), `0x2b` (`v_fract_f32_e32`), `0x2c` (`v_trunc_f32_e32`), and `0x34` (`v_frexp_mant_f32_e32`). 2. **`tools/scan_unsupported_shaders.py`**: - Added VOP3P opcodes to `KNOWN_RDNA2_BASE_OPCODES` (both statically and synchronized with `pixel_aot`). - Added `VOP3P (Vector Packed / Mixed-Precision)` classification to `classify_isa_category(opcode)`. - Added supported regexes in `SUPPORTED_INSTRUCTIONS_REGEX` matching the lowered VOP3P instructions. 3. **`tests/rdna2_tools_check.py`**: - Added golden test vectors for new VOP1 and VOP3P instructions (`v_floor_f32_e32`, `v_fract_f32_e32`, `v_trunc_f32_e32`, `v_ceil_f32_e32`, `v_pk_add_u16`, `v_pk_max_f16 clamp`, `v_dot2_f32_f16`, `v_fma_mix_f32`). - Added synthetic test `test_vop3p_opcode_table_synthetic_forms` verifying all 29 opcodes, truncation, and 32-bit literal offsets. - Added `test_vop3p_classification` asserting `classify_isa_category` assigns `"VOP3P (Vector Packed / Mixed-Precision)"`. 4. **`tests/pso_readiness_check.py`**: - Extended `check_scanner_tracks_pixel_aot()` to assert `is_opcode_recognized` and `is_instruction_supported` for `VOP3P_F16`, `VOP3P_INT16`, `v_fma_mix*`, and all 7 `v_dot*` instructions. --- ## Evidence & Verification All pure-Python checks passed without skips or errors: ```bash $ python -B tests/rdna2_tools_check.py Ran 35 tests in 0.469s OK (skipped=1) $ python -B tests/pso_readiness_check.py PSO census, evidence states, and native hash control passed $ python -B tests/shader_probe_check.py OK $ python -B tests/dxil_retarget_check.py pure-python dxil_retarget controls: ok $ python -B tests/bidi_controls_check.py Checked 504 tracked source, script and build/CI files: no bidirectional controls. $ python -B tests/docs_links_check.py Checked 10 Markdown files and 112 links. ```
Decode and print non-default VOP3P operand selection and negation modifier fields (op_sel, op_sel_hi, neg_lo, neg_hi, clamp) so packed instruction variants stay distinguishable from default forms. Retain existing golden vectors in rdna2_tools_check.py and add distinguishable encodings verification.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:59:46 +00:00
github manually merged commit 557fda2d38 into gh-pr/537/base 2026-11-26 21:59:49 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 10:25 UTC · original

The rebased head a53dae5 drops the existing golden vectors for standalone VOP1 rounding, literal FMA, VINTRP, EXP, SMEM, and basic MIMG added in #517. Please retain those cases alongside the new VOP3P vectors.

The decoder currently prints only register/literal operands and clamp. It also needs to distinguish encodings with non-default packed source selections or source sign modifiers. Dropping those fields can make a different instruction look like a supported default form to the scanner and lowerer. Please either decode and print the fields or mark those encodings unsupported in the fallback decoder. A raw-word or LLVM-based pair with identical operands and only a selection/modifier bit changed should show that the two encodings stay distinguishable.

**@⁠R0Y00** on GitHub · 2026-11-22 10:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/537#issuecomment-7077779513) The rebased head a53dae5 drops the existing golden vectors for standalone VOP1 rounding, literal FMA, VINTRP, EXP, SMEM, and basic MIMG added in #517. Please retain those cases alongside the new VOP3P vectors. The decoder currently prints only register/literal operands and clamp. It also needs to distinguish encodings with non-default packed source selections or source sign modifiers. Dropping those fields can make a different instruction look like a supported default form to the scanner and lowerer. Please either decode and print the fields or mark those encodings unsupported in the fallback decoder. A raw-word or LLVM-based pair with identical operands and only a selection/modifier bit changed should show that the two encodings stay distinguishable.
Author
Owner

@⁠Holastor on GitHub · 2026-11-22 11:08 UTC · original

@⁠R0Y00
Updated in cc4e820:

  1. Restored golden vectors: Retained all 26 existing golden vectors introduced in #517 (tests/rdna2_tools_check.py) covering VOP1 rounding, literal FMA, VINTRP, EXP, SMEM, and MIMG alongside the GFX10 VOP3P vectors (v_pk_add_u16, v_pk_max_f16, v_dot2_f32_f16, and v_fma_mix_f32).

  2. VOP3P modifier and selection decoding: In tools/disasm_rdna2.py, unpacked op_sel, op_sel_hi, neg_lo, and neg_hi bitfields:

    • When modifiers differ from their architectural defaults (op_sel = 0, op_sel_hi = 1 for packed math / 0 for v_fma_mix*, neg_lo = 0, neg_hi = 0), the disassembler emits the modifier tokens (e.g. op_sel:[1,0], op_sel_hi:[0,1], neg_lo:[1,0], neg_hi:[1,0], clamp) matching standard AMDGPU assembly. This prevents non-default selection or negation forms from masquerading as default supported forms to the scanner or lowerer.
    • For 2-source VOP3P encodings, non-zero reserved bits (src2 != 0, neg_lo[2], neg_hi[2], or op_sel[2]) are flagged as <unsupported_reserved_bits>, while op_sel_hi[2] (bit 14 of word 0) is ignored to align with LLVM MC which initializes op_sel_hi to 0b111 across all packed instructions.
  3. Distinguishability verification: Added test_vop3p_distinguishes_non_default_modifiers_and_selections in tests/rdna2_tools_check.py with raw-word pairs having identical operands (v4, v3, 1 or v1, v2, v3, v4) and modified selection/negation/clamp bits, verifying that they decode to distinct disassembled forms and do not collapse into the default form.

**@⁠Holastor** on GitHub · 2026-11-22 11:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/537#issuecomment-7078246129) @⁠R0Y00 Updated in `cc4e820`: 1. **Restored golden vectors**: Retained all 26 existing golden vectors introduced in #517 (`tests/rdna2_tools_check.py`) covering VOP1 rounding, literal FMA, VINTRP, EXP, SMEM, and MIMG alongside the GFX10 VOP3P vectors (`v_pk_add_u16`, `v_pk_max_f16`, `v_dot2_f32_f16`, and `v_fma_mix_f32`). 2. **VOP3P modifier and selection decoding**: In `tools/disasm_rdna2.py`, unpacked `op_sel`, `op_sel_hi`, `neg_lo`, and `neg_hi` bitfields: - When modifiers differ from their architectural defaults (`op_sel = 0`, `op_sel_hi = 1` for packed math / `0` for `v_fma_mix*`, `neg_lo = 0`, `neg_hi = 0`), the disassembler emits the modifier tokens (e.g. `op_sel:[1,0]`, `op_sel_hi:[0,1]`, `neg_lo:[1,0]`, `neg_hi:[1,0]`, `clamp`) matching standard AMDGPU assembly. This prevents non-default selection or negation forms from masquerading as default supported forms to the scanner or lowerer. - For 2-source VOP3P encodings, non-zero reserved bits (`src2 != 0`, `neg_lo[2]`, `neg_hi[2]`, or `op_sel[2]`) are flagged as `<unsupported_reserved_bits>`, while `op_sel_hi[2]` (bit 14 of word 0) is ignored to align with LLVM MC which initializes `op_sel_hi` to `0b111` across all packed instructions. 3. **Distinguishability verification**: Added `test_vop3p_distinguishes_non_default_modifiers_and_selections` in `tests/rdna2_tools_check.py` with raw-word pairs having identical operands (`v4, v3, 1` or `v1, v2, v3, v4`) and modified selection/negation/clamp bits, verifying that they decode to distinct disassembled forms and do not collapse into the default form.
This discussion has been locked. Commenting is limited to contributors.
No description provided.