[llvm-commits] CVS: llvm/lib/Target/SparcV9/RegAlloc/LiveRange.h

Brian Gaeke gaeke at cs.uiuc.edu
Wed Jul 28 23:43:17 PDT 2004



Changes in directory llvm/lib/Target/SparcV9/RegAlloc:

LiveRange.h updated: 1.27 -> 1.28

---
Log message:

Don't derive from ValueSet to implement class LiveRange; instead, use a
SetVector<Value *> data member.
Add << operator for LiveRanges (a dumb one, for now.)


---
Diffs of the changes:  (+25 -8)

Index: llvm/lib/Target/SparcV9/RegAlloc/LiveRange.h
diff -u llvm/lib/Target/SparcV9/RegAlloc/LiveRange.h:1.27 llvm/lib/Target/SparcV9/RegAlloc/LiveRange.h:1.28
--- llvm/lib/Target/SparcV9/RegAlloc/LiveRange.h:1.27	Wed Jul 28 23:25:43 2004
+++ llvm/lib/Target/SparcV9/RegAlloc/LiveRange.h	Thu Jul 29 01:43:06 2004
@@ -7,11 +7,8 @@
 // 
 //===----------------------------------------------------------------------===//
 //
-// Implements a live range using a ValueSet. A LiveRange is a simple set
-// of Values. 
-//
-// Since the Value pointed by a use is the same as of its def, it is sufficient
-// to keep only defs in a LiveRange.
+// Implements a live range using a SetVector of Value *s.  We keep only
+// defs in a LiveRange.
 //
 //===----------------------------------------------------------------------===//
 
@@ -19,15 +16,23 @@
 #define LIVERANGE_H
 
 #include "llvm/Value.h"
-#include "llvm/CodeGen/ValueSet.h"
+#include "Support/SetVector.h"
+#include <iostream>
 
 namespace llvm {
 
 class RegClass;
 class IGNode;
 
-class LiveRange : public ValueSet {
-  RegClass *MyRegClass;       // register class (e.g., int, FP) for this LR
+class LiveRange {
+public:
+  typedef SetVector<const Value *> ValueContainerType;
+  typedef ValueContainerType::iterator iterator;
+  typedef ValueContainerType::const_iterator const_iterator;
+
+private:
+  ValueContainerType MyValues; // Values in this LiveRange
+  RegClass *MyRegClass;        // register class (e.g., int, FP) for this LR
 
   /// doesSpanAcrossCalls - Does this live range span across calls? 
   /// This information is used by graph coloring algo to avoid allocating
@@ -70,6 +75,13 @@
   unsigned SpillCost;
 
 public:
+  iterator        begin()       { return MyValues.begin();    }
+  const_iterator  begin() const { return MyValues.begin();    }
+  iterator          end()       { return MyValues.end();      }
+  const_iterator    end() const { return MyValues.end();      }
+  bool insert(const Value *&X)  { return MyValues.insert (X); }
+  void insert(iterator b, iterator e) { MyValues.insert (b, e); }
+
   LiveRange() {
     Color = SuggestedColor = -1;        // not yet colored 
     mustSpill = false;
@@ -172,6 +184,11 @@
   }
 };
 
+static inline std::ostream &operator << (std::ostream &os, const LiveRange &lr) {
+  os << "LiveRange@" << (void *)(&lr);
+  return os;
+};
+
 } // End llvm namespace
 
 #endif





More information about the llvm-commits mailing list