From b83cc1a649010b2a4c16273b6a8508013e5b4b8d Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 21 Jul 2023 18:47:34 -0700 Subject: [PATCH] add SVP64 test for byte reverse insns --- src/openpower/test/bitmanip/bitmanip_cases.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/openpower/test/bitmanip/bitmanip_cases.py b/src/openpower/test/bitmanip/bitmanip_cases.py index 73877a57..1729bd42 100644 --- a/src/openpower/test/bitmanip/bitmanip_cases.py +++ b/src/openpower/test/bitmanip/bitmanip_cases.py @@ -4,6 +4,7 @@ from openpower.endian import bigendian 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 @@ -134,3 +135,31 @@ class BitManipTestCase(TestAccumulatorBase): 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("" + 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) -- 2.30.2