forked from OSchip/llvm-project
Add avx512cd, avx512er, avx512pf feature flags and enable them on KNL CPU.
llvm-svn: 188867
This commit is contained in:
parent
7efc04cb40
commit
679b53ac67
|
@ -969,6 +969,9 @@ def mno_aes : Flag<["-"], "mno-aes">, Group<m_x86_Features_Group>;
|
|||
def mno_avx : Flag<["-"], "mno-avx">, Group<m_x86_Features_Group>;
|
||||
def mno_avx2 : Flag<["-"], "mno-avx2">, Group<m_x86_Features_Group>;
|
||||
def mno_avx512f : Flag<["-"], "mno-avx512f">, Group<m_x86_Features_Group>;
|
||||
def mno_avx512cd : Flag<["-"], "mno-avx512cd">, Group<m_x86_Features_Group>;
|
||||
def mno_avx512er : Flag<["-"], "mno-avx512er">, Group<m_x86_Features_Group>;
|
||||
def mno_avx512pd : Flag<["-"], "mno-avx512pd">, Group<m_x86_Features_Group>;
|
||||
def mno_pclmul : Flag<["-"], "mno-pclmul">, Group<m_x86_Features_Group>;
|
||||
def mno_lzcnt : Flag<["-"], "mno-lzcnt">, Group<m_x86_Features_Group>;
|
||||
def mno_rdrnd : Flag<["-"], "mno-rdrnd">, Group<m_x86_Features_Group>;
|
||||
|
@ -1016,6 +1019,9 @@ def maes : Flag<["-"], "maes">, Group<m_x86_Features_Group>;
|
|||
def mavx : Flag<["-"], "mavx">, Group<m_x86_Features_Group>;
|
||||
def mavx2 : Flag<["-"], "mavx2">, Group<m_x86_Features_Group>;
|
||||
def mavx512f : Flag<["-"], "mavx512f">, Group<m_x86_Features_Group>;
|
||||
def mavx512cd : Flag<["-"], "mavx512cd">, Group<m_x86_Features_Group>;
|
||||
def mavx512er : Flag<["-"], "mavx512er">, Group<m_x86_Features_Group>;
|
||||
def mavx512pd : Flag<["-"], "mavx512pd">, Group<m_x86_Features_Group>;
|
||||
def mpclmul : Flag<["-"], "mpclmul">, Group<m_x86_Features_Group>;
|
||||
def mlzcnt : Flag<["-"], "mlzcnt">, Group<m_x86_Features_Group>;
|
||||
def mrdrnd : Flag<["-"], "mrdrnd">, Group<m_x86_Features_Group>;
|
||||
|
|
|
@ -1562,6 +1562,7 @@ class X86TargetInfo : public TargetInfo {
|
|||
bool HasRDSEED;
|
||||
bool HasFMA;
|
||||
bool HasF16C;
|
||||
bool HasAVX512CD, HasAVX512ER, HasAVX512PF;
|
||||
|
||||
/// \brief Enumeration of all of the X86 CPUs supported by Clang.
|
||||
///
|
||||
|
@ -1714,7 +1715,8 @@ public:
|
|||
XOPLevel(NoXOP), HasAES(false), HasPCLMUL(false), HasLZCNT(false),
|
||||
HasRDRND(false), HasBMI(false), HasBMI2(false), HasPOPCNT(false),
|
||||
HasRTM(false), HasPRFCHW(false), HasRDSEED(false), HasFMA(false),
|
||||
HasF16C(false), CPU(CK_Generic) {
|
||||
HasF16C(false), HasAVX512CD(false), HasAVX512ER(false),
|
||||
HasAVX512PF(false), CPU(CK_Generic) {
|
||||
BigEndian = false;
|
||||
LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
|
||||
}
|
||||
|
@ -1980,7 +1982,10 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
|
|||
setFeatureEnabled(Features, "fma", true);
|
||||
break;
|
||||
case CK_KNL:
|
||||
setFeatureEnabled(Features, "avx-512", true);
|
||||
setFeatureEnabled(Features, "avx512f", true);
|
||||
setFeatureEnabled(Features, "avx512cd", true);
|
||||
setFeatureEnabled(Features, "avx512er", true);
|
||||
setFeatureEnabled(Features, "avx512pf", true);
|
||||
setFeatureEnabled(Features, "aes", true);
|
||||
setFeatureEnabled(Features, "pclmul", true);
|
||||
setFeatureEnabled(Features, "lzcnt", true);
|
||||
|
@ -2119,7 +2124,8 @@ void X86TargetInfo::setSSELevel(llvm::StringMap<bool> &Features,
|
|||
case AVX2:
|
||||
Features["avx2"] = false;
|
||||
case AVX512F:
|
||||
Features["avx512f"] = false;
|
||||
Features["avx512f"] = Features["avx512cd"] = Features["avx512er"] =
|
||||
Features["avx512pf"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2221,9 +2227,12 @@ void X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
|
|||
setSSELevel(Features, AVX, Enabled);
|
||||
else if (Name == "avx2")
|
||||
setSSELevel(Features, AVX2, Enabled);
|
||||
else if (Name == "avx-512")
|
||||
else if (Name == "avx512f")
|
||||
setSSELevel(Features, AVX512F, Enabled);
|
||||
else if (Name == "fma") {
|
||||
else if (Name == "avx512cd" || Name == "avx512er" || Name == "avx512pf") {
|
||||
if (Enabled)
|
||||
setSSELevel(Features, AVX512F, Enabled);
|
||||
} else if (Name == "fma") {
|
||||
if (Enabled)
|
||||
setSSELevel(Features, AVX, Enabled);
|
||||
} else if (Name == "fma4") {
|
||||
|
@ -2306,9 +2315,24 @@ void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Feature == "avx512cd") {
|
||||
HasAVX512CD = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Feature == "avx512er") {
|
||||
HasAVX512ER = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Feature == "avx512pf") {
|
||||
HasAVX512PF = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(Features[i][0] == '+' && "Invalid target feature!");
|
||||
X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature)
|
||||
.Case("avx-512", AVX512F)
|
||||
.Case("avx512f", AVX512F)
|
||||
.Case("avx2", AVX2)
|
||||
.Case("avx", AVX)
|
||||
.Case("sse42", SSE42)
|
||||
|
@ -2541,6 +2565,13 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
|
|||
if (HasF16C)
|
||||
Builder.defineMacro("__F16C__");
|
||||
|
||||
if (HasAVX512CD)
|
||||
Builder.defineMacro("__AVX512CD__");
|
||||
if (HasAVX512ER)
|
||||
Builder.defineMacro("__AVX512ER__");
|
||||
if (HasAVX512PF)
|
||||
Builder.defineMacro("__AVX512PF__");
|
||||
|
||||
// Each case falls through to the previous one here.
|
||||
switch (SSELevel) {
|
||||
case AVX512F:
|
||||
|
@ -2614,6 +2645,9 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
|
|||
.Case("avx", SSELevel >= AVX)
|
||||
.Case("avx2", SSELevel >= AVX2)
|
||||
.Case("avx512f", SSELevel >= AVX512F)
|
||||
.Case("avx512cd", HasAVX512CD)
|
||||
.Case("avx512er", HasAVX512ER)
|
||||
.Case("avx512pf", HasAVX512PF)
|
||||
.Case("bmi", HasBMI)
|
||||
.Case("bmi2", HasBMI2)
|
||||
.Case("fma", HasFMA)
|
||||
|
|
|
@ -570,7 +570,10 @@
|
|||
// RUN: | FileCheck %s -check-prefix=CHECK_KNL_M32
|
||||
// CHECK_KNL_M32: #define __AES__ 1
|
||||
// CHECK_KNL_M32: #define __AVX2__ 1
|
||||
// CHECK_KNL_M32: #define __AVX512CD__ 1
|
||||
// CHECK_KNL_M32: #define __AVX512ER__ 1
|
||||
// CHECK_KNL_M32: #define __AVX512F__ 1
|
||||
// CHECK_KNL_M32: #define __AVX512PF__ 1
|
||||
// CHECK_KNL_M32: #define __AVX__ 1
|
||||
// CHECK_KNL_M32: #define __BMI2__ 1
|
||||
// CHECK_KNL_M32: #define __BMI__ 1
|
||||
|
@ -599,7 +602,10 @@
|
|||
// RUN: | FileCheck %s -check-prefix=CHECK_KNL_M64
|
||||
// CHECK_KNL_M64: #define __AES__ 1
|
||||
// CHECK_KNL_M64: #define __AVX2__ 1
|
||||
// CHECK_KNL_M64: #define __AVX512CD__ 1
|
||||
// CHECK_KNL_M64: #define __AVX512ER__ 1
|
||||
// CHECK_KNL_M64: #define __AVX512F__ 1
|
||||
// CHECK_KNL_M64: #define __AVX512PF__ 1
|
||||
// CHECK_KNL_M64: #define __AVX__ 1
|
||||
// CHECK_KNL_M64: #define __BMI2__ 1
|
||||
// CHECK_KNL_M64: #define __BMI__ 1
|
||||
|
|
Loading…
Reference in New Issue