X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fvector.h;h=2b84cc24869b41a3a7b536d04d14f26ec4224b00;hb=a5ab5034f4b50fc5a19ccf8910c91613e6a52f5a;hp=094cc85e22b4831ab7b69ce0a4edee6f24fa197f;hpb=37860ea49180d2c0c4d1fd476700e3a0b8d4561c;p=vpp.git diff --git a/src/vppinfra/vector.h b/src/vppinfra/vector.h index 094cc85e22b..2b84cc24869 100644 --- a/src/vppinfra/vector.h +++ b/src/vppinfra/vector.h @@ -42,11 +42,12 @@ /* Vector types. */ -#if defined (__MMX__) || defined (__IWMMXT__) || defined (__aarch64__) +#if defined (__MMX__) || defined (__IWMMXT__) || defined (__aarch64__) \ + || defined (__i686__) #define CLIB_HAVE_VEC64 #endif -#if defined (__aarch64__) && defined(__ARM_NEON) +#if defined (__aarch64__) && defined(__ARM_NEON) || defined (__i686__) #define CLIB_HAVE_VEC128 #endif @@ -58,8 +59,11 @@ #define CLIB_HAVE_VEC128 #endif -#if defined (__AVX__) +#if defined (__AVX2__) #define CLIB_HAVE_VEC256 +#if defined (__clang__) && __clang_major__ < 4 +#undef CLIB_HAVE_VEC256 +#endif #endif #if defined (__AVX512F__) @@ -154,51 +158,18 @@ typedef u64 u64x _vector_size (8); #define VECTOR_WORD_TYPE(t) t##x #define VECTOR_WORD_TYPE_LEN(t) (sizeof (VECTOR_WORD_TYPE(t)) / sizeof (t)) -/* this series of macros generate _is_equal, _is_greater, _is_zero, _add - and _sub inline funcitons for each vector type */ -#define _(t, s, c) \ - static_always_inline t##s##x##c \ -t##s##x##c##_is_equal (t##s##x##c v1, t##s##x##c v2) \ -{ return (v1 == v2); } \ - \ -static_always_inline t##s##x##c \ -t##s##x##c##_is_greater (t##s##x##c v1, t##s##x##c v2) \ -{ return (v1 > v2); } \ - \ -static_always_inline t##s##x##c \ -t##s##x##c##_is_zero (t##s##x##c v1) \ -{ t##s##x##c z = {0}; return (v1 == z); } \ - \ -static_always_inline t##s##x##c \ -t##s##x##c##_add (t##s##x##c v1, t##s##x##c v2) \ -{ return (v1 + v2); } \ - \ -static_always_inline t##s##x##c \ -t##s##x##c##_sub (t##s##x##c v1, t##s##x##c v2) \ -{ return (v1 - v2); } - foreach_vec -#undef _ - -/* this macro generate _splat inline funcitons for each scalar vector type */ -#define _(t, s, c) \ - static_always_inline t##s##x##c \ -t##s##x##c##_splat (t##s x) \ -{ \ - t##s##x##c r; \ - int i; \ - \ - for (i = 0; i < c; i++) \ - r[i] = x; \ - \ - return r; \ -} - foreach_int_vec foreach_uint_vec -#undef _ - #if defined (__SSE4_2__) && __GNUC__ >= 4 #include #endif +#if defined (__AVX2__) +#include +#endif + +#if defined (__AVX512F__) +#include +#endif + #if defined (__ALTIVEC__) #include #endif @@ -211,6 +182,24 @@ t##s##x##c##_splat (t##s x) \ #include #endif +/* this macro generate _splat inline functions for each scalar vector type */ +#ifndef CLIB_VEC128_SPLAT_DEFINED +#define _(t, s, c) \ + static_always_inline t##s##x##c \ +t##s##x##c##_splat (t##s x) \ +{ \ + t##s##x##c r; \ + int i; \ + \ + for (i = 0; i < c; i++) \ + r[i] = x; \ + \ + return r; \ +} + foreach_vec128i foreach_vec128u +#undef _ +#endif + /* *INDENT-ON* */ #endif /* included_clib_vector_h */