From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 8AC673858298 for ; Mon, 19 Sep 2022 19:59:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8AC673858298 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-x329.google.com with SMTP id u6-20020a056830118600b006595e8f9f3fso321015otq.1 for ; Mon, 19 Sep 2022 12:59:52 -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:to:from:from:to:cc:subject:date; bh=7ZlKu+POny+E0+WjJsG/gPP4U5kORuo1g6duZmxApMU=; b=ZVDT60H9nl5VaRp2Znug2P6+DF8+IUTTQchs/i0M6QzRpbbT9CFhees6IbDdIMfpKn scVMKzRU6fugbfU1ApGTRF2Jj/HxQMks1O4ItBM2FRCX6JghBOf2vyyRiE00iD3Lvovm V1Sy7GgwjT4lfVeRcIKzg35GGtJ137k0ifYov7Skbj85RmYWHhrr1y2KLQwlQnk6zMqw DOeBRvZUs9vQQ8ef05IXkkLxqdhjGoy9VMJXG5RoR+QUU3RdtnY/8paS5Aolpm3HkZgA GrKeZfJf7lmt/4ZG6bV6tv3RSTTUIhZfhAA7G+Wq9/yLeBbYwF8Vuvzu/CiTj5jnZf2A rhLQ== 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; bh=7ZlKu+POny+E0+WjJsG/gPP4U5kORuo1g6duZmxApMU=; b=A/wEo4Rx/F95D+XQqb9PsoUBJ1G5ZgynZip6u4y1ftymuY7IMIM+BWMPXySOGblK4N VVKrBAFZwSjvh8RRtOHe2UAdl/IgXCXVmm/tD//W20gCmyVTlejZbFQZrDCfmL6rrS0q MmDMx6Scho1aNRLSnpMWBrnUoYQfa6o5V8x87sOqA86R1KexS89FYICd60Z/U/458Z1g g7m0VoRAlCij9PzRNtOcC4rbs4A6g6hokW2EbpuO8dtxWYGC8BH0WVLfnSh3dpBnp/0u hxTdElSICK/RPx1ZKeRWheOwcS95bJ+yMNWCbwmHAuybdJ+l1P5VXK5/jMVPTJTVh1g1 Mskg== X-Gm-Message-State: ACrzQf222PWi+EbPwPDWwYWApVNHivi6ZM60Ay5FPNYUK6nEhm4SuD7F MD5N6PfKnpZYfpie1zZVDbvyZpRhTUJW0HkO X-Google-Smtp-Source: AMsMyM58e9j7DMwqocfH1sKbSSGvF+nKnOVTjVWkgw/cWfmRimzyDdvH1qmSizF6VTx+njUn89GQhg== X-Received: by 2002:a05:6830:2816:b0:655:f666:801d with SMTP id w22-20020a056830281600b00655f666801dmr8835084otu.303.1663617591543; Mon, 19 Sep 2022 12:59:51 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:51 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v5 17/17] sh: Add string-fzb.h Date: Mon, 19 Sep 2022 16:59:20 -0300 Message-Id: <20220919195920.956393-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-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 | 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