From patchwork Thu Sep 8 22:31:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Rolnik X-Patchwork-Id: 9322249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2073B60231 for ; Thu, 8 Sep 2016 22:47:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F18EC29A37 for ; Thu, 8 Sep 2016 22:47:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E65FE29A39; Thu, 8 Sep 2016 22:47:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6B74529A37 for ; Thu, 8 Sep 2016 22:47:02 +0000 (UTC) Received: from localhost ([::1]:54501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi861-0007Fa-3c for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Sep 2016 18:47:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi7sP-0003GF-E7 for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bi7sN-0000k4-CE for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:57 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36715) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi7sN-0000jw-1x for qemu-devel@nongnu.org; Thu, 08 Sep 2016 18:32:55 -0400 Received: by mail-wm0-x242.google.com with SMTP id l65so194368wmf.3 for ; Thu, 08 Sep 2016 15:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1Zcbm4OfJ4gVSGwT/FYZFj56VM5LF1OsK/aeMIXG8yI=; b=IiYoJH6eFv74pkvJIzXpo5Oxye1LBlQzzPBZohA6ym3Aq0x5mji0VgYvpEbq9HXahN /6+/G9UDYhWk4ZqPl2fFo1MoTBqn/RJOuUUDnOu10NSY5NuPNI+YUsPir1YTmxT6KCSP 2VxEaaazjEiTCCSXnxiL03nM52id4ocp+ZXCUbu1NtWdX4sOm2jAP6pGexL9C1A07yA5 UadSVZ5s9mPi8GjUQKBkAEbp8sEoyZTZm7fXqnygWIPF+/SwsdtcQg5HJpow9kBHKKvL W1sir8c2RXmdWbyU8pbUJe6gpw9IJaZOIrLR83p3CcsVx3FbHfTepJJ+S9KvuiBJknnS SHMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1Zcbm4OfJ4gVSGwT/FYZFj56VM5LF1OsK/aeMIXG8yI=; b=NHnOsid1CjAKSPYpsUqsGjEFiZBUXbHmCswgxN3XhECPyueRKRpYI8HN4grIjfwPFT 7etgxYd5/D+zDNBYVzbeO18rJJuGSEg8Cy83J8I2728OCUpoByCR3+DSpP/PdC95Yn86 8Q5HqYn3grmv6oTksSkOkVVG+QiVMBR5PxHNSdOYCYHdn24fWh387KaHpcO0/Cw/k1Wa PP5YnhZt+qDDGIAqjPmRdeDPbOVX8YJcPBGdj8vLzCmQYuT/1cn124Y99/O6t6nZUOMZ /ySWcxPYLEYBWK/eQQ/zeJo8WyQjlBa2D0B7nV1JmrtWnCwsX8G3TEDwJ9Vwzgyf0Azt NXfA== X-Gm-Message-State: AE9vXwOSJISxidNzN4Nf5LiAE9/tLuac+vuzuRAYr+F82QcEAdia5x45OIoZ7zYSnWtD+g== X-Received: by 10.194.21.229 with SMTP id y5mr214306wje.170.1473373974298; Thu, 08 Sep 2016 15:32:54 -0700 (PDT) Received: from a0999b0126e1.ant.amazon.com ([94.230.86.12]) by smtp.gmail.com with ESMTPSA id d8sm276298wmi.0.2016.09.08.15.32.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Sep 2016 15:32:53 -0700 (PDT) From: Michael Rolnik To: qemu-devel@nongnu.org Date: Fri, 9 Sep 2016 01:31:55 +0300 Message-Id: <1473373930-31547-15-git-send-email-mrolnik@gmail.com> X-Mailer: git-send-email 2.4.9 (Apple Git-60) In-Reply-To: <1473373930-31547-1-git-send-email-mrolnik@gmail.com> References: <1473373930-31547-1-git-send-email-mrolnik@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH RFC v1 14/29] target-arc: MPY, MPYH, MPYHU, MPYU 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: Michael Rolnik Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Michael Rolnik --- target-arc/translate-inst.c | 129 ++++++++++++++++++++++++++++++++++++++++++++ target-arc/translate-inst.h | 5 ++ 2 files changed, 134 insertions(+) diff --git a/target-arc/translate-inst.c b/target-arc/translate-inst.c index 00785bf..92c75ac 100644 --- a/target-arc/translate-inst.c +++ b/target-arc/translate-inst.c @@ -1417,3 +1417,132 @@ int arc_gen_NORM(DisasCtxt *ctx, TCGv dest, TCGv src1) return BS_NONE; } +/* + MPY +*/ +int arc_gen_MPY(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + TCGv_i64 rslt = tcg_temp_new_i64(); + TCGv_i64 srcA = tcg_temp_new_i64(); + TCGv_i64 srcB = tcg_temp_new_i64(); + + tcg_gen_ext_i32_i64(srcA, src1); + tcg_gen_ext_i32_i64(srcB, src2); + + tcg_gen_mul_i64(rslt, srcA, srcB); + + tcg_gen_trunc_i64_tl(dest, rslt); + + if (ctx->opt.f) { + TCGv_i64 temp = tcg_temp_new_i64(); + + tcg_gen_setcond_tl(TCG_COND_EQ, cpu_Zf, dest, ctx->zero); + + tcg_gen_trunc_i64_tl(cpu_Nf, rslt); + tcg_gen_shri_tl(cpu_Nf, cpu_Nf, 31); + + tcg_gen_ext_i32_i64(temp, dest); + tcg_gen_setcond_i64(TCG_COND_NE, temp, temp, rslt); + tcg_gen_trunc_i64_tl(cpu_Cf, temp); + + tcg_temp_free_i64(temp); + } + + tcg_temp_free_i64(rslt); + tcg_temp_free_i64(srcA); + tcg_temp_free_i64(srcB); + + return BS_NONE; +} + +/* + MPYH +*/ +int arc_gen_MPYH(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + TCGv_i64 rslt = tcg_temp_new_i64(); + TCGv_i64 srcA = tcg_temp_new_i64(); + TCGv_i64 srcB = tcg_temp_new_i64(); + + tcg_gen_ext_i32_i64(srcA, src1); + tcg_gen_ext_i32_i64(srcB, src2); + + tcg_gen_mul_i64(rslt, srcA, srcB); + + tcg_gen_sari_i64(rslt, rslt, 32); + tcg_gen_trunc_i64_tl(dest, rslt); + + if (ctx->opt.f) { + tcg_gen_setcond_tl(TCG_COND_EQ, cpu_Zf, dest, ctx->zero); + tcg_gen_shri_tl(cpu_Nf, dest, 31); + tcg_gen_movi_tl(cpu_Vf, 0); + } + + tcg_temp_free_i64(rslt); + tcg_temp_free_i64(srcA); + tcg_temp_free_i64(srcB); + + return BS_NONE; +} + +/* + MPYHU +*/ +int arc_gen_MPYHU(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + TCGv_i64 rslt = tcg_temp_new_i64(); + TCGv_i64 srcA = tcg_temp_new_i64(); + TCGv_i64 srcB = tcg_temp_new_i64(); + + tcg_gen_extu_i32_i64(srcA, src1); + tcg_gen_extu_i32_i64(srcB, src2); + + tcg_gen_mul_i64(rslt, srcA, srcB); + + tcg_gen_shri_i64(rslt, rslt, 32); + tcg_gen_trunc_i64_tl(dest, rslt); + + if (ctx->opt.f) { + tcg_gen_setcond_tl(TCG_COND_EQ, cpu_Zf, dest, ctx->zero); + tcg_gen_movi_tl(cpu_Nf, 0); + tcg_gen_movi_tl(cpu_Vf, 0); + } + + tcg_temp_free_i64(rslt); + tcg_temp_free_i64(srcA); + tcg_temp_free_i64(srcB); + + return BS_NONE; +} + +/* + MPYU +*/ +int arc_gen_MPYU(DisasCtxt *ctx, TCGv dest, TCGv src1, TCGv src2) +{ + TCGv_i64 rslt = tcg_temp_new_i64(); + TCGv_i64 srcA = tcg_temp_new_i64(); + TCGv_i64 srcB = tcg_temp_new_i64(); + + tcg_gen_extu_i32_i64(srcA, src1); + tcg_gen_extu_i32_i64(srcB, src2); + + tcg_gen_mul_i64(rslt, srcA, srcB); + + tcg_gen_trunc_i64_tl(dest, rslt); + + if (ctx->opt.f) { + tcg_gen_setcond_tl(TCG_COND_EQ, cpu_Zf, dest, ctx->zero); + tcg_gen_movi_tl(cpu_Nf, 0); + tcg_gen_shri_i64(rslt, rslt, 32); + tcg_gen_trunc_i64_tl(cpu_Vf, rslt); + tcg_gen_setcondi_tl(TCG_COND_NE, cpu_Vf, cpu_Vf, 0); + } + + tcg_temp_free_i64(rslt); + tcg_temp_free_i64(srcA); + tcg_temp_free_i64(srcB); + + return BS_NONE; +} + diff --git a/target-arc/translate-inst.h b/target-arc/translate-inst.h index 811c914..084c282 100644 --- a/target-arc/translate-inst.h +++ b/target-arc/translate-inst.h @@ -90,3 +90,8 @@ int arc_gen_RLC(DisasCtxt *c, TCGv dest, TCGv src1); int arc_gen_NORMW(DisasCtxt *c, TCGv dest, TCGv src1); int arc_gen_NORM(DisasCtxt *c, TCGv dest, TCGv src1); +int arc_gen_MPY(DisasCtxt *c, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_MPYH(DisasCtxt *c, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_MPYHU(DisasCtxt *c, TCGv dest, TCGv src1, TCGv src2); +int arc_gen_MPYU(DisasCtxt *c, TCGv dest, TCGv src1, TCGv src2); +