From patchwork Sat Apr 20 07:34:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 162563 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp304151jan; Sat, 20 Apr 2019 00:46:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4o0FLewXsxLMDuSjSxJRTm32pNTc7yEFQK64fyu6UjBHln/tIBix7Hml//AIB61XWR3Q2 X-Received: by 2002:a1c:9ec7:: with SMTP id h190mr5511408wme.105.1555746361442; Sat, 20 Apr 2019 00:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555746361; cv=none; d=google.com; s=arc-20160816; b=uxwtKv5ab94QY1Ou4zue7hkxMAo+loc+XR4CY/1LsYz4gCbHYpxpDsMKhiHwzLA0Aw 11OE7uQ4Pv7SV+MsEbu50gK/WTUAJPL8Cx/dVMSACzDAe1fxJyAoAVzpIxFxLznYRuYX sHtgSW6Ok/PrRunPNjCBgJIQI7IhEbNyZSFkgbarMfXUfR5TDYFw/otZ6Yq4s1T+TOsR +b1MCOAegcgkIocuEzDRJ1p+ZRg7yEhIEvvMtIdkuSZOTFm+9VISEbdse1UWTZdo4dEY XQfuxhdxJz1HgzluBnRVcez85CGm1V6QI8SlvK/SPh2q+6UEnUMyVUE81FGwaMFagWeY grNQ== 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=gN4B/Stb2lbgTIviKYPnpm58ErCGyH4cO3TJuIucX7A=; b=ltWSjSLBb4rvd0wi+5xdkufqeUtLnsRwSYwABkbhFiyzIo7CnweLG8Q5GSz7ICbKmy xJG2HXeTeVGfLzVAfQ+r7XlNXAfLKe9Fu4y00Aa5v3Bbuyq9kh1qO5SmFLuz8B3/mjgM 28u4I9k/bChZmGu9feyvoPquWlAfgmp4AqKX4uvxa0ZjbIxN5l5y0jN9E4lc7sQSArED nEC8eH1EVPRCi5yt9FsDaGIONIuBmIPOUzEvbnGcvltM5HmkqmYcitO2xTqKtBkx2K2g rec5lE1biErP+eA8KadgyZm13qVXCO6bdfPUIxWygp96hVHefDNgwDNLzGucixE6NPc7 815A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a2Fa43b5; 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 e2si3221591wrw.324.2019.04.20.00.46.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 20 Apr 2019 00:46:01 -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=a2Fa43b5; 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]:38225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHkhE-0001dX-AZ for patch@linaro.org; Sat, 20 Apr 2019 03:46:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHkWc-0008Up-SI for qemu-devel@nongnu.org; Sat, 20 Apr 2019 03:35:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHkWb-0007wj-LX for qemu-devel@nongnu.org; Sat, 20 Apr 2019 03:35:02 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:38049) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hHkWb-0007ud-EZ for qemu-devel@nongnu.org; Sat, 20 Apr 2019 03:35:01 -0400 Received: by mail-pf1-x442.google.com with SMTP id 10so3468870pfo.5 for ; Sat, 20 Apr 2019 00:35:01 -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=gN4B/Stb2lbgTIviKYPnpm58ErCGyH4cO3TJuIucX7A=; b=a2Fa43b5mKhdlmgzqumM14WhxwTkr7Duf/AZDdGRGE/bEwnGliZSOVhwrLWiwVquLL +fpLjlHf+T90QfrG6VpgMKC3RogA6sWXkDziwWQUgeZ/UcEEHgRR1eaHyzX8FcP38lp+ fg03cDQvKS8iBfXtMi/hkDXz317yNWj0CJcmegsOQJek+l2tGKJBZGuh1WtwXzqJ2Nuw jZBWCQ/lnHB7ykrQRHRyvqxlvqE5Y16kuU1bElMaSx3J4VrBl8/ZY9o5TJqkOTQU9mio d1Sg7b+ZQ58qApKBYnGMmA9yZb1Ndy3Jerc2bGBE6Z3AUyiw+/6OTFfgApqt7gsUU9Ta xq/A== 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=gN4B/Stb2lbgTIviKYPnpm58ErCGyH4cO3TJuIucX7A=; b=CroBBuQ73F6/Fl3bIWEgLA4iFAN9iYCGJh/VlIX7/rH8Luf1Jp+S64BC98IOcJYvwI 4hrGMhur1ZJA/4jZwUnj50xFPIVkLV1r+zgBtFyQDpe2b04A2tXfCENTfTGtmuTGaXjX 4e2InHSf3dGUewrnJmOEhDjB2fQjSaPHkelLkhKB53XFVvcs/lKcdNJlbcbF65KHXHQs e6yjvQq6YpQQWhL3aLBimIFw8xcq5fh3q2zUUcS6dqmcQrBnijb5NmOkYuOEGO+aZ+rr xnszC7nGuzb8S9Qf05JbXSvoxodbNGudc2T/I66ICvsHrS3icoHOm8fFS7hRy91dZlFd wyDA== X-Gm-Message-State: APjAAAXYn1fe5wQOLIpXjy/4I6KdjTj6erOLeh7Ewksqrt05RPSbP3WD 8vS4bH2pDJiCbbMhryWjfLno9oF2aO0= X-Received: by 2002:a63:6f0a:: with SMTP id k10mr8017418pgc.78.1555745700138; Sat, 20 Apr 2019 00:35:00 -0700 (PDT) Received: from localhost.localdomain (rrcs-66-91-136-155.west.biz.rr.com. [66.91.136.155]) by smtp.gmail.com with ESMTPSA id z22sm7025492pgv.23.2019.04.20.00.34.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Apr 2019 00:34:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 19 Apr 2019 21:34:13 -1000 Message-Id: <20190420073442.7488-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190420073442.7488-1-richard.henderson@linaro.org> References: <20190420073442.7488-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::442 Subject: [Qemu-devel] [PATCH 09/38] tcg/i386: Implement tcg_out_dupm_vec 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: david@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At the same time, improve tcg_out_dupi_vec wrt broadcast from the constant pool. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.inc.c | 57 +++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 0be7d8f589..fcabc1bdf2 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -358,7 +358,6 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_MOVBE_MyGy (0xf1 | P_EXT38) #define OPC_MOVD_VyEy (0x6e | P_EXT | P_DATA16) #define OPC_MOVD_EyVy (0x7e | P_EXT | P_DATA16) -#define OPC_MOVDDUP (0x12 | P_EXT | P_SIMDF2) #define OPC_MOVDQA_VxWx (0x6f | P_EXT | P_DATA16) #define OPC_MOVDQA_WxVx (0x7f | P_EXT | P_DATA16) #define OPC_MOVDQU_VxWx (0x6f | P_EXT | P_SIMDF3) @@ -458,6 +457,10 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_UD2 (0x0b | P_EXT) #define OPC_VPBLENDD (0x02 | P_EXT3A | P_DATA16) #define OPC_VPBLENDVB (0x4c | P_EXT3A | P_DATA16) +#define OPC_VPINSRB (0x20 | P_EXT3A | P_DATA16) +#define OPC_VPINSRW (0xc4 | P_EXT | P_DATA16) +#define OPC_VBROADCASTSS (0x18 | P_EXT38 | P_DATA16) +#define OPC_VBROADCASTSD (0x19 | P_EXT38 | P_DATA16) #define OPC_VPBROADCASTB (0x78 | P_EXT38 | P_DATA16) #define OPC_VPBROADCASTW (0x79 | P_EXT38 | P_DATA16) #define OPC_VPBROADCASTD (0x58 | P_EXT38 | P_DATA16) @@ -855,16 +858,17 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) return true; } +static const int avx2_dup_insn[4] = { + OPC_VPBROADCASTB, OPC_VPBROADCASTW, + OPC_VPBROADCASTD, OPC_VPBROADCASTQ, +}; + static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg r, TCGReg a) { if (have_avx2) { - static const int dup_insn[4] = { - OPC_VPBROADCASTB, OPC_VPBROADCASTW, - OPC_VPBROADCASTD, OPC_VPBROADCASTQ, - }; int vex_l = (type == TCG_TYPE_V256 ? P_VEXL : 0); - tcg_out_vex_modrm(s, dup_insn[vece] + vex_l, r, 0, a); + tcg_out_vex_modrm(s, avx2_dup_insn[vece] + vex_l, r, 0, a); } else { switch (vece) { case MO_8: @@ -894,10 +898,35 @@ static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg r, TCGReg base, intptr_t offset) { - return false; + if (have_avx2) { + int vex_l = (type == TCG_TYPE_V256 ? P_VEXL : 0); + tcg_out_vex_modrm_offset(s, avx2_dup_insn[vece] + vex_l, + r, 0, base, offset); + } else { + switch (vece) { + case MO_64: + tcg_out_vex_modrm_offset(s, OPC_VBROADCASTSD, r, 0, base, offset); + break; + case MO_32: + tcg_out_vex_modrm_offset(s, OPC_VBROADCASTSS, r, 0, base, offset); + break; + case MO_16: + tcg_out_vex_modrm_offset(s, OPC_VPINSRW, r, r, base, offset); + tcg_out8(s, 0); /* imm8 */ + tcg_out_dup_vec(s, type, vece, r, r); + break; + case MO_8: + tcg_out_vex_modrm_offset(s, OPC_VPINSRB, r, r, base, offset); + tcg_out8(s, 0); /* imm8 */ + tcg_out_dup_vec(s, type, vece, r, r); + break; + default: + g_assert_not_reached(); + } + } + return true; } - static void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { @@ -918,16 +947,16 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, } else if (have_avx2) { tcg_out_vex_modrm_pool(s, OPC_VPBROADCASTQ + vex_l, ret); } else { - tcg_out_vex_modrm_pool(s, OPC_MOVDDUP, ret); + tcg_out_vex_modrm_pool(s, OPC_VBROADCASTSD, ret); } new_pool_label(s, arg, R_386_PC32, s->code_ptr - 4, -4); - } else if (have_avx2) { - tcg_out_vex_modrm_pool(s, OPC_VPBROADCASTD + vex_l, ret); - new_pool_label(s, arg, R_386_32, s->code_ptr - 4, 0); } else { - tcg_out_vex_modrm_pool(s, OPC_MOVD_VyEy, ret); + if (have_avx2) { + tcg_out_vex_modrm_pool(s, OPC_VBROADCASTSD + vex_l, ret); + } else { + tcg_out_vex_modrm_pool(s, OPC_VBROADCASTSS, ret); + } new_pool_label(s, arg, R_386_32, s->code_ptr - 4, 0); - tcg_out_dup_vec(s, type, MO_32, ret, ret); } }