Repository navigation
Conversation
|
Checked the two retail reachability questions against all 26,503 stored 25,030 listings reported a clean disassembly and 1,473 reported at least one invalid word. These are counts over emitted listing text for the project's |
|
Tested 7c0aca1 on Intel UHD Graphics 630 (CFL GT2), Mesa ANV, subgroup 8..32: I translated the lit_literals and lit_f64_literals fixtures with the PR's tools, validated them with spirv-val (rc 0) and rendered them with vk_harness at 64x64. All 4096 pixels of ps_lit_literals are 0x40800000 0xc1000000 0x64 0x3f000000 and all 4096 pixels of ps_lit_f64_literals are 0x0 0xbf800000 0x3e800000 0xbf400000. test_shader_ir (37 tests), test_shader_meta (27), test_fma_mix_literal_probe (8), test_semantic_translator_use (3), test_vop3_const_mods (12), test_fma_mix_literal (7) and test_lit_literal (6) pass. I did not reproduce the failures on main or run the full tests/semantic suite. AI-assisted. |
|
Reviewed commit
AI-assisted (Gemini 4 Neon). |
|
Thanks, @Kev-Ball, @gertify and @DenRakEiw. @Kev-Ball's count. No retail listing carries One question about the count: which llvm-mc version wrote those listings? The build records it. I checked that llvm-mc 23.1.3 prints
So if your listings come from a version that prints @gertify (Intel UHD 630, ANV) and @DenRakEiw (Windows 11). Thanks. ANV matches the RTX 5080 words on all 4096 pixels for both fixtures, and your Windows unit run and Tests after the docs edit: AI-assisted (Claude Code). |
|
@cynbun The listings were produced with llvm-mc 23.1.5, target That confirms the disassembler used for the retail count emits the spelling on both positive controls. The zero applies to decoded instructions; 1,473 listings had at least one invalid word. AI-assisted. |
|
Thanks, @Kev-Ball. That settles it: llvm-mc 23.1.5 prints New head AI-assisted (Claude Code). |
Kam471
left a comment
There was a problem hiding this comment.
Reviewed at 7c0aca1ce on Windows 11 / Python 3.13.
python tests/semantic/test_lit_literal.py: 6/6 OK.- Negative control: the same test copied onto main
561b65a83gives 3 failures + 2 errors (Unsupported operand lit(0x3f800000),Unsupported v_rcp_f64 operand), as described. pytest tests/test_shader_ir.py tests/test_shader_meta.py tests/test_fma_mix_literal_probe.py tests/test_semantic_translator_use.py -q: 75 passed, 79 subtests passed.- Checked operand parsing:
lit(hex|decimal)becomes the sameimmas a plain literal withliteral: true;-lit,|lit|,-|lit|andneg(lit(...))set the existing sign-bit flags;lit64, float spellings and values past 32 bits stayspecial. The f64 readers use the literal high word and the interpreter checks the expected words.
Verdict: LGTM. The GPU claim is external to the PR (no GPU fixture is added); the CPU/IR evidence is solid.
larpinguser
left a comment
There was a problem hiding this comment.
Summary
tools/shader_ir.py now parses LLVM's lit(0x...) operand as the literal imm (tagged literal so 64-bit sources distinguish it from an inline constant), with -lit, |lit|, -|lit|, neg(lit) as sign-bit modifiers; lit64(), floats and >32-bit values stay Unsupported. tools/rdna2spirv.py and tools/fma_mix_literal_probe.py are adjusted. Adds tests/semantic/test_lit_literal.py plus two llvm-mc fixtures and a docs/design.md row.
Why merge
Stops the translator rejecting hand-written/disassembled lit() operands (Unsupported operand lit(...)) that LLVM emits when a literal shadows an inline constant, without changing any retail translation.
Verdict: Approve
Summary
Why mergeStops the translator rejecting hand-written/disassembled Verdict: Approve |
llvm-mc prints a 32-bit literal dword whose value is also an inline constant of the operand as lit(0x...) (e.g. ff 5e 00 7e 00 00 10 40 is v_rcp_f64_e32 v[0:1], lit(0x40100000)). operand() fell through to a "special" operand and the translator rejected the instruction. Read lit(<hex|decimal>) as the imm a plain literal gives, marked "literal": parse_line marks it f64_literal (bits 63:32 of an f64), the f64 compare and class readers already honour the flag, and cmp_class / v_ldexp_f64 now do too. -lit(..), |lit(..)|, -|lit(..)| and neg(lit(..)) are sign-bit modifiers. lit64(), a float or a value past one dword stay unsupported. Fixtures are llvm-mc 23.1.3 gfx1030 disassembly; the f32/int/f16 one is executed, the f64 one checked on its SPIR-V source words. Both also gave the expected words on an RTX 5080 (NVIDIA 615.78.08, Linux). docs/design.md gets a "lit() literals" contract row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kev-Ball counted all 26,503 gfx1013 disassembly listings of the Xbox 1.0.2.1 shader archive and found no lit( or lit64( spelling, so the row now says the rule changes no translation of those listings and is there for hand-written text such as its fixtures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kev-Ball's listings were written by llvm-mc 23.1.5, which prints lit() for the row's two example byte sequences, so their zero means no decoded retail instruction carries a literal shadowing an inline constant. The zero covers decoded instructions only: 1,473 listings have at least one invalid word. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59330bf to
653823d
Compare
Item:
lit()operand gap intools/shader_ir.py(claimed in #5581: #5581 (comment)).Cause
LLVM's disassembler prints a 32-bit literal dword as
lit(0x...)when its value would also be an inline constant for that operand, so the text reassembles to the same bytes.tools/shader_ir.pyoperand()(origin/main 561b65a, the"(" in corefallback at line ~139) turned that into{'k': 'special', 't': 'lit(0x40100000)'}, and the translator rejected the instruction (Unsupported operand lit(0x3f800000),Unsupported v_rcp_f64 operand).Retail reachability
None found. @Kev-Ball counted all 26,503
gfx1013disassembly listings of the Xbox 1.0.2.1 shader archive and found nolit(orlit64(spelling. Those listings were written by llvm-mc 23.1.5, which printslit(0x3f800000)andlit(0x40100000)for the two example byte sequences below. So the zero means no decoded retail instruction carries a literal that shadows an inline constant. It covers decoded instructions only: 1,473 listings have at least one invalid word. This PR changes no translation of those listings. It fixes hand-written text (the fixtures below, or a test program disassembled with llvm-mc), not a retail shader the translator rejected. Thedocs/design.mdrow says so.Where LLVM prints
lit()Measured with llvm-mc 23.1.3,
-mcpu=gfx1030. I disassembled bytes with the source field 0xff and a chosen literal dword, for 26 instruction forms × 16 values (VOP1/VOP2/VOP3/VOPC/VOP3P/SOP1/SOP2/SOPC, f16/f32/f64/u16-packed/32- and 64-bit integer):lit()forff 02 00 06 00 00 80 3f→v_add_f32_e32 v0, lit(0x3f800000), v1ff 16 06 7e 00 38 00 00→v_cvt_f32_f16_e32 v3, lit(0x3800)ff 10 c2 7d 40 00 00 00→v_cmp_lt_u64_e32 vcc_lo, lit(0x40), v[8:9]ff 5e 00 7e 00 00 10 40→v_rcp_f64_e32 v[0:1], lit(0x40100000)v_fmamk/fmaak_f32-lit(..),|lit(..)|and-|lit(..)|, for examplev_fma_f32 v1, -lit(0x40000000), v5, -|lit(0x40000000)|.lit64(for gfx10.lit(4)andlit(1.0).-lit(..)or|lit(..)|. It also turns|lit(0x40000000)|into the inline|2.0|. Because of this, the fixtures take their text from disassembly, not from assembly.Fix
operand()now readslit(<hex|decimal>)as the sameimma plain0x...literal gives, with"literal": Trueadded.parse_linetreats that flag like a hex spelling when it marksf64_literal(the "f64 literal sources" row). This meanslit(0x40100000)onv_rcp_f64/v_add_f64/v_cvt_f32_f64is bits 63:32 with a zero low word.compare_f64_condandcmp_class_f64already checkedsv.get("literal"), but nothing set it until now.cmp_class(the f64 branch) andv_ldexp_f64now check the flag too.-,|..|,-|..|andneg(lit(..))set the sign-bitneg/absflags, asneg(0x..)already does. They are not integer negation.lit64(..), a float insidelit()and a value past 32 bits stayspecial, so they remainUnsupported.On every operand above, the literal gives the same value as the inline constant it shadows, with one exception: an f32 bit pattern on an f16 operand. There,
lit(0x3f800000)reads its low half, +0.0, not 1.0. The translator already reads animmas raw bits, so this falls out of the fix.Tests
tests/semantic/test_lit_literal.pywith two fixtures. Every line in them is llvm-mc 23.1.3 disassembly, and each was checked to round-trip from the bytes in its comment.tests/semantic/fixtures/lit_literals.asm, executed in the interpreter: f32 VOP2, f32 VOP3 with-lit/-|lit|, SOP1/SOP2, 64-bit SOP2 and VOPC, integer VOP3 with the literal in two sources, and f16. Expected words:0x40800000 0xc1000000 0x64 0x3f000000.tests/semantic/fixtures/lit_f64_literals.asm:v_rcp_f64,v_add_f64with-lit,v_cvt_f32_f64withlit(0x0)and-|lit|, andv_cmp_gt_f64. The test checks the source words in the SPIR-V. The interpreter cannot run Float64.lit64, oversized and float spellings stayingspecial.Unsupported operand lit(0x3f800000),Unsupported v_rcp_f64 operand). With this PR it passes.spirv-val: both translated fixtures pass (translator CLI: 2 translated, 2 pass).vk_harnesswithvs_ids. Both fixtures gave the expected words on all 4096 pixels:0x40800000 0xc1000000 0x64 0x3f000000and0x0 0xbf800000 0x3e800000 0xbf400000.python -m compileall -q make_game.py tools testsis clean. These pass:tests/test_shader_ir.py,tests/test_shader_meta.py,tests/test_fma_mix_literal_probe.py,tests/test_semantic_translator_use.py,tests/semantic/test_vop3_const_mods.py,tests/semantic/test_fma_mix_literal.py.python -m unittest discover -s tests/semantic: 6156 tests OK (skipped=1, expected failures=1).tests/test_rdna2_decode.pytest_parity_with_llvm_mc_on_shader_fixturesfails the same way on main and on this branch: llvm-mc 23 printsop_sel:[0,1]andexp nulldifferently. Itsnorm_argcomparesimmby value, solit()operands now match the decoder'simm.docs/design.mdhas a new contract row, "lit()literals", placed after "f64 literal sources".Seen, not changed here
tools/rdna2_decode.py_format_operand, the--backend pythondisassembly, prints a literal below 100 in decimal. For example,ff 5e 00 7e 01 00 00 00becomesv_rcp_f64_e32 v[0:1], 1, which reads back as the inline 1 (LLVM prints0x1). So that backend loses the literal/inline difference on f64 sources.parse_linemarksf64_literalonly for the f64 ops it lists. A plain0x1literal onv_cmp_*_f64orv_cmp_class_f64(v_cmp_lt_f64_e32 vcc_lo, 0x1, v[0:1]) is still read as the inline 1, because those readers decide by value. Both cases are small values that are unlikely in compiled code. The same count found nov_cmp*_f64instruction at all, class compares included, in the retail listings.AI-assisted (Claude Code).
🤖 Generated with Claude Code