[24/40] sim/mips: Fix enum type-related issues on cp1.c

Message ID c08cb6f4df60bb7111dd8b1f699b9719f1190bdf.1666258361.git.research_trasio@irq.a4lg.com
State Committed
Headers
Series sim+gdb: Suppress warnings if built with Clang (big batch 1) |

Commit Message

Tsukasa OI Oct. 20, 2022, 9:32 a.m. UTC
  Clang generates a warning if there is an enum value with a mismatching type
without an explicit cast ("-Wenum-conversion").
On the default configuration, it causes a build failure
(unless "--disable-werror" is specified).

This commit adds explicit casts and change a type on sim/mips/cp1.c.
---
 sim/mips/cp1.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Mike Frysinger Oct. 23, 2022, 3 p.m. UTC | #1
On 20 Oct 2022 09:32, Tsukasa OI wrote:
> --- a/sim/mips/cp1.c
> +++ b/sim/mips/cp1.c
> @@ -1178,7 +1178,7 @@ inner_rsqrt(uint64_t op1,
>  	uint32_t res;
>  	sim_fpu_32to (&wop1, op1);
>  	status |= sim_fpu_sqrt (&ans, &wop1);
> -	status |= sim_fpu_round_32 (&ans, status, round);
> +	status |= sim_fpu_round_32 (&ans, (sim_fpu_round) status, (sim_fpu_denorm) round);

this doesn't look correct at all.  are you sure about this ?

> @@ -1216,7 +1216,7 @@ fp_inv_sqrt(sim_cpu *cpu,
>  	    FP_formats fmt)
>  {
>    sim_fpu_round round = rounding_mode (GETRM());
> -  sim_fpu_round denorm = denorm_mode (cpu);
> +  sim_fpu_denorm denorm = denorm_mode (cpu);

this looks fine

> @@ -1903,8 +1903,8 @@ convert_ps (sim_cpu *cpu,
>      case fmt_ps:
> -      status_u |= sim_fpu_round_32 (&wop_u, 0, round);
> -      status_l |= sim_fpu_round_32 (&wop_l, 0, round);
> +      status_u |= sim_fpu_round_32 (&wop_u, 0, (sim_fpu_denorm) round);
> +      status_l |= sim_fpu_round_32 (&wop_l, 0, (sim_fpu_denorm) round);

this also looks wrong
-mike
  

Patch

diff --git a/sim/mips/cp1.c b/sim/mips/cp1.c
index 196173c0227..56a40c00623 100644
--- a/sim/mips/cp1.c
+++ b/sim/mips/cp1.c
@@ -1178,7 +1178,7 @@  inner_rsqrt(uint64_t op1,
 	uint32_t res;
 	sim_fpu_32to (&wop1, op1);
 	status |= sim_fpu_sqrt (&ans, &wop1);
-	status |= sim_fpu_round_32 (&ans, status, round);
+	status |= sim_fpu_round_32 (&ans, (sim_fpu_round) status, (sim_fpu_denorm) round);
 	wop1 = ans;
 	op_status = sim_fpu_inv (&ans, &wop1);
 	op_status |= sim_fpu_round_32 (&ans, round, denorm);
@@ -1216,7 +1216,7 @@  fp_inv_sqrt(sim_cpu *cpu,
 	    FP_formats fmt)
 {
   sim_fpu_round round = rounding_mode (GETRM());
-  sim_fpu_round denorm = denorm_mode (cpu);
+  sim_fpu_denorm denorm = denorm_mode (cpu);
   sim_fpu_status status = 0;
   uint64_t result = 0;
 
@@ -1903,8 +1903,8 @@  convert_ps (sim_cpu *cpu,
       result = (((uint64_t)res_u) << 32) | (uint64_t)res_l;
       break;
     case fmt_ps:
-      status_u |= sim_fpu_round_32 (&wop_u, 0, round);
-      status_l |= sim_fpu_round_32 (&wop_l, 0, round);
+      status_u |= sim_fpu_round_32 (&wop_u, 0, (sim_fpu_denorm) round);
+      status_l |= sim_fpu_round_32 (&wop_l, 0, (sim_fpu_denorm) round);
       sim_fpu_to32 (&res_u, &wop_u);
       sim_fpu_to32 (&res_l, &wop_l);
       result = FP_PS_cat(res_u, res_l);