diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Basic/Targets.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/Headers/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang/lib/Headers/clzerointrin.h | 50 | ||||
| -rw-r--r-- | clang/lib/Headers/module.modulemap | 1 | ||||
| -rw-r--r-- | clang/lib/Headers/x86intrin.h | 4 |
5 files changed, 63 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index bbc3d16493d..a288a35137b 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -2489,6 +2489,7 @@ class X86TargetInfo : public TargetInfo { bool HasXSAVEC = false; bool HasXSAVES = false; bool HasMWAITX = false; + bool HasCLZERO = false; bool HasPKU = false; bool HasCLFLUSHOPT = false; bool HasCLWB = false; @@ -3201,6 +3202,7 @@ bool X86TargetInfo::initFeatureMap( setFeatureEnabledImpl(Features, "bmi", true); setFeatureEnabledImpl(Features, "bmi2", true); setFeatureEnabledImpl(Features, "clflushopt", true); + setFeatureEnabledImpl(Features, "clzero", true); setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "f16c", true); setFeatureEnabledImpl(Features, "fma", true); @@ -3560,6 +3562,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features, HasCLWB = true; } else if (Feature == "+prefetchwt1") { HasPREFETCHWT1 = true; + } else if (Feature == "+clzero") { + HasCLZERO = true; } X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature) @@ -3887,6 +3891,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__SGX__"); if (HasPREFETCHWT1) Builder.defineMacro("__PREFETCHWT1__"); + if (HasCLZERO) + Builder.defineMacro("__CLZERO__"); // Each case falls through to the previous one here. switch (SSELevel) { @@ -3973,6 +3979,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const { .Case("bmi2", HasBMI2) .Case("clflushopt", HasCLFLUSHOPT) .Case("clwb", HasCLWB) + .Case("clzero", HasCLZERO) .Case("cx16", HasCX16) .Case("f16c", HasF16C) .Case("fma", HasFMA) diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt index efc4dd0971b..35aff4017e9 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -28,6 +28,7 @@ set(files __clang_cuda_intrinsics.h __clang_cuda_math_forward_declares.h __clang_cuda_runtime_wrapper.h + clzerointrin.h cpuid.h clflushoptintrin.h emmintrin.h diff --git a/clang/lib/Headers/clzerointrin.h b/clang/lib/Headers/clzerointrin.h new file mode 100644 index 00000000000..ed7478ff87e --- /dev/null +++ b/clang/lib/Headers/clzerointrin.h @@ -0,0 +1,50 @@ +/*===----------------------- clzerointrin.h - CLZERO ----------------------=== + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __X86INTRIN_H +#error "Never use <clzerointrin.h> directly; include <x86intrin.h> instead." +#endif + +#ifndef _CLZEROINTRIN_H +#define _CLZEROINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("clzero"))) + +/// \brief Loads the cache line address and zero's out the cacheline +/// +/// \headerfile <clzerointrin.h> +/// +/// This intrinsic corresponds to the <c> CLZERO </c> instruction. +/// +/// \param __line +/// A pointer to a cacheline which needs to be zeroed out. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_clzero (void * __line) +{ + __builtin_ia32_clzero ((void *)__line); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* _CLZEROINTRIN_H */ diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap index 11ef2f90294..95d26cefa6f 100644 --- a/clang/lib/Headers/module.modulemap +++ b/clang/lib/Headers/module.modulemap @@ -61,6 +61,7 @@ module _Builtin_intrinsics [system] [extern_c] { textual header "xopintrin.h" textual header "fma4intrin.h" textual header "mwaitxintrin.h" + textual header "clzerointrin.h" explicit module mm_malloc { requires !freestanding diff --git a/clang/lib/Headers/x86intrin.h b/clang/lib/Headers/x86intrin.h index 81a404f55d0..2003029cb5a 100644 --- a/clang/lib/Headers/x86intrin.h +++ b/clang/lib/Headers/x86intrin.h @@ -80,6 +80,10 @@ #include <mwaitxintrin.h> #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLZERO__) +#include <clzerointrin.h> +#endif + /* FIXME: LWP */ #endif /* __X86INTRIN_H */ |

