From: Wilco Dijkstra Date: Wed, 15 Oct 2025 16:38:03 +0000 (+0000) Subject: AArch64: Use math-use-builtins for roundeven(f)/lrint(f)/lround(f) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0375e6e2336a779cdddb4d11442126d366b1efc2;p=thirdparty%2Fglibc.git AArch64: Use math-use-builtins for roundeven(f)/lrint(f)/lround(f) Remove target implementations of roundeven(f)/lrint(f)/lround(f) and use the math-use-builtins mechanism instead. Reviewed-by: Adhemerval Zanella  --- diff --git a/sysdeps/aarch64/fpu/math-use-builtins-llrint.h b/sysdeps/aarch64/fpu/math-use-builtins-llrint.h new file mode 100644 index 0000000000..32a6fb82b9 --- /dev/null +++ b/sysdeps/aarch64/fpu/math-use-builtins-llrint.h @@ -0,0 +1,4 @@ +#define USE_LLRINT_BUILTIN 1 +#define USE_LLRINTF_BUILTIN 1 +#define USE_LLRINTL_BUILTIN 0 +#define USE_LLRINTF128_BUILTIN 0 diff --git a/sysdeps/aarch64/fpu/math-use-builtins-llround.h b/sysdeps/aarch64/fpu/math-use-builtins-llround.h new file mode 100644 index 0000000000..d4623a0dc4 --- /dev/null +++ b/sysdeps/aarch64/fpu/math-use-builtins-llround.h @@ -0,0 +1,4 @@ +#define USE_LLROUND_BUILTIN 1 +#define USE_LLROUNDF_BUILTIN 1 +#define USE_LLROUNDL_BUILTIN 0 +#define USE_LLROUNDF128_BUILTIN 0 diff --git a/sysdeps/aarch64/fpu/math-use-builtins-lrint.h b/sysdeps/aarch64/fpu/math-use-builtins-lrint.h new file mode 100644 index 0000000000..d8a8d6c540 --- /dev/null +++ b/sysdeps/aarch64/fpu/math-use-builtins-lrint.h @@ -0,0 +1,4 @@ +#define USE_LRINT_BUILTIN 1 +#define USE_LRINTF_BUILTIN 1 +#define USE_LRINTL_BUILTIN 0 +#define USE_LRINTF128_BUILTIN 0 diff --git a/sysdeps/aarch64/fpu/math-use-builtins-lround.h b/sysdeps/aarch64/fpu/math-use-builtins-lround.h new file mode 100644 index 0000000000..eaeb601ea0 --- /dev/null +++ b/sysdeps/aarch64/fpu/math-use-builtins-lround.h @@ -0,0 +1,4 @@ +#define USE_LROUND_BUILTIN 1 +#define USE_LROUNDF_BUILTIN 1 +#define USE_LROUNDL_BUILTIN 0 +#define USE_LROUNDF128_BUILTIN 0 diff --git a/sysdeps/aarch64/fpu/math-use-builtins-roundeven.h b/sysdeps/aarch64/fpu/math-use-builtins-roundeven.h new file mode 100644 index 0000000000..b7f51730d6 --- /dev/null +++ b/sysdeps/aarch64/fpu/math-use-builtins-roundeven.h @@ -0,0 +1,4 @@ +#define USE_ROUNDEVEN_BUILTIN 1 +#define USE_ROUNDEVENF_BUILTIN 1 +#define USE_ROUNDEVENL_BUILTIN 0 +#define USE_ROUNDEVENF128_BUILTIN 0 diff --git a/sysdeps/aarch64/fpu/s_llrint.c b/sysdeps/aarch64/fpu/s_llrint.c deleted file mode 100644 index 3ed519ca2b..0000000000 --- a/sysdeps/aarch64/fpu/s_llrint.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2011-2025 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 - . */ - -#include -#include -#include - -long long int -__llrint (double x) -{ - double r = __builtin_rint (x); - - /* Prevent gcc from calling llrint directly when compiled with - -fno-math-errno by inserting a barrier. */ - - math_opt_barrier (r); - return r; -} - -libm_alias_double (__llrint, llrint) diff --git a/sysdeps/aarch64/fpu/s_llrintf.c b/sysdeps/aarch64/fpu/s_llrintf.c deleted file mode 100644 index 0f339582b2..0000000000 --- a/sysdeps/aarch64/fpu/s_llrintf.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 2011-2025 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 - . */ - -#include -#include -#include - -long long int -__llrintf (float x) -{ - float r = __builtin_rintf (x); - - /* Prevent gcc from calling llrintf directly when compiled with - -fno-math-errno by inserting a barrier. */ - - - math_opt_barrier (r); - return r; -} - -libm_alias_float (__llrint, llrint) diff --git a/sysdeps/aarch64/fpu/s_llround.c b/sysdeps/aarch64/fpu/s_llround.c deleted file mode 100644 index a1b46e8c9e..0000000000 --- a/sysdeps/aarch64/fpu/s_llround.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2011-2025 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 - . */ - -#include -#include - -long long int -__llround (double x) -{ - return __builtin_llround (x); -} - -libm_alias_double (__llround, llround) diff --git a/sysdeps/aarch64/fpu/s_llroundf.c b/sysdeps/aarch64/fpu/s_llroundf.c deleted file mode 100644 index 5269f4447e..0000000000 --- a/sysdeps/aarch64/fpu/s_llroundf.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2011-2025 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 - . */ - -#include -#include - -long long int -__llroundf (float x) -{ - return __builtin_llroundf (x); -} - -libm_alias_float (__llround, llround) diff --git a/sysdeps/aarch64/fpu/s_lrint.c b/sysdeps/aarch64/fpu/s_lrint.c deleted file mode 100644 index 66b3cca399..0000000000 --- a/sysdeps/aarch64/fpu/s_lrint.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 1996-2025 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 - . */ - -#include -#include -#include -#include -#include - -long int -__lrint (double x) -{ - double r = __builtin_rint (x); - - /* Prevent gcc from calling lrint directly when compiled with - -fno-math-errno by inserting a barrier. */ - - math_opt_barrier (r); - return r; -} - -libm_alias_double (__lrint, lrint) diff --git a/sysdeps/aarch64/fpu/s_lrintf.c b/sysdeps/aarch64/fpu/s_lrintf.c deleted file mode 100644 index cc9d44c48c..0000000000 --- a/sysdeps/aarch64/fpu/s_lrintf.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2011-2025 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 - . */ - -#include -#include -#include - -long int -__lrintf (float x) -{ - float r = __builtin_rintf (x); - - /* Prevent gcc from calling lrintf directly when compiled with - -fno-math-errno by inserting a barrier. */ - - math_opt_barrier (r); - return r; -} - -libm_alias_float (__lrint, lrint) diff --git a/sysdeps/aarch64/fpu/s_lround.c b/sysdeps/aarch64/fpu/s_lround.c deleted file mode 100644 index ab5c7cefab..0000000000 --- a/sysdeps/aarch64/fpu/s_lround.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1996-2025 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 - . */ - -#include -#include - -long int -__lround (double x) - { - return __builtin_lround (x); - } - -libm_alias_double (__lround, lround) diff --git a/sysdeps/aarch64/fpu/s_lroundf.c b/sysdeps/aarch64/fpu/s_lroundf.c deleted file mode 100644 index 236f1a8a54..0000000000 --- a/sysdeps/aarch64/fpu/s_lroundf.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2011-2025 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 - . */ - -#include -#include - -long int -__lroundf (float x) -{ - return __builtin_lroundf (x); -} - -libm_alias_float (__lround, lround) diff --git a/sysdeps/aarch64/fpu/s_roundeven.c b/sysdeps/aarch64/fpu/s_roundeven.c deleted file mode 100644 index de9ee566f6..0000000000 --- a/sysdeps/aarch64/fpu/s_roundeven.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2021-2025 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 - . */ - -#define NO_MATH_REDIRECT -#include -#include - -double -__roundeven (double x) -{ - asm volatile ("frintn \t%d0, %d1" : "=w" (x) : "w" (x)); - return x; -} -libm_alias_double (__roundeven, roundeven) diff --git a/sysdeps/aarch64/fpu/s_roundevenf.c b/sysdeps/aarch64/fpu/s_roundevenf.c deleted file mode 100644 index 63b8aa717f..0000000000 --- a/sysdeps/aarch64/fpu/s_roundevenf.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2021-2025 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 - . */ - -#define NO_MATH_REDIRECT -#include -#include - -float -__roundevenf (float x) -{ - asm volatile ("frintn \t%s0, %s1" : "=w" (x) : "w" (x)); - return x; -} -libm_alias_float (__roundeven, roundeven)