Construct the MCStreamer before constructing the MCTargetStreamer.

This has a few advantages:
* Only targets that use a MCTargetStreamer have to worry about it.
* There is never a MCTargetStreamer without a MCStreamer, so we can use a
  reference.
* A MCTargetStreamer can talk to the MCStreamer in its constructor.

llvm-svn: 200129
This commit is contained in:
Rafael Espindola 2014-01-26 06:06:37 +00:00
parent 56c4611340
commit 24ea09ef7d
26 changed files with 137 additions and 118 deletions

View File

@ -29,16 +29,15 @@ class raw_ostream;
class MCELFStreamer : public MCObjectStreamer {
public:
MCELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter)
: MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter),
SeenIdent(false) {}
MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter)
: MCObjectStreamer(Context, TAB, OS, Emitter),
SeenIdent(false) {}
MCELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter,
MCAssembler *Assembler)
: MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter, Assembler),
SeenIdent(false) {}
MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter, MCAssembler *Assembler)
: MCObjectStreamer(Context, TAB, OS, Emitter, Assembler),
SeenIdent(false) {}
virtual ~MCELFStreamer();

View File

@ -40,12 +40,10 @@ class MCObjectStreamer : public MCStreamer {
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame);
protected:
MCObjectStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
MCAsmBackend &TAB, raw_ostream &_OS,
MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS,
MCCodeEmitter *_Emitter);
MCObjectStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
MCAsmBackend &TAB, raw_ostream &_OS, MCCodeEmitter *_Emitter,
MCAssembler *_Assembler);
MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS,
MCCodeEmitter *_Emitter, MCAssembler *_Assembler);
~MCObjectStreamer();
public:

View File

@ -67,11 +67,11 @@ typedef std::pair<const MCSection *, const MCExpr *> MCSectionSubPair;
/// be treated differently. Callers should always talk to a FooTargetStreamer.
class MCTargetStreamer {
protected:
MCStreamer *Streamer;
MCStreamer &Streamer;
public:
MCTargetStreamer(MCStreamer &S);
virtual ~MCTargetStreamer();
void setStreamer(MCStreamer *S) { Streamer = S; }
// Allow a target to add behavior to the EmitLabel of MCStreamer.
virtual void emitLabel(MCSymbol *Symbol);
@ -82,6 +82,8 @@ public:
class ARMTargetStreamer : public MCTargetStreamer {
virtual void anchor();
public:
ARMTargetStreamer(MCStreamer &S);
virtual void emitFnStart() = 0;
virtual void emitFnEnd() = 0;
virtual void emitCantUnwind() = 0;
@ -147,7 +149,7 @@ class MCStreamer {
SmallVector<std::pair<MCSectionSubPair, MCSectionSubPair>, 4> SectionStack;
protected:
MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer);
MCStreamer(MCContext &Ctx);
const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A,
const MCSymbol *B);
@ -170,6 +172,10 @@ protected:
public:
virtual ~MCStreamer();
void setTargetStreamer(MCTargetStreamer *TS) {
TargetStreamer.reset(TS);
}
/// State management
///
virtual void reset();
@ -708,9 +714,9 @@ MCStreamer *createNullStreamer(MCContext &Ctx);
///
/// \param ShowInst - Whether to show the MCInst representation inline with
/// the assembly.
MCStreamer *createAsmStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer,
formatted_raw_ostream &OS, bool isVerboseAsm,
bool useLoc, bool useCFI, bool useDwarfDirectory,
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
bool isVerboseAsm, bool useLoc, bool useCFI,
bool useDwarfDirectory,
MCInstPrinter *InstPrint = 0,
MCCodeEmitter *CE = 0, MCAsmBackend *TAB = 0,
bool ShowInst = false);
@ -733,9 +739,8 @@ MCStreamer *createWinCOFFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
/// createELFStreamer - Create a machine code streamer which will generate
/// ELF format object files.
MCStreamer *createELFStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer,
MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *CE, bool RelaxAll,
MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *CE, bool RelaxAll,
bool NoExecStack);
/// createPureStreamer - Create a machine code streamer which will generate

View File

