+2016-05-06 David Malcolm <dmalcolm@redhat.com>
+
+ * 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.
+
2016-05-06 David Malcolm <dmalcolm@redhat.com>
* genattr-common.c (main): Convert argv from
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;
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<nofree_string_hash, opt_pass *> *m_name_to_pass_map;
/* References to all of the individual passes.
These fields are generated via macro expansion.
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.
while (pass);
}
-static hash_map<nofree_string_hash, opt_pass *> *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<nofree_string_hash, opt_pass *> (256);
+ if (!m_name_to_pass_map)
+ m_name_to_pass_map = new hash_map<nofree_string_hash, opt_pass *> (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. */
/* 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 <void *, passes_pass_traverse> (NULL);
+ pass_tab.safe_grow_cleared (passes_by_id_size + 1);
+ m_name_to_pass_map->traverse <void *, passes_pass_traverse> (NULL);
}
static bool override_gate_status (opt_pass *, tree, bool);
/* 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;
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)