LLVM: lib/ExecutionEngine/TargetSelect.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
23
24using namespace llvm;
25
28
29
30
32 TT = M->getTargetTriple();
33
35}
36
37
38
43 Triple TheTriple(TargetTriple);
44 if (TheTriple.getTriple().empty())
46
47
48 const Target *TheTarget = nullptr;
49 if (!MArch.empty()) {
51 [&](const Target &T) { return MArch == T.getName(); });
52
54 if (ErrorStr)
55 *ErrorStr = "No available targets are compatible with this -march, "
56 "see -version for the available targets.\n";
57 return nullptr;
58 }
59
60 TheTarget = &*I;
61
62
63
67 } else {
68 std::string Error;
70 if (!TheTarget) {
71 if (ErrorStr)
72 *ErrorStr = Error;
73 return nullptr;
74 }
75 }
76
77
78 std::string FeaturesStr;
79 if (!MAttrs.empty()) {
81 for (unsigned i = 0; i != MAttrs.size(); ++i)
83 FeaturesStr = Features.getString();
84 }
85
86
88 TheTriple, MCPU, FeaturesStr, Options, RelocModel, CMModel, OptLevel,
89 true);
90 Target->Options.EmulatedTLS = EmulatedTLS;
91
92 assert(Target && "Could not allocate target machine!");
94}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Module.h This file contains the declarations for the Module class.
LLVM_ABI TargetMachine * selectTarget()
Definition TargetSelect.cpp:26
Lightweight error class with error context and mandatory checking.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Manages the enabling and disabling of subtarget specific features.
LLVM_ABI std::string getString() const
Returns features as a string.
LLVM_ABI void AddFeature(StringRef String, bool Enable=true)
Adds Features.
Primary interface to the complete machine description for the target machine.
Target - Wrapper for Target specific information.
TargetMachine * createTargetMachine(const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM=std::nullopt, CodeGenOptLevel OL=CodeGenOptLevel::Default, bool JIT=false) const
createTargetMachine - Create a target specific machine implementation for the specified Triple.
Triple - Helper class for working with autoconf configuration names.
LLVM_ABI void setTriple(const Twine &Str)
Set all components to the new triple Str.
static LLVM_ABI ArchType getArchTypeForLLVMName(StringRef Str)
The canonical type for the given LLVM architecture name (e.g., "x86").
const std::string & getTriple() const
LLVM_ABI void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM_ABI std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
This is an optimization pass for GlobalISel generic memory operations.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
static const Target * lookupTarget(StringRef TripleStr, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
static LLVM_ABI iterator_range< iterator > targets()