qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 12/14] Add vct{u,s}xs instructions


From: Aurelien Jarno
Subject: Re: [Qemu-devel] [PATCH 12/14] Add vct{u,s}xs instructions
Date: Wed, 4 Feb 2009 15:46:23 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

On Thu, Jan 22, 2009 at 12:44:12PM -0800, Nathan Froyd wrote:
> 
> Signed-off-by: Nathan Froyd <address@hidden>
> ---
>  target-ppc/helper.h    |    2 ++
>  target-ppc/op_helper.c |   25 +++++++++++++++++++++++++
>  target-ppc/translate.c |    2 ++
>  3 files changed, 29 insertions(+), 0 deletions(-)
> 
> diff --git a/target-ppc/helper.h b/target-ppc/helper.h
> index 6e25d94..a463787 100644
> --- a/target-ppc/helper.h
> +++ b/target-ppc/helper.h
> @@ -252,6 +252,8 @@ DEF_HELPER_4(vmaddfp, void, avr, avr, avr, avr)
>  DEF_HELPER_4(vnmsubfp, void, avr, avr, avr, avr)
>  DEF_HELPER_3(vcfux, void, avr, avr, i32)
>  DEF_HELPER_3(vcfsx, void, avr, avr, i32)
> +DEF_HELPER_3(vctuxs, void, avr, avr, i32)
> +DEF_HELPER_3(vctsxs, void, avr, avr, i32)
>  
>  DEF_HELPER_1(efscfsi, i32, i32)
>  DEF_HELPER_1(efscfui, i32, i32)
> diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
> index 32ea54f..e1022ab 100644
> --- a/target-ppc/op_helper.c
> +++ b/target-ppc/op_helper.c
> @@ -2304,6 +2304,31 @@ void helper_vcmpbfp_dot (ppc_avr_t *r, ppc_avr_t *a, 
> ppc_avr_t *b)
>      vcmpbfp_internal(r, a, b, 1);
>  }
>  
> +#define VCT(suffix, type, floatcvt, satcvt, element)                    \
> +    void helper_vct##suffix (ppc_avr_t *r, ppc_avr_t *b, uint32_t uim)  \
> +    {                                                                   \
> +        int i;                                                          \
> +        int sat = 0;                                                    \
> +        for (i = 0; i < ARRAY_SIZE(r->f); i++) {                        \
> +            if (float32_is_nan(b->f[i]) ||                              \
> +                float32_is_signaling_nan(b->f[i])) {                    \
> +                r->element[i] = 0;                                      \
> +            } else {                                                    \
> +                float64 t = float32_to_float64(b->f[i], &env->vec_status); \
> +                type j;                                                 \
> +                t = float64_scalbn(t, uim, &env->vec_status);           \
> +                j = floatcvt(t, &env->vec_status);                      \
> +                r->element[i] = satcvt(j, &sat);                        \
> +            }                                                           \
> +        }                                                               \
> +        if (sat) {                                                      \
> +            env->vscr |= (1 << VSCR_SAT);                               \
> +        }                                                               \
> +    }
> +VCT(uxs, uint64_t, float64_to_uint64, cvtuduw, u32)

This doesn't work as a negative value should set VSCR_SAT. The solution
is to use instead:
VCT(uxs, int64_t, float64_to_int64, cvtsduw, u32)

Also the documentation says that the Round toward Zero mode should be
selected for this instruction.

> +VCT(sxs, int64_t, float64_to_int64, cvtsdsw, s32)
> +#undef VCT
> +
>  void helper_vmaddfp (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
>  {
>      int i;
> diff --git a/target-ppc/translate.c b/target-ppc/translate.c
> index e0cbf45..81011a2 100644
> --- a/target-ppc/translate.c
> +++ b/target-ppc/translate.c
> @@ -6520,6 +6520,8 @@ GEN_VXFORM_UIMM(vsplth, 6, 9);
>  GEN_VXFORM_UIMM(vspltw, 6, 10);
>  GEN_VXFORM_UIMM(vcfux, 5, 12);
>  GEN_VXFORM_UIMM(vcfsx, 5, 13);
> +GEN_VXFORM_UIMM(vctuxs, 5, 14);
> +GEN_VXFORM_UIMM(vctsxs, 5, 15);
>  
>  GEN_HANDLER(vsldoi, 0x04, 0x16, 0xFF, 0x00000400, PPC_ALTIVEC)
>  {
> -- 
> 1.6.0.5
> 
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
address@hidden                 http://www.aurel32.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]