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_PERMUTE_BYTES16_H |
9 | #define LIBSIMDPP_SIMDPP_CORE_PERMUTE_BYTES16_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/permute_bytes16.h> |
18 | |
19 | namespace simdpp { |
20 | namespace SIMDPP_ARCH_NAMESPACE { |
21 | |
22 | /** Selects bytes from a vector according to a mask. Each byte within the |
23 | mask defines which element to select: |
24 | * Bits 7-4 must be zero or the behavior is undefined |
25 | * Bits 3-0 define the element within the given vector. |
26 | */ |
27 | template<unsigned N, class V1, class E2> SIMDPP_INL |
28 | typename detail::get_expr_nomask<V1>::empty |
29 | permute_bytes16(const any_vec8<N,V1>& a, const uint8<N,E2>& mask) |
30 | { |
31 | typename detail::get_expr_nomask<V1>::type ra = a.wrapped().eval(); |
32 | return detail::insn::i_permute_bytes16(ra, mask.eval()); |
33 | } |
34 | |
35 | template<unsigned N, class V1, class E2> SIMDPP_INL |
36 | typename detail::get_expr_nomask<V1>::empty |
37 | permute_bytes16(const any_vec16<N,V1>& a, const uint16<N,E2>& mask) |
38 | { |
39 | typename detail::get_expr_nomask<V1>::type ra = a.wrapped().eval(); |
40 | return detail::insn::i_permute_bytes16(ra, mask.eval()); |
41 | } |
42 | |
43 | template<unsigned N, class V1, class E2> SIMDPP_INL |
44 | typename detail::get_expr_nomask<V1>::empty |
45 | permute_bytes16(const any_vec32<N,V1>& a, const uint32<N,E2>& mask) |
46 | { |
47 | typename detail::get_expr_nomask<V1>::type ra = a.wrapped().eval(); |
48 | return detail::insn::i_permute_bytes16(ra, mask.eval()); |
49 | } |
50 | |
51 | template<unsigned N, class V1, class E2> SIMDPP_INL |
52 | typename detail::get_expr_nomask<V1>::empty |
53 | permute_bytes16(const any_vec64<N,V1>& a, const uint64<N,E2>& mask) |
54 | { |
55 | typename detail::get_expr_nomask<V1>::type ra = a.wrapped().eval(); |
56 | return detail::insn::i_permute_bytes16(ra, mask.eval()); |
57 | } |
58 | } // namespace SIMDPP_ARCH_NAMESPACE |
59 | } // namespace simdpp |
60 | |
61 | #endif |
62 | |
63 | |