[4794] More efficient target register / TC accesses.
Revision: 4794
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4794 Author: ths Date: 2008-06-27 10:02:35 +0000 (Fri, 27 Jun 2008)
Log Message:
-----------
More efficient target register / TC accesses.
Modified Paths:
--------------
trunk/cpu-exec.c
trunk/gdbstub.c
trunk/hw/mips_mipssim.c
trunk/hw/mips_r4k.c
trunk/linux-user/main.c
trunk/linux-user/mips/target_signal.h
trunk/linux-user/mips64/target_signal.h
trunk/linux-user/mipsn32/target_signal.h
trunk/linux-user/signal.c
trunk/linux-user/syscall.c
trunk/monitor.c
trunk/target-mips/cpu.h
trunk/target-mips/helper.c
trunk/target-mips/op_helper.c
trunk/target-mips/translate.c
trunk/target-mips/translate_init.cModified: trunk/cpu-exec.c
===================================================================
cpu-exec.c +1 -1
@@ -197,7 +197,7 @@#elif defined(TARGET_MIPS ) flags = env->hflags & (MIPS_HFLAG_TMASK |MIPS_HFLAG_BMASK ); cs_base =0 ; - pc = env->PC[env->current_tc]; + pc = env->active_tc.PC;#elif defined(TARGET_M68K ) flags = (env->fpcr &M68K_FPCR_PREC )/* Bit 6 */ | (env->sr &SR_S )/* Bit 13 */
Modified: trunk/gdbstub.c
===================================================================
gdbstub.c +10 -10
@@ -704,17 +704,17 @@ ptr = mem_buf;for (i =0 ; i <32 ; i++) { - *(target_ulong *)ptr =tswapl (env->gpr[env->current_tc][i]); + *(target_ulong *)ptr =tswapl (env->active_tc.gpr[i]); ptr +=sizeof (target_ulong); } *(target_ulong *)ptr = (int32_t )tswap32 (env->CP0_Status); ptr +=sizeof (target_ulong); - *(target_ulong *)ptr =tswapl (env->LO[env->current_tc][0 ]); + *(target_ulong *)ptr =tswapl (env->active_tc.LO[0 ]); ptr +=sizeof (target_ulong); - *(target_ulong *)ptr =tswapl (env->HI[env->current_tc][0 ]); + *(target_ulong *)ptr =tswapl (env->active_tc.HI[0 ]); ptr +=sizeof (target_ulong); *(target_ulong *)ptr =tswapl (env->CP0_BadVAddr);
@@ -723,7 +723,7 @@ *(target_ulong *)ptr = (int32_t )tswap32 (env->CP0_Cause); ptr +=sizeof (target_ulong); - *(target_ulong *)ptr =tswapl (env->PC[env->current_tc]); + *(target_ulong *)ptr =tswapl (env->active_tc.PC); ptr +=sizeof (target_ulong);if (env->CP0_Config1 & (1 <<CP0C1_FP ))
@@ -781,17 +781,17 @@ ptr = mem_buf;for (i =0 ; i <32 ; i++) { - env->gpr[env->current_tc][i] =tswapl (*(target_ulong *)ptr); + env->active_tc.gpr[i] =tswapl (*(target_ulong *)ptr); ptr +=sizeof (target_ulong); } env->CP0_Status =tswapl (*(target_ulong *)ptr); ptr +=sizeof (target_ulong); - env->LO[env->current_tc][0 ] =tswapl (*(target_ulong *)ptr); + env->active_tc.LO[0 ] =tswapl (*(target_ulong *)ptr); ptr +=sizeof (target_ulong); - env->HI[env->current_tc][0 ] =tswapl (*(target_ulong *)ptr); + env->active_tc.HI[0 ] =tswapl (*(target_ulong *)ptr); ptr +=sizeof (target_ulong); env->CP0_BadVAddr =tswapl (*(target_ulong *)ptr);
@@ -800,7 +800,7 @@ env->CP0_Cause =tswapl (*(target_ulong *)ptr); ptr +=sizeof (target_ulong); - env->PC[env->current_tc] =tswapl (*(target_ulong *)ptr); + env->active_tc.PC =tswapl (*(target_ulong *)ptr); ptr +=sizeof (target_ulong);if (env->CP0_Config1 & (1 <<CP0C1_FP ))
@@ -1003,7 +1003,7 @@#elif defined (TARGET_SH4 ) env->pc = addr;#elif defined (TARGET_MIPS ) - env->PC[env->current_tc] = addr; + env->active_tc.PC = addr;#elif defined (TARGET_CRIS ) env->pc = addr;#endif
@@ -1040,7 +1040,7 @@#elif defined (TARGET_SH4 ) env->pc = addr;#elif defined (TARGET_MIPS ) - env->PC[env->current_tc] = addr; + env->active_tc.PC = addr;#elif defined (TARGET_CRIS ) env->pc = addr;#endif
Modified: trunk/hw/mips_mipssim.c
===================================================================
hw/mips_mipssim.c +2 -2
@@ -65,7 +65,7 @@if (kernel_size >=0 ) {if ((entry & ~0x7fffffffULL ) ==0x80000000 ) entry = (int32_t )entry; - env->PC[env->current_tc] = entry; + env->active_tc.PC = entry; }else {fprintf (stderr,"qemu: could not load kernel '%s'\n" , loaderparams.kernel_filename);
@@ -152,7 +152,7 @@cpu_register_physical_memory (0x1fc00000LL , bios_size, bios_offset |IO_MEM_ROM );/* We have a boot vector start address. */ - env->PC[env->current_tc] = (target_long )(int32_t )0xbfc00000 ; + env->active_tc.PC = (target_long )(int32_t )0xbfc00000 ; }if (kernel_filename) {
Modified: trunk/hw/mips_r4k.c
===================================================================
hw/mips_r4k.c +1 -1
@@ -87,7 +87,7 @@if (kernel_size >=0 ) {if ((entry & ~0x7fffffffULL ) ==0x80000000 ) entry = (int32_t )entry; - env->PC[env->current_tc] = entry; + env->active_tc.PC = entry; }else {fprintf (stderr,"qemu: could not load kernel '%s'\n" , loaderparams.kernel_filename);
Modified: trunk/linux-user/main.c
===================================================================
linux-user/main.c +13 -13
@@ -1779,8 +1779,8 @@ trapnr =cpu_mips_exec (env);switch (trapnr) {case EXCP_SYSCALL : - syscall_num = env->gpr[env->current_tc][2 ] -4000 ; - env->PC[env->current_tc] +=4 ; + syscall_num = env->active_tc.gpr[2 ] -4000 ; + env->active_tc.PC +=4 ;if (syscall_num >=sizeof (mips_syscall_args)) { ret = -ENOSYS ; }else {
@@ -1789,7 +1789,7 @@abi_ulong arg5 =0 , arg6 =0 , arg7 =0 , arg8 =0 ; nb_args = mips_syscall_args[syscall_num]; - sp_reg = env->gpr[env->current_tc][29 ]; + sp_reg = env->active_tc.gpr[29 ];switch (nb_args) {/* these arguments are taken from the stack */ /* FIXME - what to do if get_user() fails? */
@@ -1800,20 +1800,20 @@default :break ; } - ret =do_syscall (env, env->gpr[env->current_tc][2 ], - env->gpr[env->current_tc][4 ], - env->gpr[env->current_tc][5 ], - env->gpr[env->current_tc][6 ], - env->gpr[env->current_tc][7 ], + ret =do_syscall (env, env->active_tc.gpr[2 ], + env->active_tc.gpr[4 ], + env->active_tc.gpr[5 ], + env->active_tc.gpr[6 ], + env->active_tc.gpr[7 ], arg5, arg6/*, arg7, arg8*/ ); }if ((unsigned int )ret >= (unsigned int )(-1133 )) { - env->gpr[env->current_tc][7 ] =1 ;/* error flag */ + env->active_tc.gpr[7 ] =1 ;/* error flag */ ret = -ret; }else { - env->gpr[env->current_tc][7 ] =0 ;/* error flag */ + env->active_tc.gpr[7 ] =0 ;/* error flag */ } - env->gpr[env->current_tc][2 ] = ret; + env->active_tc.gpr[2 ] = ret;break ;case EXCP_TLBL :case EXCP_TLBS :
@@ -2566,9 +2566,9 @@int i;for (i =0 ; i <32 ; i++) { - env->gpr[env->current_tc][i] = regs->regs[i]; + env->active_tc.gpr[i] = regs->regs[i]; } - env->PC[env->current_tc] = regs->cp0_epc; + env->active_tc.PC = regs->cp0_epc; }#elif defined(TARGET_SH4) {
Modified: trunk/linux-user/mips/target_signal.h
===================================================================
linux-user/mips/target_signal.h +1 -1
@@ -23,7 +23,7 @@static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) { -return state->gpr[state->current_tc][29 ]; +return state->active_tc.gpr[29 ]; }#endif /* TARGET_SIGNAL_H */
Modified: trunk/linux-user/mips64/target_signal.h
===================================================================
linux-user/mips64/target_signal.h +1 -1
@@ -23,7 +23,7 @@static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) { -return state->gpr[state->current_tc][29 ]; +return state->active_tc.gpr[29 ]; }#endif /* TARGET_SIGNAL_H */
Modified: trunk/linux-user/mipsn32/target_signal.h
===================================================================
linux-user/mipsn32/target_signal.h +1 -1
@@ -23,7 +23,7 @@static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) { -return state->gpr[state->current_tc][29 ]; +return state->active_tc.gpr[29 ]; }#endif /* TARGET_SIGNAL_H */
Modified: trunk/linux-user/signal.c
===================================================================
linux-user/signal.c +17 -17
@@ -2290,10 +2290,10 @@ {int err =0 ; - err |=__put_user (regs->PC[regs->current_tc], &sc->sc_pc); + err |=__put_user (regs->active_tc.PC, &sc->sc_pc); -#define save_gp_reg (i) do { \ - err |= __put_user(regs->gpr[regs->current_tc][i], &sc->sc_regs[i]); \ +#define save_gp_reg (i) do { \ + err |= __put_user(regs->active_tc.gpr[i], &sc->sc_regs[i]); \ } while(0)__put_user (0 , &sc->sc_regs[0 ]);save_gp_reg (1 );save_gp_reg (2 );save_gp_reg (3 );save_gp_reg (4 );save_gp_reg (5 );save_gp_reg (6 );
@@ -2306,8 +2306,8 @@save_gp_reg (31 );#undef save_gp_reg - err |=__put_user (regs->HI[regs->current_tc][0 ], &sc->sc_mdhi); - err |=__put_user (regs->LO[regs->current_tc][0 ], &sc->sc_mdlo); + err |=__put_user (regs->active_tc.HI[0 ], &sc->sc_mdhi); + err |=__put_user (regs->active_tc.LO[0 ], &sc->sc_mdlo);/* Not used yet, but might be useful if we ever have DSP suppport */ #if 0
@@ -2367,11 +2367,11 @@ err |=__get_user (regs->CP0_EPC, &sc->sc_pc); - err |=__get_user (regs->HI[regs->current_tc][0 ], &sc->sc_mdhi); - err |=__get_user (regs->LO[regs->current_tc][0 ], &sc->sc_mdlo); + err |=__get_user (regs->active_tc.HI[0 ], &sc->sc_mdhi); + err |=__get_user (regs->active_tc.LO[0 ], &sc->sc_mdlo);#define restore_gp_reg (i) do { \ - err |= __get_user(regs->gpr[regs->current_tc][i], &sc->sc_regs[i]); \ + err |= __get_user(regs->active_tc.gpr[i], &sc->sc_regs[i]); \ } while(0)restore_gp_reg (1 );restore_gp_reg (2 );restore_gp_reg (3 );restore_gp_reg (4 );restore_gp_reg (5 );restore_gp_reg (6 );
@@ -2437,7 +2437,7 @@unsigned long sp;/* Default to using normal stack */ - sp = regs->gpr[regs->current_tc][29 ]; + sp = regs->active_tc.gpr[29 ];/* * FPU emulator may have it's own trampoline active just
@@ -2486,15 +2486,15 @@* $25 and PC point to the signal handler, $29 points to the * struct sigframe. */ - regs->gpr[regs->current_tc][4 ] = sig; - regs->gpr[regs->current_tc][5 ] =0 ; - regs->gpr[regs->current_tc][6 ] = frame_addr + offsetof(struct sigframe , sf_sc); - regs->gpr[regs->current_tc][29 ] = frame_addr; - regs->gpr[regs->current_tc][31 ] = frame_addr + offsetof(struct sigframe , sf_code); + regs->active_tc.gpr[4 ] = sig; + regs->active_tc.gpr[5 ] =0 ; + regs->active_tc.gpr[6 ] = frame_addr + offsetof(struct sigframe , sf_sc); + regs->active_tc.gpr[29 ] = frame_addr; + regs->active_tc.gpr[31 ] = frame_addr + offsetof(struct sigframe , sf_code);/* The original kernel code sets CP0_EPC to the handler * since it returns to userland using eret * we cannot do this here, and we must set PC directly */ - regs->PC[regs->current_tc] = regs->gpr[regs->current_tc][25 ] = ka->_sa_handler; + regs->active_tc.PC = regs->active_tc.gpr[25 ] = ka->_sa_handler;unlock_user_struct (frame, frame_addr,1 );return ;
@@ -2515,7 +2515,7 @@#if defined(DEBUG_SIGNAL )fprintf (stderr,"do_sigreturn\n" );#endif - frame_addr = regs->gpr[regs->current_tc][29 ]; + frame_addr = regs->active_tc.gpr[29 ];if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) goto badframe;
@@ -2542,7 +2542,7 @@/* Unreached */ #endif - regs->PC[regs->current_tc] = regs->CP0_EPC; + regs->active_tc.PC = regs->CP0_EPC;/* I am not sure this is right, but it seems to work * maybe a problem with nested signals ? */ regs->CP0_EPC =0 ;
Modified: trunk/linux-user/syscall.c
===================================================================
linux-user/syscall.c +1 -1
@@ -3686,7 +3686,7 @@if (!is_error (ret)) {#if defined(TARGET_MIPS )CPUMIPSState *env = (CPUMIPSState *)cpu_env; - env->gpr[env->current_tc][3 ] = host_pipe[1 ]; + env->active_tc.gpr[3 ] = host_pipe[1 ]; ret = host_pipe[0 ];#elif defined(TARGET_SH4 ) ((CPUSH4State *)cpu_env)->gregs[1 ] = host_pipe[1 ];
Modified: trunk/monitor.c
===================================================================
monitor.c +1 -1
@@ -316,7 +316,7 @@#elif defined(TARGET_SPARC )term_printf (" pc=0x" TARGET_FMT_lx" npc=0x" TARGET_FMT_lx, env->pc, env->npc);#elif defined(TARGET_MIPS ) -term_printf (" PC=0x" TARGET_FMT_lx, env->PC[env->current_tc]); +term_printf (" PC=0x" TARGET_FMT_lx, env->active_tc.PC);#endif if (env->halted)term_printf (" (halted)" );
Modified: trunk/target-mips/cpu.h
===================================================================
target-mips/cpu.h +40 -37
119 lines not on this page · raw message
Modified: trunk/target-mips/helper.c
===================================================================
target-mips/helper.c +15 -15
@@ -241,7 +241,7 @@cpu_dump_state (env, logfile, fprintf,0 );#endif fprintf (logfile,"%s pc " TARGET_FMT_lx" ad " TARGET_FMT_lx" rw %d mmu_idx %d smmu %d\n" , - __func__, env->PC[env->current_tc], address, rw, mmu_idx, is_softmmu); + __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu); } rw &=1 ;
@@ -370,7 +370,7 @@ name = excp_names[env->exception_index];fprintf (logfile,"%s enter: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" %s exception\n" , - __func__, env->PC[env->current_tc], env->CP0_EPC, name); + __func__, env->active_tc.PC, env->CP0_EPC, name); }if (env->exception_index ==EXCP_EXT_INTERRUPT && (env->hflags &MIPS_HFLAG_DM ))
@@ -384,7 +384,7 @@* (but we assume the pc has always been updated during * code translation). */ - env->CP0_DEPC = env->PC[env->current_tc]; + env->CP0_DEPC = env->active_tc.PC; goto enter_debug_mode;case EXCP_DINT : env->CP0_Debug |=1 <<CP0DB_DINT ;
@@ -404,10 +404,10 @@if (env->hflags &MIPS_HFLAG_BMASK ) {/* If the exception was raised from a delay slot, come back to the jump. */ - env->CP0_DEPC = env->PC[env->current_tc] -4 ; + env->CP0_DEPC = env->active_tc.PC -4 ; env->hflags &= ~MIPS_HFLAG_BMASK ; }else { - env->CP0_DEPC = env->PC[env->current_tc]; + env->CP0_DEPC = env->active_tc.PC; } enter_debug_mode: env->hflags |=MIPS_HFLAG_DM |MIPS_HFLAG_64 |MIPS_HFLAG_CP0 ;
@@ -415,7 +415,7 @@/* EJTAG probe trap enable is not implemented... */ if (!(env->CP0_Status & (1 << CP0St_EXL))) env->CP0_Cause &= ~(1 << CP0Ca_BD); - env->PC[env->current_tc] = (int32_t )0xBFC00480 ; + env->active_tc.PC = (int32_t )0xBFC00480 ;break ;case EXCP_RESET :cpu_reset (env);
@@ -430,17 +430,17 @@if (env->hflags &MIPS_HFLAG_BMASK ) {/* If the exception was raised from a delay slot, come back to the jump. */ - env->CP0_ErrorEPC = env->PC[env->current_tc] -4 ; + env->CP0_ErrorEPC = env->active_tc.PC -4 ; env->hflags &= ~MIPS_HFLAG_BMASK ; }else { - env->CP0_ErrorEPC = env->PC[env->current_tc]; + env->CP0_ErrorEPC = env->active_tc.PC; } env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV); env->hflags |=MIPS_HFLAG_64 |MIPS_HFLAG_CP0 ; env->hflags &= ~(MIPS_HFLAG_KSU );if (!(env->CP0_Status & (1 << CP0St_EXL))) env->CP0_Cause &= ~(1 << CP0Ca_BD); - env->PC[env->current_tc] = (int32_t )0xBFC00000 ; + env->active_tc.PC = (int32_t )0xBFC00000 ;break ;case EXCP_EXT_INTERRUPT : cause =0 ;
@@ -545,10 +545,10 @@if (env->hflags &MIPS_HFLAG_BMASK ) {/* If the exception was raised from a delay slot, come back to the jump. */ - env->CP0_EPC = env->PC[env->current_tc] -4 ; + env->CP0_EPC = env->active_tc.PC -4 ; env->CP0_Cause |= (1 << CP0Ca_BD); }else { - env->CP0_EPC = env->PC[env->current_tc]; + env->CP0_EPC = env->active_tc.PC; env->CP0_Cause &= ~(1 << CP0Ca_BD); } env->CP0_Status |= (1 << CP0St_EXL);
@@ -557,11 +557,11 @@ } env->hflags &= ~MIPS_HFLAG_BMASK ;if (env->CP0_Status & (1 << CP0St_BEV)) { - env->PC[env->current_tc] = (int32_t )0xBFC00200 ; + env->active_tc.PC = (int32_t )0xBFC00200 ; }else { - env->PC[env->current_tc] = (int32_t )(env->CP0_EBase & ~0x3ff ); + env->active_tc.PC = (int32_t )(env->CP0_EBase & ~0x3ff ); } - env->PC[env->current_tc] += offset; + env->active_tc.PC += offset; env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);break ;default :
@@ -575,7 +575,7 @@if (logfile && env->exception_index !=EXCP_EXT_INTERRUPT ) {fprintf (logfile,"%s: PC " TARGET_FMT_lx" EPC " TARGET_FMT_lx" cause %d\n" " S %08x C %08x A " TARGET_FMT_lx" D " TARGET_FMT_lx"\n" , - __func__, env->PC[env->current_tc], env->CP0_EPC, cause, + __func__, env->active_tc.PC, env->CP0_EPC, cause, env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr, env->CP0_DEPC); }
Modified: trunk/target-mips/op_helper.c
===================================================================
target-mips/op_helper.c +188 -80
630 lines not on this page · raw message
Modified: trunk/target-mips/translate.c
===================================================================
target-mips/translate.c +35 -63
205 lines not on this page · raw message
Modified: trunk/target-mips/translate_init.c
===================================================================
target-mips/translate_init.c +0 -2
@@ -546,8 +546,6 @@ env->CP0_TCStatus_rw_bitmask = def->CP0_TCStatus_rw_bitmask; env->CP0_SRSCtl = def->CP0_SRSCtl; env->current_tc =0 ; - env->current_tc_gprs = &env->gpr[env->current_tc][0 ]; - env->current_tc_hi = &env->HI[env->current_tc][0 ]; env->SEGBITS = def->SEGBITS; env->SEGMask = (target_ulong)((1ULL << def->SEGBITS) -1 );#if defined(TARGET_MIPS64 )