Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B89BCA9EAF for ; Mon, 21 Oct 2019 12:45:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F6C120873 for ; Mon, 21 Oct 2019 12:45:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F6C120873 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rt-rk.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMX4C-0004zS-SP for qemu-devel@archiver.kernel.org; Mon, 21 Oct 2019 08:45:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59296) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMX27-0003pS-7i for qemu-devel@nongnu.org; Mon, 21 Oct 2019 08:43:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMX24-0003LA-DM for qemu-devel@nongnu.org; Mon, 21 Oct 2019 08:43:34 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:55846 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iMX23-0002sj-UN for qemu-devel@nongnu.org; Mon, 21 Oct 2019 08:43:32 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 732611A2023; Mon, 21 Oct 2019 14:42:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com Received: from [10.10.14.77] (rtrkw870-lin.domain.local [10.10.14.77]) by mail.rt-rk.com (Postfix) with ESMTPSA id 4E81B1A1E12; Mon, 21 Oct 2019 14:42:25 +0200 (CEST) Subject: Re: [PATCH v7 3/3] target/ppc: Optimize emulation of vupkhpx and vupklpx instructions To: Aleksandar Markovic References: <1571311659-15556-1-git-send-email-stefan.brankovic@rt-rk.com> <1571311659-15556-4-git-send-email-stefan.brankovic@rt-rk.com> From: Stefan Brankovic Message-ID: <76ec488e-b8ab-77de-efb5-53613c2c5975@rt-rk.com> Date: Mon, 21 Oct 2019 14:42:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------DD34E9074EB32E76A469DBF6" Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 89.216.37.149 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: "richard.henderson@linaro.org" , "qemu-devel@nongnu.org" , "david@gibson.dropbear.id.au" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This is a multi-part message in MIME format. --------------DD34E9074EB32E76A469DBF6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hello Aleksandar, Thank you for taking a look at this patch. I will start working on a=20 version 8 of the patch where I will address all your suggestions. Kind Regards, Stefan On 19.10.19. 22:40, Aleksandar Markovic wrote: > > > On Thursday, October 17, 2019, Stefan Brankovic=20 > > wrote: > > 'trans_vupkpx' function implements both vupkhpx and vupklpx > instructions with > argument 'high' determine which instruction is processed. > Instructions are > implemented in two 'for' loops. Outer 'for' loop repeats unpacking > two times, > since both doubleword elements of destination register are formed > the same way. > It also stores result of every iteration in temporary register, > that is later > transferred to destination register. Inner 'for' loop does > unpacking of pixels > and forms resulting doubleword 32 by 32 bits. > > Signed-off-by: Stefan Brankovic > > --- > =C2=A0target/ppc/helper.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0|=C2=A0 2 - > =C2=A0target/ppc/int_helper.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0| 20 -------- > =C2=A0target/ppc/translate/vmx-impl.inc.c | 91 > ++++++++++++++++++++++++++++++++++++- > =C2=A03 files changed, 89 insertions(+), 24 deletions(-) > > diff --git a/target/ppc/helper.h b/target/ppc/helper.h > index b489b38..fd06b56 100644 > --- a/target/ppc/helper.h > +++ b/target/ppc/helper.h > @@ -233,8 +233,6 @@ DEF_HELPER_2(vextsh2d, void, avr, avr) > =C2=A0DEF_HELPER_2(vextsw2d, void, avr, avr) > =C2=A0DEF_HELPER_2(vnegw, void, avr, avr) > =C2=A0DEF_HELPER_2(vnegd, void, avr, avr) > -DEF_HELPER_2(vupkhpx, void, avr, avr) > -DEF_HELPER_2(vupklpx, void, avr, avr) > =C2=A0DEF_HELPER_2(vupkhsb, void, avr, avr) > =C2=A0DEF_HELPER_2(vupkhsh, void, avr, avr) > =C2=A0DEF_HELPER_2(vupkhsw, void, avr, avr) > diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c > index f910c11..9ee667d 100644 > --- a/target/ppc/int_helper.c > +++ b/target/ppc/int_helper.c > @@ -1737,26 +1737,6 @@ void helper_vsum4ubs(CPUPPCState *env, > ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) > =C2=A0#define UPKHI 0 > =C2=A0#define UPKLO 1 > =C2=A0#endif > -#define VUPKPX(suffix, hi) =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > -=C2=A0 =C2=A0 void helper_vupk##suffix(ppc_avr_t *r, ppc_avr_t *b)= =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > -=C2=A0 =C2=A0 { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 int i; =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 ppc_avr_t result; =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0\ > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (i =3D 0; i < ARRAY_SIZE(r->u32); = i++) { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint16_t e =3D b->u16[hi= ? i : i + 4]; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint8_t a =3D (e >> 15) = ? 0xff : 0; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint8_t r =3D (e >> 10) = & 0x1f; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0\ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint8_t g =3D (e >> 5) &= 0x1f; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint8_t b =3D e & 0x1f; = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\ > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 result.u32[i] =3D (a << = 24) | (r << 16) | (g << 8) | > b;=C2=A0 =C2=A0 =C2=A0 =C2=A0\ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 } =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\ > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 *r =3D result; =C2=A0 =C2=A0 =C2=A0 =C2= =A0 \ > -=C2=A0 =C2=A0 } > -VUPKPX(lpx, UPKLO) > -VUPKPX(hpx, UPKHI) > -#undef VUPKPX > > =C2=A0#define VUPK(suffix, unpacked, packee, hi) =C2=A0 =C2=A0 =C2=A0= =C2=A0 \ > =C2=A0 =C2=A0 =C2=A0void helper_vupk##suffix(ppc_avr_t *r, ppc_avr_= t *b) =C2=A0 =C2=A0 =C2=A0 =C2=A0 \ > diff --git a/target/ppc/translate/vmx-impl.inc.c > b/target/ppc/translate/vmx-impl.inc.c > index 3550ffa..09d80d6 100644 > --- a/target/ppc/translate/vmx-impl.inc.c > +++ b/target/ppc/translate/vmx-impl.inc.c > @@ -1031,6 +1031,95 @@ static void trans_vclzd(DisasContext *ctx) > =C2=A0 =C2=A0 =C2=A0tcg_temp_free_i64(avr); > =C2=A0} > > +/* > + * vupkhpx VRT,VRB - Vector Unpack High Pixel > + * vupklpx VRT,VRB - Vector Unpack Low Pixel > + * > + * Unpacks 4 pixels coded in 1-5-5-5 pattern from high/low > doubleword element > + * of source register into contigous array of bits in the > destination register. > + * Argument 'high' determines if high or low doubleword element > of source > + * register is processed. > + */ > +static void trans_vupkpx(DisasContext *ctx, int high) > > > The last argument should be boolean. > > +{ > +=C2=A0 =C2=A0 int VT =3D rD(ctx->opcode); > +=C2=A0 =C2=A0 int VB =3D rB(ctx->opcode); > +=C2=A0 =C2=A0 TCGv_i64 tmp =3D tcg_temp_new_i64(); > +=C2=A0 =C2=A0 TCGv_i64 avr =3D tcg_temp_new_i64(); > +=C2=A0 =C2=A0 TCGv_i64 result =3D tcg_temp_new_i64(); > +=C2=A0 =C2=A0 TCGv_i64 result1 =3D tcg_temp_new_i64(); > +=C2=A0 =C2=A0 TCGv_i64 result2 =3D tcg_temp_new_i64(); > +=C2=A0 =C2=A0 int64_t mask1 =3D 0x1fULL; > +=C2=A0 =C2=A0 int64_t mask2 =3D 0x1fULL << 8; > +=C2=A0 =C2=A0 int64_t mask3 =3D 0x1fULL << 16; > +=C2=A0 =C2=A0 int64_t mask4 =3D 0xffULL << 56; > +=C2=A0 =C2=A0 int i, j; > + > +=C2=A0 =C2=A0 if (high =3D=3D 1) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 get_avr64(avr, VB, true); > +=C2=A0 =C2=A0 } else { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 get_avr64(avr, VB, false); > +=C2=A0 =C2=A0 } > + > +=C2=A0 =C2=A0 tcg_gen_movi_i64(result, 0x0ULL); > +=C2=A0 =C2=A0 for (i =3D 0; i < 2; i++) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (j =3D 0; j < 2; j++) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shli_i64(tmp, av= r, (j * 16)); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_andi_i64(tmp, tm= p, mask1 << (j * 32)); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_or_i64(result, r= esult, tmp); > + > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shli_i64(tmp, av= r, 3 + (j * 16)); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_andi_i64(tmp, tm= p, mask2 << (j * 32)); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_or_i64(result, r= esult, tmp); > + > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shli_i64(tmp, av= r, 6 + (j * 16)); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_andi_i64(tmp, tm= p, mask3 << (j * 32)); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_or_i64(result, r= esult, tmp); > + > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shri_i64(tmp, av= r, (j * 16)); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_ext16s_i64(tmp, = tmp); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_andi_i64(tmp, tm= p, mask4); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shri_i64(tmp, tm= p, (32 * (1 - j))); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_or_i64(result, r= esult, tmp); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (i =3D=3D 0) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_mov_i64(result1,= result); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_movi_i64(result,= 0x0ULL); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shri_i64(avr, av= r, 32); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (i =3D=3D 1) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_mov_i64(result2,= result); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } > +=C2=A0 =C2=A0 } > + > +=C2=A0 =C2=A0 set_avr64(VT, result1, false); > +=C2=A0 =C2=A0 set_avr64(VT, result2, true); > + > +=C2=A0 =C2=A0 tcg_temp_free_i64(tmp); > +=C2=A0 =C2=A0 tcg_temp_free_i64(avr); > +=C2=A0 =C2=A0 tcg_temp_free_i64(result); > +=C2=A0 =C2=A0 tcg_temp_free_i64(result1); > +=C2=A0 =C2=A0 tcg_temp_free_i64(result2); > +} > + > +static void gen_vupkhpx(DisasContext *ctx) > +{ > +=C2=A0 =C2=A0 if (unlikely(!ctx->altivec_enabled)) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 gen_exception(ctx, POWERPC_EXCP_VPU); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return; > +=C2=A0 =C2=A0 } > +=C2=A0 =C2=A0 trans_vupkpx(ctx, 1); > +} > + > +static void gen_vupklpx(DisasContext *ctx) > +{ > +=C2=A0 =C2=A0 if (unlikely(!ctx->altivec_enabled)) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 gen_exception(ctx, POWERPC_EXCP_VPU); > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return; > +=C2=A0 =C2=A0 } > +=C2=A0 =C2=A0 trans_vupkpx(ctx, 0); > +} > + > =C2=A0GEN_VXFORM(vmuloub, 4, 0); > =C2=A0GEN_VXFORM(vmulouh, 4, 1); > =C2=A0GEN_VXFORM(vmulouw, 4, 2); > @@ -1348,8 +1437,6 @@ GEN_VXFORM_NOA(vupkhsw, 7, 25); > =C2=A0GEN_VXFORM_NOA(vupklsb, 7, 10); > =C2=A0GEN_VXFORM_NOA(vupklsh, 7, 11); > =C2=A0GEN_VXFORM_NOA(vupklsw, 7, 27); > -GEN_VXFORM_NOA(vupkhpx, 7, 13); > -GEN_VXFORM_NOA(vupklpx, 7, 15); > =C2=A0GEN_VXFORM_NOA_ENV(vrefp, 5, 4); > =C2=A0GEN_VXFORM_NOA_ENV(vrsqrtefp, 5, 5); > =C2=A0GEN_VXFORM_NOA_ENV(vexptefp, 5, 6); > --=20 > 2.7.4 > > --------------DD34E9074EB32E76A469DBF6 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Hello Aleksandar,

