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