From nobody Fri Nov 19 11:56:18 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 39FC4189DAD7; Fri, 19 Nov 2021 11:56:19 +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 4HwZrM17frz3DmV; Fri, 19 Nov 2021 11:56:19 +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 03B8F277F4; Fri, 19 Nov 2021 11:56:19 +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 1AJBuIYq023590; Fri, 19 Nov 2021 11:56:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AJBuIoa023589; Fri, 19 Nov 2021 11:56:18 GMT (envelope-from git) Date: Fri, 19 Nov 2021 11:56:18 GMT Message-Id: <202111191156.1AJBuIoa023589@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 2e8ff4d1d5b9 - main - Switch to Arm Optimized Routines for mem* & str* List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2e8ff4d1d5b9d32b29287efb414449121733544a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=2e8ff4d1d5b9d32b29287efb414449121733544a commit 2e8ff4d1d5b9d32b29287efb414449121733544a Author: Andrew Turner AuthorDate: 2021-11-01 13:06:56 +0000 Commit: Andrew Turner CommitDate: 2021-11-19 11:40:46 +0000 Switch to Arm Optimized Routines for mem* & str* These are the updated version of the older Cortex Strings Library we previously used. The Arm Optimized Routines also support CPU features that are currently in development on FreeBSD, e.g. Branch Target Identification (BTI). Rather than add BTI support to the old code it's easier to just use the maintained version. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32774 --- lib/libc/aarch64/string/Makefile.inc | 51 +++++++++++++++++++++++++----------- lib/libc/aarch64/string/memcpy.S | 6 +++++ lib/libc/aarch64/string/memmove.S | 5 ++++ lib/libc/aarch64/string/strchr.S | 5 ++++ lib/libc/aarch64/string/strrchr.S | 5 ++++ 5 files changed, 57 insertions(+), 15 deletions(-) diff --git a/lib/libc/aarch64/string/Makefile.inc b/lib/libc/aarch64/string/Makefile.inc index 5ce355f8b0c1..0e1f0f4b84e2 100644 --- a/lib/libc/aarch64/string/Makefile.inc +++ b/lib/libc/aarch64/string/Makefile.inc @@ -1,20 +1,41 @@ # $FreeBSD$ # -# String handling from the Cortex Strings library -# https://git.linaro.org/toolchain/cortex-strings.git +# String handling from the Arm Optimized Routines +# https://github.com/ARM-software/optimized-routines # -.PATH: ${SRCTOP}/contrib/cortex-strings/src/aarch64 +AARCH64_STRING_FUNCS= \ + memchr \ + memcmp \ + memcpy \ + memmove \ + memrchr \ + memset \ + stpcpy \ + strchr \ + strchrnul \ + strcmp \ + strcpy \ + strlen \ + strncmp \ + strnlen \ + strrchr -MDSRCS+= \ - memchr.S \ - memcmp.S \ - memcpy.S \ - memmove.S \ - memset.S \ - strchr.S \ - strcmp.S \ - strcpy.S \ - strlen.S \ - strncmp.S \ - strnlen.S +# +# Add the above functions. Generate an asm file that includes the needed +# Arm Optimized Routines file defining the function name to the libc name. +# Some file need multiple macros defined or a weak symbol added we can +# override the generated file in these cases. +# +.for FUNC in ${AARCH64_STRING_FUNCS} +.if !exists(${FUNC}.S) +${FUNC}.S: + printf '/* %sgenerated by libc/aarch64/string/Makefile.inc */\n' @ > ${.TARGET} + printf '#define __%s_aarch64 %s\n' ${FUNC} ${FUNC} >> ${.TARGET} + printf '#include "aarch64/%s.S"\n' ${FUNC} >> ${.TARGET} +CLEANFILES+= ${FUNC}.S +.endif + +MDSRCS+= ${FUNC}.S +CFLAGS.${FUNC}.S+=-I${SRCTOP}/contrib/arm-optimized-routines/string +.endfor diff --git a/lib/libc/aarch64/string/memcpy.S b/lib/libc/aarch64/string/memcpy.S new file mode 100644 index 000000000000..ac4fbe8d6175 --- /dev/null +++ b/lib/libc/aarch64/string/memcpy.S @@ -0,0 +1,6 @@ +#define __memcpy_aarch64 memcpy +#define __memmove_aarch64 memmove +#include "aarch64/memcpy.S" + +.weak index +.equ index, strchr diff --git a/lib/libc/aarch64/string/memmove.S b/lib/libc/aarch64/string/memmove.S new file mode 100644 index 000000000000..e2f99790e0da --- /dev/null +++ b/lib/libc/aarch64/string/memmove.S @@ -0,0 +1,5 @@ +/* + * memmove is implemented in memcpy.S. Having this file simplifies the build + * as it stops MISRCS from picking up the C implementation and rtld expects + * to copy the memmove object file into its object directory. + */ diff --git a/lib/libc/aarch64/string/strchr.S b/lib/libc/aarch64/string/strchr.S new file mode 100644 index 000000000000..e241b35004bb --- /dev/null +++ b/lib/libc/aarch64/string/strchr.S @@ -0,0 +1,5 @@ +#define __strchr_aarch64 strchr +#include "aarch64/strchr.S" + +.weak index +.equ index, strchr diff --git a/lib/libc/aarch64/string/strrchr.S b/lib/libc/aarch64/string/strrchr.S new file mode 100644 index 000000000000..46e966e3188a --- /dev/null +++ b/lib/libc/aarch64/string/strrchr.S @@ -0,0 +1,5 @@ +#define __strrchr_aarch64 strrchr +#include "aarch64/strrchr.S" + +.weak rindex +.equ rindex, strrchr