diff options
| author | Tom Stellard <thomas.stellard@amd.com> | 2013-06-26 18:20:56 +0000 |
|---|---|---|
| committer | Tom Stellard <thomas.stellard@amd.com> | 2013-06-26 18:20:56 +0000 |
| commit | fe23a30ef5febddf512d669e89e08f35a14872ee (patch) | |
| tree | 14caf45c01dd290da691473d6ffa6464edfc0a28 /libclc/generic/lib/shared | |
| parent | cd88a4ebb61ed01575633e9955b89202927c33ff (diff) | |
| download | bcm5719-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.cl | 11 | ||||
| -rw-r--r-- | libclc/generic/lib/shared/clamp.inc | 3 |
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)); +} |

