disasm_rdna2: consume the second dword of DPP, SDWA and literal-K forms #687
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/693"
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 roansystemlabs on 2026-11-22T20:38:46Z.
Change
tools/disasm_rdna2.pyreturns 4 bytes for several 32-bit encodings that carry a second dword, so the next record starts inside the instruction.scan_unsupported_shaders.pyuses this decoder for.bininputs, so a shader that contains one of these forms is split into phantom instructions.v_fmamk_f16,v_fmaak_f16(VOP2 0x37, 0x38)s_setreg_imm32_b32(SOPK 0x15)Example on
main(3b9bb1a):v_mov_b32_dpp v5, v1 dpp8:[0,1,2,3,4,5,6,7]followed bys_endpgm(e9020a7e 0188c6fa 000081bf) decodes asv_mov_b32_e32 v5, s233and then an 8-byteexpbuilt from the selector word and thes_endpgm. The program end is never seen. The scanner also reports the first record,v_mov_b32_e32 v5, s233, as supported, becauses233matches its register pattern; the same happens withs249(SDWA) ands250(DPP16). On this branch these records are reported as unsupported.This PR returns each of these forms as one 8-byte record:
vop1_dpp8,vop2_sdwa, … and assembly<mnemonic>_dpp <unsupported DPP8>/<mnemonic>_sdwa <unsupported SDWA>, with the mnemonic LLVM uses for that form. Operands are not decoded yet. This follows what the decoder already does for VOPC SDWA (vopc_sdwa,<unsupported SDWA>).v_fmamk_f16/v_fmaak_f16: decoded likev_fmamk_f32/v_fmaak_f32, with the K literal.s_setreg_imm32_b32:s_setreg_imm32_b32 0x<simm16>, 0x<literal>(raw hwreg field, no symbolic name).*_truncatedrecord, as the literal forms already do.VOP3 encodings are out of scope: their lengths are the subject of #576.
Verification
Windows 11 (build 26200), Python 3.12 venv from
requirements-dev.txt, branch1e30f79on3b9bb1a.New test
test_second_dword_forms_keep_the_stream_alignedintests/rdna2_tools_check.py. Ten encodings copied from the LLVM 15.0.7 MC fixtures (gfx10_asm_vop1.s,gfx10_asm_vop2.s,gfx10_asm_dpp8.s,gfx10_asm_sop.s), each followed bys_endpgm: the test checks one 8-byte record, thens_endpgmat offset 8, the assembly text and the truncated case. A control checks that the neighbouring SRC0 codes 232, 235, 248, 251 and 256 still give a 4-bytev_mov_b32_e32.rdna2_tools_check.py: 53 tests OK, 1 skipped (test_llvm_comparison, needsLLVM_LIB; CI runs it on Linux).main'sdisasm_rdna2.pyfails for all ten encodings (for example[(0, 4, 'v_mov_b32_e32'), (4, 8, 'exp')]for DPP8).AGENTS.md: all exit 0.Differential length audit (not added to the repository). Every instruction/encoding pair in ten LLVM 15.0.7 GFX10 MC fixtures (
gfx10_asm_vop1,vop2,vopc,vopcx,vopc_sdwa,dpp8,dpp16,sop,sopp-gfx10,smem) was decoded withdecode_instruction. The decoded length was compared with the fixture's encoding length. Each encoding was then followed bys_endpgmto check that the next record starts on it.main3b9bb1as_endpgmnot found at its offsetThe 5,341 broke down as 1,622 VOP1 SDWA, 1,442 VOP2 SDWA, 1,350 VOP1 DPP16, 738 VOP2 DPP16, 167 DPP8, 18
v_fmamk_f16/v_fmaak_f16and 4s_setreg_imm32_b32. The 4,890 VOP3 encodings in the same files are unchanged (#576). With this branch merged locally with #576 (git merge-tree, no conflict), all 25,265 encodings decode to the LLVM length andrdna2_tools_check.pypasses. The branch also merges without conflict with #621 and passes the same file.Negative controls. Each mutation was applied to a scratch copy of
tools/andtests/and the new test was run. All eight fail:v_fmamk_f16/v_fmaak_f16without the literals_setreg_imm32_b32literal not consumedFull suite. The change is Python-only and touches no GPU path. I ran the full suite anyway, on an earlier revision of this branch that differed only in where the helper and the test sit in their files, on an RTX 3070 (driver 32.0.16.2101, 621.01) and WARP, debug layer as configured by the
devpreset:ctest --preset dev --no-tests=error --timeout 300 -j 4gave 293 passed, 4 capability skips (bvh_wave64_hardware,bvh_wave64_warp,wave_shuffle_warp,cpu_aot_crypto_sha) and 0 failed. Onmainthe same command once hit the 60 s timeout inpixel_aot_predicate_rounding_hardware(#448). That test does not use this decoder. GPU load during the runs (nvidia-smi): 0–6 % utilization, about 5.6 GB VRAM used by resident local services.Evidence and follow-up
llvm/test/MC/AMDGPU, tagllvmorg-15.0.7, Apache-2.0 WITH LLVM-exception), used as independent reference bytes, as the existing VOPC test already does.llvm-mcfor AMDGPU locally: the official Windows LLVM build ships only the x86 target. The reference is the fixture bytes, not a local LLVM run.hwreg(...)operand ofs_setreg_imm32_b32, and thes_waitcntfield split (GFX10vmcntissimm16[3:0]plus[15:14], andexpcntis[6:4]; the decoder readsvmcntfrom[7:4]). Each can be a separate PR.Checklist
AI-assisted: yes. Prepared with an AI coding agent; I checked the results above.