Skip to content

Commit 65713ca

Browse files
committed
[libclc] Move several integer functions to CLC library
This commit moves over the OpenCL clz, hadd, mad24, mad_hi, mul24, mul_hi, popcount, rhadd, and upsample builtins to the CLC library. There are no changes to any target's CLC libraries. The OpenCL mad_hi builtin wasn't previously publicly available from the CLC libraries, as it was hash-defined to mul_hi in the header files. That issue has been fixed, and mad_hi is now exposed. The custom AMD implementation/workaround for popcount has been removed as it was only valid for clang < 7. There are still two integer functions which haven't been moved over. The OpenCL add_sat, sub_sat, and mad_sat builtins require saturating conversion builtins which haven't yet been ported.
1 parent e0a79ee commit 65713ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+780
-301
lines changed

libclc/amdgcn/lib/SOURCES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
cl_khr_int64_extended_atomics/minmax_helpers.ll
2-
integer/popcount.cl
32
math/fmax.cl
43
math/fmin.cl
54
math/ldexp.cl

libclc/amdgcn/lib/integer/popcount.cl

Lines changed: 0 additions & 6 deletions
This file was deleted.

libclc/amdgcn/lib/integer/popcount.inc

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
2+
__CLC_GENTYPE y);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef __CLC_INTEGER_CLC_CLZ_H__
2+
#define __CLC_INTEGER_CLC_CLZ_H__
3+
4+
#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
5+
// clspv and spir-v targets provide their own OpenCL-compatible clz
6+
#define __clc_clz clz
7+
#else
8+
9+
#include <clc/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#define FUNCTION __clc_clz
13+
#define __CLC_BODY "unary_decl.h"
14+
15+
#include <clc/integer/gentype.inc>
16+
17+
#undef FUNCTION
18+
19+
#endif
20+
21+
#endif // __CLC_INTEGER_CLC_CLZ_H__
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef __CLC_INTEGER_CLC_HADD_H__
2+
#define __CLC_INTEGER_CLC_HADD_H__
3+
4+
#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
5+
// clspv and spir-v targets provide their own OpenCL-compatible hadd
6+
#define __clc_hadd hadd
7+
#else
8+
9+
#include <clc/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#define FUNCTION __clc_hadd
13+
#define __CLC_BODY "binary_decl.h"
14+
15+
#include <clc/integer/gentype.inc>
16+
17+
#undef FUNCTION
18+
19+
#endif
20+
21+
#endif // __CLC_INTEGER_CLC_HADD_H__
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef __CLC_INTEGER_CLC_MAD24_H__
2+
#define __CLC_INTEGER_CLC_MAD24_H__
3+
4+
#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
5+
// clspv and spir-v targets provide their own OpenCL-compatible mad24
6+
#define __clc_mad24 mad24
7+
#else
8+
9+
#include <clc/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#define FUNCTION __clc_mad24
13+
#define __CLC_BODY "ternary_decl.h"
14+
15+
#include <clc/integer/gentype24.inc>
16+
17+
#undef FUNCTION
18+
19+
#endif
20+
21+
#endif // __CLC_INTEGER_CLC_MAD24_H__
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef __CLC_INTEGER_CLC_MAD_HI_H__
2+
#define __CLC_INTEGER_CLC_MAD_HI_H__
3+
4+
#include <clc/integer/clc_mul_hi.h>
5+
6+
#define __clc_mad_hi(a, b, c) (__clc_mul_hi((a), (b)) + (c))
7+
8+
#endif // __CLC_INTEGER_CLC_MAD_HI_H__
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef __CLC_INTEGER_CLC_MUL24_H__
2+
#define __CLC_INTEGER_CLC_MUL24_H__
3+
4+
#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
5+
// clspv and spir-v targets provide their own OpenCL-compatible mul24
6+
#define __clc_mul24 mul24
7+
#else
8+
9+
#include <clc/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#define FUNCTION __clc_mul24
13+
#define __CLC_BODY "binary_decl.h"
14+
15+
#include <clc/integer/gentype24.inc>
16+
17+
#undef FUNCTION
18+
19+
#endif
20+
21+
#endif // __CLC_INTEGER_CLC_MUL24_H__
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef __CLC_INTEGER_CLC_MUL_HI_H__
2+
#define __CLC_INTEGER_CLC_MUL_HI_H__
3+
4+
#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
5+
// clspv and spir-v targets provide their own OpenCL-compatible mul_hi
6+
#define __clc_mul_hi mul_hi
7+
#else
8+
9+
#include <clc/clcfunc.h>
10+
#include <clc/clctypes.h>
11+
12+
#define FUNCTION __clc_mul_hi
13+
#define __CLC_BODY "binary_decl.h"
14+
15+
#include <clc/integer/gentype.inc>
16+
17+
#undef FUNCTION
18+
19+
#endif
20+
21+
#endif // __CLC_INTEGER_CLC_MUL_HI_H__

0 commit comments

Comments
 (0)