diff --git a/include/llvm/ADT/BitSetVector.h b/include/llvm/ADT/BitSetVector.h index 5d1fc86c3ab..21d3cc9e7b0 100644 --- a/include/llvm/ADT/BitSetVector.h +++ b/include/llvm/ADT/BitSetVector.h @@ -27,7 +27,6 @@ #include "llvm/Support/Streams.h" #include -#include #include 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,23 +244,17 @@ public: }; -inline void BitSetVector::print(std::ostream& O) const +inline void BitSetVector::print(llvm_ostream& O) const { for (std::vector::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) { +inline std::ostream& operator<<(std::ostream& O, const BitSetVector& bset) { bset.print(O); return O; } -inline std::ostream& operator<< (std::ostream& O, const BitSetVector& bset) -{ - bset.print(O); - return O; -} - /// /// Optimized versions of fundamental comparison operations diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index 5fcda162703..cd6450fac82 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -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; diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 1f737da53c4..24effd8d49d 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -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 diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 939300f8aca..f29ed8345dc 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -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); + } }; diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h index fbf41de7cb6..008e30c93ef 100644 --- a/include/llvm/Analysis/FindUsedTypes.h +++ b/include/llvm/Analysis/FindUsedTypes.h @@ -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 diff --git a/include/llvm/Analysis/Interval.h b/include/llvm/Analysis/Interval.h index b9e1d31e3a3..bed815a6652 100644 --- a/include/llvm/Analysis/Interval.h +++ b/include/llvm/Analysis/Interval.h @@ -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 diff --git a/include/llvm/Analysis/IntervalPartition.h b/include/llvm/Analysis/IntervalPartition.h index 1cc903cae1d..bd998e81de2 100644 --- a/include/llvm/Analysis/IntervalPartition.h +++ b/include/llvm/Analysis/IntervalPartition.h @@ -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. diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 238a0f627d4..62f19e3c29e 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -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; diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 4eb0bb33b25..4aac284ee00 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -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); + } }; } diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index ba1b6d4fecb..c261dfc8e59 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -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; } diff --git a/include/llvm/Analysis/Trace.h b/include/llvm/Analysis/Trace.h index b26101d15ca..65aa593c8d2 100644 --- a/include/llvm/Analysis/Trace.h +++ b/include/llvm/Analysis/Trace.h @@ -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. diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h index 1751c21ce27..1d92066ce58 100644 --- a/include/llvm/Argument.h +++ b/include/llvm/Argument.h @@ -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: diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index f15d2b46a91..0ca8eae1a3e 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -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: diff --git a/include/llvm/CodeGen/LinkAllCodegenComponents.h b/include/llvm/CodeGen/LinkAllCodegenComponents.h index 5c39b505fec..1cf75bf01f6 100644 --- a/include/llvm/CodeGen/LinkAllCodegenComponents.h +++ b/include/llvm/CodeGen/LinkAllCodegenComponents.h @@ -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); diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index b22922c84c0..367cefeb36c 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -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; diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index 11f836b99ac..e0f60452e39 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -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 diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 896d9efe03e..1fd36ed55a7 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -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) diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h index bc701f6b86f..ffd0e556634 100644 --- a/include/llvm/CodeGen/MachineConstantPool.h +++ b/include/llvm/CodeGen/MachineConstantPool.h @@ -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. /// diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index f264c91c11d..c393b07aaf3 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -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 diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 77de83768e3..ad2ccdf8ca1 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -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; diff --git a/include/llvm/CodeGen/MachineJumpTableInfo.h b/include/llvm/CodeGen/MachineJumpTableInfo.h index 8064fa431c0..404ed15fd98 100644 --- a/include/llvm/CodeGen/MachineJumpTableInfo.h +++ b/include/llvm/CodeGen/MachineJumpTableInfo.h @@ -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. /// diff --git a/include/llvm/CodeGen/SchedGraphCommon.h b/include/llvm/CodeGen/SchedGraphCommon.h index 7da2f732bac..4fcd9acc0ea 100644 --- a/include/llvm/CodeGen/SchedGraphCommon.h +++ b/include/llvm/CodeGen/SchedGraphCommon.h @@ -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; diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h index 24fb99036ec..feb7edef0e5 100644 --- a/include/llvm/Constant.h +++ b/include/llvm/Constant.h @@ -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. diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 58184de3b18..7346c3b3e36 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -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 diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h index 0679e38bb3e..5e31c6bd196 100644 --- a/include/llvm/GlobalVariable.h +++ b/include/llvm/GlobalVariable.h @@ -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; } diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h index b9f707cf83c..98f254f5389 100644 --- a/include/llvm/InlineAsm.h +++ b/include/llvm/InlineAsm.h @@ -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 diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 4af83c7a567..ce759699024 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -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: diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 35b04b1017f..42214af1ac3 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -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 diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 15381ac978b..9663826ccf6 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -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 diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index 6866ffeb11a..f50e97959d7 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -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... /// diff --git a/include/llvm/Support/Debug.h b/include/llvm/Support/Debug.h index 09878b9d1e5..627d088eb05 100644 --- a/include/llvm/Support/Debug.h +++ b/include/llvm/Support/Debug.h @@ -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 diff --git a/include/llvm/Support/Streams.h b/include/llvm/Support/Streams.h index 82ffeeb41bf..f141c92a9fe 100644 --- a/include/llvm/Support/Streams.h +++ b/include/llvm/Support/Streams.h @@ -39,6 +39,11 @@ namespace llvm { return *this; } +// inline BaseStream &operator << (std::ios &(*Func)(std::ios&)) { +// if (Stream) *Stream << Func; +// return *this; +// } + template 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 IStream; typedef BaseStream StringStream; - extern OStream NullStream; + extern OStream cnull; extern OStream cout; extern OStream cerr; extern IStream cin; diff --git a/include/llvm/Target/SubtargetFeature.h b/include/llvm/Target/SubtargetFeature.h index 89e6efef376..f6a83dfbdbf 100644 --- a/include/llvm/Target/SubtargetFeature.h +++ b/include/llvm/Target/SubtargetFeature.h @@ -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; diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 79fe0dfedff..6cb4e942df4 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -141,10 +141,8 @@ protected: /// mutable std::vector 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; diff --git a/include/llvm/Value.h b/include/llvm/Value.h index e8df7cd096e..262880a0e74 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -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. /// diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 6e8ca184b43..dcaeaf9d338 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -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 { diff --git a/lib/Analysis/Trace.cpp b/lib/Analysis/Trace.cpp index a0aa955ebed..3e3b1b938b0 100644 --- a/lib/Analysis/Trace.cpp +++ b/lib/Analysis/Trace.cpp @@ -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; diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index c6bc22e7967..19a5919c4f9 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -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"; } diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index 8f623962188..2500d58fdf0 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -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(); diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index 63a80fd16ea..0ca16007b2d 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/lib/CodeGen/LiveInterval.cpp @@ -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 diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp index 65da788961b..0b10a22fc44 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp @@ -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 diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index 82c88edb7e2..26b6eebf429 100644 --- a/lib/CodeGen/VirtRegMap.cpp +++ b/lib/CodeGen/VirtRegMap.cpp @@ -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); } diff --git a/lib/CodeGen/VirtRegMap.h b/lib/CodeGen/VirtRegMap.h index 342d800242c..84cf2380350 100644 --- a/lib/CodeGen/VirtRegMap.h +++ b/lib/CodeGen/VirtRegMap.h @@ -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; diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index 949e3d932a8..6e67ed8f673 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -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; } diff --git a/lib/Support/Streams.cpp b/lib/Support/Streams.cpp index 02aec1fff8a..3d20e9aea35 100644 --- a/lib/Support/Streams.cpp +++ b/lib/Support/Streams.cpp @@ -16,7 +16,7 @@ #include using namespace llvm; -OStream llvm::NullStream; +OStream llvm::cnull; OStream llvm::cout(std::cout); OStream llvm::cerr(std::cerr); IStream llvm::cin(std::cin); diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index 2adfb3ef300..f0ae3852d8a 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -96,7 +96,8 @@ bool LowerSwitch::runOnFunction(Function &F) { // operator<< - Used for debugging purposes. // -OStream& operator<<(OStream &O, const std::vector &C) { +std::ostream& operator<<(std::ostream &O, + const std::vector &C) { O << "["; for (std::vector::const_iterator B = C.begin(), @@ -107,6 +108,10 @@ OStream& operator<<(OStream &O, const std::vector &C) { return O << "]"; } +OStream& operator<<(OStream &O, const std::vector &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.