reduce NORMAL svp64 mode down to a mask-value search
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 18 Sep 2022 14:04:22 +0000 (15:04 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 18 Sep 2022 14:04:22 +0000 (15:04 +0100)
src/openpower/decoder/power_insn.py

index c39ec2d8f86ac65105dd63225d134f8832353526..f17447281b90d8c792b4d40a2e1dd1d3dfbb07b0 100644 (file)
@@ -1746,28 +1746,23 @@ class RM(BaseRM):
         rm = self
 
         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)
+            table = [(0b000000, 0b111000, "simple"), # simple    (no Rc)
+                     (0b001000, 0b111000, "smr"),    # mapreduce (no Rc)
+                     (0b010000, 0b110001, "ffrc0"),  # ffirst,    Rc=0
+                     (0b010001, 0b110001, "ffrc1"),  # ffirst,    Rc=1
+                     (0b100000, 0b110000, "sat"),    # saturation(no Rc)
+                     (0b110000, 0b110001, "prrc0"),  # predicate, Rc=0
+                     (0b110001, 0b110001, "prrc1"),  # predicate, Rc=1
+                    ]
+
             rm = rm.normal
-            if rm.mode[0:2] == 0b00:
-                if rm.mode[2] == 0b0:
-                    rm = rm.simple
-                else:
-                    rm = rm.smr
-            elif rm.mode[0:2] == 0b01:
-                if Rc:
-                    rm = rm.ffrc1
-                else:
-                    rm = rm.ffrc0
-            elif rm.mode[0:2] == 0b10:
-                if self.subvl == 0b00:
-                    rm = rm.sat
-                else:
-                    if rm.mode[4]:
-                        rm = rm.satx
-            elif rm.mode[0:2] == 0b11:
-                if Rc:
-                    rm = rm.prrc1
-                else:
-                    rm = rm.prrc0
+            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:
             rm = rm.ldst_imm