@ -46,13 +46,11 @@ namespace llvm {
class MCRelocationInfo;
class MCTargetAsmParser;
class TargetMachine;
class MCTargetStreamer;
class TargetOptions;
class raw_ostream;
class formatted_raw_ostream;
MCStreamer *createAsmStreamer(MCContext &Ctx,
MCTargetStreamer *TargetStreamer,
formatted_raw_ostream &OS, bool isVerboseAsm,
bool useLoc, bool useCFI,
bool useDwarfDirectory,
@ -443,7 +441,7 @@ namespace llvm {
return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB,
ShowInst);
return llvm::createAsmStreamer(Ctx, 0, OS, isVerboseAsm, useLoc, useCFI,
return llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB,
ShowInst);
}

View File

@ -623,7 +623,7 @@ namespace {
return Symbols.end();
}
RecordStreamer(MCContext &Context) : MCStreamer(Context, 0) {}
RecordStreamer(MCContext &Context) : MCStreamer(Context) {}
virtual void EmitInstruction(const MCInst &Inst) {
// Scan for values.

View File

@ -66,11 +66,11 @@ private:
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame);
public:
MCAsmStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
formatted_raw_ostream &os, bool isVerboseAsm, bool useLoc,
bool useCFI, bool useDwarfDirectory, MCInstPrinter *printer,
MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
bool isVerboseAsm, bool useLoc, bool useCFI,
bool useDwarfDirectory, MCInstPrinter *printer,
MCCodeEmitter *emitter, MCAsmBackend *asmbackend, bool showInst)
: MCStreamer(Context, TargetStreamer), OS(os), MAI(Context.getAsmInfo()),
: MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend),
CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
ShowInst(showInst), UseLoc(useLoc), UseCFI(useCFI),
@ -1381,12 +1381,11 @@ void MCAsmStreamer::FinishImpl() {
}
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
MCTargetStreamer *TargetStreamer,
formatted_raw_ostream &OS,
bool isVerboseAsm, bool useLoc, bool useCFI,
bool useDwarfDirectory, MCInstPrinter *IP,
MCCodeEmitter *CE, MCAsmBackend *MAB,
bool ShowInst) {
return new MCAsmStreamer(Context, TargetStreamer, OS, isVerboseAsm, useLoc,
return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
useCFI, useDwarfDirectory, IP, CE, MAB, ShowInst);
}

View File

