forked from OSchip/llvm-project
There is only one Asm streamer, there is no need for targets to register it.
Instead, have the targets register a TargetStreamer to be use with the asm streamer (if any). llvm-svn: 232423
This commit is contained in:
parent
a438717638
commit
73870dd438
|
@ -130,15 +130,10 @@ namespace llvm {
|
|||
const Target &T, StringRef TT, MCContext &Ctx, MCAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *Emitter, const MCSubtargetInfo &STI,
|
||||
bool RelaxAll);
|
||||
typedef MCStreamer *(*AsmStreamerCtorTy)(MCContext &Ctx,
|
||||
formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm,
|
||||
bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint,
|
||||
MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB,
|
||||
bool ShowInst);
|
||||
typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
|
||||
typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
|
||||
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
|
||||
bool IsVerboseAsm);
|
||||
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
|
||||
MCContext &Ctx);
|
||||
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
|
||||
|
@ -219,14 +214,14 @@ namespace llvm {
|
|||
/// MCObjectStreamer, if registered.
|
||||
MCObjectStreamerCtorTy MCObjectStreamerCtorFn;
|
||||
|
||||
/// AsmStreamerCtorFn - Construction function for this target's
|
||||
/// AsmStreamer, if registered (default = llvm::createAsmStreamer).
|
||||
AsmStreamerCtorTy AsmStreamerCtorFn;
|
||||
|
||||
/// Construction function for this target's null TargetStreamer, if
|
||||
/// registered (default = nullptr).
|
||||
NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
|
||||
|
||||
/// Construction function for this target's asm TargetStreamer, if
|
||||
/// registered (default = nullptr).
|
||||
AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn;
|
||||
|
||||
/// MCRelocationInfoCtorFn - Construction function for this target's
|
||||
/// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
|
||||
MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
|
||||
|
@ -237,8 +232,8 @@ namespace llvm {
|
|||
|
||||
public:
|
||||
Target()
|
||||
: AsmStreamerCtorFn(nullptr), MCRelocationInfoCtorFn(nullptr),
|
||||
MCSymbolizerCtorFn(nullptr) {}
|
||||
: NullTargetStreamerCtorFn(nullptr), AsmTargetStreamerCtorFn(nullptr),
|
||||
MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
|
||||
|
||||
/// @name Target Information
|
||||
/// @{
|
||||
|
@ -430,20 +425,24 @@ namespace llvm {
|
|||
RelaxAll);
|
||||
}
|
||||
|
||||
/// createAsmStreamer - Create a target specific MCStreamer.
|
||||
MCStreamer *createAsmStreamer(MCContext &Ctx,
|
||||
formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm,
|
||||
bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint,
|
||||
MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB,
|
||||
bool ShowInst) const {
|
||||
if (AsmStreamerCtorFn)
|
||||
return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useDwarfDirectory,
|
||||
InstPrint, CE, TAB, ShowInst);
|
||||
return llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useDwarfDirectory,
|
||||
InstPrint, CE, TAB, ShowInst);
|
||||
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool IsVerboseAsm, bool UseDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst) const {
|
||||
MCStreamer *S =
|
||||
llvm::createAsmStreamer(Ctx, OS, IsVerboseAsm, UseDwarfDirectory,
|
||||
InstPrint, CE, TAB, ShowInst);
|
||||
createAsmTargetStreamer(*S, OS, InstPrint, IsVerboseAsm);
|
||||
return S;
|
||||
}
|
||||
|
||||
MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool IsVerboseAsm) const {
|
||||
if (AsmTargetStreamerCtorFn)
|
||||
return AsmTargetStreamerCtorFn(S, OS, InstPrint, IsVerboseAsm);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MCStreamer *createNullStreamer(MCContext &Ctx) const {
|
||||
|
@ -771,24 +770,16 @@ namespace llvm {
|
|||
T.MCObjectStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
/// RegisterAsmStreamer - Register an assembly 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 RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) {
|
||||
T.AsmStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
static void
|
||||
RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn) {
|
||||
T.NullTargetStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
static void RegisterAsmTargetStreamer(Target &T,
|
||||
Target::AsmTargetStreamerCtorTy Fn) {
|
||||
T.AsmTargetStreamerCtorFn = Fn;
|
||||
}
|
||||
|
||||
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
||||
/// implementation for the given target.
|
||||
///
|
||||
|
|
|
@ -203,15 +203,11 @@ void AArch64TargetELFStreamer::emitInst(uint32_t Inst) {
|
|||
}
|
||||
|
||||
namespace llvm {
|
||||
MCStreamer *
|
||||
createAArch64MCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst) {
|
||||
MCStreamer *S = llvm::createAsmStreamer(
|
||||
Ctx, OS, isVerboseAsm, useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
|
||||
new AArch64TargetAsmStreamer(*S, OS);
|
||||
return S;
|
||||
MCTargetStreamer *createAArch64AsmTargetStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm) {
|
||||
return new AArch64TargetAsmStreamer(S, OS);
|
||||
}
|
||||
|
||||
MCELFStreamer *createAArch64ELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
||||
|
|
|
@ -199,12 +199,12 @@ extern "C" void LLVMInitializeAArch64TargetMC() {
|
|||
TargetRegistry::RegisterMCObjectStreamer(TheARM64Target, createMCStreamer);
|
||||
|
||||
// Register the asm streamer.
|
||||
TargetRegistry::RegisterAsmStreamer(TheAArch64leTarget,
|
||||
createAArch64MCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheAArch64beTarget,
|
||||
createAArch64MCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheARM64Target,
|
||||
createAArch64MCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheAArch64leTarget,
|
||||
createAArch64AsmTargetStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheAArch64beTarget,
|
||||
createAArch64AsmTargetStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheARM64Target,
|
||||
createAArch64AsmTargetStreamer);
|
||||
|
||||
// Register the MCInstPrinter.
|
||||
TargetRegistry::RegisterMCInstPrinter(TheAArch64leTarget,
|
||||
|
|
|
@ -28,6 +28,7 @@ class MCRegisterInfo;
|
|||
class MCObjectWriter;
|
||||
class MCStreamer;
|
||||
class MCSubtargetInfo;
|
||||
class MCTargetStreamer;
|
||||
class StringRef;
|
||||
class Target;
|
||||
class raw_ostream;
|
||||
|
@ -52,11 +53,10 @@ MCObjectWriter *createAArch64ELFObjectWriter(raw_ostream &OS, uint8_t OSABI,
|
|||
MCObjectWriter *createAArch64MachObjectWriter(raw_ostream &OS, uint32_t CPUType,
|
||||
uint32_t CPUSubtype);
|
||||
|
||||
MCStreamer *
|
||||
createAArch64MCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst);
|
||||
MCTargetStreamer *createAArch64AsmTargetStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm);
|
||||
} // End llvm namespace
|
||||
|
||||
// Defines symbolic names for AArch64 registers. This defines a mapping from
|
||||
|
|
|
@ -1362,14 +1362,11 @@ void ARMELFStreamer::emitUnwindRaw(int64_t Offset,
|
|||
|
||||
namespace llvm {
|
||||
|
||||
MCStreamer *createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst) {
|
||||
MCStreamer *S = llvm::createAsmStreamer(
|
||||
Ctx, OS, isVerboseAsm, useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
|
||||
new ARMTargetAsmStreamer(*S, OS, *InstPrint, isVerboseAsm);
|
||||
return S;
|
||||
MCTargetStreamer *createARMTargetAsmStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm) {
|
||||
return new ARMTargetAsmStreamer(S, OS, *InstPrint, isVerboseAsm);
|
||||
}
|
||||
|
||||
MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S) {
|
||||
|
|
|
@ -450,10 +450,14 @@ extern "C" void LLVMInitializeARMTargetMC() {
|
|||
TargetRegistry::RegisterMCObjectStreamer(TheThumbBETarget, createMCStreamer);
|
||||
|
||||
// Register the asm streamer.
|
||||
TargetRegistry::RegisterAsmStreamer(TheARMLETarget, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheARMBETarget, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheThumbLETarget, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheThumbBETarget, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheARMLETarget,
|
||||
createARMTargetAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheARMBETarget,
|
||||
createARMTargetAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheThumbLETarget,
|
||||
createARMTargetAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheThumbBETarget,
|
||||
createARMTargetAsmStreamer);
|
||||
|
||||
// Register the null TargetStreamer.
|
||||
TargetRegistry::RegisterNullTargetStreamer(TheARMLETarget,
|
||||
|
|
|
@ -47,12 +47,11 @@ namespace ARM_MC {
|
|||
StringRef FS);
|
||||
}
|
||||
|
||||
MCStreamer *createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst);
|
||||
|
||||
MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S);
|
||||
MCTargetStreamer *createARMTargetAsmStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm);
|
||||
|
||||
MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
|
||||
const MCRegisterInfo &MRI,
|
||||
|
|
|
@ -119,15 +119,11 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
|
|||
return S;
|
||||
}
|
||||
|
||||
static MCStreamer *
|
||||
createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst) {
|
||||
MCStreamer *S = llvm::createAsmStreamer(
|
||||
Ctx, OS, isVerboseAsm, useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
|
||||
new MipsTargetAsmStreamer(*S, OS);
|
||||
return S;
|
||||
static MCTargetStreamer *createMipsAsmTargetStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm) {
|
||||
return new MipsTargetAsmStreamer(S, OS);
|
||||
}
|
||||
|
||||
static MCTargetStreamer *createMipsNullTargetStreamer(MCStreamer &S) {
|
||||
|
@ -183,10 +179,14 @@ extern "C" void LLVMInitializeMipsTargetMC() {
|
|||
createMCStreamer);
|
||||
|
||||
// Register the asm streamer.
|
||||
TargetRegistry::RegisterAsmStreamer(TheMipsTarget, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheMipselTarget, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheMips64Target, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheMips64elTarget, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheMipsTarget,
|
||||
createMipsAsmTargetStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheMipselTarget,
|
||||
createMipsAsmTargetStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheMips64Target,
|
||||
createMipsAsmTargetStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheMips64elTarget,
|
||||
createMipsAsmTargetStreamer);
|
||||
|
||||
TargetRegistry::RegisterNullTargetStreamer(TheMipsTarget,
|
||||
createMipsNullTargetStreamer);
|
||||
|
|
|
@ -239,16 +239,11 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
|
|||
return S;
|
||||
}
|
||||
|
||||
static MCStreamer *
|
||||
createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst) {
|
||||
|
||||
MCStreamer *S = llvm::createAsmStreamer(
|
||||
Ctx, OS, isVerboseAsm, useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
|
||||
new PPCTargetAsmStreamer(*S, OS);
|
||||
return S;
|
||||
static MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm) {
|
||||
return new PPCTargetAsmStreamer(S, OS);
|
||||
}
|
||||
|
||||
static MCInstPrinter *createPPCMCInstPrinter(const Target &T,
|
||||
|
@ -309,9 +304,12 @@ extern "C" void LLVMInitializePowerPCTargetMC() {
|
|||
TargetRegistry::RegisterMCObjectStreamer(ThePPC64LETarget, createMCStreamer);
|
||||
|
||||
// Register the asm streamer.
|
||||
TargetRegistry::RegisterAsmStreamer(ThePPC32Target, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(ThePPC64Target, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(ThePPC64LETarget, createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(ThePPC32Target,
|
||||
createAsmTargetStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(ThePPC64Target,
|
||||
createAsmTargetStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(ThePPC64LETarget,
|
||||
createAsmTargetStreamer);
|
||||
|
||||
// Register the MCInstPrinter.
|
||||
TargetRegistry::RegisterMCInstPrinter(ThePPC32Target, createPPCMCInstPrinter);
|
||||
|
|
|
@ -131,16 +131,11 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
|
|||
return S;
|
||||
}
|
||||
|
||||
static MCStreamer *
|
||||
createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst) {
|
||||
|
||||
MCStreamer *S = llvm::createAsmStreamer(
|
||||
Ctx, OS, isVerboseAsm, useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
|
||||
new SparcTargetAsmStreamer(*S, OS);
|
||||
return S;
|
||||
static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm) {
|
||||
return new SparcTargetAsmStreamer(S, OS);
|
||||
}
|
||||
|
||||
static MCInstPrinter *createSparcMCInstPrinter(const Target &T,
|
||||
|
@ -197,10 +192,10 @@ extern "C" void LLVMInitializeSparcTargetMC() {
|
|||
createMCStreamer);
|
||||
|
||||
// Register the asm streamer.
|
||||
TargetRegistry::RegisterAsmStreamer(TheSparcTarget,
|
||||
createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmStreamer(TheSparcV9Target,
|
||||
createMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheSparcTarget,
|
||||
createTargetAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheSparcV9Target,
|
||||
createTargetAsmStreamer);
|
||||
|
||||
// Register the MCInstPrinter
|
||||
TargetRegistry::RegisterMCInstPrinter(TheSparcTarget,
|
||||
|
|
|
@ -126,15 +126,11 @@ void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
|
|||
}
|
||||
}
|
||||
|
||||
static MCStreamer *
|
||||
createXCoreMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||
bool isVerboseAsm, bool useDwarfDirectory,
|
||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||
MCAsmBackend *TAB, bool ShowInst) {
|
||||
MCStreamer *S = llvm::createAsmStreamer(
|
||||
Ctx, OS, isVerboseAsm, useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
|
||||
new XCoreTargetAsmStreamer(*S, OS);
|
||||
return S;
|
||||
static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
|
||||
formatted_raw_ostream &OS,
|
||||
MCInstPrinter *InstPrint,
|
||||
bool isVerboseAsm) {
|
||||
return new XCoreTargetAsmStreamer(S, OS);
|
||||
}
|
||||
|
||||
// Force static initialization.
|
||||
|
@ -160,5 +156,6 @@ extern "C" void LLVMInitializeXCoreTargetMC() {
|
|||
TargetRegistry::RegisterMCInstPrinter(TheXCoreTarget,
|
||||
createXCoreMCInstPrinter);
|
||||
|
||||
TargetRegistry::RegisterAsmStreamer(TheXCoreTarget, createXCoreMCAsmStreamer);
|
||||
TargetRegistry::RegisterAsmTargetStreamer(TheXCoreTarget,
|
||||
createTargetAsmStreamer);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue