upleb.uk

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

summaryrefslogtreecommitdiff
path: root/tools/f64_diff.py
diff options
context:
space:
mode:
authorevilclanker9000 <45567075+evilclanker9000@users.noreply.github.com>2026-11-23 21:26:43 +0100
committerevilclanker9000 <45567075+evilclanker9000@users.noreply.github.com>2026-11-23 21:26:43 +0100
commit0b69f14d0334ac2bb560de56f6981fbef8e81377 (patch)
tree7ebcb81bc3450c6aef2ad52fcd1597596da4304e /tools/f64_diff.py
parent716923d134830a5b9f850ebb59da28298a1acc76 (diff)
rdna2spirv: an f64 literal's printed width picks the one-dword rule
A literal source is one ISA dword (bits 63:32 of the constant) only when its printed spelling fits one dword. LLVM pads nothing, so such a literal prints in at most 8 hex digits; a 16-digit spelling is the whole binary64 value. The magnitude check from the previous commit read 0x0000000012345678 as the high word 0x12345678 instead of the low one, and tools/f64_diff.py's CPU reference made the same mistake, so a generated program could agree with the translator on the wrong operand. tools/shader_ir.py records the literal's hex-digit count next to f64_literal (and now marks v_ldexp_f64's sources too); tools/rdna2spirv.py decides with it at all three literal readers, and tools/f64_diff.py's read_source mirrors the rule. Tests: tests/semantic/test_f64_literal_whole.py gains the padded-width case (0x0000000012345678 -> low word 0x12345678, high word 0) next to the 8-digit control, and tests/test_f64_diff.py checks the reference reads both spellings the same way.
Diffstat (limited to 'tools/f64_diff.py')
-rw-r--r--tools/f64_diff.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/f64_diff.py b/tools/f64_diff.py
index 33d46aa0f..a77b63e55 100644
--- a/tools/f64_diff.py
+++ b/tools/f64_diff.py
@@ -259,10 +259,10 @@ def read_source(tok, vgpr, sgpr):
259 elif tok.startswith(("v", "s")) and tok[1:].isdigit(): 259 elif tok.startswith(("v", "s")) and tok[1:].isdigit():
260 raise HarnessError("binary64 source must be an even register pair") 260 raise HarnessError("binary64 source must be an even register pair")
261 elif tok.startswith("0x"): 261 elif tok.startswith("0x"):
262 # A printed 32-bit ISA literal occupies bits 63:32 in forms marked by shader_ir; 262 # A printed 32-bit ISA literal occupies bits 63:32; a spelling of more than 8 hex digits is
263 # a full 64-bit hexadecimal operand is already the complete IEEE word. 263 # the whole binary64 value (the full-width form gen_source writes), as in the translator.
264 value = int(tok, 16) 264 value = int(tok, 16)
265 if value <= M32: value <<= 32 265 if len(tok) - 2 <= 8: value <<= 32
266 value &= M64 266 value &= M64
267 elif re.fullmatch(r"[-+]?\d+", tok): 267 elif re.fullmatch(r"[-+]?\d+", tok):
268 n = int(tok) 268 n = int(tok)