python: Expose the AddrRange exclude to the python world
Change-Id: I9cb1bf66d4e9390c8d3c4403afec9f896d19c162 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48904 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user