From patchwork Thu Oct 26 19:06:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 117256 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1124682qgn; Thu, 26 Oct 2017 12:08:21 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TRZdD6neiZuTCvGEPTyU/L/SsSJ4qwcJvI019QWQZfQnH3hCyJr0w3Dzm27qEjNHy+vGrv X-Received: by 10.98.204.69 with SMTP id a66mr6436668pfg.132.1509044901428; Thu, 26 Oct 2017 12:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509044901; cv=none; d=google.com; s=arc-20160816; b=w+2oInsGkpZXmV/Y97lK27O9BpzIWsmQHqO5G9AgOsfhNn0KOkNAP/+7Cfl+/SzEIM vHJnSXGynyIaNUV+bp80ARWQciy9p8DW+cH0bTJtcVTSd4bG+ybRoMs9+VnRzO9TZF1z 0p+36qxQz8AGTcQmknVUdR20PRqzDy7KLAKeQRr6++tNpCs0gdLvEIPz4S5TBeGxU/Pv mMj491uZsWfP2optM9EFD8IvWsDOrNgIt6uiaxAxkkAGqfYLBYWFPr4KDD5Gn3ufach+ uQmMyduftkm9UxCJA4T+FMmqBPSJHmlsPIaZYIwCCFsHC30f07NSMSdLavq2Ievb3C/8 19RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=MHxiNM74NZsTi+5YAQN28UzOAgNGabiy+347aY3A9aY=; b=nBez574v7XiwOtLxCIHwkkfynICilpNU0FAC4e7GDjDrmKlnCKefqQ9bDEzYqaGD+R a/oWS3EQEU5Shb7xsJg9HEepVv5OwS+CARUCqn/Epq0o6W9Gv9fS2HNa4Jkm68SLVvZZ M0tls+W0DCOKM3ublE4+9a3qJaDh0sDdK589Lmyf6MZmvcA34IYSHogyD+CABzIzMtmk LVodLWlieQPnhHXoHbzJYNc+wkKWI4vu97403/toT86jvQ3ljFM9C/68kR7a6lQRBER+ XY0A5+G/bfUBQ6+fy2C24ZtYKwTORMMVXXDmP8tXXGmJmOT8jxCbCVr2bLiassnDWFJw YNbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=q45KHi95; spf=pass (google.com: domain of libc-alpha-return-86406-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86406-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m10si3761924pgs.21.2017.10.26.12.08.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2017 12:08:21 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86406-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=q45KHi95; spf=pass (google.com: domain of libc-alpha-return-86406-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86406-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=FAA4g2w7y6Q1ayt7FyalPe3ohqgXdbj 6LVAaDz9BJVvJtGcHv74ZpygHSIZZ85h1R35XiCFQ8Lftlg8DnSg+9tsRff12fO/ 88R1xe8DMrelJ0+qPqi8Gca5/MIL0ztV5rrJ28d7B3sZngeMRCzWzoOvTRID7fRK mPJccwYfz59M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=3nMw/VQTHKo1qwk+VU6eJjWW6Ts=; b=q45KH i95q8uONw5QO+PTEtrQGPvczfSioBxvZ136557Ys0dC2dL9iKplEzPVdiOLJeVM6 sNode+rsmHbJWird1T2s+kQxydkVZRGmzXg2IBEyWy6njL18xmobjokpS5YPDQ5h R1FBUr+gGScgiihobaCjxUj+Q5xGZh41zM0jMs= Received: (qmail 97549 invoked by alias); 26 Oct 2017 19:07:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 97470 invoked by uid 89); 26 Oct 2017 19:07:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f196.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=MHxiNM74NZsTi+5YAQN28UzOAgNGabiy+347aY3A9aY=; b=ongSzU36hUJcGhOLaPFto4+Cn+INrD4tZcF0xjW4HDJNNOYwTPtxkKO+21V14rdQSl Ott35L0OiiU0DLwaiXdXk3NXnSfCYufiTEFoyoIVza+vKi+6E6Yxn9wt5mdqHTq9H919 ajyRA/1f69TFUD6br3XxjtbaIeXi8yks4QPs8hVDa8UitUFiXwpYp1+JwCJzZSF2HVzk TcmVdvHCX9JiOsz8M6YpQdo1vkIwr49k2Iuaa37JXNuINsDMBR/2Xi0jQQ4YP00V2Ubi 7RwgkbfOyGRbquN+UlmzXRP9RFP2iow66hrpfXArdemW0YPgSUBYIZj79MYOh5ItgTbJ +04g== X-Gm-Message-State: AMCzsaViPy9m/74iXnp/dB1rSWYRZXyL6Xg9sCMJqd51uXpd/dgPJYlk rMZd6U4hlpp3+Q/fWCnYGgFp9oXKbaw= X-Received: by 10.200.26.237 with SMTP id h42mr39663476qtk.22.1509044825914; Thu, 26 Oct 2017 12:07:05 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 04/25] sparc: Implement memset/bzero ifunc selection in C Date: Thu, 26 Oct 2017 17:06:32 -0200 Message-Id: <1509044813-9951-5-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509044813-9951-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509044813-9951-1-git-send-email-adhemerval.zanella@linaro.org> This patch refactor the SPARC64 ifunc selector to a C implementation. No functional change is expected, including ifunc resolution rules. Checked on sparc64-linux-gnu, sparcv9-linux-gnu and x86_64-linux-gnu. * sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile [$(subdir) = string] (sysdep_routines): Add memset-ultra1. * sysdeps/sparc/sparc64/multiarch/Makefile [$(subdir) = string] (sysdep_routines): Add memset-ultra1. * sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S: New file. * sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c: Likewise. * sysdeps/sparc/sparc64/multiarch/ifunc-memset.h: Likewise. * sysdeps/sparc/sparc64/multiarch/memset-ultra1.S: Likewise. * sysdeps/sparc/sparc64/multiarch/memset.c: Likewise. * sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S: Remove file. * sysdeps/sparc/sparc64/multiarch/memset.S: Likewise. Signed-off-by: Adhemerval Zanella --- ChangeLog | 13 +++ sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile | 2 +- .../sparc32/sparcv9/multiarch/memset-ultra1.S | 30 +++++ sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S | 4 - sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c | 1 + sysdeps/sparc/sparc64/multiarch/Makefile | 2 +- sysdeps/sparc/sparc64/multiarch/ifunc-memset.h | 34 ++++++ sysdeps/sparc/sparc64/multiarch/memset-ultra1.S | 31 ++++++ sysdeps/sparc/sparc64/multiarch/memset.S | 124 --------------------- sysdeps/sparc/sparc64/multiarch/memset.c | 42 +++++++ 10 files changed, 153 insertions(+), 130 deletions(-) create mode 100644 sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S delete mode 100644 sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S create mode 100644 sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c create mode 100644 sysdeps/sparc/sparc64/multiarch/ifunc-memset.h create mode 100644 sysdeps/sparc/sparc64/multiarch/memset-ultra1.S delete mode 100644 sysdeps/sparc/sparc64/multiarch/memset.S create mode 100644 sysdeps/sparc/sparc64/multiarch/memset.c -- 2.7.4 diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile b/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile index ca44798..e12636b 100644 --- a/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile +++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile @@ -9,5 +9,5 @@ endif ifeq ($(subdir),string) sysdep_routines += memcpy-ultra3 memcpy-niagara1 memcpy-niagara2 \ memset-niagara1 memcpy-niagara4 memset-niagara4 \ - memcpy-ultra1 + memcpy-ultra1 memset-ultra1 endif diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S new file mode 100644 index 0000000..0cb71a9 --- /dev/null +++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S @@ -0,0 +1,30 @@ +/* Default SPARC64 memset implementation. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# include + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +# undef weak_alias +# define weak_alias(x, y) + +# define memset __memset_ultra1 +# define __bzero __bzero_ultra1 +#include +#endif diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S deleted file mode 100644 index 8f82643..0000000 --- a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.S +++ /dev/null @@ -1,4 +0,0 @@ -#define ASI_PNF 0x82 -#define ASI_BLK_P 0xf0 -#define XCC icc -#include diff --git a/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c new file mode 100644 index 0000000..a6c5734 --- /dev/null +++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/sparc/sparc64/multiarch/Makefile b/sysdeps/sparc/sparc64/multiarch/Makefile index 4e52526..6e90cba 100644 --- a/sysdeps/sparc/sparc64/multiarch/Makefile +++ b/sysdeps/sparc/sparc64/multiarch/Makefile @@ -9,7 +9,7 @@ endif ifeq ($(subdir),string) sysdep_routines += memcpy-ultra3 memcpy-niagara1 memcpy-niagara2 \ memset-niagara1 memcpy-niagara4 memset-niagara4 \ - memcpy-ultra1 + memcpy-ultra1 memset-ultra1 endif ifeq ($(subdir),stdlib) diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-memset.h b/sysdeps/sparc/sparc64/multiarch/ifunc-memset.h new file mode 100644 index 0000000..f3b9293 --- /dev/null +++ b/sysdeps/sparc/sparc64/multiarch/ifunc-memset.h @@ -0,0 +1,34 @@ +/* Common definition for memset/bzero implementation. + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern __typeof (REDIRECT_NAME) OPTIMIZE (niagara4) attribute_hidden; +extern __typeof (REDIRECT_NAME) OPTIMIZE (niagara1) attribute_hidden; +extern __typeof (REDIRECT_NAME) OPTIMIZE (ultra1) attribute_hidden; + +static inline void * +IFUNC_SELECTOR (int hwcap) +{ + if (hwcap & HWCAP_SPARC_CRYPTO) + return OPTIMIZE (niagara4); + if (hwcap & HWCAP_SPARC_BLKINIT) + return OPTIMIZE (niagara1); + return OPTIMIZE (ultra1); +} diff --git a/sysdeps/sparc/sparc64/multiarch/memset-ultra1.S b/sysdeps/sparc/sparc64/multiarch/memset-ultra1.S new file mode 100644 index 0000000..e85da41 --- /dev/null +++ b/sysdeps/sparc/sparc64/multiarch/memset-ultra1.S @@ -0,0 +1,31 @@ +/* Default SPARC64 memset implementation. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# include + +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) +# undef weak_alias +# define weak_alias(x, y) + +# define memset __memset_ultra1 +# define __bzero __bzero_ultra1 + +#include +#endif diff --git a/sysdeps/sparc/sparc64/multiarch/memset.S b/sysdeps/sparc/sparc64/multiarch/memset.S deleted file mode 100644 index 9469d5e..0000000 --- a/sysdeps/sparc/sparc64/multiarch/memset.S +++ /dev/null @@ -1,124 +0,0 @@ -/* Multiple versions of memset and bzero - All versions must be listed in ifunc-impl-list.c. - Copyright (C) 2010-2017 Free Software Foundation, Inc. - Contributed by David S. Miller (davem@davemloft.net) - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -#if IS_IN (libc) - .text -ENTRY(memset) - .type memset, @gnu_indirect_function -# ifdef SHARED - SETUP_PIC_REG_LEAF(o3, o5) -# endif - set HWCAP_SPARC_CRYPTO, %o1 - andcc %o0, %o1, %g0 - be 1f - andcc %o0, HWCAP_SPARC_BLKINIT, %g0 -# ifdef SHARED - sethi %gdop_hix22(__memset_niagara4), %o1 - xor %o1, %gdop_lox10(__memset_niagara4), %o1 -# else - set __memset_niagara4, %o1 -# endif - ba 10f - nop -1: be 9f - nop -# ifdef SHARED - sethi %gdop_hix22(__memset_niagara1), %o1 - xor %o1, %gdop_lox10(__memset_niagara1), %o1 -# else - set __memset_niagara1, %o1 -# endif - ba 10f - nop -9: -# ifdef SHARED - sethi %gdop_hix22(__memset_ultra1), %o1 - xor %o1, %gdop_lox10(__memset_ultra1), %o1 -# else - set __memset_ultra1, %o1 -# endif -10: -# ifdef SHARED - add %o3, %o1, %o1 -# endif - retl - mov %o1, %o0 -END(memset) - -ENTRY(__bzero) - .type bzero, @gnu_indirect_function -# ifdef SHARED - SETUP_PIC_REG_LEAF(o3, o5) -# endif - set HWCAP_SPARC_CRYPTO, %o1 - andcc %o0, %o1, %g0 - be 1f - andcc %o0, HWCAP_SPARC_BLKINIT, %g0 -# ifdef SHARED - sethi %gdop_hix22(__bzero_niagara4), %o1 - xor %o1, %gdop_lox10(__bzero_niagara4), %o1 -# else - set __bzero_niagara4, %o1 -# endif - ba 10f - nop -1: be 9f - nop -# ifdef SHARED - sethi %gdop_hix22(__bzero_niagara1), %o1 - xor %o1, %gdop_lox10(__bzero_niagara1), %o1 -# else - set __bzero_niagara1, %o1 -# endif - ba 10f - nop -9: -# ifdef SHARED - sethi %gdop_hix22(__bzero_ultra1), %o1 - xor %o1, %gdop_lox10(__bzero_ultra1), %o1 -# else - set __bzero_ultra1, %o1 -# endif -10: -# ifdef SHARED - add %o3, %o1, %o1 -# endif - retl - mov %o1, %o0 -END(__bzero) - -weak_alias (__bzero, bzero) - -# undef weak_alias -# define weak_alias(a, b) - -libc_hidden_builtin_def (memset) - -#undef libc_hidden_builtin_def -#define libc_hidden_builtin_def(name) - -#define memset __memset_ultra1 -#define __bzero __bzero_ultra1 - -#endif - -#include "../memset.S" diff --git a/sysdeps/sparc/sparc64/multiarch/memset.c b/sysdeps/sparc/sparc64/multiarch/memset.c new file mode 100644 index 0000000..c07d8e2 --- /dev/null +++ b/sysdeps/sparc/sparc64/multiarch/memset.c @@ -0,0 +1,42 @@ +/* Multiple versions of memset. + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#if IS_IN (libc) +# define memset __redirect_memset +# define bzero __redirect_bzero +# include +# undef memset +# undef bzero + +# include + +# define SYMBOL_NAME memset +# include "ifunc-memset.h" + +sparc_libc_ifunc_redirected (__redirect_memset, memset, IFUNC_SELECTOR) +sparc_ifunc_redirected_hidden_def (__redirect_memset, memset) + +# undef SYMBOL_NAME +# define SYMBOL_NAME bzero +# include "ifunc-memset.h" + +sparc_libc_ifunc_redirected (__redirect_bzero, __bzero, IFUNC_SELECTOR) +weak_alias (__bzero, bzero) + +#endif