Patchwork target-mips: Replace macros by inline functions

login
register
mail settings
Submitter Stefan Weil
Date Jan. 1, 2013, 6:44 p.m.
Message ID <1357065871-1267-1-git-send-email-sw@weilnetz.de>
Download mbox | patch
Permalink /patch/208957/
State Accepted
Headers show

Comments

Stefan Weil - Jan. 1, 2013, 6:44 p.m.
The macros RESTORE_ROUNDING_MODE and RESTORE_FLUSH_MODE silently used
variable env from their callers. Using inline functions with env passed
as a function argument is more transparent.

This modification was proposed by Peter Maydell.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 target-mips/op_helper.c |   42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)
Eric Johnson - Jan. 8, 2013, 5:43 a.m.
On 01/01/2013 10:44 AM, Stefan Weil wrote:
> The macros RESTORE_ROUNDING_MODE and RESTORE_FLUSH_MODE silently used
> variable env from their callers. Using inline functions with env passed
> as a function argument is more transparent.
>
> This modification was proposed by Peter Maydell.
>
> Cc: Peter Maydell<peter.maydell@linaro.org>
> Signed-off-by: Stefan Weil<sw@weilnetz.de>
> ---
>   target-mips/op_helper.c |   42 ++++++++++++++++++++++++------------------
>   1 file changed, 24 insertions(+), 18 deletions(-)
>
> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
> index d833d78..d5c61e8 100644
> --- a/target-mips/op_helper.c
> +++ b/target-mips/op_helper.c
> @@ -2170,11 +2170,17 @@ static unsigned int ieee_rm[] = {
>       float_round_down
>   };
>
> -#define RESTORE_ROUNDING_MODE \
> -    set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31&  3],&env->active_fpu.fp_status)
> +static inline void restore_rounding_mode(CPUMIPSState *env)
> +{
> +    set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31&  3],
> +&env->active_fpu.fp_status);
> +}
>
> -#define RESTORE_FLUSH_MODE \
> -    set_flush_to_zero((env->active_fpu.fcr31&  (1<<  24)) != 0,&env->active_fpu.fp_status)
> +static inline void restore_flush_mode(CPUMIPSState *env)
> +{
> +    set_flush_to_zero((env->active_fpu.fcr31&  (1<<  24)) != 0,
> +&env->active_fpu.fp_status);
> +}
>
>   target_ulong helper_cfc1(CPUMIPSState *env, uint32_t reg)
>   {
> @@ -2230,9 +2236,9 @@ void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t reg)
>           return;
>       }
>       /* set rounding mode */
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       /* set flush-to-zero mode */
> -    RESTORE_FLUSH_MODE;
> +    restore_flush_mode(env);
>       set_float_exception_flags(0,&env->active_fpu.fp_status);
>       if ((GET_FP_ENABLE(env->active_fpu.fcr31) | 0x20)&  GET_FP_CAUSE(env->active_fpu.fcr31))
>           do_raise_exception(env, EXCP_FPE, GETPC());
> @@ -2464,7 +2470,7 @@ uint64_t helper_float_roundl_d(CPUMIPSState *env, uint64_t fdt0)
>
>       set_float_rounding_mode(float_round_nearest_even,&env->active_fpu.fp_status);
>       dt2 = float64_to_int64(fdt0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2479,7 +2485,7 @@ uint64_t helper_float_roundl_s(CPUMIPSState *env, uint32_t fst0)
>
>       set_float_rounding_mode(float_round_nearest_even,&env->active_fpu.fp_status);
>       dt2 = float32_to_int64(fst0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2494,7 +2500,7 @@ uint32_t helper_float_roundw_d(CPUMIPSState *env, uint64_t fdt0)
>
>       set_float_rounding_mode(float_round_nearest_even,&env->active_fpu.fp_status);
>       wt2 = float64_to_int32(fdt0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2509,7 +2515,7 @@ uint32_t helper_float_roundw_s(CPUMIPSState *env, uint32_t fst0)
>
>       set_float_rounding_mode(float_round_nearest_even,&env->active_fpu.fp_status);
>       wt2 = float32_to_int32(fst0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2576,7 +2582,7 @@ uint64_t helper_float_ceill_d(CPUMIPSState *env, uint64_t fdt0)
>
>       set_float_rounding_mode(float_round_up,&env->active_fpu.fp_status);
>       dt2 = float64_to_int64(fdt0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2591,7 +2597,7 @@ uint64_t helper_float_ceill_s(CPUMIPSState *env, uint32_t fst0)
>
>       set_float_rounding_mode(float_round_up,&env->active_fpu.fp_status);
>       dt2 = float32_to_int64(fst0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2606,7 +2612,7 @@ uint32_t helper_float_ceilw_d(CPUMIPSState *env, uint64_t fdt0)
>
>       set_float_rounding_mode(float_round_up,&env->active_fpu.fp_status);
>       wt2 = float64_to_int32(fdt0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2621,7 +2627,7 @@ uint32_t helper_float_ceilw_s(CPUMIPSState *env, uint32_t fst0)
>
>       set_float_rounding_mode(float_round_up,&env->active_fpu.fp_status);
>       wt2 = float32_to_int32(fst0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2636,7 +2642,7 @@ uint64_t helper_float_floorl_d(CPUMIPSState *env, uint64_t fdt0)
>
>       set_float_rounding_mode(float_round_down,&env->active_fpu.fp_status);
>       dt2 = float64_to_int64(fdt0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2651,7 +2657,7 @@ uint64_t helper_float_floorl_s(CPUMIPSState *env, uint32_t fst0)
>
>       set_float_rounding_mode(float_round_down,&env->active_fpu.fp_status);
>       dt2 = float32_to_int64(fst0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2666,7 +2672,7 @@ uint32_t helper_float_floorw_d(CPUMIPSState *env, uint64_t fdt0)
>
>       set_float_rounding_mode(float_round_down,&env->active_fpu.fp_status);
>       wt2 = float64_to_int32(fdt0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2681,7 +2687,7 @@ uint32_t helper_float_floorw_s(CPUMIPSState *env, uint32_t fst0)
>
>       set_float_rounding_mode(float_round_down,&env->active_fpu.fp_status);
>       wt2 = float32_to_int32(fst0,&env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>       if (get_float_exception_flags(&env->active_fpu.fp_status)
>           &  (float_flag_invalid | float_flag_overflow)) {
>           wt2 = FP_TO_INT32_OVERFLOW;

Reviewed-by: Eric Johnson <ericj@mips.com>
Aurelien Jarno - Jan. 8, 2013, 3:45 p.m.
On Tue, Jan 01, 2013 at 07:44:31PM +0100, Stefan Weil wrote:
> The macros RESTORE_ROUNDING_MODE and RESTORE_FLUSH_MODE silently used
> variable env from their callers. Using inline functions with env passed
> as a function argument is more transparent.
> 
> This modification was proposed by Peter Maydell.
> 
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  target-mips/op_helper.c |   42 ++++++++++++++++++++++++------------------
>  1 file changed, 24 insertions(+), 18 deletions(-)
> 
> diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
> index d833d78..d5c61e8 100644
> --- a/target-mips/op_helper.c
> +++ b/target-mips/op_helper.c
> @@ -2170,11 +2170,17 @@ static unsigned int ieee_rm[] = {
>      float_round_down
>  };
>  
> -#define RESTORE_ROUNDING_MODE \
> -    set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], &env->active_fpu.fp_status)
> +static inline void restore_rounding_mode(CPUMIPSState *env)
> +{
> +    set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3],
> +                            &env->active_fpu.fp_status);
> +}
>  
> -#define RESTORE_FLUSH_MODE \
> -    set_flush_to_zero((env->active_fpu.fcr31 & (1 << 24)) != 0, &env->active_fpu.fp_status)
> +static inline void restore_flush_mode(CPUMIPSState *env)
> +{
> +    set_flush_to_zero((env->active_fpu.fcr31 & (1 << 24)) != 0,
> +                      &env->active_fpu.fp_status);
> +}
>  
>  target_ulong helper_cfc1(CPUMIPSState *env, uint32_t reg)
>  {
> @@ -2230,9 +2236,9 @@ void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t reg)
>          return;
>      }
>      /* set rounding mode */
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      /* set flush-to-zero mode */
> -    RESTORE_FLUSH_MODE;
> +    restore_flush_mode(env);
>      set_float_exception_flags(0, &env->active_fpu.fp_status);
>      if ((GET_FP_ENABLE(env->active_fpu.fcr31) | 0x20) & GET_FP_CAUSE(env->active_fpu.fcr31))
>          do_raise_exception(env, EXCP_FPE, GETPC());
> @@ -2464,7 +2470,7 @@ uint64_t helper_float_roundl_d(CPUMIPSState *env, uint64_t fdt0)
>  
>      set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status);
>      dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2479,7 +2485,7 @@ uint64_t helper_float_roundl_s(CPUMIPSState *env, uint32_t fst0)
>  
>      set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status);
>      dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2494,7 +2500,7 @@ uint32_t helper_float_roundw_d(CPUMIPSState *env, uint64_t fdt0)
>  
>      set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status);
>      wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2509,7 +2515,7 @@ uint32_t helper_float_roundw_s(CPUMIPSState *env, uint32_t fst0)
>  
>      set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status);
>      wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2576,7 +2582,7 @@ uint64_t helper_float_ceill_d(CPUMIPSState *env, uint64_t fdt0)
>  
>      set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status);
>      dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2591,7 +2597,7 @@ uint64_t helper_float_ceill_s(CPUMIPSState *env, uint32_t fst0)
>  
>      set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status);
>      dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2606,7 +2612,7 @@ uint32_t helper_float_ceilw_d(CPUMIPSState *env, uint64_t fdt0)
>  
>      set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status);
>      wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2621,7 +2627,7 @@ uint32_t helper_float_ceilw_s(CPUMIPSState *env, uint32_t fst0)
>  
>      set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status);
>      wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2636,7 +2642,7 @@ uint64_t helper_float_floorl_d(CPUMIPSState *env, uint64_t fdt0)
>  
>      set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status);
>      dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2651,7 +2657,7 @@ uint64_t helper_float_floorl_s(CPUMIPSState *env, uint32_t fst0)
>  
>      set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status);
>      dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          dt2 = FP_TO_INT64_OVERFLOW;
> @@ -2666,7 +2672,7 @@ uint32_t helper_float_floorw_d(CPUMIPSState *env, uint64_t fdt0)
>  
>      set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status);
>      wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          wt2 = FP_TO_INT32_OVERFLOW;
> @@ -2681,7 +2687,7 @@ uint32_t helper_float_floorw_s(CPUMIPSState *env, uint32_t fst0)
>  
>      set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status);
>      wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status);
> -    RESTORE_ROUNDING_MODE;
> +    restore_rounding_mode(env);
>      if (get_float_exception_flags(&env->active_fpu.fp_status)
>          & (float_flag_invalid | float_flag_overflow)) {
>          wt2 = FP_TO_INT32_OVERFLOW;

Thanks, applied.

Patch

diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index d833d78..d5c61e8 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -2170,11 +2170,17 @@  static unsigned int ieee_rm[] = {
     float_round_down
 };
 
-#define RESTORE_ROUNDING_MODE \
-    set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], &env->active_fpu.fp_status)
+static inline void restore_rounding_mode(CPUMIPSState *env)
+{
+    set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3],
+                            &env->active_fpu.fp_status);
+}
 
