X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=deps%2Flightrec%2Flightrec-private.h;h=0df9f938bd8bc8dc9fad2a95b3935bdf3238032e;hb=refs%2Fheads%2Flibretro;hp=12e953a2d9bbe6e7e930c177a46e9a212431ebf0;hpb=02a5662c31c401081716623cc80bb1c4ab1dbb19;p=pcsx_rearmed.git diff --git a/deps/lightrec/lightrec-private.h b/deps/lightrec/lightrec-private.h index 12e953a2..920008c2 100644 --- a/deps/lightrec/lightrec-private.h +++ b/deps/lightrec/lightrec-private.h @@ -20,6 +20,12 @@ #include #endif +#include +#include + +#define X32_FMT "0x%08"PRIx32 +#define PC_FMT "PC "X32_FMT + #define ARRAY_SIZE(x) (sizeof(x) ? sizeof(x) / sizeof((x)[0]) : 0) #define GENMASK(h, l) \ @@ -51,7 +57,11 @@ #define SET_DEFAULT_ELM(table, value) [0] = NULL #endif -#define fallthrough do {} while (0) /* fall-through */ +#if __has_attribute(__fallthrough__) +# define fallthrough __attribute__((__fallthrough__)) +#else +# define fallthrough do {} while (0) /* fallthrough */ +#endif #define container_of(ptr, type, member) \ ((type *)((void *)(ptr) - offsetof(type, member))) @@ -73,6 +83,7 @@ #define BLOCK_IS_DEAD BIT(3) #define BLOCK_IS_MEMSET BIT(4) #define BLOCK_NO_OPCODE_LIST BIT(5) +#define BLOCK_PRELOAD_PC BIT(6) #define RAM_SIZE 0x200000 #define BIOS_SIZE 0x80000 @@ -144,6 +155,7 @@ struct lightrec_cstate { struct lightrec_branch local_branches[512]; struct lightrec_branch_target targets[512]; + u16 movi_temp[32]; unsigned int nb_local_branches; unsigned int nb_targets; unsigned int cycles; @@ -156,6 +168,7 @@ struct lightrec_cstate { struct lightrec_state { struct lightrec_registers regs; u32 temp_reg; + u32 curr_pc; u32 next_pc; uintptr_t wrapper_regs[NUM_TEMPS]; u8 in_delay_slot_n; @@ -163,9 +176,10 @@ struct lightrec_state { u32 target_cycle; u32 exit_flags; u32 old_cycle_counter; + u32 cycles_per_op; + void *c_wrapper; struct block *dispatcher, *c_wrapper_block; void *c_wrappers[C_WRAPPERS_COUNT]; - void *wrappers_eps[C_WRAPPERS_COUNT]; struct blockcache *block_cache; struct recompiler *rec; struct lightrec_cstate *cstate; @@ -182,12 +196,15 @@ struct lightrec_state { unsigned int nb_maps; const struct lightrec_mem_map *maps; uintptr_t offset_ram, offset_bios, offset_scratch, offset_io; + u32 opt_flags; _Bool with_32bit_lut; _Bool mirrors_mapped; - _Bool invalidate_from_dma_only; void *code_lut[]; }; +#define lightrec_offset(ptr) \ + offsetof(struct lightrec_state, ptr) + u32 lightrec_rw(struct lightrec_state *state, union code op, u32 addr, u32 data, u32 *flags, struct block *block, u16 offset); @@ -264,7 +281,7 @@ static inline u32 get_ds_pc(const struct block *block, u16 offset, s16 imm) offset += op_flag_no_ds(flags); - return block->pc + (offset + imm << 2); + return block->pc + ((offset + imm) << 2); } static inline u32 get_branch_pc(const struct block *block, u16 offset, s16 imm) @@ -273,7 +290,7 @@ static inline u32 get_branch_pc(const struct block *block, u16 offset, s16 imm) offset -= op_flag_no_ds(flags); - return block->pc + (offset + imm << 2); + return block->pc + ((offset + imm) << 2); } void lightrec_mtc(struct lightrec_state *state, union code op, u8 reg, u32 data); @@ -290,7 +307,8 @@ int lightrec_compile_block(struct lightrec_cstate *cstate, struct block *block); void lightrec_free_opcode_list(struct lightrec_state *state, struct opcode *list); -__cnst unsigned int lightrec_cycles_of_opcode(union code code); +unsigned int lightrec_cycles_of_opcode(const struct lightrec_state *state, + union code code); static inline u8 get_mult_div_lo(union code c) { @@ -346,7 +364,7 @@ static inline u8 block_clear_flags(struct block *block, u8 mask) static inline _Bool can_sign_extend(s32 value, u8 order) { - return (u32)(value >> order - 1) + 1 < 2; + return ((u32)(value >> (order - 1)) + 1) < 2; } static inline _Bool can_zero_extend(u32 value, u8 order) @@ -360,4 +378,9 @@ get_delay_slot(const struct opcode *list, u16 i) return op_flag_no_ds(list[i].flags) ? &list[i - 1] : &list[i + 1]; } +static inline _Bool lightrec_store_next_pc(void) +{ + return NUM_REGS + NUM_TEMPS <= 4; +} + #endif /* __LIGHTREC_PRIVATE_H__ */