From: Dmitry Selyutin Date: Mon, 25 Apr 2022 19:40:32 +0000 (+0000) Subject: sv_binutils: undefine temporary macros X-Git-Tag: sv_maxu_works-initial~463 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d5ef38566aaee244019886995f1e86d5e3cc932;p=openpower-isa.git sv_binutils: undefine temporary macros --- diff --git a/src/openpower/sv/sv_binutils.py b/src/openpower/sv/sv_binutils.py index 352507e7..1775aa96 100644 --- a/src/openpower/sv/sv_binutils.py +++ b/src/openpower/sv/sv_binutils.py @@ -2,6 +2,7 @@ import abc as _abc import argparse as _argparse import dataclasses as _dataclasses import enum as _enum +import operator as _operator from openpower.decoder.power_enums import ( In1Sel as _In1Sel, @@ -568,21 +569,33 @@ class Codegen(_enum.Enum): bit_and = lambda lhs, rhs: f"({lhs} & {rhs})" bit_not = lambda val: f"~({val})" - macros = { - "CLEAR(VALUE, BIT)": + macros = ( + ( + "SVP64_FIELD_CLEAR", + ("VALUE", "BIT"), bit_and("VALUE", bit_not(bit_shl("UINT32_C(1)", "BIT"))), - "REMAP(VALUE, SRC, DST)": + ), + ( + "SVP64_FIELD_REMAP", + ("VALUE", "SRC", "DST"), bit_shl(bit_get("VALUE", "SRC"), "DST"), - "GET(ORIGIN, SRC, DST)": + ), + ( + "SVP64_FIELD_GET", + ("ORIGIN", "SRC", "DST"), "SVP64_FIELD_REMAP(ORIGIN, SRC, DST)", - "SET(RESULT, VALUE, SRC, DST)": + ), + ( + "SVP64_FIELD_SET", + ("RESULT", "VALUE", "SRC", "DST"), " = ".join(["*(RESULT)", bit_or( lhs="SVP64_FIELD_CLEAR(*(RESULT), DST)", rhs="SVP64_FIELD_REMAP(VALUE, SRC, DST)", )]), - } - for (call, body) in macros.items(): - yield f"#define SVP64_FIELD_{call} \\" + ), + ) + for (name, args, body) in macros: + yield f"#define {name}({', '.join(args)}) \\" yield from indent([body]) yield "" @@ -592,6 +605,10 @@ class Codegen(_enum.Enum): yield from subcls.c_value() yield "" + for name in map(_operator.itemgetter(0), macros): + yield f"#undef {name}" + yield "" + entries = Entry[...](entries) num_entries = Size("(sizeof (svp64_entries) / sizeof (svp64_entries[0]))")