X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetMachineRegistry.cpp;h=b5a3a553b3e179c63b9c8954f5abbd0bf7eb3734;hb=f8be5e94aaf70d53dc043f5e541fc0bf6771db22;hp=ecbfc82932b35862d89c54bc0c0e6c0b5a718eaa;hpb=d7099bc608421321c0933120baac7d1032e5fc1c;p=oota-llvm.git diff --git a/lib/Target/TargetMachineRegistry.cpp b/lib/Target/TargetMachineRegistry.cpp index ecbfc82932b..b5a3a553b3e 100644 --- a/lib/Target/TargetMachineRegistry.cpp +++ b/lib/Target/TargetMachineRegistry.cpp @@ -18,8 +18,34 @@ #include 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.