add unit test for mcrxrx
authorJacob Lifshay <programmerjake@gmail.com>
Wed, 27 Sep 2023 03:34:39 +0000 (20:34 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Dec 2023 19:26:20 +0000 (19:26 +0000)
src/openpower/test/alu/alu_cases.py

index 90e3ac11af65f8475061c333ac925bdb14bbc598..746159072099ca82432c9c1e85b814f471ac9318 100644 (file)
@@ -819,3 +819,26 @@ class ALUTestCase(TestAccumulatorBase):
                     programs[asm] = Program([asm], bigendian)
                 self.add_case(programs[asm], initial_regs,
                               initial_sprs=initial_sprs, expected=e)
+
+    def case_mcrxrx(self):
+        p = Program(["mcrxrx 3"], bigendian)
+        for i in range(16):
+            initial_sprs = {}
+            xer = SelectableInt(0, 64)
+            ov = bool(i & 8)
+            ov32 = bool(i & 4)
+            ca = bool(i & 2)
+            ca32 = bool(i & 1)
+            xer[XER_bits['OV']] = ov
+            xer[XER_bits['OV32']] = ov32
+            xer[XER_bits['CA']] = ca
+            xer[XER_bits['CA32']] = ca32
+            initial_sprs[special_sprs['XER']] = xer
+            # now construct the state
+            e = ExpectedState(pc=4)
+            e.ca = (ca32 << 1) | ca
+            e.ov = (ov32 << 1) | ov
+            e.crregs[3] = i
+
+            with self.subTest(ov=ov, ov32=ov32, ca=ca, ca32=ca32):
+                self.add_case(p, initial_sprs=initial_sprs, expected=e)