* [Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values
@ 2015-10-06 14:56 Chen Gang
2015-10-07 9:29 ` Richard Henderson
0 siblings, 1 reply; 3+ messages in thread
From: Chen Gang @ 2015-10-06 14:56 UTC (permalink / raw)
To: rth@twiddle.net, Peter Maydell, Chris Metcalf; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 5988 bytes --]
>From 3655bbab04063bc0878510ab260832c7a6a2a925 Mon Sep 17 00:00:00 2001
From: Chen Gang <gang.chen.5i5j@gmail.com>
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 <gang.chen.5i5j@gmail.com>
---
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
[-- Attachment #2: 0004-temp-floating-point-Use-make_float32-64-and-float32-.patch --]
[-- Type: application/octet-stream, Size: 5826 bytes --]
From 3655bbab04063bc0878510ab260832c7a6a2a925 Mon Sep 17 00:00:00 2001
From: Chen Gang <gang.chen.5i5j@gmail.com>
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 <gang.chen.5i5j@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values
2015-10-06 14:56 [Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values Chen Gang
@ 2015-10-07 9:29 ` Richard Henderson
2015-10-07 10:24 ` Chen Gang
0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2015-10-07 9:29 UTC (permalink / raw)
To: Chen Gang, Peter Maydell, Chris Metcalf; +Cc: qemu-devel
On 10/07/2015 01:56 AM, Chen Gang wrote:
>>From 3655bbab04063bc0878510ab260832c7a6a2a925 Mon Sep 17 00:00:00 2001
> From: Chen Gang<gang.chen.5i5j@gmail.com>
> 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<gang.chen.5i5j@gmail.com>
> ---
> target-tilegx/fpu_helper.c | 63 +++++++++++-----------------------------------
> 1 file changed, 15 insertions(+), 48 deletions(-)
This is relative to... what? The v1 patch?
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values
2015-10-07 9:29 ` Richard Henderson
@ 2015-10-07 10:24 ` Chen Gang
0 siblings, 0 replies; 3+ messages in thread
From: Chen Gang @ 2015-10-07 10:24 UTC (permalink / raw)
To: Richard Henderson, Peter Maydell, Chris Metcalf; +Cc: qemu-devel
On 10/7/15 17:29, Richard Henderson wrote:
> On 10/07/2015 01:56 AM, Chen Gang wrote:
>>> From 3655bbab04063bc0878510ab260832c7a6a2a925 Mon Sep 17 00:00:00 2001
>> From: Chen Gang<gang.chen.5i5j@gmail.com>
>> 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<gang.chen.5i5j@gmail.com>
>> ---
>> target-tilegx/fpu_helper.c | 63 +++++++++++-----------------------------------
>> 1 file changed, 15 insertions(+), 48 deletions(-)
>
> This is relative to... what? The v1 patch?
>
Yes, it is related with v1 patch (has the same name). The v1 patch is
based on patch "target-tilegx: Implement floating point temporarily".
Since they are temporary implementations, I guess, we can just left it
(do not integrate them into main line).
I sent these temporary implementations, because if someone need test
qemu tilegx, they can use these temporary patches (but of cause, I am
very glad if they can be integrated into main line, too).
Thanks.
--
Chen Gang (陈刚)
Open, share, and attitude like air, water, and life which God blessed
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-07 10:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-06 14:56 [Qemu-devel] [PATCH v2] temp-floating-point: Use make_float32/64 and float32/64_val for the input register values Chen Gang
2015-10-07 9:29 ` Richard Henderson
2015-10-07 10:24 ` Chen Gang
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).