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.
public:
/// Output stream on which we're printing assembly code.
///
- raw_ostream &O;
+ formatted_raw_ostream &O;
/// Target machine description.
///
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:
/// 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.
/// 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.
///
///
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
class Pass;
class TargetMachOWriterInfo;
class TargetELFWriterInfo;
-class raw_ostream;
+class formatted_raw_ostream;
// Relocation model types.
namespace Reloc {
/// is not supported.
///
virtual FileModel::Model addPassesToEmitFile(PassManagerBase &,
- raw_ostream &,
+ formatted_raw_ostream &,
CodeGenFileType,
CodeGenOpt::Level) {
return FileModel::None;
/// 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;
/// target-specific passes in standard locations.
///
virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM,
- raw_ostream &Out,
+ formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level);
/// 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;
}
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLowering.h"
cl::init(cl::BOU_UNSET));
char AsmPrinter::ID = 0;
-AsmPrinter::AsmPrinter(raw_ostream &o, TargetMachine &tm,
+AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
const TargetAsmInfo *T, bool VDef)
: MachineFunctionPass(&ID), FunctionNumber(0), O(o),
TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
/// printStringChar - Print a char, escaped if necessary.
///
-static void printStringChar(raw_ostream &O, unsigned char C) {
+static void printStringChar(formatted_raw_ostream &O, unsigned char C) {
if (C == '"') {
O << "\\\"";
} else if (C == '\\') {
/// printAsCString - Print the specified array as a C compatible string, only if
/// the predicate isString is true.
///
-static void printAsCString(raw_ostream &O, const ConstantArray *CVA,
+static void printAsCString(formatted_raw_ostream &O, const ConstantArray *CVA,
unsigned LastElt) {
assert(CVA->isString() && "Array is not string compatible!");
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
using namespace llvm;
namespace llvm {
FileModel::Model
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
- raw_ostream &Out,
+ formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel) {
// Add common CodeGen passes.
}
}
+/// fouts() - This returns a reference to a formatted_raw_ostream for
+/// standard output. Use it like: fouts() << "foo" << "bar";
+formatted_raw_ostream &llvm::fouts() {
+ static formatted_raw_ostream S(outs());
+ return S;
+}
+
+/// ferrs() - This returns a reference to a formatted_raw_ostream for
+/// standard error. Use it like: ferrs() << "foo" << "bar";
+formatted_raw_ostream &llvm::ferrs() {
+ static formatted_raw_ostream S(errs());
+ return S;
+}
case 0: break;
default:
// Normally the string to emit is shorter than the buffer.
- if (Size <= unsigned(OutBufEnd-OutBufStart)) {
+ if (Size <= unsigned(OutBufEnd-OutBufCur)) {
memcpy(OutBufCur, Ptr, Size);
break;
}
class MachineCodeEmitter;
class JITCodeEmitter;
class ObjectCodeEmitter;
-class raw_ostream;
+class formatted_raw_ostream;
// Enums corresponding to ARM condition codes
namespace ARMCC {
}
FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM);
-FunctionPass *createARMCodePrinterPass(raw_ostream &O,
+FunctionPass *createARMCodePrinterPass(formatted_raw_ostream &O,
ARMBaseTargetMachine &TM,
bool Verbose);
FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM,
#include "llvm/PassManager.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetMachineRegistry.h"
#include "llvm/Target/TargetOptions.h"
using namespace llvm;
bool ARMBaseTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
// Output assembly language.
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
protected:
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
- typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
ARMBaseTargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
bool DumpAsm, MachineCodeEmitter &MCE);
virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
#include <cctype>
using namespace llvm;
/// True if asm printer is printing a series of CONSTPOOL_ENTRY.
bool InCPMode;
public:
- explicit ARMAsmPrinter(raw_ostream &O, TargetMachine &TM,
+ explicit ARMAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V), DW(0), AFI(NULL), MCP(NULL),
InCPMode(false) {
}
}
-static void printSOImm(raw_ostream &O, int64_t V, bool VerboseAsm,
+static void printSOImm(formatted_raw_ostream &O, int64_t V, bool VerboseAsm,
const TargetAsmInfo *TAI) {
// Break it up into two parts that make up a shifter immediate.
V = ARM_AM::getSOImmVal(V);
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
+static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
Name != E; ++Name)
if (isprint(*Name))
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *llvm::createARMCodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createARMCodePrinterPass(formatted_raw_ostream &o,
ARMBaseTargetMachine &tm,
bool verbose) {
return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
class FunctionPass;
class MachineCodeEmitter;
class ObjectCodeEmitter;
- class raw_ostream;
+ class formatted_raw_ostream;
FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM);
- FunctionPass *createAlphaCodePrinterPass(raw_ostream &OS,
+ FunctionPass *createAlphaCodePrinterPass(formatted_raw_ostream &OS,
TargetMachine &TM,
bool Verbose);
FunctionPass *createAlphaPatternInstructionSelector(TargetMachine &TM);
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
using namespace llvm;
bool AlphaTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
PM.add(createAlphaLLRPPass(*this));
// Output assembly language.
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
}
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
}
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
}
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
- typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
TargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
bool DumpAsm, MachineCodeEmitter &MCE);
virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mangler.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
/// Unique incrementer for label values for referencing Global values.
///
- explicit AlphaAsmPrinter(raw_ostream &o, TargetMachine &tm,
+ explicit AlphaAsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
const TargetAsmInfo *T, bool V)
: AsmPrinter(o, tm, T, V) {}
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *llvm::createAlphaCodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createAlphaCodePrinterPass(formatted_raw_ostream &o,
TargetMachine &tm,
bool verbose) {
return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/MathExtras.h"
/// CWriter - This class is the main chunk of code that converts an LLVM
/// module to a C translation unit.
class CWriter : public FunctionPass, public InstVisitor<CWriter> {
- raw_ostream &Out;
+ formatted_raw_ostream &Out;
IntrinsicLowering *IL;
Mangler *Mang;
LoopInfo *LI;
public:
static char ID;
- explicit CWriter(raw_ostream &o)
+ explicit CWriter(formatted_raw_ostream &o)
: FunctionPass(&ID), Out(o), IL(0), Mang(0), LI(0),
TheModule(0), TAsm(0), TD(0), OpaqueCounter(0), NextAnonValueNumber(0) {
FPCounter = 0;
return false;
}
- raw_ostream &printType(raw_ostream &Out, const Type *Ty,
- bool isSigned = false,
- const std::string &VariableName = "",
- bool IgnoreName = false,
- const AttrListPtr &PAL = AttrListPtr());
+ raw_ostream &printType(formatted_raw_ostream &Out,
+ const Type *Ty,
+ bool isSigned = false,
+ const std::string &VariableName = "",
+ bool IgnoreName = false,
+ const AttrListPtr &PAL = AttrListPtr());
std::ostream &printType(std::ostream &Out, const Type *Ty,
bool isSigned = false,
const std::string &VariableName = "",
bool IgnoreName = false,
const AttrListPtr &PAL = AttrListPtr());
- raw_ostream &printSimpleType(raw_ostream &Out, const Type *Ty,
- bool isSigned,
- const std::string &NameSoFar = "");
+ raw_ostream &printSimpleType(formatted_raw_ostream &Out,
+ const Type *Ty,
+ bool isSigned,
+ const std::string &NameSoFar = "");
std::ostream &printSimpleType(std::ostream &Out, const Type *Ty,
bool isSigned,
const std::string &NameSoFar = "");
- void printStructReturnPointerFunctionType(raw_ostream &Out,
+ void printStructReturnPointerFunctionType(formatted_raw_ostream &Out,
const AttrListPtr &PAL,
const PointerType *Ty);
/// printStructReturnPointerFunctionType - This is like printType for a struct
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
/// print it as "Struct (*)(...)", for struct return functions.
-void CWriter::printStructReturnPointerFunctionType(raw_ostream &Out,
+void CWriter::printStructReturnPointerFunctionType(formatted_raw_ostream &Out,
const AttrListPtr &PAL,
const PointerType *TheTy) {
const FunctionType *FTy = cast<FunctionType>(TheTy->getElementType());
}
raw_ostream &
-CWriter::printSimpleType(raw_ostream &Out, const Type *Ty, bool isSigned,
+CWriter::printSimpleType(formatted_raw_ostream &Out, const Type *Ty,
+ bool isSigned,
const std::string &NameSoFar) {
assert((Ty->isPrimitiveType() || Ty->isInteger() || isa<VectorType>(Ty)) &&
"Invalid type for printSimpleType");
// Pass the Type* and the variable name and this prints out the variable
// declaration.
//
-raw_ostream &CWriter::printType(raw_ostream &Out, const Type *Ty,
- bool isSigned, const std::string &NameSoFar,
- bool IgnoreName, const AttrListPtr &PAL) {
+raw_ostream &CWriter::printType(formatted_raw_ostream &Out,
+ const Type *Ty,
+ bool isSigned, const std::string &NameSoFar,
+ bool IgnoreName, const AttrListPtr &PAL) {
if (Ty->isPrimitiveType() || Ty->isInteger() || isa<VectorType>(Ty)) {
printSimpleType(Out, Ty, isSigned, NameSoFar);
return Out;
// generateCompilerSpecificCode - This is where we add conditional compilation
// directives to cater to specific compilers as need be.
//
-static void generateCompilerSpecificCode(raw_ostream& Out,
+static void generateCompilerSpecificCode(formatted_raw_ostream& Out,
const TargetData *TD) {
// Alloca is hard to get, and we don't want to include stdlib.h here.
Out << "/* get a declaration for alloca */\n"
//===----------------------------------------------------------------------===//
bool CTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
- raw_ostream &o,
+ formatted_raw_ostream &o,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel) {
if (FileType != TargetMachine::AssemblyFile) return true;
: DataLayout(&M) {}
virtual bool WantsWholeFile() const { return true; }
- virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
+ virtual bool addPassesToEmitWholeFile(PassManager &PM,
+ formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel);
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetInstrInfo.h"
class VISIBILITY_HIDDEN SPUAsmPrinter : public AsmPrinter {
std::set<std::string> FnStubs, GVStubs;
public:
- explicit SPUAsmPrinter(raw_ostream &O, TargetMachine &TM,
+ explicit SPUAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *T, bool V) :
AsmPrinter(O, TM, T, V) {}
class VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter {
DwarfWriter *DW;
public:
- explicit LinuxAsmPrinter(raw_ostream &O, SPUTargetMachine &TM,
+ explicit LinuxAsmPrinter(formatted_raw_ostream &O, SPUTargetMachine &TM,
const TargetAsmInfo *T, bool V)
: SPUAsmPrinter(O, TM, T, V), DW(0) {}
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
+static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
Name != E; ++Name)
if (isprint(*Name))
/// assembly code for a MachineFunction to the given output stream, in a format
/// that the Linux SPU assembler can deal with.
///
-FunctionPass *llvm::createSPUAsmPrinterPass(raw_ostream &o,
+FunctionPass *llvm::createSPUAsmPrinterPass(formatted_raw_ostream &o,
SPUTargetMachine &tm,
bool verbose) {
return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
namespace llvm {
class SPUTargetMachine;
class FunctionPass;
- class raw_ostream;
+ class formatted_raw_ostream;
FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
- FunctionPass *createSPUAsmPrinterPass(raw_ostream &o,
+ FunctionPass *createSPUAsmPrinterPass(formatted_raw_ostream &o,
SPUTargetMachine &tm,
bool verbose);
bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
// Output assembly language.
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
- typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
SPUTargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
static void registerAsmPrinter(AsmPrinterCtorFn F) {
AsmPrinterCtor = F;
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Streams.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Config/config.h"
#include <algorithm>
#include <set>
/// CppWriter - This class is the main chunk of code that converts an LLVM
/// module to a C++ translation unit.
class CppWriter : public ModulePass {
- raw_ostream &Out;
+ formatted_raw_ostream &Out;
const Module *TheModule;
uint64_t uniqueNum;
TypeMap TypeNames;
public:
static char ID;
- explicit CppWriter(raw_ostream &o) :
+ explicit CppWriter(formatted_raw_ostream &o) :
ModulePass(&ID), Out(o), uniqueNum(0), is_inline(false) {}
virtual const char *getPassName() const { return "C++ backend"; }
};
static unsigned indent_level = 0;
- inline raw_ostream& nl(raw_ostream& Out, int delta = 0) {
+ inline formatted_raw_ostream& nl(formatted_raw_ostream& Out, int delta = 0) {
Out << "\n";
if (delta >= 0 || indent_level >= unsigned(-delta))
indent_level += delta;
Out << "#include <llvm/BasicBlock.h>\n";
Out << "#include <llvm/Instructions.h>\n";
Out << "#include <llvm/InlineAsm.h>\n";
+ Out << "#include <llvm/Support/FormattedStream.h>\n";
Out << "#include <llvm/Support/MathExtras.h>\n";
- Out << "#include <llvm/Support/raw_ostream.h>\n";
Out << "#include <llvm/Pass.h>\n";
Out << "#include <llvm/PassManager.h>\n";
Out << "#include <llvm/ADT/SmallVector.h>\n";
//===----------------------------------------------------------------------===//
bool CPPTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
- raw_ostream &o,
+ formatted_raw_ostream &o,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel) {
if (FileType != TargetMachine::AssemblyFile) return true;
namespace llvm {
-class raw_ostream;
+class formatted_raw_ostream;
struct CPPTargetMachine : public TargetMachine {
const TargetData DataLayout; // Calculates type size & alignment
: DataLayout(&M) {}
virtual bool WantsWholeFile() const { return true; }
- virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
+ virtual bool addPassesToEmitWholeFile(PassManager &PM,
+ formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel);
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
class IA64AsmPrinter : public AsmPrinter {
std::set<std::string> ExternalFunctionNames, ExternalObjectNames;
public:
- explicit IA64AsmPrinter(raw_ostream &O, TargetMachine &TM,
+ explicit IA64AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V) {}
/// assembly code for a MachineFunction to the given output stream, using
/// the given target machine description.
///
-FunctionPass *llvm::createIA64CodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createIA64CodePrinterPass(formatted_raw_ostream &o,
IA64TargetMachine &tm,
bool verbose) {
return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
class IA64TargetMachine;
class FunctionPass;
-class raw_ostream;
+class formatted_raw_ostream;
/// createIA64DAGToDAGInstructionSelector - This pass converts an LLVM
/// function into IA64 machine code in a sane, DAG->DAG transform.
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *createIA64CodePrinterPass(raw_ostream &o,
+FunctionPass *createIA64CodePrinterPass(formatted_raw_ostream &o,
IA64TargetMachine &tm,
bool verbose);
bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
// Output assembly language.
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
- typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
IA64TargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
static void registerAsmPrinter(AsmPrinterCtorFn F) {
AsmPrinterCtor = F;
: DataLayout(&M) {}
virtual bool WantsWholeFile() const { return true; }
- virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
+ virtual bool addPassesToEmitWholeFile(PassManager &PM,
+ formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel);
// External Interface declaration
//===----------------------------------------------------------------------===//
-bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM, raw_ostream &o,
+bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM,
+ formatted_raw_ostream &o,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel)
{
#include "llvm/PassManager.h"
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetMachineRegistry.h"
}
public:
- raw_ostream &Out;
+ formatted_raw_ostream &Out;
Module* ModulePtr;
const TargetData* TD;
Mangler* Mang;
StaticInitList;
const std::set<const Type *>* UsedTypes;
static char ID;
+<<<<<<< .mine
+ MSILWriter(formatted_raw_ostream &o) : FunctionPass(&ID), Out(o) {
+=======
DenseMap<const Value*, unsigned> AnonValueNumbers;
unsigned NextAnonValueNumber;
MSILWriter(raw_ostream &o)
: FunctionPass(&ID), Out(o), NextAnonValueNumber(0) {
+>>>>>>> .r75668
UniqID = 0;
}
namespace llvm {
class MSP430TargetMachine;
class FunctionPass;
- class raw_ostream;
+ class formatted_raw_ostream;
FunctionPass *createMSP430ISelDag(MSP430TargetMachine &TM,
CodeGenOpt::Level OptLevel);
- FunctionPass *createMSP430CodePrinterPass(raw_ostream &o,
+ FunctionPass *createMSP430CodePrinterPass(formatted_raw_ostream &o,
MSP430TargetMachine &tm,
bool verbose);
} // end namespace llvm;
#include "llvm/Target/TargetData.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
namespace {
class VISIBILITY_HIDDEN MSP430AsmPrinter : public AsmPrinter {
public:
- MSP430AsmPrinter(raw_ostream &O, MSP430TargetMachine &TM,
+ MSP430AsmPrinter(formatted_raw_ostream &O, MSP430TargetMachine &TM,
const TargetAsmInfo *TAI, bool V)
: AsmPrinter(O, TM, TAI, V) {}
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *llvm::createMSP430CodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createMSP430CodePrinterPass(formatted_raw_ostream &o,
MSP430TargetMachine &tm,
bool verbose) {
return new MSP430AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
bool MSP430TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
// Output assembly language.
PM.add(createMSP430CodePrinterPass(Out, *this, Verbose));
return false;
virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel, bool Verbose,
- raw_ostream &Out);
+ formatted_raw_ostream &Out);
static unsigned getModuleMatchQuality(const Module &M);
}; // MSP430TargetMachine.
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/raw_ostream.h"
#include <cctype>
using namespace llvm;
class VISIBILITY_HIDDEN MipsAsmPrinter : public AsmPrinter {
const MipsSubtarget *Subtarget;
public:
- explicit MipsAsmPrinter(raw_ostream &O, MipsTargetMachine &TM,
+ explicit MipsAsmPrinter(formatted_raw_ostream &O, MipsTargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V) {
Subtarget = &TM.getSubtarget<MipsSubtarget>();
/// assembly code for a MachineFunction to the given output stream,
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
-FunctionPass *llvm::createMipsCodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createMipsCodePrinterPass(formatted_raw_ostream &o,
MipsTargetMachine &tm,
bool verbose) {
return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
class MipsTargetMachine;
class FunctionPass;
class MachineCodeEmitter;
- class raw_ostream;
+ class formatted_raw_ostream;
FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
- FunctionPass *createMipsCodePrinterPass(raw_ostream &OS,
+ FunctionPass *createMipsCodePrinterPass(formatted_raw_ostream &OS,
MipsTargetMachine &TM,
bool Verbose);
} // end namespace llvm;
// true if AssemblyEmitter is supported
bool MipsTargetMachine::
addAssemblyEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out) {
+ bool Verbose, formatted_raw_ostream &Out) {
// Output assembly language.
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
PM.add(AsmPrinterCtor(Out, *this, Verbose));
#include "llvm/Target/TargetFrameInfo.h"
namespace llvm {
- class raw_ostream;
+ class formatted_raw_ostream;
class MipsTargetMachine : public LLVMTargetMachine {
MipsSubtarget Subtarget;
// To avoid having target depend on the asmprinter stuff libraries,
// asmprinter set this functions to ctor pointer at startup time if they are
// linked in.
- typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
MipsTargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
};
/// MipselTargetMachine - Mipsel target machine.
class PIC16TargetMachine;
class FunctionPass;
class MachineCodeEmitter;
- class raw_ostream;
+ class formatted_raw_ostream;
namespace PIC16CC {
enum CondCodes {
FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
- FunctionPass *createPIC16CodePrinterPass(raw_ostream &OS,
+ FunctionPass *createPIC16CodePrinterPass(formatted_raw_ostream &OS,
PIC16TargetMachine &TM,
bool Verbose);
// Banksel optimzer pass.
#include "llvm/Function.h"
#include "llvm/Module.h"
#include "llvm/CodeGen/DwarfWriter.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/CodeGen/DwarfWriter.h"
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *llvm::createPIC16CodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createPIC16CodePrinterPass(formatted_raw_ostream &o,
PIC16TargetMachine &tm,
bool verbose) {
return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
namespace llvm {
struct VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
- explicit PIC16AsmPrinter(raw_ostream &O, PIC16TargetMachine &TM,
+ explicit PIC16AsmPrinter(formatted_raw_ostream &O, PIC16TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V), DbgInfo(O, T) {
PTLI = TM.getTargetLowering();
#include "llvm/GlobalVariable.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Support/DebugLoc.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
using namespace llvm;
};
}
- class raw_ostream;
+ class formatted_raw_ostream;
class PIC16DbgInfo {
- raw_ostream &O;
+ formatted_raw_ostream &O;
const TargetAsmInfo *TAI;
std::string CurFile;
unsigned CurLine;
bool EmitDebugDirectives;
public:
- PIC16DbgInfo(raw_ostream &o, const TargetAsmInfo *T) : O(o), TAI(T) {
+ PIC16DbgInfo(formatted_raw_ostream &o, const TargetAsmInfo *T)
+ : O(o), TAI(T) {
CurFile = "";
CurLine = 0;
EmitDebugDirectives = false;
bool PIC16TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out) {
+ bool Verbose,
+ formatted_raw_ostream &Out) {
// Output assembly language.
PM.add(createPIC16CodePrinterPass(Out, *this, Verbose));
return false;
CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
}; // PIC16TargetMachine.
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetInstrInfo.h"
StringSet<> FnStubs, GVStubs, HiddenGVStubs;
const PPCSubtarget &Subtarget;
public:
- explicit PPCAsmPrinter(raw_ostream &O, TargetMachine &TM,
+ explicit PPCAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V),
Subtarget(TM.getSubtarget<PPCSubtarget>()) {}
/// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
class VISIBILITY_HIDDEN PPCLinuxAsmPrinter : public PPCAsmPrinter {
public:
- explicit PPCLinuxAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
+ explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM,
const TargetAsmInfo *T, bool V)
: PPCAsmPrinter(O, TM, T, V){}
/// PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac
/// OS X
class VISIBILITY_HIDDEN PPCDarwinAsmPrinter : public PPCAsmPrinter {
- raw_ostream &OS;
+ formatted_raw_ostream &OS;
public:
- explicit PPCDarwinAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
+ explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM,
const TargetAsmInfo *T, bool V)
: PPCAsmPrinter(O, TM, T, V), OS(O) {}
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
+static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
Name != E; ++Name)
if (isprint(*Name))
/// for a MachineFunction to the given output stream, in a format that the
/// Darwin assembler can deal with.
///
-FunctionPass *llvm::createPPCAsmPrinterPass(raw_ostream &o,
+FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o,
PPCTargetMachine &tm,
bool verbose) {
const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
class FunctionPass;
class MachineCodeEmitter;
class ObjectCodeEmitter;
- class raw_ostream;
+ class formatted_raw_ostream;
FunctionPass *createPPCBranchSelectionPass();
FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
-FunctionPass *createPPCAsmPrinterPass(raw_ostream &OS, PPCTargetMachine &TM,
+FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &OS,
+ PPCTargetMachine &TM,
bool Verbose);
FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
MachineCodeEmitter &MCE);
#include "llvm/PassManager.h"
#include "llvm/Target/TargetMachineRegistry.h"
#include "llvm/Target/TargetOptions.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
using namespace llvm;
/// PowerPCTargetMachineModule - Note that this is used on hosts that
bool PPCTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(Out, *this, Verbose));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
- typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
PPCTargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
bool DumpAsm, MachineCodeEmitter &MCE);
virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h"
ValueMapTy NumberForBB;
unsigned BBNumber;
public:
- explicit SparcAsmPrinter(raw_ostream &O, TargetMachine &TM,
+ explicit SparcAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V), BBNumber(0) {}
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *llvm::createSparcCodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createSparcCodePrinterPass(formatted_raw_ostream &o,
TargetMachine &tm,
bool verbose) {
return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
namespace llvm {
class FunctionPass;
class SparcTargetMachine;
- class raw_ostream;
+ class formatted_raw_ostream;
FunctionPass *createSparcISelDag(SparcTargetMachine &TM);
- FunctionPass *createSparcCodePrinterPass(raw_ostream &OS, TargetMachine &TM,
+ FunctionPass *createSparcCodePrinterPass(formatted_raw_ostream &OS,
+ TargetMachine &TM,
bool Verbose);
FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM);
FunctionPass *createSparcFPMoverPass(TargetMachine &TM);
bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
// Output assembly language.
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
- typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
TargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
static void registerAsmPrinter(AsmPrinterCtorFn F) {
AsmPrinterCtor = F;
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetOptions.h"
using namespace llvm;
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
+static void PrintUnmangledNameSafely(const Value *V,
+ formatted_raw_ostream &OS) {
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
Name != E; ++Name)
if (isprint(*Name))
MCContext *Context;
MCStreamer *Streamer;
public:
- explicit X86ATTAsmPrinter(raw_ostream &O, X86TargetMachine &TM,
+ explicit X86ATTAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V) {
Subtarget = &TM.getSubtarget<X86Subtarget>();
#include "X86ATTAsmPrinter.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
using namespace llvm;
// Include the auto-generated portion of the assembly writer.
/// for a MachineFunction to the given output stream, using the given target
/// machine description.
///
-FunctionPass *llvm::createX86CodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o,
X86TargetMachine &tm,
bool verbose) {
const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
namespace llvm {
struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter {
- explicit X86IntelAsmPrinter(raw_ostream &O, X86TargetMachine &TM,
+ explicit X86IntelAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V) {}
class FunctionPass;
class MachineCodeEmitter;
class JITCodeEmitter;
-class raw_ostream;
+class formatted_raw_ostream;
/// createX86ISelDag - This pass converts a legalized DAG into a
/// X86-specific DAG, ready for instruction scheduling.
/// assembly code for a MachineFunction to the given output stream,
/// using the given target machine description.
///
-FunctionPass *createX86CodePrinterPass(raw_ostream &o, X86TargetMachine &tm,
+FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
+ X86TargetMachine &tm,
bool Verbose);
/// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
#include "llvm/PassManager.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/Passes.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetMachineRegistry.h"
using namespace llvm;
bool X86TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(Out, *this, Verbose));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
- PM.add(AsmPrinterCtor(errs(), *this, true));
+ PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
return false;
namespace llvm {
-class raw_ostream;
+class formatted_raw_ostream;
class X86TargetMachine : public LLVMTargetMachine {
X86Subtarget Subtarget;
// To avoid having target depend on the asmprinter stuff libraries, asmprinter
// set this functions to ctor pointer at startup time if they are linked in.
- typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
X86TargetMachine &tm,
bool verbose);
static AsmPrinterCtorFn AsmPrinterCtor;
virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
bool DumpAsm, MachineCodeEmitter &MCE);
virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
class FunctionPass;
class TargetMachine;
class XCoreTargetMachine;
- class raw_ostream;
+ class formatted_raw_ostream;
FunctionPass *createXCoreISelDag(XCoreTargetMachine &TM);
- FunctionPass *createXCoreCodePrinterPass(raw_ostream &OS,
+ FunctionPass *createXCoreCodePrinterPass(formatted_raw_ostream &OS,
XCoreTargetMachine &TM,
bool Verbose);
} // end namespace llvm;
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cctype>
using namespace llvm;
DwarfWriter *DW;
const XCoreSubtarget &Subtarget;
public:
- explicit XCoreAsmPrinter(raw_ostream &O, XCoreTargetMachine &TM,
+ explicit XCoreAsmPrinter(formatted_raw_ostream &O, XCoreTargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V), DW(0),
Subtarget(*TM.getSubtargetImpl()) {}
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *llvm::createXCoreCodePrinterPass(raw_ostream &o,
+FunctionPass *llvm::createXCoreCodePrinterPass(formatted_raw_ostream &o,
XCoreTargetMachine &tm,
bool verbose) {
return new XCoreAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
// PrintEscapedString - Print each character of the specified string, escaping
// it if it is not printable or if it is an escape char.
-static void PrintEscapedString(const std::string &Str, raw_ostream &Out) {
+static void PrintEscapedString(const std::string &Str,
+ formatted_raw_ostream &Out) {
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
unsigned char C = Str[i];
if (isprint(C) && C != '"' && C != '\\') {
bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
- raw_ostream &Out) {
+ formatted_raw_ostream &Out) {
// Output assembly language.
PM.add(createXCoreCodePrinterPass(Out, *this, Verbose));
return false;
virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
virtual bool addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out);
+ bool Verbose, formatted_raw_ostream &Out);
};
} // end namespace llvm
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/RegistryParser.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
return outputFilename;
}
-static raw_ostream *GetOutputStream(const char *ProgName) {
+static formatted_raw_ostream *GetOutputStream(const char *ProgName) {
if (OutputFilename != "") {
if (OutputFilename == "-")
- return &outs();
+ return &fouts();
// Specified an output filename?
if (!Force && std::ifstream(OutputFilename.c_str())) {
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
std::string error;
- raw_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(), true, error);
+ raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(),
+ true, error);
+ formatted_raw_ostream *Out =
+ new formatted_raw_ostream(*FDOut, formatted_raw_ostream::DELETE_STREAM);
if (!error.empty()) {
std::cerr << error << '\n';
delete Out;
if (InputFilename == "-") {
OutputFilename = "-";
- return &outs();
+ return &fouts();
}
OutputFilename = GetFileNameRoot(InputFilename);
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
std::string error;
- raw_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(), Binary, error);
+ raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(),
+ Binary, error);
+ formatted_raw_ostream *Out =
+ new formatted_raw_ostream(*FDOut, formatted_raw_ostream::DELETE_STREAM);
if (!error.empty()) {
std::cerr << error << '\n';
delete Out;
TargetMachine &Target = *target.get();
// Figure out where we are going to send the output...
- raw_ostream *Out = GetOutputStream(argv[0]);
+ formatted_raw_ostream *Out = GetOutputStream(argv[0]);
if (Out == 0) return 1;
CodeGenOpt::Level OLvl = CodeGenOpt::Default;
if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl)) {
std::cerr << argv[0] << ": target does not support generation of this"
<< " file type!\n";
- if (Out != &outs()) delete Out;
+ if (Out != &fouts()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
case FileModel::Error:
std::cerr << argv[0] << ": target does not support generation of this"
<< " file type!\n";
- if (Out != &outs()) delete Out;
+ if (Out != &fouts()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
if (Target.addPassesToEmitFileFinish(Passes, OCE, OLvl)) {
std::cerr << argv[0] << ": target does not support generation of this"
<< " file type!\n";
- if (Out != &outs()) delete Out;
+ if (Out != &fouts()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
Passes.doFinalization();
}
+ Out->flush();
+
// Delete the ostream if it's not a stdout stream
- if (Out != &outs()) delete Out;
+ if (Out != &fouts()) delete Out;
return 0;
}
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/CodeGen/FileWriters.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/StandardPasses.h"
#include "llvm/Support/SystemUtils.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
#include "llvm/Target/SubtargetFeature.h"
#include "llvm/Target/TargetOptions.h"
// generate assembly code
bool genResult = false;
{
- raw_fd_ostream asmFile(uniqueAsmPath.c_str(), false, errMsg);
+ raw_fd_ostream asmFD(raw_fd_ostream(uniqueAsmPath.c_str(),
+ false, errMsg));
+ formatted_raw_ostream asmFile(asmFD);
if (!errMsg.empty())
return NULL;
genResult = this->generateAssemblyCode(asmFile, errMsg);
}
/// Optimize merged modules using various IPO passes
-bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
+bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out,
std::string& errMsg)
{
if ( this->determineTarget(errMsg) )
const void* compile(size_t* length, std::string& errMsg);
void setCodeGenDebugOptions(const char *opts);
private:
- bool generateAssemblyCode(llvm::raw_ostream& out,
+ bool generateAssemblyCode(llvm::formatted_raw_ostream& out,
std::string& errMsg);
bool assemble(const std::string& asmPath,
const std::string& objPath, std::string& errMsg);