rdna2: record an ISA conformance corpus for the decoder #540
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/540"
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 brcly/TuxBox. Originally posted by csj0oe on 2026-11-29T21:08:21Z.
What
115 cases covering instruction classes across control-flow contexts, stages and operand modes, each recording the encoded words and the decode they are expected to produce (465 instruction lines).
tools/isa_conformance/model.pybuilds a covering array over the four factors andtools/isa_conformance/record.pyregenerates the matrix cases, the record and the coverage counts from the case files.Coverage over the realizable matrix is complete: 182 of 182 pairwise and 10 of 10 dangerous triples, with the remaining combinations recorded as not realizable and the reason. The opcode table covers 45 of 1,088 mnemonics across 1,401
(encoding, opcode)keys; that ratio is honest — this is an interaction matrix, not an opcode sweep.The suite found four decoder gaps, recorded as exact-set ratchets rather than fixed here: DPP and sub-dword instructions lose their first source,
v_readlane_b32reports a VGPR instead of the scalar destination, VOP3B secondary destinations are not operands, and SMEMsoffsetis missing. Fixing one fails the ratchet until the list shrinks.Where the encoded words come from
Every
bytesline is LLVM's encoding of the case text, and everylineisllvm-objdump's reading of the same object. Reproduce one case by hand:The whole corpus, including the matrix cases:
It needs only
llvm-mcandllvm-objdumponPATH, and it fails listing every case when one does not assemble, so a record entry cannot drift from its case text or lose an instruction. LLVM 22.1.8 produced this record.Two cases carry
# cpu: gfx1010becausev_mad_f32andv_madak_f32have no gfx1030 encoding; the directive is in the case file and the record. No case is hand-encoded any more: the sub-dword case that used to hold hand-written words is nowv_mov_b32 v1, v2 dst_sel:BYTE_1 src0_sel:BYTE_0.No licensed or restricted output is committed. Everything here is LLVM assembler and disassembler output for text in this tree: no container bytes, no vendor disassembly text, no SDK headers, tables or binaries.
Two naming differences, normalised in the test
The expected text keeps LLVM's spelling; the test normalises it instead of renaming the decoder's output:
v_mov_b32_e32,v_add_f32_e64,v_mov_b32_dpp,v_mov_b32_sdwa— where the decoder names the operation, so the suffix is dropped from the expected mnemonic.vcc_lo; the decoder reportsvcc.The DPP8 expected text now names its permutation, which the previous record omitted, so
dpp8-movjoins both gap ratchets.Regenerating the matrix
tools/isa_conformance/model.pyholds the factors, the class bodies, the contexts and the dangerous triples.record.py matrixrewritesfixtures/isa-conformance/matrix/andmatrix.txt;tests/test_isa_conformance.pyrecomputes the counts and fails if the two disagree.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T21:11:50Z.
Thanks. A covering array over instruction class, context, stage and operand form is a good way to find decoder gaps, and the four you found are useful. Two questions before we can review it:
matrix/cases come fromtools/isa_conformance/model.py, which isn't in the PR. Could you add it, so the matrix can be regenerated and reviewed?llvm-mcfor gfx1030), please say so and add the command; if any came from the console reference compiler, they can't be committed (the same issue as #539 and #531).Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T22:03:04Z.
Thanks, this addresses it: the words now come from
llvm-mc, which anyone can run. We're putting it through the full check on both of our cards now and will merge it (as one squashed commit) if it passes.Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T22:13:41Z.
Merged as
6bab5478onmain(squashed into one commit). The full check passed on an RTX 4070 Ti SUPER and a Radeon 610M. Thanks!Pull request closed