git subrepo pull --force deps/lightrec
[pcsx_rearmed.git] / deps / lightrec / emitter.c
index 523daf7..270fd48 100644 (file)
@@ -1817,6 +1817,18 @@ static void rec_special_BREAK(struct lightrec_cstate *state,
        rec_break_syscall(state, block, offset, LIGHTREC_EXIT_BREAK);
 }
 
+static void rec_mfc(struct lightrec_cstate *state, const struct block *block, u16 offset)
+{
+       struct regcache *reg_cache = state->reg_cache;
+       union code c = block->opcode_list[offset].c;
+       jit_state_t *_jit = block->_jit;
+
+       jit_note(__FILE__, __LINE__);
+       lightrec_clean_reg_if_loaded(reg_cache, _jit, c.i.rt, true);
+
+       call_to_c_wrapper(state, block, c.opcode, C_WRAPPER_MFC);
+}
+
 static void rec_mtc(struct lightrec_cstate *state, const struct block *block, u16 offset)
 {
        struct regcache *reg_cache = state->reg_cache;
@@ -2019,6 +2031,12 @@ static void rec_cp2_basic_MFC2(struct lightrec_cstate *state,
 
        _jit_name(block->_jit, __func__);
 
+       if (state->state->ops.cop2_notify) {
+               /* We must call cop2_notify, handle that in C. */
+               rec_mfc(state, block, offset);
+               return;
+       }
+
        flags = (zext_regs & BIT(reg)) ? REG_ZEXT : REG_EXT;
        rt = lightrec_alloc_reg_out(reg_cache, _jit, c.r.rt, flags);
 
@@ -2087,6 +2105,12 @@ static void rec_cp2_basic_CFC2(struct lightrec_cstate *state,
 
        _jit_name(block->_jit, __func__);
 
+       if (state->state->ops.cop2_notify) {
+               /* We must call cop2_notify, handle that in C. */
+               rec_mfc(state, block, offset);
+               return;
+       }
+
        switch (c.r.rd) {
        case 4:
        case 12:
@@ -2118,6 +2142,12 @@ static void rec_cp2_basic_MTC2(struct lightrec_cstate *state,
 
        _jit_name(block->_jit, __func__);
 
+       if (state->state->ops.cop2_notify) {
+               /* We must call cop2_notify, handle that in C. */
+               rec_mtc(state, block, offset);
+               return;
+       }
+
        if (c.r.rd == 31)
                return;
 
@@ -2202,6 +2232,12 @@ static void rec_cp2_basic_CTC2(struct lightrec_cstate *state,
 
        _jit_name(block->_jit, __func__);
 
+       if (state->state->ops.cop2_notify) {
+               /* We must call cop2_notify, handle that in C. */
+               rec_mtc(state, block, offset);
+               return;
+       }
+
        rt = lightrec_alloc_reg_in(reg_cache, _jit, c.r.rt, 0);
 
        switch (c.r.rd) {