From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by sourceware.org (Postfix) with ESMTPS id B7BEB387101B for ; Thu, 2 Feb 2023 18:12:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7BEB387101B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-169b190e1fdso3571432fac.4 for ; Thu, 02 Feb 2023 10:12:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rhAaYi6DtXp7uLXidJGinRFumCd11mLY/aet6ITY9Xc=; b=s8MFuVjvFWTdD/tDzthcXFLWSxo1D3qrREu/VggT4fXJunXGDiqJg4J59rjPLxGqLL CUHVC3C2KeRBeqilwBZGN8+hw5qG32b01oHZi5fKiVUcNBoA5VrRYibXzM4Bw7wu3mxG mK6HDphSwT4TQCI6Vsk09P0kEFlJY+Ao0ekMoMRqdGzvZJaq5YpFiwvSyYF/yZoYE4QI Cvb+v0AjL85+Fkiz4qLF8KB1J4WsMrwTE4REDhTshEq1pZrtyHt5pT07hw5MTzcZIB/A O7MSDhUfpDNz58mkKWyZ7V5YnIb0VuwkaAvX1XneUqPlSvbUL8lxeDLuFCa9BCKY50WW eFwg== 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=rhAaYi6DtXp7uLXidJGinRFumCd11mLY/aet6ITY9Xc=; b=Og1Rgq9yy6ttDLTNQYJgrK3h+/56aIPoKm0dzfaiXBGjcCkjWHetQs5qna4wTzSKT9 5mL1k5nVzDCbtrX6VAB+LhNBENzf9zBV8fnKpXloHupsQjnYZwTkeF/ncIFDnHW4xv/4 dxY91NQ6x6Mon7IqkzpyLEFu5+Q9GAUknDjwaaR/OlFpOLri2Z5Ax2t4oI/e65bMhO55 yeDdqaoAYHonpyiGdXVPR1dj6tID4dqccoIBvOV6Yb7gHZbdzPD0LnDP2J7Lm/DpCDy7 l/+BTzCBgZ1VWcL3I84w/wllYLV/ZKNR/x2bQ4N3guwH1Y54/Em3MzaM7XxXNxTx0nN3 Bi8A== X-Gm-Message-State: AO0yUKWnxwoc0bYfiaqX/rNkV9VL2pxw6kiQbBG0iFT2gvav1LoUssP1 RA/qt9am8P3G906XfBsx3GDvLIS4fZ68/nbr+0M= X-Google-Smtp-Source: AK7set+qJOfNOAJFpPeEdKxX0IsZwQq+QvLzUqBB2TBBUvJCLhIxrxAL2cuHrrgrgpsJ3ZydB8GElA== X-Received: by 2002:a05:6870:5893:b0:163:bbe4:f7a0 with SMTP id be19-20020a056870589300b00163bbe4f7a0mr3210796oab.55.1675361564295; Thu, 02 Feb 2023 10:12:44 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:43 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 20/31] sh: Add string-fzb.h Date: Thu, 2 Feb 2023 15:11:38 -0300 Message-Id: <20230202181149.2181553-21-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 List-Id: Use the SH cmp/str on has_{zero,eq,zero_eq}. Checked on sh4-linux-gnu. --- sysdeps/sh/string-fzb.h | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 sysdeps/sh/string-fzb.h diff --git a/sysdeps/sh/string-fzb.h b/sysdeps/sh/string-fzb.h new file mode 100644 index 0000000000..c8dd176362 --- /dev/null +++ b/sysdeps/sh/string-fzb.h @@ -0,0 +1,55 @@ +/* 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\t" + "movt %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 */ -- 2.34.1