Use live out sets for return values instead of imp_defs, which is cleaner and faster.
[oota-llvm.git] / lib / CodeGen / LiveInterval.h
index 87cb570306cb89f0e70f76f5222a86d0de108908..d67e018b473adfdbef9793b84d6943baf566fc7d 100644 (file)
@@ -76,11 +76,27 @@ 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
+    /// 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 hole.
+    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);
@@ -110,7 +126,7 @@ namespace llvm {
     }
 
     bool expiredAt(unsigned index) const {
-      return endNumber() <= (index + 1);
+      return index >= endNumber();
     }
 
     bool liveAt(unsigned index) const;
@@ -126,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