1/*
2 * Function wrappers for mathbench.
3 *
4 * Copyright (c) 2022-2023, Arm Limited.
5 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
6 */
7
8static double
9atan2_wrap (double x)
10{
11  return atan2 (5.0, x);
12}
13
14static float
15atan2f_wrap (float x)
16{
17  return atan2f (5.0f, x);
18}
19
20static double
21powi_wrap (double x)
22{
23  return __builtin_powi (x, (int) round (x));
24}
25
26#if __aarch64__ && defined(__vpcs)
27
28__vpcs static v_double
29_Z_atan2_wrap (v_double x)
30{
31  return _ZGVnN2vv_atan2 (v_double_dup (5.0), x);
32}
33
34__vpcs static v_float
35_Z_atan2f_wrap (v_float x)
36{
37  return _ZGVnN4vv_atan2f (v_float_dup (5.0f), x);
38}
39
40__vpcs static v_float
41_Z_hypotf_wrap (v_float x)
42{
43  return _ZGVnN4vv_hypotf (v_float_dup (5.0f), x);
44}
45
46__vpcs static v_double
47_Z_hypot_wrap (v_double x)
48{
49  return _ZGVnN2vv_hypot (v_double_dup (5.0), x);
50}
51
52__vpcs static v_double
53xy_Z_pow (v_double x)
54{
55  return _ZGVnN2vv_pow (x, x);
56}
57
58__vpcs static v_double
59x_Z_pow (v_double x)
60{
61  return _ZGVnN2vv_pow (x, v_double_dup (23.4));
62}
63
64__vpcs static v_double
65y_Z_pow (v_double x)
66{
67  return _ZGVnN2vv_pow (v_double_dup (2.34), x);
68}
69
70__vpcs static v_float
71_Z_sincosf_wrap (v_float x)
72{
73  v_float s, c;
74  _ZGVnN4vl4l4_sincosf (x, &s, &c);
75  return s + c;
76}
77
78__vpcs static v_float
79_Z_cexpif_wrap (v_float x)
80{
81  __f32x4x2_t sc = _ZGVnN4v_cexpif (x);
82  return sc.val[0] + sc.val[1];
83}
84
85__vpcs static v_double
86_Z_sincos_wrap (v_double x)
87{
88  v_double s, c;
89  _ZGVnN2vl8l8_sincos (x, &s, &c);
90  return s + c;
91}
92
93__vpcs static v_double
94_Z_cexpi_wrap (v_double x)
95{
96  __f64x2x2_t sc = _ZGVnN2v_cexpi (x);
97  return sc.val[0] + sc.val[1];
98}
99
100#endif // __arch64__ && __vpcs
101
102#if WANT_SVE_MATH
103
104static sv_float
105_Z_sv_atan2f_wrap (sv_float x, sv_bool pg)
106{
107  return _ZGVsMxvv_atan2f (x, svdup_f32 (5.0f), pg);
108}
109
110static sv_double
111_Z_sv_atan2_wrap (sv_double x, sv_bool pg)
112{
113  return _ZGVsMxvv_atan2 (x, svdup_f64 (5.0), pg);
114}
115
116static sv_float
117_Z_sv_hypotf_wrap (sv_float x, sv_bool pg)
118{
119  return _ZGVsMxvv_hypotf (x, svdup_f32 (5.0), pg);
120}
121
122static sv_double
123_Z_sv_hypot_wrap (sv_double x, sv_bool pg)
124{
125  return _ZGVsMxvv_hypot (x, svdup_f64 (5.0), pg);
126}
127
128static sv_float
129_Z_sv_powi_wrap (sv_float x, sv_bool pg)
130{
131  return _ZGVsMxvv_powi (x, svcvt_s32_f32_x (pg, x), pg);
132}
133
134static sv_double
135_Z_sv_powk_wrap (sv_double x, sv_bool pg)
136{
137  return _ZGVsMxvv_powk (x, svcvt_s64_f64_x (pg, x), pg);
138}
139
140static sv_float
141xy_Z_sv_powf (sv_float x, sv_bool pg)
142{
143  return _ZGVsMxvv_powf (x, x, pg);
144}
145
146static sv_float
147x_Z_sv_powf (sv_float x, sv_bool pg)
148{
149  return _ZGVsMxvv_powf (x, svdup_f32 (23.4f), pg);
150}
151
152static sv_float
153y_Z_sv_powf (sv_float x, sv_bool pg)
154{
155  return _ZGVsMxvv_powf (svdup_f32 (2.34f), x, pg);
156}
157
158static sv_double
159xy_Z_sv_pow (sv_double x, sv_bool pg)
160{
161  return _ZGVsMxvv_pow (x, x, pg);
162}
163
164static sv_double
165x_Z_sv_pow (sv_double x, sv_bool pg)
166{
167  return _ZGVsMxvv_pow (x, svdup_f64 (23.4), pg);
168}
169
170static sv_double
171y_Z_sv_pow (sv_double x, sv_bool pg)
172{
173  return _ZGVsMxvv_pow (svdup_f64 (2.34), x, pg);
174}
175
176static sv_float
177_Z_sv_sincosf_wrap (sv_float x, sv_bool pg)
178{
179  float s[svcntw ()], c[svcntw ()];
180  _ZGVsMxvl4l4_sincosf (x, s, c, pg);
181  return svadd_x (pg, svld1 (pg, s), svld1 (pg, s));
182}
183
184static sv_float
185_Z_sv_cexpif_wrap (sv_float x, sv_bool pg)
186{
187  svfloat32x2_t sc = _ZGVsMxv_cexpif (x, pg);
188  return svadd_x (pg, svget2 (sc, 0), svget2 (sc, 1));
189}
190
191static sv_double
192_Z_sv_sincos_wrap (sv_double x, sv_bool pg)
193{
194  double s[svcntd ()], c[svcntd ()];
195  _ZGVsMxvl8l8_sincos (x, s, c, pg);
196  return svadd_x (pg, svld1 (pg, s), svld1 (pg, s));
197}
198
199static sv_double
200_Z_sv_cexpi_wrap (sv_double x, sv_bool pg)
201{
202  svfloat64x2_t sc = _ZGVsMxv_cexpi (x, pg);
203  return svadd_x (pg, svget2 (sc, 0), svget2 (sc, 1));
204}
205
206#endif // WANT_SVE_MATH
207