[cfe-commits] [libclc] r165386 - in /libclc/trunk/generic: include/clc/clc.h include/clc/relational/any.h lib/SOURCES lib/relational/ lib/relational/any.cl
Peter Collingbourne
peter at pcc.me.uk
Sun Oct 7 20:39:21 PDT 2012
Author: pcc
Date: Sun Oct 7 22:39:21 2012
New Revision: 165386
URL: http://llvm.org/viewvc/llvm-project?rev=165386&view=rev
Log:
Implement any() builtin. Patch by Tom Stellard!
Added:
libclc/trunk/generic/include/clc/relational/any.h
libclc/trunk/generic/lib/relational/
libclc/trunk/generic/lib/relational/any.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=165386&r1=165385&r2=165386&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Sun Oct 7 22:39:21 2012
@@ -69,6 +69,7 @@
#include <clc/geometric/normalize.h>
/* 6.11.6 Relational Functions */
+#include <clc/relational/any.h>
#include <clc/relational/select.h>
/* 6.11.8 Synchronization Functions */
Added: libclc/trunk/generic/include/clc/relational/any.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/any.h?rev=165386&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/relational/any.h (added)
+++ libclc/trunk/generic/include/clc/relational/any.h Sun Oct 7 22:39:21 2012
@@ -0,0 +1,16 @@
+
+#define _CLC_ANY_DECL(TYPE) \
+ _CLC_OVERLOAD _CLC_DECL int any(TYPE v);
+
+#define _CLC_VECTOR_ANY_DECL(TYPE) \
+ _CLC_ANY_DECL(TYPE) \
+ _CLC_ANY_DECL(TYPE##2) \
+ _CLC_ANY_DECL(TYPE##3) \
+ _CLC_ANY_DECL(TYPE##4) \
+ _CLC_ANY_DECL(TYPE##8) \
+ _CLC_ANY_DECL(TYPE##16)
+
+_CLC_VECTOR_ANY_DECL(char)
+_CLC_VECTOR_ANY_DECL(short)
+_CLC_VECTOR_ANY_DECL(int)
+_CLC_VECTOR_ANY_DECL(long)
Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=165386&r1=165385&r2=165386&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Sun Oct 7 22:39:21 2012
@@ -12,5 +12,6 @@
integer/sub_sat_impl.ll
math/hypot.cl
math/mad.cl
+relational/any.cl
workitem/get_global_id.cl
workitem/get_global_size.cl
Added: libclc/trunk/generic/lib/relational/any.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/any.cl?rev=165386&view=auto
==============================================================================
--- libclc/trunk/generic/lib/relational/any.cl (added)
+++ libclc/trunk/generic/lib/relational/any.cl Sun Oct 7 22:39:21 2012
@@ -0,0 +1,30 @@
+#include <clc/clc.h>
+
+#define _CLC_ANY(v) (((v) >> ((sizeof(v) * 8) - 1)) & 0x1)
+#define _CLC_ANY2(v) (_CLC_ANY((v).s0) | _CLC_ANY((v).s1))
+#define _CLC_ANY3(v) (_CLC_ANY2((v)) | _CLC_ANY((v).s2))
+#define _CLC_ANY4(v) (_CLC_ANY3((v)) | _CLC_ANY((v).s3))
+#define _CLC_ANY8(v) (_CLC_ANY4((v)) | _CLC_ANY((v).s4) | _CLC_ANY((v).s5) \
+ | _CLC_ANY((v).s6) | _CLC_ANY((v).s7))
+#define _CLC_ANY16(v) (_CLC_ANY8((v)) | _CLC_ANY((v).s8) | _CLC_ANY((v).s9) \
+ | _CLC_ANY((v).sA) | _CLC_ANY((v).sB) \
+ | _CLC_ANY((v).sC) | _CLC_ANY((v).sD) \
+ | _CLC_ANY((v).sE) | _CLC_ANY((v).sf))
+
+
+#define ANY_ID(TYPE) \
+ _CLC_OVERLOAD _CLC_DEF int any(TYPE v)
+
+#define ANY_VECTORIZE(TYPE) \
+ ANY_ID(TYPE) { return _CLC_ANY(v); } \
+ ANY_ID(TYPE##2) { return _CLC_ANY2(v); } \
+ ANY_ID(TYPE##3) { return _CLC_ANY3(v); } \
+ ANY_ID(TYPE##4) { return _CLC_ANY4(v); } \
+ ANY_ID(TYPE##8) { return _CLC_ANY8(v); } \
+ ANY_ID(TYPE##16) { return _CLC_ANY16(v); }
+
+ANY_VECTORIZE(char)
+ANY_VECTORIZE(short)
+ANY_VECTORIZE(int)
+ANY_VECTORIZE(long)
+
More information about the cfe-commits
mailing list