mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
Add MCSubtargetInfo target registry stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134279 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -35,6 +35,7 @@ namespace llvm {
|
|||||||
class MCInstPrinter;
|
class MCInstPrinter;
|
||||||
class MCInstrInfo;
|
class MCInstrInfo;
|
||||||
class MCRegisterInfo;
|
class MCRegisterInfo;
|
||||||
|
class MCSubtargetInfo;
|
||||||
class MCStreamer;
|
class MCStreamer;
|
||||||
class TargetAsmBackend;
|
class TargetAsmBackend;
|
||||||
class TargetAsmLexer;
|
class TargetAsmLexer;
|
||||||
@@ -69,6 +70,7 @@ namespace llvm {
|
|||||||
StringRef TT);
|
StringRef TT);
|
||||||
typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
|
typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
|
||||||
typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(void);
|
typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(void);
|
||||||
|
typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(void);
|
||||||
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
|
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
|
||||||
const std::string &TT,
|
const std::string &TT,
|
||||||
const std::string &CPU,
|
const std::string &CPU,
|
||||||
@@ -137,6 +139,10 @@ namespace llvm {
|
|||||||
/// if registered.
|
/// if registered.
|
||||||
MCRegInfoCtorFnTy MCRegInfoCtorFn;
|
MCRegInfoCtorFnTy MCRegInfoCtorFn;
|
||||||
|
|
||||||
|
/// MCSubtargetInfoCtorFn - Constructor function for this target's
|
||||||
|
/// MCSubtargetInfo, if registered.
|
||||||
|
MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
|
||||||
|
|
||||||
/// TargetMachineCtorFn - Construction function for this target's
|
/// TargetMachineCtorFn - Construction function for this target's
|
||||||
/// TargetMachine, if registered.
|
/// TargetMachine, if registered.
|
||||||
TargetMachineCtorTy TargetMachineCtorFn;
|
TargetMachineCtorTy TargetMachineCtorFn;
|
||||||
@@ -262,6 +268,14 @@ namespace llvm {
|
|||||||
return MCRegInfoCtorFn();
|
return MCRegInfoCtorFn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
|
||||||
|
///
|
||||||
|
MCSubtargetInfo *createMCSubtargetInfo() const {
|
||||||
|
if (!MCSubtargetInfoCtorFn)
|
||||||
|
return 0;
|
||||||
|
return MCSubtargetInfoCtorFn();
|
||||||
|
}
|
||||||
|
|
||||||
/// createTargetMachine - Create a target specific machine implementation
|
/// createTargetMachine - Create a target specific machine implementation
|
||||||
/// for the specified \arg Triple.
|
/// for the specified \arg Triple.
|
||||||
///
|
///
|
||||||
@@ -506,6 +520,22 @@ namespace llvm {
|
|||||||
T.MCRegInfoCtorFn = Fn;
|
T.MCRegInfoCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// RegisterMCSubtargetInfo - Register a MCSubtargetInfo 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 a MCSubtargetInfo for the target.
|
||||||
|
static void RegisterMCSubtargetInfo(Target &T,
|
||||||
|
Target::MCSubtargetInfoCtorFnTy Fn) {
|
||||||
|
// Ignore duplicate registration.
|
||||||
|
if (!T.MCSubtargetInfoCtorFn)
|
||||||
|
T.MCSubtargetInfoCtorFn = Fn;
|
||||||
|
}
|
||||||
|
|
||||||
/// RegisterTargetMachine - Register a TargetMachine implementation for the
|
/// RegisterTargetMachine - Register a TargetMachine implementation for the
|
||||||
/// given target.
|
/// given target.
|
||||||
///
|
///
|
||||||
@@ -782,6 +812,39 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 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:
|
||||||
|
static MCSubtargetInfo *Allocator() {
|
||||||
|
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
|
/// RegisterTargetMachine - Helper template for registering a target machine
|
||||||
/// implementation, for use in the target machine initialization
|
/// implementation, for use in the target machine initialization
|
||||||
/// function. Usage:
|
/// function. Usage:
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "X86TargetDesc.h"
|
#include "X86TargetDesc.h"
|
||||||
#include "llvm/MC/MCInstrInfo.h"
|
#include "llvm/MC/MCInstrInfo.h"
|
||||||
#include "llvm/MC/MCRegisterInfo.h"
|
#include "llvm/MC/MCRegisterInfo.h"
|
||||||
|
#include "llvm/MC/MCSubtargetInfo.h"
|
||||||
#include "llvm/Target/TargetRegistry.h"
|
#include "llvm/Target/TargetRegistry.h"
|
||||||
|
|
||||||
#define GET_REGINFO_MC_DESC
|
#define GET_REGINFO_MC_DESC
|
||||||
@@ -22,6 +23,9 @@
|
|||||||
#define GET_INSTRINFO_MC_DESC
|
#define GET_INSTRINFO_MC_DESC
|
||||||
#include "X86GenInstrInfo.inc"
|
#include "X86GenInstrInfo.inc"
|
||||||
|
|
||||||
|
#define GET_SUBTARGETINFO_MC_DESC
|
||||||
|
#include "X86GenSubtarget.inc"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MCInstrInfo *createX86MCInstrInfo() {
|
MCInstrInfo *createX86MCInstrInfo() {
|
||||||
@@ -36,7 +40,21 @@ MCRegisterInfo *createX86MCRegisterInfo() {
|
|||||||
return X;
|
return X;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCSubtargetInfo *createX86MCSubtargetInfo() {
|
||||||
|
MCSubtargetInfo *X = new MCSubtargetInfo();
|
||||||
|
InitX86MCSubtargetInfo(X);
|
||||||
|
return X;
|
||||||
|
}
|
||||||
|
|
||||||
// Force static initialization.
|
// Force static initialization.
|
||||||
|
extern "C" void LLVMInitializeX86MCInstrInfo() {
|
||||||
|
RegisterMCInstrInfo<MCInstrInfo> X(TheX86_32Target);
|
||||||
|
RegisterMCInstrInfo<MCInstrInfo> Y(TheX86_64Target);
|
||||||
|
|
||||||
|
TargetRegistry::RegisterMCInstrInfo(TheX86_32Target, createX86MCInstrInfo);
|
||||||
|
TargetRegistry::RegisterMCInstrInfo(TheX86_64Target, createX86MCInstrInfo);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void LLVMInitializeX86MCRegInfo() {
|
extern "C" void LLVMInitializeX86MCRegInfo() {
|
||||||
RegisterMCRegInfo<MCRegisterInfo> X(TheX86_32Target);
|
RegisterMCRegInfo<MCRegisterInfo> X(TheX86_32Target);
|
||||||
RegisterMCRegInfo<MCRegisterInfo> Y(TheX86_64Target);
|
RegisterMCRegInfo<MCRegisterInfo> Y(TheX86_64Target);
|
||||||
@@ -44,3 +62,13 @@ extern "C" void LLVMInitializeX86MCRegInfo() {
|
|||||||
TargetRegistry::RegisterMCRegInfo(TheX86_32Target, createX86MCRegisterInfo);
|
TargetRegistry::RegisterMCRegInfo(TheX86_32Target, createX86MCRegisterInfo);
|
||||||
TargetRegistry::RegisterMCRegInfo(TheX86_64Target, createX86MCRegisterInfo);
|
TargetRegistry::RegisterMCRegInfo(TheX86_64Target, createX86MCRegisterInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void LLVMInitializeX86MCSubtargetInfo() {
|
||||||
|
RegisterMCSubtargetInfo<MCSubtargetInfo> X(TheX86_32Target);
|
||||||
|
RegisterMCSubtargetInfo<MCSubtargetInfo> Y(TheX86_64Target);
|
||||||
|
|
||||||
|
TargetRegistry::RegisterMCSubtargetInfo(TheX86_32Target,
|
||||||
|
createX86MCSubtargetInfo);
|
||||||
|
TargetRegistry::RegisterMCSubtargetInfo(TheX86_64Target,
|
||||||
|
createX86MCSubtargetInfo);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user