From patchwork Sat May 4 05:52:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163370 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp257130ill; Fri, 3 May 2019 23:12:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqz67Wx2x7wgvbqWJGYl4vh1DvJGBnlWJfOtguJre/QMJlZCiqC2G5HzzT+UPkeEKND3pZzh X-Received: by 2002:a65:5342:: with SMTP id w2mr16014255pgr.220.1556950357114; Fri, 03 May 2019 23:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556950357; cv=none; d=google.com; s=arc-20160816; b=dUZBx4AQrHa2RnCngIq19Z8Js8Zgl2y+ExZIeet8f9neOC1zMAxQjEtVFd32t7xT3Z +vxzKmG13OO8YxaVjmo40sxjSTaygFt5m8Kpihv4bYTZVh57dDr+9go/KZ48UwFhp636 vROm4vT0Iw+H8azFSt8x3PbVDyJJR7igWqDF6Iuidpv3/NER1ErwIXnqUtB4D7dtT/wD R43nePR4tN+9cPuaKTFof3Ldr+XGJ6SpJWYp6p2KZ8bpSp3L4qvxltPGLiBiwUlCFicB EprN10sGwV76LvpYPXdEd+zeKJNFLkZS0QKQmkwvXscb46lQKB/QV8QtvrHEHoaMSfA8 9SzQ== 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=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=uTipNZcUpO9mHouuZq1rjcpI/Z0+t8HWcNfdPQgKpyqt1Vubxvi7yJgiZLDfWHC1eQ IC3kuRgeosTaQk0FnJOKbNcB0eGl1tNngNB1AA2fs4ixjQvSATePLW/AfZz5YUc/dtAn RoSyZlNdX3tNO9NGbUBxsRm2vzAdpiazGXYYow61jgs4PmBsV5WQP8SF9TQ/C2lBfjAX a5KI8+492+WRfdWl4AJAEcINR3FgetHhXKYryYToLNixXGnHbwmSPcppcbSOFvOC33os qY4qtmQxDc8bDaTabcg7qZIY0UnzTn0YH7jWeWsQyOtchxoByp9fj7MctMddkign193X 4Nhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XV1nax+F; 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 be1si5530570plb.286.2019.05.03.23.12.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 03 May 2019 23:12:37 -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=XV1nax+F; 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]:51878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMnu8-0007rB-Ta for patch@linaro.org; Sat, 04 May 2019 02:12:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMnbw-0007sU-6u for qemu-devel@nongnu.org; Sat, 04 May 2019 01:53:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hMnbv-0004L5-1z for qemu-devel@nongnu.org; Sat, 04 May 2019 01:53:24 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:38961) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hMnbu-0004Kp-SM for qemu-devel@nongnu.org; Sat, 04 May 2019 01:53:22 -0400 Received: by mail-pl1-x62d.google.com with SMTP id e92so3730923plb.6 for ; Fri, 03 May 2019 22:53:22 -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=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=XV1nax+FMF84Szf8k89MeWYtZmaWr9uyOFZZ9IuYA1+nkqwnpUFkELNoXVbj2kduCt qmppro2+SFBMwaoFbyrUKZOmR7gRmVxfhYEcb3y4p1y2FRUnVffgXct0X90ljFi8BtVw SNBpCp0bzft70F70CCRZfLvKLIstPrS2IU0F1bje8CYkuoHl/m5GzVMhDq63Y+JZm22o RBBuHVrueq8e+CM1tNSmlvBrw+nJXs7ygvY1Sy+phTCceINesoZpNckTrEZiZ0OwVHrA MRyPiJXe2CBOqydbceXWrymy0gYk+DIodFtjLrJtZIzK/w13q9ihpmBdWGmSdc/4C+qM E1ig== 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=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=WRme8G9oG3mZge4DJv+7ShPzaRsBjv+5Wes46NDZpRd5EoBMHJJ/O1HNSg7VEyBjRB DE+V6nf9EGSAdu46ZZCK8/i0IeSTGJhAgLo6ZjiI18n75XzpR15ccqAUoqYl8IcRxUmW en4nd6Pu1m3LBFbVqXfatSlCgOVhwfPSyOKVqjUCCasjuVpcbGaCkR+4jWnb1gl0fI+J cbn2JpLTzAF9d207ST5JYPOO99tHl89qTIvZ+4rMwaWDnuVeujfSOqRTpcmcBiahqP+u aPhyVhzqzm5NqE1VOb6qxXO2q9rvErZDqNHvLpJUJH5iu0A81CJ4L5HF1LfnLIvFxHSo Kn1g== X-Gm-Message-State: APjAAAU7+qajZ7KFkasrMXtqQ3F7jWkNye8RI1XCcXtjygFvdi6bROua 0GYxxVn10nPd/mCbdJwU/9I8+lsYhcs= X-Received: by 2002:a17:902:2702:: with SMTP id c2mr15980098plb.277.1556949201625; Fri, 03 May 2019 22:53:21 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id 15sm6680423pfo.117.2019.05.03.22.53.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 22:53:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 3 May 2019 22:52:45 -0700 Message-Id: <20190504055300.18426-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190504055300.18426-1-richard.henderson@linaro.org> References: <20190504055300.18426-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::62d Subject: [Qemu-devel] [PATCH v3 16/31] 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: , Cc: alex.bennee@linaro.org, david@redhat.com 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. */