From patchwork Wed Jun 13 01:56:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138394 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp103938lji; Tue, 12 Jun 2018 19:06:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKISx2dQJN9m8GNNCezgAo7zTPYNsg1vJQF5/vL3QCsWsTGmN/Y2zInDtIsfl/m483ZRBGgZ X-Received: by 2002:aed:38a9:: with SMTP id k38-v6mr2830803qte.30.1528855611645; Tue, 12 Jun 2018 19:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528855611; cv=none; d=google.com; s=arc-20160816; b=lI036P6aFYQ7VDUH2wNLdgOdwLE74xl6B8sRELICRasL3Sh7VR0vX9VCacE4dWm8rf fJOOpYCMPFV3f3cURXJqiAiivkS7eADKT9WRxYmDaDUGoj6usc7Z4FNJZW7URJdR9c4s 0rDhnDqShXzi9dd1QXf7OgdwS8Dre6qYPqd71F85GYzgYbw5BxMS8nyI9Z3NWUbA6RQw p18Rn2AamFPUXsno6tmQSuuBWshLejtpp6l/n5li+jAt7urPMr4KnC1qj6RfhtZIuv24 XvGnkqPbIY7MM0I9OvACqQd9G8mWyMQjBAVhkTdnFAsm++fofcIpPzBHnLxaOBMTGPu7 vEDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=0qv9waxjnItdqxrb1PCW4c/OmiL8b4gRs4csNfG9iRs=; b=EMm5ZAz04PVJSQ+5ORsuknbMO9kapsVwLM6BM2MbblTRi5kfRZ23dONEfnvQchM/BG AnMpq3rySjXFvqKHMUbAz2Gao5OUV86HCCmquJcDIEqkuAmZR1CM7KWxZgf+L9v/avzK UfpNNSwuXyYOVdBhbnp1rHNooprJsqdr6XFCvjJarLW6fXzl3NU4iK0EgMdROE793Cj0 p+W9ZMQsQ+tcWn5jhh/Gt+GAiA6xmZndwkmoBo5h2MGm38ulXYXdMTrS6ptWW9p6qyVj 6FO7HfVDLi0GWZagtZIsY9eOLENQAQRlzA77l6lWeFqdZnOLNsqDZ7M8v00HXRv8P0j/ hfBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OhNCMhyK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j6-v6si1609810qvl.174.2018.06.12.19.06.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 12 Jun 2018 19:06:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OhNCMhyK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSvBT-0001QD-1J for patch@linaro.org; Tue, 12 Jun 2018 22:06:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSv29-0002KF-J5 for qemu-devel@nongnu.org; Tue, 12 Jun 2018 21:57:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSv28-0006Gh-Am for qemu-devel@nongnu.org; Tue, 12 Jun 2018 21:57:13 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:46041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSv28-0006GW-2I for qemu-devel@nongnu.org; Tue, 12 Jun 2018 21:57:12 -0400 Received: by mail-pf0-x22f.google.com with SMTP id a22-v6so497620pfo.12 for ; Tue, 12 Jun 2018 18:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0qv9waxjnItdqxrb1PCW4c/OmiL8b4gRs4csNfG9iRs=; b=OhNCMhyKWn+ok0NnHq6HzoDuj6Cjv82cJ6nib1D/CBGxJCBqr+VxDmmnLcxQPvD2QN Ssu+gMFJPNR+QcevNdDbs6YPkNtKcno9fzG29lLwRiT3fpTaLEbPJoxsoltc+KPYK8Yw PZHjZ+fcTksULSciHVu390CgNeHgioqDZU00E= 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=0qv9waxjnItdqxrb1PCW4c/OmiL8b4gRs4csNfG9iRs=; b=EkCKI+uPMZGzPGInLp7ZenTDszdyVY52qZ7LzVHsEWF2ExjB3VsnyiiK27ZPVjYA9e Q81knK2XpnbClmVzJbNES1/yWCNw0IUpplozXvM9eV1VA2fRZ8PBicrjiM18mtDt6LDD lGF4c3nDyStN+0/7wDpB69mxk7+UWAb2HOkTAhB4Il1D8ic0e3pfKO8Ltiz/5VHctrl8 DOh+NyuCczK6+9Boo2hTErsc3uV7odWOVNg6MD+wUTLB3xq0GVOb5s43qk2q4X/Oc8qY iIrfZD54Xh8GbEugj5MWLAm315BZmvSRRhWown+S9L2KYPNIXN11FmOcRXwfKtHxEdBS Iibw== X-Gm-Message-State: APt69E3oMqd6YayHPr+DKVC9VHZ4xDg7gEKpjFM2LKs7bTKfc6jw+/hV rkH3Jl6Wdpo1TSWzIgyqyOFOoCKBe5k= X-Received: by 2002:a65:4a51:: with SMTP id a17-v6mr2395012pgu.168.1528855030753; Tue, 12 Jun 2018 18:57:10 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id g10-v6sm1647287pfi.148.2018.06.12.18.57.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jun 2018 18:57:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Jun 2018 15:56:31 -1000 Message-Id: <20180613015641.5667-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613015641.5667-1-richard.henderson@linaro.org> References: <20180613015641.5667-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22f Subject: [Qemu-devel] [PATCH v4b 08/18] target/arm: Implement SVE reverse within elements X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper-sve.h | 14 +++++++++++++ target/arm/sve_helper.c | 41 +++++++++++++++++++++++++++++++------- target/arm/translate-sve.c | 38 +++++++++++++++++++++++++++++++++++ target/arm/sve.decode | 7 +++++++ 4 files changed, 93 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index a58fb4ba01..3b7c54905d 100644 --- a/target/arm/helper-sve.h +++ b/target/arm/helper-sve.h @@ -465,6 +465,20 @@ DEF_HELPER_FLAGS_4(sve_compact_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_2(sve_last_active_element, TCG_CALL_NO_RWG, s32, ptr, i32) +DEF_HELPER_FLAGS_4(sve_revb_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(sve_revb_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(sve_revb_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(sve_revh_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(sve_revh_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(sve_revw_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(sve_rbit_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(sve_rbit_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(sve_rbit_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(sve_rbit_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + DEF_HELPER_FLAGS_5(sve_and_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve_bic_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve_eor_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index cb7d101b57..4017b9eed1 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -238,6 +238,26 @@ static inline uint64_t expand_pred_s(uint8_t byte) return word[byte & 0x11]; } +/* Swap 16-bit words within a 32-bit word. */ +static inline uint32_t hswap32(uint32_t h) +{ + return rol32(h, 16); +} + +/* Swap 16-bit words within a 64-bit word. */ +static inline uint64_t hswap64(uint64_t h) +{ + uint64_t m = 0x0000ffff0000ffffull; + h = rol64(h, 32); + return ((h & m) << 16) | ((h >> 16) & m); +} + +/* Swap 32-bit words within a 64-bit word. */ +static inline uint64_t wswap64(uint64_t h) +{ + return rol64(h, 32); +} + #define LOGICAL_PPPP(NAME, FUNC) \ void HELPER(NAME)(void *vd, void *vn, void *vm, void *vg, uint32_t desc) \ { \ @@ -616,6 +636,20 @@ DO_ZPZ(sve_neg_h, uint16_t, H1_2, DO_NEG) DO_ZPZ(sve_neg_s, uint32_t, H1_4, DO_NEG) DO_ZPZ_D(sve_neg_d, uint64_t, DO_NEG) +DO_ZPZ(sve_revb_h, uint16_t, H1_2, bswap16) +DO_ZPZ(sve_revb_s, uint32_t, H1_4, bswap32) +DO_ZPZ_D(sve_revb_d, uint64_t, bswap64) + +DO_ZPZ(sve_revh_s, uint32_t, H1_4, hswap32) +DO_ZPZ_D(sve_revh_d, uint64_t, hswap64) + +DO_ZPZ_D(sve_revw_d, uint64_t, wswap64) + +DO_ZPZ(sve_rbit_b, uint8_t, H1, revbit8) +DO_ZPZ(sve_rbit_h, uint16_t, H1_2, revbit16) +DO_ZPZ(sve_rbit_s, uint32_t, H1_4, revbit32) +DO_ZPZ_D(sve_rbit_d, uint64_t, revbit64) + /* Three-operand expander, unpredicated, in which the third operand is "wide". */ #define DO_ZZW(NAME, TYPE, TYPEW, H, OP) \ @@ -1587,13 +1621,6 @@ void HELPER(sve_rev_b)(void *vd, void *vn, uint32_t desc) } } -static inline uint64_t hswap64(uint64_t h) -{ - uint64_t m = 0x0000ffff0000ffffull; - h = rol64(h, 32); - return ((h & m) << 16) | ((h >> 16) & m); -} - void HELPER(sve_rev_h)(void *vd, void *vn, uint32_t desc) { intptr_t i, j, opr_sz = simd_oprsz(desc); diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index eed59524a9..f8d8cf1547 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -2643,6 +2643,44 @@ static bool trans_CPY_m_v(DisasContext *s, arg_rpr_esz *a, uint32_t insn) return true; } +static bool trans_REVB(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + static gen_helper_gvec_3 * const fns[4] = { + NULL, + gen_helper_sve_revb_h, + gen_helper_sve_revb_s, + gen_helper_sve_revb_d, + }; + return do_zpz_ool(s, a, fns[a->esz]); +} + +static bool trans_REVH(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + static gen_helper_gvec_3 * const fns[4] = { + NULL, + NULL, + gen_helper_sve_revh_s, + gen_helper_sve_revh_d, + }; + return do_zpz_ool(s, a, fns[a->esz]); +} + +static bool trans_REVW(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + return do_zpz_ool(s, a, a->esz == 3 ? gen_helper_sve_revw_d : NULL); +} + +static bool trans_RBIT(DisasContext *s, arg_rpr_esz *a, uint32_t insn) +{ + static gen_helper_gvec_3 * const fns[4] = { + gen_helper_sve_rbit_b, + gen_helper_sve_rbit_h, + gen_helper_sve_rbit_s, + gen_helper_sve_rbit_d, + }; + return do_zpz_ool(s, a, fns[a->esz]); +} + /* *** SVE Memory - 32-bit Gather and Unsized Contiguous Group */ diff --git a/target/arm/sve.decode b/target/arm/sve.decode index 519139f684..95eb4968a9 100644 --- a/target/arm/sve.decode +++ b/target/arm/sve.decode @@ -456,6 +456,13 @@ CPY_m_v 00000101 .. 100000 100 ... ..... ..... @rd_pg_rn # SVE copy element from general register to vector (predicated) CPY_m_r 00000101 .. 101000 101 ... ..... ..... @rd_pg_rn +# SVE reverse within elements +# Note esz >= operation size +REVB 00000101 .. 1001 00 100 ... ..... ..... @rd_pg_rn +REVH 00000101 .. 1001 01 100 ... ..... ..... @rd_pg_rn +REVW 00000101 .. 1001 10 100 ... ..... ..... @rd_pg_rn +RBIT 00000101 .. 1001 11 100 ... ..... ..... @rd_pg_rn + ### SVE Predicate Logical Operations Group # SVE predicate logical operations