|
|
a35d80 |
From b9d83bf3eb57e1cf8ef785f1a58e13ddf162b6f3 Mon Sep 17 00:00:00 2001
|
|
|
a35d80 |
From: Raphael M Zinsly <rzinsly@linux.ibm.com>
|
|
|
a35d80 |
Date: Thu, 12 Nov 2020 13:12:24 -0300
|
|
|
a35d80 |
Subject: powerpc: Add optimized strncpy for POWER9
|
|
|
a35d80 |
|
|
|
a35d80 |
Similar to the strcpy P9 optimization, this version uses VSX to improve
|
|
|
a35d80 |
performance.
|
|
|
a35d80 |
|
|
|
a35d80 |
Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
|
|
|
a35d80 |
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
|
|
|
a35d80 |
|
|
|
a35d80 |
diff --git a/sysdeps/powerpc/powerpc64/le/power9/strncpy.S b/sysdeps/powerpc/powerpc64/le/power9/strncpy.S
|
|
|
a35d80 |
new file mode 100644
|
|
|
a35d80 |
index 0000000000..cbfc37bda3
|
|
|
a35d80 |
--- /dev/null
|
|
|
a35d80 |
+++ b/sysdeps/powerpc/powerpc64/le/power9/strncpy.S
|
|
|
a35d80 |
@@ -0,0 +1,344 @@
|
|
|
a35d80 |
+/* Optimized strncpy implementation for POWER9 LE.
|
|
|
a35d80 |
+ Copyright (C) 2020 Free Software Foundation, Inc.
|
|
|
a35d80 |
+ This file is part of the GNU C Library.
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
a35d80 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
a35d80 |
+ License as published by the Free Software Foundation; either
|
|
|
a35d80 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
a35d80 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a35d80 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
a35d80 |
+ Lesser General Public License for more details.
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
a35d80 |
+ License along with the GNU C Library; if not, see
|
|
|
a35d80 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+#include <sysdep.h>
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+# ifndef STRNCPY
|
|
|
a35d80 |
+# define FUNC_NAME strncpy
|
|
|
a35d80 |
+# else
|
|
|
a35d80 |
+# define FUNC_NAME STRNCPY
|
|
|
a35d80 |
+# endif
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+#ifndef MEMSET
|
|
|
a35d80 |
+/* For builds without IFUNC support, local calls should be made to internal
|
|
|
a35d80 |
+ GLIBC symbol (created by libc_hidden_builtin_def). */
|
|
|
a35d80 |
+# ifdef SHARED
|
|
|
a35d80 |
+# define MEMSET_is_local
|
|
|
a35d80 |
+# define MEMSET __GI_memset
|
|
|
a35d80 |
+# else
|
|
|
a35d80 |
+# define MEMSET memset
|
|
|
a35d80 |
+# endif
|
|
|
a35d80 |
+#endif
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+#define FRAMESIZE (FRAME_MIN_SIZE+8)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+/* Implements the function
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ char * [r3] strncpy (char *dest [r3], const char *src [r4], size_t n [r5])
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ The implementation can load bytes past a null terminator, but only
|
|
|
a35d80 |
+ up to the next 16-byte aligned address, so it never crosses a page. */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+.machine power9
|
|
|
a35d80 |
+#ifdef MEMSET_is_local
|
|
|
a35d80 |
+ENTRY_TOCLESS (FUNC_NAME, 4)
|
|
|
a35d80 |
+#else
|
|
|
a35d80 |
+ENTRY (FUNC_NAME, 4)
|
|
|
a35d80 |
+#endif
|
|
|
a35d80 |
+ CALL_MCOUNT 2
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ /* NULL string optimizations */
|
|
|
a35d80 |
+ cmpdi r5, 0
|
|
|
a35d80 |
+ beqlr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ lbz r0,0(r4)
|
|
|
a35d80 |
+ stb r0,0(r3)
|
|
|
a35d80 |
+ addi r11,r3,1
|
|
|
a35d80 |
+ addi r5,r5,-1
|
|
|
a35d80 |
+ vspltisb v18,0 /* Zeroes in v18 */
|
|
|
a35d80 |
+ cmpdi r0,0
|
|
|
a35d80 |
+ beq L(zero_padding)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ /* Empty/1-byte string optimization */
|
|
|
a35d80 |
+ cmpdi r5,0
|
|
|
a35d80 |
+ beqlr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ addi r4,r4,1
|
|
|
a35d80 |
+ neg r7,r4
|
|
|
a35d80 |
+ rldicl r9,r7,0,60 /* How many bytes to get source 16B aligned? */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ /* Get source 16B aligned */
|
|
|
a35d80 |
+ lvx v0,0,r4
|
|
|
a35d80 |
+ lvsr v1,0,r4
|
|
|
a35d80 |
+ vperm v0,v18,v0,v1
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ vcmpequb v6,v0,v18 /* 0xff if byte is NULL, 0x00 otherwise */
|
|
|
a35d80 |
+ vctzlsbb r7,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+ addi r8,r7,1 /* Add null terminator */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ /* r8 = bytes including null
|
|
|
a35d80 |
+ r9 = bytes to get source 16B aligned
|
|
|
a35d80 |
+ if r8 > r9
|
|
|
a35d80 |
+ no null, copy r9 bytes
|
|
|
a35d80 |
+ else
|
|
|
a35d80 |
+ there is a null, copy r8 bytes and return. */
|
|
|
a35d80 |
+ cmpld r8,r9
|
|
|
a35d80 |
+ bgt L(no_null)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ cmpld cr6,r8,r5 /* r8 <= n? */
|
|
|
a35d80 |
+ ble cr6,L(null)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ sldi r10,r5,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ stxvl 32+v0,r11,r10 /* Partial store */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ blr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(null):
|
|
|
a35d80 |
+ sldi r10,r8,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ stxvl 32+v0,r11,r10 /* Partial store */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ add r11,r11,r8
|
|
|
a35d80 |
+ sub r5,r5,r8
|
|
|
a35d80 |
+ b L(zero_padding)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(no_null):
|
|
|
a35d80 |
+ cmpld r9,r5 /* Check if length was reached. */
|
|
|
a35d80 |
+ bge L(n_tail1)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ sldi r10,r9,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ stxvl 32+v0,r11,r10 /* Partial store */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ add r4,r4,r9
|
|
|
a35d80 |
+ add r11,r11,r9
|
|
|
a35d80 |
+ sub r5,r5,r9
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(loop):
|
|
|
a35d80 |
+ cmpldi cr6,r5,64 /* Check if length was reached. */
|
|
|
a35d80 |
+ ble cr6,L(final_loop)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ lxv 32+v0,0(r4)
|
|
|
a35d80 |
+ vcmpequb. v6,v0,v18 /* Any zero bytes? */
|
|
|
a35d80 |
+ bne cr6,L(prep_tail1)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ lxv 32+v1,16(r4)
|
|
|
a35d80 |
+ vcmpequb. v6,v1,v18 /* Any zero bytes? */
|
|
|
a35d80 |
+ bne cr6,L(prep_tail2)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ lxv 32+v2,32(r4)
|
|
|
a35d80 |
+ vcmpequb. v6,v2,v18 /* Any zero bytes? */
|
|
|
a35d80 |
+ bne cr6,L(prep_tail3)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ lxv 32+v3,48(r4)
|
|
|
a35d80 |
+ vcmpequb. v6,v3,v18 /* Any zero bytes? */
|
|
|
a35d80 |
+ bne cr6,L(prep_tail4)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ stxv 32+v0,0(r11)
|
|
|
a35d80 |
+ stxv 32+v1,16(r11)
|
|
|
a35d80 |
+ stxv 32+v2,32(r11)
|
|
|
a35d80 |
+ stxv 32+v3,48(r11)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ addi r4,r4,64
|
|
|
a35d80 |
+ addi r11,r11,64
|
|
|
a35d80 |
+ addi r5,r5,-64
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ b L(loop)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(final_loop):
|
|
|
a35d80 |
+ cmpldi cr5,r5,16
|
|
|
a35d80 |
+ lxv 32+v0,0(r4)
|
|
|
a35d80 |
+ vcmpequb. v6,v0,v18 /* Any zero bytes? */
|
|
|
a35d80 |
+ ble cr5,L(prep_n_tail1)
|
|
|
a35d80 |
+ bne cr6,L(count_tail1)
|
|
|
a35d80 |
+ addi r5,r5,-16
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ cmpldi cr5,r5,16
|
|
|
a35d80 |
+ lxv 32+v1,16(r4)
|
|
|
a35d80 |
+ vcmpequb. v6,v1,v18 /* Any zero bytes? */
|
|
|
a35d80 |
+ ble cr5,L(prep_n_tail2)
|
|
|
a35d80 |
+ bne cr6,L(count_tail2)
|
|
|
a35d80 |
+ addi r5,r5,-16
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ cmpldi cr5,r5,16
|
|
|
a35d80 |
+ lxv 32+v2,32(r4)
|
|
|
a35d80 |
+ vcmpequb. v6,v2,v18 /* Any zero bytes? */
|
|
|
a35d80 |
+ ble cr5,L(prep_n_tail3)
|
|
|
a35d80 |
+ bne cr6,L(count_tail3)
|
|
|
a35d80 |
+ addi r5,r5,-16
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ lxv 32+v3,48(r4)
|
|
|
a35d80 |
+ vcmpequb. v6,v3,v18 /* Any zero bytes? */
|
|
|
a35d80 |
+ beq cr6,L(n_tail4)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ vctzlsbb r8,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+ cmpld r8,r5 /* r8 < n? */
|
|
|
a35d80 |
+ blt L(tail4)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(n_tail4):
|
|
|
a35d80 |
+ stxv 32+v0,0(r11)
|
|
|
a35d80 |
+ stxv 32+v1,16(r11)
|
|
|
a35d80 |
+ stxv 32+v2,32(r11)
|
|
|
a35d80 |
+ sldi r10,r5,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ addi r11,r11,48 /* Offset */
|
|
|
a35d80 |
+ stxvl 32+v3,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ blr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(prep_n_tail1):
|
|
|
a35d80 |
+ beq cr6,L(n_tail1) /* Any zero bytes? */
|
|
|
a35d80 |
+ vctzlsbb r8,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+ cmpld r8,r5 /* r8 < n? */
|
|
|
a35d80 |
+ blt L(tail1)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(n_tail1):
|
|
|
a35d80 |
+ sldi r10,r5,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ stxvl 32+v0,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ blr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(prep_n_tail2):
|
|
|
a35d80 |
+ beq cr6,L(n_tail2) /* Any zero bytes? */
|
|
|
a35d80 |
+ vctzlsbb r8,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+ cmpld r8,r5 /* r8 < n? */
|
|
|
a35d80 |
+ blt L(tail2)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(n_tail2):
|
|
|
a35d80 |
+ stxv 32+v0,0(r11)
|
|
|
a35d80 |
+ sldi r10,r5,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ addi r11,r11,16 /* offset */
|
|
|
a35d80 |
+ stxvl 32+v1,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ blr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(prep_n_tail3):
|
|
|
a35d80 |
+ beq cr6,L(n_tail3) /* Any zero bytes? */
|
|
|
a35d80 |
+ vctzlsbb r8,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+ cmpld r8,r5 /* r8 < n? */
|
|
|
a35d80 |
+ blt L(tail3)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(n_tail3):
|
|
|
a35d80 |
+ stxv 32+v0,0(r11)
|
|
|
a35d80 |
+ stxv 32+v1,16(r11)
|
|
|
a35d80 |
+ sldi r10,r5,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ addi r11,r11,32 /* Offset */
|
|
|
a35d80 |
+ stxvl 32+v2,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ blr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(prep_tail1):
|
|
|
a35d80 |
+L(count_tail1):
|
|
|
a35d80 |
+ vctzlsbb r8,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+L(tail1):
|
|
|
a35d80 |
+ addi r9,r8,1 /* Add null terminator */
|
|
|
a35d80 |
+ sldi r10,r9,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ stxvl 32+v0,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ add r11,r11,r9
|
|
|
a35d80 |
+ sub r5,r5,r9
|
|
|
a35d80 |
+ b L(zero_padding)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(prep_tail2):
|
|
|
a35d80 |
+ addi r5,r5,-16
|
|
|
a35d80 |
+L(count_tail2):
|
|
|
a35d80 |
+ vctzlsbb r8,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+L(tail2):
|
|
|
a35d80 |
+ addi r9,r8,1 /* Add null terminator */
|
|
|
a35d80 |
+ stxv 32+v0,0(r11)
|
|
|
a35d80 |
+ sldi r10,r9,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ addi r11,r11,16 /* offset */
|
|
|
a35d80 |
+ stxvl 32+v1,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ add r11,r11,r9
|
|
|
a35d80 |
+ sub r5,r5,r9
|
|
|
a35d80 |
+ b L(zero_padding)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(prep_tail3):
|
|
|
a35d80 |
+ addi r5,r5,-32
|
|
|
a35d80 |
+L(count_tail3):
|
|
|
a35d80 |
+ vctzlsbb r8,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+L(tail3):
|
|
|
a35d80 |
+ addi r9,r8,1 /* Add null terminator */
|
|
|
a35d80 |
+ stxv 32+v0,0(r11)
|
|
|
a35d80 |
+ stxv 32+v1,16(r11)
|
|
|
a35d80 |
+ sldi r10,r9,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ addi r11,r11,32 /* offset */
|
|
|
a35d80 |
+ stxvl 32+v2,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ add r11,r11,r9
|
|
|
a35d80 |
+ sub r5,r5,r9
|
|
|
a35d80 |
+ b L(zero_padding)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(prep_tail4):
|
|
|
a35d80 |
+ addi r5,r5,-48
|
|
|
a35d80 |
+ vctzlsbb r8,v6 /* Number of trailing zeroes */
|
|
|
a35d80 |
+L(tail4):
|
|
|
a35d80 |
+ addi r9,r8,1 /* Add null terminator */
|
|
|
a35d80 |
+ stxv 32+v0,0(r11)
|
|
|
a35d80 |
+ stxv 32+v1,16(r11)
|
|
|
a35d80 |
+ stxv 32+v2,32(r11)
|
|
|
a35d80 |
+ sldi r10,r9,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ addi r11,r11,48 /* offset */
|
|
|
a35d80 |
+ stxvl 32+v3,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ add r11,r11,r9
|
|
|
a35d80 |
+ sub r5,r5,r9
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+/* This code pads the remainder of dest with NULL bytes. For large numbers
|
|
|
a35d80 |
+ memset gives a better performance, 255 was chosen through experimentation.
|
|
|
a35d80 |
+ */
|
|
|
a35d80 |
+L(zero_padding):
|
|
|
a35d80 |
+ cmpldi r5,255
|
|
|
a35d80 |
+ bge L(zero_padding_memset)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(zero_padding_loop):
|
|
|
a35d80 |
+ cmpldi cr6,r5,16 /* Check if length was reached. */
|
|
|
a35d80 |
+ ble cr6,L(zero_padding_end)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ stxv v18,0(r11)
|
|
|
a35d80 |
+ addi r11,r11,16
|
|
|
a35d80 |
+ addi r5,r5,-16
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ b L(zero_padding_loop)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+L(zero_padding_end):
|
|
|
a35d80 |
+ sldi r10,r5,56 /* stxvl wants size in top 8 bits */
|
|
|
a35d80 |
+ stxvl v18,r11,r10 /* Partial store */
|
|
|
a35d80 |
+ blr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ .align 4
|
|
|
a35d80 |
+L(zero_padding_memset):
|
|
|
a35d80 |
+ std r30,-8(r1) /* Save r30 on the stack. */
|
|
|
a35d80 |
+ cfi_offset(r30, -8)
|
|
|
a35d80 |
+ mr r30,r3 /* Save the return value of strncpy. */
|
|
|
a35d80 |
+ /* Prepare the call to memset. */
|
|
|
a35d80 |
+ mr r3,r11 /* Pointer to the area to be zero-filled. */
|
|
|
a35d80 |
+ li r4,0 /* Byte to be written (zero). */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ /* We delayed the creation of the stack frame, as well as the saving of
|
|
|
a35d80 |
+ the link register, because only at this point, we are sure that
|
|
|
a35d80 |
+ doing so is actually needed. */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ /* Save the link register. */
|
|
|
a35d80 |
+ mflr r0
|
|
|
a35d80 |
+ std r0,16(r1)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ /* Create the stack frame. */
|
|
|
a35d80 |
+ stdu r1,-FRAMESIZE(r1)
|
|
|
a35d80 |
+ cfi_adjust_cfa_offset(FRAMESIZE)
|
|
|
a35d80 |
+ cfi_offset(lr, 16)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ bl MEMSET
|
|
|
a35d80 |
+#ifndef MEMSET_is_local
|
|
|
a35d80 |
+ nop
|
|
|
a35d80 |
+#endif
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ ld r0,FRAMESIZE+16(r1)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ mr r3,r30 /* Restore the return value of strncpy, i.e.:
|
|
|
a35d80 |
+ dest. */
|
|
|
a35d80 |
+ ld r30,FRAMESIZE-8(r1) /* Restore r30. */
|
|
|
a35d80 |
+ /* Restore the stack frame. */
|
|
|
a35d80 |
+ addi r1,r1,FRAMESIZE
|
|
|
a35d80 |
+ cfi_adjust_cfa_offset(-FRAMESIZE)
|
|
|
a35d80 |
+ /* Restore the link register. */
|
|
|
a35d80 |
+ mtlr r0
|
|
|
a35d80 |
+ cfi_restore(lr)
|
|
|
a35d80 |
+ blr
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+END (FUNC_NAME)
|
|
|
a35d80 |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
a35d80 |
index 19acb6c64a..cd2b47b403 100644
|
|
|
a35d80 |
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
a35d80 |
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
|
|
|
a35d80 |
@@ -33,7 +33,7 @@ sysdep_routines += memcpy-power8-cached memcpy-power7 memcpy-a2 memcpy-power6 \
|
|
|
a35d80 |
|
|
|
a35d80 |
ifneq (,$(filter %le,$(config-machine)))
|
|
|
a35d80 |
sysdep_routines += strcmp-power9 strncmp-power9 strcpy-power9 stpcpy-power9 \
|
|
|
a35d80 |
- rawmemchr-power9 strlen-power9
|
|
|
a35d80 |
+ rawmemchr-power9 strlen-power9 strncpy-power9
|
|
|
a35d80 |
endif
|
|
|
a35d80 |
CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
|
|
|
a35d80 |
CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
|
|
|
a35d80 |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
a35d80 |
index dd54e7d6bb..135326c97a 100644
|
|
|
a35d80 |
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
a35d80 |
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
|
|
|
a35d80 |
@@ -301,6 +301,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
a35d80 |
|
|
|
a35d80 |
/* Support sysdeps/powerpc/powerpc64/multiarch/strncpy.c. */
|
|
|
a35d80 |
IFUNC_IMPL (i, name, strncpy,
|
|
|
a35d80 |
+#ifdef __LITTLE_ENDIAN__
|
|
|
a35d80 |
+ IFUNC_IMPL_ADD (array, i, strncpy,
|
|
|
a35d80 |
+ (hwcap2 & PPC_FEATURE2_ARCH_3_00)
|
|
|
a35d80 |
+ && (hwcap & PPC_FEATURE_HAS_VSX),
|
|
|
a35d80 |
+ __strncpy_power9)
|
|
|
a35d80 |
+#endif
|
|
|
a35d80 |
IFUNC_IMPL_ADD (array, i, strncpy,
|
|
|
a35d80 |
hwcap2 & PPC_FEATURE2_ARCH_2_07,
|
|
|
a35d80 |
__strncpy_power8)
|
|
|
a35d80 |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncpy-power9.S b/sysdeps/powerpc/powerpc64/multiarch/strncpy-power9.S
|
|
|
a35d80 |
new file mode 100644
|
|
|
a35d80 |
index 0000000000..2b57c190f5
|
|
|
a35d80 |
--- /dev/null
|
|
|
a35d80 |
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncpy-power9.S
|
|
|
a35d80 |
@@ -0,0 +1,32 @@
|
|
|
a35d80 |
+/* Optimized strncpy implementation for POWER9 LE.
|
|
|
a35d80 |
+ Copyright (C) 2020 Free Software Foundation, Inc.
|
|
|
a35d80 |
+ This file is part of the GNU C Library.
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
a35d80 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
a35d80 |
+ License as published by the Free Software Foundation; either
|
|
|
a35d80 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
a35d80 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a35d80 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
a35d80 |
+ Lesser General Public License for more details.
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
a35d80 |
+ License along with the GNU C Library; if not, see
|
|
|
a35d80 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+#if defined __LITTLE_ENDIAN__ && IS_IN (libc)
|
|
|
a35d80 |
+# define STRNCPY __strncpy_power9
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+# undef libc_hidden_builtin_def
|
|
|
a35d80 |
+# define libc_hidden_builtin_def(name)
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+/* memset is used to pad the end of the string. */
|
|
|
a35d80 |
+# define MEMSET __memset_power8
|
|
|
a35d80 |
+# ifdef SHARED
|
|
|
a35d80 |
+# define MEMSET_is_local
|
|
|
a35d80 |
+# endif
|
|
|
a35d80 |
+
|
|
|
a35d80 |
+# include <sysdeps/powerpc/powerpc64/le/power9/strncpy.S>
|
|
|
a35d80 |
+#endif
|
|
|
a35d80 |
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncpy.c b/sysdeps/powerpc/powerpc64/multiarch/strncpy.c
|
|
|
a35d80 |
index 7bacf28aca..af8b6cdd9c 100644
|
|
|
a35d80 |
--- a/sysdeps/powerpc/powerpc64/multiarch/strncpy.c
|
|
|
a35d80 |
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncpy.c
|
|
|
a35d80 |
@@ -28,11 +28,19 @@
|
|
|
a35d80 |
extern __typeof (strncpy) __strncpy_ppc attribute_hidden;
|
|
|
a35d80 |
extern __typeof (strncpy) __strncpy_power7 attribute_hidden;
|
|
|
a35d80 |
extern __typeof (strncpy) __strncpy_power8 attribute_hidden;
|
|
|
a35d80 |
+# ifdef __LITTLE_ENDIAN__
|
|
|
a35d80 |
+extern __typeof (strncpy) __strncpy_power9 attribute_hidden;
|
|
|
a35d80 |
+# endif
|
|
|
a35d80 |
# undef strncpy
|
|
|
a35d80 |
|
|
|
a35d80 |
/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
|
|
|
a35d80 |
ifunc symbol properly. */
|
|
|
a35d80 |
libc_ifunc_redirected (__redirect_strncpy, strncpy,
|
|
|
a35d80 |
+# ifdef __LITTLE_ENDIAN__
|
|
|
a35d80 |
+ (hwcap2 & PPC_FEATURE2_ARCH_3_00) &&
|
|
|
a35d80 |
+ (hwcap & PPC_FEATURE_HAS_VSX)
|
|
|
a35d80 |
+ ? __strncpy_power9 :
|
|
|
a35d80 |
+# endif
|
|
|
a35d80 |
(hwcap2 & PPC_FEATURE2_ARCH_2_07)
|
|
|
a35d80 |
? __strncpy_power8
|
|
|
a35d80 |
: (hwcap & PPC_FEATURE_HAS_VSX)
|