32 const Target *TheTarget = 0;
33 if (!ArchName.empty()) {
36 if (ArchName == it->getName()) {
43 Error =
"error: invalid target '" + ArchName +
"'.\n";
54 std::string TempError;
57 Error =
": error: unable to get target for '"
59 +
"', see --version and --triple.\n";
71 Error =
"Unable to find target for this triple (no targets are registered)";
74 const Target *Best = 0, *EquallyBest = 0;
75 unsigned BestQuality = 0;
77 if (
unsigned Qual = it->TripleMatchQualityFn(TT)) {
78 if (!Best || Qual > BestQuality) {
82 }
else if (Qual == BestQuality)
88 Error =
"No available targets are compatible with this triple, "
89 "see -version for the available targets.";
96 Error = std::string(
"Cannot choose between targets \"") +
97 Best->Name +
"\" and \"" + EquallyBest->Name +
"\"";
106 const char *ShortDesc,
109 assert(Name && ShortDesc && TQualityFn &&
110 "Missing required target information!");
122 T.ShortDesc = ShortDesc;
123 T.TripleMatchQualityFn = TQualityFn;
130 if (TheTarget && !TheTarget->
hasJIT()) {
131 Error =
"No JIT compatible target available for this host";
139 const std::pair<StringRef, const Target *> *RHS) {
140 return LHS->first.compare(RHS->first);
144 std::vector<std::pair<StringRef, const Target*> > Targets;
149 Targets.push_back(std::make_pair(
I->getName(), &*
I));
150 Width = std::max(Width, Targets.back().first.size());
155 OS <<
" Registered Targets:\n";
156 for (
unsigned i = 0, e = Targets.size(); i != e; ++i) {
157 OS <<
" " << Targets[i].first;
158 OS.indent(Width - Targets[i].first.size()) <<
" - "
159 << Targets[i].second->getShortDescription() <<
'\n';
static int TargetArraySortFn(const std::pair< StringRef, const Target * > *LHS, const std::pair< StringRef, const Target * > *RHS)
std::string getDefaultTargetTriple()
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
static const Target * getClosestTargetForJIT(std::string &Error)
unsigned(* TripleMatchQualityFnTy)(const std::string &TT)
static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc, Target::TripleMatchQualityFnTy TQualityFn, bool HasJIT=false)
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
void array_pod_sort(IteratorTy Start, IteratorTy End)
static void printRegisteredTargetsForVersion()
const std::string & getTriple() const
static Target * FirstTarget
static ArchType getArchTypeForLLVMName(StringRef Str)
void setArch(ArchType Kind)