diff mbox

[RFC,01/14] tcg: Use NULL for TCGV_UNUSED_*

Message ID 1479325910-9060-2-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Nov. 16, 2016, 7:51 p.m. UTC
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/tcg.c |  6 +++++-
 tcg/tcg.h | 12 ++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)
diff mbox

Patch

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