Added an automatic cast to "std::ostream*" etc. from OStream. We then can
authorBill Wendling <isanbard@gmail.com>
Sun, 17 Dec 2006 05:15:13 +0000 (05:15 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 17 Dec 2006 05:15:13 +0000 (05:15 +0000)
rework the hacks that had us passing OStream in. We pass in std::ostream*
instead, check for null, and then dispatch to the correct print() method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32636 91177308-0d34-0410-b5e6-96231b3b80d8

46 files changed:
include/llvm/ADT/BitSetVector.h
include/llvm/Analysis/AliasSetTracker.h
include/llvm/Analysis/CallGraph.h
include/llvm/Analysis/Dominators.h
include/llvm/Analysis/FindUsedTypes.h
include/llvm/Analysis/Interval.h
include/llvm/Analysis/IntervalPartition.h
include/llvm/Analysis/LoopInfo.h
include/llvm/Analysis/ScalarEvolution.h
include/llvm/Analysis/ScalarEvolutionExpressions.h
include/llvm/Analysis/Trace.h
include/llvm/Argument.h
include/llvm/BasicBlock.h
include/llvm/CodeGen/LinkAllCodegenComponents.h
include/llvm/CodeGen/LiveInterval.h
include/llvm/CodeGen/LiveIntervalAnalysis.h
include/llvm/CodeGen/MachineBasicBlock.h
include/llvm/CodeGen/MachineConstantPool.h
include/llvm/CodeGen/MachineFunction.h
include/llvm/CodeGen/MachineInstr.h
include/llvm/CodeGen/MachineJumpTableInfo.h
include/llvm/CodeGen/SchedGraphCommon.h
include/llvm/Constant.h
include/llvm/Function.h
include/llvm/GlobalVariable.h
include/llvm/InlineAsm.h
include/llvm/Instruction.h
include/llvm/Module.h
include/llvm/Pass.h
include/llvm/Support/ConstantRange.h
include/llvm/Support/Debug.h
include/llvm/Support/Streams.h
include/llvm/Target/SubtargetFeature.h
include/llvm/Type.h
include/llvm/Value.h
lib/Analysis/IPA/CallGraph.cpp
lib/Analysis/Trace.cpp
lib/Bytecode/Writer/Writer.cpp
lib/CodeGen/DwarfWriter.cpp
lib/CodeGen/LiveInterval.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp
lib/CodeGen/VirtRegMap.cpp
lib/CodeGen/VirtRegMap.h
lib/Support/Debug.cpp
lib/Support/Streams.cpp
lib/Transforms/Utils/LowerSwitch.cpp

index 5d1fc86c3ab9a8bcf561f56451c7437ea49a5b78..21d3cc9e7b0fa142cde38e606cc3a43e3a2edc15 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "llvm/Support/Streams.h"
 #include <bitset>
-#include <vector>
 #include <functional>
 
 namespace llvm {
@@ -173,10 +172,8 @@ public:
   ///
   ///  Printing and debugging support
   ///
-  void print(OStream &O) const {
-    if (O.stream()) print(*O.stream());
-  }
   void print(std::ostream &O) const;
+  void print(std::ostream *O) const { if (O) print(*O); }
   void dump() const { print(cerr); }
 
 public:
@@ -247,24 +244,18 @@ public:
 };
 
 
-inline void BitSetVector::print(std::ostream& O) const
+inline void BitSetVector::print(llvm_ostream& O) const
 {
   for (std::vector<bitword>::const_iterator
          I=bitsetVec.begin(), E=bitsetVec.end(); I != E; ++I)
     O << "<" << (*I) << ">" << (I+1 == E? "\n" : ", ");
 }
 
-inline OStream& operator<< (OStream& O, const BitSetVector& bset) {
-  bset.print(O);
-  return O;
-}
-inline std::ostream& operator<< (std::ostream& O, const BitSetVector& bset)
-{
+inline std::ostream& operator<<(std::ostream& O, const BitSetVector& bset) {
   bset.print(O);
   return O;
 }
 
-
 ///
 /// Optimized versions of fundamental comparison operations
 ///
index 5fcda162703014378998baee736ec3e097fc5820..cd6450fac82656fdb25fea45adac615691ccdedf 100644 (file)
@@ -156,10 +156,8 @@ public:
   iterator end()   const { return iterator(); }
   bool empty() const { return PtrList == 0; }
 
-  void print(OStream &OS) const {
-    if (OS.stream()) print(*OS.stream());
-  }
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   void dump() const;
 
   /// Define an iterator for alias sets... this is just a forward iterator.
@@ -248,10 +246,6 @@ private:
   bool aliasesCallSite(CallSite CS, AliasAnalysis &AA) const;
 };
 
-inline OStream& operator<<(OStream &OS, const AliasSet &AS) {
-  AS.print(OS);
-  return OS;
-}
 inline std::ostream& operator<<(std::ostream &OS, const AliasSet &AS) {
   AS.print(OS);
   return OS;
@@ -361,10 +355,8 @@ public:
   iterator begin() { return AliasSets.begin(); }
   iterator end()   { return AliasSets.end(); }
 
-  void print(OStream &OS) const {
-    if (OS.stream()) print(*OS.stream());
-  }
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   void dump() const;
 
 private:
@@ -390,10 +382,6 @@ private:
   AliasSet *findAliasSetForCallSite(CallSite CS);
 };
 
-inline OStream& operator<<(OStream &OS, const AliasSetTracker &AST) {
-  AST.print(OS);
-  return OS;
-}
 inline std::ostream& operator<<(std::ostream &OS, const AliasSetTracker &AST) {
   AST.print(OS);
   return OS;
index 1f737da53c4dc9721903ebf7d190e8b5152ec583..24effd8d49d2ec3d390e5fd48ffb67b0794dd6ed 100644 (file)
@@ -152,10 +152,8 @@ public:
   ///
   void initialize(Module &M);
 
-  void print(OStream &o, const Module *M) const {
-    if (o.stream()) print(*o.stream(), M);
-  }
   virtual void print(std::ostream &o, const Module *M) const;
+  void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
   void dump() const;
   
   // stub - dummy function, just ignore it
@@ -201,10 +199,8 @@ public:
   /// dump - Print out this call graph node.
   ///
   void dump() const;
-  void print(OStream &OS) const {
-    if (OS.stream()) print(*OS.stream());
-  }
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   //===---------------------------------------------------------------------
   // Methods to keep a call graph up to date with a function that has been
index 939300f8aca1598ec1970940fde619a31631b02d..f29ed8345dcaa74604976932ff9ae01a49045051 100644 (file)
@@ -144,6 +144,9 @@ public:
   /// print - Convert to human readable form
   ///
   virtual void print(std::ostream &OS, const Module* = 0) const;
+  void print(std::ostream *OS, const Module* M = 0) const {
+    if (OS) print(*OS, M);
+  }
 };
 
 //===-------------------------------------
@@ -234,6 +237,9 @@ public:
   /// print - Convert to human readable form
   ///
   virtual void print(std::ostream &OS, const Module* = 0) const;
+  void print(std::ostream *OS, const Module* M = 0) const {
+    if (OS) print(*OS, M);
+  }
 
   /// dominates - Return true if A dominates B.  This performs the special
   /// checks necessary if A and B are in the same basic block.
@@ -410,6 +416,9 @@ public:
   /// print - Convert to human readable form
   ///
   virtual void print(std::ostream &OS, const Module* = 0) const;
+  void print(std::ostream *OS, const Module* M = 0) const {
+    if (OS) print(*OS, M);
+  }
 };
 
 //===-------------------------------------
@@ -546,6 +555,9 @@ public:
   /// print - Convert to human readable form
   ///
   virtual void print(std::ostream &OS, const Module* = 0) const;
+  void print(std::ostream *OS, const Module* M = 0) const {
+    if (OS) print(*OS, M);
+  }
 protected:
   /// getNode - return the (Post)DominatorTree node for the specified basic
   /// block.  This is the same as using operator[] on this class.
@@ -635,6 +647,9 @@ public:
   /// print - Convert to human readable form
   ///
   virtual void print(std::ostream &OS, const Module* = 0) const;
+  void print(std::ostream *OS, const Module* M = 0) const {
+    if (OS) print(*OS, M);
+  }
 };
 
 
index fbf41de7cb6e2e843c6b8c00408d70519e7a8ffb..008e30c93efe4d6faa5e53288869d5f0f9294a88 100644 (file)
@@ -34,6 +34,7 @@ public:
   /// symbol table from the module.
   ///
   void print(std::ostream &o, const Module *M) const;
+  void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
 
 private:
   /// IncorporateType - Incorporate one type and all of its subtypes into the
index b9e1d31e3a36b4bad7e02b5308d7587945757ddf..bed815a66525e0962625ab5829975075da2e29d4 100644 (file)
@@ -99,6 +99,7 @@ public:
 
   /// print - Show contents in human readable format...
   void print(std::ostream &O) const;
+  void print(std::ostream *O) const { if (O) print(*O); }
 };
 
 /// succ_begin/succ_end - define methods so that Intervals may be used
index 1cc903cae1db1ba559802f95cf9ba497b588792c..bd998e81de22380f1092df9b5017d47dd5b86292 100644 (file)
@@ -61,6 +61,9 @@ public:
 
   // print - Show contents in human readable format...
   virtual void print(std::ostream &O, const Module* = 0) const;
+  void print(std::ostream *O, const Module* M = 0) const {
+    if (O) print(*O, M);
+  }
 
   // getRootInterval() - Return the root interval that contains the starting
   // block of the function.
index 238a0f627d470d1ed7a625eb759b575f2c1735d7..62f19e3c29eea69f35652146e1febcdae1dac875 100644 (file)
@@ -217,10 +217,10 @@ public:
   /// the mapping in the LoopInfo class.
   void removeBlockFromLoop(BasicBlock *BB);
 
-  void print(OStream &O, unsigned Depth = 0) const {
-    if (O.stream()) print(*O.stream(), Depth);
-  }
   void print(std::ostream &O, unsigned Depth = 0) const;
+  void print(std::ostream *O, unsigned Depth = 0) const {
+    if (O) print(*O, Depth);
+  }
   void dump() const;
 private:
   friend class LoopInfo;
@@ -283,10 +283,11 @@ public:
   virtual bool runOnFunction(Function &F);
 
   virtual void releaseMemory();
-  void print(OStream &O, const Module* = 0) const {
-    if (O.stream()) print(*O.stream());
-  }
+
   void print(std::ostream &O, const Module* = 0) const;
+  void print(std::ostream *O, const Module* M = 0) const {
+    if (O) print(*O, M);
+  }
 
   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
 
index 4eb0bb33b255d48fcfbe393ea7bc92117707f971..4aac284ee006775b3a80435fc369541281dcbd73 100644 (file)
@@ -97,20 +97,14 @@ namespace llvm {
     /// print - Print out the internal representation of this scalar to the
     /// specified stream.  This should really only be used for debugging
     /// purposes.
-    void print(OStream &OS) const {
-      if (OS.stream()) print(*OS.stream());
-    }
     virtual void print(std::ostream &OS) const = 0;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// dump - This method is used for debugging.
     ///
     void dump() const;
   };
 
-  inline OStream &operator<<(OStream &OS, const SCEV &S) {
-    S.print(OS);
-    return OS;
-  }
   inline std::ostream &operator<<(std::ostream &OS, const SCEV &S) {
     S.print(OS);
     return OS;
@@ -128,10 +122,8 @@ namespace llvm {
     virtual bool isLoopInvariant(const Loop *L) const;
     virtual const Type *getType() const;
     virtual bool hasComputableLoopEvolution(const Loop *L) const;
-    void print(OStream &OS) const {
-      if (OS.stream()) print(*OS.stream());
-    }
     virtual void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
     virtual SCEVHandle
     replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
                                       const SCEVHandle &Conc) const;
@@ -242,10 +234,10 @@ namespace llvm {
     virtual bool runOnFunction(Function &F);
     virtual void releaseMemory();
     virtual void getAnalysisUsage(AnalysisUsage &AU) const;
-    void print(OStream &OS, const Module* = 0) const {
-      if (OS.stream()) print(*OS.stream());
-    }
     virtual void print(std::ostream &OS, const Module* = 0) const;
+    void print(std::ostream *OS, const Module* M = 0) const {
+      if (OS) print(*OS, M);
+    }
   };
 }
 
index ba1b6d4fecb06218eb07bcbd4b39bb0801c3dcb0..c261dfc8e590aca8ab94aff323f8a6ce29d0df88 100644 (file)
@@ -62,6 +62,7 @@ namespace llvm {
     }
 
     virtual void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVConstant *S) { return true; }
@@ -108,6 +109,7 @@ namespace llvm {
     virtual ConstantRange getValueRange() const;
 
     virtual void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVTruncateExpr *S) { return true; }
@@ -154,6 +156,7 @@ namespace llvm {
     }
 
     virtual void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVZeroExtendExpr *S) { return true; }
@@ -218,6 +221,7 @@ namespace llvm {
 
     virtual const Type *getType() const { return getOperand(0)->getType(); }
     virtual void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVCommutativeExpr *S) { return true; }
@@ -332,6 +336,7 @@ namespace llvm {
     virtual const Type *getType() const;
 
     void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVSDivExpr *S) { return true; }
@@ -428,6 +433,7 @@ namespace llvm {
                                                  const SCEVHandle &Conc) const;
 
     virtual void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVAddRecExpr *S) { return true; }
@@ -472,6 +478,7 @@ namespace llvm {
     virtual const Type *getType() const;
 
     virtual void print(std::ostream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
 
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVUnknown *S) { return true; }
index b26101d15ca1a222426d9a9230e4dc6a91541eb9..65aa593c8d263665128925530a4b0b5bd3ab69f1 100644 (file)
@@ -106,7 +106,8 @@ public:
 
   /// print - Write trace to output stream.
   ///
-  void print (OStream &O) const;
+  void print (std::ostream &O) const;
+  void print (std::ostream *O) const { if (O) print(*O); }
 
   /// dump - Debugger convenience method; writes trace to standard error
   /// output stream.
index 1751c21ce274d7f2ac867768b99ddf3d6e975caf..1d92066ce582f0f3e5ed6a6c6aba8203abe9235e 100644 (file)
@@ -53,6 +53,9 @@ public:
   const Argument *getPrev() const { return Prev; }
 
   virtual void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const {
+    if (OS) print(*OS);
+  }
 
   /// classof - Methods for support type inquiry through isa, cast, and
   /// dyn_cast:
index f15d2b46a91453ca2a2bfa3802afb623389a2586..0ca8eae1a3ef01e1865083e111d85b594c55d162 100644 (file)
@@ -152,6 +152,7 @@ public:
         InstListType &getInstList()       { return InstList; }
 
   virtual void print(std::ostream &OS) const { print(OS, 0); }
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
index 5c39b505fec234ee89615c611a20d91f0603e876..1cf75bf01f647d88e2c91fc5dac8e8b0190d6f09 100644 (file)
@@ -31,6 +31,7 @@ namespace {
       (void) llvm::createSimpleRegisterAllocator();
       (void) llvm::createLocalRegisterAllocator();
       (void) llvm::createLinearScanRegisterAllocator();
+      (void) llvm::createGraphColoringRegisterAllocator();
       
       (void) llvm::createBFS_DAGScheduler(NULL, NULL, NULL);
       (void) llvm::createSimpleDAGScheduler(NULL, NULL, NULL);
index b22922c84c054ec9f29ab974ec97b16cf6525d1f..367cefeb36c0601b1d247eea85c175b73b9534f8 100644 (file)
@@ -57,16 +57,13 @@ namespace llvm {
 
     void dump() const;
     void print(std::ostream &os) const;
+    void print(std::ostream *os) const { if (os) print(*os); }
 
   private:
     LiveRange(); // DO NOT IMPLEMENT
   };
 
   std::ostream& operator<<(std::ostream& os, const LiveRange &LR);
-  inline OStream& operator<<(OStream& os, const LiveRange &LR) {
-    if (os.stream()) LR.print(*os.stream());
-    return os;
-  }
 
 
   inline bool operator<(unsigned V, const LiveRange &LR) {
@@ -260,9 +257,9 @@ namespace llvm {
       return beginNumber() < other.beginNumber();
     }
 
-    void print(OStream OS, const MRegisterInfo *MRI = 0) const;
-    void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const {
-      print(OStream(OS), MRI);
+    void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const;
+    void print(std::ostream *OS, const MRegisterInfo *MRI = 0) const {
+      if (OS) print(*OS, MRI);
     }
     void dump() const;
 
@@ -273,11 +270,6 @@ namespace llvm {
     LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT
   };
 
-  inline OStream &operator<<(OStream &OS, const LiveInterval &LI) {
-    LI.print(OS);
-    return OS;
-  }
-
   inline std::ostream &operator<<(std::ostream &OS, const LiveInterval &LI) {
     LI.print(OS);
     return OS;
index 11f836b99ac8b326b0d5920461672ff2f13654de..e0f60452e39a28f88ae745e8a3768ce7823cc9d2 100644 (file)
@@ -161,6 +161,9 @@ namespace llvm {
 
     /// print - Implement the dump method.
     virtual void print(std::ostream &O, const Module* = 0) const;
+    void print(std::ostream *O, const Module* M = 0) const {
+      if (O) print(*O, M);
+    }
 
   private:
     /// RemoveMachineInstrFromMaps - This marks the specified machine instr as
index 896d9efe03eceea34755c2706c7d1da651f83d9f..1fd36ed55a71fbe478f7b04f9181f5c777bf0e10 100644 (file)
@@ -189,10 +189,8 @@ public:
 
   // Debugging methods.
   void dump() const;
-  void print(OStream &OS) const {
-    if (OS.stream()) print(*OS.stream());
-  }
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   /// getNumber - MachineBasicBlocks are uniquely numbered at the function
   /// level, unless they're not in a MachineFunction yet, in which case this
@@ -226,10 +224,6 @@ private:   // Methods used to maintain doubly linked list of blocks...
 };
 
 std::ostream& operator<<(std::ostream &OS, const MachineBasicBlock &MBB);
-inline OStream& operator<<(OStream &OS, const MachineBasicBlock &MBB) {
-  if (OS.stream()) MBB.print(*OS.stream());
-  return OS;
-}
 
 //===--------------------------------------------------------------------===//
 // GraphTraits specializations for machine basic block graphs (machine-CFGs)
index bc701f6b86f496363e2680097ace060b3581501d..ffd0e55663465dab800917c6e39fbb54b73a23bf 100644 (file)
@@ -49,17 +49,10 @@ public:
 
   /// print - Implement operator<<...
   ///
-  void print(OStream &O) const {
-    if (O.stream()) print(*O.stream());
-  }
   virtual void print(std::ostream &O) const = 0;
+  void print(std::ostream *O) const { if (O) print(*O); }
 };
 
-inline OStream &operator<<(OStream &OS,
-                           const MachineConstantPoolValue &V) {
-  V.print(OS);
-  return OS;
-}
 inline std::ostream &operator<<(std::ostream &OS,
                                 const MachineConstantPoolValue &V) {
   V.print(OS);
@@ -143,10 +136,8 @@ public:
   /// print - Used by the MachineFunction printer to print information about
   /// constant pool objects.  Implemented in MachineFunction.cpp
   ///
-  void print(OStream &OS) const {
-    if (OS.stream()) print(*OS.stream());
-  }
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   /// dump - Call print(std::cerr) to be called from the debugger.
   ///
index f264c91c11d4527bbea24cb365b585e69aac06bb..c393b07aaf347e452296141692d6210b517f1e49 100644 (file)
@@ -238,6 +238,7 @@ public:
   /// to the specified stream.
   ///
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   /// viewCFG - This function is meant for use from the debugger.  You can just
   /// say 'call F->viewCFG()' and a ghostview window should pop up from the
index 77de83768e387a85ddd49270e107d02c1ab4449b..ad2ccdf8ca14adc40ef72e4018707d69b78b6862 100644 (file)
@@ -78,6 +78,7 @@ private:
   MachineOperand() {}
 
   void print(std::ostream &os) const;
+  void print(std::ostream *os) const { if (os) print(*os); }
 
 public:
   MachineOperand(const MachineOperand &M) {
@@ -288,10 +289,6 @@ public:
     IsDead = false;
   }
 
-  friend OStream& operator<<(OStream& os, const MachineOperand& mop) {
-    if (os.stream()) mop.print(*os.stream());
-    return os;
-  }
   friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop) {
     mop.print(os);
     return os;
@@ -403,16 +400,13 @@ public:
   //
   // Debugging support
   //
-  void print(OStream &OS, const TargetMachine *TM) const {
-    if (OS.stream()) print(*OS.stream(), TM);
+  void print(std::ostream *OS, const TargetMachine *TM) const {
+    if (OS) print(*OS, TM);
   }
   void print(std::ostream &OS, const TargetMachine *TM) const;
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   void dump() const;
-  friend OStream& operator<<(OStream& os, const MachineInstr& minstr) {
-    if (os.stream()) minstr.print(*os.stream());
-    return os;
-  }
   friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr){
     minstr.print(os);
     return os;
index 8064fa431c085c1be4effaa3a2edc87419e8fb2f..404ed15fd985ef22266aa06034f2e167b1d7267c 100644 (file)
@@ -90,6 +90,7 @@ public:
   /// jump tables.  Implemented in MachineFunction.cpp
   ///
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   /// dump - Call print(std::cerr) to be called from the debugger.
   ///
index 7da2f732bac53dc97b448d238b5d0291b1c3e8f5..4fcd9acc0ea198a66281923de2e1a11d278f916c 100644 (file)
@@ -70,10 +70,8 @@ public:
   void dump(int indent=0) const;
 
   // Debugging support
-  void print(OStream &os) const {
-    if (os.stream()) print(*os.stream());
-  }
   virtual void print(std::ostream &os) const = 0;
+  void print(std::ostream *os) const { if (os) print(*os); }
 
 protected:
   friend class SchedGraphCommon;
@@ -96,11 +94,6 @@ protected:
 };
 
 // ostream << operator for SchedGraphNode class
-inline OStream &operator<<(OStream &os,
-                           const SchedGraphNodeCommon &node) {
-  node.print(os);
-  return os;
-}
 inline std::ostream &operator<<(std::ostream &os,
                                 const SchedGraphNodeCommon &node) {
   node.print(os);
@@ -188,10 +181,8 @@ public:
 
 public:
   // Debugging support
-  void print(OStream &os) const {
-    if (os.stream()) print(*os.stream());
-  }
   void print(std::ostream &os) const;
+  void print(std::ostream *os) const { if (os) print(*os); }
   void dump(int indent=0) const;
 
 private:
@@ -200,10 +191,6 @@ private:
 };
 
 // ostream << operator for SchedGraphNode class
-inline OStream &operator<<(OStream &os, const SchedGraphEdge &edge) {
-  edge.print(os);
-  return os;
-}
 inline std::ostream &operator<<(std::ostream &os, const SchedGraphEdge &edge) {
   edge.print(os);
   return os;
index 24fb99036ecc66e24d54caf9f64af37d64dda316..feb7edef0e5d91c6a86f5391a09385f58f9e5f69 100644 (file)
@@ -54,6 +54,7 @@ public:
   virtual bool isNullValue() const = 0;
 
   virtual void print(std::ostream &O) const;
+  void print(std::ostream *O) const { if (O) print(*O); }
   
   /// canTrap - Return true if evaluation of this constant could trap.  This is
   /// true for things like constant expressions that could divide by zero.
index 58184de3b18993c9746d75fe492a15c2c47c0603..7346c3b3e361a33e097568278fbaac93acc4ef43 100644 (file)
@@ -194,6 +194,7 @@ public:
   bool                        arg_empty() const { return ArgumentList.empty(); }
 
   virtual void print(std::ostream &OS) const { print(OS, 0); }
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
 
   /// viewCFG - This function is meant for use from the debugger.  You can just
index 0679e38bb3e03dc6935e4a3a5d5b53ca93345ed4..5e31c6bd1961aea838448e3e18faec2dcf369958 100644 (file)
@@ -123,6 +123,7 @@ public:
   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
 
   virtual void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const GlobalVariable *) { return true; }
index b9f707cf83cbebd1d7e0ded73deb9b213deb5f6d..98f254f5389649354bc24907558980255183ab91 100644 (file)
@@ -60,6 +60,7 @@ public:
   const std::string &getConstraintString() const { return Constraints; }
 
   virtual void print(std::ostream &O) const { print(O, 0); }
+  void print(std::ostream *O) const { if (O) print(*O); }
   void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
 
   /// Verify - This static method can be used by the parser to check to see if
index 4af83c7a567fc6f2b272a6e90c5c2c909dd4900f..ce7596990246a43b44050ac2368d73c979410190 100644 (file)
@@ -169,6 +169,7 @@ public:
   static bool isTrapping(unsigned op);
 
   virtual void print(std::ostream &OS) const { print(OS, 0); }
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
index 35b04b1017f95c4ad121bc48ce18a27387af838f..42214af1ac37929b2c4e9acfd858722be915a030 100644 (file)
@@ -295,15 +295,13 @@ public:
 /// @{
 public:
   /// Print the module to an output stream
-  void print(OStream &OS) const {
-    if (OS.stream()) print(*OS.stream(), 0);
-  }
   void print(std::ostream &OS) const { print(OS, 0); }
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   /// Print the module to an output stream with AssemblyAnnotationWriter.
-  void print(OStream &OS, AssemblyAnnotationWriter *AAW) const {
-    if (OS.stream()) print(*OS.stream(), AAW);
-  }
   void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
+  void print(std::ostream *OS, AssemblyAnnotationWriter *AAW) const {
+    if (OS) print(*OS, AAW);
+  }
   /// Dump the module to std::cerr (for debugging).
   void dump() const;
   /// This function causes all the subinstructions to "let go" of all references
index 15381ac978b13a245bdf4898cf770ca98e12340a..9663826ccf615343b006d8b31899bb91202d9961 100644 (file)
@@ -105,10 +105,8 @@ public:
   /// provide the Module* in case the analysis doesn't need it it can just be
   /// ignored.
   ///
-  void print(OStream &O, const Module *M) const {
-    if (O.stream()) print(*O.stream(), M);
-  }
   virtual void print(std::ostream &O, const Module *M) const;
+  void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); }
   void dump() const; // dump - call print(std::cerr, 0);
 
   // Access AnalysisResolver_New
index 6866ffeb11a39e0c12bd359025a73e1e4c372cfc..f50e97959d7d08a0c1cd26f6e682d3d21d6cd042 100644 (file)
@@ -141,10 +141,8 @@ class ConstantRange {
 
   /// print - Print out the bounds to a stream...
   ///
-  void print(OStream &OS) const {
-    if (OS.stream()) print(*OS.stream());
-  }
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
 
   /// dump - Allow printing from a debugger easily...
   ///
index 09878b9d1e5f7ac5858e0b6feb6478325c8aecfb..627d088eb05e169cc184a2365bff49a009577f18 100644 (file)
@@ -65,10 +65,10 @@ bool isCurrentDebugType(const char *Type);
 /// places the std::c* I/O streams into one .cpp file and relieves the whole
 /// program from having to have hundreds of static c'tor/d'tors for them.
 /// 
-OStream getErrorOutputStream(const char *DebugType);
+OStream &getErrorOutputStream(const char *DebugType);
 
 #ifdef NDEBUG
-#define DOUT NullStream
+#define DOUT cnull
 #else
 #define DOUT getErrorOutputStream(DEBUG_TYPE)
 #endif
index 82ffeeb41bf8bd3f7ea5ddb7de749a926531d834..f141c92a9fe66cf1d39aafbce8593a72bdcdbc0b 100644 (file)
@@ -39,6 +39,11 @@ namespace llvm {
       return *this;
     }
 
+//     inline BaseStream &operator << (std::ios &(*Func)(std::ios&)) {
+//       if (Stream) *Stream << Func;
+//       return *this;
+//     }
+      
     template <typename Ty>
     BaseStream &operator << (const Ty &Thing) {
       if (Stream) *Stream << Thing;
@@ -51,6 +56,8 @@ namespace llvm {
       return *this;
     }
 
+    operator StreamTy* () { return Stream; }
+
     bool operator == (const StreamTy &S) { return &S == Stream; }
     bool operator != (const StreamTy &S) { return !(*this == S); }
     bool operator == (const BaseStream &S) { return S.Stream == Stream; }
@@ -61,7 +68,7 @@ namespace llvm {
   typedef BaseStream<std::istream> IStream;
   typedef BaseStream<std::stringstream> StringStream;
 
-  extern OStream NullStream;
+  extern OStream cnull;
   extern OStream cout;
   extern OStream cerr;
   extern IStream cin;
index 89e6efef37664228de13e6de0a68d51f471a2259..f6a83dfbdbf21d8ae6bbac8be5ba56762ebf7635 100644 (file)
@@ -98,6 +98,7 @@ public:
   
   /// Print feature string.
   void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   
   // Dump feature info.
   void dump() const;
index 79fe0dfedff77484407bd52f0905c420c8c5297d..6cb4e942df47aa2f442db81267fe61afa0461646 100644 (file)
@@ -141,10 +141,8 @@ protected:
   ///
   mutable std::vector<AbstractTypeUser *> AbstractTypeUsers;
 public:
-  void print(OStream &O) const {
-    if (O.stream()) print(*O.stream());
-  }
   void print(std::ostream &O) const;
+  void print(std::ostream *O) const { if (O) print(*O); }
 
   /// @brief Debugging support: print to stderr
   void dump() const;
index e8df7cd096e1814643eee168cac1b71be5c2a73a..262880a0e745647e7720ee3af07854bd7aa9a79f 100644 (file)
@@ -75,10 +75,8 @@ public:
 
   /// print - Implement operator<< on Value...
   ///
-  void print(OStream &O) const {
-    if (O.stream()) print(*O.stream());
-  }
   virtual void print(std::ostream &O) const = 0;
+  void print(std::ostream *O) const { if (O) print(*O); }
 
   /// All values are typed, get the type of this value.
   ///
index 6e8ca184b432a99a53a2562e4641a5a0f389bfd9..dcaeaf9d3388dbdd493af0a651fa5ce765fc29c6 100644 (file)
@@ -74,8 +74,8 @@ public:
     AU.setPreservesAll();
   }
 
-  void print(OStream &o, const Module *M) const {
-    if (o.stream()) print(*o.stream(), M);
+  void print(std::ostream *o, const Module *M) const {
+    if (o) print(*o, M);
   }
 
   virtual void print(std::ostream &o, const Module *M) const {
index a0aa955ebede538cdf65f8e6e532c72ff62ba045..3e3b1b938b0f30cb605d0fb8bde551a192903440 100644 (file)
@@ -31,13 +31,12 @@ Module *Trace::getModule() const {
 
 /// print - Write trace to output stream.
 ///
-void Trace::print(OStream &O) const {
+void Trace::print(std::ostream &O) const {
   Function *F = getFunction ();
   O << "; Trace from function " << F->getName() << ", blocks:\n";
   for (const_iterator i = begin(), e = end(); i != e; ++i) {
     O << "; ";
-    if (O.stream())
-      WriteAsOperand(*O.stream(), *i, true, getModule());
+    WriteAsOperand(O, *i, true, getModule());
     O << "\n";
   }
   O << "; Trace parent function: \n" << *F;
index c6bc22e796738afd199ed2c4654597f7c4e0610d..19a5919c4f92db46661f4e3b309f7075dedb32c7 100644 (file)
@@ -1297,4 +1297,6 @@ void llvm::WriteBytecodeToFile(const Module *M, OStream &Out,
 
   // make sure it hits disk now
   Out.stream()->flush();
+  void * p;
+  Out << std::hex << p << "\n";
 }
index 8f623962188291419a3c6212acfad37bff88a1d2..2500d58fdf0eb3b89897e69f1003d2995a093d87 100644 (file)
@@ -137,8 +137,8 @@ public:
   }
   
 #ifndef NDEBUG
-  void print(OStream &O) const {
-    if (O.stream()) print(*O.stream());
+  void print(std::ostream *O) const {
+    if (O) print(*O);
   }
   void print(std::ostream &O) const {
     O << ".debug_" << Tag;
@@ -245,8 +245,8 @@ public:
   void Emit(const Dwarf &DW) const; 
       
 #ifndef NDEBUG
-  void print(OStream &O) {
-    if (O.stream()) print(*O.stream());
+  void print(std::ostream *O) {
+    if (O) print(*O);
   }
   void print(std::ostream &O);
   void dump();
@@ -335,8 +335,8 @@ public:
   void Profile(FoldingSetNodeID &ID) ;
       
 #ifndef NDEBUG
-  void print(OStream &O, unsigned IncIndent = 0) {
-    if (O.stream()) print(*O.stream(), IncIndent);
+  void print(std::ostream *O, unsigned IncIndent = 0) {
+    if (O) print(*O, IncIndent);
   }
   void print(std::ostream &O, unsigned IncIndent = 0);
   void dump();
@@ -386,8 +386,8 @@ public:
   virtual void Profile(FoldingSetNodeID &ID) = 0;
       
 #ifndef NDEBUG
-  void print(OStream &O) {
-    if (O.stream()) print(*O.stream());
+  void print(std::ostream *O) {
+    if (O) print(*O);
   }
   virtual void print(std::ostream &O) = 0;
   void dump();
index 63a80fd16eaf2bd32f6a205585fb7606bf37535a..0ca16007b2d4b6e20eb188cb8c4d0710c8483272 100644 (file)
@@ -475,7 +475,7 @@ void LiveRange::dump() const {
   cerr << *this << "\n";
 }
 
-void LiveInterval::print(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
index 65da788961b79a7de3094c96f0bf079c072e1dfc..0b10a22fc445f8c3131248276458496ee12640d0 100644 (file)
@@ -473,7 +473,8 @@ private:
   
   /// print - Print ordering to specified output stream.
   ///
-  void print(OStream &O) const;
+  void print(std::ostream &O) const;
+  void print(std::ostream *O) const { if (O) print(*O); }
   
   void dump(const char *tag) const;
   
@@ -485,7 +486,8 @@ private:
 
   /// printNI - Print node info.
   ///
-  void printNI(OStream &O, NodeInfo *NI) const;
+  void printNI(std::ostream &O, NodeInfo *NI) const;
+  void printNI(std::ostream *O, NodeInfo *NI) const { if (O) printNI(O, NI); }
   
   /// printChanges - Hilight changes in order caused by scheduling.
   ///
@@ -636,7 +638,7 @@ void ScheduleDAGSimple::AddToGroup(NodeInfo *D, NodeInfo *U) {
 
 /// print - Print ordering to specified output stream.
 ///
-void ScheduleDAGSimple::print(OStream &O) const {
+void ScheduleDAGSimple::print(std::ostream &O) const {
 #ifndef NDEBUG
   O << "Ordering\n";
   for (unsigned i = 0, N = Ordering.size(); i < N; i++) {
@@ -710,16 +712,16 @@ static bool isFlagUser(SDNode *A) {
 
 /// printNI - Print node info.
 ///
-void ScheduleDAGSimple::printNI(OStream &O, NodeInfo *NI) const {
+void ScheduleDAGSimple::printNI(std::ostream &O, NodeInfo *NI) const {
 #ifndef NDEBUG
   SDNode *Node = NI->Node;
-  *(O.stream()) << " "
-                << std::hex << Node << std::dec
-                << ", Lat=" << NI->Latency
-                << ", Slot=" << NI->Slot
-                << ", ARITY=(" << Node->getNumOperands() << ","
-                << Node->getNumValues() << ")"
-                << " " << Node->getOperationName(&DAG);
+  O << " "
+    << std::hex << Node << std::dec
+    << ", Lat=" << NI->Latency
+    << ", Slot=" << NI->Slot
+    << ", ARITY=(" << Node->getNumOperands() << ","
+    << Node->getNumValues() << ")"
+    << " " << Node->getOperationName(&DAG);
   if (isFlagDefiner(Node)) O << "<#";
   if (isFlagUser(Node)) O << ">#";
 #endif
index 82c88edb7e2c400c3e817bcb70863b43865129ef..26b6eebf42952fe006cf587475d2f115bb922ce7 100644 (file)
@@ -113,11 +113,6 @@ void VirtRegMap::virtFolded(unsigned VirtReg, MachineInstr *OldMI,
 }
 
 void VirtRegMap::print(std::ostream &OS) const {
-  OStream LOS(OS);
-  print(LOS);
-}
-
-void VirtRegMap::print(OStream &OS) const {
   const MRegisterInfo* MRI = MF.getTarget().getRegisterInfo();
 
   OS << "********** REGISTER MAP **********\n";
@@ -136,8 +131,7 @@ void VirtRegMap::print(OStream &OS) const {
 }
 
 void VirtRegMap::dump() const {
-  OStream OS = DOUT;
-  print(OS);
+  print(DOUT);
 }
 
 
index 342d800242cac59025b98e24b683a2d2974cb576..84cf238035017286adb583a6bbbe48f296f95ef3 100644 (file)
@@ -145,10 +145,14 @@ namespace llvm {
     }
 
     void print(std::ostream &OS) const;
-    void print(OStream &OS) const;
+    void print(std::ostream *OS) const { if (OS) print(*OS); }
     void dump() const;
   };
 
+  inline std::ostream *operator<<(std::ostream *OS, const VirtRegMap &VRM) {
+    VRM.print(OS);
+    return OS;
+  }
   inline std::ostream &operator<<(std::ostream &OS, const VirtRegMap &VRM) {
     VRM.print(OS);
     return OS;
index 949e3d932a8878f653b782f36ed825faaee43af5..6e67ed8f6733c175442e4766921b100ef6fc9dd0 100644 (file)
@@ -68,9 +68,9 @@ bool llvm::isCurrentDebugType(const char *DebugType) {
 // places the std::c* I/O streams into one .cpp file and relieves the whole
 // program from having to have hundreds of static c'tor/d'tors for them.
 // 
-OStream llvm::getErrorOutputStream(const char *DebugType) {
+OStream &llvm::getErrorOutputStream(const char *DebugType) {
   if (DebugFlag && isCurrentDebugType(DebugType))
     return cerr;
   else
-    return NullStream;
+    return cnull;
 }
index 02aec1fff8a7bffe623ccfef9d74c006f1179805..3d20e9aea35ca845aca9d35dc44c1f07cb604a66 100644 (file)
@@ -16,7 +16,7 @@
 #include <iostream>
 using namespace llvm;
 
-OStream llvm::NullStream;
+OStream llvm::cnull;
 OStream llvm::cout(std::cout);
 OStream llvm::cerr(std::cerr);
 IStream llvm::cin(std::cin);
index 2adfb3ef3000a3f730ebb08b2de3204dbea80e05..f0ae3852d8a66d452ac701716683f5a76435c5a9 100644 (file)
@@ -96,7 +96,8 @@ bool LowerSwitch::runOnFunction(Function &F) {
 
 // operator<< - Used for debugging purposes.
 //
-OStream& operator<<(OStream &O, const std::vector<LowerSwitch::Case> &C) {
+std::ostream& operator<<(std::ostream &O,
+                         const std::vector<LowerSwitch::Case> &C) {
   O << "[";
 
   for (std::vector<LowerSwitch::Case>::const_iterator B = C.begin(),
@@ -107,6 +108,10 @@ OStream& operator<<(OStream &O, const std::vector<LowerSwitch::Case> &C) {
 
   return O << "]";
 }
+OStream& operator<<(OStream &O, const std::vector<LowerSwitch::Case> &C) {
+  if (O.stream()) *O.stream() << C;
+  return O;
+}
 
 // switchConvert - Convert the switch statement into a binary lookup of
 // the case values. The function recursively builds this tree.