From patchwork Wed May 4 20:49:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 618646 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r0V082nBYz9sdg for ; Thu, 5 May 2016 06:25:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=XyymhbuT; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=unZJMoh1frocLwQl437bwZ8Y6L7xCTnJI9r3y9wZ/D/1ZhgHmEx4c iVPbnK1/LAuiUkjPfvPIVXmx5ii5SyvXQHGOQfLCsAtuxp8n5xIbF61ttD9tiZpH fw+6o6jEz8D9Ai1sz2KVJimtjdXm9vrvl0BeFTM9DGIEMulAl9ZTzM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=AikHwSLtySP+EPay2wNBm3+8jg8=; b=XyymhbuTtUtQU5/c7YG9 vjM33uZtPbjSOmwj13r20YaRHA6Vyi1B+5fkCRyFkYoUsWQcYr5vqCO/4HmnITLz Au3qyC0OEjZw5o3FnFBJzHxYHvSw+oHYaGczCfwyX0hmynVAyntJa6qezv16N0sT pIffPxDd6ZlioV1ik5l5Se8= Received: (qmail 43553 invoked by alias); 4 May 2016 20:24:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 43421 invoked by uid 89); 4 May 2016 20:24:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=locating, 87814, pass_managerh, UD:pass_manager.h X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 04 May 2016 20:24:40 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42C8B811A2 for ; Wed, 4 May 2016 20:24:39 +0000 (UTC) Received: from c64.redhat.com (vpn-235-122.phx2.redhat.com [10.3.235.122]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u44KOb8Z013500; Wed, 4 May 2016 16:24:38 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 2/4] Move name_to_pass_map into class pass_manager Date: Wed, 4 May 2016 16:49:28 -0400 Message-Id: <1462394970-55471-3-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1462394970-55471-1-git-send-email-dmalcolm@redhat.com> References: <1462394970-55471-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes The RTL frontend needs to be able to lookup passes by name. passes.c has global state name_to_pass_map (albeit static, scoped to passes.c), for use by enable_disable_pass. Move it to be a field of class pass_manager, and add a get_pass_by_name method. OK for trunk? gcc/ChangeLog: * pass_manager.h (pass_manager::register_pass_name): New method. (pass_manager::get_pass_by_name): New method. (pass_manager::create_pass_tab): New method. (pass_manager::m_name_to_pass_map): New field. * passes.c (name_to_pass_map): Delete global in favor of field "m_name_to_pass_map" of pass_manager. (register_pass_name): Rename from a function to... (pass_manager::register_pass_name): ...this method, updating for renaming of global "name_to_pass_map" to field "m_name_to_pass_map". (create_pass_tab): Rename from a function to... (pass_manager::create_pass_tab): ...this method, updating for renaming of global "name_to_pass_map" to field. (get_pass_by_name): Rename from a function to... (pass_manager::get_pass_by_name): ...this method. (enable_disable_pass): Convert use of get_pass_by_name to a method call, locating the pass_manager singleton. --- gcc/pass_manager.h | 6 ++++++ gcc/passes.c | 34 +++++++++++++++------------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/gcc/pass_manager.h b/gcc/pass_manager.h index 4f89d31..464e25f 100644 --- a/gcc/pass_manager.h +++ b/gcc/pass_manager.h @@ -78,6 +78,10 @@ public: opt_pass *get_pass_peephole2 () const { return pass_peephole2_1; } opt_pass *get_pass_profile () const { return pass_profile_1; } + void register_pass_name (opt_pass *pass, const char *name); + + opt_pass *get_pass_by_name (const char *name); + public: /* The root of the compilation pass tree, once constructed. */ opt_pass *all_passes; @@ -95,9 +99,11 @@ public: private: void set_pass_for_id (int id, opt_pass *pass); void register_dump_files (opt_pass *pass); + void create_pass_tab () const; private: context *m_ctxt; + hash_map *m_name_to_pass_map; /* References to all of the individual passes. These fields are generated via macro expansion. diff --git a/gcc/passes.c b/gcc/passes.c index 2b70846..0565cfa 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -66,8 +66,6 @@ using namespace gcc; The variable current_pass is also used for statistics and plugins. */ opt_pass *current_pass; -static void register_pass_name (opt_pass *, const char *); - /* Most passes are single-instance (within their context) and thus don't need to implement cloning, but passes that support multiple instances *must* provide their own implementation of the clone method. @@ -844,21 +842,19 @@ pass_manager::register_dump_files (opt_pass *pass) while (pass); } -static hash_map *name_to_pass_map; - /* Register PASS with NAME. */ -static void -register_pass_name (opt_pass *pass, const char *name) +void +pass_manager::register_pass_name (opt_pass *pass, const char *name) { - if (!name_to_pass_map) - name_to_pass_map = new hash_map (256); + if (!m_name_to_pass_map) + m_name_to_pass_map = new hash_map (256); - if (name_to_pass_map->get (name)) + if (m_name_to_pass_map->get (name)) return; /* Ignore plugin passes. */ - const char *unique_name = xstrdup (name); - name_to_pass_map->put (unique_name, pass); + const char *unique_name = xstrdup (name); + m_name_to_pass_map->put (unique_name, pass); } /* Map from pass id to canonicalized pass name. */ @@ -882,14 +878,14 @@ passes_pass_traverse (const char *const &name, opt_pass *const &pass, void *) /* The function traverses NAME_TO_PASS_MAP and creates a pass info table for dumping purpose. */ -static void -create_pass_tab (void) +void +pass_manager::create_pass_tab (void) const { if (!flag_dump_passes) return; - pass_tab.safe_grow_cleared (g->get_passes ()->passes_by_id_size + 1); - name_to_pass_map->traverse (NULL); + pass_tab.safe_grow_cleared (passes_by_id_size + 1); + m_name_to_pass_map->traverse (NULL); } static bool override_gate_status (opt_pass *, tree, bool); @@ -960,10 +956,10 @@ pass_manager::dump_passes () const /* Returns the pass with NAME. */ -static opt_pass * -get_pass_by_name (const char *name) +opt_pass * +pass_manager::get_pass_by_name (const char *name) { - opt_pass **p = name_to_pass_map->get (name); + opt_pass **p = m_name_to_pass_map->get (name); if (p) return *p; @@ -1025,7 +1021,7 @@ enable_disable_pass (const char *arg, bool is_enable) free (argstr); return; } - pass = get_pass_by_name (phase_name); + pass = g->get_passes ()->get_pass_by_name (phase_name); if (!pass || pass->static_pass_number == -1) { if (is_enable)