diff options
Diffstat (limited to 'include/llvm/Support/TargetRegistry.h')
-rw-r--r-- | include/llvm/Support/TargetRegistry.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h index e1f6706618..b4e380b344 100644 --- a/include/llvm/Support/TargetRegistry.h +++ b/include/llvm/Support/TargetRegistry.h @@ -41,6 +41,7 @@ namespace llvm { class MCRegisterInfo; class MCStreamer; class MCSubtargetInfo; + class MCRelocationInfo; class MCTargetAsmParser; class TargetMachine; class TargetOptions; @@ -56,6 +57,8 @@ namespace llvm { MCAsmBackend *TAB, bool ShowInst); + MCRelocationInfo *createMCRelocationInfo(MCContext &Ctx); + /// Target - Wrapper for Target specific information. /// /// For registration purposes, this is a POD type so that targets can be @@ -127,6 +130,8 @@ namespace llvm { MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst); + typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT, + MCContext &Ctx); private: /// Next - The next registered target in the linked list, maintained by the @@ -206,6 +211,10 @@ namespace llvm { /// AsmStreamer, if registered (default = llvm::createAsmStreamer). AsmStreamerCtorTy AsmStreamerCtorFn; + /// MCRelocationInfoCtorFn - Construction function for this target's + /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo) + MCRelocationInfoCtorTy MCRelocationInfoCtorFn; + public: Target() : AsmStreamerCtorFn(llvm::createAsmStreamer) {} @@ -433,6 +442,16 @@ namespace llvm { useDwarfDirectory, InstPrint, CE, TAB, ShowInst); } + /// createMCRelocationInfo - Create a target specific MCRelocationInfo. + /// + /// \param TT The target triple. + /// \param Ctx The target context. + MCRelocationInfo * + createMCRelocationInfo(StringRef TT, MCContext &Ctx) const { + // MCRelocationInfoCtorFn defaults to createMCRelocationInfo + return MCRelocationInfoCtorFn(TT, Ctx); + } + /// @} }; @@ -760,6 +779,21 @@ namespace llvm { T.AsmStreamerCtorFn = 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) { + if (!T.MCRelocationInfoCtorFn) + T.MCRelocationInfoCtorFn = Fn; + } + /// @} }; |