target-mips: Add missing calls to synchronise SoftFloat status

Add missing calls to synchronise the SoftFloat status with the CP1.FSCR:

+ for the rounding and flush-to-zero modes upon processor reset,

+ for the flush-to-zero mode on FSCR updates through the GDB stub.

Refactor code accordingly and remove the redundant RESTORE_ROUNDING_MODE
macro.

Backports commit bb962386b82c1b0e9e12fdb6b9bb62106bf1f822 from qemu
This commit is contained in:
Maciej W. Rozycki 2018-02-11 16:51:17 -05:00 committed by Lioncash
parent e4ce0e92b1
commit e97c07cdca
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 15 additions and 12 deletions

View file

@ -771,6 +771,19 @@ target_ulong exception_resume_pc (CPUMIPSState *env);
extern unsigned int ieee_rm[]; extern unsigned int ieee_rm[];
int ieee_ex_to_mips(int xcpt); int ieee_ex_to_mips(int xcpt);
static inline void restore_rounding_mode(CPUMIPSState *env)
{
set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3],
&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);
}
static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *pc, static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *pc,
target_ulong *cs_base, int *flags) target_ulong *cs_base, int *flags)
{ {

View file

@ -2283,18 +2283,6 @@ unsigned int ieee_rm[] = {
float_round_down float_round_down
}; };
static inline void restore_rounding_mode(CPUMIPSState *env)
{
set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3],
&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) target_ulong helper_cfc1(CPUMIPSState *env, uint32_t reg)
{ {
target_ulong arg1 = 0; target_ulong arg1 = 0;

View file

@ -19826,6 +19826,8 @@ void cpu_state_reset(CPUMIPSState *env)
} }
compute_hflags(env); compute_hflags(env);
restore_rounding_mode(env);
restore_flush_mode(env);
cs->exception_index = EXCP_NONE; cs->exception_index = EXCP_NONE;
} }