From patchwork Mon Sep 19 19:59:18 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: 607325 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1667503lth; Mon, 19 Sep 2022 13:01:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PZtlaLkwm/CbO3NXxGL3ZEaLMC4RiJjv//5ClvMpz6nIWvRCwJzNYFHEtqFlNYk50R2zu X-Received: by 2002:a05:6402:520c:b0:451:4213:49db with SMTP id s12-20020a056402520c00b00451421349dbmr17176746edd.130.1663617689908; Mon, 19 Sep 2022 13:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617689; cv=none; d=google.com; s=arc-20160816; b=CAno3p7wdDwb4+UJ8T06qtHVg1taYpeb4pBSggPLaWQEFL1FtA1LpzXl4imt5Dym1L B4aXvaDTBLQ7wZ1Ckopsem1CR6YdjNECqI+Al4WMnBC3cfXq01EjiHska1ovfOtc5m56 xd0C/rOObU5EVdCXS/yOSJXy/gBM6nVjbZ5Wdi27CSd5BczuEPryK3uCZCLTGBSc8//X PX5PrQM7i+rl42Es9fojI2cV3pSezKOT+PAkPrcYVZkzkbn8M8WePFzY89rGnRNVlOU9 w5+YO+1YHejOqyxce4DfYhByLWqHL/wDMt6HUO3LjA++J6haP4zzshax0A7UczktLgit o+/g== 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=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; b=lbRusI7coexcfXpyon6+JiJfvuc+nzdj7PtcsfyOPbXsnpWEA/4zW5kxM706AYFvFp sFe3fA7kS50+CTnZhJcjM95DN3Tp1UZgOFtl9HWnOv00IrwPeH9GJNhOoj7KZv8d3HKW +aERWO2L2t2Xxn2vFhqcqeFdKYm4PfPdasctX0MltoSDhxfNZJtyqhyvaF0GzRGZ/H3Q gWTnqzWk4bh249IZD2Esw0uU3r8vzuK2vfUO+2mapH3EQk8hxWwno4sPEzHb5XR635yV Q+Pqa3RdGGuLrW7Sv0AtexUzMLJW29FF2ZQwfd2lbxuU+pTt6U9eYHCaw5uO7cZ0C01I ++Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AfKnAQg+; 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 j10-20020a05640211ca00b0045306aa1e63si12422584edw.614.2022.09.19.13.01.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 13:01:29 -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=AfKnAQg+; 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 C7812383FBA3 for ; Mon, 19 Sep 2022 20:01:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7812383FBA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617688; bh=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; 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=AfKnAQg+AvavoRb85Rvg9Iyz0nSuhyE48l5z9GOSe8H1u2SGjNXOrcrJHIAfFCYlK SpwWfaaS6zAdrZMyQABNSA+uMASkOMsWYB/xB4QYAtHxVQKJvkseO6w3CICvbnqtEs 3Gi9vOt6t5POneCb0VbA+U8DCRtkNccG7cGfkSDY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id 07288385842B for ; Mon, 19 Sep 2022 19:59:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 07288385842B Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-12b542cb1d3so936561fac.13 for ; Mon, 19 Sep 2022 12:59:49 -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=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; b=PAeYF20PNZnVgQ+lVCq6w4A4LH4OtjZEpn+yK107ftAgyXJe9ghI8P3NetSk2zM3Nl ZpOXwuqpqhbx6m8sGYr44k8R3eTYrPEX+I8lMEJmvkY+E1NsScZf8O7Sg4+23CFSj4dq QYkSFYdLCNhnlojrp4aNPmXW/b+ocdKYGHwsCSMa8xjLOnHQnU2iZWvDRNIrtO/8++lZ ZM9qA6FrUJhTtXWLx78gfXougtipMv1YiIgbi3DK+q2NMPaim3G7EIaD+XoJkhAhyWHd fCcn781wpGWUzVAUP9sHY6zKjwHKaHO7FhonYE4qI8upA4nbLhP3xzHCugYX3G4lgnLO G6WA== X-Gm-Message-State: ACgBeo0IPJpWmTVTvDLesKS4637u2jxla353ONnVit7x/iiTypk6eolO ZJ1rKIqszC4yMIBdSAb7mPVZanQOudvg/d0i X-Received: by 2002:a05:6870:64a2:b0:12b:7db:b8e1 with SMTP id cz34-20020a05687064a200b0012b07dbb8e1mr16088997oab.212.1663617589194; Mon, 19 Sep 2022 12:59:49 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:48 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 15/17] arm: Add string-fza.h Date: Mon, 19 Sep 2022 16:59:18 -0300 Message-Id: <20220919195920.956393-16-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 Netto Reply-To: Adhemerval Zanella Cc: Richard Henderson Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While arm has the more important string functions in assembly, there are still a few generic routines used. Use the UQSUB8 insn for testing of zeros. Checked on armv7-linux-gnueabihf --- sysdeps/arm/armv6t2/string-fza.h | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sysdeps/arm/armv6t2/string-fza.h diff --git a/sysdeps/arm/armv6t2/string-fza.h b/sysdeps/arm/armv6t2/string-fza.h new file mode 100644 index 0000000000..4fe2e8383f --- /dev/null +++ b/sysdeps/arm/armv6t2/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. ARM 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 _STRING_FZA_H +#define _STRING_FZA_H 1 + +#include +#include + +/* This function returns at least one bit set within every byte + of X that is zero. */ + +static inline op_t +find_zero_all (op_t x) +{ + /* Use unsigned saturated subtraction from 1 in each byte. + That leaves 1 for every byte that was zero. */ + op_t ret, ones = repeat_bytes (0x01); + asm ("uqsub8 %0,%1,%2" : "=r"(ret) : "r"(ones), "r"(x)); + return ret; +} + +/* Identify bytes that are equal between X1 and X2. */ + +static inline op_t +find_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1 ^ x2); +} + +/* 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_zero_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) +{ + /* Make use of the fact that we'll already have ONES in a register. */ + op_t ones = repeat_bytes (0x01); + return find_zero_all (x1) | (find_zero_all (x1 ^ x2) ^ ones); +} + +/* 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 + +#endif /* _STRING_FZA_H */