diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/CodeGen/AsmPrinter.h | 5 | ||||
-rw-r--r-- | include/llvm/CodeGen/DwarfWriter.h | 3 | ||||
-rw-r--r-- | include/llvm/CodeGen/FileWriters.h | 5 | ||||
-rw-r--r-- | include/llvm/CodeGen/GCMetadataPrinter.h | 5 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineInstr.h | 10 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineOperand.h | 7 | ||||
-rw-r--r-- | include/llvm/Support/raw_ostream.h | 35 | ||||
-rw-r--r-- | include/llvm/Target/TargetMachine.h | 9 |
8 files changed, 67 insertions, 12 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 52921531f2..08c3197a76 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -34,6 +34,7 @@ namespace llvm { class Mangler; class TargetAsmInfo; class Type; + class raw_ostream; /// AsmPrinter - This class is intended to be used as a driving class for all /// asm writers. @@ -64,7 +65,7 @@ namespace llvm { public: /// Output stream on which we're printing assembly code. /// - std::ostream &O; + raw_ostream &O; /// Target machine description. /// @@ -96,7 +97,7 @@ namespace llvm { bool IsInTextSection; protected: - AsmPrinter(std::ostream &o, TargetMachine &TM, const TargetAsmInfo *T); + AsmPrinter(raw_ostream &o, TargetMachine &TM, const TargetAsmInfo *T); public: virtual ~AsmPrinter(); diff --git a/include/llvm/CodeGen/DwarfWriter.h b/include/llvm/CodeGen/DwarfWriter.h index a0cfec766a..981513baee 100644 --- a/include/llvm/CodeGen/DwarfWriter.h +++ b/include/llvm/CodeGen/DwarfWriter.h @@ -31,6 +31,7 @@ class MachineModuleInfo; class MachineFunction; class Module; class TargetAsmInfo; +class raw_ostream; //===----------------------------------------------------------------------===// // DwarfWriter - Emits Dwarf debug and exception handling directives. @@ -48,7 +49,7 @@ private: public: - DwarfWriter(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T); + DwarfWriter(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T); virtual ~DwarfWriter(); /// SetModuleInfo - Set machine module info when it's known that pass manager diff --git a/include/llvm/CodeGen/FileWriters.h b/include/llvm/CodeGen/FileWriters.h index ac66b9d0bf..cb7aea476b 100644 --- a/include/llvm/CodeGen/FileWriters.h +++ b/include/llvm/CodeGen/FileWriters.h @@ -21,10 +21,11 @@ namespace llvm { class PassManagerBase; class MachineCodeEmitter; class TargetMachine; + class raw_ostream; - MachineCodeEmitter *AddELFWriter(PassManagerBase &FPM, std::ostream &O, + MachineCodeEmitter *AddELFWriter(PassManagerBase &FPM, raw_ostream &O, TargetMachine &TM); - MachineCodeEmitter *AddMachOWriter(PassManagerBase &FPM, std::ostream &O, + MachineCodeEmitter *AddMachOWriter(PassManagerBase &FPM, raw_ostream &O, TargetMachine &TM); } // end llvm namespace diff --git a/include/llvm/CodeGen/GCMetadataPrinter.h b/include/llvm/CodeGen/GCMetadataPrinter.h index 1ab138adec..1c0665bbd9 100644 --- a/include/llvm/CodeGen/GCMetadataPrinter.h +++ b/include/llvm/CodeGen/GCMetadataPrinter.h @@ -29,6 +29,7 @@ namespace llvm { class GCMetadataPrinter; + class raw_ostream; /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the /// defaults from Registry. @@ -63,10 +64,10 @@ namespace llvm { iterator end() { return S->end(); } /// beginAssembly/finishAssembly - Emit module metadata as assembly code. - virtual void beginAssembly(std::ostream &OS, AsmPrinter &AP, + virtual void beginAssembly(raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI); - virtual void finishAssembly(std::ostream &OS, AsmPrinter &AP, + virtual void finishAssembly(raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI); virtual ~GCMetadataPrinter(); diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 471cebef63..c9506f198e 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -258,6 +258,11 @@ public: } void print(std::ostream &OS, const TargetMachine *TM = 0) const; void print(std::ostream *OS) const { if (OS) print(*OS); } + void print(raw_ostream *OS, const TargetMachine *TM) const { + if (OS) print(*OS, TM); + } + void print(raw_ostream &OS, const TargetMachine *TM = 0) const; + void print(raw_ostream *OS) const { if (OS) print(*OS); } void dump() const; //===--------------------------------------------------------------------===// @@ -316,6 +321,11 @@ inline std::ostream& operator<<(std::ostream &OS, const MachineInstr &MI) { return OS; } +inline raw_ostream& operator<<(raw_ostream &OS, const MachineInstr &MI) { + MI.print(OS); + return OS; +} + } // End llvm namespace #endif diff --git a/include/llvm/CodeGen/MachineOperand.h b/include/llvm/CodeGen/MachineOperand.h index 05984f601e..b4ba2f46fe 100644 --- a/include/llvm/CodeGen/MachineOperand.h +++ b/include/llvm/CodeGen/MachineOperand.h @@ -26,6 +26,7 @@ class GlobalValue; class MachineInstr; class TargetMachine; class MachineRegisterInfo; +class raw_ostream; /// MachineOperand class - Representation of each machine instruction operand. /// @@ -117,6 +118,7 @@ public: const MachineInstr *getParent() const { return ParentMI; } void print(std::ostream &os, const TargetMachine *TM = 0) const; + void print(raw_ostream &os, const TargetMachine *TM = 0) const; /// Accessors that tell you what kind of MachineOperand you're looking at. /// @@ -425,6 +427,11 @@ inline std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO) { return OS; } +inline raw_ostream &operator<<(raw_ostream &OS, const MachineOperand& MO) { + MO.print(OS, 0); + return OS; +} + } // End llvm namespace #endif diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index 1694520084..8019e44e35 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_RAW_OSTREAM_H #define LLVM_SUPPORT_RAW_OSTREAM_H +#include "llvm/ADT/StringExtras.h" #include <cassert> #include <cstring> #include <string> @@ -72,7 +73,11 @@ public: return write(Str, strlen(Str)); } - raw_ostream &operator<<(unsigned N) { + raw_ostream &operator<<(const std::string& Str) { + return write(Str.data(), Str.length()); + } + + raw_ostream &operator<<(uint64_t N) { // Zero is a special case. if (N == 0) return *this << '0'; @@ -88,6 +93,34 @@ public: return write(CurPtr, EndPtr-CurPtr); } + raw_ostream &operator<<(int64_t N) { + if (N < 0) { + if (OutBufCur >= OutBufEnd) + flush_impl(); + *OutBufCur++ = '-'; + + N = -N; + } + + return this->operator<<(static_cast<uint64_t>(N)); + } + + raw_ostream &operator<<(uint32_t N) { + return this->operator<<(static_cast<uint64_t>(N)); + } + + raw_ostream &operator<<(int32_t N) { + return this->operator<<(static_cast<int64_t>(N)); + } + + raw_ostream &operator<<(size_t N) { + return this->operator<<(static_cast<uint64_t>(N)); + } + + raw_ostream &operator<<(double N) { + return this->operator<<(ftostr(N)); + } + raw_ostream &write(const char *Ptr, unsigned Size) { if (OutBufCur+Size > OutBufEnd) diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index e86af9fd8d..93c46ae28e 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -35,6 +35,7 @@ class PassManager; class Pass; class TargetMachOWriterInfo; class TargetELFWriterInfo; +class raw_ostream; // Relocation model types. namespace Reloc { @@ -196,7 +197,7 @@ public: /// is not supported. /// virtual FileModel::Model addPassesToEmitFile(PassManagerBase &, - std::ostream &, + raw_ostream &, CodeGenFileType, bool /*Fast*/) { return FileModel::None; @@ -227,7 +228,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 &, std::ostream &, + virtual bool addPassesToEmitWholeFile(PassManager &, raw_ostream &, CodeGenFileType, bool /*Fast*/) { return true; } @@ -253,7 +254,7 @@ public: /// target-specific passes in standard locations. /// virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM, - std::ostream &Out, + raw_ostream &Out, CodeGenFileType FileType, bool Fast); @@ -309,7 +310,7 @@ public: /// the asmprinter, if asm emission is supported. If this is not supported, /// 'true' should be returned. virtual bool addAssemblyEmitter(PassManagerBase &, bool /*Fast*/, - std::ostream &) { + raw_ostream &) { return true; } |