diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-16 02:06:09 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-16 02:06:09 +0000 |
commit | 603bea32743dc9914a1d32ae36fc64fe497af801 (patch) | |
tree | ca6ff5bc8e44d1c5ca644e691b2b24a33b4bca4e /lib/Support/TargetRegistry.cpp | |
parent | 494d663175bbaa7db4743105d1efdf78be9cdb03 (diff) |
Add registered target list to --version output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/TargetRegistry.cpp')
-rw-r--r-- | lib/Support/TargetRegistry.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/Support/TargetRegistry.cpp b/lib/Support/TargetRegistry.cpp index 77cf2dd72c..bf631feb68 100644 --- a/lib/Support/TargetRegistry.cpp +++ b/lib/Support/TargetRegistry.cpp @@ -14,20 +14,23 @@ using namespace llvm; // Clients are responsible for avoid race conditions in registration. static Target *FirstTarget = 0; +TargetRegistry::iterator TargetRegistry::begin() { + return iterator(FirstTarget); +} + const Target * TargetRegistry::getClosestStaticTargetForTriple(const std::string &TT, std::string &Error) { - Target *Best = 0, *EquallyBest = 0; + const Target *Best = 0, *EquallyBest = 0; unsigned BestQuality = 0; - // FIXME: Use iterator. - for (Target *i = FirstTarget; i; i = i->Next) { - if (unsigned Qual = i->TripleMatchQualityFn(TT)) { + for (iterator it = begin(), ie = end(); it != ie; ++it) { + if (unsigned Qual = it->TripleMatchQualityFn(TT)) { if (!Best || Qual > BestQuality) { - Best = i; + Best = &*it; EquallyBest = 0; BestQuality = Qual; } else if (Qual == BestQuality) - EquallyBest = i; + EquallyBest = &*it; } } @@ -50,17 +53,16 @@ TargetRegistry::getClosestStaticTargetForTriple(const std::string &TT, const Target * TargetRegistry::getClosestStaticTargetForModule(const Module &M, std::string &Error) { - Target *Best = 0, *EquallyBest = 0; + const Target *Best = 0, *EquallyBest = 0; unsigned BestQuality = 0; - // FIXME: Use iterator. - for (Target *i = FirstTarget; i; i = i->Next) { - if (unsigned Qual = i->ModuleMatchQualityFn(M)) { + for (iterator it = begin(), ie = end(); it != ie; ++it) { + if (unsigned Qual = it->ModuleMatchQualityFn(M)) { if (!Best || Qual > BestQuality) { - Best = i; + Best = &*it; EquallyBest = 0; BestQuality = Qual; } else if (Qual == BestQuality) - EquallyBest = i; + EquallyBest = &*it; } } @@ -82,17 +84,16 @@ TargetRegistry::getClosestStaticTargetForModule(const Module &M, const Target * TargetRegistry::getClosestTargetForJIT(std::string &Error) { - Target *Best = 0, *EquallyBest = 0; + const Target *Best = 0, *EquallyBest = 0; unsigned BestQuality = 0; - // FIXME: Use iterator. - for (Target *i = FirstTarget; i; i = i->Next) { - if (unsigned Qual = i->JITMatchQualityFn()) { + for (iterator it = begin(), ie = end(); it != ie; ++it) { + if (unsigned Qual = it->JITMatchQualityFn()) { if (!Best || Qual > BestQuality) { - Best = i; + Best = &*it; EquallyBest = 0; BestQuality = Qual; } else if (Qual == BestQuality) - EquallyBest = i; + EquallyBest = &*it; } } |