From patchwork Fri Sep 28 01:07:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187671 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 03D112C00AC for ; Fri, 28 Sep 2012 11:08:03 +1000 (EST) Received: from localhost ([::1]:49765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THP3h-0000zS-2g for incoming@patchwork.ozlabs.org; Thu, 27 Sep 2012 21:08:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THP3Y-0000zN-Og for qemu-devel@nongnu.org; Thu, 27 Sep 2012 21:07:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THP3X-0001dN-Jf for qemu-devel@nongnu.org; Thu, 27 Sep 2012 21:07:52 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:64610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THP3X-0001dH-Cw for qemu-devel@nongnu.org; Thu, 27 Sep 2012 21:07:51 -0400 Received: by pbbrp2 with SMTP id rp2so4393616pbb.4 for ; Thu, 27 Sep 2012 18:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=wUtJCzsYrk7E1B4Ionzg+m4uzlUrHiduXAanMKWcWcQ=; b=pVXIoHXL1Zbi3Pjj6TN5r/P5Mmw5ghtf8q0o6p3eFIFp0yf0mxsQZ8bvM0EN7Nh8fE yWhpHy3qtRNGgiWLzoUFbkIQ5+1GW6jrUSqAhna+K78UMHP7clK+jNTWCnuSSDKnwWvF 9MegCgkKsUXH/yKkr/rNIgcbupXLW0bsFyfu8Oj26oaQewzPwcTP0ubnZVvisR/r6Oqu Z8I1Xh1hrtSG6lswjkbBFTk4p7OdOv5QkrsaOEOSTDVKYvqV0HkSHusDFx/jSKyyMklm C/gxwOf5JqhH+Z3nu2EA9ChixW59/DjReui6DXlSm59/CUFRjkF9qGMgi54PVvABO65/ Xxbw== Received: by 10.68.201.104 with SMTP id jz8mr16204935pbc.141.1348794470834; Thu, 27 Sep 2012 18:07:50 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id i2sm4555423pay.31.2012.09.27.18.07.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 18:07:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 27 Sep 2012 18:07:47 -0700 Message-Id: <1348794467-28365-1-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348785610-23418-1-git-send-email-rth@twiddle.net> References: <1348785610-23418-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Alexander Graf Subject: [Qemu-devel] [PATCH 131/147] target-s390: Implement POPCNT 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-s390x/helper.h | 1 + target-s390x/insn-data.def | 3 +++ target-s390x/int_helper.c | 12 ++++++++++++ target-s390x/translate.c | 6 ++++++ 4 files changed, 22 insertions(+) diff --git a/target-s390x/helper.h b/target-s390x/helper.h index fba3b70..03effd1 100644 --- a/target-s390x/helper.h +++ b/target-s390x/helper.h @@ -86,6 +86,7 @@ DEF_HELPER_4(unpk, void, env, i32, i64, i64) DEF_HELPER_4(tr, void, env, i32, i64, i64) DEF_HELPER_4(cksm, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_2(sfpc, TCG_CALL_CONST, void, env, i64) +DEF_HELPER_FLAGS_1(popcnt, TCG_CALL_PURE|TCG_CALL_CONST, i64, i64) DEF_HELPER_FLAGS_5(calc_cc, TCG_CALL_PURE|TCG_CALL_CONST, i32, env, i32, i64, i64, i64) diff --git a/target-s390x/insn-data.def b/target-s390x/insn-data.def index 0777b55..49e4a44 100644 --- a/target-s390x/insn-data.def +++ b/target-s390x/insn-data.def @@ -539,6 +539,9 @@ C(0xe336, PFD, RXY_b, GIE, 0, 0, 0, 0, 0, 0) C(0xc602, PFDRL, RIL_c, GIE, 0, 0, 0, 0, 0, 0) +/* POPULATION COUNT */ + C(0xb9e1, POPCNT, RRE, PC, 0, r2_o, r1, 0, popcnt, nz64) + /* ROTATE LEFT SINGLE LOGICAL */ C(0xeb1d, RLL, RSY_a, Z, r3_o, sh32, new, r1_32, rll32, 0) C(0xeb1c, RLLG, RSY_a, Z, r3_o, sh64, r1, 0, rll64, 0) diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c index 00f764c..3a86fba 100644 --- a/target-s390x/int_helper.c +++ b/target-s390x/int_helper.c @@ -191,3 +191,15 @@ uint64_t HELPER(cvd)(int32_t bin) return dec; } + +uint64_t HELPER(popcnt)(uint64_t r2) +{ + uint64_t ret = 0; + int i; + + for (i = 0; i < 64; i += 8) { + uint64_t t = ctpop32((r2 >> i) & 0xff); + ret |= t << i; + } + return ret; +} diff --git a/target-s390x/translate.c b/target-s390x/translate.c index dddd822..6c23729 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -2558,6 +2558,12 @@ static ExitStatus op_ori(DisasContext *s, DisasOps *o) return NO_EXIT; } +static ExitStatus op_popcnt(DisasContext *s, DisasOps *o) +{ + gen_helper_popcnt(o->out, o->in2); + return NO_EXIT; +} + #ifndef CONFIG_USER_ONLY static ExitStatus op_ptlb(DisasContext *s, DisasOps *o) {