1 | /* Copyright (C) 2011-2012 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_DETAIL_NULL_SET_H |
9 | #define LIBSIMDPP_DETAIL_NULL_SET_H |
10 | #if SIMDPP_USE_NULL || SIMDPP_USE_NEON || SIMDPP_USE_ALTIVEC |
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 | |
18 | namespace simdpp { |
19 | namespace SIMDPP_ARCH_NAMESPACE { |
20 | namespace detail { |
21 | namespace null { |
22 | |
23 | template<class V, class E = typename V::element_type> SIMDPP_INL |
24 | V make_vec(E v0) |
25 | { |
26 | V r; |
27 | for (unsigned i = 0; i < V::length; i++) { |
28 | r.el(i) = v0; |
29 | } |
30 | return r; |
31 | } |
32 | |
33 | template<class V, class E = typename V::element_type> SIMDPP_INL |
34 | V make_vec(E v0, E v1) |
35 | { |
36 | V r; |
37 | for (unsigned i = 0; i < V::length; i+=2) { |
38 | r.el(i) = v0; |
39 | r.el(i+1) = v1; |
40 | } |
41 | return r; |
42 | } |
43 | |
44 | template<class V, class E = typename V::element_type> SIMDPP_INL |
45 | V make_vec(E v0, E v1, E v2, E v3) |
46 | { |
47 | V r; |
48 | for (unsigned i = 0; i < V::length; i+=4) { |
49 | r.el(i) = v0; |
50 | r.el(i+1) = v1; |
51 | r.el(i+2) = v2; |
52 | r.el(i+3) = v3; |
53 | } |
54 | return r; |
55 | } |
56 | |
57 | template<class V, class E = typename V::element_type> SIMDPP_INL |
58 | V make_vec(E v0, E v1, E v2, E v3, E v4, E v5, E v6, E v7) |
59 | { |
60 | V r; |
61 | for (unsigned i = 0; i < V::length; i+=8) { |
62 | r.el(i) = v0; |
63 | r.el(i+1) = v1; |
64 | r.el(i+2) = v2; |
65 | r.el(i+3) = v3; |
66 | r.el(i+4) = v4; |
67 | r.el(i+5) = v5; |
68 | r.el(i+6) = v6; |
69 | r.el(i+7) = v7; |
70 | } |
71 | return r; |
72 | } |
73 | |
74 | template<class V, class E = typename V::element_type> SIMDPP_INL |
75 | V make_vec(E v0, E v1, E v2, E v3, E v4, E v5, E v6, E v7, |
76 | E v8, E v9, E v10, E v11, E v12, E v13, E v14, E v15) |
77 | { |
78 | V r; |
79 | for (unsigned i = 0; i < V::length; i+=16) { |
80 | r.el(i) = v0; |
81 | r.el(i+1) = v1; |
82 | r.el(i+2) = v2; |
83 | r.el(i+3) = v3; |
84 | r.el(i+4) = v4; |
85 | r.el(i+5) = v5; |
86 | r.el(i+6) = v6; |
87 | r.el(i+7) = v7; |
88 | r.el(i+8) = v8; |
89 | r.el(i+9) = v9; |
90 | r.el(i+10) = v10; |
91 | r.el(i+11) = v11; |
92 | r.el(i+12) = v12; |
93 | r.el(i+13) = v13; |
94 | r.el(i+14) = v14; |
95 | r.el(i+15) = v15; |
96 | } |
97 | return r; |
98 | } |
99 | |
100 | } // namespace null |
101 | } // namespace detail |
102 | } // namespace SIMDPP_ARCH_NAMESPACE |
103 | } // namespace simdpp |
104 | |
105 | #endif |
106 | #endif |
107 | |