#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__
// 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
}
// 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
#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);
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);
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);
}
}
}
-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);
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);
}
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);
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<<TARGET_SIZE_2)));
+ emit_loadlp((u_int)addr,1);
+ assert(addr>=translation_cache&&addr<(translation_cache+(1<<TARGET_SIZE_2)));
//assert((target>=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);
}
}
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);
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)
}
// 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;
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);
}
}
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)
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
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)
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)
}
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);
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);
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) {
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);
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);
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);
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);
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);
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
}
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)
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)
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
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.
// 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
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)
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);
}
}
}
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;
}
}
{
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);
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;
}
}
{
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
{
temp=sl;
break;
}
- emit_writeword(temp,(int)®_cop2c[copr]);
+ emit_writeword(temp,®_cop2c[copr]);
assert(sl>=0);
}
}
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)
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)
#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);
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);
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);
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
}
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);
{
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<<j)) {
- start=(u_int)BASE_ADDR+i*131072+j*4096;
+ start=translation_cache+i*131072+j*4096;
end=start+4095;
j++;
while(j<32) {
end+=4096;
j++;
}else{
- end_tcache_write((void *)start,(void *)end);
+ end_tcache_write(start, end);
break;
}
}
u_int e;
};
+struct link_entry
+{
+ void *addr;
+ u_int target;
+ u_int ext;
+};
+
// used by asm:
u_char *out;
struct ht_entry hash_table[65536] __attribute__((aligned(16)));
static int ccadj[MAXBLOCK];
static int slen;
static void *instr_addr[MAXBLOCK];
- static u_int link_addr[MAXBLOCK][3];
+ static struct link_entry link_addr[MAXBLOCK];
static int linkcount;
static struct code_stub stubs[MAXBLOCK*3];
static int stubcount;
u_int a, uintptr_t b, uintptr_t c, u_int d, u_int e);
static void add_stub_r(enum stub_type type, void *addr, void *retaddr,
int i, int addr_reg, struct regstat *i_regs, int ccadj, u_int reglist);
-static void add_to_linker(int addr,int target,int ext);
-
-static int tracedebug=0;
+static void add_to_linker(void *addr, u_int target, int ext);
static void mprotect_w_x(void *start, void *end, int is_x)
{
static void *start_block(void)
{
u_char *end = out + MAX_OUTPUT_BLOCK_SIZE;
- if (end > (u_char *)BASE_ADDR + (1<<TARGET_SIZE_2))
- end = (u_char *)BASE_ADDR + (1<<TARGET_SIZE_2);
+ if (end > translation_cache + (1<<TARGET_SIZE_2))
+ end = translation_cache + (1<<TARGET_SIZE_2);
start_tcache_write(out, end);
return out;
}
head=jump_in[page];
while(head!=NULL) {
if(head->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;
}
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)) {
}
}
-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);
}
// 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);
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);
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) {
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;
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
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<RAM_SIZE) {
for(i=(start-(u_int)rdram+0x80000000)>>12;i<=(end-1-(u_int)rdram+0x80000000)>>12;i++) {
inv|=invalid_code[i];
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);
}
}
//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) {
//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<<tl);
if(th>=0) reglist&=~(1<<th);
#endif
{
//emit_xorimm(addr,3,tl);
- //emit_movsbl_indexed((int)rdram-0x80000000,tl,tl);
+ //emit_movsbl_indexed(rdram-0x80000000,tl,tl);
int x=0,a=tl;
#ifdef BIG_ENDIAN_MIPS
if(!c) emit_xorimm(addr,3,tl);
#if 1 //def RAM_OFFSET
emit_movswl_indexed(x,a,tl);
#else
- emit_movswl_indexed((int)rdram-0x80000000+x,a,tl);
+ emit_movswl_indexed(rdram-0x80000000+x,a,tl);
#endif
}
}
if(!dummy) {
int a=addr;
if(fastload_reg_override) a=fastload_reg_override;
- //emit_readword_indexed((int)rdram-0x80000000,addr,tl);
+ //emit_readword_indexed(rdram-0x80000000,addr,tl);
#ifdef HOST_IMM_ADDR32
if(c)
emit_readword_tlb(constmap[i][s]+offset,map,tl);
#endif
{
//emit_xorimm(addr,3,tl);
- //emit_movzbl_indexed((int)rdram-0x80000000,tl,tl);
+ //emit_movzbl_indexed(rdram-0x80000000,tl,tl);
int x=0,a=tl;
#ifdef BIG_ENDIAN_MIPS
if(!c) emit_xorimm(addr,3,tl);
#if 1 //def RAM_OFFSET
emit_movzwl_indexed(x,a,tl);
#else
- emit_movzwl_indexed((int)rdram-0x80000000+x,a,tl);
+ emit_movzwl_indexed(rdram-0x80000000+x,a,tl);
#endif
}
}
if(!dummy) {
int a=addr;
if(fastload_reg_override) a=fastload_reg_override;
- //emit_readword_indexed((int)rdram-0x80000000,addr,tl);
+ //emit_readword_indexed(rdram-0x80000000,addr,tl);
#ifdef HOST_IMM_ADDR32
if(c)
emit_readword_tlb(constmap[i][s]+offset,map,tl);
if(!dummy) {
int a=addr;
if(fastload_reg_override) a=fastload_reg_override;
- //if(th>=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);
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;
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;
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;
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);
}
}
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]);
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);
}
}
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]);
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]);
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);
}
{
// 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);
if(regs[i].regmap[hr]>=0) reglist|=1<<hr;
save_regs(reglist);
emit_movimm(start+i*4,0);
- emit_writeword(0,(int)&pcaddr);
- emit_call((int)do_insn_cmp);
- //emit_readword((int)&cycle,0);
+ emit_writeword(0,&pcaddr);
+ emit_call(do_insn_cmp);
+ //emit_readword(&cycle,0);
//emit_addimm(0,2,0);
- //emit_writeword(0,(int)&cycle);
+ //emit_writeword(0,&cycle);
restore_regs(reglist);
}
#else
else
assem_debug("branch: external\n");
assert(internal_branch(regs[t].is32,ba[i]+4));
- add_to_linker((int)out,ba[i]+4,internal_branch(regs[t].is32,ba[i]+4));
+ add_to_linker(out,ba[i]+4,internal_branch(regs[t].is32,ba[i]+4));
emit_jmp(0);
}
{
// Save PC as return address
emit_movimm(stubs[n].c,EAX);
- emit_writeword(EAX,(int)&pcaddr);
+ emit_writeword(EAX,&pcaddr);
}
else
{
emit_cmovne_reg(alt,addr);
}
}
- emit_writeword(addr,(int)&pcaddr);
+ emit_writeword(addr,&pcaddr);
}
else
if(itype[i]==RJUMP)
if(rs1[i]==rt1[i+1]||rs1[i]==rt2[i+1]) {
r=get_reg(branch_regs[i].regmap,RTEMP);
}
- emit_writeword(r,(int)&pcaddr);
+ emit_writeword(r,&pcaddr);
}
else {SysPrintf("Unknown branch type in do_ccstub\n");exit(1);}
}
// Update cycle count
assert(branch_regs[i].regmap[HOST_CCREG]==CCREG||branch_regs[i].regmap[HOST_CCREG]==-1);
- if(stubs[n].a) emit_addimm(HOST_CCREG,CLOCK_ADJUST((int)stubs[n].a),HOST_CCREG);
- emit_call((int)cc_interrupt);
- if(stubs[n].a) emit_addimm(HOST_CCREG,-CLOCK_ADJUST((int)stubs[n].a),HOST_CCREG);
+ if(stubs[n].a) emit_addimm(HOST_CCREG,CLOCK_ADJUST((signed int)stubs[n].a),HOST_CCREG);
+ emit_call(cc_interrupt);
+ if(stubs[n].a) emit_addimm(HOST_CCREG,-CLOCK_ADJUST((signed int)stubs[n].a),HOST_CCREG);
if(stubs[n].d==TAKEN) {
if(internal_branch(branch_regs[i].is32,ba[i]))
load_needed_regs(branch_regs[i].regmap,regs[(ba[i]-start)>>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]));
}
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++;
}
#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
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])) {
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);
}
}
#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
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
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
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
{
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)
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);
}
}
nottaken=out;
emit_jeq(1);
}else{
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jne(0);
}
}
nottaken=out;
emit_jge(1);
}else{
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jl(0);
}
}
nottaken=out;
emit_jl(1);
}else{
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jge(0);
}
}
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
ds_assemble_entry(i);
}
else {
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jmp(0);
}
}
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
{
taken=out;
emit_js(1);
nottaken1=out;
- emit_jne(2);
+ emit_jne((void *)2l);
}
if((opcode[i]&0x2f)==7) // BGTZ
{
nottaken1=out;
emit_js(2);
taken=out;
- emit_jne(1);
+ emit_jne((void *)1l);
}
} // if(!only32)
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
{
ds_assemble_entry(i);
}
else {
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jmp(0);
}
}
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
nottaken=out;
emit_jns(1);
}else{
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_js(0);
}
}
nottaken=out;
emit_js(1);
}else{
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jns(0);
}
}
nottaken=out;
emit_jns(1);
}else{
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_js(0);
}
}
nottaken=out;
emit_js(1);
}else{
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jns(0);
}
}
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
ds_assemble_entry(i);
}
else {
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jmp(0);
}
}
ds_assemble_entry(i);
}
else {
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jmp(0);
}
}
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);
}
{
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);
else // BC1F
{
nottaken=out;
- emit_jne(1);
+ emit_jne((void *)1l);
}
}
} // if(!unconditional)
ds_assemble_entry(i);
}
else {
- add_to_linker((int)out,ba[i],internal);
+ add_to_linker(out,ba[i],internal);
emit_jmp(0);
}
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);
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);
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)
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);
SysPrintf("test passed.\n");
else
SysPrintf("test failed: %08x\n", ret);
- out=(u_char *)BASE_ADDR;
+ out = translation_cache;
return ret == DRC_TEST_VAL;
}
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));
// 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) {
#else
#ifndef NO_WRITE_EXEC
// not all systems allow execute in data segment by default
- if (mprotect((void *)BASE_ADDR, 1<<TARGET_SIZE_2, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
+ if (mprotect(translation_cache, 1<<TARGET_SIZE_2, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
SysPrintf("mprotect() failed: %s\n", strerror(errno));
#endif
#endif
- out=(u_char *)BASE_ADDR;
+ out = translation_cache;
cycle_multiplier=200;
new_dynarec_clear_full();
#ifdef HOST_IMM8
sceKernelFreeMemBlock(sceBlock);
sceBlock = -1;
#else
- if (munmap ((void *)BASE_ADDR, 1<<TARGET_SIZE_2) < 0)
+ if (munmap(translation_cache, 1<<TARGET_SIZE_2) < 0)
SysPrintf("munmap() failed\n");
#endif
#endif
invalid_code[start>>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);
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");
}
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<slen;i++)
{
store_regs_bt(regs[i-2].regmap,regs[i-2].is32,regs[i-2].dirty,start+i*4);
assert(regs[i-2].regmap[HOST_CCREG]==CCREG);
}
- add_to_linker((int)out,start+i*4,0);
+ add_to_linker(out,start+i*4,0);
emit_jmp(0);
}
}
if(regs[i-1].regmap[HOST_CCREG]!=CCREG)
emit_loadreg(CCREG,HOST_CCREG);
emit_addimm(HOST_CCREG,CLOCK_ADJUST(ccadj[i-1]+1),HOST_CCREG);
- add_to_linker((int)out,start+i*4,0);
+ add_to_linker(out,start+i*4,0);
emit_jmp(0);
}
/* Pass 9 - Linker */
for(i=0;i<linkcount;i++)
{
- assem_debug("%8x -> %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<slen);
assert(instr_addr[target]);
//#ifdef CORTEX_A8_BRANCH_PREDICTION_HACK
- //set_jump_target_fillslot(link_addr[i][0],instr_addr[target],link_addr[i][2]>>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
}
}
if(((u_int)out)&7) emit_addnop(13);
#endif
assert((u_int)out-(u_int)beginning<MAX_OUTPUT_BLOCK_SIZE);
- //printf("shadow buffer: %x-%x\n",(int)copy,(int)copy+slen*4);
+ //printf("shadow buffer: %p-%p\n",copy,(u_char *)copy+slen*4);
memcpy(copy,source,slen*4);
copy+=slen*4;
// If we're within 256K of the end of the buffer,
// start over from the beginning. (Is 256K enough?)
- if((u_int)out>(u_int)BASE_ADDR+(1<<TARGET_SIZE_2)-MAX_OUTPUT_BLOCK_SIZE) out=(u_char *)BASE_ADDR;
+ if (out > translation_cache+(1<<TARGET_SIZE_2)-MAX_OUTPUT_BLOCK_SIZE)
+ out = translation_cache;
// Trap writes to any of the pages we compiled
for(i=start>>12;i<=(start+slen*4)>>12;i++) {
/* 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)<<shift); // Base address of this block
+ uintptr_t base=(uintptr_t)translation_cache+((expirep>>13)<<shift); // Base address of this block
inv_debug("EXP: Phase %d\n",expirep);
switch((expirep>>11)&3)
{