]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tcg: Reference count labels
authorRichard Henderson <richard.henderson@linaro.org>
Mon, 26 Nov 2018 20:47:28 +0000 (12:47 -0800)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 25 Dec 2018 19:40:27 +0000 (06:40 +1100)
Increment when adding branches, and decrement when removing them.

Reviewed-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
tcg/tcg-op.c
tcg/tcg-op.h
tcg/tcg.c
tcg/tcg.h

index 38652db32c1485a28e0391fbce297eb8d1f36b0b..1bd7ef24affc91b11206a7e7cb1402082b451231 100644 (file)
@@ -240,6 +240,7 @@ void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1, TCGv_i32 arg2, TCGLabel *l)
     if (cond == TCG_COND_ALWAYS) {
         tcg_gen_br(l);
     } else if (cond != TCG_COND_NEVER) {
+        l->refs++;
         tcg_gen_op4ii_i32(INDEX_op_brcond_i32, arg1, arg2, cond, label_arg(l));
     }
 }
@@ -1405,6 +1406,7 @@ void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, TCGv_i64 arg2, TCGLabel *l)
     if (cond == TCG_COND_ALWAYS) {
         tcg_gen_br(l);
     } else if (cond != TCG_COND_NEVER) {
+        l->refs++;
         if (TCG_TARGET_REG_BITS == 32) {
             tcg_gen_op6ii_i32(INDEX_op_brcond2_i32, TCGV_LOW(arg1),
                               TCGV_HIGH(arg1), TCGV_LOW(arg2),
index db4e9188f428d0a3565d81cf603ab8d33e9a9871..7007ec0d4d8b2d5e3727d3bf6ecd54dc35f6025d 100644 (file)
@@ -260,6 +260,7 @@ static inline void gen_set_label(TCGLabel *l)
 
 static inline void tcg_gen_br(TCGLabel *l)
 {
+    l->refs++;
     tcg_gen_op1(INDEX_op_br, label_arg(l));
 }
 
index 963cb3789296d21caf216d84e9c79773ef6e06c6..99afc65126d1419d3636f28a7f0629b0a3316412 100644 (file)
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2171,6 +2171,26 @@ static void process_op_defs(TCGContext *s)
 
 void tcg_op_remove(TCGContext *s, TCGOp *op)
 {
+    TCGLabel *label;
+
+    switch (op->opc) {
+    case INDEX_op_br:
+        label = arg_label(op->args[0]);
+        label->refs--;
+        break;
+    case INDEX_op_brcond_i32:
+    case INDEX_op_brcond_i64:
+        label = arg_label(op->args[3]);
+        label->refs--;
+        break;
+    case INDEX_op_brcond2_i32:
+        label = arg_label(op->args[5]);
+        label->refs--;
+        break;
+    default:
+        break;
+    }
+
     QTAILQ_REMOVE(&s->ops, op, link);
     QTAILQ_INSERT_TAIL(&s->free_ops, op, link);
     s->nb_ops--;
index 492d8dcf10fbfca1be8652ab35b766a7cefaab28..db2d91867f13d1d3e27ab3d3a38bb0bcfdb9ab0a 100644 (file)
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -244,7 +244,8 @@ typedef struct TCGRelocation {
 
 typedef struct TCGLabel {
     unsigned has_value : 1;
-    unsigned id : 31;
+    unsigned id : 15;
+    unsigned refs : 16;
     union {
         uintptr_t value;
         tcg_insn_unit *value_ptr;