31 const Target *TheTarget =
nullptr;
32 if (!ArchName.empty()) {
37 Error =
"error: invalid target '" + ArchName +
"'.\n";
50 std::string TempError;
53 Error =
": error: unable to get target for '"
55 +
"', see --version and --triple.\n";
67 Error =
"Unable to find target for this triple (no targets are registered)";
71 auto ArchMatch = [&](
const Target &
T) {
return T.ArchMatchFn(Arch); };
75 Error =
"No available targets are compatible with this triple.";
81 Error = std::string(
"Cannot choose between targets \"") +
I->Name +
82 "\" and \"" + J->Name +
"\"";
91 const char *ShortDesc,
94 assert(Name && ShortDesc && ArchMatchFn &&
95 "Missing required target information!");
107 T.ShortDesc = ShortDesc;
108 T.ArchMatchFn = ArchMatchFn;
113 const std::pair<StringRef, const Target *> *RHS) {
114 return LHS->first.compare(RHS->first);
118 std::vector<std::pair<StringRef, const Target*> > Targets;
121 Targets.push_back(std::make_pair(
T.getName(), &
T));
122 Width = std::max(Width, Targets.back().first.size());
127 OS <<
" Registered Targets:\n";
128 for (
unsigned i = 0, e = Targets.size();
i != e; ++
i) {
129 OS <<
" " << Targets[
i].first;
130 OS.indent(Width - Targets[
i].first.size()) <<
" - "
131 << 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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
This class implements an extremely fast bulk output stream that can only output to a stream...
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
void setArch(ArchType Kind)
setArch - Set the architecture (first) component of the triple to a known type.