code-morph in power_insn.py - move table-search to separate area
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 18 Sep 2022 14:52:41 +0000 (15:52 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 18 Sep 2022 14:52:41 +0000 (15:52 +0100)
src/openpower/decoder/power_insn.py

index 88810210f0c9ad754c7d81ae1bb4ecefbe5089e5..7b4b5237c0a491205a3e8f5943bd57c487b665d8 100644 (file)
@@ -1751,6 +1751,7 @@ class RM(BaseRM):
     def select(self, record, Rc):
         rm = self
 
+        table = None
         if record.svp64.mode is _SVMode.NORMAL:
             # concatenate mode 5-bit with Rc (LSB) then do a mask/map search
             #         mode   Rc   mask Rc  action(getattr)
@@ -1762,13 +1763,8 @@ class RM(BaseRM):
                      (0b110000, 0b110001, "prrc0"),  # predicate, Rc=0
                      (0b110001, 0b110001, "prrc1"),  # predicate, Rc=1
                     ]
-
             rm = rm.normal
             search = (int(rm.mode) << 1) | Rc
-            for (val, mask, action) in table:
-                if (val&search) == (mask&search):
-                    rm = getattr(rm, action)
-                    break
 
         elif record.svp64.mode is _SVMode.LDST_IMM:
             # concatenate mode 5-bit with Rc (LSB) then do a mask/map search
@@ -1785,10 +1781,6 @@ class RM(BaseRM):
                     ]
             rm = rm.ldst_imm
             search = (int(rm.mode) << 1) | Rc
-            for (val, mask, action) in table:
-                if (val&search) == (mask&search):
-                    rm = getattr(rm, action)
-                    break
 
         elif record.svp64.mode is _SVMode.LDST_IDX:
             # concatenate mode 5-bit with Rc (LSB) then do a mask/map search
@@ -1801,6 +1793,9 @@ class RM(BaseRM):
                     ]
             rm = rm.ldst_idx
             search = (int(rm.mode) << 1) | Rc
+
+        # look up in table
+        if table is not None:
             for (val, mask, action) in table:
                 if (val&search) == (mask&search):
                     rm = getattr(rm, action)