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