[libclc] r184994 - libclc: Add clamp() builtin for integer/floating point
Tom Stellard
thomas.stellard at amd.com
Wed Jun 26 11:20:57 PDT 2013
Author: tstellar
Date: Wed Jun 26 13:20:56 2013
New Revision: 184994
URL: http://llvm.org/viewvc/llvm-project?rev=184994&view=rev
Log:
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
Added:
libclc/trunk/generic/include/clc/shared/
libclc/trunk/generic/include/clc/shared/clamp.h
libclc/trunk/generic/include/clc/shared/clamp.inc
libclc/trunk/generic/lib/shared/
libclc/trunk/generic/lib/shared/clamp.cl
libclc/trunk/generic/lib/shared/clamp.inc
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES
Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=184994&r1=184993&r2=184994&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed Jun 26 13:20:56 2013
@@ -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>
Added: libclc/trunk/generic/include/clc/shared/clamp.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/shared/clamp.h?rev=184994&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/shared/clamp.h (added)
+++ libclc/trunk/generic/include/clc/shared/clamp.h Wed Jun 26 13:20:56 2013
@@ -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>
Added: libclc/trunk/generic/include/clc/shared/clamp.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/shared/clamp.inc?rev=184994&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/shared/clamp.inc (added)
+++ libclc/trunk/generic/include/clc/shared/clamp.inc Wed Jun 26 13:20:56 2013
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z);
Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=184994&r1=184993&r2=184994&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Jun 26 13:20:56 2013
@@ -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
Added: libclc/trunk/generic/lib/shared/clamp.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/clamp.cl?rev=184994&view=auto
==============================================================================
--- libclc/trunk/generic/lib/shared/clamp.cl (added)
+++ libclc/trunk/generic/lib/shared/clamp.cl Wed Jun 26 13:20:56 2013
@@ -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>
Added: libclc/trunk/generic/lib/shared/clamp.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/clamp.inc?rev=184994&view=auto
==============================================================================
--- libclc/trunk/generic/lib/shared/clamp.inc (added)
+++ libclc/trunk/generic/lib/shared/clamp.inc Wed Jun 26 13:20:56 2013
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z) {
+ return (x > z ? z : (x < y ? y : x));
+}
More information about the cfe-commits
mailing list