Thank you for taking a look at this patch. I will start working on a version 8 of the patch where I will address all your suggestions.

Kind Regards,

Stefan

On 19.10.19. 22:40, Aleksandar Markovi= c wrote:


On Thursday, October 17, 2019, Stefan Brankovic <stefan.brankovic@rt-rk.com> wrote:
'trans_vupkpx' function implements both vupkhpx and vupklpx instructions with argument 'high' determine which instruction is processed. Instructions are
implemented in two 'for' loops. Outer 'for' loop repeats unpacking two times,
since both doubleword elements of destination register are formed the same way.
It also stores result of every iteration in temporary register, that is later
transferred to destination register. Inner 'for' loop does unpacking of pixels
and forms resulting doubleword 32 by 32 bits.

Signed-off-by: Stefan Brankovic <stefan.brankovic@rt-rk.com>
---
=C2=A0target/ppc/helper.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0|=C2=A0 2 -
=C2=A0target/ppc/int_helper.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0| 20 --------
=C2=A0target/ppc/translate/vmx-impl.inc.c | 91 ++++++++++++++++++++++++++++++++++++-
=C2=A03 files changed, 89 insertions(+), 24 deletions(-)

diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index b489b38..fd06b56 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -233,8 +233,6 @@ DEF_HELPER_2(vextsh2d, void, avr, avr)
=C2=A0DEF_HELPER_2(vextsw2d, void, avr, avr)
=C2=A0DEF_HELPER_2(vnegw, void, avr, avr)
=C2=A0DEF_HELPER_2(vnegd, void, avr, avr)
-DEF_HELPER_2(vupkhpx, void, avr, avr)
-DEF_HELPER_2(vupklpx, void, avr, avr)
=C2=A0DEF_HELPER_2(vupkhsb, void, avr, avr)
=C2=A0DEF_HELPER_2(vupkhsh, void, avr, avr)
=C2=A0DEF_HELPER_2(vupkhsw, void, avr, avr)
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index f910c11..9ee667d 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -1737,26 +1737,6 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
=C2=A0#define UPKHI 0
=C2=A0#define UPKLO 1
=C2=A0#endif
-#define VUPKPX(suffix, hi)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
-=C2=A0 =C2=A0 void helper_vupk##suffix(ppc_avr_t *r, ppc_avr_t *= b)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
-=C2=A0 =C2=A0 {=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 int i;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=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=A0 =C2=A0 =C2=A0 =C2=A0 }=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 *r =3D result;=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
-=C2=A0 =C2=A0 }
-VUPKPX(lpx, UPKLO)
-VUPKPX(hpx, UPKHI)
-#undef VUPKPX

