From patchwork Mon Sep 19 19:59:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 607324 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1667340lth; Mon, 19 Sep 2022 13:01:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5iiEaBT+3CUsJNtxqmzKcdu1lpDnbAJ7dW/A6oB95d1Jxa5ijDzmu4xzpemmYIj+mBVJCS X-Received: by 2002:a17:907:d8b:b0:779:3642:acbc with SMTP id go11-20020a1709070d8b00b007793642acbcmr14081413ejc.429.1663617674316; Mon, 19 Sep 2022 13:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617674; cv=none; d=google.com; s=arc-20160816; b=H3TqwiFhbyNJt/iqUtc5LYCVUc7XrYpAm0fvBI0pQq+tixFNe6ZqzltFTBgn8c0CZZ wUOwS+kzXJXcn1M+DUOO4AyIp7WmzfhvEWllN0Q3hlnMI2sqoudw8gwNYZzbdISXpBtX DYJ6+YKOtUa7LfOUzEy+5FYz3QHTutU7/xvyhlPTdIpYdtWZ9EMwDPheE2eMtQZge9AX bKbq57EnhAYPFIeL7NOULqKxs6xAyh8CQaYVHcl5vNH6LauJOqPhTGe3mYMOFGKSVyTJ 2qJ+xFWXcegahTW9eA6rrrrbbYQkS1dsdMXYAKePBVyJZewSsTt3OCuVzu0ZaGAYT/9H Em0g== 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=5Q75peyS5l0VDpGdS8vy98EFqHj2so5KzVl/+o8GJjk=; b=AOAPeF25Gou5XmZVToPehuP5918oak9n9LqEGgGRgjdD6l1x6n6f2LBZ56i+zOz5FC yQGh7BkrwAJ028HHZhoxfRWv1XALrUPkzwIZMcPMv7q4G9Nf3ffqhxGa/kvJL1qNbjvU 2NgXCnnDi2SrAUdwkIQfmhHKrdo9Xhc0v8YUZcuwUKdgev/EbqXjlgS5nKnC5WQD48Fx MPNvxxzGrhmeUVd96u/WiiCRtjKz2NPcli+r9PvLjWeIdWKxrsx76sfratPbdVlhgsD1 tP9qBnJCsHKjyatcQudzA8O1ZhcU/LOrydD3txHiw1aDxOkmiZwxcSOwwLHQVtec2Cwx CvJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=SqPxqJMy; 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 cw9-20020a170906c78900b0073d9b010076si17784280ejb.822.2022.09.19.13.01.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 13:01:14 -0700 (PDT) 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=SqPxqJMy; 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 147EB3850200 for ; Mon, 19 Sep 2022 20:01:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 147EB3850200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617673; bh=5Q75peyS5l0VDpGdS8vy98EFqHj2so5KzVl/+o8GJjk=; 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=SqPxqJMyMWPXoNeSIH2IxZ7dfFVJlBDXpZoQv6HKekId3CuwCGaiawN3RmNTrKuVt C0Hkgx/CwzZJA7M64G2bwjZuACIheepMekgBYbdKZB76pWR0VPrGGFBeYgGiOoz5J8 llgw5MyYZvPZm3QkzM0GHOEXUuTGBbzUmi1R7KAE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by sourceware.org (Postfix) with ESMTPS id 02FAF3858415 for ; Mon, 19 Sep 2022 19:59:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 02FAF3858415 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-11e9a7135easo999489fac.6 for ; Mon, 19 Sep 2022 12:59:50 -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=5Q75peyS5l0VDpGdS8vy98EFqHj2so5KzVl/+o8GJjk=; b=Hf1sGhWMDE+U6ryQDvvHE+gA7yKuY2Bxvryp3SEURjV5MO5DcDPIdEEGpQlR5aFYOi Bh8ut0xiiXm1lxDMngmwXES9LR6A0SZXqUvYWm5MeS228Etri3WLWBWflZYiUtEDafVz 93zGld1trjr4/wBzKgvU0BOSuKMBAGNCBFG2sxH/hzSCnbko4ooQCW3I2IbbOzY3GPj4 SuQMwTkO1hnMHsCFcP0Vfmg6MZwZlgt0Vn5o9pKN0SI1+ZXXvvH3qJGNdfDRltyWq5KA Shsy3A7KjnlYZVUplwtPa/LYEdTJuBfDZMOjsHX+ywEJbkn9VyQkeMF11Vb4AvwBnOmK SKQw== X-Gm-Message-State: ACrzQf36kqt7xLlYSZcqOlYKU+omChHhyqlea0MN9eWv5xEdG8En2Tvj GQPqKn4PBoTJq85I33HEfav9QI/jLYq0b2kh X-Received: by 2002:a05:6870:701f:b0:127:8afc:e62c with SMTP id u31-20020a056870701f00b001278afce62cmr10475935oae.234.1663617590420; Mon, 19 Sep 2022 12:59:50 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:50 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 16/17] powerpc: Add string-fza.h Date: Mon, 19 Sep 2022 16:59:19 -0300 Message-Id: <20220919195920.956393-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-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 Reply-To: Adhemerval Zanella Cc: Richard Henderson 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..21fc697a9c --- /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.05 (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 /* _POWERPC_STRING_FZA_H */