summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetMachineRegistry.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-11 06:03:21 +0000
committerChris Lattner <sabre@nondot.org>2004-07-11 06:03:21 +0000
commitc9c16a0e60941640223c34a42818b2539863a9da (patch)
tree052e141c49a042b4555ef8f1565e71c965ab5c97 /llvm/lib/Target/TargetMachineRegistry.cpp
parent53d2ac55148b94ddbfe34428f4aeaa8fbe25eb96 (diff)
downloadbcm5719-llvm-c9c16a0e60941640223c34a42818b2539863a9da.tar.gz
bcm5719-llvm-c9c16a0e60941640223c34a42818b2539863a9da.zip
Implement TargetRegistrationListener
llvm-svn: 14759
Diffstat (limited to 'llvm/lib/Target/TargetMachineRegistry.cpp')
-rw-r--r--llvm/lib/Target/TargetMachineRegistry.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetMachineRegistry.cpp b/llvm/lib/Target/TargetMachineRegistry.cpp
index ecbfc82932b..b5a3a553b3e 100644
--- a/llvm/lib/Target/TargetMachineRegistry.cpp
+++ b/llvm/lib/Target/TargetMachineRegistry.cpp
@@ -18,8 +18,34 @@
#include <algorithm>
using namespace llvm;
+/// List - This is the main list of all of the registered target machines.
const TargetMachineRegistry::Entry *TargetMachineRegistry::List = 0;
+/// Listeners - All of the listeners registered to get notified when new targets
+/// are loaded.
+static TargetRegistrationListener *Listeners = 0;
+
+TargetMachineRegistry::Entry::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;
+ for (TargetRegistrationListener *L = Listeners; L; L = L->getNext())
+ L->targetRegistered(this);
+}
+
+TargetRegistrationListener::TargetRegistrationListener() {
+ Next = Listeners;
+ if (Next) Next->Prev = &Next;
+ Prev = &Listeners;
+ Listeners = this;
+}
+
+TargetRegistrationListener::~TargetRegistrationListener() {
+ *Prev = Next;
+}
+
/// getClosestStaticTargetForModule - Given an LLVM module, pick the best target
/// that is compatible with the module. If no close target can be found, this
/// returns null and sets the Error string to a reason.
OpenPOWER on IntegriCloud