Repository navigation
rdna2_decode: decode the gfx101x SMEM stores, scratch ops, atomics and s_atc_probe* - #7421
hmodymac8-droid wants to merge 2 commits into
Conversation
…d s_atc_probe* rdna2_isa_tables.SMEM is the RDNA2 (gfx103x) XML set, but rdna2_decode's default target is gfx1013, where llvm-mc 23.1.6 also decodes s_store_dword*, s_scratch_load/store_dword*, s_buffer_store_dword*, s_atomic_* and s_buffer_atomic_* (and _x2, cmpswap with the doubled width) and s_dcache_discard*. rdna2_decode reported each of them as invalid words. They go in a new SMEM_GFX101 table that the decoder consults only when mcpu is gfx101x, so a gfx1030 listing still refuses them as llvm-mc does. s_atc_probe and s_atc_probe_buffer (0x26, 0x27) exist on both targets; their SDATA field is the probe-mode immediate (`s_atc_probe 4, s[2:3], 16`). Checked four random words per SMEM opcode on gfx1013 and gfx1030 against llvm-mc: every word llvm-mc decodes now decodes to the same instruction and operands. What still differs is pre-existing and out of scope: immediate offsets print in decimal where llvm-mc prints hex (as s_load_dword already does on main), and a negative SMEM buffer offset prints unsigned (as s_buffer_load does on main). tests/test_rdna2_decode.py: test_gfx101_smem_stores_atomics_and_probes (fails on main); the file: OK. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent CPU review at
|
|
Tested 5f65cf7 on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): fail, one more gfx101x-only SMEM opcode is still reported as invalid ( What I ran:
Independent reference: llvm-mc is not installed here, and the local LLVM 22.1.1 (clang, llvm-objdump) has no AMDGPU target. So I used LLVM's own llvm-mc test vectors instead:
The 248 vectors for the new opcodes include The bug: Nits, none blocking:
Overlap: open #6237 ("tests: add schema and decoder-contract invariant tests for rdna2_isa_tables") merges cleanly with this PR, but its Not cross-checked: gfx1013 itself (the LLVM vectors are gfx1010; I relied on the shared AI-assisted (Claude Code). |
…nts as llvm-mc does Review on ItsNotRexed#7421 (AsgerCode): s_dcache_wb (0x21, no operands) is gfx101x-only like the rest and was still invalid; llvm-mc 23.1.6 decodes its vector 000084f400000000 on gfx1013 and refuses it on gfx1030. Added to SMEM_GFX101. The probe mode is printed as llvm-mc 23.1.6 prints it: decimal up to 64, hex from 65 (all 128 values of s_atc_probe and s_atc_probe_buffer checked). The table now uses the plain SDATA field for it and the decoder keys on the name, so no new operand name enters rdna2_isa_tables (ItsNotRexed#6237 checks them). The test moves next to test_mubuf_mtbuf_mimg_global_ds_exp_vintrp, apart from the other open rdna2_decode PRs' tests, and gains the 64/0x41 probe cases and s_dcache_wb. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @SweatierKey and @AsgerCode, both checks are very helpful. Pushed fc959a5:
|
…codes Review on ItsNotRexed#7337 (AsgerCode): the 31 *_src2_* entries sat in the shared DS table, so gfx1030 decoded them too, where llvm-mc 23.1.6 refuses them (and LLVM's gfx1030_err.s lists them as unsupported). They move to DS_GFX101, which the decoder reads only when mcpu is gfx101x, as ItsNotRexed#7421 does for its SMEM ops; the test checks gfx1030 and gfx1036 refuse ds_add_src2_u32. The condxchg32 and read2 test words had a nonzero unused DATA1 field, which llvm-mc refuses; they now use the words llvm-mc decodes to the expected text, so every row of the test is llvm-mc's output. Every DS word this PR changes against main, over all 256 opcodes, four operand/offset patterns and gfx1013/gfx1030/gfx1036: either it now matches llvm-mc, or llvm-mc refuses that word for a nonzero unused field, which main ignores as well. The tables' docstring names DS_GFX101. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested fc959a5 on Linux, Python 3.14.4, llvm-mc 21.1.8: pass
One leftover, same on main and not from this PR: s_get_waveid_in_workgroup (0x2a) still decodes on gfx1030, where llvm-mc refuses it. |
What changed and why
rdna2_isa_tables.SMEMis the RDNA2 (gfx103x) XML set, butrdna2_decode's default target is gfx1013.On gfx1013, llvm-mc 23.1.6 also decodes these, and
rdna2_decodereported every one of them as invalid words:s_store_dword*,s_scratch_load_dword*,s_scratch_store_dword*,s_buffer_store_dword*s_atomic_*ands_buffer_atomic_*, including_x2andcmpswapat the doubled widths_dcache_discard*They go in a new
SMEM_GFX101table that the decoder uses only whenmcpuis gfx101x, so a gfx1030 listing still refuses them, as llvm-mc does.s_atc_probeands_atc_probe_buffer(0x26,0x27) exist on both targets. Their SDATA field is the probe-mode immediate (s_atc_probe 4, s[2:3], 16).Found by decoding every opcode of every encoding with both
rdna2_decodeand llvm-mc and comparing.Claim: #7231 (new item).
Test
s_load_dwordalready does;s_buffer_loadalready does.python -I -m unittest tests.test_rdna2_decode: OK. The newtest_gfx101_smem_stores_atomics_and_probesfails on main.tests/test_shader_ir.py,tests/test_shader_disasm.py: OK.GPU and driver
No GPU needed.
AI-assisted (Claude Code).
🤖 Generated with Claude Code