diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Basic/Targets/X86.cpp | 13 | ||||
-rw-r--r-- | lib/Basic/Targets/X86.h | 1 | ||||
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 8 | ||||
-rw-r--r-- | lib/Headers/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/Headers/cpuid.h | 3 | ||||
-rw-r--r-- | lib/Headers/immintrin.h | 9 |
6 files changed, 36 insertions, 0 deletions
diff --git a/lib/Basic/Targets/X86.cpp b/lib/Basic/Targets/X86.cpp index 2345d7ffcc..b83c9382fc 100644 --- a/lib/Basic/Targets/X86.cpp +++ b/lib/Basic/Targets/X86.cpp @@ -521,6 +521,7 @@ void X86TargetInfo::setSSELevel(llvm::StringMap<bool> &Features, Features["avx512ifma"] = Features["avx512vpopcntdq"] = Features["avx512bitalg"] = Features["avx512vnni"] = Features["avx512vbmi2"] = false; + Features["avx512bf16"] = false; break; } } @@ -652,16 +653,22 @@ void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap<bool> &Features, Name == "avx512dq" || Name == "avx512bw" || Name == "avx512vl" || Name == "avx512vbmi" || Name == "avx512ifma" || Name == "avx512vpopcntdq" || Name == "avx512bitalg" || + Name == "avx512bf16" || Name == "avx512vnni" || Name == "avx512vbmi2") { if (Enabled) setSSELevel(Features, AVX512F, Enabled); // Enable BWI instruction if VBMI/VBMI2/BITALG is being enabled. if ((Name.startswith("avx512vbmi") || Name == "avx512bitalg") && Enabled) Features["avx512bw"] = true; + if (Name == "avx512bf16" && Enabled) + Features["avx512bw"] = Features["avx512vl"] = true; // Also disable VBMI/VBMI2/BITALG if BWI is being disabled. if (Name == "avx512bw" && !Enabled) Features["avx512vbmi"] = Features["avx512vbmi2"] = + Features["avx512bf16"] = Features["avx512bitalg"] = false; + if (Name == "avx512vl" && !Enabled) + Features["avx512bf16"] = false; } else if (Name == "fma") { if (Enabled) setSSELevel(Features, AVX, Enabled); @@ -751,6 +758,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features, HasAVX512VPOPCNTDQ = true; } else if (Feature == "+avx512vnni") { HasAVX512VNNI = true; + } else if (Feature == "+avx512bf16") { + HasAVX512BF16 = true; } else if (Feature == "+avx512er") { HasAVX512ER = true; } else if (Feature == "+avx512pf") { @@ -1141,6 +1150,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__AVX512VPOPCNTDQ__"); if (HasAVX512VNNI) Builder.defineMacro("__AVX512VNNI__"); + if (HasAVX512BF16) + Builder.defineMacro("__AVX512BF16__"); if (HasAVX512ER) Builder.defineMacro("__AVX512ER__"); if (HasAVX512PF) @@ -1305,6 +1316,7 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) const { .Case("avx512cd", true) .Case("avx512vpopcntdq", true) .Case("avx512vnni", true) + .Case("avx512bf16", true) .Case("avx512er", true) .Case("avx512pf", true) .Case("avx512dq", true) @@ -1383,6 +1395,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const { .Case("avx512cd", HasAVX512CD) .Case("avx512vpopcntdq", HasAVX512VPOPCNTDQ) .Case("avx512vnni", HasAVX512VNNI) + .Case("avx512bf16", HasAVX512BF16) .Case("avx512er", HasAVX512ER) .Case("avx512pf", HasAVX512PF) .Case("avx512dq", HasAVX512DQ) diff --git a/lib/Basic/Targets/X86.h b/lib/Basic/Targets/X86.h index 9f285d8d50..d7a87f8d7c 100644 --- a/lib/Basic/Targets/X86.h +++ b/lib/Basic/Targets/X86.h @@ -68,6 +68,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { bool HasAVX512CD = false; bool HasAVX512VPOPCNTDQ = false; bool HasAVX512VNNI = false; + bool HasAVX512BF16 = false; bool HasAVX512ER = false; bool HasAVX512PF = false; bool HasAVX512DQ = false; diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 5abb62c560..14b8d0b18d 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -11851,6 +11851,14 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, case X86::BI__builtin_ia32_cmpordsd: return getCmpIntrinsicCall(Intrinsic::x86_sse2_cmp_sd, 7); +// AVX512 bf16 intrinsics + case X86::BI__builtin_ia32_cvtneps2bf16_128_mask: { + Ops[2] = getMaskVecValue(*this, Ops[2], + Ops[0]->getType()->getVectorNumElements()); + Intrinsic::ID IID = Intrinsic::x86_avx512bf16_mask_cvtneps2bf16_128; + return Builder.CreateCall(CGM.getIntrinsic(IID), Ops); + } + case X86::BI__emul: case X86::BI__emulu: { llvm::Type *Int64Ty = llvm::IntegerType::get(getLLVMContext(), 64); diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt index a921d99399..bfcade4584 100644 --- a/lib/Headers/CMakeLists.txt +++ b/lib/Headers/CMakeLists.txt @@ -6,6 +6,7 @@ set(files armintr.h arm64intr.h avx2intrin.h + avx512bf16intrin.h avx512bwintrin.h avx512bitalgintrin.h avx512vlbitalgintrin.h @@ -21,6 +22,7 @@ set(files avx512vbmivlintrin.h avx512vbmi2intrin.h avx512vlvbmi2intrin.h + avx512vlbf16intrin.h avx512vlbwintrin.h avx512vlcdintrin.h avx512vldqintrin.h diff --git a/lib/Headers/cpuid.h b/lib/Headers/cpuid.h index 137b9bc7fb..ffe638adf3 100644 --- a/lib/Headers/cpuid.h +++ b/lib/Headers/cpuid.h @@ -184,6 +184,9 @@ #define bit_PCONFIG 0x00040000 #define bit_IBT 0x00100000 +/* Features in %eax for leaf 7 sub-leaf 1 */ +#define bit_AVX512BF16 0x00000020 + /* Features in %eax for leaf 13 sub-leaf 1 */ #define bit_XSAVEOPT 0x00000001 #define bit_XSAVEC 0x00000002 diff --git a/lib/Headers/immintrin.h b/lib/Headers/immintrin.h index 1fda86ed26..2bd79bd88f 100644 --- a/lib/Headers/immintrin.h +++ b/lib/Headers/immintrin.h @@ -181,6 +181,15 @@ #include <avx512pfintrin.h> #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BF16__) +#include <avx512bf16intrin.h> +#endif + +#if !defined(_MSC_VER) || __has_feature(modules) || \ + (defined(__AVX512VL__) && defined(__AVX512BF16__)) +#include <avx512vlbf16intrin.h> +#endif + #if !defined(_MSC_VER) || __has_feature(modules) || defined(__PKU__) #include <pkuintrin.h> #endif |