Shader tests: the GFX10 decoder against llvm-mc on every opcode (checked-in fixture, no LLVM needed) #87
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/uiliannn--VItoriaBr!87
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-87"
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?
@lcg007xd-c on GitHub · 2026-11-25 22:18 UTC · original
lcg007xd-c:test/llvm-decoder-oracle→main· +7649 −0 · 3 files · 1 commits · openWhat
This checks the GFX10 decoder against LLVM's, on every opcode, without needing LLVM to run the tests.
gfx10/llvm-mc-gfx1030.txt(264 KB, plain text) records whatllvm-mc -triple=amdgcn -mcpu=gfx1030 --disassemblemakes of one encoding of every opcode of every family. The families are SOP1/2/C/K/P, VOP1/2/3/3P/C, SMEM, DS, MUBUF, MTBUF, MIMG, FLAT/GLOBAL/SCRATCH, VINTRP and EXP. The ALU forms also come with a literal, and VOP3 with a literal in either the first or the third source. That is 7,093 cases, 2,393 of which LLVM decodes.decoder_agrees_with_llvmdecodes each case and compares the name (ignoring LLVM's_e32/_e64) and the length in dwords. A wrong length is the bad one, because every later instruction is then read out of step. It takes 0.02 s.KNOWN, each with a reason, and anything else fails. One pattern is skipped without listing:0xFFin a source field the instruction doesn't have (e.g. a third source on a two-source op). LLVM reads no literal there and real code never writes one.cargo test -p victory-shader regenerate_llvm_fixture -- --ignoredrewrites the fixture. It needsllvm-mc, which can be set withLLVM_MC.What it found
The 48 listed cases:
image_sample_cd_g16(all 8) andimage_gather4hhave no name; #69 adds them.0xFFin the attribute field are decoded as having a literal; #70 fixes that.v_mac_legacy_f32/v_mad_legacy_f32here, the GFX10.1 names. LLVM's gfx1030 hasv_fmac_legacy_f32/v_fma_legacy_f32there, the fused forms. Which one the console's GPU implements decides whether these round like an FMA. That is left for whoever owns the lowering. The test only records it.v_movrels*,v_readlane,v_swap*and the permlanes, or the lane mask ofv_cndmaskand the carry ops. LLVM doesn't read a literal there, and the compiler can't encode one.s_call_b64's branch target lies past the end of the test program.So nothing in today's decoder misreads real code that I can see. The test is there to keep it that way.
Tests
--target x86_64-pc-windows-msvc) pass locally. The fixture is within the asset policy's size limit.Not covered: operand text (styles differ from LLVM's), and DS/SMEM/MUBUF encodings beyond the one template each, which LLVM refuses for many opcodes.
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.