This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 32/36] PowerPC: lround/lrounf multilib for PowerPC32
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Mon, 19 Aug 2013 18:29:35 -0300
- Subject: [PATCH 32/36] PowerPC: lround/lrounf multilib for PowerPC32
- References: <52127ABC dot 40008 at linux dot vnet dot ibm dot com>
2013-08-19 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S: Move to ...
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power5+.S: ...
here.
(__lround): Rename symbol to __lround_power5plus and remove
strong_alias, weak_alias and compat_symbol definitions.
* sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S: Move to ...
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power6x.S: ...
here.
(__lround): Rename symbol to __lround_power6 and remove
strong_alias, weak_alias and compat_symbol definitions.
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-ppc32.S: New
file: default lround implementation for PPC32.
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround.c: New file:
multiarch lround for PPC32.
* sysdeps/powerpc/powerpc32/fpu/multiarch/s_lroundf.c: New file:
multiarch lroundf for PPC32.
* sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile: Add lround and
lroundf objects.
--
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
index afe1210..a9b2fc3 100644
--- a/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
@@ -20,7 +20,8 @@ libm-sysdep_routines += s_llrintf-power6 s_llrintf-power4 s_llrintf-ppc32 \
s_floorf-ppc32 s_round-power5+ s_round-ppc32 \
s_roundf-power5+ s_roundf-ppc32 s_trunc-power5+ \
s_trunc-ppc32 s_truncf-power5+ s_truncf-ppc32 \
- s_copysign-power6 s_copysign-ppc32
+ s_copysign-power6 s_copysign-ppc32 s_lround-power6x \
+ s_lround-power5+ s_lround-ppc32
CFLAGS-s_llround.c = -fno-builtin-llroundf
endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power5+.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power5+.S
new file mode 100644
index 0000000..5e664be
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power5+.S
@@ -0,0 +1,45 @@
+/* lround function. POWER5+, PowerPC32 version.
+ Copyright (C) 2006-2013 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 <sysdep.h>
+#include <math_ldbl_opt.h>
+
+/* long [r3] lround (float x [fp1])
+ IEEE 1003.1 lround function. IEEE specifies "round to the nearest
+ integer value, rounding halfway cases away from zero, regardless of
+ the current rounding mode." However PowerPC Architecture defines
+ "round to Nearest" as "Choose the best approximation. In case of a
+ tie, choose the one that is even (least significant bit o).".
+ So we pre-round using the V2.02 Floating Round to Integer Nearest
+ instruction before we use the Floating Convert to Integer Word with
+ round to zero instruction. */
+
+ .machine "power5"
+ENTRY (__lround_power5plus)
+ stwu r1,-16(r1)
+ cfi_adjust_cfa_offset (16)
+ frin fp2,fp1
+ fctiwz fp3,fp2 /* Convert To Integer Word lround toward 0. */
+ stfd fp3,8(r1)
+ nop /* Ensure the following load is in a different dispatch */
+ nop /* group to avoid pipe stall on POWER4&5. */
+ nop
+ lwz r3,12(r1)
+ addi r1,r1,16
+ blr
+END (__lround_power5plus)
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power6x.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power6x.S
new file mode 100644
index 0000000..49c5a71
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-power6x.S
@@ -0,0 +1,38 @@
+/* lround function. POWER6x, PowerPC32 version.
+ Copyright (C) 2006-2013 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 <sysdep.h>
+#include <math_ldbl_opt.h>
+
+/* long [r3] lround (float x [fp1])
+ IEEE 1003.1 lround function. IEEE specifies "round to the nearest
+ integer value, rounding halfway cases away from zero, regardless of
+ the current rounding mode." However PowerPC Architecture defines
+ "round to Nearest" as "Choose the best approximation. In case of a
+ tie, choose the one that is even (least significant bit o).".
+ So we pre-round using the V2.02 Floating Round to Integer Nearest
+ instruction before we use the Floating Convert to Integer Word with
+ round to zero instruction. */
+
+ .machine "power6"
+ENTRY (__lround_power6x)
+ frin fp2,fp1 /* Pre-round +-0.5. */
+ fctiwz fp3,fp2 /* Convert To Integer Word lround toward 0. */
+ mftgpr r3,fp3 /* Transfer fpr3 to r3. */
+ blr
+END (__lround_power6x)
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-ppc32.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-ppc32.S
new file mode 100644
index 0000000..8124cd7
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround-ppc32.S
@@ -0,0 +1,31 @@
+/* lround function. PowerPC32 default version.
+ Copyright (C) 2013 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 <sysdep.h>
+#include <math_ldbl_opt.h>
+
+#undef weak_alias
+#define weak_alias(a,b)
+#undef strong_alias
+#define strong_alias(a,b)
+#undef compat_symbol
+#define compat_symbol(a,b,c,d)
+
+#define __lround __lround_ppc32
+
+#include <sysdeps/powerpc/powerpc32/fpu/s_lround.S>
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround.c
new file mode 100644
index 0000000..f21a7e8
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lround.c
@@ -0,0 +1,43 @@
+/* Multiple versions of lround.
+ Copyright (C) 2013 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_ldbl_opt.h>
+#include <shlib-compat.h>
+#include "init-arch.h"
+
+extern __typeof (__lround) __lround_ppc32 attribute_hidden;
+extern __typeof (__lround) __lround_power5plus attribute_hidden;
+extern __typeof (__lround) __lround_power6x attribute_hidden;
+
+libc_ifunc (__lround,
+ (hwcap & PPC_FEATURE_POWER6_EXT) ?
+ __lround_power6x
+ : (hwcap & PPC_FEATURE_POWER5_PLUS) ?
+ __lround_power5plus
+ : __lround_ppc32);
+
+weak_alias (__lround, lround)
+
+#ifdef NO_LONG_DOUBLE
+weak_alias (__lround, lroundl)
+strong_alias (__lround, __lroundl)
+#endif
+#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
+compat_symbol (libm, __lround, lroundl, GLIBC_2_1);
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lroundf.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lroundf.c
new file mode 100644
index 0000000..3080637
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_lroundf.c
@@ -0,0 +1,34 @@
+/* Multiple versions of lroundf.
+ Copyright (C) 2013 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 "init-arch.h"
+
+/* It's safe to use double-precision implementation for single-precision. */
+extern __typeof (__lroundf) __lround_ppc32 attribute_hidden;
+extern __typeof (__lroundf) __lround_power5plus attribute_hidden;
+extern __typeof (__lroundf) __lround_power6x attribute_hidden;
+
+libc_ifunc (__lroundf,
+ (hwcap & PPC_FEATURE_POWER6_EXT) ?
+ __lround_power6x
+ : (hwcap & PPC_FEATURE_POWER5_PLUS) ?
+ __lround_power5plus
+ : __lround_ppc32);
+
+weak_alias (__lroundf, lroundf)
diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S
deleted file mode 100644
index d4da625..0000000
--- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/* lround function. POWER5+, PowerPC32 version.
- Copyright (C) 2006-2013 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 <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* long [r3] lround (float x [fp1])
- IEEE 1003.1 lround function. IEEE specifies "round to the nearest
- integer value, rounding halfway cases away from zero, regardless of
- the current rounding mode." However PowerPC Architecture defines
- "round to Nearest" as "Choose the best approximation. In case of a
- tie, choose the one that is even (least significant bit o).".
- So we pre-round using the V2.02 Floating Round to Integer Nearest
- instruction before we use the Floating Convert to Integer Word with
- round to zero instruction. */
-
- .machine "power5"
-ENTRY (__lround)
- stwu r1,-16(r1)
- cfi_adjust_cfa_offset (16)
- frin fp2,fp1
- fctiwz fp3,fp2 /* Convert To Integer Word lround toward 0. */
- stfd fp3,8(r1)
- nop /* Ensure the following load is in a different dispatch */
- nop /* group to avoid pipe stall on POWER4&5. */
- nop
- lwz r3,12(r1)
- addi r1,r1,16
- blr
- END (__lround)
-
-weak_alias (__lround, lround)
-
-strong_alias (__lround, __lroundf)
-weak_alias (__lround, lroundf)
-
-#ifdef NO_LONG_DOUBLE
-weak_alias (__lround, lroundl)
-strong_alias (__lround, __lroundl)
-#endif
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __lround, lroundl, GLIBC_2_1)
-#endif
diff --git a/sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S b/sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S
deleted file mode 100644
index 0a04051..0000000
--- a/sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S
+++ /dev/null
@@ -1,51 +0,0 @@
-/* lround function. POWER6x, PowerPC32 version.
- Copyright (C) 2006-2013 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 <sysdep.h>
-#include <math_ldbl_opt.h>
-
-/* long [r3] lround (float x [fp1])
- IEEE 1003.1 lround function. IEEE specifies "round to the nearest
- integer value, rounding halfway cases away from zero, regardless of
- the current rounding mode." However PowerPC Architecture defines
- "round to Nearest" as "Choose the best approximation. In case of a
- tie, choose the one that is even (least significant bit o).".
- So we pre-round using the V2.02 Floating Round to Integer Nearest
- instruction before we use the Floating Convert to Integer Word with
- round to zero instruction. */
-
- .machine "power6"
-ENTRY (__lround)
- frin fp2,fp1 /* Pre-round +-0.5. */
- fctiwz fp3,fp2 /* Convert To Integer Word lround toward 0. */
- mftgpr r3,fp3 /* Transfer fpr3 to r3. */
- blr
- END (__lround)
-
-weak_alias (__lround, lround)
-
-strong_alias (__lround, __lroundf)
-weak_alias (__lround, lroundf)
-
-#ifdef NO_LONG_DOUBLE
-weak_alias (__lround, lroundl)
-strong_alias (__lround, __lroundl)
-#endif
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __lround, lroundl, GLIBC_2_1)
-#endif
--
1.7.1