From: notaz Date: Sat, 8 Oct 2011 13:57:19 +0000 (+0300) Subject: drc: remove some old inline memhandlers X-Git-Tag: r10~9 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13e35c04a17506ac0848d7fb089fa817b3d697e9;p=pcsx_rearmed.git drc: remove some old inline memhandlers generic code handles it better now. --- diff --git a/Makefile b/Makefile index a0b96c04..fdf3724c 100644 --- a/Makefile +++ b/Makefile @@ -68,8 +68,7 @@ OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_ar OBJS += libpcsxcore/new_dynarec/pcsxmem.o endif OBJS += libpcsxcore/new_dynarec/emu_if.o -libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \ - libpcsxcore/new_dynarec/pcsxmem_inline.c +libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign ifdef DRC_DBG libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64 diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index e29f6c3f..57c6e917 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -2677,9 +2677,18 @@ emit_extjump_ds(int addr, int target) emit_extjump2(addr, target, (int)dyna_linker_ds); } -#ifdef PCSX -#include "pcsxmem_inline.c" -#endif +// put rt_val into rt, potentially making use of rs with value rs_val +static void emit_movimm_from(u_int rs_val,int rs,u_int rt_val,int rt) +{ + u_int xor=rs_val^rt_val; + u_int xs; + for(xs=xor;xs!=0&&(xs&3)==0;xs>>=2) + ; + if(xs<0x100) + emit_xorimm(rs,xor,rt); + else + emit_movimm(rt_val,rt); +} // trashes r2 static void pass_args(int a0, int a1) @@ -2906,14 +2915,12 @@ inline_readstub(int type, int i, u_int addr, signed char regmap[], int target, i assert(rs>=0); #ifdef PCSX u_int handler,host_addr=0; - if(pcsx_direct_read(type,addr,target?rs:-1,rt)) - return; handler=get_direct_memhandler(mem_rtab,addr,type,&host_addr); if (handler==0) { if(rt<0) return; - if(target==0||addr!=host_addr) - emit_movimm(host_addr,rs); + if(addr!=host_addr) + emit_movimm_from(addr,rs,host_addr,rs); switch(type) { case LOADB_STUB: emit_movsbl_indexed(0,rs,rt); break; case LOADBU_STUB: emit_movzbl_indexed(0,rs,rt); break; @@ -3211,12 +3218,10 @@ inline_writestub(int type, int i, u_int addr, signed char regmap[], int target, assert(rt>=0); #ifdef PCSX u_int handler,host_addr=0; - if(pcsx_direct_write(type,addr,rs,rt,regmap)) - return; handler=get_direct_memhandler(mem_wtab,addr,type,&host_addr); if (handler==0) { - if(target==0||addr!=host_addr) - emit_movimm(host_addr,rs); + if(addr!=host_addr) + emit_movimm_from(addr,rs,host_addr,rs); switch(type) { case STOREB_STUB: emit_writebyte_indexed(rt,0,rs); break; case STOREH_STUB: emit_writehword_indexed(rt,0,rs); break; @@ -3228,9 +3233,7 @@ inline_writestub(int type, int i, u_int addr, signed char regmap[], int target, // call a memhandler save_regs(reglist); - pass_args(target!=0?rs:-1,rt); - if(target==0) - emit_movimm(addr,0); + pass_args(rs,rt); int cc=get_reg(regmap,CCREG); if(cc<0) emit_loadreg(CCREG,2); diff --git a/libpcsxcore/new_dynarec/pcsxmem_inline.c b/libpcsxcore/new_dynarec/pcsxmem_inline.c deleted file mode 100644 index 30338eb8..00000000 --- a/libpcsxcore/new_dynarec/pcsxmem_inline.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * (C) Gražvydas "notaz" Ignotas, 2011 - * - * This work is licensed under the terms of GNU GPL version 2 or later. - * See the COPYING file in the top-level directory. - */ - -static int emit_ldr_type(int type, int offs, int rs, int rt) -{ - switch(type) { - case LOADB_STUB: - emit_movsbl_indexed(offs,rs,rt); - break; - case LOADBU_STUB: - emit_movzbl_indexed(offs,rs,rt); - break; - case LOADH_STUB: - emit_movswl_indexed(offs,rs,rt); - break; - case LOADHU_STUB: - emit_movzwl_indexed(offs,rs,rt); - break; - case LOADW_STUB: - emit_readword_indexed(offs,rs,rt); - break; - default: - assert(0); - } -} - -static int emit_str_type(int type, int offs, int rs, int rt) -{ - switch(type) { - case STOREB_STUB: - emit_writebyte_indexed(rt,offs,rs); - break; - case STOREH_STUB: - emit_writehword_indexed(rt,offs,rs); - break; - case STOREW_STUB: - emit_writeword_indexed(rt,offs,rs); - break; - default: - assert(0); - } -} - -static void convert_ram_addr(u_int a_rs, u_int a_rt, int rs, int rt) -{ - if(rs<0) - emit_movimm(a_rt,rt); - else if((a_rs&~0x60000000)==a_rt) - emit_andimm(rs,~0x60000000,rt); - else if((a_rs&~0x00600000)==a_rt) - emit_andimm(rs,~0x00600000,rt); - else - emit_movimm(a_rt,rt); -} - -static int pcsx_direct_read(int type, u_int addr, int rs, int rt) -{ - if((addr & 0x1f800000) == 0) { - assem_debug("pcsx_direct_read %08x ram\n",addr); - if(rt<0) - return 1; - u_int a=(addr&~0x60600000)|0x80000000; - convert_ram_addr(addr,a,rs,rt); - emit_ldr_type(type,0,rt,rt); - return 1; - } - if((addr & 0x1ff80000) == 0x1fc00000) { - assem_debug("pcsx_direct_read %08x bios\n",addr); - if(rt<0) - return 1; - emit_movimm((u_int)&psxR[addr&0x7ffff],rt); - emit_ldr_type(type,0,rt,rt); - return 1; - } - if((addr & 0xfffff000) == 0x1f800000) { - assem_debug("pcsx_direct_read %08x scratchpad\n",addr); - if(rt<0) - return 1; - if(type==LOADW_STUB||type==LOADBU_STUB||(addr&0xf00)==0) { - emit_readword((int)&psxH_ptr,rt); - emit_ldr_type(type,addr&0xfff,rt,rt); - } else { - emit_movimm((u_int)&psxH[addr&0xfff],rt); - emit_ldr_type(type,0,rt,rt); - } - return 1; - } - - assem_debug("pcsx_direct_read %08x miss\n",addr); - return 0; -} - -static int pcsx_direct_write(int type, u_int addr, int rs, int rt, signed char *regmap) -{ - if((addr & 0x1f800000) == 0) { - assem_debug("pcsx_direct_write %08x ram\n",addr); - u_int a=(addr&~0x60600000)|0x80000000; - convert_ram_addr(addr,a,rs,HOST_TEMPREG); - emit_str_type(type,0,HOST_TEMPREG,rt); - - int ir=get_reg(regmap,INVCP); - assert(ir>=0); - emit_cmpmem_indexedsr12_reg(ir,HOST_TEMPREG,1); - emit_callne(invalidate_addr_reg[rs]); - return 1; - } - if((addr & 0xfffff000) == 0x1f800000) { - assem_debug("pcsx_direct_write %08x scratchpad\n",addr); - if(type==STOREW_STUB||type==STOREB_STUB||(addr&0xf00)==0) { - emit_readword((int)&psxH_ptr,HOST_TEMPREG); - emit_str_type(type,addr&0xfff,HOST_TEMPREG,rt); - } else { - emit_movimm((u_int)&psxH[addr&0xfff],HOST_TEMPREG); - emit_str_type(type,0,HOST_TEMPREG,rt); - } - return 1; - } - - assem_debug("pcsx_direct_write %08x miss\n",addr); - return 0; -} - -// vim:shiftwidth=2:expandtab