#ifndef LLVM_SUPPORT_TARGETREGISTRY_H
#define LLVM_SUPPORT_TARGETREGISTRY_H
+#include "llvm-c/Disassembler.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/CodeGen.h"
-#include "llvm-c/Disassembler.h"
#include <cassert>
#include <string>
class MCSymbolizer;
class MCRelocationInfo;
class MCTargetAsmParser;
+ class MCTargetOptions;
class TargetMachine;
- class MCTargetStreamer;
class TargetOptions;
class raw_ostream;
class formatted_raw_ostream;
- MCStreamer *createAsmStreamer(MCContext &Ctx,
- MCTargetStreamer *TargetStreamer,
- formatted_raw_ostream &OS, bool isVerboseAsm,
- bool useLoc, bool useCFI,
- bool useDwarfDirectory,
+ MCStreamer *createNullStreamer(MCContext &Ctx);
+ MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
+ bool isVerboseAsm, bool useDwarfDirectory,
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
MCAsmBackend *TAB, bool ShowInst);
const MCRegisterInfo &MRI,
StringRef TT,
StringRef CPU);
- typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(MCSubtargetInfo &STI,
- MCAsmParser &P,
- const MCInstrInfo &MII);
+ typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
+ MCSubtargetInfo &STI,
+ MCAsmParser &P,
+ const MCInstrInfo &MII,
+ const MCTargetOptions &Options);
typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
- const MCSubtargetInfo &STI);
+ const MCSubtargetInfo &STI,
+ MCContext &Ctx);
typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI,
MCAsmBackend &TAB,
raw_ostream &_OS,
MCCodeEmitter *_Emitter,
+ const MCSubtargetInfo &STI,
bool RelaxAll,
bool NoExecStack);
typedef MCStreamer *(*AsmStreamerCtorTy)(MCContext &Ctx,
formatted_raw_ostream &OS,
bool isVerboseAsm,
- bool useLoc,
- bool useCFI,
bool useDwarfDirectory,
MCInstPrinter *InstPrint,
MCCodeEmitter *CE,
MCAsmBackend *TAB,
bool ShowInst);
+ typedef MCStreamer *(*NullStreamerCtorTy)(MCContext &Ctx);
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
MCContext &Ctx);
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(StringRef TT,
/// AsmStreamer, if registered (default = llvm::createAsmStreamer).
AsmStreamerCtorTy AsmStreamerCtorFn;
+ /// Construction function for this target's NullStreamer, if registered
+ /// (default = llvm::createNullStreamer).
+ NullStreamerCtorTy NullStreamerCtorFn;
+
/// MCRelocationInfoCtorFn - Construction function for this target's
/// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
public:
Target()
- : AsmStreamerCtorFn(0), MCRelocationInfoCtorFn(0),
- MCSymbolizerCtorFn(0) {}
+ : AsmStreamerCtorFn(nullptr), NullStreamerCtorFn(nullptr),
+ MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
/// @name Target Information
/// @{
bool hasJIT() const { return HasJIT; }
/// hasTargetMachine - Check if this target supports code generation.
- bool hasTargetMachine() const { return TargetMachineCtorFn != 0; }
+ bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
/// hasMCAsmBackend - Check if this target supports .o generation.
- bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != 0; }
+ bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
/// @}
/// @name Feature Constructors
MCAsmInfo *createMCAsmInfo(const MCRegisterInfo &MRI,
StringRef Triple) const {
if (!MCAsmInfoCtorFn)
- return 0;
+ return nullptr;
return MCAsmInfoCtorFn(MRI, Triple);
}
CodeModel::Model CM,
CodeGenOpt::Level OL) const {
if (!MCCodeGenInfoCtorFn)
- return 0;
+ return nullptr;
return MCCodeGenInfoCtorFn(Triple, RM, CM, OL);
}
///
MCInstrInfo *createMCInstrInfo() const {
if (!MCInstrInfoCtorFn)
- return 0;
+ return nullptr;
return MCInstrInfoCtorFn();
}
///
MCInstrAnalysis *createMCInstrAnalysis(const MCInstrInfo *Info) const {
if (!MCInstrAnalysisCtorFn)
- return 0;
+ return nullptr;
return MCInstrAnalysisCtorFn(Info);
}
///
MCRegisterInfo *createMCRegInfo(StringRef Triple) const {
if (!MCRegInfoCtorFn)
- return 0;
+ return nullptr;
return MCRegInfoCtorFn(Triple);
}
MCSubtargetInfo *createMCSubtargetInfo(StringRef Triple, StringRef CPU,
StringRef Features) const {
if (!MCSubtargetInfoCtorFn)
- return 0;
+ return nullptr;
return MCSubtargetInfoCtorFn(Triple, CPU, Features);
}
CodeModel::Model CM = CodeModel::Default,
CodeGenOpt::Level OL = CodeGenOpt::Default) const {
if (!TargetMachineCtorFn)
- return 0;
+ return nullptr;
return TargetMachineCtorFn(*this, Triple, CPU, Features, Options,
RM, CM, OL);
}
MCAsmBackend *createMCAsmBackend(const MCRegisterInfo &MRI,
StringRef Triple, StringRef CPU) const {
if (!MCAsmBackendCtorFn)
- return 0;
+ return nullptr;
return MCAsmBackendCtorFn(*this, MRI, Triple, CPU);
}
///
/// \param Parser The target independent parser implementation to use for
/// parsing and lexing.
- MCTargetAsmParser *createMCAsmParser(MCSubtargetInfo &STI,
- MCAsmParser &Parser,
- const MCInstrInfo &MII) const {
+ MCTargetAsmParser *createMCAsmParser(
+ MCSubtargetInfo &STI,
+ MCAsmParser &Parser,
+ const MCInstrInfo &MII,
+ const MCTargetOptions &Options) const {
if (!MCAsmParserCtorFn)
- return 0;
- return MCAsmParserCtorFn(STI, Parser, MII);
+ return nullptr;
+ return MCAsmParserCtorFn(STI, Parser, MII, Options);
}
/// createAsmPrinter - Create a target specific assembly printer pass. This
/// takes ownership of the MCStreamer object.
AsmPrinter *createAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) const{
if (!AsmPrinterCtorFn)
- return 0;
+ return nullptr;
return AsmPrinterCtorFn(TM, Streamer);
}
- MCDisassembler *createMCDisassembler(const MCSubtargetInfo &STI) const {
+ MCDisassembler *createMCDisassembler(const MCSubtargetInfo &STI,
+ MCContext &Ctx) const {
if (!MCDisassemblerCtorFn)
- return 0;
- return MCDisassemblerCtorFn(*this, STI);
+ return nullptr;
+ return MCDisassemblerCtorFn(*this, STI, Ctx);
}
MCInstPrinter *createMCInstPrinter(unsigned SyntaxVariant,
const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) const {
if (!MCInstPrinterCtorFn)
- return 0;
+ return nullptr;
return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, MII, MRI, STI);
}
const MCSubtargetInfo &STI,
MCContext &Ctx) const {
if (!MCCodeEmitterCtorFn)
- return 0;
+ return nullptr;
return MCCodeEmitterCtorFn(II, MRI, STI, Ctx);
}
MCAsmBackend &TAB,
raw_ostream &_OS,
MCCodeEmitter *_Emitter,
+ const MCSubtargetInfo &STI,
bool RelaxAll,
bool NoExecStack) const {
if (!MCObjectStreamerCtorFn)
- return 0;
- return MCObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter,
+ return nullptr;
+ return MCObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, STI,
RelaxAll, NoExecStack);
}
MCStreamer *createAsmStreamer(MCContext &Ctx,
formatted_raw_ostream &OS,
bool isVerboseAsm,
- bool useLoc,
- bool useCFI,
bool useDwarfDirectory,
MCInstPrinter *InstPrint,
MCCodeEmitter *CE,
MCAsmBackend *TAB,
bool ShowInst) const {
if (AsmStreamerCtorFn)
- return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI,
- useDwarfDirectory, InstPrint, CE, TAB,
- ShowInst);
- return llvm::createAsmStreamer(Ctx, 0, OS, isVerboseAsm, useLoc, useCFI,
- useDwarfDirectory, InstPrint, CE, TAB,
- ShowInst);
+ return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useDwarfDirectory,
+ InstPrint, CE, TAB, ShowInst);
+ return llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useDwarfDirectory,
+ InstPrint, CE, TAB, ShowInst);
+ }
+
+ MCStreamer *createNullStreamer(MCContext &Ctx) const {
+ if (NullStreamerCtorFn)
+ return NullStreamerCtorFn(Ctx);
+ return llvm::createNullStreamer(Ctx);
}
/// createMCRelocationInfo - Create a target specific MCRelocationInfo.
explicit iterator(Target *T) : Current(T) {}
friend struct TargetRegistry;
public:
- iterator(const iterator &I) : Current(I.Current) {}
- iterator() : Current(0) {}
+ iterator() : Current(nullptr) {}
bool operator==(const iterator &x) const {
return Current == x.Current;
T.AsmStreamerCtorFn = Fn;
}
+ static void RegisterNullStreamer(Target &T, Target::NullStreamerCtorTy Fn) {
+ T.NullStreamerCtorFn = Fn;
+ }
+
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
/// implementation for the given target.
///
private:
static MCTargetAsmParser *Allocator(MCSubtargetInfo &STI, MCAsmParser &P,
- const MCInstrInfo &MII) {
- return new MCAsmParserImpl(STI, P, MII);
+ const MCInstrInfo &MII,
+ const MCTargetOptions &Options) {
+ return new MCAsmParserImpl(STI, P, MII, Options);
}
};