From patchwork Thu Oct 11 20:51:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148682 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2601998lji; Thu, 11 Oct 2018 14:01:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV639LxKQmP1MP1dYURwtz8idEiLrPCGizf4NGGcC9/x9FwdcoUOj6NiGgT8sA+j4VOML2ft/ X-Received: by 2002:ac8:444f:: with SMTP id m15-v6mr3284753qtn.289.1539291689646; Thu, 11 Oct 2018 14:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539291689; cv=none; d=google.com; s=arc-20160816; b=RXE1BVv9FOHcfKvYu7zySiM1K8o5ecTEITVWiY3bGF0OyI5brujgofNZHxAn0BcQqh kObF69YeRdSsFLdRJDZHE0NN9fVrUTe0gm8x+6w6wnSCeu1cPkmAJGKIk09GWkG6YO5W bwaJ4MutUpVT+ZLDplbjpDy8AD5PtO8+rPC+mfvECEWaumx2t1rJRGaEyHzdehgWf++W 4V4NXgEfj0fomcnDgE2+/x+XAUB6WFINB3wtQ9FC7fkolebYBbHnLGyjOZF4KYA5+5Wx MiTs0D93HjgycRg+NRinWb9sh7XGnk/H4AGCePfcm2MlUptXfqcVfn3Ke/QQtlP+mDIf h5Ww== 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; bh=UCjLvGDYtuODMoxEmWHRu54PGDreeQMV1QK7QOr2PKo=; b=dORFZTfFqDD8EDpSBh4lV/Z+G/3fPizNMU8Jxthp16mOvbMOgbn5IVwGlhQaPGRTN5 /7QpfBbiNX763lyDYQapNcvwZwJZ59DC2xinMyzRouwtw1AmxSVOkISg5kqqVAYOs1s/ VD3+AM4Fq25A2rfb8k9TGqGK6PLHCWrTJsrR18XNaBw7mlBxw6YpPR9gxtiRt/dQeUOP Pe+tWNCnQIGnzKjxzFS9+qIZG8bT7oJXXUsx4bIXKHu50jI9yCRnL21fzsOGIJ7oQG+8 Y/kgVQ59UyTOaWOPrhe7CfU7SknqTnYDhco8Ls7r0qQWTNmbgKm+N2XI4qdnNKzjKw8/ ez8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NhfVVuNO; 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 t66-v6si1966828qka.63.2018.10.11.14.01.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 11 Oct 2018 14:01:29 -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=NhfVVuNO; 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]:37119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAi5J-0005Dh-2x for patch@linaro.org; Thu, 11 Oct 2018 17:01:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAhwp-0006s3-V7 for qemu-devel@nongnu.org; Thu, 11 Oct 2018 16:52:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAhwl-0005xJ-Og for qemu-devel@nongnu.org; Thu, 11 Oct 2018 16:52:43 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:35778) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gAhwl-0004jE-8Q for qemu-devel@nongnu.org; Thu, 11 Oct 2018 16:52:39 -0400 Received: by mail-pl1-x641.google.com with SMTP id f8-v6so4800498plb.2 for ; Thu, 11 Oct 2018 13:52:27 -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=UCjLvGDYtuODMoxEmWHRu54PGDreeQMV1QK7QOr2PKo=; b=NhfVVuNO8W/bs+fpTtnykRo7kNLA/H6Pb+V4y2/VbyCzgEOWnvXozY0pSYnH1PNa68 +uMpBr7hLsZyB+bH2domJtU3HMD/agR7VekYZX6MeVDA7RX1pveLYGUS7Y0558CP6yum As5ss5Y14SzpOZEcv+xqRs8BeeF9+ssuQkNjo= 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=UCjLvGDYtuODMoxEmWHRu54PGDreeQMV1QK7QOr2PKo=; b=geymNtQ5kYIEWoVI0XJpsNy2w7mKihkonZgN+CJdDAFZeyyPuCsD6a/gFMZyccFKWs MFgqyMm6UFV5zngzf6pMb+ZyFEosnU/d7GgiSExTnvFgx405skNjwGeOQlfiQ9RT1AlM QmFIUVu6ALg6y4va6Jwzl3D42TY3s70d3jpGrG0k0KRkCXrg8T+0u1sgXGEbya+O8aol B1W1zHT09cnFohKUSTKxn+HjlrVt9bz9FavcHWTCRZYITym751J8mKRqe6i/r3EgOJA0 h/XR+s/q1sld6aMjllBR0fWWBEOCkIF8bMu3WrEQnsHSjhb4FSAdrjfozCDNtCTXEXWg awuA== X-Gm-Message-State: ABuFfojrVGmigWbd0UKJUxyACqt8F3OLjEBelZ9GFUByLU9BlTde+FCt 4eKbYkAF8w10vw5r+e7CvCztjkdRa/M= X-Received: by 2002:a17:902:b403:: with SMTP id x3-v6mr3040457plr.237.1539291146556; Thu, 11 Oct 2018 13:52:26 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id h87-v6sm34707866pfj.78.2018.10.11.13.52.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Oct 2018 13:52:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 11 Oct 2018 13:51:58 -0700 Message-Id: <20181011205206.3552-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011205206.3552-1-richard.henderson@linaro.org> References: <20181011205206.3552-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH 12/20] target/arm: Use gvec for VSHR, VSHL 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" Signed-off-by: Richard Henderson --- target/arm/translate.c | 70 +++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index e195efcc55..a16f323d52 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -6373,8 +6373,6 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) size--; } shift = (insn >> 16) & ((1 << (3 + size)) - 1); - /* To avoid excessive duplication of ops we implement shift - by immediate using the variable shift operations. */ if (op < 8) { /* Shift by immediate: VSHR, VSRA, VRSHR, VRSRA, VSRI, VSHL, VQSHL, VQSHLU. */ @@ -6386,37 +6384,62 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) } /* Right shifts are encoded as N - shift, where N is the element size in bits. */ - if (op <= 4) + if (op <= 4) { shift = shift - (1 << (size + 3)); + } + + 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_dup8i(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 5: /* VSHL, VSLI */ + if (!u) { /* VSHL */ + /* Shifts larger than the element size are + * architecturally valid and results in zero. + */ + if (shift >= 8 << size) { + tcg_gen_gvec_dup8i(rd_ofs, vec_size, vec_size, 0); + } else { + tcg_gen_gvec_shli(size, rd_ofs, rm_ofs, shift, + vec_size, vec_size); + } + return 0; + } + break; + } + if (size == 3) { count = q + 1; } else { count = q ? 4: 2; } - switch (size) { - case 0: - imm = (uint8_t) shift; - imm |= imm << 8; - imm |= imm << 16; - break; - case 1: - imm = (uint16_t) shift; - imm |= imm << 16; - break; - case 2: - case 3: - imm = shift; - break; - default: - abort(); - } + + /* To avoid excessive duplication of ops we implement shift + * by immediate using the variable shift operations. + */ + imm = dup_const(size, shift); for (pass = 0; pass < count; pass++) { if (size == 3) { neon_load_reg64(cpu_V0, rm + pass); tcg_gen_movi_i64(cpu_V1, imm); switch (op) { - case 0: /* VSHR */ case 1: /* VSRA */ if (u) gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1); @@ -6447,6 +6470,8 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) cpu_V0, cpu_V1); } break; + default: + g_assert_not_reached(); } if (op == 1 || op == 3) { /* Accumulate. */ @@ -6475,7 +6500,6 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, imm); switch (op) { - case 0: /* VSHR */ case 1: /* VSRA */ GEN_NEON_INTEGER_OP(shl); break; @@ -6513,6 +6537,8 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) case 7: /* VQSHL */ GEN_NEON_INTEGER_OP_ENV(qshl); break; + default: + g_assert_not_reached(); } tcg_temp_free_i32(tmp2);