Browse Source

Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging

Cleanup sysemu/tcg.h usage.
Fix indirect lowering vs cond branches
Remove ATOMIC_MMU_IDX
Add tcg_constant_ptr

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmJgW38dHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV8tpggApfg2CDI0bRMDBh0g
# 04/xwNnzHuSa84/ocMOMUfD5pvBblUmeTH8fAwqcAPDM/EEZwWZl2V1bYzuIrbmR
# 8zV+r1cOenDF5Tz8PWfy8XssinTVtTWh/TE0XNV9R/SbEM9eMsjHNu5osKVuLuq1
# rnHWZf8LuY7xGsy4GYqPN0dLE6HtQOfpj/eLGRAj9mZ7re0jKeWg3GdxYoiYDmks
# NKmNHYcWD+SjjFvXlOafniQsHbBZmQc/qp7AShG/+VcYY9o1VfncWD6I2dV13RdB
# N7++ZhGyQR4NOVo6CN1zLKhfuJqzH2q+qJ7vQ3xtXNAk53LGQ91zjoE+3KaJTrcy
# dmnLUw==
# =aKdS
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 20 Apr 2022 12:14:07 PM PDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu:
  tcg: Add tcg_constant_ptr
  accel/tcg: Remove ATOMIC_MMU_IDX
  tcg: Fix indirect lowering vs TCG_OPF_COND_BRANCH
  Don't include sysemu/tcg.h if it is not necessary

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Richard Henderson 3 years ago
parent
commit
9c125d17e9

+ 0 - 1
accel/tcg/cputlb.c

