diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-08-30 06:01:05 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-08-30 06:01:05 +0000 |
| commit | b7b353be6044051cc4fa8888dd3d86a2a1b56d8c (patch) | |
| tree | ae0d3e93122d60fd7e34f8f1a09d98796e75c5bc /llvm/lib/Target | |
| parent | 987ef2ddfd3298514e2e7c8d55a981161661c7b1 (diff) | |
| download | bcm5719-llvm-b7b353be6044051cc4fa8888dd3d86a2a1b56d8c.tar.gz bcm5719-llvm-b7b353be6044051cc4fa8888dd3d86a2a1b56d8c.zip | |
[X86] Make Feature64Bit useful
We now only add +64bit to the CPU string for "generic" CPU. All other CPU names are assumed to have the feature flag already set if they support 64-bit. I've remove the implies from CMPXCHG8 so that Feature64Bit only comes in via CPUs or user passing -mattr=+64bit.
I've changed the assert to a report_fatal_error so it's not lost in Release builds.
The test updates are to fix things that tripped the new error.
Differential Revision: https://reviews.llvm.org/D51231
llvm-svn: 341022
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/X86/X86.td | 26 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86Subtarget.cpp | 21 |
2 files changed, 36 insertions, 11 deletions
diff --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td index 2ce715f8292..c783745a73d 100644 --- a/llvm/lib/Target/X86/X86.td +++ b/llvm/lib/Target/X86/X86.td @@ -88,12 +88,12 @@ def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA", [Feature3DNow]>; // All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied // feature, because SSE2 can be disabled (e.g. for compiling OS kernels) -// without disabling 64-bit mode. +// without disabling 64-bit mode. Nothing should imply this feature bit. It +// is used to enforce that only 64-bit capable CPUs are used in 64-bit mode. def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true", "Support 64-bit instructions">; def FeatureCMPXCHG16B : SubtargetFeature<"cx16", "HasCmpxchg16b", "true", - "64-bit with cmpxchg16b", - [Feature64Bit]>; + "64-bit with cmpxchg16b">; def FeatureSlowSHLD : SubtargetFeature<"slow-shld", "IsSHLDSlow", "true", "SHLD instruction is slow">; def FeatureSlowPMULLD : SubtargetFeature<"slow-pmulld", "IsPMULLDSlow", "true", @@ -520,6 +520,7 @@ def : ProcessorModel<"nocona", GenericPostRAModel, [ FeatureSSE3, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B ]>; @@ -532,6 +533,7 @@ def : ProcessorModel<"core2", SandyBridgeModel, [ FeatureSSSE3, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeatureLAHFSAHF, FeatureMacroFusion @@ -544,6 +546,7 @@ def : ProcessorModel<"penryn", SandyBridgeModel, [ FeatureSSE41, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeatureLAHFSAHF, FeatureMacroFusion @@ -559,6 +562,7 @@ class BonnellProc<string Name> : ProcessorModel<Name, AtomModel, [ FeatureSSSE3, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeatureMOVBE, FeatureLEAForSP, @@ -580,6 +584,7 @@ class SilvermontProc<string Name> : ProcessorModel<Name, SLMModel, [ FeatureSSE42, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeatureMOVBE, FeaturePOPCNT, @@ -615,6 +620,7 @@ def GLMFeatures : ProcessorFeatures<[], [ FeatureSSE42, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeatureMOVBE, FeaturePOPCNT, @@ -675,6 +681,7 @@ class NehalemProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [ FeatureSSE42, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeaturePOPCNT, FeatureLAHFSAHF, @@ -692,6 +699,7 @@ class WestmereProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [ FeatureSSE42, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeaturePOPCNT, FeatureAES, @@ -710,6 +718,7 @@ def SNBFeatures : ProcessorFeatures<[], [ FeatureAVX, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeaturePOPCNT, FeatureAES, @@ -927,13 +936,13 @@ foreach P = ["k8", "opteron", "athlon64", "athlon-fx"] in { foreach P = ["k8-sse3", "opteron-sse3", "athlon64-sse3"] in { def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureSSE3, Feature3DNowA, FeatureFXSR, FeatureNOPL, FeatureCMPXCHG16B, FeatureSlowSHLD, - FeatureCMOV]>; + FeatureCMOV, Feature64Bit]>; } foreach P = ["amdfam10", "barcelona"] in { def : Proc<P, [FeatureX87, FeatureSSE4A, Feature3DNowA, FeatureFXSR, FeatureNOPL, FeatureCMPXCHG16B, FeatureLZCNT, FeaturePOPCNT, - FeatureSlowSHLD, FeatureLAHFSAHF, FeatureCMOV]>; + FeatureSlowSHLD, FeatureLAHFSAHF, FeatureCMOV, Feature64Bit]>; } // Bobcat @@ -945,6 +954,7 @@ def : Proc<"btver1", [ FeatureSSE4A, FeatureFXSR, FeatureNOPL, + Feature64Bit, FeatureCMPXCHG16B, FeaturePRFCHW, FeatureLZCNT, @@ -963,6 +973,7 @@ def : ProcessorModel<"btver2", BtVer2Model, [ FeatureFXSR, FeatureNOPL, FeatureSSE4A, + Feature64Bit, FeatureCMPXCHG16B, FeaturePRFCHW, FeatureAES, @@ -987,6 +998,7 @@ def : Proc<"bdver1", [ FeatureCMOV, FeatureXOP, FeatureFMA4, + Feature64Bit, FeatureCMPXCHG16B, FeatureAES, FeaturePRFCHW, @@ -1011,6 +1023,7 @@ def : Proc<"bdver2", [ FeatureCMOV, FeatureXOP, FeatureFMA4, + Feature64Bit, FeatureCMPXCHG16B, FeatureAES, FeaturePRFCHW, @@ -1040,6 +1053,7 @@ def : Proc<"bdver3", [ FeatureCMOV, FeatureXOP, FeatureFMA4, + Feature64Bit, FeatureCMPXCHG16B, FeatureAES, FeaturePRFCHW, @@ -1075,6 +1089,7 @@ def : Proc<"bdver4", [ FeatureNOPL, FeatureXOP, FeatureFMA4, + Feature64Bit, FeatureCMPXCHG16B, FeatureAES, FeaturePRFCHW, @@ -1107,6 +1122,7 @@ def: ProcessorModel<"znver1", Znver1Model, [ FeatureCLFLUSHOPT, FeatureCLZERO, FeatureCMOV, + Feature64Bit, FeatureCMPXCHG16B, FeatureF16C, FeatureFMA, diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp index df8fd1a1640..c3503a363cc 100644 --- a/llvm/lib/Target/X86/X86Subtarget.cpp +++ b/llvm/lib/Target/X86/X86Subtarget.cpp @@ -230,14 +230,22 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { if (CPUName.empty()) CPUName = "generic"; - // Make sure 64-bit features are available in 64-bit mode. (But make sure - // SSE2 can be turned off explicitly.) std::string FullFS = FS; if (In64BitMode) { + // SSE2 should default to enabled in 64-bit mode, but can be turned off + // explicitly. if (!FullFS.empty()) - FullFS = "+64bit,+sse2," + FullFS; + FullFS = "+sse2," + FullFS; else - FullFS = "+64bit,+sse2"; + FullFS = "+sse2"; + + // If no CPU was specified, enable 64bit feature to satisy later check. + if (CPUName == "generic") { + if (!FullFS.empty()) + FullFS = "+64bit," + FullFS; + else + FullFS = "+64bit"; + } } // LAHF/SAHF are always supported in non-64-bit mode. @@ -272,8 +280,9 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { LLVM_DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel << ", 3DNowLevel " << X863DNowLevel << ", 64bit " << HasX86_64 << "\n"); - assert((!In64BitMode || HasX86_64) && - "64-bit code requested on a subtarget that doesn't support it!"); + if (In64BitMode && !HasX86_64) + report_fatal_error("64-bit code requested on a subtarget that doesn't " + "support it!"); // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and Solaris (both // 32 and 64 bit) and for all 64-bit targets. |

