qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] powerpc: correctly handle fpu exceptions.
@ 2013-04-09 15:00 Fabien Chouteau
  2013-04-10 22:09 ` Alexander Graf
  2013-04-19 15:29 ` Alexander Graf
  0 siblings, 2 replies; 4+ messages in thread
From: Fabien Chouteau @ 2013-04-09 15:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: Tristan Gingold, qemu-ppc, agraf

From: Tristan Gingold <gingold@adacore.com>

Raise the exception on the first occurence, do not wait for the next
floating point operation.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
---
 target-ppc/fpu_helper.c |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/target-ppc/fpu_helper.c b/target-ppc/fpu_helper.c
index 9e779ea..1e141fb 100644
--- a/target-ppc/fpu_helper.c
+++ b/target-ppc/fpu_helper.c
@@ -470,6 +470,18 @@ void store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)
 
 void helper_float_check_status(CPUPPCState *env)
 {
+    int status = get_float_exception_flags(&env->fp_status);
+
+    if (status & float_flag_divbyzero) {
+        float_zero_divide_excp(env);
+    } else if (status & float_flag_overflow) {
+        float_overflow_excp(env);
+    } else if (status & float_flag_underflow) {
+        float_underflow_excp(env);
+    } else if (status & float_flag_inexact) {
+        float_inexact_excp(env);
+    }
+
     if (env->exception_index == POWERPC_EXCP_PROGRAM &&
         (env->error_code & POWERPC_EXCP_FP)) {
         /* Differred floating-point exception after target FPR update */
@@ -477,17 +489,6 @@ void helper_float_check_status(CPUPPCState *env)
             helper_raise_exception_err(env, env->exception_index,
                                        env->error_code);
         }
-    } else {
-        int status = get_float_exception_flags(&env->fp_status);
-        if (status & float_flag_divbyzero) {
-            float_zero_divide_excp(env);
-        } else if (status & float_flag_overflow) {
-            float_overflow_excp(env);
-        } else if (status & float_flag_underflow) {
-            float_underflow_excp(env);
-        } else if (status & float_flag_inexact) {
-            float_inexact_excp(env);
-        }
     }
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] powerpc: correctly handle fpu exceptions.
  2013-04-09 15:00 [Qemu-devel] [PATCH] powerpc: correctly handle fpu exceptions Fabien Chouteau
@ 2013-04-10 22:09 ` Alexander Graf
  2013-04-11  8:29   ` Fabien Chouteau
  2013-04-19 15:29 ` Alexander Graf
  1 sibling, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2013-04-10 22:09 UTC (permalink / raw)
  To: Fabien Chouteau; +Cc: Tristan Gingold, qemu-ppc, qemu-devel


On 09.04.2013, at 17:00, Fabien Chouteau wrote:

> From: Tristan Gingold <gingold@adacore.com>
> 
> Raise the exception on the first occurence, do not wait for the next
> floating point operation.

Do you have a test case for this one that I could use to compare results with real hardware?

Alex

> 
> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
> ---
> target-ppc/fpu_helper.c |   23 ++++++++++++-----------
> 1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/target-ppc/fpu_helper.c b/target-ppc/fpu_helper.c
> index 9e779ea..1e141fb 100644
> --- a/target-ppc/fpu_helper.c
> +++ b/target-ppc/fpu_helper.c
> @@ -470,6 +470,18 @@ void store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)
> 
> void helper_float_check_status(CPUPPCState *env)
> {
> +    int status = get_float_exception_flags(&env->fp_status);
> +
> +    if (status & float_flag_divbyzero) {
> +        float_zero_divide_excp(env);
> +    } else if (status & float_flag_overflow) {
> +        float_overflow_excp(env);
> +    } else if (status & float_flag_underflow) {
> +        float_underflow_excp(env);
> +    } else if (status & float_flag_inexact) {
> +        float_inexact_excp(env);
> +    }
> +
>     if (env->exception_index == POWERPC_EXCP_PROGRAM &&
>         (env->error_code & POWERPC_EXCP_FP)) {
>         /* Differred floating-point exception after target FPR update */
> @@ -477,17 +489,6 @@ void helper_float_check_status(CPUPPCState *env)
>             helper_raise_exception_err(env, env->exception_index,
>                                        env->error_code);
>         }
> -    } else {
> -        int status = get_float_exception_flags(&env->fp_status);
> -        if (status & float_flag_divbyzero) {
> -            float_zero_divide_excp(env);
> -        } else if (status & float_flag_overflow) {
> -            float_overflow_excp(env);
> -        } else if (status & float_flag_underflow) {
> -            float_underflow_excp(env);
> -        } else if (status & float_flag_inexact) {
> -            float_inexact_excp(env);
> -        }
>     }
> }
> 
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] powerpc: correctly handle fpu exceptions.
  2013-04-10 22:09 ` Alexander Graf
