From patchwork Sun Oct 13 22:25: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: 176098 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3794047ill; Sun, 13 Oct 2019 15:44:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBjV7IX1ZtOMDxWgKiNtHdO1DbGiLGExhS2VpKMyHGl5+uJIc29JYP5zRNi1xKYkZxi/Sx X-Received: by 2002:a05:620a:1444:: with SMTP id i4mr26942229qkl.280.1571006666163; Sun, 13 Oct 2019 15:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571006666; cv=none; d=google.com; s=arc-20160816; b=u9AAueKojHWp3EhPnkNvmxBv3nDCpTKrOPBZgLhnApfVvZWhPg0qsGpia7e6e/C1Ob zE3WyXz//j/ScpTPkC3PAx6ZETWsb6o25vjnPOL7ccdCAFk56GbuovlSigDgL8D19JQL H3KdDN+b6C0N1gQHCIFDJwQ3owPZrfB7wMy1/CynUCHLY3DXCqSXWgifcggrZkT9xk4j nu1gdew6IAtXncoI+QVMUYftQHrEfK/j7zha5eTVEv1sy9UyK26pPssDnuq8N3KQKluq Q+9TG1Xcuta5w5+enOQAIsIzeO4Q1+kbib/ainx/EvOpVDcALF1iyEMrhLvzQfxi2/3u A2eg== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=2nm6apASWDrwzmzKxYCzPimVGo2WIvIIu5cuSVCbrLo=; b=NZ3ihd5LlbtSuWIzdAmU41ieDxwQ3z7Nkh8qrzd54dEfdoM+ePYIHCng/7umkIcuAC Zh9yYOW6cMcoyTrBLLm47kg2leJcsoQ6FrvT26i+bHzMcz1wfG8vl44eScOAcrXMuCC/ eVlJkWai1lz9eIfQKoLaZVuHvs2oSU6pvXdW9sVswWMvC0gQleoSWdj5VUlthZC/chAl w/GKcTKd5akxCOqB6gazZkizw6HSRelCR3zoKAMMrcxw3wbKSrHpD8/pL6oVC2I7LdJh pUGhVhz9wrEik6lobhT9u/y6RxrVPKh0DhRMp4tE37dKZy7jCgyhDvgAF01R3MltqsFc jP8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FIq+AsBt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p20si18032532qtu.245.2019.10.13.15.44.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 13 Oct 2019 15:44:26 -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=pass header.i=@linaro.org header.s=google header.b=FIq+AsBt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJmbB-0001pi-Id for patch@linaro.org; Sun, 13 Oct 2019 18:44:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51281) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJmJR-0006sZ-Fy for qemu-devel@nongnu.org; Sun, 13 Oct 2019 18:26:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJmJQ-0000wF-2E for qemu-devel@nongnu.org; Sun, 13 Oct 2019 18:26:05 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:34411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJmJP-0000vo-QP for qemu-devel@nongnu.org; Sun, 13 Oct 2019 18:26:04 -0400 Received: by mail-pg1-x52b.google.com with SMTP id k20so1581273pgi.1 for ; Sun, 13 Oct 2019 15:26:03 -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=2nm6apASWDrwzmzKxYCzPimVGo2WIvIIu5cuSVCbrLo=; b=FIq+AsBtzJEMj+Ub3hHexvQg67ZOjEOj5LoCn+vtrMT21HKgQkT10oP2/LuIVsEm8l k3C8vtupic8MulQii1EFrlaXJ58UFF7ZrcBrP/HHm4BhNTfkpqOwu2Je9+pvUK6ih40X NugfJQkzHF3rXhP5cV538gf7XAyVtk0tYairH18RQ3m9iZ7uGp1F67m06qUCMMUDDnQ0 DYrgFXOs6baftnQPBHFvOdM6h+636imrNcLJSU0EMr3H2dc7DcCkbKb2tguS5jEq5Xbo ftylbwMXDirqlpTvV9hS1tB38b1KAKbHUJfzVqjXUc5VumTG+yB7vnyU/VIYd2slNhzI oT3A== 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=2nm6apASWDrwzmzKxYCzPimVGo2WIvIIu5cuSVCbrLo=; b=VNBF8NcDmW46wopSR37P7IwMhTl9d/+NTr2JfcRp9KDBtBUkbr6e8eBTlFZpJQez3j hTLLAFi818QZDy9XgdSHys5dU7zw/72eK67WmcsFR13OVuzyUS+D2lTrVSl9GPuijcEc pdzPIuXS+Y2/tc19/avmNfZ2z2mRDwHksDlQjc0oHsOpp1y4OiDQ1Ni+4qXcrLoc0szf fibBlXDGraudj4c+9KODKftAcb6nIb0T2DWsauCQ8X2PSQnrEln7f+wNBEuZYF4UwODO qaLQFjTdSnHrHYM/BXNDnev1adr/AqH+eGB21TDcT/xtQHiIt7BbjJV9QLmyPt4irz/y Mkug== X-Gm-Message-State: APjAAAVKkCkyYHyy6GIZeJX+qLN5qN9zR0Xh3cDqXTQCy2ah1jvkMil1 V0uC92FWTqwGJYtl4no5Ka/F8bsRWss= X-Received: by 2002:a17:90a:9b86:: with SMTP id g6mr32617333pjp.76.1571005562380; Sun, 13 Oct 2019 15:26:02 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id d76sm15940571pfd.185.2019.10.13.15.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2019 15:26:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/23] tcg/ppc: Support vector shift by immediate Date: Sun, 13 Oct 2019 15:25:33 -0700 Message-Id: <20191013222544.3679-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191013222544.3679-1-richard.henderson@linaro.org> References: <20191013222544.3679-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::52b X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Aleksandar Markovic 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 Signed-off-by: Aleksandar Markovic --- tcg/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.inc.c | 58 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 3ebbbfa77e..ffb226946b 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -160,7 +160,7 @@ extern bool have_altivec; #define TCG_TARGET_HAS_abs_vec 0 #define TCG_TARGET_HAS_shi_vec 0 #define TCG_TARGET_HAS_shs_vec 0 -#define TCG_TARGET_HAS_shv_vec 0 +#define TCG_TARGET_HAS_shv_vec 1 #define TCG_TARGET_HAS_cmp_vec 1 #define TCG_TARGET_HAS_mul_vec 0 #define TCG_TARGET_HAS_sat_vec 1 diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index a1165209fc..a9264eccbe 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -514,6 +514,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) @@ -2860,8 +2870,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; @@ -2968,7 +2984,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]; @@ -3015,6 +3034,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; @@ -3059,6 +3087,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) { @@ -3110,14 +3150,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: @@ -3317,6 +3368,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: