From patchwork Tue Oct 6 14:56:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 526797 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CA49F14012C for ; Wed, 7 Oct 2015 01:59:07 +1100 (AEDT) Received: from localhost ([::1]:52178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjThq-0005Sv-0S for incoming@patchwork.ozlabs.org; Tue, 06 Oct 2015 10:59:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjTfO-0003JX-UJ for qemu-devel@nongnu.org; Tue, 06 Oct 2015 10:56:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjTfK-0002ps-OV for qemu-devel@nongnu.org; Tue, 06 Oct 2015 10:56:34 -0400 Received: from col004-omc2s9.hotmail.com ([65.55.34.83]:53184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjTfK-0002pf-Db for qemu-devel@nongnu.org; Tue, 06 Oct 2015 10:56:30 -0400 Received: from COL130-W9 ([65.55.34.73]) by COL004-OMC2S9.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Tue, 6 Oct 2015 07:56:29 -0700 X-TMN: [oFHr4MrsY/DNBZ/VhFG7nUI/GOleAKsT] X-Originating-Email: [xili_gchen_5257@hotmail.com] Message-ID: From: Chen Gang To: "rth@twiddle.net" , Peter Maydell , Chris Metcalf Date: Tue, 6 Oct 2015 22:56:29 +0800 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 06 Oct 2015 14:56:29.0897 (UTC) FILETIME=[2ED6EB90:01D10047] X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 65.55.34.83 Cc: qemu-devel Subject: [Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From 3655bbab04063bc0878510ab260832c7a6a2a925 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Tue, 6 Oct 2015 21:45:11 +0800 Subject: [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values Original implementation use int*_to_float32 and float32_to_int*, which will generate incorrect result. Also remove t_to_float64 and float64_to_t, use make_float64 and float64 instead of. Signed-off-by: Chen Gang ---  target-tilegx/fpu_helper.c | 63 +++++++++++-----------------------------------  1 file changed, 15 insertions(+), 48 deletions(-) --  1.9.3 diff --git a/target-tilegx/fpu_helper.c b/target-tilegx/fpu_helper.c index daae570..095085d 100644 --- a/target-tilegx/fpu_helper.c +++ b/target-tilegx/fpu_helper.c @@ -54,20 +54,6 @@ static void fdouble_ana(FPUTLGState *fpu,      }  }   -static float64 t_to_float64(uint64_t a) -{ -    CPU_DoubleU r; -    r.ll = a; -    return r.d; -} - -static uint64_t float64_to_t(float64 fa) -{ -    CPU_DoubleU r; -    r.d = fa; -    return r.ll; -} -  static uint64_t ctx_to_uint64(TileGXFPCtx a)  {      union { @@ -108,21 +94,21 @@ static uint64_t fdouble_calc(FPUTLGState *fpu,  uint64_t helper_fdouble_add_flags(CPUTLGState *env,                                    uint64_t rsrc, uint64_t rsrcb)  { -    return fdouble_calc(&env->fpu, t_to_float64(rsrc), t_to_float64(rsrcb), +    return fdouble_calc(&env->fpu, make_float64(rsrc), make_float64(rsrcb),                          float64_add);  }    uint64_t helper_fdouble_sub_flags(CPUTLGState *env,                                    uint64_t rsrc, uint64_t rsrcb)  { -    return fdouble_calc(&env->fpu, t_to_float64(rsrc), t_to_float64(rsrcb), +    return fdouble_calc(&env->fpu, make_float64(rsrc), make_float64(rsrcb),                          float64_sub);  }    uint64_t helper_fdouble_mul_flags(CPUTLGState *env,                                    uint64_t rsrc, uint64_t rsrcb)  { -    return fdouble_calc(&env->fpu, t_to_float64(rsrc), t_to_float64(rsrcb), +    return fdouble_calc(&env->fpu, make_float64(rsrc), make_float64(rsrcb),                          float64_mul);  }   @@ -136,17 +122,17 @@ uint64_t helper_fdouble_pack1(CPUTLGState *env,          if (ctx.data>= TILEGX_F_COUNT) {              helper_exception(env, TILEGX_EXCP_OPCODE_INVALID_VALUE);          } -        return float64_to_t(fpu->val64s[ctx.data]); +        return float64_val(fpu->val64s[ctx.data]);      }        switch (ctx.exp) {      case 0x21b00: -        return float64_to_t(uint32_to_float64(rsrc>> 4, &FP_STATUS)); +        return float64_val(uint32_to_float64(rsrc>> 4, &FP_STATUS));      case 0x121b00: -        return float64_to_t(int32_to_float64((rsrc>> 4) | SIGNBIT32, -                                             &FP_STATUS)); +        return float64_val(int32_to_float64((rsrc>> 4) | SIGNBIT32, +                                            &FP_STATUS));      default: -        fprintf(stderr, "\nUIMP: in helper_fdouble_pack2().\n"); +        qemu_log_mask(LOG_UNIMP, "\nUIMP: in %s.\n", __FUNCTION__);          helper_exception(env, TILEGX_EXCP_OPCODE_UNIMPLEMENTED);          return 0;      } @@ -199,35 +185,19 @@ static uint64_t fsingle_calc(FPUTLGState *fpu,    uint64_t helper_fsingle_add1(CPUTLGState *env, uint64_t rsrc, uint64_t rsrcb)  { -    FPUTLGState *fpu = &env->fpu; -    return fsingle_calc(fpu, int64_to_float32(rsrc, &FP_STATUS), -                        int64_to_float32(rsrcb, &FP_STATUS), +    return fsingle_calc(&env->fpu, make_float32(rsrc), make_float32(rsrcb),                          float32_add);  }    uint64_t helper_fsingle_sub1(CPUTLGState *env, uint64_t rsrc, uint64_t rsrcb)  { -    FPUTLGState *fpu = &env->fpu; -    return fsingle_calc(fpu, int64_to_float32(rsrc, &FP_STATUS), -                        int64_to_float32(rsrcb, &FP_STATUS), +    return fsingle_calc(&env->fpu, make_float32(rsrc), make_float32(rsrcb),                          float32_sub);  }    uint64_t helper_fsingle_mul1(CPUTLGState *env, uint64_t rsrc, uint64_t rsrcb)  { -    FPUTLGState *fpu = &env->fpu; -#if 0 -    { -        float32 v; -        fprintf(stderr, "\ncall helper_fsingle_mul1(), %lx, %lx\n", rsrc, rsrcb); -        v = float32_mul(int64_to_float32(rsrc, &FP_STATUS), -                        int64_to_float32(rsrcb, &FP_STATUS), -                        &FP_STATUS); -        fprintf(stderr, "result: %lx.\n", float32_to_int64(v, &FP_STATUS)); -    } -#endif -    return fsingle_calc(fpu, int64_to_float32(rsrc, &FP_STATUS), -                        int64_to_float32(rsrcb, &FP_STATUS), +    return fsingle_calc(&env->fpu, make_float32(rsrc), make_float32(rsrcb),                          float32_mul);  }   @@ -240,19 +210,16 @@ uint64_t helper_fsingle_pack2(CPUTLGState *env, uint64_t rsrc)          if (ctx.data>= TILEGX_F_COUNT) {              helper_exception(env, TILEGX_EXCP_OPCODE_INVALID_VALUE);          } -        return float32_to_int32(fpu->val32s[ctx.data], &FP_STATUS); +        return float32_val(fpu->val32s[ctx.data]);      }        switch (ctx.exp) {      case 0x9e: -        return float32_to_int64(uint32_to_float32(ctx.data, &FP_STATUS), -                                &FP_STATUS); +        return float32_val(uint32_to_float32(ctx.data, &FP_STATUS));      case 0x49e: -        return float32_to_int64(int32_to_float32(ctx.data | SIGNBIT32, -                                                 &FP_STATUS), -                                 &FP_STATUS); +        return float32_val(int32_to_float32(ctx.data | SIGNBIT32, &FP_STATUS));      default: -        fprintf(stderr, "\nUIMP: in helper_fsingle_pack2().\n"); +        qemu_log_mask(LOG_UNIMP, "\nUIMP: in %s.\n", __FUNCTION__);          helper_exception(env, TILEGX_EXCP_OPCODE_UNIMPLEMENTED);          return 0;      }