summaryrefslogtreecommitdiff
path: root/src/base/addr_range.hh
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2015-05-26 03:21:40 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2015-05-26 03:21:40 -0400
commit53a360985b5d298e03ed0102d750b2c362ec1d90 (patch)
treeb650358bd5ab73086f731f9cd60f11f54f427a57 /src/base/addr_range.hh
parent4bc7dfb697bd779b12f1fd95fbe72144ae134055 (diff)
downloadgem5-53a360985b5d298e03ed0102d750b2c362ec1d90.tar.xz
base: Allow multiple interleaved ranges
This patch changes how the address range calculates intersection such that a system can have a number of non-overlapping interleaved ranges without complaining. Without this patch we end up with a panic.
Diffstat (limited to 'src/base/addr_range.hh')
-rw-r--r--src/base/addr_range.hh22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/base/addr_range.hh b/src/base/addr_range.hh
index 2a20863b4..ed0259ff7 100644
--- a/src/base/addr_range.hh
+++ b/src/base/addr_range.hh
@@ -282,26 +282,26 @@ class AddrRange
*/
bool intersects(const AddrRange& r) const
{
- if (!interleaved()) {
- return _start <= r._end && _end >= r._start;
- }
-
- // the current range is interleaved, split the check up in
- // three cases
+ if (_start > r._end || _end < r._start)
+ // start with the simple case of no overlap at all,
+ // applicable even if we have interleaved ranges
+ return false;
+ else if (!interleaved() && !r.interleaved())
+ // if neither range is interleaved, we are done
+ return true;
+
+ // now it gets complicated, focus on the cases we care about
if (r.size() == 1)
// keep it simple and check if the address is within
// this range
return contains(r.start());
- else if (!r.interleaved())
- // be conservative and ignore the interleaving
- return _start <= r._end && _end >= r._start;
else if (mergesWith(r))
// restrict the check to ranges that belong to the
// same chunk
return intlvMatch == r.intlvMatch;
else
- panic("Cannot test intersection of interleaved range %s\n",
- to_string());
+ panic("Cannot test intersection of %s and %s\n",
+ to_string(), r.to_string());
}
/**