From patchwork Tue Mar 19 17:21:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160589 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4133780jad; Tue, 19 Mar 2019 10:21:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQd0HYKFkMPTfpngL6oKIkE5g+JDPLk5gjykylLHutS6SxkksYSaGTPNLbm+NKT+ST1SaO X-Received: by 2002:a1c:f70f:: with SMTP id v15mr4478724wmh.86.1553016117890; Tue, 19 Mar 2019 10:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016117; cv=none; d=google.com; s=arc-20160816; b=tPYj1y9AP/cpgyuamMc8iUZgsd3uqx0Z9IVIppP79dQSe4Ek5opBUMCwDfQUi0Aste O7KfV0VBZgE5v1J1DIMJgANHCelFGXwHMdogIyw04mUTgKPhyqczA0CegJdtpfaWBTYG e5U7Ckb3wseZIExbQX5dGHaPAhkz0tFcwNbOeyVxMxIvDmSlugoqEi/RDXCbchCuEy/u UV/3E2AhDPyrPXdL8uRGK9ddwmukk91UJHDmM2ceruaVXRy8M+fk/I9Me8fHo6PNe9e/ UswBIyxIM7iYGuYk13Brb2d3cWaa/hInA2mdD2A5jF57HWZaDZclYuHptIIuZ5cCu6er V99g== 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=jmuyYwVXW/xQ7qX84YnbpLmhrhQYqlDYF9YCOZY12zU=; b=IMlkAflOFM5iXfEUsKesVxvidkJWo46jGKGmc+R0LWJ5C/HkN8ypALdzmA6SpSGmpq PRU5LHodLQIXja0WB/bZS9P5b/ZkfNW+3XQnc51lCz1uymUR4QyECJNWfiEnJSqkx/Rb N1TE1+SIlJXMzXSr1qgfyYsc3ES47tKmhz+crOCtrGNzhXF+V0HcLvvvwAqXdhTxaNJw xaQxAO4MvCkPfZ24cGhiyM6mZ9qJRgfZfnEN4Tbzu8xWpf8wtHY0mGrGw0jXzcDp+KRz FoMxcDmMMHJrcLHHBAo82J404hXN5YrhpPydYuMcp6nPHDL3LXHSD9qqPVyvPsuLbjH6 g32g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Uhq+lf3i; 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 v18si9037150wru.448.2019.03.19.10.21.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:21:57 -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=Uhq+lf3i; 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]:60659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IR2-0004Y5-QA for patch@linaro.org; Tue, 19 Mar 2019 13:21:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQe-0004XF-Sq for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQe-0004QB-5w for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:32 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:38121) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQd-0004PW-QL for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:32 -0400 Received: by mail-pf1-x441.google.com with SMTP id n125so14163128pfn.5 for ; Tue, 19 Mar 2019 10:21:31 -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=jmuyYwVXW/xQ7qX84YnbpLmhrhQYqlDYF9YCOZY12zU=; b=Uhq+lf3iNMXtUhqj0Sl5OEiXWHtzGwN4d8RsWrmTMEwlkYSt9uiG40yjNRx//wk+uW BkW+2kgJ60NmTe254KS0pj6aUu14M8qNSZNa2G349IsKluPf56hQ4gW+V8xbDr9vjJgo 6GC1r6gIh3NUeVkmOeEETHh0l8RpUGEX3PFMP+7btp+Cs9yqMettR3iv7JOts5HSF4cp tTPzvaiD3lyLYkjfpxsCH4C4z3Vxqbeuk9mvyyNZd1mGFUGPr17EaeoZaRLnNn/f0OON n9DLaWtY7qEoc51dyRat08o9u+c9Ejy+GWgapPmMQO66sl9uEctkdhg9iBNSIYMVPY33 7qCg== 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=jmuyYwVXW/xQ7qX84YnbpLmhrhQYqlDYF9YCOZY12zU=; b=W80MCA3njRR3rKKynGMAHx/VsBCfCrXPzGdrixjKcBQm3LeRdcFu90Lz0WIJteJB4m Ewm09LldW1z/N4sZZuVOnf8EarNR2I7QskL+K2bLG5c3zIUoQDEigS6QruRTcWoi7DS6 0MGSQLrZX+YbvTpKHiS6//VU1f2nkgvT1KeZyL0IMPa5CgLZpj4xWu1SXLBlbwP5XKrg pDuiLB4KkX/0AdCS6sD/ehni2OYJ9nltt31d9hZvbMRULfHZOb021MdPhjW2DHdUAA60 pw42ZqeL2G2udfHwctHSAIOitLVrUWr2iVJS+8QILc4egZBPP9zpVol6UwjLYo+LUJNg t3yg== X-Gm-Message-State: APjAAAVqkGF01mH1g31MFCwLx9fscMgPGhA/hElAWYb7d2MabBmBK1RG ZfWsL7h6dgXxgfaQ7lWL3b/oKyx288s= X-Received: by 2002:a63:f412:: with SMTP id g18mr2860037pgi.444.1553016090503; Tue, 19 Mar 2019 10:21:30 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:10 -0700 Message-Id: <20190319172126.7502-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::441 Subject: [Qemu-devel] [PATCH for-4.1 v3 01/17] target/arm: Fill in .opc for cmtst_op 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows us to fall back to integers if the tcg backend does not support comparisons in the given vece. Signed-off-by: Richard Henderson --- target/arm/translate.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.17.2 diff --git a/target/arm/translate.c b/target/arm/translate.c index d408e4d7ef..13e2dc6562 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -6140,16 +6140,20 @@ static void gen_cmtst_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) const GVecGen3 cmtst_op[4] = { { .fni4 = gen_helper_neon_tst_u8, .fniv = gen_cmtst_vec, + .opc = INDEX_op_cmp_vec, .vece = MO_8 }, { .fni4 = gen_helper_neon_tst_u16, .fniv = gen_cmtst_vec, + .opc = INDEX_op_cmp_vec, .vece = MO_16 }, { .fni4 = gen_cmtst_i32, .fniv = gen_cmtst_vec, + .opc = INDEX_op_cmp_vec, .vece = MO_32 }, { .fni8 = gen_cmtst_i64, .fniv = gen_cmtst_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, + .opc = INDEX_op_cmp_vec, .vece = MO_64 }, }; From patchwork Tue Mar 19 17:21:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160592 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4136520jad; Tue, 19 Mar 2019 10:24:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8BvaJjLtIZVR1lKY/iGrUi+LaVNl5Xp3Gk7w13UUDpsEkMBkhE170jQKnQFvBTFb/9pM7 X-Received: by 2002:a1c:e185:: with SMTP id y127mr3336775wmg.76.1553016275973; Tue, 19 Mar 2019 10:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016275; cv=none; d=google.com; s=arc-20160816; b=t6ROq6hn/KKZnbtVUetFtwzPzWdIp7UoJio2VRJ1DjO8KRMTVklHLjuCoMAwVQTrnj PxVHxekwfk7OaT2qPOXSIS71Ip6p17hr319Y2CBad1k945iEBC1WysmUe9dF035RETbO jT5IK8ISIE8C63c5Zd3aG90/UF6+rICorLTSpuJyzsKpnJiEJbgjbqvKV+LB8mwuK7HY HWsMgiSevaayJL2wpCuIAgfe+t0ZCp6mKiwPiBq7sjz98YzcjUgDsKKb8RTtlKyPaZYt J5ewdPrvReer4iPwEGr9ggwikC2NIQYlVw+1nq1Ge1he9Z5PdsHJSy6ZfBxTsIT29Izt 0Mtg== 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=hodYlcpRqUFAyF1u9EayD/KhJ3+IN8OK9GoDdoOHadc=; b=f1r8tR/5SqzKNkW8F++WwrnD7hFNsCQdw5HWasacqtrU4dUyntKfpW7XQJXGEbBf1Z COrnT7u3yzOMvWyC2BKb3KKX0jzC0xvQeJa25PmanOSZocYL+VvIpqyBPGig8ngVTZOT o5mpZ/Ivay4rI0cCRXYxyvhpSxBnGvYxqJTGxoo0fOrCG81+enbtqczXkHqrURZxDwcN 0H/300mcepX8Zhv10QRAXHx8D2ASX6Vu2/5AYTVFGtucMogvKafi72ydJK0Rj6Wn1ROr p5W95BrSz8etv1uYcftoeRRDo3bTTDb40Mg59DmmhPgfrxOdhIQJsPcWr9sBfIQ8xI5j 6wTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xIXMK9qP; 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 y62si2014809wmg.2.2019.03.19.10.24.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:24:35 -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=xIXMK9qP; 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]:60678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6ITa-0006YU-Mx for patch@linaro.org; Tue, 19 Mar 2019 13:24:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQg-0004XK-NZ for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQf-0004R3-Mo for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:34 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33415) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQf-0004QX-9v for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:33 -0400 Received: by mail-pg1-x542.google.com with SMTP id b12so602652pgk.0 for ; Tue, 19 Mar 2019 10:21:33 -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=hodYlcpRqUFAyF1u9EayD/KhJ3+IN8OK9GoDdoOHadc=; b=xIXMK9qP4Y2rTEuoLYM5jiXUWC1XCXzWwNyYcniBG/TslRn24zMM3PYwt2RGScJ0mk 1SftcxDfUSKJiyLNjcpdfN5WCiAt7V8TGNoRR/wEnysC/njfdNRiDkSUTQDeoixkUjlB 8I1yC2tfTpRo/d9vB20FvsdiNmyKvLP/mq9n2Zi72y0ZF8eWVpzb77SzTfZJdZxqpvjJ 5ZdC6j0rTnzgoqNciJNXGXlvTsZQVidDNUNuzepxbbC7z6hmLMT9kmlD95J0hcv2Nh3T BOKNhGQjRJVZnxxMxLavDKtHrJ0yfK/EwxxcSoAff+U6/5qk82y2RnCflcrdoD7VeBgi ClDA== 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=hodYlcpRqUFAyF1u9EayD/KhJ3+IN8OK9GoDdoOHadc=; b=oPyDKookLqhvGxRC8TASi6zaEdsQb8NMTjx5ObbaefExXH47OC0EWJQhrckEja3SRi aXjI+x3La0yCjtaOETB8hBrD7MnVy6q83HkxfwW7EEy9xHftR/W4T5AP7fZu2hwoaNw9 nCEadzBatcaRHZdSiUp0PK0DswdHqKhrZwEcgdSiqKWu1JgSOkQXA5K0CdAHb6CGI/0D 9ZpFm5tGGzvPaFhFcLRF0W3nckURCg0GwHSVYSm/GtTWzkSwgcpeeszxI4oO0u+BIBPL GtVH5m9UtXdjSoRfGEZZ/MdSDZxpoh9tDyAqtCzLSwC0pvG9eFYteV1nVLIgRi7EF6GD 32eQ== X-Gm-Message-State: APjAAAWjRj+g/vf//PnrZ26Pv6pcP0TuXD4Nz+EZWDEd0s2s0i2fK6u5 wm1SbEns6n5FL5Zryv+rLb6dVJaY70k= X-Received: by 2002:a17:902:6b8c:: with SMTP id p12mr3219861plk.282.1553016091966; Tue, 19 Mar 2019 10:21:31 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:11 -0700 Message-Id: <20190319172126.7502-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::542 Subject: [Qemu-devel] [PATCH for-4.1 v3 02/17] tcg: Assert fixed_reg is read-only 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The only fixed_reg is cpu_env, and it should not be modified during any TB. Therefore code that tries to special-case moves into a fixed_reg is dead. Remove it. Signed-off-by: Richard Henderson --- tcg/tcg.c | 85 +++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 47 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 9b2bf7f439..6f320a4849 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3275,11 +3275,8 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, tcg_target_ulong val, TCGLifeData arg_life, TCGRegSet preferred_regs) { - if (ots->fixed_reg) { - /* For fixed registers, we do not do any constant propagation. */ - tcg_out_movi(s, ots->type, ots->reg, val); - return; - } + /* ENV should not be modified. */ + tcg_debug_assert(!ots->fixed_reg); /* The movi is not explicitly generated here. */ if (ots->val_type == TEMP_VAL_REG) { @@ -3315,6 +3312,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) ots = arg_temp(op->args[0]); ts = arg_temp(op->args[1]); + /* ENV should not be modified. */ + tcg_debug_assert(!ots->fixed_reg); + /* Note that otype != itype for no-op truncation. */ otype = ots->type; itype = ts->type; @@ -3339,7 +3339,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) } tcg_debug_assert(ts->val_type == TEMP_VAL_REG); - if (IS_DEAD_ARG(0) && !ots->fixed_reg) { + if (IS_DEAD_ARG(0)) { /* mov to a non-saved dead register makes no sense (even with liveness analysis disabled). */ tcg_debug_assert(NEED_SYNC_ARG(0)); @@ -3352,7 +3352,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) } temp_dead(s, ots); } else { - if (IS_DEAD_ARG(1) && !ts->fixed_reg && !ots->fixed_reg) { + if (IS_DEAD_ARG(1) && !ts->fixed_reg) { /* the mov can be suppressed */ if (ots->val_type == TEMP_VAL_REG) { s->reg_to_temp[ots->reg] = NULL; @@ -3505,6 +3505,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) arg = op->args[i]; arg_ct = &def->args_ct[i]; ts = arg_temp(arg); + + /* ENV should not be modified. */ + tcg_debug_assert(!ts->fixed_reg); + if ((arg_ct->ct & TCG_CT_ALIAS) && !const_args[arg_ct->alias_index]) { reg = new_args[arg_ct->alias_index]; @@ -3513,29 +3517,19 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) i_allocated_regs | o_allocated_regs, op->output_pref[k], ts->indirect_base); } else { - /* if fixed register, we try to use it */ - reg = ts->reg; - if (ts->fixed_reg && - tcg_regset_test_reg(arg_ct->u.regs, reg)) { - goto oarg_end; - } reg = tcg_reg_alloc(s, arg_ct->u.regs, o_allocated_regs, op->output_pref[k], ts->indirect_base); } tcg_regset_set_reg(o_allocated_regs, reg); - /* if a fixed register is used, then a move will be done afterwards */ - if (!ts->fixed_reg) { - if (ts->val_type == TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] = NULL; - } - ts->val_type = TEMP_VAL_REG; - ts->reg = reg; - /* temp value is modified, so the value kept in memory is - potentially not the same */ - ts->mem_coherent = 0; - s->reg_to_temp[reg] = ts; + if (ts->val_type == TEMP_VAL_REG) { + s->reg_to_temp[ts->reg] = NULL; } - oarg_end: + ts->val_type = TEMP_VAL_REG; + ts->reg = reg; + /* temp value is modified, so the value kept in memory is + potentially not the same */ + ts->mem_coherent = 0; + s->reg_to_temp[reg] = ts; new_args[i] = reg; } } @@ -3551,10 +3545,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* move the outputs in the correct register if needed */ for(i = 0; i < nb_oargs; i++) { ts = arg_temp(op->args[i]); - reg = new_args[i]; - if (ts->fixed_reg && ts->reg != reg) { - tcg_out_mov(s, ts->type, ts->reg, reg); - } + + /* ENV should not be modified. */ + tcg_debug_assert(!ts->fixed_reg); + if (NEED_SYNC_ARG(i)) { temp_sync(s, ts, o_allocated_regs, 0, IS_DEAD_ARG(i)); } else if (IS_DEAD_ARG(i)) { @@ -3675,26 +3669,23 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) for(i = 0; i < nb_oargs; i++) { arg = op->args[i]; ts = arg_temp(arg); + + /* ENV should not be modified. */ + tcg_debug_assert(!ts->fixed_reg); + reg = tcg_target_call_oarg_regs[i]; tcg_debug_assert(s->reg_to_temp[reg] == NULL); - - if (ts->fixed_reg) { - if (ts->reg != reg) { - tcg_out_mov(s, ts->type, ts->reg, reg); - } - } else { - if (ts->val_type == TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] = NULL; - } - ts->val_type = TEMP_VAL_REG; - ts->reg = reg; - ts->mem_coherent = 0; - s->reg_to_temp[reg] = ts; - if (NEED_SYNC_ARG(i)) { - temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); - } else if (IS_DEAD_ARG(i)) { - temp_dead(s, ts); - } + if (ts->val_type == TEMP_VAL_REG) { + s->reg_to_temp[ts->reg] = NULL; + } + ts->val_type = TEMP_VAL_REG; + ts->reg = reg; + ts->mem_coherent = 0; + s->reg_to_temp[reg] = ts; + if (NEED_SYNC_ARG(i)) { + temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); + } else if (IS_DEAD_ARG(i)) { + temp_dead(s, ts); } } } From patchwork Tue Mar 19 17:21:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160602 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4140689jad; Tue, 19 Mar 2019 10:28:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFCX+IfQlvVd5gARssRnJLOW54ox29qza+iB1OvvPoDLKnv1Wl3rqDRBwl3jGLdaOET8w+ X-Received: by 2002:adf:f805:: with SMTP id s5mr5243729wrp.178.1553016533616; Tue, 19 Mar 2019 10:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016533; cv=none; d=google.com; s=arc-20160816; b=EeMUnyWK9AK5w8pmzCLFjts19asONYGXP3TLNOxDAYtZ6RmqAwGEl4SN5rg3imCu19 gxOMND1JTDezTalcZKDqq/ccQ7o0bh4yMgVAtoWpUR/TAt7dFWUGDPA4IXRtICoQUW2x qMLMlqINVD7UBrLAwV/bTLs9OgOSARSyF5Zej/gmXQ2OckK1HPOkcGgCrVyZ+umK8DkH usFsp6MQtAHyycE+s20iJFcADswvd+wi8v8fCCwMbmMAu8gwQ4NomIN/weA4b9Yhm5sF 51mZy38iRhRUJQzTeym3YhaFdCsAa3ovIURiaI/sepZhE22lPHPeI9WEoOFLT/wgYSzg usEg== 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=4NBr5JXaG+X+354u2ZVP0EZV4LrsaRji1grsXyi7GNY=; b=rfdMfV/bGYdicfMV6rYU4oc2D1UhTWPWHn9OlMHCLKxelzhwWSVm7Q3Bq3RgsHzHOi WE7mtoYggVSHZEVTQhO4/NhKnN0SWje3rsA6PhSP5dV7ESyfWYZ6rySWBcjl6j+WTtKJ z1menmYoXdat/KPVnUWIoKX/UP/RRap28hOeIOeoWCddoIhWiiKoycqX2Eindpl7Dp4h YvD1TiRTSrqbfO27McPZXJT4cMVaQoIEWEfdtyHTc/YoBmmiU0d6OQ1fxfW4JYhj+dfE t6tVTYKIKcnZE8JJY+sPmtg/BqnwS1/RsNqFrf4bxKhUEa34jeYQo0or6yolhKnQ8R5Y FB8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="uPf/bA+X"; 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 l15si2020644wmc.55.2019.03.19.10.28.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:28:53 -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="uPf/bA+X"; 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]:60748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IXk-0001M3-HS for patch@linaro.org; Tue, 19 Mar 2019 13:28:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQi-0004YG-Up for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQh-0004SK-81 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:36 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:33417) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQg-0004RN-OT for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:35 -0400 Received: by mail-pg1-x544.google.com with SMTP id b12so602704pgk.0 for ; Tue, 19 Mar 2019 10:21:34 -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=4NBr5JXaG+X+354u2ZVP0EZV4LrsaRji1grsXyi7GNY=; b=uPf/bA+Xo6lIli2lIHv0lojBgDSND0yyvmv5jYA9KVu2Ln4nsV46GHE8yQrWbcSY1S zoYzsjwQwNYy9S+YmwW08OpdQLGSsyMYcWq6hDDAR1xTLa8Lx91QmuIZkxoQ41Onw08K 3RnwcT33GeLqxHqVjUOE16TzzZPmD3+upx4QunaVO2HAguJZDZF4FNDOa4wpa04J2Vlf LzSKFqvVBuv/WZNVlMGIe+IkB1EnPtvcPz6FrWGxu6ebkEwrEGlvoMn9Dxzw5XqbKKs9 3l2vDRtJrnyQrkBWzz1zkVZksDUI2WDaBe953KVSqYk/aXlzkTmqWu6ttWxiO+pvjrve tpIA== 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=4NBr5JXaG+X+354u2ZVP0EZV4LrsaRji1grsXyi7GNY=; b=ZaxDApvF5uFgF2hgpoLtTgiur0Kh+5xjADMCCiTb9dRhmCu1pmYE+jEm6pOcZwQOpI MKEUUW/yWnVDrE83R5G+PDYjiNuRMTFWGzcrVmPFuojZXE9UWGxdKWgYuGmdGjj8JNlm 5T2IOmEIky5bqsJj6jvu0rXFH+hqRUR6JxMMraflFDLicg/REVnXzf4OSZk+e1ov9RKt 1bDY+zpxCC0TU/h1jwGbUdK8EOJ0zy1/hpcylFKS9C1FwfJtzcFusP6uOq5Qx3wT0hM6 sdehCTsR0MxJcMcD5VkJ11ExCU8ADvja5gHKAzgEV9uFiLxmgyD0AlQAYoDGmoJsxTvb cdVA== X-Gm-Message-State: APjAAAVmEJKh+Cm1wknCAJgh6t3vd1FyN3aQXCnDj6/hiHLL8pg/EbUw tLPpGsuCUNhAsP4Dk9aDPlc/bxWZZBg= X-Received: by 2002:aa7:885a:: with SMTP id k26mr2992437pfo.70.1553016093389; Tue, 19 Mar 2019 10:21:33 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:12 -0700 Message-Id: <20190319172126.7502-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::544 Subject: [Qemu-devel] [PATCH for-4.1 v3 03/17] tcg: Return bool success from tcg_out_mov 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This patch merely changes the interface, aborting on all failures, of which there are currently none. Reviewed-by: David Gibson Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 5 +++-- tcg/arm/tcg-target.inc.c | 7 +++++-- tcg/i386/tcg-target.inc.c | 5 +++-- tcg/mips/tcg-target.inc.c | 3 ++- tcg/ppc/tcg-target.inc.c | 3 ++- tcg/riscv/tcg-target.inc.c | 5 +++-- tcg/s390/tcg-target.inc.c | 3 ++- tcg/sparc/tcg-target.inc.c | 3 ++- tcg/tcg.c | 14 ++++++++++---- tcg/tci/tcg-target.inc.c | 3 ++- 10 files changed, 34 insertions(+), 17 deletions(-) -- 2.17.2 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index d57f9e500f..6ba9050d9a 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -938,10 +938,10 @@ static void tcg_out_ldst(TCGContext *s, AArch64Insn insn, TCGReg rd, tcg_out_ldst_r(s, insn, rd, rn, TCG_TYPE_I64, TCG_REG_TMP); } -static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { if (ret == arg) { - return; + return true; } switch (type) { case TCG_TYPE_I32: @@ -970,6 +970,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) default: g_assert_not_reached(); } + return true; } static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index 2245a8aeb9..b303befa50 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -2250,10 +2250,13 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } -static inline void tcg_out_mov(TCGContext *s, TCGType type, +static inline bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { - tcg_out_dat_reg(s, COND_AL, ARITH_MOV, ret, 0, arg, SHIFT_IMM_LSL(0)); + if (ret != arg) { + tcg_out_dat_reg(s, COND_AL, ARITH_MOV, ret, 0, arg, SHIFT_IMM_LSL(0)); + } + return true; } static inline void tcg_out_movi(TCGContext *s, TCGType type, diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index e0670e5098..7100cf7ac3 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -808,12 +808,12 @@ static inline void tgen_arithr(TCGContext *s, int subop, int dest, int src) tcg_out_modrm(s, OPC_ARITH_GvEv + (subop << 3) + ext, dest, src); } -static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { int rexw = 0; if (arg == ret) { - return; + return true; } switch (type) { case TCG_TYPE_I64: @@ -851,6 +851,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) default: g_assert_not_reached(); } + return true; } static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c index 8a92e916dd..f31ebb43bf 100644 --- a/tcg/mips/tcg-target.inc.c +++ b/tcg/mips/tcg-target.inc.c @@ -558,13 +558,14 @@ static inline void tcg_out_dsra(TCGContext *s, TCGReg rd, TCGReg rt, TCGArg sa) tcg_out_opc_sa64(s, OPC_DSRA, OPC_DSRA32, rd, rt, sa); } -static inline void tcg_out_mov(TCGContext *s, TCGType type, +static inline bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { /* Simple reg-reg move, optimising out the 'do nothing' case */ if (ret != arg) { tcg_out_opc_reg(s, OPC_OR, ret, arg, TCG_REG_ZERO); } + return true; } static void tcg_out_movi(TCGContext *s, TCGType type, diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index 773690f1d9..ec8e336be8 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -566,12 +566,13 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, TCGReg base, tcg_target_long offset); -static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); if (ret != arg) { tcg_out32(s, OR | SAB(arg, ret, arg)); } + return true; } static inline void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs, diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index b785f4acb7..e2bf1c2c6e 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -515,10 +515,10 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, * TCG intrinsics */ -static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { if (ret == arg) { - return; + return true; } switch (type) { case TCG_TYPE_I32: @@ -528,6 +528,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) default: g_assert_not_reached(); } + return true; } static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index 7db90b3bae..eb22188d1d 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -548,7 +548,7 @@ static void tcg_out_sh32(TCGContext* s, S390Opcode op, TCGReg dest, tcg_out_insn_RS(s, op, dest, sh_reg, 0, sh_imm); } -static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg dst, TCGReg src) +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg dst, TCGReg src) { if (src != dst) { if (type == TCG_TYPE_I32) { @@ -557,6 +557,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg dst, TCGReg src) tcg_out_insn(s, RRE, LGR, dst, src); } } + return true; } static const S390Opcode lli_insns[4] = { diff --git a/tcg/sparc/tcg-target.inc.c b/tcg/sparc/tcg-target.inc.c index 7a61839dc1..83295955a7 100644 --- a/tcg/sparc/tcg-target.inc.c +++ b/tcg/sparc/tcg-target.inc.c @@ -407,12 +407,13 @@ static void tcg_out_arithc(TCGContext *s, TCGReg rd, TCGReg rs1, | (val2const ? INSN_IMM13(val2) : INSN_RS2(val2))); } -static inline void tcg_out_mov(TCGContext *s, TCGType type, +static inline bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { if (ret != arg) { tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR); } + return true; } static inline void tcg_out_sethi(TCGContext *s, TCGReg ret, uint32_t arg) diff --git a/tcg/tcg.c b/tcg/tcg.c index 6f320a4849..34ee06564f 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -102,7 +102,7 @@ static const char *target_parse_constraint(TCGArgConstraint *ct, const char *ct_str, TCGType type); static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, intptr_t arg2); -static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg); +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg); static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg); static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, @@ -3368,7 +3368,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) allocated_regs, preferred_regs, ots->indirect_base); } - tcg_out_mov(s, otype, ots->reg, ts->reg); + if (!tcg_out_mov(s, otype, ots->reg, ts->reg)) { + abort(); + } } ots->val_type = TEMP_VAL_REG; ots->mem_coherent = 0; @@ -3468,7 +3470,9 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) i_allocated_regs, 0); reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs, o_preferred_regs, ts->indirect_base); - tcg_out_mov(s, ts->type, reg, ts->reg); + if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { + abort(); + } } new_args[i] = reg; const_args[i] = 0; @@ -3625,7 +3629,9 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) if (ts->val_type == TEMP_VAL_REG) { if (ts->reg != reg) { tcg_reg_free(s, reg, allocated_regs); - tcg_out_mov(s, ts->type, reg, ts->reg); + if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { + abort(); + } } } else { TCGRegSet arg_set = 0; diff --git a/tcg/tci/tcg-target.inc.c b/tcg/tci/tcg-target.inc.c index 0015a98485..992d50cb1e 100644 --- a/tcg/tci/tcg-target.inc.c +++ b/tcg/tci/tcg-target.inc.c @@ -509,7 +509,7 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, old_code_ptr[1] = s->code_ptr - old_code_ptr; } -static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { uint8_t *old_code_ptr = s->code_ptr; tcg_debug_assert(ret != arg); @@ -521,6 +521,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) tcg_out_r(s, ret); tcg_out_r(s, arg); old_code_ptr[1] = s->code_ptr - old_code_ptr; + return true; } static void tcg_out_movi(TCGContext *s, TCGType type, From patchwork Tue Mar 19 17:21: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: 160591 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4136205jad; Tue, 19 Mar 2019 10:24:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5gWHYTAKyOpUTfrAUXH7hDxAvY7CpvjTQqFxGh67i4aYKscaTtIaPD1JKoT+jaULCEjWt X-Received: by 2002:a5d:6883:: with SMTP id h3mr17744901wru.215.1553016257746; Tue, 19 Mar 2019 10:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016257; cv=none; d=google.com; s=arc-20160816; b=UGciTdgcxvvrPGERZI49zScmTH/1BDLy/QNdLQOuoR3dVzlg4d+daPGqJoRSFD38Hv fMjMpK0Efwyb3JMfcS1JWUdgl3XeM3i5TjmxGspgOq2zg7Extci7pOgBHrsg8lYd1Rq/ pOsTq3KIO6hfy/8sl1TS+OCU/wEh6c1Vg7zM+Hq4VcrG7mwLRVRlo4EmC9HCc7fTK0uP 6wPs82mZyYaHySzd7DUYJN+j5GcZ5/2Gqz/HCQ8jMDwEAkmczS7Eub2qYxRAyVztsXkj MQSqaIK+S4+ueT8TC9ffhxsmFP0k6XYBlDCQzZHax/m9pMKukYGZIib3XvI6EcBofXq7 dR7A== 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=+1ZajJcyDX+UELwR6wwdOhI95L56RVVGuynDrcPGi6o=; b=yEPO/4jRcdhftaSZvsNX19xHIUnjUoFe2KGERVLgFkjgM604FrPQgMtvWgTZNlSdJp Qz0UQ60pQlXcEPhk/RytdmpR7Jib+RgyMJEE9UcC4QgPaj20NzVeTE5dadGwUp7Y+Hlw A3IZQzBdTgpRcGGVoNKOToHnmfCpgIVY3qSF/Uehq9qA2r8cSnsTC5rFvy7Hi0K1K2xL hUvGtfASfwjjDOyES+XlkTLNdd2jRdlwSXnhk9jMEMDmUaCdBTKgReJKvCTrJBz3S566 S70quWm/0TtS8Y6Z+P+Qcx3t4NZ0D3lZCFvBxiepmRmPlQT/csVvqqrCvskRYLDsF9vz yAyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PtRVa7zZ; 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 z18si8892828wru.23.2019.03.19.10.24.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:24:17 -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=PtRVa7zZ; 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]:60680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6ITI-0006a1-Nd for patch@linaro.org; Tue, 19 Mar 2019 13:24:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQj-0004Yn-O4 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQi-0004Tt-JY for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:37 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:38414) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQi-0004SU-7H for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:36 -0400 Received: by mail-pg1-x531.google.com with SMTP id v1so9597713pgi.5 for ; Tue, 19 Mar 2019 10:21:36 -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=+1ZajJcyDX+UELwR6wwdOhI95L56RVVGuynDrcPGi6o=; b=PtRVa7zZf5oJLar1xVe760fKgEL2nibWQXiJq5ATcx4JIY6y9L2AW0E8vbh4xETPv1 wVDnuXYqE7dGA14PnjFMi3DyimDdrRQx/OSALQH6mRlznpt/sRD3ScCXbZjIX3dS7UXl H5lJIpx6ycH7oj6es7o4rS1znwUdgjZ/Fmy7DNLAzwn/e7gChoeVIqqqoB7TJ4jEjKCp wZYwn/r21bBwL9gvN/4EHobBYibiKZUdrICrSGQrHELHpU0eMp0vNUNsfhoK6+d8w6g4 b5lhubBfV1C19X2f1EFb3WpF+HtzuN9PgCzv/NHus7vAHjMrF62u40BaFruRRa+D+gB3 f7gQ== 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=+1ZajJcyDX+UELwR6wwdOhI95L56RVVGuynDrcPGi6o=; b=BNCjTwga8tcsdSkLZCDPHJFnnbU77ToiuLuvd0icIJGy38sdw2gy+M/J/jZU4gARVJ a0gJ/M7bYHmiBilkvmQ3hnEo029I7hdjtJUG6QR5LStTihrOuoANdkGHC35MiEBekX0s iH0Tj4B9sdcuPCw2UgBGrtKZUQFv5MCibJEAuTXjQ/N4pZL02JvhsRUpbb4a86jqhOHC jFk/M+uC5Ia/b1YrQ6xvhTh7lcSgEvXd13SUMpPBzr7S9VphmIBjOmWAgsr9WMgwqJYO tH9JtKpaSRZofRHpKhoU/mPJtumQQg2IJik91/RYJyKoEt1C7S/ST2S9pW4JJlN2LPaX uZwg== X-Gm-Message-State: APjAAAVLJHb8/XY0ETlXfUfDvzKsIQ5tjLuNN5OfCSXT51TDmhcW+dCW qsNhtNT4SnX+zgMv0G1IjFwqImF7s2M= X-Received: by 2002:a17:902:bf05:: with SMTP id bi5mr26058361plb.252.1553016094848; Tue, 19 Mar 2019 10:21:34 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:13 -0700 Message-Id: <20190319172126.7502-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::531 Subject: [Qemu-devel] [PATCH for-4.1 v3 04/17] tcg: Support cross-class moves without instruction support 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" PowerPC Altivec does not support direct moves between vector registers and general registers. So when tcg_out_mov fails, we can use the backing memory for the temporary to perform the move. Signed-off-by: Richard Henderson --- tcg/tcg.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 34ee06564f..b5389ea767 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3369,7 +3369,18 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) ots->indirect_base); } if (!tcg_out_mov(s, otype, ots->reg, ts->reg)) { - abort(); + /* Cross register class move not supported. + Store the source register into the destination slot + and leave the destination temp as TEMP_VAL_MEM. */ + assert(!ots->fixed_reg); + if (!ts->mem_allocated) { + temp_allocate_frame(s, ots); + } + tcg_out_st(s, ts->type, ts->reg, + ots->mem_base->reg, ots->mem_offset); + ots->mem_coherent = 1; + temp_free_or_dead(s, ots, -1); + return; } } ots->val_type = TEMP_VAL_REG; @@ -3471,7 +3482,11 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs, o_preferred_regs, ts->indirect_base); if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { - abort(); + /* Cross register class move not supported. Sync the + temp back to its slot and load from there. */ + temp_sync(s, ts, i_allocated_regs, 0, 0); + tcg_out_ld(s, ts->type, reg, + ts->mem_base->reg, ts->mem_offset); } } new_args[i] = reg; @@ -3630,7 +3645,11 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) if (ts->reg != reg) { tcg_reg_free(s, reg, allocated_regs); if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { - abort(); + /* Cross register class move not supported. Sync the + temp back to its slot and load from there. */ + temp_sync(s, ts, allocated_regs, 0, 0); + tcg_out_ld(s, ts->type, reg, + ts->mem_base->reg, ts->mem_offset); } } } else { From patchwork Tue Mar 19 17:21:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160590 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4133953jad; Tue, 19 Mar 2019 10:22:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1iad4q/WYUikzuT0rTQK94pL9sURXo3MpN5WF7IQNmD6Svn72zoTz87jsmEZg0NM4xHS7 X-Received: by 2002:a1c:ac87:: with SMTP id v129mr4826977wme.72.1553016127451; Tue, 19 Mar 2019 10:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016127; cv=none; d=google.com; s=arc-20160816; b=jxkHBeZSTgS6y+/oajQvaHA/LmOvlXTdf2Dx01ZLilth3RvVWO96ktrxuJRktZfwmt aoLa2v/HoU/6S0/8d+GLxdsauPjdvjbiXoNr9NwBWwS9x72gWeTD9447iJBbaPch1Yus OhOEDXurjPuMxnybc3ICsyhLjyDSDYjfUiHElV/zm2TEQ6doMGgMpJz2X4jqHEghl5P7 n+q+WwMXFW45OlbLkTa719tHJrqVpIfONHruZ8T/0wkg0v4u3SAcWV7q2MShqG1tzevM +urQWrCnqu0zXPSrkq+1Om18c8ORIg+LKPvLhhliOtT+5IiBZz4g0EGVmUeOUeU8Q6KT zyBg== 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=GZIJyp4IPrmFxQhN2kp0EgDilGGl6wAJPSZllKgeFTA=; b=ABFNmYyNCP6syO1mu5nSz2Tz+pITLo45fd7e4WbBzXqJB6tIiMD6UaIvXDEloERYE5 0wJKxK+mG4IPS1lBt/fxewVlgQrrivV5u5oJ/YJSssOoXffrJNzyPrvxHhZQYYm5GZZ1 bA9OP5akGc0i4CsYmD2zNnrQOpEgW+CNbzv3bLSuC7pMXTLuLtSuJWxS4zvT+2auIc/a l7/tY6P8fDsbxHq9/+eMBypO3GEcr8PlsyUMbomuiFWL5/LRA7/ZCS8ZfDVEzaCXuwSv krhan8Ef6kj+fRFmMSL8ZT4g/6KfV+SuRlsHyZVPIoThWHuvmneCusVHG+8evF9dqXJF 215Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iUtvwhbo; 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 v12si9962394wra.89.2019.03.19.10.22.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:22:07 -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=iUtvwhbo; 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]:60665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IRC-0004e0-AE for patch@linaro.org; Tue, 19 Mar 2019 13:22:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQl-0004Zz-5M for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQj-0004Vj-Uz for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:39 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:38213) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQj-0004UD-ES for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:37 -0400 Received: by mail-pf1-x433.google.com with SMTP id n125so14163319pfn.5 for ; Tue, 19 Mar 2019 10:21:37 -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=GZIJyp4IPrmFxQhN2kp0EgDilGGl6wAJPSZllKgeFTA=; b=iUtvwhbo3P0H9Z7YwFiFIZsUKx09tXn5AzHSMHE1d2TsfgotI1N0ElcjiN0jF0Gl3C cES5lzgvmyzPOfE78P3EY6SISrqwy0/WmI0F3gnuLGgNrK0xE5NR1B87KJZMbbqdk4v9 wLFnjhzRFj/MsxY6T/f9C6G6Djv4j3q/W3xX+FIsa6VvT5PCS6ORy5Q1KfBIWAozpjOj vfbbqYJpAmjOH/VcxwRJJy0qDDUyWLhl83t7es/A2jhYecXakcYPSM17wRQQ5oIcTzXx cS+VRm0BTtypFzvOVoazWmTHFs8pF2VwCNkQfz/BLfCkFyJihvnKMdNmhu543C2dzk2n KWUQ== 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=GZIJyp4IPrmFxQhN2kp0EgDilGGl6wAJPSZllKgeFTA=; b=IXwio0j8c11SIlgcCvnJSziyZe4zKZSTbU/7wx54IXzQsQEqSNml0DKyFV4Rts6DGt WApUQEURMY2p0VSLrsR4kouLChFquCZpbpTHdeZzO758RaI10PtRuYG/Kl/ypVq8bFuI 2tdq+LiZewuUyr0MaqJImnLc3dq5wGEAGb4z4XLAqqkc8n/RDlzzUpogaD2C3LpDpRJJ glg+A0qQgveORaa8jvTx0z4hxGaIX6jFAZlBjdQug5BtJVZfLDlLxGVM51LlC3LMFL5F rFFNcr0IISFXlU2Pfx/ZPBm766+YGyWfbfGkechhLNWEiQtEDmdmCS9XHc08QouexRB3 H4EA== X-Gm-Message-State: APjAAAVV8vtlFJ+Mtwv9ZkkzDFAfENri5VhZj8rkuO1ZPY+xP3AtQUw8 KyaNvtE0WeYAB7AfmsypyweenZDzt6Q= X-Received: by 2002:a17:902:aa97:: with SMTP id d23mr3027319plr.327.1553016096051; Tue, 19 Mar 2019 10:21:36 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:14 -0700 Message-Id: <20190319172126.7502-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::433 Subject: [Qemu-devel] [PATCH for-4.1 v3 05/17] tcg: Allow add_vec, sub_vec, neg_vec, not_vec to be expanded 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/tcg-op-vec.c | 49 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) -- 2.17.2 diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 27f65600c3..cfb18682b1 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -226,16 +226,6 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr b, TCGArg o, TCGType low_type) vec_gen_3(INDEX_op_st_vec, low_type, 0, ri, bi, o); } -void tcg_gen_add_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) -{ - vec_gen_op3(INDEX_op_add_vec, vece, r, a, b); -} - -void tcg_gen_sub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) -{ - vec_gen_op3(INDEX_op_sub_vec, vece, r, a, b); -} - void tcg_gen_and_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) { vec_gen_op3(INDEX_op_and_vec, 0, r, a, b); @@ -296,11 +286,30 @@ void tcg_gen_eqv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) tcg_gen_not_vec(0, r, r); } +static bool do_op2(unsigned vece, TCGv_vec r, TCGv_vec a, TCGOpcode opc) +{ + TCGTemp *rt = tcgv_vec_temp(r); + TCGTemp *at = tcgv_vec_temp(a); + TCGArg ri = temp_arg(rt); + TCGArg ai = temp_arg(at); + TCGType type = rt->base_type; + int can; + + tcg_debug_assert(at->base_type >= type); + can = tcg_can_emit_vec_op(opc, type, vece); + if (can > 0) { + vec_gen_2(opc, type, vece, ri, ai); + } else if (can < 0) { + tcg_expand_vec_op(opc, type, vece, ri, ai); + } else { + return false; + } + return true; +} + void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a) { - if (TCG_TARGET_HAS_not_vec) { - vec_gen_op2(INDEX_op_not_vec, 0, r, a); - } else { + if (!TCG_TARGET_HAS_not_vec || !do_op2(vece, r, a, INDEX_op_not_vec)) { TCGv_vec t = tcg_const_ones_vec_matching(r); tcg_gen_xor_vec(0, r, a, t); tcg_temp_free_vec(t); @@ -309,9 +318,7 @@ void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a) void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a) { - if (TCG_TARGET_HAS_neg_vec) { - vec_gen_op2(INDEX_op_neg_vec, vece, r, a); - } else { + if (!TCG_TARGET_HAS_neg_vec || !do_op2(vece, r, a, INDEX_op_neg_vec)) { TCGv_vec t = tcg_const_zeros_vec_matching(r); tcg_gen_sub_vec(vece, r, t, a); tcg_temp_free_vec(t); @@ -409,6 +416,16 @@ static void do_op3(unsigned vece, TCGv_vec r, TCGv_vec a, } } +void tcg_gen_add_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) +{ + do_op3(vece, r, a, b, INDEX_op_add_vec); +} + +void tcg_gen_sub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) +{ + do_op3(vece, r, a, b, INDEX_op_sub_vec); +} + void tcg_gen_mul_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) { do_op3(vece, r, a, b, INDEX_op_mul_vec); From patchwork Tue Mar 19 17:21:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160593 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4136674jad; Tue, 19 Mar 2019 10:24:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDc/0pNyHRMSGNFjmqOyYvzOo3Q4HSTRxwXjk6iPm5bNGTxW94j64vz9Twv2Jc0UTtb2nu X-Received: by 2002:a7b:c111:: with SMTP id w17mr4774183wmi.6.1553016284649; Tue, 19 Mar 2019 10:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016284; cv=none; d=google.com; s=arc-20160816; b=k5kulvihy42eWJXQMEJSrb0zBEaJ+TJZHXNJIq7a7IfH+7JxstlRDy3Bq8wELQFX27 50DMWz5jSqnoI5Ej8LceKzuOoLvNmYL6u3G8XQU7OMJPkxnMn1rYDaVht6sFVk7ThldC 4ABV9+taV/mMcR+luKNNoWQz722TI9M3jtXkQ7WKs3iAZuCvv2uoureFQodJYAKIGl6G zFJDx8az2Ccd0/dVqQQq18ypSA/jERPwOGvfI6jMbSIR31D+Lei6dS+y6w1QecCFcepX ewLs8Mfh7ZCrVoiBQMcK7pZf+AbnZ0jFNmURvosSfFpCbNC33PHmIk5/zVYV2b9z2v+J Dhsg== 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=gZi8bIQjSTF/5KTE1LcSi/XifGrmbOe2PcmtjQivf7M=; b=FdultFdz8xbigMLgou8up5xj7SPg5xcN6YoRG7nwyVHHikctPKnL5m+hC1zKJUmrSi RJ1t5lop6rdbeqO5hKsAtzXEQLuAWhWyKLGgMZ8Ozkxw8dYTu/YFytVKiXTBI7opBhY8 GZ3QCXtz8+EWaVyM8kB7pl2Ct90vjVAkp0frTNIaF+GgRmoCsR89F7YsjyVW+1o0L35O RrNPPKbyh4As9xkMKjKoytZsACOocmMALdxUsz9inD7Lyfr99G0b6QonI8IuB3k67nZi hgvvxKf4Il9S2sOFJJOuMrpHpu8VtrALwvrFV2qm5MLZfcK0rb7X4YVvRGRnf8XM48di grfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=exA6Wkj9; 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 x5si8975013wrw.221.2019.03.19.10.24.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:24:44 -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=exA6Wkj9; 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]:60686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6ITj-0006fo-Hs for patch@linaro.org; Tue, 19 Mar 2019 13:24:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQn-0004cz-RS for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQm-0004XY-9T for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:41 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:46205) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQl-0004WS-QZ for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:40 -0400 Received: by mail-pf1-x42c.google.com with SMTP id s23so14148460pfe.13 for ; Tue, 19 Mar 2019 10:21:39 -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=gZi8bIQjSTF/5KTE1LcSi/XifGrmbOe2PcmtjQivf7M=; b=exA6Wkj9VOAvnYxOfHIaKJCxFMWbEaGjeA+p8CMMhJd1zHpYLJL+MevZ+dijizdqxI W2uSycYc8q8LXf8sAZAuU5UZau8knvXEXlLBcKdONyFugwnRKCRiNOw+6ypQvVvR0Gcz +cukAHypH3//Xw+kDZmzPs4Si+WjvZimL+3umEsfqZiB3QkNYYSLKd0DmJ6Uu5optX+c f8BzS0EqPkhCFssQ4iIrJ7gHzW1LA2+SVPtFba3twt9IlP0HFSQHNwv6AbmOoo02U2/D 8IVNWXJOPvilbMxP63QUKqsmR6VURntiuY+UB7zv3nYhzL5FQqM5bNkKa9WtlGZ53ksT oCRw== 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=gZi8bIQjSTF/5KTE1LcSi/XifGrmbOe2PcmtjQivf7M=; b=UJOAEd8ns4sdaxJC+nrK60gQ6VbhUEtIwE1CRP+x2v7Stu0zz9JYdSgTI0aDSDSCx2 i8iSaemrUEFMeiUY1SZ4BsHJYmTrK2OOa4RmTgPfnSarv8btpWTgyeR5txSeaTVvaUzS Env2L8NGsHU7xfdkdh2Slns1eUqGY+jiroQy+os92hhVLDgTduG/u9cB+uvgT05xPcKr FIienrefQJsieYliIDUC8/0buJVlGKZQRPjB3OrrNO5iPGe4W4XcyaIFd+1XMELs/QIt FDKo6zzOh7aVfAw692uE677I+aG0ABW4JYoLHP0fgaGnAYa++2m3n9+NHFW3BkxQJISr zrqA== X-Gm-Message-State: APjAAAUmUSQL2JdiValXJkNUmGbEdHrl2bupMDCgVQh1OOA5DiTpNb3I +ZRlGakabgJ2r0x/ps6QGz8mDGk10Ko= X-Received: by 2002:a17:902:56a:: with SMTP id 97mr3333199plf.320.1553016098336; Tue, 19 Mar 2019 10:21:38 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:15 -0700 Message-Id: <20190319172126.7502-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::42c Subject: [Qemu-devel] [PATCH for-4.1 v3 06/17] tcg: Promote tcg_out_{dup, dupi}_vec to backend interface 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The i386 backend already has these functions, and the aarch64 backend could easily split out one. Nothing is done with these functions yet, but this will aid register allocation of INDEX_op_dup_vec in a later patch. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 12 ++++++++++-- tcg/i386/tcg-target.inc.c | 3 ++- tcg/tcg.c | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) -- 2.17.2 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 6ba9050d9a..3c786ee581 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -799,7 +799,7 @@ static void tcg_out_logicali(TCGContext *s, AArch64Insn insn, TCGType ext, } static void tcg_out_dupi_vec(TCGContext *s, TCGType type, - TCGReg rd, uint64_t v64) + TCGReg rd, tcg_target_long v64) { int op, cmode, imm8; @@ -814,6 +814,14 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, } } +static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg rd, TCGReg rs) +{ + int is_q = type - TCG_TYPE_V64; + tcg_out_insn(s, 3605, DUP, is_q, rd, rs, 1 << vece, 0); + return true; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, tcg_target_long value) { @@ -2192,7 +2200,7 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, tcg_out_insn(s, 3617, NOT, is_q, 0, a0, a1); break; case INDEX_op_dup_vec: - tcg_out_insn(s, 3605, DUP, is_q, a0, a1, 1 << vece, 0); + tcg_out_dup_vec(s, type, vece, a0, a1); break; case INDEX_op_shli_vec: tcg_out_insn(s, 3614, SHL, is_q, a0, a1, a2 + (8 << vece)); diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 7100cf7ac3..b8e677e46d 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -854,7 +854,7 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) return true; } -static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, +static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg r, TCGReg a) { if (have_avx2) { @@ -887,6 +887,7 @@ static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, g_assert_not_reached(); } } + return true; } static void tcg_out_dupi_vec(TCGContext *s, TCGType type, diff --git a/tcg/tcg.c b/tcg/tcg.c index b5389ea767..ca5f3ed5ce 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -108,10 +108,24 @@ static void tcg_out_movi(TCGContext *s, TCGType type, static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, const int *const_args); #if TCG_TARGET_MAYBE_vec +static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg dst, TCGReg src); +static void tcg_out_dupi_vec(TCGContext *s, TCGType type, + TCGReg dst, tcg_target_long arg); static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, unsigned vecl, unsigned vece, const TCGArg *args, const int *const_args); #else +static inline bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg dst, TCGReg src) +{ + g_assert_not_reached(); +} +static inline void tcg_out_dupi_vec(TCGContext *s, TCGType type, + TCGReg dst, tcg_target_long arg) +{ + g_assert_not_reached(); +} static inline void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, unsigned vecl, unsigned vece, const TCGArg *args, const int *const_args) From patchwork Tue Mar 19 17:21:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160604 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4142240jad; Tue, 19 Mar 2019 10:30:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmFemc8zbZLQc3LCh+Nx7xK0pw/QJ4KXG11BYsMiVSgGTccZ7WwA2Y7spLBXqhwF4JFW03 X-Received: by 2002:a7b:cd82:: with SMTP id y2mr4364775wmj.121.1553016639037; Tue, 19 Mar 2019 10:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016639; cv=none; d=google.com; s=arc-20160816; b=iVPGMAfbjP1K3iOzWXwyshbV/FQBMu+FHV6N/xjdLlwasRkO0SlaipePkED5usxxeF Ig9eTiIhivzhxI9Kp45sb9A3ppomhz34qJoqZsR3Tl/R0Cwq6UsLYB18XIGb262DgATq hm5eGHlgGFTTdXzCSnbTqN5Au9sCm93jCssNV3BvNx5CF6uz9ZE2GdC+omeV0uaZfOhl 43eJwxoekovfnzpuKHll7JbQlQFxl+kcV3QiwsnggWDni90K2uAb4sMp5RIsqvLSR85I xqRVXTlzUbxS8pRXSW4A2ovVGKqLtbCpkeLxfRYFeMAaVK3w1W3d1arAPdlHoL+8K/lL /Ruw== 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=kFPPZstBkas5qbjcpfxyoGriUyFM5j9wSpVME/IdO1s=; b=wxD1brZ4WcZ6yiXt6KiyY1CiH8osgAkWgYMiT32q+zGxidWmYVchf/TwKPzIfr9iFt 7uJGswiEdIWEKbxMka0hkwjTMuqKCM1426JKf0N9hTyddADFkRUZeP80yJqh8sUk4fhd zPgNJ4bfwW1/K493pECdV8znsA6v/mwW7gOFUMY7zO75/Jykw8KRLy+HZ70OEkjrV1eT L2mD921ONL6GfqFAn/NiJkVUprJr9agoeB7fQGO5a15HjwDmDENwSIZlWJhKQfj3wOf4 4HWUyuropuYjOXLSTd08dkhp+YiwMws3E2ppyJlmdbJJlE5SSm/viH7afCqOEaBLLhgX 2GuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rWhAw8lD; 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 z19si2157147wma.93.2019.03.19.10.30.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:30:39 -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=rWhAw8lD; 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]:60791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IZR-0002hm-Or for patch@linaro.org; Tue, 19 Mar 2019 13:30:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQp-0004et-TG for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQn-0004Y8-B4 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:43 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:34879) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQm-0004Xc-Ug for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:41 -0400 Received: by mail-pg1-x52d.google.com with SMTP id g8so3653300pgf.2 for ; Tue, 19 Mar 2019 10:21:40 -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=kFPPZstBkas5qbjcpfxyoGriUyFM5j9wSpVME/IdO1s=; b=rWhAw8lDYO4egtJ286jVkzMp9UHVb1S0BHzrHMR8sBzdsc0y47XUaBx+Fuq+DWRwGL jZj/ktnn0mH3rqh8J9h1NZs/NEo80JcYCIWm3/Vph5w67NQeTO9VRYpiI7jG2W0s6NfY pR1WFqKirJ+Teq1oebZSNQ01VW4Wrv9n6R6tP1VOacftXhMQvIpuIcNu04PQZhu0OFrz OUNfqIR0jln68dO1EMV4zSTj44lSpwTWToksYYeOraKcDzczg0nAVGcHm8imkKiKIDcN X+0ZnJSxF6TZkSJNxtJGdGG0Z26N2fUEjRdx/7tTcFtP2sU6knalhblgfidpycijvSnz f8Sw== 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=kFPPZstBkas5qbjcpfxyoGriUyFM5j9wSpVME/IdO1s=; b=sIyCdsQw++77TvXLqY8vH5QtqxkU4ZvBWvpn5JsmbNkzCrrPoIsw8oag5TEIOuyEFK 19/YKaPwZ+Uwpcxg/EYq3IcJ/QDp2mVQscKt2y9x18Xha8jHt4KdAKGIgBMOnUfIyX4k ynYOnp1fVkqI+INQ8123bGz84ebhuTFgFhekqh22BfmVEnJwZqC+CZ7iZvBx8Z5yJDjM ffrI8/vbf9sgPK0dGyP/aqdjLGQP0SkayBUWPUMtZcIJTmAXJq7iQz/t7SqxYhCkVZrS oAu3tHq8RTQeZ7296YM786G1Bgls+GZGnQEXNLjWcanRABc+T0IpxZyXdX253SDaUAwK ma8w== X-Gm-Message-State: APjAAAWYHFLXMuZFYYlU3sHKcAevk7X2qyLT516BhFfosFeHMLQZqUab EiW8BMEtPbY0ud5UeuXu6JGSO7B+wUA= X-Received: by 2002:a62:a509:: with SMTP id v9mr3233467pfm.64.1553016099538; Tue, 19 Mar 2019 10:21:39 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:16 -0700 Message-Id: <20190319172126.7502-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::52d Subject: [Qemu-devel] [PATCH for-4.1 v3 07/17] tcg: Manually expand INDEX_op_dup_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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This case is similar to INDEX_op_mov_* in that we need to do different things depending on the current location of the source. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 9 ++-- tcg/i386/tcg-target.inc.c | 8 ++- tcg/tcg.c | 102 +++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 10 deletions(-) -- 2.17.2 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 3c786ee581..17e35f2fb6 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -2099,10 +2099,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: - case INDEX_op_mov_vec: case INDEX_op_movi_i32: /* Always emitted via tcg_out_movi. */ case INDEX_op_movi_i64: - case INDEX_op_dupi_vec: case INDEX_op_call: /* Always emitted via tcg_out_call. */ default: g_assert_not_reached(); @@ -2199,9 +2197,6 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_not_vec: tcg_out_insn(s, 3617, NOT, is_q, 0, a0, a1); break; - case INDEX_op_dup_vec: - tcg_out_dup_vec(s, type, vece, a0, a1); - break; case INDEX_op_shli_vec: tcg_out_insn(s, 3614, SHL, is_q, a0, a1, a2 + (8 << vece)); break; @@ -2245,6 +2240,10 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, } } break; + + case INDEX_op_mov_vec: /* Always emitted via tcg_out_mov. */ + case INDEX_op_dupi_vec: /* Always emitted via tcg_out_movi. */ + case INDEX_op_dup_vec: /* Always emitted via tcg_out_dup_vec. */ default: g_assert_not_reached(); } diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index b8e677e46d..09e2308557 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -2594,10 +2594,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: - case INDEX_op_mov_vec: case INDEX_op_movi_i32: /* Always emitted via tcg_out_movi. */ case INDEX_op_movi_i64: - case INDEX_op_dupi_vec: case INDEX_op_call: /* Always emitted via tcg_out_call. */ default: tcg_abort(); @@ -2786,9 +2784,6 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_st_vec: tcg_out_st(s, type, a0, a1, a2); break; - case INDEX_op_dup_vec: - tcg_out_dup_vec(s, type, vece, a0, a1); - break; case INDEX_op_x86_shufps_vec: insn = OPC_SHUFPS; @@ -2830,6 +2825,9 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, tcg_out8(s, a2); break; + case INDEX_op_mov_vec: /* Always emitted via tcg_out_mov. */ + case INDEX_op_dupi_vec: /* Always emitted via tcg_out_movi. */ + case INDEX_op_dup_vec: /* Always emitted via tcg_out_dup_vec. */ default: g_assert_not_reached(); } diff --git a/tcg/tcg.c b/tcg/tcg.c index ca5f3ed5ce..b11b30bbec 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3406,6 +3406,105 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) } } +static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) +{ + const TCGLifeData arg_life = op->life; + TCGRegSet dup_out_regs, dup_in_regs; + TCGTemp *its, *ots; + TCGType itype, vtype; + unsigned vece; + bool ok; + + ots = arg_temp(op->args[0]); + its = arg_temp(op->args[1]); + + /* There should be no fixed vector registers. */ + tcg_debug_assert(!ots->fixed_reg); + + itype = its->type; + vece = TCGOP_VECE(op); + vtype = TCGOP_VECL(op) + TCG_TYPE_V64; + + if (its->val_type == TEMP_VAL_CONST) { + /* Propagate constant via movi -> dupi. */ + tcg_target_ulong val = its->val; + if (IS_DEAD_ARG(1)) { + temp_dead(s, its); + } + tcg_reg_alloc_do_movi(s, ots, val, arg_life, op->output_pref[0]); + return; + } + + dup_out_regs = tcg_op_defs[INDEX_op_dup_vec].args_ct[0].u.regs; + dup_in_regs = tcg_op_defs[INDEX_op_dup_vec].args_ct[1].u.regs; + + /* Allocate the output register now. */ + if (ots->val_type != TEMP_VAL_REG) { + TCGRegSet allocated_regs = s->reserved_regs; + + if (!IS_DEAD_ARG(1) && its->val_type == TEMP_VAL_REG) { + /* Make sure to not spill the input register. */ + tcg_regset_set_reg(allocated_regs, its->reg); + } + ots->reg = tcg_reg_alloc(s, dup_out_regs, allocated_regs, + op->output_pref[0], ots->indirect_base); + ots->val_type = TEMP_VAL_REG; + ots->mem_coherent = 0; + s->reg_to_temp[ots->reg] = ots; + } + + switch (its->val_type) { + case TEMP_VAL_REG: + /* + * The dup constriaints must be broad, covering all possible VECE. + * However, tcg_op_dup_vec() gets to see the VECE and we allow it + * to fail, indicating that extra moves are required for that case. + */ + if (tcg_regset_test_reg(dup_in_regs, its->reg)) { + if (tcg_out_dup_vec(s, vtype, vece, ots->reg, its->reg)) { + goto done; + } + /* Try again from memory or a vector input register. */ + } + if (!its->mem_coherent) { + /* + * The input register is not synced, and so an extra store + * would be required to use memory. Attempt an integer-vector + * register move first. We do not have a TCGRegSet for this. + */ + if (tcg_out_mov(s, itype, ots->reg, its->reg)) { + break; + } + /* Sync the temp back to its slot and load from there. */ + temp_sync(s, its, s->reserved_regs, 0, 0); + } + /* fall through */ + + case TEMP_VAL_MEM: + /* TODO: dup from memory */ + tcg_out_ld(s, itype, ots->reg, its->mem_base->reg, its->mem_offset); + break; + + default: + g_assert_not_reached(); + } + + /* We now have a vector input register, so dup must succeed. */ + ok = tcg_out_dup_vec(s, vtype, vece, ots->reg, ots->reg); + tcg_debug_assert(ok); + + done: + if (IS_DEAD_ARG(1)) { + temp_dead(s, its); + } + if (NEED_SYNC_ARG(0)) { + temp_sync(s, ots, s->reserved_regs, 0, 0); + } + if (IS_DEAD_ARG(0)) { + temp_dead(s, ots); + } +} + static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) { const TCGLifeData arg_life = op->life; @@ -3974,6 +4073,9 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) case INDEX_op_dupi_vec: tcg_reg_alloc_movi(s, op); break; + case INDEX_op_dup_vec: + tcg_reg_alloc_dup(s, op); + break; case INDEX_op_insn_start: if (num_insns >= 0) { size_t off = tcg_current_code_size(s); From patchwork Tue Mar 19 17:21:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160606 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4144831jad; Tue, 19 Mar 2019 10:32:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIaB5mbPwaCOAMWAQBMPrBR353hLuQBH8ZKwb8rBn9leYgiEuSKlzFepzZqbJe2fHZvcBU X-Received: by 2002:adf:c752:: with SMTP id b18mr18339884wrh.105.1553016770456; Tue, 19 Mar 2019 10:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016770; cv=none; d=google.com; s=arc-20160816; b=qgzH/zxVKgWKH3Ts/nSfsCuJxx+OatRZeJH9wxSq4Tp5nvlzifpDHpt+jmpmDmLN6C C2BhJC7KnTrjg8xOPGm5l67k0eyVmnBxVud/LjPWQXKZJMQWQklR6Mgv6K8D7zka3R1X /CGYAx0C+ZrkoUCEp+pubSozGNfd22LMTrCKhLrZzdPypKMDF/wQkYofPfDJN82+2MU9 y9gdnNtndccg+6dzJUscidBjvZs3dy+RM3nz51/wnoy+2zZ5O90tGBCiqOypLMkzU9Q4 HOE/sq3mfGZwVbUfPxfui2JjR2xVSczcFo84xbv8vAox+Y43H/Bzd4hpbYH7yeuWgP7G y2UA== 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=WROFYqQgzpSEyJjWKfl9Kf1odJFpUVDraWD9yC+0Rzw=; b=gfN6kLYfwMFT65DvcpOgXcbOqP4f0W/CIbnGc29vo6YFXw7lRzxl3hCZc6wDh6FqOV 3zZ05wTo2Gq/zyPtYv8tR9N7J/+byPTQhq4PenMVcprhZF1qhKMK0olwgUKXTaQeVxTb hmQrV6JLoRrLKRLFB9pztSVRYIUfXPE1kDBqRuhQtBAcXfAkcHUNs7vigI/TvFnFYTL4 sP7JrYwfpSjZOAkzXDuUhXv2+xi+b9BgZdyxcp/QemcsofddHgSV4IJB2e8B/uBxUTME qwRrFKSSffB4MIxfpJaGQ4Yd8QH4Y3BA0nSYqOAd6biT9EjRSZH3hMDZl/3tuQas/eaT WhmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IRuzDORZ; 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 v12si9979998wra.89.2019.03.19.10.32.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:32:50 -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=IRuzDORZ; 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]:60808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IbZ-0003t1-EQ for patch@linaro.org; Tue, 19 Mar 2019 13:32:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQq-0004fD-61 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQo-0004Ys-GT for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:44 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33417) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQo-0004YH-1s for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:42 -0400 Received: by mail-pg1-x542.google.com with SMTP id b12so602916pgk.0 for ; Tue, 19 Mar 2019 10:21:41 -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=WROFYqQgzpSEyJjWKfl9Kf1odJFpUVDraWD9yC+0Rzw=; b=IRuzDORZvF6Um9Rvj2qYdHAW92u7hQDYdIbFljEgr7fG6WFEnNPJmKEWKsFJrJeE/u KZnXzXEVlOmLPskTd6lxvB/NxAYUikmUb/VIogOJIuuBpXoX3TkciF8Spu7p6lYiXD6f y0eUCj+Ze7fJaXPGJQFwUZuNRIvz2BtTWkp4d1u/zFhLsvs67hHzLAXlcZxDAibgiV3X qROqwX1O5YbthxUvMM3Vqo1wEEcBaxX39Jwp2rht9Qmu6QRdy1UqyH6IY6FRkUuUHAwl fG6MU98nhMOdkk1hdynQkeEDzhdsHFjWSG0Wl+pyUmdf89DVzXvQvCu/3POxH11WD0qv GlYQ== 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=WROFYqQgzpSEyJjWKfl9Kf1odJFpUVDraWD9yC+0Rzw=; b=AmDz3coRcWUFymCDAFEJ7kTsErDXizmrYnCUD2yOZCUWe/yl00ChI8zJKq7TucLeDP aj2bp3cqk9ZEEIX+SOOX9bq2TrNgRfk4yi3Ggg3XiZa8yatBPmeuNQqk89w5kEhVcxuh givsCn7sDgM4NOxoKFe9Wg6qIP6/JGkxHWa0Nnc1zcFm0bBxaZZIL1DFR7fNUgNO0djV gjB0DmStiIk2Ox+gW0EK3cNakdb3y4IY80dPl3aZCJ3nZQRCtaFfKaVhmXG92/MLHFaE 3kURa8wNzMhZTLq4pKM+0nmX0JvF9kSebCtQZw2XBG1Zh3IszyTYysJLTwkzFamTrKYA vKXg== X-Gm-Message-State: APjAAAVsErHR9uURr2ockCXHf0+b063htTWSto2xZ1bvc44YJfHgiUt4 +NzEni8pyiZQ4jqBvcauwaSWvfpLLXQ= X-Received: by 2002:a17:902:a5c9:: with SMTP id t9mr3076778plq.196.1553016100849; Tue, 19 Mar 2019 10:21:40 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:17 -0700 Message-Id: <20190319172126.7502-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::542 Subject: [Qemu-devel] [PATCH for-4.1 v3 08/17] tcg: Add tcg_out_dupm_vec to the backend interface 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Currently stubbed out in all backends that support vectors. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 6 ++++++ tcg/i386/tcg-target.inc.c | 7 +++++++ tcg/tcg.c | 19 ++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 17e35f2fb6..b34a1e5b06 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -822,6 +822,12 @@ static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, return true; } +static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg r, TCGReg base, intptr_t offset) +{ + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, tcg_target_long value) { diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 09e2308557..ae88df440a 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -890,6 +890,13 @@ static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, return true; } +static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg r, TCGReg base, intptr_t offset) +{ + return false; +} + + static void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { diff --git a/tcg/tcg.c b/tcg/tcg.c index b11b30bbec..b157e52d5c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -110,6 +110,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, #if TCG_TARGET_MAYBE_vec static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg dst, TCGReg src); +static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg dst, TCGReg base, intptr_t offset); static void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg dst, tcg_target_long arg); static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, unsigned vecl, @@ -121,6 +123,11 @@ static inline bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, { g_assert_not_reached(); } +static inline bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg dst, TCGReg base, intptr_t offset) +{ + g_assert_not_reached(); +} static inline void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg dst, tcg_target_long arg) { @@ -3412,6 +3419,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) TCGRegSet dup_out_regs, dup_in_regs; TCGTemp *its, *ots; TCGType itype, vtype; + intptr_t endian_fixup; unsigned vece; bool ok; @@ -3481,7 +3489,16 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) /* fall through */ case TEMP_VAL_MEM: - /* TODO: dup from memory */ +#ifdef HOST_WORDS_BIGENDIAN + endian_fixup = itype == TCG_TYPE_I32 ? 4 : 8; + endian_fixup -= 1 << vece; +#else + endian_fixup = 0; +#endif + if (tcg_out_dupm_vec(s, vtype, vece, ots->reg, its->mem_base->reg, + its->mem_offset + endian_fixup)) { + goto done; + } tcg_out_ld(s, itype, ots->reg, its->mem_base->reg, its->mem_offset); break; From patchwork Tue Mar 19 17:21:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160601 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4140553jad; Tue, 19 Mar 2019 10:28:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfRZde4ia+L9BrSCV43xRf5boUXLdPD/wQFImpIf0tBXMEg9I+8neFPfY3N8GSVizzzLXv X-Received: by 2002:a5d:400c:: with SMTP id n12mr4390424wrp.31.1553016524767; Tue, 19 Mar 2019 10:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016524; cv=none; d=google.com; s=arc-20160816; b=Y0rOxCBwwotUYiSseX9EDC1rDSXZnxuwrhJ10wf10gdha+vzksvEsLi2mmJgYMOxDJ ReySy0WBQ5LJSAlVvCY0yH2VxQYmAT4V2d1cdXpPSiYltaMNIAMOLeWKFfuDA2uLFI7P Kby/xp9w5Fopo729aktFr4M7VJVuM36UKPuVukoDkWRLgtVAeywD9xiqlqLSqncZOOrC cqBQkdeJmcyE3/wY7OPOImYMBycA1UNIhimP2O4o/I//zdFBSQ6ZTVW9pNF9MoesQx5w DRa2ggIuKGqIlsbLb2ebHnVfUjRzAj6fl89wfZXVhkB+WYQi9V2xgKHcsyX+E+2IbiCi fnXg== 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=7HN9lFxKcXUhGyOG3RVNLhXp/Rku+fRRHbhqaBGioDo=; b=thJciiirMa18pubtJ93PB9D066P3SbzKZ4l1NvsFKIpCV4/bO88LLRsUQbdUedmCnv 9Cq2nyes3BEBJzwWZ/XhXr+2GMncb7DYBEhMy1M1wsEaCleE+lu0QdETBv/9suA/Ks1O BhOihaHe3peUN+ffOtU25iMQJDppJg+u0OsvAhb0BOvjomnaFoANTRcsGBAcbqdX2WLA tbmO1dAs9j+7IB7eeRMow5E2ti9PPh6lJ5LIGD8fDjnv1BN9pTwpBOguR4cQuqUgJstB 9Gl5NFU4XJCAAmk4YLrbpsu1KguXNhYUKPld35S4VWjFDBk62YehAdaX/FCb0DhIhyS8 WwqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UTckg0q4; 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 u11si9661424wri.375.2019.03.19.10.28.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:28:44 -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=UTckg0q4; 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]:60750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IXb-0001PF-Mj for patch@linaro.org; Tue, 19 Mar 2019 13:28:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQr-0004gK-D8 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQp-0004Zn-RY for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:45 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:34411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQp-0004Z8-DH for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:43 -0400 Received: by mail-pg1-x543.google.com with SMTP id v12so14345656pgq.1 for ; Tue, 19 Mar 2019 10:21:43 -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=7HN9lFxKcXUhGyOG3RVNLhXp/Rku+fRRHbhqaBGioDo=; b=UTckg0q44s3F55jTIjQRtuQR4WHjYMfMnxke6Lg3KJoXyiK6YDwJhuJKeaT8J3BYFK 21r/MPUtKPjJSf3iy1IcUgGXmDTXSg7fYMAFlfGTlj0c++PMOiuYL1o82JuBCNmak1hB NDZX/YpA//cbNw/2RxypK0nZ8s8lIFs1M/GCz+8GbFjq3z4mkl9CT7Tu+FejgzAuk+Op da2wZ98ZdB/+YdDsMxHCn+zJ7Jgbt38KSy8//IC3Hjjb1OPqqyq1wOBpDLDCndKgy6Y1 RL/5vIaUrbjDOYr38xwAMzuQ7usTB103WgSMqlG9o3JyoY7TWcJw+e5G2HILfivJPHuS 79Dg== 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=7HN9lFxKcXUhGyOG3RVNLhXp/Rku+fRRHbhqaBGioDo=; b=Jtuc+1+gnevRaobCsQ93Xj6mWr7to16sfCrsykp8FwmhiFMdOcSuxfHifVazVlMLlV /sdu6eE7/FBJYNgZE8tnqyy83JNl5syrlFJIGfJVgwFxuUkatCR9t7V2YRiLVXmupY2Q gEq3wYFsSxRmXaRGVhKeMmKhZtINBC0rFmGu5PPehLhks9VbIPMHhW0LfX4wvdFh+g+y T7aHNIpXqAcTInImNIjdgC/4z6xKoUWqutFoTA9B7Eu4fboKCCUpvZC6FHqNg6dZasZv FTz0jUtTOxrGshFv3qjrMy+fkOatAbrI/UUIown32E7aKPac8z6BTM+1hVAS65oDkWSW wH7g== X-Gm-Message-State: APjAAAVA4w0dHfSM2T0RZIk3TWMhWf4gQSZNVqFhy97bgCkdRcbpG6FG K4aqn9pDXnJ6cz1ZwUJPAuN2TKcD7bY= X-Received: by 2002:aa7:90c7:: with SMTP id k7mr2989287pfk.186.1553016102117; Tue, 19 Mar 2019 10:21:42 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:18 -0700 Message-Id: <20190319172126.7502-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::543 Subject: [Qemu-devel] [PATCH for-4.1 v3 09/17] 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au 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.2 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index ae88df440a..2b88f2054e 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) @@ -457,6 +456,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) @@ -854,16 +857,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: @@ -893,10 +897,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) { @@ -917,16 +946,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); } } From patchwork Tue Mar 19 17:21:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160603 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4140862jad; Tue, 19 Mar 2019 10:29:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWmvkGaZQ3FHhdG2cy5iED2P+5ZecFuav5HhXtGEIzGVDs15fbBYJGet0EWko/pP+PoLil X-Received: by 2002:adf:f846:: with SMTP id d6mr18912336wrq.53.1553016542377; Tue, 19 Mar 2019 10:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016542; cv=none; d=google.com; s=arc-20160816; b=VnIFHHxNbWimc4raXoC9lpOP2eL+vbdPnb7Ou1ZS4UbO8Ks46dimVBMp6og/HYs4Bm DonXr4vQ1O4fOeVUXBX4UbWe3iejIc4FugRLQCoo6AzXYo/gyrOClkOE7kg4H+wwTXSf zuNIpJeBKxA1FGpNfEGcm2/BBzbAhDReSAnXf78/x4VeHNrG/u5THliqJ0UI9Qswzv8H WVYIUFVZw/J+ynpcTzu+JbBcsU9OSpt6Nx6DCSXzL7zSaKGvLJIj9FML2ttIjhimDAQ0 SC9tE0f0xUKw+Ssf++brxK+JrdoFSeerEV//fcEotFt9me2FMhkZXW3gfB9YpLM/jVZu MZ/g== 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=HZlr0Ka3i6hHKffdk3asFuuDEwowOmfTN7aIJMdZHeA=; b=LCcXPWzoptCr2ulvdrwBi/uiteB9vkmLbvcEunv0GSWMZ1AgQHZFBOJOQol/brkyYh oKwGMxDinQFTBE0BBJatICD9oxtXbZr8XJ1Mpjh5lrw84vSNNS2UEIFoyVEwMMFBeg8g K+HCnl4SCcpKPSL8S37lK3V/P8SSTCbn6P7BaHNLbQEe6bBJEdastL0JRBA4kUXlBbtx BRno0zxt4CYw3v3tHgU5sdPcWj8JMdwLS/PR4D1UHWoYKhUUzQG3uDLOfCe6xI9PxI16 SL5mB9zLfExV4KmnVHBaZr5CykUmQA+0gobQBiuakB2dIBiukxJs9MwzAQrpaWbhxbkP u4sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e5TDsfcs; 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 v13si6732711wrw.440.2019.03.19.10.29.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:29:02 -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=e5TDsfcs; 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]:60752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IXt-0001RS-AG for patch@linaro.org; Tue, 19 Mar 2019 13:29:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQu-0004gM-ER for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQr-0004b7-7p for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:46 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:45688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQq-0004a1-QL for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:45 -0400 Received: by mail-pf1-x443.google.com with SMTP id v21so14151274pfm.12 for ; Tue, 19 Mar 2019 10:21:44 -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=HZlr0Ka3i6hHKffdk3asFuuDEwowOmfTN7aIJMdZHeA=; b=e5TDsfcsxtbFGKC5ZhfodPRwXiNO6oKcSIEVaEM0dlieRf41SdTvH49nT/dz3ZFUxH zh5+kL7HKwuJaRiZk6xgnHk+lO+U+A63FbGduoUMZ1mKMMt6Q2X1inYKoE3bbszaGPDp gxkXQsAWNR9A7ZbA0Tej+umRwVdKtZUagLAgqGiz7lsFuf3r6jz50Ctyi2EcO5pEfDll x2rk0izz2p4mz0HrnAs86KLaioaBllcsre7nStpn7RYQlzFb1ODHz1D/Pl/hn6fgxtzr hw7/vNh9AlqUybeLDetJlfLwaFpo1Oxm5vLYdW/uSunvveLfUEtu8UsdzRcZ9Da6EznQ elgQ== 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=HZlr0Ka3i6hHKffdk3asFuuDEwowOmfTN7aIJMdZHeA=; b=Z3EXwVDKxYPVQ01bZCWRnVf0goIfdcgVVUYxeOHg6ZIe93GLhZQpXabVG20/+6Hniq RDOrnpochXEz3KbUyDd/LBm7m8ba7jdc9dLnX/5f3ENcAd/pSUJ12uS4Ka9MFJ4CJMdE SVuh/WwoUIlruv5ULthnlf1Gchbhe01b2VQ2IxRsbqc7rsL03uccXexwOnfhadr7/pQi 1GMmB5Ji7CuNNZEqaVzVmSLGVAQFdFpQnt1hVH1NKggB5lTvqT/0onCCHg9ZW+uLwACf s2rowDHx9mbYvuk+F2E0vC8452c+NWFtoqHqJNxwinfX2qOaC6aGxhHFisABSBjJ+27m P2qA== X-Gm-Message-State: APjAAAW+lA6Gfp2zIcXN+bIwzI5Hn4i6NEa00v6tggVjmpQsqHiU/JBU 0noJx0GiwEKRnbE5Aaz1LHCgWJBao7M= X-Received: by 2002:a62:b286:: with SMTP id z6mr2988721pfl.106.1553016103425; Tue, 19 Mar 2019 10:21:43 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:19 -0700 Message-Id: <20190319172126.7502-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::443 Subject: [Qemu-devel] [PATCH for-4.1 v3 10/17] tcg/aarch64: 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 38 ++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) -- 2.17.2 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index b34a1e5b06..d32e83ddf2 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -381,6 +381,9 @@ typedef enum { I3207_BLR = 0xd63f0000, I3207_RET = 0xd65f0000, + /* AdvSIMD load/store single structure. */ + I3303_LD1R = 0x0d40c000, + /* Load literal for loading the address at pc-relative offset */ I3305_LDR = 0x58000000, I3305_LDR_v64 = 0x5c000000, @@ -414,6 +417,8 @@ typedef enum { I3312_LDRVQ = 0x3c000000 | 3 << 22 | 0 << 30, I3312_STRVQ = 0x3c000000 | 2 << 22 | 0 << 30, + + I3312_TO_I3310 = 0x00200800, I3312_TO_I3313 = 0x01000000, @@ -566,7 +571,14 @@ static inline uint32_t tcg_in32(TCGContext *s) #define tcg_out_insn(S, FMT, OP, ...) \ glue(tcg_out_insn_,FMT)(S, glue(glue(glue(I,FMT),_),OP), ## __VA_ARGS__) -static void tcg_out_insn_3305(TCGContext *s, AArch64Insn insn, int imm19, TCGReg rt) +static void tcg_out_insn_3303(TCGContext *s, AArch64Insn insn, bool q, + TCGReg rt, TCGReg rn, unsigned size) +{ + tcg_out32(s, insn | (rt & 0x1f) | (rn << 5) | (size << 10) | (q << 30)); +} + +static void tcg_out_insn_3305(TCGContext *s, AArch64Insn insn, + int imm19, TCGReg rt) { tcg_out32(s, insn | (imm19 & 0x7ffff) << 5 | rt); } @@ -825,7 +837,29 @@ 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 (offset != 0) { + AArch64Insn add_insn = I3401_ADDI; + TCGReg temp = TCG_REG_TMP; + + if (offset < 0) { + add_insn = I3401_SUBI; + offset = -offset; + } + if (offset <= 0xfff) { + tcg_out_insn_3401(s, add_insn, 1, temp, base, offset); + } else if (offset <= 0xffffff) { + tcg_out_insn_3401(s, add_insn, 1, temp, base, offset & 0xfff000); + if (offset & 0xfff) { + tcg_out_insn_3401(s, add_insn, 1, temp, base, offset & 0xfff); + } + } else { + tcg_out_movi(s, TCG_TYPE_PTR, temp, offset); + tcg_out_insn(s, 3502, ADD, 1, temp, temp, base); + } + base = temp; + } + tcg_out_insn(s, 3303, LD1R, type == TCG_TYPE_V128, r, base, vece); + return true; } static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, From patchwork Tue Mar 19 17:21:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160594 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4138691jad; Tue, 19 Mar 2019 10:26:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaDR3mOyMARP6joFP6eZNm0Vj16NhhDY6xnJGWkeTc6IbizA3M2/dbz7V8A0pw/0Nhccgq X-Received: by 2002:a5d:428c:: with SMTP id k12mr9759442wrq.279.1553016402050; Tue, 19 Mar 2019 10:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016402; cv=none; d=google.com; s=arc-20160816; b=k7XbQVw2I7aIyZINnk0T3B1aaDSoE7iDskRfC0kTqb39hxgwI60ItZ7/XoBviC6bDT Ml74q3GcO9S4caOs5jEQCszWTfA84ToG7pip+CBRCvXO5H8eiQCD87Qmi1U0x84FrZ9V mSEcki0LDlXrb43qE76YLO0NZGLtNxEr0kAMmB4ogq6SPFzFAbOVjpp+tychGxm0EdPk 5uW3w7ZuF7FsXiLVo2FFmLq7TDqZIt5jlGNJWL0V6UdCVm1KxjZk2jTzJK+HrZjrTJ5M 29vMQaH8aJcCMt3wnHzdBlY14lfgMOh6wgpizGV5aABZrBhN2oVXV9EOUK5pTEsQ1OYl I4Tg== 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=J2Fue7yr+5hikiTIBV1JWpm8G0dcOsOrgkGb+z11kJk=; b=0s8QsY1o4x1yAOfRkpFB1NwOW0jQKRng/pnkaX9+uxw0HP6anS6kyQiPgGUQq9UpO1 DMPLVk/10fNKwxwCJ+ZWr0QKZi8+hXCctfUXbWh0VaHrlLvqX0zdhaK2W5EOBa9mXJQr lk9UodgUact6ip72/eoYsqKsuO0UR2VCNeWwpp2RF8DLp2EvBKDhUym1lVa1OUFNECep 0mUMYkCl+kFZu3czwYMbcNTBQ0x/zdQPOhd7pgXfEfIbMrk2TaGjoY6XH6haG2puVtFD f3quPCSJVwgFtvH3w+y6fpc0q11K68huAMfYP/5ts8OpUezpuCqfqblwQi4LY7aAVzNb POyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IBwQ+350; 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 j67si2007527wmb.77.2019.03.19.10.26.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:26:42 -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=IBwQ+350; 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]:60731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IVc-0008SE-TL for patch@linaro.org; Tue, 19 Mar 2019 13:26:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQu-0004gr-Tv for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQs-0004cq-Q7 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:48 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39414) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQs-0004bZ-5m for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:46 -0400 Received: by mail-pg1-x542.google.com with SMTP id h8so14304665pgp.6 for ; Tue, 19 Mar 2019 10:21:46 -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=J2Fue7yr+5hikiTIBV1JWpm8G0dcOsOrgkGb+z11kJk=; b=IBwQ+350zZoh2Zl1jVgstTHm2QiWh5Gsi1rbL/engkpyq0sK8BMgTdcnY0klRg+bUZ ySilx4Lrsu8BQhvGZLjXOkgFBOV+OBAil9IdSa2h6DwAeU7DyQtViNDT67r5vw+iP0OA 1cxJZneSeYY3PxTNDWxfDdZM3CoGmH7avJu2hoB5BIr/C+ghTJ+uRKS9PZezizMtWAt5 B4HbTA2fLCoFsBmUhEv2qW5dtRszDgXXCKmMYWLbZ1xk5l278wPWoCEi+n4A2Jnmx1SL je4IxTotfMHCxcA7U4j+WvOsu/kQSuJld8gX3k+upxva7zY+RVlBhi0WsIHAQKOck70B /lSA== 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=J2Fue7yr+5hikiTIBV1JWpm8G0dcOsOrgkGb+z11kJk=; b=fWX7tGWt2GXNLh8+50x9TWpIUKZpcs8fLpquWHAJStAFF7U1C5S8gHL0w2vKlwh8kt PjeGj0uh36uTX8NazLfKq1yRMP5ek+oROULn8laJwjjNA/z9VPQrtKhfndjG2nymXckO lsVXzzvm/jYqKXNb1XlMufAlii56qX0oPjUkFr+7Syd/EX9clPI4Vnc7f+kYgYnxXrtQ Xejql9k0FvI9Hqrn74zq+8k8DLY2UUOLehK9W8t4SiKicydAllRuHibN+plPn6RRrs6V TcwAS/j9J1Q1XEIQsCC0TrGirlAAp1ABl/Ia5PWodZlCp42V2ulHiGtIdVFuki6h+Z1Q tXZg== X-Gm-Message-State: APjAAAVZflLlYMtffQorcYslGWmy1ls1TBTw5TgiXwZkMtCGS43TRL7i 95lroQqR6YP6ao/rtAD3nQKA6fNcuM8= X-Received: by 2002:a62:d2ca:: with SMTP id c193mr3493280pfg.247.1553016104786; Tue, 19 Mar 2019 10:21:44 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:20 -0700 Message-Id: <20190319172126.7502-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::542 Subject: [Qemu-devel] [PATCH for-4.1 v3 11/17] tcg: Add INDEX_op_dup_mem_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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Allow the backend to expand dup from memory directly, instead of forcing the value into a temp first. This is especially important if integer/vector register moves do not exist. Note that officially tcg_out_dupm_vec is allowed to fail. If it did, we could fix this up relatively easily: VECE == 32/64: Load the value into a vector register, then dup. Both of these must work. VECE == 8/16: If the value happens to be at an offset such that an aligned load would place the desired value in the least significant end of the register, go ahead and load w/garbage in high bits. Load the value w/INDEX_op_ld{8,16}_i32. Attempt a move directly to vector reg, which may fail. Store the value into the backing store for OTS. Load the value into the vector reg w/TCG_TYPE_I32, which must work. Duplicate from the vector reg into itself, which must work. All of which is well and good, except that all supported hosts can support dupm for all vece, so all of the failure paths would be dead code and untestable. Signed-off-by: Richard Henderson --- tcg/tcg-op.h | 1 + tcg/tcg-opc.h | 1 + tcg/aarch64/tcg-target.inc.c | 4 ++ tcg/i386/tcg-target.inc.c | 4 ++ tcg/tcg-op-gvec.c | 88 +++++++++++++++++++----------------- tcg/tcg-op-vec.c | 11 +++++ tcg/tcg.c | 1 + 7 files changed, 69 insertions(+), 41 deletions(-) -- 2.17.2 diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index d3e51b15af..64cd3f58ef 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -950,6 +950,7 @@ void tcg_gen_atomic_umax_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); void tcg_gen_mov_vec(TCGv_vec, TCGv_vec); void tcg_gen_dup_i32_vec(unsigned vece, TCGv_vec, TCGv_i32); void tcg_gen_dup_i64_vec(unsigned vece, TCGv_vec, TCGv_i64); +void tcg_gen_dup_mem_vec(unsigned vece, TCGv_vec, TCGv_ptr, tcg_target_long); void tcg_gen_dup8i_vec(TCGv_vec, uint32_t); void tcg_gen_dup16i_vec(TCGv_vec, uint32_t); void tcg_gen_dup32i_vec(TCGv_vec, uint32_t); diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h index 4e0238ad1a..cc02e12b7e 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -217,6 +217,7 @@ DEF(dup2_vec, 1, 2, 0, IMPLVEC | IMPL(TCG_TARGET_REG_BITS == 32)) DEF(ld_vec, 1, 1, 1, IMPLVEC) DEF(st_vec, 0, 2, 1, IMPLVEC) +DEF(dupm_vec, 1, 1, 1, IMPLVEC) DEF(add_vec, 1, 2, 0, IMPLVEC) DEF(sub_vec, 1, 2, 0, IMPLVEC) diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index d32e83ddf2..bee7296713 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -2183,6 +2183,9 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_st_vec: tcg_out_st(s, type, a0, a1, a2); break; + case INDEX_op_dupm_vec: + tcg_out_dupm_vec(s, type, vece, a0, a1, a2); + break; case INDEX_op_add_vec: tcg_out_insn(s, 3616, ADD, is_q, vece, a0, a1, a2); break; @@ -2509,6 +2512,7 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) return &w_w; case INDEX_op_ld_vec: case INDEX_op_st_vec: + case INDEX_op_dupm_vec: return &w_r; case INDEX_op_dup_vec: return &w_wr; diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 2b88f2054e..54627e8d13 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -2820,6 +2820,9 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_st_vec: tcg_out_st(s, type, a0, a1, a2); break; + case INDEX_op_dupm_vec: + tcg_out_dupm_vec(s, type, vece, a0, a1, a2); + break; case INDEX_op_x86_shufps_vec: insn = OPC_SHUFPS; @@ -3102,6 +3105,7 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_ld_vec: case INDEX_op_st_vec: + case INDEX_op_dupm_vec: return &x_r; case INDEX_op_add_vec: diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c index 0996ef0812..f056018713 100644 --- a/tcg/tcg-op-gvec.c +++ b/tcg/tcg-op-gvec.c @@ -390,6 +390,40 @@ static TCGType choose_vector_type(TCGOpcode op, unsigned vece, uint32_t size, return 0; } +static void do_dup_store(TCGType type, uint32_t dofs, uint32_t oprsz, + uint32_t maxsz, TCGv_vec t_vec) +{ + uint32_t i = 0; + + switch (type) { + case TCG_TYPE_V256: + /* Recall that ARM SVE allows vector sizes that are not a + * power of 2, but always a multiple of 16. The intent is + * that e.g. size == 80 would be expanded with 2x32 + 1x16. + */ + for (; i + 32 <= oprsz; i += 32) { + tcg_gen_stl_vec(t_vec, cpu_env, dofs + i, TCG_TYPE_V256); + } + /* fallthru */ + case TCG_TYPE_V128: + for (; i + 16 <= oprsz; i += 16) { + tcg_gen_stl_vec(t_vec, cpu_env, dofs + i, TCG_TYPE_V128); + } + break; + case TCG_TYPE_V64: + for (; i < oprsz; i += 8) { + tcg_gen_stl_vec(t_vec, cpu_env, dofs + i, TCG_TYPE_V64); + } + break; + default: + g_assert_not_reached(); + } + + if (oprsz < maxsz) { + expand_clr(dofs + oprsz, maxsz - oprsz); + } +} + /* Set OPRSZ bytes at DOFS to replications of IN_32, IN_64 or IN_C. * Only one of IN_32 or IN_64 may be set; * IN_C is used if IN_32 and IN_64 are unset. @@ -429,49 +463,11 @@ static void do_dup(unsigned vece, uint32_t dofs, uint32_t oprsz, } else if (in_64) { tcg_gen_dup_i64_vec(vece, t_vec, in_64); } else { - switch (vece) { - case MO_8: - tcg_gen_dup8i_vec(t_vec, in_c); - break; - case MO_16: - tcg_gen_dup16i_vec(t_vec, in_c); - break; - case MO_32: - tcg_gen_dup32i_vec(t_vec, in_c); - break; - default: - tcg_gen_dup64i_vec(t_vec, in_c); - break; - } + tcg_gen_dupi_vec(vece, t_vec, in_c); } - - i = 0; - switch (type) { - case TCG_TYPE_V256: - /* Recall that ARM SVE allows vector sizes that are not a - * power of 2, but always a multiple of 16. The intent is - * that e.g. size == 80 would be expanded with 2x32 + 1x16. - */ - for (; i + 32 <= oprsz; i += 32) { - tcg_gen_stl_vec(t_vec, cpu_env, dofs + i, TCG_TYPE_V256); - } - /* fallthru */ - case TCG_TYPE_V128: - for (; i + 16 <= oprsz; i += 16) { - tcg_gen_stl_vec(t_vec, cpu_env, dofs + i, TCG_TYPE_V128); - } - break; - case TCG_TYPE_V64: - for (; i < oprsz; i += 8) { - tcg_gen_stl_vec(t_vec, cpu_env, dofs + i, TCG_TYPE_V64); - } - break; - default: - g_assert_not_reached(); - } - + do_dup_store(type, dofs, oprsz, maxsz, t_vec); tcg_temp_free_vec(t_vec); - goto done; + return; } /* Otherwise, inline with an integer type, unless "large". */ @@ -1287,6 +1283,16 @@ void tcg_gen_gvec_dup_i64(unsigned vece, uint32_t dofs, uint32_t oprsz, void tcg_gen_gvec_dup_mem(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t oprsz, uint32_t maxsz) { + if (vece <= MO_64) { + TCGType type = choose_vector_type(0, vece, oprsz, 0); + if (type != 0) { + TCGv_vec t_vec = tcg_temp_new_vec(type); + tcg_gen_dup_mem_vec(vece, t_vec, cpu_env, aofs); + do_dup_store(type, dofs, oprsz, maxsz, t_vec); + tcg_temp_free_vec(t_vec); + return; + } + } if (vece <= MO_32) { TCGv_i32 in = tcg_temp_new_i32(); switch (vece) { diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index cfb18682b1..ce7987b858 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -194,6 +194,17 @@ void tcg_gen_dup_i32_vec(unsigned vece, TCGv_vec r, TCGv_i32 a) vec_gen_2(INDEX_op_dup_vec, type, vece, ri, ai); } +void tcg_gen_dup_mem_vec(unsigned vece, TCGv_vec r, TCGv_ptr b, + tcg_target_long ofs) +{ + TCGArg ri = tcgv_vec_arg(r); + TCGArg bi = tcgv_ptr_arg(b); + TCGTemp *rt = arg_temp(ri); + TCGType type = rt->base_type; + + vec_gen_3(INDEX_op_dupm_vec, type, vece, ri, bi, ofs); +} + static void vec_gen_ldst(TCGOpcode opc, TCGv_vec r, TCGv_ptr b, TCGArg o) { TCGArg ri = tcgv_vec_arg(r); diff --git a/tcg/tcg.c b/tcg/tcg.c index b157e52d5c..47f36a358d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1601,6 +1601,7 @@ bool tcg_op_supported(TCGOpcode op) case INDEX_op_mov_vec: case INDEX_op_dup_vec: case INDEX_op_dupi_vec: + case INDEX_op_dupm_vec: case INDEX_op_ld_vec: case INDEX_op_st_vec: case INDEX_op_add_vec: From patchwork Tue Mar 19 17:21:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160609 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4147052jad; Tue, 19 Mar 2019 10:35:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeGR5DzIqazE5rGcvpYUyIFx02H0keSqFNU4d34ZJeaVct09WQVqcLLQwNexjYHiD+S4Cr X-Received: by 2002:a1c:c6ce:: with SMTP id w197mr3818396wmf.95.1553016912184; Tue, 19 Mar 2019 10:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016912; cv=none; d=google.com; s=arc-20160816; b=DGweV5n36mTVeYFqp1MjqjlEpWDwDnhPx/8aR+lWo8T/p/8stjfrAqJhbvyfLFe/ju G6329LD11qWEQTlYzuD3kfBlp9Z/nhe2f9mFWdjhlg1sufFH+WTi5eTQj7FEqXggxBI0 mwf+fdkWTO7xyN2iJ4AduQvvpxmBdxbLxuHQ+FhW9jTfTSKHeUdOorXTJYclCVyopLIi /y9O52M3p/YPwprnVDzypTF211Fm17OTy5tn9b9CEu7NTewdzn/NRghRbU9sfPRlFPc/ jjHrn1NZ7COKB3VhGooD+xusq09aMWwwjykzvvy/LmXaHgmF/pzogVfTyKwUkjPMyBfX QjmA== 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=fjX1Uwow3OOAygBbdL2Oek0cPoeEy3JZN38iqGTZCrk=; b=meJI5WYrFKMmXgKXIZT83VZjMsYveF4VOCrn/ev62gdfXbdps9PRpa9Pv4kUgML5dE xfwI5INSUw4VdlqlEqHlVwmWVn2V/eZ/E3Dvfxr6RfjKVSZO1ahxF4n9Vvv7/RXQudZg TRpSj/0P75hNDNWBuQY2C68ac/YzWK6ncEBGZcVSG18JOuZ3gcTaE1YkvX8hSFR6EWyu eZPTPpRniEUOJXM+aUpDVofAPO/QuRU9rujeEtSDuW/ujxDME/Z9UBI0IQIbOeGxhdKq vnzclpxEL45fmNoApexMquaEzrKqKkl+q5SPyQkU0HxKLhhuTVbCamhpv6nobbBPkIAM zcFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YMvBkpZ9; 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 j9si1991165wmh.164.2019.03.19.10.35.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:35:12 -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=YMvBkpZ9; 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]:60830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6Idr-0005HF-1S for patch@linaro.org; Tue, 19 Mar 2019 13:35:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IR2-0004oC-9u for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:22:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQv-0004eq-0d for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:56 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:39310) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQu-0004df-79 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:48 -0400 Received: by mail-pf1-x442.google.com with SMTP id i17so4400014pfo.6 for ; Tue, 19 Mar 2019 10:21:48 -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=fjX1Uwow3OOAygBbdL2Oek0cPoeEy3JZN38iqGTZCrk=; b=YMvBkpZ9mOOyMhgyWaCvsFVEg3nPA5ttiS3dePa2Gtmrn6Tju3Y5KkxF5liHn09Dp/ kkIXHWb/TJTRe+DT1LXdWp+V/2AGak3FsZhqxDpYonF+4FHwFygUgmMhJwIqbHfmMe7k FIA2Hi5H2Nk4rFeIIQc+5rQUZ7y0xjMO00e26HCB7oNwkaCbU0Y7r6zkqL/qahyr8ZA2 2Z+KyBqm/66Ue6mmT21m7VbJkZ9Ty4v8jF+UHdh3+EUFVuMsnLaIPBZBgCeWQc23MqGX 4gOtjj5z/3nkP0+bw0qvNpVrWRPQy31vH1H+BRqvfSYPAkLM1CmdJs5GmzQzs9lMRKF7 0E1w== 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=fjX1Uwow3OOAygBbdL2Oek0cPoeEy3JZN38iqGTZCrk=; b=lv6A+QCGFW5AqygHFc+KyiQhV5T4f58CXwWMLJn+wTAQbRdROjkqnUCmdun85rOvK7 J3+U4FaOWmUoRIUq9nzHmlAmIxIZuh+97DO1GG0uDb3jptHvi0QJmqk8UO+/GT1/DQfb pmbja/nllWmPmcVqtE0rfI1ifQC0sRBOD4HRloW+vbb8CargvWBRoNaHx/qVlPOz2je4 RIdvm9EGYxt2fZmACWmBUYk043tPV+leE1qUgqSY/rux+NcjDX59h/cGtmwFr2Vgix9k Pq6qrDm5cQqN00Ug1OzH0aLgOPyNmItJwXryjTD9npJALbaniStcViMeDFugZ9JJi4zT PdYA== X-Gm-Message-State: APjAAAVjM0R9JvdNNGMu8X2vBKP70ThyCbkFEQEl+REwKXwiVP7nHOly lEhYbdj2E1U5ycAIwyNcXK2D47nLBA8= X-Received: by 2002:a62:3996:: with SMTP id u22mr20084259pfj.28.1553016106328; Tue, 19 Mar 2019 10:21:46 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:21 -0700 Message-Id: <20190319172126.7502-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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 for-4.1 v3 12/17] tcg/ppc: Initial backend support for Altivec 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There are a few missing operations yet, like expansion of multiply and shifts. But this has move, load, store, and basic arithmetic. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 33 +- tcg/ppc/tcg-target.opc.h | 3 + tcg/ppc/tcg-target.inc.c | 721 +++++++++++++++++++++++++++++++++++---- 3 files changed, 685 insertions(+), 72 deletions(-) create mode 100644 tcg/ppc/tcg-target.opc.h -- 2.17.2 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 52c1bb04b1..3f669de7a7 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -31,7 +31,7 @@ # define TCG_TARGET_REG_BITS 32 #endif -#define TCG_TARGET_NB_REGS 32 +#define TCG_TARGET_NB_REGS 64 #define TCG_TARGET_INSN_UNIT_SIZE 4 #define TCG_TARGET_TLB_DISPLACEMENT_BITS 16 @@ -45,10 +45,20 @@ typedef enum { TCG_REG_R24, TCG_REG_R25, TCG_REG_R26, TCG_REG_R27, TCG_REG_R28, TCG_REG_R29, TCG_REG_R30, TCG_REG_R31, + TCG_REG_V0, TCG_REG_V1, TCG_REG_V2, TCG_REG_V3, + TCG_REG_V4, TCG_REG_V5, TCG_REG_V6, TCG_REG_V7, + TCG_REG_V8, TCG_REG_V9, TCG_REG_V10, TCG_REG_V11, + TCG_REG_V12, TCG_REG_V13, TCG_REG_V14, TCG_REG_V15, + TCG_REG_V16, TCG_REG_V17, TCG_REG_V18, TCG_REG_V19, + TCG_REG_V20, TCG_REG_V21, TCG_REG_V22, TCG_REG_V23, + TCG_REG_V24, TCG_REG_V25, TCG_REG_V26, TCG_REG_V27, + TCG_REG_V28, TCG_REG_V29, TCG_REG_V30, TCG_REG_V31, + TCG_REG_CALL_STACK = TCG_REG_R1, TCG_AREG0 = TCG_REG_R27 } TCGReg; +extern bool have_isa_altivec; extern bool have_isa_2_06; extern bool have_isa_3_00; @@ -124,6 +134,27 @@ extern bool have_isa_3_00; #define TCG_TARGET_HAS_mulsh_i64 1 #endif +/* + * While technically Altivec could support V64, it has no 64-bit store + * instruction, which makes the generate code quite large. + */ +#define TCG_TARGET_HAS_v64 0 +#define TCG_TARGET_HAS_v128 have_isa_altivec +#define TCG_TARGET_HAS_v256 0 + +#define TCG_TARGET_HAS_andc_vec 1 +#define TCG_TARGET_HAS_orc_vec 0 +#define TCG_TARGET_HAS_not_vec 1 +#define TCG_TARGET_HAS_neg_vec 0 +#define TCG_TARGET_HAS_shi_vec 0 +#define TCG_TARGET_HAS_shs_vec 0 +#define TCG_TARGET_HAS_shv_vec 0 +#define TCG_TARGET_HAS_cmp_vec 1 +#define TCG_TARGET_HAS_mul_vec 0 +#define TCG_TARGET_HAS_sat_vec 1 +#define TCG_TARGET_HAS_minmax_vec 1 +#define TCG_TARGET_HAS_dupm_vec 1 + void flush_icache_range(uintptr_t start, uintptr_t stop); void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/ppc/tcg-target.opc.h b/tcg/ppc/tcg-target.opc.h new file mode 100644 index 0000000000..4816a6c3d4 --- /dev/null +++ b/tcg/ppc/tcg-target.opc.h @@ -0,0 +1,3 @@ +/* Target-specific opcodes for host vector expansion. These will be + emitted by tcg_expand_vec_op. For those familiar with GCC internals, + consider these to be UNSPEC with names. */ diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index ec8e336be8..70a64dd214 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -42,6 +42,9 @@ # define TCG_REG_TMP1 TCG_REG_R12 #endif +#define TCG_VEC_TMP1 TCG_REG_V0 +#define TCG_VEC_TMP2 TCG_REG_V1 + #define TCG_REG_TB TCG_REG_R31 #define USE_REG_TB (TCG_TARGET_REG_BITS == 64) @@ -61,6 +64,7 @@ static tcg_insn_unit *tb_ret_addr; +bool have_isa_altivec; bool have_isa_2_06; bool have_isa_3_00; @@ -72,39 +76,15 @@ bool have_isa_3_00; #endif #ifdef CONFIG_DEBUG_TCG -static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { - "r0", - "r1", - "r2", - "r3", - "r4", - "r5", - "r6", - "r7", - "r8", - "r9", - "r10", - "r11", - "r12", - "r13", - "r14", - "r15", - "r16", - "r17", - "r18", - "r19", - "r20", - "r21", - "r22", - "r23", - "r24", - "r25", - "r26", - "r27", - "r28", - "r29", - "r30", - "r31" +static const char tcg_target_reg_names[TCG_TARGET_NB_REGS][4] = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", + "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", + "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", + "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", + "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", + "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", }; #endif @@ -139,6 +119,26 @@ static const int tcg_target_reg_alloc_order[] = { TCG_REG_R5, TCG_REG_R4, TCG_REG_R3, + + /* V0 and V1 reserved as temporaries; V20 - V31 are call-saved */ + TCG_REG_V2, /* call clobbered, vectors */ + TCG_REG_V3, + TCG_REG_V4, + TCG_REG_V5, + TCG_REG_V6, + TCG_REG_V7, + TCG_REG_V8, + TCG_REG_V9, + TCG_REG_V10, + TCG_REG_V11, + TCG_REG_V12, + TCG_REG_V13, + TCG_REG_V14, + TCG_REG_V15, + TCG_REG_V16, + TCG_REG_V17, + TCG_REG_V18, + TCG_REG_V19, }; static const int tcg_target_call_iarg_regs[] = { @@ -233,6 +233,10 @@ static const char *target_parse_constraint(TCGArgConstraint *ct, ct->ct |= TCG_CT_REG; ct->u.regs = 0xffffffff; break; + case 'v': + ct->ct |= TCG_CT_REG; + ct->u.regs = 0xffffffff00000000ull; + break; case 'L': /* qemu_ld constraint */ ct->ct |= TCG_CT_REG; ct->u.regs = 0xffffffff; @@ -320,6 +324,7 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define XO31(opc) (OPCD(31)|((opc)<<1)) #define XO58(opc) (OPCD(58)|(opc)) #define XO62(opc) (OPCD(62)|(opc)) +#define VX4(opc) (OPCD(4)|(opc)) #define B OPCD( 18) #define BC OPCD( 16) @@ -461,6 +466,72 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define NOP ORI /* ori 0,0,0 */ +#define LVX XO31(103) +#define LVEBX XO31(7) +#define LVEHX XO31(39) +#define LVEWX XO31(71) + +#define STVX XO31(231) +#define STVEWX XO31(199) + +#define VADDSBS VX4(768) +#define VADDUBS VX4(512) +#define VADDUBM VX4(0) +#define VADDSHS VX4(832) +#define VADDUHS VX4(576) +#define VADDUHM VX4(64) +#define VADDSWS VX4(896) +#define VADDUWS VX4(640) +#define VADDUWM VX4(128) + +#define VSUBSBS VX4(1792) +#define VSUBUBS VX4(1536) +#define VSUBUBM VX4(1024) +#define VSUBSHS VX4(1856) +#define VSUBUHS VX4(1600) +#define VSUBUHM VX4(1088) +#define VSUBSWS VX4(1920) +#define VSUBUWS VX4(1664) +#define VSUBUWM VX4(1152) + +#define VMAXSB VX4(258) +#define VMAXSH VX4(322) +#define VMAXSW VX4(386) +#define VMAXUB VX4(2) +#define VMAXUH VX4(66) +#define VMAXUW VX4(130) +#define VMINSB VX4(770) +#define VMINSH VX4(834) +#define VMINSW VX4(898) +#define VMINUB VX4(514) +#define VMINUH VX4(578) +#define VMINUW VX4(642) + +#define VCMPEQUB VX4(6) +#define VCMPEQUH VX4(70) +#define VCMPEQUW VX4(134) +#define VCMPGTSB VX4(774) +#define VCMPGTSH VX4(838) +#define VCMPGTSW VX4(902) +#define VCMPGTUB VX4(518) +#define VCMPGTUH VX4(582) +#define VCMPGTUW VX4(646) + +#define VAND VX4(1028) +#define VANDC VX4(1092) +#define VNOR VX4(1284) +#define VOR VX4(1156) +#define VXOR VX4(1220) + +#define VSPLTB VX4(524) +#define VSPLTH VX4(588) +#define VSPLTW VX4(652) +#define VSPLTISB VX4(780) +#define VSPLTISH VX4(844) +#define VSPLTISW VX4(908) + +#define VSLDOI VX4(44) + #define RT(r) ((r)<<21) #define RS(r) ((r)<<21) #define RA(r) ((r)<<16) @@ -473,6 +544,11 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define MB64(b) ((b)<<5) #define FXM(b) (1 << (19 - (b))) +#define VRT(r) (((r) & 31) << 21) +#define VRA(r) (((r) & 31) << 16) +#define VRB(r) (((r) & 31) << 11) +#define VRC(r) (((r) & 31) << 6) + #define LK 1 #define TAB(t, a, b) (RT(t) | RA(a) | RB(b)) @@ -530,6 +606,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, { tcg_insn_unit *target; tcg_insn_unit old; + int16_t lo; + int32_t hi; value += addend; target = (tcg_insn_unit *)value; @@ -540,22 +618,31 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, case R_PPC_REL24: return reloc_pc24(code_ptr, target); case R_PPC_ADDR16: - /* We are abusing this relocation type. This points to a pair - of insns, addis + load. If the displacement is small, we - can nop out the addis. */ + /* + * We are abusing this relocation type. This points to a pair + * of insns, addis + load. If the displacement is small, we + * can nop out the addis. + */ if (value == (int16_t)value) { code_ptr[0] = NOP; old = deposit32(code_ptr[1], 0, 16, value); code_ptr[1] = deposit32(old, 16, 5, TCG_REG_TB); - } else { - int16_t lo = value; - int hi = value - lo; - if (hi + lo != value) { - return false; - } - code_ptr[0] = deposit32(code_ptr[0], 0, 16, hi >> 16); - code_ptr[1] = deposit32(code_ptr[1], 0, 16, lo); + break; } + /* fall through */ + case R_PPC_ADDR32: + /* + * We are abusing this relocation type. Again, this points to + * a pair of insns, lis + load. This is an absolute address + * relocation for PPC32 so the lis cannot be removed. + */ + lo = value; + hi = value - lo; + if (hi + lo != value) { + return false; + } + code_ptr[0] = deposit32(code_ptr[0], 0, 16, hi >> 16); + code_ptr[1] = deposit32(code_ptr[1], 0, 16, lo); break; default: g_assert_not_reached(); @@ -568,9 +655,29 @@ static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) { - tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); - if (ret != arg) { - tcg_out32(s, OR | SAB(arg, ret, arg)); + if (ret == arg) { + return true; + } + switch (type) { + case TCG_TYPE_I64: + tcg_debug_assert(TCG_TARGET_REG_BITS == 64); + /* fallthru */ + case TCG_TYPE_I32: + if (ret < 32 && arg < 32) { + tcg_out32(s, OR | SAB(arg, ret, arg)); + break; + } else if (ret < 32 || arg < 32) { + /* Altivec does not support vector/integer moves. */ + return false; + } + /* fallthru */ + case TCG_TYPE_V64: + case TCG_TYPE_V128: + tcg_debug_assert(ret >= 32 && arg >= 32); + tcg_out32(s, VOR | VRT(ret) | VRA(arg) | VRB(arg)); + break; + default: + g_assert_not_reached(); } return true; } @@ -720,10 +827,73 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, } } -static inline void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, - tcg_target_long arg) +static void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg ret, + tcg_target_long val) { - tcg_out_movi_int(s, type, ret, arg, false); + uint32_t load_insn; + int rel, base, low; + intptr_t add; + + low = (int8_t)val; + if (low >= -16 && low < 16) { + if (val == (tcg_target_long)dup_const(MO_8, low)) { + tcg_out32(s, VSPLTISB | VRT(ret) | ((val & 31) << 16)); + return; + } + if (val == (tcg_target_long)dup_const(MO_16, low)) { + tcg_out32(s, VSPLTISH | VRT(ret) | ((val & 31) << 16)); + return; + } + if (val == (tcg_target_long)dup_const(MO_32, low)) { + tcg_out32(s, VSPLTISW | VRT(ret) | ((val & 31) << 16)); + return; + } + } + + /* + * Otherwise we must load the value from the constant pool. + */ + if (USE_REG_TB) { + base = TCG_REG_TB; + rel = R_PPC_ADDR16; + add = -(intptr_t)s->code_gen_ptr; + } else { + base = 0; + rel = R_PPC_ADDR32; + add = 0; + } + + load_insn = LVX | VRT(ret) | RB(TCG_REG_TMP1); + if (TCG_TARGET_REG_BITS == 64) { + new_pool_l2(s, rel, s->code_ptr, add, val, val); + } else { + new_pool_l4(s, rel, s->code_ptr, add, val, val, val, val); + } + + tcg_out32(s, ADDIS | TAI(TCG_REG_TMP1, base, 0)); + tcg_out32(s, ADDI | TAI(TCG_REG_TMP1, TCG_REG_TMP1, 0)); + tcg_out32(s, load_insn); +} + +static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, + tcg_target_long arg) +{ + switch (type) { + case TCG_TYPE_I32: + case TCG_TYPE_I64: + tcg_debug_assert(ret < 32); + tcg_out_movi_int(s, type, ret, arg, false); + break; + + case TCG_TYPE_V64: + case TCG_TYPE_V128: + tcg_debug_assert(ret >= 32); + tcg_out_dupi_vec(s, type, ret, arg); + break; + + default: + g_assert_not_reached(); + } } static bool mask_operand(uint32_t c, int *mb, int *me) @@ -876,7 +1046,7 @@ static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, } /* For unaligned, or very large offsets, use the indexed form. */ - if (offset & align || offset != (int32_t)offset) { + if (offset & align || offset != (int32_t)offset || opi == 0) { if (rs == base) { rs = TCG_REG_R0; } @@ -907,32 +1077,96 @@ static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, } } -static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, - TCGReg arg1, intptr_t arg2) +static void tcg_out_vsldoi(TCGContext *s, TCGReg ret, + TCGReg va, TCGReg vb, int shb) { - int opi, opx; - - tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); - if (type == TCG_TYPE_I32) { - opi = LWZ, opx = LWZX; - } else { - opi = LD, opx = LDX; - } - tcg_out_mem_long(s, opi, opx, ret, arg1, arg2); + tcg_out32(s, VSLDOI | VRT(ret) | VRA(va) | VRB(vb) | (shb << 6)); } -static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, - TCGReg arg1, intptr_t arg2) +static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, + TCGReg base, intptr_t offset) { - int opi, opx; + int shift; - tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); - if (type == TCG_TYPE_I32) { - opi = STW, opx = STWX; - } else { - opi = STD, opx = STDX; + switch (type) { + case TCG_TYPE_I32: + if (ret < 32) { + tcg_out_mem_long(s, LWZ, LWZX, ret, base, offset); + break; + } + assert((offset & 3) == 0); + tcg_out_mem_long(s, 0, LVEWX, ret & 31, base, offset); + shift = (offset - 4) & 0xc; + if (shift) { + tcg_out_vsldoi(s, ret, ret, ret, shift); + } + break; + case TCG_TYPE_I64: + if (ret < 32) { + tcg_out_mem_long(s, LD, LDX, ret, base, offset); + break; + } + /* fallthru */ + case TCG_TYPE_V64: + tcg_debug_assert(ret >= 32); + assert((offset & 7) == 0); + tcg_out_mem_long(s, 0, LVX, ret & 31, base, offset & -16); + if (offset & 8) { + tcg_out_vsldoi(s, ret, ret, ret, 8); + } + break; + case TCG_TYPE_V128: + tcg_debug_assert(ret >= 32); + assert((offset & 15) == 0); + tcg_out_mem_long(s, 0, LVX, ret & 31, base, offset); + break; + default: + g_assert_not_reached(); + } +} + +static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, + TCGReg base, intptr_t offset) +{ + int shift; + + switch (type) { + case TCG_TYPE_I32: + if (arg < 32) { + tcg_out_mem_long(s, STW, STWX, arg, base, offset); + break; + } + assert((offset & 3) == 0); + shift = (offset - 4) & 0xc; + if (shift) { + tcg_out_vsldoi(s, TCG_VEC_TMP1, arg, arg, shift); + arg = TCG_VEC_TMP1; + } + tcg_out_mem_long(s, 0, STVEWX, arg & 31, base, offset); + break; + case TCG_TYPE_I64: + if (arg < 32) { + tcg_out_mem_long(s, STD, STDX, arg, base, offset); + break; + } + /* fallthru */ + case TCG_TYPE_V64: + tcg_debug_assert(arg >= 32); + assert((offset & 7) == 0); + if (offset & 8) { + tcg_out_vsldoi(s, TCG_VEC_TMP1, arg, arg, 8); + arg = TCG_VEC_TMP1; + } + tcg_out_mem_long(s, 0, STVEWX, arg & 31, base, offset); + tcg_out_mem_long(s, 0, STVEWX, arg & 31, base, offset + 4); + break; + case TCG_TYPE_V128: + tcg_debug_assert(arg >= 32); + tcg_out_mem_long(s, 0, STVX, arg & 31, base, offset); + break; + default: + g_assert_not_reached(); } - tcg_out_mem_long(s, opi, opx, arg, arg1, arg2); } static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, @@ -2618,6 +2852,292 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, } } +int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) +{ + switch (opc) { + case INDEX_op_and_vec: + case INDEX_op_or_vec: + case INDEX_op_xor_vec: + case INDEX_op_andc_vec: + case INDEX_op_not_vec: + return 1; + case INDEX_op_add_vec: + case INDEX_op_sub_vec: + case INDEX_op_smax_vec: + case INDEX_op_smin_vec: + case INDEX_op_umax_vec: + case INDEX_op_umin_vec: + case INDEX_op_ssadd_vec: + case INDEX_op_sssub_vec: + case INDEX_op_usadd_vec: + case INDEX_op_ussub_vec: + return vece <= MO_32; + case INDEX_op_cmp_vec: + return vece <= MO_32 ? -1 : 0; + default: + return 0; + } +} + +static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg dst, TCGReg src) +{ + tcg_debug_assert(dst >= 32); + tcg_debug_assert(src >= 32); + + /* + * Recall we use (or emulate) VSX integer loads, so the integer is + * right justified within the left (zero-index) double-word. + */ + switch (vece) { + case MO_8: + tcg_out32(s, VSPLTB | VRT(dst) | VRB(src) | (7 << 16)); + break; + case MO_16: + tcg_out32(s, VSPLTH | VRT(dst) | VRB(src) | (3 << 16)); + break; + case MO_32: + tcg_out32(s, VSPLTW | VRT(dst) | VRB(src) | (1 << 16)); + break; + case MO_64: + tcg_out_vsldoi(s, TCG_VEC_TMP1, src, src, 8); + tcg_out_vsldoi(s, dst, TCG_VEC_TMP1, src, 8); + break; + default: + g_assert_not_reached(); + } + return true; +} + +static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, + TCGReg out, TCGReg base, intptr_t offset) +{ + int elt; + + tcg_debug_assert(out >= 32); + out &= 31; + switch (vece) { + case MO_8: + tcg_out_mem_long(s, 0, LVEBX, out, base, offset); + elt = extract32(offset, 0, 4); +#ifndef HOST_WORDS_BIGENDIAN + elt ^= 15; +#endif + tcg_out32(s, VSPLTB | VRT(out) | VRB(out) | (elt << 16)); + break; + case MO_16: + assert((offset & 1) == 0); + tcg_out_mem_long(s, 0, LVEHX, out, base, offset); + elt = extract32(offset, 1, 3); +#ifndef HOST_WORDS_BIGENDIAN + elt ^= 7; +#endif + tcg_out32(s, VSPLTH | VRT(out) | VRB(out) | (elt << 16)); + break; + case MO_32: + assert((offset & 3) == 0); + tcg_out_mem_long(s, 0, LVEWX, out, base, offset); + elt = extract32(offset, 2, 2); +#ifndef HOST_WORDS_BIGENDIAN + elt ^= 3; +#endif + tcg_out32(s, VSPLTW | VRT(out) | VRB(out) | (elt << 16)); + break; + case MO_64: + assert((offset & 7) == 0); + tcg_out_mem_long(s, 0, LVX, out, base, offset & -16); + tcg_out_vsldoi(s, TCG_VEC_TMP1, out, out, 8); + elt = extract32(offset, 3, 1); +#ifndef HOST_WORDS_BIGENDIAN + elt = !elt; +#endif + if (elt) { + tcg_out_vsldoi(s, out, out, TCG_VEC_TMP1, 8); + } else { + tcg_out_vsldoi(s, out, TCG_VEC_TMP1, out, 8); + } + break; + default: + g_assert_not_reached(); + } + return true; +} + +static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, + unsigned vecl, unsigned vece, + const TCGArg *args, const int *const_args) +{ + static const uint32_t + add_op[4] = { VADDUBM, VADDUHM, VADDUWM, 0 }, + sub_op[4] = { VSUBUBM, VSUBUHM, VSUBUWM, 0 }, + eq_op[4] = { VCMPEQUB, VCMPEQUH, VCMPEQUW, 0 }, + gts_op[4] = { VCMPGTSB, VCMPGTSH, VCMPGTSW, 0 }, + gtu_op[4] = { VCMPGTUB, VCMPGTUH, VCMPGTUW, 0 }, + ssadd_op[4] = { VADDSBS, VADDSHS, VADDSWS, 0 }, + usadd_op[4] = { VADDUBS, VADDUHS, VADDUWS, 0 }, + sssub_op[4] = { VSUBSBS, VSUBSHS, VSUBSWS, 0 }, + ussub_op[4] = { VSUBUBS, VSUBUHS, VSUBUWS, 0 }, + umin_op[4] = { VMINUB, VMINUH, VMINUW, 0 }, + smin_op[4] = { VMINSB, VMINSH, VMINSW, 0 }, + umax_op[4] = { VMAXUB, VMAXUH, VMAXUW, 0 }, + smax_op[4] = { VMAXSB, VMAXSH, VMAXSW, 0 }; + + TCGType type = vecl + TCG_TYPE_V64; + TCGArg a0 = args[0], a1 = args[1], a2 = args[2]; + uint32_t insn; + + switch (opc) { + case INDEX_op_ld_vec: + tcg_out_ld(s, type, a0, a1, a2); + return; + case INDEX_op_st_vec: + tcg_out_st(s, type, a0, a1, a2); + return; + case INDEX_op_dupm_vec: + tcg_out_dupm_vec(s, type, vece, a0, a1, a2); + return; + + case INDEX_op_add_vec: + insn = add_op[vece]; + break; + case INDEX_op_sub_vec: + insn = sub_op[vece]; + break; + case INDEX_op_ssadd_vec: + insn = ssadd_op[vece]; + break; + case INDEX_op_sssub_vec: + insn = sssub_op[vece]; + break; + case INDEX_op_usadd_vec: + insn = usadd_op[vece]; + break; + case INDEX_op_ussub_vec: + insn = ussub_op[vece]; + break; + case INDEX_op_smin_vec: + insn = smin_op[vece]; + break; + case INDEX_op_umin_vec: + insn = umin_op[vece]; + break; + case INDEX_op_smax_vec: + insn = smax_op[vece]; + break; + case INDEX_op_umax_vec: + insn = umax_op[vece]; + break; + case INDEX_op_and_vec: + insn = VAND; + break; + case INDEX_op_or_vec: + insn = VOR; + break; + case INDEX_op_xor_vec: + insn = VXOR; + break; + case INDEX_op_andc_vec: + insn = VANDC; + break; + case INDEX_op_not_vec: + insn = VNOR; + a2 = a1; + break; + + case INDEX_op_cmp_vec: + switch (args[3]) { + case TCG_COND_EQ: + insn = eq_op[vece]; + break; + case TCG_COND_GT: + insn = gts_op[vece]; + break; + case TCG_COND_GTU: + insn = gtu_op[vece]; + break; + default: + g_assert_not_reached(); + } + break; + + case INDEX_op_mov_vec: /* Always emitted via tcg_out_mov. */ + case INDEX_op_dupi_vec: /* Always emitted via tcg_out_movi. */ + case INDEX_op_dup_vec: /* Always emitted via tcg_out_dup_vec. */ + default: + g_assert_not_reached(); + } + + tcg_debug_assert(insn != 0); + tcg_out32(s, insn | VRT(a0) | VRA(a1) | VRB(a2)); +} + +static void expand_vec_cmp(TCGType type, unsigned vece, TCGv_vec v0, + TCGv_vec v1, TCGv_vec v2, TCGCond cond) +{ + bool need_swap = false, need_inv = false; + + tcg_debug_assert(vece <= MO_32); + + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_GT: + case TCG_COND_GTU: + break; + case TCG_COND_NE: + case TCG_COND_LE: + case TCG_COND_LEU: + need_inv = true; + break; + case TCG_COND_LT: + case TCG_COND_LTU: + need_swap = true; + break; + case TCG_COND_GE: + case TCG_COND_GEU: + need_swap = need_inv = true; + break; + default: + g_assert_not_reached(); + } + + if (need_inv) { + cond = tcg_invert_cond(cond); + } + if (need_swap) { + TCGv_vec t1; + t1 = v1, v1 = v2, v2 = t1; + cond = tcg_swap_cond(cond); + } + + vec_gen_4(INDEX_op_cmp_vec, type, vece, tcgv_vec_arg(v0), + tcgv_vec_arg(v1), tcgv_vec_arg(v2), cond); + + if (need_inv) { + tcg_gen_not_vec(vece, v0, v0); + } +} + +void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, + TCGArg a0, ...) +{ + va_list va; + TCGv_vec v0, v1, v2; + + va_start(va, a0); + v0 = temp_tcgv_vec(arg_temp(a0)); + v1 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg))); + v2 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg))); + + switch (opc) { + case INDEX_op_cmp_vec: + expand_vec_cmp(type, vece, v0, v1, v2, va_arg(va, TCGArg)); + break; + default: + g_assert_not_reached(); + } + va_end(va); +} + static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) { static const TCGTargetOpDef r = { .args_ct_str = { "r" } }; @@ -2655,6 +3175,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) = { .args_ct_str = { "r", "r", "r", "r", "rI", "rZM" } }; static const TCGTargetOpDef sub2 = { .args_ct_str = { "r", "r", "rI", "rZM", "r", "r" } }; + static const TCGTargetOpDef v_r = { .args_ct_str = { "v", "r" } }; + static const TCGTargetOpDef v_v = { .args_ct_str = { "v", "v" } }; + static const TCGTargetOpDef v_v_v = { .args_ct_str = { "v", "v", "v" } }; switch (op) { case INDEX_op_goto_ptr: @@ -2790,6 +3313,32 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) return (TCG_TARGET_REG_BITS == 64 ? &S_S : TARGET_LONG_BITS == 32 ? &S_S_S : &S_S_S_S); + case INDEX_op_add_vec: + case INDEX_op_sub_vec: + case INDEX_op_mul_vec: + case INDEX_op_and_vec: + case INDEX_op_or_vec: + case INDEX_op_xor_vec: + case INDEX_op_andc_vec: + case INDEX_op_orc_vec: + case INDEX_op_cmp_vec: + case INDEX_op_ssadd_vec: + case INDEX_op_sssub_vec: + case INDEX_op_usadd_vec: + case INDEX_op_ussub_vec: + case INDEX_op_smax_vec: + case INDEX_op_smin_vec: + case INDEX_op_umax_vec: + case INDEX_op_umin_vec: + return &v_v_v; + case INDEX_op_not_vec: + case INDEX_op_dup_vec: + return &v_v; + case INDEX_op_ld_vec: + case INDEX_op_st_vec: + case INDEX_op_dupm_vec: + return &v_r; + default: return NULL; } @@ -2800,6 +3349,9 @@ static void tcg_target_init(TCGContext *s) unsigned long hwcap = qemu_getauxval(AT_HWCAP); unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2); + if (hwcap & PPC_FEATURE_HAS_ALTIVEC) { + have_isa_altivec = true; + } if (hwcap & PPC_FEATURE_ARCH_2_06) { have_isa_2_06 = true; } @@ -2811,6 +3363,10 @@ static void tcg_target_init(TCGContext *s) tcg_target_available_regs[TCG_TYPE_I32] = 0xffffffff; tcg_target_available_regs[TCG_TYPE_I64] = 0xffffffff; + if (have_isa_altivec) { + tcg_target_available_regs[TCG_TYPE_V64] = 0xffffffff00000000ull; + tcg_target_available_regs[TCG_TYPE_V128] = 0xffffffff00000000ull; + } tcg_target_call_clobber_regs = 0; tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R0); @@ -2826,6 +3382,27 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R11); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R12); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V0); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V1); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V2); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V3); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V4); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V5); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V6); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V7); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V8); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V9); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V10); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V11); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V12); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V13); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V14); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V15); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V16); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V17); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V18); + tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V19); + s->reserved_regs = 0; tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0); /* tcg temp */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_R1); /* stack pointer */ @@ -2836,6 +3413,8 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_R13); /* thread pointer */ #endif tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP1); /* mem temp */ + tcg_regset_set_reg(s->reserved_regs, TCG_VEC_TMP1); + tcg_regset_set_reg(s->reserved_regs, TCG_VEC_TMP2); if (USE_REG_TB) { tcg_regset_set_reg(s->reserved_regs, TCG_REG_TB); /* tb->tc_ptr */ } From patchwork Tue Mar 19 17:21: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: 160608 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4146807jad; Tue, 19 Mar 2019 10:34:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwD3RVt6qV4lI6KM9q+bBDLQDlxQXmHF2UgrcZ6orKPCYi0f1MOYtV03gW3HRm0IifBVV/r X-Received: by 2002:a05:6000:1107:: with SMTP id z7mr17156264wrw.87.1553016894935; Tue, 19 Mar 2019 10:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016894; cv=none; d=google.com; s=arc-20160816; b=xlyos7j88zrb8sfRPc6HlMMZTfQiVVGbIVW81obdD6ASD2d/Rekjzr/kEgGgOmOPvq 5yAdBpG3SN1ysShSfuOm0WvSBxmUE9Qxfd+m8r7PYwytaCeFWuXpfRlMoljBU1FWVuRf A4WOVw2ZnD0KIzfu1/qRk+mHySrejFCxn0Nt9iF045z8SSV1tgSxx1f9SUkhEX7J+aJj riZ/vcM7Y1tdXPcHSANycmgr5StkiEpHLi+8+g9XcoXDLyrHsJUCSBgIFuI45fqu7tDC zQPbMx95B2rk+r+R09t6cmgO4IAL6IkpH2HYgxPiJqhls90aQ18s9Y2zdujzifpHaYYm I5qQ== 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=JB64GhE0tqhCRxnSjkMcq+mPZMqJHRX7NnKGNtPhbPE=; b=sBMbHwDp9dJYiduC1OSBWj3H6Wk2WOMUBod3FVDCjoGz2w/cBCGVS0g8Qp9ZVv2hfR 9vSCdzJ8sd6VPFZdg8Roxd+aaGyfybkiLzVZHTp0Jz1RbkFVmUXAlhM5/hO3auh7G32I Z110jy8HeGOx8JJknyTpWTe0Rw5dNqQvWJAr9s4bkX6zt0BneUoFzle6jVPN8UWct4WZ eLXaEjSW3o510+mBTBQ/pzI2QsrEhSYywF+X+s/EjUjIhEE9tiNTd9FPUWOc82P8Xqn1 lCRNn+kHrhA9TCQ7BzBTMftSdKCZsLxy6ZvfXbTN5SH+epMzK+G7rzbVDU2Yj/7wZZTp 01Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=glOmbVsk; 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 o4si166898wmf.52.2019.03.19.10.34.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:34:54 -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=glOmbVsk; 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]:60826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IdZ-00057y-SG for patch@linaro.org; Tue, 19 Mar 2019 13:34:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQx-0004jJ-Ho for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQv-0004f4-Bg for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:51 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44984) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQu-0004e9-S5 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:49 -0400 Received: by mail-pg1-x542.google.com with SMTP id i2so815227pgj.11 for ; Tue, 19 Mar 2019 10:21:48 -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=JB64GhE0tqhCRxnSjkMcq+mPZMqJHRX7NnKGNtPhbPE=; b=glOmbVskQNnuet+J5J7Cw6fnjPmWnWMC0I8czAee18iy0VKYMGcxi1LsTqBRbBFSes RAiy0laZAJ2RrGfxYboPai6baFjV8yA+iLOCkoM/npV1hTKypNuxFWlxQ348pC4k4kcR tyLWTODqPivkD1HV5lmFtzJtynLrMYODgulC/aNyG0l2LY9tJJU33wqR6nTSa8gXwwza BXy26zIpOUCNsGGGYzUlFGAm5dBl+dUvtI2tXn9HUGf4oduBrsA/jY1eNHd53npDwuNy wUjDnFPChNtUgBy9+8eK2xxBdvjLmIAgCglVRVAAM8UAyT0Htq5ieE9chWZryCUS5vJl tNdw== 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=JB64GhE0tqhCRxnSjkMcq+mPZMqJHRX7NnKGNtPhbPE=; b=nFdShD1APY0ZPVoOgjlVbgr5oUPkoKq+cOyIRgYOdPOr8wVNQUCs9tSKaXc6+GVKm7 v1baDeE86ofXgV+Otkm53+xl82fk++MxYZ/HmJjGVgP1cKK3GdBzQ0SR5bPCd7e9xY1n KPNcTZdz72QtLV6xz77Mdd4dnA+v7vJiTWfHZ4HWl8vukDOiFqniaIyYMZJGgsp4EDsF LmG3lKwNTaxZqPh6XeoaQf/Vhoo175i2zQyZ9ZeGajCyBxfuc0osqFcVTnhnKWuEtQ/u 8oZmMQVdBGNATg/cEctafYBpgD9Dv7ES5B34HLxsokUbQ0x9ZOf2dUNTfr6RR44EY6pc QXCQ== X-Gm-Message-State: APjAAAUnQVDezVCSvTZXUyIH1h72i4cnqvyteTEqShn+/Lm3q3IQ/1QX woPNDGptA1Zd1MfkeEIecCGMx1jwtzs= X-Received: by 2002:a17:902:b609:: with SMTP id b9mr3177272pls.134.1553016107544; Tue, 19 Mar 2019 10:21:47 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:22 -0700 Message-Id: <20190319172126.7502-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::542 Subject: [Qemu-devel] [PATCH for-4.1 v3 13/17] tcg/ppc: Support vector shift by immediate 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For Altivec, this is done via vector shift by vector, and loading the immediate into a register. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.inc.c | 58 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) -- 2.17.2 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 3f669de7a7..14af24b7e4 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -148,7 +148,7 @@ extern bool have_isa_3_00; #define TCG_TARGET_HAS_neg_vec 0 #define TCG_TARGET_HAS_shi_vec 0 #define TCG_TARGET_HAS_shs_vec 0 -#define TCG_TARGET_HAS_shv_vec 0 +#define TCG_TARGET_HAS_shv_vec 1 #define TCG_TARGET_HAS_cmp_vec 1 #define TCG_TARGET_HAS_mul_vec 0 #define TCG_TARGET_HAS_sat_vec 1 diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index 70a64dd214..465e56a83b 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -517,6 +517,16 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VCMPGTUH VX4(582) #define VCMPGTUW VX4(646) +#define VSLB VX4(260) +#define VSLH VX4(324) +#define VSLW VX4(388) +#define VSRB VX4(516) +#define VSRH VX4(580) +#define VSRW VX4(644) +#define VSRAB VX4(772) +#define VSRAH VX4(836) +#define VSRAW VX4(900) + #define VAND VX4(1028) #define VANDC VX4(1092) #define VNOR VX4(1284) @@ -2871,8 +2881,14 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_sssub_vec: case INDEX_op_usadd_vec: case INDEX_op_ussub_vec: + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + case INDEX_op_sarv_vec: return vece <= MO_32; case INDEX_op_cmp_vec: + case INDEX_op_shli_vec: + case INDEX_op_shri_vec: + case INDEX_op_sari_vec: return vece <= MO_32 ? -1 : 0; default: return 0; @@ -2980,7 +2996,10 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, umin_op[4] = { VMINUB, VMINUH, VMINUW, 0 }, smin_op[4] = { VMINSB, VMINSH, VMINSW, 0 }, umax_op[4] = { VMAXUB, VMAXUH, VMAXUW, 0 }, - smax_op[4] = { VMAXSB, VMAXSH, VMAXSW, 0 }; + smax_op[4] = { VMAXSB, VMAXSH, VMAXSW, 0 }, + shlv_op[4] = { VSLB, VSLH, VSLW, 0 }, + shrv_op[4] = { VSRB, VSRH, VSRW, 0 }, + sarv_op[4] = { VSRAB, VSRAH, VSRAW, 0 }; TCGType type = vecl + TCG_TYPE_V64; TCGArg a0 = args[0], a1 = args[1], a2 = args[2]; @@ -3027,6 +3046,15 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_umax_vec: insn = umax_op[vece]; break; + case INDEX_op_shlv_vec: + insn = shlv_op[vece]; + break; + case INDEX_op_shrv_vec: + insn = shrv_op[vece]; + break; + case INDEX_op_sarv_vec: + insn = sarv_op[vece]; + break; case INDEX_op_and_vec: insn = VAND; break; @@ -3071,6 +3099,18 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, tcg_out32(s, insn | VRT(a0) | VRA(a1) | VRB(a2)); } +static void expand_vec_shi(TCGType type, unsigned vece, TCGv_vec v0, + TCGv_vec v1, TCGArg imm, TCGOpcode opci) +{ + TCGv_vec t1 = tcg_temp_new_vec(type); + + /* Splat w/bytes for xxspltib. */ + tcg_gen_dupi_vec(MO_8, t1, imm & ((8 << vece) - 1)); + vec_gen_3(opci, type, vece, tcgv_vec_arg(v0), + tcgv_vec_arg(v1), tcgv_vec_arg(t1)); + tcg_temp_free_vec(t1); +} + static void expand_vec_cmp(TCGType type, unsigned vece, TCGv_vec v0, TCGv_vec v1, TCGv_vec v2, TCGCond cond) { @@ -3122,14 +3162,25 @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, { va_list va; TCGv_vec v0, v1, v2; + TCGArg a2; va_start(va, a0); v0 = temp_tcgv_vec(arg_temp(a0)); v1 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg))); - v2 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg))); + a2 = va_arg(va, TCGArg); switch (opc) { + case INDEX_op_shli_vec: + expand_vec_shi(type, vece, v0, v1, a2, INDEX_op_shlv_vec); + break; + case INDEX_op_shri_vec: + expand_vec_shi(type, vece, v0, v1, a2, INDEX_op_shrv_vec); + break; + case INDEX_op_sari_vec: + expand_vec_shi(type, vece, v0, v1, a2, INDEX_op_sarv_vec); + break; case INDEX_op_cmp_vec: + v2 = temp_tcgv_vec(arg_temp(a2)); expand_vec_cmp(type, vece, v0, v1, v2, va_arg(va, TCGArg)); break; default: @@ -3330,6 +3381,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_smin_vec: case INDEX_op_umax_vec: case INDEX_op_umin_vec: + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + case INDEX_op_sarv_vec: return &v_v_v; case INDEX_op_not_vec: case INDEX_op_dup_vec: From patchwork Tue Mar 19 17:21:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160605 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4144625jad; Tue, 19 Mar 2019 10:32:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjMtKodzfZI3ADgwM4kCYONZT9ipe+awoeyDDLRoqwAF/p9L9Mo1Cee1Ogj+rMcIjvp6Pp X-Received: by 2002:a7b:cb04:: with SMTP id u4mr4949005wmj.18.1553016760217; Tue, 19 Mar 2019 10:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016760; cv=none; d=google.com; s=arc-20160816; b=o+OcOjcEEOTdjyy6v3vbslZzV4XNWW9obHZsC3DZIdwJJ9OZKZhIaCnLgEoHYW8iBt UH19eJIuNe1G9Yx9RwGVAUI+rJs8l8hQYilNGLGnQbnAq2jb6S4m4vhpdXhpo9d9ls/4 WfdEbUl08yLeqFsgMXLQjPXgQkvSva6iq0oVYTp8z0wkkXzur3rK6ewE7rSyKSsgd6UQ kEPeYCj2Lo40EmjDrtK1TrJVeTOaQGb5eUjn5z0OUOkh0Yz8UC4wNgGDSiFMBawG8waX 2qZTCubYPns7RGgFyBcl04uu2a29TX6NcuPbpvETa4nIz+JuIl2sr/kua8Jt/Xm7HvWe pjPA== 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=5dMs4Bg4Ljtzouu5nA6He25eikxaOxPJEkE7hP1m9ms=; b=LQQwnftU2//Z/92Wms3UHvzdQL6iy1WHsCziy+OTMV4EFHLU57/iI/3A39U3pG9f0f qXq8emAk0q58yU862XF5ZsEmJabzGYCFZzhY48R3AcM4BzyYbvAK0CZLUQU7jAmaov5s c60sExum4Sdlg5VPqVCeJg/0LHnEkFedm/w/CK4tqrUnYvEDS8o9WeKFSGsGYWTPA/JR 4c1KFz/LuHaqQFlqMbW7BgKaAn5rDL3iJpwuBzDACv8/T92AVxd4f+ljLXJorrr5qoxU ApKFoGZoMNtP7Qzo5rVyKdmN3N7qveujb+5TtwGDfF9vM7+s6E39D8xgE4DemxZJMEgR cLCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NAC9EqIE; 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 89si9933642wra.0.2019.03.19.10.32.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:32:40 -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=NAC9EqIE; 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]:60810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IbP-0003xJ-3h for patch@linaro.org; Tue, 19 Mar 2019 13:32:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IQz-0004lY-Rh for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQw-0004fe-Rf for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:53 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:43949) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQw-0004f9-A0 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:50 -0400 Received: by mail-pf1-x435.google.com with SMTP id c8so7517682pfd.10 for ; Tue, 19 Mar 2019 10:21:50 -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=5dMs4Bg4Ljtzouu5nA6He25eikxaOxPJEkE7hP1m9ms=; b=NAC9EqIETmhI2RNZmWvOUGv0JVaFSAD1A2odMnqzecVyeTYkMqEHpPCp2CEYWTq0CT e1wuN0mIN/+1dkqRuYw812+iapXCHO9Lgm8yy8xo4o0xv2+p4zm6YXANt7B/BK7e11/i SbQQSEwcQ195H6LHeJUpMblVRzdf4iTXww/SjTA7kflEkXjcX+xZ4Katsk08qQ57ccCa uOqReBbx0OBwJEw0p53Ge4S/e0Tl0fYqRHdy7xf2HacY8KOuHbMvJ8cC1WTC6nOmsOR8 9ux/Ad4LYSP7zPvQ5xr5khomTkHAUoUeRmw0ABNtaAVEaGCP057lCNZ1RhW2TxgsLhIZ WD5A== 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=5dMs4Bg4Ljtzouu5nA6He25eikxaOxPJEkE7hP1m9ms=; b=Q+uKcD8Ye+6xKPmnZKoDGtMTDi4L0oihQkiA+WjZuU3lS3UP5oTiHYzfvZ1p6QsvY2 wceKZ+Q9Uy8oarHzi8QQXitdAf28sW+YQrazGsOr19JO4/zU45ajw+9aBW0CHvo3saPR KrlUqGDSipZyOvApYXVBkvssD+iTprSOc2wdVAi2aLJZV4/M5t6tiwvory6MT72ZYL98 o65AZ05adGqEzDan2gyZmSD3JLakg0+/ADXt8JVpLXVWxoLd6y1a9dj1k7fe3z3cBsI/ 4w0MUkCVx4G9MMP5pdA+pFUFb/8mjG5UvGoMgTievhPam1yzxhlO+XFmei9WiRbJhA1h aK4g== X-Gm-Message-State: APjAAAVm/VaTc7KHc1K+vV/aQsUFwSGPYl2Uk86w/xLlwwMrwEdPxkm1 xzVFMBu9cxSjIgQWOVhZg7Ns76/g2gA= X-Received: by 2002:a62:20d2:: with SMTP id m79mr3099098pfj.135.1553016108794; Tue, 19 Mar 2019 10:21:48 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:23 -0700 Message-Id: <20190319172126.7502-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::435 Subject: [Qemu-devel] [PATCH for-4.1 v3 14/17] tcg/ppc: Support vector multiply 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For Altivec, this is always an expansion. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.opc.h | 8 +++ tcg/ppc/tcg-target.inc.c | 112 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 120 insertions(+), 2 deletions(-) -- 2.17.2 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 14af24b7e4..5a2c1bce5c 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -150,7 +150,7 @@ extern bool have_isa_3_00; #define TCG_TARGET_HAS_shs_vec 0 #define TCG_TARGET_HAS_shv_vec 1 #define TCG_TARGET_HAS_cmp_vec 1 -#define TCG_TARGET_HAS_mul_vec 0 +#define TCG_TARGET_HAS_mul_vec 1 #define TCG_TARGET_HAS_sat_vec 1 #define TCG_TARGET_HAS_minmax_vec 1 #define TCG_TARGET_HAS_dupm_vec 1 diff --git a/tcg/ppc/tcg-target.opc.h b/tcg/ppc/tcg-target.opc.h index 4816a6c3d4..5c6a5ad52c 100644 --- a/tcg/ppc/tcg-target.opc.h +++ b/tcg/ppc/tcg-target.opc.h @@ -1,3 +1,11 @@ /* Target-specific opcodes for host vector expansion. These will be emitted by tcg_expand_vec_op. For those familiar with GCC internals, consider these to be UNSPEC with names. */ + +DEF(ppc_mrgh_vec, 1, 2, 0, IMPLVEC) +DEF(ppc_mrgl_vec, 1, 2, 0, IMPLVEC) +DEF(ppc_msum_vec, 1, 3, 0, IMPLVEC) +DEF(ppc_muleu_vec, 1, 2, 0, IMPLVEC) +DEF(ppc_mulou_vec, 1, 2, 0, IMPLVEC) +DEF(ppc_pkum_vec, 1, 2, 0, IMPLVEC) +DEF(ppc_rotl_vec, 1, 2, 0, IMPLVEC) diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index 465e56a83b..4373989761 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -526,6 +526,25 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VSRAB VX4(772) #define VSRAH VX4(836) #define VSRAW VX4(900) +#define VRLB VX4(4) +#define VRLH VX4(68) +#define VRLW VX4(132) + +#define VMULEUB VX4(520) +#define VMULEUH VX4(584) +#define VMULOUB VX4(8) +#define VMULOUH VX4(72) +#define VMSUMUHM VX4(38) + +#define VMRGHB VX4(12) +#define VMRGHH VX4(76) +#define VMRGHW VX4(140) +#define VMRGLB VX4(268) +#define VMRGLH VX4(332) +#define VMRGLW VX4(396) + +#define VPKUHUM VX4(14) +#define VPKUWUM VX4(78) #define VAND VX4(1028) #define VANDC VX4(1092) @@ -2886,6 +2905,7 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_sarv_vec: return vece <= MO_32; case INDEX_op_cmp_vec: + case INDEX_op_mul_vec: case INDEX_op_shli_vec: case INDEX_op_shri_vec: case INDEX_op_sari_vec: @@ -2999,7 +3019,13 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, smax_op[4] = { VMAXSB, VMAXSH, VMAXSW, 0 }, shlv_op[4] = { VSLB, VSLH, VSLW, 0 }, shrv_op[4] = { VSRB, VSRH, VSRW, 0 }, - sarv_op[4] = { VSRAB, VSRAH, VSRAW, 0 }; + sarv_op[4] = { VSRAB, VSRAH, VSRAW, 0 }, + mrgh_op[4] = { VMRGHB, VMRGHH, VMRGHW, 0 }, + mrgl_op[4] = { VMRGLB, VMRGLH, VMRGLW, 0 }, + muleu_op[4] = { VMULEUB, VMULEUH, 0, 0 }, + mulou_op[4] = { VMULOUB, VMULOUH, 0, 0 }, + pkum_op[4] = { VPKUHUM, VPKUWUM, 0, 0 }, + rotl_op[4] = { VRLB, VRLH, VRLW, 0 }; TCGType type = vecl + TCG_TYPE_V64; TCGArg a0 = args[0], a1 = args[1], a2 = args[2]; @@ -3088,6 +3114,29 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, } break; + case INDEX_op_ppc_mrgh_vec: + insn = mrgh_op[vece]; + break; + case INDEX_op_ppc_mrgl_vec: + insn = mrgl_op[vece]; + break; + case INDEX_op_ppc_muleu_vec: + insn = muleu_op[vece]; + break; + case INDEX_op_ppc_mulou_vec: + insn = mulou_op[vece]; + break; + case INDEX_op_ppc_pkum_vec: + insn = pkum_op[vece]; + break; + case INDEX_op_ppc_rotl_vec: + insn = rotl_op[vece]; + break; + case INDEX_op_ppc_msum_vec: + tcg_debug_assert(vece == MO_16); + tcg_out32(s, VMSUMUHM | VRT(a0) | VRA(a1) | VRB(a2) | VRC(args[3])); + return; + case INDEX_op_mov_vec: /* Always emitted via tcg_out_mov. */ case INDEX_op_dupi_vec: /* Always emitted via tcg_out_movi. */ case INDEX_op_dup_vec: /* Always emitted via tcg_out_dup_vec. */ @@ -3157,6 +3206,53 @@ static void expand_vec_cmp(TCGType type, unsigned vece, TCGv_vec v0, } } +static void expand_vec_mul(TCGType type, unsigned vece, TCGv_vec v0, + TCGv_vec v1, TCGv_vec v2) +{ + TCGv_vec t1 = tcg_temp_new_vec(type); + TCGv_vec t2 = tcg_temp_new_vec(type); + TCGv_vec t3, t4; + + switch (vece) { + case MO_8: + case MO_16: + vec_gen_3(INDEX_op_ppc_muleu_vec, type, vece, tcgv_vec_arg(t1), + tcgv_vec_arg(v1), tcgv_vec_arg(v2)); + vec_gen_3(INDEX_op_ppc_mulou_vec, type, vece, tcgv_vec_arg(t2), + tcgv_vec_arg(v1), tcgv_vec_arg(v2)); + vec_gen_3(INDEX_op_ppc_mrgh_vec, type, vece + 1, tcgv_vec_arg(v0), + tcgv_vec_arg(t1), tcgv_vec_arg(t2)); + vec_gen_3(INDEX_op_ppc_mrgl_vec, type, vece + 1, tcgv_vec_arg(t1), + tcgv_vec_arg(t1), tcgv_vec_arg(t2)); + vec_gen_3(INDEX_op_ppc_pkum_vec, type, vece, tcgv_vec_arg(v0), + tcgv_vec_arg(v0), tcgv_vec_arg(t1)); + break; + + case MO_32: + t3 = tcg_temp_new_vec(type); + t4 = tcg_temp_new_vec(type); + tcg_gen_dupi_vec(MO_8, t4, -16); + vec_gen_3(INDEX_op_ppc_rotl_vec, type, MO_32, tcgv_vec_arg(t1), + tcgv_vec_arg(v2), tcgv_vec_arg(t4)); + vec_gen_3(INDEX_op_ppc_mulou_vec, type, MO_16, tcgv_vec_arg(t2), + tcgv_vec_arg(v1), tcgv_vec_arg(v2)); + tcg_gen_dupi_vec(MO_8, t3, 0); + vec_gen_4(INDEX_op_ppc_msum_vec, type, MO_16, tcgv_vec_arg(t3), + tcgv_vec_arg(v1), tcgv_vec_arg(t1), tcgv_vec_arg(t3)); + vec_gen_3(INDEX_op_shlv_vec, type, MO_32, tcgv_vec_arg(t3), + tcgv_vec_arg(t3), tcgv_vec_arg(t4)); + tcg_gen_add_vec(MO_32, v0, t2, t3); + tcg_temp_free_vec(t3); + tcg_temp_free_vec(t4); + break; + + default: + g_assert_not_reached(); + } + tcg_temp_free_vec(t1); + tcg_temp_free_vec(t2); +} + void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, TCGArg a0, ...) { @@ -3183,6 +3279,10 @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, v2 = temp_tcgv_vec(arg_temp(a2)); expand_vec_cmp(type, vece, v0, v1, v2, va_arg(va, TCGArg)); break; + case INDEX_op_mul_vec: + v2 = temp_tcgv_vec(arg_temp(a2)); + expand_vec_mul(type, vece, v0, v1, v2); + break; default: g_assert_not_reached(); } @@ -3229,6 +3329,8 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) static const TCGTargetOpDef v_r = { .args_ct_str = { "v", "r" } }; static const TCGTargetOpDef v_v = { .args_ct_str = { "v", "v" } }; static const TCGTargetOpDef v_v_v = { .args_ct_str = { "v", "v", "v" } }; + static const TCGTargetOpDef v_v_v_v + = { .args_ct_str = { "v", "v", "v", "v" } }; switch (op) { case INDEX_op_goto_ptr: @@ -3384,6 +3486,12 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_shlv_vec: case INDEX_op_shrv_vec: case INDEX_op_sarv_vec: + case INDEX_op_ppc_mrgh_vec: + case INDEX_op_ppc_mrgl_vec: + case INDEX_op_ppc_muleu_vec: + case INDEX_op_ppc_mulou_vec: + case INDEX_op_ppc_pkum_vec: + case INDEX_op_ppc_rotl_vec: return &v_v_v; case INDEX_op_not_vec: case INDEX_op_dup_vec: @@ -3392,6 +3500,8 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_st_vec: case INDEX_op_dupm_vec: return &v_r; + case INDEX_op_ppc_msum_vec: + return &v_v_v_v; default: return NULL; From patchwork Tue Mar 19 17:21:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160610 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4148712jad; Tue, 19 Mar 2019 10:37:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfWe+3vbHSqQ82E5rMaFxgOrG331Ie0NHoQUiqU1HHtBm1avWu+p0nDne3xq9BwOWFaAR3 X-Received: by 2002:a05:6000:1107:: with SMTP id z7mr17163891wrw.87.1553017021946; Tue, 19 Mar 2019 10:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553017021; cv=none; d=google.com; s=arc-20160816; b=qP9cDxXoSUfZeVRzmb2WYYyjUybiGRc1iYDCbEKznidYJgLM3domTCg1dUJ14nVlgE NdbKmWM/8L+5pYA0ePVL83Eqt+DOuUs1DQSwEgAJzKn4WM51rCxgd7O+KmLDzfUVQ2OT 7ehaan2oc5MPpWnRCm9/iru4zQBAomQf+QlpgVwOaiCxCTDO1H/hK+wfCSaTFdtxjwEG lQIb30EZMNTcmOC19SANxs0tkxkSd8Qz5t54ZNqIgAukWksyg2CrfKCmqbOSs+29c/bJ OAcq3kM2OMqUIr6pWqocBXebmFh9wsm/lqW5gW2eNmWKJRS8TpY8saQuj7jVWo+S9mCv YP4Q== 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=ZDPVA7ZDvX2aGjnTSlv4yCN4opIORtdYUSC2oXHkrkw=; b=GYkYA9AjPoTsiujBwJOZ+qvaoJuzjGH2lRrQ7j/NEoZzGQzaNutZh93c50qEgdCSAu tDzmjGo6rR+7w+pXs88TbebbhjJiHRNq72nD4euErFC/aJj+x+YkcbqUY4clDjGQi+/2 tITGtMiC68BLxCAw8GlgfdW5dFIczSeu8UEFEWjlvivzPjxFpxleqWOI1q4y3sobjouN 5KgxhGEGV26NL7kVGpXGKaZGtHLSVGF3MqhRsizGmxKM+lHzwDBpGHiTYQgIHNBhybgj 1VjVpiKoxIc5Du7JPeGHg1B+EJAInsrTqn69GzqsKDS93jYlpGwXoiQ2oaIl2VQJXzMi GCWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PL47UI76; 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 x17si2067428wmh.122.2019.03.19.10.37.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:37: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=PL47UI76; 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]:60872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6Ifc-0006MU-SK for patch@linaro.org; Tue, 19 Mar 2019 13:37:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IR0-0004m2-Bp for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQx-0004fz-Om for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:54 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:46443) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQx-0004fX-95 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:51 -0400 Received: by mail-pf1-x444.google.com with SMTP id s23so14148820pfe.13 for ; Tue, 19 Mar 2019 10:21:51 -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=ZDPVA7ZDvX2aGjnTSlv4yCN4opIORtdYUSC2oXHkrkw=; b=PL47UI76+n9qzR5yd49tXcstM2gOYPlPZvnmTl2jl7Yo6St7glbdDLbgDwBuTA0YB9 VtFasd2EbZNZqzqW4HWsBuTVeaeqP4bswqY97bU5ctwNUH6RpO8RlERYSyiEsLMT9GRm gZ/lw/TXsyWNGIe2agW87/PCJo6MDD6QXIo/ptCqBbCCZJUxSMWOnxYnnlB+71ckgrG6 eba644wMwffoR1UXrE5b9J7wAIN/EsiBMCr/ZKz10ZlGOMo2UloFsvTWugXLDVeb99dh +kVj24aElWxUPF/NPYUrtco19fqYtH4zXXCtWfZQ5AAEsKBaxnHyWN6Mu9S/SF8br10y pdUA== 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=ZDPVA7ZDvX2aGjnTSlv4yCN4opIORtdYUSC2oXHkrkw=; b=YDUkroMHPziP7qruSaIWj0vt2HjR0NlEWbWaQEq8dxjqPIEZaLEZbdwHqa29MLSKIb De4xH3ntVN5FynngsfjNl1/JYa/7j0ERsXUXOd/ES0xDx7mUHbYXXh2RuKlxecEHaPch 1d98t8+5gB1UoPbcCqBgLjs3qmptJMA39NkXu+iPLbutxx/ToWfJie+miMLn043G15PL 82ZNmprIPeBM2wehH0mvPZsYiA61dGUR2QCXX43en/jr1R8LVKTIZMn7SSP/meNASNiw f5jhRbGEoOTk76YJkXi/6VA9Aoej066e+NBGupqsLVFu2wZn6tuorl98rf5D2uPDxiGy CVKQ== X-Gm-Message-State: APjAAAUQC6aIX93x+11nU8qDCMkKM8KYPLWJmzYxst4BGdWmade/AuT3 y67OVx/eUrExciR+xHvjxU0nm+Dxp5c= X-Received: by 2002:a17:902:45a5:: with SMTP id n34mr3233903pld.127.1553016109941; Tue, 19 Mar 2019 10:21:49 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:24 -0700 Message-Id: <20190319172126.7502-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::444 Subject: [Qemu-devel] [PATCH for-4.1 v3 15/17] tcg/ppc: Update vector support to v2.06 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes double-word loads and stores, double-word load and splat, and double-word permute. All of which require multiple operations in the base Altivec instruction set. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 3 ++- tcg/ppc/tcg-target.inc.c | 43 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) -- 2.17.2 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 5a2c1bce5c..57455cfdc7 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -60,6 +60,7 @@ typedef enum { extern bool have_isa_altivec; extern bool have_isa_2_06; +extern bool have_isa_2_06_vsx; extern bool have_isa_3_00; /* optional instructions automatically implemented */ @@ -138,7 +139,7 @@ extern bool have_isa_3_00; * While technically Altivec could support V64, it has no 64-bit store * instruction, which makes the generate code quite large. */ -#define TCG_TARGET_HAS_v64 0 +#define TCG_TARGET_HAS_v64 have_isa_2_06_vsx #define TCG_TARGET_HAS_v128 have_isa_altivec #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index 4373989761..b7c2e2a6f8 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -66,6 +66,7 @@ static tcg_insn_unit *tb_ret_addr; bool have_isa_altivec; bool have_isa_2_06; +bool have_isa_2_06_vsx; bool have_isa_3_00; #define HAVE_ISA_2_06 have_isa_2_06 @@ -470,9 +471,12 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define LVEBX XO31(7) #define LVEHX XO31(39) #define LVEWX XO31(71) +#define LXSDX XO31(588) /* v2.06 */ +#define LXVDSX XO31(332) /* v2.06 */ #define STVX XO31(231) #define STVEWX XO31(199) +#define STXSDX XO31(716) /* v2.06 */ #define VADDSBS VX4(768) #define VADDUBS VX4(512) @@ -561,6 +565,8 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VSLDOI VX4(44) +#define XXPERMDI (OPCD(60) | (10 << 3)) /* v2.06 */ + #define RT(r) ((r)<<21) #define RS(r) ((r)<<21) #define RA(r) ((r)<<16) @@ -892,11 +898,21 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg ret, add = 0; } - load_insn = LVX | VRT(ret) | RB(TCG_REG_TMP1); - if (TCG_TARGET_REG_BITS == 64) { - new_pool_l2(s, rel, s->code_ptr, add, val, val); + if (have_isa_2_06_vsx) { + load_insn = type == TCG_TYPE_V64 ? LXSDX : LXVDSX; + load_insn |= VRT(ret) | RB(TCG_REG_TMP1) | 1; + if (TCG_TARGET_REG_BITS == 64) { + new_pool_label(s, val, rel, s->code_ptr, add); + } else { + new_pool_l2(s, rel, s->code_ptr, add, val, val); + } } else { - new_pool_l4(s, rel, s->code_ptr, add, val, val, val, val); + load_insn = LVX | VRT(ret) | RB(TCG_REG_TMP1); + if (TCG_TARGET_REG_BITS == 64) { + new_pool_l2(s, rel, s->code_ptr, add, val, val); + } else { + new_pool_l4(s, rel, s->code_ptr, add, val, val, val, val); + } } tcg_out32(s, ADDIS | TAI(TCG_REG_TMP1, base, 0)); @@ -1138,6 +1154,10 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, /* fallthru */ case TCG_TYPE_V64: tcg_debug_assert(ret >= 32); + if (have_isa_2_06_vsx) { + tcg_out_mem_long(s, 0, LXSDX | 1, ret & 31, base, offset); + break; + } assert((offset & 7) == 0); tcg_out_mem_long(s, 0, LVX, ret & 31, base, offset & -16); if (offset & 8) { @@ -1181,6 +1201,10 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, /* fallthru */ case TCG_TYPE_V64: tcg_debug_assert(arg >= 32); + if (have_isa_2_06_vsx) { + tcg_out_mem_long(s, 0, STXSDX | 1, arg & 31, base, offset); + break; + } assert((offset & 7) == 0); if (offset & 8) { tcg_out_vsldoi(s, TCG_VEC_TMP1, arg, arg, 8); @@ -2936,6 +2960,10 @@ static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out32(s, VSPLTW | VRT(dst) | VRB(src) | (1 << 16)); break; case MO_64: + if (have_isa_2_06_vsx) { + tcg_out32(s, XXPERMDI | 7 | VRT(dst) | VRA(src) | VRB(src)); + break; + } tcg_out_vsldoi(s, TCG_VEC_TMP1, src, src, 8); tcg_out_vsldoi(s, dst, TCG_VEC_TMP1, src, 8); break; @@ -2980,6 +3008,10 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out32(s, VSPLTW | VRT(out) | VRB(out) | (elt << 16)); break; case MO_64: + if (have_isa_2_06_vsx) { + tcg_out_mem_long(s, 0, LXVDSX | 1, out, base, offset); + break; + } assert((offset & 7) == 0); tcg_out_mem_long(s, 0, LVX, out, base, offset & -16); tcg_out_vsldoi(s, TCG_VEC_TMP1, out, out, 8); @@ -3518,6 +3550,9 @@ static void tcg_target_init(TCGContext *s) } if (hwcap & PPC_FEATURE_ARCH_2_06) { have_isa_2_06 = true; + if (hwcap & PPC_FEATURE_HAS_VSX) { + have_isa_2_06_vsx = true; + } } #ifdef PPC_FEATURE2_ARCH_3_00 if (hwcap2 & PPC_FEATURE2_ARCH_3_00) { From patchwork Tue Mar 19 17:21:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160611 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4149948jad; Tue, 19 Mar 2019 10:38:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6YyFo+NlS5ZC0Ev+M3+0/ZfDjVBMeSbKwldYp5z7adY/Vud8Qg1nogZyFASqc3ODpRrYc X-Received: by 2002:adf:f54b:: with SMTP id j11mr19170457wrp.39.1553017103872; Tue, 19 Mar 2019 10:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553017103; cv=none; d=google.com; s=arc-20160816; b=CoiQ04M8hve3uzNqTZF/uUq9aPeBGprPWoN6+rlnhy53Km2wjbkv2YMEQMtGWq0DDi XY9VUGCU7nbqz4HbEAlscRQF9Whc9x4Od6SS5Qjtk2iotvM9weJ5TrRPCDl6y/4LfOx/ mfzk85KFDbiP0rCCjQlamupdN+eF7+rMsTE3CcfiFbIrmDjOadNI93RfqsbH9Fn3U9fF lbCK7Cz8WL6x44l8RohUxLaotmU5Y82VDZZ+1HdOUGydrFFL3FSKEdKY5L6gLnbMGqNo 5/q7tBzmkd/EfDQhwvLxsz/g0fpm2LYASV2AAPZLmpQS369obyqfrdqDkHqBPW5gOP7D U7Xg== 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=mQeG91WgBFz4wCftdJEPTFpu/Owe1GnQDfmVBFD/UDE=; b=VXw6J9VykRdD+9KUdew5CODJUEfoiIwONYXprx3fqLnQj5rHYjX5w69J5ckpsZvBy6 4RQ5kd9oG7WdThPZzHMaPRH6irYK+pwhRIhblrCqa4drhoU0onD2+BumJaMHgzL4YP1K CO+TGW1DSvxah6kB6rWm36Al0s/yyQ7lvxO65HDp3MLIiNYBIucqbCFrCPuWUCCZXMoL G+MB7yO2y53HpXnsZnybNgoODW/4qpQ8ERGNpA64oOKMUd/+v6JaNZPBkdnsmA92HHX/ tA8+aeaQlBR/PszMYNZQxa4pkVZGG7i2G0qRTWlXZ4rK9tC53YCPoPdfY0bxBV4ysqfr 0Waw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="TNsRgl/A"; 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 g193si2412237wme.159.2019.03.19.10.38.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:38:23 -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="TNsRgl/A"; 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]:60894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6Igw-00076N-S5 for patch@linaro.org; Tue, 19 Mar 2019 13:38:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IR2-0004ol-RI for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:22:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IQz-0004hd-7B for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:56 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:44062) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQy-0004gT-My for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:53 -0400 Received: by mail-pf1-x443.google.com with SMTP id a3so14157273pff.11 for ; Tue, 19 Mar 2019 10:21:52 -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=mQeG91WgBFz4wCftdJEPTFpu/Owe1GnQDfmVBFD/UDE=; b=TNsRgl/Ac+bkWLmB9H9G+mo7ygC7ekZnjR8wWuI4gYQfvUpCkap2ec8B7PEP52OmvB 9eIY/BbxBo3JCiF+GAJweTJpC4k+CvvURwCW+sV8lvQhrH/997HQ4jpOv1r9RL5IPGdZ j5VcKDVOsS0IghkGyt+UAudVpBshc4a+F/yXB1W6zrascd+Vkna/2OZnbnnIe3Cq39Ij Wi0UJI+yFOix3czBoGftrQKepC4ufCF6tOpIy/a2q9we4u6PrZ9xlafavFTOBbKke0yD Ynmbi2w/0lx/YM9lqfZDBjt0KjMDiPsFOkb3MGu4XLYR9ASvy0KVa/t7L0OxZ9KyGKVA 5uGg== 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=mQeG91WgBFz4wCftdJEPTFpu/Owe1GnQDfmVBFD/UDE=; b=SgFmRWhxL2HdWltrBMbr0fhDr0pQsWrraijGYRAqOxnRmIbW/3xrWI560znj0N5dRs PpJfFJb83HkKu6b+czE0UCAjyNZ2hKEuIPsiVzmo3QW9GfSCqbmxBbDc27g+O3/2QIlL jONZF3p0qr+WE2ZLW1ue+ACUdJ3p/WyU/0DvmuFKKB8rPIF2Wr5jXMgXDDKXULgq6b+A zD36PifGpronpYmkj/FACCr9XD8VxQ33P8zkGiTJud0dr+5ha0JdTxRzUOO8O+eCj+a6 fd8leF2aEgiF6Jv95xxVcDDN/04qYdHfgi1badPF0NqrlmXfg6ygetiu2zCMKjiFVoW0 yEmg== X-Gm-Message-State: APjAAAXG0ZE7D2P/8AcSHRlRVPbusANCNchM9eAhnIoVf1zsx+vG1GKT 5yhK6dEMDZ/BxKksRfo7vbSvD3svfaE= X-Received: by 2002:aa7:83ca:: with SMTP id j10mr25788101pfn.50.1553016111311; Tue, 19 Mar 2019 10:21:51 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:25 -0700 Message-Id: <20190319172126.7502-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::443 Subject: [Qemu-devel] [PATCH for-4.1 v3 16/17] tcg/ppc: Update vector support to v2.07 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes single-word loads and stores, lots of double-word arithmetic, and a few extra logical operations. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 3 +- tcg/ppc/tcg-target.inc.c | 103 ++++++++++++++++++++++++++++++++------- 2 files changed, 87 insertions(+), 19 deletions(-) -- 2.17.2 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 57455cfdc7..4546fcd83c 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -61,6 +61,7 @@ typedef enum { extern bool have_isa_altivec; extern bool have_isa_2_06; extern bool have_isa_2_06_vsx; +extern bool have_isa_2_07_vsx; extern bool have_isa_3_00; /* optional instructions automatically implemented */ @@ -144,7 +145,7 @@ extern bool have_isa_3_00; #define TCG_TARGET_HAS_v256 0 #define TCG_TARGET_HAS_andc_vec 1 -#define TCG_TARGET_HAS_orc_vec 0 +#define TCG_TARGET_HAS_orc_vec have_isa_2_07_vsx #define TCG_TARGET_HAS_not_vec 1 #define TCG_TARGET_HAS_neg_vec 0 #define TCG_TARGET_HAS_shi_vec 0 diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index b7c2e2a6f8..c340806158 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -67,6 +67,7 @@ static tcg_insn_unit *tb_ret_addr; bool have_isa_altivec; bool have_isa_2_06; bool have_isa_2_06_vsx; +bool have_isa_2_07_vsx; bool have_isa_3_00; #define HAVE_ISA_2_06 have_isa_2_06 @@ -473,10 +474,12 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define LVEWX XO31(71) #define LXSDX XO31(588) /* v2.06 */ #define LXVDSX XO31(332) /* v2.06 */ +#define LXSIWZX XO31(12) /* v2.07 */ #define STVX XO31(231) #define STVEWX XO31(199) #define STXSDX XO31(716) /* v2.06 */ +#define STXSIWX XO31(140) /* v2.07 */ #define VADDSBS VX4(768) #define VADDUBS VX4(512) @@ -487,6 +490,7 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VADDSWS VX4(896) #define VADDUWS VX4(640) #define VADDUWM VX4(128) +#define VADDUDM VX4(192) /* v2.07 */ #define VSUBSBS VX4(1792) #define VSUBUBS VX4(1536) @@ -497,47 +501,62 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VSUBSWS VX4(1920) #define VSUBUWS VX4(1664) #define VSUBUWM VX4(1152) +#define VSUBUDM VX4(1216) /* v2.07 */ #define VMAXSB VX4(258) #define VMAXSH VX4(322) #define VMAXSW VX4(386) +#define VMAXSD VX4(450) /* v2.07 */ #define VMAXUB VX4(2) #define VMAXUH VX4(66) #define VMAXUW VX4(130) +#define VMAXUD VX4(194) /* v2.07 */ #define VMINSB VX4(770) #define VMINSH VX4(834) #define VMINSW VX4(898) +#define VMINSD VX4(962) /* v2.07 */ #define VMINUB VX4(514) #define VMINUH VX4(578) #define VMINUW VX4(642) +#define VMINUD VX4(706) /* v2.07 */ #define VCMPEQUB VX4(6) #define VCMPEQUH VX4(70) #define VCMPEQUW VX4(134) +#define VCMPEQUD VX4(199) /* v2.07 */ #define VCMPGTSB VX4(774) #define VCMPGTSH VX4(838) #define VCMPGTSW VX4(902) +#define VCMPGTSD VX4(967) /* v2.07 */ #define VCMPGTUB VX4(518) #define VCMPGTUH VX4(582) #define VCMPGTUW VX4(646) +#define VCMPGTUD VX4(711) /* v2.07 */ #define VSLB VX4(260) #define VSLH VX4(324) #define VSLW VX4(388) +#define VSLD VX4(1476) /* v2.07 */ #define VSRB VX4(516) #define VSRH VX4(580) #define VSRW VX4(644) +#define VSRD VX4(1732) /* v2.07 */ #define VSRAB VX4(772) #define VSRAH VX4(836) #define VSRAW VX4(900) +#define VSRAD VX4(964) /* v2.07 */ #define VRLB VX4(4) #define VRLH VX4(68) #define VRLW VX4(132) +#define VRLD VX4(196) /* v2.07 */ #define VMULEUB VX4(520) #define VMULEUH VX4(584) +#define VMULEUW VX4(648) /* v2.07 */ #define VMULOUB VX4(8) #define VMULOUH VX4(72) +#define VMULOUW VX4(136) /* v2.07 */ +#define VMULUWM VX4(137) /* v2.07 */ #define VMSUMUHM VX4(38) #define VMRGHB VX4(12) @@ -555,6 +574,9 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VNOR VX4(1284) #define VOR VX4(1156) #define VXOR VX4(1220) +#define VEQV VX4(1668) /* v2.07 */ +#define VNAND VX4(1412) /* v2.07 */ +#define VORC VX4(1348) /* v2.07 */ #define VSPLTB VX4(524) #define VSPLTH VX4(588) @@ -567,6 +589,11 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define XXPERMDI (OPCD(60) | (10 << 3)) /* v2.06 */ +#define MFVSRD XO31(51) /* v2.07 */ +#define MFVSRWZ XO31(115) /* v2.07 */ +#define MTVSRD XO31(179) /* v2.07 */ +#define MTVSRWZ XO31(179) /* v2.07 */ + #define RT(r) ((r)<<21) #define RS(r) ((r)<<21) #define RA(r) ((r)<<16) @@ -701,7 +728,15 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) if (ret < 32 && arg < 32) { tcg_out32(s, OR | SAB(arg, ret, arg)); break; - } else if (ret < 32 || arg < 32) { + } else if (ret < 32 && have_isa_2_07_vsx) { + tcg_out32(s, (type == TCG_TYPE_I32 ? MFVSRWZ : MFVSRD) + | VRT(arg) | RA(ret) | 1); + break; + } else if (arg < 32 && have_isa_2_07_vsx) { + tcg_out32(s, (type == TCG_TYPE_I32 ? MTVSRWZ : MTVSRD) + | VRT(ret) | RA(arg) | 1); + break; + } else { /* Altivec does not support vector/integer moves. */ return false; } @@ -1139,6 +1174,10 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, tcg_out_mem_long(s, LWZ, LWZX, ret, base, offset); break; } + if (have_isa_2_07_vsx) { + tcg_out_mem_long(s, 0, LXSIWZX | 1, ret & 31, base, offset); + break; + } assert((offset & 3) == 0); tcg_out_mem_long(s, 0, LVEWX, ret & 31, base, offset); shift = (offset - 4) & 0xc; @@ -1185,6 +1224,10 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, tcg_out_mem_long(s, STW, STWX, arg, base, offset); break; } + if (have_isa_2_07_vsx) { + tcg_out_mem_long(s, 0, STXSIWX | 1, arg & 31, base, offset); + break; + } assert((offset & 3) == 0); shift = (offset - 4) & 0xc; if (shift) { @@ -2914,26 +2957,37 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_andc_vec: case INDEX_op_not_vec: return 1; + case INDEX_op_orc_vec: + return have_isa_2_07_vsx; case INDEX_op_add_vec: case INDEX_op_sub_vec: case INDEX_op_smax_vec: case INDEX_op_smin_vec: case INDEX_op_umax_vec: case INDEX_op_umin_vec: + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + case INDEX_op_sarv_vec: + return vece <= MO_32 || have_isa_2_07_vsx; case INDEX_op_ssadd_vec: case INDEX_op_sssub_vec: case INDEX_op_usadd_vec: case INDEX_op_ussub_vec: - case INDEX_op_shlv_vec: - case INDEX_op_shrv_vec: - case INDEX_op_sarv_vec: return vece <= MO_32; case INDEX_op_cmp_vec: - case INDEX_op_mul_vec: case INDEX_op_shli_vec: case INDEX_op_shri_vec: case INDEX_op_sari_vec: - return vece <= MO_32 ? -1 : 0; + return vece <= MO_32 || have_isa_2_07_vsx ? -1 : 0; + case INDEX_op_mul_vec: + switch (vece) { + case MO_8: + case MO_16: + return -1; + case MO_32: + return have_isa_2_07_vsx ? 1 : -1; + } + return 0; default: return 0; } @@ -3036,11 +3090,11 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, const int *const_args) { static const uint32_t - add_op[4] = { VADDUBM, VADDUHM, VADDUWM, 0 }, - sub_op[4] = { VSUBUBM, VSUBUHM, VSUBUWM, 0 }, - eq_op[4] = { VCMPEQUB, VCMPEQUH, VCMPEQUW, 0 }, - gts_op[4] = { VCMPGTSB, VCMPGTSH, VCMPGTSW, 0 }, - gtu_op[4] = { VCMPGTUB, VCMPGTUH, VCMPGTUW, 0 }, + add_op[4] = { VADDUBM, VADDUHM, VADDUWM, VADDUDM }, + sub_op[4] = { VSUBUBM, VSUBUHM, VSUBUWM, VSUBUDM }, + eq_op[4] = { VCMPEQUB, VCMPEQUH, VCMPEQUW, VCMPEQUD }, + gts_op[4] = { VCMPGTSB, VCMPGTSH, VCMPGTSW, VCMPGTSD }, + gtu_op[4] = { VCMPGTUB, VCMPGTUH, VCMPGTUW, VCMPGTUD }, ssadd_op[4] = { VADDSBS, VADDSHS, VADDSWS, 0 }, usadd_op[4] = { VADDUBS, VADDUHS, VADDUWS, 0 }, sssub_op[4] = { VSUBSBS, VSUBSHS, VSUBSWS, 0 }, @@ -3049,15 +3103,15 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, smin_op[4] = { VMINSB, VMINSH, VMINSW, 0 }, umax_op[4] = { VMAXUB, VMAXUH, VMAXUW, 0 }, smax_op[4] = { VMAXSB, VMAXSH, VMAXSW, 0 }, - shlv_op[4] = { VSLB, VSLH, VSLW, 0 }, - shrv_op[4] = { VSRB, VSRH, VSRW, 0 }, - sarv_op[4] = { VSRAB, VSRAH, VSRAW, 0 }, + shlv_op[4] = { VSLB, VSLH, VSLW, VSLD }, + shrv_op[4] = { VSRB, VSRH, VSRW, VSRD }, + sarv_op[4] = { VSRAB, VSRAH, VSRAW, VSRAD }, mrgh_op[4] = { VMRGHB, VMRGHH, VMRGHW, 0 }, mrgl_op[4] = { VMRGLB, VMRGLH, VMRGLW, 0 }, - muleu_op[4] = { VMULEUB, VMULEUH, 0, 0 }, - mulou_op[4] = { VMULOUB, VMULOUH, 0, 0 }, + muleu_op[4] = { VMULEUB, VMULEUH, VMULEUW, 0 }, + mulou_op[4] = { VMULOUB, VMULOUH, VMULOUW, 0 }, pkum_op[4] = { VPKUHUM, VPKUWUM, 0, 0 }, - rotl_op[4] = { VRLB, VRLH, VRLW, 0 }; + rotl_op[4] = { VRLB, VRLH, VRLW, VRLD }; TCGType type = vecl + TCG_TYPE_V64; TCGArg a0 = args[0], a1 = args[1], a2 = args[2]; @@ -3080,6 +3134,10 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_sub_vec: insn = sub_op[vece]; break; + case INDEX_op_mul_vec: + tcg_debug_assert(vece == MO_32 && have_isa_2_07_vsx); + insn = VMULUWM; + break; case INDEX_op_ssadd_vec: insn = ssadd_op[vece]; break; @@ -3129,6 +3187,9 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, insn = VNOR; a2 = a1; break; + case INDEX_op_orc_vec: + insn = VORC; + break; case INDEX_op_cmp_vec: switch (args[3]) { @@ -3197,7 +3258,7 @@ static void expand_vec_cmp(TCGType type, unsigned vece, TCGv_vec v0, { bool need_swap = false, need_inv = false; - tcg_debug_assert(vece <= MO_32); + tcg_debug_assert(vece <= MO_32 || have_isa_2_07_vsx); switch (cond) { case TCG_COND_EQ: @@ -3261,6 +3322,7 @@ static void expand_vec_mul(TCGType type, unsigned vece, TCGv_vec v0, break; case MO_32: + tcg_debug_assert(!have_isa_2_07_vsx); t3 = tcg_temp_new_vec(type); t4 = tcg_temp_new_vec(type); tcg_gen_dupi_vec(MO_8, t4, -16); @@ -3554,6 +3616,11 @@ static void tcg_target_init(TCGContext *s) have_isa_2_06_vsx = true; } } + if (hwcap2 & PPC_FEATURE2_ARCH_2_07) { + if (hwcap & PPC_FEATURE_HAS_VSX) { + have_isa_2_07_vsx = true; + } + } #ifdef PPC_FEATURE2_ARCH_3_00 if (hwcap2 & PPC_FEATURE2_ARCH_3_00) { have_isa_3_00 = true; From patchwork Tue Mar 19 17:21:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160607 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4145123jad; Tue, 19 Mar 2019 10:33:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzx46ODITeZvJyFdeM6qIzXoOlnk3Ovmkp4whxjNlqQ2RURJVavtVbwfYVw4CscQAttjVsY X-Received: by 2002:adf:f70e:: with SMTP id r14mr2652835wrp.37.1553016787423; Tue, 19 Mar 2019 10:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553016787; cv=none; d=google.com; s=arc-20160816; b=MTRCeImw3tZahXA7CI94y7OACXjqHFWHJMWGkhbJxv4zTmJR93+ujVUld5TnEDmUec nfaBVR6betkRKDQiPKN95iPFqcmrBy9m935ePLxsXg6Z+L07RVzu4FQEoK9QtjPvm35Y mQZkOjY1vMAloSbpjRv+TUmG3cARYdAdifGfMaJIXc9BZMlOlvGPQnXWZVPxQPvWDv0H SL8jDLPZsckpVzLyTmqc4pM/f0gOhcfd5/Cr3Ur+a0dt3a4g/4UNKAWbOmZdF897ebDr tqYAsHiU4eU1THIF6LZbgnsuD4ewhFqwmYJ8HR2qDEnJT/yFaS0U4pKD0zj3QfGusrSS s4/w== 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=f+nZftJct4PG9U/ho9/G7hv/qP3KbyU48cT7pTmMyRA=; b=e0hW63AtiDhQENdJX70ktj0XCSjiYNAAyuxcv/ZQ8XRdVuBjmyI6nEgl4XTuMwFlXC B3WbiHEcBOaMNMqwk+PNd/PD6cxHBlZTqUCFTA2Jy+sJJZrmxcHvZXwXwBvxsN0TdA3j 7oZVySv0f8+KE3vPPHK6l6CgcFUSOzDNmHp2fdGBNt4cGoRokNjfZOKzTJDlb5TTCo8i JDrIYRVxflwa9wWpo0wXsi1CkGWnvuli4XlEGSCfUT1co1U5iHS7KgLSv2YzQJ815maV H29zq+gpIK98B+cD0pvBazQjcrtwmo7i3+ArAChJ7e54da1CE20aRAySSj/gOXZyg+9K TAWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tKZ4RDVJ; 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 l18si2033217wmj.143.2019.03.19.10.33.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Mar 2019 10:33:07 -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=tKZ4RDVJ; 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]:60818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6Ibq-00042B-4x for patch@linaro.org; Tue, 19 Mar 2019 13:33:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6IR4-0004s1-2u for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:22:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6IR0-0004iq-GJ for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:58 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:40841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h6IQz-0004hl-T1 for qemu-devel@nongnu.org; Tue, 19 Mar 2019 13:21:54 -0400 Received: by mail-pf1-x433.google.com with SMTP id c207so5175708pfc.7 for ; Tue, 19 Mar 2019 10:21:53 -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=f+nZftJct4PG9U/ho9/G7hv/qP3KbyU48cT7pTmMyRA=; b=tKZ4RDVJJmk3UdfjUXDF/H+NjAsEy1jbsFDZX1KgFSz7il+fFWb7oxIAApOXtyKJui EwNnSI7g1HXp8m0cO7P5YuXJWQ5UyLpKcGU38Zl0D/HIkXfKBBV955Xiq/0S+F2cUSVy k5s2xnTew7xb4yaNtWC7O3ArpHxHcA19Tvj/AvY1tTI004wdskrm/iMWTOYniJGQ+ORP rztAsiv4sdt4+rKbPorWKzj/WeFztZ/ExkIa8IdvKJ5/ncZKEUp4Tknxn+yGk3D4pPzH SOqj8OEOhewW3JMfP3D58T/88od1WkXpUF7rdgiPiHuK3H4SDo31FvXkz4l5iK5TprzS QHtg== 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=f+nZftJct4PG9U/ho9/G7hv/qP3KbyU48cT7pTmMyRA=; b=mdcB52TZxnxE3jZD89eoLMjqz+WRt0zMS/MFMMjWqL81rYHASxZNYJT6kYNZWnkAN2 erIAuBEYj+nRTLeAEvufiCX5Tg76Stc/LHvrykbTR7igtJUbCOmBmM6DTtjljEGDeeV1 b3ii2GKuO6qrbTQe9n9HERZ1+tIfOjUb45SOl1/sFUwNe+Qe9TmekEVKRpQfVFYXbaja 8KICNJuTWHJ68ZUc0JVK6LgUekaRWsC4dAt1Ll+9Qs49E3yJTftTPvkkDPmmmvO0c3Ay +Gdbl1hTBtlPDkIzbM0o7uXqFCPDQjvt84jNdkxRaYnHCfxKpWnSY907euTYCe+9VF6u 9A8w== X-Gm-Message-State: APjAAAU4Ks6LELl93yF343/5w+vtT5kfOqrkfTcvoOfqsRnmckDpbwPn IqUB2M1Et8tykEc3nLIEwh2TPuMS7bA= X-Received: by 2002:a63:618d:: with SMTP id v135mr2871087pgb.2.1553016112527; Tue, 19 Mar 2019 10:21:52 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id w68sm5616666pfb.176.2019.03.19.10.21.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 10:21:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2019 10:21:26 -0700 Message-Id: <20190319172126.7502-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190319172126.7502-1-richard.henderson@linaro.org> References: <20190319172126.7502-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::433 Subject: [Qemu-devel] [PATCH for-4.1 v3 17/17] tcg/ppc: Update vector support to v3.00 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes vector load/store with immediate offset, some extra move and splat insns, compare ne, and negate. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 3 +- tcg/ppc/tcg-target.inc.c | 103 ++++++++++++++++++++++++++++++++++----- 2 files changed, 94 insertions(+), 12 deletions(-) -- 2.17.2 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 4546fcd83c..f3bc7fdc51 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -63,6 +63,7 @@ extern bool have_isa_2_06; extern bool have_isa_2_06_vsx; extern bool have_isa_2_07_vsx; extern bool have_isa_3_00; +extern bool have_isa_3_00_vsx; /* optional instructions automatically implemented */ #define TCG_TARGET_HAS_ext8u_i32 0 /* andi */ @@ -147,7 +148,7 @@ extern bool have_isa_3_00; #define TCG_TARGET_HAS_andc_vec 1 #define TCG_TARGET_HAS_orc_vec have_isa_2_07_vsx #define TCG_TARGET_HAS_not_vec 1 -#define TCG_TARGET_HAS_neg_vec 0 +#define TCG_TARGET_HAS_neg_vec have_isa_3_00_vsx #define TCG_TARGET_HAS_shi_vec 0 #define TCG_TARGET_HAS_shs_vec 0 #define TCG_TARGET_HAS_shv_vec 1 diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index c340806158..d53aad9d5d 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -69,6 +69,7 @@ bool have_isa_2_06; bool have_isa_2_06_vsx; bool have_isa_2_07_vsx; bool have_isa_3_00; +bool have_isa_3_00_vsx; #define HAVE_ISA_2_06 have_isa_2_06 #define HAVE_ISEL have_isa_2_06 @@ -475,11 +476,16 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define LXSDX XO31(588) /* v2.06 */ #define LXVDSX XO31(332) /* v2.06 */ #define LXSIWZX XO31(12) /* v2.07 */ +#define LXV (OPCD(61) | 1) /* v3.00 */ +#define LXSD (OPCD(57) | 2) /* v3.00 */ +#define LXVWSX XO31(364) /* v3.00 */ #define STVX XO31(231) #define STVEWX XO31(199) #define STXSDX XO31(716) /* v2.06 */ #define STXSIWX XO31(140) /* v2.07 */ +#define STXV (OPCD(61) | 5) /* v3.00 */ +#define STXSD (OPCD(61) | 2) /* v3.00 */ #define VADDSBS VX4(768) #define VADDUBS VX4(512) @@ -503,6 +509,9 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VSUBUWM VX4(1152) #define VSUBUDM VX4(1216) /* v2.07 */ +#define VNEGW (VX4(1538) | (6 << 16)) /* v3.00 */ +#define VNEGD (VX4(1538) | (7 << 16)) /* v3.00 */ + #define VMAXSB VX4(258) #define VMAXSH VX4(322) #define VMAXSW VX4(386) @@ -532,6 +541,9 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VCMPGTUH VX4(582) #define VCMPGTUW VX4(646) #define VCMPGTUD VX4(711) /* v2.07 */ +#define VCMPNEB VX4(7) /* v3.00 */ +#define VCMPNEH VX4(71) /* v3.00 */ +#define VCMPNEW VX4(135) /* v3.00 */ #define VSLB VX4(260) #define VSLH VX4(324) @@ -588,11 +600,14 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VSLDOI VX4(44) #define XXPERMDI (OPCD(60) | (10 << 3)) /* v2.06 */ +#define XXSPLTIB (OPCD(60) | (360 << 1)) /* v3.00 */ #define MFVSRD XO31(51) /* v2.07 */ #define MFVSRWZ XO31(115) /* v2.07 */ #define MTVSRD XO31(179) /* v2.07 */ #define MTVSRWZ XO31(179) /* v2.07 */ +#define MTVSRDD XO31(435) /* v3.00 */ +#define MTVSRWS XO31(403) /* v3.00 */ #define RT(r) ((r)<<21) #define RS(r) ((r)<<21) @@ -919,6 +934,10 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg ret, return; } } + if (have_isa_3_00_vsx && val == (tcg_target_long)dup_const(MO_8, val)) { + tcg_out32(s, XXSPLTIB | VRT(ret) | ((val & 0xff) << 11) | 1); + return; + } /* * Otherwise we must load the value from the constant pool. @@ -1104,7 +1123,7 @@ static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, TCGReg base, tcg_target_long offset) { tcg_target_long orig = offset, l0, l1, extra = 0, align = 0; - bool is_store = false; + bool is_int_store = false; TCGReg rs = TCG_REG_TMP1; switch (opi) { @@ -1117,11 +1136,20 @@ static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, break; } break; + case LXSD: + case STXSD: + align = 3; + break; + case LXV: case LXV | 8: + case STXV: case STXV | 8: + /* The |8 cases force altivec registers. */ + align = 15; + break; case STD: align = 3; /* FALLTHRU */ case STB: case STH: case STW: - is_store = true; + is_int_store = true; break; } @@ -1130,7 +1158,7 @@ static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, if (rs == base) { rs = TCG_REG_R0; } - tcg_debug_assert(!is_store || rs != rt); + tcg_debug_assert(!is_int_store || rs != rt); tcg_out_movi(s, TCG_TYPE_PTR, rs, orig); tcg_out32(s, opx | TAB(rt, base, rs)); return; @@ -1194,7 +1222,8 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, case TCG_TYPE_V64: tcg_debug_assert(ret >= 32); if (have_isa_2_06_vsx) { - tcg_out_mem_long(s, 0, LXSDX | 1, ret & 31, base, offset); + tcg_out_mem_long(s, have_isa_3_00_vsx ? LXSD : 0, LXSDX | 1, + ret & 31, base, offset); break; } assert((offset & 7) == 0); @@ -1206,7 +1235,8 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, case TCG_TYPE_V128: tcg_debug_assert(ret >= 32); assert((offset & 15) == 0); - tcg_out_mem_long(s, 0, LVX, ret & 31, base, offset); + tcg_out_mem_long(s, have_isa_3_00_vsx ? LXV | 8 : 0, LVX, + ret & 31, base, offset); break; default: g_assert_not_reached(); @@ -1245,7 +1275,8 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, case TCG_TYPE_V64: tcg_debug_assert(arg >= 32); if (have_isa_2_06_vsx) { - tcg_out_mem_long(s, 0, STXSDX | 1, arg & 31, base, offset); + tcg_out_mem_long(s, have_isa_3_00_vsx ? STXSD : 0, + STXSDX | 1, arg & 31, base, offset); break; } assert((offset & 7) == 0); @@ -1258,7 +1289,8 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, break; case TCG_TYPE_V128: tcg_debug_assert(arg >= 32); - tcg_out_mem_long(s, 0, STVX, arg & 31, base, offset); + tcg_out_mem_long(s, have_isa_3_00_vsx ? STXV | 8 : 0, STVX, + arg & 31, base, offset); break; default: g_assert_not_reached(); @@ -2979,6 +3011,8 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_shri_vec: case INDEX_op_sari_vec: return vece <= MO_32 || have_isa_2_07_vsx ? -1 : 0; + case INDEX_op_neg_vec: + return vece >= MO_32 && have_isa_3_00_vsx; case INDEX_op_mul_vec: switch (vece) { case MO_8: @@ -2997,7 +3031,22 @@ static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg dst, TCGReg src) { tcg_debug_assert(dst >= 32); - tcg_debug_assert(src >= 32); + + /* Splat from integer reg allowed via constraints for v3.00. */ + if (src < 32) { + tcg_debug_assert(have_isa_3_00_vsx); + switch (vece) { + case MO_64: + tcg_out32(s, MTVSRDD | 1 | VRT(dst) | RA(src) | RB(src)); + return true; + case MO_32: + tcg_out32(s, MTVSRWS | 1 | VRT(dst) | RA(src)); + return true; + default: + /* Fail, so that we fall back on either dupm or mov+dup. */ + return false; + } + } /* * Recall we use (or emulate) VSX integer loads, so the integer is @@ -3036,7 +3085,11 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, out &= 31; switch (vece) { case MO_8: - tcg_out_mem_long(s, 0, LVEBX, out, base, offset); + if (have_isa_3_00_vsx) { + tcg_out_mem_long(s, LXV | 8, LVX, out, base, offset & -16); + } else { + tcg_out_mem_long(s, 0, LVEBX, out, base, offset); + } elt = extract32(offset, 0, 4); #ifndef HOST_WORDS_BIGENDIAN elt ^= 15; @@ -3045,7 +3098,11 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, break; case MO_16: assert((offset & 1) == 0); - tcg_out_mem_long(s, 0, LVEHX, out, base, offset); + if (have_isa_3_00_vsx) { + tcg_out_mem_long(s, LXV | 8, LVX, out, base, offset & -16); + } else { + tcg_out_mem_long(s, 0, LVEHX, out, base, offset); + } elt = extract32(offset, 1, 3); #ifndef HOST_WORDS_BIGENDIAN elt ^= 7; @@ -3053,6 +3110,10 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out32(s, VSPLTH | VRT(out) | VRB(out) | (elt << 16)); break; case MO_32: + if (have_isa_3_00_vsx) { + tcg_out_mem_long(s, 0, LXVWSX | 1, out, base, offset); + break; + } assert((offset & 3) == 0); tcg_out_mem_long(s, 0, LVEWX, out, base, offset); elt = extract32(offset, 2, 2); @@ -3092,7 +3153,9 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, static const uint32_t add_op[4] = { VADDUBM, VADDUHM, VADDUWM, VADDUDM }, sub_op[4] = { VSUBUBM, VSUBUHM, VSUBUWM, VSUBUDM }, + neg_op[4] = { 0, 0, VNEGW, VNEGD }, eq_op[4] = { VCMPEQUB, VCMPEQUH, VCMPEQUW, VCMPEQUD }, + ne_op[4] = { VCMPNEB, VCMPNEH, VCMPNEW, 0 }, gts_op[4] = { VCMPGTSB, VCMPGTSH, VCMPGTSW, VCMPGTSD }, gtu_op[4] = { VCMPGTUB, VCMPGTUH, VCMPGTUW, VCMPGTUD }, ssadd_op[4] = { VADDSBS, VADDSHS, VADDSWS, 0 }, @@ -3134,6 +3197,11 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_sub_vec: insn = sub_op[vece]; break; + case INDEX_op_neg_vec: + insn = neg_op[vece]; + a2 = a1; + a1 = 0; + break; case INDEX_op_mul_vec: tcg_debug_assert(vece == MO_32 && have_isa_2_07_vsx); insn = VMULUWM; @@ -3196,6 +3264,9 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case TCG_COND_EQ: insn = eq_op[vece]; break; + case TCG_COND_NE: + insn = ne_op[vece]; + break; case TCG_COND_GT: insn = gts_op[vece]; break; @@ -3266,6 +3337,10 @@ static void expand_vec_cmp(TCGType type, unsigned vece, TCGv_vec v0, case TCG_COND_GTU: break; case TCG_COND_NE: + if (have_isa_3_00_vsx && vece <= MO_32) { + break; + } + /* fall through */ case TCG_COND_LE: case TCG_COND_LEU: need_inv = true; @@ -3421,6 +3496,7 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) static const TCGTargetOpDef sub2 = { .args_ct_str = { "r", "r", "rI", "rZM", "r", "r" } }; static const TCGTargetOpDef v_r = { .args_ct_str = { "v", "r" } }; + static const TCGTargetOpDef v_vr = { .args_ct_str = { "v", "vr" } }; static const TCGTargetOpDef v_v = { .args_ct_str = { "v", "v" } }; static const TCGTargetOpDef v_v_v = { .args_ct_str = { "v", "v", "v" } }; static const TCGTargetOpDef v_v_v_v @@ -3588,8 +3664,10 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_ppc_rotl_vec: return &v_v_v; case INDEX_op_not_vec: - case INDEX_op_dup_vec: + case INDEX_op_neg_vec: return &v_v; + case INDEX_op_dup_vec: + return have_isa_3_00_vsx ? &v_vr : &v_v; case INDEX_op_ld_vec: case INDEX_op_st_vec: case INDEX_op_dupm_vec: @@ -3624,6 +3702,9 @@ static void tcg_target_init(TCGContext *s) #ifdef PPC_FEATURE2_ARCH_3_00 if (hwcap2 & PPC_FEATURE2_ARCH_3_00) { have_isa_3_00 = true; + if (hwcap & PPC_FEATURE_HAS_VSX) { + have_isa_3_00_vsx = true; + } } #endif