1 | /* Copyright (C) 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_DETAIL_SHUFFLE_SHUFFLE_MASK_H |
9 | #define LIBSIMDPP_SIMDPP_DETAIL_SHUFFLE_SHUFFLE_MASK_H |
10 | |
11 | #ifndef LIBSIMDPP_SIMD_H |
12 | #error "This file must be included through simd.h" |
13 | #endif |
14 | |
15 | #if SIMDPP_LITTLE_ENDIAN |
16 | #define SIMDPP_VSX_SHUFFLE_MASK_2x2(x0, x1) ((((x0) << 1) | (x1)) & 0x3) |
17 | #else |
18 | #define SIMDPP_VSX_SHUFFLE_MASK_2x2(x0, x1) ((((x1) << 1) | (x0)) & 0x3) |
19 | #endif |
20 | |
21 | #define SIMDPP_SHUFFLE_MASK_2x2(x0, x1) ((((x1) << 1) | (x0)) & 0x3) |
22 | |
23 | #define SIMDPP_SHUFFLE_MASK_2x2_2(x0, x1) \ |
24 | ((SIMDPP_SHUFFLE_MASK_2x2(x0, x1) << 2) | \ |
25 | SIMDPP_SHUFFLE_MASK_2x2(x0, x1)) |
26 | |
27 | #define SIMDPP_SHUFFLE_MASK_2x2_4(x0, x1) \ |
28 | ((SIMDPP_SHUFFLE_MASK_2x2_2(x0, x1) << 4) | \ |
29 | SIMDPP_SHUFFLE_MASK_2x2_2(x0, x1)) |
30 | |
31 | #define SIMDPP_SHUFFLE_MASK_4x2(x0, x1, x2, x3) \ |
32 | ((((x3) << 3) | ((x2) << 2) | ((x1) << 1) | (x0)) & 0xf) |
33 | |
34 | #define SIMDPP_SHUFFLE_MASK_4x2_2(x0, x1, x2, x3) \ |
35 | ((SIMDPP_SHUFFLE_MASK_4x2(x0, x1, x2, x3) << 4) | \ |
36 | SIMDPP_SHUFFLE_MASK_4x2(x0, x1, x2, x3)) |
37 | |
38 | #define SIMDPP_SHUFFLE_MASK_4x2_4(x0, x1, x2, x3) \ |
39 | ((SIMDPP_SHUFFLE_MASK_4x2_2(x0, x1, x2, x3) << 8) | \ |
40 | SIMDPP_SHUFFLE_MASK_4x2_2(x0, x1, x2, x3)) |
41 | |
42 | #define SIMDPP_SHUFFLE_MASK_4x4(x0, x1, x2, x3) \ |
43 | ((((x3) << 6) | ((x2) << 4) | ((x1) << 2) | (x0)) & 0xff) |
44 | |
45 | #endif |
46 | |