xref: /freebsd/contrib/arm-optimized-routines/pl/math/test/pl_test.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /*
2  * PL macros for emitting various details about routines for consumption by
3  * runulp.sh.
4  *
5  * Copyright (c) 2022-2023, Arm Limited.
6  * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception.
7  */
8 
9 /* Emit the max ULP threshold, l, for routine f. Piggy-back PL_TEST_EXPECT_FENV
10    on PL_TEST_ULP to add EXPECT_FENV to all scalar routines.  */
11 #if WANT_VMATH || defined(IGNORE_SCALAR_FENV)
12 # define PL_TEST_ULP(f, l) PL_TEST_ULP f l
13 #else
14 # define PL_TEST_ULP(f, l)                                                   \
15     PL_TEST_EXPECT_FENV_ALWAYS (f)                                            \
16     PL_TEST_ULP f l
17 #endif
18 
19 /* Emit routine name if e == 1 and f is expected to correctly trigger fenv
20    exceptions. e allows declaration to be emitted conditionally upon certain
21    build flags - defer expansion by one pass to allow those flags to be expanded
22    properly.  */
23 #define PL_TEST_EXPECT_FENV(f, e) PL_TEST_EXPECT_FENV_ (f, e)
24 #define PL_TEST_EXPECT_FENV_(f, e) PL_TEST_EXPECT_FENV_##e (f)
25 #define PL_TEST_EXPECT_FENV_1(f) PL_TEST_EXPECT_FENV_ENABLED f
26 #define PL_TEST_EXPECT_FENV_ALWAYS(f) PL_TEST_EXPECT_FENV (f, 1)
27 
28 #define PL_TEST_INTERVAL(f, lo, hi, n) PL_TEST_INTERVAL f lo hi n
29 #define PL_TEST_SYM_INTERVAL(f, lo, hi, n)                                    \
30   PL_TEST_INTERVAL (f, lo, hi, n)                                             \
31   PL_TEST_INTERVAL (f, -lo, -hi, n)
32 #define PL_TEST_INTERVAL_C(f, lo, hi, n, c) PL_TEST_INTERVAL f lo hi n c
33 #define PL_TEST_SYM_INTERVAL_C(f, lo, hi, n, c)                               \
34   PL_TEST_INTERVAL_C (f, lo, hi, n, c)                                        \
35   PL_TEST_INTERVAL_C (f, -lo, -hi, n, c)
36 // clang-format off
37 #define PL_TEST_INTERVAL2(f, xlo, xhi, ylo, yhi, n)                            \
38   PL_TEST_INTERVAL f xlo,ylo xhi,yhi n
39 // clang-format on
40