Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions libclc/clc/include/clc/integer/clc_bit_reverse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_INTEGER_CLC_BIT_REVERSE_H__
#define __CLC_INTEGER_CLC_BIT_REVERSE_H__

#define FUNCTION __clc_bit_reverse
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/integer/gentype.inc>

#undef FUNCTION

#endif // __CLC_INTEGER_CLC_BIT_REVERSE_H__
10 changes: 10 additions & 0 deletions libclc/clc/include/clc/integer/clc_bitfield_extract.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//===----------------------------------------------------------------------===//
//
// 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_DECL __RETTYPE FUNCTION(__CLC_GENTYPE base, uint offset,
uint count);
23 changes: 23 additions & 0 deletions libclc/clc/include/clc/integer/clc_bitfield_extract_signed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_INTEGER_CLC_BITFIELD_EXTRACT_SIGNED_H__
#define __CLC_INTEGER_CLC_BITFIELD_EXTRACT_SIGNED_H__

#include <clc/internal/clc.h>

#define FUNCTION __clc_bitfield_extract_signed
#define __RETTYPE __CLC_S_GENTYPE

#define __CLC_BODY <clc/integer/clc_bitfield_extract.inc>
#include <clc/integer/gentype.inc>

#undef __RETTYPE
#undef FUNCTION

#endif // __CLC_INTEGER_CLC_BITFIELD_EXTRACT_SIGNED_H__
23 changes: 23 additions & 0 deletions libclc/clc/include/clc/integer/clc_bitfield_extract_unsigned.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_INTEGER_CLC_BITFIELD_EXTRACT_SIGNED_H__
#define __CLC_INTEGER_CLC_BITFIELD_EXTRACT_SIGNED_H__

#include <clc/internal/clc.h>

#define FUNCTION __clc_bitfield_extract_unsigned
#define __RETTYPE __CLC_U_GENTYPE

#define __CLC_BODY <clc/integer/clc_bitfield_extract.inc>
#include <clc/integer/gentype.inc>

#undef __RETTYPE
#undef FUNCTION

#endif // __CLC_INTEGER_CLC_BITFIELD_EXTRACT_SIGNED_H__
17 changes: 17 additions & 0 deletions libclc/clc/include/clc/integer/clc_bitfield_insert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_INTEGER_CLC_BITFIELD_INSERT_H__
#define __CLC_INTEGER_CLC_BITFIELD_INSERT_H__

#include <clc/internal/clc.h>

#define __CLC_BODY <clc/integer/clc_bitfield_insert.inc>
#include <clc/integer/gentype.inc>

#endif // __CLC_INTEGER_CLC_BITFIELD_INSERT_H__
10 changes: 10 additions & 0 deletions libclc/clc/include/clc/integer/clc_bitfield_insert.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//===----------------------------------------------------------------------===//
//
// 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_DECL __CLC_GENTYPE __clc_bitfield_insert(
__CLC_GENTYPE base, __CLC_GENTYPE insert, uint offset, uint count);
4 changes: 4 additions & 0 deletions libclc/clc/lib/generic/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ geometric/clc_normalize.cl
integer/clc_abs.cl
integer/clc_abs_diff.cl
integer/clc_add_sat.cl
integer/clc_bitfield_extract_signed.cl
integer/clc_bitfield_extract_unsigned.cl
integer/clc_bitfield_insert.cl
integer/clc_bit_reverse.cl
integer/clc_clz.cl
integer/clc_ctz.cl
integer/clc_hadd.cl
Expand Down
15 changes: 15 additions & 0 deletions libclc/clc/lib/generic/integer/clc_bit_reverse.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include <clc/integer/clc_bit_reverse.h>

#define FUNCTION __clc_bit_reverse
#define __IMPL_FUNCTION(x) __builtin_elementwise_bitreverse
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/integer/gentype.inc>
12 changes: 12 additions & 0 deletions libclc/clc/lib/generic/integer/clc_bitfield_extract_signed.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include <clc/integer/clc_bitfield_extract_signed.h>

#define __CLC_BODY <clc_bitfield_extract_signed.inc>
#include <clc/integer/gentype.inc>
19 changes: 19 additions & 0 deletions libclc/clc/lib/generic/integer/clc_bitfield_extract_signed.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// 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_S_GENTYPE
__clc_bitfield_extract_signed(__CLC_GENTYPE base, uint offset, uint count) {
if (count == 0)
return 0;
__CLC_U_GENTYPE x = __CLC_AS_U_GENTYPE(base)
<< (__CLC_GENSIZE - offset - count);
// Implement an arithmetic shift right.
__CLC_U_GENTYPE s = -(x >> (__CLC_GENSIZE - 1));
__CLC_U_GENTYPE result = ((s ^ x) >> (__CLC_GENSIZE - count)) ^ s;
return __CLC_AS_S_GENTYPE(result);
}
12 changes: 12 additions & 0 deletions libclc/clc/lib/generic/integer/clc_bitfield_extract_unsigned.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include <clc/integer/clc_bitfield_extract_unsigned.h>

#define __CLC_BODY <clc_bitfield_extract_unsigned.inc>
#include <clc/integer/gentype.inc>
16 changes: 16 additions & 0 deletions libclc/clc/lib/generic/integer/clc_bitfield_extract_unsigned.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===----------------------------------------------------------------------===//
//
// 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_U_GENTYPE
__clc_bitfield_extract_unsigned(__CLC_GENTYPE base, uint offset, uint count) {
if (count == 0)
return 0;
__CLC_U_GENTYPE result = __CLC_AS_U_GENTYPE(base)
<< (__CLC_GENSIZE - offset - count);
return result >> (__CLC_GENSIZE - count);
}
12 changes: 12 additions & 0 deletions libclc/clc/lib/generic/integer/clc_bitfield_insert.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include <clc/integer/clc_bitfield_insert.h>

