}
u_int offset = (u_char *)addr - (u_char *)&dynarec_local;
assert(offset<4096);
- assem_debug("ldr %s,fp+%d\n",regname[hr],offset);
+ assem_debug("ldr %s,fp+%d # r%d\n",regname[hr],offset,r);
output_w32(0xe5900000|rd_rn_rm(hr,FP,0)|offset);
}
}
}
u_int offset = addr-(u_int)&dynarec_local;
assert(offset<4096);
- assem_debug("str %s,fp+%d\n",regname[hr],offset);
+ assem_debug("str %s,fp+%d # r%d\n",regname[hr],offset,r);
output_w32(0xe5800000|rd_rn_rm(hr,FP,0)|offset);
}
void jump_handler_write_h(u32 addr, u32 data, u32 cycles, void *handler);
void jump_handle_swl(u32 addr, u32 data, u32 cycles);
void jump_handle_swr(u32 addr, u32 data, u32 cycles);
-void rcnt0_read_count_m0(u32 addr, u32, u32 cycles);
-void rcnt0_read_count_m1(u32 addr, u32, u32 cycles);
-void rcnt1_read_count_m0(u32 addr, u32, u32 cycles);
-void rcnt1_read_count_m1(u32 addr, u32, u32 cycles);
-void rcnt2_read_count_m0(u32 addr, u32, u32 cycles);
-void rcnt2_read_count_m1(u32 addr, u32, u32 cycles);
+u32 rcnt0_read_count_m0(u32 addr, u32, u32 cycles);
+u32 rcnt0_read_count_m1(u32 addr, u32, u32 cycles);
+u32 rcnt1_read_count_m0(u32 addr, u32, u32 cycles);
+u32 rcnt1_read_count_m1(u32 addr, u32, u32 cycles);
+u32 rcnt2_read_count_m0(u32 addr, u32, u32 cycles);
+u32 rcnt2_read_count_m1(u32 addr, u32, u32 cycles);
extern unsigned int address;
extern unsigned int hack_addr;
INVCODE_STUB = 14,
};
+// regmap_pre[i] - regs before [i] insn starts; dirty things here that
+// don't match .regmap will be written back
+// [i].regmap_entry - regs that must be set up if someone jumps here
+// [i].regmap - regs [i] insn will read/(over)write
struct regstat
{
- signed char regmap_entry[HOST_REGS]; // pre-insn + loop preloaded regs?
+ signed char regmap_entry[HOST_REGS];
signed char regmap[HOST_REGS];
uint64_t wasdirty;
uint64_t dirty;
static u_int ba[MAXBLOCK];
static uint64_t unneeded_reg[MAXBLOCK];
static uint64_t branch_unneeded_reg[MAXBLOCK];
- // pre-instruction [i], excluding loop-preload regs?
+ // see 'struct regstat' for a description
static signed char regmap_pre[MAXBLOCK][HOST_REGS];
// contains 'real' consts at [i] insn, but may differ from what's actually
// loaded in host reg as 'final' value is always loaded, see get_final_value()
return get_addr(vaddr);
}
-void clear_all_regs(signed char regmap[])
+static void clear_all_regs(signed char regmap[])
{
- int hr;
- for (hr=0;hr<HOST_REGS;hr++) regmap[hr]=-1;
+ memset(regmap, -1, sizeof(regmap[0]) * HOST_REGS);
}
static signed char get_reg(const signed char regmap[],int r)
/* Pass 3 - Register allocation */
struct regstat current; // Current register allocations/status
- current.dirty=0;
- current.u=unneeded_reg[0];
+ clear_all_regs(current.regmap_entry);
clear_all_regs(current.regmap);
- alloc_reg(¤t,0,CCREG);
- dirty_reg(¤t,CCREG);
- current.isconst=0;
- current.wasconst=0;
- current.waswritten=0;
+ current.wasdirty = current.dirty = 0;
+ current.u = unneeded_reg[0];
+ alloc_reg(¤t, 0, CCREG);
+ dirty_reg(¤t, CCREG);
+ current.wasconst = 0;
+ current.isconst = 0;
+ current.loadedconst = 0;
+ current.waswritten = 0;
int ds=0;
int cc=0;
int hr=-1;
memcpy(regmap_pre[i],current.regmap,sizeof(current.regmap));
regs[i].wasconst=current.isconst;
regs[i].wasdirty=current.dirty;
+ regs[i].dirty=0;
+ regs[i].u=0;
+ regs[i].isconst=0;
regs[i].loadedconst=0;
if (!dops[i].is_jump) {
if(i+1<slen) {
if(get_reg(regs[i+1].regmap,dops[i+1].rs1)<0) {
hr=get_reg2(regs[i].regmap,regs[i+1].regmap,-1);
if(hr<0) hr=get_reg(regs[i+1].regmap,-1);
- else {regs[i+1].regmap[hr]=AGEN1+((i+1)&1);regs[i+1].isconst&=~(1<<hr);}
+ else {
+ regs[i+1].regmap[hr]=AGEN1+((i+1)&1);
+ regs[i+1].isconst&=~(1<<hr);
+ }
assert(hr>=0);
if(regs[i].regmap[hr]<0&®s[i+1].regmap_entry[hr]<0)
{