| 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_CONV_MACROS_H |
| 9 | #define LIBSIMDPP_SIMDPP_DETAIL_VECTOR_ARRAY_CONV_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 | #include <simdpp/core/detail/subvec_insert.h> |
| 17 | #include <simdpp/core/detail/subvec_extract.h> |
| 18 | |
| 19 | // Used when the native vector of source vector corresponds to multiple native |
| 20 | // vectors in the destination vector. This happens when a vector type of |
| 21 | // smaller element size is converted to a vector type with larger element size |
| 22 | #define SIMDPP_VEC_ARRAY_IMPL_CONV_INSERT(RTYPE, OP, A) \ |
| 23 | RTYPE r; for (unsigned i = 0; i < (A).vec_length; ++i) { \ |
| 24 | detail::subvec_insert(r, OP(a.vec(i)), i); } \ |
| 25 | return r; |
| 26 | |
| 27 | // Used when the native vector of destination vector corresponds to multiple |
| 28 | // native vectors in the source vector. This happens when a vector type of |
| 29 | // larger element size is converted to a vector type with smaller element size. |
| 30 | #define (RTYPE, OP, A) \ |
| 31 | RTYPE r; for (unsigned i = 0; i < r.vec_length; ++i) { \ |
| 32 | r.vec(i) = OP(detail::subvec_extract<RTYPE::base_length>((A), i)); } \ |
| 33 | return r; |
| 34 | |
| 35 | #endif |
| 36 | |