xref: /freebsd/contrib/arm-optimized-routines/math/include/mathlib.h (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1 /*
2  * Public API.
3  *
4  * Copyright (c) 2015-2020, Arm Limited.
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #ifndef _MATHLIB_H
9 #define _MATHLIB_H
10 
11 float expf (float);
12 float exp2f (float);
13 float logf (float);
14 float log2f (float);
15 float powf (float, float);
16 float sinf (float);
17 float cosf (float);
18 void sincosf (float, float*, float*);
19 
20 double exp (double);
21 double exp2 (double);
22 double log (double);
23 double log2 (double);
24 double pow (double, double);
25 
26 /* Scalar functions using the vector algorithm with identical result.  */
27 float __s_sinf (float);
28 float __s_cosf (float);
29 float __s_expf (float);
30 float __s_expf_1u (float);
31 float __s_exp2f (float);
32 float __s_exp2f_1u (float);
33 float __s_logf (float);
34 float __s_powf (float, float);
35 double __s_sin (double);
36 double __s_cos (double);
37 double __s_exp (double);
38 double __s_log (double);
39 double __s_pow (double, double);
40 
41 #if __aarch64__
42 #if __GNUC__ >= 5
43 typedef __Float32x4_t __f32x4_t;
44 typedef __Float64x2_t __f64x2_t;
45 #elif __clang_major__*100+__clang_minor__ >= 305
46 typedef __attribute__((__neon_vector_type__(4))) float __f32x4_t;
47 typedef __attribute__((__neon_vector_type__(2))) double __f64x2_t;
48 #else
49 #error Unsupported compiler
50 #endif
51 
52 /* Vector functions following the base PCS.  */
53 __f32x4_t __v_sinf (__f32x4_t);
54 __f32x4_t __v_cosf (__f32x4_t);
55 __f32x4_t __v_expf (__f32x4_t);
56 __f32x4_t __v_expf_1u (__f32x4_t);
57 __f32x4_t __v_exp2f (__f32x4_t);
58 __f32x4_t __v_exp2f_1u (__f32x4_t);
59 __f32x4_t __v_logf (__f32x4_t);
60 __f32x4_t __v_powf (__f32x4_t, __f32x4_t);
61 __f64x2_t __v_sin (__f64x2_t);
62 __f64x2_t __v_cos (__f64x2_t);
63 __f64x2_t __v_exp (__f64x2_t);
64 __f64x2_t __v_log (__f64x2_t);
65 __f64x2_t __v_pow (__f64x2_t, __f64x2_t);
66 
67 #if __GNUC__ >= 9 || __clang_major__ >= 8
68 #define __vpcs __attribute__((__aarch64_vector_pcs__))
69 
70 /* Vector functions following the vector PCS.  */
71 __vpcs __f32x4_t __vn_sinf (__f32x4_t);
72 __vpcs __f32x4_t __vn_cosf (__f32x4_t);
73 __vpcs __f32x4_t __vn_expf (__f32x4_t);
74 __vpcs __f32x4_t __vn_expf_1u (__f32x4_t);
75 __vpcs __f32x4_t __vn_exp2f (__f32x4_t);
76 __vpcs __f32x4_t __vn_exp2f_1u (__f32x4_t);
77 __vpcs __f32x4_t __vn_logf (__f32x4_t);
78 __vpcs __f32x4_t __vn_powf (__f32x4_t, __f32x4_t);
79 __vpcs __f64x2_t __vn_sin (__f64x2_t);
80 __vpcs __f64x2_t __vn_cos (__f64x2_t);
81 __vpcs __f64x2_t __vn_exp (__f64x2_t);
82 __vpcs __f64x2_t __vn_log (__f64x2_t);
83 __vpcs __f64x2_t __vn_pow (__f64x2_t, __f64x2_t);
84 
85 /* Vector functions following the vector PCS using ABI names.  */
86 __vpcs __f32x4_t _ZGVnN4v_sinf (__f32x4_t);
87 __vpcs __f32x4_t _ZGVnN4v_cosf (__f32x4_t);
88 __vpcs __f32x4_t _ZGVnN4v_expf (__f32x4_t);
89 __vpcs __f32x4_t _ZGVnN4v_exp2f (__f32x4_t);
90 __vpcs __f32x4_t _ZGVnN4v_logf (__f32x4_t);
91 __vpcs __f32x4_t _ZGVnN4vv_powf (__f32x4_t, __f32x4_t);
92 __vpcs __f64x2_t _ZGVnN2v_sin (__f64x2_t);
93 __vpcs __f64x2_t _ZGVnN2v_cos (__f64x2_t);
94 __vpcs __f64x2_t _ZGVnN2v_exp (__f64x2_t);
95 __vpcs __f64x2_t _ZGVnN2v_log (__f64x2_t);
96 __vpcs __f64x2_t _ZGVnN2vv_pow (__f64x2_t, __f64x2_t);
97 #endif
98 #endif
99 
100 #endif
101