Print the symbolic register name in a register allocator debug dump.
authorChris Lattner <sabre@nondot.org>
Sat, 14 May 2005 05:34:15 +0000 (05:34 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 14 May 2005 05:34:15 +0000 (05:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22002 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveInterval.h
lib/CodeGen/LiveInterval.cpp
lib/CodeGen/LiveInterval.h
lib/CodeGen/LiveIntervalAnalysis.cpp

index d67e018b473adfdbef9793b84d6943baf566fc7d..6cac0960b2127f19b47716531054d01dda55e98b 100644 (file)
@@ -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 @@ namespace llvm {
       return beginNumber() < other.beginNumber();
     }
 
+    void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const;
     void dump() const;
 
   private:
@@ -185,7 +188,10 @@ namespace llvm {
     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 ffa4caab06f13960aa4d0af45ef919cd0db8b41b..01298e9c6c9d20f97defc25f4242c2c9979a2254 100644 (file)
@@ -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 @@ void LiveRange::dump() const {
   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 d67e018b473adfdbef9793b84d6943baf566fc7d..6cac0960b2127f19b47716531054d01dda55e98b 100644 (file)
@@ -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 @@ namespace llvm {
       return beginNumber() < other.beginNumber();
     }
 
+    void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const;
     void dump() const;
 
   private:
@@ -185,7 +188,10 @@ namespace llvm {
     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 d75bf3fb0efd1d59ddfb057663e9feaa7b477e83..9f0bce8296f84c8cf3dc8b6072ab93f7a9db843c 100644 (file)
@@ -142,11 +142,11 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
 
   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();