make ternlogi tests run
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 9 Dec 2021 06:04:10 +0000 (22:04 -0800)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 9 Dec 2021 06:04:10 +0000 (22:04 -0800)
src/openpower/decoder/isa/caller.py
src/openpower/test/bitmanip/bitmanip_cases.py

index 604bc20481c1b14ceb847ccf5bd7b9954737e31a..944d0324d09a7dce1ff40d59659c01f9b86864bd 100644 (file)
@@ -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
index 97981fecf54af7ce05370d70d0b5eefb64ff7a81..8b1120942a2e4f09783c94d0889433922afaf83e 100644 (file)
@@ -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)