From patchwork Tue Jan 10 21:01:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 640910 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2918232pvb; Tue, 10 Jan 2023 13:05:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXs6KUzLQ2LCDExiR+jDz7El1viuVxB4pwXdpzMnCdr8BerXJgOTUQOLTCEoxYXWBJjA2j0X X-Received: by 2002:a05:6402:3712:b0:499:70a8:f918 with SMTP id ek18-20020a056402371200b0049970a8f918mr8672123edb.16.1673384751849; Tue, 10 Jan 2023 13:05:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673384751; cv=none; d=google.com; s=arc-20160816; b=yaSxcQK890V59uViwsmj9P43A753d0NHaBHbJdEAU+rCN7argt7StYdYQ0cKKnaAK5 GoZRBYSuc9sULZiv+//icP3Y1B/QQevVuZAjQb7NpOl4CSRr0p6nv42eQX8sqTJCNQRL ukYHbbfU2S+8berrGYRVoMdL+atwq1G8tOy2hyPiYCFxaqWHuf1N3Pvv6cexgvUJuPr6 fIlhtf+40cpJn5WBDwWOskGolR3kZ58hEAwVWP4vrPezDxM3n7iP/xp24x3WSW3f/usi Hx31Ugc8v/89Z7aqJas169aw0Le88Ji2/eFjRZnpk1dxtPvE4iLxQ2Z8kzBbezrfc4Kv jLag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=yGPovr38ZU02FWiH7KoXJ0+CqtlDx/oj85V6st1cjgM=; b=kthkXPjEEGohaJmPQZLfswaD9jhl2W+HU7U8k5a1m2R/BK4TnUWTaEbSbR2xBoQl38 fgUkYNITq3P4KyTbaMlF6S72yiJhb4U3CMsmJMzuY5G8nmX6Fpt0ClaPDTgJOl8qZF55 3ZTvasZEyuoGeIVnLDITaXQgyDrdZ9fzZiEVjUeTsx5UmLqru0zJggiUCWMWEHhx3FTD WVpvq/9yJ3DxHcaZU+5GXWqS3/wWbLSKe78uyYVCfbOtR+c56l8XE/0EwFiihBAcV0TF SV01fQ5BPHhFyWCrGF5YjMoZO1KkD2tOQbDwbBurFHrV+D0X+6BOGO9I+ZpyH6iYGk6y yrGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IEoL21Ew; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Return-Path: Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f15-20020a0564021e8f00b0048d6ace589esi15958552edf.128.2023.01.10.13.05.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:05:51 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IEoL21Ew; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC40F38432EA for ; Tue, 10 Jan 2023 21:05:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC40F38432EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673384750; bh=yGPovr38ZU02FWiH7KoXJ0+CqtlDx/oj85V6st1cjgM=; 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=IEoL21Ew260KFJxRuxvzAyUqXO1U+0iiRa0+dSbQv4VkreaWh2BG+eBHPmoGFhkHY /7JuX8ius8NF2IVM6KPIQ11CU+C3gmSo7YWr7JoGRoaqTVMNhP8vQ2EYj0fTN5becn Sgcs/kjEqM3Qvm8PWVOyNoX+DhOu7iaaqKUWzDww= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by sourceware.org (Postfix) with ESMTPS id 1018438432C1 for ; Tue, 10 Jan 2023 21:01:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1018438432C1 Received: by mail-oo1-xc35.google.com with SMTP id d2-20020a4ab202000000b004ae3035538bso3537320ooo.12 for ; Tue, 10 Jan 2023 13:01:52 -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=yGPovr38ZU02FWiH7KoXJ0+CqtlDx/oj85V6st1cjgM=; b=Z40GKuKLR7NwI5VTd+YaEHsRUI+EYJeyW2WB7PNgpiuh8KTqW69XfJEDtQlcujjG1Z wRAFq9mRZr8O2qtAFMyD84bvyU6f1MExbR0+fJymQ7SM/zpihr+UNUXgrMLX06e4LTdA YYeLSQTCZOnRLxkzxvpm35gT2tvPwAodaZ5fsdSq1Bl6draGdRhnBJQvAii2vR8RDjUo FPAAVILZFaXWMhVOfMMthNeWjh7M9LM4QqO8WVpEK8WdCw1iguuFtop6X4igN8eoPEhz 02CI6QuV1dXvvfiCLPHblMDQ3SiKS01KjGeP4yQ4DGVDNR5q/dWl+xNscq231mAvXzqq Zsag== X-Gm-Message-State: AFqh2kqIkIa44wXP6bgL0J/Ze4QpYPwT0engNr924ve0eL5t3SGkFwP+ V9rNflUVC3BzKnNDAIiQrKfYQVpXEb0CYEEGIkc= X-Received: by 2002:a4a:e606:0:b0:4f2:1b88:6364 with SMTP id f6-20020a4ae606000000b004f21b886364mr895412oot.3.1673384511422; Tue, 10 Jan 2023 13:01:51 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a93a:e8a0:dd55:3328:997]) by smtp.gmail.com with ESMTPSA id r5-20020a4a83c5000000b0049ee88e86f9sm6202193oog.10.2023.01.10.13.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:01:50 -0800 (PST) To: libc-alpha@sourceware.org, Noah Goldstein , Richard Henderson Cc: Adhemerval Zanella Netto Subject: [PATCH v6 17/17] sh: Add string-fzb.h Date: Tue, 10 Jan 2023 18:01:06 -0300 Message-Id: <20230110210106.1457686-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230110210106.1457686-1-adhemerval.zanella@linaro.org> References: <20230110210106.1457686-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 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 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: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.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. --- 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 */