Unifacalize the CALLSEQ{START,END} stuff.
[oota-llvm.git] / lib / Target / TargetMachineRegistry.cpp
index ecbfc82932b35862d89c54bc0c0e6c0b5a718eaa..3b43eb836ba67b03eb7f166c758b52951c45a8c0 100644 (file)
@@ -1,10 +1,10 @@
 //===-- TargetMachineRegistry.cpp - Target Auto Registration Impl ---------===//
-// 
+//
 //                     The LLVM Compiler Infrastructure
 //
 // This file was developed by the LLVM research group and is distributed under
 // the University of Illinois Open Source License. See LICENSE.TXT for details.
-// 
+//
 //===----------------------------------------------------------------------===//
 //
 // This file exposes the RegisterTarget class, which TargetMachine
 #include <algorithm>
 using namespace llvm;
 
-const TargetMachineRegistry::Entry *TargetMachineRegistry::List = 0;
+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 (Registry<TargetMachine>::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";
     return 0;
   } else if (UsableTargets.size() == 1)
     return UsableTargets.back().second;
-  
+
   // Otherwise, take the best target, but make sure we don't have to equally
   // good best targets.
   std::sort(UsableTargets.begin(), UsableTargets.end());
@@ -49,33 +54,32 @@ TargetMachineRegistry::getClosestStaticTargetForModule(const Module &M,
   return UsableTargets.back().second;
 }
 
-/// getClosestTargetForJIT - Given an LLVM module, pick the best target that
-/// is compatible with the current host and the specified module.  If no
-/// close target can be found, this returns null and sets the Error string
-/// to a reason.
-const TargetMachineRegistry::Entry *
+/// 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 *
 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 (Registry<TargetMachine>::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";
     return 0;
   } else if (UsableTargets.size() == 1)
     return UsableTargets.back().second;
-  
+
   // 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) {
       MaxQual = UsableTargets[i].first;
       MaxQualTarget = UsableTargets[i].second;
     }
-  
+
   return MaxQualTarget;
 }
-                                    
+