[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/7] target/ppc: introduce set_dfp{64,128}() helper functions
From: |
Richard Henderson |
Subject: |
Re: [PATCH 2/7] target/ppc: introduce set_dfp{64,128}() helper functions |
Date: |
Tue, 24 Sep 2019 14:27:18 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
On 9/24/19 8:35 AM, Mark Cave-Ayland wrote:
> The existing functions (now incorrectly) assume that the MSB and LSB of DFP
> numbers are stored as consecutive 64-bit words in memory. Instead of accessing
> the DFP numbers directly, introduce set_dfp{64,128}() helper functions to ease
> the switch to the correct representation.
>
> Signed-off-by: Mark Cave-Ayland <address@hidden>
> ---
> target/ppc/dfp_helper.c | 90 ++++++++++++++++++++++-------------------
> 1 file changed, 48 insertions(+), 42 deletions(-)
>
> diff --git a/target/ppc/dfp_helper.c b/target/ppc/dfp_helper.c
> index 354a4aa877..cb98780d20 100644
> --- a/target/ppc/dfp_helper.c
> +++ b/target/ppc/dfp_helper.c
> @@ -47,6 +47,17 @@ static void get_dfp128(uint64_t *dst, uint64_t *dfp)
> dst[1] = dfp[LO_IDX];
> }
>
> +static void set_dfp64(uint64_t *dfp, uint64_t *src)
> +{
> + dfp[0] = src[0];
> +}
> +
> +static void set_dfp128(uint64_t *dfp, uint64_t *src)
> +{
> + dfp[0] = src[HI_IDX];
> + dfp[1] = src[LO_IDX];
> +}
...
> decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t,
> &dfp.context);\
> postprocs(&dfp); \
> if (size == 64) { \
> - t[0] = dfp.t64[0]; \
> + set_dfp64(t, dfp.t64); \
> } else if (size == 128) { \
> - t[0] = dfp.t64[HI_IDX]; \
> - t[1] = dfp.t64[LO_IDX]; \
> + set_dfp128(t, dfp.t64); \
> }
This is perhaps a bit harder to see than the get case, because POSTPROCS is in
the way.
However, we can guess, because postprocs has not been passed GETPC(), that it
cannot longjmp out, and therefore not interfere with writing back of the result
to the register file. And, as it turns out from inspection, the set of
postprocs also does not modify dfp->t64; only looks at dfp->context.status.
Therefore, as a first step we can move postprocs down, then as a second step
combine the conversion from decNumber (dfp->t) to decimal128, and then into the
register file (t).
r~
- [PATCH 0/7] target/ppc: DFP fixes and improvements, Mark Cave-Ayland, 2019/09/24
- [PATCH 2/7] target/ppc: introduce set_dfp{64,128}() helper functions, Mark Cave-Ayland, 2019/09/24
- Re: [PATCH 2/7] target/ppc: introduce set_dfp{64,128}() helper functions,
Richard Henderson <=
- [PATCH 3/7] target/ppc: update {get, set}_dfp{64, 128}() helper functions to read/write DFP numbers correctly, Mark Cave-Ayland, 2019/09/24
- [PATCH 6/7] target/ppc: use existing VsrD() macro to eliminate HI_IDX and LO_IDX from dfp_helper.c, Mark Cave-Ayland, 2019/09/24
[PATCH 4/7] target/ppc: introduce dfp_finalize_decimal{64, 128}() helper functions, Mark Cave-Ayland, 2019/09/24
[PATCH 5/7] target/ppc: change struct PPC_DFP decimal storage from uint64[2] to ppc_vsr_t, Mark Cave-Ayland, 2019/09/24