-#define RESTORE_FLUSH_MODE \
-    set_flush_to_zero((env->active_fpu.fcr31 & (1 << 24)) != 0, &env->active_fpu.fp_status)
+static inline void restore_flush_mode(CPUMIPSState *env)
+{
+    set_flush_to_zero((env->active_fpu.fcr31 & (1 << 24)) != 0,
+                      &env->active_fpu.fp_status);
+}
 
 target_ulong helper_cfc1(CPUMIPSState *env, uint32_t reg)
 {
@@ -2230,9 +2236,9 @@  void helper_ctc1(CPUMIPSState *env, target_ulong arg1, uint32_t reg)
         return;
     }
     /* set rounding mode */
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     /* set flush-to-zero mode */
-    RESTORE_FLUSH_MODE;
+    restore_flush_mode(env);
     set_float_exception_flags(0, &env->active_fpu.fp_status);
     if ((GET_FP_ENABLE(env->active_fpu.fcr31) | 0x20) & GET_FP_CAUSE(env->active_fpu.fcr31))
         do_raise_exception(env, EXCP_FPE, GETPC());
@@ -2464,7 +2470,7 @@  uint64_t helper_float_roundl_d(CPUMIPSState *env, uint64_t fdt0)
 
     set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status);
     dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         dt2 = FP_TO_INT64_OVERFLOW;
