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