From ee3cd95d31406c8c5d80a2c29fdd803bd5993697 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 9 May 2013 15:07:46 +0000 Subject: [PATCH] xopintrin.h: Add wrappers for all flavors of _mm_com. GCC defines only the wrappers, MSVC defines both, we define both now too. PR15844. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181514 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Headers/xopintrin.h | 393 +++++++++++++++++++++++++++++++++++++++ test/Headers/x86intrin.c | 91 +++++++++ 2 files changed, 484 insertions(+) create mode 100644 test/Headers/x86intrin.c diff --git a/lib/Headers/xopintrin.h b/lib/Headers/xopintrin.h index 9a5824c971..cc94ca0264 100644 --- a/lib/Headers/xopintrin.h +++ b/lib/Headers/xopintrin.h @@ -342,6 +342,399 @@ _mm_sha_epi64(__m128i __A, __m128i __B) __m128i __B = (B); \ (__m128i)__builtin_ia32_vpcomq((__v2di)__A, (__v2di)__B, (N)); }) +#define _MM_PCOMCTRL_LT 0 +#define _MM_PCOMCTRL_LE 1 +#define _MM_PCOMCTRL_GT 2 +#define _MM_PCOMCTRL_GE 3 +#define _MM_PCOMCTRL_EQ 4 +#define _MM_PCOMCTRL_NEQ 5 +#define _MM_PCOMCTRL_FALSE 6 +#define _MM_PCOMCTRL_TRUE 7 + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comlt_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comle_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comgt_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comge_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comeq_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comneq_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comfalse_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_comtrue_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_TRUE); +} + #define _mm_permute2_pd(X, Y, C, I) __extension__ ({ \ __m128d __X = (X); \ __m128d __Y = (Y); \ diff --git a/test/Headers/x86intrin.c b/test/Headers/x86intrin.c new file mode 100644 index 0000000000..d095c00674 --- /dev/null +++ b/test/Headers/x86intrin.c @@ -0,0 +1,91 @@ +// RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify +// RUN: %clang_cc1 -fsyntax-only -ffreestanding -fno-lax-vector-conversions %s -verify +// RUN: %clang_cc1 -fsyntax-only -ffreestanding -x c++ %s -verify +// expected-no-diagnostics + +#if defined(i386) || defined(__x86_64__) + +// Pretend to enable all features. +#ifndef __3dNOW__ +#define __3dNOW__ +#endif +#ifndef __BMI__ +#define __BMI__ +#endif +#ifndef __BMI2__ +#define __BMI2__ +#endif +#ifndef __LZCNT__ +#define __LZCNT__ +#endif +#ifndef __POPCNT__ +#define __POPCNT__ +#endif +#ifndef __RDSEED__ +#define __RDSEED__ +#endif +#ifndef __PRFCHW__ +#define __PRFCHW__ +#endif +#ifndef __SSE4A__ +#define __SSE4A__ +#endif +#ifndef __FMA4__ +#define __FMA4__ +#endif +#ifndef __XOP__ +#define __XOP__ +#endif +#ifndef __F16C__ +#define __F16C__ +#endif +#ifndef __MMX__ +#define __MMX__ +#endif +#ifndef __SSE__ +#define __SSE__ +#endif +#ifndef __SSE2__ +#define __SSE2__ +#endif +#ifndef __SSE3__ +#define __SSE3__ +#endif +#ifndef __SSSE3__ +#define __SSSE3__ +#endif +#ifndef __SSE4_1__ +#define __SSE4_1__ +#endif +#ifndef __SSE4_2__ +#define __SSE4_2__ +#endif +#ifndef __AES__ +#define __AES__ +#endif +#ifndef __AVX__ +#define __AVX__ +#endif +#ifndef __AVX2__ +#define __AVX2__ +#endif +#ifndef __BMI__ +#define __BMI__ +#endif +#ifndef __BMI2__ +#define __BMI2__ +#endif +#ifndef __LZCNT__ +#define __LZCNT__ +#endif +#ifndef __FMA__ +#define __FMA__ +#endif +#ifndef __RDRND__ +#define __RDRND__ +#endif + +// Now include the metaheader that includes all x86 intrinsic headers. +#include + +#endif -- 2.40.0