|
Packit Service |
82fcde |
/* RISC-V softfloat definitions
|
|
Packit Service |
82fcde |
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library. If not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <fenv.h>
|
|
Packit Service |
82fcde |
#include <fpu_control.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#if __riscv_xlen == 32
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# error "rv32i-based targets are not supported"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define _FP_W_TYPE_SIZE 64
|
|
Packit Service |
82fcde |
# define _FP_W_TYPE unsigned long long
|
|
Packit Service |
82fcde |
# define _FP_WS_TYPE signed long long
|
|
Packit Service |
82fcde |
# define _FP_I_TYPE long long
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define _FP_MUL_MEAT_S(R, X, Y) \
|
|
Packit Service |
82fcde |
_FP_MUL_MEAT_1_imm (_FP_WFRACBITS_S, R, X, Y)
|
|
Packit Service |
82fcde |
# define _FP_MUL_MEAT_D(R, X, Y) \
|
|
Packit Service |
82fcde |
_FP_MUL_MEAT_1_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm)
|
|
Packit Service |
82fcde |
# define _FP_MUL_MEAT_Q(R, X, Y) \
|
|
Packit Service |
82fcde |
_FP_MUL_MEAT_2_wide_3mul (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define _FP_MUL_MEAT_DW_S(R, X, Y) \
|
|
Packit Service |
82fcde |
_FP_MUL_MEAT_DW_1_imm (_FP_WFRACBITS_S, R, X, Y)
|
|
Packit Service |
82fcde |
# define _FP_MUL_MEAT_DW_D(R, X, Y) \
|
|
Packit Service |
82fcde |
_FP_MUL_MEAT_DW_1_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm)
|
|
Packit Service |
82fcde |
# define _FP_MUL_MEAT_DW_Q(R, X, Y) \
|
|
Packit Service |
82fcde |
_FP_MUL_MEAT_DW_2_wide_3mul (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define _FP_DIV_MEAT_S(R, X, Y) _FP_DIV_MEAT_1_imm (S, R, X, Y, _FP_DIV_HELP_imm)
|
|
Packit Service |
82fcde |
# define _FP_DIV_MEAT_D(R, X, Y) _FP_DIV_MEAT_1_udiv_norm (D, R, X, Y)
|
|
Packit Service |
82fcde |
# define _FP_DIV_MEAT_Q(R, X, Y) _FP_DIV_MEAT_2_udiv (Q, R, X, Y)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define _FP_NANFRAC_S _FP_QNANBIT_S
|
|
Packit Service |
82fcde |
# define _FP_NANFRAC_D _FP_QNANBIT_D
|
|
Packit Service |
82fcde |
# define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define _FP_NANSIGN_S 0
|
|
Packit Service |
82fcde |
#define _FP_NANSIGN_D 0
|
|
Packit Service |
82fcde |
#define _FP_NANSIGN_Q 0
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define _FP_KEEPNANFRACP 0
|
|
Packit Service |
82fcde |
#define _FP_QNANNEGATEDP 0
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
|
|
Packit Service |
82fcde |
do { \
|
|
Packit Service |
82fcde |
R##_s = _FP_NANSIGN_##fs; \
|
|
Packit Service |
82fcde |
_FP_FRAC_SET_##wc (R, _FP_NANFRAC_##fs); \
|
|
Packit Service |
82fcde |
R##_c = FP_CLS_NAN; \
|
|
Packit Service |
82fcde |
} while (0)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define _FP_DECL_EX int _frm __attribute__ ((unused));
|
|
Packit Service |
82fcde |
#define FP_ROUNDMODE _frm
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define FP_RND_NEAREST FE_TONEAREST
|
|
Packit Service |
82fcde |
#define FP_RND_ZERO FE_TOWARDZERO
|
|
Packit Service |
82fcde |
#define FP_RND_PINF FE_UPWARD
|
|
Packit Service |
82fcde |
#define FP_RND_MINF FE_DOWNWARD
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define FP_EX_INVALID FE_INVALID
|
|
Packit Service |
82fcde |
#define FP_EX_OVERFLOW FE_OVERFLOW
|
|
Packit Service |
82fcde |
#define FP_EX_UNDERFLOW FE_UNDERFLOW
|
|
Packit Service |
82fcde |
#define FP_EX_DIVZERO FE_DIVBYZERO
|
|
Packit Service |
82fcde |
#define FP_EX_INEXACT FE_INEXACT
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define _FP_TININESS_AFTER_ROUNDING 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __riscv_flen
|
|
Packit Service |
82fcde |
# define FP_INIT_ROUNDMODE \
|
|
Packit Service |
82fcde |
do { \
|
|
Packit Service |
82fcde |
__asm__ volatile ("frrm %0" : "=r" (_frm)); \
|
|
Packit Service |
82fcde |
} while (0)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define FP_HANDLE_EXCEPTIONS \
|
|
Packit Service |
82fcde |
do { \
|
|
Packit Service |
82fcde |
if (__builtin_expect (_fex, 0)) \
|
|
Packit Service |
82fcde |
__asm__ volatile ("csrs fflags, %0" : : "rK" (_fex)); \
|
|
Packit Service |
82fcde |
} while (0)
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
# define FP_INIT_ROUNDMODE _frm = FP_RND_NEAREST
|
|
Packit Service |
82fcde |
#endif
|