1/* Copyright (C) 2013 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_DETAIL_NULL_MASK_H
9#define LIBSIMDPP_DETAIL_NULL_MASK_H
10#if SIMDPP_USE_NULL || SIMDPP_USE_NEON || SIMDPP_USE_ALTIVEC
11
12#ifndef LIBSIMDPP_SIMD_H
13 #error "This file must be included through simd.h"
14#endif
15
16#include <simdpp/types.h>
17#include <simdpp/core/cast.h>
18
19namespace simdpp {
20namespace SIMDPP_ARCH_NAMESPACE {
21namespace detail {
22namespace null {
23
24template<class V, class M> SIMDPP_INL
25V unmask_mask(const M& m)
26{
27 static_assert(V::length == M::length && V::size_tag == M::size_tag,
28 "Can't convert mask to different type");
29 V r;
30 typename V::uint_element_type all_bits_uint = V::all_bits;
31 typename V::element_type all_bits = bit_cast<typename V::element_type>(all_bits_uint);
32 for (unsigned i = 0; i < V::vec_length; ++i) {
33 for (unsigned j = 0; j < V::base_vector_type::length; j++) {
34 r.vec(i).el(j) = m.vec(i).el(j) ? all_bits : 0;
35 }
36 }
37 return r;
38}
39
40
41} // namespace null
42} // namespace detail
43} // namespace SIMDPP_ARCH_NAMESPACE
44} // namespace simdpp
45
46#endif
47#endif
48