From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 2DF77385801E for ; Fri, 2 Sep 2022 20:40:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2DF77385801E 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-ot1-x330.google.com with SMTP id q39-20020a056830442700b0063889adc0ddso2243500otv.1 for ; Fri, 02 Sep 2022 13:40:14 -0700 (PDT) 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; bh=7ZlKu+POny+E0+WjJsG/gPP4U5kORuo1g6duZmxApMU=; b=BrMi5PR3aDlsAwZ7X3qZOFT9mR1ja4mcnUdABH6jnOQnMuyCse3kW6anvYYlrsKGBn pnAtZI5IXCOEefcZjlE9rrhVCFlwFg2AI+twshFVqnIct9DExEt/UIN2J2WbYvVfGtSc YN+0flMu+8TRNRQSg7xTnrR60pCRGXSl2QQn2nalhvT/kvq+4G2xl+Xgpg/1cVQj0Gk4 tX2YHDD3esqiSCmQZ8wSHyddeMUnLwN3esdgNCbrNeGmGUD3eSFF65Bcz6JGy24NqEIU RS4JCZms0LJixcBIUkxfytRCH8LJVRf/m447n9fXF67zPYf0VWy0sxsDQS1Dk6WBbaiK DzEw== 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=7ZlKu+POny+E0+WjJsG/gPP4U5kORuo1g6duZmxApMU=; b=g/OKxUzAqaIJaP2no7bTRYYOYAZPOAbb8DnCLWZR18UpQcrU3oKY8inAQ1gXbGQCXR OnbG1C5+0UHoyzIgoviMMRz1DJLUOKpYqzm6KxH1NB3AHvEwogUnonhPJoBYIa9gEYjp pBt/fKyZxpS1hnXEwBaKn9Tc58tUg8AScN0ezQUR12bKueiQtT/uB3O8tAWictUapfjJ sac6l38nmmaeMIngMQOK/+eCB39085MBDCzhEUjNS/eS+QzSWHE1aVqHC3A8eLngt94S 6SSqPvPb46W7QPzqtQakL/C3B3mBEtPCA9yoIxJbptajC0kVMLYWhNYTF/7nCioKgw6r oYlg== X-Gm-Message-State: ACgBeo1EnnkMngxFTTf2ugJFv9P36sPDnmSNDvVNIKg/6nlavkuhL7oe /RFYtNLVNooBnIBA1p5kcDhfdqhA4V0qHA== X-Google-Smtp-Source: AA6agR4/rvPMljEpMC6Luuj96i69fJZnqKrIylSl39GowzETozSvGacFcgrCi0ZgVnTL0voc5+IfVg== X-Received: by 2002:a05:6830:910:b0:637:18dd:7743 with SMTP id v16-20020a056830091000b0063718dd7743mr14623615ott.226.1662151213346; Fri, 02 Sep 2022 13:40:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:13 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joseph Myers , caiyinyu Subject: [PATCH 17/17] sh: Add string-fzb.h Date: Fri, 2 Sep 2022 17:39:40 -0300 Message-Id: <20220902203940.2385967-18-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 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,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 List-Id: Use the SH cmp/str on has_{zero,eq,zero_eq}. Checked on sh4-linux-gnu. --- sysdeps/sh/string-fzb.h | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 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..62823b4d0e --- /dev/null +++ b/sysdeps/sh/string-fzb.h @@ -0,0 +1,53 @@ +/* Zero byte detection; boolean. SH4 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_FZB_H +#define STRING_FZB_H 1 + +#include + +/* Determine if any byte within X is zero. This is a pure boolean test. */ + +static 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 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 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