| 1 | /* Copyright (C) 2013-2014 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_TRAITS_H |
| 9 | #define LIBSIMDPP_SIMDPP_DETAIL_TRAITS_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 | |
| 17 | namespace simdpp { |
| 18 | namespace SIMDPP_ARCH_NAMESPACE { |
| 19 | namespace detail { |
| 20 | |
| 21 | /* Normalizes vector type. Removes sign from a vector type. |
| 22 | */ |
| 23 | template<class V> struct remove_sign { using type = V; using expr = V; }; |
| 24 | |
| 25 | template<unsigned N, class E> |
| 26 | struct remove_sign<int8<N,E>> { using type = uint8<N>; using expr = uint8<N,E>; }; |
| 27 | template<unsigned N, class E> |
| 28 | struct remove_sign<int16<N,E>> { using type = uint16<N>; using expr = uint16<N,E>; }; |
| 29 | template<unsigned N, class E> |
| 30 | struct remove_sign<int32<N,E>> { using type = uint32<N>; using expr = uint32<N,E>; }; |
| 31 | template<unsigned N, class E> |
| 32 | struct remove_sign<int64<N,E>> { using type = uint64<N>; using expr = uint64<N,E>; }; |
| 33 | |
| 34 | /* Normalizes vector type. Removes sign from a vector type. Result type is a |
| 35 | value type, not an expression. |
| 36 | */ |
| 37 | template<class V> struct remove_mask { using type = V; using expr = V; }; |
| 38 | |
| 39 | template<unsigned N, class E> |
| 40 | struct remove_mask<mask_int8<N,E>> { using type = uint8<N>; using expr = uint8<N,E>; }; |
| 41 | template<unsigned N, class E> |
| 42 | struct remove_mask<mask_int16<N,E>> { using type = uint16<N>; using expr = uint16<N,E>; }; |
| 43 | template<unsigned N, class E> |
| 44 | struct remove_mask<mask_int32<N,E>> { using type = uint32<N>; using expr = uint32<N,E>; }; |
| 45 | template<unsigned N, class E> |
| 46 | struct remove_mask<mask_int64<N,E>> { using type = uint64<N>; using expr = uint64<N,E>; }; |
| 47 | template<unsigned N, class E> |
| 48 | struct remove_mask<mask_float32<N,E>> { using type = float32<N>; using expr = float32<N,E>; }; |
| 49 | template<unsigned N, class E> |
| 50 | struct remove_mask<mask_float64<N,E>> { using type = float64<N>; using expr = float64<N,E>; }; |
| 51 | |
| 52 | } // namespace detail |
| 53 | } // namespace SIMDPP_ARCH_NAMESPACE |
| 54 | } // namespace simdpp |
| 55 | |
| 56 | #endif |
| 57 | |