diff options
author | Eric Christopher <echristo@apple.com> | 2010-03-20 07:43:28 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-03-20 07:43:28 +0000 |
commit | 67a5936a1d60fff1ec12441de63fd27ea50b0130 (patch) | |
tree | 128f075c61b3c86381887f0236890ac47c93feab | |
parent | cb61a7bbe635cfa941b1aeaaa1fbda1bf900ee51 (diff) |
Add sse4.2 header and builtin support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99051 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/BuiltinsX86.def | 24 | ||||
-rw-r--r-- | lib/Headers/nmmintrin.h | 35 | ||||
-rw-r--r-- | lib/Headers/smmintrin.h | 112 |
3 files changed, 171 insertions, 0 deletions
diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def index 9a79f90d1e..00b076aa10 100644 --- a/include/clang/Basic/BuiltinsX86.def +++ b/include/clang/Basic/BuiltinsX86.def @@ -293,4 +293,28 @@ BUILTIN(__builtin_ia32_ptestnzc128, "iV2LLiV2LLi", "") BUILTIN(__builtin_ia32_pcmpeqq, "V2LLiV2LLiV2LLi", "") BUILTIN(__builtin_ia32_mpsadbw128, "V16cV16cV16ci", "") +// SSE 4.2 +BUILTIN(__builtin_ia32_pcmpistrm128, "V16cV16cV16cc", "") +BUILTIN(__builtin_ia32_pcmpistri128, "iV16cV16cc", "") +BUILTIN(__builtin_ia32_pcmpestrm128, "V16cV16ciV16cic", "") +BUILTIN(__builtin_ia32_pcmpestri128, "iV16ciV16cic","") + +BUILTIN(__builtin_ia32_pcmpistria128, "iV16ciV16cic","") +BUILTIN(__builtin_ia32_pcmpistric128, "iV16ciV16cic","") +BUILTIN(__builtin_ia32_pcmpistrio128, "iV16ciV16cic","") +BUILTIN(__builtin_ia32_pcmpistris128, "iV16ciV16cic","") +BUILTIN(__builtin_ia32_pcmpistriz128, "iV16ciV16cic","") + +BUILTIN(__builtin_ia32_pcmpestria128, "iV16ciV16cic","") +BUILTIN(__builtin_ia32_pcmpestric128, "iV16ciV16cic","") +BUILTIN(__builtin_ia32_pcmpestrio128, "iV16ciV16cic","") +BUILTIN(__builtin_ia32_pcmpestris128, "iV16ciV16cic","") +BUILTIN(__builtin_ia32_pcmpestriz128, "iV16ciV16cic","") + +BUILTIN(__builtin_ia32_pcmpgtq, "V2LLiV2LLiV2LLi", "") + +BUILTIN(__builtin_ia32_crc32qi, "iic", "") +BUILTIN(__builtin_ia32_crc32hi, "iis", "") +BUILTIN(__builtin_ia32_crc32si, "iii", "") +BUILTIN(__builtin_ia32_crc32di, "LLiLLiLLi", "") #undef BUILTIN diff --git a/lib/Headers/nmmintrin.h b/lib/Headers/nmmintrin.h new file mode 100644 index 0000000000..f24352b246 --- /dev/null +++ b/lib/Headers/nmmintrin.h @@ -0,0 +1,35 @@ +/*===---- nmmintrin.h - SSE 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 _NMMINTRIN_H +#define _NMMINTRIN_H + +#ifndef __SSE4_2__ +#error "SSE4.2 instruction set not enabled" +#else + +/* To match expectations of gcc we put the sse4.2 definitions into smmintrin.h, + just include it now then. */ +#include <smmintrin.h> +#endif /* __SSE4_2__ */ +#endif /* _NMMINTRIN_H */
\ No newline at end of file diff --git a/lib/Headers/smmintrin.h b/lib/Headers/smmintrin.h index 972b2e0d30..9c8d53d0e4 100644 --- a/lib/Headers/smmintrin.h +++ b/lib/Headers/smmintrin.h @@ -337,6 +337,118 @@ _mm_packus_epi32(__m128i __V1, __m128i __V2) /* SSE4 Multiple Packed Sums of Absolute Difference. */ #define _mm_mpsadbw_epu8(X, Y, M) __builtin_ia32_mpsadbw128((X), (Y), (M)) +/* These definitions are normally in nmmintrin.h, but gcc puts them in here + so we'll do the same. */ +#ifdef __SSE4_2__ + +/* These specify the type of data that we're comparing. */ +#define _SIDD_UBYTE_OPS 0x00 +#define _SIDD_UWORD_OPS 0x01 +#define _SIDD_SBYTE_OPS 0x02 +#define _SIDD_SWORD_OPS 0x03 + +/* These specify the type of comparison operation. */ +#define _SIDD_CMP_EQUAL_ANY 0x00 +#define _SIDD_CMP_RANGES 0x04 +#define _SIDD_CMP_EQUAL_EACH 0x08 +#define _SIDD_CMP_EQUAL_ORDERED 0x0c + +/* These macros specify the polarity of the operation. */ +#define _SIDD_POSITIVE_POLARITY 0x00 +#define _SIDD_NEGATIVE_POLARITY 0x10 +#define _SIDD_MASKED_POSITIVE_POLARITY 0x20 +#define _SIDD_MASKED_NEGATIVE_POLARITY 0x30 + +/* These macros are used in _mm_cmpXstri() to specify the return. */ +#define _SIDD_LEAST_SIGNIFICANT 0x00 +#define _SIDD_MOST_SIGNIFICANT 0x40 + +/* These macros are used in _mm_cmpXstri() to specify the return. */ +#define _SIDD_BIT_MASK 0x00 +#define _SIDD_UNIT_MASK 0x40 + +/* SSE4.2 Packed Comparison Intrinsics. */ +#define _mm_cmpistrm(A, B, M) __builtin_ia32_pcmpistrm128((A), (B), (M)) +#define _mm_cmpistri(A, B, M) __builtin_ia32_pcmpistri128((A), (B), (M)) + +#define _mm_cmpestrm(A, LA, B, LB, M) \ + __builtin_ia32_pcmpestrm128((A), (LA), (B), (LB), (M)) +#define _mm_cmpestri(X, LX, Y, LY, M) \ + __builtin_ia32_pcmpestri128((A), (LA), (B), (LB), (M)) + +/* SSE4.2 Packed Comparison Intrinsics and EFlag Reading. */ +#define _mm_cmpistra(A, LA, B, LB, M) \ + __builtin_ia32_pcmpistria128((A), (LA), (B), (LB), (M)) +#define _mm_cmpistrc(A, LA, B, LB, M) \ + __builtin_ia32_pcmpistric128((A), (LA), (B), (LB), (M)) +#define _mm_cmpistro(A, LA, B, LB, M) \ + __builtin_ia32_pcmpistrio128((A), (LA), (B), (LB), (M)) +#define _mm_cmpistrs(A, LA, B, LB, M) \ + __builtin_ia32_pcmpistris128((A), (LA), (B), (LB), (M)) +#define _mm_cmpistrz(A, LA, B, LB, M) \ + __builtin_ia32_pcmpistriz128((A), (LA), (B), (LB), (M)) + +#define _mm_cmpestra(A, LA, B, LB, M) \ + __builtin_ia32_pcmpestria128((A), (LA), (B), (LB), (M)) +#define _mm_cmpestrc(A, LA, B, LB, M) \ + __builtin_ia32_pcmpestric128((A), (LA), (B), (LB), (M)) +#define _mm_cmpestro(A, LA, B, LB, M) \ + __builtin_ia32_pcmpestrio128((A), (LA), (B), (LB), (M)) +#define _mm_cmpestrs(A, LA, B, LB, M) \ + __builtin_ia32_pcmpestris128((A), (LA), (B), (LB), (M)) +#define _mm_cmpestrz(A, LA, B, LB, M) \ + __builtin_ia32_pcmpestriz128((A), (LA), (B), (LB), (M)) + +/* SSE4.2 Compare Packed Data -- Greater Than. */ +static inline __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_cmpgt_epi64(__m128i __V1, __m128i __V2) +{ + return __builtin_ia32_pcmpgtq((__v2di)__V1, (__v2di)__V2); +} + +/* SSE4.2 Accumulate CRC32. */ +static inline unsigned int __attribute__((__always_inline__, __nodebug__)) +_mm_crc32_u8(unsigned int __C, unsigned char __D) +{ + return __builtin_ia32_crc32qi(__C, __D); +} + +static inline unsigned int __attribute__((__always_inline__, __nodebug__)) +_mm_crc32_u16(unsigned int __C, unsigned short __D) +{ + return __builtin_ia32_crc32hi(__C, __D); +} + +static inline unsigned int __attribute__((__always_inline__, __nodebug__)) +_mm_crc32_u32(unsigned int __C, unsigned int __D) +{ + return __builtin_ia32_crc32si(__C, __D); +} + +#ifdef __x86_64__ +static inline unsigned long long __attribute__((__always_inline__, __nodebug__)) +_mm_crc32_u64(unsigned long long __C, unsigned long long __D) +{ + return __builtin_ia32_crc32di(__C, __D); +} +#endif /* __x86_64__ */ + +/* SSE4.2 Population Count. */ +static inline int __attribute__((__always_inline__, __nodebug__)) +_mm_popcnt_u32(unsigned int __A) +{ + return __builtin_popcount(__A); +} + +#ifdef __x86_64__ +static inline long long __attribute__((__always_inline__, __nodebug__)) +_mm_popcnt_u64(unsigned long long __A) +{ + return __builtin_popcountll(__A); +} +#endif /* __x86_64__ */ + +#endif /* __SSE4_2__ */ #endif /* __SSE4_1__ */ #endif /* _SMMINTRIN_H */ |