From patchwork Sun Mar 17 09:08:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160463 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1406271jad; Sun, 17 Mar 2019 02:12:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyv36jrhPE1KbZJtBMbw6Z2cHC1w9GzQSXvMC0oBp5VCuYT6NAGVC3DTAkFKSnK1n8RttIK X-Received: by 2002:adf:ef0f:: with SMTP id e15mr898293wro.323.1552813942518; Sun, 17 Mar 2019 02:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552813942; cv=none; d=google.com; s=arc-20160816; b=Vs/vJrDseLUuL2sAyLX08CoSrnAoqet3ZvchAsHwAyVZOyUNk2WWjspH0swlRj+Y8w oku21MXHrJifDR6MnzqKfcdG+FF+ZVo7ilF8ZhaG7yjXM7QMfK2ESVtZi7Sfy0gdOauS XktNwqklwBA9cY+gyn1MT/sMx99S0Sz8ehRZiPI2YWwFikvxeqQ2c8ZySTdxnCaH2hAh nr47L8a4PE1dzsy/oSFDQK60d+aLGteM1AkKg7K41Xrr35qk0Zu8zUCNyPbjpEauccPs CZx2ob/D854T09vgIOCIHdtY2vjSFiJaW2wNC8rNAds7RDxgsSYmHvN92LjuGPNwVQ/R JW3w== 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=DI+dKOMHlj5qC6BlkD+neUxReHyEoxD6l7ZaHgSu0oA=; b=NqqgEm4lwZSCK1SRWwbcxXaXQEp76Pzk0y06Iwe7SPAn6jDeoXvtecfrzLv/B2T7SX y6B3SIrd5DK2SHsplG7roBZ7e8nb3+iZ5l56oAVlTUkM2vdC6gPKEqxAYYMP2lO2SOj9 VeVvrCFTFciT6/U2+aJycAza/EVChceu02foc53JXSAXWNZna4nZsIKvANUUWhjDQsrs OyFlKkRtBK/TRw4zlBUGVK5RKAdtbjVuyHfc+8rqGmnAnRcUrASBhboFeekZUKoBmZfe nwQbTU86sjGnAPjXBiedk6jiKqPlKmkGTjwVmsNWTaSKVR07U5sr5WuSy0GicTodbYky /bQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zCe9fX43; 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 v8si5098400wrg.314.2019.03.17.02.12.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 17 Mar 2019 02:12: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=zCe9fX43; 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]:52129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5Rq9-0008VE-Ap for patch@linaro.org; Sun, 17 Mar 2019 05:12:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5Rmm-0005iU-4B for qemu-devel@nongnu.org; Sun, 17 Mar 2019 05:08:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h5Rml-0004Cg-2c for qemu-devel@nongnu.org; Sun, 17 Mar 2019 05:08:52 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:32975) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h5Rmk-0004BD-Kv for qemu-devel@nongnu.org; Sun, 17 Mar 2019 05:08:50 -0400 Received: by mail-pf1-x442.google.com with SMTP id i19so9249856pfd.0 for ; Sun, 17 Mar 2019 02:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DI+dKOMHlj5qC6BlkD+neUxReHyEoxD6l7ZaHgSu0oA=; b=zCe9fX43l8rKSEyjDYhJMo8eX25/tf+TZr4aHTTx4ilEoPZOSuev2dGSXHxUtWWya3 RJkBetzclBBvjqX0Jg+28C/kOXezoXmXymzPhPn6Hl5SxSFAWaHxDdN0eQztp8Q2HoKj 7fIp0P0P4ExiFPbb0Mz6Wp+x0nvbbMgC/vslVYMliP3wy+YzlvdNkrFG1NLQOgdtpDLZ XFkU2kQZKymaj15vn+c2QZT+lTHZBqvCCxKQ+JWm2CHkPE3hBH6V0O6J7rOmIio4R6j1 54fTkfjs0jwDRmMyHUol5FNCBoYIHXDO6u0KeZw3BcZ0v4mM0vOR6iCpMEWafxieNT2P 4vMA== 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=DI+dKOMHlj5qC6BlkD+neUxReHyEoxD6l7ZaHgSu0oA=; b=pSu2dK0T2QVZbQ0gu6FxNHuFOVznjJQ+9wfcHWr6Eoq+J8ixFWIQt2Qltedko5NcuP OEBRsfnP6mb3qYx82mOoxhbJERc7LlhY1v5YGj7qMDLtJuyxGk4G31Mca75byhu/rGiU yqJLG/14gO0+vDYx4NUyVreKGimWY5nGLTYrT0dWrrhaOqzeZ/wYuga1dHKCR4+hc03G 0sANzqSlKXuH12W42WUy4aVk04dfUnhsJo1mbrE99DKQyITIAaUUf7x0H4fYJPUYSrFM zXFh15N3dfbWyIedsZn0yAZA1u46Gu449EyGgjxof3if6IOQBcqajkH0Mcq7VYpt1Ogk BZGA== X-Gm-Message-State: APjAAAV7JTV4Z/eNuauO6YNjamUg0NbCXFFfpJesMhHNNrjRZo0JH2/x xAf5Su5NudJcu89zt3zhYRIi45uNkco= X-Received: by 2002:a63:b242:: with SMTP id t2mr12162038pgo.451.1552813729466; Sun, 17 Mar 2019 02:08:49 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id b85sm19378435pfj.56.2019.03.17.02.08.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Mar 2019 02:08:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 17 Mar 2019 02:08:30 -0700 Message-Id: <20190317090834.5552-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190317090834.5552-1-richard.henderson@linaro.org> References: <20190317090834.5552-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH for-4.1 v2 09/13] tcg/ppc: Support vector shift by immediate X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For Altivec, this is done via vector shift by vector, and loading the immediate into a register. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.inc.c | 58 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) -- 2.17.2 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 8ba5668fae..5797ad35d5 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -147,7 +147,7 @@ extern bool have_isa_3_00; #define TCG_TARGET_HAS_neg_vec 0 #define TCG_TARGET_HAS_shi_vec 0 #define TCG_TARGET_HAS_shs_vec 0 -#define TCG_TARGET_HAS_shv_vec 0 +#define TCG_TARGET_HAS_shv_vec 1 #define TCG_TARGET_HAS_cmp_vec 1 #define TCG_TARGET_HAS_mul_vec 1 #define TCG_TARGET_HAS_sat_vec 1 diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index 85e332fcd3..d91bc9a229 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -517,6 +517,16 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, #define VCMPGTUH VX4(582) #define VCMPGTUW VX4(646) +#define VSLB VX4(260) +#define VSLH VX4(324) +#define VSLW VX4(388) +#define VSRB VX4(516) +#define VSRH VX4(580) +#define VSRW VX4(644) +#define VSRAB VX4(772) +#define VSRAH VX4(836) +#define VSRAW VX4(900) + #define VAND VX4(1028) #define VANDC VX4(1092) #define VNOR VX4(1284) @@ -2849,8 +2859,14 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) case INDEX_op_sssub_vec: case INDEX_op_usadd_vec: case INDEX_op_ussub_vec: + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + case INDEX_op_sarv_vec: return vece <= MO_32; case INDEX_op_cmp_vec: + case INDEX_op_shli_vec: + case INDEX_op_shri_vec: + case INDEX_op_sari_vec: return vece <= MO_32 ? -1 : 0; default: return 0; @@ -2923,7 +2939,10 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, umin_op[4] = { VMINUB, VMINUH, VMINUW, 0 }, smin_op[4] = { VMINSB, VMINSH, VMINSW, 0 }, umax_op[4] = { VMAXUB, VMAXUH, VMAXUW, 0 }, - smax_op[4] = { VMAXSB, VMAXSH, VMAXSW, 0 }; + smax_op[4] = { VMAXSB, VMAXSH, VMAXSW, 0 }, + shlv_op[4] = { VSLB, VSLH, VSLW, 0 }, + shrv_op[4] = { VSRB, VSRH, VSRW, 0 }, + sarv_op[4] = { VSRAB, VSRAH, VSRAW, 0 }; TCGType type = vecl + TCG_TYPE_V64; TCGArg a0 = args[0], a1 = args[1], a2 = args[2]; @@ -2969,6 +2988,15 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_umax_vec: insn = umax_op[vece]; break; + case INDEX_op_shlv_vec: + insn = shlv_op[vece]; + break; + case INDEX_op_shrv_vec: + insn = shrv_op[vece]; + break; + case INDEX_op_sarv_vec: + insn = sarv_op[vece]; + break; case INDEX_op_and_vec: insn = VAND; break; @@ -3040,6 +3068,18 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, tcg_out32(s, insn | VRT(a0) | VRA(a1) | VRB(a2)); } +static void expand_vec_shi(TCGType type, unsigned vece, TCGv_vec v0, + TCGv_vec v1, TCGArg imm, TCGOpcode opci) +{ + TCGv_vec t1 = tcg_temp_new_vec(type); + + /* Splat w/bytes for xxspltib. */ + tcg_gen_dupi_vec(MO_8, t1, imm & ((8 << vece) - 1)); + vec_gen_3(opci, type, vece, tcgv_vec_arg(v0), + tcgv_vec_arg(v1), tcgv_vec_arg(t1)); + tcg_temp_free_vec(t1); +} + static void expand_vec_cmp(TCGType type, unsigned vece, TCGv_vec v0, TCGv_vec v1, TCGv_vec v2, TCGCond cond) { @@ -3091,14 +3131,25 @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece, { va_list va; TCGv_vec v0, v1, v2; + TCGArg a2; va_start(va, a0); v0 = temp_tcgv_vec(arg_temp(a0)); v1 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg))); - v2 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg))); + a2 = va_arg(va, TCGArg); switch (opc) { + case INDEX_op_shli_vec: + expand_vec_shi(type, vece, v0, v1, a2, INDEX_op_shlv_vec); + break; + case INDEX_op_shri_vec: + expand_vec_shi(type, vece, v0, v1, a2, INDEX_op_shrv_vec); + break; + case INDEX_op_sari_vec: + expand_vec_shi(type, vece, v0, v1, a2, INDEX_op_sarv_vec); + break; case INDEX_op_cmp_vec: + v2 = temp_tcgv_vec(arg_temp(a2)); expand_vec_cmp(type, vece, v0, v1, v2, va_arg(va, TCGArg)); break; default: @@ -3299,6 +3350,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_smin_vec: case INDEX_op_umax_vec: case INDEX_op_umin_vec: + case INDEX_op_shlv_vec: + case INDEX_op_shrv_vec: + case INDEX_op_sarv_vec: return &v_v_v; case INDEX_op_not_vec: case INDEX_op_dup_vec: