From 1d600cd599e2b1ce668c2d1a833cb8850bc4faa1 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Fri, 30 Jul 2021 10:57:06 +0100 Subject: [PATCH] python: Expose the AddrRange exclude to the python world Change-Id: I9cb1bf66d4e9390c8d3c4403afec9f896d19c162 Signed-off-by: Giacomo Travaglini Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48904 Reviewed-by: Jason Lowe-Power Reviewed-by: Andreas Sandberg Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/python/m5/params.py | 11 +++++++++++ src/python/pybind11/core.cc | 1 + 2 files changed, 12 insertions(+) diff --git a/src/python/m5/params.py b/src/python/m5/params.py index 67bba65d9d..8db8e6afb7 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -864,6 +864,17 @@ class AddrRange(ParamValue): return AddrRange(int(self.start), int(self.end), self.masks, int(self.intlvMatch)) + def exclude(self, ranges): + from _m5.range import AddrRangeVector + + # The wrapped C++ class is assuming an AddrRangeVector + # We are therefore converting to it before excluding ranges + # and reconverting it into a list of AddrRange before returning + pybind_exclude = AddrRangeVector([ r.getValue() for r in ranges ]) + pybind_include = self.getValue().exclude(pybind_exclude) + + return [ AddrRange(r.start(), r.end()) for r in pybind_include ] + # Boolean parameter type. Python doesn't let you subclass bool, since # it doesn't want to let you create multiple instances of True and # False. Thus this is a little more complicated than String. diff --git a/src/python/pybind11/core.cc b/src/python/pybind11/core.cc index 0e9c31110f..257ae231ac 100644 --- a/src/python/pybind11/core.cc +++ b/src/python/pybind11/core.cc @@ -167,6 +167,7 @@ init_range(py::module_ &m_native) .def("mergesWith", &AddrRange::mergesWith) .def("intersects", &AddrRange::intersects) .def("isSubset", &AddrRange::isSubset) + .def("exclude", &AddrRange::exclude) ; // We need to make vectors of AddrRange opaque to avoid weird