diff options
| author | Gabor Buella <gabor.buella@intel.com> | 2018-05-10 07:28:54 +0000 |
|---|---|---|
| committer | Gabor Buella <gabor.buella@intel.com> | 2018-05-10 07:28:54 +0000 |
| commit | 3a7571259eb2d86671b14d71327af383306ba3e1 (patch) | |
| tree | bc4e31ae80e8f08523bf0a49c515cc204924bf1e /clang/lib | |
| parent | a832b22baefa6c4d7e5518bd2469add47d5605d5 (diff) | |
| download | bcm5719-llvm-3a7571259eb2d86671b14d71327af383306ba3e1.tar.gz bcm5719-llvm-3a7571259eb2d86671b14d71327af383306ba3e1.zip | |
[X86] ptwrite intrinsic
Reviewers: craig.topper, RKSimon
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D46540
llvm-svn: 331962
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Basic/Targets/X86.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/Basic/Targets/X86.h | 1 | ||||
| -rw-r--r-- | clang/lib/Headers/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang/lib/Headers/cpuid.h | 3 | ||||
| -rw-r--r-- | clang/lib/Headers/module.modulemap | 1 | ||||
| -rw-r--r-- | clang/lib/Headers/ptwriteintrin.h | 51 | ||||
| -rw-r--r-- | clang/lib/Headers/x86intrin.h | 4 |
7 files changed, 68 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 95a8e114b1e..41c4179ec64 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -253,6 +253,7 @@ bool X86TargetInfo::initFeatureMap( setFeatureEnabledImpl(Features, "waitpkg", true); LLVM_FALLTHROUGH; case CK_GoldmontPlus: + setFeatureEnabledImpl(Features, "ptwrite", true); setFeatureEnabledImpl(Features, "rdpid", true); setFeatureEnabledImpl(Features, "sgx", true); LLVM_FALLTHROUGH; @@ -830,6 +831,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features, HasMOVDIR64B = true; } else if (Feature == "+pconfig") { HasPCONFIG = true; + } else if (Feature == "+ptwrite") { + HasPTWRITE = true; } X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature) @@ -1192,6 +1195,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__MOVDIR64B__"); if (HasPCONFIG) Builder.defineMacro("__PCONFIG__"); + if (HasPTWRITE) + Builder.defineMacro("__PTWRITE__"); // Each case falls through to the previous one here. switch (SSELevel) { @@ -1326,6 +1331,7 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) const { .Case("popcnt", true) .Case("prefetchwt1", true) .Case("prfchw", true) + .Case("ptwrite", true) .Case("rdpid", true) .Case("rdrnd", true) .Case("rdseed", true) @@ -1405,6 +1411,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const { .Case("popcnt", HasPOPCNT) .Case("prefetchwt1", HasPREFETCHWT1) .Case("prfchw", HasPRFCHW) + .Case("ptwrite", HasPTWRITE) .Case("rdpid", HasRDPID) .Case("rdrnd", HasRDRND) .Case("rdseed", HasRDSEED) diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index 074f8d9f80e..c995ec1f61f 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -106,6 +106,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { bool HasWAITPKG = false; bool HasMOVDIRI = false; bool HasMOVDIR64B = false; + bool HasPTWRITE = false; protected: /// Enumeration of all of the X86 CPUs supported by Clang. diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt index 16675273ccc..b34bc9b5587 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -76,6 +76,7 @@ set(files pconfigintrin.h popcntintrin.h prfchwintrin.h + ptwriteintrin.h rdseedintrin.h rtmintrin.h sgxintrin.h diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h index 8a7658dc06c..ce7dfb69898 100644 --- a/clang/lib/Headers/cpuid.h +++ b/clang/lib/Headers/cpuid.h @@ -202,6 +202,9 @@ #define bit_XSAVEC 0x00000002 #define bit_XSAVES 0x00000008 +/* Features in %eax for leaf 0x14 sub-leaf 0 */ +#define bit_PTWRITE 0x00000010 + /* Features in %ecx for leaf 0x80000001 */ #define bit_LAHF_LM 0x00000001 #define bit_ABM 0x00000020 diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap index 6ffac2f0dcd..0f10dd4c081 100644 --- a/clang/lib/Headers/module.modulemap +++ b/clang/lib/Headers/module.modulemap @@ -69,6 +69,7 @@ module _Builtin_intrinsics [system] [extern_c] { textual header "movdirintrin.h" textual header "pconfigintrin.h" textual header "sgxintrin.h" + textual header "ptwriteintrin.h" explicit module mm_malloc { requires !freestanding diff --git a/clang/lib/Headers/ptwriteintrin.h b/clang/lib/Headers/ptwriteintrin.h new file mode 100644 index 00000000000..4dacf1743f4 --- /dev/null +++ b/clang/lib/Headers/ptwriteintrin.h @@ -0,0 +1,51 @@ +/*===------------ ptwriteintrin.h - PTWRITE intrinsic --------------------=== + * + * 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 <ptwriteintrin.h> directly; include <x86intrin.h> instead." +#endif + +#ifndef __PTWRITEINTRIN_H +#define __PTWRITEINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("ptwrite"))) + +static __inline__ void __DEFAULT_FN_ATTRS +_ptwrite32(unsigned int __value) { + __builtin_ia32_ptwrite32(__value); +} + +#ifdef __x86_64__ + +static __inline__ void __DEFAULT_FN_ATTRS +_ptwrite64(unsigned long long __value) { + __builtin_ia32_ptwrite64(__value); +} + +#endif /* __x86_64__ */ + +#undef __DEFAULT_FN_ATTRS + +#endif /* __PTWRITEINTRIN_H */ diff --git a/clang/lib/Headers/x86intrin.h b/clang/lib/Headers/x86intrin.h index 82d69be287c..afece4c66d4 100644 --- a/clang/lib/Headers/x86intrin.h +++ b/clang/lib/Headers/x86intrin.h @@ -113,4 +113,8 @@ #include <sgxintrin.h> #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PTWRITE__) +#include <ptwriteintrin.h> +#endif + #endif /* __X86INTRIN_H */ |

