insndb/db: introduce section command
authorDmitry Selyutin <ghostmansd@gmail.com>
Thu, 22 Jun 2023 20:22:38 +0000 (23:22 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Dec 2023 19:26:19 +0000 (19:26 +0000)
src/openpower/insndb/db.py

index 0de00b10072ac4e528d946d64675ebe183e2672f..50fe9ebab5d767fab023cb4dc5c458a2fbaf0ddc 100644 (file)
@@ -14,6 +14,7 @@ from openpower.insndb.core import (
     PCode,
     Operands,
     Record,
+    Section,
     SVP64Record,
     Walker,
 )
@@ -139,6 +140,44 @@ class PTypeVisitor(SVP64InstructionVisitor):
         yield node
 
 
+class SectionVisitor(InstructionVisitor):
+    @mdis.dispatcher.Hook(Section.Path)
+    @contextlib.contextmanager
+    def dispatch_path(self, node):
+        print("path", node)
+        yield node
+
+    @mdis.dispatcher.Hook(Section.BitSel)
+    @contextlib.contextmanager
+    def dispatch_bitsel(self, node):
+        print("bitsel", node)
+        yield node
+
+    @mdis.dispatcher.Hook(Section.Suffix)
+    @contextlib.contextmanager
+    def dispatch_suffix(self, node):
+        print("suffix", node)
+        yield node
+
+    @mdis.dispatcher.Hook(Section.Mode)
+    @contextlib.contextmanager
+    def dispatch_mode(self, node):
+        print("mode", node)
+        yield node
+
+    @mdis.dispatcher.Hook(Section.Opcode)
+    @contextlib.contextmanager
+    def dispatch_opcode(self, node):
+        print("opcode", int(node))
+        yield node
+
+    @mdis.dispatcher.Hook(Section.Priority)
+    @contextlib.contextmanager
+    def dispatch_priority(self, node):
+        print("priority", node)
+        yield node
+
+
 class ExtrasVisitor(SVP64InstructionVisitor, SelectorsVisitor):
     @mdis.dispatcher.Hook(SVP64Record.ExtraMap)
     @contextlib.contextmanager
@@ -195,6 +234,10 @@ def main():
             PTypeVisitor,
             "print instruction ptype",
         ),
+        "section": (
+            SectionVisitor,
+            "print instruction section",
+        ),
         "extras": (
             ExtrasVisitor,
             "print instruction extras (SVP64)",