summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Watry <awatry@gmail.com>2014-09-10 15:43:32 +0000
committerAaron Watry <awatry@gmail.com>2014-09-10 15:43:32 +0000
commit951ab64d19f275445b18ac6751e8f64f63866f82 (patch)
treefd4e44bdf4906164ff74a713927f1a8570577ffb
parent268beab921232abb652b18eea3aef021dc29a518 (diff)
downloadbcm5719-llvm-951ab64d19f275445b18ac6751e8f64f63866f82.tar.gz
bcm5719-llvm-951ab64d19f275445b18ac6751e8f64f63866f82.zip
math: Add asin implementation
asin(x) = atan2(x, sqrt( 1-x^2 )) alternatively: asin(x) = PI/2 - acos(x) Use the atan2 implementation since it produces slightly shorter bitcode and R600 machine code. Signed-off-by: Aaron Watry <awatry@gmail.com> Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu> llvm-svn: 217510
-rw-r--r--libclc/generic/include/clc/clc.h1
-rw-r--r--libclc/generic/include/clc/math/asin.h2
-rw-r--r--libclc/generic/include/clc/math/asin.inc1
-rw-r--r--libclc/generic/lib/SOURCES1
-rw-r--r--libclc/generic/lib/math/asin.cl8
-rw-r--r--libclc/generic/lib/math/asin.inc3
6 files changed, 16 insertions, 0 deletions
diff --git a/libclc/generic/include/clc/clc.h b/libclc/generic/include/clc/clc.h
index 0fc8530e994..d0c6e729b81 100644
--- a/libclc/generic/include/clc/clc.h
+++ b/libclc/generic/include/clc/clc.h
@@ -33,6 +33,7 @@
/* 6.11.2 Math Functions */
#include <clc/math/acos.h>
+#include <clc/math/asin.h>
#include <clc/math/atan.h>
#include <clc/math/atan2.h>
#include <clc/math/copysign.h>
diff --git a/libclc/generic/include/clc/math/asin.h b/libclc/generic/include/clc/math/asin.h
new file mode 100644
index 00000000000..2a858721e95
--- /dev/null
+++ b/libclc/generic/include/clc/math/asin.h
@@ -0,0 +1,2 @@
+#define __CLC_BODY <clc/math/asin.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/generic/include/clc/math/asin.inc b/libclc/generic/include/clc/math/asin.inc
new file mode 100644
index 00000000000..b4ad8ff1231
--- /dev/null
+++ b/libclc/generic/include/clc/math/asin.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE asin(__CLC_GENTYPE x);
diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES
index 577671cc216..385f22b2fdf 100644
--- a/libclc/generic/lib/SOURCES
+++ b/libclc/generic/lib/SOURCES
@@ -30,6 +30,7 @@ integer/sub_sat_if.ll
integer/sub_sat_impl.ll
integer/upsample.cl
math/acos.cl
+math/asin.cl
math/atan.cl
math/atan2.cl
math/copysign.cl
diff --git a/libclc/generic/lib/math/asin.cl b/libclc/generic/lib/math/asin.cl
new file mode 100644
index 00000000000..d56dbd780a7
--- /dev/null
+++ b/libclc/generic/lib/math/asin.cl
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define __CLC_BODY <asin.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/generic/lib/math/asin.inc b/libclc/generic/lib/math/asin.inc
new file mode 100644
index 00000000000..a109c367fc7
--- /dev/null
+++ b/libclc/generic/lib/math/asin.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE asin(__CLC_GENTYPE x) {
+ return atan2(x, sqrt( (__CLC_GENTYPE)1.0 -(x*x) ));
+} \ No newline at end of file
OpenPOWER on IntegriCloud