From patchwork Tue Oct 18 18:50:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 120496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 10666B6F8E for ; Wed, 19 Oct 2011 06:39:18 +1100 (EST) Received: from localhost ([::1]:54755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGEm2-000228-7D for incoming@patchwork.ozlabs.org; Tue, 18 Oct 2011 14:52:26 -0400 Received: from eggs.gnu.org ([140.186.70.92]:43861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGEle-0001ej-5P for qemu-devel@nongnu.org; Tue, 18 Oct 2011 14:52:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGElc-0002FZ-2o for qemu-devel@nongnu.org; Tue, 18 Oct 2011 14:52:01 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:53655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGEla-0002CC-TX for qemu-devel@nongnu.org; Tue, 18 Oct 2011 14:51:59 -0400 Received: by mail-wy0-f173.google.com with SMTP id 15so1034654wyh.4 for ; Tue, 18 Oct 2011 11:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=uUQUWCDwER7qieUoHeI8dQ4fzCMUTVUZz5rmf4DgTvg=; b=CwyPsWw2hFPwx6B5Lc/4nbj1pMJH5yXctQmttrGJCYVDDcN+/FiwOfmNklmr8DUU0g uw8eaomew/05mnEhuO5O4Ty2X1bi2mWTMHgsoVZzw6So1rkgFm58Zv1095/PVWWsDeu1 iproXCo6BpzqtUf+WZktELykzU5tVjGWhCsh0= Received: by 10.216.9.141 with SMTP id 13mr5874796wet.79.1318963918388; Tue, 18 Oct 2011 11:51:58 -0700 (PDT) Received: from localhost.localdomain (c-71-227-161-214.hsd1.wa.comcast.net. [71.227.161.214]) by mx.google.com with ESMTPS id 11sm5169602wby.15.2011.10.18.11.51.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Oct 2011 11:51:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2011 11:50:35 -0700 Message-Id: <1318963843-25100-14-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.6.4 In-Reply-To: <1318963843-25100-1-git-send-email-rth@twiddle.net> References: <1318963843-25100-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 13/21] target-sparc: Implement PDIST. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Richard Henderson --- target-sparc/helper.h | 1 + target-sparc/translate.c | 21 +++++++++++++++++++-- target-sparc/vis_helper.c | 21 +++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/target-sparc/helper.h b/target-sparc/helper.h index 6e66574..1a8e586 100644 --- a/target-sparc/helper.h +++ b/target-sparc/helper.h @@ -137,6 +137,7 @@ DEF_HELPER_FLAGS_2(fmul8ulx16, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmuld8sux16, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64) DEF_HELPER_FLAGS_2(fmuld8ulx16, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64) DEF_HELPER_FLAGS_2(fexpand, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64) +DEF_HELPER_FLAGS_3(pdist, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64, i64) #define VIS_HELPER(name) \ DEF_HELPER_FLAGS_2(f ## name ## 16, TCG_CALL_CONST | TCG_CALL_PURE, \ i64, i64, i64) \ diff --git a/target-sparc/translate.c b/target-sparc/translate.c index d3f7648..0acb477 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -1743,6 +1743,21 @@ static void gen_ne_fop_DDD(DisasContext *dc, int rd, int rs1, int rs2, gen_store_fpr_D(dc, rd, dst); } + +static void gen_ne_fop_DDDD(DisasContext *dc, int rd, int rs1, int rs2, + void (*gen)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64)) +{ + TCGv_i64 dst, src0, src1, src2; + + src1 = gen_load_fpr_D(dc, rs1); + src2 = gen_load_fpr_D(dc, rs2); + src0 = gen_load_fpr_D(dc, rd); + dst = gen_dest_fpr_D(); + + gen(dst, src0, src1, src2); + + gen_store_fpr_D(dc, rd, dst); +} #endif static void gen_fop_QQ(DisasContext *dc, int rd, int rs, @@ -4064,9 +4079,11 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) case 0x03a: /* VIS I fpack32 */ case 0x03b: /* VIS I fpack16 */ case 0x03d: /* VIS I fpackfix */ - case 0x03e: /* VIS I pdist */ - // XXX goto illegal_insn; + case 0x03e: /* VIS I pdist */ + CHECK_FPU_FEATURE(dc, VIS1); + gen_ne_fop_DDDD(dc, rd, rs1, rs2, gen_helper_pdist); + break; case 0x048: /* VIS I faligndata */ CHECK_FPU_FEATURE(dc, VIS1); cpu_src1_64 = gen_load_fpr_D(dc, rs1); diff --git a/target-sparc/vis_helper.c b/target-sparc/vis_helper.c index 39c8d9a..cd5d4a7 100644 --- a/target-sparc/vis_helper.c +++ b/target-sparc/vis_helper.c @@ -396,3 +396,24 @@ VIS_CMPHELPER(helper_fcmpgt, FCMPGT) VIS_CMPHELPER(helper_fcmpeq, FCMPEQ) VIS_CMPHELPER(helper_fcmple, FCMPLE) VIS_CMPHELPER(helper_fcmpne, FCMPNE) + +uint64_t helper_pdist(uint64_t sum, uint64_t src1, uint64_t src2) +{ + int i; + for (i = 0; i < 8; i++) { + int s1, s2; + + s1 = (src1 >> (56 - (i * 8))) & 0xff; + s2 = (src2 >> (56 - (i * 8))) & 0xff; + + /* Absolute value of difference. */ + s1 -= s2; + if (s1 < 0) { + s1 = -s1; + } + + sum += s1; + } + + return sum; +}