[llvm-commits] CVS: llvm/lib/Target/TargetMachineRegistry.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Jul 11 01:04:01 PDT 2004
Changes in directory llvm/lib/Target:
TargetMachineRegistry.cpp updated: 1.2 -> 1.3
---
Log message:
Implement TargetRegistrationListener
---
Diffs of the changes: (+26 -0)
Index: llvm/lib/Target/TargetMachineRegistry.cpp
diff -u llvm/lib/Target/TargetMachineRegistry.cpp:1.2 llvm/lib/Target/TargetMachineRegistry.cpp:1.3
--- llvm/lib/Target/TargetMachineRegistry.cpp:1.2 Sat Jul 10 23:00:19 2004
+++ llvm/lib/Target/TargetMachineRegistry.cpp Sun Jul 11 01:03:21 2004
@@ -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.
More information about the llvm-commits
mailing list