1 // clang-format off 2 /* 3 * Public API. 4 * 5 * Copyright (c) 2015-2023, Arm Limited. 6 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception 7 */ 8 9 #ifndef _MATHLIB_H 10 #define _MATHLIB_H 11 12 float acoshf (float); 13 float asinhf (float); 14 float atan2f (float, float); 15 float atanf (float); 16 float atanhf (float); 17 float cbrtf (float); 18 float coshf (float); 19 float erfcf (float); 20 float erff (float); 21 float expm1f (float); 22 float log10f (float); 23 float log1pf (float); 24 float sinhf (float); 25 float tanf (float); 26 float tanhf (float); 27 28 double acosh (double); 29 double asinh (double); 30 double atan (double); 31 double atan2 (double, double); 32 double atanh (double); 33 double cbrt (double); 34 double cosh (double); 35 double erfc (double); 36 double expm1 (double); 37 double log10 (double); 38 double log1p (double); 39 double sinh (double); 40 double tanh (double); 41 42 float __s_acoshf (float); 43 float __s_asinhf (float); 44 float __s_atanf (float); 45 float __s_atan2f (float, float); 46 float __s_atanhf (float); 47 float __s_cbrtf (float); 48 float __s_coshf (float); 49 float __s_erfcf (float); 50 float __s_erff (float); 51 float __s_expm1f (float); 52 float __s_log10f (float); 53 float __s_log1pf (float); 54 float __s_log2f (float); 55 float __s_sinhf (float); 56 float __s_tanf (float); 57 float __s_tanhf (float); 58 59 double __s_acosh (double); 60 double __s_asinh (double); 61 double __s_atan (double); 62 double __s_atan2 (double, double); 63 double __s_atanh (double); 64 double __s_cbrt (double); 65 double __s_cosh (double); 66 double __s_erf (double); 67 double __s_erfc (double); 68 double __s_expm1 (double); 69 double __s_log10 (double); 70 double __s_log1p (double); 71 double __s_log2 (double); 72 double __s_sinh (double); 73 double __s_tan (double); 74 double __s_tanh (double); 75 76 #if __aarch64__ 77 #if __GNUC__ >= 5 78 typedef __Float32x4_t __f32x4_t; 79 typedef __Float64x2_t __f64x2_t; 80 #elif __clang_major__*100+__clang_minor__ >= 305 81 typedef __attribute__((__neon_vector_type__(4))) float __f32x4_t; 82 typedef __attribute__((__neon_vector_type__(2))) double __f64x2_t; 83 #else 84 #error Unsupported compiler 85 #endif 86 87 /* Vector functions following the base PCS. */ 88 __f32x4_t __v_acoshf (__f32x4_t); 89 __f64x2_t __v_acosh (__f64x2_t); 90 __f32x4_t __v_asinhf (__f32x4_t); 91 __f64x2_t __v_asinh (__f64x2_t); 92 __f32x4_t __v_atanf (__f32x4_t); 93 __f64x2_t __v_atan (__f64x2_t); 94 __f32x4_t __v_atan2f (__f32x4_t, __f32x4_t); 95 __f64x2_t __v_atan2 (__f64x2_t, __f64x2_t); 96 __f32x4_t __v_atanhf (__f32x4_t); 97 __f64x2_t __v_atanh (__f64x2_t); 98 __f32x4_t __v_cbrtf (__f32x4_t); 99 __f64x2_t __v_cbrt (__f64x2_t); 100 __f32x4_t __v_coshf (__f32x4_t); 101 __f64x2_t __v_cosh (__f64x2_t); 102 __f32x4_t __v_erff (__f32x4_t); 103 __f64x2_t __v_erf (__f64x2_t); 104 __f32x4_t __v_erfcf (__f32x4_t); 105 __f64x2_t __v_erfc (__f64x2_t); 106 __f32x4_t __v_expm1f (__f32x4_t); 107 __f64x2_t __v_expm1 (__f64x2_t); 108 __f32x4_t __v_log10f (__f32x4_t); 109 __f64x2_t __v_log10 (__f64x2_t); 110 __f32x4_t __v_log1pf (__f32x4_t); 111 __f64x2_t __v_log1p (__f64x2_t); 112 __f32x4_t __v_log2f (__f32x4_t); 113 __f64x2_t __v_log2 (__f64x2_t); 114 __f32x4_t __v_sinhf (__f32x4_t); 115 __f64x2_t __v_sinh (__f64x2_t); 116 __f32x4_t __v_tanf (__f32x4_t); 117 __f64x2_t __v_tan (__f64x2_t); 118 __f32x4_t __v_tanhf (__f32x4_t); 119 __f64x2_t __v_tanh (__f64x2_t); 120 121 #if __GNUC__ >= 9 || __clang_major__ >= 8 122 #define __vpcs __attribute__((__aarch64_vector_pcs__)) 123 124 /* Vector functions following the vector PCS. */ 125 __vpcs __f32x4_t __vn_acoshf (__f32x4_t); 126 __vpcs __f64x2_t __vn_acosh (__f64x2_t); 127 __vpcs __f32x4_t __vn_asinhf (__f32x4_t); 128 __vpcs __f64x2_t __vn_asinh (__f64x2_t); 129 __vpcs __f32x4_t __vn_atanf (__f32x4_t); 130 __vpcs __f64x2_t __vn_atan (__f64x2_t); 131 __vpcs __f32x4_t __vn_atan2f (__f32x4_t, __f32x4_t); 132 __vpcs __f64x2_t __vn_atan2 (__f64x2_t, __f64x2_t); 133 __vpcs __f32x4_t __vn_atanhf (__f32x4_t); 134 __vpcs __f64x2_t __vn_atanh (__f64x2_t); 135 __vpcs __f32x4_t __vn_cbrtf (__f32x4_t); 136 __vpcs __f64x2_t __vn_cbrt (__f64x2_t); 137 __vpcs __f32x4_t __vn_coshf (__f32x4_t); 138 __vpcs __f64x2_t __vn_cosh (__f64x2_t); 139 __vpcs __f32x4_t __vn_erff (__f32x4_t); 140 __vpcs __f64x2_t __vn_erf (__f64x2_t); 141 __vpcs __f32x4_t __vn_erfcf (__f32x4_t); 142 __vpcs __f64x2_t __vn_erfc (__f64x2_t); 143 __vpcs __f32x4_t __vn_expm1f (__f32x4_t); 144 __vpcs __f64x2_t __vn_expm1 (__f64x2_t); 145 __vpcs __f32x4_t __vn_log10f (__f32x4_t); 146 __vpcs __f64x2_t __vn_log10 (__f64x2_t); 147 __vpcs __f32x4_t __vn_log1pf (__f32x4_t); 148 __vpcs __f64x2_t __vn_log1p (__f64x2_t); 149 __vpcs __f32x4_t __vn_log2f (__f32x4_t); 150 __vpcs __f64x2_t __vn_log2 (__f64x2_t); 151 __vpcs __f32x4_t __vn_sinhf (__f32x4_t); 152 __vpcs __f64x2_t __vn_sinh (__f64x2_t); 153 __vpcs __f32x4_t __vn_tanf (__f32x4_t); 154 __vpcs __f64x2_t __vn_tan (__f64x2_t); 155 __vpcs __f32x4_t __vn_tanhf (__f32x4_t); 156 __vpcs __f64x2_t __vn_tanh (__f64x2_t); 157 158 /* Vector functions following the vector PCS using ABI names. */ 159 __vpcs __f32x4_t _ZGVnN4v_acoshf (__f32x4_t); 160 __vpcs __f64x2_t _ZGVnN2v_acosh (__f64x2_t); 161 __vpcs __f32x4_t _ZGVnN4v_asinhf (__f32x4_t); 162 __vpcs __f64x2_t _ZGVnN2v_asinh (__f64x2_t); 163 __vpcs __f32x4_t _ZGVnN4v_atanf (__f32x4_t); 164 __vpcs __f64x2_t _ZGVnN2v_atan (__f64x2_t); 165 __vpcs __f32x4_t _ZGVnN4vv_atan2f (__f32x4_t, __f32x4_t); 166 __vpcs __f64x2_t _ZGVnN2vv_atan2 (__f64x2_t, __f64x2_t); 167 __vpcs __f32x4_t _ZGVnN4v_atanhf (__f32x4_t); 168 __vpcs __f64x2_t _ZGVnN2v_atanh (__f64x2_t); 169 __vpcs __f32x4_t _ZGVnN4v_cbrtf (__f32x4_t); 170 __vpcs __f64x2_t _ZGVnN2v_cbrt (__f64x2_t); 171 __vpcs __f32x4_t _ZGVnN4v_coshf (__f32x4_t); 172 __vpcs __f64x2_t _ZGVnN2v_cosh (__f64x2_t); 173 __vpcs __f32x4_t _ZGVnN4v_erff (__f32x4_t); 174 __vpcs __f64x2_t _ZGVnN2v_erf (__f64x2_t); 175 __vpcs __f32x4_t _ZGVnN4v_erfcf (__f32x4_t); 176 __vpcs __f64x2_t _ZGVnN2v_erfc (__f64x2_t); 177 __vpcs __f32x4_t _ZGVnN4v_expm1f (__f32x4_t); 178 __vpcs __f64x2_t _ZGVnN2v_expm1 (__f64x2_t); 179 __vpcs __f32x4_t _ZGVnN4v_log10f (__f32x4_t); 180 __vpcs __f64x2_t _ZGVnN2v_log10 (__f64x2_t); 181 __vpcs __f32x4_t _ZGVnN4v_log1pf (__f32x4_t); 182 __vpcs __f64x2_t _ZGVnN2v_log1p (__f64x2_t); 183 __vpcs __f32x4_t _ZGVnN4v_log2f (__f32x4_t); 184 __vpcs __f64x2_t _ZGVnN2v_log2 (__f64x2_t); 185 __vpcs __f32x4_t _ZGVnN4v_sinhf (__f32x4_t); 186 __vpcs __f64x2_t _ZGVnN2v_sinh (__f64x2_t); 187 __vpcs __f32x4_t _ZGVnN4v_tanf (__f32x4_t); 188 __vpcs __f64x2_t _ZGVnN2v_tan (__f64x2_t); 189 __vpcs __f32x4_t _ZGVnN4v_tanhf (__f32x4_t); 190 __vpcs __f64x2_t _ZGVnN2v_tanh (__f64x2_t); 191 192 #endif 193 194 #if WANT_SVE_MATH 195 #include <arm_sve.h> 196 svfloat32_t __sv_atan2f_x (svfloat32_t, svfloat32_t, svbool_t); 197 svfloat32_t __sv_atanf_x (svfloat32_t, svbool_t); 198 svfloat64_t __sv_atan_x (svfloat64_t, svbool_t); 199 svfloat64_t __sv_atan2_x (svfloat64_t, svfloat64_t, svbool_t); 200 svfloat32_t __sv_cosf_x (svfloat32_t, svbool_t); 201 svfloat64_t __sv_cos_x (svfloat64_t, svbool_t); 202 svfloat32_t __sv_erff_x (svfloat32_t, svbool_t); 203 svfloat64_t __sv_erf_x (svfloat64_t, svbool_t); 204 svfloat64_t __sv_erfc_x (svfloat64_t, svbool_t); 205 svfloat32_t __sv_expf_x (svfloat32_t, svbool_t); 206 svfloat32_t __sv_logf_x (svfloat32_t, svbool_t); 207 svfloat64_t __sv_log_x (svfloat64_t, svbool_t); 208 svfloat32_t __sv_log10f_x (svfloat32_t, svbool_t); 209 svfloat64_t __sv_log10_x (svfloat64_t, svbool_t); 210 svfloat32_t __sv_log2f_x (svfloat32_t, svbool_t); 211 svfloat64_t __sv_log2_x (svfloat64_t, svbool_t); 212 svfloat32_t __sv_powif_x (svfloat32_t, svint32_t, svbool_t); 213 svfloat64_t __sv_powi_x (svfloat64_t, svint64_t, svbool_t); 214 svfloat32_t __sv_sinf_x (svfloat32_t, svbool_t); 215 svfloat64_t __sv_sin_x (svfloat64_t, svbool_t); 216 svfloat32_t __sv_tanf_x (svfloat32_t, svbool_t); 217 /* SVE ABI names. */ 218 svfloat32_t _ZGVsMxvv_atan2f (svfloat32_t, svfloat32_t, svbool_t); 219 svfloat32_t _ZGVsMxv_atanf (svfloat32_t, svbool_t); 220 svfloat64_t _ZGVsMxv_atan (svfloat64_t, svbool_t); 221 svfloat64_t _ZGVsMxvv_atan2 (svfloat64_t, svfloat64_t, svbool_t); 222 svfloat32_t _ZGVsMxv_cosf (svfloat32_t, svbool_t); 223 svfloat64_t _ZGVsMxv_cos (svfloat64_t, svbool_t); 224 svfloat32_t _ZGVsMxv_erff (svfloat32_t, svbool_t); 225 svfloat64_t _ZGVsMxv_erf (svfloat64_t, svbool_t); 226 svfloat64_t _ZGVsMxv_erfc (svfloat64_t, svbool_t); 227 svfloat32_t _ZGVsMxv_expf (svfloat32_t, svbool_t); 228 svfloat32_t _ZGVsMxv_logf (svfloat32_t, svbool_t); 229 svfloat64_t _ZGVsMxv_log (svfloat64_t, svbool_t); 230 svfloat32_t _ZGVsMxv_log10f (svfloat32_t, svbool_t); 231 svfloat64_t _ZGVsMxv_log10 (svfloat64_t, svbool_t); 232 svfloat32_t _ZGVsMxv_log2f (svfloat32_t, svbool_t); 233 svfloat64_t _ZGVsMxv_log2 (svfloat64_t, svbool_t); 234 svfloat32_t _ZGVsMxvv_powi(svfloat32_t, svint32_t, svbool_t); 235 svfloat64_t _ZGVsMxvv_powk(svfloat64_t, svint64_t, svbool_t); 236 svfloat32_t _ZGVsMxv_sinf (svfloat32_t, svbool_t); 237 svfloat64_t _ZGVsMxv_sin (svfloat64_t, svbool_t); 238 svfloat32_t _ZGVsMxv_tanf (svfloat32_t, svbool_t); 239 #endif 240 241 #endif 242 243 #endif 244 // clang-format on 245