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: 63174 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0D9D338A9095 for ; Fri, 13 Jan 2023 18:29:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D9D338A9095 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673634583; 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=t5Hhddmt4hNMVG7/1MGEvDUgR5/6niWHOTQJUgReQ1pM9gsT7Gn38iqWL0aCFdlam 0zkbDSgeJKYbmyW0FK6+H2GH+A2EeyfwphC1iMd717F9fRXevCnfEc1GZPD9+GcnuZ wyyShA/gDI9vHMDP+OqgVQyrB6e2r09RlbiRACTU= 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-Google-Smtp-Source: AMrXdXsdAeMkRCjA9DRc8TqBVpNWLP9LfqdnLU8Ipp9lOv7KUmJmwvlQq7BnTSTCeg5CRsccsvO8mg== 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+patchwork=sourceware.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 */