[libclc] r192384 - Implement sign() builtin
Tom Stellard
thomas.stellard at amd.com
Thu Oct 10 12:08:57 PDT 2013
Author: tstellar
Date: Thu Oct 10 14:08:56 2013
New Revision: 192384
URL: http://llvm.org/viewvc/llvm-project?rev=192384&view=rev
Log:
Implement sign() builtin
Added:
libclc/trunk/generic/include/clc/common/
libclc/trunk/generic/include/clc/common/sign.h
libclc/trunk/generic/lib/common/
libclc/trunk/generic/lib/common/sign.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES
Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=192384&r1=192383&r2=192384&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Oct 10 14:08:56 2013
@@ -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>
Added: libclc/trunk/generic/include/clc/common/sign.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/common/sign.h?rev=192384&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/common/sign.h (added)
+++ libclc/trunk/generic/include/clc/common/sign.h Thu Oct 10 14:08:56 2013
@@ -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
Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=192384&r1=192383&r2=192384&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Oct 10 14:08:56 2013
@@ -1,5 +1,6 @@
atomic/atomic_impl.ll
convert.cl
+common/sign.cl
geometric/cross.cl
geometric/dot.cl
geometric/length.cl
Added: libclc/trunk/generic/lib/common/sign.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/common/sign.cl?rev=192384&view=auto
==============================================================================
--- libclc/trunk/generic/lib/common/sign.cl (added)
+++ libclc/trunk/generic/lib/common/sign.cl Thu Oct 10 14:08:56 2013
@@ -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
More information about the cfe-commits
mailing list