#define __CLC_BODY <clc_bitfield_insert.inc>
#include <clc/integer/gentype.inc>
20 changes: 20 additions & 0 deletions libclc/clc/lib/generic/integer/clc_bitfield_insert.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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_bitfield_insert(__CLC_GENTYPE base,
__CLC_GENTYPE insert,
uint offset,
uint count) {
__CLC_U_GENTYPE u_base = __CLC_AS_U_GENTYPE(base);
__CLC_U_GENTYPE u_insert = __CLC_AS_U_GENTYPE(insert);
__CLC_U_GENTYPE mask = (((__CLC_U_GENTYPE)1 << count) - (__CLC_U_GENTYPE)1)
<< offset;
mask = count < __CLC_GENSIZE ? mask : ~(__CLC_U_GENTYPE)0;
__CLC_U_GENTYPE result = ((u_insert << offset) & mask) | (u_base & ~mask);
return __CLC_AS_GENTYPE(result);
}
21 changes: 21 additions & 0 deletions libclc/opencl/include/clc/opencl/integer/bit_reverse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_OPENCL_INTEGER_BIT_REVERSE_H__
#define __CLC_OPENCL_INTEGER_BIT_REVERSE_H__

#include <clc/opencl/opencl-base.h>

#define FUNCTION bit_reverse
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/integer/gentype.inc>

#undef FUNCTION

#endif // __CLC_OPENCL_INTEGER_BIT_REVERSE_H__
10 changes: 10 additions & 0 deletions libclc/opencl/include/clc/opencl/integer/bitfield_extract.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//===----------------------------------------------------------------------===//
//
// 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_DECL __RETTYPE FUNCTION(__CLC_GENTYPE base, uint offset,
uint count);
23 changes: 23 additions & 0 deletions libclc/opencl/include/clc/opencl/integer/bitfield_extract_signed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_OPENCL_INTEGER_BITFIELD_EXTRACT_SIGNED_H__
#define __CLC_OPENCL_INTEGER_BITFIELD_EXTRACT_SIGNED_H__

#include <clc/opencl/opencl-base.h>

#define FUNCTION bitfield_extract_signed
#define __RETTYPE __CLC_S_GENTYPE

#define __CLC_BODY <clc/opencl/integer/bitfield_extract.inc>
#include <clc/integer/gentype.inc>

#undef __RETTYPE
#undef FUNCTION

#endif // __CLC_OPENCL_INTEGER_BITFIELD_EXTRACT_SIGNED_H__
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_OPENCL_INTEGER_BITFIELD_EXTRACT_UNSIGNED_H__
#define __CLC_OPENCL_INTEGER_BITFIELD_EXTRACT_UNSIGNED_H__

#include <clc/opencl/opencl-base.h>

#define FUNCTION bitfield_extract_unsigned
#define __RETTYPE __CLC_U_GENTYPE

#define __CLC_BODY <clc/opencl/integer/bitfield_extract.inc>
#include <clc/integer/gentype.inc>

#undef __RETTYPE
#undef FUNCTION

#endif // __CLC_OPENCL_INTEGER_BITFIELD_EXTRACT_UNSIGNED_H__
19 changes: 19 additions & 0 deletions libclc/opencl/include/clc/opencl/integer/bitfield_insert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_OPENCL_INTEGER_BITFIELD_INSERT_H__
#define __CLC_OPENCL_INTEGER_BITFIELD_INSERT_H__

#include <clc/opencl/opencl-base.h>

#define __CLC_BODY <clc/integer/clc_bitfield_insert.inc>
#include <clc/integer/gentype.inc>

#undef FUNCTION

#endif // __CLC_OPENCL_INTEGER_BITFIELD_INSERT_H__
11 changes: 11 additions & 0 deletions libclc/opencl/include/clc/opencl/integer/bitfield_insert.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_DECL __CLC_GENTYPE bitfield_insert(__CLC_GENTYPE base,
__CLC_GENTYPE insert,
uint offset, uint count);
4 changes: 4 additions & 0 deletions libclc/opencl/lib/generic/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ geometric/normalize.cl
integer/abs.cl
integer/abs_diff.cl
integer/add_sat.cl
integer/bitfield_extract_signed.cl
integer/bitfield_extract_unsigned.cl
integer/bitfield_insert.cl
integer/bit_reverse.cl
integer/clz.cl
integer/ctz.cl
integer/hadd.cl
Expand Down
19 changes: 19 additions & 0 deletions libclc/opencl/lib/generic/integer/bit_reverse.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifdef cl_khr_extended_bit_ops

#include <clc/integer/clc_bit_reverse.h>
#include <clc/opencl/integer/bit_reverse.h>

#define FUNCTION bit_reverse
#define __CLC_BODY <clc/shared/unary_def.inc>

#include <clc/integer/gentype.inc>

#endif // cl_khr_extended_bit_ops
16 changes: 16 additions & 0 deletions libclc/opencl/lib/generic/integer/bitfield_extract.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __IMPL_FUNCTION
#define __IMPL_FUNCTION(x) __CLC_CONCAT(__clc_, x)
#endif

_CLC_OVERLOAD _CLC_DEF __RETTYPE FUNCTION(__CLC_GENTYPE base, uint offset,
uint count) {
return __IMPL_FUNCTION(FUNCTION)(base, offset, count);
}
Loading
Loading