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,
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 ""
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]))")