[llvm-commits] CVS: llvm/lib/CodeGen/LiveInterval.cpp LiveInterval.h

Chris Lattner lattner at cs.uiuc.edu
Wed Nov 17 19:47:46 PST 2004



Changes in directory llvm/lib/CodeGen:

LiveInterval.cpp updated: 1.14 -> 1.15
LiveInterval.h updated: 1.11 -> 1.12
---
Log message:

Add ability to give hints to the overlaps routines.


---
Diffs of the changes:  (+27 -7)

Index: llvm/lib/CodeGen/LiveInterval.cpp
diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.14 llvm/lib/CodeGen/LiveInterval.cpp:1.15
--- llvm/lib/CodeGen/LiveInterval.cpp:1.14	Tue Nov 16 00:52:35 2004
+++ llvm/lib/CodeGen/LiveInterval.cpp	Wed Nov 17 21:47:34 2004
@@ -42,6 +42,9 @@
   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 @@
 //
 // 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);


Index: llvm/lib/CodeGen/LiveInterval.h
diff -u llvm/lib/CodeGen/LiveInterval.h:1.11 llvm/lib/CodeGen/LiveInterval.h:1.12
--- llvm/lib/CodeGen/LiveInterval.h:1.11	Wed Nov 17 20:37:31 2004
+++ llvm/lib/CodeGen/LiveInterval.h	Wed Nov 17 21:47:34 2004
@@ -76,11 +76,14 @@
       : 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 @@
     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






More information about the llvm-commits mailing list