Print PseudoSourceValue.
authorEvan Cheng <evan.cheng@apple.com>
Sun, 24 Aug 2008 18:51:20 +0000 (18:51 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Sun, 24 Aug 2008 18:51:20 +0000 (18:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55291 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/PseudoSourceValue.h
lib/CodeGen/MachineInstr.cpp
lib/CodeGen/PseudoSourceValue.cpp

index 115e565b6b6cac5584ca5402ae025730876d5c18..4620456ecfe07dbbbd0b3211ccec391a07c1b4ab 100644 (file)
@@ -18,6 +18,7 @@
 
 namespace llvm {
   class MachineFrameInfo;
+  class raw_ostream;
 
   /// PseudoSourceValue - Special value supplied for machine level alias
   /// analysis. It indicates that the a memory access references the functions
@@ -28,6 +29,7 @@ namespace llvm {
     PseudoSourceValue();
 
     virtual void print(std::ostream &OS) const;
+    virtual void print(raw_ostream &OS) const;
 
     /// isConstant - Test whether this PseudoSourceValue has a constant value.
     ///
@@ -59,6 +61,16 @@ namespace llvm {
     /// A SV referencing the jump table
     static const PseudoSourceValue *getJumpTable();
   };
+
+inline std::ostream &operator<<(std::ostream &OS,const PseudoSourceValue &PSV) {
+  PSV.print(OS);
+  return OS;
+}
+inline raw_ostream &operator<<(raw_ostream &OS, const PseudoSourceValue &PSV) {
+  PSV.print(OS);
+  return OS;
+}
+
 } // End llvm namespace
 
 #endif
index 00987d76fcdde0836b536ccf57228f1111ee2d70..41df5df5a564b5bee2d888b1f4a780b9b5d59978 100644 (file)
@@ -756,8 +756,8 @@ void MachineInstr::print(std::ostream &OS, const TargetMachine *TM) const {
         OS << "<unknown>";
       else if (!V->getName().empty())
         OS << V->getName();
-      else if (isa<PseudoSourceValue>(V))
-        OS << *V;
+      else if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V))
+        OS << *PSV;
       else
         OS << V;
 
index bcf4ea8fb75da67d8171ab9c24daf4f7f24332a9..ac41609d39a78266aedd2bfe375220789703f2fc 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/raw_ostream.h"
 #include <map>
 
 namespace llvm {
@@ -43,6 +44,9 @@ namespace llvm {
   void PseudoSourceValue::print(std::ostream &OS) const {
     OS << PSVNames[this - *PSVs];
   }
+  void PseudoSourceValue::print(raw_ostream &OS) const {
+    OS << PSVNames[this - *PSVs];
+  }
 
   /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
   /// for holding FixedStack values, which must include a frame
@@ -58,6 +62,9 @@ namespace llvm {
     virtual void print(std::ostream &OS) const {
       OS << "FixedStack" << FI;
     }
+    virtual void print(raw_ostream &OS) const {
+      OS << "FixedStack" << FI;
+    }
   };
 
   static ManagedStatic<std::map<int, const PseudoSourceValue *> > FSValues;