add addex to simulator
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 30 Mar 2023 07:02:56 +0000 (00:02 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 30 Mar 2023 07:10:40 +0000 (00:10 -0700)
works, except it has incorrect CA/OV outputs, which I'll fix as part of fixing all add-like ops

src/openpower/decoder/isa/caller.py
src/openpower/decoder/power_enums.py
src/openpower/test/alu/alu_cases.py

index 5552d1500f812a50e8e8d2d9630b869aac0758e3..38b239dcde18172f61db4db029181da970236635 100644 (file)
@@ -1333,6 +1333,8 @@ class ISACaller(ISACallerHelper, ISAFPHelpers, StepLoop):
         self.namespace['XER'] = self.spr['XER']
         self.namespace['CA'] = self.spr['XER'][XER_bits['CA']].value
         self.namespace['CA32'] = self.spr['XER'][XER_bits['CA32']].value
+        self.namespace['OV'] = self.spr['XER'][XER_bits['OV']].value
+        self.namespace['OV32'] = self.spr['XER'][XER_bits['OV32']].value
         self.namespace['XLEN'] = xlen
 
         # add some SVSTATE convenience variables
index 506b2dc7c5cd93076d58ece85bb2598b5aad9719..90a91e1dba50b4af8da59b9628d5d4c4ca634bdd 100644 (file)
@@ -689,6 +689,7 @@ _insns = [
     "NONE", "add", "addc", "addco", "adde", "addeo",
     "addi", "addic", "addic.", "addis",
     "addme", "addmeo", "addo", "addze", "addzeo",
+    "addex",
     "addg6s",
     "and", "andc", "andi.", "andis.",
     "attn",
index 17bad9ba97de0018397c56e4af594707986d0d98..8580e3f885b343d8cf1540e7d91e9b9b933bb5b3 100644 (file)
@@ -87,6 +87,35 @@ def check_addmeo_subfmeo_matches_reference(instr, case_filter, out):
 
 
 class ALUTestCase(TestAccumulatorBase):
+    def case_addex(self):
+        lst = [f"addex 3, 4, 5, 0"]
+        program = Program(lst, bigendian)
+        values = (*range(-2, 4), ~1 << 63, (1 << 63) - 1)
+        for ra in values:
+            ra %= 1 << 64
+            for rb in values:
+                rb %= 1 << 64
+                for ov in (0, 1):
+                    with self.subTest(ra=hex(ra), rb=hex(rb), ov=ov):
+                        initial_regs = [0] * 32
+                        initial_regs[4] = ra
+                        initial_regs[5] = rb
+                        initial_sprs = {}
+                        xer = SelectableInt(0, 64)
+                        xer[XER_bits['OV']] = ov
+                        initial_sprs[special_sprs['XER']] = xer
+                        e = ExpectedState(pc=4)
+                        v = ra + rb + ov
+                        v32 = (ra % (1 << 32)) + (rb % (1 << 32)) + ov
+                        ov = v >> 64
+                        ov32 = v32 >> 32
+                        e.intregs[3] = v % (1 << 64)
+                        e.intregs[4] = ra
+                        e.intregs[5] = rb
+                        e.ov = (ov32 << 1) | ov
+                        self.add_case(program, initial_regs,
+                                      initial_sprs=initial_sprs, expected=e)
+
     def case_nego_(self):
         lst = [f"nego. 3, 4"]
         initial_regs = [0] * 32