from openpower.simulator.program import Program
from openpower.test.state import ExpectedState
from nmutil.sim_util import hash_256
+from openpower.decoder.isa.caller import SVP64State
import struct
e = ExpectedState(pc=4, int_regs=gprs)
e.intregs[3] = expected
self.add_case(prog, gprs, expected=e)
+
+ def case_sv_byterev(self):
+ """ sv.brh/brw/brd """
+ for pack_str, mnemonic in ("HHHH", "brh"), ("LL", "brw"), ("Q", "brd"):
+ prog = Program(list(SVP64Asm([
+ f"sv.{mnemonic} *10,*20"])), bigendian)
+ for case_idx in range(10):
+ VL = 5
+ svstate = SVP64State()
+ svstate.vl = VL
+ svstate.maxvl = VL
+ gprs = [0] * 128
+ for elidx in range(VL):
+ k = f"sv.{mnemonic} {case_idx} {elidx} r20"
+ gprs[20 + elidx] = hash_256(k) % 2**64
+ e = ExpectedState(pc=8, int_regs=gprs)
+ for elidx in range(VL):
+ chunks = struct.unpack(
+ "<" + pack_str, struct.pack("<Q", gprs[20 + elidx]))
+ e.intregs[10 + elidx] = struct.unpack(
+ "<Q", struct.pack(">" + pack_str, *chunks))[0]
+ with self.subTest(
+ case_idx=case_idx,
+ RS_in=[hex(gprs[20 + i]) for i in range(VL)],
+ expected_RA=[hex(e.intregs[10 + i]) for i in range(VL)],
+ ):
+ self.add_case(prog, gprs, expected=e,
+ initial_svstate=svstate)