1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Add a default implementation of createObjectStreamer.

This removes duplicated code from backends that don't need to do anything
fancy.

llvm-svn: 232658
This commit is contained in:
Rafael Espindola 2015-03-18 19:08:20 +00:00
parent 9be33ff87e
commit 5462815f32
5 changed files with 20 additions and 43 deletions

View File

@ -58,6 +58,10 @@ namespace llvm {
bool isVerboseAsm, bool useDwarfDirectory,
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
MCAsmBackend *TAB, bool ShowInst);
MCStreamer *createObjectStreamer(const Triple &T, MCContext &Ctx,
MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter,
const MCSubtargetInfo &STI, bool RelaxAll);
MCRelocationInfo *createMCRelocationInfo(StringRef TT, MCContext &Ctx);
@ -419,7 +423,8 @@ namespace llvm {
const MCSubtargetInfo &STI,
bool RelaxAll) const {
if (!MCObjectStreamerCtorFn)
return nullptr;
return llvm::createObjectStreamer(T, Ctx, TAB, OS, Emitter, STI,
RelaxAll);
return MCObjectStreamerCtorFn(T, Ctx, TAB, OS, Emitter, STI, RelaxAll);
}

View File

@ -20,6 +20,7 @@
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
@ -422,3 +423,16 @@ void MCObjectStreamer::FinishImpl() {
flushPendingLabels(nullptr);
getAssembler().Finish();
}
MCStreamer *llvm::createObjectStreamer(const Triple &T, MCContext &Ctx,
MCAsmBackend &TAB, raw_ostream &OS,
MCCodeEmitter *Emitter,
const MCSubtargetInfo &STI,
bool RelaxAll) {
switch (T.getObjectFormat()) {
default:
return nullptr;
case Triple::ELF:
return createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
}
}

View File

@ -47,15 +47,6 @@ static MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) {
return X;
}
static MCStreamer *
createHexagonELFStreamer(MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *CE,
bool RelaxAll) {
MCELFStreamer *ES = new MCELFStreamer(Context, MAB, OS, CE);
return ES;
}
static MCSubtargetInfo *
createHexagonMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS) {
MCSubtargetInfo *X = new MCSubtargetInfo();
@ -75,16 +66,6 @@ static MCAsmInfo *createHexagonMCAsmInfo(const MCRegisterInfo &MRI,
return MAI;
}
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
MCAsmBackend &MAB, raw_ostream &OS,
MCCodeEmitter *Emitter,
MCSubtargetInfo const &STI, bool RelaxAll) {
MCStreamer *ES = createHexagonELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
new MCTargetStreamer(*ES);
return ES;
}
static MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM,
CodeModel::Model CM,
CodeGenOpt::Level OL) {
@ -135,7 +116,4 @@ extern "C" void LLVMInitializeHexagonTargetMC() {
// Register the asm backend
TargetRegistry::RegisterMCAsmBackend(TheHexagonTarget,
createHexagonAsmBackend);
// Register the obj streamer
TargetRegistry::RegisterMCObjectStreamer(TheHexagonTarget, createMCStreamer);
}

View File

@ -73,13 +73,6 @@ static MCInstPrinter *createAMDGPUMCInstPrinter(const Target &T,
return new AMDGPUInstPrinter(MAI, MII, MRI);
}
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Ctx,
MCAsmBackend &MAB, raw_ostream &OS,
MCCodeEmitter *Emitter,
const MCSubtargetInfo &STI, bool RelaxAll) {
return createELFStreamer(Ctx, MAB, OS, Emitter, false);
}
extern "C" void LLVMInitializeR600TargetMC() {
RegisterMCAsmInfo<AMDGPUMCAsmInfo> Y(TheAMDGPUTarget);
@ -105,7 +98,4 @@ extern "C" void LLVMInitializeR600TargetMC() {
TargetRegistry::RegisterMCAsmBackend(TheAMDGPUTarget, createAMDGPUAsmBackend);
TargetRegistry::RegisterMCAsmBackend(TheGCNTarget, createAMDGPUAsmBackend);
TargetRegistry::RegisterMCObjectStreamer(TheAMDGPUTarget, createMCStreamer);
TargetRegistry::RegisterMCObjectStreamer(TheGCNTarget, createMCStreamer);
}

View File

@ -181,12 +181,6 @@ static MCInstPrinter *createSystemZMCInstPrinter(const Target &T,
return new SystemZInstPrinter(MAI, MII, MRI);
}
static MCStreamer *createSystemZMCObjectStreamer(
const Triple &T, MCContext &Ctx, MCAsmBackend &MAB, raw_ostream &OS,
MCCodeEmitter *Emitter, const MCSubtargetInfo &STI, bool RelaxAll) {
return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
}
extern "C" void LLVMInitializeSystemZTargetMC() {
// Register the MCAsmInfo.
TargetRegistry::RegisterMCAsmInfo(TheSystemZTarget,
@ -219,8 +213,4 @@ extern "C" void LLVMInitializeSystemZTargetMC() {
// Register the MCInstPrinter.
TargetRegistry::RegisterMCInstPrinter(TheSystemZTarget,
createSystemZMCInstPrinter);
// Register the MCObjectStreamer;
TargetRegistry::RegisterMCObjectStreamer(TheSystemZTarget,
createSystemZMCObjectStreamer);
}