31 const Target *TheTarget =
nullptr;
32 if (!ArchName.empty()) {
38 Error =
"error: invalid target '" + ArchName +
"'.\n";
51 std::string TempError;
54 Error =
": error: unable to get target for '"
56 +
"', see --version and --triple.\n";
68 Error =
"Unable to find target for this triple (no targets are registered)";
72 auto ArchMatch = [&](
const Target &
T) {
return T.ArchMatchFn(Arch); };
76 Error =
"No available targets are compatible with this triple, "
77 "see -version for the available targets.";
81 auto J = std::find_if(std::next(
I),
targets().
end(), ArchMatch);
83 Error = std::string(
"Cannot choose between targets \"") +
I->Name +
84 "\" and \"" + J->Name +
"\"";
93 const char *ShortDesc,
96 assert(Name && ShortDesc && ArchMatchFn &&
97 "Missing required target information!");
109 T.ShortDesc = ShortDesc;
110 T.ArchMatchFn = ArchMatchFn;
115 const std::pair<StringRef, const Target *> *RHS) {
116 return LHS->first.compare(RHS->first);
120 std::vector<std::pair<StringRef, const Target*> > Targets;
123 Targets.push_back(std::make_pair(
T.getName(), &
T));
124 Width = std::max(Width, Targets.back().first.size());
129 OS <<
" Registered Targets:\n";
130 for (
unsigned i = 0, e = Targets.size(); i != e; ++i) {
131 OS <<
" " << Targets[i].first;
132 OS.indent(Width - Targets[i].first.size()) <<
" - "
133 << Targets[i].second->getShortDescription() <<
'\n';
const_iterator end(StringRef path)
Get end iterator over path.
const char * getName() const
getName - Get the target name.
static int TargetArraySortFn(const std::pair< StringRef, const Target * > *LHS, const std::pair< StringRef, const Target * > *RHS)
const_iterator begin(StringRef path)
Get begin iterator over path.
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc, Target::ArchMatchFnTy ArchMatchFn, bool HasJIT=false)
RegisterTarget - Register the given target.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
static iterator_range< iterator > targets()
raw_ostream & outs()
This returns a reference to a raw_ostream for standard output.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
static void printRegisteredTargetsForVersion()
printRegisteredTargetsForVersion - Print the registered targets appropriately for inclusion in a tool...
The instances of the Type class are immutable: once they are created, they are never changed...
const std::string & getTriple() const
bool(* ArchMatchFnTy)(Triple::ArchType Arch)
static Target * FirstTarget
Triple - Helper class for working with autoconf configuration names.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static ArchType getArchTypeForLLVMName(StringRef Str)
getArchTypeForLLVMName - The canonical type for the given LLVM architecture name (e.g., "x86").
A range adaptor for a pair of iterators.
Target - Wrapper for Target specific information.
This class implements an extremely fast bulk output stream that can only output to a stream...
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.