[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [V2 PATCH 30/37] target-ppc: Introduce Round to DFP Short/Lon
From: |
Tom Musta |
Subject: |
[Qemu-ppc] [V2 PATCH 30/37] target-ppc: Introduce Round to DFP Short/Long |
Date: |
Mon, 21 Apr 2014 15:55:14 -0500 |
Add emulation of the PowerPC Round to DFP Short (drsp[.]) and Round to
DFP Long (drdpq[.]) instructions.
Signed-off-by: Tom Musta <address@hidden>
---
V2: Modify post-processor handling per Richard Henderson's review.
target-ppc/dfp_helper.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
target-ppc/helper.h | 2 +
target-ppc/translate.c | 4 +++
3 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/target-ppc/dfp_helper.c b/target-ppc/dfp_helper.c
index 7a62ed0..3c92543 100644
--- a/target-ppc/dfp_helper.c
+++ b/target-ppc/dfp_helper.c
@@ -247,6 +247,20 @@ static void dfp_set_FPRF_from_FRT(struct PPC_DFP *dfp)
dfp_set_FPRF_from_FRT_with_context(dfp, &dfp->context);
}
+static void dfp_set_FPRF_from_FRT_short(struct PPC_DFP *dfp)
+{
+ decContext shortContext;
+ decContextDefault(&shortContext, DEC_INIT_DECIMAL32);
+ dfp_set_FPRF_from_FRT_with_context(dfp, &shortContext);
+}
+
+static void dfp_set_FPRF_from_FRT_long(struct PPC_DFP *dfp)
+{
+ decContext longContext;
+ decContextDefault(&longContext, DEC_INIT_DECIMAL64);
+ dfp_set_FPRF_from_FRT_with_context(dfp, &longContext);
+}
+
static void dfp_check_for_OX(struct PPC_DFP *dfp)
{
if (dfp->context.status & DEC_Overflow) {
@@ -870,3 +884,37 @@ void helper_dctqpq(CPUPPCState *env, uint64_t *t, uint64_t
*b)
t[0] = dfp.t64[HI_IDX];
t[1] = dfp.t64[LO_IDX];
}
+
+void helper_drsp(CPUPPCState *env, uint64_t *t, uint64_t *b)
+{
+ struct PPC_DFP dfp;
+ uint32_t t_short = 0;
+ dfp_prepare_decimal64(&dfp, 0, b, env);
+ decimal32FromNumber((decimal32 *)&t_short, &dfp.b, &dfp.context);
+ decimal32ToNumber((decimal32 *)&t_short, &dfp.t);
+
+ dfp_set_FPRF_from_FRT_short(&dfp);
+ dfp_check_for_OX(&dfp);
+ dfp_check_for_UX(&dfp);
+ dfp_check_for_XX(&dfp);
+
+ *t = t_short;
+}
+
+void helper_drdpq(CPUPPCState *env, uint64_t *t, uint64_t *b)
+{
+ struct PPC_DFP dfp;
+ dfp_prepare_decimal128(&dfp, 0, b, env);
+ decimal64FromNumber((decimal64 *)&dfp.t64, &dfp.b, &dfp.context);
+ decimal64ToNumber((decimal64 *)&dfp.t64, &dfp.t);
+
+ dfp_check_for_VXSNAN_and_convert_to_QNaN(&dfp);
+ dfp_set_FPRF_from_FRT_long(&dfp);
+ dfp_check_for_OX(&dfp);
+ dfp_check_for_UX(&dfp);
+ dfp_check_for_XX(&dfp);
+
+ decimal64FromNumber((decimal64 *)dfp.t64, &dfp.t, &dfp.context);
+ t[0] = dfp.t64[0];
+ t[1] = 0;
+}
diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index a99ca1c..d9ef8f6 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -650,4 +650,6 @@ DEF_HELPER_5(drintn, void, env, fprp, fprp, i32, i32)
DEF_HELPER_5(drintnq, void, env, fprp, fprp, i32, i32)
DEF_HELPER_3(dctdp, void, env, fprp, fprp)
DEF_HELPER_3(dctqpq, void, env, fprp, fprp)
+DEF_HELPER_3(drsp, void, env, fprp, fprp)
+DEF_HELPER_3(drdpq, void, env, fprp, fprp)
#include "exec/def-helper.h"
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index da70c8d..391f55d 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -8388,6 +8388,8 @@ GEN_DFP_T_B_U32_U32_Rc(drintn, FPW, RMC)
GEN_DFP_T_B_U32_U32_Rc(drintnq, FPW, RMC)
GEN_DFP_T_B_Rc(dctdp)
GEN_DFP_T_B_Rc(dctqpq)
+GEN_DFP_T_B_Rc(drsp)
+GEN_DFP_T_B_Rc(drdpq)
/*** SPE extension ***/
/* Register moves */
@@ -11347,6 +11349,8 @@ GEN_DFP_R_T_B_RMC_Rc(drintn, 0x03, 0x07),
GEN_DFP_R_Tp_Bp_RMC_Rc(drintnq, 0x03, 0x07),
GEN_DFP_T_B_Rc(dctdp, 0x02, 0x08),
GEN_DFP_Tp_B_Rc(dctqpq, 0x02, 0x08),
+GEN_DFP_T_B_Rc(drsp, 0x02, 0x18),
+GEN_DFP_Tp_Bp_Rc(drdpq, 0x02, 0x18),
#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)
--
1.7.1
- [Qemu-ppc] [V2 PATCH 11/37] libdecnumber: Fix decNumberSetBCD, (continued)
- [Qemu-ppc] [V2 PATCH 11/37] libdecnumber: Fix decNumberSetBCD, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 13/37] target-ppc: Introduce Generator Macros for DFP Arithmetic Forms, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 14/37] target-ppc: Introduce Decoder Macros for DFP, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 16/37] target-ppc: Introduce DFP Post Processor Utilities, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 17/37] target-ppc: Introduce DFP Add, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 18/37] target-ppc: Introduce DFP Subtract, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 19/37] target-ppc: Introduce DFP Multiply, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 20/37] target-ppc: Introduce DFP Divide, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 28/37] target-ppc: Introduce DFP Round to Integer, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 29/37] target-ppc: Introduce DFP Convert to Long/Extended, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 30/37] target-ppc: Introduce Round to DFP Short/Long,
Tom Musta <=
- [Qemu-ppc] [V2 PATCH 32/37] target-ppc: Introduce DFP Convert to Fixed, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 33/37] target-ppc: Introduce DFP Decode DPD to BCD, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 31/37] target-ppc: Introduce DFP Convert to Fixed, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 23/37] target-ppc: Introduce DFP Test Data Group, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 24/37] target-ppc: Introduce DFP Test Exponent, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 21/37] target-ppc: Introduce DFP Compares, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 01/37] libdecnumber: Introduce libdecnumber Code, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 35/37] target-ppc: Introduce DFP Extract Biased Exponent, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 22/37] target-ppc: Introduce DFP Test Data Class, Tom Musta, 2014/04/21
- [Qemu-ppc] [V2 PATCH 27/37] target-ppc: Introduce DFP Reround, Tom Musta, 2014/04/21