| 1 | /* Copyright (C) 2017 Povilas Kanapickas <povilas@radix.lt> |
| 2 | |
| 3 | Distributed under the Boost Software License, Version 1.0. |
| 4 | (See accompanying file LICENSE_1_0.txt or copy at |
| 5 | http://www.boost.org/LICENSE_1_0.txt) |
| 6 | */ |
| 7 | |
| 8 | #ifndef LIBSIMDPP_SIMDPP_DETAIL_VECTOR_ARRAY_MACROS_H |
| 9 | #define LIBSIMDPP_SIMDPP_DETAIL_VECTOR_ARRAY_MACROS_H |
| 10 | |
| 11 | #ifndef LIBSIMDPP_SIMD_H |
| 12 | #error "This file must be included through simd.h" |
| 13 | #endif |
| 14 | |
| 15 | #include <simdpp/types.h> |
| 16 | |
| 17 | #define SIMDPP_VEC_ARRAY_IMPL1(RTYPE, OP, V1) \ |
| 18 | RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \ |
| 19 | r.vec(i) = OP((V1).vec(i)); } \ |
| 20 | return r; |
| 21 | |
| 22 | #define SIMDPP_VEC_ARRAY_IMPL2(RTYPE, OP, V1, V2) \ |
| 23 | RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \ |
| 24 | r.vec(i) = OP((V1).vec(i), (V2).vec(i)); } \ |
| 25 | return r; |
| 26 | |
| 27 | #define SIMDPP_VEC_ARRAY_IMPL2S(RTYPE, OP, V1, A2) \ |
| 28 | RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \ |
| 29 | r.vec(i) = OP((V1).vec(i), (A2)); } \ |
| 30 | return r; |
| 31 | |
| 32 | #define SIMDPP_VEC_ARRAY_IMPL3(RTYPE, OP, V1, V2, V3) \ |
| 33 | RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \ |
| 34 | r.vec(i) = OP((V1).vec(i), (V2).vec(i), (V3).vec(i)); \ |
| 35 | } \ |
| 36 | return r; |
| 37 | |
| 38 | #define SIMDPP_VEC_ARRAY_IMPL_REF1(RTYPE, OP, V1) \ |
| 39 | for (unsigned i = 0; i < RTYPE::vec_length; ++i) { \ |
| 40 | OP((V1).vec(i)); } |
| 41 | |
| 42 | #define SIMDPP_VEC_ARRAY_IMPL_REF2(RTYPE, OP, V1, V2) \ |
| 43 | for (unsigned i = 0; i < RTYPE::vec_length; ++i) { \ |
| 44 | OP((V1).vec(i), (V2).vec(i)); } |
| 45 | |
| 46 | #define SIMDPP_VEC_ARRAY_IMPL_REF3(RTYPE, OP, V1, V2, V3) \ |
| 47 | for (unsigned i = 0; i < RTYPE::vec_length; ++i) { \ |
| 48 | OP((V1).vec(i), (V2).vec(i), (V3).vec(i)); } |
| 49 | |
| 50 | #define SIMDPP_VEC_ARRAY_IMPL_REF4(RTYPE, OP, V1, V2, V3, V4) \ |
| 51 | for (unsigned i = 0; i < RTYPE::vec_length; ++i) { \ |
| 52 | OP((V1).vec(i), (V2).vec(i), (V3).vec(i), (V4).vec(i)); } |
| 53 | |
| 54 | #endif |
| 55 | |