1 //===- TargetRegistry.cpp -------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #include <mcld/Support/TargetRegistry.h> 10 11 12 mcld::TargetRegistry::TargetListTy mcld::TargetRegistry::s_TargetList; 13 14 void mcld::TargetRegistry::RegisterTarget(mcld::Target &T) 15 { 16 s_TargetList.push_back(&T); 17 } 18 19 const mcld::Target* 20 mcld::TargetRegistry::lookupTarget(const llvm::Target &pTarget) 21 { 22 mcld::Target *result = 0; 23 TargetListTy::const_iterator TIter, TEnd = s_TargetList.end(); 24 for (TIter=s_TargetList.begin(); TIter!=TEnd; ++TIter) { 25 if ((*TIter)->get()==&pTarget) { 26 result = (*TIter); 27 break; 28 } 29 } 30 return result; 31 } 32 33 const mcld::Target* 34 mcld::TargetRegistry::lookupTarget(const std::string &pTriple, 35 std::string &pError) 36 { 37 const llvm::Target* target = llvm::TargetRegistry::lookupTarget(pTriple, pError); 38 if (!target) 39 return NULL; 40 41 return lookupTarget( *target ); 42 } 43 44