From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKzp4-0007dH-Uw for qemu-devel@nongnu.org; Sat, 14 Sep 2013 20:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKzoy-00011w-2h for qemu-devel@nongnu.org; Sat, 14 Sep 2013 20:04:18 -0400 Received: from mail-pb0-x233.google.com ([2607:f8b0:400e:c01::233]:53032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKzox-00011o-S9 for qemu-devel@nongnu.org; Sat, 14 Sep 2013 20:04:12 -0400 Received: by mail-pb0-f51.google.com with SMTP id jt11so2645683pbb.24 for ; Sat, 14 Sep 2013 17:04:11 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Sat, 14 Sep 2013 17:03:54 -0700 Message-Id: <1379203434-5680-9-git-send-email-rth@twiddle.net> In-Reply-To: <1379203434-5680-1-git-send-email-rth@twiddle.net> References: <1379203434-5680-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 8/8] tcg: Merge tcg_register_helper into tcg_context_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Richard Henderson , aurelien@aurel32.net, sw@weilnetz.de Eliminates the repeated checks for having created the s->helpers hash table. Signed-off-by: Richard Henderson --- 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