summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/TargetRegistry.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-16 02:06:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-16 02:06:09 +0000
commit78c8fb1056a80c3a8b11763da10d151176839de7 (patch)
tree4c16d164d47f2f6997269bf2c664ffdcfaaeeb55 /llvm/lib/Support/TargetRegistry.cpp
parent3d92d936b975b1ad02533e4a2333d0b0c2f68e5c (diff)
downloadbcm5719-llvm-78c8fb1056a80c3a8b11763da10d151176839de7.tar.gz
bcm5719-llvm-78c8fb1056a80c3a8b11763da10d151176839de7.zip
Add registered target list to --version output.
llvm-svn: 75889
Diffstat (limited to 'llvm/lib/Support/TargetRegistry.cpp')
-rw-r--r--llvm/lib/Support/TargetRegistry.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/llvm/lib/Support/TargetRegistry.cpp b/llvm/lib/Support/TargetRegistry.cpp
index 77cf2dd72cf..bf631feb686 100644
--- a/llvm/lib/Support/TargetRegistry.cpp
+++ b/llvm/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;
}
}
OpenPOWER on IntegriCloud