qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: "Víctor Colombo" <victor.colombo@eldorado.org.br>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: clg@kaod.org, david@gibson.dropbear.id.au, groug@kaod.org,
	richard.henderson@linaro.org, matheus.ferst@eldorado.org.br,
	lucas.araujo@eldorado.org.br, leandro.lupori@eldorado.org.br,
	lucas.coutinho@eldorado.org.br
Subject: Re: [PATCH 04/19] target/ppc: Set result to QNaN for DENBCD when VXCVI occurs
Date: Mon, 5 Sep 2022 15:21:14 -0300	[thread overview]
Message-ID: <85d51bff-9943-06e6-6cac-473ebf5bea4f@gmail.com> (raw)
In-Reply-To: <20220901131756.26060-5-victor.colombo@eldorado.org.br>



On 9/1/22 10:17, Víctor Colombo wrote:
> According to the ISA, for instruction DENBCD:
> "If an invalid BCD digit or sign code is detected in the source
> operand, an invalid-operation exception (VXCVI) occurs."
> 
> In the Invalid Operation Exception section, there is the situation:
> "When Invalid Operation Exception is disabled (VE=0) and Invalid
> Operation occurs (...) If the operation is an (...) or format the
> target FPR is set to a Quiet NaN". This was not being done in
> QEMU.
> 
> This patch sets the result to QNaN when the instruction DENBCD causes
> an Invalid Operation Exception.
> 
> Signed-off-by: Víctor Colombo <victor.colombo@eldorado.org.br>
> ---

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>

