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

Chris Lattner lattner at cs.uiuc.edu
Fri May 13 22:34:32 PDT 2005



Changes in directory llvm/lib/CodeGen:

LiveInterval.cpp updated: 1.20 -> 1.21
LiveInterval.h updated: 1.13 -> 1.14
LiveIntervalAnalysis.cpp updated: 1.140 -> 1.141
---
Log message:

Print the symbolic register name in a register allocator debug dump.


---
Diffs of the changes:  (+29 -17)

 LiveInterval.cpp         |   28 +++++++++++++++++-----------
 LiveInterval.h           |    8 +++++++-
 LiveIntervalAnalysis.cpp |   10 +++++-----
 3 files changed, 29 insertions(+), 17 deletions(-)


Index: llvm/lib/CodeGen/LiveInterval.cpp
diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.20 llvm/lib/CodeGen/LiveInterval.cpp:1.21
--- llvm/lib/CodeGen/LiveInterval.cpp:1.20	Thu Apr 21 17:33:33 2005
+++ llvm/lib/CodeGen/LiveInterval.cpp	Sat May 14 00:34:15 2005
@@ -20,6 +20,7 @@
 
 #include "LiveInterval.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Target/MRegisterInfo.h"
 #include <algorithm>
 #include <iostream>
 #include <map>
@@ -351,17 +352,22 @@
   std::cerr << *this << "\n";
 }
 
-
-std::ostream& llvm::operator<<(std::ostream& os, const LiveInterval& li) {
-  os << "%reg" << li.reg << ',' << li.weight;
-  if (li.empty())
-    return os << "EMPTY";
-
-  os << " = ";
-  for (LiveInterval::Ranges::const_iterator i = li.ranges.begin(),
-         e = li.ranges.end(); i != e; ++i)
-    os << *i;
-  return os;
+void LiveInterval::print(std::ostream &OS, const MRegisterInfo *MRI) const {
+  if (MRI && MRegisterInfo::isPhysicalRegister(reg))
+    OS << MRI->getName(reg);
+  else
+    OS << "%reg" << reg;
+
+  OS << ',' << weight;
+
+  if (empty())
+    OS << "EMPTY";
+  else {
+    OS << " = ";
+    for (LiveInterval::Ranges::const_iterator I = ranges.begin(),
+           E = ranges.end(); I != E; ++I)
+    OS << *I;
+  }
 }
 
 void LiveInterval::dump() const {


Index: llvm/lib/CodeGen/LiveInterval.h
diff -u llvm/lib/CodeGen/LiveInterval.h:1.13 llvm/lib/CodeGen/LiveInterval.h:1.14
--- llvm/lib/CodeGen/LiveInterval.h:1.13	Wed Nov 17 22:31:10 2004
+++ llvm/lib/CodeGen/LiveInterval.h	Sat May 14 00:34:15 2005
@@ -26,6 +26,8 @@
 #include <cassert>
 
 namespace llvm {
+  class MRegisterInfo;
+
   /// LiveRange structure - This represents a simple register range in the
   /// program, with an inclusive start point and an exclusive end point.
   /// These ranges are rendered as [start,end).
@@ -175,6 +177,7 @@
       return beginNumber() < other.beginNumber();
     }
 
+    void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const;
     void dump() const;
 
   private:
@@ -185,7 +188,10 @@
     LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT
   };
 
-  std::ostream& operator<<(std::ostream& os, const LiveInterval& li);
+  inline std::ostream &operator<<(std::ostream &OS, const LiveInterval &LI) {
+    LI.print(OS);
+    return OS;
+  }
 }
 
 #endif


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.140 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.141
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.140	Fri May 13 02:08:07 2005
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp	Sat May 14 00:34:15 2005
@@ -142,11 +142,11 @@
 
   numIntervals += getNumIntervals();
 
-#if 1
-  DEBUG(std::cerr << "********** INTERVALS **********\n");
-  DEBUG(for (iterator I = begin(), E = end(); I != E; ++I)
-        std::cerr << I->second << "\n");
-#endif
+  DEBUG(std::cerr << "********** INTERVALS **********\n";
+        for (iterator I = begin(), E = end(); I != E; ++I) {
+          I->second.print(std::cerr, mri_);
+          std::cerr << "\n";
+        });
 
   // join intervals if requested
   if (EnableJoining) joinIntervals();






More information about the llvm-commits mailing list