Message ID | 20190921043256.4575-2-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | target/alpha: Fix linux-user exception for CVTTQ | expand |
On 9/21/19 6:32 AM, Richard Henderson wrote: > This is a bit more straight-forward than using a switch statement. > No functional change. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > target/alpha/helper.c | 24 ++++++++---------------- > 1 file changed, 8 insertions(+), 16 deletions(-) > > diff --git a/target/alpha/helper.c b/target/alpha/helper.c > index 19cda0a2db..6c1703682e 100644 > --- a/target/alpha/helper.c > +++ b/target/alpha/helper.c > @@ -36,6 +36,13 @@ uint64_t cpu_alpha_load_fpcr(CPUAlphaState *env) > > void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) > { > + static const uint8_t rm_map[] = { > + [FPCR_DYN_NORMAL >> FPCR_DYN_SHIFT] = float_round_nearest_even, > + [FPCR_DYN_CHOPPED >> FPCR_DYN_SHIFT] = float_round_to_zero, > + [FPCR_DYN_MINUS >> FPCR_DYN_SHIFT] = float_round_down, > + [FPCR_DYN_PLUS >> FPCR_DYN_SHIFT] = float_round_up, > + }; > + > uint32_t fpcr = val >> 32; > uint32_t t = 0; > > @@ -48,22 +55,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) > env->fpcr = fpcr; > env->fpcr_exc_enable = ~t & FPCR_STATUS_MASK; > > - switch (fpcr & FPCR_DYN_MASK) { > - case FPCR_DYN_NORMAL: > - default: > - t = float_round_nearest_even; > - break; > - case FPCR_DYN_CHOPPED: > - t = float_round_to_zero; > - break; > - case FPCR_DYN_MINUS: > - t = float_round_down; > - break; > - case FPCR_DYN_PLUS: > - t = float_round_up; > - break; > - } > - env->fpcr_dyn_round = t; > + env->fpcr_dyn_round = rm_map[(fpcr & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT]; > > env->fpcr_flush_to_zero = (fpcr & FPCR_UNFD) && (fpcr & FPCR_UNDZ); > env->fp_status.flush_inputs_to_zero = (fpcr & FPCR_DNZ) != 0; >
Richard Henderson <richard.henderson@linaro.org> writes: > This is a bit more straight-forward than using a switch statement. > No functional change. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> > --- > target/alpha/helper.c | 24 ++++++++---------------- > 1 file changed, 8 insertions(+), 16 deletions(-) > > diff --git a/target/alpha/helper.c b/target/alpha/helper.c > index 19cda0a2db..6c1703682e 100644 > --- a/target/alpha/helper.c > +++ b/target/alpha/helper.c > @@ -36,6 +36,13 @@ uint64_t cpu_alpha_load_fpcr(CPUAlphaState *env) > > void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) > { > + static const uint8_t rm_map[] = { > + [FPCR_DYN_NORMAL >> FPCR_DYN_SHIFT] = float_round_nearest_even, > + [FPCR_DYN_CHOPPED >> FPCR_DYN_SHIFT] = float_round_to_zero, > + [FPCR_DYN_MINUS >> FPCR_DYN_SHIFT] = float_round_down, > + [FPCR_DYN_PLUS >> FPCR_DYN_SHIFT] = float_round_up, > + }; > + > uint32_t fpcr = val >> 32; > uint32_t t = 0; > > @@ -48,22 +55,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) > env->fpcr = fpcr; > env->fpcr_exc_enable = ~t & FPCR_STATUS_MASK; > > - switch (fpcr & FPCR_DYN_MASK) { > - case FPCR_DYN_NORMAL: > - default: > - t = float_round_nearest_even; > - break; > - case FPCR_DYN_CHOPPED: > - t = float_round_to_zero; > - break; > - case FPCR_DYN_MINUS: > - t = float_round_down; > - break; > - case FPCR_DYN_PLUS: > - t = float_round_up; > - break; > - } > - env->fpcr_dyn_round = t; > + env->fpcr_dyn_round = rm_map[(fpcr & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT]; > > env->fpcr_flush_to_zero = (fpcr & FPCR_UNFD) && (fpcr & FPCR_UNDZ); > env->fp_status.flush_inputs_to_zero = (fpcr & FPCR_DNZ) != 0; -- Alex Bennée
diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 19cda0a2db..6c1703682e 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -36,6 +36,13 @@ uint64_t cpu_alpha_load_fpcr(CPUAlphaState *env) void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) { + static const uint8_t rm_map[] = { + [FPCR_DYN_NORMAL >> FPCR_DYN_SHIFT] = float_round_nearest_even, + [FPCR_DYN_CHOPPED >> FPCR_DYN_SHIFT] = float_round_to_zero, + [FPCR_DYN_MINUS >> FPCR_DYN_SHIFT] = float_round_down, + [FPCR_DYN_PLUS >> FPCR_DYN_SHIFT] = float_round_up, + }; + uint32_t fpcr = val >> 32; uint32_t t = 0; @@ -48,22 +55,7 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val) env->fpcr = fpcr; env->fpcr_exc_enable = ~t & FPCR_STATUS_MASK; - switch (fpcr & FPCR_DYN_MASK) { - case FPCR_DYN_NORMAL: - default: - t = float_round_nearest_even; - break; - case FPCR_DYN_CHOPPED: - t = float_round_to_zero; - break; - case FPCR_DYN_MINUS: - t = float_round_down; - break; - case FPCR_DYN_PLUS: - t = float_round_up; - break; - } - env->fpcr_dyn_round = t; + env->fpcr_dyn_round = rm_map[(fpcr & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT]; env->fpcr_flush_to_zero = (fpcr & FPCR_UNFD) && (fpcr & FPCR_UNDZ); env->fp_status.flush_inputs_to_zero = (fpcr & FPCR_DNZ) != 0;
This is a bit more straight-forward than using a switch statement. No functional change. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/alpha/helper.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) -- 2.17.1