qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC 01/14] tcg: Use NULL for TCGV_UNUSED_*


From: Richard Henderson
Subject: [Qemu-devel] [RFC 01/14] tcg: Use NULL for TCGV_UNUSED_*
Date: Wed, 16 Nov 2016 20:51:37 +0100

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

diff --git a/tcg/tcg.c b/tcg/tcg.c
index aabf94f..057c1ea 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -329,7 +329,11 @@ void tcg_context_init(TCGContext *s)
     GHashTable *helper_table;
 
     memset(s, 0, sizeof(*s));
-    s->nb_globals = 0;
+
+    /* Reserve global 0 so that, when foxing these integrals
+       as pointers, NULL is unused.  */
+    s->nb_globals = 1;
+    s->nb_temps = 1;
 
     /* Count total number of arguments and allocate the corresponding
        space */
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 5fd3733..b2cdaff 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -467,13 +467,13 @@ static inline intptr_t QEMU_ARTIFICIAL 
GET_TCGV_PTR(TCGv_ptr t)
 #define TCGV_EQUAL_PTR(a, b) (GET_TCGV_PTR(a) == GET_TCGV_PTR(b))
 
 /* Dummy definition to avoid compiler warnings.  */
-#define TCGV_UNUSED_I32(x) x = MAKE_TCGV_I32(-1)
-#define TCGV_UNUSED_I64(x) x = MAKE_TCGV_I64(-1)
-#define TCGV_UNUSED_PTR(x) x = MAKE_TCGV_PTR(-1)
+#define TCGV_UNUSED_I32(x) x = NULL
+#define TCGV_UNUSED_I64(x) x = NULL
+#define TCGV_UNUSED_PTR(x) x = NULL
 
-#define TCGV_IS_UNUSED_I32(x) (GET_TCGV_I32(x) == -1)
-#define TCGV_IS_UNUSED_I64(x) (GET_TCGV_I64(x) == -1)
-#define TCGV_IS_UNUSED_PTR(x) (GET_TCGV_PTR(x) == -1)
+#define TCGV_IS_UNUSED_I32(x) ((x) == NULL)
+#define TCGV_IS_UNUSED_I64(x) ((x) == NULL)
+#define TCGV_IS_UNUSED_PTR(x) ((x) == NULL)
 
 /* call flags */
 /* Helper does not read globals (either directly or through an exception). It
-- 
2.7.4




reply via email to

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