File tree Expand file tree Collapse file tree 8 files changed +46
-43
lines changed Expand file tree Collapse file tree 8 files changed +46
-43
lines changed Original file line number Diff line number Diff line change 1+ #ifndef __CLC_INTEGER_CLC_ROTATE_H__
2+ #define __CLC_INTEGER_CLC_ROTATE_H__
3+
4+ #define __CLC_FUNCTION __clc_rotate
5+ #define __CLC_BODY <clc/shared/binary_decl.inc>
6+
7+ #include <clc/integer/gentype.inc>
8+
9+ #undef __CLC_BODY
10+ #undef __CLC_FUNCTION
11+
12+ #endif // __CLC_INTEGER_CLC_ROTATE_H__
Original file line number Diff line number Diff line change 77../generic/integer/clc_mul_hi.cl
88../generic/integer/clc_popcount.cl
99../generic/integer/clc_rhadd.cl
10+ ../generic/integer/clc_rotate.cl
1011../generic/integer/clc_sub_sat.cl
1112../generic/integer/clc_upsample.cl
1213../generic/math/clc_ceil.cl
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ integer/clc_mul24.cl
1313integer/clc_mul_hi.cl
1414integer/clc_popcount.cl
1515integer/clc_rhadd.cl
16+ integer/clc_rotate.cl
1617integer/clc_sub_sat.cl
1718integer/clc_upsample.cl
1819math/clc_ceil.cl
Original file line number Diff line number Diff line change 1+ #include <clc/internal/clc.h>
2+ #include <clc/utils.h>
3+
4+ #define __CLC_BODY <clc_rotate.inc>
5+ #include <clc/integer/gentype.inc>
Original file line number Diff line number Diff line change 1+ #define __CLC_AS_GENTYPE (x ) __CLC_XCONCAT(__clc_as_, __CLC_GENTYPE)(x)
2+ #define __CLC_AS_U_GENTYPE (x ) __CLC_XCONCAT(__clc_as_, __CLC_U_GENTYPE)(x)
3+
4+ // The rotate(A, B) builtin left-shifts corresponding to the usual OpenCL shift
5+ // modulo rules. These rules state that A is left-shifted by the log2(N) least
6+ // significant bits in B when viewed as an unsigned integer value. Thus we don't
7+ // have to worry about signed shift amounts, and can perform the computation in
8+ // unsigned types.
9+ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_rotate (__CLC_GENTYPE x,
10+ __CLC_GENTYPE n) {
11+ __CLC_U_GENTYPE x_as_u = __CLC_AS_U_GENTYPE (x);
12+ __CLC_U_GENTYPE mask = (__CLC_U_GENTYPE)(__CLC_GENSIZE - 1 );
13+
14+ __CLC_U_GENTYPE lshift_amt = __CLC_AS_U_GENTYPE (n) & mask;
15+
16+ __CLC_U_GENTYPE rshift_amt =
17+ (((__CLC_U_GENTYPE)__CLC_GENSIZE - lshift_amt) & mask);
18+
19+ __CLC_U_GENTYPE result = (x_as_u << lshift_amt) | (x_as_u >> rshift_amt);
20+
21+ return __CLC_AS_GENTYPE (result);
22+ }
Original file line number Diff line number Diff line change 1111../generic/integer/clc_mul_hi.cl
1212../generic/integer/clc_popcount.cl
1313../generic/integer/clc_rhadd.cl
14+ ../generic/integer/clc_rotate.cl
1415../generic/integer/clc_sub_sat.cl
1516../generic/integer/clc_upsample.cl
1617../generic/math/clc_ceil.cl
Original file line number Diff line number Diff line change 11#include <clc/clc.h>
2+ #include <clc/integer/clc_rotate.h>
3+
4+ #define FUNCTION rotate
5+ #define __CLC_BODY <clc/shared/binary_def.inc>
26
3- #define __CLC_BODY <rotate.inc>
47#include <clc/integer/gentype.inc>
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments