From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 71EC13858C39 for ; Mon, 31 Jul 2023 06:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 71EC13858C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy02.your-server.de ([78.47.166.47]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qQMmP-000Pwt-3E; Mon, 31 Jul 2023 08:53:21 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qQMmO-000Weu-VJ; Mon, 31 Jul 2023 08:53:21 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id A0CC148004C; Mon, 31 Jul 2023 08:53:20 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavis, port 10032) with ESMTP id 4XHbPF5fuJAL; Mon, 31 Jul 2023 08:53:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id ED0FB4800A3; Mon, 31 Jul 2023 08:53:19 +0200 (CEST) X-Virus-Scanned: amavis at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavis, port 10026) with ESMTP id UX80iCN-SlMH; Mon, 31 Jul 2023 08:53:19 +0200 (CEST) Received: from zimbra.eb.localhost (unknown [192.168.96.242]) by mail.embedded-brains.de (Postfix) with ESMTPSA id CA37448004C; Mon, 31 Jul 2023 08:53:19 +0200 (CEST) From: Sebastian Huber To: newlib@sourceware.org Cc: Richard Earnshaw Subject: [PATCH v2] aarch64: Import memrchr.S Date: Mon, 31 Jul 2023 08:53:17 +0200 Message-Id: <20230731065317.64217-1-sebastian.huber@embedded-brains.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldi-networks.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26985/Sun Jul 30 09:27:27 2023) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Import memrchr.S for AArch64 from: https://github.com/ARM-software/optimized-routines commit 88b050e7d88d8dff4ffda97d9cf13a1c1b448eb7 Author: Joe Ramsay Date: Tue Jul 25 10:01:52 2023 +0100 pl/math: Use width-agnostic intrinsic forms No effect on performance, but a small improvement in readability. --- v2: Fix support for __OPTIMIZE_SIZE__ and PREFER_SIZE_OVER_SPEED. newlib/Makefile.in | 56 ++++++++-- newlib/libc/machine/aarch64/Makefile.inc | 2 + newlib/libc/machine/aarch64/memrchr-stub.c | 11 ++ newlib/libc/machine/aarch64/memrchr.S | 115 +++++++++++++++++++++ 4 files changed, 176 insertions(+), 8 deletions(-) create mode 100644 newlib/libc/machine/aarch64/memrchr-stub.c create mode 100644 newlib/libc/machine/aarch64/memrchr.S diff --git a/newlib/Makefile.in b/newlib/Makefile.in index 4d2b5e7825..302dbeea29 100644 --- a/newlib/Makefile.in +++ b/newlib/Makefile.in @@ -594,6 +594,8 @@ check_PROGRAMS =3D @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/memcpy.S \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/memmove-stub.c \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/memmove.S \ +@HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/memrchr-stub.c \ +@HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/memrchr.S \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/memset-stub.c \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/memset.S \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/rawmemchr.S \ @@ -911,18 +913,18 @@ check_PROGRAMS =3D @NEWLIB_HW_FP_FALSE@am__append_136 =3D libm/math/math.tex @HAVE_LONG_DOUBLE_TRUE@am__append_137 =3D $(libm_common_lsrc) @HAVE_FPMATH_H_TRUE@@HAVE_LONG_DOUBLE_TRUE@am__append_138 =3D $(libm_ld_= lsrc) -@HAVE_FPMATH_H_TRUE@am__append_139 =3D -@HAVE_FPMATH_H_TRUE@am__append_140 =3D +@HAVE_FPMATH_H_TRUE@am__append_139 =3D=20 +@HAVE_FPMATH_H_TRUE@am__append_140 =3D=20 @HAVE_LIBM_MACHINE_AARCH64_TRUE@am__append_141 =3D $(libm_machine_aarch6= 4_src) @HAVE_LIBM_MACHINE_AARCH64_TRUE@@HAVE_LONG_DOUBLE_TRUE@am__append_142 =3D= $(libm_ld128_lsrc) -@HAVE_LIBM_MACHINE_AARCH64_TRUE@am__append_143 =3D -@HAVE_LIBM_MACHINE_AARCH64_TRUE@am__append_144 =3D +@HAVE_LIBM_MACHINE_AARCH64_TRUE@am__append_143 =3D=20 +@HAVE_LIBM_MACHINE_AARCH64_TRUE@am__append_144 =3D=20 @HAVE_LIBM_MACHINE_AMDGCN_TRUE@am__append_145 =3D $(libm_machine_amdgcn_= src) @HAVE_LIBM_MACHINE_ARM_TRUE@am__append_146 =3D $(libm_machine_arm_src) @HAVE_LIBM_MACHINE_I386_TRUE@am__append_147 =3D $(libm_machine_i386_src) @HAVE_LIBM_MACHINE_I386_TRUE@@HAVE_LONG_DOUBLE_TRUE@am__append_148 =3D $= (libm_ld80_lsrc) -@HAVE_LIBM_MACHINE_I386_TRUE@am__append_149 =3D -@HAVE_LIBM_MACHINE_I386_TRUE@am__append_150 =3D +@HAVE_LIBM_MACHINE_I386_TRUE@am__append_149 =3D=20 +@HAVE_LIBM_MACHINE_I386_TRUE@am__append_150 =3D=20 @HAVE_LIBM_MACHINE_MIPS_TRUE@am__append_151 =3D $(libm_machine_mips_src) @HAS_NDS32_FPU_SP_TRUE@@HAVE_LIBM_MACHINE_NDS32_TRUE@am__append_152 =3D = libm/machine/nds32/wf_sqrt.S @HAS_NDS32_FPU_DP_TRUE@@HAVE_LIBM_MACHINE_NDS32_TRUE@am__append_153 =3D = libm/machine/nds32/w_sqrt.S @@ -934,8 +936,8 @@ check_PROGRAMS =3D @HAVE_LIBM_MACHINE_RISCV_TRUE@am__append_159 =3D $(libm_machine_riscv_sr= c) @HAVE_LIBM_MACHINE_X86_64_TRUE@am__append_160 =3D $(libm_machine_x86_64_= src) @HAVE_LIBM_MACHINE_X86_64_TRUE@@HAVE_LONG_DOUBLE_TRUE@am__append_161 =3D= $(libm_ld80_lsrc) -@HAVE_LIBM_MACHINE_X86_64_TRUE@am__append_162 =3D -@HAVE_LIBM_MACHINE_X86_64_TRUE@am__append_163 =3D +@HAVE_LIBM_MACHINE_X86_64_TRUE@am__append_162 =3D=20 +@HAVE_LIBM_MACHINE_X86_64_TRUE@am__append_163 =3D=20 subdir =3D . ACLOCAL_M4 =3D $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps =3D $(top_srcdir)/../config/depstand.m4 \ @@ -1831,6 +1833,8 @@ am__objects_51 =3D libc/ssp/libc_a-chk_fail.$(OBJEX= T) \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/libc_a-memcpy.$(OB= JEXT) \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/libc_a-memmove-stu= b.$(OBJEXT) \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/libc_a-memmove.$(O= BJEXT) \ +@HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/libc_a-memrchr-stu= b.$(OBJEXT) \ +@HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/libc_a-memrchr.$(O= BJEXT) \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/libc_a-memset-stub= .$(OBJEXT) \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/libc_a-memset.$(OB= JEXT) \ @HAVE_LIBC_MACHINE_AARCH64_TRUE@ libc/machine/aarch64/libc_a-rawmemchr.$= (OBJEXT) \ @@ -7948,6 +7952,12 @@ libc/machine/aarch64/libc_a-memmove-stub.$(OBJEXT)= : \ libc/machine/aarch64/libc_a-memmove.$(OBJEXT): \ libc/machine/aarch64/$(am__dirstamp) \ libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp) +libc/machine/aarch64/libc_a-memrchr-stub.$(OBJEXT): \ + libc/machine/aarch64/$(am__dirstamp) \ + libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp) +libc/machine/aarch64/libc_a-memrchr.$(OBJEXT): \ + libc/machine/aarch64/$(am__dirstamp) \ + libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp) libc/machine/aarch64/libc_a-memset-stub.$(OBJEXT): \ libc/machine/aarch64/$(am__dirstamp) \ libc/machine/aarch64/$(DEPDIR)/$(am__dirstamp) @@ -12588,6 +12598,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc= _a-memcpy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc= _a-memmove-stub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc= _a-memmove.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc= _a-memrchr-stub.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc= _a-memrchr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc= _a-memset-stub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc= _a-memset.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc= _a-rawmemchr-stub.Po@am__quote@ @@ -16547,6 +16559,20 @@ libc/machine/aarch64/libc_a-memmove.obj: libc/ma= chine/aarch64/memmove.S @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=3D$(DEPDIR) $(CCASDEPMODE) $(= depcomp) @AMDEPBACKSLASH@ @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAUL= T_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS= ) $(CCASFLAGS) -c -o libc/machine/aarch64/libc_a-memmove.obj `if test -f = 'libc/machine/aarch64/memmove.S'; then $(CYGPATH_W) 'libc/machine/aarch64= /memmove.S'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memmove.S'= ; fi` =20 +libc/machine/aarch64/libc_a-memrchr.o: libc/machine/aarch64/memrchr.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) = $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAG= S) -MT libc/machine/aarch64/libc_a-memrchr.o -MD -MP -MF libc/machine/aar= ch64/$(DEPDIR)/libc_a-memrchr.Tpo -c -o libc/machine/aarch64/libc_a-memrc= hr.o `test -f 'libc/machine/aarch64/memrchr.S' || echo '$(srcdir)/'`libc/= machine/aarch64/memrchr.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR= )/libc_a-memrchr.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source=3D'libc/machine/= aarch64/memrchr.S' object=3D'libc/machine/aarch64/libc_a-memrchr.o' libto= ol=3Dno @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=3D$(DEPDIR) $(CCASDEPMODE) $(= depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAUL= T_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS= ) $(CCASFLAGS) -c -o libc/machine/aarch64/libc_a-memrchr.o `test -f 'libc= /machine/aarch64/memrchr.S' || echo '$(srcdir)/'`libc/machine/aarch64/mem= rchr.S + +libc/machine/aarch64/libc_a-memrchr.obj: libc/machine/aarch64/memrchr.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) = $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAG= S) -MT libc/machine/aarch64/libc_a-memrchr.obj -MD -MP -MF libc/machine/a= arch64/$(DEPDIR)/libc_a-memrchr.Tpo -c -o libc/machine/aarch64/libc_a-mem= rchr.obj `if test -f 'libc/machine/aarch64/memrchr.S'; then $(CYGPATH_W) = 'libc/machine/aarch64/memrchr.S'; else $(CYGPATH_W) '$(srcdir)/libc/machi= ne/aarch64/memrchr.S'; fi` +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR= )/libc_a-memrchr.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source=3D'libc/machine/= aarch64/memrchr.S' object=3D'libc/machine/aarch64/libc_a-memrchr.obj' lib= tool=3Dno @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=3D$(DEPDIR) $(CCASDEPMODE) $(= depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CCAS) $(DEFS) $(DEFAUL= T_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS= ) $(CCASFLAGS) -c -o libc/machine/aarch64/libc_a-memrchr.obj `if test -f = 'libc/machine/aarch64/memrchr.S'; then $(CYGPATH_W) 'libc/machine/aarch64= /memrchr.S'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memrchr.S'= ; fi` + libc/machine/aarch64/libc_a-memset.o: libc/machine/aarch64/memset.S @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) = $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CCASFLAGS) $(CCASFLAG= S) -MT libc/machine/aarch64/libc_a-memset.o -MD -MP -MF libc/machine/aarc= h64/$(DEPDIR)/libc_a-memset.Tpo -c -o libc/machine/aarch64/libc_a-memset.= o `test -f 'libc/machine/aarch64/memset.S' || echo '$(srcdir)/'`libc/mach= ine/aarch64/memset.S @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR= )/libc_a-memset.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memset.Po @@ -32649,6 +32675,20 @@ libc/machine/aarch64/libc_a-memmove-stub.obj: li= bc/machine/aarch64/memmove-stub. @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=3D$(DEPDIR) $(CCDEPMODE) $(depc= omp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLU= DES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS= ) -c -o libc/machine/aarch64/libc_a-memmove-stub.obj `if test -f 'libc/ma= chine/aarch64/memmove-stub.c'; then $(CYGPATH_W) 'libc/machine/aarch64/me= mmove-stub.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memmove-= stub.c'; fi` =20 +libc/machine/aarch64/libc_a-memrchr-stub.o: libc/machine/aarch64/memrchr= -stub.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLU= DES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/m= achine/aarch64/libc_a-memrchr-stub.o -MD -MP -MF libc/machine/aarch64/$(D= EPDIR)/libc_a-memrchr-stub.Tpo -c -o libc/machine/aarch64/libc_a-memrchr-= stub.o `test -f 'libc/machine/aarch64/memrchr-stub.c' || echo '$(srcdir)/= '`libc/machine/aarch64/memrchr-stub.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/= libc_a-memrchr-stub.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr-stu= b.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source=3D'libc/machine/aarch= 64/memrchr-stub.c' object=3D'libc/machine/aarch64/libc_a-memrchr-stub.o' = libtool=3Dno @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=3D$(DEPDIR) $(CCDEPMODE) $(depc= omp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLU= DES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS= ) -c -o libc/machine/aarch64/libc_a-memrchr-stub.o `test -f 'libc/machine= /aarch64/memrchr-stub.c' || echo '$(srcdir)/'`libc/machine/aarch64/memrch= r-stub.c + +libc/machine/aarch64/libc_a-memrchr-stub.obj: libc/machine/aarch64/memrc= hr-stub.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLU= DES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/m= achine/aarch64/libc_a-memrchr-stub.obj -MD -MP -MF libc/machine/aarch64/$= (DEPDIR)/libc_a-memrchr-stub.Tpo -c -o libc/machine/aarch64/libc_a-memrch= r-stub.obj `if test -f 'libc/machine/aarch64/memrchr-stub.c'; then $(CYGP= ATH_W) 'libc/machine/aarch64/memrchr-stub.c'; else $(CYGPATH_W) '$(srcdir= )/libc/machine/aarch64/memrchr-stub.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/= libc_a-memrchr-stub.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memrchr-stu= b.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source=3D'libc/machine/aarch= 64/memrchr-stub.c' object=3D'libc/machine/aarch64/libc_a-memrchr-stub.obj= ' libtool=3Dno @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=3D$(DEPDIR) $(CCDEPMODE) $(depc= omp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLU= DES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS= ) -c -o libc/machine/aarch64/libc_a-memrchr-stub.obj `if test -f 'libc/ma= chine/aarch64/memrchr-stub.c'; then $(CYGPATH_W) 'libc/machine/aarch64/me= mrchr-stub.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/memrchr-= stub.c'; fi` + libc/machine/aarch64/libc_a-memset-stub.o: libc/machine/aarch64/memset-s= tub.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLU= DES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/m= achine/aarch64/libc_a-memset-stub.o -MD -MP -MF libc/machine/aarch64/$(DE= PDIR)/libc_a-memset-stub.Tpo -c -o libc/machine/aarch64/libc_a-memset-stu= b.o `test -f 'libc/machine/aarch64/memset-stub.c' || echo '$(srcdir)/'`li= bc/machine/aarch64/memset-stub.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/machine/aarch64/$(DEPDIR)/= libc_a-memset-stub.Tpo libc/machine/aarch64/$(DEPDIR)/libc_a-memset-stub.= Po diff --git a/newlib/libc/machine/aarch64/Makefile.inc b/newlib/libc/machi= ne/aarch64/Makefile.inc index 063a2a84ae..c749b0d575 100644 --- a/newlib/libc/machine/aarch64/Makefile.inc +++ b/newlib/libc/machine/aarch64/Makefile.inc @@ -7,6 +7,8 @@ libc_a_SOURCES +=3D \ %D%/memcpy.S \ %D%/memmove-stub.c \ %D%/memmove.S \ + %D%/memrchr-stub.c \ + %D%/memrchr.S \ %D%/memset-stub.c \ %D%/memset.S \ %D%/rawmemchr.S \ diff --git a/newlib/libc/machine/aarch64/memrchr-stub.c b/newlib/libc/mac= hine/aarch64/memrchr-stub.c new file mode 100644 index 0000000000..d80ca88ab0 --- /dev/null +++ b/newlib/libc/machine/aarch64/memrchr-stub.c @@ -0,0 +1,11 @@ +/*=20 + * Copyright (C) 2023 embedded brains GmbH & Co. KG + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) +#include "../../string/memrchr.c" +#else +/* See memrchr.S */ +#endif diff --git a/newlib/libc/machine/aarch64/memrchr.S b/newlib/libc/machine/= aarch64/memrchr.S new file mode 100644 index 0000000000..ba9915cc3d --- /dev/null +++ b/newlib/libc/machine/aarch64/memrchr.S @@ -0,0 +1,115 @@ +/* + * memrchr - find last character in a memory zone. + * + * Copyright (c) 2020-2022, Arm Limited. + * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception + */ + +/* Assumptions: + * + * ARMv8-a, AArch64, Advanced SIMD. + * MTE compatible. + */ + +#if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) +/* See memrchr-stub.c */ +#else +#include "asmdefs.h" + +#define srcin x0 +#define chrin w1 +#define cntin x2 +#define result x0 + +#define src x3 +#define cntrem x4 +#define synd x5 +#define shift x6 +#define tmp x7 +#define end x8 +#define endm1 x9 + +#define vrepchr v0 +#define qdata q1 +#define vdata v1 +#define vhas_chr v2 +#define vend v3 +#define dend d3 + +/* + Core algorithm: + For each 16-byte chunk we calculate a 64-bit nibble mask value with f= our bits + per byte. We take 4 bits of every comparison byte with shift right an= d narrow + by 4 instruction. Since the bits in the nibble mask reflect the order= in + which things occur in the original string, counting leading zeros ide= ntifies + exactly which byte matched. */ + +ENTRY (memrchr) + PTR_ARG (0) + add end, srcin, cntin + sub endm1, end, 1 + bic src, endm1, 15 + cbz cntin, L(nomatch) + ld1 {vdata.16b}, [src] + dup vrepchr.16b, chrin + cmeq vhas_chr.16b, vdata.16b, vrepchr.16b + neg shift, end, lsl 2 + shrn vend.8b, vhas_chr.8h, 4 /* 128->64 */ + fmov synd, dend + lsl synd, synd, shift + cbz synd, L(start_loop) + + clz synd, synd + sub result, endm1, synd, lsr 2 + cmp cntin, synd, lsr 2 + csel result, result, xzr, hi + ret + + nop +L(start_loop): + subs cntrem, src, srcin + b.ls L(nomatch) + + /* Make sure that it won't overread by a 16-byte chunk */ + sub cntrem, cntrem, 1 + tbz cntrem, 4, L(loop32_2) + add src, src, 16 + + .p2align 5 +L(loop32): + ldr qdata, [src, -32]! + cmeq vhas_chr.16b, vdata.16b, vrepchr.16b + umaxp vend.16b, vhas_chr.16b, vhas_chr.16b /* 128->64 */ + fmov synd, dend + cbnz synd, L(end) + +L(loop32_2): + ldr qdata, [src, -16] + subs cntrem, cntrem, 32 + cmeq vhas_chr.16b, vdata.16b, vrepchr.16b + b.lo L(end_2) + umaxp vend.16b, vhas_chr.16b, vhas_chr.16b /* 128->64 */ + fmov synd, dend + cbz synd, L(loop32) +L(end_2): + sub src, src, 16 +L(end): + shrn vend.8b, vhas_chr.8h, 4 /* 128->64 */ + fmov synd, dend + + add tmp, src, 15 +#ifdef __AARCH64EB__ + rbit synd, synd +#endif + clz synd, synd + sub tmp, tmp, synd, lsr 2 + cmp tmp, srcin + csel result, tmp, xzr, hs + ret + +L(nomatch): + mov result, 0 + ret + +END (memrchr) +#endif --=20 2.35.3