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_CORE_BIT_ANDNOT_H |
9 | #define LIBSIMDPP_SIMDPP_CORE_BIT_ANDNOT_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/insn/bit_andnot.h> |
17 | #include <simdpp/detail/expr/bit_andnot.h> |
18 | #include <simdpp/core/detail/get_expr_bitwise.h> |
19 | #include <simdpp/core/detail/scalar_arg_impl.h> |
20 | |
21 | namespace simdpp { |
22 | namespace SIMDPP_ARCH_NAMESPACE { |
23 | |
24 | /** Computes bitwise AND NOT of two integer or floating-point vectors. |
25 | |
26 | @code |
27 | r0 = a0 & ~b0 |
28 | ... |
29 | rN = aN & ~bN |
30 | @endcode |
31 | |
32 | @todo: icost |
33 | */ |
34 | template<unsigned N, class V1, class V2> SIMDPP_INL |
35 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, V1, V2>::type |
36 | bit_andnot(const any_vec<N,V1>& a, const any_vec<N,V2>& b) |
37 | { |
38 | return { { a.wrapped(), b.wrapped() } }; |
39 | } |
40 | |
41 | // support scalar arguments |
42 | template<unsigned N, class V> SIMDPP_INL |
43 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, unsigned, V>::type |
44 | bit_andnot(const unsigned& a, const any_vec<N,V>& b) |
45 | { |
46 | return { { a, b.wrapped() } }; |
47 | } |
48 | template<unsigned N, class V> SIMDPP_INL |
49 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, unsigned long, V>::type |
50 | bit_andnot(const unsigned long& a, const any_vec<N,V>& b) |
51 | { |
52 | return { { a, b.wrapped() } }; |
53 | } |
54 | template<unsigned N, class V> SIMDPP_INL |
55 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, unsigned long long, V>::type |
56 | bit_andnot(const unsigned long long& a, const any_vec<N,V>& b) |
57 | { |
58 | return { { a, b.wrapped() } }; |
59 | } |
60 | template<unsigned N, class V> SIMDPP_INL |
61 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, int, V>::type |
62 | bit_andnot(const int& a, const any_vec<N,V>& b) |
63 | { |
64 | return { { a, b.wrapped() } }; |
65 | } |
66 | template<unsigned N, class V> SIMDPP_INL |
67 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, long, V>::type |
68 | bit_andnot(const long& a, const any_vec<N,V>& b) |
69 | { |
70 | return { { a, b.wrapped() } }; |
71 | } |
72 | template<unsigned N, class V> SIMDPP_INL |
73 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, long long, V>::type |
74 | bit_andnot(const long long& a, const any_vec<N,V>& b) |
75 | { |
76 | return { { a, b.wrapped() } }; |
77 | } |
78 | |
79 | template<unsigned N, class V> SIMDPP_INL |
80 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, V, unsigned>::type |
81 | bit_andnot(const any_vec<N,V>& a, const unsigned& b) |
82 | { |
83 | return { { a.wrapped(), b } }; |
84 | } |
85 | template<unsigned N, class V> SIMDPP_INL |
86 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, V, unsigned long>::type |
87 | bit_andnot(const any_vec<N,V>& a, const unsigned long& b) |
88 | { |
89 | return { { a.wrapped(), b } }; |
90 | } |
91 | template<unsigned N, class V> SIMDPP_INL |
92 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, V, unsigned long long>::type |
93 | bit_andnot(const any_vec<N,V>& a, const unsigned long long& b) |
94 | { |
95 | return { { a.wrapped(), b } }; |
96 | } |
97 | template<unsigned N, class V> SIMDPP_INL |
98 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, V, int>::type |
99 | bit_andnot(const any_vec<N,V>& a, const int& b) |
100 | { |
101 | return { { a.wrapped(), b } }; |
102 | } |
103 | template<unsigned N, class V> SIMDPP_INL |
104 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, V, long>::type |
105 | bit_andnot(const any_vec<N,V>& a, const long& b) |
106 | { |
107 | return { { a.wrapped(), b } }; |
108 | } |
109 | template<unsigned N, class V> SIMDPP_INL |
110 | typename detail::get_expr_bitwise2_and<expr_bit_andnot, V, long long>::type |
111 | bit_andnot(const any_vec<N,V>& a, const long long& b) |
112 | { |
113 | return { { a.wrapped(), b } }; |
114 | } |
115 | |
116 | } // namespace SIMDPP_ARCH_NAMESPACE |
117 | } // namespace simdpp |
118 | |
119 | #endif |
120 | |
121 | |