select: Add vector implementation

Passes CTS on Carrizo

Reviewed-by: Aaron Watry <awatry@gmail.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 326819
This commit is contained in:
Jan Vesely 2018-03-06 17:48:43 +00:00
parent 44f21978a2
commit ae156b66f8
5 changed files with 91 additions and 1 deletions

View File

@ -1 +1,11 @@
#define select(a, b, c) ((c) ? (b) : (a))
/* Duplciate these so we don't have to distribute utils.h */
#define __CLC_CONCAT(x, y) x ## y
#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)
#define __CLC_BODY <clc/relational/select.inc>
#include <clc/math/gentype.inc>
#define __CLC_BODY <clc/relational/select.inc>
#include <clc/integer/gentype.inc>
#undef __CLC_CONCAT
#undef __CLC_XCONCAT

View File

@ -0,0 +1,25 @@
#ifdef __CLC_SCALAR
#define __CLC_VECSIZE
#endif
#if __CLC_FPSIZE == 64
#define __CLC_S_GENTYPE __CLC_XCONCAT(long, __CLC_VECSIZE)
#define __CLC_U_GENTYPE __CLC_XCONCAT(ulong, __CLC_VECSIZE)
#elif __CLC_FPSIZE == 32
#define __CLC_S_GENTYPE __CLC_XCONCAT(int, __CLC_VECSIZE)
#define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE)
#elif __CLC_FPSIZE == 16
#define __CLC_S_GENTYPE __CLC_XCONCAT(char, __CLC_VECSIZE)
#define __CLC_U_GENTYPE __CLC_XCONCAT(uchar, __CLC_VECSIZE)
#endif
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_S_GENTYPE z);
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_U_GENTYPE z);
#ifdef __CLC_FPSIZE
#undef __CLC_S_GENTYPE
#undef __CLC_U_GENTYPE
#endif
#ifdef __CLC_SCALAR
#undef __CLC_VECSIZE
#endif

View File

@ -189,6 +189,7 @@ relational/isnormal.cl
relational/isnotequal.cl
relational/isordered.cl
relational/isunordered.cl
relational/select.cl
relational/signbit.cl
shared/clamp.cl
shared/max.cl

View File

@ -0,0 +1,7 @@
#include <clc/clc.h>
#include <utils.h>
#define __CLC_BODY <select.inc>
#include <clc/math/gentype.inc>
#define __CLC_BODY <select.inc>
#include <clc/integer/gentype.inc>

View File

@ -0,0 +1,47 @@
#ifdef __CLC_SCALAR
#define __CLC_VECSIZE
#endif
#if __CLC_FPSIZE == 64
#define __CLC_S_GENTYPE __CLC_XCONCAT(long, __CLC_VECSIZE)
#define __CLC_U_GENTYPE __CLC_XCONCAT(ulong, __CLC_VECSIZE)
#elif __CLC_FPSIZE == 32
#define __CLC_S_GENTYPE __CLC_XCONCAT(int, __CLC_VECSIZE)
#define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE)
#elif __CLC_FPSIZE == 16
#define __CLC_S_GENTYPE __CLC_XCONCAT(char, __CLC_VECSIZE)
#define __CLC_U_GENTYPE __CLC_XCONCAT(uchar, __CLC_VECSIZE)
#endif
#ifdef __CLC_FPSIZE
#define __CLC_GENSIZE __CLC_FPSIZE
#endif
#define __CLC_AS_S_GENTYPE __CLC_XCONCAT(as_, __CLC_S_GENTYPE)
#define __CLC_AS_GENTYPE __CLC_XCONCAT(as_, __CLC_GENTYPE)
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_S_GENTYPE z)
{
#ifdef __CLC_SCALAR
return z ? y : x;
#else
__CLC_S_GENTYPE bitmask = z >> (__CLC_GENSIZE - 1);
return __CLC_AS_GENTYPE(bitselect(__CLC_AS_S_GENTYPE(x), __CLC_AS_S_GENTYPE(y), bitmask));
#endif
}
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_U_GENTYPE z)
{
return select(x, y, __CLC_AS_S_GENTYPE(z));
}
#undef __CLC_AS_S_GENTYPE
#undef __CLC_AS_GENTYPE
#ifdef __CLC_FPSIZE
#undef __CLC_S_GENTYPE
#undef __CLC_U_GENTYPE
#undef __CLC_GENSIZE
#endif
#ifdef __CLC_SCALAR
#undef __CLC_VECSIZE
#endif