From patchwork Thu Mar 3 20:59:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 547824 Delivered-To: patch@linaro.org Received: by 2002:ac0:f585:0:0:0:0:0 with SMTP id s5csp983656imq; Thu, 3 Mar 2022 13:10:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkcxUQNR9gg/QAxWUtxiJ/hj3vjL5HPUIugau5FpPK1FJ3pI29uTumSB3fy0lOLuwXL4A1 X-Received: by 2002:a81:1182:0:b0:2dc:4e58:da41 with SMTP id 124-20020a811182000000b002dc4e58da41mr2989536ywr.268.1646341857189; Thu, 03 Mar 2022 13:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646341857; cv=none; d=google.com; s=arc-20160816; b=CnFkTWolH8/i2wjvczIyZaOaG5S2FHXQFyLjKS9XloPmVPeDUeKobbhOfUK0wo+Tf6 I57pp+eQfKa4b5IRFS2V0VXrePLFZ2ULzN5tEVWVj21lMg1yLB8gCUInIIBjime7GjKu glfdwq5pYsAnGJbasXbiOGUvtaLeZrr9TOferYHHmsB1kiNpksiOhnUYsBQ6bQUgQwk6 qWpyR4S7ckolxPX3HLEYWAl8cXWuL0/oFsVnWQ5fr/yeSYDn/Z+ucGtaDI2cHr8MKpeX CDeLerSakc7WmKKOXc5a3LGaV/NbKd355bWpaGqNYlkNfsfOrZFUlVvNz8+6aJktdg5G 1AgA== 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=lmCGsVlVB2Sxn+d9Xto17STB1G1KASx4q7ezK/DByYA=; b=m5GmSEM+5j+aQA/OfY6FPWOp5VB3aXXrjeA/V0CgYiNhhMY9GLIaOcj9Ha+K7yNCGt UJSyr0xt1RO3tpeKwqTbX05HKFr7XTL4twpv2Wxc9gu6nkfrmMThtsCyFZkzaRlxIG08 S84m/wrefimoLV/8Fc0vzctF/eq9dsq6QCNj/CWf7itfCxPPGDzhDTT6S5df6itcOsxZ Ydx8bqcmjNxp65ucNsLDBhw+4pbGYAicuTtUtk8/iGgr4KlWpdkjhleiuNSaeOFpdRYb v8xugK37jPxLcegSYuWqXkmpveOQcvPlE9NpEpEEA5OwrMxgPGW8SB4ZEzJvF3mc51MJ 9Q3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U9VTLjWM; 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 a132-20020a254d8a000000b006241c25c84bsi2479657ybb.503.2022.03.03.13.10.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Mar 2022 13:10:57 -0800 (PST) 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=U9VTLjWM; 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]:53134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPsiu-00081Y-G8 for patch@linaro.org; Thu, 03 Mar 2022 16:10:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPsYL-0005g4-72 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 16:00:01 -0500 Received: from [2607:f8b0:4864:20::630] (port=33656 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPsYJ-00043l-H5 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 16:00:00 -0500 Received: by mail-pl1-x630.google.com with SMTP id c9so5907696pll.0 for ; Thu, 03 Mar 2022 12:59:59 -0800 (PST) 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=lmCGsVlVB2Sxn+d9Xto17STB1G1KASx4q7ezK/DByYA=; b=U9VTLjWMzIC9TiXpbhZYmxOEJA3DIu0hl1q9ZiAVagoqxxxdvqjyHhesVJasb7JWXj P6klqKSXUcgcdD0X6Do+W9BtIJkndGiGQ8BCAm3dHJylExjCRqTyGDvuOHsF4iPXOwWJ ca0HhALc47DJJqFFABZknjFVGtyJYtjlX8+0s98iRWSbtCQ+zqIey8F/xs8o4nuO3Xj0 gO62ofLVJ1JeDFOrs9D4uIotqCaRkEQEQtZ+jbVr/MeFDkJR4RtV2SFoFMQqrBKC+/P4 szQU8E1SfDbGxfwwS1KrTrTwvrW6A0dNio84v5iH7CLTj01y1geBTd6vhAigM7teObX9 hEpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lmCGsVlVB2Sxn+d9Xto17STB1G1KASx4q7ezK/DByYA=; b=ovP9UFA9ZCO8U4sejUi5wDMBVv5LPHjhwYdQk2zORgA9aj7aB0sbSQhPaZ3ZpvqVUt 43hUW4dtMUG01zFZUQuXt5A6OJ6VbEDli1Ayqw6PuC2XzWDoZCck2qUioQMRor3K0cLS qE0M/Qu6TDCd27voQWnHEFdggd2x/5DxxmJFPTz9qMhiRIjbEAcNv6/kZDl/fKQKqHG9 zzXDBC2NazIH8ASkIeR88FLo5+BN6b0UyFKYIYT/w1MGRXN8WJAVW6/fQaoYhKh4NpOa +N1JfWRuBkdrTCOlyfaTp7edK5Y3yzvJfcT6PTKmWjU2OrKkvebMFcCu7cK1XXn6jQzY mrkw== X-Gm-Message-State: AOAM531sEV64aU5z0w8TBoQtpjIVv+F/4/+yMBTn59YzdAT00rb5umqD woS6qbKV4BLjsb+RlVWNfW9rxhnGzi42hQ== X-Received: by 2002:a17:902:e541:b0:151:8722:5a87 with SMTP id n1-20020a170902e54100b0015187225a87mr14173904plf.71.1646341198227; Thu, 03 Mar 2022 12:59:58 -0800 (PST) Received: from localhost.localdomain (2603-800c-1201-c600-119c-490c-a4ee-08e8.res6.spectrum.com. [2603:800c:1201:c600:119c:490c:a4ee:8e8]) by smtp.gmail.com with ESMTPSA id t8-20020a6549c8000000b00372eb3a7fb3sm2729934pgs.92.2022.03.03.12.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 12:59:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/30] tcg/i386: Add tcg_out_evex_opc Date: Thu, 3 Mar 2022 10:59:21 -1000 Message-Id: <20220303205944.469445-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303205944.469445-1-richard.henderson@linaro.org> References: <20220303205944.469445-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::630 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The evex encoding is added here, for use in a subsequent patch. Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 51 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 7516be5d5f..89497b2b45 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -262,6 +262,7 @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) #define P_SIMDF3 0x20000 /* 0xf3 opcode prefix */ #define P_SIMDF2 0x40000 /* 0xf2 opcode prefix */ #define P_VEXL 0x80000 /* Set VEX.L = 1 */ +#define P_EVEX 0x100000 /* Requires EVEX encoding */ #define OPC_ARITH_EvIz (0x81) #define OPC_ARITH_EvIb (0x83) @@ -626,9 +627,57 @@ static void tcg_out_vex_opc(TCGContext *s, int opc, int r, int v, tcg_out8(s, opc); } +static void tcg_out_evex_opc(TCGContext *s, int opc, int r, int v, + int rm, int index) +{ + /* The entire 4-byte evex prefix; with R' and V' set. */ + uint32_t p = 0x08041062; + int mm, pp; + + tcg_debug_assert(have_avx512vl); + + /* EVEX.mm */ + if (opc & P_EXT3A) { + mm = 3; + } else if (opc & P_EXT38) { + mm = 2; + } else if (opc & P_EXT) { + mm = 1; + } else { + g_assert_not_reached(); + } + + /* EVEX.pp */ + if (opc & P_DATA16) { + pp = 1; /* 0x66 */ + } else if (opc & P_SIMDF3) { + pp = 2; /* 0xf3 */ + } else if (opc & P_SIMDF2) { + pp = 3; /* 0xf2 */ + } else { + pp = 0; + } + + p = deposit32(p, 8, 2, mm); + p = deposit32(p, 13, 1, (rm & 8) == 0); /* EVEX.RXB.B */ + p = deposit32(p, 14, 1, (index & 8) == 0); /* EVEX.RXB.X */ + p = deposit32(p, 15, 1, (r & 8) == 0); /* EVEX.RXB.R */ + p = deposit32(p, 16, 2, pp); + p = deposit32(p, 19, 4, ~v); + p = deposit32(p, 23, 1, (opc & P_VEXW) != 0); + p = deposit32(p, 29, 2, (opc & P_VEXL) != 0); + + tcg_out32(s, p); + tcg_out8(s, opc); +} + static void tcg_out_vex_modrm(TCGContext *s, int opc, int r, int v, int rm) { - tcg_out_vex_opc(s, opc, r, v, rm, 0); + if (opc & P_EVEX) { + tcg_out_evex_opc(s, opc, r, v, rm, 0); + } else { + tcg_out_vex_opc(s, opc, r, v, rm, 0); + } tcg_out8(s, 0xc0 | (LOWREGMASK(r) << 3) | LOWREGMASK(rm)); }