Momentous day: remove the "O" member from AsmPrinter. Now all

"asm printering" happens through MCStreamer.  This also 
Streamerizes PIC16 debug info, which escaped my attention.

This removes a leak from LLVMTargetMachine of the 'legacy'
output stream.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100327 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-04-04 08:18:47 +00:00
parent de0f339ec3
commit b23569aff0
21 changed files with 86 additions and 149 deletions

View File

@ -54,7 +54,6 @@ namespace llvm {
class TargetLoweringObjectFile; class TargetLoweringObjectFile;
class Twine; class Twine;
class Type; class Type;
class formatted_raw_ostream;
/// AsmPrinter - This class is intended to be used as a driving class for all /// AsmPrinter - This class is intended to be used as a driving class for all
/// asm writers. /// asm writers.
@ -80,10 +79,6 @@ namespace llvm {
public: public:
/// Output stream on which we're printing assembly code.
///
formatted_raw_ostream &O;
/// Target machine description. /// Target machine description.
/// ///
TargetMachine &TM; TargetMachine &TM;
@ -138,8 +133,7 @@ namespace llvm {
mutable unsigned SetCounter; mutable unsigned SetCounter;
protected: protected:
explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM, explicit AsmPrinter(TargetMachine &TM, MCStreamer &Streamer);
MCStreamer &Streamer);
public: public:
virtual ~AsmPrinter(); virtual ~AsmPrinter();

View File

@ -38,7 +38,6 @@ namespace llvm {
class TargetAsmLexer; class TargetAsmLexer;
class TargetAsmParser; class TargetAsmParser;
class TargetMachine; class TargetMachine;
class formatted_raw_ostream;
class raw_ostream; class raw_ostream;
/// Target - Wrapper for Target specific information. /// Target - Wrapper for Target specific information.
@ -60,8 +59,7 @@ namespace llvm {
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T, typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
const std::string &TT, const std::string &TT,
const std::string &Features); const std::string &Features);
typedef AsmPrinter *(*AsmPrinterCtorTy)(formatted_raw_ostream &OS, typedef AsmPrinter *(*AsmPrinterCtorTy)(TargetMachine &TM,
TargetMachine &TM,
MCStreamer &Streamer); MCStreamer &Streamer);
typedef TargetAsmBackend *(*AsmBackendCtorTy)(const Target &T, typedef TargetAsmBackend *(*AsmBackendCtorTy)(const Target &T,
const std::string &TT); const std::string &TT);
@ -233,11 +231,10 @@ namespace llvm {
/// createAsmPrinter - Create a target specific assembly printer pass. This /// createAsmPrinter - Create a target specific assembly printer pass. This
/// takes ownership of the MCStreamer object. /// takes ownership of the MCStreamer object.
AsmPrinter *createAsmPrinter(formatted_raw_ostream &OS, TargetMachine &TM, AsmPrinter *createAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) const{
MCStreamer &Streamer) const {
if (!AsmPrinterCtorFn) if (!AsmPrinterCtorFn)
return 0; return 0;
return AsmPrinterCtorFn(OS, TM, Streamer); return AsmPrinterCtorFn(TM, Streamer);
} }
MCDisassembler *createMCDisassembler() const { MCDisassembler *createMCDisassembler() const {
@ -644,9 +641,8 @@ namespace llvm {
} }
private: private:
static AsmPrinter *Allocator(formatted_raw_ostream &OS, TargetMachine &TM, static AsmPrinter *Allocator(TargetMachine &TM, MCStreamer &Streamer) {
MCStreamer &Streamer) { return new AsmPrinterImpl(TM, Streamer);
return new AsmPrinterImpl(OS, TM, Streamer);
} }
}; };

View File

@ -48,7 +48,6 @@
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"
#include "llvm/Support/FormattedStream.h"
#include <cerrno> #include <cerrno>
using namespace llvm; using namespace llvm;
@ -56,9 +55,8 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
char AsmPrinter::ID = 0; char AsmPrinter::ID = 0;
AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm, AsmPrinter::AsmPrinter(TargetMachine &tm, MCStreamer &Streamer)
MCStreamer &Streamer) : MachineFunctionPass(&ID),
: MachineFunctionPass(&ID), O(o),
TM(tm), MAI(tm.getMCAsmInfo()), TRI(tm.getRegisterInfo()), TM(tm), MAI(tm.getMCAsmInfo()), TRI(tm.getRegisterInfo()),
OutContext(Streamer.getContext()), OutContext(Streamer.getContext()),
OutStreamer(Streamer), OutStreamer(Streamer),

