base: support calculating the intersection of two AddrRange
Change-Id: I2f089039c709fe4c3f7086263fb56470c7713bad Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/68617 Maintainer: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
committed by
Han-sheng Liu
parent
6884aeb86a
commit
da050eedde
@@ -732,6 +732,22 @@ class AddrRange
|
||||
{
|
||||
return !(*this == r);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup api_addr_range
|
||||
*/
|
||||
AddrRange
|
||||
operator&(const AddrRange& r) const
|
||||
{
|
||||
panic_if(this->interleaved() || r.interleaved(),
|
||||
"Cannot calculate intersection of interleaved ranges.");
|
||||
Addr start = std::max(this->_start, r._start);
|
||||
Addr end = std::min(this->_end, r._end);
|
||||
if (end <= start) {
|
||||
return AddrRange(0, 0);
|
||||
}
|
||||
return AddrRange(start, end);
|
||||
}
|
||||
};
|
||||
|
||||
static inline AddrRangeList
|
||||
|
||||
Reference in New Issue
Block a user