summaryrefslogtreecommitdiffstats
path: root/libclc/generic/lib/shared
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2013-06-26 18:20:56 +0000
committerTom Stellard <thomas.stellard@amd.com>2013-06-26 18:20:56 +0000
commitfe23a30ef5febddf512d669e89e08f35a14872ee (patch)
tree14caf45c01dd290da691473d6ffa6464edfc0a28 /libclc/generic/lib/shared
parentcd88a4ebb61ed01575633e9955b89202927c33ff (diff)
downloadbcm5719-llvm-fe23a30ef5febddf512d669e89e08f35a14872ee.tar.gz
bcm5719-llvm-fe23a30ef5febddf512d669e89e08f35a14872ee.zip
libclc: Add clamp() builtin for integer/floating point
Created under a new shared/ directory for functions which are available for both integer and floating point types. Patch by: Aaron Watry llvm-svn: 184994
Diffstat (limited to 'libclc/generic/lib/shared')
-rw-r--r--libclc/generic/lib/shared/clamp.cl11
-rw-r--r--libclc/generic/lib/shared/clamp.inc3
2 files changed, 14 insertions, 0 deletions
diff --git a/libclc/generic/lib/shared/clamp.cl b/libclc/generic/lib/shared/clamp.cl
new file mode 100644
index 00000000000..0e8d2234929
--- /dev/null
+++ b/libclc/generic/lib/shared/clamp.cl
@@ -0,0 +1,11 @@
+#include <clc/clc.h>
+
+#define BODY <clamp.inc>
+#include <clc/integer/gentype.inc>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define BODY <clamp.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/generic/lib/shared/clamp.inc b/libclc/generic/lib/shared/clamp.inc
new file mode 100644
index 00000000000..ed49b8e8fd5
--- /dev/null
+++ b/libclc/generic/lib/shared/clamp.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z) {
+ return (x > z ? z : (x < y ? y : x));
+}
OpenPOWER on IntegriCloud