Fix vector macros to correctly check argument types. <rdar://problem/10261670>

llvm-svn: 143792
This commit is contained in:
Bob Wilson 2011-11-05 06:08:06 +00:00
parent b3675dd660
commit c9b97cc1da
5 changed files with 85 additions and 50 deletions

View File

@ -337,19 +337,23 @@ _mm256_dp_ps(__m256 a, __m256 b, const int c)
}
/* Vector shuffle */
#define _mm256_shuffle_ps(a, b, mask) \
(__builtin_shufflevector((__v8sf)(a), (__v8sf)(b), \
#define _mm256_shuffle_ps(a, b, mask) __extension__ ({ \
__m256 __a = (a); \
__m256 __b = (b); \
(__m256)__builtin_shufflevector((__v8sf)__a, (__v8sf)__b, \
(mask) & 0x3, ((mask) & 0xc) >> 2, \
(((mask) & 0x30) >> 4) + 8, (((mask) & 0xc0) >> 6) + 8, \
((mask) & 0x3) + 4, (((mask) & 0xc) >> 2) + 4, \
(((mask) & 0x30) >> 4) + 12, (((mask) & 0xc0) >> 6) + 12))
(((mask) & 0x30) >> 4) + 12, (((mask) & 0xc0) >> 6) + 12); })
#define _mm256_shuffle_pd(a, b, mask) \
(__builtin_shufflevector((__v4df)(a), (__v4df)(b), \
#define _mm256_shuffle_pd(a, b, mask) __extension__ ({ \
__m256d __a = (a); \
__m256d __b = (b); \
(__m256d)__builtin_shufflevector((__v4df)__a, (__v4df)__b, \
(mask) & 0x1, \
(((mask) & 0x2) >> 1) + 4, \
(((mask) & 0x4) >> 2) + 2, \
(((mask) & 0x8) >> 3) + 6))
(((mask) & 0x8) >> 3) + 6); })
/* Compare */
#define _CMP_EQ_OQ 0x00 /* Equal (ordered, non-signaling) */
@ -385,23 +389,35 @@ _mm256_dp_ps(__m256 a, __m256 b, const int c)
#define _CMP_GT_OQ 0x1e /* Greater-than (ordered, non-signaling) */
#define _CMP_TRUE_US 0x1f /* True (unordered, signaling) */
#define _mm_cmp_pd(a, b, c) \
(__m128d)__builtin_ia32_cmppd((__v2df)(a), (__v2df)(b), (c))
#define _mm_cmp_pd(a, b, c) __extension__ ({ \
__m128d __a = (a); \
__m128d __b = (b); \
(__m128d)__builtin_ia32_cmppd((__v2df)__a, (__v2df)__b, (c)); })
#define _mm_cmp_ps(a, b, c) \
(__m128)__builtin_ia32_cmpps((__v4sf)(a), (__v4sf)(b), (c))
#define _mm_cmp_ps(a, b, c) __extension__ ({ \
__m128 __a = (a); \
__m128 __b = (b); \
(__m128)__builtin_ia32_cmpps((__v4sf)__a, (__v4sf)__b, (c)); })
#define _mm256_cmp_pd(a, b, c) \
(__m256d)__builtin_ia32_cmppd256((__v4df)(a), (__v4df)(b), (c))
#define _mm256_cmp_pd(a, b, c) __extension__ ({ \
__m256d __a = (a); \
__m256d __b = (b); \
(__m256d)__builtin_ia32_cmppd256((__v4df)__a, (__v4df)__b, (c)); })
#define _mm256_cmp_ps(a, b, c) \
(__m256)__builtin_ia32_cmpps256((__v8sf)(a), (__v8sf)(b), (c))
#define _mm256_cmp_ps(a, b, c) __extension__ ({ \
__m256 __a = (a); \
__m256 __b = (b); \
(__m256)__builtin_ia32_cmpps256((__v8sf)__a, (__v8sf)__b, (c)); })
#define _mm_cmp_sd(a, b, c) \
(__m128d)__builtin_ia32_cmpsd((__v2df)(a), (__v2df)(b), (c))
#define _mm_cmp_sd(a, b, c) __extension__ ({ \
__m128d __a = (a); \
__m128d __b = (b); \
(__m128d)__builtin_ia32_cmpsd((__v2df)__a, (__v2df)__b, (c)); })
#define _mm_cmp_ss(a, b, c) \
(__m128)__builtin_ia32_cmpss((__v4sf)(a), (__v4sf)(b), (c))
#define _mm_cmp_ss(a, b, c) __extension__ ({ \
__m128 __a = (a); \
__m128 __b = (b); \
(__m128)__builtin_ia32_cmpss((__v4sf)__a, (__v4sf)__b, (c)); })
/* Vector extract */
static __inline __m128d __attribute__((__always_inline__, __nodebug__))

View File

