1// This file is generated by tools/gen_operators.pl. CHANGES WILL BE OVERWRITTEN
2/* Copyright (C) 2013-2014 Povilas Kanapickas <povilas@radix.lt>
3
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7*/
8
9#ifndef LIBSIMDPP_SIMDPP_CORE_I_MUL_OPERATOR_H
10#define LIBSIMDPP_SIMDPP_CORE_I_MUL_OPERATOR_H
11
12#ifndef LIBSIMDPP_SIMD_H
13 #error "This file must be included through simd.h"
14#endif
15
16#include <simdpp/types.h>
17#include <simdpp/detail/expr/i_mul.h>
18#include <simdpp/core/detail/get_expr_uint.h>
19#include <simdpp/core/detail/scalar_arg_impl.h>
20#include <simdpp/core/detail/get_expr_uint.h>
21
22namespace simdpp {
23namespace SIMDPP_ARCH_NAMESPACE {
24
25// no 8 bit multiplications in SSE
26/** Multiplies 16-bit values and returns the lower part of the multiplication
27
28 @code
29 r0 = low(a0 * b0)
30 ...
31 rN = low(aN * bN)
32 @endcode
33
34 @par 256-bit version:
35 @icost{SSE2-AVX, NEON, ALTIVEC, 2}
36*/
37template<unsigned N, class V1, class V2> SIMDPP_INL
38typename detail::get_expr_uint<expr_mul_lo, V1, V2>::type
39 operator*(const any_int16<N,V1>& a,
40 const any_int16<N,V2>& b)
41{
42 return { { a.wrapped(), b.wrapped() } };
43}
44
45SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(operator*, expr_mul_lo, any_int16, int16)
46
47/** Multiplies 32-bit values and returns the lower half of the result.
48
49 @code
50 r0 = low(a0 * b0)
51 ...
52 rN = low(aN * bN)
53 @endcode
54
55 @par 128-bit version:
56 @icost{SSE2-SSSE3, 6}
57 @icost{ALTIVEC, 8}
58
59 @par 256-bit version:
60 @icost{SSE2-SSSE3, 12}
61 @icost{SSE4.1, AVX, NEON, 2}
62 @icost{ALTIVEC, 16}
63*/
64template<unsigned N, class V1, class V2> SIMDPP_INL
65typename detail::get_expr_uint<expr_mul_lo, V1, V2>::type
66 operator*(const any_int32<N,V1>& a,
67 const any_int32<N,V2>& b)
68{
69 return { { a.wrapped(), b.wrapped() } };
70}
71
72SIMDPP_SCALAR_ARG_IMPL_INT_UNSIGNED(operator*, expr_mul_lo, any_int32, int32)
73
74
75} // namespace SIMDPP_ARCH_NAMESPACE
76} // namespace simdpp
77
78#endif
79
80