git subrepo pull --force deps/lightrec
authorPaul Cercueil <paul@crapouillou.net>
Sat, 2 Sep 2023 20:45:44 +0000 (22:45 +0200)
committerPaul Cercueil <paul@crapouillou.net>
Sat, 2 Sep 2023 20:45:44 +0000 (22:45 +0200)
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
deps/lightrec/disassembler.h
deps/lightrec/emitter.c
deps/lightrec/interpreter.c
deps/lightrec/lightrec.h

index b2e393a..ddebd0b 100644 (file)
@@ -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
index 1804f88..e05a093 100644 (file)
@@ -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,
index b7ace19..275ed2a 100644 (file)
@@ -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,
index 37264d3..2112b55 100644 (file)
@@ -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)
index 9779951..5a66e73 100644 (file)
@@ -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)