From patchwork Fri Sep 2 20:39:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 602187 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1791694mae; Fri, 2 Sep 2022 13:44:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR6XNVtpm4bdcplwg8ZVGH96CmZkQZYrvUX9Il9nlOBCpKB7MMgATffG3/kIZC8b/PeXFzDt X-Received: by 2002:a50:8e11:0:b0:447:cf39:10a1 with SMTP id 17-20020a508e11000000b00447cf3910a1mr32393921edw.382.1662151478297; Fri, 02 Sep 2022 13:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151478; cv=none; d=google.com; s=arc-20160816; b=GC/IX0piL78NoMQtFiPoqhTB0zBH8dxan+44/0a1974d8O+bLJDBYYSsuuMtu7VgWa 93RKT0+hHvbI353/DWRbydidujKTNwt77VPCzHG3zPv/oe0pKLMaH6tXDpcCGM70K5r9 qF+9UepD+VxTzuhYnnFc3U7CkD3rZxNspVjz7t+bgHIctxKedOouCSFjfxabGRTVe5cw w1rBGSa6NOOqIUhoGdF15oCiu6aF2OGYUh3w1oL6GYXn3FlktEydtEi8wCX+JF6m9Fga jAgof5HTyyhxUNo4hC6sJqby3r4ynrIM01Z07MZpCo5G1IPSQrDFeNzUNcRepNN47OBw SGxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=/uCRcF9qUCajChP7TLbUSNFzBkE0RzW5ftlKjiF8tuM=; b=Ovp9UBmgUwClUrORv3e1YHHUuc1MRQ7Ddr0SaXcWsX+T/g5Z8w3lfnPnQGGIC5Cswm 5AUcN8Iqsax6czrlhlcUuxBM1Tfu2m0ITwcs0ZWPtYR42/m9lKpzB2tbTgQct2Xc+3Wn MPgSV9av/xwQwkeNgOaeM/JSISZ8I9v1+KLekenAf3//wvnnIiMq0hUvklpDVDq2kZ+L Wx4n2XaduuETWLOoLZDtNBt2QddPkLxbxW03hbcq5U8YhHB9SOhk/D5KX5KQo6q9R3dd H6eC5cCCwKmv+t+kZREaW4NQygiy/c8gjU6GYR5i12tmsU7wpSCx0FPcFKqu4XPsHEgc 22hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=aO1XnfIV; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y4-20020a170906558400b00741a05cb703si2363123ejp.534.2022.09.02.13.44.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:44:38 -0700 (PDT) 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=aO1XnfIV; 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 1929C382DB0E for ; Fri, 2 Sep 2022 20:44:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1929C382DB0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151477; bh=/uCRcF9qUCajChP7TLbUSNFzBkE0RzW5ftlKjiF8tuM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=aO1XnfIVOLpf6A/OtWAv0bgqnpPDTOs+xmrMdGqc+ofLRf40cfuYm+Gr9aiFLchrY afUS0SIg+h8t5J+npwBHU7alL1sHqIF9o0TtSVunYeYiBiZldrLHQ/E1X5b6qOcxbG NspZX80QYVyeQq+ZfgkwPjelG9beyaPp2Bane8N0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id A5301385700C for ; Fri, 2 Sep 2022 20:40:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A5301385700C Received: by mail-ot1-x334.google.com with SMTP id 92-20020a9d0be5000000b0063946111607so2219221oth.10 for ; Fri, 02 Sep 2022 13:40:12 -0700 (PDT) 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:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/uCRcF9qUCajChP7TLbUSNFzBkE0RzW5ftlKjiF8tuM=; b=xP24fhmsb2dEvpIv+Yj867BtwDtDz5c4wLpKnTNAcPLLfXeyqoR1akXKt7sK6dI5x7 b4XHHqs+69aOrQBE+8TxIyEyQ4NV4nxC8OOn4HS+9aTWu3cumZUNvlzLKe45yg7D0A2c 6+BaKp9oaCpWsUvyH248HQFZYIprIBoeGL7Jsdk68e3Kf272hxcOnGIu6E4DHaYIehdz B4jOz1h4rR1jszEufP8tPyUpF0zkzq9lUEgSHfeB9PYIySQUcPUVRJ897Zkg2AV/N8SQ cSVWjPocf8xLQQ5hvhq1XI6sQ5dEiM4J1CXep8sRvQv/PgwnMvdk0fXlCkO9KDDdxryU ep5g== X-Gm-Message-State: ACgBeo37tAbFC7jSLPmDZze6G2StDJQf82x1izrWbmIMxFCadlap/Hiy z+KYBbLSfEgXi9IlEH1EWenY7WGzJUT3og== X-Received: by 2002:a9d:d83:0:b0:639:c1a4:4d78 with SMTP id 3-20020a9d0d83000000b00639c1a44d78mr13344104ots.100.1662151211923; Fri, 02 Sep 2022 13:40:11 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:11 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 16/17] powerpc: Add string-fza.h Date: Fri, 2 Sep 2022 17:39:39 -0300 Message-Id: <20220902203940.2385967-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-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, T_SCC_BODY_TEXT_LINE 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 Cc: Richard Henderson , Joseph Myers , caiyinyu 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..5f7e9c5cbe --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. PowerPC version. + Copyright (C) 2022 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.03 (POWER6) provides cmpb instruction. */ +#ifdef _ARCH_PWR6 +# include + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static 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 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 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 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 /* STRING_FZA_H */