From: Dmitry Selyutin Date: Thu, 22 Jun 2023 18:31:59 +0000 (+0300) Subject: insndb/db: refactor extras command X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5c486d28f0b643f8dcdfa98790a1d527edb71d45;p=openpower-isa.git insndb/db: refactor extras command --- diff --git a/src/openpower/insndb/db.py b/src/openpower/insndb/db.py index d18df31d..4c725fee 100644 --- a/src/openpower/insndb/db.py +++ b/src/openpower/insndb/db.py @@ -1,7 +1,6 @@ import argparse import contextlib import os -import types import mdis.dispatcher import mdis.visitor @@ -15,8 +14,19 @@ from openpower.insndb.core import ( PCode, Operands, Record, + SVP64Record, Walker, ) +from openpower.decoder.power_enums import ( + SVExtra, + In1Sel, + In2Sel, + In3Sel, + OutSel, + CRInSel, + CRIn2Sel, + CROutSel, +) class Instruction(str): @@ -97,15 +107,41 @@ class PCodeVisitor(InstructionVisitor): class ExtrasVisitor(SVP64InstructionVisitor): - @mdis.dispatcher.Hook(Record) + @mdis.dispatcher.Hook( + In1Sel, In2Sel, In3Sel, CRInSel, CRIn2Sel, + OutSel, CROutSel, + ) @contextlib.contextmanager - def dispatch_record(self, node): - for (name, extra) in node.extras.items(): - print(name) - print(" sel", extra["sel"]) - print(" reg", extra["reg"]) - print(" seltype", extra["seltype"]) - print(" idx", extra["idx"]) + def dispatch_selector(self, node): + typename = node.__class__.__name__ + typename = typename.replace("CR", "CR_") + typename = typename.replace("Sel", "") + typename = typename.lower() + print(typename, node) + yield node + + @mdis.dispatcher.Hook(SVP64Record.ExtraMap) + @contextlib.contextmanager + def dispatch_extramap(self, node): + self.__index = -1 + yield node + + @mdis.dispatcher.Hook(SVP64Record.ExtraMap.Extra) + @contextlib.contextmanager + def dispatch_extramap_extra(self, node): + self.__index += 1 + yield node + + @mdis.dispatcher.Hook(SVP64Record.ExtraMap.Extra.Entry) + @contextlib.contextmanager + def dispatch_extramap_extra_entry(self, node): + idxmap = ( + SVExtra.Idx0, + SVExtra.Idx1, + SVExtra.Idx2, + SVExtra.Idx3, + ) + print(idxmap[self.__index], node) yield node