>   target/ppc/dfp_helper.c | 26 ++++++++++++++++++++++++--
>   1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/target/ppc/dfp_helper.c b/target/ppc/dfp_helper.c
> index be7aa5357a..cc024316d5 100644
> --- a/target/ppc/dfp_helper.c
> +++ b/target/ppc/dfp_helper.c
> @@ -1147,6 +1147,26 @@ static inline uint8_t dfp_get_bcd_digit_128(ppc_vsr_t *t, unsigned n)
>       return t->VsrD((n & 0x10) ? 0 : 1) >> ((n << 2) & 63) & 15;
>   }
>   
> +static inline void dfp_invalid_op_vxcvi_64(struct PPC_DFP *dfp)
> +{
> +    /* TODO: fpscr is incorrectly not being saved to env */
> +    dfp_set_FPSCR_flag(dfp, FP_VX | FP_VXCVI, FPSCR_VE);
> +    if ((dfp->env->fpscr & FP_VE) == 0) {
> +        dfp->vt.VsrD(1) = 0x7c00000000000000; /* QNaN */
> +    }
> +}
> +
> +
> +static inline void dfp_invalid_op_vxcvi_128(struct PPC_DFP *dfp)
> +{
> +    /* TODO: fpscr is incorrectly not being saved to env */
> +    dfp_set_FPSCR_flag(dfp, FP_VX | FP_VXCVI, FPSCR_VE);
> +    if ((dfp->env->fpscr & FP_VE) == 0) {
> +        dfp->vt.VsrD(0) = 0x7c00000000000000; /* QNaN */
> +        dfp->vt.VsrD(1) = 0x0;
> +    }
> +}
> +
>   #define DFP_HELPER_ENBCD(op, size)                                           \
>   void helper_##op(CPUPPCState *env, ppc_fprp_t *t, ppc_fprp_t *b,             \
>                    uint32_t s)                                                 \
> @@ -1173,7 +1193,8 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t, ppc_fprp_t *b,             \
>               sgn = 0;                                                         \
>               break;                                                           \
>           default:                                                             \
> -            dfp_set_FPSCR_flag(&dfp, FP_VX | FP_VXCVI, FPSCR_VE);            \
> +            dfp_invalid_op_vxcvi_##size(&dfp);                               \
> +            set_dfp##size(t, &dfp.vt);                                       \
>               return;                                                          \
>           }                                                                    \
>           }                                                                    \
> @@ -1183,7 +1204,8 @@ void helper_##op(CPUPPCState *env, ppc_fprp_t *t, ppc_fprp_t *b,             \
>           digits[(size) / 4 - n] = dfp_get_bcd_digit_##size(&dfp.vb,           \
>                                                             offset++);         \
>           if (digits[(size) / 4 - n] > 10) {                                   \
> -            dfp_set_FPSCR_flag(&dfp, FP_VX | FP_VXCVI, FPSCR_VE);            \
> +            dfp_invalid_op_vxcvi_##size(&dfp);                               \
> +            set_dfp##size(t, &dfp.vt);                                       \
>               return;                                                          \
>           } else {                                                             \
>               nonzero |= (digits[(size) / 4 - n] > 0);                         \


  reply	other threads:[~2022-09-05 18:25 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01 13:17 [PATCH 00/19] Multiple ppc instructions fixes Víctor Colombo
2022-09-01 13:17 ` [PATCH 01/19] target/ppc: Remove extra space from s128 field in ppc_vsr_t Víctor Colombo
2022-09-05 13:17   ` Daniel Henrique Barboza
2022-09-01 13:17 ` [PATCH 02/19] target/ppc: Remove unused xer_* macros Víctor Colombo
2022-09-05 13:58   ` Daniel Henrique Barboza
2022-09-01 13:17 ` [PATCH 03/19] target/ppc: Zero second doubleword in DFP instructions Víctor Colombo
2022-09-05 18:19   ` Daniel Henrique Barboza
2022-09-01 13:17 ` [PATCH 04/19] target/ppc: Set result to QNaN for DENBCD when VXCVI occurs Víctor Colombo
2022-09-05 18:21   ` Daniel Henrique Barboza [this message]
2022-09-01 13:17 ` [PATCH 05/19] target/ppc: Zero second doubleword for VSX madd instructions Víctor Colombo
2022-09-05 18:23   ` Daniel Henrique Barboza
2022-09-01 13:17 ` [PATCH 06/19] target/ppc: Set OV32 when OV is set Víctor Colombo
2022-09-05 18:25   ` Daniel Henrique Barboza
2022-09-01 13:17 ` [PATCH 07/19] target/ppc: Zero second doubleword of VSR registers for FPR insns Víctor Colombo
2022-09-05 18:26   ` Daniel Henrique Barboza
2022-09-01 13:17 ` [PATCH 08/19] target/ppc: Clear fpstatus flags on VSX_CVT_INT_TO_FP_VECTOR Víctor Colombo
2022-09-05 18:35   ` Daniel Henrique Barboza
2022-09-01 13:17 ` [PATCH 09/19] target/ppc: Clear fpstatus flags on VSX_CVT_INT_TO_FP Víctor Colombo
2022-09-01 13:17 ` [PATCH 10/19] target/ppc: Clear fpstatus flags on VSX_CVT_FP_TO_FP Víctor Colombo
2022-09-05 18:32   ` Daniel Henrique Barboza
2022-09-01 13:17 ` [PATCH 11/19] target/ppc: Clear fpstatus flags on VSX_CVT_FP_TO_INT_VECTOR Víctor Colombo
2022-09-01 13:17 ` [PATCH 12/19] target/ppc: Clear fpstatus flags on VSX_CVT_FP_TO_INT2 Víctor Colombo
2022-09-01 13:17 ` [PATCH 13/19] target/ppc: Clear fpstatus flags on VSX_CVT_FP_TO_INT Víctor Colombo
2022-09-01 13:17 ` [PATCH 14/19] target/ppc: Clear fpstatus flags on VSX_CVT_FP_TO_FP_HP Víctor Colombo
2022-09-01 13:17 ` [PATCH 15/19] target/ppc: Clear fpstatus flags on VSX_CVT_FP_TO_FP_VECTOR Víctor Colombo
2022-09-01 13:17 ` [PATCH 16/19] target/ppc: Clear fpstatus flags for xscvqpdp Víctor Colombo
2022-09-01 13:17 ` [PATCH 17/19] target/ppc: Clear fpstatus flags for xscvdpsp[n] Víctor Colombo
2022-09-01 13:17 ` [PATCH 18/19] target/ppc: Clear fpstatus flags on VSX_CMP Víctor Colombo
2022-09-05 18:41   ` Daniel Henrique Barboza
2022-09-05 18:58     ` Víctor Colombo
2022-09-01 13:17 ` [PATCH 19/19] target/ppc: Clear fpstatus flags on VSX_ROUND Víctor Colombo
2022-09-05 18:33   ` Daniel Henrique Barboza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85d51bff-9943-06e6-6cac-473ebf5bea4f@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=clg@kaod.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=leandro.lupori@eldorado.org.br \
    --cc=lucas.araujo@eldorado.org.br \
    --cc=lucas.coutinho@eldorado.org.br \
    --cc=matheus.ferst@eldorado.org.br \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=victor.colombo@eldorado.org.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).