diff options
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/CodeGen/AsmPrinter.h | 6 | ||||
-rw-r--r-- | include/llvm/Support/FormattedStream.h | 34 | ||||
-rw-r--r-- | include/llvm/Target/TargetMachine.h | 11 |
3 files changed, 40 insertions, 11 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index d7a0225..1a43f5e 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -40,7 +40,7 @@ namespace llvm { class Section; class TargetAsmInfo; class Type; - class raw_ostream; + class formatted_raw_ostream; /// AsmPrinter - This class is intended to be used as a driving class for all /// asm writers. @@ -69,7 +69,7 @@ namespace llvm { public: /// Output stream on which we're printing assembly code. /// - raw_ostream &O; + formatted_raw_ostream &O; /// Target machine description. /// @@ -118,7 +118,7 @@ namespace llvm { mutable DebugLocTuple PrevDLT; protected: - explicit AsmPrinter(raw_ostream &o, TargetMachine &TM, + explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM, const TargetAsmInfo *T, bool V); public: diff --git a/include/llvm/Support/FormattedStream.h b/include/llvm/Support/FormattedStream.h index 2cead0a..1c213ab 100644 --- a/include/llvm/Support/FormattedStream.h +++ b/include/llvm/Support/FormattedStream.h @@ -23,10 +23,23 @@ namespace llvm /// asm-specific constructs. /// class formatted_raw_ostream : public raw_ostream { + public: + /// DELETE_STREAM - Tell the destructor to delete the held stream. + /// + const static bool DELETE_STREAM = true; + /// PRESERVE_STREAM - Tell the destructor to not delete the held + /// stream. + /// + const static bool PRESERVE_STREAM = false; + private: /// TheStream - The real stream we output to. /// raw_ostream &TheStream; + /// DeleteStream - Do we need to delete TheStream in the + /// destructor? + /// + bool DeleteStream; /// Column - The current output column of the stream. The column /// scheme is zero-based. @@ -61,8 +74,13 @@ namespace llvm /// stream will use stdout instead. /// \param Binary - The file should be opened in binary mode on /// platforms that support this distinction. - formatted_raw_ostream(raw_ostream &Stream) - : raw_ostream(), TheStream(Stream), Column(0) {} + formatted_raw_ostream(raw_ostream &Stream, bool Delete = false) + : raw_ostream(), TheStream(Stream), DeleteStream(Delete), Column(0) {} + + ~formatted_raw_ostream() { + if (DeleteStream) + delete &TheStream; + } /// PadToColumn - Align the output to some column number. /// @@ -72,6 +90,16 @@ namespace llvm /// void PadToColumn(unsigned NewCol, unsigned MinPad = 0); }; -} + +/// fouts() - This returns a reference to a formatted_raw_ostream for +/// standard output. Use it like: fouts() << "foo" << "bar"; +formatted_raw_ostream &fouts(); + +/// ferrs() - This returns a reference to a formatted_raw_ostream for +/// standard error. Use it like: ferrs() << "foo" << "bar"; +formatted_raw_ostream &ferrs(); + +} // end llvm namespace + #endif diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 21e778d..ce293d5 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -37,7 +37,7 @@ class PassManager; class Pass; class TargetMachOWriterInfo; class TargetELFWriterInfo; -class raw_ostream; +class formatted_raw_ostream; // Relocation model types. namespace Reloc { @@ -232,7 +232,7 @@ public: /// is not supported. /// virtual FileModel::Model addPassesToEmitFile(PassManagerBase &, - raw_ostream &, + formatted_raw_ostream &, CodeGenFileType, CodeGenOpt::Level) { return FileModel::None; @@ -296,7 +296,7 @@ public: /// require having the entire module at once. This is not recommended, do not /// use this. virtual bool WantsWholeFile() const { return false; } - virtual bool addPassesToEmitWholeFile(PassManager &, raw_ostream &, + virtual bool addPassesToEmitWholeFile(PassManager &, formatted_raw_ostream &, CodeGenFileType, CodeGenOpt::Level) { return true; @@ -329,7 +329,7 @@ public: /// target-specific passes in standard locations. /// virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM, - raw_ostream &Out, + formatted_raw_ostream &Out, CodeGenFileType FileType, CodeGenOpt::Level); @@ -413,7 +413,8 @@ public: /// the asmprinter, if asm emission is supported. If this is not supported, /// 'true' should be returned. virtual bool addAssemblyEmitter(PassManagerBase &, CodeGenOpt::Level, - bool /* VerboseAsmDefault */, raw_ostream &) { + bool /* VerboseAsmDefault */, + formatted_raw_ostream &) { return true; } |