From patchwork Sun Sep 15 00:03:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 274997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 52BC52C00C5 for ; Sun, 15 Sep 2013 10:08:59 +1000 (EST) Received: from localhost ([::1]:55000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKztZ-0005t8-AN for incoming@patchwork.ozlabs.org; Sat, 14 Sep 2013 20:08:57 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=HhvZws9jFl18npp5z7l7J5sCSFyATXR31fsj9n2Q3Ao=; b=p1aLaYh4sTKrluFhRwveXuHed6q1TNzUnJdbMKOQCdDkC2201s4iQOsuA8TENrmALn Tf2VHisRdqZI84mkm9fSr23hetRDzYT8ulm0G04t5OSyuGxrOLL+rPFlUKHZw8D1d9rD hZAfV5SWNjLysWJxywi8Jm5OJPVvCK0UjNwylKfQfTMxgIMXL6hPBsdXzvBiEKja2HrH XkLjQ5c2dOCjSEqMed9KPyO2mQnpbQprn+iBvC5mDF5WN7hHVSSSCxU64c2KCFzUW1ia OBBhiU0tEHLZvsH4i+T/dtVH+WzaFkCDf9yLkEHFfPdhEqZLNpLlMx/t32WuGTwpvGHv c1KA== X-Received: by 10.66.26.112 with SMTP id k16mr22761076pag.65.1379203450979; Sat, 14 Sep 2013 17:04:10 -0700 (PDT) Received: from anchor.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id vz4sm27763065pab.11.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 14 Sep 2013 17:04:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 14 Sep 2013 17:03:54 -0700 Message-Id: <1379203434-5680-9-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1379203434-5680-1-git-send-email-rth@twiddle.net> References: <1379203434-5680-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::233 Cc: peter.maydell@linaro.org, Richard Henderson , aurelien@aurel32.net, sw@weilnetz.de Subject: [Qemu-devel] [PATCH 8/8] tcg: Merge tcg_register_helper into tcg_context_init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);