View File

@ -123,7 +123,6 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
const MCAsmInfo &MAI = *getMCAsmInfo(); const MCAsmInfo &MAI = *getMCAsmInfo();
OwningPtr<MCStreamer> AsmStreamer; OwningPtr<MCStreamer> AsmStreamer;
formatted_raw_ostream *LegacyOutput;
switch (FileType) { switch (FileType) {
default: return true; default: return true;
case CGFT_AssemblyFile: { case CGFT_AssemblyFile: {
@ -133,8 +132,6 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
getTargetData()->isLittleEndian(), getTargetData()->isLittleEndian(),
getVerboseAsm(), InstPrinter, getVerboseAsm(), InstPrinter,
/*codeemitter*/0)); /*codeemitter*/0));
// Set the AsmPrinter's "O" to the output file.
LegacyOutput = &Out;
break; break;
} }
case CGFT_ObjectFile: { case CGFT_ObjectFile: {
@ -146,29 +143,17 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
return true; return true;
AsmStreamer.reset(createMachOStreamer(*Context, *TAB, Out, MCE)); AsmStreamer.reset(createMachOStreamer(*Context, *TAB, Out, MCE));
// Any output to the asmprinter's "O" stream is bad and needs to be fixed,
// force it to come out stderr.
// FIXME: this is horrible and leaks, eventually remove the raw_ostream from
// asmprinter.
LegacyOutput = new formatted_raw_ostream(errs());
break; break;
} }
case CGFT_Null: case CGFT_Null:
// The Null output is intended for use for performance analysis and testing, // The Null output is intended for use for performance analysis and testing,
// not real users. // not real users.
AsmStreamer.reset(createNullStreamer(*Context)); AsmStreamer.reset(createNullStreamer(*Context));
// Any output to the asmprinter's "O" stream is bad and needs to be fixed,
// force it to come out stderr.
// FIXME: this is horrible and leaks, eventually remove the raw_ostream from
// asmprinter.
LegacyOutput = new formatted_raw_ostream(errs());
break; break;
} }
// Create the AsmPrinter, which takes ownership of AsmStreamer if successful. // Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
FunctionPass *Printer = FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer);
getTarget().createAsmPrinter(*LegacyOutput, *this, *AsmStreamer);
if (Printer == 0) if (Printer == 0)
return true; return true;

View File

@ -46,11 +46,9 @@
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/MathExtras.h"
#include <cctype> #include <cctype>
using namespace llvm; using namespace llvm;
@ -74,9 +72,8 @@ namespace {
const MachineConstantPool *MCP; const MachineConstantPool *MCP;
public: public:
explicit ARMAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL) {
: AsmPrinter(O, TM, Streamer), AFI(NULL), MCP(NULL) {
Subtarget = &TM.getSubtarget<ARMSubtarget>(); Subtarget = &TM.getSubtarget<ARMSubtarget>();
} }

View File

