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
This commit is contained in:
Tom Stellard 2013-06-26 18:20:56 +00:00
parent cd88a4ebb6
commit fe23a30ef5
6 changed files with 24 additions and 0 deletions

View File

@ -67,6 +67,9 @@
#include <clc/integer/max.h>
#include <clc/integer/sub_sat.h>
/* 6.11.2 and 6.11.3 Shared Integer/Math Functions */
#include <clc/shared/clamp.h>
/* 6.11.5 Geometric Functions */
#include <clc/geometric/cross.h>
#include <clc/geometric/dot.h>

View File

@ -0,0 +1,5 @@
#define BODY <clc/shared/clamp.inc>
#include <clc/integer/gentype.inc>
#define BODY <clc/shared/clamp.inc>
#include <clc/math/gentype.inc>

View File

@ -0,0 +1 @@
_CLC_OVERLOAD _CLC_DECL GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z);

View File

@ -18,5 +18,6 @@ math/hypot.cl
math/mad.cl
math/max.cl
relational/any.cl
shared/clamp.cl
workitem/get_global_id.cl
workitem/get_global_size.cl

View File

@ -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>

View File

@ -0,0 +1,3 @@
_CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z) {
return (x > z ? z : (x < y ? y : x));
}