16 #ifdef LLVM_BUILD_GLOBAL_ISEL
25 #ifdef LLVM_BUILD_GLOBAL_ISEL
51 #define DEBUG_TYPE "subtarget"
53 #define GET_SUBTARGETINFO_TARGET_DESC
54 #define GET_SUBTARGETINFO_CTOR
55 #include "X86GenSubtargetInfo.inc"
61 cl::desc(
"Enable early if-conversion on X86"));
118 if (CR->getUnsignedMax().ult(128))
155 const Function *
F = dyn_cast_or_null<Function>(GV);
208 std::string CPUName = CPU;
214 std::string FullFS = FS;
217 FullFS =
"+64bit,+sse2," + FullFS;
219 FullFS =
"+64bit,+sse2";
225 FullFS =
"+sahf," + FullFS;
240 InstrItins = getInstrItineraryForCPU(CPUName);
245 ToggleFeature(X86::Mode64Bit);
246 else if (In32BitMode)
247 ToggleFeature(X86::Mode32Bit);
248 else if (In16BitMode)
249 ToggleFeature(X86::Mode16Bit);
257 "64-bit code requested on a subtarget that doesn't support it!");
261 if (StackAlignOverride)
268 void X86Subtarget::initializeEnvironment() {
347 initializeEnvironment();
348 initSubtargetFeatures(CPU, FS);
352 #ifdef LLVM_BUILD_GLOBAL_ISEL
356 std::unique_ptr<CallLowering> CallLoweringInfo;
357 std::unique_ptr<LegalizerInfo>
Legalizer;
358 std::unique_ptr<RegisterBankInfo> RegBankInfo;
359 std::unique_ptr<InstructionSelector> InstSelector;
362 return CallLoweringInfo.get();
366 return InstSelector.get();
374 return RegBankInfo.get();
383 unsigned StackAlignOverride)
385 PICStyle(PICStyles::
None), TM(TM), TargetTriple(TT),
386 StackAlignOverride(StackAlignOverride),
387 In64BitMode(TargetTriple.getArch() ==
Triple::x86_64),
388 In32BitMode(TargetTriple.getArch() ==
Triple::x86 &&
389 TargetTriple.getEnvironment() !=
Triple::CODE16),
390 In16BitMode(TargetTriple.getArch() ==
Triple::x86 &&
391 TargetTriple.getEnvironment() ==
Triple::CODE16),
392 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
393 FrameLowering(*this, getStackAlignment()) {
405 #ifndef LLVM_BUILD_GLOBAL_ISEL
408 X86GISelActualAccessor *GISel =
new X86GISelActualAccessor();
414 GISel->RegBankInfo.reset(RBI);
421 assert(
GISel &&
"Access to GlobalISel APIs not set");
422 return GISel->getCallLowering();
426 assert(
GISel &&
"Access to GlobalISel APIs not set");
427 return GISel->getInstructionSelector();
431 assert(
GISel &&
"Access to GlobalISel APIs not set");
432 return GISel->getLegalizerInfo();
436 assert(
GISel &&
"Access to GlobalISel APIs not set");
437 return GISel->getRegBankInfo();
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
bool HasPRFCHW
Processor has PRFCHW instructions.
bool HasFXSR
Target has FXSAVE/FXRESTOR instructions.
bool HasTBM
Target has TBM instructions.
bool HasBMI2
Processor has BMI2 instructions.
The goal of this helper class is to gather the accessor to all the APIs related to GlobalISel...
bool HasSGX
Processor has Software Guard Extensions.
const CallLowering * getCallLowering() const override
Methods used by Global ISel.
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
A Module instance is used to store all the information related to an LLVM module. ...
bool HasLAHFSAHF
Processor has LAHF/SAHF instructions.
bool HasCDI
Processor has AVX-512 Conflict Detection Instructions.
bool HasAES
Target has AES instructions.
void setPICStyle(PICStyles::Style Style)
bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isMacOSXVersionLT - Comparison function for checking OS X version compatibility, which handles suppor...
bool HasERI
Processor has AVX-512 Exponential and Reciprocal Instructions.
unsigned MaxInlineSizeThreshold
Max.
bool HasERMSB
True if the processor has enhanced REP MOVSB/STOSB.
bool LEAUsesAG
True if the LEA instruction inputs have to be ready at address generation (AG) time.
bool HasVPOPCNTDQ
Processor has AVX-512 population count Instructions.
const LegalizerInfo * getLegalizerInfo() const override
bool HasFastScalarFSQRT
True if hardware SQRTSS instruction is at least as fast (latency) as RSQRTSS followed by a Newton-Rap...
static cl::opt< bool > X86EarlyIfConv("x86-early-ifcvt", cl::Hidden, cl::desc("Enable early if-conversion on X86"))
bool IsUAMem32Slow
True if unaligned memory accesses of 32-bytes are slow.
bool HasLWP
Target has LWP instructions.
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
bool IsPMULLDSlow
True if the PMULLD instruction is slow compared to PMULLW/PMULHW and.
bool HasRDRAND
True if the processor has the RDRAND instruction.
bool HasFastPartialYMMorZMMWrite
True if there is no performance penalty to writing only the lower parts of a YMM or ZMM register with...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool HasCLWB
Processor supports Cache Line Write Back instruction.
bool HasFMA
Target has 3-operand fused multiply-add.
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
bool HasFastVectorFSQRT
True if hardware SQRTPS/VSQRTPS instructions are at least as fast (throughput) as RSQRTPS/VRSQRTPS fo...
Holds all the information related to register banks.
void setGISelAccessor(GISelAccessor &GISel)
This object will take onwership of GISelAccessor.
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
bool isTargetSolaris() const
bool hasCommonLinkage() const
bool isTargetDarwin() const
bool HasCLFLUSHOPT
Processor supports Flush Cache Line instruction.
bool HasPOPCNT
True if the processor supports POPCNT.
bool HasPKU
Processor has PKU extenstions.
This class provides the information for the target register banks.
const InstructionSelector * getInstructionSelector() const override
This file contains the simple types necessary to represent the attributes associated with functions a...
const Triple & getTargetTriple() const
bool HasSlowDivide32
True if 8-bit divisions are significantly faster than 32-bit divisions and should be used when possib...
bool HasPFI
Processor has AVX-512 PreFetch Instructions.
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
bool HasIFMA
Processor has Integer Fused Multiply Add.
bool is64Bit() const
Is this x86_64? (disregarding specific ABI / programming model)
bool HasCmpxchg16b
True if this processor has the CMPXCHG16B instruction; this is true for most x86-64 chips...
MO_ABS8 - On a symbol operand this indicates that the symbol is known to be an absolute symbol in ran...
bool HasX87
True if the processor supports X87 instructions.
bool UseLeaForSP
True if the LEA instruction should be used for adjusting the stack pointer.
X863DNowEnum X863DNowLevel
MMX, 3DNow, 3DNow Athlon, or none supported.
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
bool HasSSE4A
True if the processor supports SSE4A instructions.
bool CallRegIndirect
True if the Calls with memory reference should be converted to a register-based indirect call...
bool HasLZCNT
Processor has LZCNT instruction.
bool HasF16C
Processor has 16-bit floating point conversion instructions.
bool SlowIncDec
True if INC and DEC instructions are slow when writing to flags.
const X86TargetLowering * getTargetLowering() const override
X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS, const X86TargetMachine &TM, unsigned StackAlignOverride)
This constructor initializes the data members to match that of the specified triple.
CodeModel::Model getCodeModel() const
Returns the code model.
bool isTargetCOFF() const
bool HasMWAITX
Processor has MONITORX/MWAITX instructions.
bool hasSinCos() const
This function returns true if the target has sincos() routine in its compiler runtime or math librari...
bool IsBTMemSlow
True if BT (bit test) of memory instructions are slow.
bool HasADX
Processor has ADX instructions.
bool HasBWI
Processor has AVX-512 Byte and Word instructions.
bool isPositionIndependent() const
bool isTargetWin32() const
bool HasFastSHLDRotate
True if SHLD based rotate is fast.
std::unique_ptr< GISelAccessor > GISel
Gather the accessor points to GlobalISel-related APIs.
bool HasXOP
Target has XOP instructions.
bool SlowLEA
True if the LEA instruction with certain arguments is slow.
bool HasDQI
Processor has AVX-512 Doubleword and Quadword instructions.
bool enableEarlyIfConversion() const override
unsigned char classifyLocalReference(const GlobalValue *GV) const
Classify a global variable reference for the current subtarget according to how we should reference i...
bool IsSHLDSlow
True if SHLD instructions are slow.
InstrItineraryData InstrItins
Instruction itineraries for scheduling.
bool HasFSGSBase
Processor has FS/GS base insturctions.
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
unsigned char classifyBlockAddressReference() const
Classify a blockaddress reference for the current subtarget according to how we should reference it i...
bool IsUAMem16Slow
True if unaligned memory accesses of 16-bytes are slow.
Triple - Helper class for working with autoconf configuration names.
This file declares the targeting of the RegisterBankInfo class for X86.
const X86RegisterInfo * getRegisterInfo() const override
bool HasMPX
Processor supports MPX - Memory Protection Extensions.
bool HasX86_64
True if the processor supports X86-64 instructions.
bool HasSSEUnalignedMem
True if SSE operations can have unaligned memory operands.
unsigned char classifyGlobalFunctionReference(const GlobalValue *GV, const Module &M) const
Classify a global function reference for the current subtarget.
bool HasXSAVES
Target has XSAVES instructions.
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None...
bool HasSHA
Processor has SHA instructions.
bool HasBMI
Processor has BMI1 instructions.
bool isTargetLinux() const
bool HasVBMI
Processor has VBMI instructions.
InstructionSelector * createX86InstructionSelector(const X86TargetMachine &TM, X86Subtarget &, X86RegisterBankInfo &)
bool Slow3OpsLEA
True if the LEA instruction has all three source operands: base, index, and offset or if the LEA inst...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool UseSoftFloat
Use software floating point for code generation.
This file describes how to lower LLVM calls to machine code calls.
llvm_unreachable("Unknown RegBank!")
bool HasPCLMUL
Target has carry-less multiplication.
Provides the logic to select generic machine instructions.
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
This class provides the information for the target register banks.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool HasXSAVEOPT
Target has XSAVEOPT instructions.
X86SSEEnum X86SSELevel
SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, or none supported.
unsigned char classifyGlobalReference(const GlobalValue *GV, const Module &M) const
bool HasXSAVE
Target has XSAVE instructions.
MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...
bool HasCMov
True if this processor has conditional move instructions (generally pentium pro+).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
bool HasFMA4
Target has 4-operand fused multiply-add.
This file describes how to lower LLVM calls to machine code calls.
bool HasRTM
Processor has RTM instructions.
This file declares the targeting of the Machinelegalizer class for X86.
const RegisterBankInfo * getRegBankInfo() const override
bool HasXSAVEC
Target has XSAVEC instructions.
bool HasVLX
Processor has AVX-512 Vector Length eXtenstions.
bool HasFastLZCNT
True if LZCNT instruction is fast.
const char * getBZeroEntry() const
This function returns the name of a function which has an interface like the non-standard bzero funct...
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
StringRef - Represent a constant reference to a string, i.e.
bool HasRDSEED
Processor has RDSEED instructions.
Register calling convention used for parameters transfer optimization.
unsigned stackAlignment
The minimum alignment known to hold of the stack frame on entry to the function and which must be mai...
bool isTargetKFreeBSD() const
bool isLegalToCallImmediateAddr() const
Return true if the subtarget allows calls to immediate address.
bool isDeclarationForLinker() const
bool HasMOVBE
True if the processor has the MOVBE instruction.
bool PadShortFunctions
True if the short functions should be padded to prevent a stall when returning too early...
bool HasCLZERO
Processor has Cache Line Zero instruction.
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...
bool HasSlowDivide64
True if 32-bit divides are significantly faster than 64-bit divisions and should be used when possibl...