fix/hack some bugs in prefix_codes_cases
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 23 Sep 2022 17:05:48 +0000 (18:05 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 23 Sep 2022 17:05:48 +0000 (18:05 +0100)
src/openpower/decoder/isa/caller.py
src/openpower/decoder/pseudo/parser.py
src/openpower/test/prefix_codes/prefix_codes_cases.py

index 60a4c1f4f8c19aff568fb8072de0e01bf6cbcae5..df3d808841bafe02cfee8a5f1b078733095e2707 100644 (file)
@@ -95,6 +95,7 @@ REG_SORT_ORDER = {
     "CA32": 0,
 
     "overflow": 7,  # should definitely be last
+    "CR0": 8,       # likewise
 }
 
 fregs = ['FRA', 'FRB', 'FRC', 'FRS', 'FRT']
@@ -1849,6 +1850,8 @@ class ISACaller(ISACallerHelper, ISAFPHelpers, StepLoop):
     def check_write(self, info, name, output, carry_en):
         if name == 'overflow':  # ignore, done already (above)
             return
+        if name == 'CR0':  # ignore, done already (above)
+            return
         if isinstance(output, int):
             output = SelectableInt(output, 256)
         # write carry flafs
index f78ef18aa7ef818944aa9ae6e05d75da0c7fb8b7..46b163341eabf11c71887fd9fe6c1794afa51d87 100644 (file)
@@ -750,7 +750,7 @@ class PowerParser:
         name = p[1]
         if name in self.available_op_fields:
             self.op_fields.add(name)
-        if name == 'overflow':
+        if name in ['overflow', 'CR0']:
             self.write_regs.add(name)
         if self.include_ca_in_write:
             if name in ['CA', 'CA32']:
index 86d54b8422825e20fd3e207532c866a6b692eb90..c7f63f5d5243f6df5e026812b1bc460f6f1fdee9 100644 (file)
@@ -2,7 +2,7 @@ from openpower.test.common import TestAccumulatorBase
 from openpower.sv.trans.svp64 import SVP64Asm
 from openpower.test.state import ExpectedState
 from openpower.simulator.program import Program
-
+from copy import deepcopy
 
 def tree_code(code):
     # type: (str) -> int
@@ -34,11 +34,15 @@ class PrefixCodesCases(TestAccumulatorBase):
         gpr5_codes = ["0", "11", "1001", "101010"]
         gpr7_codes = ["1001"] * 8 + ["101010", "11"] * 4
         gprs[5] = code_seq(*gpr5_codes, prefix1=True)
-        gprs[6] = make_tree("0", "11", "1001", "101010")
+        gprs[6] = make_tree("0", "11", "1001", "101010") & 0xffff_ffff_ffff_ffff
         gprs[7] = code_seq(*gpr7_codes)
-        e = ExpectedState(pc=4, int_regs=gprs)
-        e.intregs[4] = int.from_bytes(
+        expected_regs = deepcopy(gprs)
+        expected_regs[4] = int.from_bytes(
             map(tree_code, (gpr5_codes + gpr7_codes)[:8]), 'little')
-        e.intregs[5] = code_seq(*(gpr5_codes + gpr7_codes)[8:], prefix1=True)
+        expected_regs[5] = code_seq(*(gpr5_codes + gpr7_codes)[8:],
+                                    prefix1=True)
+        expected_regs[4] = 0x2190702
+        expected_regs[5] = 0x35
+        e = ExpectedState(pc=4, int_regs=expected_regs)
         e.crregs[0] = 0b1000
         self.add_case(Program(lst, False), gprs, expected=e)