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_OR_H
9 #define LIBSIMDPP_SIMDPP_CORE_BIT_OR_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_or.h>
17 #include <simdpp/detail/expr/bit_or.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 OR of integer 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_bit_or<V1, V2>::type
bit_or(const any_vec<N,V1> & a,const any_vec<N,V2> & b)36         bit_or(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_or, unsigned, V>::type
bit_or(const unsigned & a,const any_vec<N,V> & b)44         bit_or(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_or, unsigned long, V>::type
bit_or(const unsigned long & a,const any_vec<N,V> & b)50         bit_or(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_or, unsigned long long, V>::type
bit_or(const unsigned long long & a,const any_vec<N,V> & b)56         bit_or(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_or, int, V>::type
bit_or(const int & a,const any_vec<N,V> & b)62         bit_or(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_or, long, V>::type
bit_or(const long & a,const any_vec<N,V> & b)68         bit_or(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_or, long long, V>::type
bit_or(const long long & a,const any_vec<N,V> & b)74         bit_or(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_or, V, unsigned>::type
bit_or(const any_vec<N,V> & a,const unsigned & b)81         bit_or(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_or, V, unsigned long>::type
bit_or(const any_vec<N,V> & a,const unsigned long & b)87         bit_or(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_or, V, unsigned long long>::type
bit_or(const any_vec<N,V> & a,const unsigned long long & b)93         bit_or(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_or, V, int>::type
bit_or(const any_vec<N,V> & a,const int & b)99         bit_or(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_or, V, long>::type
bit_or(const any_vec<N,V> & a,const long & b)105         bit_or(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_or, V, long long>::type
bit_or(const any_vec<N,V> & a,const long long & b)111         bit_or(const any_vec<N,V>& a, const long long& b)
112 {
113     return { { a.wrapped(), b } };
114 }
115 
116 
117 } // namespace SIMDPP_ARCH_NAMESPACE
118 } // namespace simdpp
119 
120 #endif
121 
122 
123