From 11357fef3e80fd3b788ffd9a937758de5d5fd622 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Sat, 11 Jun 2022 00:17:16 +0100 Subject: [PATCH] git subrepo pull --force deps/lightrec subrepo: subdir: "deps/lightrec" merged: "30bad28d" upstream: origin: "https://github.com/pcercuei/lightrec.git" branch: "master" commit: "30bad28d" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" --- deps/lightrec/.gitrepo | 4 ++-- deps/lightrec/emitter.c | 2 +- deps/lightrec/lightrec-private.h | 8 ++++++++ deps/lightrec/lightrec.c | 25 +++++++++++++++++-------- deps/lightrec/recompiler.c | 4 ++-- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/deps/lightrec/.gitrepo b/deps/lightrec/.gitrepo index 809f13b2..125d138a 100644 --- a/deps/lightrec/.gitrepo +++ b/deps/lightrec/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/pcercuei/lightrec.git branch = master - commit = a8fe7568cef718517b230a13fe48891faa60f04b - parent = 2f609094ad9ec14212fb730897ccb63f2f44bc40 + commit = 30bad28d7a2b2903cd7f3d8024ae7a34a0c8b482 + parent = 0141267e1c5e17c27548f6ad57c7acc22e589990 method = merge cmdver = 0.4.3 diff --git a/deps/lightrec/emitter.c b/deps/lightrec/emitter.c index fd289356..15e1c6ef 100644 --- a/deps/lightrec/emitter.c +++ b/deps/lightrec/emitter.c @@ -75,7 +75,7 @@ static void lightrec_emit_end_of_block(struct lightrec_cstate *state, pr_debug("EOB: %u cycles\n", cycles); } - if (offset + !!(op->flags & LIGHTREC_NO_DS) < block->nb_ops - 1) + if (offset - !!(op->flags & LIGHTREC_NO_DS) < block->nb_ops - 1) state->branches[state->nb_branches++] = jit_b(); } diff --git a/deps/lightrec/lightrec-private.h b/deps/lightrec/lightrec-private.h index fe89e66b..3c043d5e 100644 --- a/deps/lightrec/lightrec-private.h +++ b/deps/lightrec/lightrec-private.h @@ -71,6 +71,14 @@ struct regcache; struct opcode; struct reaper; +struct u16x2 { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + u16 h, l; +#else + u16 l, h; +#endif +}; + struct block { jit_state_t *_jit; struct opcode *opcode_list; diff --git a/deps/lightrec/lightrec.c b/deps/lightrec/lightrec.c index ba734ad2..3b3fd090 100644 --- a/deps/lightrec/lightrec.c +++ b/deps/lightrec/lightrec.c @@ -370,6 +370,16 @@ static u32 clamp_s32(s32 val, s32 min, s32 max) return val < min ? min : val > max ? max : val; } +static u16 load_u16(u32 *ptr) +{ + return ((struct u16x2 *) ptr)->l; +} + +static void store_u16(u32 *ptr, u16 value) +{ + ((struct u16x2 *) ptr)->l = value; +} + static u32 lightrec_mfc2(struct lightrec_state *state, u8 reg) { s16 gteir1, gteir2, gteir3; @@ -382,18 +392,18 @@ static u32 lightrec_mfc2(struct lightrec_state *state, u8 reg) case 9: case 10: case 11: - return (s32)(s16) state->regs.cp2d[reg]; + return (s32)(s16) load_u16(&state->regs.cp2d[reg]); case 7: case 16: case 17: case 18: case 19: - return (u16) state->regs.cp2d[reg]; + return load_u16(&state->regs.cp2d[reg]); case 28: case 29: - gteir1 = (s16) state->regs.cp2d[9]; - gteir2 = (s16) state->regs.cp2d[10]; - gteir3 = (s16) state->regs.cp2d[11]; + gteir1 = (s16) load_u16(&state->regs.cp2d[9]); + gteir2 = (s16) load_u16(&state->regs.cp2d[10]); + gteir3 = (s16) load_u16(&state->regs.cp2d[11]); return clamp_s32(gteir1 >> 7, 0, 0x1f) << 0 | clamp_s32(gteir2 >> 7, 0, 0x1f) << 5 | @@ -519,16 +529,15 @@ static void lightrec_ctc2(struct lightrec_state *state, u8 reg, u32 data) case 27: case 29: case 30: - data = (s32)(s16) data; + store_u16(&state->regs.cp2c[reg], data); break; case 31: data = (data & 0x7ffff000) | !!(data & 0x7f87e000) << 31; fallthrough; default: + state->regs.cp2c[reg] = data; break; } - - state->regs.cp2c[reg] = data; } void lightrec_mtc(struct lightrec_state *state, union code op, u32 data) diff --git a/deps/lightrec/recompiler.c b/deps/lightrec/recompiler.c index 4ddc522b..7350adba 100644 --- a/deps/lightrec/recompiler.c +++ b/deps/lightrec/recompiler.c @@ -48,7 +48,7 @@ struct recompiler { static unsigned int get_processors_count(void) { - unsigned int nb; + unsigned int nb = 1; #if defined(PTW32_VERSION) nb = pthread_num_processors_np(); @@ -57,7 +57,7 @@ static unsigned int get_processors_count(void) size_t size = sizeof(count); nb = sysctlbyname("hw.ncpu", &count, &size, NULL, 0) ? 1 : count; -#elif defined(__linux__) +#elif defined(_SC_NPROCESSORS_ONLN) nb = sysconf(_SC_NPROCESSORS_ONLN); #endif -- 2.39.5