mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Split the object streamer callback in one per file format.
There are two main advantages to doing this * Targets that only need to handle one of the formats specially don't have to worry about the others. For example, x86 now only registers a constructor for the COFF streamer. * Changes to the arguments passed to one format constructor will not impact the other formats. llvm-svn: 232699
This commit is contained in:
parent
9ae019b470
commit
dcba9c010c
@ -748,20 +748,6 @@ MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst);
|
||||
|
||||
/// Create a machine code streamer which will generate Mach-O format object
|
||||
/// files.
|
||||
///
|
||||
/// Takes ownership of \p TAB and \p CE.
|
||||
MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *CE,
|
||||
bool RelaxAll, bool LabelSections = false);
|
||||
|
||||
/// Create a machine code streamer which will generate ELF format object files.
|
||||
MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *CE,
|
||||
bool RelaxAll);
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
@ -58,10 +58,14 @@ 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);
|
||||
|
||||
/// Takes ownership of \p TAB and \p CE.
|
||||
MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *CE,
|
||||
bool RelaxAll);
|
||||
MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *CE,
|
||||
bool RelaxAll, bool LabelSections = false);
|
||||
|
||||
MCRelocationInfo *createMCRelocationInfo(StringRef TT, MCContext &Ctx);
|
||||
|
||||
@ -130,13 +134,25 @@ namespace llvm {
|
||||
typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
|
||||
const MCRegisterInfo &MRI,
|
||||
MCContext &Ctx);
|
||||
typedef MCStreamer *(*MCObjectStreamerCtorTy)(
|
||||
const Triple &T, MCContext &Ctx, MCAsmBackend &TAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter, const MCSubtargetInfo &STI, bool RelaxAll);
|
||||
typedef MCStreamer *(*ELFStreamerCtorTy)(const Triple &T, MCContext &Ctx,
|
||||
MCAsmBackend &TAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
bool RelaxAll);
|
||||
typedef MCStreamer *(*MachOStreamerCtorTy)(MCContext &Ctx,
|
||||
MCAsmBackend &TAB,
|
||||
raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
bool RelaxAll);
|
||||
typedef MCStreamer *(*COFFStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
|
||||
raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
bool RelaxAll);
|
||||
typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
|
||||
typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
|
||||
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
|
||||
bool IsVerboseAsm);
|
||||
typedef MCTargetStreamer *(*ObjectTargetStreamerCtorTy)(
|
||||
MCStreamer &S, const MCSubtargetInfo &STI);
|
||||
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
|
||||
MCContext &Ctx);
|
||||
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
|
||||
@ -213,9 +229,10 @@ namespace llvm {
|
||||
/// CodeEmitter, if registered.
|
||||
MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
|
||||
|
||||
/// MCObjectStreamerCtorFn - Construction function for this target's
|
||||
/// MCObjectStreamer, if registered.
|
||||
MCObjectStreamerCtorTy MCObjectStreamerCtorFn;
|
||||
// Construction functions for the various object formats, if registered.
|
||||
COFFStreamerCtorTy COFFStreamerCtorFn;
|
||||
MachOStreamerCtorTy MachOStreamerCtorFn;
|
||||
ELFStreamerCtorTy ELFStreamerCtorFn;
|
||||
|
||||
/// Construction function for this target's null TargetStreamer, if
|
||||
/// registered (default = nullptr).
|
||||
@ -225,6 +242,10 @@ namespace llvm {
|
||||
/// registered (default = nullptr).
|
||||
AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn;
|
||||
|
||||
/// Construction function for this target's obj TargetStreamer, if
|
||||
/// registered (default = nullptr).
|
||||
ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn;
|
||||
|
||||
/// MCRelocationInfoCtorFn - Construction function for this target's
|
||||
/// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
|
||||
MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
|
||||
@ -235,9 +256,10 @@ namespace llvm {
|
||||
|
||||
public:
|
||||
Target()
|
||||
: MCObjectStreamerCtorFn(nullptr), NullTargetStreamerCtorFn(nullptr),
|
||||
AsmTargetStreamerCtorFn(nullptr), MCRelocationInfoCtorFn(nullptr),
|
||||
MCSymbolizerCtorFn(nullptr) {}
|
||||
: COFFStreamerCtorFn(nullptr), MachOStreamerCtorFn(nullptr),
|
||||
ELFStreamerCtorFn(nullptr), NullTargetStreamerCtorFn(nullptr),
|
||||
AsmTargetStreamerCtorFn(nullptr), ObjectTargetStreamerCtorFn(nullptr),
|
||||
MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
|
||||
|
||||
/// @name Target Information
|
||||
/// @{
|
||||
@ -423,10 +445,30 @@ namespace llvm {
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI,
|
||||
bool RelaxAll) const {
|
||||
if (!MCObjectStreamerCtorFn)
|
||||
return llvm::createObjectStreamer(T, Ctx, TAB, OS, Emitter, STI,
|
||||
RelaxAll);
|
||||
return MCObjectStreamerCtorFn(T, Ctx, TAB, OS, Emitter, STI, RelaxAll);
|
||||
MCStreamer *S;
|
||||
switch (T.getObjectFormat()) {
|
||||
default:
|
||||
llvm_unreachable("Unknown object format");
|
||||
case Triple::COFF:
|
||||
assert(T.isOSWindows() && "only Windows COFF is supported");
|
||||
S = COFFStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll);
|
||||
break;
|
||||
case Triple::MachO:
|
||||
if (MachOStreamerCtorFn)
|
||||
S = MachOStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll);
|
||||
else
|
||||
S = createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
|
||||
break;
|
||||
case Triple::ELF:
|
||||
if (ELFStreamerCtorFn)
|
||||
S = ELFStreamerCtorFn(T, Ctx, TAB, OS, Emitter, RelaxAll);
|
||||
else
|
||||
S = createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
|
||||
break;
|
||||
}
|
||||
if (ObjectTargetStreamerCtorFn)
|
||||
ObjectTargetStreamerCtorFn(*S, STI);
|
||||
return S;
|
||||
}
|
||||
|
||||
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
@ -760,18 +802,17 @@ namespace llvm {
|
||||
T.MCCodeEmitterCtorFn = Fn;
|
||||
}
|
||||
|
||||
/// RegisterMCObjectStreamer - Register a object code MCStreamer
|
||||
/// implementation for the given target.
|
||||
///
|
||||
/// Clients are responsible for ensuring that registration doesn't occur
|
||||
/// while another thread is attempting to access the registry. Typically
|
||||
/// this is done by initializing all targets at program startup.
|
||||
///
|
||||
/// @param T - The target being registered.
|
||||
/// @param Fn - A function to construct an MCStreamer for the target.
|
||||
static void RegisterMCObjectStreamer(Target &T,
|
||||
Target::MCObjectStreamerCtorTy Fn) {
|
||||
T.MCObjectStreamerCtorFn = Fn;
|
||||
static void RegisterCOFFStreamer(Target &T, Target::COFFStreamerCtorTy Fn) {
|
||||
T.COFFStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
static void RegisterMachOStreamer(Target &T,
|
||||
Target::MachOStreamerCtorTy Fn) {
|
||||
T.MachOStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn) {
|
||||
T.ELFStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -784,6 +825,12 @@ namespace llvm {
|
||||
T.AsmTargetStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
static void
|
||||
RegisterObjectTargetStreamer(Target &T,
|
||||
Target::ObjectTargetStreamerCtorTy Fn) {
|
||||
T.ObjectTargetStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
||||
/// implementation for the given target.
|
||||
///
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ELF.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
@ -423,16 +423,3 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@ -214,9 +214,16 @@ MCELFStreamer *createAArch64ELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||
bool RelaxAll) {
|
||||
AArch64ELFStreamer *S = new AArch64ELFStreamer(Context, TAB, OS, Emitter);
|
||||
new AArch64TargetELFStreamer(*S);
|
||||
if (RelaxAll)
|
||||
S->getAssembler().setRelaxAll(true);
|
||||
return S;
|
||||
}
|
||||
|
||||
MCTargetStreamer *
|
||||
createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
|
||||
Triple TT(STI.getTargetTriple());
|
||||
if (TT.getObjectFormat() == Triple::ELF)
|
||||
return new AArch64TargetELFStreamer(S);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -123,17 +123,19 @@ static MCInstPrinter *createAArch64MCInstPrinter(const Target &T,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Ctx,
|
||||
MCAsmBackend &TAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI, bool RelaxAll) {
|
||||
if (T.isOSDarwin())
|
||||
return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll,
|
||||
/*LabelSections*/ true);
|
||||
|
||||
static MCStreamer *createELFStreamer(const Triple &T, MCContext &Ctx,
|
||||
MCAsmBackend &TAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter, bool RelaxAll) {
|
||||
return createAArch64ELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
|
||||
}
|
||||
|
||||
static MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||
bool RelaxAll) {
|
||||
return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll,
|
||||
/*LabelSections*/ true);
|
||||
}
|
||||
|
||||
// Force static initialization.
|
||||
extern "C" void LLVMInitializeAArch64TargetMC() {
|
||||
for (Target *T :
|
||||
@ -156,8 +158,13 @@ extern "C" void LLVMInitializeAArch64TargetMC() {
|
||||
// Register the MC Code Emitter
|
||||
TargetRegistry::RegisterMCCodeEmitter(*T, createAArch64MCCodeEmitter);
|
||||
|
||||
// Register the object streamer.
|
||||
TargetRegistry::RegisterMCObjectStreamer(*T, createMCStreamer);
|
||||
// Register the obj streamers.
|
||||
TargetRegistry::RegisterELFStreamer(*T, createELFStreamer);
|
||||
TargetRegistry::RegisterMachOStreamer(*T, createMachOStreamer);
|
||||
|
||||
// Register the obj target streamer.
|
||||
TargetRegistry::RegisterObjectTargetStreamer(
|
||||
*T, createAArch64ObjectTargetStreamer);
|
||||
|
||||
// Register the asm streamer.
|
||||
TargetRegistry::RegisterAsmTargetStreamer(*T,
|
||||
|
@ -31,6 +31,7 @@ class MCSubtargetInfo;
|
||||
class MCTargetStreamer;
|
||||
class StringRef;
|
||||
class Target;
|
||||
class Triple;
|
||||
class raw_ostream;
|
||||
|
||||
extern Target TheAArch64leTarget;
|
||||
@ -57,6 +58,10 @@ MCTargetStreamer *createAArch64AsmTargetStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm);
|
||||
|
||||
MCTargetStreamer *createAArch64ObjectTargetStreamer(MCStreamer &S,
|
||||
const MCSubtargetInfo &STI);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
// Defines symbolic names for AArch64 registers. This defines a mapping from
|
||||
|
@ -1374,11 +1374,18 @@ MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S) {
|
||||
return new ARMTargetStreamer(S);
|
||||
}
|
||||
|
||||
MCTargetStreamer *createARMObjectTargetStreamer(MCStreamer &S,
|
||||
const MCSubtargetInfo &STI) {
|
||||
Triple TT(STI.getTargetTriple());
|
||||
if (TT.getObjectFormat() == Triple::ELF)
|
||||
return new ARMTargetELFStreamer(S);
|
||||
return new ARMTargetStreamer(S);
|
||||
}
|
||||
|
||||
MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||
bool RelaxAll, bool 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.
|
||||
|
@ -298,25 +298,18 @@ static MCCodeGenInfo *createARMMCCodeGenInfo(StringRef TT, Reloc::Model RM,
|
||||
return X;
|
||||
}
|
||||
|
||||
// This is duplicated code. Refactor this.
|
||||
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Ctx,
|
||||
MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI, bool RelaxAll) {
|
||||
switch (T.getObjectFormat()) {
|
||||
default: llvm_unreachable("unsupported object format");
|
||||
case Triple::MachO: {
|
||||
MCStreamer *S = createMachOStreamer(Ctx, MAB, OS, Emitter, false);
|
||||
new ARMTargetStreamer(*S);
|
||||
return S;
|
||||
}
|
||||
case Triple::COFF:
|
||||
assert(T.isOSWindows() && "non-Windows ARM COFF is not supported");
|
||||
return createARMWinCOFFStreamer(Ctx, MAB, *Emitter, OS);
|
||||
case Triple::ELF:
|
||||
return createARMELFStreamer(Ctx, MAB, OS, Emitter, false,
|
||||
T.getArch() == Triple::thumb);
|
||||
}
|
||||
static MCStreamer *createELFStreamer(const Triple &T, MCContext &Ctx,
|
||||
MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter, bool RelaxAll) {
|
||||
return createARMELFStreamer(Ctx, MAB, OS, Emitter, false,
|
||||
T.getArch() == Triple::thumb);
|
||||
}
|
||||
|
||||
static MCStreamer *createARMMachOStreamer(MCContext &Ctx, MCAsmBackend &MAB,
|
||||
raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
bool RelaxAll) {
|
||||
return createMachOStreamer(Ctx, MAB, OS, Emitter, false);
|
||||
}
|
||||
|
||||
static MCInstPrinter *createARMMCInstPrinter(const Target &T,
|
||||
@ -401,8 +394,13 @@ extern "C" void LLVMInitializeARMTargetMC() {
|
||||
// Register the MC instruction analyzer.
|
||||
TargetRegistry::RegisterMCInstrAnalysis(*T, createARMMCInstrAnalysis);
|
||||
|
||||
// Register the object streamer.
|
||||
TargetRegistry::RegisterMCObjectStreamer(*T, createMCStreamer);
|
||||
TargetRegistry::RegisterELFStreamer(*T, createELFStreamer);
|
||||
TargetRegistry::RegisterCOFFStreamer(*T, createARMWinCOFFStreamer);
|
||||
TargetRegistry::RegisterMachOStreamer(*T, createARMMachOStreamer);
|
||||
|
||||
// Register the obj target streamer.
|
||||
TargetRegistry::RegisterObjectTargetStreamer(*T,
|
||||
createARMObjectTargetStreamer);
|
||||
|
||||
// Register the asm streamer.
|
||||
TargetRegistry::RegisterAsmTargetStreamer(*T, createARMTargetAsmStreamer);
|
||||
|
@ -32,6 +32,7 @@ class MCRelocationInfo;
|
||||
class MCTargetStreamer;
|
||||
class StringRef;
|
||||
class Target;
|
||||
class Triple;
|
||||
class raw_ostream;
|
||||
|
||||
extern Target TheARMLETarget, TheThumbLETarget;
|
||||
@ -52,6 +53,8 @@ MCTargetStreamer *createARMTargetAsmStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm);
|
||||
MCTargetStreamer *createARMObjectTargetStreamer(MCStreamer &S,
|
||||
const MCSubtargetInfo &STI);
|
||||
|
||||
MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
|
||||
const MCRegisterInfo &MRI,
|
||||
@ -77,10 +80,11 @@ MCAsmBackend *createThumbLEAsmBackend(const Target &T, const MCRegisterInfo &MRI
|
||||
MCAsmBackend *createThumbBEAsmBackend(const Target &T, const MCRegisterInfo &MRI,
|
||||
StringRef TT, StringRef CPU);
|
||||
|
||||
/// createARMWinCOFFStreamer - Construct a PE/COFF machine code streamer which
|
||||
/// will generate a PE/COFF object file.
|
||||
// Construct a PE/COFF machine code streamer which will generate a PE/COFF
|
||||
// object file.
|
||||
MCStreamer *createARMWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
|
||||
MCCodeEmitter &Emitter, raw_ostream &OS);
|
||||
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||
bool RelaxAll);
|
||||
|
||||
/// createARMELFObjectWriter - Construct an ELF Mach-O object writer.
|
||||
MCObjectWriter *createARMELFObjectWriter(raw_ostream &OS,
|
||||
|
@ -37,10 +37,10 @@ void ARMWinCOFFStreamer::EmitThumbFunc(MCSymbol *Symbol) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
MCStreamer *createARMWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
|
||||
MCCodeEmitter &Emitter, raw_ostream &OS) {
|
||||
return new ARMWinCOFFStreamer(Context, MAB, Emitter, OS);
|
||||
}
|
||||
MCStreamer *llvm::createARMWinCOFFStreamer(MCContext &Context,
|
||||
MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
bool RelaxAll) {
|
||||
return new ARMWinCOFFStreamer(Context, MAB, *Emitter, OS);
|
||||
}
|
||||
|
||||
|
@ -69,11 +69,9 @@ void MipsELFStreamer::EmitMipsOptionRecords() {
|
||||
I->EmitMipsOptionRecord();
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB,
|
||||
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI,
|
||||
bool RelaxAll) {
|
||||
return new MipsELFStreamer(Context, MAB, OS, Emitter, STI);
|
||||
}
|
||||
MCELFStreamer *llvm::createMipsELFStreamer(MCContext &Context,
|
||||
MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
bool RelaxAll) {
|
||||
return new MipsELFStreamer(Context, MAB, OS, Emitter);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class MipsELFStreamer : public MCELFStreamer {
|
||||
|
||||
public:
|
||||
MipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter, const MCSubtargetInfo &STI)
|
||||
MCCodeEmitter *Emitter)
|
||||
: MCELFStreamer(Context, MAB, OS, Emitter) {
|
||||
|
||||
RegInfoRecord = new MipsRegInfoRecord(this, Context);
|
||||
@ -69,6 +69,6 @@ public:
|
||||
|
||||
MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB,
|
||||
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI, bool RelaxAll);
|
||||
bool RelaxAll);
|
||||
} // namespace llvm.
|
||||
#endif
|
||||
|
@ -25,7 +25,6 @@ bool baseRegNeedsLoadStoreMask(unsigned Reg);
|
||||
MCELFStreamer *createMipsNaClELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
||||
raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI,
|
||||
bool RelaxAll);
|
||||
}
|
||||
|
||||
|
@ -108,14 +108,12 @@ static MCInstPrinter *createMipsMCInstPrinter(const Target &T,
|
||||
|
||||
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
|
||||
MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI, bool RelaxAll) {
|
||||
MCCodeEmitter *Emitter, bool RelaxAll) {
|
||||
MCStreamer *S;
|
||||
if (!T.isOSNaCl())
|
||||
S = createMipsELFStreamer(Context, MAB, OS, Emitter, STI, RelaxAll);
|
||||
S = createMipsELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
|
||||
else
|
||||
S = createMipsNaClELFStreamer(Context, MAB, OS, Emitter, STI, RelaxAll);
|
||||
new MipsTargetELFStreamer(*S, STI);
|
||||
S = createMipsNaClELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
|
||||
return S;
|
||||
}
|
||||
|
||||
@ -130,6 +128,11 @@ static MCTargetStreamer *createMipsNullTargetStreamer(MCStreamer &S) {
|
||||
return new MipsTargetStreamer(S);
|
||||
}
|
||||
|
||||
static MCTargetStreamer *
|
||||
createMipsObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
|
||||
return new MipsTargetELFStreamer(S, STI);
|
||||
}
|
||||
|
||||
extern "C" void LLVMInitializeMipsTargetMC() {
|
||||
for (Target *T : {&TheMipsTarget, &TheMipselTarget, &TheMips64Target,
|
||||
&TheMips64elTarget}) {
|
||||
@ -145,8 +148,8 @@ extern "C" void LLVMInitializeMipsTargetMC() {
|
||||
// Register the MC register info.
|
||||
TargetRegistry::RegisterMCRegInfo(*T, createMipsMCRegisterInfo);
|
||||
|
||||
// Register the object streamer.
|
||||
TargetRegistry::RegisterMCObjectStreamer(*T, createMCStreamer);
|
||||
// Register the elf streamer.
|
||||
TargetRegistry::RegisterELFStreamer(*T, createMCStreamer);
|
||||
|
||||
// Register the asm target streamer.
|
||||
TargetRegistry::RegisterAsmTargetStreamer(*T, createMipsAsmTargetStreamer);
|
||||
@ -159,6 +162,9 @@ extern "C" void LLVMInitializeMipsTargetMC() {
|
||||
|
||||
// Register the MCInstPrinter.
|
||||
TargetRegistry::RegisterMCInstPrinter(*T, createMipsMCInstPrinter);
|
||||
|
||||
TargetRegistry::RegisterObjectTargetStreamer(
|
||||
*T, createMipsObjectTargetStreamer);
|
||||
}
|
||||
|
||||
// Register the MC Code Emitter
|
||||
|
@ -37,8 +37,8 @@ const unsigned LoadStoreStackMaskReg = Mips::T7;
|
||||
class MipsNaClELFStreamer : public MipsELFStreamer {
|
||||
public:
|
||||
MipsNaClELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter, const MCSubtargetInfo &STI)
|
||||
: MipsELFStreamer(Context, TAB, OS, Emitter, STI), PendingCall(false) {}
|
||||
MCCodeEmitter *Emitter)
|
||||
: MipsELFStreamer(Context, TAB, OS, Emitter), PendingCall(false) {}
|
||||
|
||||
~MipsNaClELFStreamer() {}
|
||||
|
||||
@ -254,10 +254,8 @@ bool baseRegNeedsLoadStoreMask(unsigned Reg) {
|
||||
MCELFStreamer *createMipsNaClELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
||||
raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI,
|
||||
bool RelaxAll) {
|
||||
MipsNaClELFStreamer *S = new MipsNaClELFStreamer(Context, TAB, OS, Emitter,
|
||||
STI);
|
||||
MipsNaClELFStreamer *S = new MipsNaClELFStreamer(Context, TAB, OS, Emitter);
|
||||
if (RelaxAll)
|
||||
S->getAssembler().setRelaxAll(true);
|
||||
|
||||
|
@ -223,22 +223,6 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
// This is duplicated code. Refactor this.
|
||||
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Ctx,
|
||||
MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI, bool RelaxAll) {
|
||||
if (T.isOSDarwin()) {
|
||||
MCStreamer *S = createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
|
||||
new PPCTargetMachOStreamer(*S);
|
||||
return S;
|
||||
}
|
||||
|
||||
MCStreamer *S = createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
|
||||
new PPCTargetELFStreamer(*S);
|
||||
return S;
|
||||
}
|
||||
|
||||
static MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
@ -246,6 +230,14 @@ static MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S,
|
||||
return new PPCTargetAsmStreamer(S, OS);
|
||||
}
|
||||
|
||||
static MCTargetStreamer *
|
||||
createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
|
||||
Triple TT(STI.getTargetTriple());
|
||||
if (TT.getObjectFormat() == Triple::ELF)
|
||||
return new PPCTargetELFStreamer(S);
|
||||
return new PPCTargetMachOStreamer(S);
|
||||
}
|
||||
|
||||
static MCInstPrinter *createPPCMCInstPrinter(const Target &T,
|
||||
unsigned SyntaxVariant,
|
||||
const MCAsmInfo &MAI,
|
||||
@ -279,8 +271,9 @@ extern "C" void LLVMInitializePowerPCTargetMC() {
|
||||
// Register the asm backend.
|
||||
TargetRegistry::RegisterMCAsmBackend(*T, createPPCAsmBackend);
|
||||
|
||||
// Register the object streamer.
|
||||
TargetRegistry::RegisterMCObjectStreamer(*T, createMCStreamer);
|
||||
// Register the object target streamer.
|
||||
TargetRegistry::RegisterObjectTargetStreamer(*T,
|
||||
createObjectTargetStreamer);
|
||||
|
||||
// Register the asm target streamer.
|
||||
TargetRegistry::RegisterAsmTargetStreamer(*T, createAsmTargetStreamer);
|
||||
|
@ -122,13 +122,9 @@ static MCCodeGenInfo *createSparcV9MCCodeGenInfo(StringRef TT, Reloc::Model RM,
|
||||
return X;
|
||||
}
|
||||
|
||||
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
|
||||
MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI, bool RelaxAll) {
|
||||
MCStreamer *S = createELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
|
||||
new SparcTargetELFStreamer(*S);
|
||||
return S;
|
||||
static MCTargetStreamer *
|
||||
createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
|
||||
return new SparcTargetELFStreamer(S);
|
||||
}
|
||||
|
||||
static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
|
||||
@ -168,8 +164,9 @@ extern "C" void LLVMInitializeSparcTargetMC() {
|
||||
// Register the asm backend.
|
||||
TargetRegistry::RegisterMCAsmBackend(*T, createSparcAsmBackend);
|
||||
|
||||
// Register the object streamer.
|
||||
TargetRegistry::RegisterMCObjectStreamer(*T, createMCStreamer);
|
||||
// Register the object target streamer.
|
||||
TargetRegistry::RegisterObjectTargetStreamer(*T,
|
||||
createObjectTargetStreamer);
|
||||
|
||||
// Register the asm streamer.
|
||||
TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer);
|
||||
|
@ -344,22 +344,6 @@ static MCCodeGenInfo *createX86MCCodeGenInfo(StringRef TT, Reloc::Model RM,
|
||||
return X;
|
||||
}
|
||||
|
||||
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Ctx,
|
||||
MCAsmBackend &MAB, raw_ostream &OS,
|
||||
MCCodeEmitter *Emitter,
|
||||
const MCSubtargetInfo &STI, bool RelaxAll) {
|
||||
switch (T.getObjectFormat()) {
|
||||
default: llvm_unreachable("unsupported object format");
|
||||
case Triple::MachO:
|
||||
return createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
|
||||
case Triple::COFF:
|
||||
assert(T.isOSWindows() && "only Windows COFF is supported");
|
||||
return createX86WinCOFFStreamer(Ctx, MAB, Emitter, OS, RelaxAll);
|
||||
case Triple::ELF:
|
||||
return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
|
||||
}
|
||||
}
|
||||
|
||||
static MCInstPrinter *createX86MCInstPrinter(const Target &T,
|
||||
unsigned SyntaxVariant,
|
||||
const MCAsmInfo &MAI,
|
||||
@ -414,7 +398,7 @@ extern "C" void LLVMInitializeX86TargetMC() {
|
||||
TargetRegistry::RegisterMCCodeEmitter(*T, createX86MCCodeEmitter);
|
||||
|
||||
// Register the object streamer.
|
||||
TargetRegistry::RegisterMCObjectStreamer(*T, createMCStreamer);
|
||||
TargetRegistry::RegisterCOFFStreamer(*T, createX86WinCOFFStreamer);
|
||||
|
||||
// Register the MCInstPrinter.
|
||||
TargetRegistry::RegisterMCInstPrinter(*T, createX86MCInstPrinter);
|
||||
|
@ -85,12 +85,12 @@ MCAsmBackend *createX86_32AsmBackend(const Target &T, const MCRegisterInfo &MRI,
|
||||
MCAsmBackend *createX86_64AsmBackend(const Target &T, const MCRegisterInfo &MRI,
|
||||
StringRef TT, StringRef CPU);
|
||||
|
||||
/// createX86WinCOFFStreamer - Construct an X86 Windows COFF machine code
|
||||
/// streamer which will generate PE/COFF format object files.
|
||||
/// Construct an X86 Windows COFF machine code streamer which will generate
|
||||
/// PE/COFF format object files.
|
||||
///
|
||||
/// Takes ownership of \p AB and \p CE.
|
||||
MCStreamer *createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
|
||||
MCCodeEmitter *CE, raw_ostream &OS,
|
||||
raw_ostream &OS, MCCodeEmitter *CE,
|
||||
bool RelaxAll);
|
||||
|
||||
/// createX86MachObjectWriter - Construct an X86 Mach-O object writer.
|
||||
|
@ -48,13 +48,11 @@ void X86WinCOFFStreamer::FinishImpl() {
|
||||
}
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
MCStreamer *createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
|
||||
MCCodeEmitter *CE, raw_ostream &OS,
|
||||
bool RelaxAll) {
|
||||
MCStreamer *llvm::createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
|
||||
raw_ostream &OS, MCCodeEmitter *CE,
|
||||
bool RelaxAll) {
|
||||
X86WinCOFFStreamer *S = new X86WinCOFFStreamer(C, AB, CE, OS);
|
||||
S->getAssembler().setRelaxAll(RelaxAll);
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user