On 2020/6/3 12:27, Richard Henderson wrote:
On 5/21/20 2:43 AM, LIU Zhiwei wrote:
@@ -174,6 +175,9 @@ static int write_frm(CPURISCVState *env, int csrno,
target_ulong val)
env->mstatus |= MSTATUS_FS;
#endif
env->frm = val & (FSR_RD >> FSR_RD_SHIFT);
+ if (!riscv_cpu_set_rounding_mode(env, env->frm)) {
+ return -1;
+ }
This will raise an exception immediately in helper_csrrw().
According to Section 8.2, the no exception should occur until the next fp
operation that uses the invalid frm.
You're doing this just fine in helper_set_rounding_mode(), which is sufficient
for scalar fp ops. Without looking forward to later patches, I suppose we'll
need to do something else for vector fp ops.
Hi Richard,
I think you are right. Maybe I should transmit frm to ctx->frm, and
check ctx->frm in vector fp ops.
We can set ctx->frm = env->frm instead of ctx->frm = -1 in
riscv_tr_init_disas_context.
And remove the sentence ctx->frm = rm; from gen_set_rm.
Is it right?
Zhiwei
r~