class MCELFStreamer : public MCObjectStreamer {
public:
- MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter)
- : MCObjectStreamer(Context, TAB, OS, Emitter) {}
+ MCELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter);
~MCELFStreamer() override = default;
SmallVector<MCDataFragment *, 4> BundleGroups;
};
-MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
+MCELFStreamer *createARMELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll,
bool IsThumb);
/// implementation.
class MCObjectStreamer : public MCStreamer {
std::unique_ptr<MCObjectWriter> ObjectWriter;
+ std::unique_ptr<MCAsmBackend> TAB;
std::unique_ptr<MCAssembler> Assembler;
MCSection::iterator CurInsertionPoint;
bool EmitEHFrame;
MCSymbol *EmitCFILabel() override;
protected:
- MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter);
+ MCObjectStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter);
~MCObjectStreamer() override;
public:
class MCWasmStreamer : public MCObjectStreamer {
public:
- MCWasmStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter)
- : MCObjectStreamer(Context, TAB, OS, Emitter), SeenIdent(false) {}
+ MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
+ : MCObjectStreamer(Context, std::move(TAB), OS, Emitter),
+ SeenIdent(false) {}
~MCWasmStreamer() override;
class MCWinCOFFStreamer : public MCObjectStreamer {
public:
- MCWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB, MCCodeEmitter &CE,
- raw_pwrite_stream &OS);
+ MCWinCOFFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
+ MCCodeEmitter &CE, raw_pwrite_stream &OS);
/// state management
void reset() override {
MCAsmBackend *TAB, bool ShowInst);
/// Takes ownership of \p TAB and \p CE.
-MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
+MCStreamer *createELFStreamer(MCContext &Ctx,
+ std::unique_ptr<MCAsmBackend> &&TAB,
raw_pwrite_stream &OS, MCCodeEmitter *CE,
bool RelaxAll);
-MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
+MCStreamer *createMachOStreamer(MCContext &Ctx,
+ std::unique_ptr<MCAsmBackend> &&TAB,
raw_pwrite_stream &OS, MCCodeEmitter *CE,
bool RelaxAll, bool DWARFMustBeAtTheEnd,
bool LabelSections = false);
-MCStreamer *createWasmStreamer(MCContext &Ctx, MCAsmBackend &TAB,
+MCStreamer *createWasmStreamer(MCContext &Ctx,
+ std::unique_ptr<MCAsmBackend> &&TAB,
raw_pwrite_stream &OS, MCCodeEmitter *CE,
bool RelaxAll);
const MCRegisterInfo &MRI,
MCContext &Ctx);
using ELFStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
- MCAsmBackend &TAB,
+ std::unique_ptr<MCAsmBackend> &&TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter,
bool RelaxAll);
- using MachOStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
- raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter,
- bool RelaxAll,
- bool DWARFMustBeAtTheEnd);
- using COFFStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
- raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter,
- bool RelaxAll,
- bool IncrementalLinkerCompatible);
- using WasmStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
- MCAsmBackend &TAB,
- raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter,
- bool RelaxAll);
+ using MachOStreamerCtorTy =
+ MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
+ bool RelaxAll, bool DWARFMustBeAtTheEnd);
+ using COFFStreamerCtorTy =
+ MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
+ bool RelaxAll, bool IncrementalLinkerCompatible);
+ using WasmStreamerCtorTy = MCStreamer
+ *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool RelaxAll);
using NullTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S);
using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)(
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
/// \param Emitter The target independent assembler object.Takes ownership.
/// \param RelaxAll Relax all fixups?
MCStreamer *createMCObjectStreamer(const Triple &T, MCContext &Ctx,
- MCAsmBackend &TAB, raw_pwrite_stream &OS,
+ std::unique_ptr<MCAsmBackend> &&TAB,
+ raw_pwrite_stream &OS,
MCCodeEmitter *Emitter,
const MCSubtargetInfo &STI, bool RelaxAll,
bool IncrementalLinkerCompatible,
llvm_unreachable("Unknown object format");
case Triple::COFF:
assert(T.isOSWindows() && "only Windows COFF is supported");
- S = COFFStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll,
+ S = COFFStreamerCtorFn(Ctx, std::move(TAB), OS, Emitter, RelaxAll,
IncrementalLinkerCompatible);
break;
case Triple::MachO:
if (MachOStreamerCtorFn)
- S = MachOStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll,
+ S = MachOStreamerCtorFn(Ctx, std::move(TAB), OS, Emitter, RelaxAll,
DWARFMustBeAtTheEnd);
else
- S = createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll,
+ S = createMachOStreamer(Ctx, std::move(TAB), OS, Emitter, RelaxAll,
DWARFMustBeAtTheEnd);
break;
case Triple::ELF:
if (ELFStreamerCtorFn)
- S = ELFStreamerCtorFn(T, Ctx, TAB, OS, Emitter, RelaxAll);
+ S = ELFStreamerCtorFn(T, Ctx, std::move(TAB), OS, Emitter, RelaxAll);
else
- S = createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
+ S = createELFStreamer(Ctx, std::move(TAB), OS, Emitter, RelaxAll);
break;
case Triple::Wasm:
if (WasmStreamerCtorFn)
- S = WasmStreamerCtorFn(T, Ctx, TAB, OS, Emitter, RelaxAll);
+ S = WasmStreamerCtorFn(T, Ctx, std::move(TAB), OS, Emitter, RelaxAll);
else
- S = createWasmStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
+ S = createWasmStreamer(Ctx, std::move(TAB), OS, Emitter, RelaxAll);
break;
}
if (ObjectTargetStreamerCtorFn)
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Verifier.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInstrInfo.h"
Triple T(getTargetTriple().str());
AsmStreamer.reset(getTarget().createMCObjectStreamer(
- T, Context, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll,
+ T, Context, std::unique_ptr<MCAsmBackend>(MAB), Out, MCE, STI,
+ Options.MCOptions.MCRelaxAll,
Options.MCOptions.MCIncrementalLinkerCompatible,
/*DWARFMustBeAtTheEnd*/ true));
break;
const Triple &T = getTargetTriple();
const MCSubtargetInfo &STI = *getMCSubtargetInfo();
std::unique_ptr<MCStreamer> AsmStreamer(getTarget().createMCObjectStreamer(
- T, *Ctx, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll,
+ T, *Ctx, std::unique_ptr<MCAsmBackend>(MAB), Out, MCE, STI,
+ Options.MCOptions.MCRelaxAll,
Options.MCOptions.MCIncrementalLinkerCompatible,
/*DWARFMustBeAtTheEnd*/ true));
using namespace llvm;
+MCELFStreamer::MCELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
+ : MCObjectStreamer(Context, std::move(TAB), OS, Emitter) {}
+
bool MCELFStreamer::isBundleLocked() const {
return getCurrentSectionOnly()->isBundleLocked();
}
llvm_unreachable("ELF doesn't support this directive");
}
-MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
+MCStreamer *llvm::createELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> &&MAB,
raw_pwrite_stream &OS, MCCodeEmitter *CE,
bool RelaxAll) {
- MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
+ MCELFStreamer *S = new MCELFStreamer(Context, std::move(MAB), OS, CE);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
return S;
void EmitDataRegionEnd();
public:
- MCMachOStreamer(MCContext &Context, MCAsmBackend &MAB, raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter, bool DWARFMustBeAtTheEnd, bool label)
- : MCObjectStreamer(Context, MAB, OS, Emitter), LabelSections(label),
- DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd), CreatedADWARFSection(false) {}
+ MCMachOStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
+ bool DWARFMustBeAtTheEnd, bool label)
+ : MCObjectStreamer(Context, std::move(MAB), OS, Emitter),
+ LabelSections(label), DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd),
+ CreatedADWARFSection(false) {}
/// state management
void reset() override {
this->MCObjectStreamer::FinishImpl();
}
-MCStreamer *llvm::createMachOStreamer(MCContext &Context, MCAsmBackend &MAB,
+MCStreamer *llvm::createMachOStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> &&MAB,
raw_pwrite_stream &OS, MCCodeEmitter *CE,
bool RelaxAll, bool DWARFMustBeAtTheEnd,
bool LabelSections) {
- MCMachOStreamer *S = new MCMachOStreamer(Context, MAB, OS, CE,
+ MCMachOStreamer *S = new MCMachOStreamer(Context, std::move(MAB), OS, CE,
DWARFMustBeAtTheEnd, LabelSections);
const Triple &TT = Context.getObjectFileInfo()->getTargetTriple();
if (TT.isOSDarwin()) {
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
-MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
+MCObjectStreamer::MCObjectStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter_)
- : MCStreamer(Context), ObjectWriter(TAB.createObjectWriter(OS)),
- Assembler(llvm::make_unique<MCAssembler>(Context, TAB, *Emitter_,
- *ObjectWriter)),
+ : MCStreamer(Context), ObjectWriter(TAB->createObjectWriter(OS)),
+ TAB(std::move(TAB)), Assembler(llvm::make_unique<MCAssembler>(
+ Context, *this->TAB, *Emitter_, *ObjectWriter)),
EmitEHFrame(true), EmitDebugFrame(false) {}
MCObjectStreamer::~MCObjectStreamer() {
- delete &Assembler->getBackend();
delete &Assembler->getEmitter();
}
this->MCObjectStreamer::FinishImpl();
}
-MCStreamer *llvm::createWasmStreamer(MCContext &Context, MCAsmBackend &MAB,
+MCStreamer *llvm::createWasmStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> &&MAB,
raw_pwrite_stream &OS, MCCodeEmitter *CE,
bool RelaxAll) {
- MCWasmStreamer *S = new MCWasmStreamer(Context, MAB, OS, CE);
+ MCWasmStreamer *S = new MCWasmStreamer(Context, std::move(MAB), OS, CE);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
return S;
#define DEBUG_TYPE "WinCOFFStreamer"
-MCWinCOFFStreamer::MCWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
+MCWinCOFFStreamer::MCWinCOFFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> MAB,
MCCodeEmitter &CE, raw_pwrite_stream &OS)
- : MCObjectStreamer(Context, MAB, OS, &CE), CurSymbol(nullptr) {}
+ : MCObjectStreamer(Context, std::move(MAB), OS, &CE), CurSymbol(nullptr) {}
void MCWinCOFFStreamer::EmitInstToData(const MCInst &Inst,
const MCSubtargetInfo &STI) {
public:
friend class AArch64TargetELFStreamer;
- AArch64ELFStreamer(MCContext &Context, MCAsmBackend &TAB,
+ AArch64ELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
- : MCELFStreamer(Context, TAB, OS, Emitter), MappingSymbolCounter(0),
- LastEMS(EMS_None) {}
+ : MCELFStreamer(Context, std::move(TAB), OS, Emitter),
+ MappingSymbolCounter(0), LastEMS(EMS_None) {}
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override {
// We have to keep track of the mapping symbol state of any sections we
return new AArch64TargetAsmStreamer(S, OS);
}
-MCELFStreamer *createAArch64ELFStreamer(MCContext &Context, MCAsmBackend &TAB,
+MCELFStreamer *createAArch64ELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll) {
- AArch64ELFStreamer *S = new AArch64ELFStreamer(Context, TAB, OS, Emitter);
+ AArch64ELFStreamer *S =
+ new AArch64ELFStreamer(Context, std::move(TAB), OS, Emitter);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
return S;
namespace llvm {
-MCELFStreamer *createAArch64ELFStreamer(MCContext &Context, MCAsmBackend &TAB,
+MCELFStreamer *createAArch64ELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll);
}
}
static MCStreamer *createELFStreamer(const Triple &T, MCContext &Ctx,
- MCAsmBackend &TAB, raw_pwrite_stream &OS,
+ std::unique_ptr<MCAsmBackend> &&TAB,
+ raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll) {
- return createAArch64ELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
+ return createAArch64ELFStreamer(Ctx, std::move(TAB), OS, Emitter, RelaxAll);
}
-static MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
+static MCStreamer *createMachOStreamer(MCContext &Ctx,
+ std::unique_ptr<MCAsmBackend> &&TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll,
bool DWARFMustBeAtTheEnd) {
- return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll,
+ return createMachOStreamer(Ctx, std::move(TAB), OS, Emitter, RelaxAll,
DWARFMustBeAtTheEnd,
/*LabelSections*/ true);
}
-static MCStreamer *createWinCOFFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
+static MCStreamer *createWinCOFFStreamer(MCContext &Ctx,
+ std::unique_ptr<MCAsmBackend> &&TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll,
bool IncrementalLinkerCompatible) {
- return createAArch64WinCOFFStreamer(Ctx, TAB, OS, Emitter, RelaxAll,
- IncrementalLinkerCompatible);
+ return createAArch64WinCOFFStreamer(Ctx, std::move(TAB), OS, Emitter,
+ RelaxAll, IncrementalLinkerCompatible);
}
static MCInstrAnalysis *createAArch64InstrAnalysis(const MCInstrInfo *Info) {
public:
friend class AArch64TargetWinCOFFStreamer;
- AArch64WinCOFFStreamer(MCContext &C, MCAsmBackend &AB, MCCodeEmitter &CE,
- raw_pwrite_stream &OS)
- : MCWinCOFFStreamer(C, AB, CE, OS) {}
+ AArch64WinCOFFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> AB,
+ MCCodeEmitter &CE, raw_pwrite_stream &OS)
+ : MCWinCOFFStreamer(C, std::move(AB), CE, OS) {}
};
} // end anonymous namespace
namespace llvm {
-MCWinCOFFStreamer
-*createAArch64WinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
- raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter, bool RelaxAll,
- bool IncrementalLinkerCompatible) {
- auto *S = new AArch64WinCOFFStreamer(Context, MAB, *Emitter, OS);
+MCWinCOFFStreamer *
+createAArch64WinCOFFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
+ bool RelaxAll, bool IncrementalLinkerCompatible) {
+ auto *S = new AArch64WinCOFFStreamer(Context, std::move(MAB), *Emitter, OS);
S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
return S;
}
#define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64WINCOFFSTREAMER_H
#include "AArch64TargetStreamer.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCWinCOFFStreamer.h"
namespace {
namespace llvm {
-MCWinCOFFStreamer
-*createAArch64WinCOFFStreamer(MCContext &Context, MCAsmBackend &TAB,
- raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter, bool RelaxAll,
- bool IncrementalLinkerCompatible);
+MCWinCOFFStreamer *
+createAArch64WinCOFFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
+ bool RelaxAll, bool IncrementalLinkerCompatible);
} // end llvm namespace
#endif
#include "AMDGPUELFStreamer.h"
#include "Utils/AMDGPUBaseInfo.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/MC/MCAsmBackend.h"
using namespace llvm;
AMDGPUELFStreamer::AMDGPUELFStreamer(const Triple &T, MCContext &Context,
- MCAsmBackend &MAB, raw_pwrite_stream &OS,
+ std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS,
MCCodeEmitter *Emitter)
- : MCELFStreamer(Context, MAB, OS, Emitter) {
+ : MCELFStreamer(Context, std::move(MAB), OS, Emitter) {
unsigned Arch = ELF::EF_AMDGPU_ARCH_NONE;
switch (T.getArch()) {
case Triple::r600:
MCA.setELFHeaderEFlags(EFlags);
}
-MCELFStreamer *llvm::createAMDGPUELFStreamer(const Triple &T, MCContext &Context,
- MCAsmBackend &MAB,
- raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter,
- bool RelaxAll) {
- return new AMDGPUELFStreamer(T, Context, MAB, OS, Emitter);
+MCELFStreamer *llvm::createAMDGPUELFStreamer(
+ const Triple &T, MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool RelaxAll) {
+ return new AMDGPUELFStreamer(T, Context, std::move(MAB), OS, Emitter);
}
class AMDGPUELFStreamer : public MCELFStreamer {
public:
- AMDGPUELFStreamer(const Triple &T, MCContext &Context, MCAsmBackend &MAB,
- raw_pwrite_stream &OS, MCCodeEmitter *Emitter);
+ AMDGPUELFStreamer(const Triple &T, MCContext &Context,
+ std::unique_ptr<MCAsmBackend> MAB, raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter);
};
MCELFStreamer *createAMDGPUELFStreamer(const Triple &T, MCContext &Context,
- MCAsmBackend &MAB, raw_pwrite_stream &OS,
+ std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll);
} // namespace llvm.
#include "AMDGPUTargetStreamer.h"
#include "InstPrinter/AMDGPUInstPrinter.h"
#include "SIDefines.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
}
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
- MCAsmBackend &MAB, raw_pwrite_stream &OS,
+ std::unique_ptr<MCAsmBackend> &&MAB,
+ raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll) {
- return createAMDGPUELFStreamer(T, Context, MAB, OS, Emitter, RelaxAll);
+ return createAMDGPUELFStreamer(T, Context, std::move(MAB), OS, Emitter,
+ RelaxAll);
}
extern "C" void LLVMInitializeAMDGPUTargetMC() {
public:
friend class ARMTargetELFStreamer;
- ARMELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter, bool IsThumb)
- : MCELFStreamer(Context, TAB, OS, Emitter), IsThumb(IsThumb) {
+ ARMELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool IsThumb)
+ : MCELFStreamer(Context, std::move(TAB), OS, Emitter), IsThumb(IsThumb) {
EHReset();
}
return new ARMTargetStreamer(S);
}
-MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
+MCELFStreamer *createARMELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll,
bool IsThumb) {
- ARMELFStreamer *S = new ARMELFStreamer(Context, TAB, OS, Emitter, IsThumb);
- // 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.
- S->getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
-
- if (RelaxAll)
- S->getAssembler().setRelaxAll(true);
- return S;
+ ARMELFStreamer *S =
+ new ARMELFStreamer(Context, std::move(TAB), OS, Emitter, IsThumb);
+ // 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.
+ S->getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
+
+ if (RelaxAll)
+ S->getAssembler().setRelaxAll(true);
+ return S;
}
} // end namespace llvm
#include "ARMMCAsmInfo.h"
#include "InstPrinter/ARMInstPrinter.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCELFStreamer.h"
#include "llvm/MC/MCInstrAnalysis.h"
#include "llvm/MC/MCInstrInfo.h"
}
static MCStreamer *createELFStreamer(const Triple &T, MCContext &Ctx,
- MCAsmBackend &MAB, raw_pwrite_stream &OS,
+ std::unique_ptr<MCAsmBackend> &&MAB,
+ raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll) {
- return createARMELFStreamer(Ctx, MAB, OS, Emitter, false,
- (T.getArch() == Triple::thumb ||
- T.getArch() == Triple::thumbeb));
+ return createARMELFStreamer(
+ Ctx, std::move(MAB), OS, Emitter, false,
+ (T.getArch() == Triple::thumb || T.getArch() == Triple::thumbeb));
}
-static MCStreamer *createARMMachOStreamer(MCContext &Ctx, MCAsmBackend &MAB,
+static MCStreamer *createARMMachOStreamer(MCContext &Ctx,
+ std::unique_ptr<MCAsmBackend> &&MAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll,
bool DWARFMustBeAtTheEnd) {
- return createMachOStreamer(Ctx, MAB, OS, Emitter, false, DWARFMustBeAtTheEnd);
+ return createMachOStreamer(Ctx, std::move(MAB), OS, Emitter, false,
+ DWARFMustBeAtTheEnd);
}
static MCInstPrinter *createARMMCInstPrinter(const Triple &T,
// Construct a PE/COFF machine code streamer which will generate a PE/COFF
// object file.
-MCStreamer *createARMWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
+MCStreamer *createARMWinCOFFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> &&MAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll,
bool IncrementalLinkerCompatible);
//===----------------------------------------------------------------------===//
#include "ARMMCTargetDesc.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCWinCOFFStreamer.h"
using namespace llvm;
namespace {
class ARMWinCOFFStreamer : public MCWinCOFFStreamer {
public:
- ARMWinCOFFStreamer(MCContext &C, MCAsmBackend &AB, MCCodeEmitter &CE,
- raw_pwrite_stream &OS)
- : MCWinCOFFStreamer(C, AB, CE, OS) {}
+ ARMWinCOFFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> AB,
+ MCCodeEmitter &CE, raw_pwrite_stream &OS)
+ : MCWinCOFFStreamer(C, std::move(AB), CE, OS) {}
void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
void EmitThumbFunc(MCSymbol *Symbol) override;
}
}
-MCStreamer *llvm::createARMWinCOFFStreamer(
- MCContext &Context, MCAsmBackend &MAB, raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter, bool RelaxAll, bool IncrementalLinkerCompatible) {
- auto *S = new ARMWinCOFFStreamer(Context, MAB, *Emitter, OS);
+MCStreamer *llvm::createARMWinCOFFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> &&MAB,
+ raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter,
+ bool RelaxAll,
+ bool IncrementalLinkerCompatible) {
+ auto *S = new ARMWinCOFFStreamer(Context, std::move(MAB), *Emitter, OS);
S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
return S;
}
return createBPFMCSubtargetInfoImpl(TT, CPU, FS);
}
-static MCStreamer *createBPFMCStreamer(const Triple &T,
- MCContext &Ctx, MCAsmBackend &MAB,
- raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
- bool RelaxAll) {
- return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
+static MCStreamer *createBPFMCStreamer(const Triple &T, MCContext &Ctx,
+ std::unique_ptr<MCAsmBackend> &&MAB,
+ raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter, bool RelaxAll) {
+ return createELFStreamer(Ctx, std::move(MAB), OS, Emitter, RelaxAll);
}
static MCInstPrinter *createBPFMCInstPrinter(const Triple &T,
#include "MCTargetDesc/HexagonMCShuffler.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
cl::Prefix,
cl::init(8));
+HexagonMCELFStreamer::HexagonMCELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter)
+ : MCELFStreamer(Context, std::move(TAB), OS, Emitter),
+ MCII(createHexagonMCInstrInfo()) {}
+
+HexagonMCELFStreamer::HexagonMCELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter,
+ MCAssembler *Assembler)
+ : MCELFStreamer(Context, std::move(TAB), OS, Emitter),
+ MCII(createHexagonMCInstrInfo()) {}
+
void HexagonMCELFStreamer::EmitInstruction(const MCInst &MCB,
const MCSubtargetInfo &STI, bool) {
assert(MCB.getOpcode() == Hexagon::BUNDLE);
namespace llvm {
- MCStreamer *createHexagonELFStreamer(Triple const &TT, MCContext &Context,
- MCAsmBackend &MAB,
- raw_pwrite_stream &OS, MCCodeEmitter *CE) {
- return new HexagonMCELFStreamer(Context, MAB, OS, CE);
+MCStreamer *createHexagonELFStreamer(Triple const &TT, MCContext &Context,
+ std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *CE) {
+ return new HexagonMCELFStreamer(Context, std::move(MAB), OS, CE);
}
} // end namespace llvm
std::unique_ptr<MCInstrInfo> MCII;
public:
- HexagonMCELFStreamer(MCContext &Context, MCAsmBackend &TAB,
- raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
- : MCELFStreamer(Context, TAB, OS, Emitter),
- MCII(createHexagonMCInstrInfo()) {}
+ HexagonMCELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter);
- HexagonMCELFStreamer(MCContext &Context,
- MCAsmBackend &TAB,
+ HexagonMCELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
- MCAssembler *Assembler) :
- MCELFStreamer(Context, TAB, OS, Emitter),
- MCII (createHexagonMCInstrInfo()) {}
+ MCAssembler *Assembler);
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
bool) override;
};
MCStreamer *createHexagonELFStreamer(Triple const &TT, MCContext &Context,
- MCAsmBackend &MAB, raw_pwrite_stream &OS,
- MCCodeEmitter *CE);
+ std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *CE);
} // end namespace llvm
#include "MCTargetDesc/HexagonMCInstrInfo.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCELFStreamer.h"
return new HexagonTargetAsmStreamer(S, OS, IsVerboseAsm, *IP);
}
-static MCStreamer *createMCStreamer(Triple const &T,
- MCContext &Context,
- MCAsmBackend &MAB,
+static MCStreamer *createMCStreamer(Triple const &T, MCContext &Context,
+ std::unique_ptr<MCAsmBackend> &&MAB,
raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter,
- bool RelaxAll) {
- return createHexagonELFStreamer(T, Context, MAB, OS, Emitter);
+ MCCodeEmitter *Emitter, bool RelaxAll) {
+ return createHexagonELFStreamer(T, Context, std::move(MAB), OS, Emitter);
}
static MCTargetStreamer *
}
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
- MCAsmBackend &MAB, raw_pwrite_stream &OS,
+ std::unique_ptr<MCAsmBackend> &&MAB,
+ raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll) {
if (!T.isOSBinFormatELF())
llvm_unreachable("OS not supported");
- return createELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
+ return createELFStreamer(Context, std::move(MAB), OS, Emitter, RelaxAll);
}
static MCInstPrinter *createLanaiMCInstPrinter(const Triple & /*T*/,
#include "MipsOptionRecord.h"
#include "MipsTargetStreamer.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInst.h"
using namespace llvm;
+MipsELFStreamer::MipsELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
+ : MCELFStreamer(Context, std::move(MAB), OS, Emitter) {
+ RegInfoRecord = new MipsRegInfoRecord(this, Context);
+ MipsOptionRecords.push_back(
+ std::unique_ptr<MipsRegInfoRecord>(RegInfoRecord));
+}
+
void MipsELFStreamer::EmitInstruction(const MCInst &Inst,
const MCSubtargetInfo &STI, bool) {
MCELFStreamer::EmitInstruction(Inst, STI);
}
MCELFStreamer *llvm::createMipsELFStreamer(MCContext &Context,
- MCAsmBackend &MAB,
+ std::unique_ptr<MCAsmBackend> MAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter,
bool RelaxAll) {
- return new MipsELFStreamer(Context, MAB, OS, Emitter);
+ return new MipsELFStreamer(Context, std::move(MAB), OS, Emitter);
}
SmallVector<MCSymbol*, 4> Labels;
public:
- MipsELFStreamer(MCContext &Context, MCAsmBackend &MAB, raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter)
- : MCELFStreamer(Context, MAB, OS, Emitter) {
- RegInfoRecord = new MipsRegInfoRecord(this, Context);
- MipsOptionRecords.push_back(
- std::unique_ptr<MipsRegInfoRecord>(RegInfoRecord));
- }
+ MipsELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *Emitter);
/// Overriding this function allows us to add arbitrary behaviour before the
/// \p Inst is actually emitted. For example, we can inspect the operands and
void createPendingLabelRelocs();
};
-MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &MAB,
+MCELFStreamer *createMipsELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> MAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll);
} // end namespace llvm
bool baseRegNeedsLoadStoreMask(unsigned Reg);
// This function creates an MCELFStreamer for Mips NaCl.
-MCELFStreamer *createMipsNaClELFStreamer(MCContext &Context, MCAsmBackend &TAB,
+MCELFStreamer *createMipsNaClELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll);
}
}
static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
- MCAsmBackend &MAB, raw_pwrite_stream &OS,
+ std::unique_ptr<MCAsmBackend> &&MAB,
+ raw_pwrite_stream &OS,
MCCodeEmitter *Emitter, bool RelaxAll) {
MCStreamer *S;
if (!T.isOSNaCl())
- S = createMipsELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
+ S = createMipsELFStreamer(Context, std::move(MAB), OS, Emitter, RelaxAll);
else
- S = createMipsNaClELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
+ S = createMipsNaClELFStreamer(Context, std::move(MAB), OS, Emitter,
+ RelaxAll);
return S;
}
#include "Mips.h"
#include "MipsELFStreamer.h"
#include "MipsMCNaCl.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCELFStreamer.h"
#include "llvm/MC/MCInst.h"
class MipsNaClELFStreamer : public MipsELFStreamer {
public:
- MipsNaClELFStreamer(MCContext &Context, MCAsmBackend &TAB,
+ MipsNaClELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
- : MipsELFStreamer(Context, TAB, OS, Emitter) {}
+ : MipsELFStreamer(Context, std::move(TAB), OS, Emitter) {}
~MipsNaClELFStreamer() override = default;
return Reg != Mips::SP && Reg != Mips::T8;
}
-MCELFStreamer *createMipsNaClELFStreamer(MCContext &Context, MCAsmBackend &TAB,
+MCELFStreamer *createMipsNaClELFStreamer(MCContext &Context,
+ std::unique_ptr<MCAsmBackend> TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter,
bool RelaxAll) {
- MipsNaClELFStreamer *S = new MipsNaClELFStreamer(Context, TAB, OS, Emitter);
+ MipsNaClELFStreamer *S =
+ new MipsNaClELFStreamer(Context, std::move(TAB), OS, Emitter);
if (RelaxAll)
S->getAssembler().setRelaxAll(true);
/// PE/COFF format object files.
///
/// Takes ownership of \p AB and \p CE.
-MCStreamer *createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
+MCStreamer *createX86WinCOFFStreamer(MCContext &C,
+ std::unique_ptr<MCAsmBackend> &&AB,
raw_pwrite_stream &OS, MCCodeEmitter *CE,
- bool RelaxAll, bool IncrementalLinkerCompatible);
+ bool RelaxAll,
+ bool IncrementalLinkerCompatible);
/// Construct an X86 Mach-O object writer.
std::unique_ptr<MCObjectWriter> createX86MachObjectWriter(raw_pwrite_stream &OS,
//===----------------------------------------------------------------------===//
#include "X86MCTargetDesc.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCWin64EH.h"
#include "llvm/MC/MCWinCOFFStreamer.h"
class X86WinCOFFStreamer : public MCWinCOFFStreamer {
Win64EH::UnwindEmitter EHStreamer;
public:
- X86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB, MCCodeEmitter *CE,
- raw_pwrite_stream &OS)
- : MCWinCOFFStreamer(C, AB, *CE, OS) {}
+ X86WinCOFFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> AB,
+ MCCodeEmitter *CE, raw_pwrite_stream &OS)
+ : MCWinCOFFStreamer(C, std::move(AB), *CE, OS) {}
void EmitWinEHHandlerData(SMLoc Loc) override;
void EmitWindowsUnwindTables() override;
}
}
-MCStreamer *llvm::createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
+MCStreamer *llvm::createX86WinCOFFStreamer(MCContext &C,
+ std::unique_ptr<MCAsmBackend> &&AB,
raw_pwrite_stream &OS,
MCCodeEmitter *CE, bool RelaxAll,
bool IncrementalLinkerCompatible) {
- X86WinCOFFStreamer *S = new X86WinCOFFStreamer(C, AB, CE, OS);
+ X86WinCOFFStreamer *S = new X86WinCOFFStreamer(C, std::move(AB), CE, OS);
S->getAssembler().setRelaxAll(RelaxAll);
S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
return S;
MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
MS = TheTarget->createMCObjectStreamer(
- TheTriple, *MC, *MAB, *OutFile, MCE, *MSTI, MCOptions.MCRelaxAll,
- MCOptions.MCIncrementalLinkerCompatible,
+ TheTriple, *MC, std::unique_ptr<MCAsmBackend>(MAB), *OutFile, MCE, *MSTI,
+ MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
/*DWARFMustBeAtTheEnd*/ false);
if (!MS)
return error("no object streamer for target " + TripleName, Context);
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
+#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInstrInfo.h"
MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
std::unique_ptr<MCStreamer> MS(TheTarget->createMCObjectStreamer(
- TheTriple, MC, *MAB, OutFile, MCE, *MSTI, MCOptions.MCRelaxAll,
- MCOptions.MCIncrementalLinkerCompatible,
+ TheTriple, MC, std::unique_ptr<MCAsmBackend>(MAB), OutFile, MCE, *MSTI,
+ MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
/*DWARFMustBeAtTheEnd*/ false));
if (!MS)
return error("no object streamer for target " + TripleName, Context);
MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU,
MCOptions);
Str.reset(TheTarget->createMCObjectStreamer(
- TheTriple, Ctx, *MAB, *OS, CE, *STI, MCOptions.MCRelaxAll,
- MCOptions.MCIncrementalLinkerCompatible,
+ TheTriple, Ctx, std::unique_ptr<MCAsmBackend>(MAB), *OS, CE, *STI,
+ MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
/*DWARFMustBeAtTheEnd*/ false));
if (NoExecStack)
Str->InitSections(true);
MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
MS = TheTarget->createMCObjectStreamer(
- TheTriple, *MC, *MAB, *Stream, MCE, *MSTI, MCOptions.MCRelaxAll,
- MCOptions.MCIncrementalLinkerCompatible,
+ TheTriple, *MC, std::unique_ptr<MCAsmBackend>(MAB), *Stream, MCE, *MSTI,
+ MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
/*DWARFMustBeAtTheEnd*/ false);
if (!MS)
return make_error<StringError>("no object streamer for target " +