use log function for warnings about .mdwn files in pagereader.py
[openpower-isa.git] / src / openpower / decoder / power_insn.py
index 4c0ac759459dcb7165c9a8e86b25b36c1cc97fab..6ea7f58d37e5ed5091f4d8cd032f4d8936ff8d9e 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
@@ -1233,8 +1219,57 @@ class SVP64Instruction(PrefixedInstruction):
                 else:
                     mode = mode.prrc0
 
-        if type(mode) is Mode:
-            raise NotImplementedError
+        modes = {
+            NormalMode.simple: "normal: simple",
+            NormalMode.smr: "normal: smr",
+            NormalMode.pmr: "normal: pmr",
+            NormalMode.svmr: "normal: svmr",
+            NormalMode.pu: "normal: pu",
+            NormalMode.ffrc1: "normal: ffrc1",
+            NormalMode.ffrc0: "normal: ffrc0",
+            NormalMode.sat: "normal: sat",
+            NormalMode.satx: "normal: satx",
+            NormalMode.satpu: "normal: satpu",
+            NormalMode.prrc1: "normal: prrc1",
+            NormalMode.prrc0: "normal: prrc0",
+            LDSTImmMode.simple: "ld/st imm: simple",
+            LDSTImmMode.spu: "ld/st imm: spu",
+            LDSTImmMode.ffrc1: "ld/st imm: ffrc1",
+            LDSTImmMode.ffrc0: "ld/st imm: ffrc0",
+            LDSTImmMode.sat: "ld/st imm: sat",
+            LDSTImmMode.prrc1: "ld/st imm: prrc1",
+            LDSTImmMode.prrc0: "ld/st imm: prrc0",
+            LDSTIdxMode.simple: "ld/st idx simple",
+            LDSTIdxMode.stride: "ld/st idx stride",
+            LDSTIdxMode.sat: "ld/st idx sat",
+            LDSTIdxMode.prrc1: "ld/st idx prrc1",
+            LDSTIdxMode.prrc0: "ld/st idx prrc0",
+        }
+        for (cls, desc) in modes.items():
+            if isinstance(mode, cls):
+                return (mode, desc)
+
+        raise NotImplementedError
+
+    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}"
+
+        (mode, mode_desc) = self.mode(db=db)
 
         if verbose:
             indent = (" " * 4)
@@ -1264,6 +1299,9 @@ class SVP64Instruction(PrefixedInstruction):
                     record=record, verbose=True)
                 for part in parts:
                     yield f"{indent}{indent}{part}"
+
+            yield f"{indent}mode"
+            yield f"{indent}{indent}{mode_desc}"
             yield ""