aboutsummaryrefslogtreecommitdiff
path: root/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
commit7c38def077bc75a12262a5433b1fcebe310bc2b2 (patch)
tree6403e2afbbc2ab09efed4f03e03ae4006ce1aeca /lib/Target/TargetMachineRegistry.cpp
parent2845ece825f302f9d841e8a743539ffd3f7edff8 (diff)
Implement TargetRegistrationListener
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14759 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetMachineRegistry.cpp')
-rw-r--r--lib/Target/TargetMachineRegistry.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Target/TargetMachineRegistry.cpp b/lib/Target/TargetMachineRegistry.cpp
index ecbfc82932..b5a3a553b3 100644
--- a/lib/Target/TargetMachineRegistry.cpp
+++ b/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.