From 950e54f10be461122e30fde1b2957b342bb9b0ba Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 8 Dec 2021 22:04:10 -0800 Subject: [PATCH] make ternlogi tests run --- src/openpower/decoder/isa/caller.py | 4 ++ src/openpower/test/bitmanip/bitmanip_cases.py | 49 ++++++++++++------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/openpower/decoder/isa/caller.py b/src/openpower/decoder/isa/caller.py index 604bc204..944d0324 100644 --- a/src/openpower/decoder/isa/caller.py +++ b/src/openpower/decoder/isa/caller.py @@ -1233,6 +1233,10 @@ class ISACaller(ISACallerHelper, ISAFPHelpers): illegal = False ins_name = 'ffadds' + if asmop == 'ternlogi' or asmop == 'ternlogi.': + illegal = False + ins_name = asmop + # branch-conditional redirects to sv.bc if asmop.startswith('bc') and self.is_svp64_mode: ins_name = 'sv.%s' % ins_name diff --git a/src/openpower/test/bitmanip/bitmanip_cases.py b/src/openpower/test/bitmanip/bitmanip_cases.py index 97981fec..8b112094 100644 --- a/src/openpower/test/bitmanip/bitmanip_cases.py +++ b/src/openpower/test/bitmanip/bitmanip_cases.py @@ -1,4 +1,4 @@ -from openpower.test.common import TestAccumulatorBase +from openpower.test.common import TestAccumulatorBase, skip_case from openpower.endian import bigendian from openpower.simulator.program import Program from hashlib import sha256 @@ -12,25 +12,40 @@ def hash_256(v): class BitManipTestCase(TestAccumulatorBase): - def case_ternlogi(self): + def do_case_ternlogi(self, rt_v, ra_v, rb_v, imm, rc): po = 5 + xo = 0 rt = 3 ra = 4 rb = 5 - rc = 1 - xo = 0 + instr = po + instr = (instr << 5) | rt + instr = (instr << 5) | ra + instr = (instr << 5) | rb + instr = (instr << 8) | imm + instr = (instr << 2) | xo + instr = (instr << 1) | rc + asm = f"ternlogi{'.' * rc} {rt}, {ra}, {rb}, {imm}" + lst = [f".4byte {hex(instr)} # {asm}"] + initial_regs = [0] * 32 + initial_regs[3] = rt_v % 2 ** 64 + initial_regs[4] = ra_v % 2 ** 64 + initial_regs[5] = rb_v % 2 ** 64 + self.add_case(Program(lst, bigendian), initial_regs) + + def case_ternlogi_0(self): + self.do_case_ternlogi(0x8000_0000_FFFF_0000, + 0x8000_0000_FF00_FF00, + 0x8000_0000_F0F0_F0F0, 0x80, rc=1) + + def case_ternlogi_FF(self): + self.do_case_ternlogi(0, 0, 0, 0xFF, rc=1) + + @skip_case + def case_ternlogi_random(self): for i in range(100): imm = hash_256(f"ternlogi imm {i}") & 0xFF - instr = po - instr = (instr << 5) | rt - instr = (instr << 5) | ra - instr = (instr << 5) | rb - instr = (instr << 8) | imm - instr = (instr << 2) | xo - instr = (instr << 1) | rc - lst = [f".4byte {hex(instr)}"] - initial_regs = [0] * 32 - initial_regs[3] = hash_256(f"ternlogi rt {i}") % 2 ** 64 - initial_regs[4] = hash_256(f"ternlogi ra {i}") % 2 ** 64 - initial_regs[5] = hash_256(f"ternlogi rb {i}") % 2 ** 64 - self.add_case(Program(lst, bigendian), initial_regs) + rt_v = hash_256(f"ternlogi rt {i}") % 2 ** 64 + ra_v = hash_256(f"ternlogi ra {i}") % 2 ** 64 + rb_v = hash_256(f"ternlogi rb {i}") % 2 ** 64 + self.do_case_ternlogi(rt_v, ra_v, rb_v, imm, rc=1) -- 2.30.2