14 #define DEBUG_TYPE "subtarget"
27 #define GET_SUBTARGETINFO_TARGET_DESC
28 #define GET_SUBTARGETINFO_CTOR
29 #include "X86GenSubtargetInfo.inc"
82 assert(
isTargetELF() &&
"Unknown rip-relative target");
174 #if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)\
175 || defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
176 #if defined(__GNUC__)
181 __asm__ (
".byte 0x0f, 0x01, 0xd0" :
"=a" (rEAX),
"=d" (rEDX) :
"c" (0));
182 #elif defined(_MSC_FULL_VER) && defined(_XCR_XFEATURE_ENABLED_MASK)
183 unsigned long long rEAX = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
187 return (rEAX & 6) == 6;
207 if ((
EDX >> 15) & 1) {
HasCMov =
true; ToggleFeature(X86::FeatureCMOV); }
219 bool IsIntel =
memcmp(text.c,
"GenuineIntel", 12) == 0;
220 bool IsAMD = !IsIntel &&
memcmp(text.c,
"AuthenticAMD", 12) == 0;
222 if ((
ECX >> 1) & 0x1) {
224 ToggleFeature(X86::FeaturePCLMUL);
226 if ((
ECX >> 12) & 0x1) {
228 ToggleFeature(X86::FeatureFMA);
230 if (IsIntel && ((
ECX >> 22) & 0x1)) {
232 ToggleFeature(X86::FeatureMOVBE);
234 if ((
ECX >> 23) & 0x1) {
236 ToggleFeature(X86::FeaturePOPCNT);
238 if ((
ECX >> 25) & 0x1) {
240 ToggleFeature(X86::FeatureAES);
242 if ((
ECX >> 29) & 0x1) {
244 ToggleFeature(X86::FeatureF16C);
246 if (IsIntel && ((
ECX >> 30) & 0x1)) {
248 ToggleFeature(X86::FeatureRDRAND);
251 if ((
ECX >> 13) & 0x1) {
253 ToggleFeature(X86::FeatureCMPXCHG16B);
256 if (IsIntel || IsAMD) {
261 if (IsAMD || (Family == 6 && Model >= 13)) {
263 ToggleFeature(X86::FeatureSlowBTMem);
270 ((Family == 6 && Model == 0x1E) ||
272 (Family == 6 && Model == 0x1A) ||
273 (Family == 6 && Model == 0x2E) ||
274 (Family == 6 && Model == 0x25) ||
275 (Family == 6 && Model == 0x2C) ||
276 (Family == 6 && Model == 0x2F) ||
277 (Family == 6 && Model == 0x2A) ||
278 (Family == 6 && Model == 0x2D) ||
279 (Family == 6 && Model == 0x3A) ||
280 (Family == 6 && Model == 0x3E) ||
281 (Family == 6 && Model == 0x3C) ||
282 (Family == 6 && Model == 0x3F) ||
283 (Family == 6 && Model == 0x45) ||
284 (Family == 6 && Model == 0x46))) {
286 ToggleFeature(X86::FeatureFastUAMem);
291 (Model == 28 || Model == 38 || Model == 39 ||
292 Model == 53 || Model == 54)) {
296 ToggleFeature(X86::FeatureLeaForSP);
298 else if (Family == 6 &&
299 (Model == 55 || Model == 74 || Model == 77)) {
303 unsigned MaxExtLevel;
306 if (MaxExtLevel >= 0x80000001) {
308 if ((
EDX >> 29) & 0x1) {
310 ToggleFeature(X86::Feature64Bit);
312 if ((
ECX >> 5) & 0x1) {
314 ToggleFeature(X86::FeatureLZCNT);
316 if (IsIntel && ((
ECX >> 8) & 0x1)) {
318 ToggleFeature(X86::FeaturePRFCHW);
321 if ((
ECX >> 6) & 0x1) {
323 ToggleFeature(X86::FeatureSSE4A);
325 if ((
ECX >> 11) & 0x1) {
327 ToggleFeature(X86::FeatureXOP);
329 if ((
ECX >> 16) & 0x1) {
331 ToggleFeature(X86::FeatureFMA4);
339 if (IsIntel && (
EBX & 0x1)) {
341 ToggleFeature(X86::FeatureFSGSBase);
343 if ((
EBX >> 3) & 0x1) {
345 ToggleFeature(X86::FeatureBMI);
347 if ((
EBX >> 4) & 0x1) {
349 ToggleFeature(X86::FeatureHLE);
351 if (IsIntel && ((
EBX >> 5) & 0x1)) {
353 ToggleFeature(X86::FeatureAVX2);
355 if (IsIntel && ((
EBX >> 8) & 0x1)) {
357 ToggleFeature(X86::FeatureBMI2);
359 if (IsIntel && ((
EBX >> 11) & 0x1)) {
361 ToggleFeature(X86::FeatureRTM);
363 if (IsIntel && ((
EBX >> 16) & 0x1)) {
365 ToggleFeature(X86::FeatureAVX512);
367 if (IsIntel && ((
EBX >> 18) & 0x1)) {
369 ToggleFeature(X86::FeatureRDSEED);
371 if (IsIntel && ((
EBX >> 19) & 0x1)) {
373 ToggleFeature(X86::FeatureADX);
375 if (IsIntel && ((
EBX >> 26) & 0x1)) {
377 ToggleFeature(X86::FeaturePFI);
379 if (IsIntel && ((
EBX >> 27) & 0x1)) {
381 ToggleFeature(X86::FeatureERI);
383 if (IsIntel && ((
EBX >> 28) & 0x1)) {
385 ToggleFeature(X86::FeatureCDI);
387 if (IsIntel && ((
EBX >> 29) & 0x1)) {
389 ToggleFeature(X86::FeatureSHA);
392 if (IsAMD && ((
ECX >> 21) & 0x1)) {
394 ToggleFeature(X86::FeatureTBM);
410 initializeEnvironment();
416 std::string CPUName = CPU;
418 if (CPUName.empty()) {
419 #if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)\
420 || defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
429 std::string FullFS =
FS;
432 FullFS =
"+64bit,+sse2," + FullFS;
434 FullFS =
"+64bit,+sse2";
440 if (CPUName.empty()) {
441 #if defined (__x86_64__) || defined(__i386__)
453 if (!
HasCMov) {
HasCMov =
true; ToggleFeature(X86::FeatureCMOV); }
457 ToggleFeature(X86::FeatureSSE1);
458 ToggleFeature(X86::FeatureSSE2);
465 InitCPUSchedModel(CPUName);
470 InstrItins = getInstrItineraryForCPU(CPUName);
475 ToggleFeature(X86::Mode64Bit);
481 "64-bit code requested on a subtarget that doesn't support it!");
485 if (StackAlignOverride)
492 void X86Subtarget::initializeEnvironment() {
537 const std::string &FS,
538 unsigned StackAlignOverride,
bool is64Bit)
540 , X86ProcFamily(Others)
541 , PICStyle(PICStyles::
None)
543 , StackAlignOverride(StackAlignOverride)
544 , In64BitMode(is64Bit) {
545 initializeEnvironment();
552 RegClassVector& CriticalPathRCs)
const {
554 CriticalPathRCs.clear();
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
bool HasPRFCHW
HasPRFCHW - Processor has PRFCHW instructions.
bool HasTBM
HasTBM - Target has TBM instructions.
bool HasBMI2
HasBMI2 - Processor has BMI2 instructions.
Reloc::Model getRelocationModel() const
bool HasCDI
Processor has AVX-512 Conflict Detection Instructions.
bool HasAES
HasAES - Target has AES instructions.
bool HasERI
Processor has AVX-512 Exponential and Reciprocal Instructions.
unsigned char ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const
X86Subtarget(const std::string &TT, const std::string &CPU, const std::string &FS, unsigned StackAlignOverride, bool is64Bit)
unsigned MaxInlineSizeThreshold
bool hasAvailableExternallyLinkage() const
const Function * getFunction() const
bool HasRDRAND
HasRDRAND - True if the processor has the RDRAND instruction.
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
bool HasFMA
HasFMA - Target has 3-operand fused multiply-add.
bool isTargetSolaris() const
bool hasCommonLinkage() const
bool hasDefaultVisibility() const
bool isTargetDarwin() const
bool GetCpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX, unsigned *rECX, unsigned *rEDX)
bool HasPOPCNT
HasPOPCNT - True if the processor supports POPCNT.
This file contains the simple types necessary to represent the attributes associated with functions a...
No attributes have been set.
const Triple & getTargetTriple() const
bool HasPFI
Processor has AVX-512 PreFetch Instructions.
unsigned isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
bool is64Bit() const
Is this x86_64? (disregarding specific ABI / programming model)
bool isPICStyleRIPRel() const
bool isMaterializable() const
X863DNowEnum X863DNowLevel
bool HasSSE4A
HasSSE4A - True if the processor supports SSE4A instructions.
bool HasLZCNT
HasLZCNT - Processor has LZCNT instruction.
bool HasF16C
HasF16C - Processor has 16-bit floating point conversion instructions.
static bool isWeakForLinker(LinkageTypes Linkage)
virtual void resetSubtargetFeatures(const MachineFunction *MF)
Reset the features for the X86 target.
static bool OSHasAVXSupport()
unsigned char ClassifyBlockAddressReference() const
int memcmp(const void *s1, const void *s2, size_t n);
CodeModel::Model getCodeModel() const
bool isPICStyleStubPIC() const
bool IsBTMemSlow
IsBTMemSlow - True if BT (bit test) of memory instructions are slow.
bool HasADX
HasADX - Processor has ADX instructions.
bool hasHiddenVisibility() const
std::string getHostCPUName()
bool GetCpuIDAndInfoEx(unsigned value, unsigned subleaf, unsigned *rEAX, unsigned *rEBX, unsigned *rECX, unsigned *rEDX)
bool IsLegalToCallImmediateAddr(const TargetMachine &TM) const
bool HasXOP
HasXOP - Target has XOP instructions.
bool isPICStyleStubNoDynamic() const
bool isPICStyleGOT() const
InstrItineraryData InstrItins
Instruction itineraries for scheduling.
bool HasFSGSBase
HasFSGSBase - Processor has FS/GS base insturctions.
void DetectFamilyModel(unsigned EAX, unsigned &Family, unsigned &Model)
X86ProcFamilyEnum X86ProcFamily
X86ProcFamily - X86 processor family: Intel Atom, and others.
bool PostRAScheduler
PostRAScheduler - True if using post-register-allocation scheduler.
bool HasSHA
HasSHA - Processor has SHA instructions.
bool HasBMI
HasBMI - Processor has BMI1 instructions.
bool isTargetLinux() const
bool HasHLE
HasHLE - Processor has HLE.
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
AttributeSet getAttributes() const
Return the attribute list for this Function.
bool HasPCLMUL
HasPCLMUL - Target has carry-less multiplication.
bool isDeclaration() const
bool hasLocalLinkage() const
Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
StringRef getValueAsString() const
Return the attribute's value as a string. This requires the attribute to be a string attribute...
void AutoDetectSubtargetFeatures()
bool isTargetWin64() const
bool HasFMA4
HasFMA4 - Target has 4-operand fused multiply-add.
bool HasRTM
HasRTM - Processor has RTM instructions.
bool hasDLLImportLinkage() const
const char * getBZeroEntry() const
bool HasRDSEED
HasRDSEED - Processor has RDSEED instructions.
bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, TargetSubtargetInfo::AntiDepBreakMode &Mode, RegClassVector &CriticalPathRCs) const
enablePostRAScheduler - run for Atom optimization.
bool IsUAMemFast
IsUAMemFast - True if unaligned memory access is fast.
bool HasMOVBE
HasMOVBE - True if the processor has the MOVBE instruction.
bool empty() const
empty - Check if the string is empty.