From 905bd130985cd2d35b4de24a55b12a47d44672bf Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Tue, 19 Apr 2022 21:45:47 +0000 Subject: [PATCH] sv_binutils: inherit Struct; drop code duplication --- src/openpower/sv/sv_binutils.py | 35 ++------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/src/openpower/sv/sv_binutils.py b/src/openpower/sv/sv_binutils.py index f2ec62a1..faadbbd3 100644 --- a/src/openpower/sv/sv_binutils.py +++ b/src/openpower/sv/sv_binutils.py @@ -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() -- 2.30.2