[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/53] target/ppc: introduce dfp_finalize_decimal{64, 128}() helpe
From: |
David Gibson |
Subject: |
[PULL 25/53] target/ppc: introduce dfp_finalize_decimal{64, 128}() helper functions |
Date: |
Fri, 4 Oct 2019 19:37:19 +1000 |
From: Mark Cave-Ayland <address@hidden>
Most of the DFP helper functions call decimal{64,128}FromNumber() just before
returning in order to convert the decNumber stored in dfp.t64 back to a
Decimal{64,128} to write back to the FP registers.
Introduce new dfp_finalize_decimal{64,128}() helper functions which both enable
the parameter list to be reduced considerably, and also help minimise the
changes required in the next patch.
Signed-off-by: Mark Cave-Ayland <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
target/ppc/dfp_helper.c | 42 ++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/target/ppc/dfp_helper.c b/target/ppc/dfp_helper.c
index ab5e91d8ed..8e1ea2971a 100644
--- a/target/ppc/dfp_helper.c
+++ b/target/ppc/dfp_helper.c
@@ -191,6 +191,16 @@ static void dfp_prepare_decimal128(struct PPC_DFP *dfp,
ppc_fprp_t *a,
}
}
+static void dfp_finalize_decimal64(struct PPC_DFP *dfp)
+{
+ decimal64FromNumber((decimal64 *)&dfp->t64, &dfp->t, &dfp->context);
+}
+
+static void dfp_finalize_decimal128(struct PPC_DFP *dfp)
+{
+ decimal128FromNumber((decimal128 *)&dfp->t64, &dfp->t, &dfp->context);
+}
+
static void dfp_set_FPSCR_flag(struct PPC_DFP *dfp, uint64_t flag,
uint64_t enabled)
{
@@ -422,7 +432,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *a, \
struct PPC_DFP dfp;
\
dfp_prepare_decimal##size(&dfp, a, b, env);
\
dnop(&dfp.t, &dfp.a, &dfp.b, &dfp.context);
\
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, &dfp.context);
\
+ dfp_finalize_decimal##size(&dfp);
\
postprocs(&dfp);
\
if (size == 64) {
\
set_dfp64(t, dfp.t64);
\
@@ -491,7 +501,7 @@ uint32_t helper_##op(CPUPPCState *env, ppc_fprp_t *a,
ppc_fprp_t *b) \
struct PPC_DFP dfp;
\
dfp_prepare_decimal##size(&dfp, a, b, env);
\
dnop(&dfp.t, &dfp.a, &dfp.b, &dfp.context);
\
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, &dfp.context);
\
+ dfp_finalize_decimal##size(&dfp);
\
postprocs(&dfp);
\
return dfp.crbf;
\
}
@@ -741,8 +751,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *b, \
dfp.a.exponent = (int32_t)((int8_t)(te << 3) >> 3); \
\
dfp_quantize(rmc, &dfp); \
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, \
- &dfp.context); \
+ dfp_finalize_decimal##size(&dfp); \
QUA_PPs(&dfp); \
\
if (size == 64) { \
@@ -764,8 +773,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *a, \
dfp_prepare_decimal##size(&dfp, a, b, env); \
\
dfp_quantize(rmc, &dfp); \
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, \
- &dfp.context); \
+ dfp_finalize_decimal##size(&dfp); \
QUA_PPs(&dfp); \
\
if (size == 64) { \
@@ -847,8 +855,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *a, \
ref_sig = a64 & 0x3f; \
\
_dfp_reround(rmc, ref_sig, xmax, &dfp); \
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, \
- &dfp.context); \
+ dfp_finalize_decimal##size(&dfp); \
QUA_PPs(&dfp); \
\
if (size == 64) { \
@@ -871,7 +878,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *b, \
\
dfp_set_round_mode_from_immediate(r, rmc, &dfp);
\
decNumberToIntegralExact(&dfp.t, &dfp.b, &dfp.context);
\
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, &dfp.context);
\
+ dfp_finalize_decimal##size(&dfp);
\
postprocs(&dfp);
\
\
if (size == 64) {
\
@@ -911,7 +918,7 @@ void helper_dctdp(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *b)
dfp_prepare_decimal64(&dfp, 0, 0, env);
decimal32ToNumber((decimal32 *)&b_short, &dfp.t);
- decimal64FromNumber((decimal64 *)&dfp.t64, &dfp.t, &dfp.context);
+ dfp_finalize_decimal64(&dfp);
set_dfp64(t, dfp.t64);
dfp_set_FPRF_from_FRT(&dfp);
}
@@ -927,7 +934,7 @@ void helper_dctqpq(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *b)
dfp_check_for_VXSNAN_and_convert_to_QNaN(&dfp);
dfp_set_FPRF_from_FRT(&dfp);
- decimal128FromNumber((decimal128 *)&dfp.t64, &dfp.t, &dfp.context);
+ dfp_finalize_decimal128(&dfp);
set_dfp128(t, dfp.t64);
}
@@ -963,7 +970,7 @@ void helper_drdpq(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *b)
dfp_check_for_XX(&dfp);
dfp.t64[0] = dfp.t64[1] = 0;
- decimal64FromNumber((decimal64 *)dfp.t64, &dfp.t, &dfp.context);
+ dfp_finalize_decimal64(&dfp);
set_dfp128(t, dfp.t64);
}
@@ -975,7 +982,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *b) \
dfp_prepare_decimal##size(&dfp, 0, b, env);
\
get_dfp64(&b64, b);
\
decNumberFromInt64(&dfp.t, (int64_t)b64);
\
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, &dfp.context);
\
+ dfp_finalize_decimal##size(&dfp);
\
CFFIX_PPs(&dfp);
\
\
if (size == 64) {
\
@@ -1155,8 +1162,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *b, \
if (s && sgn) { \
dfp.t.bits |= DECNEG; \
} \
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, \
- &dfp.context); \
+ dfp_finalize_decimal##size(&dfp); \
dfp_set_FPRF_from_FRT(&dfp); \
if ((size) == 64) { \
set_dfp64(t, dfp.t64); \
@@ -1259,8 +1265,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *a, \
dfp.t.bits &= ~DECSPECIAL; \
} \
dfp.t.exponent = exp - bias; \
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, \
- &dfp.context); \
+ dfp_finalize_decimal##size(&dfp); \
} \
if (size == 64) { \
set_dfp64(t, dfp.t64); \
@@ -1340,8 +1345,7 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t,
ppc_fprp_t *a, \
dfp.t.digits = max_digits - 1; \
} \
\
- decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, \
- &dfp.context); \
+ dfp_finalize_decimal##size(&dfp); \
} else { \
if ((size) == 64) { \
dfp.t64[0] = dfp.a64[0] & 0xFFFC000000000000ULL; \
--
2.21.0
- [PULL 20/53] spapr: Stop providing RTAS blob, (continued)
- [PULL 20/53] spapr: Stop providing RTAS blob, David Gibson, 2019/10/04
- [PULL 13/53] ppc: Use FPSCR defines instead of constants, David Gibson, 2019/10/04
- [PULL 26/53] target/ppc: change struct PPC_DFP decimal storage from uint64[2] to ppc_vsr_t, David Gibson, 2019/10/04
- [PULL 18/53] spapr: Skip leading zeroes from memory@ DT node names, David Gibson, 2019/10/04
- [PULL 17/53] spapr: Fixes a leak in CAS, David Gibson, 2019/10/04
- [PULL 15/53] spapr: Simplify handling of pre ISA 3.0 guest workaround handling, David Gibson, 2019/10/04
- [PULL 19/53] spapr: Do not put empty properties for -kernel/-initrd/-append, David Gibson, 2019/10/04
- [PULL 28/53] target/ppc: remove unnecessary if() around calls to set_dfp{64, 128}() in DFP macros, David Gibson, 2019/10/04
- [PULL 32/53] spapr/xive: skip partially initialized vCPUs in presenter, David Gibson, 2019/10/04
- [PULL 22/53] target/ppc: introduce get_dfp{64, 128}() helper functions, David Gibson, 2019/10/04
- [PULL 25/53] target/ppc: introduce dfp_finalize_decimal{64, 128}() helper functions,
David Gibson <=
- [PULL 29/53] spapr-pci: Stop providing assigned-addresses, David Gibson, 2019/10/04
- [PULL 30/53] spapr: Render full FDT on ibm, client-architecture-support, David Gibson, 2019/10/04
- [PULL 27/53] target/ppc: use existing VsrD() macro to eliminate HI_IDX and LO_IDX from dfp_helper.c, David Gibson, 2019/10/04
- [PULL 31/53] target/ppc: use Vsr macros in BCD helpers, David Gibson, 2019/10/04
- [PULL 23/53] target/ppc: introduce set_dfp{64, 128}() helper functions, David Gibson, 2019/10/04
- [PULL 33/53] xics: Minor fixes for XICSFabric interface, David Gibson, 2019/10/04
- [PULL 35/53] xics: Rename misleading ics_simple_*() functions, David Gibson, 2019/10/04
- [PULL 37/53] xics: Merge TYPE_ICS_BASE and TYPE_ICS_SIMPLE classes, David Gibson, 2019/10/04
- [PULL 36/53] xics: Eliminate reset hook, David Gibson, 2019/10/04
- [PULL 34/53] xics: Eliminate 'reject', 'resend' and 'eoi' class hooks, David Gibson, 2019/10/04