Add a --exclude parameter to the check command.

Also, remove the expand command; when a group of checks is selected by
the 'check' command, its members are immediately added to the session.
main
Jean-François Nguyen 2 years ago
parent 7b7aa6cc9b
commit c16e678c49

@ -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


@ -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):

@ -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 *

@ -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

@ -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:

Loading…
Cancel
Save