Repository navigation
rdna2_decode: an f64 source's literal prints in hex, apart from the inline integer (SHADER-890) - #5115
rdna2_decode: an f64 source's literal prints in hex, apart from the inline integer (SHADER-890)#5115hmodymac8-droid wants to merge 1 commit into
Conversation
…nline integer (SHADER-890) The decoder printed every immediate below 100 in decimal, so the literal dword of an f64 source came out the same as an inline integer: `v_add_f64 v[4:5], 1, 1` for a literal 1 and an inline 1. On an f64 source the two differ (the literal is bits 63:32, the inline integer the whole value), LLVM prints the literal in hex (`0x1`), and shader_ir only marks an f64 source as a literal from that spelling, so the Python backend handed the translator an inline constant where the code had a literal. _src marks a literal on a 64-bit operand (`lit64`), and format_insn prints it in hex when the opcode is an f64 one. 32-bit literals, 64-bit integer operands and the decoded operand dicts of 32-bit literals are unchanged. tests/test_rdna2_decode.py: the finder's encoding now prints `v_add_f64 v[4:5], 0x1, 1` and shader_ir flags only the first source as an f64 literal (fails on main); a 32-bit literal 1 still prints as `1`. Found by tupacfan04. Synthetic encodings only; no game files. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kacper-serewis
left a comment
There was a problem hiding this comment.
Integrated #5115 cb6bcea with #5104 3ceecb6 in private scratch. Six hand-encoded ordinary f64 equality compares distinguished inline 1 from literal dword 1 through formatting, parsing, translation and CPU interpretation, including e64 right-hand operands. All six focused compare tests passed. Across 26,503 cached listings there were no static f64 compares, and all 468 source operands at the identified f64 sites were registers. Applicability of the literal case comes from the synthetic tests. AI-assisted, CPU only.
|
Tested
Code read: only a literal (code 255) read as a 64-bit operand is marked AI-assisted (Claude). |
|
Independent Windows check of
CPU only, using synthetic instructions. AI-assisted. |
|
Tested
|
|
Independent Windows CPU verification on
|
Claimed in #5032: #5032 (comment) (SHADER-890,
tupacfan04's finding)What and why
tools/rdna2_decode.pyprinted every immediate below 100 in decimal (_format_operand). That made the literal dword of an f64 source look the same as an inline integer: the finder's encoding came out asv_add_f64 v[4:5], 1, 1, while LLVM printsv_add_f64 v[4:5], 0x1, 1.On an f64 source the two mean different things:
shader_ir.parse_linemarks an f64 source as a literal only from the0xspelling (f64_literal), so the Python backend gave the translator an inline constant where the code had a literal.Change
_src: a literal (code 255) on a 64-bit operand (n == 2) getslit64: True.format_insn/_format_operand: that literal prints in hex when the opcode is an f64 one ("_f64" in op), as LLVM'sprintImmediate64does for a non-inline FP64 value.v_add_f32_e64 v4, 1, 1). The same goes for 64-bit integer operands, which LLVM also prints in decimal when the value is inline-sized. The decoded dicts of 32-bit literals are unchanged too, since the existing tests compare them exactly.Test
tests/test_rdna2_decode.pygainstest_small_f64_literal_prints_in_hex_like_llvm. The finder's encoding now printsv_add_f64 v[4:5], 0x1, 1, andshader_irflags only the first source asf64_literal. A 32-bit literal 1 still prints as1, and its dict stays{"k": "imm", "v": 1}. Onmain3faac557the new test fails, and with the change it passes.Tested
Synthetic encodings only, no game files, no GPU. On Windows 11, Python 3.13.5:
python -I tests/test_rdna2_decode.py: OK (10 tests, 1 skipped: the llvm-mc parity test, since llvm-mc isn't installed here)python -I tests/test_shader_disasm.py: OKpython -I tests/test_shader_ir.py: OKpython -m compileall -qon both files: cleangit diff --check: cleanAI-assisted (Claude Code).
🤖 Generated with Claude Code