@ 2013-04-11  8:29   ` Fabien Chouteau
  0 siblings, 0 replies; 4+ messages in thread
From: Fabien Chouteau @ 2013-04-11  8:29 UTC (permalink / raw)
  To: Alexander Graf; +Cc: Tristan Gingold, qemu-ppc, qemu-devel

On 04/11/2013 12:09 AM, Alexander Graf wrote:
> 
> On 09.04.2013, at 17:00, Fabien Chouteau wrote:
> 
>> From: Tristan Gingold <gingold@adacore.com>
>>
>> Raise the exception on the first occurence, do not wait for the next
>> floating point operation.
> 
> Do you have a test case for this one that I could use to compare results with real hardware?
> 

Not for real hardware, maybe you can try to build a simple program with
just do a division by zero.

-- 
Fabien Chouteau

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] powerpc: correctly handle fpu exceptions.
  2013-04-09 15:00 [Qemu-devel] [PATCH] powerpc: correctly handle fpu exceptions Fabien Chouteau
  2013-04-10 22:09 ` Alexander Graf
@ 2013-04-19 15:29 ` Alexander Graf
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2013-04-19 15:29 UTC (permalink / raw)
  To: Fabien Chouteau; +Cc: Tristan Gingold, qemu-ppc, qemu-devel


On 09.04.2013, at 17:00, Fabien Chouteau wrote:

> From: Tristan Gingold <gingold@adacore.com>
> 
> Raise the exception on the first occurence, do not wait for the next
> floating point operation.
> 
> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>

Thanks, applied to ppc-next.

Alex

> ---
> target-ppc/fpu_helper.c |   23 ++++++++++++-----------
> 1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/target-ppc/fpu_helper.c b/target-ppc/fpu_helper.c
> index 9e779ea..1e141fb 100644
> --- a/target-ppc/fpu_helper.c
> +++ b/target-ppc/fpu_helper.c
> @@ -470,6 +470,18 @@ void store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask)
> 
> void helper_float_check_status(CPUPPCState *env)
> {
> +    int status = get_float_exception_flags(&env->fp_status);
> +
> +    if (status & float_flag_divbyzero) {
> +        float_zero_divide_excp(env);
> +    } else if (status & float_flag_overflow) {
> +        float_overflow_excp(env);
> +    } else if (status & float_flag_underflow) {
> +        float_underflow_excp(env);
> +    } else if (status & float_flag_inexact) {
> +        float_inexact_excp(env);
> +    }
> +
>     if (env->exception_index == POWERPC_EXCP_PROGRAM &&
>         (env->error_code & POWERPC_EXCP_FP)) {
>         /* Differred floating-point exception after target FPR update */
> @@ -477,17 +489,6 @@ void helper_float_check_status(CPUPPCState *env)
>             helper_raise_exception_err(env, env->exception_index,
>                                        env->error_code);
>         }
> -    } else {
> -        int status = get_float_exception_flags(&env->fp_status);
> -        if (status & float_flag_divbyzero) {
> -            float_zero_divide_excp(env);
> -        } else if (status & float_flag_overflow) {
> -            float_overflow_excp(env);
> -        } else if (status & float_flag_underflow) {
> -            float_underflow_excp(env);
> -        } else if (status & float_flag_inexact) {
> -            float_inexact_excp(env);
> -        }
>     }
> }
> 
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-19 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-09 15:00 [Qemu-devel] [PATCH] powerpc: correctly handle fpu exceptions Fabien Chouteau
2013-04-10 22:09 ` Alexander Graf
2013-04-11  8:29   ` Fabien Chouteau
2013-04-19 15:29 ` Alexander Graf

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).