From patchwork Fri May 15 14:20:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 186836 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp483485ilb; Fri, 15 May 2020 07:23:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy8jemrYZ5JnBP2p9+dtOU2q62BBYOj+Ijd/P1WHtjgDfhLFKJ4QIMePU7Xcp1HxhB8R3m X-Received: by 2002:a0c:d981:: with SMTP id y1mr2383888qvj.64.1589552607006; Fri, 15 May 2020 07:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589552607; cv=none; d=google.com; s=arc-20160816; b=qDBKlyYxJQnfDPRfLHlKOnbE9TI8IxKma4O8Pko9pQuCLOTv/IyINOneOgr6n3m/Po +6n7RpUX7brgU+gHyNDcsHyupbuUNJVs6SgsKTXvdBTgFQ2yH69/pF2weLmvaLz1lxwI Rjgal5yM1TOM2clH7K4JROnrLk63nO549eGDW5KNyvJi0XNcPbssw+SkERb+1pkXHhDc y/tT8BlnQByUXDewr+V3pZlXMF8+AIfPRRqmie08ksTnflxG2+D8R7lGz+zJxmRwUMef /cYaaz8gbPr3iQhk5J0mGd9sd5XjxoYbVjwZyZfTSF7AKn1Tt9V8fF3pWRsPA9Jsfjpz d1EA== 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=t3k1YQ3YiPwjNYyBRfLq+hISGgzCVFU8auqRb6w56y0=; b=h0YDlOdW52I5HZpAeOyuHvlLxMSbQII9//VBeeR1aXf87XIhltQGmIDeRTy/YwHQfk e5kB22MJzaGFB7Eni90ntEoON5q+druPrxqu+MdQhV18R7P1Wdv60R+bq9TNBm5UrXr1 +HKkJDM1ku98clICfxTqi0Tck1ty26xrKjevTUSEYQVIz4Tge/4L1sNBjP9J+Kk8eu4P 3J+tWeO7krcaMY5nNPSFjYDuWQ+2lV+lMNjhC5XSACz3rAxcsUgq6iF6BYBACFuj3POT nNSs2B/Wj6syyS8aDQw95unsrFK65I/pK/EAAv8JZblQ14skQGDsat9oOhg+rRZxRL+M c3Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l+QqZYzC; 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 g53si1369669qtc.190.2020.05.15.07.23.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 May 2020 07:23:26 -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=l+QqZYzC; 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]:40782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZbFG-0005NU-G1 for patch@linaro.org; Fri, 15 May 2020 10:23:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZbD4-0000xL-Rc for qemu-devel@nongnu.org; Fri, 15 May 2020 10:21:10 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:39760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jZbD3-0003tW-Eg for qemu-devel@nongnu.org; Fri, 15 May 2020 10:21:10 -0400 Received: by mail-wm1-x332.google.com with SMTP id w64so2855444wmg.4 for ; Fri, 15 May 2020 07:21:09 -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=t3k1YQ3YiPwjNYyBRfLq+hISGgzCVFU8auqRb6w56y0=; b=l+QqZYzCRr4nLEcvxPdjVOcUe+AmZvJMVlwv1eegUJSgpEiV0ddzolUhCwsNp1caIy 4Ggg8u4OQRgHjltGvee35g0Lo2nz2hvcRi6rz5XQKN79KoStIV6UKsdk36FSrxOUYCoe h3X6vHgetEq9HiUcMDm+O4Q+hvWt29bSpkDc9km/3EZGU2sACcLw1EWeEf+xvtY5D+rn JftWx53MtYyzHY7lt+2tQpDpC0rIc40xhZ2/ngPH4kt7bujzxZxsXcGP+e+hoIlkRsGA d4Gm+K29/cmPJsTwVrzVRx/sTGvJXFZedJfFuyo9IkCoOswiOuyZAfmVwPDxsVk/PrCb I7LQ== 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=t3k1YQ3YiPwjNYyBRfLq+hISGgzCVFU8auqRb6w56y0=; b=npqUjLH4aTgPyCh/qyvn4a1Pq8mM00Ujt1yBR32ZSautbGYL29Mena44uot7nkNrHJ fykIswWDt7vimnOIdENPPDH2oovY4yW9QeaCUVaFPQi3bl8/WMf571qZuUeY4dmk0ceF xWsioBA6T82Q0eiQCZjNtHdeYpl1Tfks0wTGeA10mlUk/LtgCYpplUNS/yM9SyIAVgvI yKA0YoLN0Jbhh7INJ0SLtVaqQbVATGLLBoeadmYq1vk3L83VTvmZ3UBh3Qe7dvrs/cS+ 6CnIav5gArWAYdJ1t0D+cvB+2rx2M0/TENhwmbOCxQCAFWd0KE/D4iYYH9Isozz9SuUJ +9hQ== X-Gm-Message-State: AOAM530u1BJDWADwOgn1XwASDTljrmdeg9uP8iKxsP0wFNTx0DjpmSTZ JCairNyWbpB7+gObUpDl8cf2rw== X-Received: by 2002:a1c:dd09:: with SMTP id u9mr4384418wmg.77.1589552467889; Fri, 15 May 2020 07:21:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:21:07 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 08/10] target/arm: Convert Neon VSHLL, VMOVL to decodetree Date: Fri, 15 May 2020 15:20:54 +0100 Message-Id: <20200515142056.21346-9-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::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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 VSHLL and VMOVL insns from the 2-reg-shift group to decodetree. Since the loop always has two passes, we unroll it to avoid the awkward reassignment of one TCGv to another. Signed-off-by: Peter Maydell --- target/arm/neon-dp.decode | 14 ++++++ target/arm/translate-neon.inc.c | 81 +++++++++++++++++++++++++++++++++ target/arm/translate.c | 46 +------------------ 3 files changed, 97 insertions(+), 44 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode index bf4ef8c555f..4438c1c8728 100644 --- a/target/arm/neon-dp.decode +++ b/target/arm/neon-dp.decode @@ -404,3 +404,17 @@ VQRSHRN_U32_2sh 1111 001 1 1 . 01 .... .... 1001 0 . . 1 .... \ @2reg_shift_q1 size=2 shift=%neon_rshift_i4 VQRSHRN_U16_2sh 1111 001 1 1 . 001 ... .... 1001 0 . . 1 .... \ @2reg_shift_q1 size=1 shift=%neon_rshift_i3 + +VSHLL_S_2sh 1111 001 0 1 . 1 shift:5 .... 1010 0 . . 1 .... \ + @2reg_shift_q0 size=2 +VSHLL_S_2sh 1111 001 0 1 . 01 shift:4 .... 1010 0 . . 1 .... \ + @2reg_shift_q0 size=1 +VSHLL_S_2sh 1111 001 0 1 . 001 shift:3 .... 1010 0 . . 1 .... \ + @2reg_shift_q0 size=0 + +VSHLL_U_2sh 1111 001 1 1 . 1 shift:5 .... 1010 0 . . 1 .... \ + @2reg_shift_q0 size=2 +VSHLL_U_2sh 1111 001 1 1 . 01 shift:4 .... 1010 0 . . 1 .... \ + @2reg_shift_q0 size=1 +VSHLL_U_2sh 1111 001 1 1 . 001 shift:3 .... 1010 0 . . 1 .... \ + @2reg_shift_q0 size=0 diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c index 9a75a69a4f5..5678bfd0d4d 100644 --- a/target/arm/translate-neon.inc.c +++ b/target/arm/translate-neon.inc.c @@ -1687,3 +1687,84 @@ DO_2SN_32(VQSHRN_U16, gen_helper_neon_shl_u16, gen_helper_neon_narrow_sat_u8) DO_2SN_64(VQRSHRN_U64, gen_helper_neon_rshl_u64, gen_helper_neon_narrow_sat_u32) DO_2SN_32(VQRSHRN_U32, gen_helper_neon_rshl_u32, gen_helper_neon_narrow_sat_u16) DO_2SN_32(VQRSHRN_U16, gen_helper_neon_rshl_u16, gen_helper_neon_narrow_sat_u8) + +static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, + NeonGenWidenFn *widenfn, bool u) +{ + TCGv_i64 tmp; + TCGv_i32 rm0, rm1; + uint64_t widen_mask = 0; + + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { + return false; + } + + /* UNDEF accesses to D16-D31 if they don't exist. */ + if (!dc_isar_feature(aa32_simd_r32, s) && + ((a->vd | a->vm) & 0x10)) { + return false; + } + + if (a->vd & 1) { + return false; + } + + if (!vfp_access_check(s)) { + return true; + } + + /* + * This is a widen-and-shift operation. The shift is always less + * than the width of the source type, so after widening the input + * vector we can simply shift the whole 64-bit widened register, + * and then clear the potential overflow bits resulting from left + * bits of the narrow input appearing as right bits of the left + * neighbour narrow input. Calculate a mask of bits to clear. + */ + if ((a->shift != 0) && (a->size < 2 || u)) { + int esize = 8 << a->size; + widen_mask = MAKE_64BIT_MASK(0, esize); + widen_mask >>= esize - a->shift; + widen_mask = dup_const(a->size + 1, widen_mask); + } + + rm0 = neon_load_reg(a->vm, 0); + rm1 = neon_load_reg(a->vm, 1); + tmp = tcg_temp_new_i64(); + + widenfn(tmp, rm0); + if (a->shift != 0) { + tcg_gen_shli_i64(tmp, tmp, a->shift); + tcg_gen_andi_i64(tmp, tmp, ~widen_mask); + } + neon_store_reg64(tmp, a->vd); + + widenfn(tmp, rm1); + if (a->shift != 0) { + tcg_gen_shli_i64(tmp, tmp, a->shift); + tcg_gen_andi_i64(tmp, tmp, ~widen_mask); + } + neon_store_reg64(tmp, a->vd + 1); + tcg_temp_free_i64(tmp); + return true; +} + +static bool trans_VSHLL_S_2sh(DisasContext *s, arg_2reg_shift *a) +{ + NeonGenWidenFn *widenfn[] = { + gen_helper_neon_widen_s8, + gen_helper_neon_widen_s16, + tcg_gen_ext_i32_i64, + }; + return do_vshll_2sh(s, a, widenfn[a->size], false); +} + +static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) +{ + NeonGenWidenFn *widenfn[] = { + gen_helper_neon_widen_u8, + gen_helper_neon_widen_u16, + tcg_gen_extu_i32_i64, + }; + return do_vshll_2sh(s, a, widenfn[a->size], true); +} diff --git a/target/arm/translate.c b/target/arm/translate.c index f728231b198..ef39c89f10a 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -5248,6 +5248,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) case 7: /* VQSHL */ case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ case 9: /* VQSHRN, VQRSHRN */ + case 10: /* VSHLL, including VMOVL */ return 1; /* handled by decodetree */ default: break; @@ -5265,50 +5266,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) size--; } shift = (insn >> 16) & ((1 << (3 + size)) - 1); - if (op == 10) { - /* VSHLL, VMOVL */ - if (q || (rd & 1)) { - return 1; - } - tmp = neon_load_reg(rm, 0); - tmp2 = neon_load_reg(rm, 1); - for (pass = 0; pass < 2; pass++) { - if (pass == 1) - tmp = tmp2; - - gen_neon_widen(cpu_V0, tmp, size, u); - - if (shift != 0) { - /* The shift is less than the width of the source - type, so we can just shift the whole register. */ - tcg_gen_shli_i64(cpu_V0, cpu_V0, shift); - /* Widen the result of shift: we need to clear - * the potential overflow bits resulting from - * left bits of the narrow input appearing as - * right bits of left the neighbour narrow - * input. */ - if (size < 2 || !u) { - uint64_t imm64; - if (size == 0) { - imm = (0xffu >> (8 - shift)); - imm |= imm << 16; - } else if (size == 1) { - imm = 0xffff >> (16 - shift); - } else { - /* size == 2 */ - imm = 0xffffffff >> (32 - shift); - } - if (size < 2) { - imm64 = imm | (((uint64_t)imm) << 32); - } else { - imm64 = imm; - } - tcg_gen_andi_i64(cpu_V0, cpu_V0, ~imm64); - } - } - neon_store_reg64(cpu_V0, rd + pass); - } - } else if (op >= 14) { + if (op >= 14) { /* VCVT fixed-point. */ TCGv_ptr fpst; TCGv_i32 shiftv;