summaryrefslogtreecommitdiffstats
path: root/libclc/generic/lib
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2013-10-10 19:08:41 +0000
committerTom Stellard <thomas.stellard@amd.com>2013-10-10 19:08:41 +0000
commite36e9dec65626dcf54eb0ec2ac1bef6fd605a8f0 (patch)
treeb30fa7ec6d20701aa7ff83d3ba63131b046d644c /libclc/generic/lib
parentef13294c931f42cf303adb2104fa2aa1a6adc9a7 (diff)
downloadbcm5719-llvm-e36e9dec65626dcf54eb0ec2ac1bef6fd605a8f0.tar.gz
bcm5719-llvm-e36e9dec65626dcf54eb0ec2ac1bef6fd605a8f0.zip
Implement isnan() builtin
llvm-svn: 192382
Diffstat (limited to 'libclc/generic/lib')
-rw-r--r--libclc/generic/lib/SOURCES1
-rw-r--r--libclc/generic/lib/relational/isnan.cl17
2 files changed, 18 insertions, 0 deletions
diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES
index 16db9bc87ba..383a66e8ad3 100644
--- a/libclc/generic/lib/SOURCES
+++ b/libclc/generic/lib/SOURCES
@@ -27,6 +27,7 @@ math/fmin.cl
math/hypot.cl
math/mad.cl
relational/any.cl
+relational/isnan.cl
shared/clamp.cl
shared/max.cl
shared/min.cl
diff --git a/libclc/generic/lib/relational/isnan.cl b/libclc/generic/lib/relational/isnan.cl
new file mode 100644
index 00000000000..1a64f67dbd2
--- /dev/null
+++ b/libclc/generic/lib/relational/isnan.cl
@@ -0,0 +1,17 @@
+#include <clc/clc.h>
+
+_CLC_DEFINE_UNARY_BUILTIN(int, isnan, __builtin_isnan, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+// The scalar version of isnan(double) returns an int, but the vector versions
+// return long.
+_CLC_DEF _CLC_OVERLOAD int isnan(double x) {
+ return __builtin_isnan(x);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, long, isnan, double)
+
+#endif
OpenPOWER on IntegriCloud