xref: /freebsd/contrib/arm-optimized-routines/pl/math/test/pl_test.h (revision 5a02ffc32e777041dd2dad4e651ed2a0865a0a5d)
1072a4ba8SAndrew Turner /*
2072a4ba8SAndrew Turner  * PL macros for emitting various details about routines for consumption by
3072a4ba8SAndrew Turner  * runulp.sh.
4072a4ba8SAndrew Turner  *
5072a4ba8SAndrew Turner  * Copyright (c) 2022-2023, Arm Limited.
6072a4ba8SAndrew Turner  * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception.
7072a4ba8SAndrew Turner  */
8072a4ba8SAndrew Turner 
9072a4ba8SAndrew Turner /* Emit the max ULP threshold, l, for routine f. Piggy-back PL_TEST_EXPECT_FENV
10072a4ba8SAndrew Turner    on PL_TEST_ULP to add EXPECT_FENV to all scalar routines.  */
11*5a02ffc3SAndrew Turner #if WANT_VMATH || defined(IGNORE_SCALAR_FENV)
12*5a02ffc3SAndrew Turner # define PL_TEST_ULP(f, l) PL_TEST_ULP f l
13*5a02ffc3SAndrew Turner #else
14072a4ba8SAndrew Turner # define PL_TEST_ULP(f, l)                                                   \
15072a4ba8SAndrew Turner     PL_TEST_EXPECT_FENV_ALWAYS (f)                                            \
16072a4ba8SAndrew Turner     PL_TEST_ULP f l
17072a4ba8SAndrew Turner #endif
18072a4ba8SAndrew Turner 
19072a4ba8SAndrew Turner /* Emit routine name if e == 1 and f is expected to correctly trigger fenv
20072a4ba8SAndrew Turner    exceptions. e allows declaration to be emitted conditionally upon certain
21072a4ba8SAndrew Turner    build flags - defer expansion by one pass to allow those flags to be expanded
22072a4ba8SAndrew Turner    properly.  */
23072a4ba8SAndrew Turner #define PL_TEST_EXPECT_FENV(f, e) PL_TEST_EXPECT_FENV_ (f, e)
24072a4ba8SAndrew Turner #define PL_TEST_EXPECT_FENV_(f, e) PL_TEST_EXPECT_FENV_##e (f)
25072a4ba8SAndrew Turner #define PL_TEST_EXPECT_FENV_1(f) PL_TEST_EXPECT_FENV_ENABLED f
26072a4ba8SAndrew Turner #define PL_TEST_EXPECT_FENV_ALWAYS(f) PL_TEST_EXPECT_FENV (f, 1)
27072a4ba8SAndrew Turner 
28072a4ba8SAndrew Turner #define PL_TEST_INTERVAL(f, lo, hi, n) PL_TEST_INTERVAL f lo hi n
29*5a02ffc3SAndrew Turner #define PL_TEST_SYM_INTERVAL(f, lo, hi, n)                                    \
30*5a02ffc3SAndrew Turner   PL_TEST_INTERVAL (f, lo, hi, n)                                             \
31*5a02ffc3SAndrew Turner   PL_TEST_INTERVAL (f, -lo, -hi, n)
32072a4ba8SAndrew Turner #define PL_TEST_INTERVAL_C(f, lo, hi, n, c) PL_TEST_INTERVAL f lo hi n c
33*5a02ffc3SAndrew Turner #define PL_TEST_SYM_INTERVAL_C(f, lo, hi, n, c)                               \
34*5a02ffc3SAndrew Turner   PL_TEST_INTERVAL_C (f, lo, hi, n, c)                                        \
35*5a02ffc3SAndrew Turner   PL_TEST_INTERVAL_C (f, -lo, -hi, n, c)
36*5a02ffc3SAndrew Turner // clang-format off
37*5a02ffc3SAndrew Turner #define PL_TEST_INTERVAL2(f, xlo, xhi, ylo, yhi, n)                            \
38*5a02ffc3SAndrew Turner   PL_TEST_INTERVAL f xlo,ylo xhi,yhi n
39*5a02ffc3SAndrew Turner // clang-format on
40