mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-10 02:29:32 +00:00
Add MCInstrInfo registeration machinery.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134026 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
22fee2dff4
commit
94b01f6882
@ -33,6 +33,7 @@ namespace llvm {
|
|||||||
class MCContext;
|
class MCContext;
|
||||||
class MCDisassembler;
|
class MCDisassembler;
|
||||||
class MCInstPrinter;
|
class MCInstPrinter;
|
||||||
|
class MCInstrInfo;
|
||||||
class MCRegisterInfo;
|
class MCRegisterInfo;
|
||||||
class MCStreamer;
|
class MCStreamer;
|
||||||
class TargetAsmBackend;
|
class TargetAsmBackend;
|
||||||
@ -66,6 +67,7 @@ namespace llvm {
|
|||||||
|
|
||||||
typedef MCAsmInfo *(*AsmInfoCtorFnTy)(const Target &T,
|
typedef MCAsmInfo *(*AsmInfoCtorFnTy)(const Target &T,
|
||||||
StringRef TT);
|
StringRef TT);
|
||||||
|
typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
|
||||||
typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(void);
|
typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(void);
|
||||||
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
|
typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
|
||||||
const std::string &TT,
|
const std::string &TT,
|
||||||
@ -126,6 +128,10 @@ namespace llvm {
|
|||||||
/// registered.
|
/// registered.
|
||||||
AsmInfoCtorFnTy AsmInfoCtorFn;
|
AsmInfoCtorFnTy AsmInfoCtorFn;
|
||||||
|
|
||||||
|
/// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
|
||||||
|
/// if registered.
|
||||||
|
MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
|
||||||
|
|
||||||
/// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
|
/// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
|
||||||
/// if registered.
|
/// if registered.
|
||||||
MCRegInfoCtorFnTy MCRegInfoCtorFn;
|
MCRegInfoCtorFnTy MCRegInfoCtorFn;
|
||||||
@ -239,6 +245,14 @@ namespace llvm {
|
|||||||
return AsmInfoCtorFn(*this, Triple);
|
return AsmInfoCtorFn(*this, Triple);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// createMCInstrInfo - Create a MCInstrInfo implementation.
|
||||||
|
///
|
||||||
|
MCInstrInfo *createMCInstrInfo() const {
|
||||||
|
if (!MCInstrInfoCtorFn)
|
||||||
|
return 0;
|
||||||
|
return MCInstrInfoCtorFn();
|
||||||
|
}
|
||||||
|
|
||||||
/// createMCRegInfo - Create a MCRegisterInfo implementation.
|
/// createMCRegInfo - Create a MCRegisterInfo implementation.
|
||||||
///
|
///
|
||||||
MCRegisterInfo *createMCRegInfo() const {
|
MCRegisterInfo *createMCRegInfo() const {
|
||||||
@ -460,6 +474,21 @@ namespace llvm {
|
|||||||
T.AsmInfoCtorFn = Fn;
|
T.AsmInfoCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// RegisterMCInstrInfo - Register a MCInstrInfo 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 MCInstrInfo for the target.
|
||||||
|
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn) {
|
||||||
|
// Ignore duplicate registration.
|
||||||
|
if (!T.MCInstrInfoCtorFn)
|
||||||
|
T.MCInstrInfoCtorFn = Fn;
|
||||||
|
}
|
||||||
|
|
||||||
/// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
|
/// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
|
||||||
/// given target.
|
/// given target.
|
||||||
///
|
///
|
||||||
@ -685,6 +714,39 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// RegisterMCRegInfo - Helper template for registering a target register info
|
/// RegisterMCRegInfo - Helper template for registering a target register info
|
||||||
/// implementation. This invokes the static "Create" method on the class to
|
/// implementation. This invokes the static "Create" method on the class to
|
||||||
/// actually do the construction. Usage:
|
/// actually do the construction. Usage:
|
||||||
|
@ -24,6 +24,12 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
MCInstrInfo *createX86MCInstrInfo() {
|
||||||
|
MCInstrInfo *X = new MCInstrInfo();
|
||||||
|
InitX86MCInstrInfo(X);
|
||||||
|
return X;
|
||||||
|
}
|
||||||
|
|
||||||
MCRegisterInfo *createX86MCRegisterInfo() {
|
MCRegisterInfo *createX86MCRegisterInfo() {
|
||||||
MCRegisterInfo *X = new MCRegisterInfo();
|
MCRegisterInfo *X = new MCRegisterInfo();
|
||||||
InitX86MCRegisterInfo(X);
|
InitX86MCRegisterInfo(X);
|
||||||
|
@ -206,7 +206,15 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
|
|||||||
for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i)
|
for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i)
|
||||||
emitRecord(*NumberedInstructions[i], i, InstrInfo, EmittedLists,
|
emitRecord(*NumberedInstructions[i], i, InstrInfo, EmittedLists,
|
||||||
OperandInfoIDs, OS);
|
OperandInfoIDs, OS);
|
||||||
OS << "};\n";
|
OS << "};\n\n";
|
||||||
|
|
||||||
|
|
||||||
|
// MCInstrInfo initialization routine.
|
||||||
|
OS << "static inline void Init" << TargetName
|
||||||
|
<< "MCInstrInfo(MCInstrInfo *II) {\n";
|
||||||
|
OS << " II->InitMCInstrInfo(" << TargetName << "Insts, "
|
||||||
|
<< NumberedInstructions.size() << ");\n}\n\n";
|
||||||
|
|
||||||
OS << "} // End llvm namespace \n";
|
OS << "} // End llvm namespace \n";
|
||||||
|
|
||||||
OS << "#endif // GET_INSTRINFO_MC_DESC\n\n";
|
OS << "#endif // GET_INSTRINFO_MC_DESC\n\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user