diff options
Diffstat (limited to 'include/llvm/Target/TargetRegistry.h')
-rw-r--r-- | include/llvm/Target/TargetRegistry.h | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h index a464822893..2e219011ab 100644 --- a/include/llvm/Target/TargetRegistry.h +++ b/include/llvm/Target/TargetRegistry.h @@ -33,6 +33,7 @@ namespace llvm { class MCContext; class MCDisassembler; class MCInstPrinter; + class MCRegisterInfo; class MCStreamer; class TargetAsmBackend; class TargetAsmLexer; @@ -64,7 +65,9 @@ namespace llvm { typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT); typedef MCAsmInfo *(*AsmInfoCtorFnTy)(const Target &T, - StringRef TT); + StringRef TT); + typedef MCRegisterInfo *(*RegInfoCtorFnTy)(const Target &T, + StringRef TT); typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T, const std::string &TT, const std::string &Features); @@ -120,8 +123,14 @@ namespace llvm { /// HasJIT - Whether this target supports the JIT. bool HasJIT; + /// AsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if + /// registered. AsmInfoCtorFnTy AsmInfoCtorFn; + /// RegInfoCtorFn - Constructor function for this target's MCRegisterInfo, + /// if registered. + RegInfoCtorFnTy RegInfoCtorFn; + /// TargetMachineCtorFn - Construction function for this target's /// TargetMachine, if registered. TargetMachineCtorTy TargetMachineCtorFn; @@ -231,6 +240,19 @@ namespace llvm { return AsmInfoCtorFn(*this, Triple); } + /// createRegInfo - Create a MCRegisterInfo implementation for the specified + /// target triple. + /// + /// \arg Triple - This argument is used to determine the target machine + /// 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. + MCRegisterInfo *createRegInfo(StringRef Triple) const { + if (!RegInfoCtorFn) + return 0; + return RegInfoCtorFn(*this, Triple); + } + /// createTargetMachine - Create a target specific machine implementation /// for the specified \arg Triple. /// @@ -444,6 +466,21 @@ namespace llvm { T.AsmInfoCtorFn = Fn; } + /// RegisterRegInfo - Register a MCRegisterInfo 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 MCRegisterInfo for the target. + static void RegisterRegInfo(Target &T, Target::RegInfoCtorFnTy Fn) { + // Ignore duplicate registration. + if (!T.RegInfoCtorFn) + T.RegInfoCtorFn = Fn; + } + /// RegisterTargetMachine - Register a TargetMachine implementation for the /// given target. /// |