diff options
Diffstat (limited to 'REORG.TODO/sysdeps/aarch64/fpu')
50 files changed, 1969 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/aarch64/fpu/e_sqrt.c b/REORG.TODO/sysdeps/aarch64/fpu/e_sqrt.c new file mode 100644 index 0000000000..f984d877b6 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/e_sqrt.c @@ -0,0 +1,28 @@ +/* Square root of floating point number. + Copyright (C) 2015-2017 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_private.h> + +double +__ieee754_sqrt (double d) +{ + double res; + asm ("fsqrt %d0, %d1" : "=w" (res) : "w" (d)); + return res; +} +strong_alias (__ieee754_sqrt, __sqrt_finite) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/e_sqrtf.c b/REORG.TODO/sysdeps/aarch64/fpu/e_sqrtf.c new file mode 100644 index 0000000000..67707ef833 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/e_sqrtf.c @@ -0,0 +1,28 @@ +/* Single-precision floating point square root. + Copyright (C) 2015-2017 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_private.h> + +float +__ieee754_sqrtf (float s) +{ + float res; + asm ("fsqrt %s0, %s1" : "=w" (res) : "w" (s)); + return res; +} +strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fclrexcpt.c b/REORG.TODO/sysdeps/aarch64/fpu/fclrexcpt.c new file mode 100644 index 0000000000..254f6a6b54 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fclrexcpt.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1997-2017 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) +{ + fpu_fpsr_t fpsr; + fpu_fpsr_t fpsr_new; + + excepts &= FE_ALL_EXCEPT; + + _FPU_GETFPSR (fpsr); + fpsr_new = fpsr & ~excepts; + + if (fpsr != fpsr_new) + _FPU_SETFPSR (fpsr_new); + + return 0; +} +libm_hidden_def (feclearexcept) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fedisblxcpt.c b/REORG.TODO/sysdeps/aarch64/fpu/fedisblxcpt.c new file mode 100644 index 0000000000..900da1f4ec --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fedisblxcpt.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2001-2017 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 +fedisableexcept (int excepts) +{ + fpu_control_t fpcr; + fpu_control_t fpcr_new; + + _FPU_GETCW (fpcr); + excepts &= FE_ALL_EXCEPT; + fpcr_new = fpcr & ~(excepts << FE_EXCEPT_SHIFT); + + if (fpcr != fpcr_new) + _FPU_SETCW (fpcr_new); + + return (fpcr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT; +} diff --git a/REORG.TODO/sysdeps/aarch64/fpu/feenablxcpt.c b/REORG.TODO/sysdeps/aarch64/fpu/feenablxcpt.c new file mode 100644 index 0000000000..029ef1db8b --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/feenablxcpt.c @@ -0,0 +1,47 @@ +/* Copyright (C) 2001-2017 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 +feenableexcept (int excepts) +{ + fpu_control_t fpcr; + fpu_control_t fpcr_new; + fpu_control_t updated_fpcr; + + _FPU_GETCW (fpcr); + excepts &= FE_ALL_EXCEPT; + fpcr_new = fpcr | (excepts << FE_EXCEPT_SHIFT); + + if (fpcr != fpcr_new) + { + _FPU_SETCW (fpcr_new); + + /* Trapping exceptions are optional in AArch64; the relevant enable + bits in FPCR are RES0 hence the absence of support can be detected + by reading back the FPCR and comparing with the required value. */ + _FPU_GETCW (updated_fpcr); + + if (fpcr_new & ~updated_fpcr) + return -1; + } + + return (fpcr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT; +} diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fegetenv.c b/REORG.TODO/sysdeps/aarch64/fpu/fegetenv.c new file mode 100644 index 0000000000..ac277949d7 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fegetenv.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1997-2017 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_control_t fpcr; + fpu_fpsr_t fpsr; + _FPU_GETCW (fpcr); + _FPU_GETFPSR (fpsr); + envp->__fpcr = fpcr; + envp->__fpsr = fpsr; + return 0; +} +libm_hidden_def (__fegetenv) +weak_alias (__fegetenv, fegetenv) +libm_hidden_weak (fegetenv) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fegetexcept.c b/REORG.TODO/sysdeps/aarch64/fpu/fegetexcept.c new file mode 100644 index 0000000000..fa44334644 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fegetexcept.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2001-2017 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 +fegetexcept (void) +{ + fpu_control_t fpcr; + _FPU_GETCW (fpcr); + return (fpcr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT; +} diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fegetmode.c b/REORG.TODO/sysdeps/aarch64/fpu/fegetmode.c new file mode 100644 index 0000000000..1898732184 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fegetmode.c @@ -0,0 +1,27 @@ +/* Store current floating-point control modes. AArch64 version. + Copyright (C) 2016-2017 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; +} diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fegetround.c b/REORG.TODO/sysdeps/aarch64/fpu/fegetround.c new file mode 100644 index 0000000000..3d51d9b43e --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fegetround.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1997-2017 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 <get-rounding-mode.h> + +int +__fegetround (void) +{ + return get_rounding_mode (); +} +libm_hidden_def (__fegetround) +weak_alias (__fegetround, fegetround) +libm_hidden_weak (fegetround) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/feholdexcpt.c b/REORG.TODO/sysdeps/aarch64/fpu/feholdexcpt.c new file mode 100644 index 0000000000..df775ffc53 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/feholdexcpt.c @@ -0,0 +1,30 @@ +/* Copyright (C) 1997-2017 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_aarch64 (envp); + return 0; +} +libm_hidden_def (__feholdexcept) +weak_alias (__feholdexcept, feholdexcept) +libm_hidden_weak (feholdexcept) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fesetenv.c b/REORG.TODO/sysdeps/aarch64/fpu/fesetenv.c new file mode 100644 index 0000000000..9875188735 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fesetenv.c @@ -0,0 +1,78 @@ +/* Copyright (C) 1997-2017 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 +__fesetenv (const fenv_t *envp) +{ + fpu_control_t fpcr; + fpu_control_t fpcr_new; + fpu_control_t updated_fpcr; + fpu_fpsr_t fpsr; + fpu_fpsr_t fpsr_new; + + _FPU_GETCW (fpcr); + + if ((envp != FE_DFL_ENV) && (envp != FE_NOMASK_ENV)) + { + /* The new FPCR/FPSR are valid, so don't merge the reserved flags. */ + fpcr_new = envp->__fpcr; + + if (fpcr != fpcr_new) + _FPU_SETCW (fpcr_new); + + _FPU_SETFPSR (envp->__fpsr); + return 0; + } + + _FPU_GETFPSR (fpsr); + fpcr_new = fpcr & _FPU_RESERVED; + fpsr_new = fpsr & _FPU_FPSR_RESERVED; + + if (envp == FE_DFL_ENV) + { + fpcr_new |= _FPU_DEFAULT; + fpsr_new |= _FPU_FPSR_DEFAULT; + } + else + { + fpcr_new |= _FPU_FPCR_IEEE; + fpsr_new |= _FPU_FPSR_IEEE; + } + + _FPU_SETFPSR (fpsr_new); + + if (fpcr != fpcr_new) + { + _FPU_SETCW (fpcr_new); + + /* Trapping exceptions are optional in AArch64; the relevant enable + bits in FPCR are RES0 hence the absence of support can be detected + by reading back the FPCR and comparing with the required value. */ + _FPU_GETCW (updated_fpcr); + + return fpcr_new & ~updated_fpcr; + } + + return 0; +} +libm_hidden_def (__fesetenv) +weak_alias (__fesetenv, fesetenv) +libm_hidden_weak (fesetenv) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fesetexcept.c b/REORG.TODO/sysdeps/aarch64/fpu/fesetexcept.c new file mode 100644 index 0000000000..b8915cd91b --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fesetexcept.c @@ -0,0 +1,34 @@ +/* Set given exception flags. AArch64 version. + Copyright (C) 2016-2017 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 +fesetexcept (int excepts) +{ + fpu_fpsr_t fpsr; + fpu_fpsr_t fpsr_new; + + _FPU_GETFPSR (fpsr); + fpsr_new = fpsr | (excepts & FE_ALL_EXCEPT); + if (fpsr != fpsr_new) + _FPU_SETFPSR (fpsr_new); + + return 0; +} diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fesetmode.c b/REORG.TODO/sysdeps/aarch64/fpu/fesetmode.c new file mode 100644 index 0000000000..1947eb2a4f --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fesetmode.c @@ -0,0 +1,34 @@ +/* Install given floating-point control modes. AArch64 version. + Copyright (C) 2016-2017 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) +{ + fpu_control_t fpcr, fpcr_new; + _FPU_GETCW (fpcr); + if (modep == FE_DFL_MODE) + fpcr_new = (fpcr & _FPU_RESERVED) | _FPU_DEFAULT; + else + fpcr_new = *modep; + if (fpcr != fpcr_new) + _FPU_SETCW (fpcr_new); + return 0; +} diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fesetround.c b/REORG.TODO/sysdeps/aarch64/fpu/fesetround.c new file mode 100644 index 0000000000..caae99f75d --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fesetround.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1997-2017 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> +#include <fpu_control.h> + +int +__fesetround (int round) +{ + if (round & ~_FPU_FPCR_RM_MASK) + return 1; + + libc_fesetround_aarch64 (round); + return 0; +} +libm_hidden_def (__fesetround) +weak_alias (__fesetround, fesetround) +libm_hidden_weak (fesetround) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/feupdateenv.c b/REORG.TODO/sysdeps/aarch64/fpu/feupdateenv.c new file mode 100644 index 0000000000..e56fc3a44f --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/feupdateenv.c @@ -0,0 +1,89 @@ +/* Copyright (C) 2009-2017 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 +__feupdateenv (const fenv_t *envp) +{ + fpu_control_t fpcr; + fpu_control_t fpcr_new; + fpu_control_t updated_fpcr; + fpu_fpsr_t fpsr; + fpu_fpsr_t fpsr_new; + int excepts; + + _FPU_GETCW (fpcr); + _FPU_GETFPSR (fpsr); + excepts = fpsr & FE_ALL_EXCEPT; + + if ((envp != FE_DFL_ENV) && (envp != FE_NOMASK_ENV)) + { + fpcr_new = envp->__fpcr; + fpsr_new = envp->__fpsr | excepts; + + if (fpcr != fpcr_new) + _FPU_SETCW (fpcr_new); + + if (fpsr != fpsr_new) + _FPU_SETFPSR (fpsr_new); + + if (excepts & (fpcr_new >> FE_EXCEPT_SHIFT)) + return __feraiseexcept (excepts); + + return 0; + } + + fpcr_new = fpcr & _FPU_RESERVED; + fpsr_new = fpsr & (_FPU_FPSR_RESERVED | FE_ALL_EXCEPT); + + if (envp == FE_DFL_ENV) + { + fpcr_new |= _FPU_DEFAULT; + fpsr_new |= _FPU_FPSR_DEFAULT; + } + else + { + fpcr_new |= _FPU_FPCR_IEEE; + fpsr_new |= _FPU_FPSR_IEEE; + } + + _FPU_SETFPSR (fpsr_new); + + if (fpcr != fpcr_new) + { + _FPU_SETCW (fpcr_new); + + /* Trapping exceptions are optional in AArch64; the relevant enable + bits in FPCR are RES0 hence the absence of support can be detected + by reading back the FPCR and comparing with the required value. */ + _FPU_GETCW (updated_fpcr); + + if (fpcr_new & ~updated_fpcr) + return 1; + } + + if (excepts & (fpcr_new >> FE_EXCEPT_SHIFT)) + return __feraiseexcept (excepts); + + return 0; +} +libm_hidden_def (__feupdateenv) +weak_alias (__feupdateenv, feupdateenv) +libm_hidden_weak (feupdateenv) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fgetexcptflg.c b/REORG.TODO/sysdeps/aarch64/fpu/fgetexcptflg.c new file mode 100644 index 0000000000..348c58ac40 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fgetexcptflg.c @@ -0,0 +1,27 @@ +/* Copyright (C) 2001-2017 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) +{ + *flagp = libc_fetestexcept_aarch64 (excepts); + return 0; +} diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fpu_control.h b/REORG.TODO/sysdeps/aarch64/fpu/fpu_control.h new file mode 100644 index 0000000000..efad68b98e --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fpu_control.h @@ -0,0 +1,81 @@ +/* Copyright (C) 1996-2017 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 _AARCH64_FPU_CONTROL_H +#define _AARCH64_FPU_CONTROL_H + +/* Macros for accessing the FPCR and FPSR. */ + +#define _FPU_GETCW(fpcr) \ + __asm__ __volatile__ ("mrs %0, fpcr" : "=r" (fpcr)) + +#define _FPU_SETCW(fpcr) \ + __asm__ __volatile__ ("msr fpcr, %0" : : "r" (fpcr)) + +#define _FPU_GETFPSR(fpsr) \ + __asm__ __volatile__ ("mrs %0, fpsr" : "=r" (fpsr)) + +#define _FPU_SETFPSR(fpsr) \ + __asm__ __volatile__ ("msr fpsr, %0" : : "r" (fpsr)) + +/* Reserved bits should be preserved when modifying register + contents. These two masks indicate which bits in each of FPCR and + FPSR should not be changed. */ + +#define _FPU_RESERVED 0xfe0fe0ff +#define _FPU_FPSR_RESERVED 0x0fffffe0 + +#define _FPU_DEFAULT 0x00000000 +#define _FPU_FPSR_DEFAULT 0x00000000 + +/* Layout of FPCR and FPSR: + + | | | | | | | | + 0 0 0 0 1 1 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 + s s s s s s s s s s s + c c c c c c c c c c c c + N Z C V Q A D F R R S S S L L L I U U I U O D I I U U I U O D I + C H N Z M M T T B E E E D N N X F F Z O D N N X F F Z O + P O O R R Z N N N E K K E E E E E C K K C C C C C + D D I I P + E E D D + E E + */ + +#define _FPU_FPCR_RM_MASK 0xc00000 + +#define _FPU_FPCR_MASK_IXE 0x1000 +#define _FPU_FPCR_MASK_UFE 0x0800 +#define _FPU_FPCR_MASK_OFE 0x0400 +#define _FPU_FPCR_MASK_DZE 0x0200 +#define _FPU_FPCR_MASK_IOE 0x0100 + +#define _FPU_FPCR_IEEE \ + (_FPU_DEFAULT | _FPU_FPCR_MASK_IXE | \ + _FPU_FPCR_MASK_UFE | _FPU_FPCR_MASK_OFE | \ + _FPU_FPCR_MASK_DZE | _FPU_FPCR_MASK_IOE) + +#define _FPU_FPSR_IEEE 0 + +typedef unsigned int fpu_control_t; +typedef unsigned int fpu_fpsr_t; + +/* Default control word set at startup. */ +extern fpu_control_t __fpu_control; + +#endif diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fraiseexcpt.c b/REORG.TODO/sysdeps/aarch64/fpu/fraiseexcpt.c new file mode 100644 index 0000000000..557b061ca7 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fraiseexcpt.c @@ -0,0 +1,93 @@ +/* Copyright (C) 1997-2017 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> +#include <float.h> + +int +__feraiseexcept (int excepts) +{ + int fpsr; + const float fp_zero = 0.0; + const float fp_one = 1.0; + const float fp_max = FLT_MAX; + const float fp_min = FLT_MIN; + const float fp_1e32 = 1.0e32f; + const float fp_two = 2.0; + const float fp_three = 3.0; + + /* Raise exceptions represented by EXCEPTS. But we must raise only + one signal at a time. It is important that if the OVERFLOW or + UNDERFLOW exception and the inexact exception are given at the + same time, the OVERFLOW or UNDERFLOW exception precedes the + INEXACT exception. + + After each exception we read from the FPSR, to force the + exception to be raised immediately. */ + + if (FE_INVALID & excepts) + __asm__ __volatile__ ( + "ldr s0, %1\n\t" + "fdiv s0, s0, s0\n\t" + "mrs %0, fpsr" : "=r" (fpsr) + : "m" (fp_zero) + : "d0"); + + if (FE_DIVBYZERO & excepts) + __asm__ __volatile__ ( + "ldr s0, %1\n\t" + "ldr s1, %2\n\t" + "fdiv s0, s0, s1\n\t" + "mrs %0, fpsr" : "=r" (fpsr) + : "m" (fp_one), "m" (fp_zero) + : "d0", "d1"); + + if (FE_OVERFLOW & excepts) + /* There's no way to raise overflow without also raising inexact. */ + __asm__ __volatile__ ( + "ldr s0, %1\n\t" + "ldr s1, %2\n\t" + "fadd s0, s0, s1\n\t" + "mrs %0, fpsr" : "=r" (fpsr) + : "m" (fp_max), "m" (fp_1e32) + : "d0", "d1"); + + if (FE_UNDERFLOW & excepts) + __asm__ __volatile__ ( + "ldr s0, %1\n\t" + "ldr s1, %2\n\t" + "fdiv s0, s0, s1\n\t" + "mrs %0, fpsr" : "=r" (fpsr) + : "m" (fp_min), "m" (fp_three) + : "d0", "d1"); + + if (FE_INEXACT & excepts) + __asm__ __volatile__ ( + "ldr s0, %1\n\t" + "ldr s1, %2\n\t" + "fdiv s0, s0, s1\n\t" + "mrs %0, fpsr" : "=r" (fpsr) + : "m" (fp_two), "m" (fp_three) + : "d0", "d1"); + + return 0; +} +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/fsetexcptflg.c b/REORG.TODO/sysdeps/aarch64/fpu/fsetexcptflg.c new file mode 100644 index 0000000000..dfa4810f58 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/fsetexcptflg.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1997-2017 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) +{ + fpu_fpsr_t fpsr; + fpu_fpsr_t fpsr_new; + + /* Get the current environment. */ + _FPU_GETFPSR (fpsr); + excepts &= FE_ALL_EXCEPT; + + /* Set the desired exception mask. */ + fpsr_new = fpsr & ~excepts; + fpsr_new |= *flagp & excepts; + + /* Save state back to the FPU. */ + if (fpsr != fpsr_new) + _FPU_SETFPSR (fpsr_new); + + return 0; +} diff --git a/REORG.TODO/sysdeps/aarch64/fpu/ftestexcept.c b/REORG.TODO/sysdeps/aarch64/fpu/ftestexcept.c new file mode 100644 index 0000000000..d41c46bedc --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/ftestexcept.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1997-2017 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_aarch64 (excepts); +} +libm_hidden_def (fetestexcept) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/get-rounding-mode.h b/REORG.TODO/sysdeps/aarch64/fpu/get-rounding-mode.h new file mode 100644 index 0000000000..17ec111abc --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/get-rounding-mode.h @@ -0,0 +1,38 @@ +/* Determine floating-point rounding mode within libc. AArch64 version. + + Copyright (C) 2012-2017 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 _AARCH64_GET_ROUNDING_MODE_H +#define _AARCH64_GET_ROUNDING_MODE_H 1 + +#include <fenv.h> +#include <fpu_control.h> + +/* Return the floating-point rounding mode. */ + +static inline int +get_rounding_mode (void) +{ + fpu_control_t fpcr; + + _FPU_GETCW (fpcr); + return fpcr & _FPU_FPCR_RM_MASK; +} + +#endif /* get-rounding-mode.h */ diff --git a/REORG.TODO/sysdeps/aarch64/fpu/math_private.h b/REORG.TODO/sysdeps/aarch64/fpu/math_private.h new file mode 100644 index 0000000000..807111ea5a --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/math_private.h @@ -0,0 +1,324 @@ +/* Private floating point rounding and exceptions handling. AArch64 version. + Copyright (C) 2014-2017 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 AARCH64_MATH_PRIVATE_H +#define AARCH64_MATH_PRIVATE_H 1 + +#include <fenv.h> +#include <fpu_control.h> + +#define math_opt_barrier(x) \ +({ __typeof (x) __x = (x); __asm ("" : "+w" (__x)); __x; }) +#define math_force_eval(x) \ +({ __typeof (x) __x = (x); __asm __volatile__ ("" : : "w" (__x)); }) + +extern __always_inline double +__ieee754_sqrt (double d) +{ + double res; + asm __volatile__ ("fsqrt %d0, %d1" : "=w" (res) : "w" (d)); + return res; +} + +extern __always_inline float +__ieee754_sqrtf (float s) +{ + float res; + asm __volatile__ ("fsqrt %s0, %s1" : "=w" (res) : "w" (s)); + return res; +} + +static __always_inline void +libc_feholdexcept_aarch64 (fenv_t *envp) +{ + fpu_control_t fpcr; + fpu_control_t new_fpcr; + fpu_fpsr_t fpsr; + fpu_fpsr_t new_fpsr; + + _FPU_GETCW (fpcr); + _FPU_GETFPSR (fpsr); + envp->__fpcr = fpcr; + envp->__fpsr = fpsr; + + /* Clear exception flags and set all exceptions to non-stop. */ + new_fpcr = fpcr & ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT); + new_fpsr = fpsr & ~FE_ALL_EXCEPT; + + if (__glibc_unlikely (new_fpcr != fpcr)) + _FPU_SETCW (new_fpcr); + + if (new_fpsr != fpsr) + _FPU_SETFPSR (new_fpsr); +} + +#define libc_feholdexcept libc_feholdexcept_aarch64 +#define libc_feholdexceptf libc_feholdexcept_aarch64 +#define libc_feholdexceptl libc_feholdexcept_aarch64 + +static __always_inline void +libc_fesetround_aarch64 (int round) +{ + fpu_control_t fpcr; + + _FPU_GETCW (fpcr); + + /* Check whether rounding modes are different. */ + round = (fpcr ^ round) & _FPU_FPCR_RM_MASK; + + /* Set new rounding mode if different. */ + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (fpcr ^ round); +} + +#define libc_fesetround libc_fesetround_aarch64 +#define libc_fesetroundf libc_fesetround_aarch64 +#define libc_fesetroundl libc_fesetround_aarch64 + +static __always_inline void +libc_feholdexcept_setround_aarch64 (fenv_t *envp, int round) +{ + fpu_control_t fpcr; + fpu_control_t new_fpcr; + fpu_fpsr_t fpsr; + fpu_fpsr_t new_fpsr; + + _FPU_GETCW (fpcr); + _FPU_GETFPSR (fpsr); + envp->__fpcr = fpcr; + envp->__fpsr = fpsr; + + /* Clear exception flags, set all exceptions to non-stop, + and set new rounding mode. */ + new_fpcr = fpcr & ~((FE_ALL_EXCEPT << FE_EXCEPT_SHIFT) | _FPU_FPCR_RM_MASK); + new_fpcr |= round; + new_fpsr = fpsr & ~FE_ALL_EXCEPT; + + if (__glibc_unlikely (new_fpcr != fpcr)) + _FPU_SETCW (new_fpcr); + + if (new_fpsr != fpsr) + _FPU_SETFPSR (new_fpsr); +} + +#define libc_feholdexcept_setround libc_feholdexcept_setround_aarch64 +#define libc_feholdexcept_setroundf libc_feholdexcept_setround_aarch64 +#define libc_feholdexcept_setroundl libc_feholdexcept_setround_aarch64 + +static __always_inline int +libc_fetestexcept_aarch64 (int ex) +{ + fpu_fpsr_t fpsr; + + _FPU_GETFPSR (fpsr); + return fpsr & ex & FE_ALL_EXCEPT; +} + +#define libc_fetestexcept libc_fetestexcept_aarch64 +#define libc_fetestexceptf libc_fetestexcept_aarch64 +#define libc_fetestexceptl libc_fetestexcept_aarch64 + +static __always_inline void +libc_fesetenv_aarch64 (const fenv_t *envp) +{ + fpu_control_t fpcr; + fpu_control_t new_fpcr; + + _FPU_GETCW (fpcr); + new_fpcr = envp->__fpcr; + + if (__glibc_unlikely (fpcr != new_fpcr)) + _FPU_SETCW (new_fpcr); + + _FPU_SETFPSR (envp->__fpsr); +} + +#define libc_fesetenv libc_fesetenv_aarch64 +#define libc_fesetenvf libc_fesetenv_aarch64 +#define libc_fesetenvl libc_fesetenv_aarch64 +#define libc_feresetround_noex libc_fesetenv_aarch64 +#define libc_feresetround_noexf libc_fesetenv_aarch64 +#define libc_feresetround_noexl libc_fesetenv_aarch64 + +static __always_inline int +libc_feupdateenv_test_aarch64 (const fenv_t *envp, int ex) +{ + fpu_control_t fpcr; + fpu_control_t new_fpcr; + fpu_fpsr_t fpsr; + fpu_fpsr_t new_fpsr; + int excepts; + + _FPU_GETCW (fpcr); + _FPU_GETFPSR (fpsr); + + /* Merge current exception flags with the saved fenv. */ + excepts = fpsr & FE_ALL_EXCEPT; + new_fpcr = envp->__fpcr; + new_fpsr = envp->__fpsr | excepts; + + if (__glibc_unlikely (fpcr != new_fpcr)) + _FPU_SETCW (new_fpcr); + + if (fpsr != new_fpsr) + _FPU_SETFPSR (new_fpsr); + + /* Raise the exceptions if enabled in the new FP state. */ + if (__glibc_unlikely (excepts & (new_fpcr >> FE_EXCEPT_SHIFT))) + __feraiseexcept (excepts); + + return excepts & ex; +} + +#define libc_feupdateenv_test libc_feupdateenv_test_aarch64 +#define libc_feupdateenv_testf libc_feupdateenv_test_aarch64 +#define libc_feupdateenv_testl libc_feupdateenv_test_aarch64 + +static __always_inline void +libc_feupdateenv_aarch64 (const fenv_t *envp) +{ + libc_feupdateenv_test_aarch64 (envp, 0); +} + +#define libc_feupdateenv libc_feupdateenv_aarch64 +#define libc_feupdateenvf libc_feupdateenv_aarch64 +#define libc_feupdateenvl libc_feupdateenv_aarch64 + +static __always_inline void +libc_feholdsetround_aarch64 (fenv_t *envp, int round) +{ + fpu_control_t fpcr; + fpu_fpsr_t fpsr; + + _FPU_GETCW (fpcr); + _FPU_GETFPSR (fpsr); + envp->__fpcr = fpcr; + envp->__fpsr = fpsr; + + /* Check whether rounding modes are different. */ + round = (fpcr ^ round) & _FPU_FPCR_RM_MASK; + + /* Set new rounding mode if different. */ + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (fpcr ^ round); +} + +#define libc_feholdsetround libc_feholdsetround_aarch64 +#define libc_feholdsetroundf libc_feholdsetround_aarch64 +#define libc_feholdsetroundl libc_feholdsetround_aarch64 + +static __always_inline void +libc_feresetround_aarch64 (fenv_t *envp) +{ + fpu_control_t fpcr; + int round; + + _FPU_GETCW (fpcr); + + /* Check whether rounding modes are different. */ + round = (envp->__fpcr ^ fpcr) & _FPU_FPCR_RM_MASK; + + /* Restore the rounding mode if it was changed. */ + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (fpcr ^ round); +} + +#define libc_feresetround libc_feresetround_aarch64 +#define libc_feresetroundf libc_feresetround_aarch64 +#define libc_feresetroundl libc_feresetround_aarch64 + +/* We have support for rounding mode context. */ +#define HAVE_RM_CTX 1 + +static __always_inline void +libc_feholdsetround_aarch64_ctx (struct rm_ctx *ctx, int r) +{ + fpu_control_t fpcr; + int round; + + _FPU_GETCW (fpcr); + ctx->env.__fpcr = fpcr; + + /* Check whether rounding modes are different. */ + round = (fpcr ^ r) & _FPU_FPCR_RM_MASK; + ctx->updated_status = round != 0; + + /* Set the rounding mode if changed. */ + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (fpcr ^ round); +} + +#define libc_feholdsetround_ctx libc_feholdsetround_aarch64_ctx +#define libc_feholdsetroundf_ctx libc_feholdsetround_aarch64_ctx +#define libc_feholdsetroundl_ctx libc_feholdsetround_aarch64_ctx + +static __always_inline void +libc_feresetround_aarch64_ctx (struct rm_ctx *ctx) +{ + /* Restore the rounding mode if updated. */ + if (__glibc_unlikely (ctx->updated_status)) + _FPU_SETCW (ctx->env.__fpcr); +} + +#define libc_feresetround_ctx libc_feresetround_aarch64_ctx +#define libc_feresetroundf_ctx libc_feresetround_aarch64_ctx +#define libc_feresetroundl_ctx libc_feresetround_aarch64_ctx + +static __always_inline void +libc_feholdsetround_noex_aarch64_ctx (struct rm_ctx *ctx, int r) +{ + fpu_control_t fpcr; + fpu_fpsr_t fpsr; + int round; + + _FPU_GETCW (fpcr); + _FPU_GETFPSR (fpsr); + ctx->env.__fpcr = fpcr; + ctx->env.__fpsr = fpsr; + + /* Check whether rounding modes are different. */ + round = (fpcr ^ r) & _FPU_FPCR_RM_MASK; + ctx->updated_status = round != 0; + + /* Set the rounding mode if changed. */ + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (fpcr ^ round); +} + +#define libc_feholdsetround_noex_ctx libc_feholdsetround_noex_aarch64_ctx +#define libc_feholdsetround_noexf_ctx libc_feholdsetround_noex_aarch64_ctx +#define libc_feholdsetround_noexl_ctx libc_feholdsetround_noex_aarch64_ctx + +static __always_inline void +libc_feresetround_noex_aarch64_ctx (struct rm_ctx *ctx) +{ + /* Restore the rounding mode if updated. */ + if (__glibc_unlikely (ctx->updated_status)) + _FPU_SETCW (ctx->env.__fpcr); + + /* Write new FPSR to restore exception flags. */ + _FPU_SETFPSR (ctx->env.__fpsr); +} + +#define libc_feresetround_noex_ctx libc_feresetround_noex_aarch64_ctx +#define libc_feresetround_noexf_ctx libc_feresetround_noex_aarch64_ctx +#define libc_feresetround_noexl_ctx libc_feresetround_noex_aarch64_ctx + +#include_next <math_private.h> + +#endif diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_ceil.c b/REORG.TODO/sysdeps/aarch64/fpu/s_ceil.c new file mode 100644 index 0000000000..d0a8bd8981 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_ceil.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC ceil +#define INSN "frintp" +#include <s_frint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_ceilf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_ceilf.c new file mode 100644 index 0000000000..b9c2e7c3e5 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_ceilf.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC ceilf +#define INSN "frintp" +#include <s_frintf.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_floor.c b/REORG.TODO/sysdeps/aarch64/fpu/s_floor.c new file mode 100644 index 0000000000..f7f8731d98 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_floor.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC floor +#define INSN "frintm" +#include <s_frint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_floorf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_floorf.c new file mode 100644 index 0000000000..7be63b5a04 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_floorf.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC floorf +#define INSN "frintm" +#include <s_frintf.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_fma.c b/REORG.TODO/sysdeps/aarch64/fpu/s_fma.c new file mode 100644 index 0000000000..6f62ce2365 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_fma.c @@ -0,0 +1,45 @@ +/* Copyright (C) 1996-2017 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> + +#ifndef FUNC +# define FUNC fma +#endif + +#ifndef TYPE +# define TYPE double +# define REGS "d" +#else +# ifndef REGS +# error REGS not defined +# endif +#endif + +#define __CONCATX(a,b) __CONCAT(a,b) + +TYPE +__CONCATX(__,FUNC) (TYPE x, TYPE y, TYPE z) +{ + TYPE result; + asm ( "fmadd" "\t%" REGS "0, %" REGS "1, %" REGS "2, %" REGS "3" + : "=w" (result) : "w" (x), "w" (y), "w" (z) ); + return result; +} + +weak_alias (__CONCATX(__,FUNC), FUNC) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_fmaf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_fmaf.c new file mode 100644 index 0000000000..880a22dfd4 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_fmaf.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC fmaf +#define TYPE float +#define REGS "s" +#include <s_fma.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_fmax.c b/REORG.TODO/sysdeps/aarch64/fpu/s_fmax.c new file mode 100644 index 0000000000..395a9bacfd --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_fmax.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC fmax +#define INSN "fmaxnm" +#include <fpu/s_fmin.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_fmaxf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_fmaxf.c new file mode 100644 index 0000000000..f450d9fe82 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_fmaxf.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC fmaxf +#define INSN "fmaxnm" +#define TYPE float +#define REGS "s" +#include <fpu/s_fmin.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_fmin.c b/REORG.TODO/sysdeps/aarch64/fpu/s_fmin.c new file mode 100644 index 0000000000..b6d32d5050 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_fmin.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1996-2017 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> + +#ifndef FUNC +# define FUNC fmin +#endif + +#ifndef INSN +# define INSN "fminnm" +#endif + +#ifndef TYPE +# define TYPE double +# define REGS "d" +#else +# ifndef REGS +# error REGS not defined +# endif +#endif + +#define __CONCATX(a,b) __CONCAT(a,b) + +TYPE +__CONCATX(__,FUNC) (TYPE x, TYPE y) +{ + TYPE result; + asm ( INSN "\t%" REGS "0, %" REGS "1, %" REGS "2" + : "=w" (result) : "w" (x), "w" (y) ); + return result; +} + +weak_alias (__CONCATX(__,FUNC), FUNC) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_fminf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_fminf.c new file mode 100644 index 0000000000..032262d953 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_fminf.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC fminf +#define TYPE float +#define REGS "s" +#include <fpu/s_fmin.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_frint.c b/REORG.TODO/sysdeps/aarch64/fpu/s_frint.c new file mode 100644 index 0000000000..48881f5868 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_frint.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1996-2017 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> + +#ifndef FUNC +# error FUNC not defined +#endif + +#ifndef TYPE +# define TYPE double +# define REGS "d" +#else +# ifndef REGS +# error REGS not defined +# endif +#endif + +#ifndef INSN +# error INSN not defined +#endif + +#define __CONCATX(a,b) __CONCAT(a,b) + +TYPE +__CONCATX(__,FUNC) (TYPE x) +{ + TYPE result; + asm ( INSN "\t%" REGS "0, %" REGS "1" : + "=w" (result) : "w" (x) ); + return result; +} + +weak_alias (__CONCATX(__,FUNC), FUNC) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_frintf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_frintf.c new file mode 100644 index 0000000000..dae99d7816 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_frintf.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2011-2017 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 FUNC +# error FUNC not defined +#endif +#define TYPE float +#define REGS "s" +#include <s_frint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_llrint.c b/REORG.TODO/sysdeps/aarch64/fpu/s_llrint.c new file mode 100644 index 0000000000..c0d0d0e879 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_llrint.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC llrint +#define OTYPE long long int +#include <s_lrint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_llrintf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_llrintf.c new file mode 100644 index 0000000000..67724c6d47 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_llrintf.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC llrintf +#define ITYPE float +#define IREGS "s" +#define OTYPE long long int +#include <s_lrint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_llround.c b/REORG.TODO/sysdeps/aarch64/fpu/s_llround.c new file mode 100644 index 0000000000..ed4b192d5c --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_llround.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC llround +#define OTYPE long long int +#include <s_lround.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_llroundf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_llroundf.c new file mode 100644 index 0000000000..360ce8b4c5 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_llroundf.c @@ -0,0 +1,23 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC llroundf +#define ITYPE float +#define IREGS "s" +#define OTYPE long long int +#include <s_lround.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_lrint.c b/REORG.TODO/sysdeps/aarch64/fpu/s_lrint.c new file mode 100644 index 0000000000..8c61a039bf --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_lrint.c @@ -0,0 +1,53 @@ +/* Copyright (C) 1996-2017 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> + +#ifndef FUNC +# define FUNC lrint +#endif + +#ifndef ITYPE +# define ITYPE double +# define IREGS "d" +#else +# ifndef IREGS +# error IREGS not defined +# endif +#endif + +#ifndef OTYPE +# define OTYPE long int +#endif + +#define OREGS "x" + +#define __CONCATX(a,b) __CONCAT(a,b) + +OTYPE +__CONCATX(__,FUNC) (ITYPE x) +{ + OTYPE result; + ITYPE temp; + asm ( "frintx" "\t%" IREGS "1, %" IREGS "2\n\t" + "fcvtzs" "\t%" OREGS "0, %" IREGS "1" + : "=r" (result), "=w" (temp) : "w" (x) ); + return result; +} + +weak_alias (__CONCATX(__,FUNC), FUNC) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_lrintf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_lrintf.c new file mode 100644 index 0000000000..a995e4b96f --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_lrintf.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC lrintf +#define ITYPE float +#define IREGS "s" +#include <s_lrint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_lround.c b/REORG.TODO/sysdeps/aarch64/fpu/s_lround.c new file mode 100644 index 0000000000..9be9e7fb0f --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_lround.c @@ -0,0 +1,51 @@ +/* Copyright (C) 1996-2017 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> + +#ifndef FUNC +# define FUNC lround +#endif + +#ifndef ITYPE +# define ITYPE double +# define IREGS "d" +#else +# ifndef IREGS +# error IREGS not defined +# endif +#endif + +#ifndef OTYPE +# define OTYPE long int +#endif + +#define OREGS "x" + +#define __CONCATX(a,b) __CONCAT(a,b) + +OTYPE +__CONCATX(__,FUNC) (ITYPE x) +{ + OTYPE result; + asm ( "fcvtas" "\t%" OREGS "0, %" IREGS "1" + : "=r" (result) : "w" (x) ); + return result; +} + +weak_alias (__CONCATX(__,FUNC), FUNC) diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_lroundf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_lroundf.c new file mode 100644 index 0000000000..4a066d4816 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_lroundf.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC lroundf +#define ITYPE float +#define IREGS "s" +#include <s_lround.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_nearbyint.c b/REORG.TODO/sysdeps/aarch64/fpu/s_nearbyint.c new file mode 100644 index 0000000000..51067f23c8 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_nearbyint.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC nearbyint +#define INSN "frinti" +#include <s_frint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_nearbyintf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_nearbyintf.c new file mode 100644 index 0000000000..8125646c2e --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_nearbyintf.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC nearbyintf +#define INSN "frinti" +#include <s_frintf.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_rint.c b/REORG.TODO/sysdeps/aarch64/fpu/s_rint.c new file mode 100644 index 0000000000..73b4e26786 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_rint.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC rint +#define INSN "frintx" +#include <s_frint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_rintf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_rintf.c new file mode 100644 index 0000000000..3560dc2827 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_rintf.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC rintf +#define INSN "frintx" +#include <s_frintf.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_round.c b/REORG.TODO/sysdeps/aarch64/fpu/s_round.c new file mode 100644 index 0000000000..67817485c3 --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_round.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC round +#define INSN "frinta" +#include <s_frint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_roundf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_roundf.c new file mode 100644 index 0000000000..ef6f672c7d --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_roundf.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC roundf +#define INSN "frinta" +#include <s_frintf.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_trunc.c b/REORG.TODO/sysdeps/aarch64/fpu/s_trunc.c new file mode 100644 index 0000000000..2bf5474a7e --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_trunc.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC trunc +#define INSN "frintz" +#include <s_frint.c> diff --git a/REORG.TODO/sysdeps/aarch64/fpu/s_truncf.c b/REORG.TODO/sysdeps/aarch64/fpu/s_truncf.c new file mode 100644 index 0000000000..94865a470b --- /dev/null +++ b/REORG.TODO/sysdeps/aarch64/fpu/s_truncf.c @@ -0,0 +1,21 @@ +/* Copyright (C) 2011-2017 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/>. */ + +#define FUNC truncf +#define INSN "frintz" +#include <s_frintf.c> |