mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-25 14:30:06 +00:00
RISC-V: Hard Float Support
This patch contains hardware floating-point support for the RISC-V ISA. While we currently only support hard-float systems with both the F and D extensions, I've left the F-specific code split out into seperate folders in order to ease adding support for F-only and RV32I-based systems in the future. I gave this a quick once-over and believe I've removed all the code that implements RV32IF, RV32IFD, and RV64IF targets. 2018-01-29 Palmer Dabbelt <palmer@sifive.com> * sysdeps/riscv/rv64/rvd/s_ceil.c: New file. * sysdeps/riscv/rv64/rvd/s_floor.c: Likewise. * sysdeps/riscv/rv64/rvd/s_llrint.c: Likewise. * sysdeps/riscv/rv64/rvd/s_llround.c: Likewise. * sysdeps/riscv/rv64/rvd/s_lrint.c: Likewise. * sysdeps/riscv/rv64/rvd/s_lround.c: Likewise. * sysdeps/riscv/rv64/rvd/s_nearbyint.c: Likewise. * sysdeps/riscv/rv64/rvd/s_rint.c: Likewise. * sysdeps/riscv/rv64/rvd/s_round.c: Likewise. * sysdeps/riscv/rv64/rvd/s_roundeven.c: Likewise. * sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise. * sysdeps/riscv/rv64/rvf/s_llrintf.c: Likewise. * sysdeps/riscv/rv64/rvf/s_llroundf.c: Likewise. * sysdeps/riscv/rv64/rvf/s_lrintf.c: Likewise. * sysdeps/riscv/rv64/rvf/s_lroundf.c: Likewise. * sysdeps/riscv/rvd/e_sqrt.c: Likewise. * sysdeps/riscv/rvd/s_copysign.c: Likewise. * sysdeps/riscv/rvd/s_finite.c: Likewise. * sysdeps/riscv/rvd/s_fma.c: Likewise. * sysdeps/riscv/rvd/s_fmax.c: Likewise. * sysdeps/riscv/rvd/s_fmin.c: Likewise. * sysdeps/riscv/rvd/s_fpclassify.c: Likewise. * sysdeps/riscv/rvd/s_isinf.c: Likewise. * sysdeps/riscv/rvd/s_isnan.c: Likewise. * sysdeps/riscv/rvd/s_issignaling.c: Likewise. * sysdeps/riscv/rvf/e_sqrtf.c: Likewise. * sysdeps/riscv/rvf/fclrexcpt.c: Likewise. * sysdeps/riscv/rvf/fegetenv.c: Likewise. * sysdeps/riscv/rvf/fegetmode.c: Likewise. * sysdeps/riscv/rvf/fegetround.c: Likewise. * sysdeps/riscv/rvf/feholdexcpt.c: Likewise. * sysdeps/riscv/rvf/fesetenv.c: Likewise. * sysdeps/riscv/rvf/fesetexcept.c: Likewise. * sysdeps/riscv/rvf/fesetmode.c: Likewise. * sysdeps/riscv/rvf/fesetround.c: Likewise. * sysdeps/riscv/rvf/feupdateenv.c: Likewise. * sysdeps/riscv/rvf/fgetexcptflg.c: Likewise. * sysdeps/riscv/rvf/fraiseexcpt.c: Likewise. * sysdeps/riscv/rvf/fsetexcptflg.c: Likewise. * sysdeps/riscv/rvf/ftestexcept.c: Likewise. * sysdeps/riscv/rvf/get-rounding-mode.h: Likewise. * sysdeps/riscv/rvf/math_private.h: Likewise. * sysdeps/riscv/rvf/s_ceilf.c: Likewise. * sysdeps/riscv/rvf/s_copysignf.c: Likewise. * sysdeps/riscv/rvf/s_finitef.c: Likewise. * sysdeps/riscv/rvf/s_floorf.c: Likewise. * sysdeps/riscv/rvf/s_fmaf.c: Likewise. * sysdeps/riscv/rvf/s_fmaxf.c: Likewise. * sysdeps/riscv/rvf/s_fminf.c: Likewise. * sysdeps/riscv/rvf/s_fpclassifyf.c: Likewise. * sysdeps/riscv/rvf/s_isinff.c: Likewise. * sysdeps/riscv/rvf/s_isnanf.c: Likewise. * sysdeps/riscv/rvf/s_issignalingf.c: Likewise. * sysdeps/riscv/rvf/s_nearbyintf.c: Likewise. * sysdeps/riscv/rvf/s_rintf.c: Likewise. * sysdeps/riscv/rvf/s_roundevenf.c: Likewise. * sysdeps/riscv/rvf/s_roundf.c: Likewise. * sysdeps/riscv/rvf/s_truncf.c: Likewise.
This commit is contained in:
parent
67236aeb6e
commit
b2cb5e0298
58
ChangeLog
58
ChangeLog
@ -34,6 +34,64 @@
|
||||
* sysdeps/riscv/nofpu/Implies: Likewise.
|
||||
* sysdeps/riscv/sfp-machine.h: Likewise.
|
||||
* sysdeps/riscv/tininess.h: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_ceil.c: New file.
|
||||
* sysdeps/riscv/rv64/rvd/s_floor.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_llrint.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_llround.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_lrint.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_lround.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_nearbyint.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_rint.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_round.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_roundeven.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvf/s_llrintf.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvf/s_llroundf.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvf/s_lrintf.c: Likewise.
|
||||
* sysdeps/riscv/rv64/rvf/s_lroundf.c: Likewise.
|
||||
* sysdeps/riscv/rvd/e_sqrt.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_copysign.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_finite.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_fma.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_fmax.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_fmin.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_fpclassify.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_isinf.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_isnan.c: Likewise.
|
||||
* sysdeps/riscv/rvd/s_issignaling.c: Likewise.
|
||||
* sysdeps/riscv/rvf/e_sqrtf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fclrexcpt.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fegetenv.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fegetmode.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fegetround.c: Likewise.
|
||||
* sysdeps/riscv/rvf/feholdexcpt.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fesetenv.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fesetexcept.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fesetmode.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fesetround.c: Likewise.
|
||||
* sysdeps/riscv/rvf/feupdateenv.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fgetexcptflg.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fraiseexcpt.c: Likewise.
|
||||
* sysdeps/riscv/rvf/fsetexcptflg.c: Likewise.
|
||||
* sysdeps/riscv/rvf/ftestexcept.c: Likewise.
|
||||
* sysdeps/riscv/rvf/get-rounding-mode.h: Likewise.
|
||||
* sysdeps/riscv/rvf/math_private.h: Likewise.
|
||||
* sysdeps/riscv/rvf/s_ceilf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_copysignf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_finitef.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_floorf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_fmaf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_fmaxf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_fminf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_fpclassifyf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_isinff.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_isnanf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_issignalingf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_nearbyintf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_rintf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_roundevenf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_roundf.c: Likewise.
|
||||
* sysdeps/riscv/rvf/s_truncf.c: Likewise.
|
||||
|
||||
2018-01-29 Florian Weimer <fweimer@redhat.com>
|
||||
|
||||
|
52
sysdeps/riscv/rv64/rvd/s_ceil.c
Normal file
52
sysdeps/riscv/rv64/rvd/s_ceil.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* ceil(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
double
|
||||
__ceil (double x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
double mag = fabs (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1ULL << __DBL_MANT_DIG__))
|
||||
{
|
||||
int64_t i;
|
||||
double new_x;
|
||||
|
||||
asm volatile ("fcvt.l.d %0, %1, rup" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.d.l %0, %1, rup" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* ceil(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysign (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_double (__ceil, ceil)
|
52
sysdeps/riscv/rv64/rvd/s_floor.c
Normal file
52
sysdeps/riscv/rv64/rvd/s_floor.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* floor(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
double
|
||||
__floor (double x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
double mag = fabs (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1ULL << __DBL_MANT_DIG__))
|
||||
{
|
||||
int64_t i;
|
||||
double new_x;
|
||||
|
||||
asm volatile ("fcvt.l.d %0, %1, rdn" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.d.l %0, %1, rdn" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* floor(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysign (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_double (__floor, floor)
|
30
sysdeps/riscv/rv64/rvd/s_llrint.c
Normal file
30
sysdeps/riscv/rv64/rvd/s_llrint.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* llrint(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long long int
|
||||
__llrint (double x)
|
||||
{
|
||||
int64_t res;
|
||||
asm ("fcvt.l.d %0, %1" : "=r" (res) : "f" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
libm_alias_double (__llrint, llrint)
|
30
sysdeps/riscv/rv64/rvd/s_llround.c
Normal file
30
sysdeps/riscv/rv64/rvd/s_llround.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* llround(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long long int
|
||||
__llround (double x)
|
||||
{
|
||||
int64_t res;
|
||||
asm ("fcvt.l.d %0, %1, rmm" : "=r" (res) : "f" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
libm_alias_double (__llround, llround)
|
30
sysdeps/riscv/rv64/rvd/s_lrint.c
Normal file
30
sysdeps/riscv/rv64/rvd/s_lrint.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* lrint(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long int
|
||||
__lrint (double x)
|
||||
{
|
||||
int64_t res;
|
||||
asm ("fcvt.l.d %0, %1" : "=r" (res) : "f" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
libm_alias_double (__lrint, lrint)
|
30
sysdeps/riscv/rv64/rvd/s_lround.c
Normal file
30
sysdeps/riscv/rv64/rvd/s_lround.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* llround(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long int
|
||||
__lround (double x)
|
||||
{
|
||||
int64_t res;
|
||||
asm ("fcvt.l.d %0, %1, rmm" : "=r" (res) : "f" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
libm_alias_double (__lround, lround)
|
52
sysdeps/riscv/rv64/rvd/s_nearbyint.c
Normal file
52
sysdeps/riscv/rv64/rvd/s_nearbyint.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* nearbyint(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
double
|
||||
__nearbyint (double x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
double mag = fabs (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1ULL << __DBL_MANT_DIG__))
|
||||
{
|
||||
int64_t i;
|
||||
double new_x;
|
||||
|
||||
asm volatile ("fcvt.l.d %0, %1" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.d.l %0, %1" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* nearbyint(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysign (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_double (__nearbyint, nearbyint)
|
52
sysdeps/riscv/rv64/rvd/s_rint.c
Normal file
52
sysdeps/riscv/rv64/rvd/s_rint.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* rint(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
double
|
||||
__rint (double x)
|
||||
{
|
||||
bool nan;
|
||||
double mag;
|
||||
|
||||
nan = isnan (x);
|
||||
mag = fabs (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1ULL << __DBL_MANT_DIG__))
|
||||
{
|
||||
int64_t i;
|
||||
double new_x;
|
||||
|
||||
asm ("fcvt.l.d %0, %1" : "=r" (i) : "f" (x));
|
||||
asm ("fcvt.d.l %0, %1" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* rint(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysign (new_x, x);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_double (__rint, rint)
|
52
sysdeps/riscv/rv64/rvd/s_round.c
Normal file
52
sysdeps/riscv/rv64/rvd/s_round.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* round(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
double
|
||||
__round (double x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
double mag = fabs (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1ULL << __DBL_MANT_DIG__))
|
||||
{
|
||||
int64_t i;
|
||||
double new_x;
|
||||
|
||||
asm volatile ("fcvt.l.d %0, %1, rmm" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.d.l %0, %1, rmm" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* round(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysign (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_double (__round, round)
|
53
sysdeps/riscv/rv64/rvd/s_roundeven.c
Normal file
53
sysdeps/riscv/rv64/rvd/s_roundeven.c
Normal file
@ -0,0 +1,53 @@
|
||||
/* Round to nearest integer value, rounding halfway cases to even.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
double
|
||||
__roundeven (double x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
double mag = fabs (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1ULL << __DBL_MANT_DIG__))
|
||||
{
|
||||
int64_t i;
|
||||
double new_x;
|
||||
|
||||
asm volatile ("fcvt.l.d %0, %1, rne" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.d.l %0, %1, rne" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* roundeven(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysign (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
hidden_def (__roundeven)
|
||||
libm_alias_double (__roundeven, roundeven)
|
52
sysdeps/riscv/rv64/rvd/s_trunc.c
Normal file
52
sysdeps/riscv/rv64/rvd/s_trunc.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* trunc(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-double.h>
|
||||
#include <stdint.h>
|
||||
|
||||
double
|
||||
__trunc (double x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
double mag = fabs (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1ULL << __DBL_MANT_DIG__))
|
||||
{
|
||||
int64_t i;
|
||||
double new_x;
|
||||
|
||||
asm volatile ("fcvt.l.d %0, %1, rtz" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.d.l %0, %1, rtz" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* trunc(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysign (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_double (__trunc, trunc)
|
30
sysdeps/riscv/rv64/rvf/s_llrintf.c
Normal file
30
sysdeps/riscv/rv64/rvf/s_llrintf.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Round argument to nearest integral value according to current direction.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long long int
|
||||
__llrintf (float x)
|
||||
{
|
||||
int64_t res;
|
||||
asm ("fcvt.l.s %0, %1" : "=r" (res) : "f" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
libm_alias_float (__llrint, llrint)
|
30
sysdeps/riscv/rv64/rvf/s_llroundf.c
Normal file
30
sysdeps/riscv/rv64/rvf/s_llroundf.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Round float value to long long int. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long long int
|
||||
__llroundf (float x)
|
||||
{
|
||||
int64_t res;
|
||||
asm ("fcvt.l.s %0, %1, rmm" : "=r" (res) : "f" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
libm_alias_float (__llround, llround)
|
31
sysdeps/riscv/rv64/rvf/s_lrintf.c
Normal file
31
sysdeps/riscv/rv64/rvf/s_lrintf.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* lrintf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long int
|
||||
__lrintf (float x)
|
||||
{
|
||||
int64_t res;
|
||||
asm ("fcvt.l.s %0, %1" : "=r" (res) : "f" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
libm_alias_float (__lrint, lrint)
|
31
sysdeps/riscv/rv64/rvf/s_lroundf.c
Normal file
31
sysdeps/riscv/rv64/rvf/s_lroundf.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* lroundf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long int
|
||||
__lroundf (float x)
|
||||
{
|
||||
int64_t res;
|
||||
asm ("fcvt.l.s %0, %1, rmm" : "=r" (res) : "f" (x));
|
||||
return res;
|
||||
}
|
||||
|
||||
libm_alias_float (__lround, lround)
|
27
sysdeps/riscv/rvd/e_sqrt.c
Normal file
27
sysdeps/riscv/rvd/e_sqrt.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* Double precision floating point square root. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
__ieee754_sqrt (double x)
|
||||
{
|
||||
asm ("fsqrt.d %0, %1" : "=f" (x) : "f" (x));
|
||||
return x;
|
||||
}
|
||||
strong_alias (__ieee754_sqrt, __sqrt_finite)
|
28
sysdeps/riscv/rvd/s_copysign.c
Normal file
28
sysdeps/riscv/rvd/s_copysign.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copy sign bit between floating-point values. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <libm-alias-double.h>
|
||||
|
||||
double
|
||||
__copysign (double x, double y)
|
||||
{
|
||||
asm ("fsgnj.d %0, %1, %2" : "=f" (x) : "f" (x), "f" (y));
|
||||
return x;
|
||||
}
|
||||
libm_alias_double (__copysign, copysign)
|
28
sysdeps/riscv/rvd/s_finite.c
Normal file
28
sysdeps/riscv/rvd/s_finite.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* finite(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__finite (double x)
|
||||
{
|
||||
return _FCLASS (x) & ~(_FCLASS_INF | _FCLASS_NAN);
|
||||
}
|
||||
hidden_def (__finite)
|
||||
weak_alias (__finite, finite)
|
30
sysdeps/riscv/rvd/s_fma.c
Normal file
30
sysdeps/riscv/rvd/s_fma.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Double precision floating point fused multiply-add. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <fenv.h>
|
||||
#include <ieee754.h>
|
||||
#include <libm-alias-double.h>
|
||||
|
||||
double
|
||||
__fma (double x, double y, double z)
|
||||
{
|
||||
asm ("fmadd.d %0, %1, %2, %3" : "=f" (x) : "f" (x), "f" (y), "f" (z));
|
||||
return x;
|
||||
}
|
||||
libm_alias_double (__fma, fma)
|
28
sysdeps/riscv/rvd/s_fmax.c
Normal file
28
sysdeps/riscv/rvd/s_fmax.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* fmax(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <libm-alias-double.h>
|
||||
|
||||
double
|
||||
__fmax (double x, double y)
|
||||
{
|
||||
asm ("fmax.d %0, %1, %2" : "=f" (x) : "f" (x), "f" (y));
|
||||
return x;
|
||||
}
|
||||
libm_alias_double (__fmax, fmax)
|
28
sysdeps/riscv/rvd/s_fmin.c
Normal file
28
sysdeps/riscv/rvd/s_fmin.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* fmin(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <libm-alias-double.h>
|
||||
|
||||
double
|
||||
__fmin (double x, double y)
|
||||
{
|
||||
asm ("fmin.d %0, %1, %2" : "=f" (x) : "f" (x), "f" (y));
|
||||
return x;
|
||||
}
|
||||
libm_alias_double (__fmin, fmin)
|
36
sysdeps/riscv/rvd/s_fpclassify.c
Normal file
36
sysdeps/riscv/rvd/s_fpclassify.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* fpclassify(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__fpclassify (double x)
|
||||
{
|
||||
int cls = _FCLASS (x);
|
||||
if (__builtin_expect (cls & _FCLASS_NORM, _FCLASS_NORM))
|
||||
return FP_NORMAL;
|
||||
if (__builtin_expect (cls & _FCLASS_ZERO, _FCLASS_ZERO))
|
||||
return FP_ZERO;
|
||||
if (__builtin_expect (cls & _FCLASS_SUBNORM, _FCLASS_SUBNORM))
|
||||
return FP_SUBNORMAL;
|
||||
if (__builtin_expect (cls & _FCLASS_INF, _FCLASS_INF))
|
||||
return FP_INFINITE;
|
||||
return FP_NAN;
|
||||
}
|
||||
libm_hidden_def (__fpclassify)
|
29
sysdeps/riscv/rvd/s_isinf.c
Normal file
29
sysdeps/riscv/rvd/s_isinf.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* isinf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__isinf (double x)
|
||||
{
|
||||
int cls = _FCLASS (x);
|
||||
return -((cls & _FCLASS_MINF) ? 1 : 0) | ((cls & _FCLASS_PINF) ? 1 : 0);
|
||||
}
|
||||
hidden_def (__isinf)
|
||||
weak_alias (__isinf, isinf)
|
28
sysdeps/riscv/rvd/s_isnan.c
Normal file
28
sysdeps/riscv/rvd/s_isnan.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* isnan(). RISC_V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__isnan (double x)
|
||||
{
|
||||
return (_FCLASS (x) & _FCLASS_NAN) != 0;
|
||||
}
|
||||
hidden_def (__isnan)
|
||||
weak_alias (__isnan, isnan)
|
27
sysdeps/riscv/rvd/s_issignaling.c
Normal file
27
sysdeps/riscv/rvd/s_issignaling.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* issignaling(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__issignaling (double x)
|
||||
{
|
||||
return (_FCLASS (x) & _FCLASS_SNAN) != 0;
|
||||
}
|
||||
libm_hidden_def (__issignaling)
|
27
sysdeps/riscv/rvf/e_sqrtf.c
Normal file
27
sysdeps/riscv/rvf/e_sqrtf.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* Single precision floating point square root. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
__ieee754_sqrtf (float x)
|
||||
{
|
||||
asm ("fsqrt.s %0, %1" : "=f" (x) : "f" (x));
|
||||
return x;
|
||||
}
|
||||
strong_alias (__ieee754_sqrtf, __sqrtf_finite)
|
28
sysdeps/riscv/rvf/fclrexcpt.c
Normal file
28
sysdeps/riscv/rvf/fclrexcpt.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* Clear given exceptions in current floating-point environment.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
feclearexcept (int excepts)
|
||||
{
|
||||
asm volatile ("csrc fflags, %0" : : "r" (excepts));
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (feclearexcept)
|
32
sysdeps/riscv/rvf/fegetenv.c
Normal file
32
sysdeps/riscv/rvf/fegetenv.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* Store current floating-point environment.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
__fegetenv (fenv_t *envp)
|
||||
{
|
||||
_FPU_GETCW (*envp);
|
||||
|
||||
/* Success. */
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__fegetenv)
|
||||
weak_alias (__fegetenv, fegetenv)
|
||||
libm_hidden_weak (fegetenv)
|
27
sysdeps/riscv/rvf/fegetmode.c
Normal file
27
sysdeps/riscv/rvf/fegetmode.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* Store current floating-point control modes. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
fegetmode (femode_t *modep)
|
||||
{
|
||||
_FPU_GETCW (*modep);
|
||||
return 0;
|
||||
}
|
29
sysdeps/riscv/rvf/fegetround.c
Normal file
29
sysdeps/riscv/rvf/fegetround.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* Return current rounding direction.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__fegetround (void)
|
||||
{
|
||||
return riscv_getround ();
|
||||
}
|
||||
libm_hidden_def (__fegetround)
|
||||
weak_alias (__fegetround, fegetround)
|
||||
libm_hidden_weak (fegetround)
|
30
sysdeps/riscv/rvf/feholdexcpt.c
Normal file
30
sysdeps/riscv/rvf/feholdexcpt.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Store current floating-point environment and clear exceptions.
|
||||
Copyright (C) 2000-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__feholdexcept (fenv_t *envp)
|
||||
{
|
||||
libc_feholdexcept_riscv (envp);
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__feholdexcept)
|
||||
weak_alias (__feholdexcept, feholdexcept)
|
||||
libm_hidden_weak (feholdexcept)
|
30
sysdeps/riscv/rvf/fesetenv.c
Normal file
30
sysdeps/riscv/rvf/fesetenv.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Install given floating-point environment.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__fesetenv (const fenv_t *envp)
|
||||
{
|
||||
libc_fesetenv_riscv (envp);
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__fesetenv)
|
||||
weak_alias (__fesetenv, fesetenv)
|
||||
libm_hidden_weak (fesetenv)
|
26
sysdeps/riscv/rvf/fesetexcept.c
Normal file
26
sysdeps/riscv/rvf/fesetexcept.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* Set given exception flags. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
|
||||
int
|
||||
fesetexcept (int excepts)
|
||||
{
|
||||
asm volatile ("csrs fflags, %0" : : "r" (excepts));
|
||||
return 0;
|
||||
}
|
31
sysdeps/riscv/rvf/fesetmode.c
Normal file
31
sysdeps/riscv/rvf/fesetmode.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* Install given floating-point control modes. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
fesetmode (const femode_t *modep)
|
||||
{
|
||||
asm volatile ("csrc fcsr, %0" : : "r" (~FE_ALL_EXCEPT));
|
||||
|
||||
if (modep != FE_DFL_MODE)
|
||||
asm volatile ("csrs fcsr, %0" : : "r" (*modep & ~FE_ALL_EXCEPT));
|
||||
|
||||
return 0;
|
||||
}
|
39
sysdeps/riscv/rvf/fesetround.c
Normal file
39
sysdeps/riscv/rvf/fesetround.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* Set current rounding direction.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__fesetround (int round)
|
||||
{
|
||||
switch (round)
|
||||
{
|
||||
case FE_TONEAREST:
|
||||
case FE_TOWARDZERO:
|
||||
case FE_DOWNWARD:
|
||||
case FE_UPWARD:
|
||||
riscv_setround (round);
|
||||
return 0;
|
||||
default:
|
||||
return round; /* A nonzero value. */
|
||||
}
|
||||
}
|
||||
libm_hidden_def (__fesetround)
|
||||
weak_alias (__fesetround, fesetround)
|
||||
libm_hidden_weak (fesetround)
|
30
sysdeps/riscv/rvf/feupdateenv.c
Normal file
30
sysdeps/riscv/rvf/feupdateenv.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Install given floating-point environment and raise exceptions.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__feupdateenv (const fenv_t *envp)
|
||||
{
|
||||
libc_feupdateenv_riscv (envp);
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__feupdateenv)
|
||||
weak_alias (__feupdateenv, feupdateenv)
|
||||
libm_hidden_weak (feupdateenv)
|
30
sysdeps/riscv/rvf/fgetexcptflg.c
Normal file
30
sysdeps/riscv/rvf/fgetexcptflg.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Store current representation for exceptions.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
fegetexceptflag (fexcept_t *flagp, int excepts)
|
||||
{
|
||||
/* Get the current exceptions. */
|
||||
*flagp = riscv_getflags () & excepts;
|
||||
|
||||
/* Success. */
|
||||
return 0;
|
||||
}
|
30
sysdeps/riscv/rvf/fraiseexcpt.c
Normal file
30
sysdeps/riscv/rvf/fraiseexcpt.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Raise given exceptions.
|
||||
Copyright (C) 2000-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
__feraiseexcept (int excepts)
|
||||
{
|
||||
asm volatile ("csrs fflags, %0" : : "r" (excepts));
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__feraiseexcept)
|
||||
weak_alias (__feraiseexcept, feraiseexcept)
|
||||
libm_hidden_weak (feraiseexcept)
|
30
sysdeps/riscv/rvf/fsetexcptflg.c
Normal file
30
sysdeps/riscv/rvf/fsetexcptflg.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Set floating-point environment exception handling.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
fesetexceptflag (const fexcept_t *flagp, int excepts)
|
||||
{
|
||||
fexcept_t flags = *flagp;
|
||||
asm volatile ("csrc fflags, %0" : : "r" (excepts));
|
||||
asm volatile ("csrs fflags, %0" : : "r" (flags & excepts));
|
||||
|
||||
return 0;
|
||||
}
|
27
sysdeps/riscv/rvf/ftestexcept.c
Normal file
27
sysdeps/riscv/rvf/ftestexcept.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* Test exception in current environment.
|
||||
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <fenv.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
fetestexcept (int excepts)
|
||||
{
|
||||
return libc_fetestexcept_riscv (excepts);
|
||||
}
|
||||
libm_hidden_def (fetestexcept)
|
32
sysdeps/riscv/rvf/get-rounding-mode.h
Normal file
32
sysdeps/riscv/rvf/get-rounding-mode.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* Determine floating-point rounding mode within libc. RISC-V version.
|
||||
Copyright (C) 2015-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _RISCV_GET_ROUNDING_MODE_H
|
||||
#define _RISCV_GET_ROUNDING_MODE_H
|
||||
|
||||
/* Return the floating-point rounding mode. */
|
||||
|
||||
static inline int
|
||||
get_rounding_mode (void)
|
||||
{
|
||||
int rm;
|
||||
asm volatile ("frrm %0" : "=r" (rm));
|
||||
return rm;
|
||||
}
|
||||
|
||||
#endif /* get-rounding-mode.h */
|
161
sysdeps/riscv/rvf/math_private.h
Normal file
161
sysdeps/riscv/rvf/math_private.h
Normal file
@ -0,0 +1,161 @@
|
||||
/* Private floating point rounding and exceptions handling. RISC-V version.
|
||||
Copyright (C) 2014-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef RISCV_MATH_PRIVATE_H
|
||||
#define RISCV_MATH_PRIVATE_H 1
|
||||
|
||||
#include <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <get-rounding-mode.h>
|
||||
|
||||
static __always_inline int
|
||||
riscv_getround (void)
|
||||
{
|
||||
return get_rounding_mode ();
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
riscv_setround (int rm)
|
||||
{
|
||||
asm volatile ("fsrm %z0" : : "rJ" (rm));
|
||||
}
|
||||
|
||||
static __always_inline int
|
||||
riscv_getflags (void)
|
||||
{
|
||||
int flags;
|
||||
asm volatile ("frflags %0" : "=r" (flags));
|
||||
return flags;
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
riscv_setflags (int flags)
|
||||
{
|
||||
asm volatile ("fsflags %z0" : : "rJ" (flags));
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_feholdexcept_riscv (fenv_t *envp)
|
||||
{
|
||||
asm volatile ("csrrc %0, fcsr, %1" : "=r" (*envp) : "i" (FE_ALL_EXCEPT));
|
||||
}
|
||||
|
||||
#define libc_feholdexcept libc_feholdexcept_riscv
|
||||
#define libc_feholdexceptf libc_feholdexcept_riscv
|
||||
#define libc_feholdexceptl libc_feholdexcept_riscv
|
||||
|
||||
static __always_inline void
|
||||
libc_fesetround_riscv (int round)
|
||||
{
|
||||
riscv_setround (round);
|
||||
}
|
||||
|
||||
#define libc_fesetround libc_fesetround_riscv
|
||||
#define libc_fesetroundf libc_fesetround_riscv
|
||||
#define libc_fesetroundl libc_fesetround_riscv
|
||||
|
||||
static __always_inline void
|
||||
libc_feholdexcept_setround_riscv (fenv_t *envp, int round)
|
||||
{
|
||||
libc_fesetround_riscv (round);
|
||||
libc_feholdexcept_riscv (envp);
|
||||
}
|
||||
|
||||
#define libc_feholdexcept_setround libc_feholdexcept_setround_riscv
|
||||
#define libc_feholdexcept_setroundf libc_feholdexcept_setround_riscv
|
||||
#define libc_feholdexcept_setroundl libc_feholdexcept_setround_riscv
|
||||
|
||||
static __always_inline int
|
||||
libc_fetestexcept_riscv (int ex)
|
||||
{
|
||||
return riscv_getflags () & ex;
|
||||
}
|
||||
|
||||
#define libc_fetestexcept libc_fetestexcept_riscv
|
||||
#define libc_fetestexceptf libc_fetestexcept_riscv
|
||||
#define libc_fetestexceptl libc_fetestexcept_riscv
|
||||
|
||||
static __always_inline void
|
||||
libc_fesetenv_riscv (const fenv_t *envp)
|
||||
{
|
||||
long int env = (long int) envp - (long int) FE_DFL_ENV;
|
||||
if (env != 0)
|
||||
env = *envp;
|
||||
|
||||
_FPU_SETCW (env);
|
||||
}
|
||||
|
||||
#define libc_fesetenv libc_fesetenv_riscv
|
||||
#define libc_fesetenvf libc_fesetenv_riscv
|
||||
#define libc_fesetenvl libc_fesetenv_riscv
|
||||
#define libc_feresetround_noex libc_fesetenv_riscv
|
||||
#define libc_feresetround_noexf libc_fesetenv_riscv
|
||||
#define libc_feresetround_noexl libc_fesetenv_riscv
|
||||
|
||||
static __always_inline int
|
||||
libc_feupdateenv_test_riscv (const fenv_t *envp, int ex)
|
||||
{
|
||||
fenv_t env = *envp;
|
||||
int flags = riscv_getflags ();
|
||||
asm volatile ("csrw fcsr, %z0" : : "rJ" (env | flags));
|
||||
return flags & ex;
|
||||
}
|
||||
|
||||
#define libc_feupdateenv_test libc_feupdateenv_test_riscv
|
||||
#define libc_feupdateenv_testf libc_feupdateenv_test_riscv
|
||||
#define libc_feupdateenv_testl libc_feupdateenv_test_riscv
|
||||
|
||||
static __always_inline void
|
||||
libc_feupdateenv_riscv (const fenv_t *envp)
|
||||
{
|
||||
_FPU_SETCW (*envp | riscv_getflags ());
|
||||
}
|
||||
|
||||
#define libc_feupdateenv libc_feupdateenv_riscv
|
||||
#define libc_feupdateenvf libc_feupdateenv_riscv
|
||||
#define libc_feupdateenvl libc_feupdateenv_riscv
|
||||
|
||||
static __always_inline void
|
||||
libc_feholdsetround_riscv (fenv_t *envp, int round)
|
||||
{
|
||||
/* Note this implementation makes an improperly-formatted fenv_t and
|
||||
so should only be used in conjunction with libc_feresetround. */
|
||||
int old_round;
|
||||
asm volatile ("csrrw %0, frm, %z1" : "=r" (old_round) : "rJ" (round));
|
||||
*envp = old_round;
|
||||
}
|
||||
|
||||
#define libc_feholdsetround libc_feholdsetround_riscv
|
||||
#define libc_feholdsetroundf libc_feholdsetround_riscv
|
||||
#define libc_feholdsetroundl libc_feholdsetround_riscv
|
||||
|
||||
static __always_inline void
|
||||
libc_feresetround_riscv (fenv_t *envp)
|
||||
{
|
||||
/* Note this implementation takes an improperly-formatted fenv_t and
|
||||
so should only be used in conjunction with libc_feholdsetround. */
|
||||
riscv_setround (*envp);
|
||||
}
|
||||
|
||||
#define libc_feresetround libc_feresetround_riscv
|
||||
#define libc_feresetroundf libc_feresetround_riscv
|
||||
#define libc_feresetroundl libc_feresetround_riscv
|
||||
|
||||
#include_next <math_private.h>
|
||||
|
||||
#endif
|
52
sysdeps/riscv/rvf/s_ceilf.c
Normal file
52
sysdeps/riscv/rvf/s_ceilf.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* ceilf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
float
|
||||
__ceilf (float x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
float mag = fabsf (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1 << __FLT_MANT_DIG__))
|
||||
{
|
||||
int32_t i;
|
||||
float new_x;
|
||||
|
||||
asm volatile ("fcvt.w.s %0, %1, rup" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.s.w %0, %1, rup" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* ceil(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysignf (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_float (__ceil, ceil)
|
28
sysdeps/riscv/rvf/s_copysignf.c
Normal file
28
sysdeps/riscv/rvf/s_copysignf.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* copysignf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <libm-alias-float.h>
|
||||
|
||||
float
|
||||
__copysignf (float x, float y)
|
||||
{
|
||||
asm ("fsgnj.s %0, %1, %2" : "=f" (x) : "f" (x), "f" (y));
|
||||
return x;
|
||||
}
|
||||
libm_alias_float (__copysign, copysign)
|
28
sysdeps/riscv/rvf/s_finitef.c
Normal file
28
sysdeps/riscv/rvf/s_finitef.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* finitef(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__finitef (float x)
|
||||
{
|
||||
return _FCLASS (x) & ~(_FCLASS_INF | _FCLASS_NAN);
|
||||
}
|
||||
hidden_def (__finitef)
|
||||
weak_alias (__finitef, finitef)
|
52
sysdeps/riscv/rvf/s_floorf.c
Normal file
52
sysdeps/riscv/rvf/s_floorf.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* floorf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
float
|
||||
__floorf (float x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
float mag = fabsf (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1 << __FLT_MANT_DIG__))
|
||||
{
|
||||
int32_t i;
|
||||
float new_x;
|
||||
|
||||
asm volatile ("fcvt.w.s %0, %1, rdn" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.s.w %0, %1, rdn" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* floor(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysignf (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_float (__floor, floor)
|
30
sysdeps/riscv/rvf/s_fmaf.c
Normal file
30
sysdeps/riscv/rvf/s_fmaf.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* fmaf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <fenv.h>
|
||||
#include <ieee754.h>
|
||||
#include <libm-alias-float.h>
|
||||
|
||||
float
|
||||
__fmaf (float x, float y, float z)
|
||||
{
|
||||
asm ("fmadd.s %0, %1, %2, %3" : "=f" (x) : "f" (x), "f" (y), "f" (z));
|
||||
return x;
|
||||
}
|
||||
libm_alias_float (__fma, fma)
|
28
sysdeps/riscv/rvf/s_fmaxf.c
Normal file
28
sysdeps/riscv/rvf/s_fmaxf.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* fmaxf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <libm-alias-float.h>
|
||||
|
||||
float
|
||||
__fmaxf (float x, float y)
|
||||
{
|
||||
asm ("fmax.s %0, %1, %2" : "=f" (x) : "f" (x), "f" (y));
|
||||
return x;
|
||||
}
|
||||
libm_alias_float (__fmax, fmax)
|
28
sysdeps/riscv/rvf/s_fminf.c
Normal file
28
sysdeps/riscv/rvf/s_fminf.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* fminf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <libm-alias-float.h>
|
||||
|
||||
float
|
||||
__fminf (float x, float y)
|
||||
{
|
||||
asm ("fmin.s %0, %1, %2" : "=f" (x) : "f" (x), "f" (y));
|
||||
return x;
|
||||
}
|
||||
libm_alias_float (__fmin, fmin)
|
36
sysdeps/riscv/rvf/s_fpclassifyf.c
Normal file
36
sysdeps/riscv/rvf/s_fpclassifyf.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* fpclassifyf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__fpclassifyf (float x)
|
||||
{
|
||||
int cls = _FCLASS (x);
|
||||
if (__builtin_expect (cls & _FCLASS_NORM, _FCLASS_NORM))
|
||||
return FP_NORMAL;
|
||||
if (__builtin_expect (cls & _FCLASS_ZERO, _FCLASS_ZERO))
|
||||
return FP_ZERO;
|
||||
if (__builtin_expect (cls & _FCLASS_SUBNORM, _FCLASS_SUBNORM))
|
||||
return FP_SUBNORMAL;
|
||||
if (__builtin_expect (cls & _FCLASS_INF, _FCLASS_INF))
|
||||
return FP_INFINITE;
|
||||
return FP_NAN;
|
||||
}
|
||||
libm_hidden_def (__fpclassifyf)
|
29
sysdeps/riscv/rvf/s_isinff.c
Normal file
29
sysdeps/riscv/rvf/s_isinff.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* isinff(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__isinff (float x)
|
||||
{
|
||||
int cls = _FCLASS (x);
|
||||
return -((cls & _FCLASS_MINF) ? 1 : 0) | ((cls & _FCLASS_PINF) ? 1 : 0);
|
||||
}
|
||||
hidden_def (__isinff)
|
||||
weak_alias (__isinff, isinff)
|
28
sysdeps/riscv/rvf/s_isnanf.c
Normal file
28
sysdeps/riscv/rvf/s_isnanf.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* isnanf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__isnanf (float x)
|
||||
{
|
||||
return (_FCLASS (x) & _FCLASS_NAN) != 0;
|
||||
}
|
||||
hidden_def (__isnanf)
|
||||
weak_alias (__isnanf, isnanf)
|
27
sysdeps/riscv/rvf/s_issignalingf.c
Normal file
27
sysdeps/riscv/rvf/s_issignalingf.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* issignalingf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
|
||||
int
|
||||
__issignalingf (float x)
|
||||
{
|
||||
return (_FCLASS (x) & _FCLASS_SNAN) != 0;
|
||||
}
|
||||
libm_hidden_def (__issignalingf)
|
52
sysdeps/riscv/rvf/s_nearbyintf.c
Normal file
52
sysdeps/riscv/rvf/s_nearbyintf.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* Round to int floating-point values. RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
float
|
||||
__nearbyintf (float x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
float mag = fabsf (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1 << __FLT_MANT_DIG__))
|
||||
{
|
||||
int32_t i;
|
||||
float new_x;
|
||||
|
||||
asm volatile ("fcvt.w.s %0, %1" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.s.w %0, %1" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* nearbyint(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysignf (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_float (__nearbyint, nearbyint)
|
52
sysdeps/riscv/rvf/s_rintf.c
Normal file
52
sysdeps/riscv/rvf/s_rintf.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* rintf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
float
|
||||
__rintf (float x)
|
||||
{
|
||||
bool nan;
|
||||
float mag;
|
||||
|
||||
nan = isnan (x);
|
||||
mag = fabsf (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1 << __FLT_MANT_DIG__))
|
||||
{
|
||||
int32_t i;
|
||||
float new_x;
|
||||
|
||||
asm ("fcvt.w.s %0, %1" : "=r" (i) : "f" (x));
|
||||
asm ("fcvt.s.w %0, %1" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* rint(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysignf (new_x, x);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_float (__rint, rint)
|
52
sysdeps/riscv/rvf/s_roundevenf.c
Normal file
52
sysdeps/riscv/rvf/s_roundevenf.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* Round to nearest integer value, rounding halfway cases to even.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
float
|
||||
__roundevenf (float x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
float mag = fabsf (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1 << __FLT_MANT_DIG__))
|
||||
{
|
||||
int32_t i;
|
||||
float new_x;
|
||||
|
||||
asm volatile ("fcvt.w.s %0, %1, rne" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.s.w %0, %1, rne" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* roundeven(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysignf (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_float (__roundeven, roundeven)
|
52
sysdeps/riscv/rvf/s_roundf.c
Normal file
52
sysdeps/riscv/rvf/s_roundf.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* roundf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
float
|
||||
__roundf (float x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
float mag = fabsf (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1 << __FLT_MANT_DIG__))
|
||||
{
|
||||
int32_t i;
|
||||
float new_x;
|
||||
|
||||
asm volatile ("fcvt.w.s %0, %1, rmm" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.s.w %0, %1, rmm" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* round(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysignf (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_float (__round, round)
|
52
sysdeps/riscv/rvf/s_truncf.c
Normal file
52
sysdeps/riscv/rvf/s_truncf.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* truncf(). RISC-V version.
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <libm-alias-float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
float
|
||||
__truncf (float x)
|
||||
{
|
||||
int flags = riscv_getflags ();
|
||||
bool nan = isnan (x);
|
||||
float mag = fabsf (x);
|
||||
|
||||
if (nan)
|
||||
return x + x;
|
||||
|
||||
if (mag < (1 << __FLT_MANT_DIG__))
|
||||
{
|
||||
int32_t i;
|
||||
float new_x;
|
||||
|
||||
asm volatile ("fcvt.w.s %0, %1, rtz" : "=r" (i) : "f" (x));
|
||||
asm volatile ("fcvt.s.w %0, %1, rtz" : "=f" (new_x) : "r" (i));
|
||||
|
||||
/* trunc(-0) == -0, and in general we'll always have the same
|
||||
sign as our input. */
|
||||
x = copysignf (new_x, x);
|
||||
|
||||
riscv_setflags (flags);
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
libm_alias_float (__trunc, trunc)
|
Loading…
Reference in New Issue
Block a user