tooling: decode GFX10 VOP1 and VOP2 SDWA instructions #1179
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1186"
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 Batushn on 2026-11-24T02:59:29Z.
Change
Decode GFX10 8-byte
VOP1andVOP2SDWA(src0=249) forms intools/disasm_rdna2.pyinstead of returning<unsupported SDWA>placeholders._decode_vop1_sdwa(VOP_SDWA9Ae): handlesv_noprestricted SDWA form, scalar/VGPRsrc0(src0_sel,sext/abs/neg),dst_sel,dst_unused(UNUSED_PAD/UNUSED_SEXT/UNUSED_PRESERVE),clamp,omod(mul:2,mul:4,div:2), and rejects 64-bit / non-SDWAVOP1ops, invalid selectors, scalar codes forbidden onv_movrel*, and LLVM 15 unsupported scalar codes (209-234,249,250,255)._decode_vop2_sdwa(VOP_SDWA9Ae/VOP_SDWA9Befor carry opsv_add_co_ci_u32,v_sub_co_ci_u32,v_subrev_co_ci_u32,v_cndmask_b32): handles two-operandsrc0/src1selectors & modifiers (includingv_ldexp_f16intsrc1andv_cvt_pkrtz_f16_f32floatsrc0/src1), carry-invcc_loonSDWA9Be, and rejects unsupported VOP2 opcodes (0x02,0x06,0x0d,0x1f..0x21,0x2b..0x2d,0x36..0x38,0x3c) and invalid fields._format_sdwa_float_modifierswith_decode_vopc_sdwa.Verification
Commit
89e00bf(based onmain063df2c):python -B tests/rdna2_tools_check.py:Ran 112 tests in 2.616s — OK (skipped=11)(the 11 skips are tests gated onLLVM_LIB, which is not configured in this local environment).python -B tests/shader_census_check.py: passed (7/7).python -B tests/shader_corpus_report_check.py: passed (8/8).python -B tests/shader_probe_check.py: passed.python -B tests/docs_links_check.py: passed (253 links checked).python -B tests/bidi_controls_check.py: passed (948 files checked).Evidence and follow-up
tests/rdna2_tools_check.pyare synthetic little-endian instruction words cross-checked against LLVM 15 (VOPInstructions.td,VOP1Instructions.td,VOP2Instructions.td).VOP1/VOP2SDWA opcodes, invaliddst_sel/src_sel/omodfields, SGPR onv_movrel*, and non-zero reserved/fixed control bits.LLVM_LIBconfigured will also exercise the 11 LLVM-cross-check tests.Checklist
AI-assisted: yes
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:03:58Z.
Review: COMMENTED
Technical review on Linux (Windows build/tests were not executed locally).
Checks run (Linux, commit
89e00bf8)python3 tests/rdna2_tools_check.py:Ran 112 tests in 2.273s — OK (skipped=11)(withoutLLVM_LIB).python3 -B tests/shader_census_check.py:Ran 7 tests in 0.419s — OK.python3 -B tests/shader_corpus_report_check.py:Ran 8 tests in 0.639s — OK.python3 -B tests/docs_links_check.pyandpython3 -B tests/bidi_controls_check.py: passed.python3 -B tests/shader_probe_check.py: failed withModuleNotFoundError: No module named 'pefile'in this environment.LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so LLVM_MC=/usr/bin/llvm-mc-19 LLVM_OBJCOPY=/usr/bin/llvm-objcopy-19 python3 -B tests/rdna2_tools_check.py -k "vop1_vop2" -v: failed intest_vop1_vop2_sdwa_llvm_round_trip(see findings).Findings
tests/rdna2_tools_check.py(test_vop1_vop2_sdwa_llvm_round_trip):Line 1472 calls
resolve_llvm_assembler_tools(), which is not defined intests/rdna2_tools_check.py(existing tests useresolve_tool("LLVM_MC", ...)andresolve_tool("LLVM_OBJCOPY", ...)). WhenLLVM_LIBis set, the test raisesNameError: name 'resolve_llvm_assembler_tools' is not defined.f9040a02c106860e(v_cndmask_b32_sdwa ... sext(v2)):Both
libLLVM-19.so(Unknown instruction at byte 0) andllvm-mc-19(error: not a valid operandonsext(v2)) rejectsext(v2)onv_cndmask_b32_sdwa, andlibLLVM-19.soacceptsv_movrels_b32_sdwa/v_movrelsd_b32_sdwawiths2(f986007e02068600,f988007e02068600). Please verify against LLVM 15 onceresolve_llvm_assembler_tools()is fixed.Decoder logic (
_decode_vop1_sdwa,_decode_vop2_sdwa,0xF9dispatch,v_nopmask,dst_sel/dst_unused/src*_sel,omod/clamp/sext/abs/neg,vcc_loon carry ops/v_cndmask_b32, and scanner sync intest_binary_scan_recognizes_vop1_vop2_sdwa) is otherwise clean and title-neutral.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:40:54Z.
Review: COMMENTED
Retest on Linux at commit
832abf98(Windows build/tests were not executed locally).Checks run (Linux, commit
832abf98)/root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py:Ran 112 tests in 2.607s — OK (skipped=11)(withoutLLVM_LIB)./root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py -k "vop1_vop2" -v:Ran 4 tests — OK (skipped=2)(withoutLLVM_LIB)./root/.local/share/x2w-rev-venv/bin/python -B tests/shader_probe_check.py,tests/form_coverage_check.py,tests/shader_census_check.py(7/7),tests/shader_corpus_report_check.py(8/8),tests/docs_links_check.py,tests/bidi_controls_check.py: all passed.LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so LLVM_MC=/usr/bin/llvm-mc-19 LLVM_OBJCOPY=/usr/bin/llvm-objcopy-19 /root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py -k "vop1_vop2" -v:Ran 4 tests — FAILED (errors=2)intest_vop1_vop2_sdwa_llvm_round_trip(see below).Retest status against previous review (
89e00bf8)resolve_llvm_assembler_tools()NameError:test_vop1_vop2_sdwa_llvm_round_tripnow usesresolve_tool("LLVM_MC", ...)andresolve_tool("LLVM_OBJCOPY", ...), so the assembler/objcopy lookup no longer raisesNameError.f9040a02c106860e(v_cndmask_b32_sdwa v5, -1, sext(v2), vcc_lo ...): Under LLVM 19,libLLVM-19.sostill raisesValueError: Unknown instruction at byte 0onf9040a02c106860e, andllvm-mc-19rejectssext(v2)witherror: not a valid operand. All other 28 vectors inVOP1_VOP2_SDWA_DECODEDassemble withllvm-mc-19and disassemble withlibLLVM-19.so(perAGENTS.md, CI runs LLVM 15, which remains authoritative for this vector).