| 1 | /* Copyright (C) 2013-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_CORE_SHUFFLE_ZBYTES16_H |
| 9 | #define LIBSIMDPP_SIMDPP_CORE_SHUFFLE_ZBYTES16_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/detail/get_expr.h> |
| 17 | #include <simdpp/detail/insn/shuffle_zbytes16.h> |
| 18 | |
| 19 | namespace simdpp { |
| 20 | namespace SIMDPP_ARCH_NAMESPACE { |
| 21 | |
| 22 | /** Selects bytes from two vectors according to a mask, optionally selecting |
| 23 | zero. Each byte within the mask defines which element to select: |
| 24 | * Bit 7 results in the result byte being zeroed, if set. |
| 25 | * Bits 6-5 must be zero or the behavior is undefined |
| 26 | * Bit 4 defines which vector to select. 0 corresponds to @a a, 1 to @a b. |
| 27 | * Bits 3-0 define the element within the selected vector. |
| 28 | */ |
| 29 | template<unsigned N, class V1, class V2, class E3> SIMDPP_INL |
| 30 | typename detail::get_expr_nomask<V1>::empty |
| 31 | shuffle_zbytes16(const any_vec8<N,V1>& a, const any_vec8<N,V2>& b, |
| 32 | const uint8<N,E3>& mask) |
| 33 | { |
| 34 | typename detail::get_expr_nomask<V1>::type ra = a.wrapped().eval(), |
| 35 | rb = b.wrapped().eval(); |
| 36 | return detail::insn::i_shuffle_zbytes16(ra, rb, mask.eval()); |
| 37 | } |
| 38 | |
| 39 | template<unsigned N, class V1, class V2, class E3> SIMDPP_INL |
| 40 | typename detail::get_expr_nomask<V1>::empty |
| 41 | shuffle_zbytes16(const any_vec16<N,V1>& a, const any_vec16<N,V2>& b, |
| 42 | const uint16<N,E3>& mask) |
| 43 | { |
| 44 | typename detail::get_expr_nomask<V1>::type ra = a.wrapped().eval(), |
| 45 | rb = b.wrapped().eval(); |
| 46 | return detail::insn::i_shuffle_zbytes16(ra, rb, mask.eval()); |
| 47 | } |
| 48 | |
| 49 | template<unsigned N, class V1, class V2, class E3> SIMDPP_INL |
| 50 | typename detail::get_expr_nomask<V1>::empty |
| 51 | shuffle_zbytes16(const any_vec32<N,V1>& a, const any_vec32<N,V2>& b, |
| 52 | const uint32<N,E3>& mask) |
| 53 | { |
| 54 | typename detail::get_expr_nomask<V1>::type ra = a.wrapped().eval(), |
| 55 | rb = b.wrapped().eval(); |
| 56 | return detail::insn::i_shuffle_zbytes16(ra, rb, mask.eval()); |
| 57 | } |
| 58 | |
| 59 | template<unsigned N, class V1, class V2, class E3> SIMDPP_INL |
| 60 | typename detail::get_expr_nomask<V1>::empty |
| 61 | shuffle_zbytes16(const any_vec64<N,V1>& a, const any_vec64<N,V2>& b, |
| 62 | const uint64<N,E3>& mask) |
| 63 | { |
| 64 | typename detail::get_expr_nomask<V1>::type ra = a.wrapped().eval(), |
| 65 | rb = b.wrapped().eval(); |
| 66 | return detail::insn::i_shuffle_zbytes16(ra, rb, mask.eval()); |
| 67 | } |
| 68 | |
| 69 | } // namespace SIMDPP_ARCH_NAMESPACE |
| 70 | } // namespace simdpp |
| 71 | |
| 72 | #endif |
| 73 | |
| 74 | |