From 6cc8d23c0c5284522c62ce333a7c2286198e9db8 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 27 Jan 2022 23:54:42 +0200 Subject: [PATCH] drc: init some variables, adjust comments no proof that is actually needed, but it felt like some path could pick up something uninitialized --- libpcsxcore/new_dynarec/assem_arm.c | 4 +-- libpcsxcore/new_dynarec/emu_if.h | 12 ++++----- libpcsxcore/new_dynarec/new_dynarec.c | 37 +++++++++++++++++---------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index ef3219f4..32ef9794 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -545,7 +545,7 @@ static void emit_loadreg(int r, int hr) } 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); } } @@ -566,7 +566,7 @@ static void emit_storereg(int r, int hr) } 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); } diff --git a/libpcsxcore/new_dynarec/emu_if.h b/libpcsxcore/new_dynarec/emu_if.h index db11f7b2..5a3a5e8d 100644 --- a/libpcsxcore/new_dynarec/emu_if.h +++ b/libpcsxcore/new_dynarec/emu_if.h @@ -68,12 +68,12 @@ void jump_handler_write32(u32 addr, u32 data, u32 cycles, u32 *table); 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; diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 2ca0f604..de444483 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -119,9 +119,13 @@ enum stub_type { 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; @@ -207,7 +211,7 @@ static struct decoded_insn 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() @@ -599,10 +603,9 @@ void *get_addr_ht(u_int vaddr) 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=0); if(regs[i].regmap[hr]<0&®s[i+1].regmap_entry[hr]<0) { -- 2.39.2