From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id A5301385700C for ; Fri, 2 Sep 2022 20:40:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A5301385700C 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-x334.google.com with SMTP id 92-20020a9d0be5000000b0063946111607so2219221oth.10 for ; Fri, 02 Sep 2022 13:40:12 -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=/uCRcF9qUCajChP7TLbUSNFzBkE0RzW5ftlKjiF8tuM=; b=LnPbOx20tk95DvkonDbGHEBHknePoCescqf3hUlYZFnjrV9aTs5fak/8vXBKASbs2V coCnjN8VC/RSyaBeCqqxbB+oka6+sKmi36uwcsoEvNPgfHhMDsRkIFo/U03whkFdmDWS P8wz/58eHuEQAvQDflTLCNEJLZVc6NVVXjKA/YF5l6rFrozMnN80qW5VIwjt6xNh5VhT OYdoYm+euovYIP26n7XCnLC2NP4FrdbakjElnM2Dcc/kf1wBf/dj57CACfOa63hhmk8K AMwBfxGjCPeZolnomdSIr21gDjSNrvFy6HeBfx5u2fMVhG+X/exHS5XNjsNRQs1HhlR5 kivQ== 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=/uCRcF9qUCajChP7TLbUSNFzBkE0RzW5ftlKjiF8tuM=; b=xP24fhmsb2dEvpIv+Yj867BtwDtDz5c4wLpKnTNAcPLLfXeyqoR1akXKt7sK6dI5x7 b4XHHqs+69aOrQBE+8TxIyEyQ4NV4nxC8OOn4HS+9aTWu3cumZUNvlzLKe45yg7D0A2c 6+BaKp9oaCpWsUvyH248HQFZYIprIBoeGL7Jsdk68e3Kf272hxcOnGIu6E4DHaYIehdz B4jOz1h4rR1jszEufP8tPyUpF0zkzq9lUEgSHfeB9PYIySQUcPUVRJ897Zkg2AV/N8SQ cSVWjPocf8xLQQ5hvhq1XI6sQ5dEiM4J1CXep8sRvQv/PgwnMvdk0fXlCkO9KDDdxryU ep5g== X-Gm-Message-State: ACgBeo37tAbFC7jSLPmDZze6G2StDJQf82x1izrWbmIMxFCadlap/Hiy z+KYBbLSfEgXi9IlEH1EWenY7WGzJUT3og== X-Google-Smtp-Source: AA6agR60W+dzfcodwBfJSplxB93vT4ntOm1SrWCxUKAPb8YtXi5cMFWfrbDVAbI3dPeFqdzBT1D9+Q== X-Received: by 2002:a9d:d83:0:b0:639:c1a4:4d78 with SMTP id 3-20020a9d0d83000000b00639c1a44d78mr13344104ots.100.1662151211923; Fri, 02 Sep 2022 13:40:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:11 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joseph Myers , caiyinyu , Richard Henderson Subject: [PATCH 16/17] powerpc: Add string-fza.h Date: Fri, 2 Sep 2022 17:39:39 -0300 Message-Id: <20220902203940.2385967-17-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: 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..5f7e9c5cbe --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. PowerPC 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 POWERPC_STRING_FZA_H +#define POWERPC_STRING_FZA_H 1 + +/* PowerISA 2.03 (POWER6) provides cmpb instruction. */ +#ifdef _ARCH_PWR6 +# include + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static 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 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 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 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 /* STRING_FZA_H */ -- 2.34.1