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
This commit is contained in:
Aaron Watry 2014-09-10 15:43:32 +00:00
parent 268beab921
commit 951ab64d19
6 changed files with 16 additions and 0 deletions

View File

@ -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>

View File

@ -0,0 +1,2 @@
#define __CLC_BODY <clc/math/asin.inc>
#include <clc/math/gentype.inc>

View File

@ -0,0 +1 @@
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE asin(__CLC_GENTYPE x);

View File

@ -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

View File

@ -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>

View File

@ -0,0 +1,3 @@
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE asin(__CLC_GENTYPE x) {
return atan2(x, sqrt( (__CLC_GENTYPE)1.0 -(x*x) ));
}