{"id":819294,"url":"http://patchwork.ozlabs.org/api/patches/819294/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/patch/1506542999-97895-3-git-send-email-patrick.mcgehearty@oracle.com/","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1506542999-97895-3-git-send-email-patrick.mcgehearty@oracle.com>","list_archive_url":null,"date":"2017-09-27T20:09:58","name":"[2/3] sparc: assembly version of memmove for ultra1+","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"66df7526a6f7fa70e78b58e40782eb6f66516f7a","submitter":{"id":72081,"url":"http://patchwork.ozlabs.org/api/people/72081/?format=json","name":"Patrick McGehearty","email":"patrick.mcgehearty@oracle.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/1506542999-97895-3-git-send-email-patrick.mcgehearty@oracle.com/mbox/","series":[{"id":5435,"url":"http://patchwork.ozlabs.org/api/series/5435/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/list/?series=5435","date":"2017-09-27T20:09:56","name":"sparc M7 optimized memcpy/memset","version":1,"mbox":"http://patchwork.ozlabs.org/series/5435/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/819294/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/819294/checks/","tags":{},"related":[],"headers":{"Return-Path":"<libc-alpha-return-85039-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-85039-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"xejFZ4cx\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y2TTX1FS4z9t67\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 28 Sep 2017 06:10:39 +1000 (AEST)","(qmail 123441 invoked by alias); 27 Sep 2017 20:10:14 -0000","(qmail 123294 invoked by uid 89); 27 Sep 2017 20:10:13 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:subject:date:message-id:in-reply-to\n\t:references; q=dns; s=default; b=lqpIbW9EuLFLRMEWLhu4J1ZWJ5Mt4Tm\n\tx+W6GoUZQ3BWpDjPb1aR7tpxGWyaS+97PsEzNrIEsqMjj9lrop/nwDzu8q6FxY24\n\tDbpNN4x5ozoQ1BN/JWYvMAWyflliOaDv/h2YDrEvi0TuLZRzQl/MVsxZ/OMdplYW\n\ta5Ns6ZeZ5Qm0=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:subject:date:message-id:in-reply-to\n\t:references; s=default; bh=Se8beSmv3Vzdi3519QNAaj6eBAc=; b=xejFZ\n\t4cxlA/nLUT6369dPTATOk6qLMaCU0qiGdlmIADZIYDHcaiSTY2F+SmmLcG8NfMHQ\n\t5H0QCKXH3XcMzlEnetKZg5XJmezv5j5A2Mfg18iLLGxdOX3ibCOP3TP8mIgJKff5\n\tEBFz8NtHEsyFlOmduWTTb2b+dIatZ7unT6GmhE=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-24.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_PASS, UNPARSEABLE_RELAY,\n\tUNSUBSCRIBE_BODY autolearn=ham version=3.3.2 spammy=","X-HELO":"aserp1040.oracle.com","From":"Patrick McGehearty <patrick.mcgehearty@oracle.com>","To":"libc-alpha@sourceware.org","Subject":"[PATCH 2/3] sparc: assembly version of memmove for ultra1+","Date":"Wed, 27 Sep 2017 16:09:58 -0400","Message-Id":"<1506542999-97895-3-git-send-email-patrick.mcgehearty@oracle.com>","In-Reply-To":"<1506542999-97895-2-git-send-email-patrick.mcgehearty@oracle.com>","References":"<1506542999-97895-1-git-send-email-patrick.mcgehearty@oracle.com>\n\t<1506542999-97895-2-git-send-email-patrick.mcgehearty@oracle.com>"},"content":"From: Jose E. Marchesi <jose.marchesi@oracle.com>\n\nTested in sparcv9-*-* and sparc64-*-* targets in both non-multi-arch and\nmulti-arch configurations.\n---\n ChangeLog                                    |    7 +\n sysdeps/sparc/sparc32/sparcv9/memmove.S      |    2 +\n sysdeps/sparc/sparc32/sparcv9/rtld-memmove.c |    1 +\n sysdeps/sparc/sparc64/memmove.S              |  186 ++++++++++++++++++++++++++\n sysdeps/sparc/sparc64/rtld-memmove.c         |    2 +\n 5 files changed, 198 insertions(+), 0 deletions(-)\n create mode 100644 sysdeps/sparc/sparc32/sparcv9/memmove.S\n create mode 100644 sysdeps/sparc/sparc32/sparcv9/rtld-memmove.c\n create mode 100644 sysdeps/sparc/sparc64/memmove.S\n create mode 100644 sysdeps/sparc/sparc64/rtld-memmove.c","diff":"diff --git a/ChangeLog b/ChangeLog\nindex 3f9db7a..ee70dde 100644\n--- a/ChangeLog\n+++ b/ChangeLog\n@@ -1,5 +1,12 @@\n 2017-09-26  Jose E. Marchesi  <jose.marchesi@oracle.com>\n \n+\t* sysdeps/sparc/sparc32/sparcv9/memmove.S: New file.\n+\t* sysdeps/sparc/sparc32/sparcv9/rtld-memmove.c: Likewise.\n+\t* sysdeps/sparc/sparc64/memmove.S: Likewise.\n+\t* sysdeps/sparc/sparc64/rtld-memmove.c: Likewise.\n+\n+2017-09-26  Jose E. Marchesi  <jose.marchesi@oracle.com>\n+\n \t* sysdeps/sparc/bits/hwcap.h (HWCAP_SPARC_ADP): Defined.\n \t* sysdeps/sparc/dl-procinfo.c: Added \"adp\" to the\n \t_dl_sparc_cap_flags array.\ndiff --git a/sysdeps/sparc/sparc32/sparcv9/memmove.S b/sysdeps/sparc/sparc32/sparcv9/memmove.S\nnew file mode 100644\nindex 0000000..39adeb2\n--- /dev/null\n+++ b/sysdeps/sparc/sparc32/sparcv9/memmove.S\n@@ -0,0 +1,2 @@\n+#define XCC icc\n+#include <sparc64/memmove.S>\ndiff --git a/sysdeps/sparc/sparc32/sparcv9/rtld-memmove.c b/sysdeps/sparc/sparc32/sparcv9/rtld-memmove.c\nnew file mode 100644\nindex 0000000..a2fe190\n--- /dev/null\n+++ b/sysdeps/sparc/sparc32/sparcv9/rtld-memmove.c\n@@ -0,0 +1 @@\n+#include <sparc64/rtld-memmove.c>\ndiff --git a/sysdeps/sparc/sparc64/memmove.S b/sysdeps/sparc/sparc64/memmove.S\nnew file mode 100644\nindex 0000000..eb71ef3\n--- /dev/null\n+++ b/sysdeps/sparc/sparc64/memmove.S\n@@ -0,0 +1,186 @@\n+/* Copy memory to memory until the specified number of bytes\n+   has been copied.  Overlap is handled correctly.\n+   For SPARC V9.\n+   Copyright (C) 2017 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <http://www.gnu.org/licenses/>.  */\n+\n+#include <sysdep.h>\n+\n+#ifndef XCC\n+# define XCC    xcc\n+\t.register\t%g2, #scratch\n+#endif\n+\n+ENTRY(memmove)\n+\tmov\t%o0, %g2\t/* Save pointer to destination  */\n+\tcmp\t%o1, %o0\t/* if from address is >= to use forward copy  */\n+\tbgeu,a\t%XCC, 2f\t/* else use backward if ...  */\n+\t cmp\t%o2, 17\t\t/* delay slot, for small counts copy bytes  */\n+\n+\tsub\t%o0, %o1, %o4\t/* get difference of two addresses  */\n+\tcmp\t%o2, %o4\t/* compare size and difference of addresses  */\n+\tbgu\t%XCC, .Lovbc\t/* if size is bigger, have to do overlapped copy  */\n+\t cmp\t%o2, 17\t\t/* delay slot, for small counts copy bytes  */\n+/*\n+ * normal, copy forwards\n+ */\n+2:\tble\t%XCC, .Ldbytecp\n+\t andcc\t%o1, 3, %o5\t/* is src word aligned  */\n+\tbz,pn\t%icc, .Laldst\n+\t cmp\t%o5, 2\t\t/* is src half-word aligned  */\n+\tbe,pn\t%icc, .Ls2alg\n+\t cmp\t%o5, 3\t\t/* src is byte aligned  */\n+\tldub\t[%o1], %o3\t/* move 1 or 3 bytes to align it  */\n+\tinc\t1, %o1\n+\tstb\t%o3, [%o0]\t/* move a byte to align src  */\n+\tinc\t1, %o0\n+\tbne,pn\t%icc, .Ls2alg\n+\t dec\t%o2\n+\tb\t.Lald\t\t/* now go align dest  */\n+\t andcc\t%o0, 3, %o5\n+\n+.Ls2alg:\n+\tlduh\t[%o1], %o3\t/* know src is 2 byte aligned  */\n+\tinc\t2, %o1\n+\tsrl\t%o3, 8, %o4\n+\tstb\t%o4, [%o0]\t/* have to do bytes,  */\n+\tstb\t%o3, [%o0 + 1]\t/* don't know dst alingment  */\n+\tinc\t2, %o0\n+\tdec\t2, %o2\n+\n+.Laldst:\n+\tandcc\t%o0, 3, %o5\t/* align the destination address  */\n+.Lald:\tbz,pn\t%icc, .Lw4cp\n+\t cmp\t%o5, 2\n+\tbz,pn\t%icc, .Lw2cp\n+\t cmp\t%o5, 3\n+.Lw3cp:\n+\tlduw\t[%o1], %o4\n+\tinc\t4, %o1\n+\tsrl\t%o4, 24, %o5\n+\tstb\t%o5, [%o0]\n+\tbne,pt\t%icc, .Lw1cp\n+\t inc\t%o0\n+\tdec\t1, %o2\n+\tandn\t%o2, 3, %o3\t/* i3 is aligned word count  */\n+\tdec\t4, %o3\t\t/* avoid reading beyond tail of src  */\n+\tsub\t%o1, %o0, %o1\t/* i1 gets the difference  */\n+\n+1:\tsll\t%o4, 8, %g1\t/* save residual bytes  */\n+\tlduw\t[%o1+%o0], %o4\n+\tdeccc\t4, %o3\n+\tsrl\t%o4, 24, %o5\t/* merge with residual  */\n+\tor\t%o5, %g1, %g1\n+\tst\t%g1, [%o0]\n+\tbnz,pt\t%XCC, 1b\n+\t inc\t4, %o0\n+\tsub\t%o1, 3, %o1\t/* used one byte of last word read  */\n+\tand\t%o2, 3, %o2\n+\tb\t7f\n+\t inc\t4, %o2\n+\n+.Lw1cp:\n+\tsrl\t%o4, 8, %o5\n+\tsth\t%o5, [%o0]\n+\tinc\t2, %o0\n+\tdec\t3, %o2\n+\tandn\t%o2, 3, %o3\n+\tdec\t4, %o3\t\t/* avoid reading beyond tail of src  */\n+\tsub\t%o1, %o0, %o1\t/* i1 gets the difference  */\n+\n+2:\tsll\t%o4, 24, %g1\t/* save residual bytes  */\n+\tlduw\t[%o1+%o0], %o4\n+\tdeccc\t4, %o3\n+\tsrl\t%o4, 8, %o5\t/* merge with residual  */\n+\tor\t%o5, %g1, %g1\n+\tst\t%g1, [%o0]\n+\tbnz,pt\t%XCC, 2b\n+\t inc\t4, %o0\n+\tsub\t%o1, 1, %o1\t/* used three bytes of last word read  */\n+\tand\t%o2, 3, %o2\n+\tb\t7f\n+\tinc\t4, %o2\n+\n+.Lw2cp:\n+\tlduw\t[%o1], %o4\n+\tinc\t4, %o1\n+\tsrl\t%o4, 16, %o5\n+\tsth\t%o5, [%o0]\n+\tinc\t2, %o0\n+\tdec\t2, %o2\n+\tandn\t%o2, 3, %o3\t/* i3 is aligned word count  */\n+\tdec\t4, %o3\t\t/* avoid reading beyond tail of src  */\n+\tsub\t%o1, %o0, %o1\t/* i1 gets the difference  */\n+\n+3:\tsll\t%o4, 16, %g1\t/* save residual bytes  */\n+\tlduw\t[%o1+%o0], %o4\n+\tdeccc\t4, %o3\n+\tsrl\t%o4, 16, %o5\t/* merge with residual  */\n+\tor\t%o5, %g1, %g1\n+\tst\t%g1, [%o0]\n+\tbnz,pt\t%XCC, 3b\n+\t inc\t4, %o0\n+\tsub\t%o1, 2, %o1\t/* used two bytes of last word read  */\n+\tand\t%o2, 3, %o2\n+\tb\t7f\n+\t inc\t4, %o2\n+\n+.Lw4cp:\n+\tandn\t%o2, 3, %o3\t/* i3 is aligned word count  */\n+\tsub\t%o1, %o0, %o1\t/* i1 gets the difference  */\n+\n+1:\tlduw\t[%o1+%o0], %o4\t/* read from address  */\n+\tdeccc\t4, %o3\t\t/* decrement count  */\n+\tst\t%o4, [%o0]\t/* write at destination address  */\n+\tbg,pt\t%XCC, 1b\n+\t inc\t4, %o0\t\t/* increment to address  */\n+\tb\t7f\n+\t and\t%o2, 3, %o2\t/* number of leftover bytes, if any  */\n+\n+/*\n+ * differenced byte copy, works with any alignment\n+ */\n+.Ldbytecp:\n+\tb\t7f\n+\t sub\t%o1, %o0, %o1\t/* i1 gets the difference  */\n+\n+4:\tstb\t%o4, [%o0]\t/* write to address  */\n+\tinc\t%o0\t\t/* inc to address  */\n+7:\tdeccc\t%o2\t\t/* decrement count  */\n+\tbge,a\t%XCC, 4b\t/* loop till done  */\n+\t ldub\t[%o1+%o0], %o4\t/* read from address  */\n+\tretl\n+\t mov\t%g2, %o0\t/* return pointer to destination  */\n+\n+/*\n+ * an overlapped copy that must be done \"backwards\"\n+ */\n+.Lovbc:\n+\tadd\t%o1, %o2, %o1\t/* get to end of source space  */\n+\tadd\t%o0, %o2, %o0\t/* get to end of destination space  */\n+\tsub\t%o1, %o0, %o1\t/* i1 gets the difference  */\n+\n+5:\tdec\t%o0\t\t/* decrement to address  */\n+\tldub\t[%o1+%o0], %o3\t/* read a byte  */\n+\tdeccc\t%o2\t\t/* decrement count  */\n+\tbg,pt\t%XCC, 5b \t/* loop until done  */\n+\t stb\t%o3, [%o0]\t/* write byte  */\n+\tretl\n+\t mov\t%g2, %o0\t/* return pointer to destination  */\n+END(memmove)\n+\n+libc_hidden_builtin_def (memmove)\ndiff --git a/sysdeps/sparc/sparc64/rtld-memmove.c b/sysdeps/sparc/sparc64/rtld-memmove.c\nnew file mode 100644\nindex 0000000..1e73c6b\n--- /dev/null\n+++ b/sysdeps/sparc/sparc64/rtld-memmove.c\n@@ -0,0 +1,2 @@\n+#include <string/wordcopy.c>\n+#include <string/memmove.c>\n","prefixes":["2/3"]}