summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2013-06-26 18:20:46 +0000
committerTom Stellard <thomas.stellard@amd.com>2013-06-26 18:20:46 +0000
commitec87fb0b0c4c66edbec96e810ba4fd302dbaf50d (patch)
treed8e6ff4ac960f9b693b1b519503ca48fa52a06c3
parent30f554b23d35aba942a5223c912e4e0361413884 (diff)
downloadbcm5719-llvm-ec87fb0b0c4c66edbec96e810ba4fd302dbaf50d.tar.gz
bcm5719-llvm-ec87fb0b0c4c66edbec96e810ba4fd302dbaf50d.zip
libclc: Add max() builtin function
Adds this function for both int and floating data types. Patch by: Aaron Watry llvm-svn: 184992
-rw-r--r--libclc/generic/include/clc/clc.h2
-rw-r--r--libclc/generic/include/clc/integer/max.h2
-rw-r--r--libclc/generic/include/clc/integer/max.inc1
-rw-r--r--libclc/generic/include/clc/math/max.h2
-rw-r--r--libclc/generic/include/clc/math/max.inc1
-rw-r--r--libclc/generic/lib/SOURCES2
-rw-r--r--libclc/generic/lib/integer/max.cl4
-rw-r--r--libclc/generic/lib/integer/max.inc3
-rw-r--r--libclc/generic/lib/math/max.cl8
-rw-r--r--libclc/generic/lib/math/max.inc3
10 files changed, 28 insertions, 0 deletions
diff --git a/libclc/generic/include/clc/clc.h b/libclc/generic/include/clc/clc.h
index 4394c9ed4f3..f6668a36675 100644
--- a/libclc/generic/include/clc/clc.h
+++ b/libclc/generic/include/clc/clc.h
@@ -45,6 +45,7 @@
#include <clc/math/log.h>
#include <clc/math/log2.h>
#include <clc/math/mad.h>
+#include <clc/math/max.h>
#include <clc/math/pow.h>
#include <clc/math/sin.h>
#include <clc/math/sqrt.h>
@@ -63,6 +64,7 @@
#include <clc/integer/abs.h>
#include <clc/integer/abs_diff.h>
#include <clc/integer/add_sat.h>
+#include <clc/integer/max.h>
#include <clc/integer/sub_sat.h>
/* 6.11.5 Geometric Functions */
diff --git a/libclc/generic/include/clc/integer/max.h b/libclc/generic/include/clc/integer/max.h
new file mode 100644
index 00000000000..e74a459fcf3
--- /dev/null
+++ b/libclc/generic/include/clc/integer/max.h
@@ -0,0 +1,2 @@
+#define BODY <clc/integer/max.inc>
+#include <clc/integer/gentype.inc>
diff --git a/libclc/generic/include/clc/integer/max.inc b/libclc/generic/include/clc/integer/max.inc
new file mode 100644
index 00000000000..ce6c6d0d5fa
--- /dev/null
+++ b/libclc/generic/include/clc/integer/max.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE max(GENTYPE a, GENTYPE b);
diff --git a/libclc/generic/include/clc/math/max.h b/libclc/generic/include/clc/math/max.h
new file mode 100644
index 00000000000..3d158f12f04
--- /dev/null
+++ b/libclc/generic/include/clc/math/max.h
@@ -0,0 +1,2 @@
+#define BODY <clc/math/max.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/generic/include/clc/math/max.inc b/libclc/generic/include/clc/math/max.inc
new file mode 100644
index 00000000000..ce6c6d0d5fa
--- /dev/null
+++ b/libclc/generic/include/clc/math/max.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE max(GENTYPE a, GENTYPE b);
diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES
index 86c008b026f..b593941e85a 100644
--- a/libclc/generic/lib/SOURCES
+++ b/libclc/generic/lib/SOURCES
@@ -7,6 +7,7 @@ integer/abs.cl
integer/add_sat.cl
integer/add_sat.ll
integer/add_sat_impl.ll
+integer/max.cl
integer/sub_sat.cl
integer/sub_sat.ll
integer/sub_sat_impl.ll
@@ -14,6 +15,7 @@ math/fmax.cl
math/fmin.cl
math/hypot.cl
math/mad.cl
+math/max.cl
relational/any.cl
workitem/get_global_id.cl
workitem/get_global_size.cl
diff --git a/libclc/generic/lib/integer/max.cl b/libclc/generic/lib/integer/max.cl
new file mode 100644
index 00000000000..89fec7c53d3
--- /dev/null
+++ b/libclc/generic/lib/integer/max.cl
@@ -0,0 +1,4 @@
+#include <clc/clc.h>
+
+#define BODY <max.inc>
+#include <clc/integer/gentype.inc>
diff --git a/libclc/generic/lib/integer/max.inc b/libclc/generic/lib/integer/max.inc
new file mode 100644
index 00000000000..37409fc8a24
--- /dev/null
+++ b/libclc/generic/lib/integer/max.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE max(GENTYPE a, GENTYPE b) {
+ return (a > b ? a : b);
+}
diff --git a/libclc/generic/lib/math/max.cl b/libclc/generic/lib/math/max.cl
new file mode 100644
index 00000000000..d1254a7be5a
--- /dev/null
+++ b/libclc/generic/lib/math/max.cl
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define BODY <max.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/generic/lib/math/max.inc b/libclc/generic/lib/math/max.inc
new file mode 100644
index 00000000000..37409fc8a24
--- /dev/null
+++ b/libclc/generic/lib/math/max.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE max(GENTYPE a, GENTYPE b) {
+ return (a > b ? a : b);
+}
OpenPOWER on IntegriCloud