diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-25 10:09:50 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-25 10:09:50 +0000 |
commit | d6fd377f3333922c4e928019cdfa124ff7f4dd2e (patch) | |
tree | da15e380d88d8a3072e1d8cf434f424880b0a2ce /lib/Support | |
parent | e0d12d5f7b0a6369df128c8b0cc43e6e08a804a0 (diff) | |
download | external_llvm-d6fd377f3333922c4e928019cdfa124ff7f4dd2e.zip external_llvm-d6fd377f3333922c4e928019cdfa124ff7f4dd2e.tar.gz external_llvm-d6fd377f3333922c4e928019cdfa124ff7f4dd2e.tar.bz2 |
Simplify JIT target selection.
- Instead of requiring targets to define a JIT quality match function, we just
have them specify if they support a JIT.
- Target selection for the JIT just gets the host triple and looks for the best
target which matches the triple and has a JIT.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77060 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/TargetRegistry.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/Support/TargetRegistry.cpp b/lib/Support/TargetRegistry.cpp index b3446e6..f9026f1 100644 --- a/lib/Support/TargetRegistry.cpp +++ b/lib/Support/TargetRegistry.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/TargetRegistry.h" +#include "llvm/System/Host.h" #include <cassert> using namespace llvm; @@ -77,9 +78,18 @@ TargetRegistry::getClosestStaticTargetForModule(const Module &M, } } + // FIXME: This is a hack to ignore super weak matches like msil, etc. and look + // by host instead. They will be found again via the triple. + if (Best && BestQuality == 1) + Best = EquallyBest = 0; + + // If that failed, try looking up the host triple. + if (!Best) + Best = getClosestStaticTargetForTriple(sys::getHostTriple(), Error); + if (!Best) { Error = "No available targets are compatible with this module"; - return 0; + return Best; } // Otherwise, take the best target, but make sure we don't have two equally @@ -95,6 +105,8 @@ TargetRegistry::getClosestStaticTargetForModule(const Module &M, const Target * TargetRegistry::getClosestTargetForJIT(std::string &Error) { + std::string Triple = sys::getHostTriple(); + // Provide special warning when no targets are initialized. if (begin() == end()) { Error = "No JIT is available for this host (no targets are registered)"; @@ -104,7 +116,10 @@ TargetRegistry::getClosestTargetForJIT(std::string &Error) { const Target *Best = 0, *EquallyBest = 0; unsigned BestQuality = 0; for (iterator it = begin(), ie = end(); it != ie; ++it) { - if (unsigned Qual = it->JITMatchQualityFn()) { + if (!it->hasJIT()) + continue; + + if (unsigned Qual = it->TripleMatchQualityFn(Triple)) { if (!Best || Qual > BestQuality) { Best = &*it; EquallyBest = 0; @@ -128,8 +143,8 @@ void TargetRegistry::RegisterTarget(Target &T, const char *ShortDesc, Target::TripleMatchQualityFnTy TQualityFn, Target::ModuleMatchQualityFnTy MQualityFn, - Target::JITMatchQualityFnTy JITQualityFn) { - assert(Name && ShortDesc && TQualityFn && MQualityFn && JITQualityFn && + bool HasJIT) { + assert(Name && ShortDesc && TQualityFn && MQualityFn && "Missing required target information!"); // Check if this target has already been initialized, we allow this as a @@ -145,6 +160,6 @@ void TargetRegistry::RegisterTarget(Target &T, T.ShortDesc = ShortDesc; T.TripleMatchQualityFn = TQualityFn; T.ModuleMatchQualityFn = MQualityFn; - T.JITMatchQualityFn = JITQualityFn; + T.HasJIT = HasJIT; } |