tooling: scan records after s_endpgm #1048
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1055"
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 romn4rch on 2026-11-23T23:37:07Z.
Change
disasm_rdna2stopped at the firsts_endpgmeven when the caller supplied more code, so the shader scan omitted later records. Continue decoding the supplied span, name SOPP opcode0x1fass_code_end, and recognize it in the scanner without marking it translator-supported. The LLVM 15 fixture also confirms the all-zero word must remain a four-byte unknown record. Lowering and caller-owned bounds remain unchanged.Fixes #938
Verification
python -B tests/rdna2_tools_check.py- passed: 97 tests, 8 skipped. The LLVM source-built boundary test was skipped locally becauseLLVM_LIB,llvm-mc, andllvm-objcopyare unavailable.git diff --check- passed.ctest --preset dev --no-tests=error -R '^rdna2_tools_check$'- not run; the CTest build tree is not configured (out\build\dev\CTestTestfile.cmakeis absent).Evidence and follow-up
The synthetic gfx1013 regressions cover a one-exit control, a branch past the first exit,
s_code_end, and a trailing zero word. The binary scan test verifies that post-exit instructions are counted while lowering still rejects them after program end. The LLVM 15 source-built comparison runs when its tools are available. No game files or external samples are used. Format-aware callers remain responsible for trimming verified padding; no README or build documentation change is needed because no public build requirement changed.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T23:47:49Z.
The
Assemble and translate gfx1013 fixturesjob fails on one test. The immediate cause is in the SOPP table: SOPP0x14is notS_CODE_END, it isS_INCPERFLEVEL.S_CODE_ENDis0x1f, and it is missing from the table.The ISA. In the RDNA 2 reference (§12.5, https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf) the
Opcode #column is decimal: 14 isS_SLEEP, which is0x0e; 20 isS_INCPERFLEVEL, which is0x14; 31 isS_CODE_END, which is0x1f. LLVM 15.0.7, the encoder this job runs, has the same numbers for the GFX10 generation gfx1013 belongs to (llvm/lib/Target/AMDGPU/[email protected]:S_SLEEP0x00e,S_INCPERFLEVEL0x014,S_CODE_END0x01f).The CI log confirms it for gfx1013:
llvm-mc -mcpu=gfx1013assembleds_code_endto the word your decoder reports ass_sopp_1f, i.e. SOPP0x1f.Your decoder, run locally on the four words (I did not run
llvm-mcmyself, so the CI log is my only LLVM 15 evidence):So the entry at
tools/disasm_rdna2.py:137names the wrong opcode,0x1fis missing, and0x0eis a separate gap in the same table.Consequences beyond the red test:
S_INCPERFLEVEL(0x14) decodes ass_code_endand takes the no-operand branch attools/disasm_rdna2.py:1685, so itsSIMM16operand is dropped and the scan counts a perf-level instruction as a code-end marker.S_CODE_ENDstill comes back as an unrecognised SOPP, so the scan never sees the marker this PR is about.0x0eabsent, a realS_SLEEPdecodes tos_sopp_0e, which cannot match thes_sleeppattern inSUPPORTED_INSTRUCTIONS_REGEX(tools/scan_unsupported_shaders.py:89). That predates this PR, but it is the same table.Offset 20 differs as well, and the log shows it: your decoder returns
(20, 4, 'v_vop2_00', 'v_vop2_00 v0, s0, v0')where the expectation saysword_0x00000000/.long 0x00000000.0x00000000matches the VOP2 test (bit 31 == 0) before the.longfallback. But VOP2 opcode0x000is not a defined gfx10 instruction — LLVM 15 putsV_CNDMASK_B32at0x001— so the decoder is inventing an instruction for an undefined encoding, and the.longexpectation matches what LLVM 15 does with that word: it fails to decode it. Since I have not run LLVM 15 here, whetherassertRaisesRegex(ValueError, "at byte 20$")passes on that job is unverified: check it there rather than change the expectation.Two things I would raise on the change itself rather than on the red:
s_endpgmmeans every trailing padding word in a shader is now decoded — that is what surfaces offset 20 here. It is worth saying in the PR body, because the scan output for existing files changes.assertTrue(is_opcode_recognized("s_code_end"))is circular: it compares a name againstKNOWN_RDNA2_BASE_OPCODES(tools/scan_unsupported_shaders.py:363-375) and never touches the decode table. Only the decode path proves the marker is recognised.Suggested table, if it helps:
Note that
test_s_code_end_is_recognized_but_not_translatedin this PR decodes000094bfand expectss_code_end; once0x14is renamed it has to use00009fbf. And theelsebranch prints these immediates as0x0, where LLVM prints0; several tests compare against LLVM's text, so that format will need to match.AI-assisted; I read the failing job log and ran your decoder locally on the words above. I did not run
llvm-mcor libLLVM 15, so the LLVM 15 behaviour at offset 20 is unverified.Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-24T00:00:45Z.
Checked at
edb4eb20, and the job that was red is now green.Assemble and translate gfx1013 fixtures: success. It runsLLVM_LIB=libLLVM-15.so.1 LLVM_MC=llvm-mc-15 LLVM_OBJCOPY=llvm-objcopy-15 python3 -B tests/rdna2_tools_check.py— 97 tests, no failure — sotest_source_built_records_after_s_endpgmpassed against real LLVM output this time. That is the assertion that carried the diagnosis, and it now holds with0x1fin the table.Locally on your head, the four words behave as follows:
So the marker and the zero word are both where you want them.
0x0eand0x14still fall through to the unknown-SOPP path; that is not a blocker for this PR, and thes_sleepregex point stays open only if you want it folded in here.The two Windows jobs were still
in_progresswhen I looked, so this is about the LLVM job and the Linux Python job (both green), not the whole gate.AI-assisted.