power_insn: update disassembly target_addr
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Sep 2022 17:44:33 +0000 (20:44 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Sep 2022 18:41:29 +0000 (21:41 +0300)
src/openpower/decoder/power_insn.py

index 7c1ad7c5d4dd9cee78b68ea52b82ddf8a0356b90..a655111ef7cd0b9ce240fbedf2fdd85a04ba2131 100644 (file)
@@ -436,21 +436,39 @@ class Operands:
 
     @_dataclasses.dataclass(eq=True, frozen=True)
     class DynamicOperandIFormLI(DynamicOperand):
+        @property
+        def name(self):
+            return "LI"
+
+        @name.setter
+        def name(self, _):
+            pass
+
         def disassemble(self, value, record, verbose=False):
             span = record.fields["LI"]
             value = value[span]
             if verbose:
-                return f"{int(value):0{value.bits}b}{{00}} {span}"
+                hints = "(target_addr=EXTS(LI || 0b00)))"
+                return f"{int(value):0{value.bits}b} {span} {hints}"
             else:
                 return hex(int(_selectconcat(value,
                     _SelectableInt(value=0b00, bits=2))))
 
     class DynamicOperandBFormBD(DynamicOperand):
+        @property
+        def name(self):
+            return "BD"
+
+        @name.setter
+        def name(self, _):
+            pass
+
         def disassemble(self, value, record, verbose=False):
             span = record.fields["BD"]
             value = value[span]
             if verbose:
-                return f"{int(value):0{value.bits}b}{{00}} {span}"
+                hints = "(target_addr=EXTS(BD || 0b00))"
+                return f"{int(value):0{value.bits}b} {span} {hints}"
             else:
                 return hex(int(_selectconcat(value,
                     _SelectableInt(value=0b00, bits=2))))
@@ -747,18 +765,19 @@ class WordInstruction(Instruction):
         yield f"{blob}    {record.name}{operands}"
 
         if verbose:
-            indent = (" " * 4)
+            lindent = (" " * 4)
+            rindent = (len(blob) - len(lindent))
             spec = self.spec(record=record)
             opcode = self.opcode(record=record)
             mask = self.mask(record=record)
-            yield f"{indent}{'spec':11}{spec}"
-            yield f"{indent}{'opcode':11}{opcode}"
-            yield f"{indent}{'mask':11}{mask}"
+            yield f"{lindent}{'spec':{rindent}}{spec}"
+            yield f"{lindent}{'opcode':{rindent}}{opcode}"
+            yield f"{lindent}{'mask':{rindent}}{mask}"
             for operand in record.operands:
                 name = operand.name
                 value = operand.disassemble(value=self,
                     record=record, verbose=True)
-                yield f"{indent}{name:11}{value}"
+                yield f"{lindent}{name:{rindent}}{value}"
 
 
 class PrefixedInstruction(Instruction):