1 //===-- generic/include/clc/misc/shuffle2.h ------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #define _CLC_SHUFFLE2_DECL(TYPE, MASKTYPE, RETTYPE) \
10 _CLC_OVERLOAD _CLC_DECL RETTYPE shuffle2(TYPE x, TYPE y, MASKTYPE mask);
12 //Return type is same base type as the input type, with the same vector size as the mask.
13 //Elements in the mask must be the same size (number of bits) as the input value.
14 //E.g. char8 ret = shuffle2(char2 x, char2 y, uchar8 mask);
16 #define _CLC_VECTOR_SHUFFLE2_MASKSIZE(INBASE, INTYPE, MASKTYPE) \
17 _CLC_SHUFFLE2_DECL(INTYPE, MASKTYPE##2, INBASE##2) \
18 _CLC_SHUFFLE2_DECL(INTYPE, MASKTYPE##4, INBASE##4) \
19 _CLC_SHUFFLE2_DECL(INTYPE, MASKTYPE##8, INBASE##8) \
20 _CLC_SHUFFLE2_DECL(INTYPE, MASKTYPE##16, INBASE##16) \
22 #define _CLC_VECTOR_SHUFFLE2_INSIZE(TYPE, MASKTYPE) \
23 _CLC_VECTOR_SHUFFLE2_MASKSIZE(TYPE, TYPE##2, MASKTYPE) \
24 _CLC_VECTOR_SHUFFLE2_MASKSIZE(TYPE, TYPE##4, MASKTYPE) \
25 _CLC_VECTOR_SHUFFLE2_MASKSIZE(TYPE, TYPE##8, MASKTYPE) \
26 _CLC_VECTOR_SHUFFLE2_MASKSIZE(TYPE, TYPE##16, MASKTYPE) \
28 _CLC_VECTOR_SHUFFLE2_INSIZE(char, uchar)
29 _CLC_VECTOR_SHUFFLE2_INSIZE(short, ushort
)
30 _CLC_VECTOR_SHUFFLE2_INSIZE(int, uint
)
31 _CLC_VECTOR_SHUFFLE2_INSIZE(long, ulong
)
32 _CLC_VECTOR_SHUFFLE2_INSIZE(uchar
, uchar
)
33 _CLC_VECTOR_SHUFFLE2_INSIZE(ushort
, ushort
)
34 _CLC_VECTOR_SHUFFLE2_INSIZE(uint
, uint
)
35 _CLC_VECTOR_SHUFFLE2_INSIZE(ulong
, ulong
)
36 _CLC_VECTOR_SHUFFLE2_INSIZE(float, uint
)
38 _CLC_VECTOR_SHUFFLE2_INSIZE(double, ulong
)
41 _CLC_VECTOR_SHUFFLE2_INSIZE(half
, ushort
)
44 #undef _CLC_SHUFFLE_DECL
45 #undef _CLC_VECTOR_SHUFFLE2_MASKSIZE
46 #undef _CLC_VECTOR_SHUFFLE2_INSIZE