r188867 - Add avx512cd, avx512er, avx512pf feature flags and enable them on KNL CPU.
Craig Topper
craig.topper at gmail.com
Tue Aug 20 22:29:10 PDT 2013
Author: ctopper
Date: Wed Aug 21 00:29:10 2013
New Revision: 188867
URL: http://llvm.org/viewvc/llvm-project?rev=188867&view=rev
Log:
Add avx512cd, avx512er, avx512pf feature flags and enable them on KNL CPU.
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=188867&r1=188866&r2=188867&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Aug 21 00:29:10 2013
@@ -969,6 +969,9 @@ def mno_aes : Flag<["-"], "mno-aes">, Gr
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_
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>;
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=188867&r1=188866&r2=188867&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Aug 21 00:29:10 2013
@@ -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(l
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::St
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(ll
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
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(con
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
.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)
Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=188867&r1=188866&r2=188867&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Wed Aug 21 00:29:10 2013
@@ -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
More information about the cfe-commits
mailing list