disasm_rdna2: format 64-bit SOP1 and SOP2 operands as register pairs #682
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/688"
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-22T20:21:14Z.
Summary
Addresses review feedback on #688 by addressing the root cause in
tools/disasm_rdna2.pyrather than loosening operand syntax in the shader translator and scanner:s[N:N+1]), matching standard LLVM assembly syntax (llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1013).tools/disasm_rdna2.pyformatted SOP1 and SOP2 operands usingdecode_s_reg()instead ofdecode_s_reg64(), emitting single register names (e.g.s2instead ofs[2:3]) for 64-bit instructions (s_mov_b64,s_not_b64,s_and_b64, etc.).decode_instruction()intools/disasm_rdna2.pyto usedecode_s_reg64()for 64-bit SOP1 and SOP2 instructions, keeping single registers for 32-bit shift counts/bitfield offsets (s_lshl_b64,s_lshr_b64,s_ashr_b64,s_bfe_u64,s_bfe_i64,s_bfm_b64).0x0b: ("s_cselect_b64", "Scalar conditional select 64-bit")toSOP2_OPS.tests/rdna2_tools_check.pywith golden vectors for 64-bit SOP1/SOP2 pair formatting (s_mov_b64 s[2:3], s[0:1],s_not_b64,s_and_b64,s_lshl_b64,s_wqm_b64).tools/pixel_aot.py,tools/pixel_cb_read.py, andtools/scan_unsupported_shaders.py, avoiding non-LLVM syntax, scanner-translator disparity, and conflicts with #700.Verification
tests/rdna2_tools_check.py: 54 passed (1 capability skip for localLLVM_LIB).tests/pixel_aot_check.py: Passed.tests/docs_links_check.py: Checked 10 Markdown files and 134 links, all passed.tests/bidi_controls_check.py: Checked 601 tracked files, all passed.tests/pso_readiness_check.py: Passed.tests/dxil_retarget_check.py: Passed.Imported from R0Y00/Xbox2Windows. Originally posted by MatyEjsr on 2026-11-22T21:51:41Z.
Verdict: Request changes (reviewed head
dac105cbd407531ed963da998a4ff3aa8ca8106d, compared againstmain4c3b573).Verification
Environment: Windows 11 x64, Python 3.12.10, and WSL Arch
llvm-mc23.1.5 (-triple=amdgcn--amdpal -mcpu=gfx1013). Zero-GPU review (no WARP or hardware draw executed).Commands and results on
dac105c:python -B tests/pixel_aot_check.py: passed (exit 0).python -B tests/rdna2_tools_check.py: 53 passed, 1 skipped (test_llvm_comparison, skipped becauseLLVM_LIBis not set on Windows).python -B tests/docs_links_check.pyandpython -B tests/bidi_controls_check.py: both passed.git merge-tree --write-tree main dac105c: clean against4c3b573(exit 0); conflicts with #700 (git merge-treeexit 1).Issues to address
Root cause is
tools/disasm_rdna2.pyformatting, not Wave32 /gfx1013assembly syntax:llvm-mc -triple=amdgcn--amdpal -mcpu=gfx1013 -show-encoding: single-SGPR operands on 64-bit SALU ops are rejected (s_mov_b64 s0, s2,s_and_b64 s0, s2, s4,s_lshl_b64 s0, s2, 4,s_bfe_u64 s0, s2, s4all fail witherror: invalid operand for instruction), whereass[0:1], s[2:3]assembles and disassembles cleanly.s_mov_b64 s2, s0) comes fromtools/disasm_rdna2.pycallingdecode_s_reginstead ofdecode_s_reg64(unlike SOPC/VOPC, which already usedecode_s_reg64). Fixingdisasm_rdna2.pyto emits[N:N+1]for 64-bit SOP1/SOP2 instructions addresses the root cause without introducing non-LLVM syntax intopixel_aot.py,pixel_cb_read.py, andscan_unsupported_shaders.py.Scanner vs. translator disagreement and missing opcode recognition (
tools/scan_unsupported_shaders.py):SCALAR64_DSTandSCALAR64_SOURCEallows\d+without checking even alignment or the0..104bound, sois_instruction_supported()returnsTruefor inputs thatpixel_aot.pyrejects:s_mov_b64 s45, s46,s_mov_b64 s44, s45,s_mov_b64 s106, s44s_and_b64 s45, s44, s46,s_and_b64 s44, s45, s46s_bfe_u64 s45, s44, s46,s_bfm_b64 s45, 4, 8s_bfe_[ui]64is added toSUPPORTED_INSTRUCTIONS_REGEX, makingis_instruction_supported("s_bfe_u64 s44, s44, s46") == True, whiles_bfe_u64ands_bfe_i64are missing fromKNOWN_RDNA2_BASE_OPCODES(is_opcode_recognized() == False).tools/pixel_cb_read.pyleaks unrelated #684 changes and has incomplete/unvalidated 64-bit write tracking:#684exec_lo/s_wqm_b32 exec, exec/s_and_b32 exec, ...changes (mixing a separate PR into this one).if op.endswith(("_b64", "_i64", "_u64")) and re.fullmatch(r"s\d+", dest): return range(n, n + 2)skips even-alignment and range checks (scalar_writes("s_mov_b64 s45, s46") == range(45, 47),scalar_writes("s_mov_b64 s105, s46") == range(105, 107)).s_not_b64,s_brev_b64, ands_cmov_b64were added to the opcode list; other 64-bit SALU ops widened inpixel_aot.py(s_and_b64,s_or_b64,s_cselect_b64,s_lshl_b64,s_bfm_b64,s_bfe_u64) still returnNonefromscalar_writes().Conflict and contradiction with #700, plus no runtime draw coverage for general
s_mov_b64:s_bfe_*64/s_bfm_b64.s_mov_b64lowering inpixel_aot.pyis only checked statically incheck_controls(), with no observable draw test.AI-assisted review (local Python and
llvm-mcchecks executed locally).Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-22T22:21:37Z.
Thanks for the thorough review and for pinpointing the root cause, @MatyEjsr! You're completely right:
llvm-mcstrictly requiress[N:N+1]pairs for 64-bit SALU operations inamdgcn--amdpal -mcpu=gfx1013, and the single-SGPR syntax was an artifact oftools/disasm_rdna2.pyformatting withdecode_s_reg()instead ofdecode_s_reg64().We have updated this PR to fix the root cause cleanly:
tools/disasm_rdna2.py:decode_s_reg64()forsdstandssrc0.decode_s_reg64()forsdst,ssrc0(excepts_bfm_b64), andssrc1(except 32-bit shift/bfe operandss_lshl_b64,s_lshr_b64,s_ashr_b64,s_bfe_u64,s_bfe_i64,s_bfm_b64).s_cselect_b64(opcode0x0b) toSOP2_OPS.tools/pixel_aot.py,tools/pixel_cb_read.py, andtools/scan_unsupported_shaders.py:tests/rdna2_tools_check.py):s_mov_b64 s2, s0tos_mov_b64 s[2:3], s[0:1].s_not_b64 s[2:3], s[0:1],s_and_b64 s[0:1], s[2:3], s[4:5],s_lshl_b64 s[0:1], s[2:3], s4,s_mov_b64 s[50:51], exec,s_wqm_b64 exec, exec, ands_and_b64 exec, exec, s[50:51].All test suites pass locally (
tests/rdna2_tools_check.py,tests/pixel_aot_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py,tests/pso_readiness_check.py,tests/dxil_retarget_check.py).