[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 7/9] target-xtensa: implement FP0 conversions
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 7/9] target-xtensa: implement FP0 conversions |
Date: |
Sun, 9 Sep 2012 12:06:47 +0100 |
On 9 September 2012 02:29, Max Filippov <address@hidden> wrote:
> +uint32_t HELPER(ftoui)(float32 v, uint32_t rounding_mode, uint32_t scale)
> +{
> + float_status fp_status = {0};
> + float32 zero = {0};
This probably won't compile if you turn on USE_SOFTFLOAT_STRUCT_TYPES
in softfloat.h. (That's a define intended to assist in avoiding
accidental mixing of the softfloat types with native int/float types.)
In any case softfloat.h provides a float32_zero which is probably what
you want to use here.
> + float32 res;
> +
> + set_float_rounding_mode(rounding_mode, &fp_status);
> +
> + res = float32_mul(v, uint32_to_float32(scale, &fp_status), &fp_status);
Can you use the softflota scalbn function here instead?
> +
> + if (float32_compare_quiet(v, zero, &fp_status) == float_relation_less) {
> + return float32_to_int32(res, &fp_status);
> + } else {
> + return float32_to_uint32(res, &fp_status);
> + }
This looks rather odd...are you sure it's correct?
> +}
> +
> +float32 HELPER(itof)(CPUXtensaState *env, uint32_t v, uint32_t scale)
> +{
> + return float32_div(
> + int32_to_float32(v, &env->fp_status),
> + uint32_to_float32(scale, &env->fp_status),
> + &env->fp_status);
> +}
> +
> +float32 HELPER(uitof)(CPUXtensaState *env, uint32_t v, uint32_t scale)
> +{
> + return float32_div(
> + uint32_to_float32(v, &env->fp_status),
> + uint32_to_float32(scale, &env->fp_status),
> + &env->fp_status);
Again, scalbn should let you avoid this division. (check how the
ARM float-to-int and int-to-float are done, I think the semantics
are similar.)
-- PMM
- Re: [Qemu-devel] [PATCH 3/9] target-xtensa: specialize softfloat NaN rules, (continued)
[Qemu-devel] [PATCH 4/9] target-xtensa: add FP registers, Max Filippov, 2012/09/08
[Qemu-devel] [PATCH 5/9] target-xtensa: implement LSCX and LSCI groups, Max Filippov, 2012/09/08
[Qemu-devel] [PATCH 6/9] target-xtensa: implement FP0 arithmetic, Max Filippov, 2012/09/08
[Qemu-devel] [PATCH 7/9] target-xtensa: implement FP0 conversions, Max Filippov, 2012/09/08
- Re: [Qemu-devel] [PATCH 7/9] target-xtensa: implement FP0 conversions,
Peter Maydell <=
[Qemu-devel] [PATCH 8/9] target-xtensa: implement FP1 group, Max Filippov, 2012/09/08
[Qemu-devel] [PATCH 9/9] target-xtensa: implement coprocessor context option, Max Filippov, 2012/09/08