From owner-dev-commits-src-all@freebsd.org Tue Apr 6 11:27:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A2D415CC9FE; Tue, 6 Apr 2021 11:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FF4xc4CRmz4ZxS; Tue, 6 Apr 2021 11:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8364A2C53; Tue, 6 Apr 2021 11:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 136BRGmv052464; Tue, 6 Apr 2021 11:27:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136BRG5b052463; Tue, 6 Apr 2021 11:27:16 GMT (envelope-from git) Date: Tue, 6 Apr 2021 11:27:16 GMT Message-Id: <202104061127.136BRG5b052463@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Leandro Lupori Subject: git: e21b6ce854f2 - stable/13 - [PowerPC64] Port optimized strcpy to PPC64LE MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: luporl X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e21b6ce854f25540f9f8ba33f15d60c5de91bc29 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 11:27:16 -0000 The branch stable/13 has been updated by luporl: URL: https://cgit.FreeBSD.org/src/commit/?id=e21b6ce854f25540f9f8ba33f15d60c5de91bc29 commit e21b6ce854f25540f9f8ba33f15d60c5de91bc29 Author: Leandro Lupori AuthorDate: 2021-03-25 16:14:00 +0000 Commit: Leandro Lupori CommitDate: 2021-04-06 11:26:30 +0000 [PowerPC64] Port optimized strcpy to PPC64LE Submitted by: Bruno Larsen Reviewed by: luporl, bdragon (IRC) MFC after: 1 week Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D29067 (cherry picked from commit 9f50aa45be18b9b11b14345fe0a137d1ac51a391) --- lib/libc/powerpc64/string/Makefile.inc | 7 +-- lib/libc/powerpc64/string/strcpy_arch_2_05.S | 66 ++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/lib/libc/powerpc64/string/Makefile.inc b/lib/libc/powerpc64/string/Makefile.inc index 14f0845595c9..486ca47a44be 100644 --- a/lib/libc/powerpc64/string/Makefile.inc +++ b/lib/libc/powerpc64/string/Makefile.inc @@ -12,12 +12,7 @@ MDSRCS+= \ memmove_resolver.c \ strncpy_arch_2_05.S \ strncpy.c \ - strncpy_resolver.c - -# XXX Port strcpy to LE. -.if ${MACHINE_ARCH} == "powerpc64" -MDSRCS+= \ + strncpy_resolver.c \ strcpy_arch_2_05.S \ strcpy.c \ strcpy_resolver.c -.endif diff --git a/lib/libc/powerpc64/string/strcpy_arch_2_05.S b/lib/libc/powerpc64/string/strcpy_arch_2_05.S index 23ffb5c2a75e..7f42fd813395 100644 --- a/lib/libc/powerpc64/string/strcpy_arch_2_05.S +++ b/lib/libc/powerpc64/string/strcpy_arch_2_05.S @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#if !defined(__BIG_ENDIAN__) -#error "Optimized SRTCPY is only supported by big-endian architecture!" -#endif #include __FBSDID("$FreeBSD$"); @@ -71,6 +68,7 @@ ENTRY(__strcpy_arch_2_05) beq cr7,.Lcopy_dw_loop addi %r8,%r8,8 /* Forward r8 to use std instruction. */ +#if defined(__BIG_ENDIAN__) /* Find where the zero is located. */ .Lcheck_zero: rldicr. %r5,%r0,0,7 @@ -136,6 +134,68 @@ ENTRY(__strcpy_arch_2_05) .Lfound_on_byte_0: srdi %r6,%r0,56 stb %r6,0(%r8) +#elif defined(__LITTLE_ENDIAN__) +/* Find where the zero is located. */ +.Lcheck_zero: + andi. %r7,%r0,0xff + beq .Lfound_on_byte_0 + andi. %r7,%r0,0xff00 + beq .Lfound_on_byte_1 + andis. %r7,%r0,0xff + beq .Lfound_on_byte_2 + andis. %r7,%r0,0xff00 + beq .Lfound_on_byte_3 + rldicr. %r7,%r0,24,7 + beq .Lfound_on_byte_4 + rldicr. %r7,%r0,16,7 + beq .Lfound_on_byte_5 + rldicr. %r7,%r0,8,7 + beq .Lfound_on_byte_6 + +/* Copy the last string bytes according to the string end position. */ +.Lfound_on_byte_7: + std %r0,0(%r8) + b .Lexit + +.Lfound_on_byte_6: + stw %r0,0(%r8) + srdi %r6,%r0,32 + sth %r6,4(%r8) + srdi %r6,%r0,48 + stb %r6,6(%r8) + b .Lexit + +.Lfound_on_byte_5: + stw %r0,0(%r8) + srdi %r6,%r0,32 + sth %r6,4(%r8) + b .Lexit + +.Lfound_on_byte_4: + stw %r0,0(%r8) + srdi %r6,%r0,32 + stb %r6,4(%r8) + b .Lexit + +.Lfound_on_byte_3: + stw %r0,0(%r8) + b .Lexit + +.Lfound_on_byte_2: + sth %r0,0(%r8) + srdi %r6,%r0,16 + stb %r6,2(%r8) + b .Lexit + +.Lfound_on_byte_1: + sth %r0,0(%r8) + b .Lexit + +.Lfound_on_byte_0: + stb %r0,0(%r8) +#else +#error "Unable to determine Endianness" +#endif .Lexit: blr