[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and flo
From: |
Chen Gang |
Subject: |
[Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values |
Date: |
Tue, 6 Oct 2015 22:56:29 +0800 |
>From 3655bbab04063bc0878510ab260832c7a6a2a925 Mon Sep 17 00:00:00 2001
From: Chen Gang <address@hidden>
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 <address@hidden>
---
target-tilegx/fpu_helper.c | 63 +++++++++++-----------------------------------
1 file changed, 15 insertions(+), 48 deletions(-)
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;
}
--
1.9.3
0004-temp-floating-point-Use-make_float32-64-and-float32-.patch
Description: Binary data
- [Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values,
Chen Gang <=