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_I_SUB_H
9 #define LIBSIMDPP_SIMDPP_CORE_I_SUB_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/expr/i_sub.h>
17 #include <simdpp/core/detail/get_expr_uint.h>
18 #include <simdpp/core/detail/scalar_arg_impl.h>
19 #include <simdpp/core/detail/get_expr_uint.h>
20 
21 namespace simdpp {
22 namespace SIMDPP_ARCH_NAMESPACE {
23 
24 /** Subtracts 8-bit integer values.
25 
26     @code
27     r0 = a0 - b0
28     ...
29     rN = aN - bN
30     @endcode
31 
32     @par 256-bit version:
33     @icost{SSE2-AVX, NEON, ALTIVEC, 2}
34 */
35 template<unsigned N, class V1, class V2> SIMDPP_INL
36 typename detail::get_expr_uint<expr_isub, V1, V2>::type
sub(const any_int8<N,V1> & a,const any_int8<N,V2> & b)37         sub(const any_int8<N,V1>& a,
38             const any_int8<N,V2>& b)
39 {
40     return { { a.wrapped(), b.wrapped() } };
41 }
42 
SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(sub,expr_isub,any_int8,int8)43 SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(sub, expr_isub, any_int8, int8)
44 
45 /** Subtracts 16-bit integer values.
46 
47     @code
48     r0 = a0 - b0
49     ...
50     rN = aN - bN
51     @endcode
52 
53     @par 256-bit version:
54     @icost{SSE2-AVX, NEON, ALTIVEC, 2}
55 */
56 template<unsigned N, class V1, class V2> SIMDPP_INL
57 typename detail::get_expr_uint<expr_isub, V1, V2>::type
58         sub(const any_int16<N,V1>& a,
59             const any_int16<N,V2>& b)
60 {
61     return { { a.wrapped(), b.wrapped() } };
62 }
63 
SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(sub,expr_isub,any_int16,int16)64 SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(sub, expr_isub, any_int16, int16)
65 
66 /** Subtracts 32-bit integer values.
67 
68     @code
69     r0 = a0 - b0
70     ...
71     rN = aN - bN
72     @endcode
73 
74     @par 256-bit version:
75     @icost{SSE2-AVX, NEON, ALTIVEC, 2}
76 */
77 template<unsigned N, class V1, class V2> SIMDPP_INL
78 typename detail::get_expr_uint<expr_isub, V1, V2>::type
79         sub(const any_int32<N,V1>& a,
80             const any_int32<N,V2>& b)
81 {
82     return { { a.wrapped(), b.wrapped() } };
83 }
84 
SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(sub,expr_isub,any_int32,int32)85 SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(sub, expr_isub, any_int32, int32)
86 
87 /** Subtracts 64-bit integer values.
88 
89     @code
90     r0 = a0 - b0
91     ...
92     rN = aN - bN
93     @endcode
94 
95     @par 128-bit version:
96     @icost{ALTIVEC, 5-6}
97 
98     @par 256-bit version:
99     @icost{SSE2-AVX, NEON, 2}
100     @icost{ALTIVEC, 10-11}
101 */
102 template<unsigned N, class V1, class V2> SIMDPP_INL
103 typename detail::get_expr_uint<expr_isub, V1, V2>::type
104         sub(const any_int64<N,V1>& a,
105             const any_int64<N,V2>& b)
106 {
107     return { { a.wrapped(), b.wrapped() } };
108 }
109 
110 SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(sub, expr_isub, any_int64, int64)
111 
112 
113 } // namespace SIMDPP_ARCH_NAMESPACE
114 } // namespace simdpp
115 
116 #endif
117 
118