target-mips: Add more reg numbers for RDHWR
PATCH 1/1 target-mips: Add more reg numbers for RDHWR
Add more register numbers for RDHWR
Add check_hwrena() to simplify access control checkings. Add RDHWR support to microMIPS R6
Signed-off-by Yongbok Kim <[email protected]>
--- target-mips/cpu.h | 1 + target-mips/helper.h | 2 + target-mips/op_helper.c | 63 +++++++++++++++++++++++++--------------------- target-mips/translate.c | 28 ++++++++++++++++++-- 4 files changed, 62 insertions(+), 32 deletions(-)
target-mips/cpu.h +1 -0
@@ -468,6 +468,7 @@ struct CPUMIPSState {#define CP0C5_CV 29#define CP0C5_EVA 28#define CP0C5_MSAEn 27 +#define CP0C5_XNP 13#define CP0C5_UFE 9#define CP0C5_FRE 8#define CP0C5_SBRI 6
target-mips/helper.h +2 -0
@@ -358,6 +358,8 @@ DEF_HELPER_1(rdhwr_cpunum, tl, env) DEF_HELPER_1(rdhwr_synci_step, tl, env) DEF_HELPER_1(rdhwr_cc, tl, env) DEF_HELPER_1(rdhwr_ccres, tl, env) +DEF_HELPER_1(rdhwr_performance, tl, env) +DEF_HELPER_1(rdhwr_xnp, tl, env) DEF_HELPER_2(pmon, void, env, int)DEF_HELPER_1 (wait, void, env)
target-mips/op_helper.c +34 -29
93 lines not on this page · raw message
target-mips/translate.c +25 -3
@@ -10337,7 +10337,7 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, } } -static void gen_rdhwr (DisasContext *ctx,int rt,int rd) +static void gen_rdhwr (DisasContext *ctx,int rt,int rd,int sel) {TCGv t0;
@@ -10365,6 +10365,22 @@ static void gen_rdhwr(DisasContext *ctx, int rt, int rd)gen_helper_rdhwr_ccres (t0, cpu_env);gen_store_gpr (t0, rt);break ; +case 4 : +check_insn (ctx,ISA_MIPS32R6 ); +if (sel !=0 ) { +/* Performance counter registers are not implemented other than +* control register 0. +*/ +generate_exception (ctx,EXCP_RI ); + } +gen_helper_rdhwr_performance (t0, cpu_env); +gen_store_gpr (t0, rt); +break ; +case 5 : +check_insn (ctx,ISA_MIPS32R6 ); +gen_helper_rdhwr_xnp (t0, cpu_env); +gen_store_gpr (t0, rt); +break ;case 29 :#if defined(CONFIG_USER_ONLY ) tcg_gen_ld_tl(t0, cpu_env,
@@ -11983,6 +11999,7 @@ enum {ROTR =0x3 ,SELEQZ =0x5 ,SELNEZ =0x6 , +R6_RDHWR =0x7 ,SLLV =0x0 , SRLV = 0x1,
@@ -12937,7 +12954,8 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)gen_cl (ctx, mips32_op, rt, rs);break ;case RDHWR : -gen_rdhwr (ctx, rt, rs); +check_insn_opc_removed (ctx,ISA_MIPS32R6 ); +gen_rdhwr (ctx, rt, rs,0 );break ;case WSBH :gen_bshfl (ctx,OPC_WSBH , rs, rt);
@@ -13492,6 +13510,10 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx)check_insn (ctx,ISA_MIPS32R6 );gen_cond_move (ctx,OPC_SELNEZ , rd, rs, rt);break ; +case R6_RDHWR : +check_insn (ctx,ISA_MIPS32R6 ); +gen_rdhwr (ctx, rt, rs,extract32 (ctx->opcode,11 ,3 )); +break ;default : goto pool32a_invalid; }
@@ -17742,7 +17764,7 @@ static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx)break ;#endif case OPC_RDHWR : -gen_rdhwr (ctx, rt, rd); +gen_rdhwr (ctx, rt, rd,extract32 (ctx->opcode,6 ,3 ));break ;case OPC_FORK :check_insn (ctx,ASE_MT );
Signature · 1 line
1.7.1
Quoted 1 line · Yongbok Kim
Add more register numbers for RDHWR
Could the commit message say which registers exactly this patch is adding?
target-mips/op_helper.c void helper_mtc0_hwrena(CPUMIPSState *env, target_ulong arg1) · line 1362
Quoted 13 lines
Add
check_hwrena()to simplify access control checkings. Add RDHWR support to microMIPS R6Signed-off-by Yongbok Kim <[email protected]>---
target-mips/op_helper.c +3
-0@@ -1357,6 +1357,12 @@ void helper_mtc0_hwrena(CPUMIPSState *env, target_ulong arg1) {uint32_t mask =0x0000000F ; +if (env->CP0_Config1 & (1 <<CP0C1_PC )) { + mask |= (1 <<4 ); + }
I think we should check also for ISA_MIPS32R6 here. The access to CP0.PerfCnt via RDHWR was added in R6 and before that the register number 4 in HWREna was reserved.
Otherwise looks good to me.
Thanks,
Leon