From patchwork Thu Oct 5 13:51:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 114940 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp250870edb; Thu, 5 Oct 2017 06:51:55 -0700 (PDT) X-Received: by 10.98.42.77 with SMTP id q74mr23213003pfq.272.1507211515401; Thu, 05 Oct 2017 06:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507211515; cv=none; d=google.com; s=arc-20160816; b=xaSSO5mfTifRMhPcHn5tztFv+CoUGarbBqMrn6y48t+yNsx7crZQXKi5u1XE88uWCf smySylTQSylONAKRb/Zh1Gu6GiTPY5uj1lKLiuKgQcG39sNJnM4P2WFb4c5uovuR+wI/ vzQAoIqGTRljt3qVFvdeHATzLRLRDxXUZSnZbaH2heaqIvVCRXTsHU1lDFcfLKZu8csP r9DHtaiuf7O83xcaMBSBnQJlodYEhCburBdKVYdH0SknwR5P7pgSZNaSULmhjitb7KeU fIOkQ15Jj7ooOwhAcFzMqLJ5uPvWSzc1hmjaTnEflEVXVMmbre6aH4tcBa0M+47DXNV3 jj9g== 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=qy4Iz3IoxdrautJYUJ/RJSQTXSs/NtsR9iasYpI9c8g=; b=MF4JdNGR9wCCHERaZ9VtT/PqWcpIGVnJNJlyRXLElqfeNcV261FbCJooK5zHJsDSGC rvtRF/XScjnNwKG1M+ax7o7/HjgtfzpdZC/JU0PzNzKrr4oYKOFxl0XCypUBlvYJdlYi sOrATvwrCOgT39weVcgT1AyPghRsX9NbtBm/Kgi7dXIwaUh5o9T69/GLD8MPwf3E+4xy oQJrPqm2DoUEFJK2kXDm25BFPCsTvJhECjp6BqNKbqNYTedv0VLQoxVBeLI8Vt3mtCaq OgFlT/4vF+ilw8+tzcDN3skJuwPthnBy+HH+Mo+s1qlij1Q8sgMGdJouo0gEojOGJopy OFXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NNHI5g5a; spf=pass (google.com: domain of libc-alpha-return-85440-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85440-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 y7si12984154plt.42.2017.10.05.06.51.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 06:51:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-85440-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=NNHI5g5a; spf=pass (google.com: domain of libc-alpha-return-85440-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-85440-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=TvQ6gjutqAuhNGtCZaNSAbL9CMmjOAX htOgNkrjH6lzI0B+pJ76CDqv78JL84QQRnkypNZgxiTBU6BSX2tyuSCJxXa5kboG P6fFfNsaebUataGmrD6WiWHprIFrzy/++OXttREkwhXA/2+cF+xncM9yk9s+gEEO lE0FifSo6MZo= 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=O4FEsANt+DO9+PPIGsW0JU0XGKM=; b=NNHI5 g5a3+1EREStbpIHiHwuIOWGT1DCLxEX9COLXDjn+0fGIu3a/vyRXohxVIAq1G/4e sxZ2uUUqeT7y5ohq8By7Rf5P5Nhazs/FBVzzYGnihosfb/bR6Z3b2MtIE09Z1pya YuOOYZJjROMLHX79+z8Mxm7uSu8mJ9faZRqYXk= Received: (qmail 130257 invoked by alias); 5 Oct 2017 13:51:27 -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 129861 invoked by uid 89); 5 Oct 2017 13:51:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=95 X-HELO: mail-qk0-f170.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=qy4Iz3IoxdrautJYUJ/RJSQTXSs/NtsR9iasYpI9c8g=; b=uAf7lkRQ8okhiRHzVvHBoZUuCUdbDRaqZF05c9tGM3RkcLSZ9rbsQ8fZQEbAl1kqit cLuoXJQ+rMXcpVirR7S3geA50SQJmEU3KzpLTGLwkC0zLeNYgRryGtDrXhjmGh3dLXzK E2YH08rpTlw5D1p8pvgYorAJHuKpiIOzAgpel5IU7CHsINAkjShebt+W3ah+1ymrFn4D 0qN2LAKo2Vj09ZENxp4VOh+UaTcAI2SxrNpddAZqY2apt0FbL+jDl2eKY85rQLfcXjsH +lYx3ZH2ZNoBn6HLUWZIyCw0kTIwyzt50TNh/LxThlWg3vsLzSxdCef2hNY6vFgIVUx8 /BRQ== X-Gm-Message-State: AMCzsaWNqSrC90to0nu14oyDFoz1it9rqa4hYHhtLLVGmWVjT19gcDjM dPCVRpofnRgx9j7ZXO0lVg2F0KnqX9I= X-Google-Smtp-Source: AOwi7QCWImNlC9anmbYfPb6qO61nFDdf2dKZ3tkfvgnHdaJtXPGE9YbRVxK61IccRWUHvMtHqHkn1A== X-Received: by 10.233.232.8 with SMTP id a8mr20942397qkg.263.1507211481640; Thu, 05 Oct 2017 06:51:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/4] sparc: Implement memset/bzero ifunc selection in C Date: Thu, 5 Oct 2017 10:51:10 -0300 Message-Id: <1507211472-1194-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1507211472-1194-1-git-send-email-adhemerval.zanella@linaro.org> References: <1507211472-1194-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. --- ChangeLog | 13 +++ sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile | 2 +- .../sparc32/sparcv9/multiarch/memset-ultra1.S | 33 ++++++ 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 | 33 ++++++ sysdeps/sparc/sparc64/multiarch/memset.S | 124 --------------------- sysdeps/sparc/sparc64/multiarch/memset.c | 49 ++++++++ 10 files changed, 165 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..4a5508d --- /dev/null +++ b/sysdeps/sparc/sparc32/sparcv9/multiarch/memset-ultra1.S @@ -0,0 +1,33 @@ +/* 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 + +#endif + +#include 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..eaf0fb8 --- /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..728c179 --- /dev/null +++ b/sysdeps/sparc/sparc64/multiarch/memset-ultra1.S @@ -0,0 +1,33 @@ +/* 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 + +#endif + +#include 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..7f1d499 --- /dev/null +++ b/sysdeps/sparc/sparc64/multiarch/memset.c @@ -0,0 +1,49 @@ +/* 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); + +/* It essentially does libc_hidden_builtin_def (memset) and redirect + the internal symbol to ifunc implementation. */ +# ifdef SHARED +__hidden_ver1 (memset, __GI_memset, __redirect_memset) + __attribute__ ((visibility ("hidden"))); +# endif +# 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