From patchwork Wed Jan 10 12:48:01 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: 124080 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5235062qgn; Wed, 10 Jan 2018 04:49:19 -0800 (PST) X-Google-Smtp-Source: ACJfBosRPhvdpfWkCX7XoUX4A7nbBCxzxtHfHdLBW366iTWSzuKNiwES8mTlwGOWL6wpmFD9lvbJ X-Received: by 10.98.43.3 with SMTP id r3mr16533992pfr.130.1515588559677; Wed, 10 Jan 2018 04:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515588559; cv=none; d=google.com; s=arc-20160816; b=e4fc3ByUb6FkUruYbbZwFaCpVI/HcdBhr2ax5rr8JCR9T5cSJr/kNkPoLuBEBkXDJ3 yeBHbNkmOv9iPl6AwdsG/EmncKNrjlUdjBs9a3V0uVHKp5Adul/mYUEWpwCDxemI+hRi omvKVGxUnNKheidfPSBHv9dwvqTUGvqEX7fC++Sh0fS6F1VYhJqy8W09bKSb84hhOQk+ 9T/A5DWzS9IIKmfjq4uQ+Na4rUIKhKNcMwu5EtBGAHeMc/VPYGcpyqomhpD1Ev8yPc2Y atbytc4T17KKKY6y+Eo0Pn87cxTbuYtkT5hryAoNihHYT64rFKN/PoXriATS6LDswAvT URYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=wRjeFs1mWfSroKruWagOxHvKNvLVUS+0Cx0dYQtIMYA=; b=N0iek21pjm1i1Bk22gxDOfXshcNCSfcQFYO7FNud9gmnA/GO+wqiVPENwiEQ2GN7er m+IDXRiXX1pgDxCICCmt6kwzOJOERXRWMdXeAe8JvtAfHHqJ2JbSsHz1G1fICeWmksTH 4L1YSG0+EKlZ3y5VfncuPtvWUEOKUDdrPxlksYA1K4IlC0PIZoBdfKaxTBc33Fp7MV8v dW6wQWW/hJulQXV5lFCGpLMirWmBlS5dkJF9ZpuVYCWymCmIEmLNSw6jnb/+mVwJzhoc ZTupFdazhb20UCyajyzbiKAE5ai6LPEcJYp3rgDPVSa+rNjzuANj07vHRb/7H5O2o6jq BKnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pZTLDux5; spf=pass (google.com: domain of libc-alpha-return-89004-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89004-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b17si11689877pfd.406.2018.01.10.04.49.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 04:49:19 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-89004-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pZTLDux5; spf=pass (google.com: domain of libc-alpha-return-89004-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89004-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=GjiH7yTuIYeelm9Z7XcuP916TFiwS3n IKKrD/8C2d0jCnXv8EgqzOKo7GfXdB65aOLWSgHIHbl60ksygMZG13mMZm17KZCf RXFFEKJPIR8Jcz4Wkkg9rfjErCmYzNJLXj3APjg3Mktm+V6fJFBP0RMCK0U8ZslU 4/E/avfE1ZiU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=PpA+8LHyTYQZgVMHvaRBR0Fgp88=; b=pZTLD ux5/UBi4C21zL+dOJMV5qi9g/b9Os73zpBu2P6084adv+u9qwb7jQPYlecrKZ7BY nHD9I/MEW3mvaVloeKEUixnVPCeUeWHSBIZcATML+SVtgvM8HBuhkk63IzWWJFYn E/gtTCAXJJTw87AqOQZ6DDEcYyYannzxHmjTjY= Received: (qmail 129891 invoked by alias); 10 Jan 2018 12:48:43 -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 127925 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=Identify, basics X-HELO: mail-qk0-f195.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:cc:subject:date:message-id:in-reply-to :references; bh=wRjeFs1mWfSroKruWagOxHvKNvLVUS+0Cx0dYQtIMYA=; b=fXIVxwDEtehtWzhH+mKw8wi7DME5lwvt/0YwcVpeu5V4Eq+eQ2JyK+FOkEXRDGB1y/ GlbGBzU3AfeWC03XTb92BQu0EzfwRBdKiCJtLtvbLb1tnI2YFt9GIdnbcj+xUMqexAVr iiYx1lEaOIMLFtoJBy/8w6dH5YUHXhfA38470D6BXGn8cy16htt+SZTQ5AjtaApp02jO eSBbuqw1rFWve81Vj8VjK9jssO5lsFZctqHoxXnpZ7UxXa+KZg28sX4lx+Rd68qqpy2A wE0J6K0PV/eZSlO4McnkAWDebOG973Ji3sDKnTFofE/WhdOxRZ1zhOuCmMcCwLeHlFB5 KrpA== X-Gm-Message-State: AKwxytfLTAa5sAdAf2rzm6E0cB4e09cYAoeDXAGR/jJNKmRPAWp2sNQt MPUQ26JEHIc7TmWFlnEO+uEyKTjk8os= X-Received: by 10.55.65.75 with SMTP id o72mr12987184qka.202.1515588515590; Wed, 10 Jan 2018 04:48:35 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Richard Henderson Subject: [PATCH v3 17/18] powerpc: Add string-fza.h Date: Wed, 10 Jan 2018 10:48:01 -0200 Message-Id: <1515588482-15744-18-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> 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. Richard Henderson * sysdeps/powerpc/power6/string-fza.h: New file. * sysdeps/powerpc/powerpc32/power6/string-fza.h: Likewise. * sysdeps/powerpc/powerpc64/power6/string-fza.h: Likewise. --- sysdeps/powerpc/power6/string-fza.h | 65 +++++++++++++++++++++++++++ sysdeps/powerpc/powerpc32/power6/string-fza.h | 1 + sysdeps/powerpc/powerpc64/power6/string-fza.h | 1 + 3 files changed, 67 insertions(+) create mode 100644 sysdeps/powerpc/power6/string-fza.h create mode 100644 sysdeps/powerpc/powerpc32/power6/string-fza.h create mode 100644 sysdeps/powerpc/powerpc64/power6/string-fza.h -- 2.7.4 Reviewed-by: Tulio Magno Quites Machado Filho diff --git a/sysdeps/powerpc/power6/string-fza.h b/sysdeps/powerpc/power6/string-fza.h new file mode 100644 index 0000000..4549dde --- /dev/null +++ b/sysdeps/powerpc/power6/string-fza.h @@ -0,0 +1,65 @@ +/* Zero byte detection; basics. Power6/ISA 2.03 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_FZA_H +#define STRING_FZA_H 1 + +#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 + +#endif /* STRING_FZA_H */ diff --git a/sysdeps/powerpc/powerpc32/power6/string-fza.h b/sysdeps/powerpc/powerpc32/power6/string-fza.h new file mode 100644 index 0000000..bb00d7c --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power6/string-fza.h @@ -0,0 +1 @@ +#include diff --git a/sysdeps/powerpc/powerpc64/power6/string-fza.h b/sysdeps/powerpc/powerpc64/power6/string-fza.h new file mode 100644 index 0000000..bb00d7c --- /dev/null +++ b/sysdeps/powerpc/powerpc64/power6/string-fza.h @@ -0,0 +1 @@ +#include