1 | // RUN: %clang_cc1 -fsyntax-only -ffreestanding %s -verify |
2 | // RUN: %clang_cc1 -fsyntax-only -ffreestanding -fno-lax-vector-conversions %s -verify |
3 | // RUN: %clang_cc1 -fsyntax-only -ffreestanding -x c++ %s -verify |
4 | // expected-no-diagnostics |
5 | |
6 | #if defined(i386) || defined(__x86_64__) |
7 | |
8 | // Include the metaheader that includes all x86 intrinsic headers. |
9 | #include <x86intrin.h> |
10 | |
11 | void __attribute__((__target__("mmx"))) mm_empty_wrap(void) { |
12 | _mm_empty(); |
13 | } |
14 | |
15 | __m128 __attribute__((__target__("sse"))) mm_add_ss_wrap(__m128 a, __m128 b) { |
16 | return _mm_add_ss(a, b); |
17 | } |
18 | |
19 | __m128d __attribute__((__target__("sse2"))) mm_sqrt_sd_wrap(__m128d a, __m128d b) { |
20 | return _mm_sqrt_sd(a, b); |
21 | } |
22 | |
23 | void __attribute__((__target__("sse3"))) mm_mwait_wrap(int a) { |
24 | _mm_mwait(0, 0); |
25 | } |
26 | |
27 | __m64 __attribute__((__target__("ssse3"))) mm_abs_pi8_wrap(__m64 a) { |
28 | return _mm_abs_pi8(a); |
29 | } |
30 | |
31 | __m128i __attribute__((__target__("sse4.1"))) mm_minpos_epu16_wrap(__m128i v) { |
32 | return _mm_minpos_epu16(v); |
33 | } |
34 | |
35 | unsigned int __attribute__((__target__("sse4.2"))) mm_crc32_u8_wrap(unsigned int c, unsigned char d) { |
36 | return _mm_crc32_u8(c, d); |
37 | } |
38 | |
39 | __m128i __attribute__((__target__("aes"))) mm_aesenc_si128_wrap(__m128i v, __m128i r) { |
40 | return _mm_aesenc_si128(v, r); |
41 | } |
42 | |
43 | __m256d __attribute__((__target__("avx"))) mm256_add_pd_wrap(__m256d a, __m256d b) { |
44 | return _mm256_add_pd(a, b); |
45 | } |
46 | |
47 | __m256i __attribute__((__target__("avx2"))) mm256_abs_epi8_wrap(__m256i a) { |
48 | return _mm256_abs_epi8(a); |
49 | } |
50 | |
51 | unsigned short __attribute__((__target__("bmi"))) tzcnt_u16_wrap(unsigned short x) { |
52 | return __tzcnt_u16(x); |
53 | } |
54 | |
55 | unsigned int __attribute__((__target__("bmi2"))) bzhi_u32_wrap(unsigned int x, unsigned int y) { |
56 | return _bzhi_u32(x, y); |
57 | } |
58 | |
59 | unsigned short __attribute__((__target__("lzcnt"))) lzcnt16_wrap(unsigned short x) { |
60 | return __lzcnt16(x); |
61 | } |
62 | |
63 | __m256d __attribute__((__target__("fma"))) mm256_fmsubadd_pd_wrap(__m256d a, __m256d b, __m256d c) { |
64 | return _mm256_fmsubadd_pd(a, b, c); |
65 | } |
66 | |
67 | __m512i __attribute__((__target__("avx512f"))) mm512_setzero_si512_wrap(void) { |
68 | return _mm512_setzero_si512(); |
69 | } |
70 | |
71 | __mmask8 __attribute__((__target__("avx512vl"))) mm_cmpeq_epi32_mask_wrap(__m128i a, __m128i b) { |
72 | return _mm_cmpeq_epi32_mask(a, b); |
73 | } |
74 | |
75 | __m512i __attribute__((__target__("avx512dq"))) mm512_mullo_epi64_wrap(__m512i a, __m512i b) { |
76 | return _mm512_mullo_epi64(a, b); |
77 | } |
78 | |
79 | __mmask16 __attribute__((__target__("avx512vl,avx512bw"))) mm_cmpeq_epi8_mask_wrap(__m128i a, __m128i b) { |
80 | return _mm_cmpeq_epi8_mask(a, b); |
81 | } |
82 | |
83 | __m256i __attribute__((__target__("avx512vl,avx512dq"))) mm256_mullo_epi64_wrap(__m256i a, __m256i b) { |
84 | return _mm256_mullo_epi64(a, b); |
85 | } |
86 | |
87 | int __attribute__((__target__("rdrnd"))) rdrand16_step_wrap(unsigned short *p) { |
88 | return _rdrand16_step(p); |
89 | } |
90 | |
91 | #if defined(__x86_64__) |
92 | unsigned int __attribute__((__target__("fsgsbase"))) readfsbase_u32_wrap(void) { |
93 | return _readfsbase_u32(); |
94 | } |
95 | #endif |
96 | |
97 | unsigned int __attribute__((__target__("rtm"))) xbegin_wrap(void) { |
98 | return _xbegin(); |
99 | } |
100 | |
101 | __m128i __attribute__((__target__("sha"))) mm_sha1nexte_epu32_wrap(__m128i x, __m128i y) { |
102 | return _mm_sha1nexte_epu32(x, y); |
103 | } |
104 | |
105 | int __attribute__((__target__("rdseed"))) rdseed16_step_wrap(unsigned short *p) { |
106 | return _rdseed16_step(p); |
107 | } |
108 | |
109 | __m128i __attribute__((__target__("sse4a"))) mm_extract_si64_wrap(__m128i x, __m128i y) { |
110 | return _mm_extract_si64(x, y); |
111 | } |
112 | |
113 | __m128 __attribute__((__target__("fma4"))) mm_macc_ps_wrap(__m128 a, __m128 b, __m128 c) { |
114 | return _mm_macc_ps(a, b, c); |
115 | } |
116 | |
117 | __m256 __attribute__((__target__("xop"))) mm256_frcz_ps_wrap(__m256 a) { |
118 | return _mm256_frcz_ps(a); |
119 | } |
120 | |
121 | unsigned int __attribute__((__target__("tbm"))) blcfill_u32_wrap(unsigned int a) { |
122 | return __blcfill_u32(a); |
123 | } |
124 | |
125 | __m128 __attribute__((__target__("f16c"))) mm_cvtph_ps_wrap(__m128i a) { |
126 | return _mm_cvtph_ps(a); |
127 | } |
128 | |
129 | int __attribute__((__target__("rtm"))) xtest_wrap(void) { |
130 | return _xtest(); |
131 | } |
132 | |
133 | #endif |
134 | |