sv_binutils: inherit Struct; drop code duplication
authorDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Tue, 19 Apr 2022 21:45:47 +0000 (21:45 +0000)
committerDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Tue, 19 Apr 2022 21:45:47 +0000 (21:45 +0000)
src/openpower/sv/sv_binutils.py

index f2ec62a113ab8ac8d011ff4e5e797af7117cd170..faadbbd3b2ad62226fbade526556aa9c7d12dd45 100644 (file)
@@ -235,7 +235,7 @@ class Name(CType, str):
 
 
 @_dataclasses.dataclass(eq=True, frozen=True)
-class Record(CType):
+class Record(Struct):
     in1: In1Sel
     in2: In2Sel
     in3: In3Sel
@@ -266,21 +266,9 @@ class Record(CType):
             yield from indent([f"uint64_t : {bits_rsvd};"])
         yield f"}};"
 
-    def c_value(self, prefix="", suffix=""):
-        yield f"{prefix}{{"
-        for field in _dataclasses.fields(self):
-            name = field.name
-            attr = getattr(self, name)
-            yield from indent(attr.c_value(prefix=f".{name} = ", suffix=","))
-        yield f"}}{suffix}"
-
-    @classmethod
-    def c_var(cls, name):
-        yield f"struct svp64_record {name}"
-
 
 @_dataclasses.dataclass(eq=True, frozen=True)
-class Entry(CType):
+class Entry(Struct):
     name: Name
     record: Record
 
@@ -290,25 +278,6 @@ class Entry(CType):
 
         return self.name < other.name
 
-    @classmethod
-    def c_decl(cls):
-        yield f"struct svp64_entry {{"
-        for field in _dataclasses.fields(cls):
-            yield from indent(field.type.c_var(name=f"{field.name};"))
-        yield f"}};"
-
-    def c_value(self, prefix="", suffix=""):
-        yield f"{prefix}{{"
-        for field in _dataclasses.fields(self):
-            name = field.name
-            attr = getattr(self, name)
-            yield from indent(attr.c_value(prefix=f".{name} = ", suffix=","))
-        yield f"}}{suffix}"
-
-    @classmethod
-    def c_var(cls, name):
-        yield f"struct svp64_entry {name}"
-
 
 class Codegen(_enum.Enum):
     PPC_SVP64_H = _enum.auto()