diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Basic/Targets.cpp | 22 | ||||
-rw-r--r-- | lib/Headers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/Headers/immintrin.h | 4 | ||||
-rw-r--r-- | lib/Headers/rtmintrin.h | 49 |
4 files changed, 73 insertions, 3 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index ed3bd0be49..26a4f41442 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -1470,6 +1470,7 @@ class X86TargetInfo : public TargetInfo { bool HasBMI; bool HasBMI2; bool HasPOPCNT; + bool HasRTM; bool HasSSE4a; bool HasFMA4; bool HasFMA; @@ -1620,9 +1621,9 @@ public: X86TargetInfo(const std::string& triple) : TargetInfo(triple), SSELevel(NoSSE), MMX3DNowLevel(NoMMX3DNow), HasAES(false), HasPCLMUL(false), HasLZCNT(false), HasRDRND(false), - HasBMI(false), HasBMI2(false), HasPOPCNT(false), HasSSE4a(false), - HasFMA4(false), HasFMA(false), HasXOP(false), HasF16C(false), - CPU(CK_Generic) { + HasBMI(false), HasBMI2(false), HasPOPCNT(false), HasRTM(false), + HasSSE4a(false), HasFMA4(false), HasFMA(false), HasXOP(false), + HasF16C(false), CPU(CK_Generic) { BigEndian = false; LongDoubleFormat = &llvm::APFloat::x87DoubleExtended; } @@ -1826,6 +1827,7 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { Features["bmi"] = false; Features["bmi2"] = false; Features["popcnt"] = false; + Features["rtm"] = false; Features["fma4"] = false; Features["fma"] = false; Features["xop"] = false; @@ -1906,6 +1908,7 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { setFeatureEnabled(Features, "rdrnd", true); setFeatureEnabled(Features, "bmi", true); setFeatureEnabled(Features, "bmi2", true); + setFeatureEnabled(Features, "rtm", true); setFeatureEnabled(Features, "fma", true); break; case CK_K6: @@ -2042,6 +2045,8 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, Features["popcnt"] = true; else if (Name == "f16c") Features["f16c"] = true; + else if (Name == "rtm") + Features["rtm"] = true; } else { if (Name == "mmx") Features["mmx"] = Features["3dnow"] = Features["3dnowa"] = false; @@ -2104,6 +2109,8 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, Features["xop"] = false; else if (Name == "f16c") Features["f16c"] = false; + else if (Name == "rtm") + Features["rtm"] = false; } return true; @@ -2155,6 +2162,11 @@ void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) { continue; } + if (Feature == "rtm") { + HasRTM = true; + continue; + } + if (Feature == "sse4a") { HasSSE4a = true; continue; @@ -2376,6 +2388,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, if (HasPOPCNT) Builder.defineMacro("__POPCNT__"); + if (HasRTM) + Builder.defineMacro("__RTM__"); + if (HasSSE4a) Builder.defineMacro("__SSE4A__"); @@ -2463,6 +2478,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const { .Case("mmx", MMX3DNowLevel >= MMX) .Case("pclmul", HasPCLMUL) .Case("popcnt", HasPOPCNT) + .Case("rtm", HasRTM) .Case("sse", SSELevel >= SSE1) .Case("sse2", SSELevel >= SSE2) .Case("sse3", SSELevel >= SSE3) diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt index ca83793767..25e4d903bb 100644 --- a/lib/Headers/CMakeLists.txt +++ b/lib/Headers/CMakeLists.txt @@ -20,6 +20,7 @@ set(files nmmintrin.h pmmintrin.h popcntintrin.h + rtmintrin.h smmintrin.h stdalign.h stdarg.h diff --git a/lib/Headers/immintrin.h b/lib/Headers/immintrin.h index 15b65f3fd8..cd733bfc71 100644 --- a/lib/Headers/immintrin.h +++ b/lib/Headers/immintrin.h @@ -98,4 +98,8 @@ _rdrand64_step(unsigned long long *__p) #endif #endif /* __RDRND__ */ +#ifdef __RTM__ +#include <rtmintrin.h> +#endif + #endif /* __IMMINTRIN_H */ diff --git a/lib/Headers/rtmintrin.h b/lib/Headers/rtmintrin.h new file mode 100644 index 0000000000..bdc2b99426 --- /dev/null +++ b/lib/Headers/rtmintrin.h @@ -0,0 +1,49 @@ +/*===---- rtmintrin.h - RTM intrinsics -------------------------------------=== + * + * 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 __IMMINTRIN_H +#error "Never use <rtmintrin.h> directly; include <immintrin.h> instead." +#endif + +#define _XBEGIN_STARTED (~0u) +#define _XABORT_EXPLICIT (1 << 0) +#define _XABORT_RETRY (1 << 1) +#define _XABORT_CONFLICT (1 << 2) +#define _XABORT_CAPACITY (1 << 3) +#define _XABORT_DEBUG (1 << 4) +#define _XABORT_NESTED (1 << 5) +#define _XABORT_CODE(x) (((x) >> 24) & 0xFF) + +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) +_xbegin(void) +{ + return __builtin_ia32_xbegin(); +} + +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +_xend(void) +{ + __builtin_ia32_xend(); +} + +#define _xabort(imm) __builtin_ia32_xabort((imm)) |