mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
std::unique_ptrify the MCStreamer argument to createAsmPrinter
llvm-svn: 226414
This commit is contained in:
parent
e51db749de
commit
8839ae1559
@ -127,7 +127,7 @@ private:
|
||||
DwarfDebug *DD;
|
||||
|
||||
protected:
|
||||
explicit AsmPrinter(TargetMachine &TM, MCStreamer &Streamer);
|
||||
explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);
|
||||
|
||||
public:
|
||||
virtual ~AsmPrinter();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Support/CodeGen.h"
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
@ -99,8 +100,11 @@ namespace llvm {
|
||||
Reloc::Model RM,
|
||||
CodeModel::Model CM,
|
||||
CodeGenOpt::Level OL);
|
||||
typedef AsmPrinter *(*AsmPrinterCtorTy)(TargetMachine &TM,
|
||||
MCStreamer &Streamer);
|
||||
// If it weren't for layering issues (this header is in llvm/Support, but
|
||||
// depends on MC?) this should take the Streamer by value rather than rvalue
|
||||
// reference.
|
||||
typedef AsmPrinter *(*AsmPrinterCtorTy)(
|
||||
TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
|
||||
typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T,
|
||||
const MCRegisterInfo &MRI,
|
||||
StringRef TT,
|
||||
@ -376,10 +380,11 @@ namespace llvm {
|
||||
|
||||
/// createAsmPrinter - Create a target specific assembly printer pass. This
|
||||
/// takes ownership of the MCStreamer object.
|
||||
AsmPrinter *createAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) const{
|
||||
AsmPrinter *createAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer) const {
|
||||
if (!AsmPrinterCtorFn)
|
||||
return nullptr;
|
||||
return AsmPrinterCtorFn(TM, Streamer);
|
||||
return AsmPrinterCtorFn(TM, std::move(Streamer));
|
||||
}
|
||||
|
||||
MCDisassembler *createMCDisassembler(const MCSubtargetInfo &STI,
|
||||
@ -1121,8 +1126,9 @@ namespace llvm {
|
||||
}
|
||||
|
||||
private:
|
||||
static AsmPrinter *Allocator(TargetMachine &TM, MCStreamer &Streamer) {
|
||||
return new AsmPrinterImpl(TM, Streamer);
|
||||
static AsmPrinter *Allocator(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> &&Streamer) {
|
||||
return new AsmPrinterImpl(TM, std::move(Streamer));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -98,15 +98,15 @@ static unsigned getGVAlignmentLog2(const GlobalValue *GV, const DataLayout &TD,
|
||||
return NumBits;
|
||||
}
|
||||
|
||||
AsmPrinter::AsmPrinter(TargetMachine &tm, MCStreamer &Streamer)
|
||||
AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
|
||||
: MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()),
|
||||
MII(tm.getSubtargetImpl()->getInstrInfo()),
|
||||
OutContext(Streamer.getContext()), OutStreamer(Streamer), LastMI(nullptr),
|
||||
LastFn(0), Counter(~0U), SetCounter(0) {
|
||||
OutContext(Streamer->getContext()), OutStreamer(*Streamer.release()),
|
||||
LastMI(nullptr), LastFn(0), Counter(~0U), SetCounter(0) {
|
||||
DD = nullptr; MMI = nullptr; LI = nullptr; MF = nullptr;
|
||||
CurrentFnSym = CurrentFnSymForSize = nullptr;
|
||||
GCMetadataPrinters = nullptr;
|
||||
VerboseAsm = Streamer.isVerboseAsm();
|
||||
VerboseAsm = OutStreamer.isVerboseAsm();
|
||||
}
|
||||
|
||||
AsmPrinter::~AsmPrinter() {
|
||||
|
@ -221,13 +221,11 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
||||
}
|
||||
|
||||
// Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
|
||||
FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer);
|
||||
FunctionPass *Printer =
|
||||
getTarget().createAsmPrinter(*this, std::move(AsmStreamer));
|
||||
if (!Printer)
|
||||
return true;
|
||||
|
||||
// If successful, createAsmPrinter took ownership of AsmStreamer.
|
||||
AsmStreamer.release();
|
||||
|
||||
PM.add(Printer);
|
||||
|
||||
return false;
|
||||
@ -261,20 +259,16 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM,
|
||||
if (!MCE || !MAB)
|
||||
return true;
|
||||
|
||||
std::unique_ptr<MCStreamer> AsmStreamer;
|
||||
AsmStreamer.reset(getTarget()
|
||||
.createMCObjectStreamer(getTargetTriple(), *Ctx, *MAB,
|
||||
Out, MCE, STI,
|
||||
Options.MCOptions.MCRelaxAll));
|
||||
std::unique_ptr<MCStreamer> AsmStreamer(getTarget().createMCObjectStreamer(
|
||||
getTargetTriple(), *Ctx, *MAB, Out, MCE, STI,
|
||||
Options.MCOptions.MCRelaxAll));
|
||||
|
||||
// Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
|
||||
FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer);
|
||||
FunctionPass *Printer =
|
||||
getTarget().createAsmPrinter(*this, std::move(AsmStreamer));
|
||||
if (!Printer)
|
||||
return true;
|
||||
|
||||
// If successful, createAsmPrinter took ownership of AsmStreamer.
|
||||
AsmStreamer.release();
|
||||
|
||||
PM.add(Printer);
|
||||
|
||||
return false; // success!
|
||||
|
@ -51,8 +51,8 @@ class AArch64AsmPrinter : public AsmPrinter {
|
||||
StackMaps SM;
|
||||
|
||||
public:
|
||||
AArch64AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer),
|
||||
AArch64AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)),
|
||||
Subtarget(&TM.getSubtarget<AArch64Subtarget>()),
|
||||
MCInstLowering(OutContext, *this), SM(*this), AArch64FI(nullptr),
|
||||
LOHLabelCounter(0) {}
|
||||
|
@ -57,6 +57,13 @@ using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
|
||||
ARMAsmPrinter::ARMAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)), AFI(nullptr), MCP(nullptr),
|
||||
InConstantPool(false) {
|
||||
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
||||
}
|
||||
|
||||
void ARMAsmPrinter::EmitFunctionBodyEnd() {
|
||||
// Make sure to terminate any constant pools that were at the end
|
||||
// of the function.
|
||||
|
@ -52,11 +52,8 @@ class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
|
||||
SmallVector<std::pair<unsigned, MCSymbol*>, 4> ThumbIndirectPads;
|
||||
|
||||
public:
|
||||
explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer), AFI(nullptr), MCP(nullptr),
|
||||
InConstantPool(false) {
|
||||
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
||||
}
|
||||
explicit ARMAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer);
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "ARM Assembly / Object Emitter";
|
||||
|
@ -61,6 +61,12 @@ static cl::opt<bool> AlignCalls(
|
||||
"hexagon-align-calls", cl::Hidden, cl::init(true),
|
||||
cl::desc("Insert falign after call instruction for Hexagon target"));
|
||||
|
||||
HexagonAsmPrinter::HexagonAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)) {
|
||||
Subtarget = &TM.getSubtarget<HexagonSubtarget>();
|
||||
}
|
||||
|
||||
void HexagonAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
const MachineOperand &MO = MI->getOperand(OpNo);
|
||||
|
@ -25,10 +25,8 @@ namespace llvm {
|
||||
const HexagonSubtarget *Subtarget;
|
||||
|
||||
public:
|
||||
explicit HexagonAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer) {
|
||||
Subtarget = &TM.getSubtarget<HexagonSubtarget>();
|
||||
}
|
||||
explicit HexagonAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer);
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "Hexagon Assembly Printer";
|
||||
|
@ -39,8 +39,8 @@ using namespace llvm;
|
||||
namespace {
|
||||
class MSP430AsmPrinter : public AsmPrinter {
|
||||
public:
|
||||
MSP430AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer) {}
|
||||
MSP430AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)) {}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "MSP430 Assembly Printer";
|
||||
|
@ -99,9 +99,11 @@ public:
|
||||
// reside on the TargetMachine, but are on the subtarget currently
|
||||
// and we need them for the beginning of file output before we've
|
||||
// seen a single function.
|
||||
explicit MipsAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer), MCP(nullptr), InConstantPool(false),
|
||||
Subtarget(&TM.getSubtarget<MipsSubtarget>()), MCInstLowering(*this) {}
|
||||
explicit MipsAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)), MCP(nullptr),
|
||||
InConstantPool(false), Subtarget(&TM.getSubtarget<MipsSubtarget>()),
|
||||
MCInstLowering(*this) {}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "Mips Assembly Printer";
|
||||
|
@ -298,8 +298,8 @@ private:
|
||||
bool EmitGeneric;
|
||||
|
||||
public:
|
||||
NVPTXAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer),
|
||||
NVPTXAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)),
|
||||
nvptxSubtarget(TM.getSubtarget<NVPTXSubtarget>()) {
|
||||
CurrentBankselLabelInBasicBlock = "";
|
||||
reader = nullptr;
|
||||
|
@ -72,9 +72,11 @@ namespace {
|
||||
uint64_t TOCLabelID;
|
||||
StackMaps SM;
|
||||
public:
|
||||
explicit PPCAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer),
|
||||
Subtarget(TM.getSubtarget<PPCSubtarget>()), TOCLabelID(0), SM(*this) {}
|
||||
explicit PPCAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)),
|
||||
Subtarget(TM.getSubtarget<PPCSubtarget>()), TOCLabelID(0), SM(*this) {
|
||||
}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "PowerPC Assembly Printer";
|
||||
@ -104,8 +106,9 @@ namespace {
|
||||
/// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
|
||||
class PPCLinuxAsmPrinter : public PPCAsmPrinter {
|
||||
public:
|
||||
explicit PPCLinuxAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: PPCAsmPrinter(TM, Streamer) {}
|
||||
explicit PPCLinuxAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: PPCAsmPrinter(TM, std::move(Streamer)) {}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "Linux PPC Assembly Printer";
|
||||
@ -124,8 +127,9 @@ namespace {
|
||||
/// OS X
|
||||
class PPCDarwinAsmPrinter : public PPCAsmPrinter {
|
||||
public:
|
||||
explicit PPCDarwinAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: PPCAsmPrinter(TM, Streamer) {}
|
||||
explicit PPCDarwinAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: PPCAsmPrinter(TM, std::move(Streamer)) {}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "Darwin PPC Assembly Printer";
|
||||
@ -1471,13 +1475,14 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
|
||||
/// for a MachineFunction to the given output stream, in a format that the
|
||||
/// Darwin assembler can deal with.
|
||||
///
|
||||
static AsmPrinter *createPPCAsmPrinterPass(TargetMachine &tm,
|
||||
MCStreamer &Streamer) {
|
||||
static AsmPrinter *
|
||||
createPPCAsmPrinterPass(TargetMachine &tm,
|
||||
std::unique_ptr<MCStreamer> &&Streamer) {
|
||||
const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
|
||||
|
||||
if (Subtarget->isDarwin())
|
||||
return new PPCDarwinAsmPrinter(tm, Streamer);
|
||||
return new PPCLinuxAsmPrinter(tm, Streamer);
|
||||
return new PPCDarwinAsmPrinter(tm, std::move(Streamer));
|
||||
return new PPCLinuxAsmPrinter(tm, std::move(Streamer));
|
||||
}
|
||||
|
||||
// Force static initialization.
|
||||
|
@ -73,9 +73,10 @@ static uint32_t getFPMode(const MachineFunction &F) {
|
||||
FP_DENORM_MODE_DP(FP64Denormals);
|
||||
}
|
||||
|
||||
static AsmPrinter *createAMDGPUAsmPrinterPass(TargetMachine &tm,
|
||||
MCStreamer &Streamer) {
|
||||
return new AMDGPUAsmPrinter(tm, Streamer);
|
||||
static AsmPrinter *
|
||||
createAMDGPUAsmPrinterPass(TargetMachine &tm,
|
||||
std::unique_ptr<MCStreamer> &&Streamer) {
|
||||
return new AMDGPUAsmPrinter(tm, std::move(Streamer));
|
||||
}
|
||||
|
||||
extern "C" void LLVMInitializeR600AsmPrinter() {
|
||||
@ -83,8 +84,9 @@ extern "C" void LLVMInitializeR600AsmPrinter() {
|
||||
TargetRegistry::RegisterAsmPrinter(TheGCNTarget, createAMDGPUAsmPrinterPass);
|
||||
}
|
||||
|
||||
AMDGPUAsmPrinter::AMDGPUAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer) {
|
||||
AMDGPUAsmPrinter::AMDGPUAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)) {
|
||||
DisasmEnabled = TM.getSubtarget<AMDGPUSubtarget>().dumpCode();
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,8 @@ private:
|
||||
const SIProgramInfo &KernelInfo) const;
|
||||
|
||||
public:
|
||||
explicit AMDGPUAsmPrinter(TargetMachine &TM, MCStreamer &Streamer);
|
||||
explicit AMDGPUAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer);
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||
|
||||
|
@ -43,8 +43,9 @@ namespace {
|
||||
*OutStreamer.getTargetStreamer());
|
||||
}
|
||||
public:
|
||||
explicit SparcAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer) {}
|
||||
explicit SparcAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)) {}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "Sparc Assembly Printer";
|
||||
|
@ -26,8 +26,8 @@ private:
|
||||
const SystemZSubtarget *Subtarget;
|
||||
|
||||
public:
|
||||
SystemZAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer) {
|
||||
SystemZAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)) {
|
||||
Subtarget = &TM.getSubtarget<SystemZSubtarget>();
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,9 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
|
||||
void LowerTlsAddr(X86MCInstLower &MCInstLowering, const MachineInstr &MI);
|
||||
|
||||
public:
|
||||
explicit X86AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer), SM(*this), SMShadowTracker(TM) {
|
||||
explicit X86AsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)), SM(*this), SMShadowTracker(TM) {
|
||||
Subtarget = &TM.getSubtarget<X86Subtarget>();
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,10 @@ namespace {
|
||||
XCoreTargetStreamer &getTargetStreamer();
|
||||
|
||||
public:
|
||||
explicit XCoreAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||
: AsmPrinter(TM, Streamer), Subtarget(TM.getSubtarget<XCoreSubtarget>()),
|
||||
MCInstLowering(*this) {}
|
||||
explicit XCoreAsmPrinter(TargetMachine &TM,
|
||||
std::unique_ptr<MCStreamer> Streamer)
|
||||
: AsmPrinter(TM, std::move(Streamer)),
|
||||
Subtarget(TM.getSubtarget<XCoreSubtarget>()), MCInstLowering(*this) {}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "XCore Assembly Printer";
|
||||
|
Loading…
Reference in New Issue
Block a user