diff options
author | Jairo Balart <jairo.balart@metempsy.com> | 2019-01-07 07:45:14 +0100 |
---|---|---|
committer | Jairo Balart <jairo.balart@metempsy.com> | 2019-05-13 11:44:08 +0000 |
commit | e541767279f7d8b47f9892145a02f1f5c859be89 (patch) | |
tree | 2033b6794d3146cb13deb95c31eea862b52c85bf /configs/common/BPConfig.py | |
parent | 0473f8f65f8c70ddaf55e9f90b99631a9baacaa7 (diff) | |
download | gem5-e541767279f7d8b47f9892145a02f1f5c859be89.tar.xz |
config: add an option to list and select indirect branch predictor
Change-Id: I9a855d36de7d95b7785ff8a897899037cea6a3d8
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/15320
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'configs/common/BPConfig.py')
-rw-r--r-- | configs/common/BPConfig.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/configs/common/BPConfig.py b/configs/common/BPConfig.py index 65e6d65a2..e6fe1f9c0 100644 --- a/configs/common/BPConfig.py +++ b/configs/common/BPConfig.py @@ -86,3 +86,54 @@ def bp_names(): for name, cls in inspect.getmembers(m5.objects, is_bp_class): _bp_classes[name] = cls + +# The same for indirect branch predictors... +# Dictionary of mapping names of real branch predictor models to classes. +_indirect_bp_classes = {} + + +def is_indirect_bp_class(cls): + """Determine if a class is an indirect branch predictor that can be + instantiated""" + + # We can't use the normal inspect.isclass because the ParamFactory + # and ProxyFactory classes have a tendency to confuse it. + try: + return issubclass(cls, m5.objects.IndirectPredictor) and \ + not cls.abstract + except (TypeError, AttributeError): + return False + +def get_indirect(name): + """Get an Indirect BP class from a user provided class name or alias.""" + + try: + indirect_bp_class = _indirect_bp_classes[name] + return indirect_bp_class + except KeyError: + print("%s is not a valid indirect BP model." % (name,)) + sys.exit(1) + +def print_indirect_bp_list(): + """Print a list of available indirect BP classes.""" + + print("Available Indirect BranchPredictor classes:") + doc_wrapper = TextWrapper(initial_indent="\t\t", subsequent_indent="\t\t") + for name, cls in _indirect_bp_classes.items(): + print("\t%s" % name) + + # Try to extract the class documentation from the class help + # string. + doc = inspect.getdoc(cls) + if doc: + for line in doc_wrapper.wrap(doc): + print(line) + +def indirect_bp_names(): + """Return a list of valid Indirect Branch Predictor names.""" + return _indirect_bp_classes.keys() + +# Add all indirect BPs in the object hierarchy. +for name, cls in inspect.getmembers(m5.objects, is_indirect_bp_class): + _indirect_bp_classes[name] = cls + |