@@ -2479,7 +2485,7 @@  uint64_t helper_float_roundl_s(CPUMIPSState *env, uint32_t fst0)
 
     set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status);
     dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         dt2 = FP_TO_INT64_OVERFLOW;
@@ -2494,7 +2500,7 @@  uint32_t helper_float_roundw_d(CPUMIPSState *env, uint64_t fdt0)
 
     set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status);
     wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         wt2 = FP_TO_INT32_OVERFLOW;
@@ -2509,7 +2515,7 @@  uint32_t helper_float_roundw_s(CPUMIPSState *env, uint32_t fst0)
 
     set_float_rounding_mode(float_round_nearest_even, &env->active_fpu.fp_status);
     wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         wt2 = FP_TO_INT32_OVERFLOW;
@@ -2576,7 +2582,7 @@  uint64_t helper_float_ceill_d(CPUMIPSState *env, uint64_t fdt0)
 
     set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status);
     dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         dt2 = FP_TO_INT64_OVERFLOW;
@@ -2591,7 +2597,7 @@  uint64_t helper_float_ceill_s(CPUMIPSState *env, uint32_t fst0)
 
     set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status);
     dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         dt2 = FP_TO_INT64_OVERFLOW;
@@ -2606,7 +2612,7 @@  uint32_t helper_float_ceilw_d(CPUMIPSState *env, uint64_t fdt0)
 
     set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status);
     wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         wt2 = FP_TO_INT32_OVERFLOW;
