Repository navigation
Conversation
…inline constant _src dropped the literal marker for source code 255, and _format_operand printed any value under 100 in decimal, so a small f64 literal came out as an inline constant would (`v_add_f64 v[4:5], 1, 1` instead of `0x1, 1`). The disassembly then lost the literal/inline distinction shader_ir and the translator read from it. The operand keeps "literal": True and is printed in hex. New test test_f64_literal_printed_as_hex; test_sop1_sop2_sopc_sopk_with_literals now expects the marker on its literal operand. Found by @tupacfan04.
|
Tested 4c4c6ea merged with main 561b65a (PR already based on it) on Linux WSL2, Python 3.12.16: pass tests/test_rdna2_decode.py: 15 run, 14 passed, 1 skipped, 0 failed. tests/test_shader_disasm.py (the other consumer of rdna2_decode): 29 run, 29 passed. Negative control: with tools/rdna2_decode.py restored to upstream/main, tests/test_rdna2_decode.py runs 15 tests with 2 failures (the new hex test and the updated imm-operand expectation). Read the diff: the new "literal": True key on a decoded 255-code operand matches what tools/rdna2spirv.py already reads via .get("literal"), so it is the existing convention. Note the new test only asserts the substring '0x1' in the first line. No failure found. |
|
Related data, in case you want LLVM-exact output: llvm-mc 23.1.3 doesn't print every literal in hex — it prints |
|
@cynbun thanks, that's very useful data. I'll keep this PR to plain hex for now. It is unambiguous, |
|
Sounds right — plain hex here, and the LLVM-exact |
Claimed in the coordination issue as: #5361 (comment) (from @tupacfan04's finding; offered to the finder first)
What and why
tools/rdna2_decode.pyloses the literal marker of a source operand with code 255 (_src, line 223), and_format_operandprints any value below 100 in decimal. A small literal word, for example the f64 literal1, is therefore printed exactly like the inline constant1:v_add_f64 v[4:5], 1, 1instead ofv_add_f64 v[4:5], 0x1, 1. The disassembly then loses the literal/inline distinction thatshader_irand the translator read from it.The change
_src: a code-255 operand keeps"literal": True._format_operand: an operand with that marker is printed in hex. Other immediates are unchanged.tests/test_rdna2_decode.py:test_f64_literal_printed_as_hex, built from hand-written bytes040064d5ff02010001000000;test_sop1_sop2_sopc_sopk_with_literalsnow expects the marker on its literal operand ({"k": "imm", "v": 0x12345678, "literal": True}). That is the only change to the operand dict's shape.Tested
Windows 11 23H2, Python 3.12, at
main+ this commit:pytest tests/test_rdna2_decode.py: 14 passed, 1 skipped (llvm-mc parity, TEST-1010). With the tool change reverted and the tests kept, 2 fail (the new test and the updated dict), as expected.pytest tests/test_shader_disasm.py tests/test_shader_ir.py(the decoder's consumers): 66 passed.tests/semantic, the*decode*modules: 8 passed.No game files. AI-assisted: written by an agent on this machine, and checked and re-run by me.