Eric Christopher <echri...@gmail.com> writes:
> Author: echristo
> Date: Wed Jun 17 02:09:32 2015
> New Revision: 239883
>
> URL: http://llvm.org/viewvc/llvm-project?rev=239883&view=rev
> Log:
> Update the intel intrinsic headers to use the target attribute support.
>
> This involved removing the conditional inclusion and replacing them
> with target attributes matching the original conditional inclusion
> and checks. The testcase update removes the macro checks for each
> file and replaces them with usage of the __target__ attribute, e.g.:
>
> int __attribute__((__target__(("sse3")))) foo(int a) {
>   _mm_mwait(0, 0);
>   return 4;
> }
>
> This usage does require the enclosing function have the requisite
> __target__ attribute for inlining and code generation - also for
> any macro intrinsic uses in the enclosing function. There's no change
> for existing uses of the intrinsic headers.
>
...
> Added: cfe/trunk/test/Headers/pmmintrin.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/pmmintrin.c?rev=239883&view=auto
> ==============================================================================
> --- cfe/trunk/test/Headers/pmmintrin.c (added)
> +++ cfe/trunk/test/Headers/pmmintrin.c Wed Jun 17 02:09:32 2015
> @@ -0,0 +1,12 @@
> +// RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify
> +// RUN: %clang_cc1 -fsyntax-only -ffreestanding -x c++ %s -verify
> +// expected-no-diagnostics
> +
> +#if defined(i386) || defined(__x86_64__)
> +#include <pmmintrin.h>
> +
> +int __attribute__((__target__(("sse3")))) foo(int a) {
> +  _mm_mwait(0, 0);
> +  return 4;
> +}
> +#endif
>
> Added: cfe/trunk/test/Headers/x86intrin-2.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/x86intrin-2.c?rev=239883&view=auto
> ==============================================================================
> --- cfe/trunk/test/Headers/x86intrin-2.c (added)
> +++ cfe/trunk/test/Headers/x86intrin-2.c Wed Jun 17 02:09:32 2015
> @@ -0,0 +1,131 @@
> +// 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__)
> +
> +// Include the metaheader that includes all x86 intrinsic headers.
> +#include <x86intrin.h>
> +
> +void __attribute__((__target__("mmx"))) mm_empty_wrap(void) {
> +  _mm_empty();
> +}
> +
> +__m128 __attribute__((__target__("sse"))) mm_add_ss_wrap(__m128 a, __m128 b) 
> {
> +  return _mm_add_ss(a, b);
> +}
> +
> +__m128d __attribute__((__target__("sse2"))) mm_sqrt_sd_wrap(__m128d a, 
> __m128d b) {
> +  return _mm_sqrt_sd(a, b);
> +}
> +
> +void __attribute__((__target__("sse3"))) mm_mwait_wrap(int a) {
> +  _mm_mwait(0, 0);
> +}
> +
> +__m64 __attribute__((__target__("ssse3"))) mm_abs_pi8_wrap(__m64 a) {
> +  return _mm_abs_pi8(a);
> +}
> +
> +__m128i __attribute__((__target__("sse4.1"))) mm_minpos_epu16_wrap(__m128i 
> v) {
> +  return _mm_minpos_epu16(v);
> +}
> +
> +unsigned int __attribute__((__target__("sse4.2"))) mm_crc32_u8_wrap(unsigned 
> int c, unsigned char d) {
> +  return _mm_crc32_u8(c, d);
> +}
> +
> +__m128i __attribute__((__target__("aes"))) mm_aesenc_si128_wrap(__m128i v, 
> __m128i r) {
> +  return _mm_aesenc_si128(v, r);
> +}
> +
> +__m256d __attribute__((__target__("avx"))) mm256_add_pd_wrap(__m256d a, 
> __m256d b) {
> +  return _mm256_add_pd(a, b);
> +}
> +
> +__m256i __attribute__((__target__("avx2"))) mm256_abs_epi8_wrap(__m256i a) {
> +  return _mm256_abs_epi8(a);
> +}
> +
> +unsigned short __attribute__((__target__("bmi"))) tzcnt_u16_wrap(unsigned 
> short x) {
> +  return __tzcnt_u16(x);
> +}
> +
> +unsigned int __attribute__((__target__("bmi2"))) bzhi_u32_wrap(unsigned int 
> x, unsigned int y) {
> +  return _bzhi_u32(x, y);
> +}
> +
> +unsigned short __attribute__((__target__("lzcnt"))) lzcnt16_wrap(unsigned 
> short x) {
> +  return __lzcnt16(x);
> +}
> +
> +__m256d __attribute__((__target__("fma"))) mm256_fmsubadd_pd_wrap(__m256d a, 
> __m256d b, __m256d c) {
> +  return _mm256_fmsubadd_pd(a, b, c);
> +}
> +
> +__m512i __attribute__((__target__("avx512f"))) 
> mm512_setzero_si512_wrap(void) {
> +  return _mm512_setzero_si512();
> +}
> +
> +__mmask8 __attribute__((__target__("avx512vl"))) 
> mm_cmpeq_epi32_mask_wrap(__m128i a, __m128i b) {
> +  return _mm_cmpeq_epi32_mask(a, b);
> +}
> +
> +__v64qi __attribute__((__target__("avx512bw"))) mm512_setzero_qi_wrap(void) {
> +  return _mm512_setzero_qi();
> +}
> +
> +__m512i __attribute__((__target__("avx512dq"))) 
> mm512_mullo_epi64_wrap(__m512i a, __m512i b) {
> +  return _mm512_mullo_epi64(a, b);
> +}
> +
> +__mmask16 __attribute__((__target__("avx512vl,avx512bw"))) 
> mm_cmpeq_epi8_mask_wrap(__m128i a, __m128i b) {
> +  return _mm_cmpeq_epi8_mask(a, b);
> +}
> +
> +__m256i __attribute__((__target__("avx512vl,avx512dq"))) 
> mm256_mullo_epi64_wrap(__m256i a, __m256i b) {
> +  return _mm256_mullo_epi64(a, b);
> +}
> +
> +int __attribute__((__target__("rdrnd"))) rdrand16_step_wrap(unsigned short 
> *p) {
> +  return _rdrand16_step(p);
> +}
> +
> +unsigned int __attribute__((__target__("fsgsbase"))) 
> readfsbase_u32_wrap(void) {
> +  return _readfsbase_u32();
> +}
> +
> +unsigned int __attribute__((__target__("rtm"))) xbegin_wrap(void) {
> +  return _xbegin();
> +}
> +
> +__m128i __attribute__((__target__("sha"))) mm_sha1nexte_epu32_wrap(__m128i 
> x, __m128i y) {
> +  return _mm_sha1nexte_epu32(x, y);
> +}
> +
> +int __attribute__((__target__("rdseed"))) rdseed16_step_wrap(unsigned short 
> *p) {
> +  return _rdseed16_step(p);
> +}
> +
> +__m128i __attribute__((__target__("sse4a"))) mm_extract_si64_wrap(__m128i x, 
> __m128i y) {
> +  return _mm_extract_si64(x, y);
> +}
> +
> +__m128 __attribute__((__target__("fma4"))) mm_macc_ps_wrap(__m128 a, __m128 
> b, __m128 c) {
> +  return _mm_macc_ps(a, b, c);
> +}
> +
> +__m256 __attribute__((__target__("xop"))) mm256_frcz_ps_wrap(__m256 a) {
> +  return _mm256_frcz_ps(a);
> +}
> +
> +unsigned int __attribute__((__target__("tbm"))) blcfill_u32_wrap(unsigned 
> int a) {
> +  return __blcfill_u32(a);
> +}
> +
> +__m128 __attribute__((__target__("f16c"))) mm_cvtph_ps_wrap(__m128i a) {
> +  return _mm_cvtph_ps(a);
> +}
> +
> +#endif

Where are the negative test cases? Diagnosing uses of these functions
when they aren't valid is really important - it's a pretty serious
regression if we don't.
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to