| 1 | /* Copyright (C) 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_DETAIL_EVAL_SCALAR_H |
| 9 | #define LIBSIMDPP_SIMDPP_DETAIL_EVAL_SCALAR_H |
| 10 | |
| 11 | #ifndef LIBSIMDPP_SIMD_H |
| 12 | #error "This file must be included through simd.h" |
| 13 | #endif |
| 14 | |
| 15 | #include <simdpp/setup_arch.h> |
| 16 | #include <simdpp/expr.h> |
| 17 | #include <simdpp/detail/expr/scalar.h> |
| 18 | |
| 19 | namespace simdpp { |
| 20 | namespace SIMDPP_ARCH_NAMESPACE { |
| 21 | namespace detail { |
| 22 | |
| 23 | template<class R, class E> |
| 24 | struct eval_maybe_scalar { |
| 25 | static SIMDPP_INL R eval(const E& e) { return (R) e.eval(); } |
| 26 | }; |
| 27 | |
| 28 | template<class R> |
| 29 | struct eval_maybe_scalar<R, int> { |
| 30 | static SIMDPP_INL R eval(const int& e) { return expr_eval_scalar<R>(e); } |
| 31 | }; |
| 32 | |
| 33 | template<class R> |
| 34 | struct eval_maybe_scalar<R, long> { |
| 35 | static SIMDPP_INL R eval(const long& e) { return expr_eval_scalar<R>(e); } |
| 36 | }; |
| 37 | |
| 38 | template<class R> |
| 39 | struct eval_maybe_scalar<R, long long> { |
| 40 | static SIMDPP_INL R eval(const long long& e) { return expr_eval_scalar<R>(e); } |
| 41 | }; |
| 42 | |
| 43 | template<class R> |
| 44 | struct eval_maybe_scalar<R, unsigned> { |
| 45 | static SIMDPP_INL R eval(const unsigned& e) { return expr_eval_scalar<R>(e); } |
| 46 | }; |
| 47 | |
| 48 | template<class R> |
| 49 | struct eval_maybe_scalar<R, unsigned long> { |
| 50 | static SIMDPP_INL R eval(const unsigned long& e) { return expr_eval_scalar<R>(e); } |
| 51 | }; |
| 52 | |
| 53 | template<class R> |
| 54 | struct eval_maybe_scalar<R, unsigned long long> { |
| 55 | static SIMDPP_INL R eval(const unsigned long long& e) { return expr_eval_scalar<R>(e); } |
| 56 | }; |
| 57 | |
| 58 | template<class R> |
| 59 | struct eval_maybe_scalar<R, float> { |
| 60 | static SIMDPP_INL R eval(const float& e) { return expr_eval_scalar<R>(e); } |
| 61 | }; |
| 62 | |
| 63 | template<class R> |
| 64 | struct eval_maybe_scalar<R, double> { |
| 65 | static SIMDPP_INL R eval(const double& e) { return expr_eval_scalar<R>(e); } |
| 66 | }; |
| 67 | |
| 68 | template<class R, class E> |
| 69 | struct eval_maybe_scalar_bitwise { |
| 70 | static SIMDPP_INL R eval(const E& e) { return (R) e.eval(); } |
| 71 | }; |
| 72 | |
| 73 | template<class R> |
| 74 | struct eval_maybe_scalar_bitwise<R, int> { |
| 75 | static SIMDPP_INL R eval(const int& e) { return expr_eval_scalar_bitwise<R>(e); } |
| 76 | }; |
| 77 | |
| 78 | template<class R> |
| 79 | struct eval_maybe_scalar_bitwise<R, long> { |
| 80 | static SIMDPP_INL R eval(const long& e) { return expr_eval_scalar_bitwise<R>(e); } |
| 81 | }; |
| 82 | |
| 83 | template<class R> |
| 84 | struct eval_maybe_scalar_bitwise<R, long long> { |
| 85 | static SIMDPP_INL R eval(const long long& e) { return expr_eval_scalar_bitwise<R>(e); } |
| 86 | }; |
| 87 | |
| 88 | template<class R> |
| 89 | struct eval_maybe_scalar_bitwise<R, unsigned> { |
| 90 | static SIMDPP_INL R eval(const unsigned& e) { return expr_eval_scalar_bitwise<R>(e); } |
| 91 | }; |
| 92 | |
| 93 | template<class R> |
| 94 | struct eval_maybe_scalar_bitwise<R, unsigned long> { |
| 95 | static SIMDPP_INL R eval(const unsigned long& e) { return expr_eval_scalar_bitwise<R>(e); } |
| 96 | }; |
| 97 | |
| 98 | template<class R> |
| 99 | struct eval_maybe_scalar_bitwise<R, unsigned long long> { |
| 100 | static SIMDPP_INL R eval(const unsigned long long& e) { return expr_eval_scalar_bitwise<R>(e); } |
| 101 | }; |
| 102 | |
| 103 | template<class R> |
| 104 | struct eval_maybe_scalar_bitwise<R, float> { |
| 105 | static SIMDPP_INL R eval(const float& e) { return expr_eval_scalar_bitwise<R>(e); } |
| 106 | }; |
| 107 | |
| 108 | template<class R> |
| 109 | struct eval_maybe_scalar_bitwise<R, double> { |
| 110 | static SIMDPP_INL R eval(const double& e) { return expr_eval_scalar_bitwise<R>(e); } |
| 111 | }; |
| 112 | |
| 113 | } // namespace detail |
| 114 | } // namespace SIMDPP_ARCH_NAMESPACE |
| 115 | } // namespace simdpp |
| 116 | |
| 117 | #endif |
| 118 | |