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 BADAC38493CB for ; Wed, 11 Jan 2023 20:46:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BADAC38493CB 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-1442977d77dso16827444fac.6 for ; Wed, 11 Jan 2023 12:46:39 -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:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yGPovr38ZU02FWiH7KoXJ0+CqtlDx/oj85V6st1cjgM=; b=s0jxYmns9pstFHaDVnhcsdNSy72AC/UBZh2ZLIfRiDw3rSAZB6/8Na13YwkduTYHIL IynEQuWTjlGE756Usa7vWf2K0zq0qZfbUGho++XUimiscZT5hUEF8nYHtdpwUYNL4Rg0 lXHan2nVtW2bdL1D/36Q+HteZ1uJVVsu121xspiQDju+eNKpPG2oO4bEy68L9YsDe87N m/YWP/VEz7T1MfScQU/3Od2GTRvxkFNFW0BEeF39yS7h6iObo2nnpyfbGDoXpZZT2IlA MKd1EQCRoo4vVsEozs5ZAXu8oeDH5lmag87UIn5gMBo8gyu8XybTQ/ocRHovs62qKszr TCOA== 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=yGPovr38ZU02FWiH7KoXJ0+CqtlDx/oj85V6st1cjgM=; b=eqLZCZrvF+1zxWtSXlK8CMBcmaiMXgVDzA5KYxeEZx4IR6gExM7eYUIxc2RsF4MXXW mNhg+1uy8N7dOSgfqZqPnFdqJ9tUbcqKaBC8fbjMpqe0MH0whzh8YMjLl2Fkbpo30YnS s01qd8FQG8vUKAAcorcfWDyzDhG9EWAsdOTYsqIK28f1ZK6BJOqes/cUsrG6BnHNnyLX aXGL179bkZen7gw5wdTHOzzklNLj7rpQ7l2F8eOikjOxyW1WOm3rR86wgIXZyYvpjkZt MWKE6yH44DewzJKm/aSGiEQZgXTiDoqwI7AmpE6FGEQiZD/7908be6H/m6yrHeeseFya 01oQ== X-Gm-Message-State: AFqh2krBXkdLorHo1RNrWny16yTafX1DxEnPRyG+hpzQf9vDaKnAUAhG d/Z9c1rNCTnvx+Wllz+63N+LfkK+BYDr8ijViSo= X-Google-Smtp-Source: AMrXdXvMVOnjsEdxsvaq3uQ6Z+a/LD8OgCExO/FDPvhdx1Qk8AKNgoqceX0paocjWdT3g9UMgQakbA== X-Received: by 2002:a05:6870:6d0f:b0:15b:94ef:ffcd with SMTP id mw15-20020a0568706d0f00b0015b94efffcdmr5355920oab.6.1673469998885; Wed, 11 Jan 2023 12:46:38 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a93a:a504:f3f6:dd7b:801]) by smtp.gmail.com with ESMTPSA id kw18-20020a056870ac1200b0014c8b5d54b2sm7990274oab.20.2023.01.11.12.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 12:46:38 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Noah Goldstein , Richard Henderson Cc: Adhemerval Zanella Netto Subject: [PATCH v7 17/17] sh: Add string-fzb.h Date: Wed, 11 Jan 2023 17:45:58 -0300 Message-Id: <20230111204558.2402155-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111204558.2402155-1-adhemerval.zanella@linaro.org> References: <20230111204558.2402155-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.0 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: From: Adhemerval Zanella Netto Use the SH cmp/str on has_{zero,eq,zero_eq}. Checked on sh4-linux-gnu. --- sysdeps/sh/string-fzb.h | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 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..0ad19b58c9 --- /dev/null +++ b/sysdeps/sh/string-fzb.h @@ -0,0 +1,54 @@ +/* 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 byte within X is zero. This is a pure boolean test. */ + +static __always_inline _Bool +has_zero (op_t x) +{ + op_t zero = 0x0, ret; + asm volatile ("cmp/str %1,%2\n" + "movt %0\n" + : "=r" (ret) + : "r" (zero), "r" (x)); + return ret; +} + +/* Likewise, but for byte equality between X1 and X2. */ + +static __always_inline _Bool +has_eq (op_t x1, op_t x2) +{ + return has_zero (x1 ^ x2); +} + +/* 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