mirror of https://github.com/xemu-project/xemu.git
target/xtensa: Factor out calls to set_use_first_nan()
In xtensa we currently call set_use_first_nan() in a lot of places where we want to switch the NaN-propagation handling. We're about to change the softfloat API we use to do that, so start by factoring all the calls out into a single xtensa_use_first_nan() function. The bulk of this change was done with sed -i -e 's/set_use_first_nan(\([^,]*\),[^)]*)/xtensa_use_first_nan(env, \1)/' target/xtensa/fpu_helper.c Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20241025141254.2141506-14-peter.maydell@linaro.org
This commit is contained in:
parent
4482f32dcd
commit
80de5f24e0
|
@ -134,7 +134,7 @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)
|
||||||
cs->halted = env->runstall;
|
cs->halted = env->runstall;
|
||||||
#endif
|
#endif
|
||||||
set_no_signaling_nans(!dfpu, &env->fp_status);
|
set_no_signaling_nans(!dfpu, &env->fp_status);
|
||||||
set_use_first_nan(!dfpu, &env->fp_status);
|
xtensa_use_first_nan(env, !dfpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ObjectClass *xtensa_cpu_class_by_name(const char *cpu_model)
|
static ObjectClass *xtensa_cpu_class_by_name(const char *cpu_model)
|
||||||
|
|
|
@ -802,4 +802,10 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, vaddr *pc,
|
||||||
XtensaCPU *xtensa_cpu_create_with_clock(const char *cpu_type,
|
XtensaCPU *xtensa_cpu_create_with_clock(const char *cpu_type,
|
||||||
Clock *cpu_refclk);
|
Clock *cpu_refclk);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the NaN propagation rule for future FPU operations:
|
||||||
|
* use_first is true to pick the first NaN as the result if both
|
||||||
|
* inputs are NaNs, false to pick the second.
|
||||||
|
*/
|
||||||
|
void xtensa_use_first_nan(CPUXtensaState *env, bool use_first);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,6 +57,11 @@ static const struct {
|
||||||
{ XTENSA_FP_V, float_flag_invalid, },
|
{ XTENSA_FP_V, float_flag_invalid, },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void xtensa_use_first_nan(CPUXtensaState *env, bool use_first)
|
||||||
|
{
|
||||||
|
set_use_first_nan(use_first, &env->fp_status);
|
||||||
|
}
|
||||||
|
|
||||||
void HELPER(wur_fpu2k_fcr)(CPUXtensaState *env, uint32_t v)
|
void HELPER(wur_fpu2k_fcr)(CPUXtensaState *env, uint32_t v)
|
||||||
{
|
{
|
||||||
static const int rounding_mode[] = {
|
static const int rounding_mode[] = {
|
||||||
|
@ -171,87 +176,87 @@ float32 HELPER(fpu2k_msub_s)(CPUXtensaState *env,
|
||||||
|
|
||||||
float64 HELPER(add_d)(CPUXtensaState *env, float64 a, float64 b)
|
float64 HELPER(add_d)(CPUXtensaState *env, float64 a, float64 b)
|
||||||
{
|
{
|
||||||
set_use_first_nan(true, &env->fp_status);
|
xtensa_use_first_nan(env, true);
|
||||||
return float64_add(a, b, &env->fp_status);
|
return float64_add(a, b, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32 HELPER(add_s)(CPUXtensaState *env, float32 a, float32 b)
|
float32 HELPER(add_s)(CPUXtensaState *env, float32 a, float32 b)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float32_add(a, b, &env->fp_status);
|
return float32_add(a, b, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float64 HELPER(sub_d)(CPUXtensaState *env, float64 a, float64 b)
|
float64 HELPER(sub_d)(CPUXtensaState *env, float64 a, float64 b)
|
||||||
{
|
{
|
||||||
set_use_first_nan(true, &env->fp_status);
|
xtensa_use_first_nan(env, true);
|
||||||
return float64_sub(a, b, &env->fp_status);
|
return float64_sub(a, b, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32 HELPER(sub_s)(CPUXtensaState *env, float32 a, float32 b)
|
float32 HELPER(sub_s)(CPUXtensaState *env, float32 a, float32 b)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float32_sub(a, b, &env->fp_status);
|
return float32_sub(a, b, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float64 HELPER(mul_d)(CPUXtensaState *env, float64 a, float64 b)
|
float64 HELPER(mul_d)(CPUXtensaState *env, float64 a, float64 b)
|
||||||
{
|
{
|
||||||
set_use_first_nan(true, &env->fp_status);
|
xtensa_use_first_nan(env, true);
|
||||||
return float64_mul(a, b, &env->fp_status);
|
return float64_mul(a, b, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32 HELPER(mul_s)(CPUXtensaState *env, float32 a, float32 b)
|
float32 HELPER(mul_s)(CPUXtensaState *env, float32 a, float32 b)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float32_mul(a, b, &env->fp_status);
|
return float32_mul(a, b, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float64 HELPER(madd_d)(CPUXtensaState *env, float64 a, float64 b, float64 c)
|
float64 HELPER(madd_d)(CPUXtensaState *env, float64 a, float64 b, float64 c)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float64_muladd(b, c, a, 0, &env->fp_status);
|
return float64_muladd(b, c, a, 0, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32 HELPER(madd_s)(CPUXtensaState *env, float32 a, float32 b, float32 c)
|
float32 HELPER(madd_s)(CPUXtensaState *env, float32 a, float32 b, float32 c)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float32_muladd(b, c, a, 0, &env->fp_status);
|
return float32_muladd(b, c, a, 0, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float64 HELPER(msub_d)(CPUXtensaState *env, float64 a, float64 b, float64 c)
|
float64 HELPER(msub_d)(CPUXtensaState *env, float64 a, float64 b, float64 c)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float64_muladd(b, c, a, float_muladd_negate_product,
|
return float64_muladd(b, c, a, float_muladd_negate_product,
|
||||||
&env->fp_status);
|
&env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32 HELPER(msub_s)(CPUXtensaState *env, float32 a, float32 b, float32 c)
|
float32 HELPER(msub_s)(CPUXtensaState *env, float32 a, float32 b, float32 c)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float32_muladd(b, c, a, float_muladd_negate_product,
|
return float32_muladd(b, c, a, float_muladd_negate_product,
|
||||||
&env->fp_status);
|
&env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float64 HELPER(mkdadj_d)(CPUXtensaState *env, float64 a, float64 b)
|
float64 HELPER(mkdadj_d)(CPUXtensaState *env, float64 a, float64 b)
|
||||||
{
|
{
|
||||||
set_use_first_nan(true, &env->fp_status);
|
xtensa_use_first_nan(env, true);
|
||||||
return float64_div(b, a, &env->fp_status);
|
return float64_div(b, a, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32 HELPER(mkdadj_s)(CPUXtensaState *env, float32 a, float32 b)
|
float32 HELPER(mkdadj_s)(CPUXtensaState *env, float32 a, float32 b)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float32_div(b, a, &env->fp_status);
|
return float32_div(b, a, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float64 HELPER(mksadj_d)(CPUXtensaState *env, float64 v)
|
float64 HELPER(mksadj_d)(CPUXtensaState *env, float64 v)
|
||||||
{
|
{
|
||||||
set_use_first_nan(true, &env->fp_status);
|
xtensa_use_first_nan(env, true);
|
||||||
return float64_sqrt(v, &env->fp_status);
|
return float64_sqrt(v, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32 HELPER(mksadj_s)(CPUXtensaState *env, float32 v)
|
float32 HELPER(mksadj_s)(CPUXtensaState *env, float32 v)
|
||||||
{
|
{
|
||||||
set_use_first_nan(env->config->use_first_nan, &env->fp_status);
|
xtensa_use_first_nan(env, env->config->use_first_nan);
|
||||||
return float32_sqrt(v, &env->fp_status);
|
return float32_sqrt(v, &env->fp_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue