2011-08-24 20:08:43 +02:00
|
|
|
//===-- Support/TargetRegistry.h - Target Registration ----------*- C++ -*-===//
|
2009-07-15 06:24:58 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file exposes the TargetRegistry interface, which tools can use to access
|
|
|
|
// the appropriate target specific classes (TargetMachine, AsmPrinter, etc.)
|
|
|
|
// which have been registered.
|
|
|
|
//
|
|
|
|
// Target specific class implementations should register themselves using the
|
|
|
|
// appropriate TargetRegistry interfaces.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-08-24 20:08:43 +02:00
|
|
|
#ifndef LLVM_SUPPORT_TARGETREGISTRY_H
|
|
|
|
#define LLVM_SUPPORT_TARGETREGISTRY_H
|
2009-07-15 06:24:58 +02:00
|
|
|
|
2014-01-07 12:48:04 +01:00
|
|
|
#include "llvm-c/Disassembler.h"
|
2009-07-26 07:03:33 +02:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2012-12-03 18:02:12 +01:00
|
|
|
#include "llvm/Support/CodeGen.h"
|
2015-04-09 23:06:08 +02:00
|
|
|
#include "llvm/Support/FormattedStream.h"
|
2009-07-15 06:24:58 +02:00
|
|
|
#include <cassert>
|
2015-01-18 21:29:04 +01:00
|
|
|
#include <memory>
|
2012-12-03 18:02:12 +01:00
|
|
|
#include <string>
|
2009-07-15 06:24:58 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
2015-05-26 23:18:29 +02:00
|
|
|
class AsmPrinter;
|
|
|
|
class MCAsmBackend;
|
|
|
|
class MCAsmInfo;
|
|
|
|
class MCAsmParser;
|
|
|
|
class MCCodeEmitter;
|
|
|
|
class MCCodeGenInfo;
|
|
|
|
class MCContext;
|
|
|
|
class MCDisassembler;
|
|
|
|
class MCInstrAnalysis;
|
|
|
|
class MCInstPrinter;
|
|
|
|
class MCInstrInfo;
|
|
|
|
class MCRegisterInfo;
|
|
|
|
class MCStreamer;
|
|
|
|
class MCSubtargetInfo;
|
|
|
|
class MCSymbolizer;
|
|
|
|
class MCRelocationInfo;
|
|
|
|
class MCTargetAsmParser;
|
|
|
|
class MCTargetOptions;
|
|
|
|
class MCTargetStreamer;
|
|
|
|
class TargetMachine;
|
|
|
|
class TargetOptions;
|
|
|
|
class raw_ostream;
|
|
|
|
class raw_pwrite_stream;
|
|
|
|
class formatted_raw_ostream;
|
|
|
|
|
|
|
|
MCStreamer *createNullStreamer(MCContext &Ctx);
|
|
|
|
MCStreamer *createAsmStreamer(MCContext &Ctx,
|
|
|
|
std::unique_ptr<formatted_raw_ostream> OS,
|
|
|
|
bool isVerboseAsm, bool useDwarfDirectory,
|
|
|
|
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
|
|
|
MCAsmBackend *TAB, bool ShowInst);
|
|
|
|
|
|
|
|
/// Takes ownership of \p TAB and \p CE.
|
|
|
|
MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
|
|
|
|
raw_pwrite_stream &OS, MCCodeEmitter *CE,
|
|
|
|
bool RelaxAll);
|
|
|
|
MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
|
2015-04-15 00:14:34 +02:00
|
|
|
raw_pwrite_stream &OS, MCCodeEmitter *CE,
|
2015-05-26 23:18:29 +02:00
|
|
|
bool RelaxAll, bool DWARFMustBeAtTheEnd,
|
|
|
|
bool LabelSections = false);
|
|
|
|
|
2015-09-15 18:17:27 +02:00
|
|
|
MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx);
|
2015-05-26 23:18:29 +02:00
|
|
|
|
2015-09-15 18:17:27 +02:00
|
|
|
MCSymbolizer *createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
|
2015-05-26 23:18:29 +02:00
|
|
|
LLVMSymbolLookupCallback SymbolLookUp,
|
|
|
|
void *DisInfo, MCContext *Ctx,
|
|
|
|
std::unique_ptr<MCRelocationInfo> &&RelInfo);
|
|
|
|
|
|
|
|
/// Target - Wrapper for Target specific information.
|
|
|
|
///
|
|
|
|
/// For registration purposes, this is a POD type so that targets can be
|
|
|
|
/// registered without the use of static constructors.
|
|
|
|
///
|
|
|
|
/// Targets should implement a single global instance of this class (which
|
|
|
|
/// will be zero initialized), and pass that instance to the TargetRegistry as
|
|
|
|
/// part of their initialization.
|
|
|
|
class Target {
|
|
|
|
public:
|
|
|
|
friend struct TargetRegistry;
|
|
|
|
|
|
|
|
typedef bool (*ArchMatchFnTy)(Triple::ArchType Arch);
|
|
|
|
|
|
|
|
typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI,
|
2015-09-15 18:17:27 +02:00
|
|
|
const Triple &TT);
|
|
|
|
typedef MCCodeGenInfo *(*MCCodeGenInfoCtorFnTy)(const Triple &TT,
|
2015-07-06 18:56:07 +02:00
|
|
|
Reloc::Model RM,
|
2011-11-16 09:38:26 +01:00
|
|
|
CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL);
|
2015-05-26 23:18:29 +02:00
|
|
|
typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
|
|
|
|
typedef MCInstrAnalysis *(*MCInstrAnalysisCtorFnTy)(const MCInstrInfo *Info);
|
2015-09-15 18:17:27 +02:00
|
|
|
typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(const Triple &TT);
|
|
|
|
typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(const Triple &TT,
|
2015-05-26 23:18:29 +02:00
|
|
|
StringRef CPU,
|
|
|
|
StringRef Features);
|
|
|
|
typedef TargetMachine *(*TargetMachineCtorTy)(
|
2015-09-15 18:17:27 +02:00
|
|
|
const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
|
2015-05-26 23:18:29 +02:00
|
|
|
const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL);
|
|
|
|
// 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,
|
2015-09-15 18:17:27 +02:00
|
|
|
const Triple &TT, StringRef CPU);
|
2015-05-26 23:18:29 +02:00
|
|
|
typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
|
2015-11-14 07:35:56 +01:00
|
|
|
const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
|
2015-05-26 23:18:29 +02:00
|
|
|
const MCTargetOptions &Options);
|
|
|
|
typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
|
|
|
|
const MCSubtargetInfo &STI,
|
2011-07-26 02:42:34 +02:00
|
|
|
MCContext &Ctx);
|
2015-09-15 18:17:27 +02:00
|
|
|
typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Triple &T,
|
2015-05-26 23:18:29 +02:00
|
|
|
unsigned SyntaxVariant,
|
|
|
|
const MCAsmInfo &MAI,
|
|
|
|
const MCInstrInfo &MII,
|
|
|
|
const MCRegisterInfo &MRI);
|
|
|
|
typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
|
|
|
|
const MCRegisterInfo &MRI,
|
|
|
|
MCContext &Ctx);
|
2015-09-15 18:17:27 +02:00
|
|
|
typedef MCStreamer *(*ELFStreamerCtorTy)(const Triple &T, MCContext &Ctx,
|
2015-05-26 23:18:29 +02:00
|
|
|
MCAsmBackend &TAB,
|
|
|
|
raw_pwrite_stream &OS,
|
|
|
|
MCCodeEmitter *Emitter,
|
|
|
|
bool RelaxAll);
|
|
|
|
typedef MCStreamer *(*MachOStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
|
2015-04-15 00:14:34 +02:00
|
|
|
raw_pwrite_stream &OS,
|
2015-03-19 02:50:16 +01:00
|
|
|
MCCodeEmitter *Emitter,
|
2015-05-26 23:18:29 +02:00
|
|
|
bool RelaxAll,
|
|
|
|
bool DWARFMustBeAtTheEnd);
|
|
|
|
typedef MCStreamer *(*COFFStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
|
|
|
|
raw_pwrite_stream &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);
|
2015-09-15 18:17:27 +02:00
|
|
|
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(const Triple &TT,
|
2015-05-26 23:18:29 +02:00
|
|
|
MCContext &Ctx);
|
|
|
|
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
|
2015-09-15 18:17:27 +02:00
|
|
|
const Triple &TT, LLVMOpInfoCallback GetOpInfo,
|
2015-05-26 23:18:29 +02:00
|
|
|
LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
|
|
|
|
std::unique_ptr<MCRelocationInfo> &&RelInfo);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// Next - The next registered target in the linked list, maintained by the
|
|
|
|
/// TargetRegistry.
|
|
|
|
Target *Next;
|
|
|
|
|
|
|
|
/// The target function for checking if an architecture is supported.
|
|
|
|
ArchMatchFnTy ArchMatchFn;
|
|
|
|
|
|
|
|
/// Name - The target name.
|
|
|
|
const char *Name;
|
|
|
|
|
|
|
|
/// ShortDesc - A short description of the target.
|
|
|
|
const char *ShortDesc;
|
|
|
|
|
|
|
|
/// HasJIT - Whether this target supports the JIT.
|
|
|
|
bool HasJIT;
|
|
|
|
|
|
|
|
/// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
|
|
|
|
/// registered.
|
|
|
|
MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
|
|
|
|
|
|
|
|
/// MCCodeGenInfoCtorFn - Constructor function for this target's
|
|
|
|
/// MCCodeGenInfo, if registered.
|
|
|
|
MCCodeGenInfoCtorFnTy MCCodeGenInfoCtorFn;
|
|
|
|
|
|
|
|
/// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
|
|
|
|
/// if registered.
|
|
|
|
MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
|
|
|
|
|
|
|
|
/// MCInstrAnalysisCtorFn - Constructor function for this target's
|
|
|
|
/// MCInstrAnalysis, if registered.
|
|
|
|
MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
|
|
|
|
|
|
|
|
/// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
|
|
|
|
/// if registered.
|
|
|
|
MCRegInfoCtorFnTy MCRegInfoCtorFn;
|
|
|
|
|
|
|
|
/// MCSubtargetInfoCtorFn - Constructor function for this target's
|
|
|
|
/// MCSubtargetInfo, if registered.
|
|
|
|
MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
|
|
|
|
|
|
|
|
/// TargetMachineCtorFn - Construction function for this target's
|
|
|
|
/// TargetMachine, if registered.
|
|
|
|
TargetMachineCtorTy TargetMachineCtorFn;
|
|
|
|
|
|
|
|
/// MCAsmBackendCtorFn - Construction function for this target's
|
|
|
|
/// MCAsmBackend, if registered.
|
|
|
|
MCAsmBackendCtorTy MCAsmBackendCtorFn;
|
|
|
|
|
|
|
|
/// MCAsmParserCtorFn - Construction function for this target's
|
|
|
|
/// MCTargetAsmParser, if registered.
|
|
|
|
MCAsmParserCtorTy MCAsmParserCtorFn;
|
|
|
|
|
|
|
|
/// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
|
|
|
|
/// if registered.
|
|
|
|
AsmPrinterCtorTy AsmPrinterCtorFn;
|
|
|
|
|
|
|
|
/// MCDisassemblerCtorFn - Construction function for this target's
|
|
|
|
/// MCDisassembler, if registered.
|
|
|
|
MCDisassemblerCtorTy MCDisassemblerCtorFn;
|
|
|
|
|
|
|
|
/// MCInstPrinterCtorFn - Construction function for this target's
|
|
|
|
/// MCInstPrinter, if registered.
|
|
|
|
MCInstPrinterCtorTy MCInstPrinterCtorFn;
|
|
|
|
|
|
|
|
/// MCCodeEmitterCtorFn - Construction function for this target's
|
|
|
|
/// CodeEmitter, if registered.
|
|
|
|
MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
|
|
|
|
|
|
|
|
// 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).
|
|
|
|
NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
|
|
|
|
|
|
|
|
/// Construction function for this target's asm TargetStreamer, if
|
|
|
|
/// 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;
|
2013-05-25 00:51:52 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// MCSymbolizerCtorFn - Construction function for this target's
|
|
|
|
/// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
|
|
|
|
MCSymbolizerCtorTy MCSymbolizerCtorFn;
|
2010-02-21 22:53:37 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
public:
|
|
|
|
Target()
|
|
|
|
: COFFStreamerCtorFn(nullptr), MachOStreamerCtorFn(nullptr),
|
|
|
|
ELFStreamerCtorFn(nullptr), NullTargetStreamerCtorFn(nullptr),
|
|
|
|
AsmTargetStreamerCtorFn(nullptr), ObjectTargetStreamerCtorFn(nullptr),
|
|
|
|
MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
|
2011-07-19 08:37:02 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @name Target Information
|
|
|
|
/// @{
|
2011-06-28 22:29:03 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
// getNext - Return the next registered target.
|
|
|
|
const Target *getNext() const { return Next; }
|
2011-08-08 20:56:44 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// getName - Get the target name.
|
|
|
|
const char *getName() const { return Name; }
|
2011-06-24 03:44:41 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// getShortDescription - Get a short description of the target.
|
|
|
|
const char *getShortDescription() const { return ShortDesc; }
|
2011-07-09 07:47:46 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @}
|
|
|
|
/// @name Feature Predicates
|
|
|
|
/// @{
|
2009-07-15 06:24:58 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// hasJIT - Check if this targets supports the just-in-time compilation.
|
|
|
|
bool hasJIT() const { return HasJIT; }
|
2010-02-21 22:53:53 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// hasTargetMachine - Check if this target supports code generation.
|
|
|
|
bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
|
2010-02-21 22:53:37 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// hasMCAsmBackend - Check if this target supports .o generation.
|
|
|
|
bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
|
2010-02-21 22:53:37 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @}
|
|
|
|
/// @name Feature Constructors
|
|
|
|
/// @{
|
2010-02-21 22:53:37 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createMCAsmInfo - Create a MCAsmInfo implementation for the specified
|
|
|
|
/// target triple.
|
|
|
|
///
|
2015-09-15 18:17:27 +02:00
|
|
|
/// \param TheTriple This argument is used to determine the target machine
|
2015-05-26 23:18:29 +02:00
|
|
|
/// feature set; it should always be provided. Generally this should be
|
|
|
|
/// either the target triple from the module, or the target triple of the
|
|
|
|
/// host if that does not exist.
|
2015-09-15 18:17:27 +02:00
|
|
|
MCAsmInfo *createMCAsmInfo(const MCRegisterInfo &MRI,
|
|
|
|
StringRef TheTriple) const {
|
2015-05-26 23:18:29 +02:00
|
|
|
if (!MCAsmInfoCtorFn)
|
2015-03-16 22:43:42 +01:00
|
|
|
return nullptr;
|
2015-09-15 18:17:27 +02:00
|
|
|
return MCAsmInfoCtorFn(MRI, Triple(TheTriple));
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
2010-11-08 03:21:17 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createMCCodeGenInfo - Create a MCCodeGenInfo implementation.
|
|
|
|
///
|
2015-07-06 18:56:07 +02:00
|
|
|
MCCodeGenInfo *createMCCodeGenInfo(StringRef TT, Reloc::Model RM,
|
2015-05-26 23:18:29 +02:00
|
|
|
CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL) const {
|
|
|
|
if (!MCCodeGenInfoCtorFn)
|
2015-02-19 01:45:02 +01:00
|
|
|
return nullptr;
|
2015-09-15 18:17:27 +02:00
|
|
|
return MCCodeGenInfoCtorFn(Triple(TT), RM, CM, OL);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
2013-05-25 00:51:52 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createMCInstrInfo - Create a MCInstrInfo implementation.
|
|
|
|
///
|
|
|
|
MCInstrInfo *createMCInstrInfo() const {
|
|
|
|
if (!MCInstrInfoCtorFn)
|
|
|
|
return nullptr;
|
|
|
|
return MCInstrInfoCtorFn();
|
|
|
|
}
|
2009-07-15 06:24:58 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
|
|
|
|
///
|
|
|
|
MCInstrAnalysis *createMCInstrAnalysis(const MCInstrInfo *Info) const {
|
|
|
|
if (!MCInstrAnalysisCtorFn)
|
|
|
|
return nullptr;
|
|
|
|
return MCInstrAnalysisCtorFn(Info);
|
|
|
|
}
|
2010-02-21 22:53:53 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createMCRegInfo - Create a MCRegisterInfo implementation.
|
|
|
|
///
|
2015-07-06 18:56:07 +02:00
|
|
|
MCRegisterInfo *createMCRegInfo(StringRef TT) const {
|
2015-05-26 23:18:29 +02:00
|
|
|
if (!MCRegInfoCtorFn)
|
|
|
|
return nullptr;
|
2015-09-15 18:17:27 +02:00
|
|
|
return MCRegInfoCtorFn(Triple(TT));
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
2010-02-21 22:53:37 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
|
|
|
|
///
|
2015-09-15 18:17:27 +02:00
|
|
|
/// \param TheTriple This argument is used to determine the target machine
|
2015-05-26 23:18:29 +02:00
|
|
|
/// feature set; it should always be provided. Generally this should be
|
|
|
|
/// either the target triple from the module, or the target triple of the
|
|
|
|
/// host if that does not exist.
|
|
|
|
/// \param CPU This specifies the name of the target CPU.
|
|
|
|
/// \param Features This specifies the string representation of the
|
|
|
|
/// additional target features.
|
2015-09-15 18:17:27 +02:00
|
|
|
MCSubtargetInfo *createMCSubtargetInfo(StringRef TheTriple, StringRef CPU,
|
2015-05-26 23:18:29 +02:00
|
|
|
StringRef Features) const {
|
|
|
|
if (!MCSubtargetInfoCtorFn)
|
|
|
|
return nullptr;
|
2015-09-15 18:17:27 +02:00
|
|
|
return MCSubtargetInfoCtorFn(Triple(TheTriple), CPU, Features);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
2010-02-21 22:53:37 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createTargetMachine - Create a target specific machine implementation
|
2015-09-15 18:17:27 +02:00
|
|
|
/// for the specified \p Triple.
|
2015-05-26 23:18:29 +02:00
|
|
|
///
|
2015-07-07 06:09:55 +02:00
|
|
|
/// \param TT This argument is used to determine the target machine
|
2015-05-26 23:18:29 +02:00
|
|
|
/// feature set; it should always be provided. Generally this should be
|
|
|
|
/// either the target triple from the module, or the target triple of the
|
|
|
|
/// host if that does not exist.
|
|
|
|
TargetMachine *
|
2015-07-06 18:56:07 +02:00
|
|
|
createTargetMachine(StringRef TT, StringRef CPU, StringRef Features,
|
2015-05-26 23:18:29 +02:00
|
|
|
const TargetOptions &Options,
|
|
|
|
Reloc::Model RM = Reloc::Default,
|
|
|
|
CodeModel::Model CM = CodeModel::Default,
|
|
|
|
CodeGenOpt::Level OL = CodeGenOpt::Default) const {
|
|
|
|
if (!TargetMachineCtorFn)
|
|
|
|
return nullptr;
|
2015-09-15 18:17:27 +02:00
|
|
|
return TargetMachineCtorFn(*this, Triple(TT), CPU, Features, Options, RM,
|
|
|
|
CM, OL);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
2009-07-15 06:24:58 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createMCAsmBackend - Create a target specific assembly parser.
|
|
|
|
///
|
2015-09-15 18:17:27 +02:00
|
|
|
/// \param TheTriple The target triple string.
|
|
|
|
MCAsmBackend *createMCAsmBackend(const MCRegisterInfo &MRI,
|
|
|
|
StringRef TheTriple, StringRef CPU) const {
|
2015-05-26 23:18:29 +02:00
|
|
|
if (!MCAsmBackendCtorFn)
|
|
|
|
return nullptr;
|
2015-09-15 18:17:27 +02:00
|
|
|
return MCAsmBackendCtorFn(*this, MRI, Triple(TheTriple), CPU);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
2010-02-21 22:53:37 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// createMCAsmParser - Create a target specific assembly parser.
|
|
|
|
///
|
|
|
|
/// \param Parser The target independent parser implementation to use for
|
|
|
|
/// parsing and lexing.
|
2015-11-14 07:35:56 +01:00
|
|
|
MCTargetAsmParser *createMCAsmParser(const MCSubtargetInfo &STI,
|
2015-05-26 23:18:29 +02:00
|
|
|
MCAsmParser &Parser,
|
|
|
|
const MCInstrInfo &MII,
|
|
|
|
const MCTargetOptions &Options) const {
|
|
|
|
if (!MCAsmParserCtorFn)
|
|
|
|
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,
|
|
|
|
std::unique_ptr<MCStreamer> &&Streamer) const {
|
|
|
|
if (!AsmPrinterCtorFn)
|
|
|
|
return nullptr;
|
|
|
|
return AsmPrinterCtorFn(TM, std::move(Streamer));
|
|
|
|
}
|
2009-08-27 02:51:57 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
MCDisassembler *createMCDisassembler(const MCSubtargetInfo &STI,
|
|
|
|
MCContext &Ctx) const {
|
|
|
|
if (!MCDisassemblerCtorFn)
|
|
|
|
return nullptr;
|
|
|
|
return MCDisassemblerCtorFn(*this, STI, Ctx);
|
|
|
|
}
|
|
|
|
|
2015-09-15 18:17:27 +02:00
|
|
|
MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
|
2015-05-26 23:18:29 +02:00
|
|
|
const MCAsmInfo &MAI,
|
|
|
|
const MCInstrInfo &MII,
|
|
|
|
const MCRegisterInfo &MRI) const {
|
|
|
|
if (!MCInstPrinterCtorFn)
|
|
|
|
return nullptr;
|
2015-09-15 18:17:27 +02:00
|
|
|
return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// createMCCodeEmitter - Create a target specific code emitter.
|
|
|
|
MCCodeEmitter *createMCCodeEmitter(const MCInstrInfo &II,
|
|
|
|
const MCRegisterInfo &MRI,
|
|
|
|
MCContext &Ctx) const {
|
|
|
|
if (!MCCodeEmitterCtorFn)
|
|
|
|
return nullptr;
|
|
|
|
return MCCodeEmitterCtorFn(II, MRI, Ctx);
|
|
|
|
}
|
2015-03-19 02:50:16 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// Create a target specific MCStreamer.
|
|
|
|
///
|
2015-09-15 18:17:27 +02:00
|
|
|
/// \param T The target triple.
|
2015-05-26 23:18:29 +02:00
|
|
|
/// \param Ctx The target context.
|
|
|
|
/// \param TAB The target assembler backend object. Takes ownership.
|
|
|
|
/// \param OS The stream object.
|
|
|
|
/// \param Emitter The target independent assembler object.Takes ownership.
|
|
|
|
/// \param RelaxAll Relax all fixups?
|
2015-09-15 18:17:27 +02:00
|
|
|
MCStreamer *createMCObjectStreamer(const Triple &T, MCContext &Ctx,
|
2015-05-26 23:18:29 +02:00
|
|
|
MCAsmBackend &TAB, raw_pwrite_stream &OS,
|
|
|
|
MCCodeEmitter *Emitter,
|
|
|
|
const MCSubtargetInfo &STI, bool RelaxAll,
|
|
|
|
bool DWARFMustBeAtTheEnd) const {
|
|
|
|
MCStreamer *S;
|
2015-09-15 18:17:27 +02:00
|
|
|
switch (T.getObjectFormat()) {
|
2015-05-26 23:18:29 +02:00
|
|
|
default:
|
|
|
|
llvm_unreachable("Unknown object format");
|
2015-09-15 18:17:27 +02:00
|
|
|
case Triple::COFF:
|
|
|
|
assert(T.isOSWindows() && "only Windows COFF is supported");
|
2015-05-26 23:18:29 +02:00
|
|
|
S = COFFStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll);
|
|
|
|
break;
|
2015-09-15 18:17:27 +02:00
|
|
|
case Triple::MachO:
|
2015-05-26 23:18:29 +02:00
|
|
|
if (MachOStreamerCtorFn)
|
|
|
|
S = MachOStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll,
|
|
|
|
DWARFMustBeAtTheEnd);
|
|
|
|
else
|
|
|
|
S = createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll,
|
|
|
|
DWARFMustBeAtTheEnd);
|
|
|
|
break;
|
2015-09-15 18:17:27 +02:00
|
|
|
case Triple::ELF:
|
2015-05-26 23:18:29 +02:00
|
|
|
if (ELFStreamerCtorFn)
|
2015-09-15 18:17:27 +02:00
|
|
|
S = ELFStreamerCtorFn(T, Ctx, TAB, OS, Emitter, RelaxAll);
|
2015-05-26 23:18:29 +02:00
|
|
|
else
|
|
|
|
S = createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ObjectTargetStreamerCtorFn)
|
|
|
|
ObjectTargetStreamerCtorFn(*S, STI);
|
|
|
|
return S;
|
|
|
|
}
|
2015-03-19 02:50:16 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
MCStreamer *createAsmStreamer(MCContext &Ctx,
|
|
|
|
std::unique_ptr<formatted_raw_ostream> OS,
|
|
|
|
bool IsVerboseAsm, bool UseDwarfDirectory,
|
|
|
|
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
|
|
|
MCAsmBackend *TAB, bool ShowInst) const {
|
|
|
|
formatted_raw_ostream &OSRef = *OS;
|
|
|
|
MCStreamer *S = llvm::createAsmStreamer(Ctx, std::move(OS), IsVerboseAsm,
|
|
|
|
UseDwarfDirectory, InstPrint, CE,
|
|
|
|
TAB, ShowInst);
|
|
|
|
createAsmTargetStreamer(*S, OSRef, 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 {
|
|
|
|
MCStreamer *S = llvm::createNullStreamer(Ctx);
|
|
|
|
createNullTargetStreamer(*S);
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) const {
|
|
|
|
if (NullTargetStreamerCtorFn)
|
|
|
|
return NullTargetStreamerCtorFn(S);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// createMCRelocationInfo - Create a target specific MCRelocationInfo.
|
|
|
|
///
|
|
|
|
/// \param TT The target triple.
|
|
|
|
/// \param Ctx The target context.
|
|
|
|
MCRelocationInfo *createMCRelocationInfo(StringRef TT, MCContext &Ctx) const {
|
|
|
|
MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
|
|
|
|
? MCRelocationInfoCtorFn
|
|
|
|
: llvm::createMCRelocationInfo;
|
2015-09-15 18:17:27 +02:00
|
|
|
return Fn(Triple(TT), Ctx);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// createMCSymbolizer - Create a target specific MCSymbolizer.
|
|
|
|
///
|
|
|
|
/// \param TT The target triple.
|
|
|
|
/// \param GetOpInfo The function to get the symbolic information for
|
|
|
|
/// operands.
|
|
|
|
/// \param SymbolLookUp The function to lookup a symbol name.
|
|
|
|
/// \param DisInfo The pointer to the block of symbolic information for above
|
|
|
|
/// call
|
|
|
|
/// back.
|
|
|
|
/// \param Ctx The target context.
|
|
|
|
/// \param RelInfo The relocation information for this target. Takes
|
|
|
|
/// ownership.
|
|
|
|
MCSymbolizer *
|
|
|
|
createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo,
|
|
|
|
LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
|
|
|
|
MCContext *Ctx,
|
|
|
|
std::unique_ptr<MCRelocationInfo> &&RelInfo) const {
|
|
|
|
MCSymbolizerCtorTy Fn =
|
|
|
|
MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
|
2015-09-15 18:17:27 +02:00
|
|
|
return Fn(Triple(TT), GetOpInfo, SymbolLookUp, DisInfo, Ctx,
|
2015-07-06 18:56:07 +02:00
|
|
|
std::move(RelInfo));
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// TargetRegistry - Generic interface to target specific features.
|
|
|
|
struct TargetRegistry {
|
|
|
|
// FIXME: Make this a namespace, probably just move all the Register*
|
|
|
|
// functions into Target (currently they all just set members on the Target
|
|
|
|
// anyway, and Target friends this class so those functions can...
|
|
|
|
// function).
|
|
|
|
TargetRegistry() = delete;
|
|
|
|
|
|
|
|
class iterator
|
|
|
|
: public std::iterator<std::forward_iterator_tag, Target, ptrdiff_t> {
|
|
|
|
const Target *Current;
|
|
|
|
explicit iterator(Target *T) : Current(T) {}
|
|
|
|
friend struct TargetRegistry;
|
2010-05-21 14:54:43 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
public:
|
|
|
|
iterator() : Current(nullptr) {}
|
2015-02-19 01:45:02 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
bool operator==(const iterator &x) const { return Current == x.Current; }
|
|
|
|
bool operator!=(const iterator &x) const { return !operator==(x); }
|
2015-03-16 22:43:42 +01:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
// Iterator traversal: forward iteration only
|
|
|
|
iterator &operator++() { // Preincrement
|
|
|
|
assert(Current && "Cannot increment end iterator!");
|
|
|
|
Current = Current->getNext();
|
|
|
|
return *this;
|
2015-03-19 02:50:16 +01:00
|
|
|
}
|
2015-05-26 23:18:29 +02:00
|
|
|
iterator operator++(int) { // Postincrement
|
|
|
|
iterator tmp = *this;
|
|
|
|
++*this;
|
|
|
|
return tmp;
|
Add MCSymbolizer for symbolic/annotated disassembly.
This is a basic first step towards symbolization of disassembled
instructions. This used to be done using externally provided (C API)
callbacks. This patch introduces:
- the MCSymbolizer class, that mimics the same functions that were used
in the X86 and ARM disassemblers to symbolize immediate operands and
to annotate loads based off PC (for things like c string literals).
- the MCExternalSymbolizer class, which implements the old C API.
- the MCRelocationInfo class, which provides a way for targets to
translate relocations (either object::RelocationRef, or disassembler
C API VariantKinds) to MCExprs.
- the MCObjectSymbolizer class, which does symbolization using what it
finds in an object::ObjectFile. This makes simple symbolization (with
no fancy relocation stuff) work for all object formats!
- x86-64 Mach-O and ELF MCRelocationInfos.
- A basic ARM Mach-O MCRelocationInfo, that provides just enough to
support the C API VariantKinds.
Most of what works in otool (the only user of the old symbolization API
that I know of) for x86-64 symbolic disassembly (-tvV) works, namely:
- symbol references: call _foo; jmp 15 <_foo+50>
- relocations: call _foo-_bar; call _foo-4
- __cf?string: leaq 193(%rip), %rax ## literal pool for "hello"
Stub support is the main missing part (because libObject doesn't know,
among other things, about mach-o indirect symbols).
As for the MCSymbolizer API, instead of relying on the disassemblers
to call the tryAdding* methods, maybe this could be done automagically
using InstrInfo? For instance, even though PC-relative LEAs are used
to get the address of string literals in a typical Mach-O file, a MOV
would be used in an ELF file. And right now, the explicit symbolization
only recognizes PC-relative LEAs. InstrInfo should have already have
most of what is needed to know what to symbolize, so this can
definitely be improved.
I'd also like to remove object::RelocationRef::getValueString (it seems
only used by relocation printing in objdump), as simply printing the
created MCExpr is definitely enough (and cleaner than string concats).
llvm-svn: 182625
2013-05-24 02:39:57 +02:00
|
|
|
}
|
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
const Target &operator*() const {
|
|
|
|
assert(Current && "Cannot dereference end iterator!");
|
|
|
|
return *Current;
|
2013-05-25 00:51:52 +02:00
|
|
|
}
|
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
const Target *operator->() const { return &operator*(); }
|
2009-07-15 06:24:58 +02:00
|
|
|
};
|
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// printRegisteredTargetsForVersion - Print the registered targets
|
|
|
|
/// appropriately for inclusion in a tool's version output.
|
|
|
|
static void printRegisteredTargetsForVersion();
|
|
|
|
|
|
|
|
/// @name Registry Access
|
|
|
|
/// @{
|
2009-07-25 08:49:55 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
static iterator_range<iterator> targets();
|
2009-07-25 08:49:55 +02:00
|
|
|
|
2015-05-26 23:18:29 +02:00
|
|
|
/// lookupTarget - Lookup a target based on a target triple.
|
2009-07-25 08:49:55 +02:00
|
|
|
///
|
2015-09-15 18:17:27 +02:00
|
|
|
/// \param Triple - The triple to use for finding a target.
|
2015-05-26 23:18:29 +02:00
|
|
|
/// \param Error - On failure, an error string describing why no target was
|
|
|
|
/// found.
|
2015-09-15 18:17:27 +02:00
|
|
|
static const Target *lookupTarget(const std::string &Triple,
|
|
|
|
std::string &Error);
|
2015-05-26 23:18:29 +02:00
|
|
|
|
|
|
|
/// lookupTarget - Lookup a target based on an architecture name
|
|
|
|
/// and a target triple. If the architecture name is non-empty,
|
|
|
|
/// then the lookup is done by architecture. Otherwise, the target
|
|
|
|
/// triple is used.
|
2009-07-25 08:49:55 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// \param ArchName - The architecture to use for finding a target.
|
2015-09-15 18:17:27 +02:00
|
|
|
/// \param TheTriple - The triple to use for finding a target. The
|
2015-05-26 23:18:29 +02:00
|
|
|
/// triple is updated with canonical architecture name if a lookup
|
|
|
|
/// by architecture is done.
|
|
|
|
/// \param Error - On failure, an error string describing why no target was
|
|
|
|
/// found.
|
2015-09-15 18:17:27 +02:00
|
|
|
static const Target *lookupTarget(const std::string &ArchName,
|
|
|
|
Triple &TheTriple, std::string &Error);
|
2015-05-26 23:18:29 +02:00
|
|
|
|
|
|
|
/// @}
|
|
|
|
/// @name Target Registration
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// RegisterTarget - Register the given target. Attempts to register a
|
|
|
|
/// target which has already been registered will be ignored.
|
2009-07-25 08:49:55 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2009-08-12 09:22:17 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Name - The target name. This should be a static string.
|
|
|
|
/// @param ShortDesc - A short target description. This should be a static
|
|
|
|
/// string.
|
|
|
|
/// @param ArchMatchFn - The arch match checking function for this target.
|
|
|
|
/// @param HasJIT - Whether the target supports JIT code
|
|
|
|
/// generation.
|
|
|
|
static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc,
|
|
|
|
Target::ArchMatchFnTy ArchMatchFn,
|
|
|
|
bool HasJIT = false);
|
|
|
|
|
|
|
|
/// RegisterMCAsmInfo - Register a MCAsmInfo implementation for the
|
|
|
|
/// given target.
|
2009-08-12 09:22:17 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2011-07-19 08:37:02 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Fn - A function to construct a MCAsmInfo for the target.
|
|
|
|
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn) {
|
|
|
|
T.MCAsmInfoCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCCodeGenInfo - Register a MCCodeGenInfo implementation for the
|
|
|
|
/// given target.
|
2011-07-19 08:37:02 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2011-06-28 22:29:03 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Fn - A function to construct a MCCodeGenInfo for the target.
|
|
|
|
static void RegisterMCCodeGenInfo(Target &T,
|
|
|
|
Target::MCCodeGenInfoCtorFnTy Fn) {
|
|
|
|
T.MCCodeGenInfoCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
|
|
|
|
/// given target.
|
2011-06-28 22:29:03 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2011-08-23 22:15:21 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Fn - A function to construct a MCInstrInfo for the target.
|
|
|
|
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn) {
|
|
|
|
T.MCInstrInfoCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
|
|
|
|
/// the given target.
|
|
|
|
static void RegisterMCInstrAnalysis(Target &T,
|
|
|
|
Target::MCInstrAnalysisCtorFnTy Fn) {
|
|
|
|
T.MCInstrAnalysisCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
|
|
|
|
/// given target.
|
2011-08-23 22:15:21 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2011-06-24 22:42:09 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Fn - A function to construct a MCRegisterInfo for the target.
|
|
|
|
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn) {
|
|
|
|
T.MCRegInfoCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
|
|
|
|
/// the given target.
|
2011-06-24 22:42:09 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2011-07-09 07:47:46 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Fn - A function to construct a MCSubtargetInfo for the target.
|
|
|
|
static void RegisterMCSubtargetInfo(Target &T,
|
|
|
|
Target::MCSubtargetInfoCtorFnTy Fn) {
|
|
|
|
T.MCSubtargetInfoCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterTargetMachine - Register a TargetMachine implementation for the
|
|
|
|
/// given target.
|
2011-07-09 07:47:46 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2009-07-25 08:49:55 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Fn - A function to construct a TargetMachine for the target.
|
|
|
|
static void RegisterTargetMachine(Target &T, Target::TargetMachineCtorTy Fn) {
|
|
|
|
T.TargetMachineCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
|
|
|
|
/// given target.
|
2010-02-21 22:53:53 +01:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2009-07-25 08:49:55 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Fn - A function to construct an AsmBackend for the target.
|
|
|
|
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn) {
|
|
|
|
T.MCAsmBackendCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
|
|
|
|
/// the given target.
|
2010-02-21 22:53:37 +01:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// 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.
|
2009-08-27 02:51:57 +02:00
|
|
|
///
|
2015-05-26 23:18:29 +02:00
|
|
|
/// @param T - The target being registered.
|
|
|
|
/// @param Fn - A function to construct an MCTargetAsmParser for the target.
|
|
|
|
static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn) {
|
|
|
|
T.MCAsmParserCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterAsmPrinter - Register an AsmPrinter 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 AsmPrinter for the target.
|
|
|
|
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) {
|
|
|
|
T.AsmPrinterCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCDisassembler - Register a MCDisassembler 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 MCDisassembler for the target.
|
|
|
|
static void RegisterMCDisassembler(Target &T,
|
|
|
|
Target::MCDisassemblerCtorTy Fn) {
|
|
|
|
T.MCDisassemblerCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCInstPrinter - Register a MCInstPrinter 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 MCInstPrinter for the target.
|
|
|
|
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn) {
|
|
|
|
T.MCInstPrinterCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCCodeEmitter - Register a MCCodeEmitter 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 MCCodeEmitter for the target.
|
|
|
|
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn) {
|
|
|
|
T.MCCodeEmitterCtorFn = 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 RegisterNullTargetStreamer(Target &T,
|
|
|
|
Target::NullTargetStreamerCtorTy Fn) {
|
|
|
|
T.NullTargetStreamerCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void RegisterAsmTargetStreamer(Target &T,
|
|
|
|
Target::AsmTargetStreamerCtorTy Fn) {
|
|
|
|
T.AsmTargetStreamerCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RegisterObjectTargetStreamer(Target &T,
|
|
|
|
Target::ObjectTargetStreamerCtorTy Fn) {
|
|
|
|
T.ObjectTargetStreamerCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
|
|
|
/// 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 MCRelocationInfo for the target.
|
|
|
|
static void RegisterMCRelocationInfo(Target &T,
|
|
|
|
Target::MCRelocationInfoCtorTy Fn) {
|
|
|
|
T.MCRelocationInfoCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RegisterMCSymbolizer - Register an MCSymbolizer
|
|
|
|
/// 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 MCSymbolizer for the target.
|
|
|
|
static void RegisterMCSymbolizer(Target &T, Target::MCSymbolizerCtorTy Fn) {
|
|
|
|
T.MCSymbolizerCtorFn = Fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
};
|
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// RegisterTarget - Helper template for registering a target, for use in the
|
|
|
|
/// target's initialization function. Usage:
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Target TheFooTarget; // The global target instance.
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTargetInfo() {
|
|
|
|
/// RegisterTarget<Triple::foo> X(TheFooTarget, "foo", "Foo description");
|
|
|
|
/// }
|
|
|
|
template <Triple::ArchType TargetArchType = Triple::UnknownArch,
|
|
|
|
bool HasJIT = false>
|
|
|
|
struct RegisterTarget {
|
|
|
|
RegisterTarget(Target &T, const char *Name, const char *Desc) {
|
|
|
|
TargetRegistry::RegisterTarget(T, Name, Desc, &getArchMatch, HasJIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool getArchMatch(Triple::ArchType Arch) {
|
|
|
|
return Arch == TargetArchType;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCAsmInfo - Helper template for registering a target assembly info
|
|
|
|
/// implementation. This invokes the static "Create" method on the class to
|
|
|
|
/// actually do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCAsmInfoImpl> struct RegisterMCAsmInfo {
|
|
|
|
RegisterMCAsmInfo(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCAsmInfo(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-06-04 15:12:25 +02:00
|
|
|
static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/,
|
2015-09-15 18:17:27 +02:00
|
|
|
const Triple &TT) {
|
|
|
|
return new MCAsmInfoImpl(TT);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
|
|
|
|
/// implementation. This invokes the specified function to do the
|
|
|
|
/// construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
|
|
|
|
/// }
|
|
|
|
struct RegisterMCAsmInfoFn {
|
|
|
|
RegisterMCAsmInfoFn(Target &T, Target::MCAsmInfoCtorFnTy Fn) {
|
|
|
|
TargetRegistry::RegisterMCAsmInfo(T, Fn);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCCodeGenInfo - Helper template for registering a target codegen
|
|
|
|
/// info
|
|
|
|
/// implementation. This invokes the static "Create" method on the class
|
|
|
|
/// to actually do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCCodeGenInfo<FooMCCodeGenInfo> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCCodeGenInfoImpl> struct RegisterMCCodeGenInfo {
|
|
|
|
RegisterMCCodeGenInfo(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCCodeGenInfo(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-09-15 18:17:27 +02:00
|
|
|
static MCCodeGenInfo *Allocator(const Triple & /*TT*/, Reloc::Model /*RM*/,
|
|
|
|
CodeModel::Model /*CM*/,
|
2015-05-26 23:18:29 +02:00
|
|
|
CodeGenOpt::Level /*OL*/) {
|
|
|
|
return new MCCodeGenInfoImpl();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCCodeGenInfoFn - Helper template for registering a target codegen
|
|
|
|
/// info implementation. This invokes the specified function to do the
|
|
|
|
/// construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCCodeGenInfoFn X(TheFooTarget, TheFunction);
|
|
|
|
/// }
|
|
|
|
struct RegisterMCCodeGenInfoFn {
|
|
|
|
RegisterMCCodeGenInfoFn(Target &T, Target::MCCodeGenInfoCtorFnTy Fn) {
|
|
|
|
TargetRegistry::RegisterMCCodeGenInfo(T, Fn);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCInstrInfo - Helper template for registering a target instruction
|
|
|
|
/// info implementation. This invokes the static "Create" method on the class
|
|
|
|
/// to actually do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCInstrInfoImpl> struct RegisterMCInstrInfo {
|
|
|
|
RegisterMCInstrInfo(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static MCInstrInfo *Allocator() { return new MCInstrInfoImpl(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCInstrInfoFn - Helper template for registering a target
|
|
|
|
/// instruction info implementation. This invokes the specified function to
|
|
|
|
/// do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
|
|
|
|
/// }
|
|
|
|
struct RegisterMCInstrInfoFn {
|
|
|
|
RegisterMCInstrInfoFn(Target &T, Target::MCInstrInfoCtorFnTy Fn) {
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(T, Fn);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCInstrAnalysis - Helper template for registering a target
|
|
|
|
/// instruction analyzer implementation. This invokes the static "Create"
|
|
|
|
/// method on the class to actually do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCInstrAnalysisImpl> struct RegisterMCInstrAnalysis {
|
|
|
|
RegisterMCInstrAnalysis(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCInstrAnalysis(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
|
|
|
|
return new MCInstrAnalysisImpl(Info);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCInstrAnalysisFn - Helper template for registering a target
|
|
|
|
/// instruction analyzer implementation. This invokes the specified function
|
|
|
|
/// to do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
|
|
|
|
/// }
|
|
|
|
struct RegisterMCInstrAnalysisFn {
|
|
|
|
RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn) {
|
|
|
|
TargetRegistry::RegisterMCInstrAnalysis(T, Fn);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCRegInfo - Helper template for registering a target register info
|
|
|
|
/// implementation. This invokes the static "Create" method on the class to
|
|
|
|
/// actually do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCRegisterInfoImpl> struct RegisterMCRegInfo {
|
|
|
|
RegisterMCRegInfo(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCRegInfo(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-09-15 18:17:27 +02:00
|
|
|
static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
|
2015-05-26 23:18:29 +02:00
|
|
|
return new MCRegisterInfoImpl();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCRegInfoFn - Helper template for registering a target register
|
|
|
|
/// info implementation. This invokes the specified function to do the
|
|
|
|
/// construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
|
|
|
|
/// }
|
|
|
|
struct RegisterMCRegInfoFn {
|
|
|
|
RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn) {
|
|
|
|
TargetRegistry::RegisterMCRegInfo(T, Fn);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCSubtargetInfo - Helper template for registering a target
|
|
|
|
/// subtarget info implementation. This invokes the static "Create" method
|
|
|
|
/// on the class to actually do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCSubtargetInfoImpl> struct RegisterMCSubtargetInfo {
|
|
|
|
RegisterMCSubtargetInfo(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-09-15 18:17:27 +02:00
|
|
|
static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
|
|
|
|
StringRef /*FS*/) {
|
2015-05-26 23:18:29 +02:00
|
|
|
return new MCSubtargetInfoImpl();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCSubtargetInfoFn - Helper template for registering a target
|
|
|
|
/// subtarget info implementation. This invokes the specified function to
|
|
|
|
/// do the construction. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
|
|
|
|
/// }
|
|
|
|
struct RegisterMCSubtargetInfoFn {
|
|
|
|
RegisterMCSubtargetInfoFn(Target &T, Target::MCSubtargetInfoCtorFnTy Fn) {
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(T, Fn);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterTargetMachine - Helper template for registering a target machine
|
|
|
|
/// implementation, for use in the target machine initialization
|
|
|
|
/// function. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooTarget() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class TargetMachineImpl> struct RegisterTargetMachine {
|
|
|
|
RegisterTargetMachine(Target &T) {
|
|
|
|
TargetRegistry::RegisterTargetMachine(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-09-15 18:17:27 +02:00
|
|
|
static TargetMachine *Allocator(const Target &T, const Triple &TT,
|
2015-07-06 18:56:07 +02:00
|
|
|
StringRef CPU, StringRef FS,
|
|
|
|
const TargetOptions &Options, Reloc::Model RM,
|
|
|
|
CodeModel::Model CM, CodeGenOpt::Level OL) {
|
2015-09-15 18:17:27 +02:00
|
|
|
return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCAsmBackend - Helper template for registering a target specific
|
|
|
|
/// assembler backend. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooMCAsmBackend() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCAsmBackendImpl> struct RegisterMCAsmBackend {
|
|
|
|
RegisterMCAsmBackend(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCAsmBackend(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static MCAsmBackend *Allocator(const Target &T, const MCRegisterInfo &MRI,
|
2015-09-15 18:17:27 +02:00
|
|
|
const Triple &TheTriple, StringRef CPU) {
|
|
|
|
return new MCAsmBackendImpl(T, MRI, TheTriple, CPU);
|
2015-05-26 23:18:29 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCAsmParser - Helper template for registering a target specific
|
|
|
|
/// assembly parser, for use in the target machine initialization
|
|
|
|
/// function. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooMCAsmParser() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCAsmParserImpl> struct RegisterMCAsmParser {
|
|
|
|
RegisterMCAsmParser(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCAsmParser(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-11-14 07:35:56 +01:00
|
|
|
static MCTargetAsmParser *Allocator(const MCSubtargetInfo &STI,
|
|
|
|
MCAsmParser &P, const MCInstrInfo &MII,
|
2015-05-26 23:18:29 +02:00
|
|
|
const MCTargetOptions &Options) {
|
|
|
|
return new MCAsmParserImpl(STI, P, MII, Options);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterAsmPrinter - Helper template for registering a target specific
|
|
|
|
/// assembly printer, for use in the target machine initialization
|
|
|
|
/// function. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooAsmPrinter() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class AsmPrinterImpl> struct RegisterAsmPrinter {
|
|
|
|
RegisterAsmPrinter(Target &T) {
|
|
|
|
TargetRegistry::RegisterAsmPrinter(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static AsmPrinter *Allocator(TargetMachine &TM,
|
|
|
|
std::unique_ptr<MCStreamer> &&Streamer) {
|
|
|
|
return new AsmPrinterImpl(TM, std::move(Streamer));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// RegisterMCCodeEmitter - Helper template for registering a target specific
|
|
|
|
/// machine code emitter, for use in the target initialization
|
|
|
|
/// function. Usage:
|
|
|
|
///
|
|
|
|
/// extern "C" void LLVMInitializeFooMCCodeEmitter() {
|
|
|
|
/// extern Target TheFooTarget;
|
|
|
|
/// RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
|
|
|
|
/// }
|
|
|
|
template <class MCCodeEmitterImpl> struct RegisterMCCodeEmitter {
|
|
|
|
RegisterMCCodeEmitter(Target &T) {
|
|
|
|
TargetRegistry::RegisterMCCodeEmitter(T, &Allocator);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static MCCodeEmitter *Allocator(const MCInstrInfo & /*II*/,
|
|
|
|
const MCRegisterInfo & /*MRI*/,
|
|
|
|
MCContext & /*Ctx*/) {
|
|
|
|
return new MCCodeEmitterImpl();
|
|
|
|
}
|
|
|
|
};
|
2015-06-23 11:49:53 +02:00
|
|
|
}
|
2009-07-15 06:24:58 +02:00
|
|
|
|
|
|
|
#endif
|