power_insn: support SVP64 verbose mode
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Sep 2022 21:15:22 +0000 (00:15 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Sep 2022 21:19:20 +0000 (00:19 +0300)
src/openpower/decoder/power_insn.py

index a9929bd91859a55ceb36d908798a61a293d72930..085414c1302b4f74eebdb212e4b21c5680eec206 100644 (file)
@@ -1081,6 +1081,23 @@ class SVP64Instruction(PrefixedInstruction):
 
     prefix: Prefix
 
+    @property
+    def binary(self):
+        bits = []
+        for idx in range(64):
+            bit = int(self[idx])
+            bits.append(bit)
+        return "".join(map(str, bits))
+
+    def spec(self, record):
+        return f"sv.{self.suffix.spec(record=record)}"
+
+    def opcode(self, record):
+        return self.suffix.opcode(record=record)
+
+    def mask(self, record):
+        return self.suffix.mask(record=record)
+
     def disassemble(self, db, byteorder="little", verbose=False):
         integer_prefix = int(self.prefix)
         blob_prefix = integer_prefix.to_bytes(length=4, byteorder=byteorder)
@@ -1177,6 +1194,36 @@ class SVP64Instruction(PrefixedInstruction):
         yield f"{blob_prefix}    sv.{record.name}"
         yield f"{blob_suffix}"
 
+        if verbose:
+            indent = (" " * 4)
+            binary = self.binary
+            spec = self.spec(record=record)
+            opcode = self.opcode(record=record)
+            mask = self.mask(record=record)
+            yield f"{indent}spec"
+            yield f"{indent}{indent}{spec}"
+            yield f"{indent}binary"
+            yield f"{indent}{indent}[0:8]   {binary[0:8]}"
+            yield f"{indent}{indent}[8:16]  {binary[8:16]}"
+            yield f"{indent}{indent}[16:24] {binary[16:24]}"
+            yield f"{indent}{indent}[24:32] {binary[24:32]}"
+            yield f"{indent}{indent}[32:40] {binary[32:40]}"
+            yield f"{indent}{indent}[40:48] {binary[40:48]}"
+            yield f"{indent}{indent}[48:56] {binary[48:56]}"
+            yield f"{indent}{indent}[56:64] {binary[56:64]}"
+            yield f"{indent}opcode"
+            yield f"{indent}{indent}{opcode}"
+            yield f"{indent}mask"
+            yield f"{indent}{indent}{mask}"
+            for operand in record.operands:
+                name = operand.name
+                yield f"{indent}{name}"
+                parts = operand.disassemble(value=self,
+                    record=record, verbose=True)
+                for part in parts:
+                    yield f"{indent}{indent}{part}"
+            yield ""
+
 
 def parse(stream, factory):
     lines = filter(lambda line: not line.strip().startswith("#"), stream)