[libclc] r211046 - relational: Add isequal(floatN) builtin

Aaron Watry awatry at gmail.com
Mon Jun 16 12:53:57 PDT 2014


Author: awatry
Date: Mon Jun 16 14:53:57 2014
New Revision: 211046

URL: http://llvm.org/viewvc/llvm-project?rev=211046&view=rev
Log:
relational: Add isequal(floatN) builtin

Signed-off-by: Aaron Watry <awatry at gmail.com>
Reviewed-by: Tom Stellard <tom at stellard.net>

Added:
    libclc/trunk/generic/include/clc/relational/isequal.h
    libclc/trunk/generic/lib/relational/isequal.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=211046&r1=211045&r2=211046&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Mon Jun 16 14:53:57 2014
@@ -105,6 +105,7 @@
 #include <clc/relational/all.h>
 #include <clc/relational/any.h>
 #include <clc/relational/bitselect.h>
+#include <clc/relational/isequal.h>
 #include <clc/relational/isnan.h>
 #include <clc/relational/select.h>
 

Added: libclc/trunk/generic/include/clc/relational/isequal.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/isequal.h?rev=211046&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/relational/isequal.h (added)
+++ libclc/trunk/generic/include/clc/relational/isequal.h Mon Jun 16 14:53:57 2014
@@ -0,0 +1,18 @@
+
+#define _CLC_ISEQUAL_DECL(TYPE, RETTYPE) \
+  _CLC_OVERLOAD _CLC_DECL RETTYPE isequal(TYPE x, TYPE y);
+
+#define _CLC_VECTOR_ISEQUAL_DECL(TYPE, RETTYPE) \
+  _CLC_ISEQUAL_DECL(TYPE##2, RETTYPE##2)  \
+  _CLC_ISEQUAL_DECL(TYPE##3, RETTYPE##3)  \
+  _CLC_ISEQUAL_DECL(TYPE##4, RETTYPE##4)  \
+  _CLC_ISEQUAL_DECL(TYPE##8, RETTYPE##8)  \
+  _CLC_ISEQUAL_DECL(TYPE##16, RETTYPE##16)
+
+_CLC_ISEQUAL_DECL(float, int)
+_CLC_VECTOR_ISEQUAL_DECL(float, int)
+
+#ifdef cl_khr_fp64
+_CLC_ISEQUAL_DECL(double, int)
+_CLC_VECTOR_ISEQUAL_DECL(double, long)
+#endif
\ No newline at end of file

Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=211046&r1=211045&r2=211046&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Mon Jun 16 14:53:57 2014
@@ -37,6 +37,7 @@ math/nextafter.cl
 math/sincos.cl
 relational/all.cl
 relational/any.cl
+relational/isequal.cl
 relational/isnan.cl
 shared/clamp.cl
 shared/max.cl

Added: libclc/trunk/generic/lib/relational/isequal.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/relational/isequal.cl?rev=211046&view=auto
==============================================================================
--- libclc/trunk/generic/lib/relational/isequal.cl (added)
+++ libclc/trunk/generic/lib/relational/isequal.cl Mon Jun 16 14:53:57 2014
@@ -0,0 +1,30 @@
+#include <clc/clc.h>
+
+#define _CLC_DEFINE_ISEQUAL(RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \
+_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \
+  return (x == y); \
+} \
+
+_CLC_DEFINE_ISEQUAL(int, isequal, float, float)
+_CLC_DEFINE_ISEQUAL(int2, isequal, float2, float2)
+_CLC_DEFINE_ISEQUAL(int3, isequal, float3, float3)
+_CLC_DEFINE_ISEQUAL(int4, isequal, float4, float4)
+_CLC_DEFINE_ISEQUAL(int8, isequal, float8, float8)
+_CLC_DEFINE_ISEQUAL(int16, isequal, float16, float16)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isequal(double) returns an int, but the vector versions
+// return long.
+_CLC_DEFINE_ISEQUAL(int, isequal, double, double)
+_CLC_DEFINE_ISEQUAL(long2, isequal, double2, double2)
+_CLC_DEFINE_ISEQUAL(long3, isequal, double3, double3)
+_CLC_DEFINE_ISEQUAL(long4, isequal, double4, double4)
+_CLC_DEFINE_ISEQUAL(long8, isequal, double8, double8)
+_CLC_DEFINE_ISEQUAL(long16, isequal, double16, double16)
+
+#endif
+
+#undef _CLC_DEFINE_ISEQUAL
\ No newline at end of file





More information about the cfe-commits mailing list