Implement sign() builtin

llvm-svn: 192384
This commit is contained in:
Tom Stellard 2013-10-10 19:08:56 +00:00
parent 6c7b86c106
commit 436bf70519
4 changed files with 36 additions and 0 deletions

View File

@ -86,6 +86,9 @@
#include <clc/shared/vload.h>
#include <clc/shared/vstore.h>
/* 6.11.4 Common Functions */
#include <clc/common/sign.h>
/* 6.11.5 Geometric Functions */
#include <clc/geometric/cross.h>
#include <clc/geometric/dot.h>

View File

@ -0,0 +1,5 @@
#define __CLC_FUNCTION sign
#define __CLC_BODY <clc/math/unary_decl.inc>
#include <clc/math/gentype.inc>
#undef __CLC_FUNCTION
#undef __CLC_BODY

View File

@ -1,5 +1,6 @@
atomic/atomic_impl.ll
convert.cl
common/sign.cl
geometric/cross.cl
geometric/dot.cl
geometric/length.cl

View File

@ -0,0 +1,27 @@
#include <clc/clc.h>
#define SIGN(TYPE, F) \
_CLC_DEF _CLC_OVERLOAD TYPE sign(TYPE x) { \
if (isnan(x)) { \
return 0.0F; \
} \
if (x > 0.0F) { \
return 1.0F; \
} \
if (x < 0.0F) { \
return -1.0F; \
} \
return x; /* -0.0 or +0.0 */ \
}
SIGN(float, f)
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, sign, float)
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
SIGN(double, )
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, sign, double)
#endif