qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 04/14] tcg: Add temp_global bit to TCGTemp


From: Richard Henderson
Subject: [Qemu-devel] [RFC 04/14] tcg: Add temp_global bit to TCGTemp
Date: Wed, 16 Nov 2016 20:51:40 +0100

This avoids needing to test the index of a temp against nb_globals.

Signed-off-by: Richard Henderson <address@hidden>
---
 tcg/tcg.c | 12 +++++++++---
 tcg/tcg.h | 12 ++++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/tcg/tcg.c b/tcg/tcg.c
index 8ae41a6..b186b38 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -458,9 +458,14 @@ static inline TCGTemp *tcg_temp_alloc(TCGContext *s)
 
 static inline TCGTemp *tcg_global_alloc(TCGContext *s)
 {
+    TCGTemp *ts;
+
     tcg_debug_assert(s->nb_globals == s->nb_temps);
     s->nb_globals++;
-    return tcg_temp_alloc(s);
+    ts = tcg_temp_alloc(s);
+    ts->temp_global = 1;
+
+    return ts;
 }
 
 static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type,
@@ -906,7 +911,7 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, 
int buf_size,
 {
     int idx = temp_idx(ts);
 
-    if (idx < s->nb_globals) {
+    if (ts->temp_global) {
         pstrcpy(buf, buf_size, ts->name);
     } else if (ts->temp_local) {
         snprintf(buf, buf_size, "loc%d", idx - s->nb_globals);
@@ -1718,6 +1723,7 @@ static bool liveness_pass_2(TCGContext *s)
            so that we reload when needed.  */
         for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) {
             arg_idx = arg_index(args[i]);
+            /* Note this unsigned test catches TCG_CALL_ARG_DUMMY too.  */
             if (arg_idx < nb_globals) {
                 arg_ts = arg_temp(args[i]);
                 dir_ts = arg_ts->state_ptr;
@@ -1900,7 +1906,7 @@ static void temp_free_or_dead(TCGContext *s, TCGTemp *ts, 
int free_or_dead)
     }
     ts->val_type = (free_or_dead < 0
                     || ts->temp_local
-                    || temp_idx(ts) < s->nb_globals
+                    || ts->temp_global
                     ? TEMP_VAL_MEM : TEMP_VAL_DEAD);
 }
 
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 723e06f..dbd6308 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -401,10 +401,14 @@ typedef struct TCGTemp {
     unsigned int indirect_base:1;
     unsigned int mem_coherent:1;
     unsigned int mem_allocated:1;
-    unsigned int temp_local:1; /* If true, the temp is saved across
-                                  basic blocks. Otherwise, it is not
-                                  preserved across basic blocks. */
-    unsigned int temp_allocated:1; /* never used for code gen */
+    /* If true, the temp is saved across both basic blocks and
+       translation blocks.  */
+    unsigned int temp_global:1;
+    /* If true, the temp is saved across basic blocks but dead
+       at the end of translation blocks.  If false, the temp is
+       dead at the end of basic blocks.  */
+    unsigned int temp_local:1;
+    unsigned int temp_allocated:1;
 
     tcg_target_long val;
     struct TCGTemp *mem_base;
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]