summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-11-18 03:47:34 +0000
committerChris Lattner <sabre@nondot.org>2004-11-18 03:47:34 +0000
commitcb0c9655bfa5bcdbbab54f740a8c07c682fecbdd (patch)
tree42c6814d96e2e1020603e1690f44741a24953852 /llvm/lib/CodeGen
parenta1f777987643075f6d9dd843f25597f82063ff85 (diff)
downloadbcm5719-llvm-cb0c9655bfa5bcdbbab54f740a8c07c682fecbdd.tar.gz
bcm5719-llvm-cb0c9655bfa5bcdbbab54f740a8c07c682fecbdd.zip
Add ability to give hints to the overlaps routines.
llvm-svn: 17934
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/LiveInterval.cpp18
-rw-r--r--llvm/lib/CodeGen/LiveInterval.h16
2 files changed, 27 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp
index 8306116b1a8..3c7e8dd7632 100644
--- a/llvm/lib/CodeGen/LiveInterval.cpp
+++ b/llvm/lib/CodeGen/LiveInterval.cpp
@@ -42,6 +42,9 @@ bool LiveInterval::liveAt(unsigned I) const {
return r->contains(I);
}
+// overlaps - Return true if the intersection of the two live intervals is
+// not empty.
+//
// An example for overlaps():
//
// 0: A = ...
@@ -56,11 +59,16 @@ bool LiveInterval::liveAt(unsigned I) const {
//
// A->overlaps(C) should return false since we want to be able to join
// A and C.
-bool LiveInterval::overlaps(const LiveInterval& other) const {
- Ranges::const_iterator i = ranges.begin();
- Ranges::const_iterator ie = ranges.end();
- Ranges::const_iterator j = other.ranges.begin();
- Ranges::const_iterator je = other.ranges.end();
+//
+bool LiveInterval::overlapsFrom(const LiveInterval& other,
+ const_iterator StartPos) const {
+ const_iterator i = begin();
+ const_iterator ie = end();
+ const_iterator j = StartPos;
+ const_iterator je = other.end();
+
+ assert((StartPos->start <= i->start || StartPos == other.begin()) &&
+ "Bogus start position hint!");
if (i->start < j->start) {
i = std::upper_bound(i, ie, j->start);
diff --git a/llvm/lib/CodeGen/LiveInterval.h b/llvm/lib/CodeGen/LiveInterval.h
index 05ebcc1ca2f..55de7e38d84 100644
--- a/llvm/lib/CodeGen/LiveInterval.h
+++ b/llvm/lib/CodeGen/LiveInterval.h
@@ -76,11 +76,14 @@ namespace llvm {
: reg(Reg), weight(Weight), NumValues(0) {
}
-
typedef Ranges::iterator iterator;
iterator begin() { return ranges.begin(); }
iterator end() { return ranges.end(); }
+ typedef Ranges::const_iterator const_iterator;
+ const_iterator begin() const { return ranges.begin(); }
+ const_iterator end() const { return ranges.end(); }
+
/// advanceTo - Advance the specified iterator to point to the LiveRange
/// containing the specified position, or end() if the position is past the
@@ -139,7 +142,16 @@ namespace llvm {
bool joinable(const LiveInterval& other, unsigned CopyIdx) const;
- bool overlaps(const LiveInterval& other) const;
+ /// overlaps - Return true if the intersection of the two live intervals is
+ /// not empty.
+ bool overlaps(const LiveInterval& other) const {
+ return overlapsFrom(other, other.begin());
+ }
+
+ /// overlapsFrom - Return true if the intersection of the two live intervals
+ /// is not empty. The specified iterator is a hint that we can begin
+ /// scanning the Other interval starting at I.
+ bool overlapsFrom(const LiveInterval& other, const_iterator I) const;
/// addRange - Add the specified LiveRange to this interval, merging
/// intervals as appropriate. This returns an iterator to the inserted live
OpenPOWER on IntegriCloud