@ -821,8 +821,9 @@ _mm_xor_si128(__m128i a, __m128i b)
return a ^ b;
}
#define _mm_slli_si128(VEC, IMM) \
((__m128i)__builtin_ia32_pslldqi128((__m128i)(VEC), (IMM)*8))
#define _mm_slli_si128(a, count) __extension__ ({ \
__m128i __a = (a); \
(__m128i)__builtin_ia32_pslldqi128(__a, (count)*8); })
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_slli_epi16(__m128i a, int count)
@ -885,8 +886,9 @@ _mm_sra_epi32(__m128i a, __m128i count)
}
#define _mm_srli_si128(VEC, IMM) \
((__m128i)__builtin_ia32_psrldqi128((__m128i)(VEC), (IMM)*8))
#define _mm_srli_si128(a, count) __extension__ ({ \
__m128i __a = (a); \
(__m128i)__builtin_ia32_psrldqi128(__a, (count)*8); })
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_srli_epi16(__m128i a, int count)
@ -1259,23 +1261,27 @@ _mm_movemask_epi8(__m128i a)
return __builtin_ia32_pmovmskb128((__v16qi)a);
}
#define _mm_shuffle_epi32(a, imm) \
((__m128i)__builtin_shufflevector((__v4si)(a), (__v4si) _mm_set1_epi32(0), \
(imm) & 0x3, ((imm) & 0xc) >> 2, \
((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6))
#define _mm_shuffle_epi32(a, imm) __extension__ ({ \
__m128i __a = (a); \
(__m128i)__builtin_shufflevector((__v4si)__a, (__v4si) _mm_set1_epi32(0), \
(imm) & 0x3, ((imm) & 0xc) >> 2, \
((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6); })
#define _mm_shufflelo_epi16(a, imm) __extension__ ({ \
__m128i __a = (a); \
(__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \
(imm) & 0x3, ((imm) & 0xc) >> 2, \
((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \
4, 5, 6, 7); })
#define _mm_shufflelo_epi16(a, imm) \
((__m128i)__builtin_shufflevector((__v8hi)(a), (__v8hi) _mm_set1_epi16(0), \
(imm) & 0x3, ((imm) & 0xc) >> 2, \
((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \
4, 5, 6, 7))
#define _mm_shufflehi_epi16(a, imm) \
((__m128i)__builtin_shufflevector((__v8hi)(a), (__v8hi) _mm_set1_epi16(0), 0, 1, 2, 3, \
4 + (((imm) & 0x03) >> 0), \
4 + (((imm) & 0x0c) >> 2), \
4 + (((imm) & 0x30) >> 4), \
4 + (((imm) & 0xc0) >> 6)))
#define _mm_shufflehi_epi16(a, imm) __extension__ ({ \
__m128i __a = (a); \
(__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi) _mm_set1_epi16(0), \
0, 1, 2, 3, \
4 + (((imm) & 0x03) >> 0), \
4 + (((imm) & 0x0c) >> 2), \
4 + (((imm) & 0x30) >> 4), \
4 + (((imm) & 0xc0) >> 6)); })
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_unpackhi_epi8(__m128i a, __m128i b)
@ -1361,9 +1367,10 @@ _mm_movemask_pd(__m128d a)
return __builtin_ia32_movmskpd(a);
}
#define _mm_shuffle_pd(a, b, i) \
(__builtin_shufflevector((__m128d)(a), (__m128d)(b), (i) & 1, \
(((i) & 2) >> 1) + 2))
#define _mm_shuffle_pd(a, b, i) __extension__ ({ \
__m128d __a = (a); \
__m128d __b = (b); \
__builtin_shufflevector(__a, __b, (i) & 1, (((i) & 2) >> 1) + 2); })
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_castpd_ps(__m128d in)

View File

@ -66,8 +66,15 @@ _mm_abs_epi32(__m128i a)
return (__m128i)__builtin_ia32_pabsd128((__v4si)a);
}
#define _mm_alignr_epi8(a, b, n) (__builtin_ia32_palignr128((a), (b), (n)))
#define _mm_alignr_pi8(a, b, n) (__builtin_ia32_palignr((a), (b), (n)))
#define _mm_alignr_epi8(a, b, n) __extension__ ({ \
__m128i __a = (a); \
__m128i __b = (b); \
(__m128i)__builtin_ia32_palignr128((__v16qi)__a, (__v16qi)__b, (n)); })
#define _mm_alignr_pi8(a, b, n) __extension__ ({ \
__m64 __a = (a); \
__m64 __b = (b); \
(__m64)__builtin_ia32_palignr((__v8qi)__a, (__v8qi)__b, (n)); })
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
_mm_hadd_epi16(__m128i a, __m128i b)

View File

@ -735,8 +735,9 @@ _mm_mulhi_pu16(__m64 a, __m64 b)
return (__m64)__builtin_ia32_pmulhuw((__v4hi)a, (__v4hi)b);
}
#define _mm_shuffle_pi16(a, n) \
((__m64)__builtin_ia32_pshufw(a, n))
#define _mm_shuffle_pi16(a, n) __extension__ ({ \
__m64 __a = (a); \
(__m64)__builtin_ia32_pshufw((__v4hi)__a, (n)); })
static __inline__ void __attribute__((__always_inline__, __nodebug__))
_mm_maskmove_si64(__m64 d, __m64 n, char *p)
@ -774,11 +775,13 @@ _mm_setcsr(unsigned int i)
__builtin_ia32_ldmxcsr(i);
}
#define _mm_shuffle_ps(a, b, mask) \
(__builtin_shufflevector((__v4sf)(a), (__v4sf)(b), \
(mask) & 0x3, ((mask) & 0xc) >> 2, \
(((mask) & 0x30) >> 4) + 4, \
(((mask) & 0xc0) >> 6) + 4))
#define _mm_shuffle_ps(a, b, mask) __extension__ ({ \
__m128 __a = (a); \
__m128 __b = (b); \
(__m128)__builtin_shufflevector((__v4sf)__a, (__v4sf)__b, \
(mask) & 0x3, ((mask) & 0xc) >> 2, \
(((mask) & 0x30) >> 4) + 4, \
(((mask) & 0xc0) >> 6) + 4); })
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
_mm_unpackhi_ps(__m128 a, __m128 b)

View File

@ -4,7 +4,9 @@
#include <tmmintrin.h>
__m64 test1(__m64 a, __m64 b, int c) {
return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}}
// FIXME: The "incompatible result type" error is due to pr10112 and should
// be removed when that is fixed.
return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}} expected-error {{incompatible result type}}
}
int test2(int N) {