Skip to content

Commit

Permalink
Update the intel intrinsic headers to use the target attribute support.
Browse files Browse the repository at this point in the history
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.

llvm-svn: 239883
  • Loading branch information
echristo committed Jun 17, 2015
1 parent 4d18516 commit 9fc7fb2
Show file tree
Hide file tree
Showing 38 changed files with 192 additions and 356 deletions.
8 changes: 1 addition & 7 deletions clang/lib/Headers/__wmmintrin_aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@

#include <emmintrin.h>

#if !defined (__AES__)
# error "AES instructions not enabled"
#else

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes")))

static __inline__ __m128i DEFAULT_FN_ATTRS
_mm_aesenc_si128(__m128i __V, __m128i __R)
Expand Down Expand Up @@ -67,6 +63,4 @@ _mm_aesimc_si128(__m128i __V)

#undef DEFAULT_FN_ATTRS

#endif

#endif /* _WMMINTRIN_AES_H */
4 changes: 0 additions & 4 deletions clang/lib/Headers/__wmmintrin_pclmul.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@
#ifndef _WMMINTRIN_PCLMUL_H
#define _WMMINTRIN_PCLMUL_H

#if !defined (__PCLMUL__)
# error "PCLMUL instruction is not enabled"
#else
#define _mm_clmulepi64_si128(__X, __Y, __I) \
((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(__X), \
(__v2di)(__m128i)(__Y), (char)(__I)))
#endif

#endif /* _WMMINTRIN_PCLMUL_H */
6 changes: 2 additions & 4 deletions clang/lib/Headers/adxintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,21 @@
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))

/* Intrinsics that are available only if __ADX__ defined */
#ifdef __ADX__
static __inline unsigned char DEFAULT_FN_ATTRS
static __inline unsigned char __attribute__((__always_inline__, __nodebug__, __target__("adx")))
_addcarryx_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
unsigned int *__p)
{
return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);
}

#ifdef __x86_64__
static __inline unsigned char DEFAULT_FN_ATTRS
static __inline unsigned char __attribute__((__always_inline__, __nodebug__, __target__("adx")))
_addcarryx_u64(unsigned char __cf, unsigned long long __x,
unsigned long long __y, unsigned long long *__p)
{
return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p);
}
#endif
#endif

/* Intrinsics that are also available if __ADX__ undefined */
static __inline unsigned char DEFAULT_FN_ATTRS
Expand Down
8 changes: 1 addition & 7 deletions clang/lib/Headers/ammintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@
#ifndef __AMMINTRIN_H
#define __AMMINTRIN_H

#ifndef __SSE4A__
#error "SSE4A instruction set not enabled"
#else

#include <pmmintrin.h>

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4a")))

/// \brief Extracts the specified bits from the lower 64 bits of the 128-bit
/// integer vector operand at the index idx and of the length len.
Expand Down Expand Up @@ -210,6 +206,4 @@ _mm_stream_ss(float *__p, __m128 __a)

#undef DEFAULT_FN_ATTRS

#endif /* __SSE4A__ */

#endif /* __AMMINTRIN_H */
2 changes: 1 addition & 1 deletion clang/lib/Headers/avx2intrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define __AVX2INTRIN_H

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx2")))

/* SSE4 Multiple Packed Sums of Absolute Difference. */
#define _mm256_mpsadbw_epu8(X, Y, M) __builtin_ia32_mpsadbw256((X), (Y), (M))
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/avx512bwintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef char __v64qi __attribute__ ((__vector_size__ (64)));
typedef short __v32hi __attribute__ ((__vector_size__ (64)));

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512bw")))

static __inline __v64qi DEFAULT_FN_ATTRS
_mm512_setzero_qi (void) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/avx512dqintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define __AVX512DQINTRIN_H

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512dq")))

static __inline__ __m512i DEFAULT_FN_ATTRS
_mm512_mullo_epi64 (__m512i __A, __m512i __B) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/avx512fintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ typedef unsigned short __mmask16;
#define _MM_FROUND_CUR_DIRECTION 0x04

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512f")))

/* Create vectors with repeated elements */

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/avx512vlbwintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define __AVX512VLBWINTRIN_H

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512vl,avx512bw")))

/* Integer compare */

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/avx512vldqintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define __AVX512VLDQINTRIN_H

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512vl,avx512dq")))

static __inline__ __m256i DEFAULT_FN_ATTRS
_mm256_mullo_epi64 (__m256i __A, __m256i __B) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/avx512vlintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define __AVX512VLINTRIN_H

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512vl")))

