From patchwork Fri Jan 13 18:27:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 642042 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp358433pvb; Fri, 13 Jan 2023 10:29:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXu36Q9sSovuEM4ZWov1TZI+ITnZiRyswpKB3IHEhprT9bn0CAd+W32+hLYjOBeom9fJ/K5V X-Received: by 2002:a50:fe89:0:b0:49b:53dc:fe0 with SMTP id d9-20020a50fe89000000b0049b53dc0fe0mr7977813edt.40.1673634571826; Fri, 13 Jan 2023 10:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673634571; cv=none; d=google.com; s=arc-20160816; b=d+p0hMQ7IHlN0NRfILmo0RgXcHi/q+zUTgBsDUKOfXjFQ6UlgmWT1v8NxZCBQAvbq7 Eu0JXqaXI/SS1yK7OoSpAR9nMu0ds5GJRMVz7nVi5W/Bq29i6+eUIDPQssS9S5EWjdID 1ZHaA2sS7sZXbeX6RjuYA0Ysd4eNF1bmJlLTqzgRpJ7xuTo0sMHssLgns+7gV+OLfTtp YCSMN3R/ZHDu8N+bDbEU6gxcc5Et3T+x2SjNYJLf/qzKAUaL7bVJitLnk7HoR+ohXEV3 MJu3qdqV9EWaFbMRxvNEVpF7DG4nbTi8kYbCAz54U4g81PHG93X7TC3sEewjJpX1KTmU GBmA== 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:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=GyLtL9HgZ7A139N6K1a5xCBABR+k0+1g1HSS56x7RLs=; b=FgTkCmc8e2sZ5TIRQ1J1oNG0XN8GrDG9kA8orbz4unYW1n9y1prRQYpW0Tl4P4SAE4 VebK/R9NrXtdJnUVzUkTdTREPOdrGlVIXNURJMVt+tTtRP4Fe8SLdxX/2u9U3xC4RCej 7r7EsyJ+qGkRTUjtLuFfzMx50/+QcJ82gUYcUM55vkKUmVyREXqWnG0rYNhKMPIOBiJX bxSzF09BybD3k0JEOYYXkzFfwERRxlE4Wvq4fpZLALWOZ0pHdYVofEepbDKo5mhu0PXb Fjfq1t7LPZ/J2gvf9nmTeXvxaX1IYvPXcWvOhe4nk0gxCe9FBf/QK4tGjFtYF0HshjtI tCpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=not1MNEi; 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 cm25-20020a0564020c9900b00490ff375640si8721312edb.518.2023.01.13.10.29.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 10:29:31 -0800 (PST) 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=not1MNEi; 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 5E85F3889E25 for ; Fri, 13 Jan 2023 18:29:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E85F3889E25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673634570; bh=GyLtL9HgZ7A139N6K1a5xCBABR+k0+1g1HSS56x7RLs=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=not1MNEi4SY5pYBYtYyNN4cvMIEpoxrABI5cr/niZQh12WRO6Z/EQMGbensbHV535 cBGwU1gxVEUfrI6QHssrMNwWFjsUFVVg39IbPdfCTGlUhm3FyIVeJj2g678a9AHRNi H+KKtCeFDzGM2xuztEZvjZ+kqOiw9sqT592sYoCc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id DA7C93881D1A for ; Fri, 13 Jan 2023 18:28:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA7C93881D1A Received: by mail-pj1-x102c.google.com with SMTP id q64so23220026pjq.4 for ; Fri, 13 Jan 2023 10:28:02 -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:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GyLtL9HgZ7A139N6K1a5xCBABR+k0+1g1HSS56x7RLs=; b=xVlZ3k0/TIx+i/WLqwF9zBDbtiuTqde+08CRTtRtYLptf6k17v5+WYwHc74QPYPDfb 4rN/Mi2mkWpUQYCLGo970MkCNdSH4zekZ0lm6UwoDk1uoQ+gf3QbAu3JjGdz/STvJSSW KVKhQ3eTO8gzsweSvkEKoMExeHaEFmzvGQvxnhQcKt1bMWPJMpyOvOY13tiV06sOIBy5 PRnDUKOxOTEDWljO+Wrq3demwlysedSNkMzwuU922X5R/u/4H0xkIAMbqVd2vYoxvw3R 2i/Dr/d/5FbzNrOsCcJ9j7CH1QA2FKvQusnyT32skfSAbtVvyMqHPlBdzr4Jr+HeN49H 5XWA== X-Gm-Message-State: AFqh2kqjBld6SLKIe8AFzqmXV80QRaOh6+Pz9DssV5eGUUX19ORuJlHA m90xNMfJ6OZz2xNwqpEl3HKiW9LKvosEiZNH X-Received: by 2002:a17:902:f54b:b0:194:7813:2be5 with SMTP id h11-20020a170902f54b00b0019478132be5mr1655182plf.48.1673634481890; Fri, 13 Jan 2023 10:28:01 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id s17-20020a170902c65100b001927ebc40e2sm14443640pls.193.2023.01.13.10.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 10:28:01 -0800 (PST) To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org, goldstein.w.n@gmail.com Subject: [PATCH v8 17/17] sh: Add string-fzb.h Date: Fri, 13 Jan 2023 08:27:33 -1000 Message-Id: <20230113182733.1268668-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113182733.1268668-1-richard.henderson@linaro.org> References: <20230113182733.1268668-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 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: Richard Henderson via Libc-alpha From: Richard Henderson Reply-To: Richard Henderson Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Adhemerval Zanella Netto Use the SH cmp/str on has_{zero,eq,zero_eq}. Checked on sh4-linux-gnu. Message-Id: <20230111204558.2402155-18-adhemerval.zanella@linaro.org> --- sysdeps/powerpc/{ => power6}/string-fza.h | 0 sysdeps/sh/string-fzb.h | 59 +++++++++++++++++++++++ 2 files changed, 59 insertions(+) rename sysdeps/powerpc/{ => power6}/string-fza.h (100%) create mode 100644 sysdeps/sh/string-fzb.h diff --git a/sysdeps/powerpc/string-fza.h b/sysdeps/powerpc/power6/string-fza.h similarity index 100% rename from sysdeps/powerpc/string-fza.h rename to sysdeps/powerpc/power6/string-fza.h diff --git a/sysdeps/sh/string-fzb.h b/sysdeps/sh/string-fzb.h new file mode 100644 index 0000000000..5a7868333b --- /dev/null +++ b/sysdeps/sh/string-fzb.h @@ -0,0 +1,59 @@ +/* Zero byte detection; boolean. SH4 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 STRING_FZB_H +#define STRING_FZB_H 1 + +#include +#include + +/* Determine if any bytes within X1 and X2 are equal. */ + +static __always_inline _Bool +has_eq (op_t x1, op_t x2) +{ + int ret; + + /* + * TODO: A compiler builtin for cmp/str would be much better. + * It is difficult to use asm goto here, because the range of + * bt/bf are quite small. + */ + asm("cmp/str %1,%2\n\tmovt %0" + : "=r" (ret) : "r" (x1), "r" (x2) : "t"); + + return ret; +} + +/* Determine if any byte within X is zero. */ + +static __always_inline _Bool +has_zero (op_t x) +{ + return has_eq (x, 0); +} + +/* Likewise, but for zeros in X1 and equal bytes between X1 and X2. */ + +static __always_inline _Bool +has_zero_eq (op_t x1, op_t x2) +{ + return has_zero (x1) | has_eq (x1, x2); +} + +#endif /* STRING_FZB_H */