diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ExecutionEngine/JIT/TargetSelect.cpp | 5 | ||||
-rw-r--r-- | lib/Target/CBackend/CBackend.cpp | 2 | ||||
-rw-r--r-- | lib/Target/TargetMachineRegistry.cpp | 55 |
3 files changed, 21 insertions, 41 deletions
diff --git a/lib/ExecutionEngine/JIT/TargetSelect.cpp b/lib/ExecutionEngine/JIT/TargetSelect.cpp index bf968af..14e0a5f 100644 --- a/lib/ExecutionEngine/JIT/TargetSelect.cpp +++ b/lib/ExecutionEngine/JIT/TargetSelect.cpp @@ -20,7 +20,8 @@ #include "llvm/Target/TargetMachineRegistry.h" using namespace llvm; -static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser> +static cl::opt<const TargetMachineRegistry::entry*, false, + TargetMachineRegistry::Parser> MArch("march", cl::desc("Architecture to generate assembly for:")); static cl::opt<std::string> @@ -39,7 +40,7 @@ MAttrs("mattr", /// for the current target. Otherwise, return null. /// ExecutionEngine *JIT::create(ModuleProvider *MP, std::string *ErrorStr) { - const TargetMachineRegistry::Entry *TheArch = MArch; + const TargetMachineRegistry::entry *TheArch = MArch; if (TheArch == 0) { std::string Error; TheArch = TargetMachineRegistry::getClosestTargetForJIT(Error); diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 35205c6..f874a18 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -2684,7 +2684,7 @@ std::string CWriter::InterpretASMConstraint(InlineAsm::ConstraintInfo& c) { //Grab the translation table from TargetAsmInfo if it exists if (!TAsm) { std::string E; - const TargetMachineRegistry::Entry* Match = + const TargetMachineRegistry::entry* Match = TargetMachineRegistry::getClosestStaticTargetForModule(*TheModule, E); if (Match) { //Per platform Target Machines don't exist, so create it diff --git a/lib/Target/TargetMachineRegistry.cpp b/lib/Target/TargetMachineRegistry.cpp index 5be9eb1..077b7e8 100644 --- a/lib/Target/TargetMachineRegistry.cpp +++ b/lib/Target/TargetMachineRegistry.cpp @@ -18,44 +18,23 @@ #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 &,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; -} +template<> Registry<TargetMachine>::node *Registry<TargetMachine>::Head = 0; +template<> Registry<TargetMachine>::node *Registry<TargetMachine>::Tail = 0; +template<> Registry<TargetMachine>::listener *Registry<TargetMachine>:: +ListenerHead = 0; +template<> Registry<TargetMachine>::listener *Registry<TargetMachine>:: +ListenerTail = 0; /// 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. -const TargetMachineRegistry::Entry * +const TargetMachineRegistry::entry * TargetMachineRegistry::getClosestStaticTargetForModule(const Module &M, std::string &Error) { - std::vector<std::pair<unsigned, const Entry *> > UsableTargets; - for (const Entry *E = getList(); E; E = E->getNext()) - if (unsigned Qual = E->ModuleMatchQualityFn(M)) - UsableTargets.push_back(std::make_pair(Qual, E)); + std::vector<std::pair<unsigned, const entry *> > UsableTargets; + for (iterator I = begin(), E = end(); I != E; ++I) + if (unsigned Qual = I->ModuleMatchQualityFn(M)) + UsableTargets.push_back(std::make_pair(Qual, &*I)); if (UsableTargets.empty()) { Error = "No available targets are compatible with this module"; @@ -78,12 +57,12 @@ TargetMachineRegistry::getClosestStaticTargetForModule(const Module &M, /// getClosestTargetForJIT - Pick the best target that is compatible with /// the current host. If no close target can be found, this returns null /// and sets the Error string to a reason. -const TargetMachineRegistry::Entry * +const TargetMachineRegistry::entry * TargetMachineRegistry::getClosestTargetForJIT(std::string &Error) { - std::vector<std::pair<unsigned, const Entry *> > UsableTargets; - for (const Entry *E = getList(); E; E = E->getNext()) - if (unsigned Qual = E->JITMatchQualityFn()) - UsableTargets.push_back(std::make_pair(Qual, E)); + std::vector<std::pair<unsigned, const entry *> > UsableTargets; + for (iterator I = begin(), E = end(); I != E; ++I) + if (unsigned Qual = I->JITMatchQualityFn()) + UsableTargets.push_back(std::make_pair(Qual, &*I)); if (UsableTargets.empty()) { Error = "No JIT is available for this host"; @@ -93,7 +72,7 @@ TargetMachineRegistry::getClosestTargetForJIT(std::string &Error) { // Otherwise, take the best target. If there is a tie, just pick one. unsigned MaxQual = UsableTargets.front().first; - const Entry *MaxQualTarget = UsableTargets.front().second; + const entry *MaxQualTarget = UsableTargets.front().second; for (unsigned i = 1, e = UsableTargets.size(); i != e; ++i) if (UsableTargets[i].first > MaxQual) { |