Match MachineFunction::UsedPhysRegs changes.
[oota-llvm.git] / lib / CodeGen / LiveInterval.cpp
index d178a6f444eab42a62ba208fd1b93e2ea0921dc5..45c1dd03da5881e46a9ba7a876e20ebf057c1c13 100644 (file)
@@ -23,8 +23,8 @@
 #include "llvm/Support/Streams.h"
 #include "llvm/Target/MRegisterInfo.h"
 #include <algorithm>
-#include <iostream>
 #include <map>
+#include <ostream>
 using namespace llvm;
 
 // An example for liveAt():
@@ -349,6 +349,8 @@ void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments,
   ValueNumberInfo.clear();
   ValueNumberInfo.append(NewValueNumberInfo.begin(), NewValueNumberInfo.end());
   weight += Other.weight;
+  if (Other.preference && !preference)
+    preference = Other.preference;
 }
 
 /// MergeRangesInAsValue - Merge all of the intervals in RHS into this live
@@ -467,15 +469,22 @@ void LiveInterval::MergeValueNumberInto(unsigned V1, unsigned V2) {
   }
 }
 
+unsigned LiveInterval::getSize() const {
+  unsigned Sum = 0;
+  for (const_iterator I = begin(), E = end(); I != E; ++I)
+    Sum += I->end - I->start;
+  return Sum;
+}
+
 std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) {
   return os << '[' << LR.start << ',' << LR.end << ':' << LR.ValId << ")";
 }
 
 void LiveRange::dump() const {
-  llvm_cerr << *this << "\n";
+  cerr << *this << "\n";
 }
 
-void LiveInterval::print(llvm_ostream OS, const MRegisterInfo *MRI) const {
+void LiveInterval::print(std::ostream &OS, const MRegisterInfo *MRI) const {
   if (MRI && MRegisterInfo::isPhysicalRegister(reg))
     OS << MRI->getName(reg);
   else
@@ -508,5 +517,10 @@ void LiveInterval::print(llvm_ostream OS, const MRegisterInfo *MRI) const {
 }
 
 void LiveInterval::dump() const {
-  llvm_cerr << *this << "\n";
+  cerr << *this << "\n";
+}
+
+
+void LiveRange::print(std::ostream &os) const {
+  os << *this;
 }