Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 1 addition & 34 deletions libclc/clc/lib/generic/integer/clc_clz.cl
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,5 @@
#include <clc/integer/clc_clz.h>
#include <clc/internal/clc.h>

_CLC_OVERLOAD _CLC_DEF char __clc_clz(char x) {
return __clc_clz((ushort)(uchar)x) - 8;
}

_CLC_OVERLOAD _CLC_DEF uchar __clc_clz(uchar x) {
return __clc_clz((ushort)x) - 8;
}

_CLC_OVERLOAD _CLC_DEF short __clc_clz(short x) {
return x ? __builtin_clzs(x) : 16;
}

_CLC_OVERLOAD _CLC_DEF ushort __clc_clz(ushort x) {
return x ? __builtin_clzs(x) : 16;
}

_CLC_OVERLOAD _CLC_DEF int __clc_clz(int x) {
return x ? __builtin_clz(x) : 32;
}

_CLC_OVERLOAD _CLC_DEF uint __clc_clz(uint x) {
return x ? __builtin_clz(x) : 32;
}

_CLC_OVERLOAD _CLC_DEF long __clc_clz(long x) {
return x ? __builtin_clzl(x) : 64;
}

_CLC_OVERLOAD _CLC_DEF ulong __clc_clz(ulong x) {
return x ? __builtin_clzl(x) : 64;
}

#define __CLC_FUNCTION __clc_clz
#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
#define __CLC_BODY <clc_clz.inc>
#include <clc/integer/gentype.inc>
11 changes: 11 additions & 0 deletions libclc/clc/lib/generic/integer/clc_clz.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_clz(__CLC_GENTYPE x) {
return __builtin_elementwise_ctlz(x, (__CLC_GENTYPE)__CLC_GENSIZE);
}
31 changes: 1 addition & 30 deletions libclc/clc/lib/generic/integer/clc_ctz.cl
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,5 @@
#include <clc/integer/clc_ctz.h>
#include <clc/internal/clc.h>

_CLC_OVERLOAD _CLC_DEF char __clc_ctz(char x) {
return __clc_ctz(__clc_as_uchar(x));
}

_CLC_OVERLOAD _CLC_DEF uchar __clc_ctz(uchar x) { return __builtin_ctzg(x, 8); }

_CLC_OVERLOAD _CLC_DEF short __clc_ctz(short x) {
return __clc_ctz(__clc_as_ushort(x));
}

_CLC_OVERLOAD _CLC_DEF ushort __clc_ctz(ushort x) {
return __builtin_ctzg(x, 16);
}

_CLC_OVERLOAD _CLC_DEF int __clc_ctz(int x) {
return __clc_ctz(__clc_as_uint(x));
}

_CLC_OVERLOAD _CLC_DEF uint __clc_ctz(uint x) { return __builtin_ctzg(x, 32); }

_CLC_OVERLOAD _CLC_DEF long __clc_ctz(long x) {
return __clc_ctz(__clc_as_ulong(x));
}

_CLC_OVERLOAD _CLC_DEF ulong __clc_ctz(ulong x) {
return __builtin_ctzg(x, 64);
}

#define __CLC_FUNCTION __clc_ctz
#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
#define __CLC_BODY <clc_ctz.inc>
#include <clc/integer/gentype.inc>
11 changes: 11 additions & 0 deletions libclc/clc/lib/generic/integer/clc_ctz.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_ctz(__CLC_GENTYPE x) {
return __builtin_elementwise_cttz(x, (__CLC_GENTYPE)__CLC_GENSIZE);
}
Loading