power_fields: restore class-oriented traversal
authorDmitry Selyutin <ghostmansd@gmail.com>
Tue, 20 Sep 2022 20:50:43 +0000 (23:50 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sat, 24 Sep 2022 09:07:36 +0000 (12:07 +0300)
src/openpower/decoder/power_fields.py
src/openpower/decoder/power_insn.py
src/openpower/sv/sv_binutils.py
src/openpower/sv/trans/svp64.py

index f39ff38603b096e145076bc2b42684278aa1d564..07dfe70b7df20aabdf6316a73211ffb80a7c4e43 100644 (file)
@@ -185,9 +185,9 @@ class Field(Reference, metaclass=FieldMeta):
 
         return _selectconcat(*(self[bit] for bit in tuple(key)))
 
-    def traverse(self, path):
-        span = self.__class__.__members__
-        yield (path, self.storage[span], span)
+    @classmethod
+    def traverse(cls, path):
+        yield (path, cls.__members__)
 
 
 class MappingMeta(type):
@@ -274,8 +274,9 @@ class Mapping(Reference, metaclass=MappingMeta):
 
         return self.__members[key]
 
-    def traverse(self, path=""):
-        for (name, member) in self.__members.items():
+    @classmethod
+    def traverse(cls, path):
+        for (name, member) in cls.__members__.items():
             if name == "_":
                 yield from member.traverse(path=path)
             elif path == "":
index 75879f86b126db3298809cab051b070ad9895134..c1fb4a2fcf6047f92b555ae08bdb15424e01bbbf 100644 (file)
@@ -1295,10 +1295,11 @@ class BaseRM(_Mapping):
     def disassemble(self, verbosity=Verbosity.NORMAL):
         if verbosity >= Verbosity.VERBOSE:
             indent = (" " * 4)
-            for (name, value, members) in self.traverse(path="RM"):
+            for (name, span) in self.traverse(path="RM"):
+                value = self.storage[span]
                 yield f"{name}"
                 yield f"{indent}{int(value):0{value.bits}b}"
-                yield f"{indent}{', '.join(map(str, members))}"
+                yield f"{indent}{', '.join(map(str, span))}"
 
 
 class FFPRRc1BaseRM(BaseRM):
index 6ace71b20e7b5cb08c51919c6f8e35e394c72341..713c272eb20510db07bd897531dd2db61caf6a2a 100644 (file)
@@ -320,7 +320,7 @@ class Instruction(Struct, c_tag="svp64_insn"):
 
         yield from super().c_decl()
         yield ""
-        for (path, field) in _SVP64Instruction.traverse():
+        for (path, field) in _SVP64Instruction.traverse(path="svp64_insn"):
             yield from getter(path, field)
             yield from setter(path, field)
 
index eb1f811540c2ab864b7e7bd5e2307238faad1e43..29047b11ef3f1b26c194848d66afbc5597022d93 100644 (file)
@@ -1455,8 +1455,9 @@ class SVP64Asm:
             if not v30b_op.endswith('.'):
                 v30b_op += rc
             yield "%s %s" % (v30b_op, ", ".join(v30b_newfields))
-        for (field, value, span) in svp64_insn.traverse("SVP64"):
-            log(field, f"{value.value:0{value.bits}b}", span)
+        for (name, span) in svp64_insn.traverse("SVP64"):
+            value = svp64_insn.storage[span]
+            log(name, f"{value.value:0{value.bits}b}", span)
         log("new v3.0B fields", v30b_op, v30b_newfields)
 
     def translate(self, lst):