Use live out sets for return values instead of imp_defs, which is cleaner and faster.
[oota-llvm.git] / lib / CodeGen / LiveInterval.h
index 75acf52c4acce2d9df3e488971afa7c1f785c6b5..d67e018b473adfdbef9793b84d6943baf566fc7d 100644 (file)
@@ -76,6 +76,34 @@ 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);
+      ranges.swap(other.ranges);
+      std::swap(NumValues, other.NumValues);
+    }
+
     bool containsOneValue() const { return NumValues == 1; }
 
     unsigned getNextValue() {
@@ -84,28 +112,28 @@ namespace llvm {
 
     bool empty() const { return ranges.empty(); }
 
-    /// start - Return the lowest numbered slot covered by interval.
-    unsigned start() const {
+    /// beginNumber - Return the lowest numbered slot covered by interval.
+    unsigned beginNumber() const {
       assert(!empty() && "empty interval for register");
       return ranges.front().start;
     }
 
-    /// end - return the maximum point of the interval of the whole,
+    /// endNumber - return the maximum point of the interval of the whole,
     /// exclusive.
-    unsigned end() const {
+    unsigned endNumber() const {
       assert(!empty() && "empty interval for register");
       return ranges.back().end;
     }
 
     bool expiredAt(unsigned index) const {
-      return end() <= (index + 1);
+      return index >= endNumber();
     }
 
     bool liveAt(unsigned index) const;
 
     /// getLiveRangeContaining - Return the live range that contains the
     /// specified index, or null if there is none.
-    LiveRange *getLiveRangeContaining(unsigned Idx);
+    const LiveRange *getLiveRangeContaining(unsigned Idx) const;
 
 
     /// joinable - Two intervals are joinable if the either don't overlap at all
@@ -114,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
@@ -135,7 +172,7 @@ namespace llvm {
     void removeRange(unsigned Start, unsigned End);
 
     bool operator<(const LiveInterval& other) const {
-      return start() < other.start();
+      return beginNumber() < other.beginNumber();
     }
 
     void dump() const;
@@ -145,6 +182,7 @@ namespace llvm {
     Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From);
     void extendIntervalEndTo(Ranges::iterator I, unsigned NewEnd);
     Ranges::iterator extendIntervalStartTo(Ranges::iterator I, unsigned NewStr);
+    LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT
   };
 
   std::ostream& operator<<(std::ostream& os, const LiveInterval& li);