From e78344dfae4abb858bb04bc1fcafb57f4bd9f49d Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 26 Jun 2013 18:21:55 +0000 Subject: libclc: Implement clz() builtin Squashed commit of the following: commit a0df0a0e86c55c1bdc0b9c0f5a739e5adef4b056 Author: Aaron Watry Date: Mon Apr 15 18:42:04 2013 -0500 libclc: Rename clz.ll to clz_if.ll to ensure it gets built. configure.py treats files that have the same name with the .cl and .ll extensions as overriding eachother. E.g. If you have clz.cl and clz.ll both specified to be built in the same SOURCES file, only the first file listed will actually be built. Since the contents of clz.ll were an interface that is implemented in clz_impl.ll, rename clz.ll to clz_if.ll to make sure that the interface is built. commit 931b62bed05c58f737de625bd415af09571a6a5a Author: Aaron Watry Date: Sat Apr 13 12:32:54 2013 -0500 libclc: llvm assembly implementation of clz Untested... currently crashes in the same manner as add_sat. commit 6ef0b7b0b6d2e5584086b4b9a9243743b2e0538f Author: Aaron Watry Date: Sat Mar 23 12:35:27 2013 -0500 libclc: Add stub clz builtin For scalar int/uint, attempt to use the clz llvm builtin.. for all others return 0 until an actual implementation is finished. Patch by: Aaron Watry llvm-svn: 185004 --- libclc/generic/lib/integer/clz.cl | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 libclc/generic/lib/integer/clz.cl (limited to 'libclc/generic/lib/integer/clz.cl') diff --git a/libclc/generic/lib/integer/clz.cl b/libclc/generic/lib/integer/clz.cl new file mode 100644 index 00000000000..83ef2dd800c --- /dev/null +++ b/libclc/generic/lib/integer/clz.cl @@ -0,0 +1,52 @@ +#include + +// From clz.ll +_CLC_DECL char __clc_clz_s8(char); +_CLC_DECL uchar __clc_clz_u8(uchar); +_CLC_DECL short __clc_clz_s16(short); +_CLC_DECL ushort __clc_clz_u16(ushort); +_CLC_DECL int __clc_clz_s32(int); +_CLC_DECL uint __clc_clz_u32(uint); +_CLC_DECL long __clc_clz_s64(long); +_CLC_DECL ulong __clc_clz_u64(ulong); + +_CLC_OVERLOAD _CLC_DEF char clz(char x) { + return __clc_clz_s8(x); +} + +_CLC_OVERLOAD _CLC_DEF uchar clz(uchar x) { + return __clc_clz_u8(x); +} + +_CLC_OVERLOAD _CLC_DEF short clz(short x) { + return __clc_clz_s16(x); +} + +_CLC_OVERLOAD _CLC_DEF ushort clz(ushort x) { + return __clc_clz_u16(x); +} + +_CLC_OVERLOAD _CLC_DEF int clz(int x) { + return __clc_clz_s32(x); +} + +_CLC_OVERLOAD _CLC_DEF uint clz(uint x) { + return __clc_clz_u32(x); +} + +_CLC_OVERLOAD _CLC_DEF long clz(long x) { + return __clc_clz_s64(x); +} + +_CLC_OVERLOAD _CLC_DEF ulong clz(ulong x) { + return __clc_clz_u64(x); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, char, clz, char) +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, uchar, clz, uchar) +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, short, clz, short) +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, ushort, clz, ushort) +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, int, clz, int) +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, uint, clz, uint) +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, long, clz, long) +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, ulong, clz, ulong) -- cgit v1.2.3