+/// 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*,
+ const std::string &),
+ 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;
+}
+