From: Dmitry Selyutin Date: Sun, 27 Feb 2022 21:51:04 +0000 (+0000) Subject: sv_binutils: introduce constants class X-Git-Tag: sv_maxu_works-initial~518 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d1b415e4383366cf445fd4ff2db828a612f88099;p=openpower-isa.git sv_binutils: introduce constants class --- diff --git a/src/openpower/sv/sv_binutils.py b/src/openpower/sv/sv_binutils.py index f65e78b1..e11c9f47 100644 --- a/src/openpower/sv/sv_binutils.py +++ b/src/openpower/sv/sv_binutils.py @@ -15,6 +15,7 @@ from openpower.decoder.power_enums import ( SVEXTRA as _SVEXTRA, RC as _RC, ) +from openpower.consts import SVP64MODE as _SVP64MODE from openpower.decoder.power_svp64 import SVP64RM as _SVP64RM @@ -92,6 +93,24 @@ SVEType = Enum("SVEType", names=_SVEtype.__members__.items()) SVEXTRA = Enum("SVEXTRA", names=_SVEXTRA.__members__.items()) +class Constant(CType, _enum.Enum): + @classmethod + def c_decl(cls): + c_tag = f"svp64_{cls.__name__.lower()}" + yield f"/* {c_tag.upper()} constants */" + for (key, item) in cls.__members__.items(): + key = f"{c_tag.upper()}_{key.upper()}" + value = f"0x{item.value:08x}U" + yield f"#define {key} {value}" + + def c_value(self, prefix="", suffix=""): + c_tag = f"svp64_{self.__class__.__name__.lower()}" + yield f"{prefix}{c_tag.upper()}_{self.name.upper()}{suffix}" + + +Mode = Constant("Mode", names=_SVP64MODE.__members__.items()) + + class Opcode(CType): def __init__(self, value, mask, bits): self.__value = value @@ -296,6 +315,7 @@ class Codegen(_enum.Enum): In1Sel, In2Sel, In3Sel, OutSel, CRInSel, CROutSel, SVPType, SVEType, SVEXTRA, + Mode, ) for enum in enums: yield from enum.c_decl()