LLVM: lib/Target/X86/X86Subtarget.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
38
39#if defined(_MSC_VER)
40#include <intrin.h>
41#endif
42
43using namespace llvm;
44
45#define DEBUG_TYPE "subtarget"
46
47#define GET_SUBTARGETINFO_TARGET_DESC
48#define GET_SUBTARGETINFO_CTOR
49#include "X86GenSubtargetInfo.inc"
50
51
52
55 cl::desc("Enable early if-conversion on X86"));
56
57
58
59
62}
63
64
65
66unsigned char
69}
70
71unsigned char
74
75
76
77 if (AllowTaggedGlobals && CM != CodeModel::Large && GV && !isa(GV))
79
80
83
85
88 "Tiny codesize model not supported on X86");
89
90
93
94 if (GV)
96
97
98
100 }
101
102
103
105 }
106
107
110
112
113
114
115
118
120 }
121
123}
124
126 const Module &M) const {
127
130
131
132 if (GV) {
134
135
136
137 if (CR->getUnsignedMax().ult(128))
139 else
141 }
142 }
143
146
148
149 if (!GV)
154 }
155
158
160
161
162
165
166
167
168 if (AllowTaggedGlobals && GV && !isa(GV))
171 }
172
177 }
178
179
180
184}
185
186unsigned char
189}
190
191unsigned char
193 const Module &M) const {
196
197
198
199
200
202 if (!GV)
207 }
208
209 const Function *F = dyn_cast_or_null(GV);
210
213
214
215
217
218 if (((F && F->hasFnAttribute(Attribute::NonLazyBind)) ||
219 ( && M.getRtLibUseGOT())) &&
222
226 }
227
229 if (F && F->hasFnAttribute(Attribute::NonLazyBind))
230
231
232
235 }
236
238}
239
240
242
243
244
246 return false;
248}
249
250void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef TuneCPU,
253 CPU = "generic";
254
255 if (TuneCPU.empty())
256 TuneCPU = "i586";
257
259 assert(!FullFS.empty() && "Failed to parse X86 triple");
260
261 if (!FS.empty())
262 FullFS = (Twine(FullFS) + "," + FS).str();
263
264
265
266
267 if (CPU == "generic" || CPU == "pentium4" || CPU == "x86-64") {
268 size_t posNoEVEX512 = FS.rfind("-evex512");
269
270 size_t posNoAVX512F =
271 FS.ends_with("-avx512f") ? FS.size() - 8 : FS.rfind("-avx512f,");
272 size_t posEVEX512 = FS.rfind("+evex512");
273
274 size_t posAVX512F = FS.rfind("+avx512");
275
277 (posNoAVX512F == StringRef::npos || posNoAVX512F < posAVX512F))
279 FullFS += ",+evex512";
280 }
281
282
284 "egpr", "push2pop2", "ppx", "ndd", "ccmp", "nf", "cf", "zu", "uintr"};
285 if (FullFS.find("-64bit-mode") != std:🧵:npos)
286 for (StringRef F : FeaturesIn64BitOnly)
287 FullFS += ",-" + F.str();
288
289
291
292
293
294
295
296 if (hasSSE42() || hasSSE4A())
297 IsUnalignedMem16Slow = false;
298
299 LLVM_DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
300 << ", MMX " << HasMMX << ", 64bit " << HasX86_64 << "\n");
301 if (Is64Bit && !HasX86_64)
302 report_fatal_error("64-bit code requested on a subtarget that doesn't "
303 "support it!");
304
305
306
307
308 if (StackAlignOverride)
309 stackAlignment = *StackAlignOverride;
312 stackAlignment = Align(16);
313
314
315 if (PreferVectorWidthOverride)
316 PreferVectorWidth = PreferVectorWidthOverride;
317 else if (Prefer128Bit)
318 PreferVectorWidth = 128;
319 else if (Prefer256Bit)
320 PreferVectorWidth = 256;
321}
322
326 initSubtargetFeatures(CPU, TuneCPU, FS);
327 return *this;
328}
329
333 unsigned PreferVectorWidthOverride,
334 unsigned RequiredVectorWidth)
336 PICStyle(PICStyles::Style::None), TM(TM), TargetTriple(TT),
337 StackAlignOverride(StackAlignOverride),
338 PreferVectorWidthOverride(PreferVectorWidthOverride),
339 RequiredVectorWidth(RequiredVectorWidth),
340 InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
341 TLInfo(TM, *this), FrameLowering(*this, getStackAlignment()) {
342
344
345
355
358
360 RegBankInfo.reset(RBI);
362}
363
365 return CallLoweringInfo.get();
366}
367
369 return InstSelector.get();
370}
371
374}
375
377 return RegBankInfo.get();
378}
379
382}
383
385 std::vector<std::unique_ptr> &Mutations) const {
387}
388
391}
This file contains the simple types necessary to represent the attributes associated with functions a...
This file describes how to lower LLVM calls to machine code calls.
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file describes how to lower LLVM calls to machine code calls.
static bool is64Bit(const char *name)
This file declares the targeting of the Machinelegalizer class for X86.
This file declares the targeting of the RegisterBankInfo class for X86.
static cl::opt< bool > X86EarlyIfConv("x86-early-ifcvt", cl::Hidden, cl::desc("Enable early if-conversion on X86"))
bool hasDLLImportStorageClass() const
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
std::optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns std::null...
bool hasCommonLinkage() const
A Module instance is used to store all the information related to an LLVM module.
Holds all the information related to register banks.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
static constexpr size_t npos
bool isPositionIndependent() const
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
bool shouldAssumeDSOLocal(const GlobalValue *GV) const
CodeModel::Model getCodeModel() const
Returns the code model.
bool isLargeGlobalValue(const GlobalValue *GV) const
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class provides the information for the target register banks.
bool enableEarlyIfConversion() const override
bool isTargetKFreeBSD() const
InstructionSelector * getInstructionSelector() const override
const X86TargetLowering * getTargetLowering() const override
bool isLegalToCallImmediateAddr() const
Return true if the subtarget allows calls to immediate address.
bool isTargetDarwin() const
const RegisterBankInfo * getRegBankInfo() const override
bool isTargetCOFF() const
bool isTargetNaCl() const
unsigned char classifyGlobalReference(const GlobalValue *GV, const Module &M) const
const LegalizerInfo * getLegalizerInfo() const override
bool isPositionIndependent() const
unsigned char classifyLocalReference(const GlobalValue *GV) const
Classify a global variable reference for the current subtarget according to how we should reference i...
unsigned char classifyBlockAddressReference() const
Classify a blockaddress reference for the current subtarget according to how we should reference it i...
const X86RegisterInfo * getRegisterInfo() const override
void setPICStyle(PICStyles::Style Style)
X86Subtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS, const X86TargetMachine &TM, MaybeAlign StackAlignOverride, unsigned PreferVectorWidthOverride, unsigned RequiredVectorWidth)
This constructor initializes the data members to match that of the specified triple.
const CallLowering * getCallLowering() const override
Methods used by Global ISel.
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
void getPostRAMutations(std::vector< std::unique_ptr< ScheduleDAGMutation > > &Mutations) const override
bool isTargetWin32() const
unsigned char classifyGlobalFunctionReference(const GlobalValue *GV, const Module &M) const
Classify a global function reference for the current subtarget.
bool isTargetLinux() const
@ X86_RegCall
Register calling convention used for parameters transfer optimization.
@ MO_GOTPCREL_NORELAX
MO_GOTPCREL_NORELAX - Same as MO_GOTPCREL except that R_X86_64_GOTPCREL relocations are guaranteed to...
@ MO_GOTOFF
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
@ MO_DARWIN_NONLAZY_PIC_BASE
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
@ MO_DARWIN_NONLAZY
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
@ MO_GOT
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
@ MO_ABS8
MO_ABS8 - On a symbol operand this indicates that the symbol is known to be an absolute symbol in ran...
@ MO_PLT
MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...
@ MO_NO_FLAG
MO_NO_FLAG - No flag for the operand.
@ MO_DLLIMPORT
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...
@ MO_PIC_BASE_OFFSET
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
@ MO_GOTPCREL
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
std::string ParseX86Triple(const Triple &TT)
This is an optimization pass for GlobalISel generic memory operations.
std::unique_ptr< ScheduleDAGMutation > createX86MacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createX86MacroFusionDAGMutation()); to X86PassConfig::crea...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
InstructionSelector * createX86InstructionSelector(const X86TargetMachine &TM, const X86Subtarget &, const X86RegisterBankInfo &)
This struct is a compact representation of a valid (non-zero power of two) alignment.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.