From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by sourceware.org (Postfix) with ESMTPS id 297F2385B50C for ; Wed, 11 Jan 2023 20:46:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 297F2385B50C 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-x2c.google.com with SMTP id 586e51a60fabf-14455716674so16844156fac.7 for ; Wed, 11 Jan 2023 12:46:38 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=NB6MyQN54L0ZfjYrf0IIqicl8+o3iDBFOSABu07doRU=; b=j0M8v98ZVWq1jKeNY9NQKhYK/IW3hK/wuY6EbssqZ2bvRLGBqKupwc8NCDWfFdu+gK MIJKKZ6ll/WTR9cItnZnbVXB4cGRccB88xpxhJCu1e5bsdHaBsbJN3seiOK9m9SAET7V Et6m1+zBV60GDLIAISvGctatoWzLoxZXUO/v0O1sk8lcnzYjusWb2XLXARfbqn/hsHdT VXqVBrNvSiTrKyBsFZ6ghl9tgyKvN9vyvextDfm1cHu/aAt1hE1H1Qv8JX64ioawHVmq gWIuip793y0eNJNq2n/v8XaXonm0TxcmE9f8vqLr1zsiWrkMH4vSth9LscbYklFIKtqA zovw== 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:message-id:reply-to; bh=NB6MyQN54L0ZfjYrf0IIqicl8+o3iDBFOSABu07doRU=; b=s2bMCX/DbmMdo1vnDgMQIDeZi0NKzRUmGY3t9rpO/lF550uueiTKKhe41aKb/mAF2d rEco2lHC/YzbLM5Rx4Upwy6nfucExjKNhguYt90HV8deNT/QtZps+QErOPWKxiyZxwPU KxWfaN/AIUDoTq2AEmskmwdEjVYExqL31NzbF6rt5PvOgbmQFNHYDmAlh7jHEOZkybQh o/PPDTxftnOYgGdo7r1iJrDevM6YkCS4xJLHaiA9JCDj0TVs0eL7DVNuRhDS4BdoCHiO m5b9v1ChyLXEArKAAhVVLyeNjGBWKc8DZE0o0l6sGRuu1wyHz8rIQ/bo8Z8TJbckN1rd cP1Q== X-Gm-Message-State: AFqh2kqvlRCsJSZwcUaW9a1JpxGurmOkWufqmhwybxAXOIM+QfUy4flH 6kwJrrdXQRdImFR04luYIzdHQt6niHk/0XNWZv0= X-Google-Smtp-Source: AMrXdXtPJQ9boyM1hAzXv9EdmBlJRnGppRH59s0Bq5OV39diTMUoaZcnW7+ut7qH8IdXR8yPJcaPfw== X-Received: by 2002:a05:6870:2404:b0:13b:dafe:5756 with SMTP id n4-20020a056870240400b0013bdafe5756mr36961830oap.23.1673469996805; Wed, 11 Jan 2023 12:46:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 12:46:36 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Noah Goldstein , Richard Henderson Subject: [PATCH v7 16/17] powerpc: Add string-fza.h Date: Wed, 11 Jan 2023 17:45:57 -0300 Message-Id: <20230111204558.2402155-17-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: Richard Henderson While ppc has the more important string functions in assembly, there are still a few generic routines used. Use the Power 6 CMPB insn for testing of zeros. Checked on powerpc64le-linux-gnu. --- sysdeps/powerpc/string-fza.h | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sysdeps/powerpc/string-fza.h diff --git a/sysdeps/powerpc/string-fza.h b/sysdeps/powerpc/string-fza.h new file mode 100644 index 0000000000..5496c9db4b --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. PowerPC 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 _POWERPC_STRING_FZA_H +#define _POWERPC_STRING_FZA_H 1 + +/* PowerISA 2.05 (POWER6) provides cmpb instruction. */ +#ifdef _ARCH_PWR6 +# include + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static __always_inline op_t +find_eq_all (op_t x1, op_t x2) +{ + op_t ret; + asm ("cmpb %0,%1,%2" : "=r"(ret) : "r"(x1), "r"(x2)); + return ret; +} + +/* This function returns 0xff for each byte that is zero in X. */ + +static __always_inline op_t +find_zero_all (op_t x) +{ + return find_eq_all (x, 0); +} + +/* Identify zero bytes in X1 or equality between X1 and X2. */ + +static __always_inline op_t +find_zero_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | find_eq_all (x1, x2); +} + +/* Identify zero bytes in X1 or inequality between X1 and X2. */ + +static __always_inline op_t +find_zero_ne_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | ~find_eq_all (x1, x2); +} + +/* Define the "inexact" versions in terms of the exact versions. */ +# define find_zero_low find_zero_all +# define find_eq_low find_eq_all +# define find_zero_eq_low find_zero_eq_all +# define find_zero_ne_low find_zero_ne_all +#else +# include +#endif /* _ARCH_PWR6 */ + +#endif /* _POWERPC_STRING_FZA_H */ -- 2.34.1