From patchwork Tue Jan 17 20:00:07 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: 643411 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1366365pvb; Tue, 17 Jan 2023 12:04:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXsp9Uq06yosQeKgP/eMH0MXchUkkRQp1aVk0hayA9WA6T/UJHV07KlxRAP5gPeSNyhwWJBh X-Received: by 2002:a17:906:1450:b0:7ad:c5b7:1c79 with SMTP id q16-20020a170906145000b007adc5b71c79mr4288492ejc.45.1673985844347; Tue, 17 Jan 2023 12:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673985844; cv=none; d=google.com; s=arc-20160816; b=kzLHkcBbYuzGlwGdzXLJQqIwX1KFqrssNaOYNvED6JJSXrKvmEwUJGbqPGLV4wtUMP 29taEpsuk67GIP857JiM2q7u+QMu2/wQ9iJk12bmVzNviJJSZehqGOVj/n2t2aWmgkF+ xSXSpSash9bi5g5wuxli7ZmZoZQA/P0DBt4ftawwzkeMtRBu3wj3IQW86YDTwF0XoHGL caqQbTHyq2xNlcPqakF1NTmNwjCgYB18FWc3LIJzIpZ6H3x6i9asZOd/MCBdwbxjCqXU C4xwHWXM+skvwIYImuMyFbRyTxDruLHl0BbLTzRgozUb7VOHTOrv9glUloYAcXMYPkVL yzRg== 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=kkMVjcQtif0+aGBkPM2pYkem/SVecldr0MLVq9MfSD4=; b=Nn2BflWLdg9ran4RRd617n7VGxPlTzte9ecAd0upsL0YATOLxQbg/JV+StzCnKlr0m NFEmvzVIjzPZ0VSHtYc4dV/GuQxvAFlfQ/3/EhUdP5K7vKav62GXCGR6PHS7D/fMMi2z ZC0Q/2Tf60ZkpgOyn03ZA0nR1I2D9RI7/dmJoqW4Vlp4GUdlYk4fFoTAIPelLkIaQ2qu RugCDumv6qilCGvapIwyhsowbqnRM98DFGt66RVvLmsWfHpAPBASCcMQxgPR2uppIz94 lPNpsnB1KUBCyRQ/IeBbe+Mrej2x/XsPAZnvo8QEXhT/lS9+o1bRYMSe5zTggj9WLerg q08Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="gzVqr/no"; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qw42-20020a1709066a2a00b007ad943d0608si10911901ejc.630.2023.01.17.12.04.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:04:04 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="gzVqr/no"; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 041893854395 for ; Tue, 17 Jan 2023 20:04:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 041893854395 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985843; bh=kkMVjcQtif0+aGBkPM2pYkem/SVecldr0MLVq9MfSD4=; 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=gzVqr/not3Bke+FUq74KCzZ7p3r50/5D2DTI7wkNw8aO3uJDzfZUBcV95q5pMWLd8 tHxFnS7cmbcicqaEeLPd8gFc1E1Kvpy6fFpgxUEqyeSyk9XIi8kSPB5ARlg+58F975 8fG+MxSWiDciEeaZTXaZ6zJynYc0wLSEvLCp2VZU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id CBF8F3857C45 for ; Tue, 17 Jan 2023 20:00:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBF8F3857C45 Received: by mail-oi1-x232.google.com with SMTP id j130so26885457oif.4 for ; Tue, 17 Jan 2023 12:00: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=kkMVjcQtif0+aGBkPM2pYkem/SVecldr0MLVq9MfSD4=; b=GXX3coZXq2vx5gxmcnL2HL2qYbGaDbhD74Mpys/PQ/zm2vdYMgCPY6MnZ0zYIgWked WgQWj5FtdyxzHIKyJfv7TSYGljT2IG6s51cNHzuRGXdAzCaVFbXjcQbBIfQzGfWoJYT1 drzzK7L9um5128t98ETHAQs6ETKORD3TCRpRxcRlXsukwsatZPITxJ8ADYXyKRLydZF8 RpW5bD71qiMPL1PSBWu6VJpLTPQ1pgsCus1zDdbrkhsYZ+Oj/XWBNG4TSwodx7wgxhvH Y3nYUKlgM0vIu6OB7dOdxQh16TH21rqapznSLMFBlF+L0n/xm23E6/Z8eY+89UQmemzM DR0w== X-Gm-Message-State: AFqh2kppizcKskTVyNUF4nKbM0aDDkgRUsQF3eQXBaIZ4Op063uNsQfi /mUre0t4X7EL8ZD7HU7atUCgcRlwCR8jI8+W+eA= X-Received: by 2002:a05:6808:1810:b0:35e:1be8:2354 with SMTP id bh16-20020a056808181000b0035e1be82354mr2939035oib.48.1673985650014; Tue, 17 Jan 2023 12:00:50 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:49 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v9 15/22] powerpc: Add string-fza.h Date: Tue, 17 Jan 2023 17:00:07 -0300 Message-Id: <20230117200014.1299923-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-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 | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 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..ff0a1ac2c9 --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,72 @@ +/* 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 +# include + +/* The functions return a byte mask. */ +typedef op_t find_t; + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static __always_inline find_t +find_eq_all (op_t x1, op_t x2) +{ + return __builtin_cmpb (x1, x2); +} + +/* This function returns 0xff for each byte that is zero in X. */ + +static __always_inline find_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 find_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 find_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 */