Added more entries to the LEON processor configuration register
PATCH 1/1 Added more entries to the LEON processor configuration register
--- target-sparc/helper.h | 1 + target-sparc/ldst_helper.c | 6 ++++++ target-sparc/translate.c | 10 +++------- 3 files changed, 10 insertions(+), 7 deletions(-)
target-sparc/helper.h +1 -0
@@ -5,6 +5,7 @@ DEF_HELPER_1(rett, void, env) DEF_HELPER_2(wrpsr, void, env, tl) DEF_HELPER_1(rdpsr, tl, env) DEF_HELPER_1(power_down, void, env) +DEF_HELPER_1(rdasr17, tl, env)#else DEF_HELPER_2(wrpil, void, env, tl)DEF_HELPER_2 (wrpstate, void, env, tl)
target-sparc/ldst_helper.c +6 -0
@@ -2326,6 +2326,12 @@ void helper_power_down(CPUSPARCState *env)cpu_loop_exit (env); } +target_ulong helper_rdasr17 (CPUSPARCState *env) +{ +/* CPU ID, Meiko FPU, SPARC V8, Number of register windows */ +return env->cpu_index <<28 | (2 <<10 ) | (1 <<8 ) | (env->nwindows -1 ); +} +#if !defined(CONFIG_USER_ONLY )#ifndef TARGET_SPARC64 void cpu_unassigned_access(CPUSPARCState *env, target_phys_addr_t addr,
target-sparc/translate.c +3 -7
@@ -2590,13 +2590,9 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)microSPARC II */ /* Read Asr17 */ if (rs1 ==0x11 && dc->def->features &CPU_FEATURE_ASR17 ) { -TCGv r_const; - -/* Read Asr17 for a Leon3 monoprocessor */ - r_const =tcg_const_tl ((1 <<8 ) - | (dc->def->nwindows -1 )); -gen_movl_TN_reg (rd, r_const); -tcg_temp_free (r_const); +/* Read Asr17 on LEON3 */ +gen_helper_rdasr17 (cpu_dst, cpu_env); +gen_movl_TN_reg (rd, cpu_dst);break ; }#endif
Signature · 1 line
1.7.2.5
Quoted 1 line · Ronald Hecht
Signed-off-by Ronald Hecht <[email protected]>
Signature · 1 line
Fabien Chouteau
Quoted 43 lines · Ronald Hecht
Signed-off-by Ronald Hecht <[email protected]>--- target-sparc/helper.h | 1 + target-sparc/ldst_helper.c | 6 ++++++ target-sparc/translate.c | 10 +++------- 3 files changed, 10 insertions(+), 7 deletions(-)target-sparc/helper.h +1
-0@@ -5,6 +5,7 @@ DEF_HELPER_1(rett, void, env) DEF_HELPER_2(wrpsr, void, env, tl) DEF_HELPER_1(rdpsr, tl, env) DEF_HELPER_1(power_down, void, env) +DEF_HELPER_1(rdasr17, tl, env)#else DEF_HELPER_2(wrpil, void, env, tl)DEF_HELPER_2 (wrpstate, void, env, tl)target-sparc/ldst_helper.c +6
-0@@ -2326,6 +2326,12 @@ void helper_power_down(CPUSPARCState *env)cpu_loop_exit (env); } +target_ulong helper_rdasr17 (CPUSPARCState *env) +{ +/* CPU ID, Meiko FPU, SPARC V8, Number of register windows */ +return env->cpu_index <<28 | (2 <<10 ) | (1 <<8 ) | (env->nwindows -1 ); +} +#if !defined(CONFIG_USER_ONLY )#ifndef TARGET_SPARC64 void cpu_unassigned_access(CPUSPARCState *env, target_phys_addr_t addr,target-sparc/translate.c +0
-0@@ -2590,13 +2590,9 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)microSPARC II */ /* Read Asr17 */
target-sparc/translate.c static void disas_sparc_insn(DisasContext * dc, unsigned int insn) · line 2594
Quoted 10 lines
target-sparc/translate.c +2
-7if (rs1 ==0x11 && dc->def->features &CPU_FEATURE_ASR17 ) { -TCGv r_const; - -/* Read Asr17 for a Leon3 monoprocessor */ - r_const =tcg_const_tl ((1 <<8 ) - | (dc->def->nwindows -1 )); -gen_movl_TN_reg (rd, r_const); -tcg_temp_free (r_const); +/* Read Asr17 on LEON3 */ +gen_helper_rdasr17 (cpu_dst, cpu_env);
Is the register is read very often? If it is, we could avoid the helper call by performing the load of env->cpu_index, the shift and OR with the above constant with TCG ops. The arithmetic could be even avoided completely by storing precalculated values in cpu_index, then other accesses to cpu_index need to shift right by 28 to read the index (depends on balance of other cpu_index uses vs. this instruction).
Quoted 7 lines
target-sparc/translate.c +1
-1+gen_movl_TN_reg (rd, cpu_dst); break; }#endif --1.7.2.5
Quoted 15 lines · Blue Swirl
Quoted 15 lines
target-sparc/translate.c +2
-7@@ -2590,13 +2590,9 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)microSPARC II */ /* Read Asr17 */ if (rs1 ==0x11 && dc->def->features&CPU_FEATURE_ASR17 ) { -TCGv r_const; - -/* Read Asr17 for a Leon3 monoprocessor */ - r_const =tcg_const_tl ((1 <<8 ) - | (dc->def->nwindows -1 )); -gen_movl_TN_reg (rd, r_const); -tcg_temp_free (r_const); +/* Read Asr17 on LEON3 */ +gen_helper_rdasr17 (cpu_dst, cpu_env);
Quoted 9 lines
Quoted 1 line
Is the register is read very often? If it is, we could avoid the helper call by performing the load of
env->cpu_index, the shift and OR with the above constant with TCG ops. The arithmetic could be even avoided completely by storing precalculated values incpu_index, then other accesses tocpu_indexneed to shift right by 28 to read the index (depends on balance of othercpu_indexuses vs. this instruction).
The register is read quite often, but not as often as the PSR. It is normally read when entering the OS (Linux, PikeOS ...) Kernel to know on which CPU we are running a thread. But polluting the cpu_index in env sounds a bit strange and overkill to me. Do you really mean the cpu_index in the structure CPUSPARCState? Or could we place it in dc->def as a constant?
Best regards,
Ronald
Quoted 33 lines · Ronald Hecht
Quoted 22 lines · Blue Swirl
Quoted 11 lines
target-sparc/translate.c +0
-0@@ -2590,13 +2590,9 @@ static void disas_sparc_insn(DisasContext * dc,unsigned int insn) microSPARC II */ /* Read Asr17 */ if (rs1 ==0x11 && dc->def->features&CPU_FEATURE_ASR17 ) {target-sparc/translate.c static void disas_sparc_insn(DisasContext * dc, · line 2594
Quoted 10 lines
target-sparc/translate.c +2
-7-TCGv r_const; - -/* Read Asr17 for a Leon3 monoprocessor */ - r_const =tcg_const_tl ((1 <<8 ) - | (dc->def->nwindows - 1)); -gen_movl_TN_reg (rd, r_const); -tcg_temp_free (r_const); +/* Read Asr17 on LEON3 */ +gen_helper_rdasr17 (cpu_dst, cpu_env);Quoted 8 lines
Is the register is read very often? If it is, we could avoid the helper call by performing the load of
env->cpu_index, the shift and OR with the above constant with TCG ops. The arithmetic could be even avoided completely by storing precalculated values incpu_index, then other accesses tocpu_indexneed to shift right by 28 to read the index (depends on balance of othercpu_indexuses vs. this instruction).
Quoted 5 lines
The register is read quite often, but not as often as the PSR. It is normally read when entering the OS (Linux, PikeOS ...) Kernel to know on which CPU we are running a thread. But polluting the
cpu_indexin env sounds a bit strange and overkill to me. Do you really mean thecpu_indexin the structure CPUSPARCState? Or could we place it indc->defas a constant?
It could be a new field specific to asr17. The field value is not necessarily known at translation time since translation could be done for another CPU, so dc->def would not work.
Quoted 3 lines
Best regards,
Ronald