Han-sheng Liu has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/68617?usp=email )

Change subject: base: support calculating the intersection of two AddrRange
......................................................................

base: support calculating the intersection of two AddrRange

Change-Id: I2f089039c709fe4c3f7086263fb56470c7713bad
---
M src/base/addr_range.hh
1 file changed, 16 insertions(+), 0 deletions(-)



diff --git a/src/base/addr_range.hh b/src/base/addr_range.hh
index 07bd255..5386838 100644
--- a/src/base/addr_range.hh
+++ b/src/base/addr_range.hh
@@ -732,6 +732,22 @@
     {
         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

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/68617?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I2f089039c709fe4c3f7086263fb56470c7713bad
Gerrit-Change-Number: 68617
Gerrit-PatchSet: 1
Gerrit-Owner: Han-sheng Liu <handsome...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to