From patchwork Fri May 15 14:20:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 186832 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp482148ilb; Fri, 15 May 2020 07:21:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbKa7v7BDbO4o5gM+oy52ftYtruIFdPkk/FAzGjnm2Nq5cik0COCZ2R07/Cxvw4MSl4qTX X-Received: by 2002:a37:5987:: with SMTP id n129mr3653568qkb.257.1589552499262; Fri, 15 May 2020 07:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589552499; cv=none; d=google.com; s=arc-20160816; b=Wgv9kRNMUBChSn6DSWrVHrdpu/VBlYvCVb6fQelkCbyvptZnxhR563nrKRGziYdjbA IeJrpoz+2zRZFhlFn9PtoWd6F2Yzd4YR9pTc2qExm+CjnGGUynNQz+QyXW+cj7gpxqOH 5WqicNDGiqVOY7IYMBL9gYwtdi3GZwQIbKr2V+p27rWcksrURZKpuRngLJAWIiEPBxlN 7F439y1OEZ2D0o7Dg0R+skMeibN9d0okkrGgbAhyQHUHIAxyvhQzePtmLDcPnB/kWinA 6SwXPnfVpeNRMPmuQnR6DW+humaVaGngZJ+TPmAGoVnTfQOCSf3v5JTnqCWQ6xmBxumr BVSQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hKEL7z4LxXMw8xsvvZqstECIgOw6TAEOPxp9PR9rpGE=; b=t5PWgiuDyJPIXopH2I5jFdK/QiWwzael9SX7LGh4f7Z1cfJRVb+rtP4HRDtDRLyl6V tYfV0EwgLdNqPyVm08dy2wby8ITdZ+4LEDoZEeB0ZAr80bivxQLvWq/irxeqIhtj45vU ttObl+REoj0f8g3zUJ47Ul1L9aoKMjjM4vsMPny9fRrwpAp1mlePiA2CmCCh0ZFTZWH2 Raoe0x/HkkpBw4edT5VNnRJoa6v3PMv+XDTDfITtjHhZDUouT/2tjPG2onOlLuJ24DLS RvIPDODPSkfumv+k3PIBOh5ZCPjoTcQH5xDq3sKcXkuRlaGyL2xzQvTLd4NNjYyce5Qj hmCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GX+Cpsnh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b133si1252505qkc.299.2020.05.15.07.21.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 May 2020 07:21:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GX+Cpsnh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZbDW-0001eT-N1 for patch@linaro.org; Fri, 15 May 2020 10:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZbCy-0000gO-RX for qemu-devel@nongnu.org; Fri, 15 May 2020 10:21:04 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:53906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jZbCx-0003s4-NU for qemu-devel@nongnu.org; Fri, 15 May 2020 10:21:04 -0400 Received: by mail-wm1-x341.google.com with SMTP id k12so2506959wmj.3 for ; Fri, 15 May 2020 07:21:03 -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 :mime-version:content-transfer-encoding; bh=hKEL7z4LxXMw8xsvvZqstECIgOw6TAEOPxp9PR9rpGE=; b=GX+CpsnhbSVEVmKZ18h/6DwQfYUec0YIsWsoUXMn60OwTssJZJD0ObsjurPS9THSqI Ew668yFwCSigE4OUt8a/oL0/qJKvbAaqLdw9Gr2ncXbu7+QpKtyemXMV8yEhLETXEPe7 KezTYlismGvSo7mgdquj5fRM2gvrDgGeyUFG7IRSu76Ds9IIJEWPyv5iokK2MISo5CrU GLRLAYevukem7yBF6SuqzxTFpg/YlPsQzqHfxQrYLrH/ISeQrd+zW1JomJaGnsYqQ9VO 1HSFSaeJRJeftUuxLsSrJVsYyHnhUy4D86w37wkR0IW6ZKz6OEBs8v3CLchef2orARy2 8tXg== 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:mime-version:content-transfer-encoding; bh=hKEL7z4LxXMw8xsvvZqstECIgOw6TAEOPxp9PR9rpGE=; b=CrC30ZiY990DnkQBwR/AGlYHIh5ZlppjKICLSLesRdjJLSjYFTKs33MoFm+lxEB9n+ bYsHNyt6K6Cd1u6EiOUO0NH8b90aFPxYp/413SBuSSfXpmgIveOz+KyYTELMXZY5M2Nd RcfJbzZByhF/LEDJlKlLSCU972Q/fcu5/6Hf+tkjD9nVUz77CSWXjgDE1dstUqDudwx0 ZjHa4YUraA6MzGX1s6w5ztbVDal72bXlMxR7BSgi+PHXZrqw6JEtNyHFnSNysg1C5yGa vd73PYn6tVYigbw/lhKbHtR5piqSgX2ELlRm6sobN25WWluI9XFovSN2xtWkfbGirpyh PGPQ== X-Gm-Message-State: AOAM532hK/HduAIXbHuOkEig4mqJB2fQ6SUsdMkhB7c4xShfQbNWTcUm Qt4pIb2EOeTOADNLxoVjecuQNg== X-Received: by 2002:a7b:c413:: with SMTP id k19mr4284214wmi.124.1589552462175; Fri, 15 May 2020 07:21:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id s14sm3738327wmh.18.2020.05.15.07.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:21:01 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 03/10] target/arm: Convert Neon VSHR 2-reg-shift insns to decodetree Date: Fri, 15 May 2020 15:20:49 +0100 Message-Id: <20200515142056.21346-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200515142056.21346-1-peter.maydell@linaro.org> References: <20200515142056.21346-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Convert the VSHR 2-reg-shift insns to decodetree. Note that unlike the legacy decoder, we present the right shift amount to the trans_ function as a positive integer. Signed-off-by: Peter Maydell --- target/arm/neon-dp.decode | 24 +++++++++++++++++++ target/arm/translate-neon.inc.c | 41 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 21 +---------------- 3 files changed, 66 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode index df7b4798a5a..648812395f1 100644 --- a/target/arm/neon-dp.decode +++ b/target/arm/neon-dp.decode @@ -209,6 +209,30 @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp @2reg_shift .... ... . . . ...... .... .... . q:1 . . .... \ &2reg_shift vm=%vm_dp vd=%vd_dp +# Right shifts are encoded as N - shift, where N is the element size in bits. +%neon_rshift_i6 16:6 !function=rsub_64 +%neon_rshift_i5 16:5 !function=rsub_32 +%neon_rshift_i4 16:4 !function=rsub_16 +%neon_rshift_i3 16:3 !function=rsub_8 + +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 1 . . 1 .... \ + @2reg_shift size=3 shift=%neon_rshift_i6 +VSHR_S_2sh 1111 001 0 1 . 1 ..... .... 0000 0 . . 1 .... \ + @2reg_shift size=2 shift=%neon_rshift_i5 +VSHR_S_2sh 1111 001 0 1 . 01 .... .... 0000 0 . . 1 .... \ + @2reg_shift size=1 shift=%neon_rshift_i4 +VSHR_S_2sh 1111 001 0 1 . 001 ... .... 0000 0 . . 1 .... \ + @2reg_shift size=0 shift=%neon_rshift_i3 + +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 1 . . 1 .... \ + @2reg_shift size=3 shift=%neon_rshift_i6 +VSHR_U_2sh 1111 001 1 1 . 1 ..... .... 0000 0 . . 1 .... \ + @2reg_shift size=2 shift=%neon_rshift_i5 +VSHR_U_2sh 1111 001 1 1 . 01 .... .... 0000 0 . . 1 .... \ + @2reg_shift size=1 shift=%neon_rshift_i4 +VSHR_U_2sh 1111 001 1 1 . 001 ... .... 0000 0 . . 1 .... \ + @2reg_shift size=0 shift=%neon_rshift_i3 + VSHL_2sh 1111 001 0 1 . shift:6 .... 0101 1 . . 1 .... \ @2reg_shift size=3 VSHL_2sh 1111 001 0 1 . 1 shift:5 .... 0101 0 . . 1 .... \ diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c index 305213fe6d9..0475696835f 100644 --- a/target/arm/translate-neon.inc.c +++ b/target/arm/translate-neon.inc.c @@ -31,6 +31,24 @@ static inline int plus1(DisasContext *s, int x) return x + 1; } +static inline int rsub_64(DisasContext *s, int x) +{ + return 64 - x; +} + +static inline int rsub_32(DisasContext *s, int x) +{ + return 32 - x; +} +static inline int rsub_16(DisasContext *s, int x) +{ + return 16 - x; +} +static inline int rsub_8(DisasContext *s, int x) +{ + return 8 - x; +} + /* Include the generated Neon decoder */ #include "decode-neon-dp.inc.c" #include "decode-neon-ls.inc.c" @@ -1348,3 +1366,26 @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) DO_2SH(VSHL, tcg_gen_gvec_shli) DO_2SH(VSLI, gen_gvec_sli) + +static bool trans_VSHR_S_2sh(DisasContext *s, arg_2reg_shift *a) +{ + /* Signed shift out of range results in all-sign-bits */ + a->shift = MIN(a->shift, (8 << a->size) - 1); + return do_vector_2sh(s, a, tcg_gen_gvec_sari); +} + +static void gen_zero_rd_2sh(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs, + int64_t shift, uint32_t oprsz, uint32_t maxsz) +{ + tcg_gen_gvec_dup_imm(vece, rd_ofs, oprsz, maxsz, 0); +} + +static bool trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) +{ + /* Shift out of range is architecturally valid and results in zero. */ + if (a->shift >= (8 << a->size)) { + return do_vector_2sh(s, a, gen_zero_rd_2sh); + } else { + return do_vector_2sh(s, a, tcg_gen_gvec_shri); + } +} diff --git a/target/arm/translate.c b/target/arm/translate.c index d0a4a08f6d9..f2ccab1b21c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -5296,6 +5296,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) op = (insn >> 8) & 0xf; switch (op) { + case 0: /* VSHR */ case 5: /* VSHL, VSLI */ return 1; /* handled by decodetree */ default: @@ -5330,26 +5331,6 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) } switch (op) { - case 0: /* VSHR */ - /* Right shift comes here negative. */ - shift = -shift; - /* Shifts larger than the element size are architecturally - * valid. Unsigned results in all zeros; signed results - * in all sign bits. - */ - if (!u) { - tcg_gen_gvec_sari(size, rd_ofs, rm_ofs, - MIN(shift, (8 << size) - 1), - vec_size, vec_size); - } else if (shift >= 8 << size) { - tcg_gen_gvec_dup_imm(MO_8, rd_ofs, vec_size, - vec_size, 0); - } else { - tcg_gen_gvec_shri(size, rd_ofs, rm_ofs, shift, - vec_size, vec_size); - } - return 0; - case 1: /* VSRA */ /* Right shift comes here negative. */ shift = -shift;