Instead of open-coding the "take NOCP exception if FPU disabled,
otherwise call gen_preserve_fp_state()" code in the accessors for
FPCXT_NS, add an argument to vfp_access_check_m() which tells it to
skip the gen_update_fp_context() call, so we can use it for the
FPCXT_NS case.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id:
20210618141019.10671-8-peter.maydell@linaro.org
void load_reg_var(DisasContext *s, TCGv_i32 var, int reg);
void arm_gen_condlabel(DisasContext *s);
bool vfp_access_check(DisasContext *s);
-void gen_preserve_fp_state(DisasContext *s);
+bool vfp_access_check_m(DisasContext *s, bool skip_context_update);
void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop);
void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop);
void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop);
* otherwise PreserveFPState(), and then FPCXT_NS writes
* behave the same as FPCXT_S writes.
*/
- if (s->fp_excp_el) {
- gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
- syn_uncategorized(), s->fp_excp_el);
+ if (!vfp_access_check_m(s, true)) {
/*
* This was only a conditional exception, so override
* gen_exception_insn()'s default to DISAS_NORETURN
s->base.is_jmp = DISAS_NEXT;
break;
}
- gen_preserve_fp_state(s);
}
/* fall through */
case ARM_VFP_FPCXT_S:
* otherwise PreserveFPState(), and then FPCXT_NS
* reads the same as FPCXT_S.
*/
- if (s->fp_excp_el) {
- gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
- syn_uncategorized(), s->fp_excp_el);
+ if (!vfp_access_check_m(s, true)) {
/*
* This was only a conditional exception, so override
* gen_exception_insn()'s default to DISAS_NORETURN
s->base.is_jmp = DISAS_NEXT;
break;
}
- gen_preserve_fp_state(s);
tmp = tcg_temp_new_i32();
sfpa = tcg_temp_new_i32();
fpscr = tcg_temp_new_i32();
* Generate code for M-profile lazy FP state preservation if needed;
* this corresponds to the pseudocode PreserveFPState() function.
*/
-void gen_preserve_fp_state(DisasContext *s)
+static void gen_preserve_fp_state(DisasContext *s)
{
if (s->v7m_lspact) {
/*
* If VFP is enabled, do the necessary M-profile lazy-FP handling and then
* return true. If not, emit code to generate an appropriate exception and
* return false.
+ * skip_context_update is true to skip the "update FP context" part of this.
*/
-static bool vfp_access_check_m(DisasContext *s)
+bool vfp_access_check_m(DisasContext *s, bool skip_context_update)
{
if (s->fp_excp_el) {
/*
/* Trigger lazy-state preservation if necessary */
gen_preserve_fp_state(s);
- /* Update ownership of FP context and create new FP context if needed */
- gen_update_fp_context(s);
+ if (!skip_context_update) {
+ /* Update ownership of FP context and create new FP context if needed */
+ gen_update_fp_context(s);
+ }
return true;
}
bool vfp_access_check(DisasContext *s)
{
if (arm_dc_feature(s, ARM_FEATURE_M)) {
- return vfp_access_check_m(s);
+ return vfp_access_check_m(s, false);
} else {
return vfp_access_check_a(s, false);
}