/* Integer compare */

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/avxintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef double __m256d __attribute__((__vector_size__(32)));
typedef long long __m256i __attribute__((__vector_size__(32)));

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx")))

/* Arithmetic */
static __inline __m256d DEFAULT_FN_ATTRS
Expand Down
6 changes: 1 addition & 5 deletions clang/lib/Headers/bmi2intrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
#error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead."
#endif

#ifndef __BMI2__
# error "BMI2 instruction set not enabled"
#endif /* __BMI2__ */

#ifndef __BMI2INTRIN_H
#define __BMI2INTRIN_H

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi2")))

static __inline__ unsigned int DEFAULT_FN_ATTRS
_bzhi_u32(unsigned int __X, unsigned int __Y)
Expand Down
6 changes: 1 addition & 5 deletions clang/lib/Headers/bmiintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead."
#endif

#ifndef __BMI__
# error "BMI instruction set not enabled"
#endif /* __BMI__ */

#ifndef __BMIINTRIN_H
#define __BMIINTRIN_H

Expand All @@ -41,7 +37,7 @@
#define _tzcnt_u32(a) (__tzcnt_u32((a)))

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))

static __inline__ unsigned short DEFAULT_FN_ATTRS
__tzcnt_u16(unsigned short __X)
Expand Down
8 changes: 1 addition & 7 deletions clang/lib/Headers/emmintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#ifndef __EMMINTRIN_H
#define __EMMINTRIN_H

#ifndef __SSE2__
#error "SSE2 instruction set not enabled"
#else

#include <xmmintrin.h>

typedef double __m128d __attribute__((__vector_size__(16)));
Expand All @@ -40,7 +36,7 @@ typedef short __v8hi __attribute__((__vector_size__(16)));
typedef char __v16qi __attribute__((__vector_size__(16)));

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2")))

static __inline__ __m128d DEFAULT_FN_ATTRS
_mm_add_sd(__m128d __a, __m128d __b)
Expand Down Expand Up @@ -1475,6 +1471,4 @@ _mm_pause(void)

#define _MM_SHUFFLE2(x, y) (((x) << 1) | (y))

#endif /* __SSE2__ */

#endif /* __EMMINTRIN_H */
6 changes: 1 addition & 5 deletions clang/lib/Headers/f16cintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@
#error "Never use <f16cintrin.h> directly; include <x86intrin.h> instead."
#endif

#ifndef __F16C__
# error "F16C instruction is not enabled"
#endif /* __F16C__ */

#ifndef __F16CINTRIN_H
#define __F16CINTRIN_H

typedef float __v8sf __attribute__ ((__vector_size__ (32)));
typedef float __m256 __attribute__ ((__vector_size__ (32)));

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("f16c")))

#define _mm_cvtps_ph(a, imm) __extension__ ({ \
__m128 __a = (a); \
Expand Down
8 changes: 1 addition & 7 deletions clang/lib/Headers/fma4intrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@
#ifndef __FMA4INTRIN_H
#define __FMA4INTRIN_H

#ifndef __FMA4__
# error "FMA4 instruction set is not enabled"
#else

#include <pmmintrin.h>

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("fma4")))

static __inline__ __m128 DEFAULT_FN_ATTRS
_mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
Expand Down Expand Up @@ -231,6 +227,4 @@ _mm256_msubadd_pd(__m256d __A, __m256d __B, __m256d __C)

#undef DEFAULT_FN_ATTRS

#endif /* __FMA4__ */

#endif /* __FMA4INTRIN_H */
8 changes: 1 addition & 7 deletions clang/lib/Headers/fmaintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@
#ifndef __FMAINTRIN_H
#define __FMAINTRIN_H

#ifndef __FMA__
# error "FMA instruction set is not enabled"
#else

/* Define the default attributes for the functions in this file. */
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
#define DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("fma")))

static __inline__ __m128 DEFAULT_FN_ATTRS
_mm_fmadd_ps(__m128 __A, __m128 __B, __m128 __C)
Expand Down Expand Up @@ -229,6 +225,4 @@ _mm256_fmsubadd_pd(__m256d __A, __m256d __B, __m256d __C)

#undef DEFAULT_FN_ATTRS

#endif /* __FMA__ */

#endif /* __FMAINTRIN_H */
Loading

0 comments on commit 9fc7fb2

Please sign in to comment.