summaryrefslogtreecommitdiff
path: root/libclc
diff options
context:
space:
mode:
authorJan Vesely <jan.vesely@rutgers.edu>2019-03-13 07:05:56 +0000
committerJan Vesely <jan.vesely@rutgers.edu>2019-03-13 07:05:56 +0000
commit82c6c846af23bf75420f435bd2fb896d7ea258af (patch)
tree6de4a21b25eb9e87663dbeb17d9cabfb72391da2 /libclc
parentmad: Convert to standard ternary header (diff)
downloadllvm-project-82c6c846af23bf75420f435bd2fb896d7ea258af.tar.gz
llvm-project-82c6c846af23bf75420f435bd2fb896d7ea258af.tar.bz2
llvm-project-82c6c846af23bf75420f435bd2fb896d7ea258af.zip
sqrt: Split function generation to a shared inc file.
This will be reused by other unary functions. Reviewer: Aaron Watry Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> llvm-svn: 356012
Diffstat (limited to 'libclc')
-rw-r--r--libclc/generic/lib/math/sqrt.cl20
-rw-r--r--libclc/generic/lib/math/unary_builtin.inc24
2 files changed, 26 insertions, 18 deletions
diff --git a/libclc/generic/lib/math/sqrt.cl b/libclc/generic/lib/math/sqrt.cl
index b05d6bc0a069..8df25dd45adb 100644
--- a/libclc/generic/lib/math/sqrt.cl
+++ b/libclc/generic/lib/math/sqrt.cl
@@ -21,23 +21,7 @@
*/
#include <clc/clc.h>
-#include "../clcmacro.h"
#include "math/clc_sqrt.h"
-_CLC_DEFINE_UNARY_BUILTIN(float, sqrt, __clc_sqrt, float)
-
-#ifdef cl_khr_fp64
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-_CLC_DEFINE_UNARY_BUILTIN(double, sqrt, __clc_sqrt, double)
-
-#endif
-
-#ifdef cl_khr_fp16
-
-#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-
-_CLC_DEFINE_UNARY_BUILTIN(half, sqrt, __clc_sqrt, half)
-
-#endif
+#define __CLC_FUNCTION sqrt
+#include "unary_builtin.inc"
diff --git a/libclc/generic/lib/math/unary_builtin.inc b/libclc/generic/lib/math/unary_builtin.inc
new file mode 100644
index 000000000000..4e7ca5ba9b98
--- /dev/null
+++ b/libclc/generic/lib/math/unary_builtin.inc
@@ -0,0 +1,24 @@
+#include "../clcmacro.h"
+#include "utils.h"
+
+#ifndef __CLC_BUILTIN
+#define __CLC_BUILTIN __CLC_XCONCAT(__clc_, __CLC_FUNCTION)
+#endif
+
+_CLC_DEFINE_UNARY_BUILTIN(float, __CLC_FUNCTION, __CLC_BUILTIN, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_DEFINE_UNARY_BUILTIN(double, __CLC_FUNCTION, __CLC_BUILTIN, double)
+
+#endif
+
+#ifdef cl_khr_fp16
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+_CLC_DEFINE_UNARY_BUILTIN(half, __CLC_FUNCTION, __CLC_BUILTIN, half)
+
+#endif