target/sparc: Split ver from env->fsr

This field is read-only.  It is easier to store it separately
and merge it only upon read.

While we're at it, use FSR_VER_SHIFT to initialize fpu_version.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20231103173841.33651-17-richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2023-11-03 10:38:35 -07:00
parent 1ccd6e13cc
commit 49bb972513
3 changed files with 23 additions and 16 deletions

View File

@ -368,7 +368,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "Fujitsu MB86904", .name = "Fujitsu MB86904",
.iu_version = 0x04 << 24, /* Impl 0, ver 4 */ .iu_version = 0x04 << 24, /* Impl 0, ver 4 */
.fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */
.mmu_version = 0x04 << 24, /* Impl 0, ver 4 */ .mmu_version = 0x04 << 24, /* Impl 0, ver 4 */
.mmu_bm = 0x00004000, .mmu_bm = 0x00004000,
.mmu_ctpr_mask = 0x00ffffc0, .mmu_ctpr_mask = 0x00ffffc0,
@ -381,7 +381,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "Fujitsu MB86907", .name = "Fujitsu MB86907",
.iu_version = 0x05 << 24, /* Impl 0, ver 5 */ .iu_version = 0x05 << 24, /* Impl 0, ver 5 */
.fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */
.mmu_version = 0x05 << 24, /* Impl 0, ver 5 */ .mmu_version = 0x05 << 24, /* Impl 0, ver 5 */
.mmu_bm = 0x00004000, .mmu_bm = 0x00004000,
.mmu_ctpr_mask = 0xffffffc0, .mmu_ctpr_mask = 0xffffffc0,
@ -394,7 +394,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI MicroSparc I", .name = "TI MicroSparc I",
.iu_version = 0x41000000, .iu_version = 0x41000000,
.fpu_version = 4 << 17, .fpu_version = 4 << FSR_VER_SHIFT,
.mmu_version = 0x41000000, .mmu_version = 0x41000000,
.mmu_bm = 0x00004000, .mmu_bm = 0x00004000,
.mmu_ctpr_mask = 0x007ffff0, .mmu_ctpr_mask = 0x007ffff0,
@ -407,7 +407,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI MicroSparc II", .name = "TI MicroSparc II",
.iu_version = 0x42000000, .iu_version = 0x42000000,
.fpu_version = 4 << 17, .fpu_version = 4 << FSR_VER_SHIFT,
.mmu_version = 0x02000000, .mmu_version = 0x02000000,
.mmu_bm = 0x00004000, .mmu_bm = 0x00004000,
.mmu_ctpr_mask = 0x00ffffc0, .mmu_ctpr_mask = 0x00ffffc0,
@ -420,7 +420,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI MicroSparc IIep", .name = "TI MicroSparc IIep",
.iu_version = 0x42000000, .iu_version = 0x42000000,
.fpu_version = 4 << 17, .fpu_version = 4 << FSR_VER_SHIFT,
.mmu_version = 0x04000000, .mmu_version = 0x04000000,
.mmu_bm = 0x00004000, .mmu_bm = 0x00004000,
.mmu_ctpr_mask = 0x00ffffc0, .mmu_ctpr_mask = 0x00ffffc0,
@ -433,7 +433,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI SuperSparc 40", /* STP1020NPGA */ .name = "TI SuperSparc 40", /* STP1020NPGA */
.iu_version = 0x41000000, /* SuperSPARC 2.x */ .iu_version = 0x41000000, /* SuperSPARC 2.x */
.fpu_version = 0 << 17, .fpu_version = 0 << FSR_VER_SHIFT,
.mmu_version = 0x00000800, /* SuperSPARC 2.x, no MXCC */ .mmu_version = 0x00000800, /* SuperSPARC 2.x, no MXCC */
.mmu_bm = 0x00002000, .mmu_bm = 0x00002000,
.mmu_ctpr_mask = 0xffffffc0, .mmu_ctpr_mask = 0xffffffc0,
@ -446,7 +446,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI SuperSparc 50", /* STP1020PGA */ .name = "TI SuperSparc 50", /* STP1020PGA */
.iu_version = 0x40000000, /* SuperSPARC 3.x */ .iu_version = 0x40000000, /* SuperSPARC 3.x */
.fpu_version = 0 << 17, .fpu_version = 0 << FSR_VER_SHIFT,
.mmu_version = 0x01000800, /* SuperSPARC 3.x, no MXCC */ .mmu_version = 0x01000800, /* SuperSPARC 3.x, no MXCC */
.mmu_bm = 0x00002000, .mmu_bm = 0x00002000,
.mmu_ctpr_mask = 0xffffffc0, .mmu_ctpr_mask = 0xffffffc0,
@ -459,7 +459,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI SuperSparc 51", .name = "TI SuperSparc 51",
.iu_version = 0x40000000, /* SuperSPARC 3.x */ .iu_version = 0x40000000, /* SuperSPARC 3.x */
.fpu_version = 0 << 17, .fpu_version = 0 << FSR_VER_SHIFT,
.mmu_version = 0x01000000, /* SuperSPARC 3.x, MXCC */ .mmu_version = 0x01000000, /* SuperSPARC 3.x, MXCC */
.mmu_bm = 0x00002000, .mmu_bm = 0x00002000,
.mmu_ctpr_mask = 0xffffffc0, .mmu_ctpr_mask = 0xffffffc0,
@ -473,7 +473,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI SuperSparc 60", /* STP1020APGA */ .name = "TI SuperSparc 60", /* STP1020APGA */
.iu_version = 0x40000000, /* SuperSPARC 3.x */ .iu_version = 0x40000000, /* SuperSPARC 3.x */
.fpu_version = 0 << 17, .fpu_version = 0 << FSR_VER_SHIFT,
.mmu_version = 0x01000800, /* SuperSPARC 3.x, no MXCC */ .mmu_version = 0x01000800, /* SuperSPARC 3.x, no MXCC */
.mmu_bm = 0x00002000, .mmu_bm = 0x00002000,
.mmu_ctpr_mask = 0xffffffc0, .mmu_ctpr_mask = 0xffffffc0,
@ -486,7 +486,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI SuperSparc 61", .name = "TI SuperSparc 61",
.iu_version = 0x44000000, /* SuperSPARC 3.x */ .iu_version = 0x44000000, /* SuperSPARC 3.x */
.fpu_version = 0 << 17, .fpu_version = 0 << FSR_VER_SHIFT,
.mmu_version = 0x01000000, /* SuperSPARC 3.x, MXCC */ .mmu_version = 0x01000000, /* SuperSPARC 3.x, MXCC */
.mmu_bm = 0x00002000, .mmu_bm = 0x00002000,
.mmu_ctpr_mask = 0xffffffc0, .mmu_ctpr_mask = 0xffffffc0,
@ -500,7 +500,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "TI SuperSparc II", .name = "TI SuperSparc II",
.iu_version = 0x40000000, /* SuperSPARC II 1.x */ .iu_version = 0x40000000, /* SuperSPARC II 1.x */
.fpu_version = 0 << 17, .fpu_version = 0 << FSR_VER_SHIFT,
.mmu_version = 0x08000000, /* SuperSPARC II 1.x, MXCC */ .mmu_version = 0x08000000, /* SuperSPARC II 1.x, MXCC */
.mmu_bm = 0x00002000, .mmu_bm = 0x00002000,
.mmu_ctpr_mask = 0xffffffc0, .mmu_ctpr_mask = 0xffffffc0,
@ -514,7 +514,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "LEON2", .name = "LEON2",
.iu_version = 0xf2000000, .iu_version = 0xf2000000,
.fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */
.mmu_version = 0xf2000000, .mmu_version = 0xf2000000,
.mmu_bm = 0x00004000, .mmu_bm = 0x00004000,
.mmu_ctpr_mask = 0x007ffff0, .mmu_ctpr_mask = 0x007ffff0,
@ -527,7 +527,7 @@ static const sparc_def_t sparc_defs[] = {
{ {
.name = "LEON3", .name = "LEON3",
.iu_version = 0xf3000000, .iu_version = 0xf3000000,
.fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */
.mmu_version = 0xf3000000, .mmu_version = 0xf3000000,
.mmu_bm = 0x00000000, .mmu_bm = 0x00000000,
.mmu_ctpr_mask = 0xfffffffc, .mmu_ctpr_mask = 0xfffffffc,
@ -786,7 +786,6 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
#endif #endif
env->version = env->def.iu_version; env->version = env->def.iu_version;
env->fsr = env->def.fpu_version;
env->nwindows = env->def.nwindows; env->nwindows = env->def.nwindows;
#if !defined(TARGET_SPARC64) #if !defined(TARGET_SPARC64)
env->mmuregs[0] |= env->def.mmu_version; env->mmuregs[0] |= env->def.mmu_version;

View File

@ -191,6 +191,9 @@ enum {
#define FSR_NXC (1ULL << 0) #define FSR_NXC (1ULL << 0)
#define FSR_CEXC_MASK (FSR_NVC | FSR_OFC | FSR_UFC | FSR_DZC | FSR_NXC) #define FSR_CEXC_MASK (FSR_NVC | FSR_OFC | FSR_UFC | FSR_DZC | FSR_NXC)
#define FSR_VER_SHIFT 17
#define FSR_VER_MASK (7 << FSR_VER_SHIFT)
#define FSR_FTT2 (1ULL << 16) #define FSR_FTT2 (1ULL << 16)
#define FSR_FTT1 (1ULL << 15) #define FSR_FTT1 (1ULL << 15)
#define FSR_FTT0 (1ULL << 14) #define FSR_FTT0 (1ULL << 14)

View File

@ -349,7 +349,12 @@ GEN_FCMP(fcmpeq_fcc3, float128, 26, 1);
target_ulong cpu_get_fsr(CPUSPARCState *env) target_ulong cpu_get_fsr(CPUSPARCState *env)
{ {
return env->fsr; target_ulong fsr = env->fsr;
/* VER is kept completely separate until re-assembly. */
fsr |= env->def.fpu_version;
return fsr;
} }
target_ulong helper_get_fsr(CPUSPARCState *env) target_ulong helper_get_fsr(CPUSPARCState *env)
@ -361,7 +366,7 @@ static void set_fsr_nonsplit(CPUSPARCState *env, target_ulong fsr)
{ {
int rnd_mode; int rnd_mode;
env->fsr = fsr; env->fsr = fsr & ~FSR_VER_MASK;
switch (fsr & FSR_RD_MASK) { switch (fsr & FSR_RD_MASK) {
case FSR_RD_NEAREST: case FSR_RD_NEAREST: