static void rcache_evict_vreg(int x)
{
-#if REMAP_REGISTER
rcache_remap_vreg(x);
-#else
- rcache_clean_vreg(x);
-#endif
rcache_unmap_vreg(x);
}
return x;
}
-#if REMAP_REGISTER
// maps a host register to a REG
static int rcache_map_reg(sh2_reg_e r, int hr)
{
+#if REMAP_REGISTER
int i;
gconst_kill(r);
RCACHE_CHECK("after map");
#endif
return cache_regs[i].hreg;
+#else
+ return rcache_get_reg(r, RC_GR_WRITE, NULL);
+#endif
}
// remap vreg from a TEMP to a REG if it will be used (upcoming TEMP invalidation)
static void rcache_remap_vreg(int x)
{
+#if REMAP_REGISTER
u32 rsl_d = rcache_regs_soon | rcache_regs_late;
int d;
#if DRC_DEBUG & 64
RCACHE_CHECK("after remap");
#endif
-}
+#else
+ rcache_clean_vreg(x);
#endif
+}
-#if ALIAS_REGISTERS
static void rcache_alias_vreg(sh2_reg_e rd, sh2_reg_e rs)
{
+#if ALIAS_REGISTERS
int x;
// if s isn't constant, it must be in cache for aliasing
#if DRC_DEBUG & 64
RCACHE_CHECK("after alias");
#endif
-}
+#else
+ int hr_s = rcache_get_reg(rs, RC_GR_READ, NULL);
+ int hr_d = rcache_get_reg(rd, RC_GR_WRITE, NULL);
+
+ emith_move_r_r(hr_d, hr_s);
+ gconst_copy(rd, rs);
#endif
+}
// note: must not be called when doing conditional code
static int rcache_get_reg_(sh2_reg_e r, rc_gr_mode mode, int do_locking, int *hr)
for (i = 0; i < ARRAY_SIZE(cache_regs); i++)
if (cache_regs[i].type == HR_CACHED && (cache_regs[i].htype & HRT_TEMP)) {
rcache_unlock(i);
-#if REMAP_REGISTER
rcache_remap_vreg(i);
-#else
- rcache_clean_vreg(i);
-#endif
}
rcache_regs_clean = 0;
}
static void emit_move_r_r(sh2_reg_e dst, sh2_reg_e src)
{
- if (gconst_check(src) || rcache_is_cached(src)) {
-#if ALIAS_REGISTERS
+ if (gconst_check(src) || rcache_is_cached(src))
rcache_alias_vreg(dst, src);
-#else
- int hr_s = rcache_get_reg(src, RC_GR_READ, NULL);
- int hr_d = rcache_get_reg(dst, RC_GR_WRITE, NULL);
- emith_move_r_r(hr_d, hr_s);
- gconst_copy(dst, src);
-#endif
- } else {
+ else {
int hr_d = rcache_get_reg(dst, RC_GR_WRITE, NULL);
emith_ctx_read(hr_d, src * 4);
}
if (rd == SHR_TMP)
hr2 = hr;
else
-#if REMAP_REGISTER
hr2 = rcache_map_reg(rd, hr);
-#else
- hr2 = rcache_get_reg(rd, RC_GR_WRITE, NULL);
-#endif
if (hr != hr2) {
emith_move_r_r(hr2, hr);
if (rd == SHR_TMP)
hr2 = hr;
else
-#if REMAP_REGISTER
hr2 = rcache_map_reg(rd, hr);
-#else
- hr2 = rcache_get_reg(rd, RC_GR_WRITE, NULL);
-#endif
if (hr != hr2) {
emith_move_r_r(hr2, hr);
emith_add_r_r_imm(tmp, tmp2, 2 + (op & 0xff) * 2);
}
tmp2 = emit_memhandler_read(opd->size);
-#if REMAP_REGISTER
tmp3 = rcache_map_reg(GET_Rn(), tmp2);
-#else
- tmp3 = rcache_get_reg(GET_Rn(), RC_GR_WRITE, NULL);
-#endif
if (tmp3 != tmp2) {
emith_move_r_r(tmp3, tmp2);
rcache_free_tmp(tmp2);
rcache_invalidate_tmp();
emith_abicall(sh2_drc_divu32);
tmp = rcache_get_tmp_ret();
-#if REMAP_REGISTER
tmp2 = rcache_map_reg(div(opd).rn, tmp);
-#else
- tmp2 = rcache_get_reg(div(opd).rn, RC_GR_WRITE, NULL);
-#endif
if (tmp != tmp2)
emith_move_r_r(tmp2, tmp);
rcache_invalidate_tmp();
emith_abicall(sh2_drc_divu64);
tmp = rcache_get_tmp_ret();
-#if REMAP_REGISTER
tmp2 = rcache_map_reg(div(opd).rn, tmp);
-#else
- tmp2 = rcache_get_reg(div(opd).rn, RC_GR_WRITE, NULL);
-#endif
tmp4 = rcache_get_reg(div(opd).ro, RC_GR_WRITE, NULL);
if (tmp != tmp2)
emith_move_r_r(tmp2, tmp);
rcache_invalidate_tmp();
emith_abicall(sh2_drc_divs32);
tmp = rcache_get_tmp_ret();
-#if REMAP_REGISTER
tmp2 = rcache_map_reg(div(opd).rn, tmp);
-#else
- tmp2 = rcache_get_reg(div(opd).rn, RC_GR_WRITE, NULL);
-#endif
if (tmp != tmp2)
emith_move_r_r(tmp2, tmp);
tmp3 = rcache_get_tmp();
rcache_invalidate_tmp();
emith_abicall(sh2_drc_divs64);
tmp = rcache_get_tmp_ret();
-#if REMAP_REGISTER
tmp2 = rcache_map_reg(div(opd).rn, tmp);
-#else
- tmp2 = rcache_get_reg(div(opd).rn, RC_GR_WRITE, NULL);
-#endif
tmp4 = rcache_get_reg(div(opd).ro, RC_GR_WRITE, NULL);
if (tmp != tmp2)
emith_move_r_r(tmp2, tmp);
int sh2_drc_init(SH2 *sh2);
void sh2_drc_finish(SH2 *sh2);
-void sh2_drc_wcheck_ram(uint32_t a, unsigned len, SH2 *sh2);
-void sh2_drc_wcheck_da(uint32_t a, unsigned len, SH2 *sh2);
+void sh2_drc_wcheck_ram(u32 a, unsigned len, SH2 *sh2);
+void sh2_drc_wcheck_da(u32 a, unsigned len, SH2 *sh2);
#ifdef DRC_SH2
void sh2_drc_mem_setup(SH2 *sh2);
#define OF_DELAY_LOOP (2 << 2)
#define OF_POLL_LOOP (3 << 2)
-unsigned short scan_block(uint32_t base_pc, int is_slave,
- unsigned char *op_flags, uint32_t *end_pc,
- uint32_t *base_literals, uint32_t *end_literals);
+u16 scan_block(u32 base_pc, int is_slave, u8 *op_flags, u32 *end_pc,
+ u32 *base_literals, u32 *end_literals);
#if defined(DRC_SH2) && defined(__GNUC__) && !defined(__clang__)
// direct access to some host CPU registers used by the DRC if gcc is used.