From 369e20353cc00e98dac1be978bb08833123f9a4b Mon Sep 17 00:00:00 2001 From: Jan Vesely Date: Fri, 5 Sep 2014 13:59:09 +0000 Subject: [PATCH] add isnormal builtin v2: simplify and remove isnan leftovers remove trailing newline Signed-off-by: Jan Vesely Reviewed-by: Aaron Watry llvm-svn: 217244 --- libclc/generic/include/clc/clc.h | 1 + .../generic/include/clc/relational/isnormal.h | 9 +++++++++ libclc/generic/lib/SOURCES | 1 + libclc/generic/lib/relational/isnormal.cl | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 libclc/generic/include/clc/relational/isnormal.h create mode 100644 libclc/generic/lib/relational/isnormal.cl diff --git a/libclc/generic/include/clc/clc.h b/libclc/generic/include/clc/clc.h index f7085cea4192..148a83b7be0a 100644 --- a/libclc/generic/include/clc/clc.h +++ b/libclc/generic/include/clc/clc.h @@ -121,6 +121,7 @@ #include #include #include +#include #include #include #include diff --git a/libclc/generic/include/clc/relational/isnormal.h b/libclc/generic/include/clc/relational/isnormal.h new file mode 100644 index 000000000000..f568c56f8e6e --- /dev/null +++ b/libclc/generic/include/clc/relational/isnormal.h @@ -0,0 +1,9 @@ +#undef isnormal + +#define __CLC_FUNCTION isnormal +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES index 3c021183e9ad..115cbee198eb 100644 --- a/libclc/generic/lib/SOURCES +++ b/libclc/generic/lib/SOURCES @@ -56,6 +56,7 @@ relational/isinf.cl relational/isless.cl relational/islessequal.cl relational/isnan.cl +relational/isnormal.cl relational/isnotequal.cl relational/signbit.cl shared/clamp.cl diff --git a/libclc/generic/lib/relational/isnormal.cl b/libclc/generic/lib/relational/isnormal.cl new file mode 100644 index 000000000000..2e6b42d00178 --- /dev/null +++ b/libclc/generic/lib/relational/isnormal.cl @@ -0,0 +1,18 @@ +#include +#include "relational.h" + +_CLC_DEFINE_RELATIONAL_UNARY(int, isnormal, __builtin_isnormal, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +// The scalar version of isnormal(double) returns an int, but the vector versions +// return long. +_CLC_DEF _CLC_OVERLOAD int isnormal(double x) { + return __builtin_isnormal(x); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, isnormal, double) + +#endif