From patchwork Fri Apr 18 14:50:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Musta X-Patchwork-Id: 340367 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EC3571400FD for ; Sat, 19 Apr 2014 02:20:05 +1000 (EST) Received: from localhost ([::1]:38446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbAOk-0002de-N3 for incoming@patchwork.ozlabs.org; Fri, 18 Apr 2014 11:08:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbA8w-0006lY-S8 for qemu-devel@nongnu.org; Fri, 18 Apr 2014 10:52:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WbA8j-0000vn-0P for qemu-devel@nongnu.org; Fri, 18 Apr 2014 10:51:54 -0400 Received: from mail-qg0-x233.google.com ([2607:f8b0:400d:c04::233]:46632) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbA8i-0000vc-Rn; Fri, 18 Apr 2014 10:51:40 -0400 Received: by mail-qg0-f51.google.com with SMTP id q108so1766106qgd.10 for ; Fri, 18 Apr 2014 07:51:40 -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=rayXE0l7W+v9Zz+lFg+B2MQI/iE89JTHMBSruFVZqOo=; b=K8lE0JkEi3kSyZ1TeVTMwcgvBpl+H61+HcVJKPlsi95etBBkKK8Q/ORy6cNlkiAMlW wUuUTH/kLCnKzrqlROIdc7kv2LqVQtJNgXk5CMONNoffoHVPyhb+WTvTKODuBKp+LQr9 GFdJiyzxUUQ8RUYMMt30Gbjh9cZuCghZRVN+nZlPQeA8JKQ7gNTPmUeo8GvTcxtG2e69 AJNBmBJvbh2ooEtzNqwH5FoZc0K/rqtmbk1eIiEIhZtszR1DMI+uXTtkP3qpZj3wvrOX GebhrLlhA1bKAvenPNCrX+ZggiRlk/TuVXaI8Ceia1OPl/atoKuKqCCgh16I7F8NEthO 9hyQ== X-Received: by 10.224.115.3 with SMTP id g3mr21415210qaq.19.1397832700381; Fri, 18 Apr 2014 07:51:40 -0700 (PDT) Received: from tmusta-sc.rchland.ibm.com (rchp4.rochester.ibm.com. [129.42.161.36]) by mx.google.com with ESMTPSA id u59sm37020178qga.8.2014.04.18.07.51.39 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Apr 2014 07:51:39 -0700 (PDT) From: Tom Musta To: qemu-devel@nongnu.org Date: Fri, 18 Apr 2014 09:50:37 -0500 Message-Id: <1397832641-10254-34-git-send-email-tommusta@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397832641-10254-1-git-send-email-tommusta@gmail.com> References: <1397832641-10254-1-git-send-email-tommusta@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::233 Cc: Tom Musta , qemu-ppc@nongnu.org Subject: [Qemu-devel] [PATCH 33/37] target-ppc: Introduce DFP Decode DPD to BCD 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 Add emulation of the Power PC Decimal Floating Point Decode Densely Packed Decimal to Binary Coded Decimal instructions ddedpd[q][.]. Signed-off-by: Tom Musta --- target-ppc/dfp_helper.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/helper.h | 2 + target-ppc/translate.c | 4 +++ 3 files changed, 72 insertions(+), 0 deletions(-) diff --git a/target-ppc/dfp_helper.c b/target-ppc/dfp_helper.c index bf30bd8..174db20 100644 --- a/target-ppc/dfp_helper.c +++ b/target-ppc/dfp_helper.c @@ -993,3 +993,69 @@ void helper_##op(CPUPPCState *env, uint64_t *t, uint64_t *b) \ DFP_HELPER_CTFIX(dctfix, 64) DFP_HELPER_CTFIX(dctfixq, 128) + +static inline void dfp_set_bcd_digit_64(uint64_t *t, uint8_t digit, + unsigned n) +{ + *t |= ((uint64_t)(digit & 0xF) << (n << 2)); +} + +static inline void dfp_set_bcd_digit_128(uint64_t *t, uint8_t digit, + unsigned n) +{ + t[(n & 0x10) ? HI_IDX : LO_IDX] |= + ((uint64_t)(digit & 0xF) << ((n & 15) << 2)); +} + +static inline void dfp_set_sign_64(uint64_t *t, uint8_t sgn) +{ + *t <<= 4; + *t |= (sgn & 0xF); +} + +static inline void dfp_set_sign_128(uint64_t *t, uint8_t sgn) +{ + t[HI_IDX] <<= 4; + t[HI_IDX] |= (t[LO_IDX] >> 60); + t[LO_IDX] <<= 4; + t[LO_IDX] |= (sgn & 0xF); +} + +#define DFP_HELPER_DEDPD(op, size) \ +void helper_##op(CPUPPCState *env, uint64_t *t, uint64_t *b, uint32_t sp) \ +{ \ + struct PPC_DFP dfp; \ + uint8_t digits[34]; \ + int i, N; \ + \ + dfp_prepare_decimal##size(&dfp, 0, b, env); \ + \ + decNumberGetBCD(&dfp.b, digits); \ + dfp.t64[0] = dfp.t64[1] = 0; \ + N = dfp.b.digits; \ + \ + for (i = 0; (i < N) && (i < (size)/4); i++) { \ + dfp_set_bcd_digit_##size(dfp.t64, digits[N-i-1], i); \ + } \ + \ + if (sp & 2) { \ + uint8_t sgn; \ + \ + if (decNumberIsNegative(&dfp.b)) { \ + sgn = 0xD; \ + } else { \ + sgn = ((sp & 1) ? 0xF : 0xC); \ + } \ + dfp_set_sign_##size(dfp.t64, sgn); \ + } \ + \ + if (size == 64) { \ + t[0] = dfp.t64[0]; \ + } else if (size == 128) { \ + t[0] = dfp.t64[HI_IDX]; \ + t[1] = dfp.t64[LO_IDX]; \ + } \ +} + +DFP_HELPER_DEDPD(ddedpd, 64) +DFP_HELPER_DEDPD(ddedpdq, 128) diff --git a/target-ppc/helper.h b/target-ppc/helper.h index 30ba9d9..0d5acf5 100644 --- a/target-ppc/helper.h +++ b/target-ppc/helper.h @@ -656,4 +656,6 @@ DEF_HELPER_3(dcffix, void, env, fprp, fprp) DEF_HELPER_3(dcffixq, void, env, fprp, fprp) DEF_HELPER_3(dctfix, void, env, fprp, fprp) DEF_HELPER_3(dctfixq, void, env, fprp, fprp) +DEF_HELPER_4(ddedpd, void, env, fprp, fprp, i32) +DEF_HELPER_4(ddedpdq, void, env, fprp, fprp, i32) #include "exec/def-helper.h" diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 3f2f649..395a048 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -8394,6 +8394,8 @@ GEN_DFP_T_B_Rc(dcffix) GEN_DFP_T_B_Rc(dcffixq) GEN_DFP_T_B_Rc(dctfix) GEN_DFP_T_B_Rc(dctfixq) +GEN_DFP_T_FPR_I32_Rc(ddedpd, rB, SP) +GEN_DFP_T_FPR_I32_Rc(ddedpdq, rB, SP) /*** SPE extension ***/ /* Register moves */ @@ -11359,6 +11361,8 @@ GEN_DFP_T_B_Rc(dcffix, 0x02, 0x19), GEN_DFP_Tp_B_Rc(dcffixq, 0x02, 0x19), GEN_DFP_T_B_Rc(dctfix, 0x02, 0x09), GEN_DFP_T_Bp_Rc(dctfixq, 0x02, 0x09), +GEN_DFP_SP_T_B_Rc(ddedpd, 0x02, 0x0a), +GEN_DFP_SP_Tp_Bp_Rc(ddedpdq, 0x02, 0x0a), #undef GEN_SPE #define GEN_SPE(name0, name1, opc2, opc3, inval0, inval1, type) \ GEN_OPCODE_DUAL(name0##_##name1, 0x04, opc2, opc3, inval0, inval1, type, PPC_NONE)