add gbbd (bmatflip) test case - just the one for now
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 27 Nov 2023 13:55:53 +0000 (13:55 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 7 Dec 2023 17:52:56 +0000 (17:52 +0000)
src/openpower/decoder/isa/caller.py
src/openpower/decoder/power_enums.py
src/openpower/test/bitmanip/bitmanip_cases.py

index e32116b2d7bcbf6d008628df4ad4871d64540d5c..299df0c20a568846faee25e0f0aabaa85667b208 100644 (file)
@@ -2088,7 +2088,7 @@ class ISACaller(ISACallerHelper, ISAFPHelpers, StepLoop):
                        "brh", "brw", "brd",
                        'setvl', 'svindex', 'svremap', 'svstep',
                        'svshape', 'svshape2',
-                       'ternlogi', 'bmask', 'cprop',
+                       'ternlogi', 'bmask', 'cprop', 'gbbd',
                        'absdu', 'absds', 'absdacs', 'absdacu', 'avgadd',
                        'fmvis', 'fishmv', 'pcdec', "maddedu", "divmod2du",
                        "dsld", "dsrd", "maddedus",
index 42d57c6bf3a608df9ceda63b2121bf5b86ada708..c0c1ddcacdb8bb48762caf9e460fb090cc63c40e 100644 (file)
@@ -767,6 +767,7 @@ _insns = [
     "fmr", "fabs", "fnabs", "fneg", "fcpsgn",           # FP move/abs/neg
     "fmvis",   # FP load immediate
     "fishmv",  # Float Replace Lower-Half Single, Immediate
+    "gbbd",          # bitmanip - (aka bmatflip)
     "cffpr", "cffpro",
     "mffpr", "mffprs",
     "ctfpr", "ctfprs",
index 494ff0f0b1c662a30c60436fb324d6913b0b4ee9..e9f6bb46e2b10bcf42625ffe6a54364ac71c20d1 100644 (file)
@@ -5,11 +5,33 @@ 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
+from openpower.util import log
 import struct
 import itertools
 
+def bmatflip(ra):
+    result = 0
+    for j in range(8):
+        for k in range(8):
+            b = (ra >> (63-k*8-j)) & 1
+            result |= b << (63-j*8-k)
+    return result
+
 
 class BitManipTestCase(TestAccumulatorBase):
+    def case_gbbd(self):
+        lst = ["gbbd 0, 1"]
+        lst = list(SVP64Asm(lst, bigendian))
+        initial_regs = [0] * 32
+        initial_regs[1] = 0x9231_5897_2083_ffff
+        e = ExpectedState(pc=4)
+        e.intregs[0] = bmatflip(initial_regs[1])
+        e.intregs[1] = initial_regs[1]
+        log("case_gbbd", bin(initial_regs[1]), bin(e.intregs[0]))
+        log("hex", hex(initial_regs[1]), hex(e.intregs[0]))
+
+        self.add_case(Program(lst, bigendian), initial_regs, expected=e)
+
     def do_case_ternlogi(self, rc, rt, ra, rb, imm):
         rc_dot = "." if rc else ""
         lst = [f"ternlogi{rc_dot} 3, 4, 5, {imm}"]