From patchwork Wed May 1 05:05:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163199 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4131345ill; Tue, 30 Apr 2019 22:22:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9zpoJSEkgDSRL/BRoAXCDsl8WquEAx5++1atV7yrbpEB8z7DnQPkJXAYNhLEiQDSsHlXY X-Received: by 2002:a1c:2743:: with SMTP id n64mr5265254wmn.19.1556688145721; Tue, 30 Apr 2019 22:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688145; cv=none; d=google.com; s=arc-20160816; b=AlVAX/LXfUPAEG4aTubhza/Hek8aw0jham1GaZcE0LGccqUHLSmQMpEYJ1+zX5KyG2 ukZ0gU3mRZ/dnUoU6VWoKqsds7LnfQcd2OF4oZ00wqgsIx2n9ARXwWzS3NC8aBMQXsrM +2nBpAczLRGg3ehpc7jV+R/XtR8iWYumy4owLjOOi+2n0mT43YViIQF6I0BafJs/ppK3 IMPncGmzAPjTd98o54SwXtzv3r/W3fmCPTIRljdzP37YPsVX2rIHLbJuGi4b7uK16iEG Up1saZgcH0BhlLzlStOOeGmGfctbr/Oz0QCOg/AGL4IJyBF49Vw/ZAtANCYXcIFZce4F u3ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=kpdZPEGFDPzcK//Rzbiw5kG5qwfHiaI/mNPJPTUoA9CUYzkeot8cDVagX7A+GSpbwE vLJwFzkVT8Jw4V+eSfBoYzIPDARNUyLekZLd4mQMQRIFJmuFB3aDJtjRgmvM6t+fg0Nj FnftPNa2Gnp948qq9XDsUFGrToOm86bkFEeaPBeejC69lvqxOY+6ZeGLa0wZfsVo8QWT Etiwnp4ttBHI8L1faZBnsp3J8qU7nFMGDprAIYfpXkJCkpFrP2ZA4CLmVq+lB3o4rqvd qhk4uImF+S3qgzeeeK3p30efrjOe2a/bstaPTVkDR+K4cdayHzEb1W0GRFuGZBYl2VOW KncQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oPNiRrYe; 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=fail (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 r126si2775206wmf.153.2019.04.30.22.22.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:22:25 -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=fail header.i=@linaro.org header.s=google header.b=oPNiRrYe; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:36449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhhI-0003BE-Ks for patch@linaro.org; Wed, 01 May 2019 01:22:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRZ-0006YI-BL for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRV-0002wU-KD for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:09 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:44318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRT-0002vP-Sx for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:04 -0400 Received: by mail-pf1-x42e.google.com with SMTP id y13so8131579pfm.11 for ; Tue, 30 Apr 2019 22:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=oPNiRrYepa1vkZOy7NCmvfNcxpTTnVUmlpKjD2CacgHuC9+F+niucdvnZ3N2/0ZjHk CghQkki3jy2DoEtb3fWj3YVUAUp1jA7ribj/+Em07+WtvuPSVFT5lGI4hABQa75YZ6G3 40D3E3+P9X3KBbzAilzXRIYB9FlBVuotbWITASbDv8avwp+RgdWcG0XJvQ9r/2n+NFM5 JgpV9HY52FVtbO3km4/PqgRHQahDv+qOIC4aWepTZWCcsEWmezFCF8l01VPcR7Fg7ZQN aNnr9DHnVnF7sp5ZvjtKyCXgtR/kBK46whbk6r3vGQeIOfdBvH7Xh1OCr2REP+8yXsSR LrAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=IH0yGM0X8OFePJf//QZRaaF98WXRxA664Lfnrg5U4D/FycjmfIedZEmU44EJcLtpwY pmoC83FUZfBHnzwqdJYiJdgzYChBL37omLsHjb82aJ3rs+FxSQaVR5GkclzFKTWhZt1a sg1Q4f9MUHmPQYh7r8uAvW2z6wOu9pYU4TYniFP9aQZUDrNjoRMVkAiR4CjcfiNx1oG0 //l++Elrq0IqHILdcvkugiM1UPeE6uAx3TUpSiTpne6lgi/ZT9eUAW5sO+msoRPR0zvF U1DqM3ZsTgloYOTtjOAyJnHtPakWnZbmUiEqQB6bQSjFv6ldJcCjVn2ucU0YIX93EubF BcrA== X-Gm-Message-State: APjAAAUdXc5un+X9kaZf7frIXN+zSIReHRujJZSWItmaep+zjcDxnOMT Brjj2KvaCXIYrDQiFgBiocFXisAbriY= X-Received: by 2002:a63:ff05:: with SMTP id k5mr59148047pgi.342.1556687162256; Tue, 30 Apr 2019 22:06:02 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:22 -0700 Message-Id: <20190501050536.15580-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-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::42e Subject: [Qemu-devel] [PATCH v2 15/29] tcg/i386: Support vector variable shift opcodes 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.inc.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 241bf19413..b240633455 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -184,7 +184,7 @@ extern bool have_avx2; #define TCG_TARGET_HAS_neg_vec 0 #define TCG_TARGET_HAS_shi_vec 1 #define TCG_TARGET_HAS_shs_vec 0 -#define TCG_TARGET_HAS_shv_vec 0 +#define TCG_TARGET_HAS_shv_vec have_avx2 #define TCG_TARGET_HAS_cmp_vec 1 #define TCG_TARGET_HAS_mul_vec 1 #define TCG_TARGET_HAS_sat_vec 1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 5b33bbd99b..c9448b6d84 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -467,6 +467,11 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_VPBROADCASTQ (0x59 | P_EXT38 | P_DATA16) #define OPC_VPERMQ (0x00 | P_EXT3A | P_DATA16 | P_REXW) #define OPC_VPERM2I128 (0x46 | P_EXT3A | P_DATA16 | P_VEXL) +#define OPC_VPSLLVD (0x47 | P_EXT38 | P_DATA16) +#define OPC_VPSLLVQ (0x47 | P_EXT38 | P_DATA16 | P_REXW) +#define OPC_VPSRAVD (0x46 | P_EXT38 | P_DATA16) +#define OPC_VPSRLVD (0x45 | P_EXT38 | P_DATA16) +#define OPC_VPSRLVQ (0x45 | P_EXT38 | P_DATA16 | P_REXW) #define OPC_VZEROUPPER (0x77 | P_EXT) #define OPC_XCHG_ax_r32 (0x90) @@ -2707,6 +2712,18 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, static int const umax_insn[4] = { OPC_PMAXUB, OPC_PMAXUW, OPC_PMAXUD, OPC_UD2 }; + static int const shlv_insn[4] = { + /* TODO: AVX512 adds support for MO_16. */ + OPC_UD2, OPC_UD2, OPC_VPSLLVD, OPC_VPSLLVQ + }; + static int const shrv_insn[4] = { + /* TODO: AVX512 adds support for MO_16. */ + OPC_UD2, OPC_UD2, OPC_VPSRLVD, OPC_VPSRLVQ + }; + static int const sarv_insn[4] = { + /* TODO: AVX512 adds support for MO_16, MO_64. */ + OPC_UD2, OPC_UD2, OPC_VPSRAVD, OPC_UD2 + }; TCGType type = vecl + TCG_TYPE_V64; int insn, sub; @@ -2759,6 +2776,15 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_umax_vec: insn = umax_insn[vece]; goto gen_simd; + case INDEX_op_shlv_vec: + insn = shlv_insn[vece]; + goto gen_simd; + case INDEX_op_shrv_vec: + insn = shrv_insn[vece]; + goto gen_simd; + case INDEX_op_sarv_vec: + insn = sarv_insn[vece]; + goto gen_simd; case INDEX_op_x86_punpckl_vec: insn = punpckl_insn[vece]; goto gen_simd; @@ -3136,6 +3162,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_umin_vec: case INDEX_op_smax_vec: case INDEX_op_umax_vec: + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + case INDEX_op_sarv_vec: case INDEX_op_cmp_vec: case INDEX_op_x86_shufps_vec: case INDEX_op_x86_blend_vec: @@ -3193,6 +3222,12 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) } return 1; + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + return have_avx2 && vece >= MO_32; + case INDEX_op_sarv_vec: + return have_avx2 && vece == MO_32; + case INDEX_op_mul_vec: if (vece == MO_8) { /* We can expand the operation for MO_8. */