target/arm: Define new fp_status_a32 and fp_status_a64

We want to split the existing fp_status in the Arm CPUState into
separate float_status fields for AArch32 and AArch64.  (This is
because new control bits defined by FEAT_AFP only have an effect for
AArch64, not AArch32.) To make this split we will:
 * define new fp_status_a32 and fp_status_a64 which have
   identical behaviour to the existing fp_status
 * move existing uses of fp_status to fp_status_a32 or
   fp_status_a64 as appropriate
 * delete the old fp_status when it has no uses left

In this patch we add the new float_status fields.

We will also need to split fp_status_f16, but we will do that
as a separate series of patches.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20250124162836.2332150-7-peter.maydell@linaro.org
This commit is contained in:
Peter Maydell 2025-01-24 16:27:26 +00:00
parent eda8d53083
commit 2208cb46e6
4 changed files with 30 additions and 0 deletions

View file

@ -573,6 +573,8 @@ static void arm_cpu_reset_hold(Object *obj, ResetType type)
set_default_nan_mode(1, &env->vfp.standard_fp_status); set_default_nan_mode(1, &env->vfp.standard_fp_status);
set_default_nan_mode(1, &env->vfp.standard_fp_status_f16); set_default_nan_mode(1, &env->vfp.standard_fp_status_f16);
arm_set_default_fp_behaviours(&env->vfp.fp_status); arm_set_default_fp_behaviours(&env->vfp.fp_status);
arm_set_default_fp_behaviours(&env->vfp.fp_status_a32);
arm_set_default_fp_behaviours(&env->vfp.fp_status_a64);
arm_set_default_fp_behaviours(&env->vfp.standard_fp_status); arm_set_default_fp_behaviours(&env->vfp.standard_fp_status);
arm_set_default_fp_behaviours(&env->vfp.fp_status_f16); arm_set_default_fp_behaviours(&env->vfp.fp_status_f16);
arm_set_default_fp_behaviours(&env->vfp.standard_fp_status_f16); arm_set_default_fp_behaviours(&env->vfp.standard_fp_status_f16);

View file

@ -634,6 +634,8 @@ typedef struct CPUArchState {
/* There are a number of distinct float control structures: /* There are a number of distinct float control structures:
* *
* fp_status: is the "normal" fp status. * fp_status: is the "normal" fp status.
* fp_status_a32: is the "normal" fp status for AArch32 insns
* fp_status_a64: is the "normal" fp status for AArch64 insns
* fp_status_fp16: used for half-precision calculations * fp_status_fp16: used for half-precision calculations
* standard_fp_status : the ARM "Standard FPSCR Value" * standard_fp_status : the ARM "Standard FPSCR Value"
* standard_fp_status_fp16 : used for half-precision * standard_fp_status_fp16 : used for half-precision
@ -659,6 +661,8 @@ typedef struct CPUArchState {
* an explicit FPSCR read. * an explicit FPSCR read.
*/ */
float_status fp_status; float_status fp_status;
float_status fp_status_a32;
float_status fp_status_a64;
float_status fp_status_f16; float_status fp_status_f16;
float_status standard_fp_status; float_status standard_fp_status;
float_status standard_fp_status_f16; float_status standard_fp_status_f16;

View file

@ -671,6 +671,8 @@ static inline CPUARMTBFlags arm_tbflags_from_tb(const TranslationBlock *tb)
*/ */
typedef enum ARMFPStatusFlavour { typedef enum ARMFPStatusFlavour {
FPST_FPCR, FPST_FPCR,
FPST_A32,
FPST_A64,
FPST_FPCR_F16, FPST_FPCR_F16,
FPST_STD, FPST_STD,
FPST_STD_F16, FPST_STD_F16,
@ -686,6 +688,10 @@ typedef enum ARMFPStatusFlavour {
* *
* FPST_FPCR * FPST_FPCR
* for non-FP16 operations controlled by the FPCR * for non-FP16 operations controlled by the FPCR
* FPST_A32
* for AArch32 non-FP16 operations controlled by the FPCR
* FPST_A64
* for AArch64 non-FP16 operations controlled by the FPCR
* FPST_FPCR_F16 * FPST_FPCR_F16
* for operations controlled by the FPCR where FPCR.FZ16 is to be used * for operations controlled by the FPCR where FPCR.FZ16 is to be used
* FPST_STD * FPST_STD
@ -702,6 +708,12 @@ static inline TCGv_ptr fpstatus_ptr(ARMFPStatusFlavour flavour)
case FPST_FPCR: case FPST_FPCR:
offset = offsetof(CPUARMState, vfp.fp_status); offset = offsetof(CPUARMState, vfp.fp_status);
break; break;
case FPST_A32:
offset = offsetof(CPUARMState, vfp.fp_status_a32);
break;
case FPST_A64:
offset = offsetof(CPUARMState, vfp.fp_status_a64);
break;
case FPST_FPCR_F16: case FPST_FPCR_F16:
offset = offsetof(CPUARMState, vfp.fp_status_f16); offset = offsetof(CPUARMState, vfp.fp_status_f16);
break; break;

View file

@ -64,6 +64,8 @@ static uint32_t vfp_get_fpsr_from_host(CPUARMState *env)
uint32_t i; uint32_t i;
i = get_float_exception_flags(&env->vfp.fp_status); i = get_float_exception_flags(&env->vfp.fp_status);
i |= get_float_exception_flags(&env->vfp.fp_status_a32);
i |= get_float_exception_flags(&env->vfp.fp_status_a64);
i |= get_float_exception_flags(&env->vfp.standard_fp_status); i |= get_float_exception_flags(&env->vfp.standard_fp_status);
/* FZ16 does not generate an input denormal exception. */ /* FZ16 does not generate an input denormal exception. */
i |= (get_float_exception_flags(&env->vfp.fp_status_f16) i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
@ -81,6 +83,8 @@ static void vfp_clear_float_status_exc_flags(CPUARMState *env)
* be the architecturally up-to-date exception flag information first. * be the architecturally up-to-date exception flag information first.
*/ */
set_float_exception_flags(0, &env->vfp.fp_status); set_float_exception_flags(0, &env->vfp.fp_status);
set_float_exception_flags(0, &env->vfp.fp_status_a32);
set_float_exception_flags(0, &env->vfp.fp_status_a64);
set_float_exception_flags(0, &env->vfp.fp_status_f16); set_float_exception_flags(0, &env->vfp.fp_status_f16);
set_float_exception_flags(0, &env->vfp.standard_fp_status); set_float_exception_flags(0, &env->vfp.standard_fp_status);
set_float_exception_flags(0, &env->vfp.standard_fp_status_f16); set_float_exception_flags(0, &env->vfp.standard_fp_status_f16);
@ -109,6 +113,8 @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask)
break; break;
} }
set_float_rounding_mode(i, &env->vfp.fp_status); set_float_rounding_mode(i, &env->vfp.fp_status);
set_float_rounding_mode(i, &env->vfp.fp_status_a32);
set_float_rounding_mode(i, &env->vfp.fp_status_a64);
set_float_rounding_mode(i, &env->vfp.fp_status_f16); set_float_rounding_mode(i, &env->vfp.fp_status_f16);
} }
if (changed & FPCR_FZ16) { if (changed & FPCR_FZ16) {
@ -122,10 +128,16 @@ static void vfp_set_fpcr_to_host(CPUARMState *env, uint32_t val, uint32_t mask)
bool ftz_enabled = val & FPCR_FZ; bool ftz_enabled = val & FPCR_FZ;
set_flush_to_zero(ftz_enabled, &env->vfp.fp_status); set_flush_to_zero(ftz_enabled, &env->vfp.fp_status);
set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status); set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status);
set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_a32);
set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_a32);
set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_a64);
set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_a64);
} }
if (changed & FPCR_DN) { if (changed & FPCR_DN) {
bool dnan_enabled = val & FPCR_DN; bool dnan_enabled = val & FPCR_DN;
set_default_nan_mode(dnan_enabled, &env->vfp.fp_status); set_default_nan_mode(dnan_enabled, &env->vfp.fp_status);
set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a32);
set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_a64);
set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16);
} }
} }