All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Richard Henderson <rth@twiddle.net>,
	aurelien@aurel32.net, sw@weilnetz.de
Subject: [Qemu-devel] [PATCH 8/8] tcg: Merge tcg_register_helper into tcg_context_init
Date: Sat, 14 Sep 2013 17:03:54 -0700	[thread overview]
Message-ID: <1379203434-5680-9-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1379203434-5680-1-git-send-email-rth@twiddle.net>

Eliminates the repeated checks for having created
the s->helpers hash table.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/tcg.c | 21 ++++++---------------
 tcg/tcg.h |  1 -
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/tcg/tcg.c b/tcg/tcg.c
index bf4edfd..f401044 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -288,6 +288,7 @@ void tcg_context_init(TCGContext *s)
     TCGOpDef *def;
     TCGArgConstraint *args_ct;
     int *sorted_args;
+    GHashTable *helper_table;
 
     memset(s, 0, sizeof(*s));
     s->nb_globals = 0;
@@ -314,8 +315,12 @@ void tcg_context_init(TCGContext *s)
     }
 
     /* Register helpers.  */
+    /* Use g_direct_hash/equal for direct pointer comparisons on func.  */
+    s->helpers = helper_table = g_hash_table_new(NULL, NULL);
+
     for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) {
-        tcg_register_helper(all_helpers[i].func, all_helpers[i].name);
+        g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func,
+                            (gpointer)all_helpers[i].name);
     }
 
     tcg_target_init(s);
@@ -653,20 +658,6 @@ int tcg_check_temp_count(void)
 }
 #endif
 
-void tcg_register_helper(void *func, const char *name)
-{
-    TCGContext *s = &tcg_ctx;
-    GHashTable *table = s->helpers;
-
-    if (table == NULL) {
-        /* Use g_direct_hash/equal for direct pointer comparisons on func.  */
-        table = g_hash_table_new(NULL, NULL);
-        s->helpers = table;
-    }
-
-    g_hash_table_insert(table, (gpointer)func, (gpointer)name);
-}
-
 /* Note: we convert the 64 bit args to 32 bit and do some alignment
    and endian swap. Maybe it would be better to do the alignment
    and endian swap in tcg_reg_alloc_call(). */
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 8c5eb42..f67fdb6 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -672,7 +672,6 @@ TCGArg *tcg_optimize(TCGContext *s, uint16_t *tcg_opc_ptr, TCGArg *args,
                      TCGOpDef *tcg_op_def);
 
 /* only used for debugging purposes */
-void tcg_register_helper(void *func, const char *name);
 void tcg_dump_ops(TCGContext *s);
 
 void dump_ops(const uint16_t *opc_buf, const TCGArg *opparam_buf);
-- 
1.8.1.4

      parent reply	other threads:[~2013-09-15  0:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-15  0:03 [Qemu-devel] [PATCH 0/8] tcg: Tidy helpers registration Richard Henderson
2013-09-15  0:03 ` [Qemu-devel] [PATCH 1/8] tcg: Delete tcg_helper_get_name declaration Richard Henderson
2013-09-15  6:14   ` Stefan Weil
2013-09-15  0:03 ` [Qemu-devel] [PATCH 2/8] tcg: Use a GHashTable for tcg_find_helper Richard Henderson
2013-09-15  6:32   ` Stefan Weil
2013-09-15  0:03 ` [Qemu-devel] [PATCH 3/8] target-m68k: Rename helpers.h to helper.h Richard Henderson
2013-09-15  6:35   ` Stefan Weil
2013-09-15  0:03 ` [Qemu-devel] [PATCH 4/8] tcg: Move helper registration into tcg_context_init Richard Henderson
2013-09-15  0:03 ` [Qemu-devel] [PATCH 5/8] tcg: Remove stray semi-colons from target-*/helper.h Richard Henderson
2013-09-15  7:03   ` Stefan Weil
2013-09-15 10:44     ` Peter Maydell
2013-09-15  0:03 ` [Qemu-devel] [PATCH 6/8] tcg: Put target helper data into an array Richard Henderson
2013-09-15  0:03 ` [Qemu-devel] [PATCH 7/8] tcg: Add tcg-runtime.c helpers to all_helpers Richard Henderson
2013-09-15  0:03 ` Richard Henderson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379203434-5680-9-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=aurelien@aurel32.net \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.