LLVM: lib/Target/TargetMachine.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
27using namespace llvm;
28
29
30
31
32
36 : TheTarget(T), DL(DataLayoutString), TargetTriple(TT),
37 TargetCPU(std::string(CPU)), TargetFS(std::string(FS)), AsmInfo(nullptr),
38 MRI(nullptr), MII(nullptr), STI(nullptr), RequireStructuredCFG(false),
40
42
45 return false;
46
47
48
49
52
54
55
56 if (!GO)
57 return true;
58
59 auto *GV = dyn_cast(GO);
60
62 return Name.consume_front(Prefix) && (Name.empty() || Name[0] == '.');
63 };
64
65
66 if (!GV) {
67
68
69 if (GO->hasSection()) {
71 return IsPrefix(Name, ".ltext");
72 }
74 }
75
76 if (GV->isThreadLocal())
77 return false;
78
79
80
81 if (auto CM = GV->getCodeModel()) {
83 return false;
85 return true;
86 }
87
88
89
90
91
92 if (GV->hasSection()) {
94 return IsPrefix(Name, ".lbss") || IsPrefix(Name, ".ldata") ||
95 IsPrefix(Name, ".lrodata");
96 }
97
98
101 if (!GV->getValueType()->isSized())
102 return true;
103
104
105 if (GV->isDeclaration() && (GV->getName() == "__ehdr_start" ||
106 GV->getName().starts_with("__start_") ||
107 GV->getName().starts_with("__stop_")))
108 return true;
112 }
113
114 return false;
115}
116
119}
120
121
122
123
124
125
126
127
128
130#define RESET_OPTION(X, Y) \
131 do { \
132 Options.X = F.getFnAttribute(Y).getValueAsBool(); \
133 } while (0)
134
135 RESET_OPTION(UnsafeFPMath, "unsafe-fp-math");
136 RESET_OPTION(NoInfsFPMath, "no-infs-fp-math");
137 RESET_OPTION(NoNaNsFPMath, "no-nans-fp-math");
138 RESET_OPTION(NoSignedZerosFPMath, "no-signed-zeros-fp-math");
139 RESET_OPTION(ApproxFuncFPMath, "approx-func-fp-math");
140}
141
142
143
145
156 }
158}
159
160
164 llvm_unreachable("getSelectedTLSModel for non-TLS variable");
165 break;
174 }
176}
177
181
182
183
184
185
186
187
188
189
190 if (!GV)
191 return false;
192
193
195 return true;
196
197 if (TT.isOSBinFormatCOFF()) {
198
200 return false;
201
202
203
204
205
206
208 isa(GV))
209 return false;
210
211
212
213
215 return false;
216
217
218 return true;
219 }
220
221 if (TT.isOSBinFormatGOFF())
222 return true;
223
224 if (TT.isOSBinFormatMachO()) {
226 return true;
228 }
229
230 assert(TT.isOSBinFormatELF() || TT.isOSBinFormatWasm() ||
231 TT.isOSBinFormatXCOFF());
232 return false;
233}
234
237
241 bool IsSharedLibrary = RM == Reloc::PIC_ && !IsPIE;
243
245 if (IsSharedLibrary) {
246 if (IsLocal)
248 else
250 } else {
251 if (IsLocal)
253 else
255 }
256
257
259 if (SelectedModel > Model)
260 return SelectedModel;
261
262 return Model;
263}
264
268}
269
272 bool MayAlwaysUsePrivate) const {
274
275
277 return;
278 }
281}
282
285
287 return TargetSymbol;
288
292}
293
295
296
299}
300
303 return {INT_MAX, INT_MAX};
304 std::pair<int, int> Ret;
305 if (.consumeInteger(10, Ret.first) && Version.consume_front("."))
306 Version.consumeInteger(10, Ret.second);
307 return Ret;
308}
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static TLSModel::Model getSelectedTLSModel(const GlobalValue *GV)
Get the IR-specified TLS model for Var.
#define RESET_OPTION(X, Y)
This pass exposes codegen information to IR-level passes.
A parsed version of the target data layout string in and methods for querying it.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
bool hasPrivateLinkage() const
bool hasExternalWeakLinkage() const
ThreadLocalMode getThreadLocalMode() const
bool hasDLLImportStorageClass() const
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
const GlobalObject * getAliaseeObject() const
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
MCContext & getContext() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
PIELevel::Level getPIELevel() const
Returns the PIE level (small or large model)
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
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.
Analysis pass providing the TargetTransformInfo.
virtual void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const
Mangler & getMangler() const
virtual MCSymbol * getTargetSymbol(const GlobalValue *GV, const TargetMachine &TM) const
Targets that have a special convention for their symbols could use this hook to return a specialized ...
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
bool isPositionIndependent() const
uint64_t getMaxCodeSize() const
Returns the maximum code size possible under the code model.
const Triple & getTargetTriple() const
bool useTLSDESC() const
Returns true if this target uses TLS Descriptors.
uint64_t LargeDataThreshold
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
virtual TargetLoweringObjectFile * getObjFileLowering() const
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const
Return a TargetTransformInfo for a given function.
const DataLayout DL
DataLayout for the target: keep ABI type size and alignment.
bool shouldAssumeDSOLocal(const GlobalValue *GV) const
static std::pair< int, int > parseBinutilsVersion(StringRef Version)
TargetIRAnalysis getTargetIRAnalysis() const
Get a TargetIRAnalysis appropriate for the target.
MCSymbol * getSymbol(const GlobalValue *GV) const
CodeModel::Model getCodeModel() const
Returns the code model.
bool isLargeGlobalValue(const GlobalValue *GV) const
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
TargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TargetTriple, StringRef CPU, StringRef FS, const TargetOptions &Options)
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
unsigned EnableTLSDESC
EnableTLSDESC - This flag enables TLS Descriptors.
unsigned EmulatedTLS
EmulatedTLS - This flag enables emulated TLS model, using emutls function in the runtime library.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
Implement std::hash so that hash_code can be used in STL containers.