@@ -2552,7 +2552,6 @@ void cpu_stq_le_mmu(CPUArchState *env, target_ulong addr, uint64_t val,
     glue(glue(glue(cpu_atomic_ ## X, SUFFIX), END), _mmu)
     glue(glue(glue(cpu_atomic_ ## X, SUFFIX), END), _mmu)
 
 
 #define ATOMIC_MMU_CLEANUP
 #define ATOMIC_MMU_CLEANUP
-#define ATOMIC_MMU_IDX   get_mmuidx(oi)
 
 
 #include "atomic_common.c.inc"
 #include "atomic_common.c.inc"
 
 

+ 0 - 1
accel/tcg/hmp.c

@@ -4,7 +4,6 @@
 #include "qapi/qapi-commands-machine.h"
 #include "qapi/qapi-commands-machine.h"
 #include "exec/exec-all.h"
 #include "exec/exec-all.h"
 #include "monitor/monitor.h"
 #include "monitor/monitor.h"
-#include "sysemu/tcg.h"
 
 
 static void hmp_tcg_register(void)
 static void hmp_tcg_register(void)
 {
 {

+ 0 - 1
accel/tcg/tcg-accel-ops-icount.c

@@ -24,7 +24,6 @@
  */
  */
 
 
 #include "qemu/osdep.h"
 #include "qemu/osdep.h"
-#include "sysemu/tcg.h"
 #include "sysemu/replay.h"
 #include "sysemu/replay.h"
 #include "sysemu/cpu-timers.h"
 #include "sysemu/cpu-timers.h"
 #include "qemu/main-loop.h"
 #include "qemu/main-loop.h"

+ 0 - 1
accel/tcg/user-exec.c

@@ -506,7 +506,6 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
 #define ATOMIC_NAME(X) \
 #define ATOMIC_NAME(X) \
     glue(glue(glue(cpu_atomic_ ## X, SUFFIX), END), _mmu)
     glue(glue(glue(cpu_atomic_ ## X, SUFFIX), END), _mmu)
 #define ATOMIC_MMU_CLEANUP do { clear_helper_retaddr(); } while (0)
 #define ATOMIC_MMU_CLEANUP do { clear_helper_retaddr(); } while (0)
-#define ATOMIC_MMU_IDX MMU_USER_IDX
 
 
 #define DATA_SIZE 1
 #define DATA_SIZE 1
 #include "atomic_template.h"
 #include "atomic_template.h"

+ 0 - 1
bsd-user/main.c

@@ -27,7 +27,6 @@
 #include "qemu-common.h"
 #include "qemu-common.h"
 #include "qemu/units.h"
 #include "qemu/units.h"
 #include "qemu/accel.h"
 #include "qemu/accel.h"
-#include "sysemu/tcg.h"
 #include "qemu-version.h"
 #include "qemu-version.h"
 #include <machine/trap.h>
 #include <machine/trap.h>
 
 

+ 0 - 1
hw/virtio/vhost.c

@@ -26,7 +26,6 @@
 #include "migration/blocker.h"
 #include "migration/blocker.h"
 #include "migration/qemu-file-types.h"
 #include "migration/qemu-file-types.h"
 #include "sysemu/dma.h"
 #include "sysemu/dma.h"
-#include "sysemu/tcg.h"
 #include "trace.h"
 #include "trace.h"
 
 
 /* enabled until disconnected backend stabilizes */
 /* enabled until disconnected backend stabilizes */

+ 4 - 0
include/tcg/tcg.h

@@ -433,6 +433,8 @@ typedef enum TCGTempVal {
 typedef enum TCGTempKind {
 typedef enum TCGTempKind {
     /* Temp is dead at the end of all basic blocks. */
     /* Temp is dead at the end of all basic blocks. */
     TEMP_NORMAL,
     TEMP_NORMAL,
+    /* Temp is live across conditional branch, but dead otherwise. */
+    TEMP_EBB,
     /* Temp is saved across basic blocks but dead at the end of TBs. */
     /* Temp is saved across basic blocks but dead at the end of TBs. */
     TEMP_LOCAL,
     TEMP_LOCAL,
     /* Temp is saved across both basic blocks and translation blocks. */
     /* Temp is saved across both basic blocks and translation blocks. */
@@ -1054,9 +1056,11 @@ TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val);
 #if UINTPTR_MAX == UINT32_MAX
 #if UINTPTR_MAX == UINT32_MAX
 # define tcg_const_ptr(x)        ((TCGv_ptr)tcg_const_i32((intptr_t)(x)))
 # define tcg_const_ptr(x)        ((TCGv_ptr)tcg_const_i32((intptr_t)(x)))
 # define tcg_const_local_ptr(x)  ((TCGv_ptr)tcg_const_local_i32((intptr_t)(x)))
 # define tcg_const_local_ptr(x)  ((TCGv_ptr)tcg_const_local_i32((intptr_t)(x)))
+# define tcg_constant_ptr(x)     ((TCGv_ptr)tcg_constant_i32((intptr_t)(x)))
 #else
 #else
 # define tcg_const_ptr(x)        ((TCGv_ptr)tcg_const_i64((intptr_t)(x)))
 # define tcg_const_ptr(x)        ((TCGv_ptr)tcg_const_i64((intptr_t)(x)))
 # define tcg_const_local_ptr(x)  ((TCGv_ptr)tcg_const_local_i64((intptr_t)(x)))
 # define tcg_const_local_ptr(x)  ((TCGv_ptr)tcg_const_local_i64((intptr_t)(x)))
+# define tcg_constant_ptr(x)     ((TCGv_ptr)tcg_constant_i64((intptr_t)(x)))
 #endif
 #endif
 
 
 TCGLabel *gen_new_label(void);
 TCGLabel *gen_new_label(void);

+ 0 - 1
linux-user/main.c

@@ -21,7 +21,6 @@
 #include "qemu-common.h"
 #include "qemu-common.h"
 #include "qemu/units.h"
 #include "qemu/units.h"
 #include "qemu/accel.h"
 #include "qemu/accel.h"
-#include "sysemu/tcg.h"
 #include "qemu-version.h"
 #include "qemu-version.h"
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 #include <sys/resource.h>
 #include <sys/resource.h>

+ 0 - 1
monitor/misc.c

@@ -48,7 +48,6 @@
 #include "qapi/util.h"
 #include "qapi/util.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/sysemu.h"
-#include "sysemu/tcg.h"
 #include "sysemu/tpm.h"
 #include "sysemu/tpm.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qerror.h"

+ 0 - 1
target/arm/helper.c

@@ -27,7 +27,6 @@
 #include "sysemu/cpus.h"
 #include "sysemu/cpus.h"
 #include "sysemu/cpu-timers.h"
 #include "sysemu/cpu-timers.h"
 #include "sysemu/kvm.h"
 #include "sysemu/kvm.h"
-#include "sysemu/tcg.h"
 #include "qemu/range.h"
 #include "qemu/range.h"
 #include "qapi/qapi-commands-machine-target.h"
 #include "qapi/qapi-commands-machine-target.h"
 #include "qapi/error.h"
 #include "qapi/error.h"

+ 0 - 1
target/s390x/cpu_models_sysemu.c

@@ -15,7 +15,6 @@
 #include "s390x-internal.h"
 #include "s390x-internal.h"
 #include "kvm/kvm_s390x.h"
 #include "kvm/kvm_s390x.h"
 #include "sysemu/kvm.h"
 #include "sysemu/kvm.h"
-#include "sysemu/tcg.h"
 #include "qapi/error.h"
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "qapi/visitor.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qerror.h"

+ 0 - 1
target/s390x/helper.c

@@ -27,7 +27,6 @@
 #include "hw/s390x/pv.h"
 #include "hw/s390x/pv.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/runstate.h"
 #include "sysemu/runstate.h"
-#include "sysemu/tcg.h"
 
 
 void s390x_tod_timer(void *opaque)
 void s390x_tod_timer(void *opaque)
 {
 {

+ 27 - 7
tcg/tcg.c

@@ -1027,9 +1027,18 @@ void tcg_temp_free_internal(TCGTemp *ts)
     TCGContext *s = tcg_ctx;
     TCGContext *s = tcg_ctx;
     int k, idx;
     int k, idx;
 
 
-    /* In order to simplify users of tcg_constant_*, silently ignore free. */
-    if (ts->kind == TEMP_CONST) {
+    switch (ts->kind) {
+    case TEMP_CONST:
+        /*
+         * In order to simplify users of tcg_constant_*,
+         * silently ignore free.
+         */
         return;
         return;
+    case TEMP_NORMAL:
+    case TEMP_LOCAL:
+        break;
+    default:
+        g_assert_not_reached();
     }
     }
 
 
 #if defined(CONFIG_DEBUG_TCG)
 #if defined(CONFIG_DEBUG_TCG)
@@ -1039,7 +1048,6 @@ void tcg_temp_free_internal(TCGTemp *ts)
     }
     }
 #endif
 #endif
 
 
-    tcg_debug_assert(ts->kind < TEMP_GLOBAL);
     tcg_debug_assert(ts->temp_allocated != 0);
     tcg_debug_assert(ts->temp_allocated != 0);
     ts->temp_allocated = 0;
     ts->temp_allocated = 0;
 
 
@@ -1677,6 +1685,7 @@ static void tcg_reg_alloc_start(TCGContext *s)
         case TEMP_GLOBAL:
         case TEMP_GLOBAL:
             break;
             break;
         case TEMP_NORMAL:
         case TEMP_NORMAL:
+        case TEMP_EBB:
             val = TEMP_VAL_DEAD;
             val = TEMP_VAL_DEAD;
             /* fall through */
             /* fall through */
         case TEMP_LOCAL:
         case TEMP_LOCAL:
@@ -1704,6 +1713,9 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, int buf_size,
     case TEMP_LOCAL:
     case TEMP_LOCAL:
         snprintf(buf, buf_size, "loc%d", idx - s->nb_globals);
         snprintf(buf, buf_size, "loc%d", idx - s->nb_globals);
         break;
         break;
+    case TEMP_EBB:
+        snprintf(buf, buf_size, "ebb%d", idx - s->nb_globals);
+        break;
     case TEMP_NORMAL:
     case TEMP_NORMAL:
         snprintf(buf, buf_size, "tmp%d", idx - s->nb_globals);
         snprintf(buf, buf_size, "tmp%d", idx - s->nb_globals);
         break;
         break;
@@ -2376,6 +2388,7 @@ static void la_bb_end(TCGContext *s, int ng, int nt)
             state = TS_DEAD | TS_MEM;
             state = TS_DEAD | TS_MEM;
             break;
             break;
         case TEMP_NORMAL:
         case TEMP_NORMAL:
+        case TEMP_EBB:
         case TEMP_CONST:
         case TEMP_CONST:
             state = TS_DEAD;
             state = TS_DEAD;
             break;
             break;
@@ -2403,8 +2416,9 @@ static void la_global_sync(TCGContext *s, int ng)
 }
 }
 
 
 /*
 /*
- * liveness analysis: conditional branch: all temps are dead,
- * globals and local temps should be synced.
+ * liveness analysis: conditional branch: all temps are dead unless
+ * explicitly live-across-conditional-branch, globals and local temps
+ * should be synced.
  */
  */
 static void la_bb_sync(TCGContext *s, int ng, int nt)
 static void la_bb_sync(TCGContext *s, int ng, int nt)
 {
 {
@@ -2425,6 +2439,7 @@ static void la_bb_sync(TCGContext *s, int ng, int nt)
         case TEMP_NORMAL:
         case TEMP_NORMAL:
             s->temps[i].state = TS_DEAD;
             s->temps[i].state = TS_DEAD;
             break;
             break;
+        case TEMP_EBB:
         case TEMP_CONST:
         case TEMP_CONST:
             continue;
             continue;
         default:
         default:
@@ -2795,6 +2810,7 @@ static bool liveness_pass_2(TCGContext *s)
             TCGTemp *dts = tcg_temp_alloc(s);
             TCGTemp *dts = tcg_temp_alloc(s);
             dts->type = its->type;
             dts->type = its->type;
             dts->base_type = its->base_type;
             dts->base_type = its->base_type;
+            dts->kind = TEMP_EBB;
             its->state_ptr = dts;
             its->state_ptr = dts;
         } else {
         } else {
             its->state_ptr = NULL;
             its->state_ptr = NULL;
@@ -3105,6 +3121,7 @@ static void temp_free_or_dead(TCGContext *s, TCGTemp *ts, int free_or_dead)
         new_type = TEMP_VAL_MEM;
         new_type = TEMP_VAL_MEM;
         break;
         break;
     case TEMP_NORMAL:
     case TEMP_NORMAL:
+    case TEMP_EBB:
         new_type = free_or_dead < 0 ? TEMP_VAL_MEM : TEMP_VAL_DEAD;
         new_type = free_or_dead < 0 ? TEMP_VAL_MEM : TEMP_VAL_DEAD;
         break;
         break;
     case TEMP_CONST:
     case TEMP_CONST:
@@ -3351,6 +3368,7 @@ static void tcg_reg_alloc_bb_end(TCGContext *s, TCGRegSet allocated_regs)
             temp_save(s, ts, allocated_regs);
             temp_save(s, ts, allocated_regs);
             break;
             break;
         case TEMP_NORMAL:
         case TEMP_NORMAL:
+        case TEMP_EBB:
             /* The liveness analysis already ensures that temps are dead.
             /* The liveness analysis already ensures that temps are dead.
                Keep an tcg_debug_assert for safety. */
                Keep an tcg_debug_assert for safety. */
             tcg_debug_assert(ts->val_type == TEMP_VAL_DEAD);
             tcg_debug_assert(ts->val_type == TEMP_VAL_DEAD);
@@ -3368,8 +3386,9 @@ static void tcg_reg_alloc_bb_end(TCGContext *s, TCGRegSet allocated_regs)
 }
 }
 
 
 /*
 /*
- * At a conditional branch, we assume all temporaries are dead and
- * all globals and local temps are synced to their location.
+ * At a conditional branch, we assume all temporaries are dead unless
+ * explicitly live-across-conditional-branch; all globals and local
+ * temps are synced to their location.
  */
  */
 static void tcg_reg_alloc_cbranch(TCGContext *s, TCGRegSet allocated_regs)
 static void tcg_reg_alloc_cbranch(TCGContext *s, TCGRegSet allocated_regs)
 {
 {
@@ -3388,6 +3407,7 @@ static void tcg_reg_alloc_cbranch(TCGContext *s, TCGRegSet allocated_regs)
         case TEMP_NORMAL:
         case TEMP_NORMAL:
             tcg_debug_assert(ts->val_type == TEMP_VAL_DEAD);
             tcg_debug_assert(ts->val_type == TEMP_VAL_DEAD);
             break;
             break;
+        case TEMP_EBB:
         case TEMP_CONST:
         case TEMP_CONST:
             break;
             break;
         default:
         default: