diff options
36 files changed, 269 insertions, 250 deletions
diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp index f4c5c3d698..09f2203c68 100644 --- a/examples/Fibonacci/fibonacci.cpp +++ b/examples/Fibonacci/fibonacci.cpp @@ -32,7 +32,7 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" -#include <iostream> +#include "llvm/Support/raw_ostream.h" using namespace llvm; static Function *CreateFibFunction(Module *M) { @@ -100,15 +100,15 @@ int main(int argc, char **argv) { ExistingModuleProvider *MP = new ExistingModuleProvider(M); ExecutionEngine *EE = ExecutionEngine::create(MP, false); - std::cerr << "verifying... "; + errs() << "verifying... "; if (verifyModule(*M)) { - std::cerr << argv[0] << ": Error constructing function!\n"; + errs() << argv[0] << ": Error constructing function!\n"; return 1; } - std::cerr << "OK\n"; - std::cerr << "We just constructed this LLVM module:\n\n---------\n" << *M; - std::cerr << "---------\nstarting fibonacci(" << n << ") with JIT...\n"; + errs() << "OK\n"; + errs() << "We just constructed this LLVM module:\n\n---------\n" << *M; + errs() << "---------\nstarting fibonacci(" << n << ") with JIT...\n"; // Call the Fibonacci function with argument n: std::vector<GenericValue> Args(1); @@ -116,6 +116,6 @@ int main(int argc, char **argv) { GenericValue GV = EE->runFunction(FibF, Args); // import result of execution - std::cout << "Result: " << GV.IntVal << "\n"; + outs() << "Result: " << GV.IntVal << "\n"; return 0; } diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp index d50000579e..0482df6248 100644 --- a/examples/HowToUseJIT/HowToUseJIT.cpp +++ b/examples/HowToUseJIT/HowToUseJIT.cpp @@ -42,7 +42,7 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" -#include <iostream> +#include "llvm/Support/raw_ostream.h" using namespace llvm; int main() { @@ -99,14 +99,15 @@ int main() { ExistingModuleProvider* MP = new ExistingModuleProvider(M); ExecutionEngine* EE = ExecutionEngine::create(MP, false); - std::cout << "We just constructed this LLVM module:\n\n" << *M; - std::cout << "\n\nRunning foo: " << std::flush; + outs() << "We just constructed this LLVM module:\n\n" << *M; + outs() << "\n\nRunning foo: "; + outs().flush(); // Call the `foo' function with no arguments: std::vector<GenericValue> noargs; GenericValue gv = EE->runFunction(FooF, noargs); // Import result of execution: - std::cout << "Result: " << gv.IntVal << "\n"; + outs() << "Result: " << gv.IntVal << "\n"; return 0; } diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 25505c836e..6baf12383b 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -19,13 +19,13 @@ #include "llvm/Support/MathExtras.h" #include <cassert> #include <cstring> -#include <iosfwd> #include <string> namespace llvm { class Serializer; class Deserializer; class FoldingSetNodeID; + class raw_ostream; template<typename T> class SmallVectorImpl; @@ -1115,8 +1115,7 @@ public: /// @} /// @name Conversion Functions /// @{ - - void print(std::ostream &OS, bool isSigned) const; + void print(raw_ostream &OS, bool isSigned) const; /// toString - Converts an APInt to a string and append it to Str. Str is /// commonly a SmallString. @@ -1385,7 +1384,7 @@ inline bool operator!=(uint64_t V1, const APInt& V2) { return V2 != V1; } -inline std::ostream &operator<<(std::ostream &OS, const APInt &I) { +inline raw_ostream &operator<<(raw_ostream &OS, const APInt &I) { I.print(OS, true); return OS; } diff --git a/include/llvm/ADT/APSInt.h b/include/llvm/ADT/APSInt.h index 00bece62ad..f16f49dc79 100644 --- a/include/llvm/ADT/APSInt.h +++ b/include/llvm/ADT/APSInt.h @@ -239,7 +239,7 @@ public: void Profile(FoldingSetNodeID& ID) const; }; -inline std::ostream &operator<<(std::ostream &OS, const APSInt &I) { +inline raw_ostream &operator<<(raw_ostream &OS, const APSInt &I) { I.print(OS, I.isSigned()); return OS; } diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h index 650bee3d10..c69caab831 100644 --- a/include/llvm/Argument.h +++ b/include/llvm/Argument.h @@ -65,11 +65,6 @@ public: /// removeAttr - Remove a ParamAttr from an argument void removeAttr(ParameterAttributes); - 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/Assembly/AsmAnnotationWriter.h b/include/llvm/Assembly/AsmAnnotationWriter.h index 62926bb007..b254940722 100644 --- a/include/llvm/Assembly/AsmAnnotationWriter.h +++ b/include/llvm/Assembly/AsmAnnotationWriter.h @@ -17,13 +17,12 @@ #ifndef LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H #define LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H -#include <iosfwd> - namespace llvm { class Function; class BasicBlock; class Instruction; +class raw_ostream; struct AssemblyAnnotationWriter { @@ -31,21 +30,21 @@ struct AssemblyAnnotationWriter { // emitFunctionAnnot - This may be implemented to emit a string right before // the start of a function. - virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) {} + virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {} // emitBasicBlockStartAnnot - This may be implemented to emit a string right // after the basic block label, but before the first instruction in the block. - virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, std::ostream &OS){ + virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, raw_ostream &OS){ } // emitBasicBlockEndAnnot - This may be implemented to emit a string right // after the basic block. - virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, std::ostream &OS){ + virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS){ } // emitInstructionAnnot - This may be implemented to emit a string right // before an instruction is emitted. - virtual void emitInstructionAnnot(const Instruction *I, std::ostream &OS) {} + virtual void emitInstructionAnnot(const Instruction *I, raw_ostream &OS) {} }; } // End llvm namespace diff --git a/include/llvm/Assembly/Writer.h b/include/llvm/Assembly/Writer.h index b4765df7a5..c9f8edb352 100644 --- a/include/llvm/Assembly/Writer.h +++ b/include/llvm/Assembly/Writer.h @@ -24,12 +24,14 @@ namespace llvm { class Type; class Module; class Value; +class raw_ostream; // WriteTypeSymbolic - This attempts to write the specified type as a symbolic // type, iff there is an entry in the Module's symbol table for the specified // type or one of its component types. This is slower than a simple x << Type; // void WriteTypeSymbolic(std::ostream &, const Type *, const Module *M); +void WriteTypeSymbolic(raw_ostream &, const Type *, const Module *M); // WriteAsOperand - Write the name of the specified value out to the specified // ostream. This can be useful when you just want to print int %reg126, not the @@ -39,6 +41,8 @@ void WriteTypeSymbolic(std::ostream &, const Type *, const Module *M); // void WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true, const Module *Context = 0); +void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy = true, + const Module *Context = 0); } // End llvm namespace diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 6614a93883..fd729acd28 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -157,10 +157,6 @@ public: const InstListType &getInstList() const { return InstList; } 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: static inline bool classof(const BasicBlock *) { return true; } static inline bool classof(const Value *V) { diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h index ba491ce255..b6bf566f3f 100644 --- a/include/llvm/CodeGen/MachineConstantPool.h +++ b/include/llvm/CodeGen/MachineConstantPool.h @@ -29,6 +29,7 @@ class TargetData; class TargetMachine; class Type; class MachineConstantPool; +class raw_ostream; /// Abstract base class for all machine specific constantpool value subclasses. /// @@ -50,8 +51,9 @@ public: /// print - Implement operator<<... /// - virtual void print(std::ostream &O) const = 0; + void print(std::ostream &O) const; void print(std::ostream *O) const { if (O) print(*O); } + virtual void print(raw_ostream &O) const = 0; }; inline std::ostream &operator<<(std::ostream &OS, @@ -59,6 +61,13 @@ inline std::ostream &operator<<(std::ostream &OS, V.print(OS); return OS; } + +inline raw_ostream &operator<<(raw_ostream &OS, + const MachineConstantPoolValue &V) { + V.print(OS); + return OS; +} + /// This class is a data container for one entry in a MachineConstantPool. /// It contains a pointer to the value and an offset from the start of diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 9796e066dd..6c1565916e 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1260,6 +1260,7 @@ public: /// std::string getOperationName(const SelectionDAG *G = 0) const; static const char* getIndexedModeName(ISD::MemIndexedMode AM); + void print(raw_ostream &OS, const SelectionDAG *G = 0) const; void dump() const; void dump(const SelectionDAG *G) const; diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h index faaced8041..12e1dd2db9 100644 --- a/include/llvm/Constant.h +++ b/include/llvm/Constant.h @@ -58,9 +58,6 @@ public: /// getNullValue. 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. bool canTrap() const; diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 04e0535ace..f302ff570f 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -301,10 +301,6 @@ public: size_t arg_size() const; bool arg_empty() const; - 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 /// say 'call F->viewCFG()' and a ghostview window should pop up from the /// program, displaying the CFG of the current function with the code for each diff --git a/include/llvm/GlobalAlias.h b/include/llvm/GlobalAlias.h index 124cf94fa9..4dfc9c4d5e 100644 --- a/include/llvm/GlobalAlias.h +++ b/include/llvm/GlobalAlias.h @@ -62,9 +62,6 @@ public: /// void eraseFromParent(); - virtual void print(std::ostream &OS) const; - void print(std::ostream *OS) const { if (OS) print(*OS); } - /// set/getAliasee - These methods retrive and set alias target. void setAliasee(Constant* GV); const Constant* getAliasee() const { diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h index b6910d54c9..aae17e409d 100644 --- a/include/llvm/GlobalVariable.h +++ b/include/llvm/GlobalVariable.h @@ -133,9 +133,6 @@ public: /// replace constant initializers. 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; } static inline bool classof(const Value *V) { diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h index bb046c2a3c..325b777dd4 100644 --- a/include/llvm/InlineAsm.h +++ b/include/llvm/InlineAsm.h @@ -21,7 +21,6 @@ namespace llvm { -struct AssemblyAnnotationWriter; class PointerType; class FunctionType; class Module; @@ -58,10 +57,6 @@ public: const std::string &getAsmString() const { return AsmString; } 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 /// the specified constraint string is legal for the type. This returns true /// if legal, false if not. diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index ac33a68bbf..cec9144e35 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -20,8 +20,6 @@ namespace llvm { -struct AssemblyAnnotationWriter; - template<typename ValueSubClass, typename ItemParentClass> class SymbolTableListTraits; @@ -180,10 +178,6 @@ 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: static inline bool classof(const Instruction *) { return true; } static inline bool classof(const Value *V) { diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 56207a0af2..de12157875 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -350,15 +350,11 @@ public: /// @name Utility functions for printing and dumping Module objects /// @{ public: - /// Print the module to an output stream - 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(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const; 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). + + /// Dump the module to stderr (for debugging). void dump() const; /// This function causes all the subinstructions to "let go" of all references /// that they are maintaining. This allows one to 'delete' a whole class at @@ -385,9 +381,14 @@ public: /// An iostream inserter for modules. inline std::ostream &operator<<(std::ostream &O, const Module &M) { - M.print(O); + M.print(O, 0); + return O; +} +inline raw_ostream &operator<<(raw_ostream &O, const Module &M) { + M.print(O, 0); return O; } + inline ValueSymbolTable * ilist_traits<Function>::getSymTab(Module *M) { diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index 2e477cf899..1a8907666f 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -32,8 +32,6 @@ #include "llvm/ADT/APInt.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/Streams.h" -#include <iosfwd> namespace llvm { @@ -180,15 +178,14 @@ class ConstantRange { /// print - Print out the bounds to a stream... /// - void print(std::ostream &OS) const; - void print(std::ostream *OS) const { if (OS) print(*OS); } + void print(raw_ostream &OS) const; /// dump - Allow printing from a debugger easily... /// void dump() const; }; -inline std::ostream &operator<<(std::ostream &OS, const ConstantRange &CR) { +inline raw_ostream &operator<<(raw_ostream &OS, const ConstantRange &CR) { CR.print(OS); return OS; } diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index e78cfe8641..9fb5f6cb38 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -96,7 +96,7 @@ public: raw_ostream &operator<<(long N); raw_ostream &operator<<(unsigned long long N); raw_ostream &operator<<(long long N); - + raw_ostream &operator<<(const void *P); raw_ostream &operator<<(unsigned int N) { return this->operator<<(static_cast<unsigned long>(N)); } @@ -201,7 +201,8 @@ class raw_os_ostream : public raw_ostream { std::ostream &OS; public: raw_os_ostream(std::ostream &O) : OS(O) {} - + ~raw_os_ostream(); + /// flush_impl - The is the piece of the class that is implemented by /// subclasses. This outputs the currently buffered data and resets the /// buffer to empty. diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 5bcb654a4a..ec970565dc 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -14,7 +14,6 @@ #include "llvm/AbstractTypeUser.h" #include "llvm/Support/Casting.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/Streams.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator.h" #include <string> @@ -26,6 +25,7 @@ class DerivedType; class PointerType; class IntegerType; class TypeMapBase; +class raw_ostream; /// This file contains the declaration of the Type class. For more "Type" type /// stuff, look in DerivedTypes.h. @@ -156,6 +156,7 @@ protected: PATypeHandle *ContainedTys; public: + void print(raw_ostream &O) const; void print(std::ostream &O) const; void print(std::ostream *O) const { if (O) print(*O); } @@ -450,6 +451,7 @@ template <> inline bool isa_impl<PointerType, Type>(const Type &Ty) { } std::ostream &operator<<(std::ostream &OS, const Type &T); +raw_ostream &operator<<(raw_ostream &OS, const Type &T); } // End llvm namespace diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 82e1502e58..ceb1ad246d 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -35,6 +35,8 @@ class ValueSymbolTable; class TypeSymbolTable; template<typename ValueTy> class StringMapEntry; typedef StringMapEntry<Value*> ValueName; +class raw_ostream; +class AssemblyAnnotationWriter; //===----------------------------------------------------------------------===// // Value Class @@ -76,10 +78,10 @@ public: // virtual void dump() const; - /// print - Implement operator<< on Value... + /// print - Implement operator<< on Value. /// - virtual void print(std::ostream &O) const = 0; - void print(std::ostream *O) const { if (O) print(*O); } + void print(std::ostream &O, AssemblyAnnotationWriter *AAW = 0) const; + void print(raw_ostream &O, AssemblyAnnotationWriter *AAW = 0) const; /// All values are typed, get the type of this value. /// @@ -237,7 +239,11 @@ inline std::ostream &operator<<(std::ostream &OS, const Value &V) { V.print(OS); return OS; } - +inline raw_ostream &operator<<(raw_ostream &OS, const Value &V) { + V.print(OS); + return OS; +} + void Use::init(Value *V, User *) { Val = V; if (V) V->addUse(*this); diff --git a/lib/Analysis/LoopVR.cpp b/lib/Analysis/LoopVR.cpp index eb7524a9c2..7f5de259ca 100644 --- a/lib/Analysis/LoopVR.cpp +++ b/lib/Analysis/LoopVR.cpp @@ -6,6 +6,10 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// FIXME: What does this do? +// +//===----------------------------------------------------------------------===// #define DEBUG_TYPE "loopvr" #include "llvm/Analysis/LoopVR.h" @@ -15,13 +19,11 @@ #include "llvm/Assembly/Writer.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/Streams.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; char LoopVR::ID = 0; -namespace { static RegisterPass<LoopVR> X("loopvr", "Loop Value Ranges", true, true); -} /// getRange - determine the range for a particular SCEV within a given Loop ConstantRange LoopVR::getRange(SCEVHandle S, Loop *L, ScalarEvolution &SE) { @@ -220,11 +222,10 @@ ConstantRange LoopVR::getRange(SCEVHandle S, SCEVHandle T, ScalarEvolution &SE){ bool LoopVR::runOnFunction(Function &F) { Map.clear(); return false; } void LoopVR::print(std::ostream &os, const Module *) const { + raw_os_ostream OS(os); for (std::map<Value *, ConstantRange *>::const_iterator I = Map.begin(), E = Map.end(); I != E; ++I) { - os << *I->first << ": "; - I->second->print(os); - os << "\n"; + OS << *I->first << ": " << *I->second << '\n'; } } diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index b243297253..bc5d59e8be 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -28,6 +28,7 @@ #include "llvm/Instructions.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/GraphWriter.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Config/config.h" #include <fstream> @@ -525,6 +526,10 @@ unsigned MachineConstantPool::getConstantPoolIndex(MachineConstantPoolValue *V, return Constants.size()-1; } +void MachineConstantPoolValue::print(std::ostream &o) const { + raw_os_ostream OS(o); + print(OS); +} void MachineConstantPool::print(std::ostream &OS) const { for (unsigned i = 0, e = Constants.size(); i != e; ++i) { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 9275a21f9f..fa73e73de0 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -24,12 +24,13 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" -#include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" @@ -4980,169 +4981,166 @@ std::string ISD::ArgFlagsTy::getArgFlagsString() { void SDNode::dump() const { dump(0); } void SDNode::dump(const SelectionDAG *G) const { - cerr << (void*)this << ": "; + print(errs(), G); +} + +void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const { + OS << (void*)this << ": "; for (unsigned i = 0, e = getNumValues(); i != e; ++i) { - if (i) cerr << ","; + if (i) OS << ","; if (getValueType(i) == MVT::Other) - cerr << "ch"; + OS << "ch"; else - cerr << getValueType(i).getMVTString(); + OS << getValueType(i).getMVTString(); } - cerr << " = " << getOperationName(G); + OS << " = " << getOperationName(G); - cerr << " "; + OS << " "; for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { - if (i) cerr << ", "; - cerr << (void*)getOperand(i).Val; + if (i) OS << ", "; + OS << (void*)getOperand(i).Val; if (unsigned RN = getOperand(i).ResNo) - cerr << ":" << RN; + OS << ":" << RN; } if (!isTargetOpcode() && getOpcode() == ISD::VECTOR_SHUFFLE) { SDNode *Mask = getOperand(2).Val; - cerr << "<"; + OS << "<"; for (unsigned i = 0, e = Mask->getNumOperands(); i != e; ++i) { - if (i) cerr << ","; + if (i) OS << ","; if (Mask->getOperand(i).getOpcode() == ISD::UNDEF) - cerr << "u"; + OS << "u"; else - cerr << cast<ConstantSDNode>(Mask->getOperand(i))->getValue(); + OS << cast<ConstantSDNode>(Mask->getOperand(i))->getValue(); } - cerr << ">"; + OS << ">"; } if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(this)) { - cerr << '<' << CSDN->getAPIntValue() << '>'; + OS << '<' << CSDN->getAPIntValue() << '>'; } else if (const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(this)) { if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle) - cerr << '<' << CSDN->getValueAPF().convertToFloat() << '>'; + OS << '<' << CSDN->getValueAPF().convertToFloat() << '>'; else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble) - cerr << '<' << CSDN->getValueAP |