From 3a1a7e909481e3ddbaea54e3825aeded9e984624 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 11 Apr 2016 11:32:00 -0400 Subject: [PATCH 56/71] FIXME: move name_to_pass_map into class pass_manager --- gcc/pass_manager.h | 7 ++++++- gcc/passes.c | 34 +++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/gcc/pass_manager.h b/gcc/pass_manager.h index 04dc7a1..942a1b4 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,11 +99,12 @@ 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; - public: /* 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 1bf89ed..ca8e368 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. @@ -845,21 +843,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. */ @@ -883,14 +879,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); @@ -961,10 +957,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; @@ -1026,7 +1022,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) -- 1.8.5.3