PYTHONREMU properly supports S_PACK_LL_B32_B16 (#14527)

* PYTHONREMU properly supports S_PACK_LL_B32_B16

* default
This commit is contained in:
Christopher Milan
2026-02-03 20:45:33 -08:00
committed by GitHub
parent 720c9597a9
commit ecbce5269e
2 changed files with 11 additions and 1 deletions

View File

@@ -440,7 +440,7 @@ class Parser:
self.eat('COMMA')
lo = self.parse()
self.eat('RBRACE')
return (hi.cast(dtypes.uint64) << _u64(32)) | lo.cast(dtypes.uint64)
return (hi.cast(dt:=_BITS_DT.get((s:=lo.dtype.bitsize) * 2, dtypes.uint64)) << _const(dt, s)) | lo.cast(dt)
if self.at('NUM'):
num = self.eat('NUM').val
if self.try_eat('QUOTE'):

View File

@@ -62,6 +62,16 @@ class TestWithSources(unittest.TestCase):
dest, val = assigns[0]
self.assertEqual(val.op, Ops.MUL)
def test_s_pack_ll_b32_b16(self):
"""Test S_PACK_LL_B32_B16 packs two 16-bit values into 32-bit result."""
s0 = UOp.const(dtypes.uint32, 0xDEADAAAA)
s1 = UOp.const(dtypes.uint32, 0xDEADBBBB)
_, assigns = parse_pcode(PCODE[SOP2Op.S_PACK_LL_B32_B16], {'S0': s0, 'S1': s1})
self.assertEqual(len(assigns), 1)
dest, val = assigns[0]
self.assertTrue(dest.startswith('D0'))
self.assertEqual(val.simplify().arg, 0xBBBBAAAA)
class TestParseExpr(unittest.TestCase):
"""Test the parse_expr function directly."""