summaryrefslogtreecommitdiff
path: root/generic/include
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2013-06-26 18:20:25 +0000
committerTom Stellard <thomas.stellard@amd.com>2013-06-26 18:20:25 +0000
commit0fd3463974cf8b2aad009ee97dd240222ffd7065 (patch)
tree57cdf2e22d9e486e8e6bd9c2dc278b9d7fc00807 /generic/include
parentb08be4f10886231672844974d8671ddd47276dc7 (diff)
Implement fmax() and fmin() builtins
git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@184987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'generic/include')
-rw-r--r--generic/include/clc/clc.h2
-rw-r--r--generic/include/clc/math/binary_decl.inc6
-rw-r--r--generic/include/clc/math/fmax.h11
-rw-r--r--generic/include/clc/math/fmin.h11
-rw-r--r--generic/include/clc/math/gentype.inc4
5 files changed, 34 insertions, 0 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 315693b..c917a46 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -38,6 +38,8 @@
#include <clc/math/fabs.h>
#include <clc/math/floor.h>
#include <clc/math/fma.h>
+#include <clc/math/fmax.h>
+#include <clc/math/fmin.h>
#include <clc/math/hypot.h>
#include <clc/math/log.h>
#include <clc/math/log2.h>
diff --git a/generic/include/clc/math/binary_decl.inc b/generic/include/clc/math/binary_decl.inc
new file mode 100644
index 0000000..1a49e26
--- /dev/null
+++ b/generic/include/clc/math/binary_decl.inc
@@ -0,0 +1,6 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, GENTYPE b);
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, float b);
+
+#ifdef cl_khr_fp64
+_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, double b);
+#endif
diff --git a/generic/include/clc/math/fmax.h b/generic/include/clc/math/fmax.h
new file mode 100644
index 0000000..d26e5d6
--- /dev/null
+++ b/generic/include/clc/math/fmax.h
@@ -0,0 +1,11 @@
+#undef fmax
+#define fmax __clc_fmax
+
+#define BODY <clc/math/binary_decl.inc>
+#define FUNCTION __clc_fmax
+
+#include <clc/math/gentype.inc>
+
+#undef BODY
+#undef FUNCTION
+
diff --git a/generic/include/clc/math/fmin.h b/generic/include/clc/math/fmin.h
new file mode 100644
index 0000000..3506aef
--- /dev/null
+++ b/generic/include/clc/math/fmin.h
@@ -0,0 +1,11 @@
+#undef fmin
+#define fmin __clc_fmin
+
+#define BODY <clc/math/binary_decl.inc>
+#define FUNCTION __clc_fmin
+
+#include <clc/math/gentype.inc>
+
+#undef BODY
+#undef FUNCTION
+
diff --git a/generic/include/clc/math/gentype.inc b/generic/include/clc/math/gentype.inc
index 4506920..b525c4b 100644
--- a/generic/include/clc/math/gentype.inc
+++ b/generic/include/clc/math/gentype.inc
@@ -1,6 +1,8 @@
#define GENTYPE float
+#define SCALAR
#include BODY
#undef GENTYPE
+#undef SCALAR
#define GENTYPE float2
#include BODY
@@ -23,9 +25,11 @@
#undef GENTYPE
#ifdef cl_khr_fp64
+#define SCALAR
#define GENTYPE double
#include BODY
#undef GENTYPE
+#undef SCALAR
#define GENTYPE double2
#include BODY