summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2012-05-28 22:22:13 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2012-05-28 22:22:13 +0000
commit117180439615bd06e7a536e61270af9ea6b1406e (patch)
tree84cf328a07dc7e60107dfd26c162694e9feedd02
parent96eafe454afb36b06aa0704cd87b223b3b6f92da (diff)
Add fabs builtin.
git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@157595 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--generic/include/clc/clc.h1
-rw-r--r--generic/include/clc/math/fabs.h6
-rw-r--r--test/fabs.cl3
3 files changed, 10 insertions, 0 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index f2536bc..72e2f23 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -33,6 +33,7 @@
/* 6.11.2 Math Functions */
#include <clc/math/cos.h>
+#include <clc/math/fabs.h>
#include <clc/math/sin.h>
#include <clc/math/sqrt.h>
#include <clc/math/native_cos.h>
diff --git a/generic/include/clc/math/fabs.h b/generic/include/clc/math/fabs.h
new file mode 100644
index 0000000..4da013c
--- /dev/null
+++ b/generic/include/clc/math/fabs.h
@@ -0,0 +1,6 @@
+#undef fabs
+#define fabs __clc_fabs
+
+#define FUNCTION __clc_fabs
+#define INTRINSIC "llvm.fabs"
+#include <clc/math/unary_intrin.inc>
diff --git a/test/fabs.cl b/test/fabs.cl
new file mode 100644
index 0000000..91d42c4
--- /dev/null
+++ b/test/fabs.cl
@@ -0,0 +1,3 @@
+__kernel void foo(float *f) {
+ *f = fabs(*f);
+}