diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-11 06:02:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-11 06:02:59 +0000 |
commit | 2845ece825f302f9d841e8a743539ffd3f7edff8 (patch) | |
tree | 9459bfec952af25ef9737a435a92c58c5866be27 /include | |
parent | 68905bb6fc8848b6437057f3998b89cbf5d6f837 (diff) | |
download | external_llvm-2845ece825f302f9d841e8a743539ffd3f7edff8.zip external_llvm-2845ece825f302f9d841e8a743539ffd3f7edff8.tar.gz external_llvm-2845ece825f302f9d841e8a743539ffd3f7edff8.tar.bz2 |
Add a new listener class for things that want to be informed about new
targets that are loaded
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14758 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Target/TargetMachineRegistry.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/include/llvm/Target/TargetMachineRegistry.h b/include/llvm/Target/TargetMachineRegistry.h index e122e9a..008b69c 100644 --- a/include/llvm/Target/TargetMachineRegistry.h +++ b/include/llvm/Target/TargetMachineRegistry.h @@ -58,11 +58,7 @@ namespace llvm { protected: Entry(const char *N, const char *SD, TargetMachine *(*CF)(const Module &, IntrinsicLowering*), - unsigned (*MMF)(const Module &M), unsigned (*JMF)()) - : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF), - JITMatchQualityFn(JMF), Next(List) { - List = this; - } + unsigned (*MMF)(const Module &M), unsigned (*JMF)()); private: const Entry *Next; // Next entry in the linked list. }; @@ -89,10 +85,24 @@ namespace llvm { } }; + /// TargetRegistrationListener - This class allows code to listen for targets + /// that are dynamically registered, and be notified of it when they are. + class TargetRegistrationListener { + TargetRegistrationListener **Prev, *Next; + public: + TargetRegistrationListener(); + virtual ~TargetRegistrationListener(); + + TargetRegistrationListener *getNext() const { return Next; } + + virtual void targetRegistered(const TargetMachineRegistry::Entry *E) = 0; + }; + + //===--------------------------------------------------------------------===// /// TargetNameParser - This option can be used to provide a command line /// option to choose among the various registered targets (commonly -march). - class TargetNameParser : + class TargetNameParser : public TargetRegistrationListener, public cl::parser<const TargetMachineRegistry::Entry*> { public: void initialize(cl::Option &O) { @@ -102,6 +112,11 @@ namespace llvm { std::make_pair(E, E->ShortDesc))); cl::parser<const TargetMachineRegistry::Entry*>::initialize(O); } + + virtual void targetRegistered(const TargetMachineRegistry::Entry *E) { + Values.push_back(std::make_pair(E->Name, + std::make_pair(E, E->ShortDesc))); + } }; } |