X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fnew_dynarec%2Fnew_dynarec.c;h=1fe2c0c4114c8f4ff1077623c022e15376c74cbf;hp=39204ceda1b21eba8ba5bd12c62389b77781028e;hb=2adcd6fad4594a18025b4f00c49e43a23f8f8992;hpb=3e5353548dd510c805424878a1f0de1da7a44a0c diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 39204ced..1fe2c0c4 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -126,6 +126,7 @@ struct ll_entry #else static const u_int using_tlb=0; #endif + static u_int sp_in_mirror; u_int stop_after_jal; extern u_char restore_candidate[512]; extern int cycle_count; @@ -2826,6 +2827,13 @@ void load_assemble(int i,struct regstat *i_regs) if(rs1[i]!=29||start<0x80001000||start>=0x80000000+RAM_SIZE) #endif { + #ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) { + emit_andimm(addr,~0x00e00000,HOST_TEMPREG); + emit_cmpimm(HOST_TEMPREG,RAM_SIZE); + } + else + #endif emit_cmpimm(addr,RAM_SIZE); jaddr=(int)out; #ifdef CORTEX_A8_BRANCH_PREDICTION_HACK @@ -2865,6 +2873,9 @@ void load_assemble(int i,struct regstat *i_regs) else x=((constmap[i][s]+offset)^3)-(constmap[i][s]+offset); #else if(!c) a=addr; +#endif +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; #endif emit_movsbl_indexed_tlb(x,a,map,tl); } @@ -2890,6 +2901,9 @@ void load_assemble(int i,struct regstat *i_regs) else x=((constmap[i][s]+offset)^2)-(constmap[i][s]+offset); #else if(!c) a=addr; +#endif +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; #endif //#ifdef //emit_movswl_indexed_tlb(x,tl,map,tl); @@ -2915,13 +2929,17 @@ void load_assemble(int i,struct regstat *i_regs) if (opcode[i]==0x23) { // LW if(!c||memtarget) { if(!dummy) { + int a=addr; +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; +#endif //emit_readword_indexed((int)rdram-0x80000000,addr,tl); #ifdef HOST_IMM_ADDR32 if(c) emit_readword_tlb(constmap[i][s]+offset,map,tl); else #endif - emit_readword_indexed_tlb(0,addr,map,tl); + emit_readword_indexed_tlb(0,a,map,tl); } if(jaddr) add_stub(LOADW_STUB,jaddr,(int)out,i,addr,(int)i_regs,ccadj[i],reglist); @@ -2947,6 +2965,9 @@ void load_assemble(int i,struct regstat *i_regs) else x=((constmap[i][s]+offset)^3)-(constmap[i][s]+offset); #else if(!c) a=addr; +#endif +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; #endif emit_movzbl_indexed_tlb(x,a,map,tl); } @@ -2972,6 +2993,9 @@ void load_assemble(int i,struct regstat *i_regs) else x=((constmap[i][s]+offset)^2)-(constmap[i][s]+offset); #else if(!c) a=addr; +#endif +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; #endif //#ifdef //emit_movzwl_indexed_tlb(x,tl,map,tl); @@ -2998,13 +3022,17 @@ void load_assemble(int i,struct regstat *i_regs) assert(th>=0); if(!c||memtarget) { if(!dummy) { + int a=addr; +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; +#endif //emit_readword_indexed((int)rdram-0x80000000,addr,tl); #ifdef HOST_IMM_ADDR32 if(c) emit_readword_tlb(constmap[i][s]+offset,map,tl); else #endif - emit_readword_indexed_tlb(0,addr,map,tl); + emit_readword_indexed_tlb(0,a,map,tl); } if(jaddr) add_stub(LOADW_STUB,jaddr,(int)out,i,addr,(int)i_regs,ccadj[i],reglist); @@ -3017,6 +3045,10 @@ void load_assemble(int i,struct regstat *i_regs) if (opcode[i]==0x37) { // LD if(!c||memtarget) { if(!dummy) { + int a=addr; +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; +#endif //gen_tlb_addr_r(tl,map); //if(th>=0) emit_readword_indexed((int)rdram-0x80000000,addr,th); //emit_readword_indexed((int)rdram-0x7FFFFFFC,addr,tl); @@ -3025,7 +3057,7 @@ void load_assemble(int i,struct regstat *i_regs) emit_readdword_tlb(constmap[i][s]+offset,map,th,tl); else #endif - emit_readdword_indexed_tlb(0,addr,map,th,tl); + emit_readdword_indexed_tlb(0,a,map,th,tl); } if(jaddr) add_stub(LOADD_STUB,jaddr,(int)out,i,addr,(int)i_regs,ccadj[i],reglist); @@ -3105,9 +3137,15 @@ void store_assemble(int i,struct regstat *i_regs) else addr=s; if(!using_tlb) { if(!c) { + #ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) { + emit_andimm(addr,~0x00e00000,HOST_TEMPREG); + emit_cmpimm(HOST_TEMPREG,RAM_SIZE); + } + else + #endif #ifdef R29_HACK // Strmnnrmn's speed hack - memtarget=1; if(rs1[i]!=29||start<0x80001000||start>=0x80000000+RAM_SIZE) #endif emit_cmpimm(addr,RAM_SIZE); @@ -3115,6 +3153,7 @@ void store_assemble(int i,struct regstat *i_regs) if(s==addr) emit_mov(s,temp); #endif #ifdef R29_HACK + memtarget=1; if(rs1[i]!=29||start<0x80001000||start>=0x80000000+RAM_SIZE) #endif { @@ -3146,6 +3185,9 @@ void store_assemble(int i,struct regstat *i_regs) else x=((constmap[i][s]+offset)^3)-(constmap[i][s]+offset); #else if(!c) a=addr; +#endif +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; #endif //gen_tlb_addr_w(temp,map); //emit_writebyte_indexed(tl,(int)rdram-0x80000000,temp); @@ -3161,6 +3203,9 @@ void store_assemble(int i,struct regstat *i_regs) else x=((constmap[i][s]+offset)^2)-(constmap[i][s]+offset); #else if(!c) a=addr; +#endif +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; #endif //#ifdef //emit_writehword_indexed_tlb(tl,x,temp,map,temp); @@ -3174,23 +3219,32 @@ void store_assemble(int i,struct regstat *i_regs) type=STOREH_STUB; } if (opcode[i]==0x2B) { // SW - if(!c||memtarget) + if(!c||memtarget) { + int a=addr; +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; +#endif //emit_writeword_indexed(tl,(int)rdram-0x80000000,addr); - emit_writeword_indexed_tlb(tl,0,addr,map,temp); + emit_writeword_indexed_tlb(tl,0,a,map,temp); + } type=STOREW_STUB; } if (opcode[i]==0x3F) { // SD if(!c||memtarget) { + int a=addr; +#ifdef PCSX + if(sp_in_mirror&&rs1[i]==29) a=HOST_TEMPREG; +#endif if(rs2[i]) { assert(th>=0); //emit_writeword_indexed(th,(int)rdram-0x80000000,addr); //emit_writeword_indexed(tl,(int)rdram-0x7FFFFFFC,addr); - emit_writedword_indexed_tlb(th,tl,0,addr,map,temp); + emit_writedword_indexed_tlb(th,tl,0,a,map,temp); }else{ // Store zero //emit_writeword_indexed(tl,(int)rdram-0x80000000,temp); //emit_writeword_indexed(tl,(int)rdram-0x7FFFFFFC,temp); - emit_writedword_indexed_tlb(tl,tl,0,addr,map,temp); + emit_writedword_indexed_tlb(tl,tl,0,a,map,temp); } } type=STORED_STUB; @@ -5111,34 +5165,19 @@ void ujump_assemble(int i,struct regstat *i_regs) if(i_regmap[temp]==PTEMP) emit_movimm((int)hash_table[((return_address>>16)^return_address)&0xFFFF],temp); } #endif - ds_assemble(i+1,i_regs); - uint64_t bc_unneeded=branch_regs[i].u; - uint64_t bc_unneeded_upper=branch_regs[i].uu; - bc_unneeded|=1|(1LL<=0); return_address=start+i*4+8; if(rt>=0) { #ifdef USE_MINI_HT - if(internal_branch(branch_regs[i].is32,return_address)) { - int temp=rt+1; - if(temp==EXCLUDE_REG||temp>=HOST_REGS|| - branch_regs[i].regmap[temp]>=0) - { - temp=get_reg(branch_regs[i].regmap,-1); - } + if(internal_branch(branch_regs[i].is32,return_address)&&rt1[i+1]!=31) { + int temp=-1; // note: must be ds-safe #ifdef HOST_TEMPREG - if(temp<0) temp=HOST_TEMPREG; + temp=HOST_TEMPREG; #endif if(temp>=0) do_miniht_insert(return_address,rt,temp); else emit_movimm(return_address,rt); @@ -5159,6 +5198,14 @@ void ujump_assemble(int i,struct regstat *i_regs) } } } + ds_assemble(i+1,i_regs); + uint64_t bc_unneeded=branch_regs[i].u; + uint64_t bc_unneeded_upper=branch_regs[i].uu; + bc_unneeded|=1|(1LL<0x80200000&& + 0x10000<=psxRegs.GPR.n.sp&&(psxRegs.GPR.n.sp&~0xe0e00000)