From patchwork Wed May 1 05:05:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163178 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4120414ill; Tue, 30 Apr 2019 22:06:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRkYe1gW6ODs/LNZY9iPA3TR4sSr4mFwutbYHuT+yJX5R+CHN91oDR9Wpsw+u83jMOkpCb X-Received: by 2002:a1c:f504:: with SMTP id t4mr5307137wmh.121.1556687178307; Tue, 30 Apr 2019 22:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687178; cv=none; d=google.com; s=arc-20160816; b=z5kkWARTJv18JsVMC1qK+Xy731H7Ve93/Bj54/NJwr7ELzcz8Oq29ucma+qDHQapxg mbmYYtk11aB3r6R+jZ3173y4sqgkoolgy27ErPGoBKybo/d82tdV/w7/nO8YDSfxBkl5 Ba4kavbAKT5QUtinr6MThRmOV+ThyAqsAgdGsN2ryKwyQ1PxvGE9r5kIxV7EJOEMlFQp NH92/qjz8e3e1tfic4KuA3objDjOd8hU9YgCKL4EgxoN2T+94a8jeSffN2MWHOjb6peQ VUpJ8H59PybAkIb3hd+9KeuAUzkKi2kz6Crm7Auk43/M2LYjRAACxmptAKVGR3rbK3rs /MLQ== 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=t8ctKlc9U63HakIXPViyowL9bAHDjmJ4FjvlF6YAxdQ=; b=uI2UwLLbMxYzGYoK9lSxD0tto2jhkuVjKtEDhBltpMYeIBlAmY7DTBIlLuhVPeSDFJ pcrTtTBJ232sQlsfApm3/tjrqWJpxHF6JIYcwVq0YCADjZ2Za2Nwht7x4P/H9e9YVetw O9i9QCm/puTtWbzBC9hpPl0ixwn6lqE2dFLyMksFM/zE5x6KcRoSQ+3pCDODAs+8vJv+ 3U6yhMGNNCx7yVBQq87sRgLp5+5Zk2Jlmi/Xq00Da8f/u99RXNULHIeSxgXCCPhVHwPu jqsUBqNrVHkamOwgHwsJU8dFiGOzaz4kX92h+3QbalwMgNPvS7tTNCHxoFR35GJl4aSJ mhvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KsOhlLmp; 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 x12si2781445wrl.73.2019.04.30.22.06.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:06:18 -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=KsOhlLmp; 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]:36211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRh-0006LP-4h for patch@linaro.org; Wed, 01 May 2019 01:06:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRG-0006Kr-Fh for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRC-0002nB-TU for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:50 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:33078) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRC-0002mr-JX for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:46 -0400 Received: by mail-pg1-x543.google.com with SMTP id k19so7877009pgh.0 for ; Tue, 30 Apr 2019 22:05: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=t8ctKlc9U63HakIXPViyowL9bAHDjmJ4FjvlF6YAxdQ=; b=KsOhlLmp+94N6ed3uFQHeRnvYzpeluJB1Pf83Np4y0T5la7nSe7nTdUALeYmC66+98 qYyOsrb74rta83U82oRkK1cVNoRnhoxCerAeIFnXcbp5h5A1vXn9rBzcMMZ6wfaAMgbM 6C2Atq+9BbzUIPCwgM5esnhQHp1aDKaHuGOuGNIpmLLVj/0cwCFfqlGOo1Q1BqM8cWdm mxoMir93daeIqRsOM0qyfuD1t04i+OJoFXK1OwhPLs1Qp6hmwX8oeYjEX7yV72w5upuy WnRoMm7VtCp8Y6C2kvTV1ASAJD4j03RvR2uPmeiCeR3/8mvBzQvA3JrFg6tsBqBEN58v 7pfA== 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=t8ctKlc9U63HakIXPViyowL9bAHDjmJ4FjvlF6YAxdQ=; b=oLdJwpultt83nUll/lHIH65esHL1J2SZG8YbqiWCz2V9QAW2a0qNdUtxUzw5bCJDea WpOelMNjFRqyR3dnFxLMI8vH9Bo7fqEaJrQiSRJI6UprEj18p4sdxIOQVM1xMoVvsgih mMbIovbpp5PEThOglbzxTEI+WqI/p08E7B49e9ajM8uwyUAl1VqDxzEcsMrd/4VpkxJn toHSpT+EbBSMuanbw01wxZaLWQoPwMpmjr7b9LedelL1+Oun1i+yNltlumT8euQRfOPI e22OGA1hlN9tFSMVG78oKy1Bdlkankr2/jZuKeKlkjUs8kDs1hhBLLUb3+XVF7jFH20c mQPg== X-Gm-Message-State: APjAAAWUt6Uu4IsvSrEWSikf9+bnGSx8x2YfJPJdFljHE/BIviuV6jTt rJ7Cv6Mm4ntpbDeU6S4n42YX7AruCJc= X-Received: by 2002:a63:5166:: with SMTP id r38mr32452797pgl.429.1556687145243; Tue, 30 Apr 2019 22:05:45 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:08 -0700 Message-Id: <20190501050536.15580-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v2 01/29] tcg: Implement tcg_gen_gvec_3i() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let's add tcg_gen_gvec_3i(), similar to tcg_gen_gvec_2i(), however without introducing "gen_helper_gvec_3i *fnoi", as it isn't needed for now. Signed-off-by: David Hildenbrand Message-Id: <20190416185301.25344-2-david@redhat.com> Signed-off-by: Richard Henderson --- tcg/tcg-op-gvec.h | 24 ++++++++ tcg/tcg-op-gvec.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/tcg-op-gvec.h b/tcg/tcg-op-gvec.h index 850da32ded..c093243c4c 100644 --- a/tcg/tcg-op-gvec.h +++ b/tcg/tcg-op-gvec.h @@ -164,6 +164,27 @@ typedef struct { bool load_dest; } GVecGen3; +typedef struct { + /* + * Expand inline as a 64-bit or 32-bit integer. Only one of these will be + * non-NULL. + */ + void (*fni8)(TCGv_i64, TCGv_i64, TCGv_i64, int64_t); + void (*fni4)(TCGv_i32, TCGv_i32, TCGv_i32, int32_t); + /* Expand inline with a host vector type. */ + void (*fniv)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec, int64_t); + /* Expand out-of-line helper w/descriptor, data in descriptor. */ + gen_helper_gvec_3 *fno; + /* The opcode, if any, to which this corresponds. */ + TCGOpcode opc; + /* The vector element size, if applicable. */ + uint8_t vece; + /* Prefer i64 to v64. */ + bool prefer_i64; + /* Load dest as a 3rd source operand. */ + bool load_dest; +} GVecGen3i; + typedef struct { /* Expand inline as a 64-bit or 32-bit integer. Only one of these will be non-NULL. */ @@ -193,6 +214,9 @@ void tcg_gen_gvec_2s(uint32_t dofs, uint32_t aofs, uint32_t oprsz, uint32_t maxsz, TCGv_i64 c, const GVecGen2s *); void tcg_gen_gvec_3(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz, const GVecGen3 *); +void tcg_gen_gvec_3i(uint32_t dofs, uint32_t aofs, uint32_t bofs, + uint32_t oprsz, uint32_t maxsz, int64_t c, + const GVecGen3i *); void tcg_gen_gvec_4(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz, uint32_t maxsz, const GVecGen4 *); diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c index 0996ef0812..f831adb4e7 100644 --- a/tcg/tcg-op-gvec.c +++ b/tcg/tcg-op-gvec.c @@ -663,6 +663,29 @@ static void expand_3_i32(uint32_t dofs, uint32_t aofs, tcg_temp_free_i32(t0); } +static void expand_3i_i32(uint32_t dofs, uint32_t aofs, uint32_t bofs, + uint32_t oprsz, int32_t c, bool load_dest, + void (*fni)(TCGv_i32, TCGv_i32, TCGv_i32, int32_t)) +{ + TCGv_i32 t0 = tcg_temp_new_i32(); + TCGv_i32 t1 = tcg_temp_new_i32(); + TCGv_i32 t2 = tcg_temp_new_i32(); + uint32_t i; + + for (i = 0; i < oprsz; i += 4) { + tcg_gen_ld_i32(t0, cpu_env, aofs + i); + tcg_gen_ld_i32(t1, cpu_env, bofs + i); + if (load_dest) { + tcg_gen_ld_i32(t2, cpu_env, dofs + i); + } + fni(t2, t0, t1, c); + tcg_gen_st_i32(t2, cpu_env, dofs + i); + } + tcg_temp_free_i32(t0); + tcg_temp_free_i32(t1); + tcg_temp_free_i32(t2); +} + /* Expand OPSZ bytes worth of three-operand operations using i32 elements. */ static void expand_4_i32(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz, bool write_aofs, @@ -770,6 +793,29 @@ static void expand_3_i64(uint32_t dofs, uint32_t aofs, tcg_temp_free_i64(t0); } +static void expand_3i_i64(uint32_t dofs, uint32_t aofs, uint32_t bofs, + uint32_t oprsz, int64_t c, bool load_dest, + void (*fni)(TCGv_i64, TCGv_i64, TCGv_i64, int64_t)) +{ + TCGv_i64 t0 = tcg_temp_new_i64(); + TCGv_i64 t1 = tcg_temp_new_i64(); + TCGv_i64 t2 = tcg_temp_new_i64(); + uint32_t i; + + for (i = 0; i < oprsz; i += 8) { + tcg_gen_ld_i64(t0, cpu_env, aofs + i); + tcg_gen_ld_i64(t1, cpu_env, bofs + i); + if (load_dest) { + tcg_gen_ld_i64(t2, cpu_env, dofs + i); + } + fni(t2, t0, t1, c); + tcg_gen_st_i64(t2, cpu_env, dofs + i); + } + tcg_temp_free_i64(t0); + tcg_temp_free_i64(t1); + tcg_temp_free_i64(t2); +} + /* Expand OPSZ bytes worth of three-operand operations using i64 elements. */ static void expand_4_i64(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz, bool write_aofs, @@ -883,6 +929,35 @@ static void expand_3_vec(unsigned vece, uint32_t dofs, uint32_t aofs, tcg_temp_free_vec(t0); } +/* + * Expand OPSZ bytes worth of three-vector operands and an immediate operand + * using host vectors. + */ +static void expand_3i_vec(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t bofs, uint32_t oprsz, uint32_t tysz, + TCGType type, int64_t c, bool load_dest, + void (*fni)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec, + int64_t)) +{ + TCGv_vec t0 = tcg_temp_new_vec(type); + TCGv_vec t1 = tcg_temp_new_vec(type); + TCGv_vec t2 = tcg_temp_new_vec(type); + uint32_t i; + + for (i = 0; i < oprsz; i += tysz) { + tcg_gen_ld_vec(t0, cpu_env, aofs + i); + tcg_gen_ld_vec(t1, cpu_env, bofs + i); + if (load_dest) { + tcg_gen_ld_vec(t2, cpu_env, dofs + i); + } + fni(vece, t2, t0, t1, c); + tcg_gen_st_vec(t2, cpu_env, dofs + i); + } + tcg_temp_free_vec(t0); + tcg_temp_free_vec(t1); + tcg_temp_free_vec(t2); +} + /* Expand OPSZ bytes worth of four-operand operations using host vectors. */ static void expand_4_vec(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz, @@ -1174,6 +1249,70 @@ void tcg_gen_gvec_3(uint32_t dofs, uint32_t aofs, uint32_t bofs, } } +/* Expand a vector operation with three vectors and an immediate. */ +void tcg_gen_gvec_3i(uint32_t dofs, uint32_t aofs, uint32_t bofs, + uint32_t oprsz, uint32_t maxsz, int64_t c, + const GVecGen3i *g) +{ + TCGType type; + uint32_t some; + + check_size_align(oprsz, maxsz, dofs | aofs | bofs); + check_overlap_3(dofs, aofs, bofs, maxsz); + + type = 0; + if (g->fniv) { + type = choose_vector_type(g->opc, g->vece, oprsz, g->prefer_i64); + } + 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. + */ + some = QEMU_ALIGN_DOWN(oprsz, 32); + expand_3i_vec(g->vece, dofs, aofs, bofs, some, 32, TCG_TYPE_V256, + c, g->load_dest, g->fniv); + if (some == oprsz) { + break; + } + dofs += some; + aofs += some; + bofs += some; + oprsz -= some; + maxsz -= some; + /* fallthru */ + case TCG_TYPE_V128: + expand_3i_vec(g->vece, dofs, aofs, bofs, oprsz, 16, TCG_TYPE_V128, + c, g->load_dest, g->fniv); + break; + case TCG_TYPE_V64: + expand_3i_vec(g->vece, dofs, aofs, bofs, oprsz, 8, TCG_TYPE_V64, + c, g->load_dest, g->fniv); + break; + + case 0: + if (g->fni8 && check_size_impl(oprsz, 8)) { + expand_3i_i64(dofs, aofs, bofs, oprsz, c, g->load_dest, g->fni8); + } else if (g->fni4 && check_size_impl(oprsz, 4)) { + expand_3i_i32(dofs, aofs, bofs, oprsz, c, g->load_dest, g->fni4); + } else { + assert(g->fno != NULL); + tcg_gen_gvec_3_ool(dofs, aofs, bofs, oprsz, maxsz, c, g->fno); + return; + } + break; + + default: + g_assert_not_reached(); + } + + if (oprsz < maxsz) { + expand_clr(dofs + oprsz, maxsz - oprsz); + } +} + /* Expand a vector four-operand operation. */ void tcg_gen_gvec_4(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz, uint32_t maxsz, const GVecGen4 *g) From patchwork Wed May 1 05:05:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163181 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4122373ill; Tue, 30 Apr 2019 22:09:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqz87lEfbXl2CafDgXgaQ6jcFT4ZvRsaQXwug3Fv2Wy5lxgU5yoX/RpApWEoijW/66VkKJSb X-Received: by 2002:adf:dccd:: with SMTP id x13mr2347006wrm.33.1556687344784; Tue, 30 Apr 2019 22:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687344; cv=none; d=google.com; s=arc-20160816; b=BlqMG9W9igSEsCC7dpNaLs0wSxr0ror08U09PpnuBQw1R9C1MrAUujaq6D/P1jO0J6 pdZbrNwiuednleZlpGgwzE05Esl0PRSzXi3QnZIeKXkiHoU5kwMTsEpVtvxhThjCOIPx JNc9tlIb8oMGD0jNjPB4m1da0UG9Babe030pGi0eIxSixP0y0h6YUz8Kg61S6+92pxnh 6P2lhz6J1rFJmKbCG2CUiSikbQgvcMwCdNhcqqsUGbB/1i6WXfrDdPAr46VceMEJmE3S I/um5aQakrC564lzJtRcEIZeHzk2ILe0OK9NxwYukKJIhtFB2J7RAqDp0eJsn7gq8jHF J1sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=iaXmBLRJ4AetvIw8U8LEOO46+IUqp272JP0xIL80EUs=; b=FyK/GodTbIqy6ez6fqBZXp0RXGKI39VAwWZFctbi0Ubbd9SZTMV6Xk/PLJoPgSFMyf V+Zw5xKzaeng8ggy2b6d3c5f0ovsqZNuGKXey15YtMQHjC/BOtlDScpn3W8mJDEyv+H0 9YfxFvW5a7uChpZmLTTnXwgnS0TAsn7lsger0h19zeVf9/m4FCpEljaSwtWDD+vd30n8 emKKEnMM4uT+VnGBGWG4Mw4FXM5l66JO4Gf8CYneuLBH8hMQSeaP6RdPDNiANGyGnaNx DuHDLmrhUmT8O5jzitAa8p8Z1ao4lnXDN5FiKxjwsTbyCs77FZomXEyOqzxxZFm7AgKV tSHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bJpHG+XM; 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 v13si27712471wrw.421.2019.04.30.22.09.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:09:04 -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=bJpHG+XM; 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]:36231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhUN-0000Fn-Mi for patch@linaro.org; Wed, 01 May 2019 01:09:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRI-0006Kt-CF for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRE-0002o4-0u for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:52 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:44994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRD-0002nP-R1 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:47 -0400 Received: by mail-pf1-x441.google.com with SMTP id y13so8131342pfm.11 for ; Tue, 30 Apr 2019 22:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=iaXmBLRJ4AetvIw8U8LEOO46+IUqp272JP0xIL80EUs=; b=bJpHG+XM9UHP61vhMXtcaKUHzVCkogXlwPAEtaxU7AaLE653zRzyOToaHJbyd66wUe AmdPT2g7oEubhmctL2Rwf/jzl48qp79Uzc6/Cjqb8rDq9JTsBjrLYFDlxHhphTS8Bufe N3tw9w+NaZd+0ZCeR8JBU94rhBmR5jBdDEiJatZFTWY7wOMZJA3PX9Huw4F4p2gDNBJ4 FneJBv2PidSECvG1y7CGKKut+y0c+MpOpLSOdCu7gHbRYkrbULBqrCL+JcD58qpbiIuD TiNLGGekouyMCYEsfznwc3vkF+xv7ZG7YaHa5RCBeQ7n/9Pe/O+4TM2ySXey800Szdra El0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=iaXmBLRJ4AetvIw8U8LEOO46+IUqp272JP0xIL80EUs=; b=imE5Sdc5PsVbceHedF+jolMhOqrWPXYRnujTX3mZAmZT4DnYEzLy5FpGe77dJB0YL/ KvdugtONcSPjqJYaIi+S+xHftq3GGhlPLjmHYCNq86c3go84A5U+YeCSNM8hZ33iFWTX fW/q9Uw8JKWHf1Fxj2VMlvOEm4Xr/j9rF907F0fxrXrZDRB53lWh4YWg0oaye6pehbb2 M1xT565d3/RyuGFxFK8++yQp9LXsdd067RcUKnj9OI1ShmR/7ombE+EhT06zmBCRMrrk OYPovdf357j+fJHNozZ6HL1iSHOO8+mnZnp+HcKHpAQ/ZobXzaKYDJHbV9phXgvuoB28 MXnQ== X-Gm-Message-State: APjAAAUR7UNUVmwQGhILH+/ve271PxVSvoTOxxMXOLPuNTjcbIiYT2ZV PRFUABv4G2oaH8eD6VfbsIF7f1LoTFo= X-Received: by 2002:a63:564f:: with SMTP id g15mr18297097pgm.258.1556687146456; Tue, 30 Apr 2019 22:05:46 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:09 -0700 Message-Id: <20190501050536.15580-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v2 02/29] tcg: Do not recreate INDEX_op_neg_vec unless supported X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use tcg_can_emit_vec_op instead of just TCG_TARGET_HAS_neg_vec, so that we check the type and vece for the actual operation. Signed-off-by: Richard Henderson --- tcg/optimize.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/optimize.c b/tcg/optimize.c index 5150c38a25..24faa06260 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -734,9 +734,13 @@ void tcg_optimize(TCGContext *s) } else if (opc == INDEX_op_sub_i64) { neg_op = INDEX_op_neg_i64; have_neg = TCG_TARGET_HAS_neg_i64; - } else { + } else if (TCG_TARGET_HAS_neg_vec) { + TCGType type = TCGOP_VECL(op) + TCG_TYPE_V64; + unsigned vece = TCGOP_VECE(op); neg_op = INDEX_op_neg_vec; - have_neg = TCG_TARGET_HAS_neg_vec; + have_neg = tcg_can_emit_vec_op(neg_op, type, vece) > 0; + } else { + break; } if (!have_neg) { break; From patchwork Wed May 1 05:05:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163185 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4124158ill; Tue, 30 Apr 2019 22:11:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxO3c1GX71D2GItKrPqQcsf3aQuvEZajDGutlhJJUwFJWRyFY3U8dVSMdFX2nFYoGvekimt X-Received: by 2002:adf:db82:: with SMTP id u2mr33696328wri.316.1556687514051; Tue, 30 Apr 2019 22:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687514; cv=none; d=google.com; s=arc-20160816; b=WVfdA9kSh0FwWsV83dlXfmTgduZV4JcjY7C84BagofO+rzFmqQQhExMCEwHxvuAXTN GlughJfC+vpoMO0X/36sisuphD7GKroTUlgMsCmJ5nrvq7uUU9ojIXnvCnMqhfkAnUuK vP9DVf6lHlI/TvmFYVI9QfKO80EuWkK2utXECJrqu9b3x+za8XoeC2bg8cySiaf5g/6R dYlmA90WHBRkZaiSeMid0EO+RtMch4KVR8fjVjRmrwXXzEEHEsR+BssFeiS2P5xA5p08 EX0svXlcXKRDDoedazkMrFCh6x7mfACK/A8lOcFZfFG+cKcrbww22FAVj+RZvNpTJe2f 7QQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=tE6uzAjTMyTfJHn+9O8Wl99P1LuOsbUfHnL5seHXmm4=; b=U2GlIgNIb76/3AKdyWwS4aFY2zfi/wN5wMyqXdV6rfHEXi8/hSK1q3KCzwY++0pJkt m2YNVB/crbeo9I+orCtozNGKpK412ITUOkBsFbrxWtOD2q4Wbsuy3Nocaa77+uJCoiTW 4z0wnRqmLEW/DDPg0iEoAdnCGbt80H1RM8BBo+GErhBG5InfVYXSmip40/Q2hGemV8mR pg1rG+tG/AE8yaGtMScM0BQXARsV4Ko2QK4IORypnQq0gs2nrOGTyrl8Bn4VjQXFKg0T HknrakQ9Dlgt4ZJzJSU/tPFmc6jmsuGQsOyxF3n1a/07lTCLL4YAhy8HGJDE5EMuUUMM KxAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JtHBnm60; 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 z11si2637117wmf.41.2019.04.30.22.11.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:11: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=JtHBnm60; 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]:36291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhX7-0002tj-0F for patch@linaro.org; Wed, 01 May 2019 01:11:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRJ-0006L9-Ks for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRG-0002p9-Iy for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:53 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:43619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRG-0002oK-D4 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:50 -0400 Received: by mail-pg1-x543.google.com with SMTP id t22so4853901pgi.10 for ; Tue, 30 Apr 2019 22:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=tE6uzAjTMyTfJHn+9O8Wl99P1LuOsbUfHnL5seHXmm4=; b=JtHBnm60A8xlwcfxVU6lpag4oCwZ7r4A8kowmdEna3MhBbwSUfgCrbmqfxd35zIIKj +dTlyxefKoZNUq+//44t06S5ExTDfDny9KZmbG0rUVuD+H/BgFJBHDZySzXWbzzSx8+V QYp2aj+bkrsOleWG/djZncL//U4z8j3JXzMeuhxlqypuS0KJ/73ES6zkuQnulXaWGnYM BINEHtkQTcXhRzWeZoVfuI7RNLsM/Ed6Ba4D6U+0lQf6zCBtLnMk7dq+8+9RjUgMrk5m P0Mgw1PfZOkDAlGNFcXZ5YsCt+livroZn+JgN8cxbTNGVmNOqWpT3MAhFs1rMVh4R07P UVew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=tE6uzAjTMyTfJHn+9O8Wl99P1LuOsbUfHnL5seHXmm4=; b=MIP4rPDrf6jOlMIXxoHCoNN2P2+GIdEqEKyTpT03+lj7LsHOeX/ICd9k/VXsmYc6vT HzwO72jFdlCsPbxsdQELj9TcU7Il8GtgVsjrEBXfcANUaWeJFXArQjetkKG2YYsc9yUp zROfLrcYeRqBGJ88UBiWGgoMmP32sQUKdPh5oVD6Q/c2TKKGt8FDcqGgF5rLfxAziMqS xe2hse2LDStjLO22UGab8CKm/lGoRCSF60+yBEKs2w2LVeleGVr1IOBHAU45MdqBR0x4 +4VEa/pphWyTfI4z5O894le4SbVF0WWfY9HIl+1pPy2UPOAEM60pIsLErF62dK517zbw 2S+w== X-Gm-Message-State: APjAAAWglVQ+LD34Au5BvQVRgmuMACNtCKXqOtK/z3sSKw+NgtvbyKCQ EZ2PWt1YDzvB4BXzZeYMf3fd1peS8/s= X-Received: by 2002:a62:480d:: with SMTP id v13mr77874034pfa.125.1556687147454; Tue, 30 Apr 2019 22:05:47 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:10 -0700 Message-Id: <20190501050536.15580-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v2 03/29] 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- tcg/tcg-op-vec.c | 49 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée 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 Wed May 1 05:05:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163184 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4124113ill; Tue, 30 Apr 2019 22:11:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFoeXk6Yt2MfkzQzkwXShbmnozt29Wie6BBkzEpOQbJU7oApNdzFtUr8QkwuC8Lp/yiTpm X-Received: by 2002:a5d:5312:: with SMTP id e18mr94943wrv.205.1556687510202; Tue, 30 Apr 2019 22:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687510; cv=none; d=google.com; s=arc-20160816; b=rX/z8wVT5zFvqJep8Q6pTEAJ9QNWeEf4dvTTC61N2ZIPJw+ZAIFaOJAeGPe0o3uF93 o7CzZIETUUIOiBAFKQ/29k7tJYm9MXEIh2QVyN4ihHnR0yv/rLA0DEZCAaN56POFKGMc mD3kqbv6jlELl2/UvIKlXryKsI6KkQFlubVuVapFfqX6n+oEHpOalCsFFuVl+qwj4UTM ebDBRqDlYhV1kyC3pO40BAQJi73rhVJcefLXHp4gwbZ+LXszpIl6ywmoPyxFBugd61oN h7lkidsDZiq3IukznAsJDDzs8W74DM72OvYNoKaSVsJli+tXHF5e8eAXGXBVvy0lGrUt BP0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=GftYQH9nPBlQ6g/CwFs3gBqGQ2Yq7FCW48BnBv3/sM4=; b=uaTAirEDHR6dB7DvGO6NthFA9ToCGpV9A42FL0I1XD0Rp7Krdmg/9Lds2Pc7tcDNz7 QURuWbhJIY8kj+Z17wqoIz9Nl3hLeXTsWWAcxd5mMzTQH7fUaru4Z07TdapzehPq5ehi +7BFXuUBOj8IhqmoX5e/dRYYyw5IoD2vgcr/r3lSYDsesaylDgrKm/6fhcNR5ePWDIhH 8AKtxSKuzbSPjRtEPFXO4sEvWTc+5dpOw4Y4LYdXoYbvJNNTDyHr5q5PQDnVlqlQN9OR JWAGSQCQ4VJKoQBn1UvnQRYSppHUaErlxw+Ag8dN79EetCy6PYy2/m8hsvcWoI0U3MOM 1+bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Tc4xdyCW; 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 u16si16211103wrm.166.2019.04.30.22.11.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:11: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=Tc4xdyCW; 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]:36301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhX2-00037T-Ne for patch@linaro.org; Wed, 01 May 2019 01:11:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRJ-0006LB-UX for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRG-0002pI-Sv for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:53 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:43011) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRG-0002od-HA for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:50 -0400 Received: by mail-pf1-x441.google.com with SMTP id e67so8129738pfe.10 for ; Tue, 30 Apr 2019 22:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=GftYQH9nPBlQ6g/CwFs3gBqGQ2Yq7FCW48BnBv3/sM4=; b=Tc4xdyCWEHTE8yIaT+2uRgyKii3EqVcXXaoctKSvSbvoQypia6lmj56CN+5H2hdvmC u8AzMO0hTwsJztJgW00RcmrP7LcrSwEiUsuu28wCnuCaa2mOQ5mTFxvd7urc82gcJIHZ 8Kl7X+RepVXNboVBj80V3gtkZoj508kQIiNNDc3QEhhlZHDA7oGkBgItzMLVNwdcEpwm e57YBLAqUSMRY89Ix6NmjQTd3sTuhjY/0raqHQmDSrS9wBVQoX46HbQGAYHzpbL4XWzg /xkyw4n29qMrm2akS3qIyMphKCzu6xcogd3Rw5SkBEzCnX+ZLs6esVuNkUrZN+iR0QLt KVLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=GftYQH9nPBlQ6g/CwFs3gBqGQ2Yq7FCW48BnBv3/sM4=; b=eSkgkJEgsoV0cRIWb6EtsKNDw51htILHxUDYG8o1ukFAM4jwmI0g7ZBx8l6i3MHfek SUq4WJ7cPzJFGca6I1n/jIquIUqrlv/V2gajZ1PLlnSnpuDTbWcFiRsWBZmVPgC+9grQ ZlH3FPIaF836ey5ucA2MJ8DvGL/XT90fWM+O7s6IWu5K+rwUuDUfG8pulbrNu1KpN2ld DGhKM4aK3cWyA87LJVKaN9l3Qc+IrUHVdAK8k3kpUKlQiOFhgSY+kkdvKSDOM4jTvASD k842XPBx+ftWmCFE4BZ3ICoMxgtVDCWW/7Hjo9M4CgoESyK+2IwqNQXfITXZx3ko2SWF CwKw== X-Gm-Message-State: APjAAAX9PW3f6vvhW8giNq9W8vlD9L1PIG6zl8oR9tJVRsSFe7cJmIro WKOCx5TdmcGMU452E/yD2uu7IhMGVmo= X-Received: by 2002:aa7:92c4:: with SMTP id k4mr46144278pfa.183.1556687148660; Tue, 30 Apr 2019 22:05:48 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:11 -0700 Message-Id: <20190501050536.15580-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v2 04/29] tcg: Specify optional vector requirements with a list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Replace the single opcode in .opc with a null-terminated array in .opt_opc. We still require that all opcodes be used with the same .vece. Validate the contents of this list with CONFIG_DEBUG_TCG. All tcg_gen_*_vec functions will check any list active during .fniv expansion. Swap the active list in and out as we expand other opcodes, or take control away from the front-end function. Convert all existing vector aware front ends. Signed-off-by: Richard Henderson --- tcg/tcg-op-gvec.h | 24 +-- tcg/tcg.h | 20 +++ target/arm/translate-sve.c | 9 +- target/arm/translate.c | 123 +++++++++----- target/ppc/translate/vmx-impl.inc.c | 7 +- tcg/tcg-op-gvec.c | 249 ++++++++++++++++------------ tcg/tcg-op-vec.c | 102 ++++++++++++ 7 files changed, 372 insertions(+), 162 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/tcg-op-gvec.h b/tcg/tcg-op-gvec.h index c093243c4c..ac744ff7c9 100644 --- a/tcg/tcg-op-gvec.h +++ b/tcg/tcg-op-gvec.h @@ -91,8 +91,8 @@ typedef struct { void (*fniv)(unsigned, TCGv_vec, TCGv_vec); /* Expand out-of-line helper w/descriptor. */ gen_helper_gvec_2 *fno; - /* The opcode, if any, to which this corresponds. */ - TCGOpcode opc; + /* The optional opcodes, if any, utilized by .fniv. */ + const TCGOpcode *opt_opc; /* The data argument to the out-of-line helper. */ int32_t data; /* The vector element size, if applicable. */ @@ -112,8 +112,8 @@ typedef struct { gen_helper_gvec_2 *fno; /* Expand out-of-line helper w/descriptor, data as argument. */ gen_helper_gvec_2i *fnoi; - /* The opcode, if any, to which this corresponds. */ - TCGOpcode opc; + /* The optional opcodes, if any, utilized by .fniv. */ + const TCGOpcode *opt_opc; /* The vector element size, if applicable. */ uint8_t vece; /* Prefer i64 to v64. */ @@ -131,8 +131,8 @@ typedef struct { void (*fniv)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec); /* Expand out-of-line helper w/descriptor. */ gen_helper_gvec_2i *fno; - /* The opcode, if any, to which this corresponds. */ - TCGOpcode opc; + /* The optional opcodes, if any, utilized by .fniv. */ + const TCGOpcode *opt_opc; /* The data argument to the out-of-line helper. */ uint32_t data; /* The vector element size, if applicable. */ @@ -152,8 +152,8 @@ typedef struct { void (*fniv)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec); /* Expand out-of-line helper w/descriptor. */ gen_helper_gvec_3 *fno; - /* The opcode, if any, to which this corresponds. */ - TCGOpcode opc; + /* The optional opcodes, if any, utilized by .fniv. */ + const TCGOpcode *opt_opc; /* The data argument to the out-of-line helper. */ int32_t data; /* The vector element size, if applicable. */ @@ -175,8 +175,8 @@ typedef struct { void (*fniv)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec, int64_t); /* Expand out-of-line helper w/descriptor, data in descriptor. */ gen_helper_gvec_3 *fno; - /* The opcode, if any, to which this corresponds. */ - TCGOpcode opc; + /* The optional opcodes, if any, utilized by .fniv. */ + const TCGOpcode *opt_opc; /* The vector element size, if applicable. */ uint8_t vece; /* Prefer i64 to v64. */ @@ -194,8 +194,8 @@ typedef struct { void (*fniv)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec, TCGv_vec); /* Expand out-of-line helper w/descriptor. */ gen_helper_gvec_4 *fno; - /* The opcode, if any, to which this corresponds. */ - TCGOpcode opc; + /* The optional opcodes, if any, utilized by .fniv. */ + const TCGOpcode *opt_opc; /* The data argument to the out-of-line helper. */ int32_t data; /* The vector element size, if applicable. */ diff --git a/tcg/tcg.h b/tcg/tcg.h index cfc57110a1..2c7315da25 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -692,6 +692,7 @@ struct TCGContext { #ifdef CONFIG_DEBUG_TCG int temps_in_use; int goto_tb_issue_mask; + const TCGOpcode *vecop_list; #endif /* Code generation. Note that we specifically do not use tcg_insn_unit @@ -1492,4 +1493,23 @@ void helper_atomic_sto_le_mmu(CPUArchState *env, target_ulong addr, Int128 val, void helper_atomic_sto_be_mmu(CPUArchState *env, target_ulong addr, Int128 val, TCGMemOpIdx oi, uintptr_t retaddr); +#ifdef CONFIG_DEBUG_TCG +void tcg_assert_listed_vecop(TCGOpcode); +#else +static inline void tcg_assert_listed_vecop(TCGOpcode op) { } +#endif + +static inline const TCGOpcode *tcg_swap_vecop_list(const TCGOpcode *n) +{ +#ifdef CONFIG_DEBUG_TCG + const TCGOpcode *o = tcg_ctx->vecop_list; + tcg_ctx->vecop_list = n; + return o; +#else + return NULL; +#endif +} + +bool tcg_can_emit_vecop_list(const TCGOpcode *, TCGType, unsigned); + #endif /* TCG_H */ diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index 245cd82621..0682c0d32b 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -3302,29 +3302,30 @@ static bool trans_SUB_zzi(DisasContext *s, arg_rri_esz *a) static bool trans_SUBR_zzi(DisasContext *s, arg_rri_esz *a) { + static const TCGOpcode vecop_list[] = { INDEX_op_sub_vec, 0 }; static const GVecGen2s op[4] = { { .fni8 = tcg_gen_vec_sub8_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_sve_subri_b, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list, .vece = MO_8, .scalar_first = true }, { .fni8 = tcg_gen_vec_sub16_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_sve_subri_h, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list, .vece = MO_16, .scalar_first = true }, { .fni4 = tcg_gen_sub_i32, .fniv = tcg_gen_sub_vec, .fno = gen_helper_sve_subri_s, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list, .vece = MO_32, .scalar_first = true }, { .fni8 = tcg_gen_sub_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_sve_subri_d, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64, .scalar_first = true } diff --git a/target/arm/translate.c b/target/arm/translate.c index 10bc53f91c..35bd426a3d 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -5861,27 +5861,31 @@ static void gen_ssra_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) tcg_gen_add_vec(vece, d, d, a); } +static const TCGOpcode vecop_list_ssra[] = { + INDEX_op_sari_vec, INDEX_op_add_vec, 0 +}; + const GVecGen2i ssra_op[4] = { { .fni8 = gen_ssra8_i64, .fniv = gen_ssra_vec, .load_dest = true, - .opc = INDEX_op_sari_vec, + .opt_opc = vecop_list_ssra, .vece = MO_8 }, { .fni8 = gen_ssra16_i64, .fniv = gen_ssra_vec, .load_dest = true, - .opc = INDEX_op_sari_vec, + .opt_opc = vecop_list_ssra, .vece = MO_16 }, { .fni4 = gen_ssra32_i32, .fniv = gen_ssra_vec, .load_dest = true, - .opc = INDEX_op_sari_vec, + .opt_opc = vecop_list_ssra, .vece = MO_32 }, { .fni8 = gen_ssra64_i64, .fniv = gen_ssra_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, + .opt_opc = vecop_list_ssra, .load_dest = true, - .opc = INDEX_op_sari_vec, .vece = MO_64 }, }; @@ -5915,27 +5919,31 @@ static void gen_usra_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) tcg_gen_add_vec(vece, d, d, a); } +static const TCGOpcode vecop_list_usra[] = { + INDEX_op_shri_vec, INDEX_op_add_vec, 0 +}; + const GVecGen2i usra_op[4] = { { .fni8 = gen_usra8_i64, .fniv = gen_usra_vec, .load_dest = true, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list_usra, .vece = MO_8, }, { .fni8 = gen_usra16_i64, .fniv = gen_usra_vec, .load_dest = true, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list_usra, .vece = MO_16, }, { .fni4 = gen_usra32_i32, .fniv = gen_usra_vec, .load_dest = true, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list_usra, .vece = MO_32, }, { .fni8 = gen_usra64_i64, .fniv = gen_usra_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .load_dest = true, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list_usra, .vece = MO_64, }, }; @@ -5993,27 +6001,29 @@ static void gen_shr_ins_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) } } +static const TCGOpcode vecop_list_sri[] = { INDEX_op_shri_vec, 0 }; + const GVecGen2i sri_op[4] = { { .fni8 = gen_shr8_ins_i64, .fniv = gen_shr_ins_vec, .load_dest = true, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list_sri, .vece = MO_8 }, { .fni8 = gen_shr16_ins_i64, .fniv = gen_shr_ins_vec, .load_dest = true, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list_sri, .vece = MO_16 }, { .fni4 = gen_shr32_ins_i32, .fniv = gen_shr_ins_vec, .load_dest = true, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list_sri, .vece = MO_32 }, { .fni8 = gen_shr64_ins_i64, .fniv = gen_shr_ins_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .load_dest = true, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list_sri, .vece = MO_64 }, }; @@ -6069,27 +6079,29 @@ static void gen_shl_ins_vec(unsigned vece, TCGv_vec d, TCGv_vec a, int64_t sh) } } +static const TCGOpcode vecop_list_sli[] = { INDEX_op_shli_vec, 0 }; + const GVecGen2i sli_op[4] = { { .fni8 = gen_shl8_ins_i64, .fniv = gen_shl_ins_vec, .load_dest = true, - .opc = INDEX_op_shli_vec, + .opt_opc = vecop_list_sli, .vece = MO_8 }, { .fni8 = gen_shl16_ins_i64, .fniv = gen_shl_ins_vec, .load_dest = true, - .opc = INDEX_op_shli_vec, + .opt_opc = vecop_list_sli, .vece = MO_16 }, { .fni4 = gen_shl32_ins_i32, .fniv = gen_shl_ins_vec, .load_dest = true, - .opc = INDEX_op_shli_vec, + .opt_opc = vecop_list_sli, .vece = MO_32 }, { .fni8 = gen_shl64_ins_i64, .fniv = gen_shl_ins_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .load_dest = true, - .opc = INDEX_op_shli_vec, + .opt_opc = vecop_list_sli, .vece = MO_64 }, }; @@ -6156,51 +6168,60 @@ static void gen_mls_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) /* Note that while NEON does not support VMLA and VMLS as 64-bit ops, * these tables are shared with AArch64 which does support them. */ + +static const TCGOpcode vecop_list_mla[] = { + INDEX_op_mul_vec, INDEX_op_add_vec, 0 +}; + +static const TCGOpcode vecop_list_mls[] = { + INDEX_op_mul_vec, INDEX_op_sub_vec, 0 +}; + const GVecGen3 mla_op[4] = { { .fni4 = gen_mla8_i32, .fniv = gen_mla_vec, - .opc = INDEX_op_mul_vec, .load_dest = true, + .opt_opc = vecop_list_mla, .vece = MO_8 }, { .fni4 = gen_mla16_i32, .fniv = gen_mla_vec, - .opc = INDEX_op_mul_vec, .load_dest = true, + .opt_opc = vecop_list_mla, .vece = MO_16 }, { .fni4 = gen_mla32_i32, .fniv = gen_mla_vec, - .opc = INDEX_op_mul_vec, .load_dest = true, + .opt_opc = vecop_list_mla, .vece = MO_32 }, { .fni8 = gen_mla64_i64, .fniv = gen_mla_vec, - .opc = INDEX_op_mul_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .load_dest = true, + .opt_opc = vecop_list_mla, .vece = MO_64 }, }; const GVecGen3 mls_op[4] = { { .fni4 = gen_mls8_i32, .fniv = gen_mls_vec, - .opc = INDEX_op_mul_vec, .load_dest = true, + .opt_opc = vecop_list_mls, .vece = MO_8 }, { .fni4 = gen_mls16_i32, .fniv = gen_mls_vec, - .opc = INDEX_op_mul_vec, .load_dest = true, + .opt_opc = vecop_list_mls, .vece = MO_16 }, { .fni4 = gen_mls32_i32, .fniv = gen_mls_vec, - .opc = INDEX_op_mul_vec, .load_dest = true, + .opt_opc = vecop_list_mls, .vece = MO_32 }, { .fni8 = gen_mls64_i64, .fniv = gen_mls_vec, - .opc = INDEX_op_mul_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .load_dest = true, + .opt_opc = vecop_list_mls, .vece = MO_64 }, }; @@ -6226,19 +6247,25 @@ static void gen_cmtst_vec(unsigned vece, TCGv_vec d, TCGv_vec a, TCGv_vec b) tcg_gen_cmp_vec(TCG_COND_NE, vece, d, d, a); } +static const TCGOpcode vecop_list_cmtst[] = { INDEX_op_cmp_vec, 0 }; + const GVecGen3 cmtst_op[4] = { { .fni4 = gen_helper_neon_tst_u8, .fniv = gen_cmtst_vec, + .opt_opc = vecop_list_cmtst, .vece = MO_8 }, { .fni4 = gen_helper_neon_tst_u16, .fniv = gen_cmtst_vec, + .opt_opc = vecop_list_cmtst, .vece = MO_16 }, { .fni4 = gen_cmtst_i32, .fniv = gen_cmtst_vec, + .opt_opc = vecop_list_cmtst, .vece = MO_32 }, { .fni8 = gen_cmtst_i64, .fniv = gen_cmtst_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, + .opt_opc = vecop_list_cmtst, .vece = MO_64 }, }; @@ -6253,26 +6280,30 @@ static void gen_uqadd_vec(unsigned vece, TCGv_vec t, TCGv_vec sat, tcg_temp_free_vec(x); } +static const TCGOpcode vecop_list_uqadd[] = { + INDEX_op_usadd_vec, INDEX_op_cmp_vec, INDEX_op_add_vec, 0 +}; + const GVecGen4 uqadd_op[4] = { { .fniv = gen_uqadd_vec, .fno = gen_helper_gvec_uqadd_b, - .opc = INDEX_op_usadd_vec, .write_aofs = true, + .opt_opc = vecop_list_uqadd, .vece = MO_8 }, { .fniv = gen_uqadd_vec, .fno = gen_helper_gvec_uqadd_h, - .opc = INDEX_op_usadd_vec, .write_aofs = true, + .opt_opc = vecop_list_uqadd, .vece = MO_16 }, { .fniv = gen_uqadd_vec, .fno = gen_helper_gvec_uqadd_s, - .opc = INDEX_op_usadd_vec, .write_aofs = true, + .opt_opc = vecop_list_uqadd, .vece = MO_32 }, { .fniv = gen_uqadd_vec, .fno = gen_helper_gvec_uqadd_d, - .opc = INDEX_op_usadd_vec, .write_aofs = true, + .opt_opc = vecop_list_uqadd, .vece = MO_64 }, }; @@ -6287,25 +6318,29 @@ static void gen_sqadd_vec(unsigned vece, TCGv_vec t, TCGv_vec sat, tcg_temp_free_vec(x); } +static const TCGOpcode vecop_list_sqadd[] = { + INDEX_op_ssadd_vec, INDEX_op_cmp_vec, INDEX_op_add_vec, 0 +}; + const GVecGen4 sqadd_op[4] = { { .fniv = gen_sqadd_vec, .fno = gen_helper_gvec_sqadd_b, - .opc = INDEX_op_ssadd_vec, + .opt_opc = vecop_list_sqadd, .write_aofs = true, .vece = MO_8 }, { .fniv = gen_sqadd_vec, .fno = gen_helper_gvec_sqadd_h, - .opc = INDEX_op_ssadd_vec, + .opt_opc = vecop_list_sqadd, .write_aofs = true, .vece = MO_16 }, { .fniv = gen_sqadd_vec, .fno = gen_helper_gvec_sqadd_s, - .opc = INDEX_op_ssadd_vec, + .opt_opc = vecop_list_sqadd, .write_aofs = true, .vece = MO_32 }, { .fniv = gen_sqadd_vec, .fno = gen_helper_gvec_sqadd_d, - .opc = INDEX_op_ssadd_vec, + .opt_opc = vecop_list_sqadd, .write_aofs = true, .vece = MO_64 }, }; @@ -6321,25 +6356,29 @@ static void gen_uqsub_vec(unsigned vece, TCGv_vec t, TCGv_vec sat, tcg_temp_free_vec(x); } +static const TCGOpcode vecop_list_uqsub[] = { + INDEX_op_ussub_vec, INDEX_op_cmp_vec, INDEX_op_sub_vec, 0 +}; + const GVecGen4 uqsub_op[4] = { { .fniv = gen_uqsub_vec, .fno = gen_helper_gvec_uqsub_b, - .opc = INDEX_op_ussub_vec, + .opt_opc = vecop_list_uqsub, .write_aofs = true, .vece = MO_8 }, { .fniv = gen_uqsub_vec, .fno = gen_helper_gvec_uqsub_h, - .opc = INDEX_op_ussub_vec, + .opt_opc = vecop_list_uqsub, .write_aofs = true, .vece = MO_16 }, { .fniv = gen_uqsub_vec, .fno = gen_helper_gvec_uqsub_s, - .opc = INDEX_op_ussub_vec, + .opt_opc = vecop_list_uqsub, .write_aofs = true, .vece = MO_32 }, { .fniv = gen_uqsub_vec, .fno = gen_helper_gvec_uqsub_d, - .opc = INDEX_op_ussub_vec, + .opt_opc = vecop_list_uqsub, .write_aofs = true, .vece = MO_64 }, }; @@ -6355,25 +6394,29 @@ static void gen_sqsub_vec(unsigned vece, TCGv_vec t, TCGv_vec sat, tcg_temp_free_vec(x); } +static const TCGOpcode vecop_list_sqsub[] = { + INDEX_op_sssub_vec, INDEX_op_cmp_vec, INDEX_op_sub_vec, 0 +}; + const GVecGen4 sqsub_op[4] = { { .fniv = gen_sqsub_vec, .fno = gen_helper_gvec_sqsub_b, - .opc = INDEX_op_sssub_vec, + .opt_opc = vecop_list_sqsub, .write_aofs = true, .vece = MO_8 }, { .fniv = gen_sqsub_vec, .fno = gen_helper_gvec_sqsub_h, - .opc = INDEX_op_sssub_vec, + .opt_opc = vecop_list_sqsub, .write_aofs = true, .vece = MO_16 }, { .fniv = gen_sqsub_vec, .fno = gen_helper_gvec_sqsub_s, - .opc = INDEX_op_sssub_vec, + .opt_opc = vecop_list_sqsub, .write_aofs = true, .vece = MO_32 }, { .fniv = gen_sqsub_vec, .fno = gen_helper_gvec_sqsub_d, - .opc = INDEX_op_sssub_vec, + .opt_opc = vecop_list_sqsub, .write_aofs = true, .vece = MO_64 }, }; diff --git a/target/ppc/translate/vmx-impl.inc.c b/target/ppc/translate/vmx-impl.inc.c index bd3ff40e68..6861f4c5b9 100644 --- a/target/ppc/translate/vmx-impl.inc.c +++ b/target/ppc/translate/vmx-impl.inc.c @@ -566,10 +566,15 @@ static void glue(glue(gen_, NAME), _vec)(unsigned vece, TCGv_vec t, \ } \ static void glue(gen_, NAME)(DisasContext *ctx) \ { \ + static const TCGOpcode vecop_list[] = { \ + glue(glue(INDEX_op_, NORM), _vec), \ + glue(glue(INDEX_op_, SAT), _vec), \ + INDEX_op_cmp_vec, 0 \ + }; \ static const GVecGen4 g = { \ .fniv = glue(glue(gen_, NAME), _vec), \ .fno = glue(gen_helper_, NAME), \ - .opc = glue(glue(INDEX_op_, SAT), _vec), \ + .opt_opc = vecop_list, \ .write_aofs = true, \ .vece = VECE, \ }; \ diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c index f831adb4e7..3fcb2352d9 100644 --- a/tcg/tcg-op-gvec.c +++ b/tcg/tcg-op-gvec.c @@ -26,6 +26,13 @@ #define MAX_UNROLL 4 +#ifdef CONFIG_DEBUG_TCG +static const TCGOpcode vecop_list_empty[1] = { 0 }; +#else +#define vecop_list_empty NULL +#endif + + /* Verify vector size and alignment rules. OFS should be the OR of all of the operand offsets so that we can check them all at once. */ static void check_size_align(uint32_t oprsz, uint32_t maxsz, uint32_t ofs) @@ -360,31 +367,29 @@ static void gen_dup_i64(unsigned vece, TCGv_i64 out, TCGv_i64 in) * on elements of size VECE in the selected type. Do not select V64 if * PREFER_I64 is true. Return 0 if no vector type is selected. */ -static TCGType choose_vector_type(TCGOpcode op, unsigned vece, uint32_t size, - bool prefer_i64) +static TCGType choose_vector_type(const TCGOpcode *list, unsigned vece, + uint32_t size, bool prefer_i64) { if (TCG_TARGET_HAS_v256 && check_size_impl(size, 32)) { - if (op == 0) { - return TCG_TYPE_V256; - } - /* Recall that ARM SVE allows vector sizes that are not a + /* + * 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. * It is hard to imagine a case in which v256 is supported * but v128 is not, but check anyway. */ - if (tcg_can_emit_vec_op(op, TCG_TYPE_V256, vece) + if (tcg_can_emit_vecop_list(list, TCG_TYPE_V256, vece) && (size % 32 == 0 - || tcg_can_emit_vec_op(op, TCG_TYPE_V128, vece))) { + || tcg_can_emit_vecop_list(list, TCG_TYPE_V128, vece))) { return TCG_TYPE_V256; } } if (TCG_TARGET_HAS_v128 && check_size_impl(size, 16) - && (op == 0 || tcg_can_emit_vec_op(op, TCG_TYPE_V128, vece))) { + && tcg_can_emit_vecop_list(list, TCG_TYPE_V128, vece)) { return TCG_TYPE_V128; } if (TCG_TARGET_HAS_v64 && !prefer_i64 && check_size_impl(size, 8) - && (op == 0 || tcg_can_emit_vec_op(op, TCG_TYPE_V64, vece))) { + && tcg_can_emit_vecop_list(list, TCG_TYPE_V64, vece)) { return TCG_TYPE_V64; } return 0; @@ -418,7 +423,7 @@ static void do_dup(unsigned vece, uint32_t dofs, uint32_t oprsz, /* Implement inline with a vector type, if possible. * Prefer integer when 64-bit host and no variable dup. */ - type = choose_vector_type(0, vece, oprsz, + type = choose_vector_type(NULL, vece, oprsz, (TCG_TARGET_REG_BITS == 64 && in_32 == NULL && (in_64 == NULL || vece == MO_64))); if (type != 0) { @@ -991,6 +996,8 @@ static void expand_4_vec(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_2(uint32_t dofs, uint32_t aofs, uint32_t oprsz, uint32_t maxsz, const GVecGen2 *g) { + const TCGOpcode *this_list = g->opt_opc ? : vecop_list_empty; + const TCGOpcode *hold_list = tcg_swap_vecop_list(this_list); TCGType type; uint32_t some; @@ -999,7 +1006,7 @@ void tcg_gen_gvec_2(uint32_t dofs, uint32_t aofs, type = 0; if (g->fniv) { - type = choose_vector_type(g->opc, g->vece, oprsz, g->prefer_i64); + type = choose_vector_type(g->opt_opc, g->vece, oprsz, g->prefer_i64); } switch (type) { case TCG_TYPE_V256: @@ -1032,13 +1039,14 @@ void tcg_gen_gvec_2(uint32_t dofs, uint32_t aofs, } else { assert(g->fno != NULL); tcg_gen_gvec_2_ool(dofs, aofs, oprsz, maxsz, g->data, g->fno); - return; + oprsz = maxsz; } break; default: g_assert_not_reached(); } + tcg_swap_vecop_list(hold_list); if (oprsz < maxsz) { expand_clr(dofs + oprsz, maxsz - oprsz); @@ -1049,6 +1057,8 @@ void tcg_gen_gvec_2(uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_2i(uint32_t dofs, uint32_t aofs, uint32_t oprsz, uint32_t maxsz, int64_t c, const GVecGen2i *g) { + const TCGOpcode *this_list = g->opt_opc ? : vecop_list_empty; + const TCGOpcode *hold_list = tcg_swap_vecop_list(this_list); TCGType type; uint32_t some; @@ -1057,7 +1067,7 @@ void tcg_gen_gvec_2i(uint32_t dofs, uint32_t aofs, uint32_t oprsz, type = 0; if (g->fniv) { - type = choose_vector_type(g->opc, g->vece, oprsz, g->prefer_i64); + type = choose_vector_type(g->opt_opc, g->vece, oprsz, g->prefer_i64); } switch (type) { case TCG_TYPE_V256: @@ -1099,13 +1109,14 @@ void tcg_gen_gvec_2i(uint32_t dofs, uint32_t aofs, uint32_t oprsz, maxsz, c, g->fnoi); tcg_temp_free_i64(tcg_c); } - return; + oprsz = maxsz; } break; default: g_assert_not_reached(); } + tcg_swap_vecop_list(hold_list); if (oprsz < maxsz) { expand_clr(dofs + oprsz, maxsz - oprsz); @@ -1123,9 +1134,11 @@ void tcg_gen_gvec_2s(uint32_t dofs, uint32_t aofs, uint32_t oprsz, type = 0; if (g->fniv) { - type = choose_vector_type(g->opc, g->vece, oprsz, g->prefer_i64); + type = choose_vector_type(g->opt_opc, g->vece, oprsz, g->prefer_i64); } if (type != 0) { + const TCGOpcode *this_list = g->opt_opc ? : vecop_list_empty; + const TCGOpcode *hold_list = tcg_swap_vecop_list(this_list); TCGv_vec t_vec = tcg_temp_new_vec(type); uint32_t some; @@ -1163,6 +1176,7 @@ void tcg_gen_gvec_2s(uint32_t dofs, uint32_t aofs, uint32_t oprsz, g_assert_not_reached(); } tcg_temp_free_vec(t_vec); + tcg_swap_vecop_list(hold_list); } else if (g->fni8 && check_size_impl(oprsz, 8)) { TCGv_i64 t64 = tcg_temp_new_i64(); @@ -1190,6 +1204,8 @@ void tcg_gen_gvec_2s(uint32_t dofs, uint32_t aofs, uint32_t oprsz, void tcg_gen_gvec_3(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz, const GVecGen3 *g) { + const TCGOpcode *this_list = g->opt_opc ? : vecop_list_empty; + const TCGOpcode *hold_list = tcg_swap_vecop_list(this_list); TCGType type; uint32_t some; @@ -1198,7 +1214,7 @@ void tcg_gen_gvec_3(uint32_t dofs, uint32_t aofs, uint32_t bofs, type = 0; if (g->fniv) { - type = choose_vector_type(g->opc, g->vece, oprsz, g->prefer_i64); + type = choose_vector_type(g->opt_opc, g->vece, oprsz, g->prefer_i64); } switch (type) { case TCG_TYPE_V256: @@ -1236,13 +1252,14 @@ void tcg_gen_gvec_3(uint32_t dofs, uint32_t aofs, uint32_t bofs, assert(g->fno != NULL); tcg_gen_gvec_3_ool(dofs, aofs, bofs, oprsz, maxsz, g->data, g->fno); - return; + oprsz = maxsz; } break; default: g_assert_not_reached(); } + tcg_swap_vecop_list(hold_list); if (oprsz < maxsz) { expand_clr(dofs + oprsz, maxsz - oprsz); @@ -1254,6 +1271,8 @@ void tcg_gen_gvec_3i(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz, int64_t c, const GVecGen3i *g) { + const TCGOpcode *this_list = g->opt_opc ? : vecop_list_empty; + const TCGOpcode *hold_list = tcg_swap_vecop_list(this_list); TCGType type; uint32_t some; @@ -1262,7 +1281,7 @@ void tcg_gen_gvec_3i(uint32_t dofs, uint32_t aofs, uint32_t bofs, type = 0; if (g->fniv) { - type = choose_vector_type(g->opc, g->vece, oprsz, g->prefer_i64); + type = choose_vector_type(g->opt_opc, g->vece, oprsz, g->prefer_i64); } switch (type) { case TCG_TYPE_V256: @@ -1300,13 +1319,14 @@ void tcg_gen_gvec_3i(uint32_t dofs, uint32_t aofs, uint32_t bofs, } else { assert(g->fno != NULL); tcg_gen_gvec_3_ool(dofs, aofs, bofs, oprsz, maxsz, c, g->fno); - return; + oprsz = maxsz; } break; default: g_assert_not_reached(); } + tcg_swap_vecop_list(hold_list); if (oprsz < maxsz) { expand_clr(dofs + oprsz, maxsz - oprsz); @@ -1317,6 +1337,8 @@ void tcg_gen_gvec_3i(uint32_t dofs, uint32_t aofs, uint32_t bofs, void tcg_gen_gvec_4(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, uint32_t oprsz, uint32_t maxsz, const GVecGen4 *g) { + const TCGOpcode *this_list = g->opt_opc ? : vecop_list_empty; + const TCGOpcode *hold_list = tcg_swap_vecop_list(this_list); TCGType type; uint32_t some; @@ -1325,7 +1347,7 @@ void tcg_gen_gvec_4(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, type = 0; if (g->fniv) { - type = choose_vector_type(g->opc, g->vece, oprsz, g->prefer_i64); + type = choose_vector_type(g->opt_opc, g->vece, oprsz, g->prefer_i64); } switch (type) { case TCG_TYPE_V256: @@ -1366,13 +1388,14 @@ void tcg_gen_gvec_4(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t cofs, assert(g->fno != NULL); tcg_gen_gvec_4_ool(dofs, aofs, bofs, cofs, oprsz, maxsz, g->data, g->fno); - return; + oprsz = maxsz; } break; default: g_assert_not_reached(); } + tcg_swap_vecop_list(hold_list); if (oprsz < maxsz) { expand_clr(dofs + oprsz, maxsz - oprsz); @@ -1567,6 +1590,8 @@ void tcg_gen_vec_add32_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) tcg_temp_free_i64(t2); } +static const TCGOpcode vecop_list_add[] = { INDEX_op_add_vec, 0 }; + void tcg_gen_gvec_add(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { @@ -1574,22 +1599,22 @@ void tcg_gen_gvec_add(unsigned vece, uint32_t dofs, uint32_t aofs, { .fni8 = tcg_gen_vec_add8_i64, .fniv = tcg_gen_add_vec, .fno = gen_helper_gvec_add8, - .opc = INDEX_op_add_vec, + .opt_opc = vecop_list_add, .vece = MO_8 }, { .fni8 = tcg_gen_vec_add16_i64, .fniv = tcg_gen_add_vec, .fno = gen_helper_gvec_add16, - .opc = INDEX_op_add_vec, + .opt_opc = vecop_list_add, .vece = MO_16 }, { .fni4 = tcg_gen_add_i32, .fniv = tcg_gen_add_vec, .fno = gen_helper_gvec_add32, - .opc = INDEX_op_add_vec, + .opt_opc = vecop_list_add, .vece = MO_32 }, { .fni8 = tcg_gen_add_i64, .fniv = tcg_gen_add_vec, .fno = gen_helper_gvec_add64, - .opc = INDEX_op_add_vec, + .opt_opc = vecop_list_add, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -1605,22 +1630,22 @@ void tcg_gen_gvec_adds(unsigned vece, uint32_t dofs, uint32_t aofs, { .fni8 = tcg_gen_vec_add8_i64, .fniv = tcg_gen_add_vec, .fno = gen_helper_gvec_adds8, - .opc = INDEX_op_add_vec, + .opt_opc = vecop_list_add, .vece = MO_8 }, { .fni8 = tcg_gen_vec_add16_i64, .fniv = tcg_gen_add_vec, .fno = gen_helper_gvec_adds16, - .opc = INDEX_op_add_vec, + .opt_opc = vecop_list_add, .vece = MO_16 }, { .fni4 = tcg_gen_add_i32, .fniv = tcg_gen_add_vec, .fno = gen_helper_gvec_adds32, - .opc = INDEX_op_add_vec, + .opt_opc = vecop_list_add, .vece = MO_32 }, { .fni8 = tcg_gen_add_i64, .fniv = tcg_gen_add_vec, .fno = gen_helper_gvec_adds64, - .opc = INDEX_op_add_vec, + .opt_opc = vecop_list_add, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -1637,6 +1662,8 @@ void tcg_gen_gvec_addi(unsigned vece, uint32_t dofs, uint32_t aofs, tcg_temp_free_i64(tmp); } +static const TCGOpcode vecop_list_sub[] = { INDEX_op_sub_vec, 0 }; + void tcg_gen_gvec_subs(unsigned vece, uint32_t dofs, uint32_t aofs, TCGv_i64 c, uint32_t oprsz, uint32_t maxsz) { @@ -1644,22 +1671,22 @@ void tcg_gen_gvec_subs(unsigned vece, uint32_t dofs, uint32_t aofs, { .fni8 = tcg_gen_vec_sub8_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_gvec_subs8, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list_sub, .vece = MO_8 }, { .fni8 = tcg_gen_vec_sub16_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_gvec_subs16, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list_sub, .vece = MO_16 }, { .fni4 = tcg_gen_sub_i32, .fniv = tcg_gen_sub_vec, .fno = gen_helper_gvec_subs32, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list_sub, .vece = MO_32 }, { .fni8 = tcg_gen_sub_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_gvec_subs64, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list_sub, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -1723,22 +1750,22 @@ void tcg_gen_gvec_sub(unsigned vece, uint32_t dofs, uint32_t aofs, { .fni8 = tcg_gen_vec_sub8_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_gvec_sub8, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list_sub, .vece = MO_8 }, { .fni8 = tcg_gen_vec_sub16_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_gvec_sub16, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list_sub, .vece = MO_16 }, { .fni4 = tcg_gen_sub_i32, .fniv = tcg_gen_sub_vec, .fno = gen_helper_gvec_sub32, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list_sub, .vece = MO_32 }, { .fni8 = tcg_gen_sub_i64, .fniv = tcg_gen_sub_vec, .fno = gen_helper_gvec_sub64, - .opc = INDEX_op_sub_vec, + .opt_opc = vecop_list_sub, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -1747,27 +1774,29 @@ void tcg_gen_gvec_sub(unsigned vece, uint32_t dofs, uint32_t aofs, tcg_gen_gvec_3(dofs, aofs, bofs, oprsz, maxsz, &g[vece]); } +static const TCGOpcode vecop_list_mul[] = { INDEX_op_mul_vec, 0 }; + void tcg_gen_gvec_mul(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { static const GVecGen3 g[4] = { { .fniv = tcg_gen_mul_vec, .fno = gen_helper_gvec_mul8, - .opc = INDEX_op_mul_vec, + .opt_opc = vecop_list_mul, .vece = MO_8 }, { .fniv = tcg_gen_mul_vec, .fno = gen_helper_gvec_mul16, - .opc = INDEX_op_mul_vec, + .opt_opc = vecop_list_mul, .vece = MO_16 }, { .fni4 = tcg_gen_mul_i32, .fniv = tcg_gen_mul_vec, .fno = gen_helper_gvec_mul32, - .opc = INDEX_op_mul_vec, + .opt_opc = vecop_list_mul, .vece = MO_32 }, { .fni8 = tcg_gen_mul_i64, .fniv = tcg_gen_mul_vec, .fno = gen_helper_gvec_mul64, - .opc = INDEX_op_mul_vec, + .opt_opc = vecop_list_mul, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -1782,21 +1811,21 @@ void tcg_gen_gvec_muls(unsigned vece, uint32_t dofs, uint32_t aofs, static const GVecGen2s g[4] = { { .fniv = tcg_gen_mul_vec, .fno = gen_helper_gvec_muls8, - .opc = INDEX_op_mul_vec, + .opt_opc = vecop_list_mul, .vece = MO_8 }, { .fniv = tcg_gen_mul_vec, .fno = gen_helper_gvec_muls16, - .opc = INDEX_op_mul_vec, + .opt_opc = vecop_list_mul, .vece = MO_16 }, { .fni4 = tcg_gen_mul_i32, .fniv = tcg_gen_mul_vec, .fno = gen_helper_gvec_muls32, - .opc = INDEX_op_mul_vec, + .opt_opc = vecop_list_mul, .vece = MO_32 }, { .fni8 = tcg_gen_mul_i64, .fniv = tcg_gen_mul_vec, .fno = gen_helper_gvec_muls64, - .opc = INDEX_op_mul_vec, + .opt_opc = vecop_list_mul, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -1816,22 +1845,23 @@ void tcg_gen_gvec_muli(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_ssadd(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_ssadd_vec, 0 }; static const GVecGen3 g[4] = { { .fniv = tcg_gen_ssadd_vec, .fno = gen_helper_gvec_ssadd8, - .opc = INDEX_op_ssadd_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fniv = tcg_gen_ssadd_vec, .fno = gen_helper_gvec_ssadd16, - .opc = INDEX_op_ssadd_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fniv = tcg_gen_ssadd_vec, .fno = gen_helper_gvec_ssadd32, - .opc = INDEX_op_ssadd_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fniv = tcg_gen_ssadd_vec, .fno = gen_helper_gvec_ssadd64, - .opc = INDEX_op_ssadd_vec, + .opt_opc = vecop_list, .vece = MO_64 }, }; tcg_debug_assert(vece <= MO_64); @@ -1841,22 +1871,23 @@ void tcg_gen_gvec_ssadd(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_sssub(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_sssub_vec, 0 }; static const GVecGen3 g[4] = { { .fniv = tcg_gen_sssub_vec, .fno = gen_helper_gvec_sssub8, - .opc = INDEX_op_sssub_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fniv = tcg_gen_sssub_vec, .fno = gen_helper_gvec_sssub16, - .opc = INDEX_op_sssub_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fniv = tcg_gen_sssub_vec, .fno = gen_helper_gvec_sssub32, - .opc = INDEX_op_sssub_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fniv = tcg_gen_sssub_vec, .fno = gen_helper_gvec_sssub64, - .opc = INDEX_op_sssub_vec, + .opt_opc = vecop_list, .vece = MO_64 }, }; tcg_debug_assert(vece <= MO_64); @@ -1882,24 +1913,25 @@ static void tcg_gen_usadd_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) void tcg_gen_gvec_usadd(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_usadd_vec, 0 }; static const GVecGen3 g[4] = { { .fniv = tcg_gen_usadd_vec, .fno = gen_helper_gvec_usadd8, - .opc = INDEX_op_usadd_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fniv = tcg_gen_usadd_vec, .fno = gen_helper_gvec_usadd16, - .opc = INDEX_op_usadd_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_usadd_i32, .fniv = tcg_gen_usadd_vec, .fno = gen_helper_gvec_usadd32, - .opc = INDEX_op_usadd_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_usadd_i64, .fniv = tcg_gen_usadd_vec, .fno = gen_helper_gvec_usadd64, - .opc = INDEX_op_usadd_vec, + .opt_opc = vecop_list, .vece = MO_64 } }; tcg_debug_assert(vece <= MO_64); @@ -1925,24 +1957,25 @@ static void tcg_gen_ussub_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) void tcg_gen_gvec_ussub(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_ussub_vec, 0 }; static const GVecGen3 g[4] = { { .fniv = tcg_gen_ussub_vec, .fno = gen_helper_gvec_ussub8, - .opc = INDEX_op_ussub_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fniv = tcg_gen_ussub_vec, .fno = gen_helper_gvec_ussub16, - .opc = INDEX_op_ussub_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_ussub_i32, .fniv = tcg_gen_ussub_vec, .fno = gen_helper_gvec_ussub32, - .opc = INDEX_op_ussub_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_ussub_i64, .fniv = tcg_gen_ussub_vec, .fno = gen_helper_gvec_ussub64, - .opc = INDEX_op_ussub_vec, + .opt_opc = vecop_list, .vece = MO_64 } }; tcg_debug_assert(vece <= MO_64); @@ -1952,24 +1985,25 @@ void tcg_gen_gvec_ussub(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_smin(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_smin_vec, 0 }; static const GVecGen3 g[4] = { { .fniv = tcg_gen_smin_vec, .fno = gen_helper_gvec_smin8, - .opc = INDEX_op_smin_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fniv = tcg_gen_smin_vec, .fno = gen_helper_gvec_smin16, - .opc = INDEX_op_smin_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_smin_i32, .fniv = tcg_gen_smin_vec, .fno = gen_helper_gvec_smin32, - .opc = INDEX_op_smin_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_smin_i64, .fniv = tcg_gen_smin_vec, .fno = gen_helper_gvec_smin64, - .opc = INDEX_op_smin_vec, + .opt_opc = vecop_list, .vece = MO_64 } }; tcg_debug_assert(vece <= MO_64); @@ -1979,24 +2013,25 @@ void tcg_gen_gvec_smin(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_umin(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_umin_vec, 0 }; static const GVecGen3 g[4] = { { .fniv = tcg_gen_umin_vec, .fno = gen_helper_gvec_umin8, - .opc = INDEX_op_umin_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fniv = tcg_gen_umin_vec, .fno = gen_helper_gvec_umin16, - .opc = INDEX_op_umin_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_umin_i32, .fniv = tcg_gen_umin_vec, .fno = gen_helper_gvec_umin32, - .opc = INDEX_op_umin_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_umin_i64, .fniv = tcg_gen_umin_vec, .fno = gen_helper_gvec_umin64, - .opc = INDEX_op_umin_vec, + .opt_opc = vecop_list, .vece = MO_64 } }; tcg_debug_assert(vece <= MO_64); @@ -2006,24 +2041,25 @@ void tcg_gen_gvec_umin(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_smax(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_smax_vec, 0 }; static const GVecGen3 g[4] = { { .fniv = tcg_gen_smax_vec, .fno = gen_helper_gvec_smax8, - .opc = INDEX_op_smax_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fniv = tcg_gen_smax_vec, .fno = gen_helper_gvec_smax16, - .opc = INDEX_op_smax_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_smax_i32, .fniv = tcg_gen_smax_vec, .fno = gen_helper_gvec_smax32, - .opc = INDEX_op_smax_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_smax_i64, .fniv = tcg_gen_smax_vec, .fno = gen_helper_gvec_smax64, - .opc = INDEX_op_smax_vec, + .opt_opc = vecop_list, .vece = MO_64 } }; tcg_debug_assert(vece <= MO_64); @@ -2033,24 +2069,25 @@ void tcg_gen_gvec_smax(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_umax(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_umax_vec, 0 }; static const GVecGen3 g[4] = { { .fniv = tcg_gen_umax_vec, .fno = gen_helper_gvec_umax8, - .opc = INDEX_op_umax_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fniv = tcg_gen_umax_vec, .fno = gen_helper_gvec_umax16, - .opc = INDEX_op_umax_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_umax_i32, .fniv = tcg_gen_umax_vec, .fno = gen_helper_gvec_umax32, - .opc = INDEX_op_umax_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_umax_i64, .fniv = tcg_gen_umax_vec, .fno = gen_helper_gvec_umax64, - .opc = INDEX_op_umax_vec, + .opt_opc = vecop_list, .vece = MO_64 } }; tcg_debug_assert(vece <= MO_64); @@ -2104,26 +2141,27 @@ void tcg_gen_vec_neg32_i64(TCGv_i64 d, TCGv_i64 b) void tcg_gen_gvec_neg(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_neg_vec, 0 }; static const GVecGen2 g[4] = { { .fni8 = tcg_gen_vec_neg8_i64, .fniv = tcg_gen_neg_vec, .fno = gen_helper_gvec_neg8, - .opc = INDEX_op_neg_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fni8 = tcg_gen_vec_neg16_i64, .fniv = tcg_gen_neg_vec, .fno = gen_helper_gvec_neg16, - .opc = INDEX_op_neg_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_neg_i32, .fniv = tcg_gen_neg_vec, .fno = gen_helper_gvec_neg32, - .opc = INDEX_op_neg_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_neg_i64, .fniv = tcg_gen_neg_vec, .fno = gen_helper_gvec_neg64, - .opc = INDEX_op_neg_vec, + .opt_opc = vecop_list, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -2139,7 +2177,6 @@ void tcg_gen_gvec_and(unsigned vece, uint32_t dofs, uint32_t aofs, .fni8 = tcg_gen_and_i64, .fniv = tcg_gen_and_vec, .fno = gen_helper_gvec_and, - .opc = INDEX_op_and_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, }; @@ -2157,7 +2194,6 @@ void tcg_gen_gvec_or(unsigned vece, uint32_t dofs, uint32_t aofs, .fni8 = tcg_gen_or_i64, .fniv = tcg_gen_or_vec, .fno = gen_helper_gvec_or, - .opc = INDEX_op_or_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, }; @@ -2175,7 +2211,6 @@ void tcg_gen_gvec_xor(unsigned vece, uint32_t dofs, uint32_t aofs, .fni8 = tcg_gen_xor_i64, .fniv = tcg_gen_xor_vec, .fno = gen_helper_gvec_xor, - .opc = INDEX_op_xor_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, }; @@ -2193,7 +2228,6 @@ void tcg_gen_gvec_andc(unsigned vece, uint32_t dofs, uint32_t aofs, .fni8 = tcg_gen_andc_i64, .fniv = tcg_gen_andc_vec, .fno = gen_helper_gvec_andc, - .opc = INDEX_op_andc_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, }; @@ -2211,7 +2245,6 @@ void tcg_gen_gvec_orc(unsigned vece, uint32_t dofs, uint32_t aofs, .fni8 = tcg_gen_orc_i64, .fniv = tcg_gen_orc_vec, .fno = gen_helper_gvec_orc, - .opc = INDEX_op_orc_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, }; @@ -2277,7 +2310,6 @@ static const GVecGen2s gop_ands = { .fni8 = tcg_gen_and_i64, .fniv = tcg_gen_and_vec, .fno = gen_helper_gvec_ands, - .opc = INDEX_op_and_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }; @@ -2303,7 +2335,6 @@ static const GVecGen2s gop_xors = { .fni8 = tcg_gen_xor_i64, .fniv = tcg_gen_xor_vec, .fno = gen_helper_gvec_xors, - .opc = INDEX_op_xor_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }; @@ -2329,7 +2360,6 @@ static const GVecGen2s gop_ors = { .fni8 = tcg_gen_or_i64, .fniv = tcg_gen_or_vec, .fno = gen_helper_gvec_ors, - .opc = INDEX_op_or_vec, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }; @@ -2368,26 +2398,27 @@ void tcg_gen_vec_shl16i_i64(TCGv_i64 d, TCGv_i64 a, int64_t c) void tcg_gen_gvec_shli(unsigned vece, uint32_t dofs, uint32_t aofs, int64_t shift, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_shli_vec, 0 }; static const GVecGen2i g[4] = { { .fni8 = tcg_gen_vec_shl8i_i64, .fniv = tcg_gen_shli_vec, .fno = gen_helper_gvec_shl8i, - .opc = INDEX_op_shli_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fni8 = tcg_gen_vec_shl16i_i64, .fniv = tcg_gen_shli_vec, .fno = gen_helper_gvec_shl16i, - .opc = INDEX_op_shli_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_shli_i32, .fniv = tcg_gen_shli_vec, .fno = gen_helper_gvec_shl32i, - .opc = INDEX_op_shli_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_shli_i64, .fniv = tcg_gen_shli_vec, .fno = gen_helper_gvec_shl64i, - .opc = INDEX_op_shli_vec, + .opt_opc = vecop_list, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -2418,26 +2449,27 @@ void tcg_gen_vec_shr16i_i64(TCGv_i64 d, TCGv_i64 a, int64_t c) void tcg_gen_gvec_shri(unsigned vece, uint32_t dofs, uint32_t aofs, int64_t shift, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_shri_vec, 0 }; static const GVecGen2i g[4] = { { .fni8 = tcg_gen_vec_shr8i_i64, .fniv = tcg_gen_shri_vec, .fno = gen_helper_gvec_shr8i, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fni8 = tcg_gen_vec_shr16i_i64, .fniv = tcg_gen_shri_vec, .fno = gen_helper_gvec_shr16i, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_shri_i32, .fniv = tcg_gen_shri_vec, .fno = gen_helper_gvec_shr32i, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_shri_i64, .fniv = tcg_gen_shri_vec, .fno = gen_helper_gvec_shr64i, - .opc = INDEX_op_shri_vec, + .opt_opc = vecop_list, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -2482,26 +2514,27 @@ void tcg_gen_vec_sar16i_i64(TCGv_i64 d, TCGv_i64 a, int64_t c) void tcg_gen_gvec_sari(unsigned vece, uint32_t dofs, uint32_t aofs, int64_t shift, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode vecop_list[] = { INDEX_op_sari_vec, 0 }; static const GVecGen2i g[4] = { { .fni8 = tcg_gen_vec_sar8i_i64, .fniv = tcg_gen_sari_vec, .fno = gen_helper_gvec_sar8i, - .opc = INDEX_op_sari_vec, + .opt_opc = vecop_list, .vece = MO_8 }, { .fni8 = tcg_gen_vec_sar16i_i64, .fniv = tcg_gen_sari_vec, .fno = gen_helper_gvec_sar16i, - .opc = INDEX_op_sari_vec, + .opt_opc = vecop_list, .vece = MO_16 }, { .fni4 = tcg_gen_sari_i32, .fniv = tcg_gen_sari_vec, .fno = gen_helper_gvec_sar32i, - .opc = INDEX_op_sari_vec, + .opt_opc = vecop_list, .vece = MO_32 }, { .fni8 = tcg_gen_sari_i64, .fniv = tcg_gen_sari_vec, .fno = gen_helper_gvec_sar64i, - .opc = INDEX_op_sari_vec, + .opt_opc = vecop_list, .prefer_i64 = TCG_TARGET_REG_BITS == 64, .vece = MO_64 }, }; @@ -2574,6 +2607,7 @@ void tcg_gen_gvec_cmp(TCGCond cond, unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { + static const TCGOpcode cmp_list[] = { INDEX_op_cmp_vec, 0 }; static gen_helper_gvec_3 * const eq_fn[4] = { gen_helper_gvec_eq8, gen_helper_gvec_eq16, gen_helper_gvec_eq32, gen_helper_gvec_eq64 @@ -2606,6 +2640,8 @@ void tcg_gen_gvec_cmp(TCGCond cond, unsigned vece, uint32_t dofs, [TCG_COND_LTU] = ltu_fn, [TCG_COND_LEU] = leu_fn, }; + + const TCGOpcode *hold_list; TCGType type; uint32_t some; @@ -2618,10 +2654,12 @@ void tcg_gen_gvec_cmp(TCGCond cond, unsigned vece, uint32_t dofs, return; } - /* Implement inline with a vector type, if possible. + /* + * Implement inline with a vector type, if possible. * Prefer integer when 64-bit host and 64-bit comparison. */ - type = choose_vector_type(INDEX_op_cmp_vec, vece, oprsz, + hold_list = tcg_swap_vecop_list(cmp_list); + type = choose_vector_type(cmp_list, vece, oprsz, TCG_TARGET_REG_BITS == 64 && vece == MO_64); switch (type) { case TCG_TYPE_V256: @@ -2663,13 +2701,14 @@ void tcg_gen_gvec_cmp(TCGCond cond, unsigned vece, uint32_t dofs, assert(fn != NULL); } tcg_gen_gvec_3_ool(dofs, aofs, bofs, oprsz, maxsz, 0, fn[vece]); - return; + oprsz = maxsz; } break; default: g_assert_not_reached(); } + tcg_swap_vecop_list(hold_list); if (oprsz < maxsz) { expand_clr(dofs + oprsz, maxsz - oprsz); diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index cfb18682b1..914fe42b1e 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -34,6 +34,90 @@ extern TCGv_i32 TCGV_HIGH_link_error(TCGv_i64); #define TCGV_HIGH TCGV_HIGH_link_error #endif +/* + * Vector optional opcode tracking. + * Except for the basic logical operations (and, or, xor), and + * data movement (mov, ld, st, dupi), many vector opcodes are + * optional and may not be supported on the host. Thank Intel + * for the irregularity in their instruction set. + * + * The gvec expanders allow custom vector operations to be composed, + * generally via the .fniv callback in the GVecGen* structures. At + * the same time, in deciding whether to use this hook we need to + * know if the host supports the required operations. This is + * presented as an array of opcodes, terminated by 0. Each opcode + * is assumed to be expanded with the given VECE. + * + * For debugging, we want to validate this array. Therefore, when + * tcg_ctx->vec_opt_opc is non-NULL, the tcg_gen_*_vec expanders + * will validate that their opcode is present in the list. + */ +#ifdef CONFIG_DEBUG_TCG +void tcg_assert_listed_vecop(TCGOpcode op) +{ + const TCGOpcode *p = tcg_ctx->vecop_list; + if (p) { + for (; *p; ++p) { + if (*p == op) { + return; + } + } + g_assert_not_reached(); + } +} +#endif + +bool tcg_can_emit_vecop_list(const TCGOpcode *list, + TCGType type, unsigned vece) +{ + if (list == NULL) { + return true; + } + + for (; *list; ++list) { + TCGOpcode opc = *list; + +#ifdef CONFIG_DEBUG_TCG + switch (opc) { + case INDEX_op_and_vec: + case INDEX_op_or_vec: + case INDEX_op_xor_vec: + case INDEX_op_mov_vec: + case INDEX_op_dup_vec: + case INDEX_op_dupi_vec: + case INDEX_op_dup2_vec: + case INDEX_op_ld_vec: + case INDEX_op_st_vec: + /* These opcodes are mandatory and should not be listed. */ + g_assert_not_reached(); + default: + break; + } +#endif + + if (tcg_can_emit_vec_op(opc, type, vece)) { + continue; + } + + /* + * The opcode list is created by front ends based on what they + * actually invoke. We must mirror the logic in the routines + * below for generic expansions using other opcodes. + */ + switch (opc) { + case INDEX_op_neg_vec: + if (tcg_can_emit_vec_op(INDEX_op_sub_vec, type, vece)) { + continue; + } + break; + default: + break; + } + return false; + } + return true; +} + void vec_gen_2(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a) { TCGOp *op = tcg_emit_op(opc); @@ -296,11 +380,14 @@ static bool do_op2(unsigned vece, TCGv_vec r, TCGv_vec a, TCGOpcode opc) int can; tcg_debug_assert(at->base_type >= type); + tcg_assert_listed_vecop(opc); can = tcg_can_emit_vec_op(opc, type, vece); if (can > 0) { vec_gen_2(opc, type, vece, ri, ai); } else if (can < 0) { + const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL); tcg_expand_vec_op(opc, type, vece, ri, ai); + tcg_swap_vecop_list(hold_list); } else { return false; } @@ -318,11 +405,17 @@ 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) { + const TCGOpcode *hold_list; + + tcg_assert_listed_vecop(INDEX_op_neg_vec); + hold_list = tcg_swap_vecop_list(NULL); + 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); } + tcg_swap_vecop_list(hold_list); } static void do_shifti(TCGOpcode opc, unsigned vece, @@ -337,6 +430,7 @@ static void do_shifti(TCGOpcode opc, unsigned vece, tcg_debug_assert(at->base_type == type); tcg_debug_assert(i >= 0 && i < (8 << vece)); + tcg_assert_listed_vecop(opc); if (i == 0) { tcg_gen_mov_vec(r, a); @@ -350,8 +444,10 @@ static void do_shifti(TCGOpcode opc, unsigned vece, /* We leave the choice of expansion via scalar or vector shift to the target. Often, but not always, dupi can feed a vector shift easier than a scalar. */ + const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL); tcg_debug_assert(can < 0); tcg_expand_vec_op(opc, type, vece, ri, ai, i); + tcg_swap_vecop_list(hold_list); } } @@ -384,12 +480,15 @@ void tcg_gen_cmp_vec(TCGCond cond, unsigned vece, tcg_debug_assert(at->base_type >= type); tcg_debug_assert(bt->base_type >= type); + tcg_assert_listed_vecop(INDEX_op_cmp_vec); can = tcg_can_emit_vec_op(INDEX_op_cmp_vec, type, vece); if (can > 0) { vec_gen_4(INDEX_op_cmp_vec, type, vece, ri, ai, bi, cond); } else { + const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL); tcg_debug_assert(can < 0); tcg_expand_vec_op(INDEX_op_cmp_vec, type, vece, ri, ai, bi, cond); + tcg_swap_vecop_list(hold_list); } } @@ -407,12 +506,15 @@ static void do_op3(unsigned vece, TCGv_vec r, TCGv_vec a, tcg_debug_assert(at->base_type >= type); tcg_debug_assert(bt->base_type >= type); + tcg_assert_listed_vecop(opc); can = tcg_can_emit_vec_op(opc, type, vece); if (can > 0) { vec_gen_3(opc, type, vece, ri, ai, bi); } else { + const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL); tcg_debug_assert(can < 0); tcg_expand_vec_op(opc, type, vece, ri, ai, bi); + tcg_swap_vecop_list(hold_list); } } From patchwork Wed May 1 05:05:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163188 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4124458ill; Tue, 30 Apr 2019 22:12:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzi3Ym/OHbRj7WQK88ZGURdVC7sks6XAO1r2zKFdavnYBSw6x+JJrsNUsgQvTJYdyF9EJjd X-Received: by 2002:ac2:5c48:: with SMTP id s8mr2381020lfp.126.1556687541982; Tue, 30 Apr 2019 22:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687541; cv=none; d=google.com; s=arc-20160816; b=dJ/8Wze8Gi+QoHcMSQ3+7m695PUq2t0nGN03AqZdwrDR2XAE0FWrO3pGbFXY928+sb +SPNus4cmbxpCTf0BHyUYTnyi5PLoMq7pvWnfIrMsspJuASzKFIwd9gZjnoa4T897RUt Ft1w8tRYcRuggnugFzP+QYWsyNZjEBC/vIRGs8mu2AgSwMYvWzyKUn0IP3HUtuf2f++5 XR52lwZPOg3tggwiHWeqjxlvY2BCL4niqZIfrp3ZssYJXb+WrpNHhqy4nbinjGk8Vl2a uid7fwPSu/kQrtluLbIue+SsSpu1gwh2qoevMQWjtQ0L2MXZ19qmlQeQ8GhhRYPhQgZq av4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=U3BnDe65BmJP00y5pZ+7ayWPkWBbMA/WJCdscz/OiAE=; b=ajByXYzQDhUQgfpupAxNy7oTHPPgPVSzCQiLnNniRWceNUkmFjSS2PgxoDWSns3VwQ pvJnileMCv4EDOiQuUy7p1VQX/+7wZxRmhN/pCp//P6XKRY5mO0ayx5gfr4QT3aEtqH0 TVCvUfwM/pHkXEvCYq9Lt5lkqPMzIfpF+LHsFuEF/Puq+2GO+G4DLOBTxH2nej/8TVIK Pup37GSxWYw0EY9hKQvbbDXsYi6rPAI1zNMOTOR4lqXRwISkQn9wa9xJr6znFDaolAow nE6D4y2GvemeemQ8HcZUH2PZ70+QhjT2NT986nXBZnGZXch0wpJEELka2aWrmoTM9RZQ 5beA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=p1dJFdQd; 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 x26si1926535ljc.195.2019.04.30.22.12.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:12:21 -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=p1dJFdQd; 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]:36303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhXY-0003Co-FE for patch@linaro.org; Wed, 01 May 2019 01:12:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRL-0006Li-JK for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRI-0002pj-I4 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:55 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:37724) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRI-0002ow-Be for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:52 -0400 Received: by mail-pg1-x543.google.com with SMTP id e6so7869095pgc.4 for ; Tue, 30 Apr 2019 22:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=U3BnDe65BmJP00y5pZ+7ayWPkWBbMA/WJCdscz/OiAE=; b=p1dJFdQdU92z34tSiyC7YBzzcn/BuZrBM9bO6xb3PFlOzaRo6+xjz0CAuv2RkHOsYM vTQplNZoX4p6E+oB6PO6QkKKEOnhGqkqyPAX3ZU/R7eYL1E9qsSKwDuekeOqG0eyoll1 rPIX6wCAJXQ/dj6L7uDpRUDoAytb5eE4mfzEk9uS9aXn0cMeI/i6NVWqHKwGFTypmWm4 efjMlqh1MCnDzVFSqRXfse50dIzd/pARJAgGHWuBFQaDPArH1tOKEJ3MWgp60qM99vWR B00c2UI4jaD+NVLx6+vRDybXlwRDU4ZrGxARQ+r5IOopPbB1vnU3c4iVxwRuU475hkUP Yjtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=U3BnDe65BmJP00y5pZ+7ayWPkWBbMA/WJCdscz/OiAE=; b=ukOo1gyW+7yRdckxPNgkzI3lsw6LMJ8cI/8qNAwRQVPk4WO4fhVltk1WUUskklvmxD 5GrBwJ3PMe8iI6+qQ934/kIdfDsVToreRIqaGI/XbVkEVmy650qL9MiNYLnYHMM/V6F6 M+i9vr4ScW8W59o1QJY9oNqEmuRbrw0fBPf4cIVQOn+BD5HM8alHNKlOscFC8tUQ9RJE nRnCe0ePbJRqBJP3ZzIrsrqxxoa84DzFyUs8bEqd2wsI09t6sJdOLuJk0f6EHCB8p2kR 4oStoYqP5hv9Q5lmo1deVeCVNCwj7RPHhKld1ASABID9NjlvMWtAsqgltAirAgtRjSn6 tw+g== X-Gm-Message-State: APjAAAUyquZMyRZZS+NcO92k9bOa6EjYjKQQ+l7svmZ5FLmJX6/9hfOY AUPHqLR2PyrEqhM51EivA0vRKDgADhs= X-Received: by 2002:a63:ee15:: with SMTP id e21mr43206964pgi.180.1556687149735; Tue, 30 Apr 2019 22:05:49 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:12 -0700 Message-Id: <20190501050536.15580-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v2 05/29] 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: , 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. Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- tcg/tcg.c | 87 +++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 47 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/tcg.c b/tcg/tcg.c index f7bef51de8..70ca113c26 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3274,11 +3274,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) { @@ -3314,6 +3311,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; @@ -3338,7 +3338,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)); @@ -3351,7 +3351,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; @@ -3504,6 +3504,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]; @@ -3512,29 +3516,21 @@ 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; } } @@ -3550,10 +3546,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)) { @@ -3674,26 +3670,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 Wed May 1 05:05:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163179 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4122219ill; Tue, 30 Apr 2019 22:08:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGfeSH/kgzv5Or6iw78I55FqDiOdkLnsqkdCcaDDxFJuvBr+dEy4bM1yMgb26RIfjIRfQ6 X-Received: by 2002:a05:6000:110a:: with SMTP id z10mr3214604wrw.86.1556687331541; Tue, 30 Apr 2019 22:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687331; cv=none; d=google.com; s=arc-20160816; b=Flgn0jMduNM8GYB5LIrmVo/VSWO13ggbTj4PA4kSIkbrawoCbjCPmhW2tG2kW0+a9N S1iw960zR27Qkx6wsNiZ1CQns2uBjbtrDEGe6BijBGDrsMimby4UXv68bIBqaHVsSJP+ cC4frYlSALgLsNqyGQDctUNAk3gzfS205x/AA+H6bvlUhNHyMJgcH9wQmgiL/mkjtdfj VLQmSXfzwvmNtHO70hD5Z/cG80Ta9WeF6A2zcxXtNPC2pMjEWKXDuVtrOYK3xFjA6yiB Fvf84YuKlBqDDi5nYGv/OaQclPplcXk8BNsFYQ/FU62c6bdeR4aCOm1yC0aJcV0EdK/z wb6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=qiiPM6Lpw8c2dEQtxX+Nb/J/c5fJDmZyk5OYGy8I6xw=; b=sW40D4tC71EIs0a8sNBfmsmfm9K6S+YfNGuonQdHGYu3XYNfmLxBLQd5SqBB/jQvGW +LP/t3lOBj05mYnB7VroyEHt3cjaY5KWBOjhCEng1k1ipgkEeNuVtRzX4zVgNeYqyxdx 6XlKZHu9EXpPr6sTAdJ+LNUc9gnkK2qiLAV5aYc+qHEGDZ+vm68EOV76K9zda4C6Pdpj FZ/hEaQw5I0VHgoJFSnEsyTapa34hVFbe2zla5jBMF8tkAGYOC+QOZGkMDhrbl1FCLrd m9d2k3eEYDzck/QY3PxHZvBxA6O7xWG8yKILNPiRK15RvbNdKmpl8bWKG9apWrGiWA04 xNqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xivpR5MH; 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 w2si26898709wro.320.2019.04.30.22.08.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:08:51 -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=xivpR5MH; 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]:36235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhUA-0000LZ-BB for patch@linaro.org; Wed, 01 May 2019 01:08:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRL-0006Lm-MG for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRI-0002pp-Km for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:55 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:39956) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRI-0002pT-CJ for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:52 -0400 Received: by mail-pl1-x643.google.com with SMTP id b3so7749326plr.7 for ; Tue, 30 Apr 2019 22:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qiiPM6Lpw8c2dEQtxX+Nb/J/c5fJDmZyk5OYGy8I6xw=; b=xivpR5MHUxC+bP+6h6AauntNVtEeoZZlPCRU2ysbFn+WHY+jOdVfhN7f/HO+Pcdoy8 UKexga8QJLcNFrOrZQgBcsZdxQnrQldGZgpldoBWt+x6L6XKm+/57UtM62ymRwDCNKSZ yNpB1fj7VT91GxkEEfhueFMyAbZcTO3PehyOABkNlCQ7fYoJMcudT0rvveSjKbd/721L aGqTW5N/IsuOuJUU28Otp0uUTP7ZKyO1Fv6eBxJgdv9KARTGc7DqWnhXjxm9oYey1b0p qZ7Bt1Vpmk3Omsg+mA+UMvq/v8WBcsOHMSO/VV56CRFRF8KV8EP0X5mzAU389dzRdMre Vjfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qiiPM6Lpw8c2dEQtxX+Nb/J/c5fJDmZyk5OYGy8I6xw=; b=Q27b3um/S/JS+Jn/br4Xt8OgPqz2n/GV+E9JaAqWO508h20rbBb5kf3gRsP1aBs5UX vxYSQJQwhhbFQT1PPYXMG0TbqMYIKAa4D3oW/UCs93NTXY5NbDy5+mLSRf3BMu5UYRQO 5ukGm6welfi2uncWRuU1VMR5l9tjrLt49Xw9dYDF4ylpEjp4x96v/xDwqOuEtYDKuq+k H+wJHoejg9pRxOfeEZNVTogjKoHv3dOiiF1Pt+wjaFxEfj6uIXyBqMfWk5P6zsMqSN3T j6D83OYh5w9m0G87/ByibRJ3Rxqzdlg6iHq1S5Nhicpiv0Gqd7p3kPWLecpamFYM4N/t IheQ== X-Gm-Message-State: APjAAAWOMBkrdeuj09zMaUQAcigjowxukHgyQ440+NYoErm356Z6M2yL YoPlO7hk4ZgmshouCHaZ3Qkd48jXr9s= X-Received: by 2002:a17:902:b28:: with SMTP id 37mr73531641plq.322.1556687150941; Tue, 30 Apr 2019 22:05:50 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:13 -0700 Message-Id: <20190501050536.15580-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v2 06/29] 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: , 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 Hildenbrand Reviewed-by: Philippe Mathieu-Daudé 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.1 Reviewed-by: Alex Bennée diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index eefa929948..ee89734318 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 abf0c444b4..dab93f7872 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -2264,10 +2264,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 d5ed9f1ffd..1198c76392 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -809,12 +809,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: @@ -852,6 +852,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 412cacdcb9..7cafd4a790 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 36b4791707..30c095d3d5 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -559,12 +559,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 2932505094..6497a4dab2 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 3d6150b10e..331d51852c 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 70ca113c26..8ed7cb8654 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -103,7 +103,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, @@ -3367,7 +3367,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; @@ -3467,7 +3469,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; @@ -3626,7 +3630,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 Wed May 1 05:05: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: 163180 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4122257ill; Tue, 30 Apr 2019 22:08:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqywsz7SNZZ+ffHB0qXvbqOMBZ10hOT1DwH+qqQQ9a8ip8l+N2b63/m1VdgpoShRXh5iiWgv X-Received: by 2002:a1c:b646:: with SMTP id g67mr5496064wmf.125.1556687334820; Tue, 30 Apr 2019 22:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687334; cv=none; d=google.com; s=arc-20160816; b=gC2F6ZAsAfLQgh6vbBwq9wONy2l+VvwuhLFLhVh8Gpevh3mQMYO4RFXvx8C0gO8Y4K /+lsSW+eW+qDJJAPlcKnY50HlBNfTKfCQdzR/gAeuT1uSEYmjND3kxChO4/6aF5o/3Of y4Inhgj2v2FTwpT8Fs1D1gKq73CUCPijsYr0VNou/bntYU6tyzsN8dhRYVcVYC8/Id3U CP1JxzSwU9/+X0L8KpmqGwhSWCFg/T5u7Isd9izjmJ1NIwElDCOF128XfE19QFNH0oTN GR7Nlf2XP+K27AkPzYVu5ADhc274MRKd9438vb+Ya2SEWFRgRKSnBJCzfraGr7NBg0iz RKqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=jMr4oVpt08WI1vYqrX0gvWFc/UY/0FSsdcwMQYw/C7U=; b=Ku+OpWh9dG4XeJWW5id7JH+UW3zyq0BJZd9XdeGEtkq3U8+cFlZvHttNFEM2UcUKEk eud/ldlEWbDBV0krPYr3LXSsGSfDYt+bQvEvL52XsC/5ynVGRdEByUbClQf2Tv8E4Pe/ nBv+9jpa4XGNH4SlsP3Gzum92z0F/tREB9FoFxV6uWTT8vdmuiXhrhL03F11LEfQ33H5 OQsu5HzgOghwnXjgiiWj16Mb4xvBc7pPKbJoyNWi4pF7Uy9oPEE3Rqgnh0000Mk//5id zNJkHAgpkOOX4VJOIdss1x+lews7Iuk/1Qk7VLEwrnnL9UPru7Lc7hgrdZZ2o8XoYrTg P8gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WyzpWnIk; 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 h14si4931287wrp.44.2019.04.30.22.08.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:08: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=WyzpWnIk; 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]:36237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhUD-0000Og-Oe for patch@linaro.org; Wed, 01 May 2019 01:08:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRM-0006Mf-Hf for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRJ-0002qF-GM for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:56 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:45892) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRJ-0002pw-Au for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:53 -0400 Received: by mail-pg1-x541.google.com with SMTP id i21so4414707pgi.12 for ; Tue, 30 Apr 2019 22:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=jMr4oVpt08WI1vYqrX0gvWFc/UY/0FSsdcwMQYw/C7U=; b=WyzpWnIkM6OoVIcEy9MNoYvfc4GGBMTeDDMHf8BmCxFcNXkJJMjcJNGvBjuWh5oCFT NlUyXMWNcWA9BFwbcS9Ls4wq1ceJk+gU8Cu5PzlaxzPoxsNrSJDVAlVFCPctq7ogusb5 71HXXHUyzGN3geHqn5gr32APhh28mIg+e15QsZWt1fuPm8GOMArjp28+EgjqvVeJ9erJ 40oANmDEWP7u25UzmNo2pu+SqO5zBG8RAifyTtZA9h+CzydmohSo5NKnfdDfr1aMz5PU x/aARQBhFU4C88ZAEZ7cux7CuSXhwL3ILFB2Y0ieFA/waDGA03Ztp3GsP+BQl1fld86d mnhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=jMr4oVpt08WI1vYqrX0gvWFc/UY/0FSsdcwMQYw/C7U=; b=Vh++sISGmZbO4OgsEX+7vj53zWMoDWfIrc+LOc2UBzoG9Ba8OCmoHx3RSOH1vN3zgH c/JIC2JSscHS6qpcx+UdNk1IQbORN3fwZ9EAJqJTn17caod6pBzGbPudNvaIuprgFE1B PGEnzpKFAfZWoaHme82sXv53S5LzEvrvLCZPw2QknbYJbwPX3/qC7rI3gixrYrxqD8np 0gGQbJvbAO2C530Vn24hP3Neru9nHjAtzWap9E992+4ii6RlgI4fbP3Uy1Jd/JRQwsAh dGGwAlBJYV8VlNlvY1Nh1g0fzhaGQqAbSQGdEP08w8/jzXijpXJ3E1YF/C6SSM9aPjwQ Grjg== X-Gm-Message-State: APjAAAU3xoTiCMtzTNcXuMYNY4m/N6slbPJtcaGqSKB63vFOqckQ22dW RZPIpCW7iCfvbkANaHUpv891TcvU5nY= X-Received: by 2002:a63:6ac1:: with SMTP id f184mr73578421pgc.25.1556687152067; Tue, 30 Apr 2019 22:05:52 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:14 -0700 Message-Id: <20190501050536.15580-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v2 07/29] 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: , 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. Acked-by: David Hildenbrand Signed-off-by: Richard Henderson --- tcg/tcg.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tcg/tcg.c b/tcg/tcg.c index 8ed7cb8654..68d86361e2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3368,7 +3368,20 @@ 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; @@ -3470,7 +3483,13 @@ 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; @@ -3631,7 +3650,13 @@ 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 Wed May 1 05:05:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163182 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4122545ill; Tue, 30 Apr 2019 22:09:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLcdrN5pSuk19zXGOuuLhgPcFXRrYNm5TZjXD4jjjFzONqsaUWS2zWlos1Zj42xm1gjzYs X-Received: by 2002:a5d:4eca:: with SMTP id s10mr1093780wrv.319.1556687362305; Tue, 30 Apr 2019 22:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687362; cv=none; d=google.com; s=arc-20160816; b=IcagYzHTLevUsoYdLqvOS6v0OyM07/I/rNXYQQ5X8sz+R2Uf+1F1B3Wa6/KC/c+PRs jQeLlVtwS1bDYG1v8TB39DVDGhY9+23s9L6rEoy76IpJ4YR/WMfimHU2oh5l5scq2iwS AQtRQh9CqVteMPqtDNR8MNmSFLgPP9asVhL1RAXqOS4JHkGmZCaZUzv11b7cMtrbY1aX w7Nt2kxbuwGJiFtLgjqj9HXdW5rK/Cab3yEpYkcjbeqrRqPW+nEAPABjY3k/DoKYbNbU xfxrUZ61UX9DP06OQnNo8sVoya6mW5dMQz1OFyU4sEnwc6odlMxp1olSY8mfjVqZMeUI 6ykw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=rtRPUDY4TdKCbPvS0GzwaINTK6SrdvAgOdsr0QnNjbg=; b=jLsyaLyn0MNUt8Txy10yyPaZ+r2RCHob6Ao2hrLQtYOWmgLbAcPFA7A0GVtoWaWT6L gmVMLdo+Q/3ct1zz0dcRlNbMFkNWCEtPkVuxwygSgYkLL+IDvzU2myaFFrS+nocQTaDa FO7DGSG3K1UA6+3UIHfYMOVDh+W7BLLSdOlGFCAgq86PnrQnimY8zEtyImiRikKMIePh SEWpUEkVOpDnfdDbFtUz0dGXw73Rmd+4xPuIXrlOk0XMswNj4ZZgom7DBJ6WnbxuS6u2 R+Pvw6XsAXVCEmfHPeMRPedh5XuVxnimWXBHH13S2QePCHT4idQnZrv01WooJp0sKVsu aogg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YkWklY4M; 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 c3si26926466wrv.444.2019.04.30.22.09.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:09:22 -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=YkWklY4M; 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]:36241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhUf-0000SZ-4U for patch@linaro.org; Wed, 01 May 2019 01:09:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRN-0006Px-SH for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRK-0002qs-Qz for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:57 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRK-0002qg-LO for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:54 -0400 Received: by mail-pf1-x441.google.com with SMTP id b3so8156766pfd.1 for ; Tue, 30 Apr 2019 22:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=rtRPUDY4TdKCbPvS0GzwaINTK6SrdvAgOdsr0QnNjbg=; b=YkWklY4MUSrqX7mMOxEnKMMJWvhhNZCYDyRC7u31LuwmDgIlWlmw2PBMVt+YRDn/Pt IOHy3fMnuU/x8mecmftZHyoVeOWQuwKsZVZqOvdoCz+NBFhBFmQxz4H1Cz7e8/a63t4U RyNRr9D6zDF9oNkqHHUjVaqUd5L+4zZYbTncSgvUn42Ar3tTqrIFqO27e4/G5JahE7q/ nJT/m4AIJkDE9c/mBeP9NL+984FPEzoIOLKG1IpsiEsO0A4ys+WdPETCeH4GngGJqaYj URZNngTccAVIy5FMt568wujRzzK7g2zorpmk90BcycyKmXlp5thWpYsJhu2n72Hf3q46 1s+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=rtRPUDY4TdKCbPvS0GzwaINTK6SrdvAgOdsr0QnNjbg=; b=CobM8vbobNbYuiL5MBb3OZlyIitMXz+WXn+cLQa5yEjS6+yiZkNwuXcSNuZRRr5Xhr QrAUKu15hQT+b1kKKdUEK3QnZVqsPGwV/ZEXJvomdOu0WZQD/GGmiDMnS1AeBHfF7CbG NRzbWZEhwbWFZbHhHYxXBhCkXWnPhyQRfCCUZhhAGfKtw00X/AMttg5K7n02BEv1C6GX t+QZ3kFgIch4HrEEJrjOMTW2sFyXRE1ehm+zauoVB+WG4T4DTJnX6ApvA69/hbUYabPZ eIGku9FNDqLL+ADSC6YTyA0E3cGAVkH1CmA/ij2BOq1qQjqP9PvXLNn0WjH9DvXm5Jgp NIiA== X-Gm-Message-State: APjAAAUud0dgF3BA8AA+Q2fiPKWGYBTtE/arTWtgfxfZJy77NnBCU+yj g4Bd7z2Isvl3SSIVqAEJi5fnk5NeIOk= X-Received: by 2002:a63:5953:: with SMTP id j19mr71395596pgm.260.1556687153322; Tue, 30 Apr 2019 22:05:53 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:15 -0700 Message-Id: <20190501050536.15580-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v2 08/29] 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: , 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.1 Reviewed-by: Alex Bennée diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index ee89734318..e443b5df23 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) { @@ -2201,7 +2209,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 1198c76392..0d621670c7 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -855,7 +855,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) { @@ -888,6 +888,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 68d86361e2..3ef4d3478d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -109,10 +109,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 Wed May 1 05:05: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: 163186 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4124325ill; Tue, 30 Apr 2019 22:12:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGzDckFFHcbdXJtmrpigTcxNur9jM5NO9coahZ1jys9UPDZJe1cfej/ssVQewxr3U8XV8T X-Received: by 2002:a2e:9993:: with SMTP id w19mr17971345lji.111.1556687531176; Tue, 30 Apr 2019 22:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687531; cv=none; d=google.com; s=arc-20160816; b=sj0q+L79hij4eGsiXYGfaWSBPJKD9JLZEMp1PdUrq6PF3w2DyP3g6gAkwF/UHnDpbU UAHPYHYsVtvR0s+4z6QMeOy+jQD3uKdiLYuuWy2ptut4u8aiY3n+p+6ktzof5s4cfEYg OxzG82t9vgmVgk4xwiDebtkeMEbjzenypqVX+G3qUgBvxAYoDT2RjRh/HY4rtLWCNSZC i/AeU8jAd/t+VSWkYt5HLKMiZvyabCInfkgbhNAUlUvj/64zxQahDVLRU63v/f7b/WkV Hk1M59wIEtSssZxOJ2esunrFaUUzP8v2Ua7DfpS08prA7U3EP3RjF3mWwCbmY2oU6LeV I5rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=irPqBndNq933/zB17q2yuwmKsfglTIRzKNTaiyWRsts=; b=iHOAHMnAUuRPqkB8KOph/RDmIEMaDSGbQPdPRiKMO9YXCOtMGhK6H+TAeI3DTdA9fV s3zPBn6Qbi+kGUiAf1GzMOVNWRT8Cni2DLMWA8pe3lHMqiKFJQ0epa/OOEJopaRMOAv9 b/VMgnF658TpdwNXNF7U3lbcLUOQqbEcz8eGElfJzyn4kdi+2BCZW0/UclayyOD3oT2u iOZzkVjtTbKebYCQ+MrLzAoqZaUg8Jg0LJtF/932zSP0cM6QMaERV9baCMhH9wTg0L7f gpEQb/5QZx43/RB0JEmxzAL87mNPCuy7IMwASQNrZ06tSkeCoSGEIFAIgt5OFDWzjMvK T9Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ds4ofAZT; 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 q3si28341489ljb.96.2019.04.30.22.12.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:12:11 -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=Ds4ofAZT; 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]:36297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhXN-00036u-Ie for patch@linaro.org; Wed, 01 May 2019 01:12:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRP-0006RT-Ds for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRM-0002rZ-Cg for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:59 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:36882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRM-0002r9-5J for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:56 -0400 Received: by mail-pl1-x629.google.com with SMTP id z8so7764253pln.4 for ; Tue, 30 Apr 2019 22:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=irPqBndNq933/zB17q2yuwmKsfglTIRzKNTaiyWRsts=; b=Ds4ofAZTwQ+7Tc39/WSDwzjKb2cKjm2G+ZTly9d3NNG4VIlv9eehX4ooTKsud/b0tb Fr3o2iQ5w8h0+0kCq0F93jBYiOU4IN4Gkt7HduCEYAW3ZTUzGZaVrSIOJWasAVUDqahx M1/wU/q+6Ugl0Vq3g9D1Zt4KPYgZwCyXWETW83GxBS/IlembXm/JgrL/MJJLksQh4ES3 OR86+7i//3ny1tY+yOQHXatQAp4R9e7QUI9jqkwGr9EgGRzPTfsg8JtoRuDfUsrqY3k9 oGKuckQy2f5WGl5xOMnyqnEZumgUlQS2DYrHLsIyLixXGGJ7Wpr89nmqyQneMtweAGFf oxwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=irPqBndNq933/zB17q2yuwmKsfglTIRzKNTaiyWRsts=; b=hsQU1RPfmxHmcweflc5HUdyHBgLCHfmSy2Gc899n4QfQpZG3S2hgRtEkqIkOsMiGVp oc6NK+Ulzg9NV3Fc/27EphVl+ADWMrTJVL+efFFdQ+CKj/GUqWDxptHfBMmarJcGNK8n +2B1AcM0JAIcyIGj6zE4CpHFI6KcxuYQs5Ti6gae/oxj4rh1BjQZlGHyVK31TY/cOoCR lPkHZ+MW3ne/ARPnWU8pUof2ZnOIyYN1X/3R95vR9OrU5WlaTGRgVq6rj63PDE/419vh PMSI9chB8LobDs9ZAQVRRz722p5yvEVilJQYcNrPTOXuqMasGg46C14Rjh/iZ/Pq71VY zZrw== X-Gm-Message-State: APjAAAVAXj61pVrJRFS18K20clLdJDzG+8eskueKnJn8hyTYObu0hSke ARLV4QnR2h6108I/ijXJ7SdFxeZQbB0= X-Received: by 2002:a17:902:e283:: with SMTP id cf3mr34626830plb.160.1556687154565; Tue, 30 Apr 2019 22:05:54 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:16 -0700 Message-Id: <20190501050536.15580-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::629 Subject: [Qemu-devel] [PATCH v2 09/29] 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: , 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.1 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index e443b5df23..3cefdd1e43 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -2108,10 +2108,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(); @@ -2208,9 +2206,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; @@ -2254,6 +2249,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 0d621670c7..3c8229d413 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -2603,10 +2603,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(); @@ -2795,9 +2793,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; @@ -2839,6 +2834,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 3ef4d3478d..78fd0e4594 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3407,6 +3407,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; @@ -3981,6 +4080,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 Wed May 1 05:05: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: 163192 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4127157ill; Tue, 30 Apr 2019 22:16:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqymmzEGWH3v3hFy8IS7I/0gJNU+oeJJt5UTDXtm6a4SaUUfkGyLiAKegabZxYjBXzSWQiwo X-Received: by 2002:adf:ce0a:: with SMTP id p10mr5116331wrn.277.1556687773236; Tue, 30 Apr 2019 22:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687773; cv=none; d=google.com; s=arc-20160816; b=SpEbvFXb+ohWnzQTwaIqkuhirleD++dsfmw+68EDUG0CRFznYmX1NkGhAaZfTtD9A3 zLrCT2FB0D1amoI9cMN7c6utRuvxw7XSuMawdllDtMwtXU7dJhEKIQTLX3AcxTrthv7Q SqFJ/L0v3uxNUTHerRHHpiBfzeChgloxqY2TRtCU+Qnv3NzollBxenttRlmF/cnJ4tco araWJAIVlmRLln7Elh1rzdmoDbLeadhQctYhV892k5YUV0coGEzV9EqERahFDDDoUlTx A96jk6Y0164u19ML+wIc0qbFeCZuCpkmuOzablCJ46aUwpJIwWZ/iRvCrvhZlPg+VaSq IBTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=A0TLLHctb8x320fY5Kq/5/FkOQqXe52LbNwf5bR69vI=; b=mlzigPRFd33RvvVNSNfw9krg6hKiq2sF3g87NqftvCIf0FTRHs7b4SZf0MwtMcBxhO GbmiMgerE5Kapvgea+EQwTlXD/ADueA5gF+9qYW9mcX0EcT+tzro7m4aCxSAla5yNgW2 HesBC5C7Wnyaj51hwCBgSYZL9fvESrGisWKxQXgf5YWkxHMDnQ480IJkUA9xgi7cK1Vl zi18Md2aX9sKGtj2U6agNDk9ORxu2iHB4BMhZJaLABqobUABRMcp9n+us7pOc/r2TymK Bl9UNPkXHRgq/DUR7cvqAfuInBzyeQ5WjlgqQQ+t1o3Cs9TA8ioCwAMLUMTK3nbP+9v+ 0Eeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fi0++L+z; 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 u9si2672082wmj.27.2019.04.30.22.16.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:16:13 -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=fi0++L+z; 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]:36364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhbI-0006Yw-4W for patch@linaro.org; Wed, 01 May 2019 01:16:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRQ-0006Se-Pz for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRN-0002sC-OW for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:00 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:39957) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRN-0002rq-J3 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:57 -0400 Received: by mail-pl1-x644.google.com with SMTP id b3so7749390plr.7 for ; Tue, 30 Apr 2019 22:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=A0TLLHctb8x320fY5Kq/5/FkOQqXe52LbNwf5bR69vI=; b=fi0++L+zFFB2v8f3i1fupthWDz62d8FzF+KwgOGJsJpNxcxmSxCfaLdY21A0TfUclf fW3HDCVBnM/J2tYAGgdnkHDCgkzqLiKVcO/tvZABWzA/LMtdSwDPsXN6cJENJe05LDKl yfj3/5/bhmExvfVqMc3DHmeKtgjerS9Dyo4u0RJOmC4/+aE0Q6swiOGKopgYoFSc6AXf z2MJZ8vfdBD1SnGoeyZKkq2BOZGEV+jCxGOQRlQ/VTNRKCcIXpV8yV9GckTLOGaj1az+ GzRKlyBnfi1u9YxXaF3+810iyZzrcGZAA6P6uEz+Jqjfuqug/4p5tqoqmpHRww2Bahej bPFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=A0TLLHctb8x320fY5Kq/5/FkOQqXe52LbNwf5bR69vI=; b=aJ6IlReyr/RowG04TQZD8h256uc7m9R4OPY1XPBipNstKjhdxR2JjoCtL6sDQTh27N toiaYSeNAREzlTZgCRouOsiFf7QhIYGbDSkZrtOH1mKiVwqPl8MKtEqt+ZjcnNrq1vO1 Emw2gW+ZWMYZ48dolXWykmn2z+lK5PUaZs7C2LQFL9zoEsW4Dl+l/Ddax0DLD9zMslF8 +nPWAqHOTLq5jQLo1kEyjnG4HkPCwnC8Ip3MWTYNKAu/j8G+Y236vRh4EB54Y0j5ewx4 1D/RijE5IDv2zIBUTu1+kOicUXk8CIFaetquATLv1cbCpHVayuyxUELTSMNjpbtkcZNP kzcQ== X-Gm-Message-State: APjAAAWbrgg8afRe0uq8xJaipW7uhqSRlKUiQCgimv54BPlGTwW69dVb uzqcp62GHK5myIZik3L8mW9wTs4+S+Q= X-Received: by 2002:a17:902:6b:: with SMTP id 98mr59424891pla.271.1556687156129; Tue, 30 Apr 2019 22:05:56 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:17 -0700 Message-Id: <20190501050536.15580-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v2 10/29] 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: , 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.1 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 3cefdd1e43..4a3cfa778a 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 3c8229d413..f04933bc19 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -891,6 +891,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 78fd0e4594..ef01cf8214 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -111,6 +111,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, @@ -122,6 +124,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) { @@ -3413,6 +3420,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; @@ -3482,7 +3490,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 Wed May 1 05:05: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: 163189 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4125988ill; Tue, 30 Apr 2019 22:14:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/8mH6rV7dEGd/zOTzpT0bhcJGQu6/7E/XEdf4RSUhaDqBDr1lIk9YyAWr1lSrsD2bJeUn X-Received: by 2002:adf:eb44:: with SMTP id u4mr5431442wrn.83.1556687682444; Tue, 30 Apr 2019 22:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687682; cv=none; d=google.com; s=arc-20160816; b=0I21NMctpwLk9gVB79g7noAabZ/zisPDTeCwylt4MdJ0qlGhc7Vq3tjehNBydCqn2d PRRew2aAbMN8c4LgzZ841yfaPfw9vjE+TqqaySquxHtayt1nPF7CSab0I1q44oJlqwTW JUBIZ2TGdWNMsBLeZROUquFY71jCWvOkqYCwYB7JI/969Gt7Y2aoW89fglvmEfw2p69W bu3J8PHQZ3j8BiK+dMHDPVXhmrCx5TYeDiCSawIdKy425FJZ0u6npgoM1a9zY3heAXym uFPi4U+0MVGWSjBovo/wGwMo4rOCEQtPlml3JWVcIyMW2aoWan6zQ6/v3xXefLG0Rf5j 2aGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=4qREfMgDOvDIZnxD8mHxrlGbKtAgS56ZNj2GB4ImDXs=; b=CAIRAXV0fxuLTgYGyc9wEsQRETq+87c/EllZ9MD2UJ6sck8PWJZB6zX9VSiHBu96Kp 8CDUViUjPeEDCtRFFJ6AdGKN1Fd3vBqHE70LGZfglNUmffeTQ2HA+Vp6G6KPfHSnYHeE RY1saxeq6ptHoHkS9RazvjOYaNuq4SE7CfyLOoBuR01gjApdIxhklzWRaLcGrMX9feg+ /VX3d68LWoNv71Rvapj1hRYAWSEoFSjNqiEtbysj1pQNM+pjB/wY7DDbqvsjXbp1QUBW PSP7tIgZiKdVW6bDQk9DkL3eazFR2I17Eiq08JTKJ90N3ORKXEcsvGdomkScX/Vetpeb H/qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bqscjG+W; 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 h6si9777070wro.75.2019.04.30.22.14.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:14: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=bqscjG+W; 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]:36316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhZp-0005EF-9M for patch@linaro.org; Wed, 01 May 2019 01:14:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRS-0006Tz-02 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRO-0002t6-Uo for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:01 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:35810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRO-0002sh-P9 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:05:58 -0400 Received: by mail-pl1-x642.google.com with SMTP id w24so7779141plp.2 for ; Tue, 30 Apr 2019 22:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=4qREfMgDOvDIZnxD8mHxrlGbKtAgS56ZNj2GB4ImDXs=; b=bqscjG+Wp1YdwtS2sn/6hOniJqV8Nz2hTXcljNAAEFxLkBPj6WuZCNfaeNOBYx23y6 Y1RKL+saVxc54xIT/zS5eiJ607avU0sUHP0djkwNNAkUCu+xqFKh8KTkK2c4HIIQHjbr ji7p27ssArwP0mBHVGMxIP1F/xSBufQbWV9Ng0s+tzU5drSsw6UZM1PVTfJm1pK6HQ7y MeMKB5NN9tGbaZMA50zCaaoMFddHViqopFAQO1dqadIv61Sqvd3pmrzGGnePU1twT9mV lr+1Z+3BOJVBv4X/FTOX6INqKE02jhMPHZYFRPY6NPe1OOxE9MAd/mwQPkL4kG0UztBb ZYfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=4qREfMgDOvDIZnxD8mHxrlGbKtAgS56ZNj2GB4ImDXs=; b=UgckV9LlxJsA9kLaoDh5WaqjWTUoA+zKB98WQ8Bod+83vUKnmBeBeyOmWGpKE//r2b o0MRfsiX0E7G7ll12ffHBH91lDdnwgctBQu8oewSFtqk3wwl++H44qY1YugJ3hFfrXtT r+soSG5TPDF1kU1DYddnZoUSkjNt7tlE76p93q8G97PMbUz30z3mIZfD7vsPeEkvlb+S mOKZ4y7i88/jr+LP3keoBuduQKlnWOQTypbfSEZ6mec9e6jgcnf3GbxBrSHjJ75pSFlC jwKN40P6Bq+k9On7CyvhOS5K/VyY9tm74LEjT0URS1ghDTpFd5t4rAIXxx4F4hSINpm4 WEmA== X-Gm-Message-State: APjAAAVZHSb4d+UsqLVqSaH2P5uiQ2sYnJNGVx8RVCSKO2JmnjNZz1++ JJuSbvyEo21i32dwAfJvfVuujndUCbI= X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr75751535plp.74.1556687157479; Tue, 30 Apr 2019 22:05:57 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:18 -0700 Message-Id: <20190501050536.15580-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v2 11/29] 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At the same time, improve tcg_out_dupi_vec wrt broadcast from the constant pool. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.inc.c | 57 +++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index f04933bc19..f4bd00e24f 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -358,7 +358,6 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_MOVBE_MyGy (0xf1 | P_EXT38) #define OPC_MOVD_VyEy (0x6e | P_EXT | P_DATA16) #define OPC_MOVD_EyVy (0x7e | P_EXT | P_DATA16) -#define OPC_MOVDDUP (0x12 | P_EXT | P_SIMDF2) #define OPC_MOVDQA_VxWx (0x6f | P_EXT | P_DATA16) #define OPC_MOVDQA_WxVx (0x7f | P_EXT | P_DATA16) #define OPC_MOVDQU_VxWx (0x6f | P_EXT | P_SIMDF3) @@ -458,6 +457,10 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_UD2 (0x0b | P_EXT) #define OPC_VPBLENDD (0x02 | P_EXT3A | P_DATA16) #define OPC_VPBLENDVB (0x4c | P_EXT3A | P_DATA16) +#define OPC_VPINSRB (0x20 | P_EXT3A | P_DATA16) +#define OPC_VPINSRW (0xc4 | P_EXT | P_DATA16) +#define OPC_VBROADCASTSS (0x18 | P_EXT38 | P_DATA16) +#define OPC_VBROADCASTSD (0x19 | P_EXT38 | P_DATA16) #define OPC_VPBROADCASTB (0x78 | P_EXT38 | P_DATA16) #define OPC_VPBROADCASTW (0x79 | P_EXT38 | P_DATA16) #define OPC_VPBROADCASTD (0x58 | P_EXT38 | P_DATA16) @@ -855,16 +858,17 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) return true; } +static const int avx2_dup_insn[4] = { + OPC_VPBROADCASTB, OPC_VPBROADCASTW, + OPC_VPBROADCASTD, OPC_VPBROADCASTQ, +}; + static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg r, TCGReg a) { if (have_avx2) { - static const int dup_insn[4] = { - OPC_VPBROADCASTB, OPC_VPBROADCASTW, - OPC_VPBROADCASTD, OPC_VPBROADCASTQ, - }; int vex_l = (type == TCG_TYPE_V256 ? P_VEXL : 0); - tcg_out_vex_modrm(s, dup_insn[vece] + vex_l, r, 0, a); + tcg_out_vex_modrm(s, avx2_dup_insn[vece] + vex_l, r, 0, a); } else { switch (vece) { case MO_8: @@ -894,10 +898,35 @@ static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg r, TCGReg base, intptr_t offset) { - return false; + if (have_avx2) { + int vex_l = (type == TCG_TYPE_V256 ? P_VEXL : 0); + tcg_out_vex_modrm_offset(s, avx2_dup_insn[vece] + vex_l, + r, 0, base, offset); + } else { + switch (vece) { + case MO_64: + tcg_out_vex_modrm_offset(s, OPC_VBROADCASTSD, r, 0, base, offset); + break; + case MO_32: + tcg_out_vex_modrm_offset(s, OPC_VBROADCASTSS, r, 0, base, offset); + break; + case MO_16: + tcg_out_vex_modrm_offset(s, OPC_VPINSRW, r, r, base, offset); + tcg_out8(s, 0); /* imm8 */ + tcg_out_dup_vec(s, type, vece, r, r); + break; + case MO_8: + tcg_out_vex_modrm_offset(s, OPC_VPINSRB, r, r, base, offset); + tcg_out8(s, 0); /* imm8 */ + tcg_out_dup_vec(s, type, vece, r, r); + break; + default: + g_assert_not_reached(); + } + } + return true; } - static void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { @@ -918,16 +947,16 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, } else if (have_avx2) { tcg_out_vex_modrm_pool(s, OPC_VPBROADCASTQ + vex_l, ret); } else { - tcg_out_vex_modrm_pool(s, OPC_MOVDDUP, ret); + tcg_out_vex_modrm_pool(s, OPC_VBROADCASTSD, ret); } new_pool_label(s, arg, R_386_PC32, s->code_ptr - 4, -4); - } else if (have_avx2) { - tcg_out_vex_modrm_pool(s, OPC_VPBROADCASTD + vex_l, ret); - new_pool_label(s, arg, R_386_32, s->code_ptr - 4, 0); } else { - tcg_out_vex_modrm_pool(s, OPC_MOVD_VyEy, ret); + if (have_avx2) { + tcg_out_vex_modrm_pool(s, OPC_VBROADCASTSD + vex_l, ret); + } else { + tcg_out_vex_modrm_pool(s, OPC_VBROADCASTSS, ret); + } new_pool_label(s, arg, R_386_32, s->code_ptr - 4, 0); - tcg_out_dup_vec(s, type, MO_32, ret, ret); } } From patchwork Wed May 1 05:05: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: 163191 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4126165ill; Tue, 30 Apr 2019 22:14:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTeATDuLSqnxRKtRymFj3FKpOgvigxLxbPS/Jm+aPUpba6CNj2tzC4KjJ3jxIeH5+Bqsma X-Received: by 2002:adf:e302:: with SMTP id b2mr28709868wrj.328.1556687697483; Tue, 30 Apr 2019 22:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687697; cv=none; d=google.com; s=arc-20160816; b=kXymBtcEU86AR6ggUqCcBpzl3op4ootd9a5JPvUE473KR2ngsrkY+7KxBjIxdwXYjZ MM60cZkiNt8MP9TpcAED8hcgIIhK8p7855CNS8JJPIoHdi3GevwJQoi5GYks/bKWJZKU URo5qZaBYQvZ54hB1w1jQMkPCgZ+vBk5OlChyPmiGhDgNHrYWuoPy6a/d90ppWqh89I1 xNN9wNHRtkLp1PVhq/vSMUE6FY01qxdYLTKaVLcOymQLXburUekN0ymZrMEUFewAxh01 p0MMV/wYbWhXwai3SO8bSGLOXlJAQA7R9qyT+PHB8fCUaf6Zf81XYyYozm+2mxKCOuAY lNEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=g21xzi0Yfw56hjH6+dWM672fvCsm0wfniT6hVRPX/0U=; b=kDCYjw3NlRHUk/CqjBRZ33J4zcjgkAA/sy+7N7vU7PQFwr7e2rzNz+NYqD1CNbGDkB 249ewhEyNZqw5PgkTkByiF9Kg61T+LELEYcJ5AuDIv+jaBCEO5FzecsgBgXu/dlOBEyo EVp/hPkf/yeWkPVmB9dv/ZcrfjH2l5hw9qw1mywTnXb/WoWrx6SU4nco9CP/pz1i9k0h vlop2F1xqdXMQUOz/QT0LP+5XvMJ7oSMVvKrkVCZzhAHnBcsgRY69l45gN1U1s14nPXH K6i4LvX/hlVD30ZcSk3Jt6on7yfO6TSLKpMoXGDac2Vjm06qZABvXM55zS2fxL8DP2of IYPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cAJH9WPL; 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 q9si27685679wra.359.2019.04.30.22.14.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:14: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=cAJH9WPL; 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]:36325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLha4-0005RJ-Dy for patch@linaro.org; Wed, 01 May 2019 01:14:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRT-0006Vb-Qv for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRQ-0002ty-4Y for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:03 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:37297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRP-0002tF-Un for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:00 -0400 Received: by mail-pl1-x641.google.com with SMTP id z8so7764305pln.4 for ; Tue, 30 Apr 2019 22:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=g21xzi0Yfw56hjH6+dWM672fvCsm0wfniT6hVRPX/0U=; b=cAJH9WPL3m8+3hrrT9Sl+dxS03jKc5J4MmL9Ocq2D4tY7SyIJ3eVHsUe0aWz+7zxTu zXg3gx2z51OgUp4SL/JTe82h8mMNfcVqrLhUlkJYI/tv1QUTZXplhtV2vp0oW8DD+6LR wzr6czBXSsgUibKNpVMDWIpgv5yM9xWaSt+I6818bhiWjRffflY5T76eFLRBZyNIOb1Y TdX2h2tbqzJ7Tsd3vP5+njK7+4+n6homLGtolh2lF3HDlssfu8EQUnY5FMckN842Q91u 6kF5rLnWjHP/qqSdk4jgtmhPQPPDPlGRaID5gjsZ386wWtFWBOv8Kcztkqx1Rh7rJ6UV uxkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=g21xzi0Yfw56hjH6+dWM672fvCsm0wfniT6hVRPX/0U=; b=bw1Il89jMAqgLSnJ6jZJljBntPmhlvaSvgFkM+0a8Z7cuAuRk8hASO3jzYeBZjjH3f Yzsw9k6RCtNmwx9Gee5B4HWbPbrEdHJDpJNWUK7Vql4lV8oI38insNYd3K3+VdNeaWZB 7rbFEeXTapmVUh6tFhp8JtydL03/9cCjr+r0spvKmsDOuxRdSd9rdaNyu+sNnLRJPOUN XKhzO2UamUBb2iFPg/5kFcrkhucmbtRgW2Dqg3bj47GCRfijCyk3dDr8kLdKbg5b0Nx0 b6XgwtiTXTtiIz5Gmw3/MZBrDylmQZbkSUQy7sgg2zYThPYWtpQjO4Ck7w4gSt7l4eHm 0AsA== X-Gm-Message-State: APjAAAXHcJq2SoFuyCSF2y7ylKZib6I1ymRM1DDu52hKTcnpCAXQBo4w WGNImA0QdH+7nH4kSsDEPkuW2agW5RQ= X-Received: by 2002:a17:902:7b97:: with SMTP id w23mr67921813pll.335.1556687158590; Tue, 30 Apr 2019 22:05:58 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:19 -0700 Message-Id: <20190501050536.15580-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v2 12/29] 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: , 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.1 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 4a3cfa778a..411fb463ac 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 Wed May 1 05:05:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163194 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4129373ill; Tue, 30 Apr 2019 22:19:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqww1wl3j/JGOh+/UO3Pa4jMLgGMKyikNkDrxkOh8yRhR8zAgHfEgGDKxdOUy+RJDmPwOFv2 X-Received: by 2002:adf:bac9:: with SMTP id w9mr22999608wrg.256.1556687960712; Tue, 30 Apr 2019 22:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687960; cv=none; d=google.com; s=arc-20160816; b=H8jQKLD3rUL2xmSkypL0nQV81RiUDygXX1ZBTyBRxoLl2sV9ZP5zERwJPqi/uxGKBt aTa7/BVV9w5Mowa/aVPVFKjWSbab5LlLrAHBZYVdHs/XxPOqWe4IBHlvTC+eC8arH5lz bB5dpoGxUotUNhYO34MddV2BtlqTAEugL6b1XBGGmCxwus2lbYwLu1UQdhB4tAOdUqJS ZZjg1Q9TbGOazU2hskwBBQN1b8sWx+719ED/vo5mKTHUjh/bB1+PpuLutBmzA0yunm4N TfibBsTHsC+UqXzDJyJhC/COlMJR1j0Z2/6Z00Ivci18psnSjICbO96IIyq1ld5l1/B7 gpxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=BXcUne31laQN3ojMHviXYqPdeIZ3QTZ/IUq6drGJC3A=; b=PwJCmy/1Ikrpy/u3XHVjcd62DO+UbZbrhm4pBlLzsAYWI2C7eOVIz7eh14hSBCo9Ig Bl9o7Mg4Fdd4BFnYn1HALV69tc0L8iTyi6wAoDGQSpGkQ+rEpDEOD3TjVSkzhOd9hc31 QBtaoi1zIro/lnJAWmItIbBdHEgpyG/2e5D/r7uOxs9fAARGWd0D1E2E4RgUwGGmYvi7 dCUWbi5v1y4VAuGWftaSzAULt+NDjjE0AQ/f5N3v/QLfakbSprrBl9WVFnf6CW2aj32O ezrbaSUwssxTNgGYXgC3Scg7Yjk9Ea8CB13EEsgLJxxVRb0tt2Yx5e24hooWVrM6y+Ag LSMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X7TD5qTB; 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 a8si11739541wrr.413.2019.04.30.22.19.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:19:20 -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=X7TD5qTB; 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]:36389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLheJ-0000l8-Hf for patch@linaro.org; Wed, 01 May 2019 01:19:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRV-0006Xa-KT for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRR-0002uh-9N for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:05 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:42932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRQ-0002uA-T2 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:01 -0400 Received: by mail-pl1-x642.google.com with SMTP id x15so7756045pln.9 for ; Tue, 30 Apr 2019 22:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=BXcUne31laQN3ojMHviXYqPdeIZ3QTZ/IUq6drGJC3A=; b=X7TD5qTB6/gQ7LJdj1+prCLCeYeV0bBAZHOvKv7Na8vjQ1l5r6bUf7jOaL5I3Rq0A6 blCeLc/ibunxCrYzJs8KXkDze2dHQ9pi9BwjIhZKm5JqyzcYpL1wffG8OvBgieqOEyKE eCI6hAiKDelpxZ3rakBhRFGNKq8pKEht89qqeLWle8bCTu7BhMc+IFFhEF1QjbDxjrVE ekRWf39J0iH4g8wDhGMf7vEkw+JbKGkEGwMfCN6AevQO6XfXmrJBd6XhBt/8BxDVk2M9 ckmhYgXfUWJ3vk1jD++EESORXuWzbhda3A9X91gZj06/wsWl7853orzRm5s+B3PPzMPS GlnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=BXcUne31laQN3ojMHviXYqPdeIZ3QTZ/IUq6drGJC3A=; b=Wz1Be9IQPLXqu61arZNO+MSu88DP1EpemWC8Cfi4KDoy6BpAb5sIbmXExQ1TH4b4iO 343Cwk9PizZ6477KShb5M2Iyo6bPswkSRo6CIEexrynslB43/wbBwG0iTQaLWtHFvk8r cIJDG0WODenJE066PeFeaXIlJYe467l9KFqips0DZDkt9pmWKCjn7At582xTeOl234em y0ReEFQXk6wroyHWcvJyTCn+AKPWwGju4wCQg7hsGh6R62RCP4vwrLk3wbyYi5vEppfC CSN5bUP3FWsTd3QaIH3l6oJEfpwtCsqLkU5UuhHoZO9zu53BJBnA11JvYtuwOqUpdVFx bSUw== X-Gm-Message-State: APjAAAXf+Cj47hY5cUGGqmi/+qW9NLY7MT8J1PZVWnuxmQZxv71hWgpd VDOvTa11jBjOV0FeHlMu2hUbwYVVQG0= X-Received: by 2002:a17:902:2cc1:: with SMTP id n59mr12173999plb.22.1556687159667; Tue, 30 Apr 2019 22:05:59 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:05:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:20 -0700 Message-Id: <20190501050536.15580-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v2 13/29] 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: , 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 | 89 +++++++++++++++++++----------------- tcg/tcg-op-vec.c | 11 +++++ tcg/tcg.c | 1 + 7 files changed, 70 insertions(+), 41 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 1f1824c30a..9fff9864f6 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -954,6 +954,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 1bad6e4208..4bf71f261f 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -219,6 +219,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 411fb463ac..16381f5175 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -2192,6 +2192,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; @@ -2524,6 +2527,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 f4bd00e24f..5b33bbd99b 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -2829,6 +2829,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; @@ -3115,6 +3118,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 3fcb2352d9..35ebc5a201 100644 --- a/tcg/tcg-op-gvec.c +++ b/tcg/tcg-op-gvec.c @@ -395,6 +395,41 @@ static TCGType choose_vector_type(const TCGOpcode *list, unsigned vece, 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. @@ -434,49 +469,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". */ @@ -1449,6 +1446,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 914fe42b1e..213d2e22aa 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -278,6 +278,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 ef01cf8214..bb1e124e80 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1600,6 +1600,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 Wed May 1 05:05:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163196 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4130286ill; Tue, 30 Apr 2019 22:20:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZHoGUp1lZpZAbOFL8y4/2i+A9IwFpRREQdYhALWsimhYqWfwNj4zoVi45xxFcZURemFDJ X-Received: by 2002:a5d:654a:: with SMTP id z10mr21920905wrv.153.1556688039439; Tue, 30 Apr 2019 22:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688039; cv=none; d=google.com; s=arc-20160816; b=DeqwWpCbLDNVdolOT6k4zXt05nevhlaYbAukuOdFqIhfOm70sEq3vCQuyYJ1Nz7mPl bu01ypV6TWq0E3w3CLF46hSnw4DL2Y2LZujkkcZXcvUE9cga9cnoY7e6zJvwBWZu+pGM ae51Rmjqxr2KAIVRKQk3Zi7H4iharnOgzcOxY3cHpYE7R9v+0X/59rg+61W+/myB/Cgl O/9M32zPKwOHV4blUdJ99xiZKBE9uMPHvxwFa/d4l0bs1BOXJe7mbWZ7D54f7F9Q6zZh X69Jhs5TQA08CoQy5SYZzwZu1ZJyZXYKRmnnevja4z7KhOrY2JM9IsiKJcpSFo2ZgkPH PucQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=sCQms03lBEjNEnoZ94CmHhqyqEk2oJU56MWCHZv2ODM=; b=mD2EGUjivx5OJT/xPU0teTp9XLRyR+b9vw4zH2ZfYfdAvZReGsW3e890fBgeFC/h+x 64Vd8bj5IUESbg/Y4yOJ+6AJOfdxUCYlhzPnpg4mzPhfSiVhD7cHoU3ZSjv63S42a4h2 6MQDy8fCHdlPvaHmkI5DUHtX7JQ1xvqO0XNxg+YxAQuOG0+8evdaaAFUTfzX1i5G2LOh OObv3sohQ2sz4EiqR5QkK1ErY7C4a0+rU9l1kfQV2GX2Pqd80oqc2IwB+c17viLemGlB kAeIWNk0TSe4qONpNZmSftMfdzQE9iJLPiiAh8Hn1J60vxki69q5HZPIAOkLXkqXcmPR cK9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VOTFoYWJ; 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 m13si20232866wrv.62.2019.04.30.22.20.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:20: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=VOTFoYWJ; 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]:36436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhfa-00026b-7R for patch@linaro.org; Wed, 01 May 2019 01:20:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRZ-0006YJ-BH for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRV-0002wg-M9 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:09 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:41625) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRT-0002uz-Ut for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:05 -0400 Received: by mail-pg1-x542.google.com with SMTP id f6so7859774pgs.8 for ; Tue, 30 Apr 2019 22:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=sCQms03lBEjNEnoZ94CmHhqyqEk2oJU56MWCHZv2ODM=; b=VOTFoYWJr4zpFovHfEA8y+T0OJYiM8kb5ei5vt72we66mwWzYxoLvfqNYrJebXABaA Vx8xo7il14yhfMDMc+gk2pCX1yI1HjhR8Oh8y8z6Sj7YhMfW1DCda2hEeTIOEorpIHgt kGNoL6OLh6/LuN6CySObHa85RMZLWiBgVUHR+d5IR3b6Y+kwYebpTilI8w845KLKSgap YOx8rZ1U8SkcJ0npVPiN/i5zDhTnnGV8aSWM7nJl+eQx7LnEKHfrvPpH4oDcn7QMeJnN A7ebZ8hPp8/zoHMNdoQyum3Y93y294mWimwQI5gHIRX8q1NJi2e9W/lqXMBTUpTkIwuI eXsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=sCQms03lBEjNEnoZ94CmHhqyqEk2oJU56MWCHZv2ODM=; b=julPS6Z97ymZHAFdMMGsarumrdM7+hk4nofh50vLXIN49lWDL5XOUeV2WYzjJ3nUsI J0Dbeu6MuxS47smlxi+KtRD4Xf0QycflWT1PT0EwkJY0fewBJgK6w+QdaQTN7chs26ai D6hIRiuq8CEf5XmWUDeK5EIjiTAGLuO5pJno1F5/xHftn/56Nfahphd9mXAMTR7jQaGZ 8XVwY1wminTkho3bWvE69BMeYgW/ljkdeT8YJuO5F16o0uMJ1BjvDn48h3mPkYX5eob7 mRQ6IFH8oEZxZI8XGy7p4TJ+LpcqNwFjxtBOvOGB3hNYvDpQsg+JWLfU1IzshB7zs9AR csjA== X-Gm-Message-State: APjAAAXkx31hvEMj9cBmeJ6uRuVTX2UsYu/VmYHuKzsqOck4k0oXiHF/ hSAmpYpa901ZmqdL1qGxPppCT+g7U8k= X-Received: by 2002:aa7:8190:: with SMTP id g16mr30425323pfi.92.1556687160907; Tue, 30 Apr 2019 22:06:00 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.05.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:21 -0700 Message-Id: <20190501050536.15580-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v2 14/29] tcg: Add gvec expanders for variable shift X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The gvec expanders perform a modulo on the shift count. If the target requires alternate behaviour, then it cannot use the generic gvec expanders anyway, and will have to have its own custom code. Signed-off-by: Richard Henderson --- accel/tcg/tcg-runtime.h | 15 +++ tcg/tcg-op-gvec.h | 11 ++ tcg/tcg-op.h | 4 + accel/tcg/tcg-runtime-gvec.c | 144 ++++++++++++++++++++++++++ tcg/tcg-op-gvec.c | 195 +++++++++++++++++++++++++++++++++++ tcg/tcg-op-vec.c | 15 +++ 6 files changed, 384 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index dfe325625c..ed3ce5fd91 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -254,6 +254,21 @@ DEF_HELPER_FLAGS_3(gvec_sar16i, TCG_CALL_NO_RWG, void, ptr, ptr, i32) DEF_HELPER_FLAGS_3(gvec_sar32i, TCG_CALL_NO_RWG, void, ptr, ptr, i32) DEF_HELPER_FLAGS_3(gvec_sar64i, TCG_CALL_NO_RWG, void, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_shl8v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_shl16v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_shl32v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_shl64v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(gvec_shr8v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_shr16v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_shr32v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_shr64v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + +DEF_HELPER_FLAGS_4(gvec_sar8v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_sar16v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_sar32v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_4(gvec_sar64v, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + DEF_HELPER_FLAGS_4(gvec_eq8, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(gvec_eq16, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(gvec_eq32, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) diff --git a/tcg/tcg-op-gvec.h b/tcg/tcg-op-gvec.h index ac744ff7c9..84a6247b16 100644 --- a/tcg/tcg-op-gvec.h +++ b/tcg/tcg-op-gvec.h @@ -318,6 +318,17 @@ void tcg_gen_gvec_shri(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_sari(unsigned vece, uint32_t dofs, uint32_t aofs, int64_t shift, uint32_t oprsz, uint32_t maxsz); +/* + * Perform vector shift by vector element, modulo the element size. + * E.g. D[i] = A[i] << (B[i] % (8 << vece)). + */ +void tcg_gen_gvec_shlv(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t bofs, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_shrv(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t bofs, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_sarv(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t bofs, uint32_t oprsz, uint32_t maxsz); + void tcg_gen_gvec_cmp(TCGCond cond, unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz); diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 9fff9864f6..833c6330b5 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -986,6 +986,10 @@ void tcg_gen_shli_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); void tcg_gen_shri_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); void tcg_gen_sari_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); +void tcg_gen_shlv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); +void tcg_gen_shrv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); +void tcg_gen_sarv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); + void tcg_gen_cmp_vec(TCGCond cond, unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c index e2c6f24262..2152fb6903 100644 --- a/accel/tcg/tcg-runtime-gvec.c +++ b/accel/tcg/tcg-runtime-gvec.c @@ -725,6 +725,150 @@ void HELPER(gvec_sar64i)(void *d, void *a, uint32_t desc) clear_high(d, oprsz, desc); } +void HELPER(gvec_shl8v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(uint8_t)) { + uint8_t sh = *(uint8_t *)(b + i) & 7; + *(uint8_t *)(d + i) = *(uint8_t *)(a + i) << sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_shl16v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(uint16_t)) { + uint8_t sh = *(uint16_t *)(b + i) & 15; + *(uint16_t *)(d + i) = *(uint16_t *)(a + i) << sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_shl32v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(uint32_t)) { + uint8_t sh = *(uint32_t *)(b + i) & 31; + *(uint32_t *)(d + i) = *(uint32_t *)(a + i) << sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_shl64v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(uint64_t)) { + uint8_t sh = *(uint64_t *)(b + i) & 63; + *(uint64_t *)(d + i) = *(uint64_t *)(a + i) << sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_shr8v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(uint8_t)) { + uint8_t sh = *(uint8_t *)(b + i) & 7; + *(uint8_t *)(d + i) = *(uint8_t *)(a + i) >> sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_shr16v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(uint16_t)) { + uint8_t sh = *(uint16_t *)(b + i) & 15; + *(uint16_t *)(d + i) = *(uint16_t *)(a + i) >> sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_shr32v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(uint32_t)) { + uint8_t sh = *(uint32_t *)(b + i) & 31; + *(uint32_t *)(d + i) = *(uint32_t *)(a + i) >> sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_shr64v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(uint64_t)) { + uint8_t sh = *(uint64_t *)(b + i) & 63; + *(uint64_t *)(d + i) = *(uint64_t *)(a + i) >> sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_sar8v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(vec8)) { + uint8_t sh = *(uint8_t *)(b + i) & 7; + *(int8_t *)(d + i) = *(int8_t *)(a + i) >> sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_sar16v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(int16_t)) { + uint8_t sh = *(uint16_t *)(b + i) & 15; + *(int16_t *)(d + i) = *(int16_t *)(a + i) >> sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_sar32v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(vec32)) { + uint8_t sh = *(uint32_t *)(b + i) & 31; + *(int32_t *)(d + i) = *(int32_t *)(a + i) >> sh; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_sar64v)(void *d, void *a, void *b, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(vec64)) { + uint8_t sh = *(uint64_t *)(b + i) & 63; + *(int64_t *)(d + i) = *(int64_t *)(a + i) >> sh; + } + clear_high(d, oprsz, desc); +} + /* If vectors are enabled, the compiler fills in -1 for true. Otherwise, we must take care of this by hand. */ #ifdef CONFIG_VECTOR16 diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c index 35ebc5a201..061ef329f1 100644 --- a/tcg/tcg-op-gvec.c +++ b/tcg/tcg-op-gvec.c @@ -2555,6 +2555,201 @@ void tcg_gen_gvec_sari(unsigned vece, uint32_t dofs, uint32_t aofs, } } +/* + * Expand D = A << (B % element bits) + * + * Unlike scalar shifts, where it is easy for the target front end + * to include the modulo as part of the expansion. If the target + * naturally includes the modulo as part of the operation, great! + * If the target has some other behaviour from out-of-range shifts, + * then it could not use this function anyway, and would need to + * do it's own expansion with custom functions. + */ +static void tcg_gen_shlv_mod_vec(unsigned vece, TCGv_vec d, + TCGv_vec a, TCGv_vec b) +{ + TCGv_vec t = tcg_temp_new_vec_matching(d); + + tcg_gen_dupi_vec(vece, t, (8 << vece) - 1); + tcg_gen_and_vec(vece, t, t, b); + tcg_gen_shlv_vec(vece, d, a, t); + tcg_temp_free_vec(t); +} + +static void tcg_gen_shl_mod_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) +{ + TCGv_i32 t = tcg_temp_new_i32(); + + tcg_gen_andi_i32(t, b, 31); + tcg_gen_shl_i32(d, a, t); + tcg_temp_free_i32(t); +} + +static void tcg_gen_shl_mod_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) +{ + TCGv_i64 t = tcg_temp_new_i64(); + + tcg_gen_andi_i64(t, b, 63); + tcg_gen_shl_i64(d, a, t); + tcg_temp_free_i64(t); +} + +void tcg_gen_gvec_shlv(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t bofs, uint32_t oprsz, uint32_t maxsz) +{ + static const TCGOpcode vecop_list[] = { INDEX_op_shlv_vec, 0 }; + static const GVecGen3 g[4] = { + { .fniv = tcg_gen_shlv_mod_vec, + .fno = gen_helper_gvec_shl8v, + .opt_opc = vecop_list, + .vece = MO_8 }, + { .fniv = tcg_gen_shlv_mod_vec, + .fno = gen_helper_gvec_shl16v, + .opt_opc = vecop_list, + .vece = MO_16 }, + { .fni4 = tcg_gen_shl_mod_i32, + .fniv = tcg_gen_shlv_mod_vec, + .fno = gen_helper_gvec_shl32v, + .opt_opc = vecop_list, + .vece = MO_32 }, + { .fni8 = tcg_gen_shl_mod_i64, + .fniv = tcg_gen_shlv_mod_vec, + .fno = gen_helper_gvec_shl64v, + .opt_opc = vecop_list, + .prefer_i64 = TCG_TARGET_REG_BITS == 64, + .vece = MO_64 }, + }; + + tcg_debug_assert(vece <= MO_64); + tcg_gen_gvec_3(dofs, aofs, bofs, oprsz, maxsz, &g[vece]); +} + +/* + * Similarly for logical right shifts. + */ + +static void tcg_gen_shrv_mod_vec(unsigned vece, TCGv_vec d, + TCGv_vec a, TCGv_vec b) +{ + TCGv_vec t = tcg_temp_new_vec_matching(d); + + tcg_gen_dupi_vec(vece, t, (8 << vece) - 1); + tcg_gen_and_vec(vece, t, t, b); + tcg_gen_shrv_vec(vece, d, a, t); + tcg_temp_free_vec(t); +} + +static void tcg_gen_shr_mod_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) +{ + TCGv_i32 t = tcg_temp_new_i32(); + + tcg_gen_andi_i32(t, b, 31); + tcg_gen_shr_i32(d, a, t); + tcg_temp_free_i32(t); +} + +static void tcg_gen_shr_mod_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) +{ + TCGv_i64 t = tcg_temp_new_i64(); + + tcg_gen_andi_i64(t, b, 63); + tcg_gen_shr_i64(d, a, t); + tcg_temp_free_i64(t); +} + +void tcg_gen_gvec_shrv(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t bofs, uint32_t oprsz, uint32_t maxsz) +{ + static const TCGOpcode vecop_list[] = { INDEX_op_shrv_vec, 0 }; + static const GVecGen3 g[4] = { + { .fniv = tcg_gen_shrv_mod_vec, + .fno = gen_helper_gvec_shr8v, + .opt_opc = vecop_list, + .vece = MO_8 }, + { .fniv = tcg_gen_shrv_mod_vec, + .fno = gen_helper_gvec_shr16v, + .opt_opc = vecop_list, + .vece = MO_16 }, + { .fni4 = tcg_gen_shr_mod_i32, + .fniv = tcg_gen_shrv_mod_vec, + .fno = gen_helper_gvec_shr32v, + .opt_opc = vecop_list, + .vece = MO_32 }, + { .fni8 = tcg_gen_shr_mod_i64, + .fniv = tcg_gen_shrv_mod_vec, + .fno = gen_helper_gvec_shr64v, + .opt_opc = vecop_list, + .prefer_i64 = TCG_TARGET_REG_BITS == 64, + .vece = MO_64 }, + }; + + tcg_debug_assert(vece <= MO_64); + tcg_gen_gvec_3(dofs, aofs, bofs, oprsz, maxsz, &g[vece]); +} + +/* + * Similarly for arithmetic right shifts. + */ + +static void tcg_gen_sarv_mod_vec(unsigned vece, TCGv_vec d, + TCGv_vec a, TCGv_vec b) +{ + TCGv_vec t = tcg_temp_new_vec_matching(d); + + tcg_gen_dupi_vec(vece, t, (8 << vece) - 1); + tcg_gen_and_vec(vece, t, t, b); + tcg_gen_sarv_vec(vece, d, a, t); + tcg_temp_free_vec(t); +} + +static void tcg_gen_sar_mod_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b) +{ + TCGv_i32 t = tcg_temp_new_i32(); + + tcg_gen_andi_i32(t, b, 31); + tcg_gen_sar_i32(d, a, t); + tcg_temp_free_i32(t); +} + +static void tcg_gen_sar_mod_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b) +{ + TCGv_i64 t = tcg_temp_new_i64(); + + tcg_gen_andi_i64(t, b, 63); + tcg_gen_sar_i64(d, a, t); + tcg_temp_free_i64(t); +} + +void tcg_gen_gvec_sarv(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t bofs, uint32_t oprsz, uint32_t maxsz) +{ + static const TCGOpcode vecop_list[] = { INDEX_op_sarv_vec, 0 }; + static const GVecGen3 g[4] = { + { .fniv = tcg_gen_sarv_mod_vec, + .fno = gen_helper_gvec_sar8v, + .opt_opc = vecop_list, + .vece = MO_8 }, + { .fniv = tcg_gen_sarv_mod_vec, + .fno = gen_helper_gvec_sar16v, + .opt_opc = vecop_list, + .vece = MO_16 }, + { .fni4 = tcg_gen_sar_mod_i32, + .fniv = tcg_gen_sarv_mod_vec, + .fno = gen_helper_gvec_sar32v, + .opt_opc = vecop_list, + .vece = MO_32 }, + { .fni8 = tcg_gen_sar_mod_i64, + .fniv = tcg_gen_sarv_mod_vec, + .fno = gen_helper_gvec_sar64v, + .opt_opc = vecop_list, + .prefer_i64 = TCG_TARGET_REG_BITS == 64, + .vece = MO_64 }, + }; + + tcg_debug_assert(vece <= MO_64); + tcg_gen_gvec_3(dofs, aofs, bofs, oprsz, maxsz, &g[vece]); +} + /* Expand OPSZ bytes worth of three-operand operations using i32 elements. */ static void expand_cmp_i32(uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, TCGCond cond) diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 213d2e22aa..96317dbd10 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -583,3 +583,18 @@ void tcg_gen_umax_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) { do_op3(vece, r, a, b, INDEX_op_umax_vec); } + +void tcg_gen_shlv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) +{ + do_op3(vece, r, a, b, INDEX_op_shlv_vec); +} + +void tcg_gen_shrv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) +{ + do_op3(vece, r, a, b, INDEX_op_shrv_vec); +} + +void tcg_gen_sarv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) +{ + do_op3(vece, r, a, b, INDEX_op_sarv_vec); +} From patchwork Wed May 1 05:05:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163199 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4131345ill; Tue, 30 Apr 2019 22:22:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9zpoJSEkgDSRL/BRoAXCDsl8WquEAx5++1atV7yrbpEB8z7DnQPkJXAYNhLEiQDSsHlXY X-Received: by 2002:a1c:2743:: with SMTP id n64mr5265254wmn.19.1556688145721; Tue, 30 Apr 2019 22:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688145; cv=none; d=google.com; s=arc-20160816; b=AlVAX/LXfUPAEG4aTubhza/Hek8aw0jham1GaZcE0LGccqUHLSmQMpEYJ1+zX5KyG2 ukZ0gU3mRZ/dnUoU6VWoKqsds7LnfQcd2OF4oZ00wqgsIx2n9ARXwWzS3NC8aBMQXsrM +2nBpAczLRGg3ehpc7jV+R/XtR8iWYumy4owLjOOi+2n0mT43YViIQF6I0BafJs/ppK3 IMPncGmzAPjTd98o54SwXtzv3r/W3fmCPTIRljdzP37YPsVX2rIHLbJuGi4b7uK16iEG Up1saZgcH0BhlLzlStOOeGmGfctbr/Oz0QCOg/AGL4IJyBF49Vw/ZAtANCYXcIFZce4F u3ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=kpdZPEGFDPzcK//Rzbiw5kG5qwfHiaI/mNPJPTUoA9CUYzkeot8cDVagX7A+GSpbwE vLJwFzkVT8Jw4V+eSfBoYzIPDARNUyLekZLd4mQMQRIFJmuFB3aDJtjRgmvM6t+fg0Nj FnftPNa2Gnp948qq9XDsUFGrToOm86bkFEeaPBeejC69lvqxOY+6ZeGLa0wZfsVo8QWT Etiwnp4ttBHI8L1faZBnsp3J8qU7nFMGDprAIYfpXkJCkpFrP2ZA4CLmVq+lB3o4rqvd qhk4uImF+S3qgzeeeK3p30efrjOe2a/bstaPTVkDR+K4cdayHzEb1W0GRFuGZBYl2VOW KncQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oPNiRrYe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r126si2775206wmf.153.2019.04.30.22.22.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:22:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oPNiRrYe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:36449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhhI-0003BE-Ks for patch@linaro.org; Wed, 01 May 2019 01:22:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRZ-0006YI-BL for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRV-0002wU-KD for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:09 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:44318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRT-0002vP-Sx for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:04 -0400 Received: by mail-pf1-x42e.google.com with SMTP id y13so8131579pfm.11 for ; Tue, 30 Apr 2019 22:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=oPNiRrYepa1vkZOy7NCmvfNcxpTTnVUmlpKjD2CacgHuC9+F+niucdvnZ3N2/0ZjHk CghQkki3jy2DoEtb3fWj3YVUAUp1jA7ribj/+Em07+WtvuPSVFT5lGI4hABQa75YZ6G3 40D3E3+P9X3KBbzAilzXRIYB9FlBVuotbWITASbDv8avwp+RgdWcG0XJvQ9r/2n+NFM5 JgpV9HY52FVtbO3km4/PqgRHQahDv+qOIC4aWepTZWCcsEWmezFCF8l01VPcR7Fg7ZQN aNnr9DHnVnF7sp5ZvjtKyCXgtR/kBK46whbk6r3vGQeIOfdBvH7Xh1OCr2REP+8yXsSR LrAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+vy3D5n9NVcZ5Oj9MBgVyI+mUUxTaLSYcOmzMokmrqg=; b=IH0yGM0X8OFePJf//QZRaaF98WXRxA664Lfnrg5U4D/FycjmfIedZEmU44EJcLtpwY pmoC83FUZfBHnzwqdJYiJdgzYChBL37omLsHjb82aJ3rs+FxSQaVR5GkclzFKTWhZt1a sg1Q4f9MUHmPQYh7r8uAvW2z6wOu9pYU4TYniFP9aQZUDrNjoRMVkAiR4CjcfiNx1oG0 //l++Elrq0IqHILdcvkugiM1UPeE6uAx3TUpSiTpne6lgi/ZT9eUAW5sO+msoRPR0zvF U1DqM3ZsTgloYOTtjOAyJnHtPakWnZbmUiEqQB6bQSjFv6ldJcCjVn2ucU0YIX93EubF BcrA== X-Gm-Message-State: APjAAAUdXc5un+X9kaZf7frIXN+zSIReHRujJZSWItmaep+zjcDxnOMT Brjj2KvaCXIYrDQiFgBiocFXisAbriY= X-Received: by 2002:a63:ff05:: with SMTP id k5mr59148047pgi.342.1556687162256; Tue, 30 Apr 2019 22:06:02 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:22 -0700 Message-Id: <20190501050536.15580-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42e Subject: [Qemu-devel] [PATCH v2 15/29] tcg/i386: Support vector variable shift opcodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.inc.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 241bf19413..b240633455 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -184,7 +184,7 @@ extern bool have_avx2; #define TCG_TARGET_HAS_neg_vec 0 #define TCG_TARGET_HAS_shi_vec 1 #define TCG_TARGET_HAS_shs_vec 0 -#define TCG_TARGET_HAS_shv_vec 0 +#define TCG_TARGET_HAS_shv_vec have_avx2 #define TCG_TARGET_HAS_cmp_vec 1 #define TCG_TARGET_HAS_mul_vec 1 #define TCG_TARGET_HAS_sat_vec 1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 5b33bbd99b..c9448b6d84 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -467,6 +467,11 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_VPBROADCASTQ (0x59 | P_EXT38 | P_DATA16) #define OPC_VPERMQ (0x00 | P_EXT3A | P_DATA16 | P_REXW) #define OPC_VPERM2I128 (0x46 | P_EXT3A | P_DATA16 | P_VEXL) +#define OPC_VPSLLVD (0x47 | P_EXT38 | P_DATA16) +#define OPC_VPSLLVQ (0x47 | P_EXT38 | P_DATA16 | P_REXW) +#define OPC_VPSRAVD (0x46 | P_EXT38 | P_DATA16) +#define OPC_VPSRLVD (0x45 | P_EXT38 | P_DATA16) +#define OPC_VPSRLVQ (0x45 | P_EXT38 | P_DATA16 | P_REXW) #define OPC_VZEROUPPER (0x77 | P_EXT) #define OPC_XCHG_ax_r32 (0x90) @@ -2707,6 +2712,18 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, static int const umax_insn[4] = { OPC_PMAXUB, OPC_PMAXUW, OPC_PMAXUD, OPC_UD2 }; + static int const shlv_insn[4] = { + /* TODO: AVX512 adds support for MO_16. */ + OPC_UD2, OPC_UD2, OPC_VPSLLVD, OPC_VPSLLVQ + }; + static int const shrv_insn[4] = { + /* TODO: AVX512 adds support for MO_16. */ + OPC_UD2, OPC_UD2, OPC_VPSRLVD, OPC_VPSRLVQ + }; + static int const sarv_insn[4] = { + /* TODO: AVX512 adds support for MO_16, MO_64. */ + OPC_UD2, OPC_UD2, OPC_VPSRAVD, OPC_UD2 + }; TCGType type = vecl + TCG_TYPE_V64; int insn, sub; @@ -2759,6 +2776,15 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_umax_vec: insn = umax_insn[vece]; goto gen_simd; + case INDEX_op_shlv_vec: + insn = shlv_insn[vece]; + goto gen_simd; + case INDEX_op_shrv_vec: + insn = shrv_insn[vece]; + goto gen_simd; + case INDEX_op_sarv_vec: + insn = sarv_insn[vece]; + goto gen_simd; case INDEX_op_x86_punpckl_vec: insn = punpckl_insn[vece]; goto gen_simd; @@ -3136,6 +3162,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_umin_vec: case INDEX_op_smax_vec: case INDEX_op_umax_vec: + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + case INDEX_op_sarv_vec: case INDEX_op_cmp_vec: case INDEX_op_x86_shufps_vec: case INDEX_op_x86_blend_vec: @@ -3193,6 +3222,12 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) } return 1; + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + return have_avx2 && vece >= MO_32; + case INDEX_op_sarv_vec: + return have_avx2 && vece == MO_32; + case INDEX_op_mul_vec: if (vece == MO_8) { /* We can expand the operation for MO_8. */ From patchwork Wed May 1 05:05:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163183 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4124069ill; Tue, 30 Apr 2019 22:11:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPmwbhmY5yFlopnp+IpraBatAP1BvqN7wXC1xt+pHDE3A/iZrEzefiotENZjNsz55zpRtr X-Received: by 2002:adf:f309:: with SMTP id i9mr46010670wro.258.1556687503634; Tue, 30 Apr 2019 22:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687503; cv=none; d=google.com; s=arc-20160816; b=cLqRDbLWMg0Qx9R1vhNF40imwEjIbheJoYhwSCmspkY0pwlZL+8rAiSdkWLKj/jtWS t9iBV67Eazy+pQYq7Emj+9bNt55y24en3z9xVz2gx1ffS5cfqr/0d3RETQcHJKap2YtE AdNbIfbuf0CMunxvw/21b3kzeAMZCFi0NzoUD8hKJifc7Q+AGojYKevPdPefTbyLlOo/ fK62gL5t6Y7No0hC16DuwAqoo1vAO25tiUwYpESVVmlNgCz/aMNU2p19IdOu+crexfn4 fahWGN8ns8i8z6zRyRjtfAg4aQ8qK0FIL4PtRbieDTByC141CqH+mxOuo3RX15n67q5x cI2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Abtf7ymAcKqk+MfIJ4hNEtC4LePCgm1dY3zGf9JwmC8=; b=vNjBRHO7rkO0osY08BYKX63nF6n02iypm/Htkoe2vS3SDkzLwMzYGHUvohitTBekrJ hh0yrkuDcrgIiOFsOOQsnilVVYNBj3M9lbFHi/4z9d8Px59L6CA7vQYlv9zpVNlV6KrX YWAASJWOZhgPQW+L0Ayru3EtB4hrEiUoODbQrZBRssKAB4zyhtlcRvvJr90kklXbekVB /pka5H7bpO3bXDEfA8m0g4AS+R2Pr6Bx7eWSBBHCOjpIXgi8wDmLy5KBnutAbHgbHOdH 7L2f33nepfMwhN8kcx+rmtPhcDTCv/4RNFIbaJ2cnuqm4lUBAJ1NRYDl1KJORXARIrDI jeTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YGWQ3kPc; 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 n14si12472061wre.118.2019.04.30.22.11.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:11:43 -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=YGWQ3kPc; 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]:36295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhWw-00032I-Ep for patch@linaro.org; Wed, 01 May 2019 01:11:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRZ-0006YK-BT for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRV-0002ws-SE for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:09 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:39578) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRV-0002vy-JS for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:05 -0400 Received: by mail-pf1-x442.google.com with SMTP id z26so4260165pfg.6 for ; Tue, 30 Apr 2019 22:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Abtf7ymAcKqk+MfIJ4hNEtC4LePCgm1dY3zGf9JwmC8=; b=YGWQ3kPcRbB0RlOCGvzsguHvm5L1Q6I/PbfATDCENzuNEaUczoe7Tua1aWllbOFd2c 9AywBqLFeOaxhppcyULRKbkiODOe3md/sjG8GJd3q6N3/uQp7CnABqGK+9c0wNEONuft bCGbJrP/HDw5w6N+Z/xnjeS72F1GDbKZ5LXgEI4tThm1QEGwNlJIPJKQ9ZtHntRrsN++ zwM0jI8rOfSxzecY4xjz7b2GrJlju9VuB5INIpmf5ceBKZCCZG1Zs8vi+NsOMsZtlyl1 t0pOV7MBa0UG9VRML9rdoqdJX31SVkO/zQ0/0Y2r/8mN1VsiLlWSLas0IeKgQ7SQBFA7 A4Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Abtf7ymAcKqk+MfIJ4hNEtC4LePCgm1dY3zGf9JwmC8=; b=ZISXSmxmDC+W6fglYyCpDGzfB5gUbeS9duLFc8zO5skPkNd/30F/5XSAo5yevtCRxs S1k7kLyczPBO30IWwhHdhc4DIYuQymp+cF1K1t0MuK6+jaL8XZNYhW55wan/LEAH4Uxd dvX0wgqAcuPpFBGUsx6ngmXIqcws4waI31uI/KQLjZqTxnqHtTBDE8zMmVEeuAsS7xXh Ur8DfY9KegXLjFj4+WD+vLETDdHg1LpD25T1tZSfL57sa3wxloaBwGRDrTnt2VDM0ofy TiFhCLeILvzC8VFy2UbZOv69iU+bpbUqy2DUjAao552Cay0NonC5OOCg0obLAEa0KIqt 2fZg== X-Gm-Message-State: APjAAAWutN3KokLUNAw5WBIdA+ULTfNbswz64If7Gm4yBKYVymCK8YJm NtbtakdJO4+CECt/cLh685mtIwbwEGw= X-Received: by 2002:a63:6804:: with SMTP id d4mr72200013pgc.240.1556687163380; Tue, 30 Apr 2019 22:06:03 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:23 -0700 Message-Id: <20190501050536.15580-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v2 16/29] tcg/aarch64: Support vector variable shift opcodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 +- tcg/aarch64/tcg-target.opc.h | 2 ++ tcg/aarch64/tcg-target.inc.c | 42 ++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index ce2bb1f90b..f5640a229b 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -134,7 +134,7 @@ typedef enum { #define TCG_TARGET_HAS_neg_vec 1 #define TCG_TARGET_HAS_shi_vec 1 #define TCG_TARGET_HAS_shs_vec 0 -#define TCG_TARGET_HAS_shv_vec 0 +#define TCG_TARGET_HAS_shv_vec 1 #define TCG_TARGET_HAS_cmp_vec 1 #define TCG_TARGET_HAS_mul_vec 1 #define TCG_TARGET_HAS_sat_vec 1 diff --git a/tcg/aarch64/tcg-target.opc.h b/tcg/aarch64/tcg-target.opc.h index 4816a6c3d4..59e1d3f7f7 100644 --- a/tcg/aarch64/tcg-target.opc.h +++ b/tcg/aarch64/tcg-target.opc.h @@ -1,3 +1,5 @@ /* 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(aa64_sshl_vec, 1, 2, 0, IMPLVEC) diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 16381f5175..61c2dbbff2 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -538,12 +538,14 @@ typedef enum { I3616_CMEQ = 0x2e208c00, I3616_SMAX = 0x0e206400, I3616_SMIN = 0x0e206c00, + I3616_SSHL = 0x0e204400, I3616_SQADD = 0x0e200c00, I3616_SQSUB = 0x0e202c00, I3616_UMAX = 0x2e206400, I3616_UMIN = 0x2e206c00, I3616_UQADD = 0x2e200c00, I3616_UQSUB = 0x2e202c00, + I3616_USHL = 0x2e204400, /* AdvSIMD two-reg misc. */ I3617_CMGT0 = 0x0e208800, @@ -2258,6 +2260,12 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_sari_vec: tcg_out_insn(s, 3614, SSHR, is_q, a0, a1, (16 << vece) - a2); break; + case INDEX_op_shlv_vec: + tcg_out_insn(s, 3616, USHL, is_q, vece, a0, a1, a2); + break; + case INDEX_op_aa64_sshl_vec: + tcg_out_insn(s, 3616, SSHL, is_q, vece, a0, a1, a2); + break; case INDEX_op_cmp_vec: { TCGCond cond = args[3]; @@ -2325,7 +2333,11 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_smin_vec: case INDEX_op_umax_vec: case INDEX_op_umin_vec: + case INDEX_op_shlv_vec: return 1; + case INDEX_op_shrv_vec: + case INDEX_op_sarv_vec: + return -1; case INDEX_op_mul_vec: return vece < MO_64; @@ -2337,6 +2349,32 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, TCGArg a0, ...) { + va_list va; + TCGv_vec v0, v1, v2, t1; + + 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_shrv_vec: + case INDEX_op_sarv_vec: + /* Right shifts are negative left shifts for AArch64. */ + t1 = tcg_temp_new_vec(type); + tcg_gen_neg_vec(vece, t1, v2); + opc = (opc == INDEX_op_shrv_vec + ? INDEX_op_shlv_vec : INDEX_op_aa64_sshl_vec); + vec_gen_3(opc, type, vece, tcgv_vec_arg(v0), + tcgv_vec_arg(v1), tcgv_vec_arg(t1)); + tcg_temp_free_vec(t1); + break; + + default: + g_assert_not_reached(); + } + + va_end(va); } static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) @@ -2518,6 +2556,10 @@ 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: + case INDEX_op_aa64_sshl_vec: return &w_w_w; case INDEX_op_not_vec: case INDEX_op_neg_vec: From patchwork Wed May 1 05:05:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163203 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4134039ill; Tue, 30 Apr 2019 22:26:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2ycfbvnx/GOVSrQ7j83B7KBzts+vpwcm6SaYRtcU7/w5NY+wHqkuBAh7W6dHX7Tn+Kpdb X-Received: by 2002:a5d:45cc:: with SMTP id b12mr8336029wrs.142.1556688407347; Tue, 30 Apr 2019 22:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688407; cv=none; d=google.com; s=arc-20160816; b=DaI9THtXrjXY9SPywsNL3SVcuG2xDug56DyLNAbA89Ni/2AaC+t+WLDt9QIb3pltUD 1qA8i26989OweH9dBPSiZG95Cvsed6MtK1Oplg0dMXEyerVwaS2e9KaM3JhWtqd2w5Zh 3rOVcffOrabeOUKJVqXUi4BD9DKhoS6Wip4bCUIBWXQJTb1tCgVoiNuIlQSJuCTLV7Vt fMEpvCDQjqzGyE/HxjcPurEaT7mTM47GG1WwFQ0qulFyCFstslrfacAoW3kCAuNEG6bX BULoCFUArnRHDlfbumO9JJ1cQzcQ1KbVHiY0Aa2K68awEiBVvl+AeuhmowqE+93UBIqU jsGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=OYW3j0AHRDjiM+2I81b0K/4Pb/2jwavlNMFJ+AYuqcM=; b=z2Te55BQMYYrVHdEWxwDyHIjsE5dk4PhFiKs/40zAeKTrCZrd9Zy3yzJ78vSWd6ZAT aoptQwSWP1HTkbsKkhcCSLvltcOWLjN7sHBWQRnqCRth/sjbeTPpmiRKhpWtQAseGrEz IdNxCJV7oiHzURIlObdk5ltmiJYXZUndjpLWTtpbZPGVLm5+AtfGEbuKm/E4XcPi2vne WpZkqluRzc1fOS14zSh5N4clggzFgwJFR9C+mSsqI1t5hLtS5FNqVTXpoLyT4p+/VZQD Deu4laY6nq3YLXtscrRTvlrHOAxStCsYcUYJHUjTMcAZOuCs27nzkZH3vLG3mK/IVW2o VhfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XmpDLnak; 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 b4si14552414wrj.266.2019.04.30.22.26.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:26:47 -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=XmpDLnak; 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]:36584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhlW-0007dr-9B for patch@linaro.org; Wed, 01 May 2019 01:26:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRb-0006aU-R8 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRX-0002xK-2A for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:11 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:43619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRV-0002wQ-VL for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:06 -0400 Received: by mail-pg1-x542.google.com with SMTP id t22so4854158pgi.10 for ; Tue, 30 Apr 2019 22:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=OYW3j0AHRDjiM+2I81b0K/4Pb/2jwavlNMFJ+AYuqcM=; b=XmpDLnakOSblIbl9NAhd/EGXqC/UVryOyy0IKN1hVVHuzSdO6RQy/wPfKjtX6ueyvV Pj1MNVo0lUZPolos1P5a68QUDqL4V5M/3d9aE9y/sz879p1Hgz5kmnq22BAv0+tdUw7O Ps4XrC8uA0Cwmu0ZA6bH0CSLogmx/tAfIMcB1tiqWbgNnzFHaJvZgSYUytZQF9aoYUXZ oYE4SZg+hi3WUawkyLsW7TpMcsvGRtRGnfN+J7Wcf9ZF9VG2lrzrW4WBJAd1dPzN1/7f BaDecNx1mFGx/c3bErF3BR1L0AgiJVNMp+WevMyAuu6c9HlO85flQ6OpszykchsDsIPQ 3rGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=OYW3j0AHRDjiM+2I81b0K/4Pb/2jwavlNMFJ+AYuqcM=; b=gDCFtPTrR9Ae+vIqNnjCU03Y5/j9fok0OwbGQ0hC0IH7ATvOOFnpan50oQV0p73oui ro+4TgeQjOf6G+4HNRavNgtE/kwyws42TmTb6MEcX6gW79VYo2AzzxJEci+GIaJd5V0+ NAJrUfESDuXENxDQf/2O9gWy+YkKExL7QSeeFG00FzSTyLCEJx7GZSj8oYqaojpb8Imz E7KG8PDXwbaPGbKh4lWukLvFQexcOY3H1u3n2/hRoHLH8ZrlaK1LSQiW3CS2dE9mcX6c Zj4/yz6JtdvM1qIjq8F4z0vql9DhkbpxZcHlSbab1VyuNQklspOSkliapKFPQKWnkKQM jJbg== X-Gm-Message-State: APjAAAVji4aVgoxqc93KVdqzfo7cm8kmfu5Gt+p4Ov1tZSUS/R0Kv0s7 BOiKasyyUKmsG3ebu4thNlaaBVpyiyo= X-Received: by 2002:a63:e003:: with SMTP id e3mr40871702pgh.0.1556687164723; Tue, 30 Apr 2019 22:06:04 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:24 -0700 Message-Id: <20190501050536.15580-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v2 17/29] tcg: Add gvec expanders for vector shift by scalar X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/tcg-op-gvec.h | 7 ++ tcg/tcg-op.h | 4 + tcg/tcg-op-gvec.c | 204 ++++++++++++++++++++++++++++++++++++++++++++++ tcg/tcg-op-vec.c | 54 ++++++++++++ 4 files changed, 269 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/tcg-op-gvec.h b/tcg/tcg-op-gvec.h index 84a6247b16..6ee98f3378 100644 --- a/tcg/tcg-op-gvec.h +++ b/tcg/tcg-op-gvec.h @@ -318,6 +318,13 @@ void tcg_gen_gvec_shri(unsigned vece, uint32_t dofs, uint32_t aofs, void tcg_gen_gvec_sari(unsigned vece, uint32_t dofs, uint32_t aofs, int64_t shift, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_shls(unsigned vece, uint32_t dofs, uint32_t aofs, + TCGv_i32 shift, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_shrs(unsigned vece, uint32_t dofs, uint32_t aofs, + TCGv_i32 shift, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_sars(unsigned vece, uint32_t dofs, uint32_t aofs, + TCGv_i32 shift, uint32_t oprsz, uint32_t maxsz); + /* * Perform vector shift by vector element, modulo the element size. * E.g. D[i] = A[i] << (B[i] % (8 << vece)). diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 833c6330b5..472b73cb38 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -986,6 +986,10 @@ void tcg_gen_shli_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); void tcg_gen_shri_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); void tcg_gen_sari_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); +void tcg_gen_shls_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 s); +void tcg_gen_shrs_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 s); +void tcg_gen_sars_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 s); + void tcg_gen_shlv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); void tcg_gen_shrv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); void tcg_gen_sarv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c index 061ef329f1..8fc5ba042b 100644 --- a/tcg/tcg-op-gvec.c +++ b/tcg/tcg-op-gvec.c @@ -2555,6 +2555,210 @@ void tcg_gen_gvec_sari(unsigned vece, uint32_t dofs, uint32_t aofs, } } +/* + * Specialized generation vector shifts by a non-constant scalar. + */ + +static void expand_2sh_vec(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t oprsz, uint32_t tysz, TCGType type, + TCGv_i32 shift, + void (*fni)(unsigned, TCGv_vec, TCGv_vec, TCGv_i32)) +{ + TCGv_vec t0 = tcg_temp_new_vec(type); + uint32_t i; + + for (i = 0; i < oprsz; i += tysz) { + tcg_gen_ld_vec(t0, cpu_env, aofs + i); + fni(vece, t0, t0, shift); + tcg_gen_st_vec(t0, cpu_env, dofs + i); + } + tcg_temp_free_vec(t0); +} + +static void +do_gvec_shifts(unsigned vece, uint32_t dofs, uint32_t aofs, + TCGv_i32 shift, uint32_t oprsz, uint32_t maxsz, + void (*fni4)(TCGv_i32, TCGv_i32, TCGv_i32), + void (*fni8)(TCGv_i64, TCGv_i64, TCGv_i64), + void (*fniv_s)(unsigned, TCGv_vec, TCGv_vec, TCGv_i32), + void (*fniv_v)(unsigned, TCGv_vec, TCGv_vec, TCGv_vec), + gen_helper_gvec_2 *fno, + const TCGOpcode *s_list, const TCGOpcode *v_list) +{ + TCGType type; + uint32_t some; + + check_size_align(oprsz, maxsz, dofs | aofs); + check_overlap_2(dofs, aofs, maxsz); + + /* If the backend has a scalar expansion, great. */ + type = choose_vector_type(s_list, vece, oprsz, vece == MO_64); + if (type) { + const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL); + switch (type) { + case TCG_TYPE_V256: + some = QEMU_ALIGN_DOWN(oprsz, 32); + expand_2sh_vec(vece, dofs, aofs, some, 32, + TCG_TYPE_V256, shift, fniv_s); + if (some == oprsz) { + break; + } + dofs += some; + aofs += some; + oprsz -= some; + maxsz -= some; + /* fallthru */ + case TCG_TYPE_V128: + expand_2sh_vec(vece, dofs, aofs, oprsz, 16, + TCG_TYPE_V128, shift, fniv_s); + break; + case TCG_TYPE_V64: + expand_2sh_vec(vece, dofs, aofs, oprsz, 8, + TCG_TYPE_V64, shift, fniv_s); + break; + default: + g_assert_not_reached(); + } + tcg_swap_vecop_list(hold_list); + goto clear_tail; + } + + /* If the backend supports variable vector shifts, also cool. */ + type = choose_vector_type(v_list, vece, oprsz, vece == MO_64); + if (type) { + const TCGOpcode *hold_list = tcg_swap_vecop_list(NULL); + TCGv_vec v_shift = tcg_temp_new_vec(type); + + if (vece == MO_64) { + TCGv_i64 sh64 = tcg_temp_new_i64(); + tcg_gen_extu_i32_i64(sh64, shift); + tcg_gen_dup_i64_vec(MO_64, v_shift, sh64); + tcg_temp_free_i64(sh64); + } else { + tcg_gen_dup_i32_vec(vece, v_shift, shift); + } + + switch (type) { + case TCG_TYPE_V256: + some = QEMU_ALIGN_DOWN(oprsz, 32); + expand_2s_vec(vece, dofs, aofs, some, 32, TCG_TYPE_V256, + v_shift, false, fniv_v); + if (some == oprsz) { + break; + } + dofs += some; + aofs += some; + oprsz -= some; + maxsz -= some; + /* fallthru */ + case TCG_TYPE_V128: + expand_2s_vec(vece, dofs, aofs, oprsz, 16, TCG_TYPE_V128, + v_shift, false, fniv_v); + break; + case TCG_TYPE_V64: + expand_2s_vec(vece, dofs, aofs, oprsz, 8, TCG_TYPE_V64, + v_shift, false, fniv_v); + break; + default: + g_assert_not_reached(); + } + tcg_temp_free_vec(v_shift); + tcg_swap_vecop_list(hold_list); + goto clear_tail; + } + + /* Otherwise fall back to integral... */ + if (fni4 && check_size_impl(oprsz, 4)) { + expand_2s_i32(dofs, aofs, oprsz, shift, false, fni4); + } else if (fni8 && check_size_impl(oprsz, 8)) { + TCGv_i64 sh64 = tcg_temp_new_i64(); + tcg_gen_extu_i32_i64(sh64, shift); + expand_2s_i64(dofs, aofs, oprsz, sh64, false, fni8); + tcg_temp_free_i64(sh64); + } else { + TCGv_ptr a0 = tcg_temp_new_ptr(); + TCGv_ptr a1 = tcg_temp_new_ptr(); + TCGv_i32 desc = tcg_temp_new_i32(); + + tcg_gen_shli_i32(desc, shift, SIMD_DATA_SHIFT); + tcg_gen_ori_i32(desc, desc, simd_desc(oprsz, maxsz, 0)); + tcg_gen_addi_ptr(a0, cpu_env, dofs); + tcg_gen_addi_ptr(a1, cpu_env, aofs); + + fno(a0, a1, desc); + + tcg_temp_free_ptr(a0); + tcg_temp_free_ptr(a1); + tcg_temp_free_i32(desc); + return; + } + + clear_tail: + if (oprsz < maxsz) { + expand_clr(dofs + oprsz, maxsz - oprsz); + } +} + +void tcg_gen_gvec_shls(unsigned vece, uint32_t dofs, uint32_t aofs, + TCGv_i32 shift, uint32_t oprsz, uint32_t maxsz) +{ + static const TCGOpcode scalar_list[] = { INDEX_op_shls_vec, 0 }; + static const TCGOpcode vector_list[] = { INDEX_op_shlv_vec, 0 }; + static gen_helper_gvec_2 * const fno[4] = { + gen_helper_gvec_shl8i, + gen_helper_gvec_shl16i, + gen_helper_gvec_shl32i, + gen_helper_gvec_shl64i, + }; + + tcg_debug_assert(vece <= MO_64); + do_gvec_shifts(vece, dofs, aofs, shift, oprsz, maxsz, + vece == MO_32 ? tcg_gen_shl_i32 : NULL, + vece == MO_64 ? tcg_gen_shl_i64 : NULL, + tcg_gen_shls_vec, tcg_gen_shlv_vec, fno[vece], + scalar_list, vector_list); +} + +void tcg_gen_gvec_shrs(unsigned vece, uint32_t dofs, uint32_t aofs, + TCGv_i32 shift, uint32_t oprsz, uint32_t maxsz) +{ + static const TCGOpcode scalar_list[] = { INDEX_op_shrs_vec, 0 }; + static const TCGOpcode vector_list[] = { INDEX_op_shrv_vec, 0 }; + static gen_helper_gvec_2 * const fno[4] = { + gen_helper_gvec_shr8i, + gen_helper_gvec_shr16i, + gen_helper_gvec_shr32i, + gen_helper_gvec_shr64i, + }; + + tcg_debug_assert(vece <= MO_64); + do_gvec_shifts(vece, dofs, aofs, shift, oprsz, maxsz, + vece == MO_32 ? tcg_gen_shr_i32 : NULL, + vece == MO_64 ? tcg_gen_shr_i64 : NULL, + tcg_gen_shrs_vec, tcg_gen_shrv_vec, fno[vece], + scalar_list, vector_list); +} + +void tcg_gen_gvec_sars(unsigned vece, uint32_t dofs, uint32_t aofs, + TCGv_i32 shift, uint32_t oprsz, uint32_t maxsz) +{ + static const TCGOpcode scalar_list[] = { INDEX_op_sars_vec, 0 }; + static const TCGOpcode vector_list[] = { INDEX_op_sarv_vec, 0 }; + static gen_helper_gvec_2 * const fno[4] = { + gen_helper_gvec_sar8i, + gen_helper_gvec_sar16i, + gen_helper_gvec_sar32i, + gen_helper_gvec_sar64i, + }; + + tcg_debug_assert(vece <= MO_64); + do_gvec_shifts(vece, dofs, aofs, shift, oprsz, maxsz, + vece == MO_32 ? tcg_gen_sar_i32 : NULL, + vece == MO_64 ? tcg_gen_sar_i64 : NULL, + tcg_gen_sars_vec, tcg_gen_sarv_vec, fno[vece], + scalar_list, vector_list); +} + /* * Expand D = A << (B % element bits) * diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 96317dbd10..16062f5995 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -598,3 +598,57 @@ void tcg_gen_sarv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) { do_op3(vece, r, a, b, INDEX_op_sarv_vec); } + +static void do_shifts(unsigned vece, TCGv_vec r, TCGv_vec a, + TCGv_i32 s, TCGOpcode opc_s, TCGOpcode opc_v) +{ + TCGTemp *rt = tcgv_vec_temp(r); + TCGTemp *at = tcgv_vec_temp(a); + TCGTemp *st = tcgv_i32_temp(s); + TCGArg ri = temp_arg(rt); + TCGArg ai = temp_arg(at); + TCGArg si = temp_arg(st); + TCGType type = rt->base_type; + const TCGOpcode *hold_list; + int can; + + tcg_debug_assert(at->base_type >= type); + tcg_assert_listed_vecop(opc_s); + hold_list = tcg_swap_vecop_list(NULL); + + can = tcg_can_emit_vec_op(opc_s, type, vece); + if (can > 0) { + vec_gen_3(opc_s, type, vece, ri, ai, si); + } else if (can < 0) { + tcg_expand_vec_op(opc_s, type, vece, ri, ai, si); + } else { + TCGv_vec vec_s = tcg_temp_new_vec(type); + + if (vece == MO_64) { + TCGv_i64 s64 = tcg_temp_new_i64(); + tcg_gen_extu_i32_i64(s64, s); + tcg_gen_dup_i64_vec(MO_64, vec_s, s64); + tcg_temp_free_i64(s64); + } else { + tcg_gen_dup_i32_vec(vece, vec_s, s); + } + do_op3(vece, r, a, vec_s, opc_v); + tcg_temp_free_vec(vec_s); + } + tcg_swap_vecop_list(hold_list); +} + +void tcg_gen_shls_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 b) +{ + do_shifts(vece, r, a, b, INDEX_op_shls_vec, INDEX_op_shlv_vec); +} + +void tcg_gen_shrs_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 b) +{ + do_shifts(vece, r, a, b, INDEX_op_shrs_vec, INDEX_op_shrv_vec); +} + +void tcg_gen_sars_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 b) +{ + do_shifts(vece, r, a, b, INDEX_op_sars_vec, INDEX_op_sarv_vec); +} From patchwork Wed May 1 05:05: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: 163187 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4124351ill; Tue, 30 Apr 2019 22:12:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7vd6nWCAd3g3y56oYVPsIf5Wx7Bc9GH1V33J8Xhl21TtybBiDWXZ1uYeBI1Fc87CuXx9R X-Received: by 2002:a17:902:6b82:: with SMTP id p2mr17399643plk.99.1556687532908; Tue, 30 Apr 2019 22:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687532; cv=none; d=google.com; s=arc-20160816; b=fuVMvZKTOHv8tUJcJevBK8ggMaxVC4wUeQ0G/iDOPDTAqbB7bU/PNG9zvfXJNSKRPT 1mWyzWPCMQWAqeD61Iqief+a78uzvAs2PsxfO84YFLuEn/luYu1ciOkqgFnd6P8Qmv4l UcATixbyLxJNgZhe2c1dpMamF2lO0xMxjsb7boU1AibvSLT9tQzsy7TUsKp60XXLM5jl 66cjcg5oucABfF9Tde1lmZrnQAMzFQS6N5aFLUNZmxW4In2hQVoBGXnxQNFQkMhW0ks7 21A8nQdg5Pz4woCnbvCvhFu1l/Bdg7wp9Z3NnH8TbZvGX0x8hgAQs11aDXDR9md0xu/F sIoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=C9S5vov6bUnXU5tt0bNOV17wX7MiGxVomIsm/epCn2g=; b=vgwFK9vYzhmrFLhhrngp2/Ik3bDX14ew1NSBZjkxl810Xv02fNSSkBapcIoMX8apmZ LLYC/0rUZOmvWGcU4b6GyHFRNrGZSvIb+JH0KH4IG5yLP9nSn0d8PDEa41RaXwum/dfX L8+nl3SfYyh/66/v99vzfYtktgxBxCwaTJ4KlcRo14mJr10dTd/3bSyB4T3bBNeFQgc5 VMsIaiRxI8RzwYnlizMItp5cmUmTzCI7TZzcbl1AHs1inGNvXrfqfS+InCnciMp8BQe4 uYAMUEmKGO5zchxNWKLFttPe/x7ne8Imxwm2fBVJ9mgvS9ekv21bh1jzz8fW4xIBqPxU LQGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YVwRHHR5; 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 d37si39367550plb.401.2019.04.30.22.12.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:12: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=YVwRHHR5; 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]:36299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhXN-00037A-KD for patch@linaro.org; Wed, 01 May 2019 01:12:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRd-0006bl-49 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRZ-0002zp-As for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:12 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:34464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRX-0002x5-EU for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:07 -0400 Received: by mail-pf1-x42a.google.com with SMTP id b3so8156938pfd.1 for ; Tue, 30 Apr 2019 22:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=C9S5vov6bUnXU5tt0bNOV17wX7MiGxVomIsm/epCn2g=; b=YVwRHHR5znooT8iDc7LZpXeeD8UR/L3GxJzgqeEd06p49GDxJUoErxoGOZFiLTuSJK 97L6YIFj7WzAl/aUStBVALitKcmnbJUxAM0fMCxM7FZr9HJ/u/L87MUpWUIieK66HYoB 6tTVW6f95M/lW/yR1RQdHEKjCYv0OmMyQmoqWKyGYYCRwh2p9KtH+8XExorvjVwnd2Yz REd6sEwLbvVwEfU1x2KXeah+Q92eBOoKw8zyvzhrYEcLHNWNwk5DOWTnJit2pWtJ0zon XEWVWCmlq1JS58WA7zVtONR3JozUnh7lIGLBm/H2+391Wh2nDdD8YlO+EjtBrYhz8czd 6uuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=C9S5vov6bUnXU5tt0bNOV17wX7MiGxVomIsm/epCn2g=; b=TmugFi9joEQ6espZylEufGYFpScVhPpX3pLOj6xHgYvG3I4+KAv3ud+3TKOLSdhy8W Gzpgd3fE2KuS4nkZkMDoXgKqk5aZlDHvqvCz4rEWfWe4B2/1IDaW6fYJ1eM59UHSV6ee SOWtvg1uSo5E/YarkE1u7bX6QLBXGtODEbCka93+MFLCjdTEddqq8Gv2FpSZutrGn9ci dQqlkhy4NTjQULbgY4+hoATTiuq+M8BanoNqe5H85lVtq5JuAuanTkJlwJ1+5n/LRfcA onpfwl5GUyPxRWQIUKQ0BuT8D1+fo1n3zIK46lhdNU4dSA/cOQJDXu0sU1x+ts0WUk2e axLQ== X-Gm-Message-State: APjAAAWCjgg2evB372vjdzsNJOuVUhnxP6HlVE7QKpjI5G767Ea9WZkB zevQpcjaEjaa2ZRPMuu8X/szL3xUWEQ= X-Received: by 2002:a63:ed4e:: with SMTP id m14mr73239595pgk.182.1556687165871; Tue, 30 Apr 2019 22:06:05 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:25 -0700 Message-Id: <20190501050536.15580-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42a Subject: [Qemu-devel] [PATCH v2 18/29] tcg/i386: Support vector scalar shift opcodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.inc.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index b240633455..618aa520d2 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -183,7 +183,7 @@ extern bool have_avx2; #define TCG_TARGET_HAS_not_vec 0 #define TCG_TARGET_HAS_neg_vec 0 #define TCG_TARGET_HAS_shi_vec 1 -#define TCG_TARGET_HAS_shs_vec 0 +#define TCG_TARGET_HAS_shs_vec 1 #define TCG_TARGET_HAS_shv_vec have_avx2 #define TCG_TARGET_HAS_cmp_vec 1 #define TCG_TARGET_HAS_mul_vec 1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index c9448b6d84..0ba1587da4 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -420,6 +420,14 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_PSHIFTW_Ib (0x71 | P_EXT | P_DATA16) /* /2 /6 /4 */ #define OPC_PSHIFTD_Ib (0x72 | P_EXT | P_DATA16) /* /2 /6 /4 */ #define OPC_PSHIFTQ_Ib (0x73 | P_EXT | P_DATA16) /* /2 /6 /4 */ +#define OPC_PSLLW (0xf1 | P_EXT | P_DATA16) +#define OPC_PSLLD (0xf2 | P_EXT | P_DATA16) +#define OPC_PSLLQ (0xf3 | P_EXT | P_DATA16) +#define OPC_PSRAW (0xe1 | P_EXT | P_DATA16) +#define OPC_PSRAD (0xe2 | P_EXT | P_DATA16) +#define OPC_PSRLW (0xd1 | P_EXT | P_DATA16) +#define OPC_PSRLD (0xd2 | P_EXT | P_DATA16) +#define OPC_PSRLQ (0xd3 | P_EXT | P_DATA16) #define OPC_PSUBB (0xf8 | P_EXT | P_DATA16) #define OPC_PSUBW (0xf9 | P_EXT | P_DATA16) #define OPC_PSUBD (0xfa | P_EXT | P_DATA16) @@ -2724,6 +2732,15 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, /* TODO: AVX512 adds support for MO_16, MO_64. */ OPC_UD2, OPC_UD2, OPC_VPSRAVD, OPC_UD2 }; + static int const shls_insn[4] = { + OPC_UD2, OPC_PSLLW, OPC_PSLLD, OPC_PSLLQ + }; + static int const shrs_insn[4] = { + OPC_UD2, OPC_PSRLW, OPC_PSRLD, OPC_PSRLQ + }; + static int const sars_insn[4] = { + OPC_UD2, OPC_PSRAW, OPC_PSRAD, OPC_UD2 + }; TCGType type = vecl + TCG_TYPE_V64; int insn, sub; @@ -2785,6 +2802,15 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_sarv_vec: insn = sarv_insn[vece]; goto gen_simd; + case INDEX_op_shls_vec: + insn = shls_insn[vece]; + goto gen_simd; + case INDEX_op_shrs_vec: + insn = shrs_insn[vece]; + goto gen_simd; + case INDEX_op_sars_vec: + insn = sars_insn[vece]; + goto gen_simd; case INDEX_op_x86_punpckl_vec: insn = punpckl_insn[vece]; goto gen_simd; @@ -3165,6 +3191,9 @@ 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_shls_vec: + case INDEX_op_shrs_vec: + case INDEX_op_sars_vec: case INDEX_op_cmp_vec: case INDEX_op_x86_shufps_vec: case INDEX_op_x86_blend_vec: @@ -3222,6 +3251,12 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) } return 1; + case INDEX_op_shls_vec: + case INDEX_op_shrs_vec: + return vece >= MO_16; + case INDEX_op_sars_vec: + return vece >= MO_16 && vece <= MO_32; + case INDEX_op_shlv_vec: case INDEX_op_shrv_vec: return have_avx2 && vece >= MO_32; From patchwork Wed May 1 05:05:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163195 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4130091ill; Tue, 30 Apr 2019 22:20:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNmg7Vtq+ynosetqgW+eFKHlg4KW88ZVvfvtmLB/Hw+4vCWPAL55iqxqp5A4qmXJYwFtJh X-Received: by 2002:adf:f1cb:: with SMTP id z11mr20304985wro.209.1556688023966; Tue, 30 Apr 2019 22:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688023; cv=none; d=google.com; s=arc-20160816; b=Hyo5UJ3ZJegdSrI+i997AL5D3DhmbCwW96qUKzoNAV1gPidW1isdC0+Jbz0u8ngrn8 PmZfDL7AlHgYr5qycvy4ubBk2Y4ieQDt69oUV4nvu/QbNA++07KViVr8Do+VF1dGwn4U 32OsNPl3H21dW7tNhP4aHFrUSApIN+m36NIA/EsFlTm8kneIeEBA+M3RJPUsOkDlj+kV uyulQ2hyJdRDInQHCcB0oYOYg+rQI/nkHBTM39GxtSlHQrBcvGCS/c6uCTR19ZjwsH4Z URb4P4DYsgCmmBZd55SZOVhYTTHKawcRsbTbnioBJzJqBHspN26qdUF25NjkLuGDPPau bdMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=yFRiQL+bz58cWGz6Ig2AM72yMnp/aPGg7D5yMyvGces=; b=rjkykjUWYs4YDp8CQTfg6zf59V2NTrS4wEnUSEQ+KQjMXUnlNLJWhC8MzprFEh0QLB YEz0Sw+pUiAsW629Dx7eVPpJ5PNE4RpUmmWgR0sk0Hh0Mv0MdcNVMq9yKoxXnaSAs1iR n+picOWiQN3TWc7eUWutmqufr19wvPpKiMEtG+LPZlASyLa6w5PP/vppSAb/VbFus+C7 r0J8kNzcTDkN1W4eH/dAaJwDTZEnTLVy8M0MkHH2OPM7z4EBsCR0IRO4pRjhvf/AyH9t FXft/SsXttWUENM9qO+K4q6VErE8uv/2ZhAE4/qY5581Re6wvh+rejDB4EaCosdUAOkp uAtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=b0mCOOGo; 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 c16si23839679wrs.240.2019.04.30.22.20.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:20: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=b0mCOOGo; 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]:36426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhfK-0001vl-Pz for patch@linaro.org; Wed, 01 May 2019 01:20:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRf-0006de-1s for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRb-00030j-Cz for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:14 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:38308) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRZ-0002xi-Bc for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:10 -0400 Received: by mail-pg1-x542.google.com with SMTP id j26so7869534pgl.5 for ; Tue, 30 Apr 2019 22:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yFRiQL+bz58cWGz6Ig2AM72yMnp/aPGg7D5yMyvGces=; b=b0mCOOGoVldLR9CZSwIEn9gACKL8H8NKGSMp0Qijtww4FOFR1XWnobJGn5tHM/YwbT kGnQ32Hzb5wXRyVffiQIE2jvZuenjyGjKsWHDt43SaqpthiAl2xgqx2UYkET7FUygtgS 3kK2DM1mCnDe8THYeRJ/k0mTBDP647lM4FKKKuuXeHvND6IIPEBd34eel+9ho5FCa1yN NvYAO4cj2TcVi68tKvmnheWiTYRgnr6HZeT6pvBuSjylPGjunUlLvOTrfeqeeB1Ah2xQ FwypiQqrFNavZ1zvIhlmbEGP8I7Sdm2FVXMT5t5Eup6gUOxV+p8LWe+WM1Z8Zx2G1850 s9Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yFRiQL+bz58cWGz6Ig2AM72yMnp/aPGg7D5yMyvGces=; b=HEJqwLsN8JZRI9Aq6F0WnnyhR8whpO79KGRwS5PzBLQx8OzRlYa/MKTve1p7lYVaZP 1N/COitZRbUa+eYmoG9DJmoq78/ZBmwCxJIsYovw9PPfHP+BJAUvmttieYKjKdKaSlVt LQydPyorJFiW6NikiYs2eXv6ZyP+1RyDkr3jz9Jj41GtRReeFpzW+mLGDNbcmnEbHMWM x5oOZpY8RA3NpGHtfOUBrCQo4g2Cg7V2H7fF5/58qn17GqGxLWhCWFZFo76PZU0FwY+W cjSaLeQtL8j/OQoBA6grWWH3lLUBYAk8DAZLtqZUd71btaVeN2uX1DElyX9nw2356r7c w+eQ== X-Gm-Message-State: APjAAAW2Zmi1AN0ZoGhmZgKhOzJjEf9mAs0pNDcY3/QwEwOgk4qngWix 101GhX8hEX4SPwQd/EkW0l4HKPExn+g= X-Received: by 2002:a63:4f1c:: with SMTP id d28mr70620861pgb.144.1556687166937; Tue, 30 Apr 2019 22:06:06 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:26 -0700 Message-Id: <20190501050536.15580-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> MIME-Version: 1.0 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 v2 19/29] tcg: Add support for integer absolute value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Remove a function of the same name from target/arm/. Use a branchless implementation of abs gleaned from gcc. Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg-op.h | 5 +++++ target/arm/translate.c | 10 ---------- tcg/tcg-op.c | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 472b73cb38..660fe205d0 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -335,6 +335,7 @@ void tcg_gen_smin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); void tcg_gen_smax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); void tcg_gen_umin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); void tcg_gen_umax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); +void tcg_gen_abs_i32(TCGv_i32, TCGv_i32); static inline void tcg_gen_discard_i32(TCGv_i32 arg) { @@ -534,6 +535,7 @@ void tcg_gen_smin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_smax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_umin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_umax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); +void tcg_gen_abs_i64(TCGv_i64, TCGv_i64); #if TCG_TARGET_REG_BITS == 64 static inline void tcg_gen_discard_i64(TCGv_i64 arg) @@ -973,6 +975,7 @@ void tcg_gen_nor_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); void tcg_gen_eqv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 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); +void tcg_gen_abs_vec(unsigned vece, TCGv_vec r, TCGv_vec a); void tcg_gen_ssadd_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); void tcg_gen_usadd_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); void tcg_gen_sssub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); @@ -1019,6 +1022,7 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_addi_tl tcg_gen_addi_i64 #define tcg_gen_sub_tl tcg_gen_sub_i64 #define tcg_gen_neg_tl tcg_gen_neg_i64 +#define tcg_gen_abs_tl tcg_gen_abs_i64 #define tcg_gen_subfi_tl tcg_gen_subfi_i64 #define tcg_gen_subi_tl tcg_gen_subi_i64 #define tcg_gen_and_tl tcg_gen_and_i64 @@ -1131,6 +1135,7 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_addi_tl tcg_gen_addi_i32 #define tcg_gen_sub_tl tcg_gen_sub_i32 #define tcg_gen_neg_tl tcg_gen_neg_i32 +#define tcg_gen_abs_tl tcg_gen_abs_i32 #define tcg_gen_subfi_tl tcg_gen_subfi_i32 #define tcg_gen_subi_tl tcg_gen_subi_i32 #define tcg_gen_and_tl tcg_gen_and_i32 diff --git a/target/arm/translate.c b/target/arm/translate.c index 35bd426a3d..b25781554f 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -604,16 +604,6 @@ static void gen_sar(TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1) tcg_temp_free_i32(tmp1); } -static void tcg_gen_abs_i32(TCGv_i32 dest, TCGv_i32 src) -{ - TCGv_i32 c0 = tcg_const_i32(0); - TCGv_i32 tmp = tcg_temp_new_i32(); - tcg_gen_neg_i32(tmp, src); - tcg_gen_movcond_i32(TCG_COND_GT, dest, src, c0, src, tmp); - tcg_temp_free_i32(c0); - tcg_temp_free_i32(tmp); -} - static void shifter_out_im(TCGv_i32 var, int shift) { if (shift == 0) { diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index a00d1df37e..0ac291f1c4 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1091,6 +1091,16 @@ void tcg_gen_umax_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b) tcg_gen_movcond_i32(TCG_COND_LTU, ret, a, b, b, a); } +void tcg_gen_abs_i32(TCGv_i32 ret, TCGv_i32 a) +{ + TCGv_i32 t = tcg_temp_new_i32(); + + tcg_gen_sari_i32(t, a, 31); + tcg_gen_xor_i32(ret, a, t); + tcg_gen_sub_i32(ret, ret, t); + tcg_temp_free_i32(t); +} + /* 64-bit ops */ #if TCG_TARGET_REG_BITS == 32 @@ -2548,6 +2558,16 @@ void tcg_gen_umax_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b) tcg_gen_movcond_i64(TCG_COND_LTU, ret, a, b, b, a); } +void tcg_gen_abs_i64(TCGv_i64 ret, TCGv_i64 a) +{ + TCGv_i64 t = tcg_temp_new_i64(); + + tcg_gen_sari_i64(t, a, 63); + tcg_gen_xor_i64(ret, a, t); + tcg_gen_sub_i64(ret, ret, t); + tcg_temp_free_i64(t); +} + /* Size changing operations. */ void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg) From patchwork Wed May 1 05:05:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163190 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4126156ill; Tue, 30 Apr 2019 22:14:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCnoZcfiWBN6VsrcueD7V8c2vzt3gV81ARwV4fSQB8js9JaQmUPiqvOSFI/vifOR9ijKEK X-Received: by 2002:a5d:4403:: with SMTP id z3mr11421410wrq.186.1556687696969; Tue, 30 Apr 2019 22:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687696; cv=none; d=google.com; s=arc-20160816; b=V9dv4QKMugj8iPlCW5IEh9el9rHvi8shuTCDa6T82Xt3ovJAjALb6IKGSLPNFUXg4k Yjrq6vKmLA03ESf120TsKDdDztly3W+yUbu80FdSfaCzAmsGnzWMi+p9IT721xtN+a6+ C6/Sm8c6tPGEjB9G6VuocldH1BeGCr8F5zrUp4zCCPCDfd/RU7vkxMdo7p/usa64CpaJ 2iz0lvctf3ib7Diuhcbj6lC2z9lf1CUeNq1gbpngd8eKtBku2pygGR54+QS4lkdzLunx MlR2AttBfEqfm/QyYiF/qetQpDDNIdlFvPC8g2dyboMM+kOltuYY4qRLay4rWEgk5h/U vT+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=U8crGsjiLUrl6mnADifkDvQfCBtwrhI+yquLPBNbZRg=; b=i/NLyVlQWsGlfoaQXxMapfhlfhz5Ht39LbXHMTLQmo5XBb6d5+yRLGPuvkxDH7QPUa gzMylrTQXACxsLK/GiZwuJnFs2/BYscFPWynKEpAM3P3sCj7XsjLLQS/1Ral/EXUp4RD aBt+8LLKe6Qm4haxlDrVlSpINysujTkzlpglPpbN17veB7wjcVBe9SJU2NpaJJZFkCA7 2cT2YoDjf3663ntjRnKBE+i0uo4dZmKEF9C7yfU0FVP6NqIFqMi//5wTbHhsL6wTN+zD 5jQ3XZrdNXr9gpMR/+gZY8gPmWmk5GThwQfyHW3TxI9MhX/WBnn+v+YiDH3d7qxNcyfK sOYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZfIi7dMz; 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 x13si6616453wro.438.2019.04.30.22.14.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:14:56 -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=ZfIi7dMz; 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]:36323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLha3-0005Qp-Nm for patch@linaro.org; Wed, 01 May 2019 01:14:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRg-0006fu-RK for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRd-00031h-4X for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:16 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:38983) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRb-0002zP-CA for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:12 -0400 Received: by mail-pg1-x52d.google.com with SMTP id l18so7862535pgj.6 for ; Tue, 30 Apr 2019 22:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=U8crGsjiLUrl6mnADifkDvQfCBtwrhI+yquLPBNbZRg=; b=ZfIi7dMzDHPTGlSUEDkx++UJT6+ZyXmvKHT7uQxdk2z81ST+aD1ZE9dWQUNXCCpEMw G7F/zLTIsL/CBVMkiUbHtdn9UfdxOVXbM2h4tHJJK0JidlOGgixAeg2fQZbqw8SnQ1O8 4hV7ZJK+09SlAoX05YhH35txY7zbMoSwXhPHHoeYI1UQl1tD3IOQQqyIAwYl6C/98LfN GFFWy9g6KdARdqGk40BKlhscU/0NNCKRMxE4IAaPUZqfEL+9q5W276wEvydfBVykQYWH SZCGs+pr+N1wWEMQpMlocBOmne9AFvYXdCvaWTyRXsPIF1vu2KEIkTXownMbchnsvObj bbOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=U8crGsjiLUrl6mnADifkDvQfCBtwrhI+yquLPBNbZRg=; b=GHexRRrQEK2sP9YVx6OmFb0oeKOxXvK/ZSCUianTfMq/BQ/k5GQpsuYRb9sFRGr3c5 1cgAVE8CF3grD5ZgGtyWYeMmLmRiTCPizTeEDi8s9l48KX0fC1jLEPW0VMhi3T9SZZul dFikH3XsVYhdphnq7wIyzC3rstBifrpfQInqVbOJowDN0bsluVDBDe99bJ6kwl3p/eXe O+Jx2zyJ+g+10CkNuTOl/TchhfZA4ag9UNquJXoMS9C36+p+P5OCxA4NBcWGQWWBj9Br XViUbe5RG++LhnGLBxsj8sbQFpAfkLFn9N5wx+x65g7PDbP8e/Ltn+MzWxZgFFkI30Ep mbIQ== X-Gm-Message-State: APjAAAXr0LouBwYVyuMXynepgyDVURo/DE40wwpxXoG3wF5nQkQYe8pl niGOdeGzZ3a2R5XUzM1yjoXtiKNRnho= X-Received: by 2002:a63:5659:: with SMTP id g25mr18077246pgm.59.1556687168163; Tue, 30 Apr 2019 22:06:08 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:27 -0700 Message-Id: <20190501050536.15580-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52d Subject: [Qemu-devel] [PATCH v2 20/29] tcg: Add support for vector absolute value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- accel/tcg/tcg-runtime.h | 5 +++ tcg/aarch64/tcg-target.h | 1 + tcg/i386/tcg-target.h | 1 + tcg/tcg-op-gvec.h | 2 ++ tcg/tcg-opc.h | 1 + tcg/tcg.h | 1 + accel/tcg/tcg-runtime-gvec.c | 48 +++++++++++++++++++++++++++ tcg/tcg-op-gvec.c | 63 ++++++++++++++++++++++++++++++++++++ tcg/tcg-op-vec.c | 39 ++++++++++++++++++++++ tcg/tcg.c | 2 ++ tcg/README | 4 +++ 11 files changed, 167 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index ed3ce5fd91..6d73dc2d65 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -225,6 +225,11 @@ DEF_HELPER_FLAGS_3(gvec_neg16, TCG_CALL_NO_RWG, void, ptr, ptr, i32) DEF_HELPER_FLAGS_3(gvec_neg32, TCG_CALL_NO_RWG, void, ptr, ptr, i32) DEF_HELPER_FLAGS_3(gvec_neg64, TCG_CALL_NO_RWG, void, ptr, ptr, i32) +DEF_HELPER_FLAGS_3(gvec_abs8, TCG_CALL_NO_RWG, void, ptr, ptr, i32) +DEF_HELPER_FLAGS_3(gvec_abs16, TCG_CALL_NO_RWG, void, ptr, ptr, i32) +DEF_HELPER_FLAGS_3(gvec_abs32, TCG_CALL_NO_RWG, void, ptr, ptr, i32) +DEF_HELPER_FLAGS_3(gvec_abs64, TCG_CALL_NO_RWG, void, ptr, ptr, i32) + DEF_HELPER_FLAGS_3(gvec_not, TCG_CALL_NO_RWG, void, ptr, ptr, i32) DEF_HELPER_FLAGS_4(gvec_and, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_4(gvec_or, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index f5640a229b..21d06d928c 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -132,6 +132,7 @@ typedef enum { #define TCG_TARGET_HAS_orc_vec 1 #define TCG_TARGET_HAS_not_vec 1 #define TCG_TARGET_HAS_neg_vec 1 +#define TCG_TARGET_HAS_abs_vec 0 #define TCG_TARGET_HAS_shi_vec 1 #define TCG_TARGET_HAS_shs_vec 0 #define TCG_TARGET_HAS_shv_vec 1 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 618aa520d2..7445f05885 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -182,6 +182,7 @@ extern bool have_avx2; #define TCG_TARGET_HAS_orc_vec 0 #define TCG_TARGET_HAS_not_vec 0 #define TCG_TARGET_HAS_neg_vec 0 +#define TCG_TARGET_HAS_abs_vec 0 #define TCG_TARGET_HAS_shi_vec 1 #define TCG_TARGET_HAS_shs_vec 1 #define TCG_TARGET_HAS_shv_vec have_avx2 diff --git a/tcg/tcg-op-gvec.h b/tcg/tcg-op-gvec.h index 6ee98f3378..52a398c190 100644 --- a/tcg/tcg-op-gvec.h +++ b/tcg/tcg-op-gvec.h @@ -228,6 +228,8 @@ void tcg_gen_gvec_not(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t oprsz, uint32_t maxsz); void tcg_gen_gvec_neg(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_abs(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t oprsz, uint32_t maxsz); void tcg_gen_gvec_add(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz); diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h index 4bf71f261f..4a2dd116eb 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -225,6 +225,7 @@ DEF(add_vec, 1, 2, 0, IMPLVEC) DEF(sub_vec, 1, 2, 0, IMPLVEC) DEF(mul_vec, 1, 2, 0, IMPLVEC | IMPL(TCG_TARGET_HAS_mul_vec)) DEF(neg_vec, 1, 1, 0, IMPLVEC | IMPL(TCG_TARGET_HAS_neg_vec)) +DEF(abs_vec, 1, 1, 0, IMPLVEC | IMPL(TCG_TARGET_HAS_abs_vec)) DEF(ssadd_vec, 1, 2, 0, IMPLVEC | IMPL(TCG_TARGET_HAS_sat_vec)) DEF(usadd_vec, 1, 2, 0, IMPLVEC | IMPL(TCG_TARGET_HAS_sat_vec)) DEF(sssub_vec, 1, 2, 0, IMPLVEC | IMPL(TCG_TARGET_HAS_sat_vec)) diff --git a/tcg/tcg.h b/tcg/tcg.h index 2c7315da25..0e01a70d66 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -176,6 +176,7 @@ typedef uint64_t TCGRegSet; && !defined(TCG_TARGET_HAS_v128) \ && !defined(TCG_TARGET_HAS_v256) #define TCG_TARGET_MAYBE_vec 0 +#define TCG_TARGET_HAS_abs_vec 0 #define TCG_TARGET_HAS_neg_vec 0 #define TCG_TARGET_HAS_not_vec 0 #define TCG_TARGET_HAS_andc_vec 0 diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c index 2152fb6903..0f09e0ef38 100644 --- a/accel/tcg/tcg-runtime-gvec.c +++ b/accel/tcg/tcg-runtime-gvec.c @@ -398,6 +398,54 @@ void HELPER(gvec_neg64)(void *d, void *a, uint32_t desc) clear_high(d, oprsz, desc); } +void HELPER(gvec_abs8)(void *d, void *a, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(int8_t)) { + int8_t aa = *(int8_t *)(a + i); + *(int8_t *)(d + i) = aa < 0 ? -aa : aa; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_abs16)(void *d, void *a, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(int16_t)) { + int16_t aa = *(int16_t *)(a + i); + *(int16_t *)(d + i) = aa < 0 ? -aa : aa; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_abs32)(void *d, void *a, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(int32_t)) { + int32_t aa = *(int32_t *)(a + i); + *(int32_t *)(d + i) = aa < 0 ? -aa : aa; + } + clear_high(d, oprsz, desc); +} + +void HELPER(gvec_abs64)(void *d, void *a, uint32_t desc) +{ + intptr_t oprsz = simd_oprsz(desc); + intptr_t i; + + for (i = 0; i < oprsz; i += sizeof(int64_t)) { + int64_t aa = *(int64_t *)(a + i); + *(int64_t *)(d + i) = aa < 0 ? -aa : aa; + } + clear_high(d, oprsz, desc); +} + void HELPER(gvec_mov)(void *d, void *a, uint32_t desc) { intptr_t oprsz = simd_oprsz(desc); diff --git a/tcg/tcg-op-gvec.c b/tcg/tcg-op-gvec.c index 8fc5ba042b..bbccb3f5a1 100644 --- a/tcg/tcg-op-gvec.c +++ b/tcg/tcg-op-gvec.c @@ -2177,6 +2177,69 @@ void tcg_gen_gvec_neg(unsigned vece, uint32_t dofs, uint32_t aofs, tcg_gen_gvec_2(dofs, aofs, oprsz, maxsz, &g[vece]); } +static void gen_absv_mask(TCGv_i64 d, TCGv_i64 b, unsigned vece) +{ + TCGv_i64 t = tcg_temp_new_i64(); + int nbit = 8 << vece; + + /* Create -1 for each negative element. */ + tcg_gen_shri_i64(t, b, nbit - 1); + tcg_gen_andi_i64(t, t, dup_const(vece, 1)); + tcg_gen_muli_i64(t, t, (1 << nbit) - 1); + + /* + * Invert (via xor -1) and add one (via sub -1). + * Because of the ordering the msb is cleared, + * so we never have carry into the next element. + */ + tcg_gen_xor_i64(d, b, t); + tcg_gen_sub_i64(d, d, t); + + tcg_temp_free_i64(t); +} + +static void tcg_gen_vec_abs8_i64(TCGv_i64 d, TCGv_i64 b) +{ + gen_absv_mask(d, b, MO_8); +} + +static void tcg_gen_vec_abs16_i64(TCGv_i64 d, TCGv_i64 b) +{ + gen_absv_mask(d, b, MO_16); +} + +void tcg_gen_gvec_abs(unsigned vece, uint32_t dofs, uint32_t aofs, + uint32_t oprsz, uint32_t maxsz) +{ + static const TCGOpcode vecop_list[] = { INDEX_op_abs_vec, 0 }; + static const GVecGen2 g[4] = { + { .fni8 = tcg_gen_vec_abs8_i64, + .fniv = tcg_gen_abs_vec, + .fno = gen_helper_gvec_abs8, + .opt_opc = vecop_list, + .vece = MO_8 }, + { .fni8 = tcg_gen_vec_abs16_i64, + .fniv = tcg_gen_abs_vec, + .fno = gen_helper_gvec_abs16, + .opt_opc = vecop_list, + .vece = MO_16 }, + { .fni4 = tcg_gen_abs_i32, + .fniv = tcg_gen_abs_vec, + .fno = gen_helper_gvec_abs32, + .opt_opc = vecop_list, + .vece = MO_32 }, + { .fni8 = tcg_gen_abs_i64, + .fniv = tcg_gen_abs_vec, + .fno = gen_helper_gvec_abs64, + .opt_opc = vecop_list, + .prefer_i64 = TCG_TARGET_REG_BITS == 64, + .vece = MO_64 }, + }; + + tcg_debug_assert(vece <= MO_64); + tcg_gen_gvec_2(dofs, aofs, oprsz, maxsz, &g[vece]); +} + void tcg_gen_gvec_and(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz) { diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 16062f5995..543508d545 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -110,6 +110,14 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list, continue; } break; + case INDEX_op_abs_vec: + if (tcg_can_emit_vec_op(INDEX_op_sub_vec, type, vece) + && (tcg_can_emit_vec_op(INDEX_op_smax_vec, type, vece) > 0 + || tcg_can_emit_vec_op(INDEX_op_sari_vec, type, vece) > 0 + || tcg_can_emit_vec_op(INDEX_op_cmp_vec, type, vece))) { + continue; + } + break; default: break; } @@ -429,6 +437,37 @@ void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a) tcg_swap_vecop_list(hold_list); } +void tcg_gen_abs_vec(unsigned vece, TCGv_vec r, TCGv_vec a) +{ + const TCGOpcode *hold_list; + + tcg_assert_listed_vecop(INDEX_op_abs_vec); + hold_list = tcg_swap_vecop_list(NULL); + + if (!do_op2(vece, r, a, INDEX_op_abs_vec)) { + TCGType type = tcgv_vec_temp(r)->base_type; + TCGv_vec t = tcg_temp_new_vec(type); + + tcg_debug_assert(tcg_can_emit_vec_op(INDEX_op_sub_vec, type, vece)); + if (tcg_can_emit_vec_op(INDEX_op_smax_vec, type, vece) > 0) { + tcg_gen_neg_vec(vece, t, a); + tcg_gen_smax_vec(vece, r, a, t); + } else { + if (tcg_can_emit_vec_op(INDEX_op_sari_vec, type, vece) > 0) { + tcg_gen_sari_vec(vece, t, a, (8 << vece) - 1); + } else { + do_dupi_vec(t, MO_REG, 0); + tcg_gen_cmp_vec(TCG_COND_LT, vece, t, a, t); + } + tcg_gen_xor_vec(vece, r, a, t); + tcg_gen_sub_vec(vece, r, r, t); + } + + tcg_temp_free_vec(t); + } + tcg_swap_vecop_list(hold_list); +} + static void do_shifti(TCGOpcode opc, unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i) { diff --git a/tcg/tcg.c b/tcg/tcg.c index bb1e124e80..9393f21a5b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1616,6 +1616,8 @@ bool tcg_op_supported(TCGOpcode op) return have_vec && TCG_TARGET_HAS_not_vec; case INDEX_op_neg_vec: return have_vec && TCG_TARGET_HAS_neg_vec; + case INDEX_op_abs_vec: + return have_vec && TCG_TARGET_HAS_abs_vec; case INDEX_op_andc_vec: return have_vec && TCG_TARGET_HAS_andc_vec; case INDEX_op_orc_vec: diff --git a/tcg/README b/tcg/README index c30e5418a6..cbdfd3b6bc 100644 --- a/tcg/README +++ b/tcg/README @@ -561,6 +561,10 @@ E.g. VECL=1 -> 64 << 1 -> v128, and VECE=2 -> 1 << 2 -> i32. Similarly, v0 = -v1. +* abs_vec v0, v1 + + Similarly, v0 = v1 < 0 ? -v1 : v1, in elements across the vector. + * smin_vec: * umin_vec: From patchwork Wed May 1 05:05:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163198 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4131179ill; Tue, 30 Apr 2019 22:22:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqywc66Xsqw/jnjPUmmC19CO1SjNO5LMR7sCkBZ9mFX3O62vpheafUyduNpFQbaMVnASHwY8 X-Received: by 2002:adf:f2c5:: with SMTP id d5mr29118722wrp.293.1556688127855; Tue, 30 Apr 2019 22:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688127; cv=none; d=google.com; s=arc-20160816; b=py2UT3e9SaFfR14dkTyTu8kDTIsuxux9IT99S9CGoGtYAJ17pSID+Rfx2Knvp8mWR3 FIlCg0zZQO54WbDLgWbgrjjhJ0GO5pPb1ofktwIueXj/og+yza6YpowJi7asA5X+Ta5F esPRKf6hVk4Hjkis7YwgR2vVr6r31WyGf3Bp/NdIvBhO4dCi6WVx+i21tPv/I4bzTD7S 6uNuKrLmo7SuEw63BBYpEPWB1Y7GVV21DFKLmE995fGq+HOplFY8Iv3RU0pbCzm9BXUr z7V+TQTigAb0KS3TbOrxRsYleUEY2gdVYd+KPCoghXYFI+ByIL6ViqsKPQWE5UwVmT9y ilAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=4RamRVLS6CpSQqwq41FPx2oK0CgrkzF+uLuaNa5g2S4=; b=xTVsezv92T/xOA4tPwJCrXnpiAiCgM1AzaK3NgvZ6JCcHYseryyJXlJrTIARrHqBHE sekzwyg6bw1u/j7+nUyHH013wDpjdvQMwgO5V2Hjl9AHnuarFRcnkp5UqjHJldqHMN95 6tScBAXFFvgjndX24HdtRXxb0jFAHU/eu2kV62EOPpFK0/uhBNupYSzGcp3Wus27WXTq Ph6m7ibOphdgxy1wzzh7JkqG/b4Cj+4Henl2Ryfj/OmoKKUViY8+dgE1ggc5qqHyfVtu IWfhsRwvR0vLb52G+l4BWh0DGu5M3qDCcOEeh6Dbrc3oYcLJPLjIeN/EUAaS4DBWuVi2 gvKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YUlVOOhk; 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 f12si13205974wrx.51.2019.04.30.22.22.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22: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=YUlVOOhk; 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]:36445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhh0-0002ua-OO for patch@linaro.org; Wed, 01 May 2019 01:22:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRi-0006hz-VZ for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRf-00032a-0l for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:18 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:45877) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRd-00030S-ON for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:14 -0400 Received: by mail-pg1-x531.google.com with SMTP id i21so4414956pgi.12 for ; Tue, 30 Apr 2019 22:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=4RamRVLS6CpSQqwq41FPx2oK0CgrkzF+uLuaNa5g2S4=; b=YUlVOOhkSv5Iesn+A6SKAXAjPktYNIihrdUvP8bn15JIkTc+4kc2bUBv/8Zkh/ZEMt gtUSVzN8mBA2XkUiSkIOe39jcbMzr2Ja9BTAXL7Wubrg0QSYE2Kel2rVXh0XOnzPzREf /reDZFBEsiPnRh1YAzmISLr6qERR2CxVozh35uAoZNS8vPUGJg0GOFLywfL5B8a6cbF8 kjM0iSn+9jH90ovt5dgeYVXg8Mn3o/eQZB+ch/ednBIHeqFfblKBE05aC7y6vdhLclWw fi11aoPrXanaCILjPAPwB/L8DlQryyMA6qfWJnA5O6wKLLSJj0nAJeR45NVtjj3gB4tQ 8bCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=4RamRVLS6CpSQqwq41FPx2oK0CgrkzF+uLuaNa5g2S4=; b=i4GbG5kaiaO2TzUuxcgFkXeHXXz8JsAIOB9fQIvjV5bcH6Fsbp5iwpu5I9PUOcbcae 4KYSuNwEqrbLgLhbrRjqlgg6iKS2lRQRfNDiCKvmcrCjeUO6cbMqq8SZ5P35EfjefH7/ WZmVuzblts4cWQicphPZ0VPEkB7VyJfebi/OSXsvf7zyVchrcb82VFE7NRQZNkNMlQCe qJvWsafEfclTpgFSIKaahObr4DeYUsi05Yt/lKvRLN0cigtHxcV9GxNkeRbG26zS6krg 9FilyZ/L4vq+s5WElE08A/FP7HcFKeNY3UJmZ/jycULbLeObRYvsDLHN8NCRMqSG8P7c CBUQ== X-Gm-Message-State: APjAAAUpdjYk695HZX4Fq0QwwtnXeMpa+za4EiA/QnMAl9OlpoL94Jif koTTJGm2VvZJ3kOHSS3w+Ysk7SHiptM= X-Received: by 2002:a63:564f:: with SMTP id g15mr18298405pgm.258.1556687169716; Tue, 30 Apr 2019 22:06:09 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:28 -0700 Message-Id: <20190501050536.15580-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::531 Subject: [Qemu-devel] [PATCH v2 21/29] tcg/i386: Support vector absolute value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.inc.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 7445f05885..66f16fbe3c 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -182,7 +182,7 @@ extern bool have_avx2; #define TCG_TARGET_HAS_orc_vec 0 #define TCG_TARGET_HAS_not_vec 0 #define TCG_TARGET_HAS_neg_vec 0 -#define TCG_TARGET_HAS_abs_vec 0 +#define TCG_TARGET_HAS_abs_vec 1 #define TCG_TARGET_HAS_shi_vec 1 #define TCG_TARGET_HAS_shs_vec 1 #define TCG_TARGET_HAS_shv_vec have_avx2 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 0ba1587da4..aafd01cb49 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -369,6 +369,9 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_MOVSLQ (0x63 | P_REXW) #define OPC_MOVZBL (0xb6 | P_EXT) #define OPC_MOVZWL (0xb7 | P_EXT) +#define OPC_PABSB (0x1c | P_EXT38 | P_DATA16) +#define OPC_PABSW (0x1d | P_EXT38 | P_DATA16) +#define OPC_PABSD (0x1e | P_EXT38 | P_DATA16) #define OPC_PACKSSDW (0x6b | P_EXT | P_DATA16) #define OPC_PACKSSWB (0x63 | P_EXT | P_DATA16) #define OPC_PACKUSDW (0x2b | P_EXT38 | P_DATA16) @@ -2741,6 +2744,10 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, static int const sars_insn[4] = { OPC_UD2, OPC_PSRAW, OPC_PSRAD, OPC_UD2 }; + static int const abs_insn[4] = { + /* TODO: AVX512 adds support for MO_64. */ + OPC_PABSB, OPC_PABSW, OPC_PABSD, OPC_UD2 + }; TCGType type = vecl + TCG_TYPE_V64; int insn, sub; @@ -2829,6 +2836,11 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, insn = OPC_PUNPCKLDQ; goto gen_simd; #endif + case INDEX_op_abs_vec: + insn = abs_insn[vece]; + a2 = a1; + a1 = 0; + goto gen_simd; gen_simd: tcg_debug_assert(insn != OPC_UD2); if (type == TCG_TYPE_V256) { @@ -3206,6 +3218,7 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_dup2_vec: #endif return &x_x_x; + case INDEX_op_abs_vec: case INDEX_op_dup_vec: case INDEX_op_shli_vec: case INDEX_op_shri_vec: @@ -3283,6 +3296,8 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_umin_vec: case INDEX_op_umax_vec: return vece <= MO_32 ? 1 : -1; + case INDEX_op_abs_vec: + return vece <= MO_32; default: return 0; From patchwork Wed May 1 05:05:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163204 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4134215ill; Tue, 30 Apr 2019 22:27:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMm5fDDtj5AzirpKPpbW7ZCWnclmw97nLWk6nRghO5SoPEmr1z3yDrg6oNvjK1bvT0eM82 X-Received: by 2002:adf:e546:: with SMTP id z6mr4458362wrm.287.1556688423122; Tue, 30 Apr 2019 22:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688423; cv=none; d=google.com; s=arc-20160816; b=DO7GUleSo4JF2YYH2EjHsokfqRGa5BlYb6v/N/O134iDMg4gEwQsm1G2mktQ7f4X/K gylvEES79NxqosExtdAXEOsbXuvvadjnq5a621ojv5oJXWLRI6CLgP6peyb9KR5GyV/R GoazfCAuCWRlwnbZ58+b7QgEMDjBCof47xQsHVSYZ26vUoNOQdZmnvVnmtAGYihVkhCu qSKUfrRyLtDLSch1abOY96Mv5OpTscbTGN31HJxT6YyxA/Rsdc4q8go8g1t+diIW6+zT a5u8ROp4FQO1bKhr1jziPgihyJyikf7kVRUyXp4flQHkeFdTrmlHlil1EBNgBjog2bGW +UTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bE8JSPvg4RBd27AfEYsxgw0WnHCLv0Zk1q+/NsO1CmM=; b=KRUc2saaRJNdBGnAiRtr3qNLunEpRxRR3tHh/W6hB81hNlzs2/rFTceDxJhzDGmxPA zP774+v1mYyT7kQpxWsRLAk51S2fv8QIlD8mUHvaJ6p9HRJLbdaKJZNPWCa8G2Whjehh 2+skTyt/gzzT2T+eQ4twDcslIwWZzgdsd4j9RxK31/MO460ZM47OWdKYDL3fLsEm/fTc zggX85BmcbHR/YdfU5/d5hare7JzlQapPv5fjvlZaTJQMC0m9VG+SXeNfzf31HJGv/Pv kk7h5oJcKH4fVEuLp5LWA6a4fFc5Dt+fLgG3bbnxtlTc6tpAMtZnQhZh0AhpQ+HPGss2 pkPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gKoRIBrE; 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 l10si8688142wrp.239.2019.04.30.22.27.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:27:03 -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=gKoRIBrE; 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]:36586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhlm-0007gU-61 for patch@linaro.org; Wed, 01 May 2019 01:27:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRi-0006i2-Vg for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRf-00032e-0p for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:18 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:45893) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRd-000317-OX for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:14 -0400 Received: by mail-pg1-x541.google.com with SMTP id i21so4414981pgi.12 for ; Tue, 30 Apr 2019 22:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=bE8JSPvg4RBd27AfEYsxgw0WnHCLv0Zk1q+/NsO1CmM=; b=gKoRIBrEw0+91rlVQu7QJGYH2DLmv4C/UHU1dl0NdT58C0KtdRquue3JZIcJGtlnl4 KKBLDolHHckRR4CbtpGf3IO5vLGjvzOhW6y6EyBfxiPoEHyTjbXti8TwCY6O8IQQjjkz UWjSMO+223J7dO2LB7LiXT3uqLUtuZQ01Tbv+w/+hg07qygrdIfVnK4q6nlW8u8XEGDc zCgh/eUzNH9g/NEvvOCtGLoM6fUFtWrUzv39lKmcGP9CUXQ4S8wRovhSg5QO3XOGfbfk r29/YycDRRHSSxMZb5HLy/quz9C2P3E4XI++bCMAljIvEQy9qLFH072fDcy4Q9ITA0G3 QteA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=bE8JSPvg4RBd27AfEYsxgw0WnHCLv0Zk1q+/NsO1CmM=; b=Q3HtffVJmVb32+vy9Oj3We9hbZNjqBNBrhuOSrv3pPJ+wQUJrq6Q2oi9+rdVUSVmHF P+6nX6txm6E1Ii2ZTS3QCKJ8PRNJ+niJ9ziBDd07gtxsycXBjhPlDPG9GQvzDhmar6ZE deC8vIRcH1q5uS6zU4PqqtLa604jDRlBIhMt5VrX6Fz/pK61bqyaBRo0JlciH4XClF+Q Llb9pqJQUlNIYTazL9yropIWhcSy47y8k8wQH1UOKqDgJE4CGrCu3q2faXo1A8Sy48kY eLhRCo8BF17C18put337KM+b4+VssZTwnZY0w0r9RKU6nsukMc51RvGmqUSNZPdXwkWb hWMA== X-Gm-Message-State: APjAAAV+xNmu1zEf47mL/ipczLPnQnmp/OUrqrHMLOIi8uvJQOfdFp/p gcwyVLZkArfdYGL6k2M+zU+HJA4SLso= X-Received: by 2002:aa7:8212:: with SMTP id k18mr75367635pfi.50.1556687171202; Tue, 30 Apr 2019 22:06:11 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:29 -0700 Message-Id: <20190501050536.15580-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v2 22/29] tcg/aarch64: Support vector absolute value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 +- tcg/aarch64/tcg-target.inc.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 21d06d928c..e43554c3c7 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -132,7 +132,7 @@ typedef enum { #define TCG_TARGET_HAS_orc_vec 1 #define TCG_TARGET_HAS_not_vec 1 #define TCG_TARGET_HAS_neg_vec 1 -#define TCG_TARGET_HAS_abs_vec 0 +#define TCG_TARGET_HAS_abs_vec 1 #define TCG_TARGET_HAS_shi_vec 1 #define TCG_TARGET_HAS_shs_vec 0 #define TCG_TARGET_HAS_shv_vec 1 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 61c2dbbff2..e7f8d96e21 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -554,6 +554,7 @@ typedef enum { I3617_CMGE0 = 0x2e208800, I3617_CMLE0 = 0x2e20a800, I3617_NOT = 0x2e205800, + I3617_ABS = 0x0e20b800, I3617_NEG = 0x2e20b800, /* System instructions. */ @@ -2209,6 +2210,9 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_neg_vec: tcg_out_insn(s, 3617, NEG, is_q, vece, a0, a1); break; + case INDEX_op_abs_vec: + tcg_out_insn(s, 3617, ABS, is_q, vece, a0, a1); + break; case INDEX_op_and_vec: tcg_out_insn(s, 3616, AND, is_q, 0, a0, a1, a2); break; @@ -2320,6 +2324,7 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_andc_vec: case INDEX_op_orc_vec: case INDEX_op_neg_vec: + case INDEX_op_abs_vec: case INDEX_op_not_vec: case INDEX_op_cmp_vec: case INDEX_op_shli_vec: @@ -2563,6 +2568,7 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) return &w_w_w; case INDEX_op_not_vec: case INDEX_op_neg_vec: + case INDEX_op_abs_vec: case INDEX_op_shli_vec: case INDEX_op_shri_vec: case INDEX_op_sari_vec: From patchwork Wed May 1 05:05:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163200 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4132254ill; Tue, 30 Apr 2019 22:23:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqznykczDgwmjhAQJjZkQeXZp7i89bGGZPm26xfZ9zTuVDlvrHn6SfA9QwEPQpRd3eKuFZdd X-Received: by 2002:a1c:4e0a:: with SMTP id g10mr5528334wmh.128.1556688235390; Tue, 30 Apr 2019 22:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688235; cv=none; d=google.com; s=arc-20160816; b=nWqty5jM+cO7Kfr5q9RE8ofEXKE1YO1pjviTKTCnmqvMUzwRAQ6Z4T18U7CbVJ4356 8o91cTwTRBG/61FEOe7klZQrEe9zwWIU6BW/uDye2FpenYC+KygTff0euyFG0AcUBfdb EUTWH+fu29C3C1K2iLsVryAIz5mFzleI8bBU3ofTkCMiQ1al8v2UBlAz7TcOM/zuiy1D KVPmgehE8pC68wwJYUykyjpL8FtAQ/IlXxwiQeHiZwlpGsUdaGH/5Z1GBixNk5RWz0WM ZPYo3XA1wAuCSqEahrrBRPPjMGjA7rCR0HH2hXW4hlRbR55NAHIjgBwiVXRsrHHCOyCR NLPw== 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=GK5T8TUAA6xMhA0uujHB1WR5ozdMZ1Gai/FihBIFRjU=; b=RT7MX9vdX0HeViuDIE/WmEiMbBPKv5b98kOPoBW27nr+j8XNP29eOFst1Tn0uUlZMT j0iz0Ef8FhUafRjMLx6osXtDopxs+DYUiPVHDzU73Xnj3IoqeFS9D1uenW0zReP6zegw equSOTED7AE8jEDbLt+S6n3jlg5spLp7XYu9yWFqHQyUzNlJzpd9bh0ScXE5Ka95jjPe 4S+Ql3gtBA7Mpm2svr2nqupJ3559NuZvr5nMckCTKvwPvSwvPh8EkzKqDAUmnZ9iEk6c 1Z3q8n9Cu6vxdEpq/GP2ZpOsdUJk7/kgU9yM2sNZV8kWv6oLTyXseSDIcD6YYd/K/AP5 +NPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Kg37+qqw; 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 x13si6627747wro.438.2019.04.30.22.23.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:23:55 -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=Kg37+qqw; 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]:36475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhik-0004fF-7Y for patch@linaro.org; Wed, 01 May 2019 01:23:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRi-0006i3-Vl for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRf-000338-BO for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:18 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:35203) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRf-00031w-5J for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:15 -0400 Received: by mail-pl1-x635.google.com with SMTP id w24so7779410plp.2 for ; Tue, 30 Apr 2019 22:06:13 -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=GK5T8TUAA6xMhA0uujHB1WR5ozdMZ1Gai/FihBIFRjU=; b=Kg37+qqwt23sxxLC25Jlm/8oz42sO90MVD6E1GHCAgXl9sO1mRgIWVC1xMv8VNu7N7 /cSRxfCml9FK08vib+Y1jKhMFsoxkwdIQhWfQ9eTrSwBkbPcm1m4SRG0+jiev+Jyuib9 O+hIsZE2zdNMWJyRGiUqIZICS0peybP1BfyQaCpmfaCgmvoK9dTWX5Pyq3CW5xi6n0Cj lAMhFtktPvnRLetC5kv2/b8wE3leb2SxnQv1ZQtJFr9VUuij9FP0E6WZp1D9asLfCKu+ Be++Y1rKc8jHfAoOiQaqVrVTdoQ+rKuQQQ/fiBl42R2qJ3hyw1r/A/xCd4Q8dvyuTppr Nuvw== 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=GK5T8TUAA6xMhA0uujHB1WR5ozdMZ1Gai/FihBIFRjU=; b=eLlQev22D8WPfM5lC5GQ/+0vu0vr2bySnngLLzxL2g6iauEHU3y7pOb3gYy7CYZXC6 PBf4UJsmoPRtvEyz48nuBvTu8brXxAu/Ug+1gXhzLxQ2hqcoP5DLzXeN9FP/vW3W6atU 7YU8Plrb6L9a1sz2fuvYxMktQ0iryatorS7WrK2Wl2NRBnkkcZFIyEjnsCde0HFZTWyz W/hJPq+OZB5cib6iJ1m83DiV14Mgh4zwRomBkc80n9GcVW1wP2PjXt6/grxnfHdS3a+E o/QgBDZe7UwCk0ozwQMPzIzVGxgJRFqXAEa+gKuno7jxq+hXnvjnN0QU0sOM9iUVCuJM TTWg== X-Gm-Message-State: APjAAAW5spYuZj8P1L/YcGhTe9KytZw1eYTXD0bq4coUUSlFUSQvKh8G tTz5sWppzgfACIDpXQVdyjmjWjNs2PQ= X-Received: by 2002:a17:902:6bc2:: with SMTP id m2mr75115231plt.194.1556687172721; Tue, 30 Apr 2019 22:06:12 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:30 -0700 Message-Id: <20190501050536.15580-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::635 Subject: [Qemu-devel] [PATCH v2 23/29] target/arm: Use tcg_gen_abs_i64 and tcg_gen_gvec_abs 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: Peter Maydell , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-arm@nongnu.org Cc: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.h | 2 -- target/arm/neon_helper.c | 5 ----- target/arm/translate-a64.c | 41 +++++--------------------------------- target/arm/translate.c | 11 +++------- 4 files changed, 8 insertions(+), 51 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/target/arm/helper.h b/target/arm/helper.h index 50cb036378..132aa1682e 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -352,8 +352,6 @@ DEF_HELPER_2(neon_ceq_u8, i32, i32, i32) DEF_HELPER_2(neon_ceq_u16, i32, i32, i32) DEF_HELPER_2(neon_ceq_u32, i32, i32, i32) -DEF_HELPER_1(neon_abs_s8, i32, i32) -DEF_HELPER_1(neon_abs_s16, i32, i32) DEF_HELPER_1(neon_clz_u8, i32, i32) DEF_HELPER_1(neon_clz_u16, i32, i32) DEF_HELPER_1(neon_cls_s8, i32, i32) diff --git a/target/arm/neon_helper.c b/target/arm/neon_helper.c index ed1c6fc41c..4259056723 100644 --- a/target/arm/neon_helper.c +++ b/target/arm/neon_helper.c @@ -1228,11 +1228,6 @@ NEON_VOP(ceq_u16, neon_u16, 2) NEON_VOP(ceq_u32, neon_u32, 1) #undef NEON_FN -#define NEON_FN(dest, src, dummy) dest = (src < 0) ? -src : src -NEON_VOP1(abs_s8, neon_s8, 4) -NEON_VOP1(abs_s16, neon_s16, 2) -#undef NEON_FN - /* Count Leading Sign/Zero Bits. */ static inline int do_clz8(uint8_t x) { diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9dcc5ff3a3..b7c5a928b4 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -9468,11 +9468,7 @@ static void handle_2misc_64(DisasContext *s, int opcode, bool u, if (u) { tcg_gen_neg_i64(tcg_rd, tcg_rn); } else { - TCGv_i64 tcg_zero = tcg_const_i64(0); - tcg_gen_neg_i64(tcg_rd, tcg_rn); - tcg_gen_movcond_i64(TCG_COND_GT, tcg_rd, tcg_rn, tcg_zero, - tcg_rn, tcg_rd); - tcg_temp_free_i64(tcg_zero); + tcg_gen_abs_i64(tcg_rd, tcg_rn); } break; case 0x2f: /* FABS */ @@ -12366,11 +12362,12 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) } break; case 0xb: - if (u) { /* NEG */ + if (u) { /* ABS, NEG */ gen_gvec_fn2(s, is_q, rd, rn, tcg_gen_gvec_neg, size); - return; + } else { + gen_gvec_fn2(s, is_q, rd, rn, tcg_gen_gvec_abs, size); } - break; + return; } if (size == 3) { @@ -12438,17 +12435,6 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) gen_helper_neon_qabs_s32(tcg_res, cpu_env, tcg_op); } break; - case 0xb: /* ABS, NEG */ - if (u) { - tcg_gen_neg_i32(tcg_res, tcg_op); - } else { - TCGv_i32 tcg_zero = tcg_const_i32(0); - tcg_gen_neg_i32(tcg_res, tcg_op); - tcg_gen_movcond_i32(TCG_COND_GT, tcg_res, tcg_op, - tcg_zero, tcg_op, tcg_res); - tcg_temp_free_i32(tcg_zero); - } - break; case 0x2f: /* FABS */ gen_helper_vfp_abss(tcg_res, tcg_op); break; @@ -12561,23 +12547,6 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) tcg_temp_free_i32(tcg_zero); break; } - case 0xb: /* ABS, NEG */ - if (u) { - TCGv_i32 tcg_zero = tcg_const_i32(0); - if (size) { - gen_helper_neon_sub_u16(tcg_res, tcg_zero, tcg_op); - } else { - gen_helper_neon_sub_u8(tcg_res, tcg_zero, tcg_op); - } - tcg_temp_free_i32(tcg_zero); - } else { - if (size) { - gen_helper_neon_abs_s16(tcg_res, tcg_op); - } else { - gen_helper_neon_abs_s8(tcg_res, tcg_op); - } - } - break; case 0x4: /* CLS, CLZ */ if (u) { if (size == 0) { diff --git a/target/arm/translate.c b/target/arm/translate.c index b25781554f..dd053c80d6 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8120,6 +8120,9 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) case NEON_2RM_VNEG: tcg_gen_gvec_neg(size, rd_ofs, rm_ofs, vec_size, vec_size); break; + case NEON_2RM_VABS: + tcg_gen_gvec_abs(size, rd_ofs, rm_ofs, vec_size, vec_size); + break; default: elementwise: @@ -8225,14 +8228,6 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) } tcg_temp_free_i32(tmp2); break; - case NEON_2RM_VABS: - switch(size) { - case 0: gen_helper_neon_abs_s8(tmp, tmp); break; - case 1: gen_helper_neon_abs_s16(tmp, tmp); break; - case 2: tcg_gen_abs_i32(tmp, tmp); break; - default: abort(); - } - break; case NEON_2RM_VCGT0_F: { TCGv_ptr fpstatus = get_fpstatus_ptr(1); From patchwork Wed May 1 05:05:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163202 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4133926ill; Tue, 30 Apr 2019 22:26:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxn6xq96ygIWZhVEq7SyRGjSc67l1lmaKFENBEP9RjnvlZPMsTcuSIQePXOcAqQuKFhW5KM X-Received: by 2002:a1c:4905:: with SMTP id w5mr5741870wma.88.1556688395197; Tue, 30 Apr 2019 22:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688395; cv=none; d=google.com; s=arc-20160816; b=FQ4NjB5Hc1rHB/43YjGnll8KNWdRHQuMFtDUDA0jjL0x9bdmvNOOqE1S2+A4qRFC1i 6GuRtqfupOp+7ZZWS9eJOpLUW+MAMT2Q4ysLI3mfAG/cf/DP6lR/UFVQqhBWwtfsilwa /PbcOyNJdgnEM1qzX9FM9NclYxe9lj+NAGCSA79aMMnvQilOVYsp+9TJDBmVOzQYmBpZ vuXy1SZpM/LeOEHibfBauVVeho9jTicSUMN64wHODprI0hHWmGijt1SeyhT3MZSHY4MF Hi2VmSY1aLs1WfpXLzVJmFpIER33widjscHEt9jcKIo2rC3keDtnHEKxe1ITObv72bf1 gcVw== 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=o7dnHbCu/TOAfn/7tUi0VRqfElXssoeZ/3G17tDL/UE=; b=eULiCQIs8dTLsqIrP0hywWYyeeTFA4jlt/tP4L24rbk2VMrSwxvZb5Un/sNsodkJz2 2xNWorsR4dEmDcyMq25/7x3QLsoxsP092LrLytGfj/BscTuXUFRKs6YMEOMNWyJvf2GA Svc4j0uatJsa5tnMIkvCVy2X4/RoAx0zc5aH4sHEns5ttzmR972kLu/Bt4RbpCww94a8 BqXlFFCLA0E863i+SbY3JeFjwrRFrGYd27no43W2QLUgD6vcR/xQzlUAqCo8oeqfmYBR Z3+twP+79VxqcJuv4Y3rHo8/IHJCZwyJrU7EVb63Ipo0Kux+ZeFskSYQhJ/Gh4me+eOT YzFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rD5TVTu8; 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 r67si2792094wme.59.2019.04.30.22.26.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:26: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=rD5TVTu8; 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]:36556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhlK-0007VC-6L for patch@linaro.org; Wed, 01 May 2019 01:26:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRj-0006iz-Rr for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRg-00033l-R4 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:19 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:34458) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRf-00032O-Aj for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:15 -0400 Received: by mail-pf1-x443.google.com with SMTP id b3so8157055pfd.1 for ; Tue, 30 Apr 2019 22:06:15 -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=o7dnHbCu/TOAfn/7tUi0VRqfElXssoeZ/3G17tDL/UE=; b=rD5TVTu8vbSfOONYe6q+d/y+JZUCAh+eYDr1aZoENSAEpIjjVpMI40OxitBrozIGYD CcwmaFHMNMCcfZwzFAHO3TRgRsU1JSppr8y74wMvmMBNEQ7NyzfRyymVKdFT355xoBRL kiolSWCcvg7sh+N7PKfvtniwGHC6zAE+wQ98yVL49jecl55/j4u6xjul25sKUBnKnp++ /5utHI4MG9km1+pl6W8b/L12riTDg8YVDNS0mvMIx4BQ2C+UjLrZ7ksl+4KVb38cpm/F 6C+bCTgj2kUqZOiI9bZIvMMAZH76SIO93E1yromtPefBNmV89zkcHUBIIAr84qnXmRGX xhMQ== 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=o7dnHbCu/TOAfn/7tUi0VRqfElXssoeZ/3G17tDL/UE=; b=KAhOJJmx70LBb5pobDLPRGUILhoY7wtTeNSrwUVLIm9DOE6BqTq/Qz8LquKGPQlQY9 1IDzwolbC4Ecd37AgheESYUS/G2p+Vahdw/zedj+79DMV/D1ChCpWrcSjuwxQ4PmMQBe 2yPX5nL8qWfdJ5EPPc4n40+1yGoh8/67yK0ewCy6qbVkaw88v5MzTE7d2YT1ETSa9atz MVZ8h5og0UHVpWgHMfiiXa34t873IBGwkjlxiA4pbUIS8zLVwr0mzK0NNrCmm9V12mmT oHjHY3ZzwjyYLlySaRgZ5dPLgpOfWfDH33FMMyWYpxY4v5IJi2lx8V+NQ1bGO1I1b1uH 8/xg== X-Gm-Message-State: APjAAAWa1CVHY++EnvzUlLD6TtRWDUNmRTe63ZUSbteAhi0Dc+UOaF8T COlh0HMpylFs1HeLiplGePG/rr1fjTE= X-Received: by 2002:aa7:82cb:: with SMTP id f11mr29661988pfn.0.1556687173985; Tue, 30 Apr 2019 22:06:13 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:31 -0700 Message-Id: <20190501050536.15580-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v2 24/29] target/cris: Use tcg_gen_abs_tl 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: "Edgar E . Iglesias" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Edgar E. Iglesias Signed-off-by: Richard Henderson --- target/cris/translate.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) -- 2.17.1 diff --git a/target/cris/translate.c b/target/cris/translate.c index b005a5c20e..31b40a57f9 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -1686,18 +1686,11 @@ static int dec_cmp_r(CPUCRISState *env, DisasContext *dc) static int dec_abs_r(CPUCRISState *env, DisasContext *dc) { - TCGv t0; - LOG_DIS("abs $r%u, $r%u\n", dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); - t0 = tcg_temp_new(); - tcg_gen_sari_tl(t0, cpu_R[dc->op1], 31); - tcg_gen_xor_tl(cpu_R[dc->op2], cpu_R[dc->op1], t0); - tcg_gen_sub_tl(cpu_R[dc->op2], cpu_R[dc->op2], t0); - tcg_temp_free(t0); - + tcg_gen_abs_tl(cpu_R[dc->op2], cpu_R[dc->op1]); cris_alu(dc, CC_OP_MOVE, cpu_R[dc->op2], cpu_R[dc->op2], cpu_R[dc->op2], 4); return 2; From patchwork Wed May 1 05:05:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163193 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4128417ill; Tue, 30 Apr 2019 22:18:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBMXkocLN/ONHUnUaaZ3lulqSCdd6BcWKsOO3cOFXsp7oOB8UVmaz9MaFcgBlbZ7bz3dhe X-Received: by 2002:a05:600c:2506:: with SMTP id d6mr2882599wma.106.1556687881369; Tue, 30 Apr 2019 22:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556687881; cv=none; d=google.com; s=arc-20160816; b=SVId69EhPeb0R/abH+vUbpsvACX60ahDt23poEaPp0Q2vZ66VpGmT6H+c9VSB07Soc yfZc1bVVrr43zMUG2iE0g+NOrjvLUxRbIIuAfnfIWENWDuUN5rp/oy0VX+TjtkCn6Axv G40Wots4Sxa8zfjg7JX+Cc/mGyv9Ga3dQVJQ0f4KWUNKZIYLvmdfO/kc94FaqgB3UN1C UlUn22r1Je6V6cCddqufsqBdGVUOvqnHK8MQgwmKRHHfV4NwBkSV2ao1MTQgUeieSAbJ ghMW2vXJG8gRQHtBuDupzXL28FmKaKNqzWdQUH4rBPhOIBtIavQDHaGeyk1rrWx/9/sI htBg== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=FH8HIUisgKxx/wO5rpgn7QNUU9WJqnDYvJ4xHC9+spw=; b=rhHgHIh+nW/eDMWFab5XOveciqaquqR5fZGddzb/JTvDHnRDVUxfYxulDpoKMFyRTU I8RUSr1wdqpk+z/4eM5GFL/Z4MrovjtX5zZgjNh5l7nKOn4yUYweOP8JHfVTyndvPRpv ku5LwHvOwuZduq0pwzqGHpJ+Lv3cZAdSZOPSaro2AkmB/TTqNupS0qiJ37iEY9GioVM/ 8amsw4JmQgqbk6+J/gYLg29+ii6YhB9C9URaYDnjA+ga+B82RdQ2OZRP7gUhSmr0DgPL RVr1+PwHyM9ZHMpEiX2ETmPFhmIFcYHXyLT5vek7TCCLT0j974bkbSjworZtCUXtTFJk VfCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Typa60c+; 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 n16si2647208wmh.3.2019.04.30.22.18.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:18: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=Typa60c+; 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]:36381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhd2-0008AL-3P for patch@linaro.org; Wed, 01 May 2019 01:18:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRk-0006jC-3K for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRh-000344-1q for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:20 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:44934) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRg-00033F-SZ for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:16 -0400 Received: by mail-pg1-x541.google.com with SMTP id z16so7854964pgv.11 for ; Tue, 30 Apr 2019 22:06:16 -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 :mime-version:content-transfer-encoding; bh=FH8HIUisgKxx/wO5rpgn7QNUU9WJqnDYvJ4xHC9+spw=; b=Typa60c+Z3EIomuumJgdLEIvLgoW18goDviL8Ikh1kRgWYGsKBSfLvyrKklGaMeYn4 V49XvPlDOJJ/tL5Lwl/dhmEplZEYbYTS29l0NX0oyMB+22i21Lkobh5JOuJFn5fQoua4 vH6Bh96ZezD0wnTGWT86/qvUv86dubLrWDAyToa7J4H1VQbvyZuPCFuze3krvQiFABSm DWcUAPacFj9wtnnmrfDOK2lbj1y//Vj9lL+3B2v/cYqyP+wVHZhdAfLCwGhsFhAPUwPg wM00QsbpJ6m1RqaN8/DA8/gmFhwDiOtjAYfiCkPTqoqPOwvJeg+wT/lPwrbWtK3uaY70 0zlw== 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:mime-version:content-transfer-encoding; bh=FH8HIUisgKxx/wO5rpgn7QNUU9WJqnDYvJ4xHC9+spw=; b=pu/DKOmE7CoCrUWFm2Sh428/mhZU53kDAyY+zatzPr0BYvNAVq0qM10XfvOZophs+1 t/fhvzKDcoaRqtcfKh5x88rfsOyQ7ZFfWW4ZEZM8v/NSM0C/9wYluh4fvt9G9pqIk846 94AlUimVzE7tA5/PgyEWxniitv/u7g0jhuZS0uTD8WU6aiVPEkAEvCtWO0gIHXSTJpC6 Vz9q0loy1BnmxVcE0JOWkBd7rijewQx9bkPvbp4o1QwTeVBHsvEG/QX9pVtfMvLkxlJF 01uL3TCtEyzbEhtEAyajcT5cy8GrPLeRqXwdfpW5JlRapd/C042KJIZE+uEaJB4SfnZQ ULvA== X-Gm-Message-State: APjAAAV2WeTvc3krc38+CH2a6gMBkP9xTULFEdK3YahiYhovNMMHGER1 EYqaFlSb1WaLxcgZI3EwJ6qwDP4fcnw= X-Received: by 2002:aa7:9aaa:: with SMTP id x10mr33551672pfi.225.1556687175197; Tue, 30 Apr 2019 22:06:15 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:32 -0700 Message-Id: <20190501050536.15580-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v2 25/29] target/ppc: Use tcg_gen_abs_i32 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190423102145.14812-2-f4bug@amsat.org> Signed-off-by: Richard Henderson --- target/ppc/translate/spe-impl.inc.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) -- 2.17.1 diff --git a/target/ppc/translate/spe-impl.inc.c b/target/ppc/translate/spe-impl.inc.c index 7ab0a29b5f..36b4d5654d 100644 --- a/target/ppc/translate/spe-impl.inc.c +++ b/target/ppc/translate/spe-impl.inc.c @@ -126,19 +126,7 @@ static inline void gen_##name(DisasContext *ctx) \ tcg_temp_free_i32(t0); \ } -static inline void gen_op_evabs(TCGv_i32 ret, TCGv_i32 arg1) -{ - TCGLabel *l1 = gen_new_label(); - TCGLabel *l2 = gen_new_label(); - - tcg_gen_brcondi_i32(TCG_COND_GE, arg1, 0, l1); - tcg_gen_neg_i32(ret, arg1); - tcg_gen_br(l2); - gen_set_label(l1); - tcg_gen_mov_i32(ret, arg1); - gen_set_label(l2); -} -GEN_SPEOP_ARITH1(evabs, gen_op_evabs); +GEN_SPEOP_ARITH1(evabs, tcg_gen_abs_i32); GEN_SPEOP_ARITH1(evneg, tcg_gen_neg_i32); GEN_SPEOP_ARITH1(evextsb, tcg_gen_ext8s_i32); GEN_SPEOP_ARITH1(evextsh, tcg_gen_ext16s_i32); From patchwork Wed May 1 05:05:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163201 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4133700ill; Tue, 30 Apr 2019 22:26:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhfKzQ4MuZSeNDQob5xV9Hw++IfYZZ2euJY1j0t9tCAewkM+N1fB+hMDU9W4kma6KIzjD0 X-Received: by 2002:a5d:52c4:: with SMTP id r4mr36949590wrv.79.1556688371861; Tue, 30 Apr 2019 22:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688371; cv=none; d=google.com; s=arc-20160816; b=lJt8ow6W60UZgLqod9OM97azv6lqkhuSLYo4NRAL19Gm3/C93y8gI0V2/prDpNnbb3 aS87uU5qXv+xQPIoJF/Rg8sFKZaZ4oH199qXhNmKNt6lnvjJZxw2KoAxbwlNIGr8faE9 r4uZz6YsArkJD/6Ri+ZNZHc8BtPIne2zvrAdFZq+J75JF5Lzdk9DapIDzuTwQjWeMMGn dSdxNRf/t6QIujmhoz6ZPXNKBSNVmiYJrwlAvva2gLQJf7hImhMFRNGIkbfZCmzFJHBw SZrALNzIxA3F2Sfd2qRfKuU95fRJZGpJKIgFIDtkxUBs2u02YQ1xx/q8W/D/oeCpV3Po 4A5Q== 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=lPp9ip0cQ55VftFpGYXkoRqMh2/FWH1IUHTaHYTSufE=; b=QYYp4y98x1eHuNGDuIKki8UemFB65aBcwB5EHJzgkMH4PHRjjCj0NCt7GrmVR+tQvK 31tXKaeHxGnFUSI0JDDxRSQA1z0Fqr7ijyGi+s02z6+/Lc76YRoAmTtvQMpmRlzKaa8Z 6YhQYhZIKPGBEUrteVPUKCrDiv2YaJIdi1hI7Q33NdLJ+OkmgxJcXMuQTYOcWJlhkKK+ 1WLzp0SMZm+nrjDz4QlorQ+r8F1UYUiwE76uYJJkiP6tMRHNI/mhryOfQBs5wG1Lhnpq 93HIDi7xeErLiMx39VfHJRmrndPrd4Pn0q4KVrQCguCepSFmoJQVwKxCn21+gOfEHySe tvhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KBDC2y8h; 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 15si1082163wmp.105.2019.04.30.22.26.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:26:11 -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=KBDC2y8h; 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]:36530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhkw-0007DQ-Rg for patch@linaro.org; Wed, 01 May 2019 01:26:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRm-0006lM-5u for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRj-00035R-44 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:22 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:39218) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRi-00033z-UW for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:19 -0400 Received: by mail-pl1-x641.google.com with SMTP id e92so7750692plb.6 for ; Tue, 30 Apr 2019 22:06:17 -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=lPp9ip0cQ55VftFpGYXkoRqMh2/FWH1IUHTaHYTSufE=; b=KBDC2y8hv9ok5CTyFuwYt0KAHGVpU2qnT4wC4qETyqvnjGgobEVz0OFYyU5xxaOMR0 bfeYGiISl6LPpuQtt28rEWmeyNVLQjoq+daKlFv/7Q7o9ZlamTBhyQCV7v5/jqa/1gdl SR0bLmsB1bKqfDgYpF4cjAVQxh6CXGY5UiJLkkwhOxkco5gKnE2yT6Y//rFsShBL7W0O 5V+Wv+m/EyLtCgO1T13RoazsAthfsNXZKVpZkDXcwEvDSmV3FQJwyDZMCI1O3tJOyJA0 VFjnqsNQH0ikcCn2TvCBH0hLJ1LL9/aSmKLRHeCNuZm+zEw7LISqWZjTFa2w5imabQ8p WmqA== 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=lPp9ip0cQ55VftFpGYXkoRqMh2/FWH1IUHTaHYTSufE=; b=VBe6ovllVbZul3722umUJdXSckKLihIJR4gZx6UAZaTCTQ96bUN146ixhzqv41m5Pl IRnwOJT8GZNRTL1JqHbSkH5PHSObHI9bCKQno0RGYX/SZsj4X7avor46rQdohvoHK3D0 /yfc6+IyOGK8aManRqp1VrAuIhiIoq9Wbb6qH8KN0XsqEygnZVv2eqO7zB/KzIW6WKL0 EyabbqGZmIyObMVfd+6cZ4+MFXurrpNzxv/veimP5fsCIJQVyQyDWSyhQShqyjH0ZFtH 19xzj8Z/ISMXBGNQoedYRYCsR7alC/ddJ5h3LLuCOar4VukuiXX/XIsvZJrtjV3Fbjhy T6dg== X-Gm-Message-State: APjAAAUX7njHER9Ao5adLgRVJB+hOp4RuEjW7DOdT9+Oto4QHDhRAn0h 07PGNGJ0wZFX08KkxQebw8hL6f0zKW0= X-Received: by 2002:a17:902:b10c:: with SMTP id q12mr38637184plr.254.1556687176259; Tue, 30 Apr 2019 22:06:16 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:33 -0700 Message-Id: <20190501050536.15580-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v2 26/29] target/ppc: Use tcg_gen_abs_tl X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: David Gibson Signed-off-by: Richard Henderson --- target/ppc/translate.c | 68 +++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 44 deletions(-) -- 2.17.1 diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 8d08625c33..b5217f632f 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -5075,40 +5075,26 @@ static void gen_ecowx(DisasContext *ctx) /* abs - abs. */ static void gen_abs(DisasContext *ctx) { - TCGLabel *l1 = gen_new_label(); - TCGLabel *l2 = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rA(ctx->opcode)], 0, l1); - tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_br(l2); - gen_set_label(l1); - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - gen_set_label(l2); + TCGv d = cpu_gpr[rD(ctx->opcode)]; + TCGv a = cpu_gpr[rA(ctx->opcode)]; + + tcg_gen_abs_tl(d, a); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, d); } } /* abso - abso. */ static void gen_abso(DisasContext *ctx) { - TCGLabel *l1 = gen_new_label(); - TCGLabel *l2 = gen_new_label(); - TCGLabel *l3 = gen_new_label(); - /* Start with XER OV disabled, the most likely case */ - tcg_gen_movi_tl(cpu_ov, 0); - tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rA(ctx->opcode)], 0, l2); - tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[rA(ctx->opcode)], 0x80000000, l1); - tcg_gen_movi_tl(cpu_ov, 1); - tcg_gen_movi_tl(cpu_so, 1); - tcg_gen_br(l2); - gen_set_label(l1); - tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_br(l3); - gen_set_label(l2); - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - gen_set_label(l3); + TCGv d = cpu_gpr[rD(ctx->opcode)]; + TCGv a = cpu_gpr[rA(ctx->opcode)]; + + tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_ov, a, 0x80000000); + tcg_gen_abs_tl(d, a); + tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, d); } } @@ -5344,34 +5330,28 @@ static void gen_mulo(DisasContext *ctx) /* nabs - nabs. */ static void gen_nabs(DisasContext *ctx) { - TCGLabel *l1 = gen_new_label(); - TCGLabel *l2 = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_GT, cpu_gpr[rA(ctx->opcode)], 0, l1); - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_br(l2); - gen_set_label(l1); - tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - gen_set_label(l2); + TCGv d = cpu_gpr[rD(ctx->opcode)]; + TCGv a = cpu_gpr[rA(ctx->opcode)]; + + tcg_gen_abs_tl(d, a); + tcg_gen_neg_tl(d, d); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, d); } } /* nabso - nabso. */ static void gen_nabso(DisasContext *ctx) { - TCGLabel *l1 = gen_new_label(); - TCGLabel *l2 = gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_GT, cpu_gpr[rA(ctx->opcode)], 0, l1); - tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - tcg_gen_br(l2); - gen_set_label(l1); - tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); - gen_set_label(l2); + TCGv d = cpu_gpr[rD(ctx->opcode)]; + TCGv a = cpu_gpr[rA(ctx->opcode)]; + + tcg_gen_abs_tl(d, a); + tcg_gen_neg_tl(d, d); /* nabs never overflows */ tcg_gen_movi_tl(cpu_ov, 0); if (unlikely(Rc(ctx->opcode) != 0)) { - gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); + gen_set_Rc0(ctx, d); } } From patchwork Wed May 1 05:05:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163197 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4130575ill; Tue, 30 Apr 2019 22:21:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1zXpqBkur4zepA3AwVTR51OItHw393nADbPGjQyoGiiKew9SfztBSWLkaRepi9bSdsdfw X-Received: by 2002:a1c:7518:: with SMTP id o24mr5355997wmc.42.1556688068953; Tue, 30 Apr 2019 22:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688068; cv=none; d=google.com; s=arc-20160816; b=zMXcu7yvOBUt6DupSLsA2SjmJgyE/kqI0Ql6AQTR7UFvwNu8N96KWvaDkRXLYsOMtX k/E804Ebm5rVqVdmX2BlPUn+cmoGaAc44uJ67uJkD5qgRTUJVOXuyCVudNO8LvObRYop KBFn0Y77Tg/dYeFbBHlZmOAOYn+WBUvBN44JUgK3xR2sIWGuanzO2FsDKsy/6HP7FDVO nc8nagSBZX45JfmZcg04js8KLrjo9WbLafoP/0RWeB4cpSoBzniQpxsMcMdzSg/A5ZSC tso48bSPF16qnUPgJWgxtCMVoZsb52UGMerPQVtotFWmB2z+YbXQqrEsP00p2fgoD2rp YF/Q== 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=dHRZSoCZAzfR/lJhx25t08WJnqWrvEbTqWzKUdTUjVE=; b=Wf4uECH+XTIqs7Xpcffc7iTHptYi4Mqdmq60UO9kRtq5Sa0nwFeAWOnQvaf3dcWO5l +Z5DBV89ltP67bSyg8whImepgwrXLNztbesM9lYBfkukgkdh4Jkc7SQ81ufC9/BLKHWJ HFNiIG2gfER2MBkUls4B5f8WJlgBDxkPprH/qmcM9kqB3/4robLJKgpuMNDmrQob0QVa 2VEDvOsHwA1QrXRaCwl/WM7XLoj1XoKyvqasqj0VmauzsRxbxv0nApS/TSkiCFg5b/LK uE/qzAH7yIzMrX3IIyfXMxl6NvGYZqX42qmqKOD0j+0UL/FI1f44TKIBNarUeEIG+6tT 2LYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oQ4UOnvR; 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 x12si2803410wrl.73.2019.04.30.22.21.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:21:08 -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=oQ4UOnvR; 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]:36438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhg3-0002Au-TL for patch@linaro.org; Wed, 01 May 2019 01:21:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRm-0006lZ-7f for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRj-00035Y-6M for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:22 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:39580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRj-00034Q-1K for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:19 -0400 Received: by mail-pf1-x442.google.com with SMTP id z26so4260388pfg.6 for ; Tue, 30 Apr 2019 22:06:18 -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=dHRZSoCZAzfR/lJhx25t08WJnqWrvEbTqWzKUdTUjVE=; b=oQ4UOnvRZLHrm8iHTtPm7Ft6kkLTLZgR0AJ9rA5wNI93ZiF53CaCj77qYMobiBZwAw uZuCMOc10I7JRzb+N+ufYpwZ5WXm5ZIFRvXmgOwgwsxxm6FShFTV4qg073MQEtU6wniP bsOks//5vC3N8kopoa+tGBhxu9o9z95HmBGy0SVoldredlQ7sjnbBom5qTGkTqy19hdB yamE7G41r2iv2aXefpsjHQ7/7iPqa8ETfnVAPtiguoLx+qW2GUI/R0vLgUBrnlBRBtR1 zg3PipVJk5JibeoCVY9HUe7Tl8R+V5B/wxxPbNhRAC4oh2CNDLqMyKdvyqLG7CHaKoBQ /pZw== 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=dHRZSoCZAzfR/lJhx25t08WJnqWrvEbTqWzKUdTUjVE=; b=ewgqPCqPgRV10ckZPBln0HIiL8nbUBuMeuX8KYryDlU5ula1oCws/jW2S4R6kxNKxw hb29dt0ubRR1jEy2M6SLDaHal3ounhWHQae57GNg72UOg0Z+gaf2CDHixkywmnL6Ve6y hlBQ4ba8U2hxN7jQVaDYAPt/zH4YM4oEJQ6F8YYPRThPrp1AjQtfxpfdnl4kKuPn/AQS qaX3AtIZDXyP58YdlXFzNDb394DGVfjptPtzcqX5YgNnEpNHyPQOzFuEZ1rnil/jGwP9 ZEa3qOg5A+nHJ9So+x6WVFZSLVZ3jV+4QQutUPDI4knK+Si5AK5hDxmxa0Q8bpo9Mv40 R79g== X-Gm-Message-State: APjAAAWrImi47cold7aHLEiS8+mXepolnmEWi3I2F6YZbbDcH7OVlHat yZHKqYxUk1SWezBNPvpiSqiDGrx8Ehw= X-Received: by 2002:a62:d205:: with SMTP id c5mr18822438pfg.219.1556687177435; Tue, 30 Apr 2019 22:06:17 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:34 -0700 Message-Id: <20190501050536.15580-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v2 27/29] target/s390x: Use tcg_gen_abs_i64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/translate.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) -- 2.17.1 Reviewed-by: David Hildenbrand diff --git a/target/s390x/translate.c b/target/s390x/translate.c index d4951836ad..e8e8a79b7d 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -1407,13 +1407,7 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, static DisasJumpType op_abs(DisasContext *s, DisasOps *o) { - TCGv_i64 z, n; - z = tcg_const_i64(0); - n = tcg_temp_new_i64(); - tcg_gen_neg_i64(n, o->in2); - tcg_gen_movcond_i64(TCG_COND_LT, o->out, o->in2, z, n, o->in2); - tcg_temp_free_i64(n); - tcg_temp_free_i64(z); + tcg_gen_abs_i64(o->out, o->in2); return DISAS_NEXT; } From patchwork Wed May 1 05:05:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163205 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4135413ill; Tue, 30 Apr 2019 22:29:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpv/S8gZQwv6c0jzIZU/Q6vZGkUb8vRE2Cj02wzEKwKuRdIQjSqme3+F+Tmq+l8mubW0Oo X-Received: by 2002:adf:b696:: with SMTP id j22mr27760331wre.85.1556688550096; Tue, 30 Apr 2019 22:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688550; cv=none; d=google.com; s=arc-20160816; b=OUgyTPbGr4JFnT7v8aSe936mqHYwzS1T5XmJtSQTqETBoop63XTGowMa677BPxVTCV ix1IymTPghbqej6Ddv1vKJId7wtR2hX/keROs3yMMSIoN6S8wkTDAOLoPc4VTRrIx5K/ Rt96wI0LOYw/Rl2DCDY530rt6eqxVlGmhE+8arQVeFxLLJTFT8e/R73Rq9fIcuHiL5cE FF4VPWGpVWxEpWRHoaZmgPGZYjQS0In0CIdCeqZ8f0gahTsSxyWArim7+av4wr0FNRm0 ktqHFQuYsgWkmMltJoXXiueR7SMAZXCCxAx50FkAaB26qKZ4nVqoNqHl2leAsLmpzusO 4KZQ== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=a21zCVCqlzAtHHyCClfYkOw1IN8eWmtRYOfzkfNSAPM=; b=wnRuVcFddzLGYQJARwwRJv6UEWhUXwz9JERDfuRZgMTd91FPgex1GAq9oU0gG/YcDk kmeEyvXlvB9oDYGLpdf/O4WwfaqEWHDRN7PiWUb3ddraja+59fpfaHenl9tDd+j+dGXo hxj2fczF5kPrF6elhkvYsUR7MzwImVDLbGWXWV8HtmmAWysFgifnpIH5GonHMfEz6+r5 Kzu4xOmwQudka2PBL/Koiik4ttLnZIG5zOKZ0OQ60bsMlIr9A7MEQe7IyYED9QrMJc78 EXyJ6MNB836TarBFYeiwbcpkxVl1GZ029PI55eThozcmAduNX6VVIEjN/yxtFqejIMJZ 4qOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lI+ZCsSC; 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 x6si26865308wrw.188.2019.04.30.22.29.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:29:10 -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=lI+ZCsSC; 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]:36655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhnp-0000YS-2Y for patch@linaro.org; Wed, 01 May 2019 01:29:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRn-0006mf-5N for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRk-00036B-4k for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:23 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:39747) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRj-00035g-Uv for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:20 -0400 Received: by mail-pl1-x62a.google.com with SMTP id e92so7750733plb.6 for ; Tue, 30 Apr 2019 22:06:19 -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 :mime-version:content-transfer-encoding; bh=a21zCVCqlzAtHHyCClfYkOw1IN8eWmtRYOfzkfNSAPM=; b=lI+ZCsSCRXehjcQIaioXtGb36Bh1J7W4lYamcvkF6MGQM0OCr4osxnh4lQ6zoj22Mr LMuq8PUhEJD0nTjBd30SvLPhV8fcS2nqPZfkdkDCxtLYJdUk5vl+kua/PjIpTsvR7mX5 wPERvQ+V3FKVXHo9vSLNiBPLWPHYguF8HCIhiY3J9iuZQm5SF+rh5bWuJBkpVQNu6Avt OvfveOpBJdMnXFO5Tk59FXnttk3upPNSDhsnGb/HDk3PIDZXoeGMbFL4iZs8V/fSVHpa fDtT/VV9SIpsolsIUYL660lFtsgCvV1qAAYKyip1M82f8LL+cgIr6srnSy8PUsvke+Kl cplw== 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:mime-version:content-transfer-encoding; bh=a21zCVCqlzAtHHyCClfYkOw1IN8eWmtRYOfzkfNSAPM=; b=TCjCbPBwUN1Kt5oL6bzC9jxR56IwCy1yhEKlJv/Mzuvmqj6NaGjzxhq3OItYbsffln IGrwCzFsfUp4EaX0xdzyMznlyu3uVO3SUhiMN2J/m8wx59f+ibbdfW6hYm3W3e4WN1iK EtUmUz8zvMG1eA8HTULvNibTRsSlXJHKC+d9avcgeGDpyTsIagsBt4x8ZNUS5yg6E52/ pb2blgsnLa62TcXkFaN4ozWibHCqhTK0isDV40eMSz5+hFz/5NGm9lkfuuF/YEHj9Sym rIo65/Vyg75l7l0ETnAftwnXp+Hhv/STmfEF8tzSGkdyi3wzmnnS50/6ywvhv25YFPM4 Ut8A== X-Gm-Message-State: APjAAAWDWDcF4EfBKZezTqFo8C6V1Ji6L0fJOrpNJdTx8sdZEFFRHYo3 G4aHY9lGVP+Azy5CyJWTvUhT00HPDKo= X-Received: by 2002:a17:902:4101:: with SMTP id e1mr77183560pld.25.1556687178692; Tue, 30 Apr 2019 22:06:18 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:35 -0700 Message-Id: <20190501050536.15580-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62a Subject: [Qemu-devel] [PATCH v2 28/29] target/tricore: Use tcg_gen_abs_tl 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Reviewed-by: Bastian Koppelmann Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20190423102145.14812-3-f4bug@amsat.org> Signed-off-by: Richard Henderson --- target/tricore/translate.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 8f6416144e..06c4485e55 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -2415,11 +2415,7 @@ gen_msubadr32s_h(TCGv ret, TCGv r1, TCGv r2, TCGv r3, uint32_t n, uint32_t mode) static inline void gen_abs(TCGv ret, TCGv r1) { - TCGv temp = tcg_temp_new(); - TCGv t0 = tcg_const_i32(0); - - tcg_gen_neg_tl(temp, r1); - tcg_gen_movcond_tl(TCG_COND_GE, ret, r1, t0, r1, temp); + tcg_gen_abs_tl(ret, r1); /* overflow can only happen, if r1 = 0x80000000 */ tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_PSW_V, r1, 0x80000000); tcg_gen_shli_tl(cpu_PSW_V, cpu_PSW_V, 31); @@ -2430,9 +2426,6 @@ static inline void gen_abs(TCGv ret, TCGv r1) tcg_gen_xor_tl(cpu_PSW_AV, ret, cpu_PSW_AV); /* calc SAV bit */ tcg_gen_or_tl(cpu_PSW_SAV, cpu_PSW_SAV, cpu_PSW_AV); - - tcg_temp_free(temp); - tcg_temp_free(t0); } static inline void gen_absdif(TCGv ret, TCGv r1, TCGv r2) @@ -6617,13 +6610,8 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx) tcg_gen_movi_tl(cpu_PSW_AV, 0); if (!tricore_feature(env, TRICORE_FEATURE_131)) { /* overflow = (abs(D[r3+1]) >= abs(D[r2])) */ - tcg_gen_neg_tl(temp, temp3); - /* use cpu_PSW_AV to compare against 0 */ - tcg_gen_movcond_tl(TCG_COND_LT, temp, temp3, cpu_PSW_AV, - temp, temp3); - tcg_gen_neg_tl(temp2, cpu_gpr_d[r2]); - tcg_gen_movcond_tl(TCG_COND_LT, temp2, cpu_gpr_d[r2], cpu_PSW_AV, - temp2, cpu_gpr_d[r2]); + tcg_gen_abs_tl(temp, temp3); + tcg_gen_abs_tl(temp2, cpu_gpr_d[r2]); tcg_gen_setcond_tl(TCG_COND_GE, cpu_PSW_V, temp, temp2); } else { /* overflow = (D[b] == 0) */ @@ -6655,13 +6643,8 @@ static void decode_rr_divide(CPUTriCoreState *env, DisasContext *ctx) tcg_gen_movi_tl(cpu_PSW_AV, 0); if (!tricore_feature(env, TRICORE_FEATURE_131)) { /* overflow = (abs(D[r3+1]) >= abs(D[r2])) */ - tcg_gen_neg_tl(temp, temp3); - /* use cpu_PSW_AV to compare against 0 */ - tcg_gen_movcond_tl(TCG_COND_LT, temp, temp3, cpu_PSW_AV, - temp, temp3); - tcg_gen_neg_tl(temp2, cpu_gpr_d[r2]); - tcg_gen_movcond_tl(TCG_COND_LT, temp2, cpu_gpr_d[r2], cpu_PSW_AV, - temp2, cpu_gpr_d[r2]); + tcg_gen_abs_tl(temp, temp3); + tcg_gen_abs_tl(temp2, cpu_gpr_d[r2]); tcg_gen_setcond_tl(TCG_COND_GE, cpu_PSW_V, temp, temp2); } else { /* overflow = (D[b] == 0) */ From patchwork Wed May 1 05:05:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163206 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp4135528ill; Tue, 30 Apr 2019 22:29:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwL7egzbIhoPaSIBZUhqLZDQJkfcbyrughHwigYXZJdhytPQtG/D3n51v4O7ZWWIE9eABj8 X-Received: by 2002:a5d:408e:: with SMTP id o14mr14415203wrp.318.1556688560757; Tue, 30 Apr 2019 22:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556688560; cv=none; d=google.com; s=arc-20160816; b=nEe+r3gTChJv31W08TRaBLQsUomybRiH7zhqrMlp3FVPmG/zmU7mIXtS5+t/qbMd17 T75OKz38sMwVMrTqcpyvf/aKhpe8Mv52Nx/7U1w7y0cZlmSdbkQLrm5/V3RdjbrHZiM9 9rBbpOUbUhR/5FTr0AtTFUdZ12cxVZJNoIUNsNrR5zwUoiloVs7jFbtbiy+bDEneT2LF keEN2r1x8Gcr0t2hlIn9UnqbZrMAf79Kr1I2IhcJjZJPyMbEBscAHsSvY2kGPJR5/wu6 z+IvG0JM8l/dEzlTqpKD/wARDrRmhkRqGI1TNXJoz7EsaCFJj9qXrY680fQA73wTVWw5 nbhQ== 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=XwoaUdVIRqjp6Whyx2wUcZDo65i8rf+ItxdtJjgV/mU=; b=HFw54S+VEXWow6RObAlVwOHuKggZhC1ft8PMkWDCPckUcDlKlbEWwnGj279VHmBqUb c7mFLV8wItLAg2dvk7kafiLcS9S320Z6izpP1Rcl7g3F1g+/pxEjyWIN187tzWaVTA0a sAk/OyWaOkyrxZwewC6i30RQD7PSrUMjwdnrOIhSSpAFa5tsgyUK1Vi1uwch5cC6Q5Px E5kC+KxDzO30Ba1uGB7NxwtIH/fWPIpvbETWEXUg8E3V/tPgXwtfB52HpI+W2AOeW1B+ RSzhdwoS9YhOqo5PEByxrL7qeGcFcuwL5DWMeCGZdM45Nmv/H3sZQ7v4gCK6fw6nx0k/ QaGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F4k64hXY; 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 w10si8727132wrg.355.2019.04.30.22.29.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2019 22:29:20 -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=F4k64hXY; 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]:36657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhnz-0000Zq-OO for patch@linaro.org; Wed, 01 May 2019 01:29:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLhRo-0006oE-Dj for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLhRl-00036o-D1 for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:24 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:46742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLhRl-00036V-7a for qemu-devel@nongnu.org; Wed, 01 May 2019 01:06:21 -0400 Received: by mail-pg1-x543.google.com with SMTP id n2so7846960pgg.13 for ; Tue, 30 Apr 2019 22:06:21 -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=XwoaUdVIRqjp6Whyx2wUcZDo65i8rf+ItxdtJjgV/mU=; b=F4k64hXY//oO6HmbKkxd9YWheaP9IbgnoTlAHeTa920tyi2MeIdMf7ll8DcQhiGCHB DDPzWWJwjAKO8k9Z+jlGMvFqtdTsXeRQv8+vFE/xDKHDLlhP8ker8WN3MRfntkL7UpfP qwugmd998DW30MHgE9tEOYisGOy6Gkbiv97NPHg1B9d/8DFENQhwgDJsboEXHgs9QAQx uu2LcuBRd78kSmfbXkStqmm8fpdPFIMsY0pwYiNZ4mSUmQoJs0bRRyl435QyoSxWrd3v O0WJHizH9l4gpeqE5kPKQFrUPzivkYTlj6M5AnCpIEuwVb6dfc82HnvsnQjsLAeMBnHy FJ9A== 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=XwoaUdVIRqjp6Whyx2wUcZDo65i8rf+ItxdtJjgV/mU=; b=YmG5+qnBlMJXXHWYkBCtYU3fUFP2HeRyWKjROmUXf11cRMpgA4Z6B3vhtab+mJ+2iD wqeh63Xx7vTf7F1lBbSFZhItdq8REMyoE8TnPQuwEfMnBsE/AGnIMhRIhPVqaEXJRHlg STsLK4uUcFgwzmSttafHPzYenpoD+RHFWwQDTP8fp3TrwBJP73GHSl93VDX7c0G6VIPf eKcd9EFoJr76aAX5w30oLbb7fjWZT8VjpqNshGY5lcKYrNnS3129dFdHOdtTJO97Eg7N ISu8qeUffcfyyuByM5dt/ZZdEv1vuXrJ4w7I2vGsJvL7IffSrb18wC/NGQ47a8YwWsaE IIMw== X-Gm-Message-State: APjAAAUY8XeRTniiXIDDgQYZSB2JnTXTaUuXJUvL5T1pfpzE9hY2bZhi uvoJyk5yrOIBTN5sBppqbvzXvvatIzk= X-Received: by 2002:a63:6ac1:: with SMTP id f184mr73580019pgc.25.1556687180059; Tue, 30 Apr 2019 22:06:20 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id t127sm9687251pfb.106.2019.04.30.22.06.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 22:06:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 22:05:36 -0700 Message-Id: <20190501050536.15580-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190501050536.15580-1-richard.henderson@linaro.org> References: <20190501050536.15580-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v2 29/29] target/xtensa: Use tcg_gen_abs_i32 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: Max Filippov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Max Filippov Signed-off-by: Richard Henderson --- target/xtensa/translate.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) -- 2.17.1 Acked-by: Max Filippov diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 301c8e3161..b063fa85f2 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1709,14 +1709,7 @@ void restore_state_to_opc(CPUXtensaState *env, TranslationBlock *tb, static void translate_abs(DisasContext *dc, const OpcodeArg arg[], const uint32_t par[]) { - TCGv_i32 zero = tcg_const_i32(0); - TCGv_i32 neg = tcg_temp_new_i32(); - - tcg_gen_neg_i32(neg, arg[1].in); - tcg_gen_movcond_i32(TCG_COND_GE, arg[0].out, - arg[1].in, zero, arg[1].in, neg); - tcg_temp_free(neg); - tcg_temp_free(zero); + tcg_gen_abs_i32(arg[0].out, arg[1].in); } static void translate_add(DisasContext *dc, const OpcodeArg arg[],