Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / AOR_v20.02 / math / test / rtest / wrappers.h
blobe2e653a0f01e15017d4a20e548046ca9c7abc1ac
1 /*
2 * wrappers.h - wrappers to modify output of MPFR/MPC test functions
4 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 * See https://llvm.org/LICENSE.txt for license information.
6 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 */
9 typedef struct {
10 /* Structure type should be considered opaque outside wrappers.c,
11 * though we have to define it here so its size is known. */
12 int nops;
13 int nresults;
14 mpfr_srcptr mpfr_ops[2];
15 mpfr_ptr mpfr_result;
16 mpc_srcptr mpc_ops[2];
17 mpc_ptr mpc_result;
18 const uint32 *ieee_ops[2];
19 uint32 *ieee_result;
20 int size_ops[2];
21 int size_result;
22 int need_regen;
23 } wrapperctx;
25 typedef void (*wrapperfunc)(wrapperctx *ctx);
26 #define MAXWRAPPERS 3
29 * Functions for the test harness to call.
31 * When the test harness executes a test function, it should
32 * initialise a wrapperctx with wrapper_init, then provide all the
33 * operands and results in both mpfr/mpc and IEEE (+ extrabits)
34 * formats via wrapper_op_* and wrapper_result_*. Then it should run
35 * the function's wrappers using wrapper_run(), and if that returns
36 * true then the primary result has been rewritten in mpfr/mpc format
37 * and it should therefore retranslate into IEEE.
39 * 'size' in all prototypes below represents an FP type by giving the
40 * number of 32-bit words it requires, so 1=float and 2=double. Input
41 * operands will be that many words (or that many for both their real
42 * and imag parts); outputs will have one extra word for 'extrabits'.
44 * This system only applies at all to reference functions using
45 * mpfr/mpc. The seminumerical functions we implement in pure IEEE
46 * form are expected to handle all their own special cases correctly.
49 void wrapper_init(wrapperctx *ctx);
51 /* Real operand. */
52 void wrapper_op_real(wrapperctx *ctx, const mpfr_t r,
53 int size, const uint32 *ieee);
55 /* Complex operand. Real part starts at ieee[0], the imag part at ieee[2]. */
56 void wrapper_op_complex(wrapperctx *ctx, const mpc_t c,
57 int size, const uint32 *ieee);
59 /* Real result. ieee contains size+1 words, as discussed above. */
60 void wrapper_result_real(wrapperctx *ctx, mpfr_t r,
61 int size, uint32 *ieee);
63 /* Complex result. ieee contains size+1 words of real part starting at
64 * ieee[0], and another size+1 of imag part starting at ieee[4]. */
65 void wrapper_result_complex(wrapperctx *ctx, mpc_t c,
66 int size, uint32 *ieee);
68 int wrapper_run(wrapperctx *ctx, wrapperfunc wrappers[MAXWRAPPERS]);
71 * Functions for wrappers to call. 'op' indicates which operand is
72 * being requested: 0,1 means first and second, and -1 means the
73 * result.
76 mpfr_srcptr wrapper_get_mpfr(wrapperctx *ctx, int op);
77 const uint32 *wrapper_get_ieee(wrapperctx *ctx, int op);
79 mpc_srcptr wrapper_get_mpc(wrapperctx *ctx, int op);
80 mpfr_srcptr wrapper_get_mpfr_r(wrapperctx *ctx, int op);
81 mpfr_srcptr wrapper_get_mpfr_i(wrapperctx *ctx, int op);
82 const uint32 *wrapper_get_ieee_r(wrapperctx *ctx, int op);
83 const uint32 *wrapper_get_ieee_i(wrapperctx *ctx, int op);
85 /* Query operand count + types */
86 int wrapper_get_nops(wrapperctx *ctx);
87 int wrapper_get_size(wrapperctx *ctx, int op);
88 int wrapper_is_complex(wrapperctx *ctx, int op);
90 /* Change just the sign of the result. Only the top bit of 'sign' is used. */
91 void wrapper_set_sign(wrapperctx *ctx, uint32 sign);
92 void wrapper_set_sign_r(wrapperctx *ctx, uint32 sign);
93 void wrapper_set_sign_i(wrapperctx *ctx, uint32 sign);
95 /* Set a result to NaN. */
96 void wrapper_set_nan(wrapperctx *ctx);
97 void wrapper_set_nan_r(wrapperctx *ctx);
98 void wrapper_set_nan_i(wrapperctx *ctx);
100 /* Set a result to an integer value (converted to the appropriate
101 * float format). */
102 void wrapper_set_int(wrapperctx *ctx, int val);
103 void wrapper_set_int_r(wrapperctx *ctx, int val);
104 void wrapper_set_int_i(wrapperctx *ctx, int val);
106 /* Set a result to a new MPFR float. */
107 void wrapper_set_mpfr(wrapperctx *ctx, const mpfr_t val);
108 void wrapper_set_mpfr_r(wrapperctx *ctx, const mpfr_t val);
109 void wrapper_set_mpfr_i(wrapperctx *ctx, const mpfr_t val);
112 * A universal wrapper called for _all_ functions, that doesn't have
113 * to be specified individually everywhere.
115 void universal_wrapper(wrapperctx *ctx);