@ -29,8 +29,7 @@
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/FormattedStream.h"
using namespace llvm; using namespace llvm;
namespace { namespace {
@ -38,9 +37,8 @@ namespace {
/// Unique incrementer for label values for referencing Global values. /// Unique incrementer for label values for referencing Global values.
/// ///
explicit AlphaAsmPrinter(formatted_raw_ostream &o, TargetMachine &tm, explicit AlphaAsmPrinter(TargetMachine &tm, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(tm, Streamer) {}
: AsmPrinter(o, tm, Streamer) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "Alpha Assembly Printer"; return "Alpha Assembly Printer";

View File

@ -33,15 +33,14 @@
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;
namespace { namespace {
class BlackfinAsmPrinter : public AsmPrinter { class BlackfinAsmPrinter : public AsmPrinter {
public: public:
BlackfinAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, BlackfinAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer) {}
: AsmPrinter(O, TM, Streamer) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "Blackfin Assembly Printer"; return "Blackfin Assembly Printer";

View File

@ -33,15 +33,14 @@
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;
namespace { namespace {
class SPUAsmPrinter : public AsmPrinter { class SPUAsmPrinter : public AsmPrinter {
public: public:
explicit SPUAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit SPUAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) :
MCStreamer &Streamer) : AsmPrinter(TM, Streamer) {}
AsmPrinter(O, TM, Streamer) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "STI CBEA SPU Assembly Printer"; return "STI CBEA SPU Assembly Printer";

View File

@ -23,7 +23,6 @@
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFrameInfo.h"
@ -38,13 +37,9 @@
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/MathExtras.h"
#include <cctype> #include <cctype>
using namespace llvm; using namespace llvm;
@ -53,9 +48,8 @@ namespace {
class MBlazeAsmPrinter : public AsmPrinter { class MBlazeAsmPrinter : public AsmPrinter {
const MBlazeSubtarget *Subtarget; const MBlazeSubtarget *Subtarget;
public: public:
explicit MBlazeAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit MBlazeAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer) {
: AsmPrinter(O, TM, Streamer) {
Subtarget = &TM.getSubtarget<MBlazeSubtarget>(); Subtarget = &TM.getSubtarget<MBlazeSubtarget>();
} }

View File

@ -36,15 +36,14 @@
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;
namespace { namespace {
class MSP430AsmPrinter : public AsmPrinter { class MSP430AsmPrinter : public AsmPrinter {
public: public:
MSP430AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, MSP430AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer) {}
: AsmPrinter(O, TM, Streamer) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "MSP430 Assembly Printer"; return "MSP430 Assembly Printer";

View File

@ -19,9 +19,6 @@
#include "MipsInstrInfo.h" #include "MipsInstrInfo.h"
#include "MipsTargetMachine.h" #include "MipsTargetMachine.h"
#include "MipsMachineFunction.h" #include "MipsMachineFunction.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineFunctionPass.h"
@ -39,20 +36,16 @@
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h" #include "llvm/ADT/Twine.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MathExtras.h"
#include <cctype>
using namespace llvm; using namespace llvm;
namespace { namespace {
class MipsAsmPrinter : public AsmPrinter { class MipsAsmPrinter : public AsmPrinter {
const MipsSubtarget *Subtarget; const MipsSubtarget *Subtarget;
public: public:
explicit MipsAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit MipsAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer) {
: AsmPrinter(O, TM, Streamer) {
Subtarget = &TM.getSubtarget<MipsSubtarget>(); Subtarget = &TM.getSubtarget<MipsSubtarget>();
} }

View File

@ -29,16 +29,15 @@
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include <cstring> #include <cstring>
using namespace llvm; using namespace llvm;
#include "PIC16GenAsmWriter.inc" #include "PIC16GenAsmWriter.inc"
PIC16AsmPrinter::PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, PIC16AsmPrinter::PIC16AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer), DbgInfo(Streamer, TM.getMCAsmInfo()) {
: AsmPrinter(O, TM, Streamer), DbgInfo(O, TM.getMCAsmInfo()) {
PTLI = static_cast<PIC16TargetLowering*>(TM.getTargetLowering()); PTLI = static_cast<PIC16TargetLowering*>(TM.getTargetLowering());
PMAI = static_cast<const PIC16MCAsmInfo*>(TM.getMCAsmInfo()); PMAI = static_cast<const PIC16MCAsmInfo*>(TM.getMCAsmInfo());
PTOF = (PIC16TargetObjectFile *)&PTLI->getObjFileLowering(); PTOF = (PIC16TargetObjectFile *)&PTLI->getObjFileLowering();

View File

@ -31,8 +31,7 @@
namespace llvm { namespace llvm {
class VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter { class VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
public: public:
explicit PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit PIC16AsmPrinter(TargetMachine &TM, MCStreamer &Streamer);
MCStreamer &Streamer);
private: private:
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "PIC16 Assembly Printer"; return "PIC16 Assembly Printer";

View File

@ -18,10 +18,10 @@
#include "llvm/GlobalVariable.h" #include "llvm/GlobalVariable.h"
#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunction.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/DebugLoc.h" #include "llvm/Support/DebugLoc.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
using namespace llvm; using namespace llvm;
/// PopulateDebugInfo - Populate the TypeNo, Aux[] and TagName from Ty. /// PopulateDebugInfo - Populate the TypeNo, Aux[] and TagName from Ty.
@ -267,7 +267,8 @@ void PIC16DbgInfo::ChangeDebugLoc(const MachineFunction &MF,
/// ///
void PIC16DbgInfo::SwitchToLine(unsigned Line, bool IsInBeginFunction) { void PIC16DbgInfo::SwitchToLine(unsigned Line, bool IsInBeginFunction) {
if (CurLine == Line) return; if (CurLine == Line) return;
if (!IsInBeginFunction) O << "\n\t.line " << Line << "\n"; if (!IsInBeginFunction)
OS.EmitRawText("\n\t.line " + Twine(Line));
CurLine = Line; CurLine = Line;
} }
@ -286,7 +287,7 @@ void PIC16DbgInfo::EndFunction(const MachineFunction &MF) {
void PIC16DbgInfo::EndModule(Module &M) { void PIC16DbgInfo::EndModule(Module &M) {
if (! EmitDebugDirectives) return; if (! EmitDebugDirectives) return;
EmitVarDebugInfo(M); EmitVarDebugInfo(M);
if (CurFile != "") O << "\n\t.eof"; if (CurFile != "") OS.EmitRawText(StringRef("\n\t.eof"));
} }
/// EmitCompositeTypeElements - Emit debug information for members of a /// EmitCompositeTypeElements - Emit debug information for members of a
@ -410,22 +411,26 @@ void PIC16DbgInfo::EmitFunctEndDI(const Function *F, unsigned Line) {
/// ///
void PIC16DbgInfo::EmitAuxEntry(const std::string VarName, int Aux[], int Num, void PIC16DbgInfo::EmitAuxEntry(const std::string VarName, int Aux[], int Num,
std::string TagName) { std::string TagName) {
O << "\n\t.dim " << VarName << ", 1" ; std::string Tmp;
// TagName is emitted in case of structure/union objects. // TagName is emitted in case of structure/union objects.
if (TagName != "") if (!TagName.empty()) Tmp += ", " + TagName;
O << ", " << TagName;
for (int i = 0; i<Num; i++) for (int i = 0; i<Num; i++)
O << "," << (Aux[i] && 0xff); Tmp += "," + utostr(Aux[i] && 0xff);
OS.EmitRawText("\n\t.dim " + Twine(VarName) + ", 1" + Tmp);
} }
/// EmitSymbol - Emit .def for a symbol. Value is offset for the member. /// EmitSymbol - Emit .def for a symbol. Value is offset for the member.
/// ///
void PIC16DbgInfo::EmitSymbol(std::string Name, short Class, unsigned short void PIC16DbgInfo::EmitSymbol(std::string Name, short Class,
Type, unsigned long Value) { unsigned short Type, unsigned long Value) {
O << "\n\t" << ".def "<< Name << ", type = " << Type << ", class = " std::string Tmp;
<< Class;
if (Value > 0) if (Value > 0)
O << ", value = " << Value; Tmp = ", value = " + utostr(Value);
OS.EmitRawText("\n\t.def " + Twine(Name) + ", type = " + utostr(Type) +
", class = " + utostr(Class) + Tmp);
} }
/// EmitVarDebugInfo - Emit debug information for all variables. /// EmitVarDebugInfo - Emit debug information for all variables.
@ -447,14 +452,13 @@ void PIC16DbgInfo::EmitVarDebugInfo(Module &M) {
PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName); PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName);
// Emit debug info only if type information is availaible. // Emit debug info only if type information is availaible.
if (TypeNo != PIC16Dbg::T_NULL) { if (TypeNo != PIC16Dbg::T_NULL) {
O << "\n\t.type " << VarName << ", " << TypeNo; OS.EmitRawText("\t.type " + Twine(VarName) + ", " + Twine(TypeNo));
short ClassNo = getStorageClass(DIGV); short ClassNo = getStorageClass(DIGV);
O << "\n\t.class " << VarName << ", " << ClassNo; OS.EmitRawText("\t.class " + Twine(VarName) + ", " + Twine(ClassNo));
if (HasAux) if (HasAux)
EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName); EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName);
} }
} }
O << "\n";
} }
/// SwitchToCU - Switch to a new compilation unit. /// SwitchToCU - Switch to a new compilation unit.
@ -470,8 +474,9 @@ void PIC16DbgInfo::SwitchToCU(MDNode *CU) {
if ( FilePath == CurFile ) return; if ( FilePath == CurFile ) return;
// Else, close the current one and start a new. // Else, close the current one and start a new.
if (CurFile != "") O << "\n\t.eof"; if (CurFile != "")
O << "\n\t.file\t\"" << FilePath << "\"\n" ; OS.EmitRawText(StringRef("\t.eof"));
OS.EmitRawText("\n\t.file\t\"" + Twine(FilePath) + "\"");
CurFile = FilePath; CurFile = FilePath;
CurLine = 0; CurLine = 0;
} }
@ -480,6 +485,6 @@ void PIC16DbgInfo::SwitchToCU(MDNode *CU) {
/// ///
void PIC16DbgInfo::EmitEOF() { void PIC16DbgInfo::EmitEOF() {
if (CurFile != "") if (CurFile != "")
O << "\n\t.EOF"; OS.EmitRawText(StringRef("\t.EOF"));
} }

View File

@ -20,6 +20,8 @@
namespace llvm { namespace llvm {
class MachineFunction; class MachineFunction;
class DebugLoc; class DebugLoc;
class MCStreamer;
namespace PIC16Dbg { namespace PIC16Dbg {
enum VarType { enum VarType {
T_NULL, T_NULL,
@ -88,10 +90,8 @@ namespace llvm {
}; };
} }
class formatted_raw_ostream;
class PIC16DbgInfo { class PIC16DbgInfo {
formatted_raw_ostream &O; MCStreamer &OS;
const MCAsmInfo *MAI; const MCAsmInfo *MAI;
std::string CurFile; std::string CurFile;
unsigned CurLine; unsigned CurLine;
@ -101,8 +101,7 @@ namespace llvm {
bool EmitDebugDirectives; bool EmitDebugDirectives;
public: public:
PIC16DbgInfo(formatted_raw_ostream &o, const MCAsmInfo *T) PIC16DbgInfo(MCStreamer &os, const MCAsmInfo *T) : OS(os), MAI(T) {
: O(o), MAI(T) {
CurFile = ""; CurFile = "";
CurLine = 0; CurLine = 0;
EmitDebugDirectives = false; EmitDebugDirectives = false;

View File

@ -44,10 +44,8 @@
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h" #include "llvm/ADT/StringSet.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
@ -60,9 +58,8 @@ namespace {
const PPCSubtarget &Subtarget; const PPCSubtarget &Subtarget;
uint64_t LabelID; uint64_t LabelID;
public: public:
explicit PPCAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit PPCAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer),
: AsmPrinter(O, TM, Streamer),
Subtarget(TM.getSubtarget<PPCSubtarget>()), LabelID(0) {} Subtarget(TM.getSubtarget<PPCSubtarget>()), LabelID(0) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
@ -335,9 +332,8 @@ namespace {
/// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux /// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
class PPCLinuxAsmPrinter : public PPCAsmPrinter { class PPCLinuxAsmPrinter : public PPCAsmPrinter {
public: public:
explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit PPCLinuxAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : PPCAsmPrinter(TM, Streamer) {}
: PPCAsmPrinter(O, TM, Streamer) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "Linux PPC Assembly Printer"; return "Linux PPC Assembly Printer";
@ -358,11 +354,9 @@ namespace {
/// PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac /// PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac
/// OS X /// OS X
class PPCDarwinAsmPrinter : public PPCAsmPrinter { class PPCDarwinAsmPrinter : public PPCAsmPrinter {
formatted_raw_ostream &OS;
public: public:
explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit PPCDarwinAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : PPCAsmPrinter(TM, Streamer) {}
: PPCAsmPrinter(O, TM, Streamer), OS(O) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "Darwin PPC Assembly Printer"; return "Darwin PPC Assembly Printer";
@ -895,14 +889,13 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
/// for a MachineFunction to the given output stream, in a format that the /// for a MachineFunction to the given output stream, in a format that the
/// Darwin assembler can deal with. /// Darwin assembler can deal with.
/// ///
static AsmPrinter *createPPCAsmPrinterPass(formatted_raw_ostream &o, static AsmPrinter *createPPCAsmPrinterPass(TargetMachine &tm,
TargetMachine &tm,
MCStreamer &Streamer) { MCStreamer &Streamer) {
const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>(); const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
if (Subtarget->isDarwin()) if (Subtarget->isDarwin())
return new PPCDarwinAsmPrinter(o, tm, Streamer); return new PPCDarwinAsmPrinter(tm, Streamer);
return new PPCLinuxAsmPrinter(o, tm, Streamer); return new PPCLinuxAsmPrinter(tm, Streamer);
} }
// Force static initialization. // Force static initialization.

View File

@ -25,15 +25,14 @@
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;
namespace { namespace {
class SparcAsmPrinter : public AsmPrinter { class SparcAsmPrinter : public AsmPrinter {
public: public:
explicit SparcAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit SparcAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer) {}
: AsmPrinter(O, TM, Streamer) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "Sparc Assembly Printer"; return "Sparc Assembly Printer";

View File

@ -25,7 +25,6 @@
#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
@ -34,16 +33,14 @@
#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/FormattedStream.h"
using namespace llvm; using namespace llvm;
namespace { namespace {
class SystemZAsmPrinter : public AsmPrinter { class SystemZAsmPrinter : public AsmPrinter {
public: public:
SystemZAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, SystemZAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer) {}
: AsmPrinter(O, TM, Streamer) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "SystemZ Assembly Printer"; return "SystemZ Assembly Printer";
@ -172,8 +169,7 @@ void SystemZAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
} }
switch (MO.getTargetFlags()) { switch (MO.getTargetFlags()) {
default: default: assert(0 && "Unknown target flag on GV operand");
llvm_unreachable("Unknown target flag on GV operand");
case SystemZII::MO_NO_FLAG: case SystemZII::MO_NO_FLAG:
break; break;
case SystemZII::MO_GOTENT: O << "@GOTENT"; break; case SystemZII::MO_GOTENT: O << "@GOTENT"; break;

View File

@ -36,7 +36,6 @@
#include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/Mangler.h" #include "llvm/Target/Mangler.h"
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"

View File

@ -35,9 +35,8 @@ class MCSymbol;
class VISIBILITY_HIDDEN X86AsmPrinter : public AsmPrinter { class VISIBILITY_HIDDEN X86AsmPrinter : public AsmPrinter {
const X86Subtarget *Subtarget; const X86Subtarget *Subtarget;
public: public:
explicit X86AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit X86AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer) {
: AsmPrinter(O, TM, Streamer) {
Subtarget = &TM.getSubtarget<X86Subtarget>(); Subtarget = &TM.getSubtarget<X86Subtarget>();
} }

View File

@ -38,8 +38,7 @@
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
using namespace llvm; using namespace llvm;
@ -54,10 +53,8 @@ namespace {
class XCoreAsmPrinter : public AsmPrinter { class XCoreAsmPrinter : public AsmPrinter {
const XCoreSubtarget &Subtarget; const XCoreSubtarget &Subtarget;
public: public:
explicit XCoreAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, explicit XCoreAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
MCStreamer &Streamer) : AsmPrinter(TM, Streamer), Subtarget(TM.getSubtarget<XCoreSubtarget>()){}
: AsmPrinter(O, TM, Streamer),
Subtarget(TM.getSubtarget<XCoreSubtarget>()) {}
virtual const char *getPassName() const { virtual const char *getPassName() const {
return "XCore Assembly Printer"; return "XCore Assembly Printer";