@ -543,12 +543,10 @@ void MCELFStreamer::FinishImpl() {
this->MCObjectStreamer::FinishImpl();
}
MCStreamer *llvm::createELFStreamer(MCContext &Context,
MCTargetStreamer *Streamer,
MCAsmBackend &MAB, raw_ostream &OS,
MCCodeEmitter *CE, bool RelaxAll,
bool NoExecStack) {
MCELFStreamer *S = new MCELFStreamer(Context, Streamer, MAB, OS, CE);
MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *CE,
bool RelaxAll, bool NoExecStack) {
MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
if (NoExecStack)

View File

@ -38,7 +38,7 @@ private:
public:
MCMachOStreamer(MCContext &Context, MCAsmBackend &MAB, raw_ostream &OS,
MCCodeEmitter *Emitter)
: MCObjectStreamer(Context, 0, MAB, OS, Emitter) {}
: MCObjectStreamer(Context, MAB, OS, Emitter) {}
/// @name MCStreamer Interface
/// @{

View File

@ -19,7 +19,7 @@ namespace {
class MCNullStreamer : public MCStreamer {
public:
MCNullStreamer(MCContext &Context) : MCStreamer(Context, 0) {}
MCNullStreamer(MCContext &Context) : MCStreamer(Context) {}
/// @name MCStreamer Interface
/// @{

View File

@ -22,22 +22,17 @@
#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
MCObjectStreamer::MCObjectStreamer(MCContext &Context,
MCTargetStreamer *TargetStreamer,
MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter_)
: MCStreamer(Context, TargetStreamer),
MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter_)
: MCStreamer(Context),
Assembler(new MCAssembler(Context, TAB, *Emitter_,
*TAB.createObjectWriter(OS), OS)),
CurSectionData(0) {}
MCObjectStreamer::MCObjectStreamer(MCContext &Context,
MCTargetStreamer *TargetStreamer,
MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter_,
MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter_,
MCAssembler *_Assembler)
: MCStreamer(Context, TargetStreamer), Assembler(_Assembler),
CurSectionData(0) {}
: MCStreamer(Context), Assembler(_Assembler), CurSectionData(0) {}
MCObjectStreamer::~MCObjectStreamer() {
delete &Assembler->getBackend();

View File

@ -29,7 +29,7 @@ private:
public:
MCPureStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter)
: MCObjectStreamer(Context, 0, TAB, OS, Emitter) {}
: MCObjectStreamer(Context, TAB, OS, Emitter) {}
/// @name MCStreamer Interface
/// @{

View File

@ -25,14 +25,17 @@ using namespace llvm;
// Pin the vtables to this file.
MCTargetStreamer::~MCTargetStreamer() {}
MCTargetStreamer::MCTargetStreamer(MCStreamer &S) : Streamer(S) {
S.setTargetStreamer(this);
}
void MCTargetStreamer::emitLabel(MCSymbol *Symbol) {}
MCStreamer::MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer)
: Context(Ctx), TargetStreamer(TargetStreamer), EmitEHFrame(true),
EmitDebugFrame(false), CurrentW64UnwindInfo(0), LastSymbol(0) {
MCStreamer::MCStreamer(MCContext &Ctx)
: Context(Ctx), EmitEHFrame(true), EmitDebugFrame(false),
CurrentW64UnwindInfo(0), LastSymbol(0) {
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
if (TargetStreamer)
TargetStreamer->setStreamer(this);
}
MCStreamer::~MCStreamer() {

View File

@ -99,7 +99,7 @@ private:
WinCOFFStreamer::WinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
MCCodeEmitter &CE, raw_ostream &OS)
: MCObjectStreamer(Context, 0, MAB, OS, &CE), CurSymbol(NULL) {}
: MCObjectStreamer(Context, MAB, OS, &CE), CurSymbol(NULL) {}
void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment, bool External) {

View File

@ -57,7 +57,7 @@ class AArch64ELFStreamer : public MCELFStreamer {
public:
AArch64ELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter)
: MCELFStreamer(Context, 0, TAB, OS, Emitter), MappingSymbolCounter(0),
: MCELFStreamer(Context, TAB, OS, Emitter), MappingSymbolCounter(0),
LastEMS(EMS_None) {}
~AArch64ELFStreamer() {}

View File

@ -105,6 +105,7 @@ static unsigned GetArchDefaultCPUArch(unsigned ID) {
}
void ARMTargetStreamer::anchor() {}
ARMTargetStreamer::ARMTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
namespace {
@ -139,14 +140,16 @@ class ARMTargetAsmStreamer : public ARMTargetStreamer {
virtual void finishAttributeSection();
public:
ARMTargetAsmStreamer(formatted_raw_ostream &OS, MCInstPrinter &InstPrinter,
bool VerboseAsm);
ARMTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS,
MCInstPrinter &InstPrinter, bool VerboseAsm);
};
ARMTargetAsmStreamer::ARMTargetAsmStreamer(formatted_raw_ostream &OS,
ARMTargetAsmStreamer::ARMTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS,
MCInstPrinter &InstPrinter,
bool VerboseAsm)
: OS(OS), InstPrinter(InstPrinter), IsVerboseAsm(VerboseAsm) {}
: ARMTargetStreamer(S), OS(OS), InstPrinter(InstPrinter),
IsVerboseAsm(VerboseAsm) {}
void ARMTargetAsmStreamer::emitFnStart() { OS << "\t.fnstart\n"; }
void ARMTargetAsmStreamer::emitFnEnd() { OS << "\t.fnend\n"; }
void ARMTargetAsmStreamer::emitCantUnwind() { OS << "\t.cantunwind\n"; }
@ -397,10 +400,9 @@ private:
size_t calculateContentSize() const;
public:
ARMTargetELFStreamer()
: ARMTargetStreamer(), CurrentVendor("aeabi"), FPU(ARM::INVALID_FPU),
Arch(ARM::INVALID_ARCH), AttributeSection(0) {
}
ARMTargetELFStreamer(MCStreamer &S)
: ARMTargetStreamer(S), CurrentVendor("aeabi"), FPU(ARM::INVALID_FPU),
Arch(ARM::INVALID_ARCH), AttributeSection(0) {}
};
/// Extend the generic ELFStreamer class so that it can emit mapping symbols at
@ -419,11 +421,10 @@ class ARMELFStreamer : public MCELFStreamer {
public:
friend class ARMTargetELFStreamer;
ARMELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter,
bool IsThumb)
: MCELFStreamer(Context, TargetStreamer, TAB, OS, Emitter),
IsThumb(IsThumb), MappingSymbolCounter(0), LastEMS(EMS_None) {
ARMELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter, bool IsThumb)
: MCELFStreamer(Context, TAB, OS, Emitter), IsThumb(IsThumb),
MappingSymbolCounter(0), LastEMS(EMS_None) {
Reset();
}
@ -627,8 +628,7 @@ private:
} // end anonymous namespace
ARMELFStreamer &ARMTargetELFStreamer::getStreamer() {
ARMELFStreamer *S = static_cast<ARMELFStreamer *>(Streamer);
return *S;
return static_cast<ARMELFStreamer &>(Streamer);
}
void ARMTargetELFStreamer::emitFnStart() { getStreamer().emitFnStart(); }
@ -1237,21 +1237,19 @@ MCStreamer *createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
bool useDwarfDirectory,
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
MCAsmBackend *TAB, bool ShowInst) {
ARMTargetAsmStreamer *S = new ARMTargetAsmStreamer(OS, *InstPrint,
isVerboseAsm);
return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB,
ShowInst);
MCStreamer *S =
llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
new ARMTargetAsmStreamer(*S, OS, *InstPrint, isVerboseAsm);
return S;
}
MCELFStreamer* createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter,
bool RelaxAll, bool NoExecStack,
bool IsThumb) {
ARMTargetELFStreamer *TS = new ARMTargetELFStreamer();
ARMELFStreamer *S =
new ARMELFStreamer(Context, TS, TAB, OS, Emitter, IsThumb);
ARMELFStreamer *S = new ARMELFStreamer(Context, TAB, OS, Emitter, IsThumb);
new ARMTargetELFStreamer(*S);
// FIXME: This should eventually end up somewhere else where more
// intelligent flag decisions can be made. For now we are just maintaining
// the status quo for ARM and setting EF_ARM_EABI_VER5 as the default.

View File

@ -131,8 +131,10 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *Emitter,
bool RelaxAll, bool NoExecStack) {
MipsTargetELFStreamer *S = new MipsTargetELFStreamer();
return createELFStreamer(Context, S, MAB, OS, Emitter, RelaxAll, NoExecStack);
MCStreamer *S =
createELFStreamer(Context, MAB, OS, Emitter, RelaxAll, NoExecStack);
new MipsTargetELFStreamer(*S);
return S;
}
static MCStreamer *
@ -140,11 +142,11 @@ createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
bool isVerboseAsm, bool useLoc, bool useCFI,
bool useDwarfDirectory, MCInstPrinter *InstPrint,
MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) {
MipsTargetAsmStreamer *S = new MipsTargetAsmStreamer(OS);
return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB,
ShowInst);
MCStreamer *S =
llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
new MipsTargetAsmStreamer(*S, OS);
return S;
}
extern "C" void LLVMInitializeMipsTargetMC() {

View File

@ -27,8 +27,11 @@ static cl::opt<bool> PrintHackDirectives("print-hack-directives",
// Pin vtable to this file.
void MipsTargetStreamer::anchor() {}
MipsTargetAsmStreamer::MipsTargetAsmStreamer(formatted_raw_ostream &OS)
: OS(OS) {}
MipsTargetStreamer::MipsTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
MipsTargetAsmStreamer::MipsTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS)
: MipsTargetStreamer(S), OS(OS) {}
void MipsTargetAsmStreamer::emitMipsHackELFFlags(unsigned Flags) {
if (!PrintHackDirectives)
@ -93,7 +96,8 @@ void MipsTargetAsmStreamer::emitDirectiveOptionPic0() {
}
// This part is for ELF object output.
MipsTargetELFStreamer::MipsTargetELFStreamer() : MicroMipsEnabled(false) {}
MipsTargetELFStreamer::MipsTargetELFStreamer(MCStreamer &S)
: MipsTargetStreamer(S), MicroMipsEnabled(false) {}
void MipsTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
if (!isMicroMipsEnabled())
@ -110,7 +114,7 @@ void MipsTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
}
MCELFStreamer &MipsTargetELFStreamer::getStreamer() {
return static_cast<MCELFStreamer &>(*Streamer);
return static_cast<MCELFStreamer &>(Streamer);
}
void MipsTargetELFStreamer::emitMipsHackELFFlags(unsigned Flags) {

View File

@ -18,6 +18,7 @@ class MipsTargetStreamer : public MCTargetStreamer {
virtual void anchor();
public:
MipsTargetStreamer(MCStreamer &S);
virtual void emitMipsHackELFFlags(unsigned Flags) = 0;
virtual void emitDirectiveSetMicroMips() = 0;
virtual void emitDirectiveSetNoMicroMips() = 0;
@ -42,7 +43,7 @@ class MipsTargetAsmStreamer : public MipsTargetStreamer {
formatted_raw_ostream &OS;
public:
MipsTargetAsmStreamer(formatted_raw_ostream &OS);
MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
virtual void emitMipsHackELFFlags(unsigned Flags);
virtual void emitDirectiveSetMicroMips();
virtual void emitDirectiveSetNoMicroMips();
@ -69,7 +70,7 @@ class MipsTargetELFStreamer : public MipsTargetStreamer {
public:
bool isMicroMipsEnabled() const { return MicroMipsEnabled; }
MCELFStreamer &getStreamer();
MipsTargetELFStreamer();
MipsTargetELFStreamer(MCStreamer &S);
virtual void emitLabel(MCSymbol *Symbol) LLVM_OVERRIDE;

View File

@ -39,6 +39,7 @@ using namespace llvm;
// Pin the vtable to this file.
PPCTargetStreamer::~PPCTargetStreamer() {}
PPCTargetStreamer::PPCTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
static MCInstrInfo *createPPCMCInstrInfo() {
MCInstrInfo *X = new MCInstrInfo();
@ -112,7 +113,8 @@ class PPCTargetAsmStreamer : public PPCTargetStreamer {
formatted_raw_ostream &OS;
public:
PPCTargetAsmStreamer(formatted_raw_ostream &OS) : OS(OS) {}
PPCTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
: PPCTargetStreamer(S), OS(OS) {}
virtual void emitTCEntry(const MCSymbol &S) {
OS << "\t.tc ";
OS << S.getName();
@ -126,9 +128,11 @@ public:
};
class PPCTargetELFStreamer : public PPCTargetStreamer {
public:
PPCTargetELFStreamer(MCStreamer &S) : PPCTargetStreamer(S) {}
virtual void emitTCEntry(const MCSymbol &S) {
// Creates a R_PPC64_TOC relocation
Streamer->EmitSymbolValue(&S, 8);
Streamer.EmitSymbolValue(&S, 8);
}
virtual void emitMachine(StringRef CPU) {
// FIXME: Is there anything to do in here or does this directive only
@ -147,8 +151,10 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
if (Triple(TT).isOSDarwin())
return createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
PPCTargetStreamer *S = new PPCTargetELFStreamer();
return createELFStreamer(Ctx, S, MAB, OS, Emitter, RelaxAll, NoExecStack);
MCStreamer *S =
createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll, NoExecStack);
new PPCTargetELFStreamer(*S);
return S;
}
static MCStreamer *
@ -156,11 +162,12 @@ createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
bool isVerboseAsm, bool useLoc, bool useCFI,
bool useDwarfDirectory, MCInstPrinter *InstPrint,
MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) {
PPCTargetStreamer *S = new PPCTargetAsmStreamer(OS);
return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB,
ShowInst);
MCStreamer *S =
llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
new PPCTargetAsmStreamer(*S, OS);
return S;
}
static MCInstPrinter *createPPCMCInstPrinter(const Target &T,

View File

@ -15,6 +15,7 @@
namespace llvm {
class PPCTargetStreamer : public MCTargetStreamer {
public:
PPCTargetStreamer(MCStreamer &S);
virtual ~PPCTargetStreamer();
virtual void emitTCEntry(const MCSymbol &S) = 0;
virtual void emitMachine(StringRef CPU) = 0;

View File

@ -88,7 +88,7 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
MCCodeEmitter *_Emitter,
bool RelaxAll,
bool NoExecStack) {
return createELFStreamer(Ctx, 0, MAB, _OS, _Emitter, false, false);
return createELFStreamer(Ctx, MAB, _OS, _Emitter, false, false);
}
extern "C" void LLVMInitializeR600TargetMC() {

View File

@ -105,8 +105,10 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *Emitter,
bool RelaxAll, bool NoExecStack) {
SparcTargetELFStreamer *S = new SparcTargetELFStreamer();
return createELFStreamer(Context, S, MAB, OS, Emitter, RelaxAll, NoExecStack);
MCStreamer *S =
createELFStreamer(Context, MAB, OS, Emitter, RelaxAll, NoExecStack);
new SparcTargetELFStreamer(*S);
return S;
}
static MCStreamer *
@ -114,11 +116,12 @@ createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
bool isVerboseAsm, bool useLoc, bool useCFI,
bool useDwarfDirectory, MCInstPrinter *InstPrint,
MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) {
SparcTargetAsmStreamer *S = new SparcTargetAsmStreamer(OS);
return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB,
ShowInst);
MCStreamer *S =
llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
new SparcTargetAsmStreamer(*S, OS);
return S;
}
static MCInstPrinter *createSparcMCInstPrinter(const Target &T,

View File

@ -18,10 +18,13 @@
using namespace llvm;
// pin vtable to this file
SparcTargetStreamer::SparcTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
void SparcTargetStreamer::anchor() {}
SparcTargetAsmStreamer::SparcTargetAsmStreamer(formatted_raw_ostream &OS)
: OS(OS) {}
SparcTargetAsmStreamer::SparcTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS)
: SparcTargetStreamer(S), OS(OS) {}
void SparcTargetAsmStreamer::emitSparcRegisterIgnore(unsigned reg) {
OS << "\t.register "
@ -35,6 +38,9 @@ void SparcTargetAsmStreamer::emitSparcRegisterScratch(unsigned reg) {
<< ", #scratch\n";
}
SparcTargetELFStreamer::SparcTargetELFStreamer(MCStreamer &S)
: SparcTargetStreamer(S) {}
MCELFStreamer &SparcTargetELFStreamer::getStreamer() {
return static_cast<MCELFStreamer &>(*Streamer);
return static_cast<MCELFStreamer &>(Streamer);
}

View File

@ -18,6 +18,7 @@ class SparcTargetStreamer : public MCTargetStreamer {
virtual void anchor();
public:
SparcTargetStreamer(MCStreamer &S);
/// Emit ".register <reg>, #ignore".
virtual void emitSparcRegisterIgnore(unsigned reg) = 0;
/// Emit ".register <reg>, #scratch".
@ -29,7 +30,7 @@ class SparcTargetAsmStreamer : public SparcTargetStreamer {
formatted_raw_ostream &OS;
public:
SparcTargetAsmStreamer(formatted_raw_ostream &OS);
SparcTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
virtual void emitSparcRegisterIgnore(unsigned reg);
virtual void emitSparcRegisterScratch(unsigned reg);
@ -38,6 +39,7 @@ public:
// This part is for ELF object output
class SparcTargetELFStreamer : public SparcTargetStreamer {
public:
SparcTargetELFStreamer(MCStreamer &S);
MCELFStreamer &getStreamer();
virtual void emitSparcRegisterIgnore(unsigned reg) {}
virtual void emitSparcRegisterScratch(unsigned reg) {}

View File

@ -187,7 +187,7 @@ static MCStreamer *createSystemZMCObjectStreamer(const Target &T, StringRef TT,
MCCodeEmitter *Emitter,
bool RelaxAll,
bool NoExecStack) {
return createELFStreamer(Ctx, 0, MAB, OS, Emitter, RelaxAll, NoExecStack);
return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll, NoExecStack);
}
extern "C" void LLVMInitializeSystemZTargetMC() {

View File

@ -371,7 +371,7 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
if (TheTriple.isOSWindows() && TheTriple.getEnvironment() != Triple::ELF)
return createWinCOFFStreamer(Ctx, MAB, *_Emitter, _OS, RelaxAll);
return createELFStreamer(Ctx, 0, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
}
static MCInstPrinter *createX86MCInstPrinter(const Target &T,