tooling: sign-extend the SMEM immediate offset in disasm_rdna2 #1977
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1984"
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 RenzoWit35 on 2026-11-24T22:36:47Z.
Change
On GFX9+ and RDNA 2 the SMEM OFFSET[20:0] field is a signed 21-bit byte offset, and LLVM's AMDGPU disassembler sign-extends it and prints negative values as
-0x<hex>.tools/disasm_rdna2.pymasked the field to 21 bits and printed it unsigned, so an encoded -1 appeared as0x1fffff(+2 MiB). The SMEM branch now sign-extends after masking and prints negative values as-0x<hex>in both the plain form and theoffset:form used with an SGPR soffset. Positive output is byte-identical.Verification
Environment: Windows 11, Python 3.14.5, current
origin/main.python -B tools/disasm_rdna2.py --hex "000000f4ffff1ffa": befores_load_dword s0, s[0:1], 0x1fffff, afters_load_dword s0, s[0:1], -0x1.python -B tests/rdna2_tools_check.py: after the fixRan 152 tests ... OK (skipped=19).origin/maintools/disasm_rdna2.pyfails intest_golden_vectors:'s_load_dword s0, s[0:1], 0x1fffff' != 's_load_dword s0, s[0:1], -0x1'.s0 offset:-0x1).Consumers of the text:
tools/scan_unsupported_shaders.pymatches SMEM lines with0x[0-9a-f]+, so a negative offset no longer matches and the line is treated as unsupported, which is the conservative outcome (previously it was silently accepted as a huge positive offset).tools/startup/gfx2hlsl.pyparses the plain operand withint(token, 0), which accepts-0x1.Not run: the LLVM comparison in
test_llvm_comparison(needs LLVM_LIB, not installed). Theoffset:-0x1spelling for the soffset form is kept consistent with the plain form; I could not confirm it against LLVM output here.Evidence and follow-up
Rebased on current
main. No open PR touchestools/disasm_rdna2.py. The sibling PRs for the CLI input errors and VOPC DPP change other parts of the same two files; the three merge in any order.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T22:39:09Z.
Review: COMMENTED
Review of head
83bb752d2d.P1 (blocking): this change breaks an existing check, and the Linux CI job fails.
python3 -B tests/startup_smem_address_check.pypasses on current main. With this head it fails:Cause: the startup translator reads the disassembler text. Once the offset prints as a negative value, a negative immediate is no longer refused with the
SMEM immediate offsetreason. It is now reported as anSMEM modifier offset:-0x...message instead. The disassembler change needs either a matching update in the consumer (so a negative immediate is still refused with the same reason) or an updated check that states the new intended behavior. Please also say which one is intended.The fix itself looks right: for the new vectors (
-0x1,-0x100000,0xfffff,offset:-0x1) the decode matches the signed 21-bit rule.Commands run locally:
python3 tests/rdna2_tools_check.py: OK, 152 tests (19 skipped)python3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: cleangit merge-tree --write-tree --name-only origin/main HEAD: no conflictspython3 -B tests/startup_smem_address_check.py: FAIL on this head, pass withtools/disasm_rdna2.pyfrom origin/maingh pr checks 1984: Linux Python checks FAIL; Windows jobs were still pendingNot run: Win2025 and mutation checks, because the P1 above already blocks merge.
Counts: P1 = 1, P2 = 0. No merge. Please push a fixed head and it will be re-checked.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T23:11:18Z.
Both Linux jobs had stopped at
SMEM modifier offset:-0x100000. Accept the new spelling in the existing validator while refusing the address with the same specific diagnostic. Explicit signed hex, signed decimal and older positive field spellings all refuse. Local SMEM controls, translator checks, decoder suite and Markdown links passed.