From patchwork Wed Feb 1 17:03:55 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: 649181 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp408994pva; Wed, 1 Feb 2023 09:10:58 -0800 (PST) X-Google-Smtp-Source: AK7set/I6m+yZHdRbiA+zxqLrLhTVSsy0oA7szBlt94NsIOSivmZw4GxkoZ4BD4tsFzI4bE39e/W X-Received: by 2002:a17:907:8dcd:b0:878:45e9:6f96 with SMTP id tg13-20020a1709078dcd00b0087845e96f96mr3445417ejc.49.1675271457920; Wed, 01 Feb 2023 09:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675271457; cv=none; d=google.com; s=arc-20160816; b=eYaii5DajKCfOh2nO2jy6EVBHcNkH6K/HSfr8FEPIviOzZlu2N+YhI1oNFOl2nYQ8x sZzoCsSFDcBkq/s5PDE0vL0F3+cItAFMIlrVKKUwDvTmmuGYdHBcl2xsdc+vjs1ac4TE lazuqy+H/jm8jfKW9SWRbfCpVxa9Nj8dP68VvToKM3SUHi3USIfrVtPU6OC+aA57ySVQ j8MF4OiTeqW0ql5hRLJGiL4fKn4mS4nKZ2mKymYsO8U4d9QOdfx/VLov9rxEWwt1iS5c O+byjnpmmAhfPDsvcqWYXHoHLfA930T0k1noAOBYz7Ycd6SHQLb4asHh81YDO3Le2C1n VDfQ== 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=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; b=zceRZlr2TPJuszX7uyjnQDsxvL/hXibYh+EUMrZs45iejFMel91AElDsE6Yh9/uQAF f96oNZ0r/d/Cw7KyHCOOgrgZmZDN78VoD+eBA/r6Adci/hIXxpR4L3j1/Dfxf4mFkNii LDLltokO7wEZRi/NRErzWJyG2iRs8TChCOE1le+dYlV7phGWrWM0CELb3TEWpKnFqLkh SkI7aAPY8PWFvF5dj73+pP7UuGc5GusdgX9yFi1D5NDa3Bgw5sC6LoGHVr78SwkrKmJM eaReWPxAiaBf9AIIjoLbkefbsgPdkdvIoRbico2k7Vujbyp6canVyHOMBkAomzPL4p3B Mo6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=oYb+qUJo; 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 15-20020a170906208f00b0081a9c3ca498si24601694ejq.314.2023.02.01.09.10.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:10:57 -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=oYb+qUJo; 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 A7EB63893661 for ; Wed, 1 Feb 2023 17:10:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7EB63893661 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271456; bh=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; 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=oYb+qUJoTWnxnvaun5ZmAMy7w4zRtawEUtkwE9gqUl4t3olVjD9XpKTV+FJtU1ixG 6Qo+OKP0HfPXWw7qkLgZf/rWat9cMUHnRUz+mx47UU2xMPWLOptC1wh1m0M2a9Wnm2 KOraC5CbuSvOfT/8mS/oD3dyYSmJ7ib7UNGORJIw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 8543E3858C83 for ; Wed, 1 Feb 2023 17:04:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8543E3858C83 Received: by mail-oi1-x234.google.com with SMTP id p133so16253552oig.8 for ; Wed, 01 Feb 2023 09:04:59 -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=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; b=xMUGvrS6IL7byCwmyL8jySd12qgs8Vh83ob7y7QhPAUGdMuA4IEe6HcI+0JCFfish4 4rd9cQE+uK2fcHScUbTnxLZusp0q2HbAX0gYrjOEFnSL2DOJIqGDl6mHRTzqfxWHGrbh FCkuUeYbI4OEhUT7qO+rIl+d5ez/a+pI0RVj8QQGYjUaKtOMT2TbZ9H7UQI5XyBnWPTG wzFv9dPgT+56cnBGWCnMAjnTx8MKTh0a0O3ZFNmnUot/iJdDlOypgXPUVYU7h3ys/1fO 8aI89osPNwQFS+DZK+Qs2pzE4dhMlOTxg5wZpiHdGVYHA7jf2xBilL5bIIhqvGamZ5DV lBhA== X-Gm-Message-State: AO0yUKXkOF/mv+v5q46VbbiWO3cvLfTQaQ3xE0YKX/j46AT7MOVLQORa s7jTNQfxJvnruMCkGAtnwk8agNTk/zLENRERSro= X-Received: by 2002:a05:6808:481:b0:378:6ebe:a98b with SMTP id z1-20020a056808048100b003786ebea98bmr1350662oid.37.1675271098277; Wed, 01 Feb 2023 09:04:58 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:d2ed:98c2:d2cc:bf06]) by smtp.gmail.com with ESMTPSA id b17-20020a056830311100b006863ccbf067sm8077090ots.74.2023.02.01.09.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:04:57 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Subject: [PATCH v11 18/29] powerpc: Add string-fza.h Date: Wed, 1 Feb 2023 14:03:55 -0300 Message-Id: <20230201170406.303978-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201170406.303978-1-adhemerval.zanella@linaro.org> References: <20230201170406.303978-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..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 */