xf.li | bfc6e71 | 2025-02-07 01:54:34 -0800 | [diff] [blame^] | 1 | #define _FP_W_TYPE_SIZE 32 |
| 2 | #define _FP_W_TYPE unsigned long |
| 3 | #define _FP_WS_TYPE signed long |
| 4 | #define _FP_I_TYPE long |
| 5 | |
| 6 | #define _FP_MUL_MEAT_S(R,X,Y) \ |
| 7 | _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) |
| 8 | #define _FP_MUL_MEAT_D(R,X,Y) \ |
| 9 | _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) |
| 10 | #define _FP_MUL_MEAT_Q(R,X,Y) \ |
| 11 | _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) |
| 12 | |
| 13 | #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y) |
| 14 | #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y) |
| 15 | #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y) |
| 16 | |
| 17 | #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1) |
| 18 | #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1 |
| 19 | #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1 |
| 20 | #define _FP_NANSIGN_S 0 |
| 21 | #define _FP_NANSIGN_D 0 |
| 22 | #define _FP_NANSIGN_Q 0 |
| 23 | |
| 24 | #define _FP_KEEPNANFRACP 1 |
| 25 | #define _FP_QNANNEGATEDP 0 |
| 26 | |
| 27 | /* Someone please check this. */ |
| 28 | #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ |
| 29 | do { \ |
| 30 | if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \ |
| 31 | && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \ |
| 32 | { \ |
| 33 | R##_s = Y##_s; \ |
| 34 | _FP_FRAC_COPY_##wc(R,Y); \ |
| 35 | } \ |
| 36 | else \ |
| 37 | { \ |
| 38 | R##_s = X##_s; \ |
| 39 | _FP_FRAC_COPY_##wc(R,X); \ |
| 40 | } \ |
| 41 | R##_c = FP_CLS_NAN; \ |
| 42 | } while (0) |
| 43 | |
| 44 | #define _FP_TININESS_AFTER_ROUNDING 0 |
| 45 | |
| 46 | #if defined __NO_FPRS__ && !defined _SOFT_FLOAT |
| 47 | |
| 48 | /* Exception flags. We use the bit positions of the appropriate bits |
| 49 | in the FPEFSCR. */ |
| 50 | |
| 51 | # include <fenv_libc.h> |
| 52 | # include <sysdep.h> |
| 53 | # include <sys/prctl.h> |
| 54 | |
| 55 | int __feraiseexcept_soft (int); |
| 56 | libc_hidden_proto (__feraiseexcept_soft) |
| 57 | |
| 58 | # define FP_EX_INEXACT SPEFSCR_FINXS |
| 59 | # define FP_EX_INVALID SPEFSCR_FINVS |
| 60 | # define FP_EX_DIVZERO SPEFSCR_FDBZS |
| 61 | # define FP_EX_UNDERFLOW SPEFSCR_FUNFS |
| 62 | # define FP_EX_OVERFLOW SPEFSCR_FOVFS |
| 63 | |
| 64 | # define _FP_DECL_EX \ |
| 65 | int _spefscr __attribute__ ((unused)), _ftrapex __attribute__ ((unused)) = 0 |
| 66 | # define FP_INIT_ROUNDMODE \ |
| 67 | do \ |
| 68 | { \ |
| 69 | int _r; \ |
| 70 | INTERNAL_SYSCALL_DECL (_err); \ |
| 71 | \ |
| 72 | _spefscr = fegetenv_register (); \ |
| 73 | _r = INTERNAL_SYSCALL (prctl, _err, 2, PR_GET_FPEXC, &_ftrapex); \ |
| 74 | if (INTERNAL_SYSCALL_ERROR_P (_r, _err)) \ |
| 75 | _ftrapex = 0; \ |
| 76 | } \ |
| 77 | while (0) |
| 78 | # define FP_INIT_EXCEPTIONS /* Empty. */ |
| 79 | |
| 80 | # define FP_HANDLE_EXCEPTIONS __feraiseexcept_soft (_fex) |
| 81 | # define FP_ROUNDMODE (_spefscr & 0x3) |
| 82 | |
| 83 | /* Not correct in general, but sufficient for the uses in soft-fp. */ |
| 84 | # define FP_TRAPPING_EXCEPTIONS (_ftrapex & PR_FP_EXC_UND \ |
| 85 | ? FP_EX_UNDERFLOW \ |
| 86 | : 0) |
| 87 | |
| 88 | #else |
| 89 | |
| 90 | /* Exception flags. We use the bit positions of the appropriate bits |
| 91 | in the FPSCR, which also correspond to the FE_* bits. This makes |
| 92 | everything easier ;-). */ |
| 93 | # define FP_EX_INVALID (1 << (31 - 2)) |
| 94 | # define FP_EX_OVERFLOW (1 << (31 - 3)) |
| 95 | # define FP_EX_UNDERFLOW (1 << (31 - 4)) |
| 96 | # define FP_EX_DIVZERO (1 << (31 - 5)) |
| 97 | # define FP_EX_INEXACT (1 << (31 - 6)) |
| 98 | |
| 99 | # define FP_HANDLE_EXCEPTIONS __simulate_exceptions (_fex) |
| 100 | # define FP_ROUNDMODE __sim_round_mode_thread |
| 101 | # define FP_TRAPPING_EXCEPTIONS \ |
| 102 | (~__sim_disabled_exceptions_thread & 0x3e000000) |
| 103 | |
| 104 | #endif |
| 105 | |
| 106 | extern __thread int __sim_exceptions_thread attribute_tls_model_ie; |
| 107 | libc_hidden_tls_proto (__sim_exceptions_thread, tls_model ("initial-exec")); |
| 108 | extern __thread int __sim_disabled_exceptions_thread attribute_tls_model_ie; |
| 109 | libc_hidden_tls_proto (__sim_disabled_exceptions_thread, |
| 110 | tls_model ("initial-exec")); |
| 111 | extern __thread int __sim_round_mode_thread attribute_tls_model_ie; |
| 112 | libc_hidden_tls_proto (__sim_round_mode_thread, tls_model ("initial-exec")); |
| 113 | |
| 114 | extern void __simulate_exceptions (int x) attribute_hidden; |