From e26c79a878ed1c0ee25cf7dffbb023dca7a871b9 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Sat, 2 Sep 2023 22:45:44 +0200 Subject: [PATCH] git subrepo pull --force deps/lightrec subrepo: subdir: "deps/lightrec" merged: "3eee0e1e7e" upstream: origin: "https://github.com/pcercuei/lightrec.git" branch: "master" commit: "3eee0e1e7e" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "110b9eb" --- deps/lightrec/.gitrepo | 4 ++-- deps/lightrec/disassembler.h | 2 +- deps/lightrec/emitter.c | 33 +++++++++++++++++---------------- deps/lightrec/interpreter.c | 4 ++-- deps/lightrec/lightrec.h | 1 + 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/deps/lightrec/.gitrepo b/deps/lightrec/.gitrepo index b2e393a3..ddebd0bf 100644 --- a/deps/lightrec/.gitrepo +++ b/deps/lightrec/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/pcercuei/lightrec.git branch = master - commit = afc75e49d7eb8c36697e969cb980757974630b3e - parent = ba86ff938a6b17c171dd68ebdf897ca3e30550f8 + commit = 3eee0e1e7e5ada68f2da11b7951def4366caae38 + parent = c9f33835ba76a0578cfd388353e04c6391869e0a method = merge cmdver = 0.4.6 diff --git a/deps/lightrec/disassembler.h b/deps/lightrec/disassembler.h index 1804f884..e05a093c 100644 --- a/deps/lightrec/disassembler.h +++ b/deps/lightrec/disassembler.h @@ -111,7 +111,7 @@ enum standard_opcodes { OP_LWC2 = 0x32, OP_SWC2 = 0x3a, - OP_META = 0x3b, + OP_META = 0x3c, OP_META_MULT2 = 0x19, OP_META_MULTU2 = 0x1a, diff --git a/deps/lightrec/emitter.c b/deps/lightrec/emitter.c index b7ace194..275ed2ac 100644 --- a/deps/lightrec/emitter.c +++ b/deps/lightrec/emitter.c @@ -28,13 +28,6 @@ static void rec_cp2_do_mfc2(struct lightrec_cstate *state, const struct block *block, u16 offset, u8 reg, u8 out_reg); -static void unknown_opcode(struct lightrec_cstate *state, const struct block *block, u16 offset) -{ - pr_warn("Unknown opcode: 0x%08x at PC 0x%08x\n", - block->opcode_list[offset].c.opcode, - block->pc + (offset << 2)); -} - static void lightrec_jump_to_fn(jit_state_t *_jit, void (*fn)(void)) { @@ -2009,9 +2002,9 @@ static void rec_LW(struct lightrec_cstate *state, const struct block *block, u16 rec_load(state, block, offset, code, jit_code_bswapr_ui, false); } -static void rec_break_syscall(struct lightrec_cstate *state, - const struct block *block, u16 offset, - u32 exit_code) +static void rec_exit_early(struct lightrec_cstate *state, + const struct block *block, u16 offset, + u32 exit_code, u32 pc) { struct regcache *reg_cache = state->reg_cache; jit_state_t *_jit = block->_jit; @@ -2036,24 +2029,25 @@ static void rec_break_syscall(struct lightrec_cstate *state, lightrec_free_reg(reg_cache, tmp); - /* TODO: the return address should be "pc - 4" if we're a delay slot */ - lightrec_emit_end_of_block(state, block, offset, -1, - get_ds_pc(block, offset, 0), - 31, 0, true); + lightrec_emit_end_of_block(state, block, offset, -1, pc, 31, 0, true); } static void rec_special_SYSCALL(struct lightrec_cstate *state, const struct block *block, u16 offset) { _jit_name(block->_jit, __func__); - rec_break_syscall(state, block, offset, LIGHTREC_EXIT_SYSCALL); + + /* TODO: the return address should be "pc - 4" if we're a delay slot */ + rec_exit_early(state, block, offset, LIGHTREC_EXIT_SYSCALL, + get_ds_pc(block, offset, 0)); } static void rec_special_BREAK(struct lightrec_cstate *state, const struct block *block, u16 offset) { _jit_name(block->_jit, __func__); - rec_break_syscall(state, block, offset, LIGHTREC_EXIT_BREAK); + rec_exit_early(state, block, offset, LIGHTREC_EXIT_BREAK, + get_ds_pc(block, offset, 0)); } static void rec_mfc(struct lightrec_cstate *state, const struct block *block, u16 offset) @@ -2777,6 +2771,13 @@ static void rec_meta_COM(struct lightrec_cstate *state, lightrec_free_reg(reg_cache, rd); } +static void unknown_opcode(struct lightrec_cstate *state, + const struct block *block, u16 offset) +{ + rec_exit_early(state, block, offset, LIGHTREC_EXIT_UNKNOWN_OP, + block->pc + (offset << 2)); +} + static const lightrec_rec_func_t rec_standard[64] = { SET_DEFAULT_ELM(rec_standard, unknown_opcode), [OP_SPECIAL] = rec_SPECIAL, diff --git a/deps/lightrec/interpreter.c b/deps/lightrec/interpreter.c index 37264d3e..2112b553 100644 --- a/deps/lightrec/interpreter.c +++ b/deps/lightrec/interpreter.c @@ -318,9 +318,9 @@ static u32 int_delay_slot(struct interpreter *inter, u32 pc, bool branch) static u32 int_unimplemented(struct interpreter *inter) { - pr_warn("Unimplemented opcode 0x%08x\n", inter->op->opcode); + lightrec_set_exit_flags(inter->state, LIGHTREC_EXIT_UNKNOWN_OP); - return jump_next(inter); + return inter->block->pc + (inter->offset << 2); } static u32 int_jump(struct interpreter *inter, bool link) diff --git a/deps/lightrec/lightrec.h b/deps/lightrec/lightrec.h index 9779951b..5a66e73e 100644 --- a/deps/lightrec/lightrec.h +++ b/deps/lightrec/lightrec.h @@ -63,6 +63,7 @@ struct lightrec_mem_map; #define LIGHTREC_EXIT_SYSCALL (1 << 2) #define LIGHTREC_EXIT_SEGFAULT (1 << 3) #define LIGHTREC_EXIT_NOMEM (1 << 4) +#define LIGHTREC_EXIT_UNKNOWN_OP (1 << 5) /* Unsafe optimizations flags */ #define LIGHTREC_OPT_INV_DMA_ONLY (1 << 0) -- 2.39.5