xref: /freebsd/contrib/arm-optimized-routines/pl/math/include/mathlib.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /*
2  * Public API.
3  *
4  * Copyright (c) 2015-2023, Arm Limited.
5  * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
6  */
7 
8 #ifndef _MATHLIB_H
9 #define _MATHLIB_H
10 
11 float acosf (float);
12 float acoshf (float);
13 float asinf (float);
14 float asinhf (float);
15 float atan2f (float, float);
16 float atanf (float);
17 float atanhf (float);
18 float cbrtf (float);
19 float coshf (float);
20 float cospif (float);
21 float erfcf (float);
22 float erff (float);
23 float erfinvf (float);
24 float exp10f (float);
25 float expm1f (float);
26 float log10f (float);
27 float log1pf (float);
28 float sinhf (float);
29 float sinpif (float);
30 float tanf (float);
31 float tanhf (float);
32 
33 double acos (double);
34 double acosh (double);
35 double asin (double);
36 double asinh (double);
37 double atan (double);
38 double atan2 (double, double);
39 double atanh (double);
40 double cbrt (double);
41 double cosh (double);
42 double cospi (double);
43 double erfc (double);
44 double erfinv (double);
45 double exp10 (double);
46 double expm1 (double);
47 double log10 (double);
48 double log1p (double);
49 double sinh (double);
50 double sinpi (double);
51 double tanh (double);
52 
53 long double cospil (long double);
54 long double erfinvl (long double);
55 long double exp10l (long double);
56 long double sinpil (long double);
57 
58 #if __aarch64__
59 # if __GNUC__ >= 5
60 typedef __Float32x4_t __f32x4_t;
61 typedef __Float64x2_t __f64x2_t;
62 # elif __clang_major__ * 100 + __clang_minor__ >= 305
63 typedef __attribute__ ((__neon_vector_type__ (4))) float __f32x4_t;
64 typedef __attribute__ ((__neon_vector_type__ (2))) double __f64x2_t;
65 # else
66 #  error Unsupported compiler
67 # endif
68 
69 # if __GNUC__ >= 9 || __clang_major__ >= 8
70 #  define __vpcs __attribute__ ((__aarch64_vector_pcs__))
71 
72 typedef struct __f32x4x2_t
73 {
74   __f32x4_t val[2];
75 } __f32x4x2_t;
76 
77 typedef struct __f64x2x2_t
78 {
79   __f64x2_t val[2];
80 } __f64x2x2_t;
81 
82 /* Vector functions following the vector PCS using ABI names.  */
83 __vpcs __f32x4_t _ZGVnN4v_acoshf (__f32x4_t);
84 __vpcs __f64x2_t _ZGVnN2v_acosh (__f64x2_t);
85 __vpcs __f32x4_t _ZGVnN4v_acosf (__f32x4_t);
86 __vpcs __f64x2_t _ZGVnN2v_acos (__f64x2_t);
87 __vpcs __f32x4_t _ZGVnN4v_asinf (__f32x4_t);
88 __vpcs __f64x2_t _ZGVnN2v_asin (__f64x2_t);
89 __vpcs __f32x4_t _ZGVnN4v_asinhf (__f32x4_t);
90 __vpcs __f64x2_t _ZGVnN2v_asinh (__f64x2_t);
91 __vpcs __f32x4_t _ZGVnN4v_atanf (__f32x4_t);
92 __vpcs __f64x2_t _ZGVnN2v_atan (__f64x2_t);
93 __vpcs __f32x4_t _ZGVnN4vv_atan2f (__f32x4_t, __f32x4_t);
94 __vpcs __f64x2_t _ZGVnN2vv_atan2 (__f64x2_t, __f64x2_t);
95 __vpcs __f32x4_t _ZGVnN4v_atanhf (__f32x4_t);
96 __vpcs __f64x2_t _ZGVnN2v_atanh (__f64x2_t);
97 __vpcs __f32x4_t _ZGVnN4v_cbrtf (__f32x4_t);
98 __vpcs __f64x2_t _ZGVnN2v_cbrt (__f64x2_t);
99 __vpcs __f32x4x2_t _ZGVnN4v_cexpif (__f32x4_t);
100 __vpcs __f64x2x2_t _ZGVnN2v_cexpi (__f64x2_t);
101 __vpcs __f32x4_t _ZGVnN4v_coshf (__f32x4_t);
102 __vpcs __f64x2_t _ZGVnN2v_cosh (__f64x2_t);
103 __vpcs __f32x4_t _ZGVnN4v_cospif (__f32x4_t);
104 __vpcs __f64x2_t _ZGVnN2v_cospi (__f64x2_t);
105 __vpcs __f32x4_t _ZGVnN4v_erff (__f32x4_t);
106 __vpcs __f64x2_t _ZGVnN2v_erf (__f64x2_t);
107 __vpcs __f32x4_t _ZGVnN4v_erfcf (__f32x4_t);
108 __vpcs __f64x2_t _ZGVnN2v_erfc (__f64x2_t);
109 __vpcs __f32x4_t _ZGVnN4v_erfinvf (__f32x4_t);
110 __vpcs __f64x2_t _ZGVnN2v_erfinv (__f64x2_t);
111 __vpcs __f32x4_t _ZGVnN4v_exp10f (__f32x4_t);
112 __vpcs __f64x2_t _ZGVnN2v_exp10 (__f64x2_t);
113 __vpcs __f64x2_t _ZGVnN2v_exp2 (__f64x2_t);
114 __vpcs __f32x4_t _ZGVnN4v_expm1f (__f32x4_t);
115 __vpcs __f64x2_t _ZGVnN2v_expm1 (__f64x2_t);
116 __vpcs __f32x4_t _ZGVnN4vv_hypotf (__f32x4_t, __f32x4_t);
117 __vpcs __f64x2_t _ZGVnN2vv_hypot (__f64x2_t, __f64x2_t);
118 __vpcs __f32x4_t _ZGVnN4v_log10f (__f32x4_t);
119 __vpcs __f64x2_t _ZGVnN2v_log10 (__f64x2_t);
120 __vpcs __f32x4_t _ZGVnN4v_log1pf (__f32x4_t);
121 __vpcs __f64x2_t _ZGVnN2v_log1p (__f64x2_t);
122 __vpcs __f32x4_t _ZGVnN4v_log2f (__f32x4_t);
123 __vpcs __f64x2_t _ZGVnN2v_log2 (__f64x2_t);
124 __vpcs __f64x2_t _ZGVnN2vv_pow (__f64x2_t, __f64x2_t);
125 __vpcs __f32x4_t _ZGVnN4v_sinhf (__f32x4_t);
126 __vpcs __f64x2_t _ZGVnN2v_sinh (__f64x2_t);
127 __vpcs __f32x4_t _ZGVnN4v_sinpif (__f32x4_t);
128 __vpcs __f64x2_t _ZGVnN2v_sinpi (__f64x2_t);
129 __vpcs __f32x4_t _ZGVnN4v_tanf (__f32x4_t);
130 __vpcs __f64x2_t _ZGVnN2v_tan (__f64x2_t);
131 __vpcs __f32x4_t _ZGVnN4v_tanhf (__f32x4_t);
132 __vpcs __f64x2_t _ZGVnN2v_tanh (__f64x2_t);
133 __vpcs void _ZGVnN4vl4l4_sincosf (__f32x4_t, __f32x4_t *, __f32x4_t *);
134 __vpcs void _ZGVnN2vl8l8_sincos (__f64x2_t, __f64x2_t *, __f64x2_t *);
135 
136 # endif
137 
138 # if WANT_SVE_MATH
139 #  include <arm_sve.h>
140 svfloat32_t _ZGVsMxv_acoshf (svfloat32_t, svbool_t);
141 svfloat64_t _ZGVsMxv_acosh (svfloat64_t, svbool_t);
142 svfloat32_t _ZGVsMxv_acosf (svfloat32_t, svbool_t);
143 svfloat64_t _ZGVsMxv_acos (svfloat64_t, svbool_t);
144 svfloat32_t _ZGVsMxv_asinhf (svfloat32_t, svbool_t);
145 svfloat64_t _ZGVsMxv_asinh (svfloat64_t, svbool_t);
146 svfloat32_t _ZGVsMxv_asinf (svfloat32_t, svbool_t);
147 svfloat64_t _ZGVsMxv_asin (svfloat64_t, svbool_t);
148 svfloat32_t _ZGVsMxv_atanhf (svfloat32_t, svbool_t);
149 svfloat64_t _ZGVsMxv_atanh (svfloat64_t, svbool_t);
150 svfloat32_t _ZGVsMxvv_atan2f (svfloat32_t, svfloat32_t, svbool_t);
151 svfloat32_t _ZGVsMxv_atanf (svfloat32_t, svbool_t);
152 svfloat64_t _ZGVsMxv_atan (svfloat64_t, svbool_t);
153 svfloat64_t _ZGVsMxvv_atan2 (svfloat64_t, svfloat64_t, svbool_t);
154 svfloat32_t _ZGVsMxv_cbrtf (svfloat32_t, svbool_t);
155 svfloat64_t _ZGVsMxv_cbrt (svfloat64_t, svbool_t);
156 svfloat32x2_t _ZGVsMxv_cexpif (svfloat32_t, svbool_t);
157 svfloat64x2_t _ZGVsMxv_cexpi (svfloat64_t, svbool_t);
158 svfloat32_t _ZGVsMxv_coshf (svfloat32_t, svbool_t);
159 svfloat64_t _ZGVsMxv_cosh (svfloat64_t, svbool_t);
160 svfloat32_t _ZGVsMxv_cosf (svfloat32_t, svbool_t);
161 svfloat32_t _ZGVsMxv_cospif (svfloat32_t, svbool_t);
162 svfloat64_t _ZGVsMxv_cos (svfloat64_t, svbool_t);
163 svfloat64_t _ZGVsMxv_cospi (svfloat64_t, svbool_t);
164 svfloat32_t _ZGVsMxv_erff (svfloat32_t, svbool_t);
165 svfloat64_t _ZGVsMxv_erf (svfloat64_t, svbool_t);
166 svfloat64_t _ZGVsMxv_erfc (svfloat64_t, svbool_t);
167 svfloat32_t _ZGVsMxv_erfcf (svfloat32_t, svbool_t);
168 svfloat32_t _ZGVsMxv_expf (svfloat32_t, svbool_t);
169 svfloat64_t _ZGVsMxv_exp (svfloat64_t, svbool_t);
170 svfloat32_t _ZGVsMxv_exp10f (svfloat32_t, svbool_t);
171 svfloat64_t _ZGVsMxv_exp10 (svfloat64_t, svbool_t);
172 svfloat32_t _ZGVsMxv_exp2f (svfloat32_t, svbool_t);
173 svfloat64_t _ZGVsMxv_exp2 (svfloat64_t, svbool_t);
174 svfloat32_t _ZGVsMxv_expm1f (svfloat32_t, svbool_t);
175 svfloat64_t _ZGVsMxv_expm1 (svfloat64_t, svbool_t);
176 svfloat32_t _ZGVsMxvv_hypotf (svfloat32_t, svfloat32_t, svbool_t);
177 svfloat64_t _ZGVsMxvv_hypot (svfloat64_t, svfloat64_t, svbool_t);
178 svfloat32_t _ZGVsMxv_logf (svfloat32_t, svbool_t);
179 svfloat64_t _ZGVsMxv_log (svfloat64_t, svbool_t);
180 svfloat32_t _ZGVsMxv_log10f (svfloat32_t, svbool_t);
181 svfloat64_t _ZGVsMxv_log10 (svfloat64_t, svbool_t);
182 svfloat32_t _ZGVsMxv_log1pf (svfloat32_t, svbool_t);
183 svfloat64_t _ZGVsMxv_log1p (svfloat64_t, svbool_t);
184 svfloat32_t _ZGVsMxv_log2f (svfloat32_t, svbool_t);
185 svfloat64_t _ZGVsMxv_log2 (svfloat64_t, svbool_t);
186 svfloat32_t _ZGVsMxvv_powi (svfloat32_t, svint32_t, svbool_t);
187 svfloat64_t _ZGVsMxvv_powk (svfloat64_t, svint64_t, svbool_t);
188 svfloat32_t _ZGVsMxvv_powf (svfloat32_t, svfloat32_t, svbool_t);
189 svfloat64_t _ZGVsMxvv_pow (svfloat64_t, svfloat64_t, svbool_t);
190 svfloat32_t _ZGVsMxv_sinhf (svfloat32_t, svbool_t);
191 svfloat64_t _ZGVsMxv_sinh (svfloat64_t, svbool_t);
192 svfloat32_t _ZGVsMxv_sinf (svfloat32_t, svbool_t);
193 svfloat32_t _ZGVsMxv_sinpif (svfloat32_t, svbool_t);
194 svfloat64_t _ZGVsMxv_sin (svfloat64_t, svbool_t);
195 svfloat64_t _ZGVsMxv_sinpi (svfloat64_t, svbool_t);
196 svfloat32_t _ZGVsMxv_tanhf (svfloat32_t, svbool_t);
197 svfloat64_t _ZGVsMxv_tanh (svfloat64_t, svbool_t);
198 svfloat32_t _ZGVsMxv_tanf (svfloat32_t, svbool_t);
199 svfloat64_t _ZGVsMxv_tan (svfloat64_t, svbool_t);
200 void _ZGVsMxvl4l4_sincosf (svfloat32_t, float *, float *, svbool_t);
201 void _ZGVsMxvl8l8_sincos (svfloat64_t, double *, double *, svbool_t);
202 # endif
203 
204 #endif
205 
206 #endif
207