From: Dmitry Selyutin Date: Mon, 25 Apr 2022 20:15:41 +0000 (+0000) Subject: sv_binutils: comment about enum aliases X-Git-Tag: sv_maxu_works-initial~460 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c562ef0920f4b6f0813ad30acb2191f82c80b2af;p=openpower-isa.git sv_binutils: comment about enum aliases --- diff --git a/src/openpower/sv/sv_binutils.py b/src/openpower/sv/sv_binutils.py index 5684145c..a3c61958 100644 --- a/src/openpower/sv/sv_binutils.py +++ b/src/openpower/sv/sv_binutils.py @@ -119,6 +119,7 @@ class Void(CType, typedef="void"): class EnumMeta(_enum.EnumMeta, CTypeMeta): def __call__(metacls, name, entries, tag=None, **kwargs): if isinstance(entries, type) and issubclass(entries, _enum.Enum): + # Use __members__, not __iter__, otherwise aliases are lost. entries = dict(entries.__members__) if isinstance(entries, dict): entries = tuple(entries.items()) @@ -172,6 +173,7 @@ class Constant(CType, _enum.Enum, metaclass=EnumMeta): @classmethod def c_decl(cls): yield f"/* {cls.c_tag.upper()} constants */" + # Use __members__, not __iter__, otherwise aliases are lost. for (key, item) in cls.__members__.items(): key = f"{cls.c_tag.upper()}_{key.upper()}" value = f"0x{item.value:08x}U" @@ -316,6 +318,7 @@ class FieldsMappingMeta(EnumMeta): def __iter__(cls): prefix = f"svp64_{cls.__enum.__name__}" + # Use __members__, not __iter__, otherwise aliases are lost. for (name, value) in cls.__enum.__members__.items(): yield (f"{prefix}_{name}".upper(), value)