disasm_rdna2: decode GFX10 VOP3P packed instructions and sync scanner #531
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/537"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-22T10:04:18Z.
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 disassemblertools/disasm_rdna2.pyand the static instruction scannertools/scan_unsupported_shaders.pyso they decode and track these instructions without requiringlibLLVM.Summary of Changes
tools/disasm_rdna2.py:VOP3P_OPSand setVOP3P_3SRCcovering all 29 GFX10 VOP3P instructions:v_pk_add_f16,v_pk_mul_f16,v_pk_min_f16,v_pk_max_f16,v_pk_fma_f16.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.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.v_fma_mix_f32,v_fma_mixlo_f16,v_fma_mixhi_f16.(w0 & 0xff800000) == 0xcc000000), unpackingvdst,op,clamp,src0,src1,src2, handling 2-source vs 3-source assembly, and supporting optional 32-bit literal constants (length 12 bytes).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), and0x34(v_frexp_mant_f32_e32).tools/scan_unsupported_shaders.py:KNOWN_RDNA2_BASE_OPCODES(both statically and synchronized withpixel_aot).VOP3P (Vector Packed / Mixed-Precision)classification toclassify_isa_category(opcode).SUPPORTED_INSTRUCTIONS_REGEXmatching the lowered VOP3P instructions.tests/rdna2_tools_check.py: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).test_vop3p_opcode_table_synthetic_formsverifying all 29 opcodes, truncation, and 32-bit literal offsets.test_vop3p_classificationassertingclassify_isa_categoryassigns"VOP3P (Vector Packed / Mixed-Precision)".tests/pso_readiness_check.py:check_scanner_tracks_pixel_aot()to assertis_opcode_recognizedandis_instruction_supportedforVOP3P_F16,VOP3P_INT16,v_fma_mix*, and all 7v_dot*instructions.Evidence & Verification
All pure-Python checks passed without skips or errors:
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T10:25:07Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-22T11:08:30Z.
@R0Y00
Updated in
cc4e820: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, andv_fma_mix_f32).VOP3P modifier and selection decoding: In
tools/disasm_rdna2.py, unpackedop_sel,op_sel_hi,neg_lo, andneg_hibitfields:op_sel = 0,op_sel_hi = 1for packed math /0forv_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.src2 != 0,neg_lo[2],neg_hi[2], orop_sel[2]) are flagged as<unsupported_reserved_bits>, whileop_sel_hi[2](bit 14 of word 0) is ignored to align with LLVM MC which initializesop_sel_hito0b111across all packed instructions.Distinguishability verification: Added
test_vop3p_distinguishes_non_default_modifiers_and_selectionsintests/rdna2_tools_check.pywith raw-word pairs having identical operands (v4, v3, 1orv1, 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.