From patchwork Fri Jan 20 21:16:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 644652 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1017182pvb; Fri, 20 Jan 2023 13:19:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXvJFtBEmLYGXX4QcuQdN2Jj67p3ekCNplA98szRI1os/toW71y4HCmNISBvRG7r1DB9ILi4 X-Received: by 2002:a17:906:7116:b0:78d:f454:ba46 with SMTP id x22-20020a170906711600b0078df454ba46mr11971720ejj.69.1674249561360; Fri, 20 Jan 2023 13:19:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674249561; cv=none; d=google.com; s=arc-20160816; b=yZGnwuEWwWFbcqhD7/NnPE7L6L1CEBmepsN//QW+buROsc4R3k5XIv8Vo6b+MDJq75 Zo2cNngh2dbK/NPQQvipETVpiTmd8oF6+huJ4REGyi7sCjYLvJ9I+USVUVYh0+Z8kDAp r3I6gbsJXlTJ0nhO0WHrm2vOhb0hFXRUgAu8dl/IsbEA71MRPGrDo1C9tZWYtKuM6KVV tj0Uj0nQ6Ta6HhQTsfFuGanA5Y0akbtkPklrACrkOI43BRKQXs5FkZ6M23tuHdP6VvFD CpV5nLFCOZ7eu7a/bCNV9MfV8txIp2wIPWrKmySfPngPXu7Y48k+NKfCRLr3e6oLIT1D abng== 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:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; b=FvBfXo9P1395ULpniu7LoeYwr1ATdrqJj/iwTVvg6XNyZPzAOqYlrGCeE0iYfWXqhj /c/GRjxnWYQfsByv/SVF20j7NXJCyPeceWjbI8+eR2eJS+hi9MXyaTRRHI2z57BtlqT3 vbOSAl21U55TptVSNZDv6RyNBCKhDJyTaRUl0xpdjpJM60CQbNf5FYpptCi7r8kaAfG7 ZpLYo4kKu0KJG3bEMsLMc2NIeiKU2icA+MtjWIquKVeXFBj6nrNGzl6wcPigC+hSyrC5 gyo/CaPIDbuZEH159Cs+sG08KG96Aytr/IzAwE9/IPWRkjnj9aiA1nE5fm7vDLpunKR2 mzzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lrqOAxd7; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id nd12-20020a170907628c00b007c14665652esi21622131ejc.299.2023.01.20.13.19.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 13:19:21 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lrqOAxd7; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 EBFED385B530 for ; Fri, 20 Jan 2023 21:19:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBFED385B530 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674249560; bh=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=lrqOAxd7n1/H28dcGh/WBEiT4vgHR9mirnf9dBinwOKqbeoUt3Hrz8I+wj4f0k+B3 dOpYMfEmessu8rcRBovf/9oViYfa6paN+ntZCgFVZdJnV88iHsCMQIDzeO9fII4U9c p51iIsiw+nAnFSkxOR3KGLIJfvLMuwpYJxqD0pC0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 BEB7138493C9 for ; Fri, 20 Jan 2023 21:17:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEB7138493C9 Received: by mail-ot1-x329.google.com with SMTP id x21-20020a056830245500b006865ccca77aso3802551otr.11 for ; Fri, 20 Jan 2023 13:17:05 -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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; b=Qsgauvw6+oRY4Gbey8goZVlpN35q03fQ9+rgxdt4w2yuJSDUGv1fSV7aFbotQQgxQd ruh80W7pzCKkDdb1Wwt4YhKGwfnrhwGJI1nQmKT6jeSdjDZUdon3TvWjfrXxY9Zv5a5V a9dyNDO3hCOxN7QTcabc7Z2LLlEv9sYk8hBIvt2n4GYpQOHrUFg61b84GyfCFw5a1tWj pKSh9wAUFn/muLjhABuNg5aQZ2gzAXLGJWrCEjvyfpdoblnAed5cGZzKEz+RkcWUm2kX GeeTJVfkI410NsVJeIOGQi31KDqGUMbpgQGpiVwW+Uw8DsfskG8JigB4PnUEpgmxjjKM hYcQ== X-Gm-Message-State: AFqh2kpHTPgXGfDZuYMPj/YbpkZa2UnGMIt2o0iVXfzogZp3jfiF2aYu i8XHURr2+a4tBTorPDcNKn9hxkhPxWPcNl0wWPM= X-Received: by 2002:a9d:74cc:0:b0:66e:9510:1da5 with SMTP id a12-20020a9d74cc000000b0066e95101da5mr9177481otl.8.1674249424568; Fri, 20 Jan 2023 13:17:04 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:7e99:f284:be2f:4ee5:d122]) by smtp.gmail.com with ESMTPSA id d18-20020a056830139200b00686467f920bsm6937432otq.48.2023.01.20.13.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 13:17:03 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v10 16/24] powerpc: Add string-fza.h Date: Fri, 20 Jan 2023 18:16:14 -0300 Message-Id: <20230120211622.3445279-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120211622.3445279-1-adhemerval.zanella@linaro.org> References: <20230120211622.3445279-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 Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" 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 | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 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..5dec740041 --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,72 @@ +/* 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 +# include + +/* The functions return a byte mask. */ +typedef op_t find_t; + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static __always_inline find_t +find_eq_all (op_t x1, op_t x2) +{ + return __builtin_cmpb (x1, x2); +} + +/* This function returns 0xff for each byte that is zero in X. */ + +static __always_inline find_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 find_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 find_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 */