From patchwork Tue Jan 10 21:01:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 640907 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2917512pvb; Tue, 10 Jan 2023 13:04:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXsiTHlkL6DeEFigZLV6xOPJfRSbh9kqpFDrQ/2v4fIv9CsLrcoBR5ZdYGCww/rGC5VFmknr X-Received: by 2002:aa7:d393:0:b0:490:47c3:3d78 with SMTP id x19-20020aa7d393000000b0049047c33d78mr20600131edq.1.1673384658566; Tue, 10 Jan 2023 13:04:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673384658; cv=none; d=google.com; s=arc-20160816; b=GYgoFTqxTUhK7NWQjly4Mm7lyax2zQ4ka+vkWYmOwC8o5KBanDSnuOthuBjDwVSyoG rVyn9MpSxptHnkDrhmTgNQClNlYRtt09onyYWM82nkZPPoPReHJmY/0yUbixNt56n2TK mEmuo01u509kwcYm+0sdpgUJHd5eJtrHKtGyHdJsChQHgCPGUgNyYYyBrxxpsIVJk4Yv OBWAnbEPm7VogwHxh0epi8x/F0mb7KZKJe0ID8hJkQ3soCEspWg7K9qAbWa2rD5HLJkp 0vfzUi5cfN5VpCJHxz6TMKkKxst1tcWAlSA16kGZWLy5ANaJxyls+F16i1jdNJvUv97Z bFbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=NB6MyQN54L0ZfjYrf0IIqicl8+o3iDBFOSABu07doRU=; b=dI8+r8pK11NWfEnmzPcpUhijtsjYMmuVAmCBN2B/RojvpDKzQGbC6aanJiZPbEm2Si dtZEelCeGgU6bHm/3opGiiVbhL5XDdYwwVSTg0FWWMTbk7tRlUw7Oz/EkipWp/Ul37+0 NUm5dhGtWjDSJ4xS6KQdlW6OVLdeJMgIyRl+kBS3JMko4JHNy9cmdeTLUusgL0mcuXnn F/N2e0OSlxSfdWsV28+eC4HxIbiE8mPk6FTBOC76gEBF94U8ZKui48s2lx1icq9/n1To W+7Li7dV8mWDtNTMdqqZ8x7V5f+nNibVJehh6Vz1VBaJ+Suo+6v6iJjgdUyPZbC51PYA OWqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NcvN54KP; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Return-Path: Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ay23-20020a056402203700b00499c290b7e2si3153756edb.415.2023.01.10.13.04.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:04:18 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NcvN54KP; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 57851385703F for ; Tue, 10 Jan 2023 21:04:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57851385703F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673384657; bh=NB6MyQN54L0ZfjYrf0IIqicl8+o3iDBFOSABu07doRU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NcvN54KPpIDK49y5Hr0I2VFsBnIObOe73TV1FjiZOtkEQhwn1qvDU5FKHofqqeh6p 1yeBSN023/Qw0UfZbF0n1oL0cTI4DjkPcg6k2z/tR5qZ/0Gr7EQeUgrniGU7LdRUcP aPjv6siBj2AbG8xqpmAg9Zve4PClVMX8nFpAH4hU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by sourceware.org (Postfix) with ESMTPS id 5446C38493F8 for ; Tue, 10 Jan 2023 21:01:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5446C38493F8 Received: by mail-oo1-xc35.google.com with SMTP id x15-20020a4ab90f000000b004e64a0a967fso3549180ooo.2 for ; Tue, 10 Jan 2023 13:01:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NB6MyQN54L0ZfjYrf0IIqicl8+o3iDBFOSABu07doRU=; b=grXwKKjNNGx65ZDq3NMDcjXCSsSPDf85RwWD7T8scMMvhY67QzLgYKZh343DKEG3/M KI7WkebmnAD6lczp1qCEPQyAjo1xO401pnx+GtzSdwT3q4/DQHNr1ZGEFrNz68Mp3SVP GOyUVN/yxFC0lmifNybRmrUqD5TDsm0Z25aO39qmRLEC/tyCng0VXBf2Wk9z3X35zKjM YWpiTFQwB3TF8aZSJ3Gwn9jHJDWVKTkE76TVxkSBZ+AKE73zG/dccVGA3NbmGyzR7c77 6LJCDWolgOah7EG7zldazp79TIUDI9+fpXJ4+jxlHbpravZ79PJcE0EKzZiJGMf+ZFjQ fBzw== X-Gm-Message-State: AFqh2kqagAKPjeFM8buDMVZQCPqrW26Fer5GCTZOj9uD7Rr9psomWdKl N4XFIPn6WN+V49vGmZxeMJDiLxdLUOYGEcQCNGw= X-Received: by 2002:a05:6820:138a:b0:4a3:aa96:23c7 with SMTP id i10-20020a056820138a00b004a3aa9623c7mr35730049oow.6.1673384509325; Tue, 10 Jan 2023 13:01:49 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a93a:e8a0:dd55:3328:997]) by smtp.gmail.com with ESMTPSA id r5-20020a4a83c5000000b0049ee88e86f9sm6202193oog.10.2023.01.10.13.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:01:48 -0800 (PST) To: libc-alpha@sourceware.org, Noah Goldstein , Richard Henderson Subject: [PATCH v6 16/17] powerpc: Add string-fza.h Date: Tue, 10 Jan 2023 18:01:05 -0300 Message-Id: <20230110210106.1457686-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230110210106.1457686-1-adhemerval.zanella@linaro.org> References: <20230110210106.1457686-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While ppc has the more important string functions in assembly, there are still a few generic routines used. Use the Power 6 CMPB insn for testing of zeros. Checked on powerpc64le-linux-gnu. --- sysdeps/powerpc/string-fza.h | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sysdeps/powerpc/string-fza.h diff --git a/sysdeps/powerpc/string-fza.h b/sysdeps/powerpc/string-fza.h new file mode 100644 index 0000000000..5496c9db4b --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. PowerPC version. + Copyright (C) 2023 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 + . */ + +#ifndef _POWERPC_STRING_FZA_H +#define _POWERPC_STRING_FZA_H 1 + +/* PowerISA 2.05 (POWER6) provides cmpb instruction. */ +#ifdef _ARCH_PWR6 +# include + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static __always_inline op_t +find_eq_all (op_t x1, op_t x2) +{ + op_t ret; + asm ("cmpb %0,%1,%2" : "=r"(ret) : "r"(x1), "r"(x2)); + return ret; +} + +/* This function returns 0xff for each byte that is zero in X. */ + +static __always_inline op_t +find_zero_all (op_t x) +{ + return find_eq_all (x, 0); +} + +/* Identify zero bytes in X1 or equality between X1 and X2. */ + +static __always_inline op_t +find_zero_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | find_eq_all (x1, x2); +} + +/* Identify zero bytes in X1 or inequality between X1 and X2. */ + +static __always_inline op_t +find_zero_ne_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | ~find_eq_all (x1, x2); +} + +/* Define the "inexact" versions in terms of the exact versions. */ +# define find_zero_low find_zero_all +# define find_eq_low find_eq_all +# define find_zero_eq_low find_zero_eq_all +# define find_zero_ne_low find_zero_ne_all +#else +# include +#endif /* _ARCH_PWR6 */ + +#endif /* _POWERPC_STRING_FZA_H */