power_insn: decouple mode function
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 4 Sep 2022 17:36:16 +0000 (20:36 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 4 Sep 2022 17:43:42 +0000 (20:43 +0300)
src/openpower/decoder/power_insn.py

index 4c0ac759459dcb7165c9a8e86b25b36c1cc97fab..cb08b1dfcaa4cd087064e8a8439ef33262f91fd5 100644 (file)
@@ -1140,28 +1140,14 @@ class SVP64Instruction(PrefixedInstruction):
     def mask(self, db):
         return self.suffix.mask(db=db)
 
-    def disassemble(self, db, byteorder="little", verbose=False):
-        integer_prefix = int(self.prefix)
-        blob_prefix = integer_prefix.to_bytes(length=4, byteorder=byteorder)
-        blob_prefix = " ".join(map(lambda byte: f"{byte:02x}", blob_prefix))
-
-        integer_suffix = int(self.suffix)
-        blob_suffix = integer_suffix.to_bytes(length=4, byteorder=byteorder)
-        blob_suffix = " ".join(map(lambda byte: f"{byte:02x}", blob_suffix))
-
+    def mode(self, db):
         record = self.record(db=db)
-        if record is None or record.svp64 is None:
-            yield f"{blob_prefix}    .long 0x{int(self.prefix):08x}"
-            yield f"{blob_suffix}    .long 0x{int(self.suffix):08x}"
-            return
-
-        yield f"{blob_prefix}    sv.{record.name}"
-        yield f"{blob_suffix}"
 
         Rc = False
         if record.operands["Rc"] is not None:
             Rc = bool(self[record.fields["Rc"]])
 
+        record = self.record(db=db)
         subvl = self.prefix.rm.subvl
         mode = self.prefix.rm.mode
         sel = mode.sel
@@ -1236,6 +1222,26 @@ class SVP64Instruction(PrefixedInstruction):
         if type(mode) is Mode:
             raise NotImplementedError
 
+        return mode
+
+    def disassemble(self, db, byteorder="little", verbose=False):
+        integer_prefix = int(self.prefix)
+        blob_prefix = integer_prefix.to_bytes(length=4, byteorder=byteorder)
+        blob_prefix = " ".join(map(lambda byte: f"{byte:02x}", blob_prefix))
+
+        integer_suffix = int(self.suffix)
+        blob_suffix = integer_suffix.to_bytes(length=4, byteorder=byteorder)
+        blob_suffix = " ".join(map(lambda byte: f"{byte:02x}", blob_suffix))
+
+        record = self.record(db=db)
+        if record is None or record.svp64 is None:
+            yield f"{blob_prefix}    .long 0x{int(self.prefix):08x}"
+            yield f"{blob_suffix}    .long 0x{int(self.suffix):08x}"
+            return
+
+        yield f"{blob_prefix}    sv.{record.name}"
+        yield f"{blob_suffix}"
+
         if verbose:
             indent = (" " * 4)
             binary = self.binary