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