=C2=A0#define VUPK(suffix, unpacked, packee, hi)=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
=C2=A0 =C2=A0 =C2=A0void helper_vupk##suffix(ppc_avr_t *r, ppc_av= r_t *b)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
diff --git a/target/ppc/translate/vmx-impl.inc.c b/target/ppc/translate/vmx-impl.inc.c
index 3550ffa..09d80d6 100644
--- a/target/ppc/translate/vmx-impl.inc.c
+++ b/target/ppc/translate/vmx-impl.inc.c
@@ -1031,6 +1031,95 @@ static void trans_vclzd(DisasContext *ctx)
=C2=A0 =C2=A0 =C2=A0tcg_temp_free_i64(avr);
=C2=A0}

+/*
+ * vupkhpx VRT,VRB - Vector Unpack High Pixel
+ * vupklpx VRT,VRB - Vector Unpack Low Pixel
+ *
+ * Unpacks 4 pixels coded in 1-5-5-5 pattern from high/low doubleword element
+ * of source register into contigous array of bits in the destination register.
+ * Argument 'high' determines if high or low doubleword element of source
+ * register is processed.
+ */
+static void trans_vupkpx(DisasContext *ctx, int high)

The last argument should be boolean.
=C2=A0
+{
+=C2=A0 =C2=A0 int VT =3D rD(ctx->opcode);
+=C2=A0 =C2=A0 int VB =3D rB(ctx->opcode);
+=C2=A0 =C2=A0 TCGv_i64 tmp =3D tcg_temp_new_i64();
+=C2=A0 =C2=A0 TCGv_i64 avr =3D tcg_temp_new_i64();
+=C2=A0 =C2=A0 TCGv_i64 result =3D tcg_temp_new_i64();
+=C2=A0 =C2=A0 TCGv_i64 result1 =3D tcg_temp_new_i64();
+=C2=A0 =C2=A0 TCGv_i64 result2 =3D tcg_temp_new_i64();
+=C2=A0 =C2=A0 int64_t mask1 =3D 0x1fULL;
+=C2=A0 =C2=A0 int64_t mask2 =3D 0x1fULL << 8;
+=C2=A0 =C2=A0 int64_t mask3 =3D 0x1fULL << 16;
+=C2=A0 =C2=A0 int64_t mask4 =3D 0xffULL << 56;
+=C2=A0 =C2=A0 int i, j;
+
+=C2=A0 =C2=A0 if (high =3D=3D 1) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 get_avr64(avr, VB, true);
+=C2=A0 =C2=A0 } else {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 get_avr64(avr, VB, false);
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 tcg_gen_movi_i64(result, 0x0ULL);
+=C2=A0 =C2=A0 for (i =3D 0; i < 2; i++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (j =3D 0; j < 2; j++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shli_i64(tmp, = avr, (j * 16));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_andi_i64(tmp, = tmp, mask1 << (j * 32));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_or_i64(result,= result, tmp);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shli_i64(tmp, = avr, 3 + (j * 16));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_andi_i64(tmp, = tmp, mask2 << (j * 32));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_or_i64(result,= result, tmp);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shli_i64(tmp, = avr, 6 + (j * 16));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_andi_i64(tmp, = tmp, mask3 << (j * 32));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_or_i64(result,= result, tmp);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shri_i64(tmp, = avr, (j * 16));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_ext16s_i64(tmp= , tmp);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_andi_i64(tmp, = tmp, mask4);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shri_i64(tmp, = tmp, (32 * (1 - j)));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_or_i64(result,= result, tmp);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (i =3D=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_mov_i64(result= 1, result);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_movi_i64(resul= t, 0x0ULL);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_shri_i64(avr, = avr, 32);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (i =3D=3D 1) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tcg_gen_mov_i64(result= 2, result);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 set_avr64(VT, result1, false);
+=C2=A0 =C2=A0 set_avr64(VT, result2, true);
+
+=C2=A0 =C2=A0 tcg_temp_free_i64(tmp);
+=C2=A0 =C2=A0 tcg_temp_free_i64(avr);
+=C2=A0 =C2=A0 tcg_temp_free_i64(result);
+=C2=A0 =C2=A0 tcg_temp_free_i64(result1);
+=C2=A0 =C2=A0 tcg_temp_free_i64(result2);
+}
+
+static void gen_vupkhpx(DisasContext *ctx)
+{
+=C2=A0 =C2=A0 if (unlikely(!ctx->altivec_enabled)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 gen_exception(ctx, POWERPC_EXCP_VPU)= ;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 trans_vupkpx(ctx, 1);
+}
+
+static void gen_vupklpx(DisasContext *ctx)
+{
+=C2=A0 =C2=A0 if (unlikely(!ctx->altivec_enabled)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 gen_exception(ctx, POWERPC_EXCP_VPU)= ;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 trans_vupkpx(ctx, 0);
+}
+
=C2=A0GEN_VXFORM(vmuloub, 4, 0);
=C2=A0GEN_VXFORM(vmulouh, 4, 1);
=C2=A0GEN_VXFORM(vmulouw, 4, 2);
@@ -1348,8 +1437,6 @@ GEN_VXFORM_NOA(vupkhsw, 7, 25);
=C2=A0GEN_VXFORM_NOA(vupklsb, 7, 10);
=C2=A0GEN_VXFORM_NOA(vupklsh, 7, 11);
=C2=A0GEN_VXFORM_NOA(vupklsw, 7, 27);
-GEN_VXFORM_NOA(vupkhpx, 7, 13);
-GEN_VXFORM_NOA(vupklpx, 7, 15);
=C2=A0GEN_VXFORM_NOA_ENV(vrefp, 5, 4);
=C2=A0GEN_VXFORM_NOA_ENV(vrsqrtefp, 5, 5);
=C2=A0GEN_VXFORM_NOA_ENV(vexptefp, 5, 6);
--
2.7.4


--------------DD34E9074EB32E76A469DBF6--