diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2012-05-29 13:35:28 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2012-05-29 13:35:28 +0000 |
commit | de7227e5bd8427c99a494f53f30ddc52ba9ea1b6 (patch) | |
tree | b56427977eba7ec8d6e112234b71c8facdd8fa9b /libclc | |
parent | 58107dd547a883927c9be9a92b8396a7700685d9 (diff) | |
download | bcm5719-llvm-de7227e5bd8427c99a494f53f30ddc52ba9ea1b6.tar.gz bcm5719-llvm-de7227e5bd8427c99a494f53f30ddc52ba9ea1b6.zip |
Add fma, hypot builtins.
llvm-svn: 157613
Diffstat (limited to 'libclc')
-rw-r--r-- | libclc/generic/include/clc/clc.h | 2 | ||||
-rw-r--r-- | libclc/generic/include/clc/math/fma.h | 6 | ||||
-rw-r--r-- | libclc/generic/include/clc/math/hypot.h | 2 | ||||
-rw-r--r-- | libclc/generic/include/clc/math/hypot.inc | 1 | ||||
-rw-r--r-- | libclc/generic/include/clc/math/ternary_intrin.inc | 18 | ||||
-rw-r--r-- | libclc/generic/lib/SOURCES | 1 | ||||
-rw-r--r-- | libclc/generic/lib/math/hypot.cl | 8 | ||||
-rw-r--r-- | libclc/generic/lib/math/hypot.inc | 3 |
8 files changed, 41 insertions, 0 deletions
diff --git a/libclc/generic/include/clc/clc.h b/libclc/generic/include/clc/clc.h index 3b78d29f74e..65e4090a035 100644 --- a/libclc/generic/include/clc/clc.h +++ b/libclc/generic/include/clc/clc.h @@ -36,6 +36,8 @@ #include <clc/math/exp.h> #include <clc/math/exp2.h> #include <clc/math/fabs.h> +#include <clc/math/fma.h> +#include <clc/math/hypot.h> #include <clc/math/log.h> #include <clc/math/log2.h> #include <clc/math/mad.h> diff --git a/libclc/generic/include/clc/math/fma.h b/libclc/generic/include/clc/math/fma.h new file mode 100644 index 00000000000..8d862fa8f5b --- /dev/null +++ b/libclc/generic/include/clc/math/fma.h @@ -0,0 +1,6 @@ +#undef fma +#define fma __clc_fma + +#define FUNCTION __clc_fma +#define INTRINSIC "llvm.fma" +#include <clc/math/ternary_intrin.inc> diff --git a/libclc/generic/include/clc/math/hypot.h b/libclc/generic/include/clc/math/hypot.h new file mode 100644 index 00000000000..9ffda483d99 --- /dev/null +++ b/libclc/generic/include/clc/math/hypot.h @@ -0,0 +1,2 @@ +#define BODY <clc/math/hypot.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/generic/include/clc/math/hypot.inc b/libclc/generic/include/clc/math/hypot.inc new file mode 100644 index 00000000000..2f97ee576d1 --- /dev/null +++ b/libclc/generic/include/clc/math/hypot.inc @@ -0,0 +1 @@ +_CLC_OVERLOAD _CLC_DECL GENTYPE hypot(GENTYPE x, GENTYPE y); diff --git a/libclc/generic/include/clc/math/ternary_intrin.inc b/libclc/generic/include/clc/math/ternary_intrin.inc new file mode 100644 index 00000000000..7d451e96b16 --- /dev/null +++ b/libclc/generic/include/clc/math/ternary_intrin.inc @@ -0,0 +1,18 @@ +_CLC_OVERLOAD float FUNCTION(float, float, float) __asm(INTRINSIC ".f32"); +_CLC_OVERLOAD float2 FUNCTION(float2, float2, float2) __asm(INTRINSIC ".v2f32"); +_CLC_OVERLOAD float3 FUNCTION(float3, float3, float3) __asm(INTRINSIC ".v3f32"); +_CLC_OVERLOAD float4 FUNCTION(float4, float4, float4) __asm(INTRINSIC ".v4f32"); +_CLC_OVERLOAD float8 FUNCTION(float8, float8, float8) __asm(INTRINSIC ".v8f32"); +_CLC_OVERLOAD float16 FUNCTION(float16, float16, float16) __asm(INTRINSIC ".v16f32"); + +#ifdef cl_khr_fp64 +_CLC_OVERLOAD double FUNCTION(double, double, double) __asm(INTRINSIC ".f64"); +_CLC_OVERLOAD double2 FUNCTION(double2, double2, double2) __asm(INTRINSIC ".v2f64"); +_CLC_OVERLOAD double3 FUNCTION(double3, double3, double3) __asm(INTRINSIC ".v3f64"); +_CLC_OVERLOAD double4 FUNCTION(double4, double4, double4) __asm(INTRINSIC ".v4f64"); +_CLC_OVERLOAD double8 FUNCTION(double8, double8, double8) __asm(INTRINSIC ".v8f64"); +_CLC_OVERLOAD double16 FUNCTION(double16, double16, double16) __asm(INTRINSIC ".v16f64"); +#endif + +#undef FUNCTION +#undef INTRINSIC diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES index 1da1c91127e..06081169100 100644 --- a/libclc/generic/lib/SOURCES +++ b/libclc/generic/lib/SOURCES @@ -7,4 +7,5 @@ integer/abs.cl integer/add_sat.cl integer/add_sat.ll integer/add_sat_impl.ll +math/hypot.cl math/mad.cl diff --git a/libclc/generic/lib/math/hypot.cl b/libclc/generic/lib/math/hypot.cl new file mode 100644 index 00000000000..dcdc1edddd0 --- /dev/null +++ b/libclc/generic/lib/math/hypot.cl @@ -0,0 +1,8 @@ +#include <clc/clc.h> + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#endif + +#define BODY <hypot.inc> +#include <clc/math/gentype.inc> diff --git a/libclc/generic/lib/math/hypot.inc b/libclc/generic/lib/math/hypot.inc new file mode 100644 index 00000000000..3f529c881a4 --- /dev/null +++ b/libclc/generic/lib/math/hypot.inc @@ -0,0 +1,3 @@ +_CLC_OVERLOAD _CLC_DEF GENTYPE hypot(GENTYPE x, GENTYPE y) { + return sqrt(x*x + y*y); +} |