summaryrefslogtreecommitdiff
path: root/configs/common/ObjectList.py
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2019-09-03 15:45:19 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2019-10-01 06:15:03 +0000
commit34f850f80316201379d888bd72791be93aa5d06f (patch)
treee7d7be6b080fc774c8d48a449e1a6493bf02f3bd /configs/common/ObjectList.py
parent224da08be767b51e8148e5f3e6e0da2e2ea77add (diff)
downloadgem5-34f850f80316201379d888bd72791be93aa5d06f.tar.xz
configs: Port PlatformConfig to the common object list
Port PlatformConfig to use the common object list. Change-Id: If62e596bf1f28b49994da3a2800450d163383755 Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20593 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'configs/common/ObjectList.py')
-rw-r--r--configs/common/ObjectList.py36
1 files changed, 31 insertions, 5 deletions
diff --git a/configs/common/ObjectList.py b/configs/common/ObjectList.py
index 62e0db10f..c197439c5 100644
--- a/configs/common/ObjectList.py
+++ b/configs/common/ObjectList.py
@@ -63,8 +63,9 @@ class ObjectList(object):
def get(self, name):
"""Get a sub class from a user provided class name or alias."""
+ real_name = self._aliases.get(name, name)
try:
- sub_cls = self._sub_classes[name]
+ sub_cls = self._sub_classes[real_name]
return sub_cls
except KeyError:
print("{} is not a valid sub-class of {}.".format(name, \
@@ -72,7 +73,7 @@ class ObjectList(object):
raise
def print(self):
- """Print the list of available sub-classes."""
+ """Print a list of available sub-classes and aliases."""
print("Available {} classes:".format(self.base_cls))
doc_wrapper = TextWrapper(initial_indent="\t\t",
@@ -87,16 +88,28 @@ class ObjectList(object):
for line in doc_wrapper.wrap(doc):
print(line)
+ if self._aliases:
+ print("\Aliases:")
+ for alias, target in self._aliases.items():
+ print("\t{} => {}".format(alias, target))
+
def get_names(self):
- """Return a list of valid sub-class names."""
- return list(self._sub_classes.keys())
+ """Return a list of valid sub-class names and aliases."""
+ return list(self._sub_classes.keys()) + list(self._aliases.keys())
def _add_objects(self):
"""Add all sub-classes of the base class in the object hierarchy."""
for name, cls in inspect.getmembers(m5.objects, self._is_obj_class):
self._sub_classes[name] = cls
- def __init__(self, base_cls):
+ def _add_aliases(self, aliases):
+ """Add all aliases of the sub-classes."""
+ if aliases is not None:
+ for alias, target in aliases:
+ if target in self._sub_classes:
+ self._aliases[alias] = target
+
+ def __init__(self, base_cls, aliases=None):
# Base class that will be used to determine if models are of this
# object class
self.base_cls = base_cls
@@ -104,6 +117,11 @@ class ObjectList(object):
self._sub_classes = {}
self._add_objects()
+ # Filtered list of aliases. Only aliases for existing objects exist
+ # in this list.
+ self._aliases = {}
+ self._add_aliases(aliases)
+
class CPUList(ObjectList):
def _is_obj_class(self, cls):
"""Determine if a class is a CPU that can be instantiated"""
@@ -141,6 +159,14 @@ hwp_list = ObjectList(m5.objects.BasePrefetcher)
indirect_bp_list = ObjectList(m5.objects.IndirectPredictor)
mem_list = ObjectList(m5.objects.AbstractMemory)
+# Platform aliases. The platforms listed here might not be compiled,
+# we make sure they exist before we add them to the platform list.
+_platform_aliases_all = [
+ ("RealView_PBX", "RealViewPBX"),
+ ("VExpress_GEM5", "VExpress_GEM5_V1"),
+ ]
+platform_list = ObjectList(m5.objects.Platform, _platform_aliases_all)
+
def _subclass_tester(name):
sub_class = getattr(m5.objects, name, None)