mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-25 21:06:54 +00:00
tcg: Change temp_dead argument to TCGTemp
Backports commit f8bf00f1028a00a7978e9175da53944de95b9fcb from qemu
This commit is contained in:
parent
daf837956c
commit
82a4e93629
|
@ -1776,20 +1776,17 @@ static TCGReg tcg_reg_alloc(TCGContext *s, TCGRegSet reg1, TCGRegSet reg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mark a temporary as dead. */
|
/* mark a temporary as dead. */
|
||||||
static inline void temp_dead(TCGContext *s, int temp)
|
static inline void temp_dead(TCGContext *s, TCGTemp *ts)
|
||||||
{
|
{
|
||||||
TCGTemp *ts = &s->temps[temp];
|
if (ts->fixed_reg) {
|
||||||
|
return;
|
||||||
if (!ts->fixed_reg) {
|
|
||||||
if (ts->val_type == TEMP_VAL_REG) {
|
|
||||||
s->reg_to_temp[ts->reg] = NULL;
|
|
||||||
}
|
|
||||||
if (temp < s->nb_globals || ts->temp_local) {
|
|
||||||
ts->val_type = TEMP_VAL_MEM;
|
|
||||||
} else {
|
|
||||||
ts->val_type = TEMP_VAL_DEAD;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ts->val_type == TEMP_VAL_REG) {
|
||||||
|
s->reg_to_temp[ts->reg] = NULL;
|
||||||
|
}
|
||||||
|
ts->val_type = (temp_idx(s, ts) < s->nb_globals || ts->temp_local
|
||||||
|
? TEMP_VAL_MEM : TEMP_VAL_DEAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sync a temporary to memory. 'allocated_regs' is used in case a
|
/* sync a temporary to memory. 'allocated_regs' is used in case a
|
||||||
|
@ -1824,13 +1821,15 @@ static inline void temp_sync(TCGContext *s, int temp, TCGRegSet allocated_regs)
|
||||||
temporary registers needs to be allocated to store a constant. */
|
temporary registers needs to be allocated to store a constant. */
|
||||||
static inline void temp_save(TCGContext *s, int temp, TCGRegSet allocated_regs)
|
static inline void temp_save(TCGContext *s, int temp, TCGRegSet allocated_regs)
|
||||||
{
|
{
|
||||||
|
TCGTemp *ts = &s->temps[temp];
|
||||||
|
|
||||||
#ifdef USE_LIVENESS_ANALYSIS
|
#ifdef USE_LIVENESS_ANALYSIS
|
||||||
/* The liveness analysis already ensures that globals are back
|
/* The liveness analysis already ensures that globals are back
|
||||||
in memory. Keep an assert for safety. */
|
in memory. Keep an assert for safety. */
|
||||||
assert(s->temps[temp].val_type == TEMP_VAL_MEM || s->temps[temp].fixed_reg);
|
tcg_debug_assert(ts->val_type == TEMP_VAL_MEM || ts->fixed_reg);
|
||||||
#else
|
#else
|
||||||
temp_sync(s, temp, allocated_regs);
|
temp_sync(s, temp, allocated_regs);
|
||||||
temp_dead(s, temp);
|
temp_dead(s, ts);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1880,7 +1879,7 @@ static void tcg_reg_alloc_bb_end(TCGContext *s, TCGRegSet allocated_regs)
|
||||||
Keep an assert for safety. */
|
Keep an assert for safety. */
|
||||||
assert(ts->val_type == TEMP_VAL_DEAD);
|
assert(ts->val_type == TEMP_VAL_DEAD);
|
||||||
#else
|
#else
|
||||||
temp_dead(s, i);
|
temp_dead(s, ts);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1916,7 +1915,7 @@ static void tcg_reg_alloc_movi(TCGContext *s, const TCGArg *args,
|
||||||
temp_sync(s, args[0], s->reserved_regs);
|
temp_sync(s, args[0], s->reserved_regs);
|
||||||
}
|
}
|
||||||
if (IS_DEAD_ARG(0)) {
|
if (IS_DEAD_ARG(0)) {
|
||||||
temp_dead(s, args[0]);
|
temp_dead(s, ots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1966,9 +1965,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
|
||||||
}
|
}
|
||||||
tcg_out_st(s, otype, ts->reg, ots->mem_base->reg, ots->mem_offset);
|
tcg_out_st(s, otype, ts->reg, ots->mem_base->reg, ots->mem_offset);
|
||||||
if (IS_DEAD_ARG(1)) {
|
if (IS_DEAD_ARG(1)) {
|
||||||
temp_dead(s, args[1]);
|
temp_dead(s, ts);
|
||||||
}
|
}
|
||||||
temp_dead(s, args[0]);
|
temp_dead(s, ots);
|
||||||
} else if (ts->val_type == TEMP_VAL_CONST) {
|
} else if (ts->val_type == TEMP_VAL_CONST) {
|
||||||
/* propagate constant */
|
/* propagate constant */
|
||||||
if (ots->val_type == TEMP_VAL_REG) {
|
if (ots->val_type == TEMP_VAL_REG) {
|
||||||
|
@ -1986,7 +1985,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def,
|
||||||
s->reg_to_temp[ots->reg] = NULL;
|
s->reg_to_temp[ots->reg] = NULL;
|
||||||
}
|
}
|
||||||
ots->reg = ts->reg;
|
ots->reg = ts->reg;
|
||||||
temp_dead(s, args[1]);
|
temp_dead(s, ts);
|
||||||
} else {
|
} else {
|
||||||
if (ots->val_type != TEMP_VAL_REG) {
|
if (ots->val_type != TEMP_VAL_REG) {
|
||||||
/* When allocating a new register, make sure to not spill the
|
/* When allocating a new register, make sure to not spill the
|
||||||
|
@ -2093,7 +2092,7 @@ static void tcg_reg_alloc_op(TCGContext *s,
|
||||||
/* mark dead temporaries and free the associated registers */
|
/* mark dead temporaries and free the associated registers */
|
||||||
for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) {
|
for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) {
|
||||||
if (IS_DEAD_ARG(i)) {
|
if (IS_DEAD_ARG(i)) {
|
||||||
temp_dead(s, args[i]);
|
temp_dead(s, &s->temps[args[i]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2164,7 +2163,7 @@ static void tcg_reg_alloc_op(TCGContext *s,
|
||||||
tcg_reg_sync(s, reg);
|
tcg_reg_sync(s, reg);
|
||||||
}
|
}
|
||||||
if (IS_DEAD_ARG(i)) {
|
if (IS_DEAD_ARG(i)) {
|
||||||
temp_dead(s, args[i]);
|
temp_dead(s, ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2270,7 +2269,7 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs,
|
||||||
/* mark dead temporaries and free the associated registers */
|
/* mark dead temporaries and free the associated registers */
|
||||||
for(i = nb_oargs; i < nb_iargs + nb_oargs; i++) {
|
for(i = nb_oargs; i < nb_iargs + nb_oargs; i++) {
|
||||||
if (IS_DEAD_ARG(i)) {
|
if (IS_DEAD_ARG(i)) {
|
||||||
temp_dead(s, args[i]);
|
temp_dead(s, &s->temps[args[i]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2316,7 +2315,7 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs,
|
||||||
tcg_reg_sync(s, reg);
|
tcg_reg_sync(s, reg);
|
||||||
}
|
}
|
||||||
if (IS_DEAD_ARG(i)) {
|
if (IS_DEAD_ARG(i)) {
|
||||||
temp_dead(s, args[i]);
|
temp_dead(s, ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2437,7 +2436,7 @@ int tcg_gen_code(TCGContext *s, tcg_insn_unit *gen_code_buf)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INDEX_op_discard:
|
case INDEX_op_discard:
|
||||||
temp_dead(s, args[0]);
|
temp_dead(s, &s->temps[args[0]]);
|
||||||
break;
|
break;
|
||||||
case INDEX_op_set_label:
|
case INDEX_op_set_label:
|
||||||
tcg_reg_alloc_bb_end(s, s->reserved_regs);
|
tcg_reg_alloc_bb_end(s, s->reserved_regs);
|
||||||
|
|
Loading…
Reference in a new issue