From patchwork Fri Sep 2 20:39:38 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: 602185 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1790851mae; Fri, 2 Sep 2022 13:42:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR4EvqnxnKi1dE0N3hOKP3l3e/Wue2AZgTiq3h/kGoMGj49H2FsQQzXnRNgWflM3DdoHxNNr X-Received: by 2002:aa7:d348:0:b0:447:d2b4:78fd with SMTP id m8-20020aa7d348000000b00447d2b478fdmr31652514edr.201.1662151377810; Fri, 02 Sep 2022 13:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151377; cv=none; d=google.com; s=arc-20160816; b=xD+NzEJC3oEQ+8ZUdjNxtYqDJat1VUw0S3KQ/2EvPImIn/VOZFfzahgt4TbGuNR83A IXpcZcQE+EKqTY3tUllBx2HN/4chQPJoG7r8A2Codj4oG/7mz5sOVeA+c1mqRC6FCUYY flKjFsmAT+edGD623zUp9cf3JuaeA/C3a2flkkywT050LkuCAa9gbu/y5oiSYMWu9HFP WoG5+kWznNiHIZS40bMchdu1WIEzFrUnLqczZY28C8MABR1ojNL8OgqA7OzuTXUJlmaQ 1R1hmD8vZDKR560ZLcPx09vYRg/s9V4MEcP1iS1gh5QTkrBj2GHNbecMlsrgBJGGG5/7 1xOw== 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=KgvXKoucXwBuiemKC4yQoGl0+Tm4aVqGI+sY/wGI1mjEDwiqIkGfYsmhYQzUF2D6Ge JFfbQUwZdlslhbRtkOsB0XwsY8Jqs6Kviz7CxsCvwyrqk9IOmNTLk0XlKYDHrAjrRkhD VjpqzafE5ah+w/gAoXyz7s49l1bSUqamsLlyvVf4BRBcZyd4ARYAjFuPBMMjP0WSbCXf /JwfZxjjgkI20zk0pS0OUm5XPDmqn0mO1o/pg4PNVhcrNuyBVW5ogPasEzsT9P9J8tD6 kgxIyq4y09x8egWYIBad5HNQWO3oMFimJxIsIGc0xIZE70GsqlA4SLBB9iXW9W3FcrZr GqEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qF7BMOMc; 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 eb8-20020a0564020d0800b0043e1c8af8c8si3046252edb.241.2022.09.02.13.42.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:42:57 -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=qF7BMOMc; 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 88677382DA71 for ; Fri, 2 Sep 2022 20:42:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88677382DA71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151376; 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=qF7BMOMcN+cvj0hrr+lAaJLZApn2knkwehv/VSjIAS1u2l6jqxRpbl8RIzC0/Rejs AbTifjn8dU8wSrw6wv2t1h7y5HfjW5Wz+fABWRX4hG0+NHJIJeK70m9tgfPMned/zA /k3K4xPYctGfs0R147jTcjobyYrjllyXAvwEbUWI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by sourceware.org (Postfix) with ESMTPS id 2E0DC3858016 for ; Fri, 2 Sep 2022 20:40:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E0DC3858016 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-11f4e634072so7509082fac.13 for ; Fri, 02 Sep 2022 13:40:11 -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=xhEHMY7m8tNgeJaeK2/Kn1ZBP6Z6Zq3XzV+QWAwGmdscLf1cyNu82dpHzepsaJAbRz DVIkqw30X4Qz9ykbOj6ykbbdJOxQEgzzkmJvqa/Nc6w9CQOXt7SHFcXN0BoPAy07RwfW zKBzQ5m8ifOUYVHqJFF0fHSCINp0dYt921j/oDFjozojka8Ag0nY/OwgrvLZKfX9fD2Q xtl1EvMJU8SPQ302ymyZ3sKhXtY/QWw5H+VqcSRHmv8EhYicHnuEGL8cNgae7H/fkmbD jKQP/Rnee8yWfygvN4iBfS/6Z3z3F9UZzzgpCKBOwRKiOl/o757f4LLosvvfqOUwCpal pCXg== X-Gm-Message-State: ACgBeo0XFTyuUdBPof+L3ygohz8bvWoLbbcuyY/9g5vOnbpjX6DgTLro 1IofhGAzTquWSF81WTzc1+oFreKbiK7CRg== X-Received: by 2002:a05:6870:79e:b0:101:48bf:7fa8 with SMTP id en30-20020a056870079e00b0010148bf7fa8mr3073469oab.291.1662151210377; Fri, 02 Sep 2022 13:40:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:10 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 15/17] arm: Add string-fza.h Date: Fri, 2 Sep 2022 17:39:38 -0300 Message-Id: <20220902203940.2385967-16-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 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 */