X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fvector.h;h=fed6fa3c1fd3f789170c832e7f1a205f294e2ebe;hb=3648d93b9888f4d91e2fc5fa61018c4310adc86f;hp=094cc85e22b4831ab7b69ce0a4edee6f24fa197f;hpb=37860ea49180d2c0c4d1fd476700e3a0b8d4561c;p=vpp.git diff --git a/src/vppinfra/vector.h b/src/vppinfra/vector.h index 094cc85e22b..fed6fa3c1fd 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,11 +59,14 @@ #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__) +#if defined (__AVX512BITALG__) #define CLIB_HAVE_VEC512 #endif @@ -72,6 +76,7 @@ #endif #define _vector_size(n) __attribute__ ((vector_size (n))) +#define _vector_size_unaligned(n) __attribute__ ((vector_size (n), __aligned__ (1))) #define foreach_vec64i _(i,8,8) _(i,16,4) _(i,32,2) #define foreach_vec64u _(u,8,8) _(u,16,4) _(u,32,2) @@ -107,6 +112,7 @@ /* Type Definitions */ #define _(t,s,c) \ typedef t##s t##s##x##c _vector_size (s/8*c); \ +typedef t##s t##s##x##c##u _vector_size_unaligned (s/8*c); \ typedef union { \ t##s##x##c as_##t##s##x##c; \ t##s as_##t##s[c]; \ @@ -149,37 +155,42 @@ typedef u32 u32x _vector_size (8); typedef u64 u64x _vector_size (8); #endif +/* universal inlines */ +#define _(t, s, c) \ +static_always_inline t##s##x##c \ +t##s##x##c##_zero () \ +{ return (t##s##x##c) {}; } \ + +foreach_vec +#undef _ + #undef _vector_size #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 _ +#if defined (__SSE4_2__) && __GNUC__ >= 4 +#include +#endif + +#if defined (__AVX2__) +#include +#endif + +#if defined(__AVX512F__) +#include +#endif + +#if defined (__ALTIVEC__) +#include +#endif + +#if defined (__aarch64__) +#include +#endif -/* this macro generate _splat inline funcitons for each scalar vector type */ +/* 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) \ @@ -192,23 +203,8 @@ t##s##x##c##_splat (t##s x) \ \ return r; \ } - foreach_int_vec foreach_uint_vec + foreach_vec128i foreach_vec128u #undef _ - -#if defined (__SSE4_2__) && __GNUC__ >= 4 -#include -#endif - -#if defined (__ALTIVEC__) -#include -#endif - -#if defined (__aarch64__) -#include -#endif - -#if (defined(CLIB_HAVE_VEC128) || defined(CLIB_HAVE_VEC64)) -#include #endif /* *INDENT-ON* */