From patchwork Wed Jan 10 12:48:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 25323 Received: (qmail 657 invoked by alias); 10 Jan 2018 12:48:48 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 128130 invoked by uid 89); 10 Jan 2018 12:48:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f196.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=P9fXsoda5k4EO66liqE+SKWQBCGGlE75mhO5dD3ywGg=; b=o6Y4URcAGjxM9N9cURR1g6snnMWz6YEl+gUF5ZhTNuPVosSVSzZGLMEGGXCIiOufWn Gg8v/aC912Ruzmn+jKvCUH6ktmjgm9yY2ulCC7zavZU2Mi3PJgsHsEpXPcOOyH/Qfrka byMIxcs2iAHN+mYUA/zZgAp5MrVG2xNA2W+JPkujpD58blPPPg7I0lsMDCfjsYt3lpcC udWkvC684lk3j8tR623fjBc5MB+RzAmSPvU2pyJ3pP0jLThBoEMshOOqrspiznZzADlu yuzKfj+e/hmdOX0luNDtr/Muy+tIQtoJDz4NzHC7ja05iP1EixLHeOgKeSwoBR92CEW4 ZkOA== X-Gm-Message-State: AKwxytdBWcDGBHVssBSokc7pp+bxN10uJ931XzRidHC4f/v3gOUk46Hz 0qgN8P/p+v9Ql0JqypZSAs9Hz3+jCIU= X-Google-Smtp-Source: ACJfBotXEdi78SRuMfQ498Z44sxDXczj5mLIWWaRZkb/GTPIP0r+BV6cho6QWM1E95AR3TV1uBu40Q== X-Received: by 10.55.119.132 with SMTP id s126mr25934079qkc.250.1515588516945; Wed, 10 Jan 2018 04:48:36 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 18/18] sh: Add string-fzb.h Date: Wed, 10 Jan 2018 10:48:02 -0200 Message-Id: <1515588482-15744-19-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1515588482-15744-1-git-send-email-adhemerval.zanella@linaro.org> References: <1515588482-15744-1-git-send-email-adhemerval.zanella@linaro.org> Use the SH cmp/str on has_{zero,eq,zero_eq}. Checked on sh4-linux-gnu. Adhemerval Zanella * sysdeps/sh/string-fzb.h: New file. --- 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 0000000..70d8a8f --- /dev/null +++ b/sysdeps/sh/string-fzb.h @@ -0,0 +1,53 @@ +/* Zero byte detection; boolean. SH4 version. + Copyright (C) 2018 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 */