diff options
Diffstat (limited to 'lib')
55 files changed, 353 insertions, 150 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 2eccc36ccf..bf57a653ad 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -21,7 +21,7 @@ #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/Support/Mangler.h" -#include "llvm/Support/MathExtras.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Streams.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" @@ -31,11 +31,12 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringExtras.h" #include <cerrno> using namespace llvm; char AsmPrinter::ID = 0; -AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm, +AsmPrinter::AsmPrinter(raw_ostream &o, TargetMachine &tm, const TargetAsmInfo *T) : MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o), TM(tm), TAI(T), TRI(tm.getRegisterInfo()), @@ -268,8 +269,9 @@ void AsmPrinter::EmitConstantPool(unsigned Alignment, const char *Section, EmitAlignment(Alignment); for (unsigned i = 0, e = CP.size(); i != e; ++i) { O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' - << CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << ' '; - WriteTypeSymbolic(O, CP[i].first.getType(), 0); + << CP[i].second << ":\t\t\t\t\t"; + // O << TAI->getCommentString() << ' ' << + // WriteTypeSymbolic(O, CP[i].first.getType(), 0); O << '\n'; if (CP[i].first.isMachineConstantPoolEntry()) EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal); @@ -495,7 +497,7 @@ void AsmPrinter::PrintULEB128(unsigned Value) const { unsigned Byte = Value & 0x7f; Value >>= 7; if (Value) Byte |= 0x80; - O << "0x" << std::hex << Byte << std::dec; + O << "0x" << utohexstr(Byte); if (Value) O << ", "; } while (Value); } @@ -511,7 +513,7 @@ void AsmPrinter::PrintSLEB128(int Value) const { Value >>= 7; IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0; if (IsMore) Byte |= 0x80; - O << "0x" << std::hex << Byte << std::dec; + O << "0x" << utohexstr(Byte); if (IsMore) O << ", "; } while (IsMore); } @@ -523,7 +525,7 @@ void AsmPrinter::PrintSLEB128(int Value) const { /// PrintHex - Print a value as a hexidecimal value. /// void AsmPrinter::PrintHex(int Value) const { - O << "0x" << std::hex << Value << std::dec; + O << "0x" << utohexstr(static_cast<unsigned>(Value)); } /// EOL - Print a newline character to asm stream. If a comment is present @@ -622,7 +624,7 @@ static inline char toOctal(int X) { /// printStringChar - Print a char, escaped if necessary. /// -static void printStringChar(std::ostream &O, unsigned char C) { +static void printStringChar(raw_ostream &O, char C) { if (C == '"') { O << "\\\""; } else if (C == '\\') { @@ -706,7 +708,7 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV, unsigned FillValue = TAI->getTextAlignFillValue(); UseFillExpr &= IsInTextSection && FillValue; - if (UseFillExpr) O << ",0x" << std::hex << FillValue << std::dec; + if (UseFillExpr) O << ",0x" << utohexstr(FillValue); O << '\n'; } @@ -855,7 +857,7 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) { /// printAsCString - Print the specified array as a C compatible string, only if /// the predicate isString is true. /// -static void printAsCString(std::ostream &O, const ConstantArray *CVA, +static void printAsCString(raw_ostream &O, const ConstantArray *CVA, unsigned LastElt) { assert(CVA->isString() && "Array is not string compatible!"); diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 5d6acc30ba..99e94e2ac0 100644 --- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Mangler.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetRegisterInfo.h" @@ -820,7 +821,7 @@ protected: // /// O - Stream to .s file. /// - std::ostream &O; + raw_ostream &O; /// Asm - Target of Dwarf emission. /// @@ -856,7 +857,7 @@ protected: const char * const Flavor; unsigned SetCounter; - Dwarf(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T, + Dwarf(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T, const char *flavor) : O(OS) , Asm(A) @@ -2673,7 +2674,7 @@ public: //===--------------------------------------------------------------------===// // Main entry points. // - DwarfDebug(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T) + DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T) : Dwarf(OS, A, T, "dbg") , CompileUnits() , AbbreviationsSet(InitAbbreviationsSetSize) @@ -3479,7 +3480,7 @@ public: //===--------------------------------------------------------------------===// // Main entry points. // - DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T) + DwarfException(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T) : Dwarf(OS, A, T, "eh") , shouldEmitTable(false) , shouldEmitMoves(false) @@ -3879,7 +3880,7 @@ void DIE::dump() { /// DwarfWriter Implementation /// -DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A, +DwarfWriter::DwarfWriter(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T) { DE = new DwarfException(OS, A, T); DD = new DwarfDebug(OS, A, T); diff --git a/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp index 761e910cb2..16abca22e1 100644 --- a/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp @@ -15,6 +15,7 @@ #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/GCMetadataPrinter.h" #include "llvm/Module.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" @@ -25,10 +26,10 @@ namespace { class VISIBILITY_HIDDEN OcamlGCMetadataPrinter : public GCMetadataPrinter { public: - void beginAssembly(std::ostream &OS, AsmPrinter &AP, + void beginAssembly(raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI); - void finishAssembly(std::ostream &OS, AsmPrinter &AP, + void finishAssembly(raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI); }; @@ -39,7 +40,7 @@ Y("ocaml", "ocaml 3.10-compatible collector"); void llvm::linkOcamlGCPrinter() { } -static void EmitCamlGlobal(const Module &M, std::ostream &OS, AsmPrinter &AP, +static void EmitCamlGlobal(const Module &M, raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI, const char *Id) { const std::string &MId = M.getModuleIdentifier(); @@ -59,7 +60,7 @@ static void EmitCamlGlobal(const Module &M, std::ostream &OS, AsmPrinter &AP, OS << Mangled << ":\n"; } -void OcamlGCMetadataPrinter::beginAssembly(std::ostream &OS, AsmPrinter &AP, +void OcamlGCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI) { AP.SwitchToTextSection(TAI.getTextSection()); EmitCamlGlobal(getModule(), OS, AP, TAI, "code_begin"); @@ -84,7 +85,7 @@ void OcamlGCMetadataPrinter::beginAssembly(std::ostream &OS, AsmPrinter &AP, /// (FrameSize and LiveOffsets would overflow). FrameTablePrinter will abort if /// either condition is detected in a function which uses the GC. /// -void OcamlGCMetadataPrinter::finishAssembly(std::ostream &OS, AsmPrinter &AP, +void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI) { const char *AddressDirective; int AddressAlignLog; diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index 27f23f45cc..6f29112caf 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -44,6 +44,7 @@ #include "llvm/Support/Mangler.h" #include "llvm/Support/OutputBuffer.h" #include "llvm/Support/Streams.h" +#include "llvm/Support/raw_ostream.h" #include <list> using namespace llvm; @@ -51,7 +52,7 @@ char ELFWriter::ID = 0; /// AddELFWriter - Concrete function to add the ELF writer to the function pass /// manager. MachineCodeEmitter *llvm::AddELFWriter(PassManagerBase &PM, - std::ostream &O, + raw_ostream &O, TargetMachine &TM) { ELFWriter *EW = new ELFWriter(O, TM); PM.add(EW); @@ -193,7 +194,7 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &F) { // ELFWriter Implementation //===----------------------------------------------------------------------===// -ELFWriter::ELFWriter(std::ostream &o, TargetMachine &tm) +ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm) : MachineFunctionPass((intptr_t)&ID), O(o), TM(tm) { e_flags = 0; // e_flags defaults to 0, no flags. @@ -536,7 +537,7 @@ void ELFWriter::OutputSectionsAndSectionTable() { if (S.Align) for (size_t NewFileOff = (FileOff+S.Align-1) & ~(S.Align-1); FileOff != NewFileOff; ++FileOff) - O.put((char)0xAB); + O << (char)0xAB; O.write((char*)&S.SectionData[0], S.SectionData.size()); FileOff += S.SectionData.size(); @@ -557,7 +558,7 @@ void ELFWriter::OutputSectionsAndSectionTable() { // Align output for the section table. for (size_t NewFileOff = (FileOff+TableAlign-1) & ~(TableAlign-1); FileOff != NewFileOff; ++FileOff) - O.put((char)0xAB); + O << (char)0xAB; // Emit the section table itself. O.write((char*)&Table[0], Table.size()); diff --git a/lib/CodeGen/ELFWriter.h b/lib/CodeGen/ELFWriter.h index be3b39b476..31aa05a9c4 100644 --- a/lib/CodeGen/ELFWriter.h +++ b/lib/CodeGen/ELFWriter.h @@ -23,6 +23,7 @@ namespace llvm { class Mangler; class MachineCodeEmitter; class ELFCodeEmitter; + class raw_ostream; /// ELFWriter - This class implements the common target-independent code for /// writing ELF files. Targets should derive a class from this to @@ -37,7 +38,7 @@ namespace llvm { return *(MachineCodeEmitter*)MCE; } - ELFWriter(std::ostream &O, TargetMachine &TM); + ELFWriter(raw_ostream &O, TargetMachine &TM); ~ELFWriter(); typedef std::vector<unsigned char> DataBuffer; @@ -45,7 +46,7 @@ namespace llvm { protected: /// Output stream to send the resultant object file to. /// - std::ostream &O; + raw_ostream &O; /// Target machine description. /// diff --git a/lib/CodeGen/GCMetadataPrinter.cpp b/lib/CodeGen/GCMetadataPrinter.cpp index 496450325b..5a5ef84fa4 100644 --- a/lib/CodeGen/GCMetadataPrinter.cpp +++ b/lib/CodeGen/GCMetadataPrinter.cpp @@ -19,12 +19,12 @@ GCMetadataPrinter::GCMetadataPrinter() { } GCMetadataPrinter::~GCMetadataPrinter() { } -void GCMetadataPrinter::beginAssembly(std::ostream &OS, AsmPrinter &AP, +void GCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI) { // Default is no action. } -void GCMetadataPrinter::finishAssembly(std::ostream &OS, AsmPrinter &AP, +void GCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP, const TargetAsmInfo &TAI) { // Default is no action. } diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index 938e1ae9cc..fb918f35ec 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -22,6 +22,7 @@ #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden, @@ -50,7 +51,7 @@ DisablePostRAScheduler("disable-post-RA-scheduler", FileModel::Model LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, - std::ostream &Out, + raw_ostream &Out, CodeGenFileType FileType, bool Fast) { // Standard LLVM-Level Passes. diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index bed2c5ca4b..9f1cb00ca7 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -37,6 +37,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/OutputBuffer.h" #include "llvm/Support/Streams.h" +#include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cstring> using namespace llvm; @@ -44,7 +45,7 @@ using namespace llvm; /// AddMachOWriter - Concrete function to add the Mach-O writer to the function /// pass manager. MachineCodeEmitter *llvm::AddMachOWriter(PassManagerBase &PM, - std::ostream &O, + raw_ostream &O, TargetMachine &TM) { MachOWriter *MOW = new MachOWriter(O, TM); PM.add(MOW); @@ -334,7 +335,7 @@ void MachOCodeEmitter::emitJumpTables(MachineJumpTableInfo *MJTI) { //===----------------------------------------------------------------------===// char MachOWriter::ID = 0; -MachOWriter::MachOWriter(std::ostream &o, TargetMachine &tm) +MachOWriter::MachOWriter(raw_ostream &o, TargetMachine &tm) : MachineFunctionPass((intptr_t)&ID), O(o), TM(tm) { is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64; isLittleEndian = TM.getTargetData()->isLittleEndian(); diff --git a/lib/CodeGen/MachOWriter.h b/lib/CodeGen/MachOWriter.h index 44fa7d4d44..e2b6fa8dd4 100644 --- a/lib/CodeGen/MachOWriter.h +++ b/lib/CodeGen/MachOWriter.h @@ -29,6 +29,7 @@ namespace llvm { class MachineCodeEmitter; class MachOCodeEmitter; class OutputBuffer; + class raw_ostream; /// MachOSym - This struct contains information about each symbol that is /// added to logical symbol table for the module. This is eventually @@ -90,7 +91,7 @@ namespace llvm { return *(MachineCodeEmitter*)MCE; } - MachOWriter(std::ostream &O, TargetMachine &TM); + MachOWriter(raw_ostream &O, TargetMachine &TM); virtual ~MachOWriter(); virtual const char *getPassName() const { @@ -101,7 +102,7 @@ namespace llvm { protected: /// Output stream to send the resultant object file to. /// - std::ostream &O; + raw_ostream &O; /// Target machine description. /// diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 144b90f65e..39686cbcc6 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -19,15 +19,15 @@ using namespace llvm; #if defined(_MSC_VER) #include <io.h> -#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-#endif
-#ifndef STDOUT_FILENO
-# define STDOUT_FILENO 1
-#endif
-#ifndef STDERR_FILENO
-# define STDERR_FILENO 2
-#endif
+#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif #endif // An out of line virtual method to provide a home for the class vtable. @@ -82,14 +82,14 @@ void raw_stderr_ostream::handle() {} /// outs() - This returns a reference to a raw_ostream for standard output. /// Use it like: outs() << "foo" << "bar"; -raw_ostream &outs() { +raw_ostream &llvm::outs() { static raw_stdout_ostream S; return S; } /// errs() - This returns a reference to a raw_ostream for standard error. /// Use it like: errs() << "foo" << "bar"; -raw_ostream &errs() { +raw_ostream &llvm::errs() { static raw_stderr_ostream S; return S; } diff --git a/lib/Target/ARM/ARM.h b/lib/Target/ARM/ARM.h index ef0c6bf839..8050a3aa5f 100644 --- a/lib/Target/ARM/ARM.h +++ b/lib/Target/ARM/ARM.h @@ -23,6 +23,7 @@ namespace llvm { class ARMTargetMachine; class FunctionPass; class MachineCodeEmitter; +class raw_ostream; // Enums corresponding to ARM condition codes namespace ARMCC { @@ -87,7 +88,7 @@ inline static const char *ARMCondCodeToString(ARMCC::CondCodes CC) { } FunctionPass *createARMISelDag(ARMTargetMachine &TM); -FunctionPass *createARMCodePrinterPass(std::ostream &O, ARMTargetMachine &TM); +FunctionPass *createARMCodePrinterPass(raw_ostream &O, ARMTargetMachine &TM); FunctionPass *createARMCodeEmitterPass(ARMTargetMachine &TM, MachineCodeEmitter &MCE); FunctionPass *createARMLoadStoreOptimizationPass(); diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index 5b7018f56e..061307837f 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -18,6 +18,7 @@ #include "llvm/PassManager.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Target/TargetOptions.h" using namespace llvm; @@ -143,7 +144,7 @@ bool ARMTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) { } bool ARMTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, - std::ostream &Out) { + raw_ostream &Out) { // Output assembly language. assert(AsmPrinterCtor && "AsmPrinter was not linked in"); if (AsmPrinterCtor) @@ -163,7 +164,7 @@ bool ARMTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast, if (DumpAsm) { assert(AsmPrinterCtor && "AsmPrinter was not linked in"); if (AsmPrinterCtor) - PM.add(AsmPrinterCtor(*cerr.stream(), *this)); + PM.add(AsmPrinterCtor(errs(), *this)); } return false; @@ -176,7 +177,7 @@ bool ARMTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, bool Fast, if (DumpAsm) { assert(AsmPrinterCtor && "AsmPrinter was not linked in"); if (AsmPrinterCtor) - PM.add(AsmPrinterCtor(*cerr.stream(), *this)); + PM.add(AsmPrinterCtor(errs(), *this |