diff --git a/cores/microwatt/checks.pfv b/cores/microwatt/checks.pfv index 81ce8da..93f5c38 100644 --- a/cores/microwatt/checks.pfv +++ b/cores/microwatt/checks.pfv @@ -1,7 +1,7 @@ check unique --depth=15 --skip=12 check cia --depth=15 check gpr --depth=15 -check insn --depth=15 +check insn --depth=15 --exclude=brh,brw,setbc,setbcr,setnbc,setnbcr check microwatt:storage:data --depth=15 diff --git a/power_fv/check/__init__.py b/power_fv/check/__init__.py index 2ee8348..881f8ad 100644 --- a/power_fv/check/__init__.py +++ b/power_fv/check/__init__.py @@ -23,13 +23,14 @@ class PowerFVCheckMeta(ABCMeta): return cls @classmethod - def find(cls, *name): + def find(cls, name, *, sep=":"): + name = tuple(name.split(sep)) for check_name, check_cls in cls.all_checks.items(): assert isinstance(check_name, tuple) if len(name) > len(check_name): continue if name == check_name[:len(name)]: - yield check_name, check_cls + yield sep.join(check_name), check_cls class PowerFVCheck(metaclass=PowerFVCheckMeta): diff --git a/power_fv/check/insn/all.py b/power_fv/check/insn/all.py index 27a5408..5b45a55 100644 --- a/power_fv/check/insn/all.py +++ b/power_fv/check/insn/all.py @@ -8,8 +8,6 @@ from .trap import * from .logical import * from .rotate import * from .bcd import * +from .byterev import * from .msr import * from .spr import * - -# TODO: add a --exclude= argument to the 'check' command -# from .byterev import * diff --git a/power_fv/check/insn/cr.py b/power_fv/check/insn/cr.py index 2a26e0d..54fd77f 100644 --- a/power_fv/check/insn/cr.py +++ b/power_fv/check/insn/cr.py @@ -6,7 +6,7 @@ from power_fv.check.insn import InsnCheck __all__ = [ "CRAND", "CROR", "CRNAND", "CRXOR", "CRNOR", "CRANDC", "CREQV", "CRORC", "MCRF", "MCRXRX", "MTCRF", "MFOCRF", "MFCR", - "SETB", #"SETBC", "SETBCR", "SETNBC", "SETNBCR", + "SETB", "SETBC", "SETBCR", "SETNBC", "SETNBCR", ] @@ -27,9 +27,7 @@ class MFOCRF (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.MFOCRF): pass class MFCR (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.MFCR ): pass class SETB (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETB ): pass - -# TODO: add a --exclude= argument to the 'check' command -# class SETBC (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETBC ): pass -# class SETBCR (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETBCR ): pass -# class SETNBC (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETNBC ): pass -# class SETNBCR(InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETNBCR): pass +class SETBC (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETBC ): pass +class SETBCR (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETBCR ): pass +class SETNBC (InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETNBC ): pass +class SETNBCR(InsnCheck, spec_cls=CRMoveSpec, insn_cls=const.SETNBCR): pass diff --git a/power_fv/session.py b/power_fv/session.py index a94450f..90e90e1 100644 --- a/power_fv/session.py +++ b/power_fv/session.py @@ -40,12 +40,11 @@ class PowerFVSession: def __init__(self, prog=None): self.parser = _ArgumentParser(prog=prog, add_help=False) self.subparsers = self.parser.add_subparsers(help="commands") - self.namespace = dict() + self._checks = dict() self.add_help_subparser() self.add_check_subparser() self.add_dump_subparser() - self.add_expand_subparser() self.add_build_subparser() self.add_exit_subparser() @@ -102,14 +101,14 @@ class PowerFVSession: PowerFVCheck .add_check_arguments(parser) self.core_cls.add_check_arguments(parser) + parser.add_argument( + "--exclude", type=str, default="", + help="exclude a comma-separated list of checks from the selection") + def add_dump_subparser(self): parser = self.subparsers.add_parser("dump", help="inspect check parameters") parser.set_defaults(_cmd=self.dump) - def add_expand_subparser(self): - parser = self.subparsers.add_parser("expand", help="expand check parameters") - parser.set_defaults(_cmd=self.expand) - def add_build_subparser(self): parser = self.subparsers.add_parser("build", help="execute the build plan") parser.set_defaults(_cmd=self.build) @@ -130,23 +129,20 @@ class PowerFVSession: def help(self, **kwargs): self.parser.print_help() - def check(self, *, name, **kwargs): - self.namespace[name] = dict(**kwargs) - - def dump(self, **kwargs): - pprint(self.namespace, sort_dicts=False) + def check(self, *, name, exclude, **kwargs): + exclude = [f"{name}:{subname}" for subname in exclude.split(",")] + matches = list(PowerFVCheck.find(name)) + new_checks = dict() - def expand(self, **kwargs): - new_namespace = dict() + for check_name, check_cls in matches: + if check_name in exclude: + continue + new_checks[check_name] = dict(**kwargs) - for check_name, check_args in self.namespace.items(): - matches = list(PowerFVCheck.find(*check_name.split(":"))) - if not matches: - raise NameError("Unknown check {!r}".format(check_name)) - for match_name, match_cls in matches: - new_namespace[":".join(match_name)] = check_args + self._checks.update(new_checks) - self.namespace = new_namespace + def dump(self, **kwargs): + pprint(self._checks, sort_dicts=False) @staticmethod def _build_check(core_cls, check_name, check_args, build_args): @@ -156,12 +152,10 @@ class PowerFVSession: check.build(**build_args) def build(self, *, jobs, **kwargs): - self.expand() - map_func = PowerFVSession._build_check map_args = [] - for check_name, check_args in self.namespace.items(): + for check_name, check_args in self._checks.items(): map_args.append((self.core_cls, check_name, check_args, kwargs)) with multiprocessing.Pool(jobs) as pool: