Path: blob/main/contrib/arm-optimized-routines/math/test/rtest/wrappers.h
48375 views
/*1* wrappers.h - wrappers to modify output of MPFR/MPC test functions2*3* Copyright (c) 2014-2019, Arm Limited.4* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception5*/67typedef struct {8/* Structure type should be considered opaque outside wrappers.c,9* though we have to define it here so its size is known. */10int nops;11int nresults;12mpfr_srcptr mpfr_ops[2];13mpfr_ptr mpfr_result;14mpc_srcptr mpc_ops[2];15mpc_ptr mpc_result;16const uint32 *ieee_ops[2];17uint32 *ieee_result;18int size_ops[2];19int size_result;20int need_regen;21} wrapperctx;2223typedef void (*wrapperfunc)(wrapperctx *ctx);24#define MAXWRAPPERS 32526/*27* Functions for the test harness to call.28*29* When the test harness executes a test function, it should30* initialise a wrapperctx with wrapper_init, then provide all the31* operands and results in both mpfr/mpc and IEEE (+ extrabits)32* formats via wrapper_op_* and wrapper_result_*. Then it should run33* the function's wrappers using wrapper_run(), and if that returns34* true then the primary result has been rewritten in mpfr/mpc format35* and it should therefore retranslate into IEEE.36*37* 'size' in all prototypes below represents an FP type by giving the38* number of 32-bit words it requires, so 1=float and 2=double. Input39* operands will be that many words (or that many for both their real40* and imag parts); outputs will have one extra word for 'extrabits'.41*42* This system only applies at all to reference functions using43* mpfr/mpc. The seminumerical functions we implement in pure IEEE44* form are expected to handle all their own special cases correctly.45*/4647void wrapper_init(wrapperctx *ctx);4849/* Real operand. */50void wrapper_op_real(wrapperctx *ctx, const mpfr_t r,51int size, const uint32 *ieee);5253/* Complex operand. Real part starts at ieee[0], the imag part at ieee[2]. */54void wrapper_op_complex(wrapperctx *ctx, const mpc_t c,55int size, const uint32 *ieee);5657/* Real result. ieee contains size+1 words, as discussed above. */58void wrapper_result_real(wrapperctx *ctx, mpfr_t r,59int size, uint32 *ieee);6061/* Complex result. ieee contains size+1 words of real part starting at62* ieee[0], and another size+1 of imag part starting at ieee[4]. */63void wrapper_result_complex(wrapperctx *ctx, mpc_t c,64int size, uint32 *ieee);6566int wrapper_run(wrapperctx *ctx, wrapperfunc wrappers[MAXWRAPPERS]);6768/*69* Functions for wrappers to call. 'op' indicates which operand is70* being requested: 0,1 means first and second, and -1 means the71* result.72*/7374mpfr_srcptr wrapper_get_mpfr(wrapperctx *ctx, int op);75const uint32 *wrapper_get_ieee(wrapperctx *ctx, int op);7677mpc_srcptr wrapper_get_mpc(wrapperctx *ctx, int op);78mpfr_srcptr wrapper_get_mpfr_r(wrapperctx *ctx, int op);79mpfr_srcptr wrapper_get_mpfr_i(wrapperctx *ctx, int op);80const uint32 *wrapper_get_ieee_r(wrapperctx *ctx, int op);81const uint32 *wrapper_get_ieee_i(wrapperctx *ctx, int op);8283/* Query operand count + types */84int wrapper_get_nops(wrapperctx *ctx);85int wrapper_get_size(wrapperctx *ctx, int op);86int wrapper_is_complex(wrapperctx *ctx, int op);8788/* Change just the sign of the result. Only the top bit of 'sign' is used. */89void wrapper_set_sign(wrapperctx *ctx, uint32 sign);90void wrapper_set_sign_r(wrapperctx *ctx, uint32 sign);91void wrapper_set_sign_i(wrapperctx *ctx, uint32 sign);9293/* Set a result to NaN. */94void wrapper_set_nan(wrapperctx *ctx);95void wrapper_set_nan_r(wrapperctx *ctx);96void wrapper_set_nan_i(wrapperctx *ctx);9798/* Set a result to an integer value (converted to the appropriate99* float format). */100void wrapper_set_int(wrapperctx *ctx, int val);101void wrapper_set_int_r(wrapperctx *ctx, int val);102void wrapper_set_int_i(wrapperctx *ctx, int val);103104/* Set a result to a new MPFR float. */105void wrapper_set_mpfr(wrapperctx *ctx, const mpfr_t val);106void wrapper_set_mpfr_r(wrapperctx *ctx, const mpfr_t val);107void wrapper_set_mpfr_i(wrapperctx *ctx, const mpfr_t val);108109/*110* A universal wrapper called for _all_ functions, that doesn't have111* to be specified individually everywhere.112*/113void universal_wrapper(wrapperctx *ctx);114115116