Add new advanceTo method
authorChris Lattner <sabre@nondot.org>
Thu, 18 Nov 2004 02:37:31 +0000 (02:37 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Nov 2004 02:37:31 +0000 (02:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17932 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveInterval.h
lib/CodeGen/LiveInterval.h

index 2784ba7f2b19cdbe579706ebdede0ca5f3b45a5c..05ebcc1ca2fd2b9856434de40ebc8c398984b81c 100644 (file)
@@ -81,6 +81,19 @@ namespace llvm {
     iterator begin() { return ranges.begin(); }
     iterator end()   { 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
+    /// end of the interval.  If no LiveRange contains this position, but the
+    /// position is in a hole, this method returns an iterator pointing the the
+    /// LiveRange immediately after the hold.
+    iterator advanceTo(iterator I, unsigned Pos) {
+      if (Pos >= endNumber())
+        return end();
+      while (I->end <= Pos) ++I;
+      return I;
+    }
+
     void swap(LiveInterval& other) {
       std::swap(reg, other.reg);
       std::swap(weight, other.weight);
index 2784ba7f2b19cdbe579706ebdede0ca5f3b45a5c..05ebcc1ca2fd2b9856434de40ebc8c398984b81c 100644 (file)
@@ -81,6 +81,19 @@ namespace llvm {
     iterator begin() { return ranges.begin(); }
     iterator end()   { 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
+    /// end of the interval.  If no LiveRange contains this position, but the
+    /// position is in a hole, this method returns an iterator pointing the the
+    /// LiveRange immediately after the hold.
+    iterator advanceTo(iterator I, unsigned Pos) {
+      if (Pos >= endNumber())
+        return end();
+      while (I->end <= Pos) ++I;
+      return I;
+    }
+
     void swap(LiveInterval& other) {
       std::swap(reg, other.reg);
       std::swap(weight, other.weight);