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