1 | /* Copyright (C) 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_NEON_SHUFFLE_H |
9 | #define LIBSIMDPP_DETAIL_NEON_SHUFFLE_H |
10 | #if SIMDPP_USE_NEON |
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 neon { |
22 | |
23 | /** @code |
24 | a0 = b0 |
25 | a1 = a1 |
26 | b0 = a0 |
27 | b1 = b1 |
28 | @endcode |
29 | */ |
30 | static SIMDPP_INL |
31 | void swap_lo(uint64x2& a, uint64x2& b) |
32 | { |
33 | uint64x1_t ah, bh, al, bl; |
34 | al = vget_low_u64(a.native()); |
35 | bl = vget_low_u64(b.native()); |
36 | ah = vget_high_u64(a.native()); |
37 | bh = vget_high_u64(b.native()); |
38 | a = vcombine_u64(bl, ah); |
39 | b = vcombine_u64(al, bh); |
40 | } |
41 | |
42 | /** @code |
43 | a0 = a0 |
44 | a1 = b1 |
45 | b0 = b0 |
46 | b1 = a1 |
47 | @endcode |
48 | */ |
49 | static SIMDPP_INL |
50 | void swap_hi(uint64x2& a, uint64x2& b) |
51 | { |
52 | uint64x1_t ah, bh, al, bl; |
53 | al = vget_low_u64(a.native()); |
54 | bl = vget_low_u64(b.native()); |
55 | ah = vget_high_u64(a.native()); |
56 | bh = vget_high_u64(b.native()); |
57 | a = vcombine_u64(al, bh); |
58 | b = vcombine_u64(bl, ah); |
59 | } |
60 | |
61 | static SIMDPP_INL |
62 | void transpose2(uint64x2& a, uint64x2& b) |
63 | { |
64 | uint64x1_t ah, bh, al, bl; |
65 | al = vget_low_u64(a.native()); |
66 | bl = vget_low_u64(b.native()); |
67 | ah = vget_high_u64(a.native()); |
68 | bh = vget_high_u64(b.native()); |
69 | a = vcombine_u64(al, bl); |
70 | b = vcombine_u64(ah, bh); |
71 | } |
72 | |
73 | static SIMDPP_INL |
74 | uint64x2 zip2_lo(const uint64x2& ca, const uint64x2& cb) |
75 | { |
76 | uint64<2> a = ca, b = cb; |
77 | transpose2(a, b); |
78 | return a; |
79 | } |
80 | |
81 | static SIMDPP_INL |
82 | uint64x2 zip2_hi(const uint64x2& ca, const uint64x2& cb) |
83 | { |
84 | uint64<2> a = ca, b = cb; |
85 | transpose2(a, b); |
86 | return b; |
87 | } |
88 | |
89 | } // namespace neon |
90 | } // namespace detail |
91 | } // namespace SIMDPP_ARCH_NAMESPACE |
92 | } // namespace simdpp |
93 | |
94 | #endif |
95 | #endif |
96 | |