From: notaz Date: Mon, 1 Nov 2021 19:57:53 +0000 (+0200) Subject: drc: rework for 64bit, part 3 X-Git-Tag: r23~96 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=643aeae3222be00a799ca1e96e795ff846f81fee;p=pcsx_rearmed.git drc: rework for 64bit, part 3 --- diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index 940391ce..36a3e45a 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -30,9 +30,9 @@ #if defined(BASE_ADDR_FIXED) #elif defined(BASE_ADDR_DYNAMIC) -char *translation_cache; +u_char *translation_cache; #else -char translation_cache[1 << TARGET_SIZE_2] __attribute__((aligned(4096))); +u_char translation_cache[1 << TARGET_SIZE_2] __attribute__((aligned(4096))); #endif #ifndef __MACH__ @@ -219,12 +219,12 @@ static void *find_extjump_insn(void *stub) // get address that insn one after stub loads (dyna_linker arg1), // treat it as a pointer to branch insn, // return addr where that branch jumps to -static int get_pointer(void *stub) +static void *get_pointer(void *stub) { //printf("get_pointer(%x)\n",(int)stub); int *i_ptr=find_extjump_insn(stub); assert((*i_ptr&0x0f000000)==0x0a000000); - return (int)i_ptr+((*i_ptr<<8)>>6)+8; + return (u_char *)i_ptr+((*i_ptr<<8)>>6)+8; } // Find the "clean" entry point from a "dirty" entry point @@ -296,9 +296,9 @@ static int isclean(void *addr) } // get source that block at addr was compiled from (host pointers) -static void get_bounds(int addr,u_int *start,u_int *end) +static void get_bounds(void *addr,u_int *start,u_int *end) { - u_int *ptr=(u_int *)addr; + u_int *ptr = addr; #ifndef HAVE_ARMV7 u_int offset; // get from literal pool @@ -1700,8 +1700,9 @@ static const char *func_name(intptr_t a) #define func_name(x) "" #endif -static void emit_call(int a) +static void emit_call(const void *a_) { + int a = (int)a_; assem_debug("bl %x (%x+%x)%s\n",a,(int)out,a-(int)out-8,func_name(a)); u_int offset=genjmp(a); output_w32(0xeb000000|offset); @@ -1715,8 +1716,9 @@ static void emit_jmp(const void *a_) output_w32(0xea000000|offset); } -static void emit_jne(int a) +static void emit_jne(const void *a_) { + int a = (int)a_; assem_debug("bne %x\n",a); u_int offset=genjmp(a); output_w32(0x1a000000|offset); @@ -1913,6 +1915,7 @@ static void emit_movzbl_indexed(int offset, int rs, int rt) static void emit_movzbl_dualindexedx4(int rs1, int rs2, int rt) { + assert(rs2>=0); assem_debug("ldrb %s,%s,%s lsl #2\n",regname[rt],regname[rs1],regname[rs2]); output_w32(0xe7d00000|rd_rn_rm(rt,rs1,rs2)|0x100); } @@ -1952,9 +1955,9 @@ static void emit_ldrd(int offset, int rs, int rt) } } -static void emit_readword(int addr, int rt) +static void emit_readword(void *addr, int rt) { - u_int offset = addr-(u_int)&dynarec_local; + uintptr_t offset = (u_char *)addr - (u_char *)&dynarec_local; assert(offset<4096); assem_debug("ldr %s,fp+%d\n",regname[rt],offset); output_w32(0xe5900000|rd_rn_rm(rt,FP,0)|offset); @@ -2059,6 +2062,7 @@ static void emit_writebyte_indexed(int rt, int offset, int rs) static void emit_writebyte_dualindexedx4(int rt, int rs1, int rs2) { + assert(rs2>=0); assem_debug("strb %s,%s,%s lsl #2\n",regname[rt],regname[rs1],regname[rs2]); output_w32(0xe7c00000|rd_rn_rm(rt,rs1,rs2)|0x100); } @@ -2094,25 +2098,25 @@ static void emit_strcch_dualindexed(int rs1, int rs2, int rt) output_w32(0x318000b0|rd_rn_rm(rt,rs1,rs2)); } -static void emit_writeword(int rt, int addr) +static void emit_writeword(int rt, void *addr) { - u_int offset = addr-(u_int)&dynarec_local; + uintptr_t offset = (u_char *)addr - (u_char *)&dynarec_local; assert(offset<4096); assem_debug("str %s,fp+%d\n",regname[rt],offset); output_w32(0xe5800000|rd_rn_rm(rt,FP,0)|offset); } -static unused void emit_writehword(int rt, int addr) +static unused void emit_writehword(int rt, void *addr) { - u_int offset = addr-(u_int)&dynarec_local; + uintptr_t offset = (u_char *)addr - (u_char *)&dynarec_local; assert(offset<256); assem_debug("strh %s,fp+%d\n",regname[rt],offset); output_w32(0xe1c000b0|rd_rn_rm(rt,FP,0)|((offset<<4)&0xf00)|(offset&0xf)); } -static unused void emit_writebyte(int rt, int addr) +static unused void emit_writebyte(int rt, void *addr) { - u_int offset = addr-(u_int)&dynarec_local; + uintptr_t offset = (u_char *)addr - (u_char *)&dynarec_local; assert(offset<4096); assem_debug("strb %s,fp+%d\n",regname[rt],offset); output_w32(0xe5c00000|rd_rn_rm(rt,FP,0)|offset); @@ -2477,35 +2481,35 @@ static void literal_pool_jumpover(int n) set_jump_target(jaddr, out); } -static void emit_extjump2(u_int addr, int target, void *linker) +static void emit_extjump2(u_char *addr, int target, void *linker) { u_char *ptr=(u_char *)addr; assert((ptr[3]&0x0e)==0xa); (void)ptr; emit_loadlp(target,0); - emit_loadlp(addr,1); - assert(addr>=BASE_ADDR&&addr<(BASE_ADDR+(1<=translation_cache&&addr<(translation_cache+(1<=0x80000000&&target<0x80800000)||(target>0xA4000000&&target<0xA4001000)); //DEBUG > #ifdef DEBUG_CYCLE_COUNT - emit_readword((int)&last_count,ECX); + emit_readword(&last_count,ECX); emit_add(HOST_CCREG,ECX,HOST_CCREG); - emit_readword((int)&next_interupt,ECX); - emit_writeword(HOST_CCREG,(int)&Count); + emit_readword(&next_interupt,ECX); + emit_writeword(HOST_CCREG,&Count); emit_sub(HOST_CCREG,ECX,HOST_CCREG); - emit_writeword(ECX,(int)&last_count); + emit_writeword(ECX,&last_count); #endif //DEBUG < emit_jmp(linker); } -static void emit_extjump(int addr, int target) +static void emit_extjump(void *addr, int target) { emit_extjump2(addr, target, dyna_linker); } -static void emit_extjump_ds(int addr, int target) +static void emit_extjump_ds(void *addr, int target) { emit_extjump2(addr, target, dyna_linker_ds); } @@ -2621,7 +2625,7 @@ static void do_readstub(int n) } if((regs_saved||(reglist&2)==0)&&temp!=1&&rs!=1) temp2=1; - emit_readword((int)&mem_rtab,temp); + emit_readword(&mem_rtab,temp); emit_shrimm(rs,12,temp2); emit_readword_dualindexedx4(temp,temp2,temp2); emit_lsls_imm(temp2,1,temp2); @@ -2644,14 +2648,14 @@ static void do_readstub(int n) if(!regs_saved) save_regs(reglist); - int handler=0; + void *handler=NULL; if(type==LOADB_STUB||type==LOADBU_STUB) - handler=(int)jump_handler_read8; + handler=jump_handler_read8; if(type==LOADH_STUB||type==LOADHU_STUB) - handler=(int)jump_handler_read16; + handler=jump_handler_read16; if(type==LOADW_STUB) - handler=(int)jump_handler_read32; - assert(handler!=0); + handler=jump_handler_read32; + assert(handler); pass_args(rs,temp2); int cc=get_reg(i_regmap,CCREG); if(cc<0) @@ -2668,14 +2672,14 @@ static void do_readstub(int n) } // return memhandler, or get directly accessable address and return 0 -static u_int get_direct_memhandler(void *table,u_int addr,enum stub_type type,u_int *addr_host) +static void *get_direct_memhandler(void *table,u_int addr,enum stub_type type,u_int *addr_host) { u_int l1,l2=0; l1=((u_int *)table)[addr>>12]; if((l1&(1<<31))==0) { u_int v=l1<<1; *addr_host=v+addr; - return 0; + return NULL; } else { l1<<=1; @@ -2688,9 +2692,9 @@ static u_int get_direct_memhandler(void *table,u_int addr,enum stub_type type,u_ if((l2&(1<<31))==0) { u_int v=l2<<1; *addr_host=v+(addr&0xfff); - return 0; + return NULL; } - return l2<<1; + return (void *)(l2<<1); } } @@ -2700,12 +2704,13 @@ static void inline_readstub(enum stub_type type, int i, u_int addr, signed char int rt=get_reg(regmap,target); if(rs<0) rs=get_reg(regmap,-1); assert(rs>=0); - u_int handler,host_addr=0,is_dynamic,far_call=0; + u_int host_addr=0,is_dynamic,far_call=0; + void *handler; int cc=get_reg(regmap,CCREG); if(pcsx_direct_read(type,addr,CLOCK_ADJUST(adj+1),cc,target?rs:-1,rt)) return; - handler=get_direct_memhandler(mem_rtab,addr,type,&host_addr); - if (handler==0) { + handler = get_direct_memhandler(mem_rtab, addr, type, &host_addr); + if (handler == NULL) { if(rt<0||rt1[i]==0) return; if(addr!=host_addr) @@ -2723,11 +2728,11 @@ static void inline_readstub(enum stub_type type, int i, u_int addr, signed char is_dynamic=pcsxmem_is_handler_dynamic(addr); if(is_dynamic) { if(type==LOADB_STUB||type==LOADBU_STUB) - handler=(int)jump_handler_read8; + handler=jump_handler_read8; if(type==LOADH_STUB||type==LOADHU_STUB) - handler=(int)jump_handler_read16; + handler=jump_handler_read16; if(type==LOADW_STUB) - handler=(int)jump_handler_read32; + handler=jump_handler_read32; } // call a memhandler @@ -2738,10 +2743,10 @@ static void inline_readstub(enum stub_type type, int i, u_int addr, signed char emit_movimm(addr,0); else if(rs!=0) emit_mov(rs,0); - int offset=(int)handler-(int)out-8; + int offset=(u_char *)handler-out-8; if(offset<-33554432||offset>=33554432) { // unreachable memhandler, a plugin func perhaps - emit_movimm(handler,12); + emit_movimm((u_int)handler,12); far_call=1; } if(cc<0) @@ -2751,10 +2756,10 @@ static void inline_readstub(enum stub_type type, int i, u_int addr, signed char emit_addimm(cc<0?2:cc,CLOCK_ADJUST(adj+1),2); } else { - emit_readword((int)&last_count,3); + emit_readword(&last_count,3); emit_addimm(cc<0?2:cc,CLOCK_ADJUST(adj+1),2); emit_add(2,3,2); - emit_writeword(2,(int)&Count); + emit_writeword(2,&Count); } if(far_call) @@ -2811,7 +2816,7 @@ static void do_writestub(int n) } if((regs_saved||(reglist2&8)==0)&&temp!=3&&rs!=3&&rt!=3) temp2=3; - emit_readword((int)&mem_wtab,temp); + emit_readword(&mem_wtab,temp); emit_shrimm(rs,12,temp2); emit_readword_dualindexedx4(temp,temp2,temp2); emit_lsls_imm(temp2,1,temp2); @@ -2830,14 +2835,14 @@ static void do_writestub(int n) if(!regs_saved) save_regs(reglist); - int handler=0; + void *handler=NULL; switch(type) { - case STOREB_STUB: handler=(int)jump_handler_write8; break; - case STOREH_STUB: handler=(int)jump_handler_write16; break; - case STOREW_STUB: handler=(int)jump_handler_write32; break; + case STOREB_STUB: handler=jump_handler_write8; break; + case STOREH_STUB: handler=jump_handler_write16; break; + case STOREW_STUB: handler=jump_handler_write32; break; default: assert(0); } - assert(handler!=0); + assert(handler); pass_args(rs,rt); if(temp2!=3) emit_mov(temp2,3); @@ -2862,9 +2867,9 @@ static void inline_writestub(enum stub_type type, int i, u_int addr, signed char int rt=get_reg(regmap,target); assert(rs>=0); assert(rt>=0); - u_int handler,host_addr=0; - handler=get_direct_memhandler(mem_wtab,addr,type,&host_addr); - if (handler==0) { + u_int host_addr=0; + void *handler = get_direct_memhandler(mem_wtab, addr, type, &host_addr); + if (handler == NULL) { if(addr!=host_addr) emit_movimm_from(addr,rs,host_addr,rs); switch(type) { @@ -2883,9 +2888,9 @@ static void inline_writestub(enum stub_type type, int i, u_int addr, signed char if(cc<0) emit_loadreg(CCREG,2); emit_addimm(cc<0?2:cc,CLOCK_ADJUST(adj+1),2); - emit_movimm(handler,3); + emit_movimm((u_int)handler,3); // returns new cycle_count - emit_call((int)jump_handler_write_h); + emit_call(jump_handler_write_h); emit_addimm(0,-CLOCK_ADJUST(adj+1),cc<0?2:cc); if(cc<0) emit_storereg(CCREG,2); @@ -2920,7 +2925,7 @@ static void do_unalignedwritestub(int n) if(cc<0) emit_loadreg(CCREG,2); emit_addimm(cc<0?2:cc,CLOCK_ADJUST((int)stubs[n].d+1),2); - emit_call((int)(opcode[i]==0x2a?jump_handle_swl:jump_handle_swr)); + emit_call((opcode[i]==0x2a?jump_handle_swl:jump_handle_swr)); emit_addimm(0,-CLOCK_ADJUST((int)stubs[n].d+1),cc<0?2:cc); if(cc<0) emit_storereg(CCREG,2); @@ -2928,7 +2933,7 @@ static void do_unalignedwritestub(int n) emit_jmp(stubs[n].retaddr); // return address #else emit_andimm(addr,0xfffffffc,temp2); - emit_writeword(temp2,(int)&address); + emit_writeword(temp2,&address); save_regs(reglist); emit_shrimm(addr,16,1); @@ -2941,7 +2946,7 @@ static void do_unalignedwritestub(int n) emit_call((int)&indirect_jump_indexed); restore_regs(reglist); - emit_readword((int)&readmem_dword,temp2); + emit_readword(&readmem_dword,temp2); int temp=addr; //hmh emit_shlimm(addr,3,temp); emit_andimm(temp,24,temp); @@ -2959,18 +2964,18 @@ static void do_unalignedwritestub(int n) emit_bic_lsl(temp2,HOST_TEMPREG,temp,temp2); emit_orrshl(rt,temp,temp2); } - emit_readword((int)&address,addr); - emit_writeword(temp2,(int)&word); + emit_readword(&address,addr); + emit_writeword(temp2,&word); //save_regs(reglist); // don't need to, no state changes emit_shrimm(addr,16,1); emit_movimm((u_int)writemem,0); //emit_call((int)&indirect_jump_indexed); emit_mov(15,14); emit_readword_dualindexedx4(0,1,15); - emit_readword((int)&Count,HOST_TEMPREG); - emit_readword((int)&next_interupt,2); + emit_readword(&Count,HOST_TEMPREG); + emit_readword(&next_interupt,2); emit_addimm(HOST_TEMPREG,-2*stubs[n].d-2,HOST_TEMPREG); - emit_writeword(2,(int)&last_count); + emit_writeword(2,&last_count); emit_sub(HOST_TEMPREG,2,cc<0?HOST_TEMPREG:cc); if(cc<0) { emit_storereg(CCREG,HOST_TEMPREG); @@ -2987,7 +2992,7 @@ static void do_invstub(int n) set_jump_target(stubs[n].addr, out); save_regs(reglist); if(stubs[n].b!=0) emit_mov(stubs[n].b,0); - emit_call((int)&invalidate_addr); + emit_call(&invalidate_addr); restore_regs(reglist); emit_jmp(stubs[n].retaddr); // return address } @@ -3009,7 +3014,7 @@ void *do_dirty_stub(int i) emit_movw(slen*4,3); #endif emit_movimm(start+i*4,0); - emit_call((int)start<(int)0xC0000000?(int)&verify_code:(int)&verify_code_vm); + emit_call((int)start<(int)0xC0000000?&verify_code:&verify_code_vm); void *entry = out; load_regs_entry(i); if (entry == out) @@ -3033,7 +3038,7 @@ static void do_dirty_stub_ds() emit_movw(slen*4,3); #endif emit_movimm(start+1,0); - emit_call((int)&verify_code_ds); + emit_call(&verify_code_ds); } static void do_cop1stub(int n) @@ -3486,10 +3491,10 @@ static void cop0_assemble(int i,struct regstat *i_regs) if(opcode2[i]==0) // MFC0 { signed char t=get_reg(i_regs->regmap,rt1[i]); - char copr=(source[i]>>11)&0x1f; + u_int copr=(source[i]>>11)&0x1f; //assert(t>=0); // Why does this happen? OOT is weird if(t>=0&&rt1[i]!=0) { - emit_readword((int)®_cop0+copr*4,t); + emit_readword(®_cop0[copr],t); } } else if(opcode2[i]==4) // MTC0 @@ -3499,11 +3504,11 @@ static void cop0_assemble(int i,struct regstat *i_regs) assert(s>=0); wb_register(rs1[i],i_regs->regmap,i_regs->dirty,i_regs->is32); if(copr==9||copr==11||copr==12||copr==13) { - emit_readword((int)&last_count,HOST_TEMPREG); + emit_readword(&last_count,HOST_TEMPREG); emit_loadreg(CCREG,HOST_CCREG); // TODO: do proper reg alloc emit_add(HOST_CCREG,HOST_TEMPREG,HOST_CCREG); emit_addimm(HOST_CCREG,CLOCK_ADJUST(ccadj[i]),HOST_CCREG); - emit_writeword(HOST_CCREG,(int)&Count); + emit_writeword(HOST_CCREG,&Count); } // What a mess. The status register (12) can enable interrupts, // so needs a special case to handle a pending interrupt. @@ -3514,19 +3519,19 @@ static void cop0_assemble(int i,struct regstat *i_regs) // burn cycles to cause cc_interrupt, which will // reschedule next_interupt. Relies on CCREG from above. assem_debug("MTC0 DS %d\n", copr); - emit_writeword(HOST_CCREG,(int)&last_count); + emit_writeword(HOST_CCREG,&last_count); emit_movimm(0,HOST_CCREG); emit_storereg(CCREG,HOST_CCREG); emit_loadreg(rs1[i],1); emit_movimm(copr,0); - emit_call((int)pcsx_mtc0_ds); + emit_call(pcsx_mtc0_ds); emit_loadreg(rs1[i],s); return; } emit_movimm(start+i*4+4,HOST_TEMPREG); - emit_writeword(HOST_TEMPREG,(int)&pcaddr); + emit_writeword(HOST_TEMPREG,&pcaddr); emit_movimm(0,HOST_TEMPREG); - emit_writeword(HOST_TEMPREG,(int)&pending_exception); + emit_writeword(HOST_TEMPREG,&pending_exception); } //else if(copr==12&&is_delayslot) emit_call((int)MTC0_R12); //else @@ -3535,20 +3540,20 @@ static void cop0_assemble(int i,struct regstat *i_regs) else if(s!=1) emit_mov(s,1); emit_movimm(copr,0); - emit_call((int)pcsx_mtc0); + emit_call(pcsx_mtc0); if(copr==9||copr==11||copr==12||copr==13) { - emit_readword((int)&Count,HOST_CCREG); - emit_readword((int)&next_interupt,HOST_TEMPREG); + emit_readword(&Count,HOST_CCREG); + emit_readword(&next_interupt,HOST_TEMPREG); emit_addimm(HOST_CCREG,-CLOCK_ADJUST(ccadj[i]),HOST_CCREG); emit_sub(HOST_CCREG,HOST_TEMPREG,HOST_CCREG); - emit_writeword(HOST_TEMPREG,(int)&last_count); + emit_writeword(HOST_TEMPREG,&last_count); emit_storereg(CCREG,HOST_CCREG); } if(copr==12||copr==13) { assert(!is_delayslot); - emit_readword((int)&pending_exception,14); + emit_readword(&pending_exception,14); emit_test(14,14); - emit_jne((int)&do_interrupt); + emit_jne(&do_interrupt); } emit_loadreg(rs1[i],s); if(get_reg(i_regs->regmap,rs1[i]|64)>=0) @@ -3560,11 +3565,11 @@ static void cop0_assemble(int i,struct regstat *i_regs) assert(opcode2[i]==0x10); if((source[i]&0x3f)==0x10) // RFE { - emit_readword((int)&Status,0); + emit_readword(&Status,0); emit_andimm(0,0x3c,1); emit_andimm(0,~0xf,0); emit_orrshr_imm(1,2,0); - emit_writeword(0,(int)&Status); + emit_writeword(0,&Status); } } } @@ -3579,44 +3584,44 @@ static void cop2_get_dreg(u_int copr,signed char tl,signed char temp) case 9: case 10: case 11: - emit_readword((int)®_cop2d[copr],tl); + emit_readword(®_cop2d[copr],tl); emit_signextend16(tl,tl); - emit_writeword(tl,(int)®_cop2d[copr]); // hmh + emit_writeword(tl,®_cop2d[copr]); // hmh break; case 7: case 16: case 17: case 18: case 19: - emit_readword((int)®_cop2d[copr],tl); + emit_readword(®_cop2d[copr],tl); emit_andimm(tl,0xffff,tl); - emit_writeword(tl,(int)®_cop2d[copr]); + emit_writeword(tl,®_cop2d[copr]); break; case 15: - emit_readword((int)®_cop2d[14],tl); // SXY2 - emit_writeword(tl,(int)®_cop2d[copr]); + emit_readword(®_cop2d[14],tl); // SXY2 + emit_writeword(tl,®_cop2d[copr]); break; case 28: case 29: - emit_readword((int)®_cop2d[9],temp); + emit_readword(®_cop2d[9],temp); emit_testimm(temp,0x8000); // do we need this? emit_andimm(temp,0xf80,temp); emit_andne_imm(temp,0,temp); emit_shrimm(temp,7,tl); - emit_readword((int)®_cop2d[10],temp); + emit_readword(®_cop2d[10],temp); emit_testimm(temp,0x8000); emit_andimm(temp,0xf80,temp); emit_andne_imm(temp,0,temp); emit_orrshr_imm(temp,2,tl); - emit_readword((int)®_cop2d[11],temp); + emit_readword(®_cop2d[11],temp); emit_testimm(temp,0x8000); emit_andimm(temp,0xf80,temp); emit_andne_imm(temp,0,temp); emit_orrshl_imm(temp,3,tl); - emit_writeword(tl,(int)®_cop2d[copr]); + emit_writeword(tl,®_cop2d[copr]); break; default: - emit_readword((int)®_cop2d[copr],tl); + emit_readword(®_cop2d[copr],tl); break; } } @@ -3625,24 +3630,24 @@ static void cop2_put_dreg(u_int copr,signed char sl,signed char temp) { switch (copr) { case 15: - emit_readword((int)®_cop2d[13],temp); // SXY1 - emit_writeword(sl,(int)®_cop2d[copr]); - emit_writeword(temp,(int)®_cop2d[12]); // SXY0 - emit_readword((int)®_cop2d[14],temp); // SXY2 - emit_writeword(sl,(int)®_cop2d[14]); - emit_writeword(temp,(int)®_cop2d[13]); // SXY1 + emit_readword(®_cop2d[13],temp); // SXY1 + emit_writeword(sl,®_cop2d[copr]); + emit_writeword(temp,®_cop2d[12]); // SXY0 + emit_readword(®_cop2d[14],temp); // SXY2 + emit_writeword(sl,®_cop2d[14]); + emit_writeword(temp,®_cop2d[13]); // SXY1 break; case 28: emit_andimm(sl,0x001f,temp); emit_shlimm(temp,7,temp); - emit_writeword(temp,(int)®_cop2d[9]); + emit_writeword(temp,®_cop2d[9]); emit_andimm(sl,0x03e0,temp); emit_shlimm(temp,2,temp); - emit_writeword(temp,(int)®_cop2d[10]); + emit_writeword(temp,®_cop2d[10]); emit_andimm(sl,0x7c00,temp); emit_shrimm(temp,3,temp); - emit_writeword(temp,(int)®_cop2d[11]); - emit_writeword(sl,(int)®_cop2d[28]); + emit_writeword(temp,®_cop2d[11]); + emit_writeword(sl,®_cop2d[28]); break; case 30: emit_movs(sl,temp); @@ -3657,13 +3662,13 @@ static void cop2_put_dreg(u_int copr,signed char sl,signed char temp) emit_lslpls_imm(HOST_TEMPREG,1,HOST_TEMPREG); emit_jns((int)out-2*4); #endif - emit_writeword(sl,(int)®_cop2d[30]); - emit_writeword(temp,(int)®_cop2d[31]); + emit_writeword(sl,®_cop2d[30]); + emit_writeword(temp,®_cop2d[31]); break; case 31: break; default: - emit_writeword(sl,(int)®_cop2d[copr]); + emit_writeword(sl,®_cop2d[copr]); break; } } @@ -3685,7 +3690,7 @@ static void cop2_assemble(int i,struct regstat *i_regs) { signed char tl=get_reg(i_regs->regmap,rt1[i]); if(tl>=0&&rt1[i]!=0) - emit_readword((int)®_cop2c[copr],tl); + emit_readword(®_cop2c[copr],tl); } else if (opcode2[i]==6) // CTC2 { @@ -3714,7 +3719,7 @@ static void cop2_assemble(int i,struct regstat *i_regs) temp=sl; break; } - emit_writeword(temp,(int)®_cop2c[copr]); + emit_writeword(temp,®_cop2c[copr]); assert(sl>=0); } } @@ -3741,19 +3746,19 @@ static void c2op_epilogue(u_int op,u_int reglist) static void c2op_call_MACtoIR(int lm,int need_flags) { if(need_flags) - emit_call((int)(lm?gteMACtoIR_lm1:gteMACtoIR_lm0)); + emit_call(lm?gteMACtoIR_lm1:gteMACtoIR_lm0); else - emit_call((int)(lm?gteMACtoIR_lm1_nf:gteMACtoIR_lm0_nf)); + emit_call(lm?gteMACtoIR_lm1_nf:gteMACtoIR_lm0_nf); } static void c2op_call_rgb_func(void *func,int lm,int need_ir,int need_flags) { - emit_call((int)func); + emit_call(func); // func is C code and trashes r0 emit_addimm(FP,(int)&psxRegs.CP2D.r[0]-(int)&dynarec_local,0); if(need_flags||need_ir) c2op_call_MACtoIR(lm,need_flags); - emit_call((int)(need_flags?gteMACtoRGB:gteMACtoRGB_nf)); + emit_call(need_flags?gteMACtoRGB:gteMACtoRGB_nf); } static void c2op_assemble(int i,struct regstat *i_regs) @@ -3796,17 +3801,17 @@ static void c2op_assemble(int i,struct regstat *i_regs) if(mx<3) emit_addimm(0,32*4+mx*8*4,6); else - emit_readword((int)&zeromem_ptr,6); + emit_readword(&zeromem_ptr,6); if(cv<3) emit_addimm(0,32*4+(cv*8+5)*4,7); else - emit_readword((int)&zeromem_ptr,7); + emit_readword(&zeromem_ptr,7); #ifdef __ARM_NEON__ emit_movimm(source[i],1); // opcode - emit_call((int)gteMVMVA_part_neon); + emit_call(gteMVMVA_part_neon); if(need_flags) { emit_movimm(lm,1); - emit_call((int)gteMACtoIR_flags_neon); + emit_call(gteMACtoIR_flags_neon); } #else if(cv==3&&shift) @@ -3821,14 +3826,14 @@ static void c2op_assemble(int i,struct regstat *i_regs) #else /* if not HAVE_ARMV5 */ c2op_prologue(c2op,reglist); emit_movimm(source[i],1); // opcode - emit_writeword(1,(int)&psxRegs.code); + emit_writeword(1,&psxRegs.code); emit_call((int)(need_flags?gte_handlers[c2op]:gte_handlers_nf[c2op])); #endif break; } case GTE_OP: c2op_prologue(c2op,reglist); - emit_call((int)(shift?gteOP_part_shift:gteOP_part_noshift)); + emit_call(shift?gteOP_part_shift:gteOP_part_noshift); if(need_flags||need_ir) { emit_addimm(FP,(int)&psxRegs.CP2D.r[0]-(int)&dynarec_local,0); c2op_call_MACtoIR(lm,need_flags); @@ -3844,7 +3849,7 @@ static void c2op_assemble(int i,struct regstat *i_regs) break; case GTE_SQR: c2op_prologue(c2op,reglist); - emit_call((int)(shift?gteSQR_part_shift:gteSQR_part_noshift)); + emit_call(shift?gteSQR_part_shift:gteSQR_part_noshift); if(need_flags||need_ir) { emit_addimm(FP,(int)&psxRegs.CP2D.r[0]-(int)&dynarec_local,0); c2op_call_MACtoIR(lm,need_flags); @@ -3867,9 +3872,9 @@ static void c2op_assemble(int i,struct regstat *i_regs) c2op_prologue(c2op,reglist); #ifdef DRC_DBG emit_movimm(source[i],1); // opcode - emit_writeword(1,(int)&psxRegs.code); + emit_writeword(1,&psxRegs.code); #endif - emit_call((int)(need_flags?gte_handlers[c2op]:gte_handlers_nf[c2op])); + emit_call(need_flags?gte_handlers[c2op]:gte_handlers_nf[c2op]); break; } c2op_epilogue(c2op,reglist); @@ -4065,17 +4070,17 @@ static void do_miniht_jump(int rs,int rh,int ht) { static void do_miniht_insert(u_int return_address,int rt,int temp) { #ifndef HAVE_ARMV7 emit_movimm(return_address,rt); // PC into link register - add_to_linker((int)out,return_address,1); + add_to_linker(out,return_address,1); emit_pcreladdr(temp); - emit_writeword(rt,(int)&mini_ht[(return_address&0xFF)>>3][0]); - emit_writeword(temp,(int)&mini_ht[(return_address&0xFF)>>3][1]); + emit_writeword(rt,&mini_ht[(return_address&0xFF)>>3][0]); + emit_writeword(temp,&mini_ht[(return_address&0xFF)>>3][1]); #else emit_movw(return_address&0x0000FFFF,rt); - add_to_linker((int)out,return_address,1); + add_to_linker(out,return_address,1); emit_pcreladdr(temp); - emit_writeword(temp,(int)&mini_ht[(return_address&0xFF)>>3][1]); + emit_writeword(temp,&mini_ht[(return_address&0xFF)>>3][1]); emit_movt(return_address&0xFFFF0000,rt); - emit_writeword(rt,(int)&mini_ht[(return_address&0xFF)>>3][0]); + emit_writeword(rt,&mini_ht[(return_address&0xFF)>>3][0]); #endif } @@ -4165,7 +4170,7 @@ static void wb_invalidate_arm(signed char pre[],signed char entry[],uint64_t dir static void mark_clear_cache(void *target) { - u_long offset = (char *)target - (char *)BASE_ADDR; + u_long offset = (u_char *)target - translation_cache; u_int mask = 1u << ((offset >> 12) & 31); if (!(needs_clear_cache[offset >> 17] & mask)) { char *start = (char *)((u_long)target & ~4095ul); @@ -4183,11 +4188,11 @@ static void do_clear_cache() { u_int bitmap=needs_clear_cache[i]; if(bitmap) { - u_int start,end; + u_char *start, *end; for(j=0;j<32;j++) { if(bitmap&(1< (u_char *)BASE_ADDR + (1< translation_cache + (1<vaddr==vaddr) { - //printf("TRACE: count=%d next=%d (get_addr match %x: %x)\n",Count,next_interupt,vaddr,(int)head->addr); + //printf("TRACE: count=%d next=%d (get_addr match %x: %p)\n",Count,next_interupt,vaddr,head->addr); hash_table_add(hash_table_get(vaddr), vaddr, head->addr); return head->addr; } @@ -425,7 +430,7 @@ void *get_addr(u_int vaddr) head=jump_dirty[vpage]; while(head!=NULL) { if(head->vaddr==vaddr) { - //printf("TRACE: count=%d next=%d (get_addr match dirty %x: %x)\n",Count,next_interupt,vaddr,(int)head->addr); + //printf("TRACE: count=%d next=%d (get_addr match dirty %x: %p)\n",Count,next_interupt,vaddr,head->addr); // Don't restore blocks which are about to expire from the cache if (doesnt_expire_soon(head->addr)) if (verify_dirty(head->addr)) { @@ -892,14 +897,14 @@ void remove_hash(int vaddr) } } -void ll_remove_matching_addrs(struct ll_entry **head,int addr,int shift) +void ll_remove_matching_addrs(struct ll_entry **head,uintptr_t addr,int shift) { struct ll_entry *next; while(*head) { - if(((u_int)((*head)->addr)>>shift)==(addr>>shift) || - ((u_int)((*head)->addr-MAX_OUTPUT_BLOCK_SIZE)>>shift)==(addr>>shift)) + if(((uintptr_t)((*head)->addr)>>shift)==(addr>>shift) || + ((uintptr_t)((*head)->addr-MAX_OUTPUT_BLOCK_SIZE)>>shift)==(addr>>shift)) { - inv_debug("EXP: Remove pointer to %x (%x)\n",(int)(*head)->addr,(*head)->vaddr); + inv_debug("EXP: Remove pointer to %p (%x)\n",(*head)->addr,(*head)->vaddr); remove_hash((*head)->vaddr); next=(*head)->next; free(*head); @@ -928,15 +933,15 @@ void ll_clear(struct ll_entry **head) } // Dereference the pointers and remove if it matches -static void ll_kill_pointers(struct ll_entry *head,int addr,int shift) +static void ll_kill_pointers(struct ll_entry *head,uintptr_t addr,int shift) { while(head) { - int ptr=get_pointer(head->addr); - inv_debug("EXP: Lookup pointer to %x at %x (%x)\n",(int)ptr,(int)head->addr,head->vaddr); + uintptr_t ptr = (uintptr_t)get_pointer(head->addr); + inv_debug("EXP: Lookup pointer to %lx at %p (%x)\n",(long)ptr,head->addr,head->vaddr); if(((ptr>>shift)==(addr>>shift)) || (((ptr-MAX_OUTPUT_BLOCK_SIZE)>>shift)==(addr>>shift))) { - inv_debug("EXP: Kill pointer at %x (%x)\n",(int)head->addr,head->vaddr); + inv_debug("EXP: Kill pointer at %p (%x)\n",head->addr,head->vaddr); void *host_addr=find_extjump_insn(head->addr); #ifdef __arm__ mark_clear_cache(host_addr); @@ -964,7 +969,7 @@ void invalidate_page(u_int page) head=jump_out[page]; jump_out[page]=0; while(head!=NULL) { - inv_debug("INVALIDATE: kill pointer to %x (%x)\n",head->vaddr,(int)head->addr); + inv_debug("INVALIDATE: kill pointer to %x (%p)\n",head->vaddr,head->addr); void *host_addr=find_extjump_insn(head->addr); #ifdef __arm__ mark_clear_cache(host_addr); @@ -1017,7 +1022,7 @@ void invalidate_block(u_int block) while(head!=NULL) { u_int start,end; if(vpage>2047||(head->vaddr>>12)==block) { // Ignore vaddr hash collision - get_bounds((int)head->addr,&start,&end); + get_bounds(head->addr,&start,&end); //printf("start: %x end: %x\n",start,end); if(page<2048&&start>=(u_int)rdram&&end<(u_int)rdram+RAM_SIZE) { if(((start-(u_int)rdram)>>12)<=page&&((end-1-(u_int)rdram)>>12)>=page) { @@ -1054,7 +1059,7 @@ void invalidate_addr(u_int addr) for(;pg1<=page;pg1++) { for(head=jump_dirty[pg1];head!=NULL;head=head->next) { u_int start,end; - get_bounds((int)head->addr,&start,&end); + get_bounds(head->addr,&start,&end); if(ram_offset) { start-=ram_offset; end-=ram_offset; @@ -1110,13 +1115,13 @@ void invalidate_all_pages() void add_link(u_int vaddr,void *src) { u_int page=get_page(vaddr); - inv_debug("add_link: %x -> %x (%d)\n",(int)src,vaddr,page); + inv_debug("add_link: %p -> %x (%d)\n",src,vaddr,page); int *ptr=(int *)(src+4); assert((*ptr&0x0fff0000)==0x059f0000); (void)ptr; ll_add(jump_out+page,vaddr,src); - //int ptr=get_pointer(src); - //inv_debug("add_link: Pointer is to %x\n",(int)ptr); + //void *ptr=get_pointer(src); + //inv_debug("add_link: Pointer is to %p\n",ptr); } // If a code block was found to be unmodified (bit was set in @@ -1134,10 +1139,10 @@ void clean_blocks(u_int page) if (doesnt_expire_soon(head->addr)) { u_int start,end; if(verify_dirty(head->addr)) { - //printf("Possibly Restore %x (%x)\n",head->vaddr, (int)head->addr); + //printf("Possibly Restore %x (%p)\n",head->vaddr, head->addr); u_int i; u_int inv=0; - get_bounds((int)head->addr,&start,&end); + get_bounds(head->addr,&start,&end); if(start-(u_int)rdram>12;i<=(end-1-(u_int)rdram+0x80000000)>>12;i++) { inv|=invalid_code[i]; @@ -1150,7 +1155,7 @@ void clean_blocks(u_int page) void *clean_addr = get_clean_addr(head->addr); if (doesnt_expire_soon(clean_addr)) { u_int ppage=page; - inv_debug("INV: Restored %x (%x/%x)\n",head->vaddr, (int)head->addr, (int)clean_addr); + inv_debug("INV: Restored %x (%p/%p)\n",head->vaddr, head->addr, clean_addr); //printf("page=%x, addr=%x\n",page,head->vaddr); //assert(head->vaddr>>12==(page|0x80000)); ll_add_flags(jump_in+ppage,head->vaddr,head->reg_sv_flags,clean_addr); @@ -2607,7 +2612,7 @@ void load_assemble(int i,struct regstat *i_regs) } } //printf("load_assemble: c=%d\n",c); - //if(c) printf("load_assemble: const=%x\n",(int)constmap[i][s]+offset); + //if(c) printf("load_assemble: const=%lx\n",(long)constmap[i][s]+offset); // FIXME: Even if the load is a NOP, we should check for pagefaults... if((tl<0&&(!c||(((u_int)constmap[i][s]+offset)>>16)==0x1f80)) ||rt1[i]==0) { @@ -2622,7 +2627,7 @@ void load_assemble(int i,struct regstat *i_regs) //if(tl<0) tl=get_reg(i_regs->regmap,-1); if(tl>=0) { //printf("load_assemble: c=%d\n",c); - //if(c) printf("load_assemble: const=%x\n",(int)constmap[i][s]+offset); + //if(c) printf("load_assemble: const=%lx\n",(long)constmap[i][s]+offset); assert(tl>=0); // Even if the load is a NOP, we must check for pagefaults and I/O reglist&=~(1<=0) reglist&=~(1<=0) emit_readword_indexed((int)rdram-0x80000000,addr,th); - //emit_readword_indexed((int)rdram-0x7FFFFFFC,addr,tl); + //if(th>=0) emit_readword_indexed(rdram-0x80000000,addr,th); + //emit_readword_indexed(rdram-0x7FFFFFFC,addr,tl); #ifdef HOST_IMM_ADDR32 if(c) emit_readdword_tlb(constmap[i][s]+offset,map,th,tl); @@ -2897,7 +2902,7 @@ void store_assemble(int i,struct regstat *i_regs) if(!c) a=addr; #endif if(faststore_reg_override) a=faststore_reg_override; - //emit_writebyte_indexed(tl,(int)rdram-0x80000000,temp); + //emit_writebyte_indexed(tl,rdram-0x80000000,temp); emit_writebyte_indexed_tlb(tl,x,a,map,a); } type=STOREB_STUB; @@ -2918,7 +2923,7 @@ void store_assemble(int i,struct regstat *i_regs) if(map>=0) { emit_writehword_indexed(tl,x,a); }else - //emit_writehword_indexed(tl,(int)rdram-0x80000000+x,a); + //emit_writehword_indexed(tl,rdram-0x80000000+x,a); emit_writehword_indexed(tl,x,a); } type=STOREH_STUB; @@ -2927,7 +2932,7 @@ void store_assemble(int i,struct regstat *i_regs) if(!c||memtarget) { int a=addr; if(faststore_reg_override) a=faststore_reg_override; - //emit_writeword_indexed(tl,(int)rdram-0x80000000,addr); + //emit_writeword_indexed(tl,rdram-0x80000000,addr); emit_writeword_indexed_tlb(tl,0,a,map,temp); } type=STOREW_STUB; @@ -2938,13 +2943,13 @@ void store_assemble(int i,struct regstat *i_regs) if(faststore_reg_override) a=faststore_reg_override; if(rs2[i]) { assert(th>=0); - //emit_writeword_indexed(th,(int)rdram-0x80000000,addr); - //emit_writeword_indexed(tl,(int)rdram-0x7FFFFFFC,addr); + //emit_writeword_indexed(th,rdram-0x80000000,addr); + //emit_writeword_indexed(tl,rdram-0x7FFFFFFC,addr); 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_writeword_indexed(tl,rdram-0x80000000,temp); + //emit_writeword_indexed(tl,rdram-0x7FFFFFFC,temp); emit_writedword_indexed_tlb(tl,tl,0,a,map,temp); } } @@ -2968,7 +2973,7 @@ void store_assemble(int i,struct regstat *i_regs) assert(ir>=0); emit_cmpmem_indexedsr12_reg(ir,addr,1); #else - emit_cmpmem_indexedsr12_imm((int)invalid_code,addr,1); + emit_cmpmem_indexedsr12_imm(invalid_code,addr,1); #endif #if defined(HAVE_CONDITIONAL_CALL) && !defined(DESTRUCTIVE_SHIFT) emit_callne(invalidate_addr_reg[addr]); @@ -2994,7 +2999,7 @@ void store_assemble(int i,struct regstat *i_regs) load_all_consts(regs[i].regmap_entry,regs[i].was32,regs[i].wasdirty,i); wb_dirtys(regs[i].regmap_entry,regs[i].was32,regs[i].wasdirty); emit_movimm(start+i*4+4,0); - emit_writeword(0,(int)&pcaddr); + emit_writeword(0,&pcaddr); emit_jmp(do_interrupt); } } @@ -3204,7 +3209,7 @@ void storelr_assemble(int i,struct regstat *i_regs) assert(ir>=0); emit_cmpmem_indexedsr12_reg(ir,temp,1); #else - emit_cmpmem_indexedsr12_imm((int)invalid_code,temp,1); + emit_cmpmem_indexedsr12_imm(invalid_code,temp,1); #endif #if defined(HAVE_CONDITIONAL_CALL) && !defined(DESTRUCTIVE_SHIFT) emit_callne(invalidate_addr_reg[temp]); @@ -3304,7 +3309,7 @@ void c2ls_assemble(int i,struct regstat *i_regs) assert(ir>=0); emit_cmpmem_indexedsr12_reg(ir,ar,1); #else - emit_cmpmem_indexedsr12_imm((int)invalid_code,ar,1); + emit_cmpmem_indexedsr12_imm(invalid_code,ar,1); #endif #if defined(HAVE_CONDITIONAL_CALL) && !defined(DESTRUCTIVE_SHIFT) emit_callne(invalidate_addr_reg[ar]); @@ -3386,9 +3391,9 @@ void hlecall_assemble(int i,struct regstat *i_regs) emit_movimm(start+i*4+4,0); // Get PC uint32_t hleCode = source[i] & 0x03ffffff; if (hleCode >= ARRAY_SIZE(psxHLEt)) - emit_movimm((int)psxNULL,1); + emit_movimm((uintptr_t)psxNULL,1); else - emit_movimm((int)psxHLEt[hleCode],1); + emit_movimm((uintptr_t)psxHLEt[hleCode],1); emit_addimm(HOST_CCREG,CLOCK_ADJUST(ccadj[i]),HOST_CCREG); // XXX emit_jmp(jump_hlecall); } @@ -3745,13 +3750,13 @@ static int get_final_value(int hr, int i, int *value) { // Precompute load address *value=constmap[i][hr]+imm[i+1]; - //printf("c=%x imm=%x\n",(int)constmap[i][hr],imm[i+1]); + //printf("c=%x imm=%lx\n",(long)constmap[i][hr],imm[i+1]); return 1; } } } *value=constmap[i][hr]; - //printf("c=%x\n",(int)constmap[i][hr]); + //printf("c=%lx\n",(long)constmap[i][hr]); if(i==slen-1) return 1; if(reg<64) { return !((unneeded_reg[i+1]>>reg)&1); @@ -4211,11 +4216,11 @@ static void drc_dbg_emit_do_cmp(int i) if(regs[i].regmap[hr]>=0) reglist|=1<>2].regmap_entry); else if(itype[i]==RJUMP) { if(get_reg(branch_regs[i].regmap,RTEMP)>=0) - emit_readword((int)&pcaddr,get_reg(branch_regs[i].regmap,RTEMP)); + emit_readword(&pcaddr,get_reg(branch_regs[i].regmap,RTEMP)); else emit_loadreg(rs1[i],get_reg(branch_regs[i].regmap,rs1[i])); } @@ -4594,11 +4599,12 @@ static void do_ccstub(int n) emit_jmp(stubs[n].retaddr); } -static void add_to_linker(int addr,int target,int ext) +static void add_to_linker(void *addr, u_int target, int ext) { - link_addr[linkcount][0]=addr; - link_addr[linkcount][1]=target; - link_addr[linkcount][2]=ext; + assert(linkcount < ARRAY_SIZE(link_addr)); + link_addr[linkcount].addr = addr; + link_addr[linkcount].target = target; + link_addr[linkcount].ext = ext; linkcount++; } @@ -4626,7 +4632,7 @@ static void ujump_assemble_write_ra(int i) #ifdef REG_PREFETCH if(temp>=0) { - if(i_regmap[temp]!=PTEMP) emit_movimm((int)hash_table_get(return_address),temp); + if(i_regmap[temp]!=PTEMP) emit_movimm((uintptr_t)hash_table_get(return_address),temp); } #endif emit_movimm(return_address,rt); // PC into link register @@ -4649,7 +4655,7 @@ void ujump_assemble(int i,struct regstat *i_regs) signed char *i_regmap=i_regs->regmap; int return_address=start+i*4+8; if(get_reg(branch_regs[i].regmap,31)>0) - if(i_regmap[temp]==PTEMP) emit_movimm((int)hash_table_get(return_address),temp); + if(i_regmap[temp]==PTEMP) emit_movimm((uintptr_t)hash_table_get(return_address),temp); } #endif if(rt1[i]==31&&(rt1[i]==rs1[i+1]||rt1[i]==rs2[i+1])) { @@ -4684,7 +4690,7 @@ void ujump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal_branch(branch_regs[i].is32,ba[i])); + add_to_linker(out,ba[i],internal_branch(branch_regs[i].is32,ba[i])); emit_jmp(0); } } @@ -4701,7 +4707,7 @@ static void rjump_assemble_write_ra(int i) #ifdef REG_PREFETCH if(temp>=0) { - if(i_regmap[temp]!=PTEMP) emit_movimm((int)hash_table_get(return_address),temp); + if(i_regmap[temp]!=PTEMP) emit_movimm((uintptr_t)hash_table_get(return_address),temp); } #endif emit_movimm(return_address,rt); // PC into link register @@ -4732,7 +4738,7 @@ void rjump_assemble(int i,struct regstat *i_regs) if((temp=get_reg(branch_regs[i].regmap,PTEMP))>=0) { signed char *i_regmap=i_regs->regmap; int return_address=start+i*4+8; - if(i_regmap[temp]==PTEMP) emit_movimm((int)hash_table_get(return_address),temp); + if(i_regmap[temp]==PTEMP) emit_movimm((uintptr_t)hash_table_get(return_address),temp); } } #endif @@ -4900,7 +4906,7 @@ void cjump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jmp(0); } #ifdef CORTEX_A8_BRANCH_PREDICTION_HACK @@ -4926,24 +4932,24 @@ void cjump_assemble(int i,struct regstat *i_regs) if(s2h>=0) emit_cmp(s1h,s2h); else emit_test(s1h,s1h); nottaken1=out; - emit_jne(1); + emit_jne((void *)1l); } if(opcode[i]==5) // BNE { if(s2h>=0) emit_cmp(s1h,s2h); else emit_test(s1h,s1h); if(invert) taken=out; - else add_to_linker((int)out,ba[i],internal); + else add_to_linker(out,ba[i],internal); emit_jne(0); } if(opcode[i]==6) // BLEZ { emit_test(s1h,s1h); if(invert) taken=out; - else add_to_linker((int)out,ba[i],internal); + else add_to_linker(out,ba[i],internal); emit_js(0); nottaken1=out; - emit_jne(1); + emit_jne((void *)1l); } if(opcode[i]==7) // BGTZ { @@ -4951,7 +4957,7 @@ void cjump_assemble(int i,struct regstat *i_regs) nottaken1=out; emit_js(1); if(invert) taken=out; - else add_to_linker((int)out,ba[i],internal); + else add_to_linker(out,ba[i],internal); emit_jne(0); } } // if(!only32) @@ -4964,9 +4970,9 @@ void cjump_assemble(int i,struct regstat *i_regs) else emit_test(s1l,s1l); if(invert){ nottaken=out; - emit_jne(1); + emit_jne((void *)1l); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jeq(0); } } @@ -4978,7 +4984,7 @@ void cjump_assemble(int i,struct regstat *i_regs) nottaken=out; emit_jeq(1); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jne(0); } } @@ -4989,7 +4995,7 @@ void cjump_assemble(int i,struct regstat *i_regs) nottaken=out; emit_jge(1); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jl(0); } } @@ -5000,7 +5006,7 @@ void cjump_assemble(int i,struct regstat *i_regs) nottaken=out; emit_jl(1); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jge(0); } } @@ -5010,10 +5016,10 @@ void cjump_assemble(int i,struct regstat *i_regs) if(match&&(!internal||!is_ds[(ba[i]-start)>>2])) { if(adj) { emit_addimm(cc,-CLOCK_ADJUST(adj),cc); - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); }else{ emit_addnop(13); - add_to_linker((int)out,ba[i],internal*2); + add_to_linker(out,ba[i],internal*2); } emit_jmp(0); }else @@ -5030,7 +5036,7 @@ void cjump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jmp(0); } } @@ -5059,14 +5065,14 @@ void cjump_assemble(int i,struct regstat *i_regs) if(s2h>=0) emit_cmp(s1h,s2h); else emit_test(s1h,s1h); nottaken1=out; - emit_jne(2); + emit_jne((void *)2l); } if((opcode[i]&0x2f)==5) // BNE { if(s2h>=0) emit_cmp(s1h,s2h); else emit_test(s1h,s1h); taken=out; - emit_jne(1); + emit_jne((void *)1l); } if((opcode[i]&0x2f)==6) // BLEZ { @@ -5074,7 +5080,7 @@ void cjump_assemble(int i,struct regstat *i_regs) taken=out; emit_js(1); nottaken1=out; - emit_jne(2); + emit_jne((void *)2l); } if((opcode[i]&0x2f)==7) // BGTZ { @@ -5082,7 +5088,7 @@ void cjump_assemble(int i,struct regstat *i_regs) nottaken1=out; emit_js(2); taken=out; - emit_jne(1); + emit_jne((void *)1l); } } // if(!only32) @@ -5093,7 +5099,7 @@ void cjump_assemble(int i,struct regstat *i_regs) if(s2l>=0) emit_cmp(s1l,s2l); else emit_test(s1l,s1l); nottaken=out; - emit_jne(2); + emit_jne((void *)2l); } if((opcode[i]&0x2f)==5) // BNE { @@ -5153,7 +5159,7 @@ void cjump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jmp(0); } } @@ -5285,7 +5291,7 @@ void sjump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jmp(0); } #ifdef CORTEX_A8_BRANCH_PREDICTION_HACK @@ -5313,7 +5319,7 @@ void sjump_assemble(int i,struct regstat *i_regs) nottaken=out; emit_jns(1); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_js(0); } } @@ -5324,7 +5330,7 @@ void sjump_assemble(int i,struct regstat *i_regs) nottaken=out; emit_js(1); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jns(0); } } @@ -5339,7 +5345,7 @@ void sjump_assemble(int i,struct regstat *i_regs) nottaken=out; emit_jns(1); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_js(0); } } @@ -5350,7 +5356,7 @@ void sjump_assemble(int i,struct regstat *i_regs) nottaken=out; emit_js(1); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jns(0); } } @@ -5361,10 +5367,10 @@ void sjump_assemble(int i,struct regstat *i_regs) if(match&&(!internal||!is_ds[(ba[i]-start)>>2])) { if(adj) { emit_addimm(cc,-CLOCK_ADJUST(adj),cc); - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); }else{ emit_addnop(13); - add_to_linker((int)out,ba[i],internal*2); + add_to_linker(out,ba[i],internal*2); } emit_jmp(0); }else @@ -5381,7 +5387,7 @@ void sjump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jmp(0); } } @@ -5482,7 +5488,7 @@ void sjump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jmp(0); } } @@ -5588,16 +5594,16 @@ void fjump_assemble(int i,struct regstat *i_regs) nottaken=out; emit_jeq(1); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jne(0); } } else // BC1F if(invert){ nottaken=out; - emit_jne(1); + emit_jne((void *)1l); }else{ - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jeq(0); } { @@ -5619,7 +5625,7 @@ void fjump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jmp(0); } set_jump_target(nottaken, out); @@ -5648,7 +5654,7 @@ void fjump_assemble(int i,struct regstat *i_regs) else // BC1F { nottaken=out; - emit_jne(1); + emit_jne((void *)1l); } } } // if(!unconditional) @@ -5688,7 +5694,7 @@ void fjump_assemble(int i,struct regstat *i_regs) ds_assemble_entry(i); } else { - add_to_linker((int)out,ba[i],internal); + add_to_linker(out,ba[i],internal); emit_jmp(0); } @@ -5966,7 +5972,7 @@ static void pagespan_assemble(int i,struct regstat *i_regs) int target_addr=start+i*4+5; void *stub=out; void *compiled_target_addr=check_addr(target_addr); - emit_extjump_ds((int)branch_addr,target_addr); + emit_extjump_ds(branch_addr, target_addr); if(compiled_target_addr) { set_jump_target(branch_addr, compiled_target_addr); add_link(target_addr,stub); @@ -5981,7 +5987,7 @@ static void pagespan_assemble(int i,struct regstat *i_regs) int target_addr=start+i*4+8; void *stub=out; void *compiled_target_addr=check_addr(target_addr); - emit_extjump_ds((int)branch_addr,target_addr); + emit_extjump_ds(branch_addr, target_addr); if(compiled_target_addr) { set_jump_target(branch_addr, compiled_target_addr); add_link(target_addr,stub); @@ -6004,7 +6010,7 @@ static void pagespan_ds() if(regs[0].regmap[HOST_CCREG]!=CCREG) wb_register(CCREG,regs[0].regmap_entry,regs[0].wasdirty,regs[0].was32); if(regs[0].regmap[HOST_BTREG]!=BTREG) - emit_writeword(HOST_BTREG,(int)&branch_target); + emit_writeword(HOST_BTREG,&branch_target); load_regs(regs[0].regmap_entry,regs[0].regmap,regs[0].was32,rs1[0],rs2[0]); address_generation(0,®s[0],regs[0].regmap_entry); if(itype[0]==STORE||itype[0]==STORELR||(opcode[0]&0x3b)==0x39||(opcode[0]&0x3b)==0x3a) @@ -6064,7 +6070,7 @@ static void pagespan_ds() int btaddr=get_reg(regs[0].regmap,BTREG); if(btaddr<0) { btaddr=get_reg(regs[0].regmap,-1); - emit_readword((int)&branch_target,btaddr); + emit_readword(&branch_target,btaddr); } assert(btaddr!=HOST_CCREG); if(regs[0].regmap[HOST_CCREG]!=CCREG) emit_loadreg(CCREG,HOST_CCREG); @@ -6916,7 +6922,7 @@ static int new_dynarec_test(void) SysPrintf("test passed.\n"); else SysPrintf("test failed: %08x\n", ret); - out=(u_char *)BASE_ADDR; + out = translation_cache; return ret == DRC_TEST_VAL; } @@ -6925,7 +6931,7 @@ static int new_dynarec_test(void) void new_dynarec_clear_full() { int n; - out=(u_char *)BASE_ADDR; + out = translation_cache; memset(invalid_code,1,sizeof(invalid_code)); memset(hash_table,0xff,sizeof(hash_table)); memset(mini_ht,-1,sizeof(mini_ht)); @@ -6950,7 +6956,7 @@ void new_dynarec_init() // allocate/prepare a buffer for translation cache // see assem_arm.h for some explanation #if defined(BASE_ADDR_FIXED) - if (mmap (translation_cache, 1 << TARGET_SIZE_2, + if (mmap(translation_cache, 1 << TARGET_SIZE_2, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) != translation_cache) { @@ -6978,11 +6984,11 @@ void new_dynarec_init() #else #ifndef NO_WRITE_EXEC // not all systems allow execute in data segment by default - if (mprotect((void *)BASE_ADDR, 1<>12]=0; emit_movimm(start,0); - emit_writeword(0,(int)&pcaddr); + emit_writeword(0,&pcaddr); emit_jmp(new_dyna_leave); literal_pool(0); end_block(beginning); @@ -9814,27 +9820,19 @@ int new_recompile_block(int addr) if(regs[i].isconst) { printf("constants: "); #if defined(__i386__) || defined(__x86_64__) - if(regs[i].isconst&1) printf("eax=%x ",(int)constmap[i][0]); - if((regs[i].isconst>>1)&1) printf("ecx=%x ",(int)constmap[i][1]); - if((regs[i].isconst>>2)&1) printf("edx=%x ",(int)constmap[i][2]); - if((regs[i].isconst>>3)&1) printf("ebx=%x ",(int)constmap[i][3]); - if((regs[i].isconst>>5)&1) printf("ebp=%x ",(int)constmap[i][5]); - if((regs[i].isconst>>6)&1) printf("esi=%x ",(int)constmap[i][6]); - if((regs[i].isconst>>7)&1) printf("edi=%x ",(int)constmap[i][7]); + if(regs[i].isconst&1) printf("eax=%x ",(u_int)constmap[i][0]); + if((regs[i].isconst>>1)&1) printf("ecx=%x ",(u_int)constmap[i][1]); + if((regs[i].isconst>>2)&1) printf("edx=%x ",(u_int)constmap[i][2]); + if((regs[i].isconst>>3)&1) printf("ebx=%x ",(u_int)constmap[i][3]); + if((regs[i].isconst>>5)&1) printf("ebp=%x ",(u_int)constmap[i][5]); + if((regs[i].isconst>>6)&1) printf("esi=%x ",(u_int)constmap[i][6]); + if((regs[i].isconst>>7)&1) printf("edi=%x ",(u_int)constmap[i][7]); #endif #ifdef __arm__ - if(regs[i].isconst&1) printf("r0=%x ",(int)constmap[i][0]); - if((regs[i].isconst>>1)&1) printf("r1=%x ",(int)constmap[i][1]); - if((regs[i].isconst>>2)&1) printf("r2=%x ",(int)constmap[i][2]); - if((regs[i].isconst>>3)&1) printf("r3=%x ",(int)constmap[i][3]); - if((regs[i].isconst>>4)&1) printf("r4=%x ",(int)constmap[i][4]); - if((regs[i].isconst>>5)&1) printf("r5=%x ",(int)constmap[i][5]); - if((regs[i].isconst>>6)&1) printf("r6=%x ",(int)constmap[i][6]); - if((regs[i].isconst>>7)&1) printf("r7=%x ",(int)constmap[i][7]); - if((regs[i].isconst>>8)&1) printf("r8=%x ",(int)constmap[i][8]); - if((regs[i].isconst>>9)&1) printf("r9=%x ",(int)constmap[i][9]); - if((regs[i].isconst>>10)&1) printf("r10=%x ",(int)constmap[i][10]); - if((regs[i].isconst>>12)&1) printf("r12=%x ",(int)constmap[i][12]); + int r; + for (r = 0; r < ARRAY_SIZE(constmap[i]); r++) + if ((regs[i].isconst >> r) & 1) + printf(" r%d=%x", r, (u_int)constmap[i][r]); #endif printf("\n"); } @@ -9888,11 +9886,11 @@ int new_recompile_block(int addr) emit_movimm(start,0); // abuse io address var as a flag that we // have already returned here once - emit_readword((int)&address,1); - emit_writeword(0,(int)&pcaddr); - emit_writeword(0,(int)&address); + emit_readword(&address,1); + emit_writeword(0,&pcaddr); + emit_writeword(0,&address); emit_cmp(0,1); - emit_jne((int)new_dyna_leave); + emit_jne(new_dyna_leave); } for(i=0;i %8x\n",link_addr[i][0],link_addr[i][1]); + assem_debug("%p -> %8x\n",link_addr[i].addr,link_addr[i].target); literal_pool(64); - if(!link_addr[i][2]) + if (!link_addr[i].ext) { - void *stub=out; - void *addr=check_addr(link_addr[i][1]); - emit_extjump(link_addr[i][0],link_addr[i][1]); - if(addr) { - set_jump_target(link_addr[i][0], addr); - add_link(link_addr[i][1],stub); + void *stub = out; + void *addr = check_addr(link_addr[i].target); + emit_extjump(link_addr[i].addr, link_addr[i].target); + if (addr) { + set_jump_target(link_addr[i].addr, addr); + add_link(link_addr[i].target,stub); } - else set_jump_target(link_addr[i][0], stub); + else + set_jump_target(link_addr[i].addr, stub); } else { // Internal branch - int target=(link_addr[i][1]-start)>>2; + int target=(link_addr[i].target-start)>>2; assert(target>=0&&target>1); + //set_jump_target_fillslot(link_addr[i].addr,instr_addr[target],link_addr[i].ext>>1); //#else - set_jump_target(link_addr[i][0],instr_addr[target]); + set_jump_target(link_addr[i].addr, instr_addr[target]); //#endif } } @@ -10165,7 +10164,7 @@ int new_recompile_block(int addr) if(((u_int)out)&7) emit_addnop(13); #endif assert((u_int)out-(u_int)beginning(u_int)BASE_ADDR+(1< translation_cache+(1<>12;i<=(start+slen*4)>>12;i++) { @@ -10190,11 +10190,11 @@ int new_recompile_block(int addr) /* Pass 10 - Free memory by expiring oldest blocks */ - int end=((((int)out-(int)BASE_ADDR)>>(TARGET_SIZE_2-16))+16384)&65535; + int end=(((out-translation_cache)>>(TARGET_SIZE_2-16))+16384)&65535; while(expirep!=end) { int shift=TARGET_SIZE_2-3; // Divide into 8 blocks - uintptr_t base=(uintptr_t)BASE_ADDR+((expirep>>13)<>13)<>11)&3) { diff --git a/libpcsxcore/new_dynarec/pcsxmem_inline.c b/libpcsxcore/new_dynarec/pcsxmem_inline.c index 305931ae..02e7705e 100644 --- a/libpcsxcore/new_dynarec/pcsxmem_inline.c +++ b/libpcsxcore/new_dynarec/pcsxmem_inline.c @@ -15,10 +15,10 @@ static int pcsx_direct_read(int type, u_int addr, int cc_adj, int cc, int rs, in case 0x1120: // rcnt2 count if (rt < 0) goto dont_care; if (cc < 0) return 0; - emit_readword((int)&rcnts[2].mode, HOST_TEMPREG); - emit_readword((int)&rcnts[2].cycleStart, rt); + emit_readword(&rcnts[2].mode, HOST_TEMPREG); + emit_readword(&rcnts[2].cycleStart, rt); emit_testimm(HOST_TEMPREG, 0x200); - emit_readword((int)&last_count, HOST_TEMPREG); + emit_readword(&last_count, HOST_TEMPREG); emit_sub(HOST_TEMPREG, rt, HOST_TEMPREG); emit_add(HOST_TEMPREG, cc, HOST_TEMPREG); if (cc_adj) @@ -31,9 +31,9 @@ static int pcsx_direct_read(int type, u_int addr, int cc_adj, int cc, int rs, in case 0x1124: // rcnt mode if (rt < 0) return 0; t = (addr >> 4) & 3; - emit_readword((int)&rcnts[t].mode, rt); + emit_readword(&rcnts[t].mode, rt); emit_andimm(rt, ~0x1800, HOST_TEMPREG); - emit_writeword(HOST_TEMPREG, (int)&rcnts[t].mode); + emit_writeword(HOST_TEMPREG, &rcnts[t].mode); mov_loadtype_adj(type, rt, rt); goto hit; }