@@ -2621,7 +2627,7 @@  uint32_t helper_float_ceilw_s(CPUMIPSState *env, uint32_t fst0)
 
     set_float_rounding_mode(float_round_up, &env->active_fpu.fp_status);
     wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         wt2 = FP_TO_INT32_OVERFLOW;
@@ -2636,7 +2642,7 @@  uint64_t helper_float_floorl_d(CPUMIPSState *env, uint64_t fdt0)
 
     set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status);
     dt2 = float64_to_int64(fdt0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         dt2 = FP_TO_INT64_OVERFLOW;
@@ -2651,7 +2657,7 @@  uint64_t helper_float_floorl_s(CPUMIPSState *env, uint32_t fst0)
 
     set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status);
     dt2 = float32_to_int64(fst0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         dt2 = FP_TO_INT64_OVERFLOW;
@@ -2666,7 +2672,7 @@  uint32_t helper_float_floorw_d(CPUMIPSState *env, uint64_t fdt0)
 
     set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status);
     wt2 = float64_to_int32(fdt0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         wt2 = FP_TO_INT32_OVERFLOW;
@@ -2681,7 +2687,7 @@  uint32_t helper_float_floorw_s(CPUMIPSState *env, uint32_t fst0)
 
     set_float_rounding_mode(float_round_down, &env->active_fpu.fp_status);
     wt2 = float32_to_int32(fst0, &env->active_fpu.fp_status);
-    RESTORE_ROUNDING_MODE;
+    restore_rounding_mode(env);
     if (get_float_exception_flags(&env->active_fpu.fp_status)
         & (float_flag_invalid | float_flag_overflow)) {
         wt2 = FP_TO_INT32_OVERFLOW;