upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/pe_loader.cpp
diff options
context:
space:
mode:
authorshelbykb2 <80599220+shelbykb2@users.noreply.github.com>2026-11-21 13:00:09 -0700
committershelbykb2 <80599220+shelbykb2@users.noreply.github.com>2026-11-21 13:28:03 -0700
commit49dd92d41d9b68845e700fcd750b87e9f276012a (patch)
tree4058c6463b59b5b0ee9fd5dfd2390cd1319ca95c /runtime/src/pe_loader.cpp
parentdcf5f44879ffa7cc1a1b61e284568b03c39d9885 (diff)
translator: SMEM loads with soffset and imm add both (the imm was dropped)
What was wrong An RDNA2 SMEM load can carry a register offset and an immediate at once. llvm-mc prints that form as "s_buffer_load_dword s12, s[24:27], s40 offset:0x4". shader_ir.parse_line puts "offset:0x4" in mods, and Gen.scalar_load only read the third operand, so the immediate was dropped without a diagnostic: the line translated to the same SPIR-V with and without the modifier, and spirv-val accepted both. Evidence Measured on an AMD Radeon RX 6800 (gfx1030) by running the instructions as a raw compute kernel: for s_buffer_load_dword/x2/x4/x8 the address is base + soffset + imm + 4*i, e.g. soffset 8 + imm 4 reads the dword at +12. s_load_dword* with both offsets was not measured; it shares the SMEM encoding (soffset_en + imm), so giving it the same rule is an inference. Change - scalar_load adds the immediate when the third operand is a register and mods has offset:N. The no-modifier forms emit the same code as before. - Forms llvm-mc does not accept (immediate operand plus offset:, two offset: modifiers, a fourth operand, an unparseable offset) raise Unsupported. - Not changed, and listed in docs/design.md as known differences: the hardware truncates base, soffset and imm each to a multiple of 4 and s_buffer_load returns 0 past NUM_RECORDS; the translator does neither. A negative s_load immediate is still zero-extended from 32 bits, in both forms (not measured). Tests - tests/semantic/test_scalar_mem_smem.py: SmemSoffsetImmTranslatorTests runs the code scalar_load emits against concrete SGPRs and memory and asserts the addresses and values read (9 tests; 7 fail on main, where the loads read +8 instead of +12, and the imm-only / soffset-only regression cases pass). - runtime/test/shaders/cs_smem_soffset_imm.asm, wired into check.py and scripts/run_gpu_tests.py. Not run on a GPU in this change. - unittest discover -s tests/semantic: 335 -> 344, all pass. - pytest tests (--capture=sys, llvm-mc through WSL): 883 -> 893 passed, the same 6 test_rtti_scan failures before and after (pefile not installed). - The 27 hand-written GPU shaders: 27 translated, 27 pass spirv-val before and after, output byte-identical. AI-assisted. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/pe_loader.cpp')
0 files changed, 0 insertions, 0 deletions