mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-02 06:41:03 +00:00
tcg: Reference count labels
Increment when adding branches, and decrement when removing them. Backports commit d88a117eaa39b1d0eb1a79fe84c81840a39eb233 from qemu
This commit is contained in:
parent
80b4bef1cc
commit
26ab4d6560
|
@ -240,6 +240,7 @@ void tcg_gen_brcond_i32(TCGContext *s, TCGCond cond, TCGv_i32 arg1, TCGv_i32 arg
|
||||||
if (cond == TCG_COND_ALWAYS) {
|
if (cond == TCG_COND_ALWAYS) {
|
||||||
tcg_gen_br(s, l);
|
tcg_gen_br(s, l);
|
||||||
} else if (cond != TCG_COND_NEVER) {
|
} else if (cond != TCG_COND_NEVER) {
|
||||||
|
l->refs++;
|
||||||
tcg_gen_op4ii_i32(s, INDEX_op_brcond_i32, arg1, arg2, cond, label_arg(s, l));
|
tcg_gen_op4ii_i32(s, INDEX_op_brcond_i32, arg1, arg2, cond, label_arg(s, l));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1412,6 +1413,7 @@ void tcg_gen_brcond_i64(TCGContext *s, TCGCond cond, TCGv_i64 arg1, TCGv_i64 arg
|
||||||
if (cond == TCG_COND_ALWAYS) {
|
if (cond == TCG_COND_ALWAYS) {
|
||||||
tcg_gen_br(s, l);
|
tcg_gen_br(s, l);
|
||||||
} else if (cond != TCG_COND_NEVER) {
|
} else if (cond != TCG_COND_NEVER) {
|
||||||
|
l->refs++;
|
||||||
if (TCG_TARGET_REG_BITS == 32) {
|
if (TCG_TARGET_REG_BITS == 32) {
|
||||||
tcg_gen_op6ii_i32(s, INDEX_op_brcond2_i32, TCGV_LOW(s, arg1),
|
tcg_gen_op6ii_i32(s, INDEX_op_brcond2_i32, TCGV_LOW(s, arg1),
|
||||||
TCGV_HIGH(s, arg1), TCGV_LOW(s, arg2),
|
TCGV_HIGH(s, arg1), TCGV_LOW(s, arg2),
|
||||||
|
|
|
@ -273,6 +273,7 @@ static inline void gen_set_label(TCGContext *s, TCGLabel *l)
|
||||||
|
|
||||||
static inline void tcg_gen_br(TCGContext *s, TCGLabel *l)
|
static inline void tcg_gen_br(TCGContext *s, TCGLabel *l)
|
||||||
{
|
{
|
||||||
|
l->refs++;
|
||||||
tcg_gen_op1(s, INDEX_op_br, label_arg(s, l));
|
tcg_gen_op1(s, INDEX_op_br, label_arg(s, l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1678,6 +1678,26 @@ static void process_op_defs(TCGContext *s)
|
||||||
|
|
||||||
void tcg_op_remove(TCGContext *s, TCGOp *op)
|
void tcg_op_remove(TCGContext *s, TCGOp *op)
|
||||||
{
|
{
|
||||||
|
TCGLabel *label;
|
||||||
|
|
||||||
|
switch (op->opc) {
|
||||||
|
case INDEX_op_br:
|
||||||
|
label = arg_label(s, op->args[0]);
|
||||||
|
label->refs--;
|
||||||
|
break;
|
||||||
|
case INDEX_op_brcond_i32:
|
||||||
|
case INDEX_op_brcond_i64:
|
||||||
|
label = arg_label(s, op->args[3]);
|
||||||
|
label->refs--;
|
||||||
|
break;
|
||||||
|
case INDEX_op_brcond2_i32:
|
||||||
|
label = arg_label(s, op->args[5]);
|
||||||
|
label->refs--;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
QTAILQ_REMOVE(&s->ops, op, link);
|
QTAILQ_REMOVE(&s->ops, op, link);
|
||||||
QTAILQ_INSERT_TAIL(&s->free_ops, op, link);
|
QTAILQ_INSERT_TAIL(&s->free_ops, op, link);
|
||||||
s->nb_ops--;
|
s->nb_ops--;
|
||||||
|
|
|
@ -250,7 +250,8 @@ typedef struct TCGRelocation {
|
||||||
|
|
||||||
typedef struct TCGLabel {
|
typedef struct TCGLabel {
|
||||||
unsigned has_value : 1;
|
unsigned has_value : 1;
|
||||||
unsigned id : 31;
|
unsigned id : 15;
|
||||||
|
unsigned refs : 16;
|
||||||
union {
|
union {
|
||||||
uintptr_t value;
|
uintptr_t value;
|
||||||
tcg_insn_unit *value_ptr;
|
tcg_insn_unit *value_ptr;
|
||||||
|
|
Loading…
Reference in a new issue