From patchwork Thu Feb 2 18:11:37 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: 649663 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp394896pva; Thu, 2 Feb 2023 10:14:01 -0800 (PST) X-Google-Smtp-Source: AK7set95Pt1PoJJYzKJJP/ual0J3tTFBK0/JPznp/TcYOQ/Prv7Ndro0TIVnlhPiFbOLTrw4QjBv X-Received: by 2002:aa7:c70c:0:b0:4a2:6c9a:ad19 with SMTP id i12-20020aa7c70c000000b004a26c9aad19mr7068008edq.17.1675361641205; Thu, 02 Feb 2023 10:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361641; cv=none; d=google.com; s=arc-20160816; b=Fm11QTnBSF7FH4aPxysStQzCcLxXGN0479aU2FW1deDDsgRSqDks3FnwoK48w4qPol afR1FInMw+vsaSYUplQ2S4diIAfPu4I3pq4hHNB3rz4bDuhum7s5yojZ1KdGVfgmz+nT NlqaaklF+oI3TxYq5+JM6iL5HQL2PcTZInCnpwZs2NgOIuGoOauQg5+7Us8mS+GApApR 6g1Cjp/wBDVFRjhyxVi85tG1x31S+TRC8HZSI8VfLmLFHXLiAcKRdgYLjzR+vPVs9ofp rUP/eBiUTURG72yrdoglsPSQJloNzShnG++IZey+9Mah6uNvp8ijLagqSIcFTuVP3iYF /GdQ== 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=iBGDBU1LOIu4kx/c1fhVkLNNrKP6X4acltTDNOqXoVA=; b=aEHC705LDA6ekAiu2B5hjZXfQmuAD/UDXOeJkQV2pOMfK61nWHJCZxU+5scN9sBzDs KeMvH/7amOvlt1eYOIJSj/vF7uYRFDoZyB8Sh0YrYYDLLKa9JFRHKJY4FTJIgI97UkQj Y05EiMd7a42CZApN4R7MuaxxZbTpl65o4ilqKf5qLmyqviA10HCFmlxEVjLvi1COMMG0 FbmGtMpeYb8WNi6sjHIS+gBTLo4zhLr5Io8Um3ByyYVuvnh94Z20NW9g5mbERfa33el9 2Y9tmUbkTgmULqBblSSswUlKb64pNMRwZzlHAm8QrKic7G4XQCPkF+53wDVUcliZF39S 7Oug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=i3B1qOaq; 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 cs12-20020a0564020c4c00b004a0e30998b8si101514edb.55.2023.02.02.10.14.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:14:01 -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=i3B1qOaq; 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 D7F5D388214C for ; Thu, 2 Feb 2023 18:13:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7F5D388214C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675361639; bh=iBGDBU1LOIu4kx/c1fhVkLNNrKP6X4acltTDNOqXoVA=; 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=i3B1qOaqpiAUZRePf8/5p+ePHPrp5OGkGK2YTg9za56JLEtwkG+hHM0Nrqbt6z4Ly JUcZeGei2YFOJZe2DT3T1tQCwlewVpiwn8TOqgUk6DORfPA+IBbOY1mDhXk/W+XhKw IxbBkbZZrX89+5grrqOkjTVyzBpbC6+wjuWrwcoM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id D812238582BE for ; Thu, 2 Feb 2023 18:12:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D812238582BE Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-163bd802238so3591089fac.1 for ; Thu, 02 Feb 2023 10:12:42 -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=iBGDBU1LOIu4kx/c1fhVkLNNrKP6X4acltTDNOqXoVA=; b=FfRyLpeTbnXCaDOxLFOqOoYIVk+zv2oEr2c+l2E6vn7t/pdihXgn4AfjtKWohtK1Jk Vz1lGkMBWUX3tqFEQSohCVXeRPpEVXWs72+Q4y4m0oNwwpMvdxZwx43vt2TGrFnixoR1 NMSF4BiOzZquEeh6TJg4jeztTh2ivliL5nmTNWgN2hEYrCv3AJ3M7AZAAVVY+f3IhOvP pgOe+b5YPwxiM/4SSv28FabjZP8p5D4W5wACtOB/fJTa46TXHDo+pZpEOE+Ubo5oK2qS WASxg9LPt1+ZVQyXSyQvtQStsoAs0AMqSOmkn24DK6W2vo0X9NNR6JNSEPGeS962uKks D/yg== X-Gm-Message-State: AO0yUKWbRcjEjRkAE2QF9nY5GQ19wWW1w07bfdFCIIp10GHjkgIKRGkl AniFm4lNofXe3H4sJFYcwEOybboXsFwDc67LyIg= X-Received: by 2002:a05:6871:b10:b0:162:9d70:2f59 with SMTP id fq16-20020a0568710b1000b001629d702f59mr4209307oab.52.1675361561767; Thu, 02 Feb 2023 10:12:41 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:41 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 19/31] powerpc: Add string-fza.h Date: Thu, 2 Feb 2023 15:11:37 -0300 Message-Id: <20230202181149.2181553-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-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. Reviewed-by: Adhemerval Zanella --- 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..5dec740041 --- /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 */