xref: /freebsd/contrib/arm-optimized-routines/math/include/test_sig.h (revision f3087bef11543b42e0d69b708f367097a4118d24)
1 /*
2  * Macros for emitting various ulp/bench entries based on function signature
3  *
4  * Copyright (c) 2024, Arm Limited.
5  * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception.
6  */
7 
8 #define TEST_DECL_SF1(fun) float fun##f (float);
9 #define TEST_DECL_SF2(fun) float fun##f (float, float);
10 #define TEST_DECL_SD1(fun) double fun (double);
11 #define TEST_DECL_SD2(fun) double fun (double, double);
12 
13 #define TEST_DECL_VF1(fun)                                                    \
14   float32x4_t VPCS_ATTR V_NAME_F1 (fun##f) (float32x4_t);
15 #define TEST_DECL_VF2(fun)                                                    \
16   float32x4_t VPCS_ATTR V_NAME_F2 (fun##f) (float32x4_t, float32x4_t);
17 #define TEST_DECL_VD1(fun) VPCS_ATTR float64x2_t V_NAME_D1 (fun) (float64x2_t);
18 #define TEST_DECL_VD2(fun)                                                    \
19   VPCS_ATTR float64x2_t V_NAME_D2 (fun) (float64x2_t, float64x2_t);
20 
21 #define TEST_DECL_SVF1(fun)                                                   \
22   svfloat32_t SV_NAME_F1 (fun) (svfloat32_t, svbool_t);
23 #define TEST_DECL_SVF2(fun)                                                   \
24   svfloat32_t SV_NAME_F2 (fun) (svfloat32_t, svfloat32_t, svbool_t);
25 #define TEST_DECL_SVD1(fun)                                                   \
26   svfloat64_t SV_NAME_D1 (fun) (svfloat64_t, svbool_t);
27 #define TEST_DECL_SVD2(fun)                                                   \
28   svfloat64_t SV_NAME_D2 (fun) (svfloat64_t, svfloat64_t, svbool_t);
29 
30 /* For building the routines, emit function prototype from TEST_SIG. This
31    ensures that the correct signature has been chosen (wrong one will be a
32    compile error). TEST_SIG is defined differently by various components of the
33    build system to emit entries in the wrappers and entries for mathbench and
34    ulp.  */
35 #ifndef _TEST_SIG
36 # if defined(EMIT_ULP_FUNCS)
37 #  define _TEST_SIG(v, t, a, f, ...) TEST_SIG _Z##v##t##a (f)
38 # elif defined(EMIT_ULP_WRAPPERS)
39 #  define _TEST_SIG(v, t, a, f, ...) TEST_SIG Z##v##N##t##a##_WRAP (f)
40 # elif defined(EMIT_MATHBENCH_FUNCS)
41 #  define _TEST_SIG(v, t, a, f, ...) TEST_SIG _Z##v##t##a (f, ##__VA_ARGS__)
42 # else
43 #  define _TEST_SIG(v, t, a, f, ...) TEST_DECL_##v##t##a (f)
44 # endif
45 #endif
46 
47 #define TEST_SIG(...) _TEST_SIG (__VA_ARGS__)
48