diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-04-18 08:52:15 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-04-18 08:52:15 +0000 |
commit | b685be0c1e9ad74ae9b48a676ec8099990f6add7 (patch) | |
tree | c81058a38b42d26ebfc63fdc3d8af8736aa36bb5 /llvm | |
parent | 508a7dda4a21dbe5dcef852b40361ca33c4e81a7 (diff) | |
download | bcm5719-llvm-b685be0c1e9ad74ae9b48a676ec8099990f6add7.tar.gz bcm5719-llvm-b685be0c1e9ad74ae9b48a676ec8099990f6add7.zip |
Add a new LiveInterval::overlaps(). It checks if the live interval overlaps a range specified by [Start, End).
llvm-svn: 69434
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/CodeGen/LiveInterval.h | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/LiveInterval.cpp | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h index c75d5947b96..00b51a16f1e 100644 --- a/llvm/include/llvm/CodeGen/LiveInterval.h +++ b/llvm/include/llvm/CodeGen/LiveInterval.h @@ -379,6 +379,10 @@ namespace llvm { return overlapsFrom(other, other.begin()); } + /// overlaps - Return true if the live interval overlaps a range specified + /// by [Start, End). + bool overlaps(unsigned Start, unsigned End) const; + /// 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. diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp index 3f8714085ae..68d9ad4b3e6 100644 --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -123,6 +123,22 @@ bool LiveInterval::overlapsFrom(const LiveInterval& other, return false; } +/// overlaps - Return true if the live interval overlaps a range specified +/// by [Start, End). +bool LiveInterval::overlaps(unsigned Start, unsigned End) const { + assert(Start < End && "Invalid range"); + const_iterator I = begin(); + const_iterator E = end(); + const_iterator si = std::upper_bound(I, E, Start); + const_iterator ei = std::upper_bound(I, E, End); + if (si != ei) + return true; + if (si == I) + return false; + --si; + return si->contains(Start); +} + /// extendIntervalEndTo - This method is used when we want to extend the range /// specified by I to end at the specified endpoint. To do this, we should /// merge and eliminate all ranges that this will overlap with. The iterator is |