diff options
author | Grigori Fursin <grigori.fursin@inria.fr> | 2009-12-01 20:12:29 +0100 |
---|---|---|
committer | Joern Rennecke <amylaar@gcc.gnu.org> | 2009-12-01 19:12:29 +0000 |
commit | 090fa0ab610a8735d967f854f2e0e4517a3d3602 (patch) | |
tree | 5cb060dd65f054dc0a5dfd551c6f71e558fcdb9f /gcc/passes.c | |
parent | d0d565e1b0134910f6f5b85e812de0970ea5b60b (diff) | |
download | gcc-090fa0ab610a8735d967f854f2e0e4517a3d3602.zip gcc-090fa0ab610a8735d967f854f2e0e4517a3d3602.tar.gz gcc-090fa0ab610a8735d967f854f2e0e4517a3d3602.tar.bz2 |
cgraphunit.c (plugin.h): Include.
2009-12-01 Grigori Fursin <grigori.fursin@inria.fr>
Joern Rennecke <amylaar@spamcop.net>
* cgraphunit.c (plugin.h): Include.
(ipa_passes): Invoke PLUGIN_ALL_IPA_PASSES_START /
PLUGIN_ALL_IPA_PASSES_END at start / end of processing.
* gcc-plugin.h (highlev-plugin-common.h, hashtab.h): Include.
(enum plugin_event): Define by including plugin.def.
Last enumerator is now called PLUGIN_EVENT_FIRST_DYNAMIC.
(plugin_event_name): Change type to const char **.
(get_event_last, get_named_event_id, unregister_callback): Declare.
(register_callback): Change type of event argument to int.
(highlev-plugin-common.h): New file.
* Makefile.in (GCC_PLUGIN_H): Add highlev-plugin-common.h and
$(HASHTAB_H)
(tree-optimize.o passes.o): Depend on $(PLUGIN_H).
(PLUGIN_HEADERS): Add opts.h, $(PARAMS_H) and plugin.def.
(s-header-vars): New rule.
(install-plugin): Depend on s-header-vars. Install b-header-vars.
* params.c (get_num_compiler_params): New function.
* params.h (get_num_compiler_params): Declare.
* passes.c (plugin.h): Include.
(make_pass_instance): Invoke PLUGIN_NEW_PASS.
(do_per_function_toporder, pass_init_dump_file): No longer static.
(pass_fini_dump_file): Likewise.
(execute_one_pass): Likewise. Invoke PLUGIN_OVERRIDE_GATE and
PLUGIN_PASS_EXECUTION.
(execute_ipa_pass_list): Invoke PLUGIN_EARLY_GIMPLE_PASSES_START and
PLUGIN_EARLY_GIMPLE_PASSES_END.
* plugin.c (plugin_event_name_init): New array, defined by
including plugin.def.
(FMT_FOR_PLUGIN_EVENT): Update.
(plugin_event_name): Change type to const char ** and initialize
to plugin_event_name_init.
(event_tab, event_last, event_horizon): New variable.
(get_event_last): New function.
(plugin_callbacks_init): New array.
(plugin_callbacks: Change type to struct callback_info **.
Initialize to plugin_callbacks_init.
(htab_event_eq, get_named_event_id, unregister_callback): New function.
(invoke_plugin_va_callbacks): Likewise.
(register_callback): Change type of event argument to int.
Handle new events. Allow dynamic events.
(invoke_plugin_callbacks): Likewise. Return success status.
(plugins_active_p): Allow dynamic callbacks.
* plugin.def: New file.
* plugin.h (invoke_plugin_callbacks): Update prototype.
(invoke_plugin_va_callbacks): Declare.
* tree-optimize.c (plugin.h): Include.
(tree_rest_of_compilation): Invoke PLUGIN_ALL_PASSES_START and
PLUGIN_ALL_PASSES_END.
* tree-pass.h (execute_one_pass, pass_init_dump_file): Declare.
(pass_fini_dump_file, do_per_function_toporder): Likewise.
* doc/plugin.texi: Document new event types.
Co-Authored-By: Joern Rennecke <amylaar@spamcop.net>
From-SVN: r154877
Diffstat (limited to 'gcc/passes.c')
-rw-r--r-- | gcc/passes.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/gcc/passes.c b/gcc/passes.c index 57b55c0..818adde 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -85,6 +85,7 @@ along with GCC; see the file COPYING3. If not see #include "df.h" #include "predict.h" #include "lto-streamer.h" +#include "plugin.h" #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO) #include "dwarf2out.h" @@ -104,7 +105,8 @@ along with GCC; see the file COPYING3. If not see #endif /* This is used for debugging. It allows the current pass to printed - from anywhere in compilation. */ + from anywhere in compilation. + The variable current_pass is also used for statistics and plugins. */ struct opt_pass *current_pass; /* Call from anywhere to find out what pass this is. Useful for @@ -479,6 +481,8 @@ make_pass_instance (struct opt_pass *pass, bool track_duplicates) { pass->todo_flags_start |= TODO_mark_first_instance; pass->static_pass_number = -1; + + invoke_plugin_callbacks (PLUGIN_NEW_PASS, pass); } return pass; } @@ -1090,9 +1094,9 @@ static GTY ((length ("nnodes"))) struct cgraph_node **order; /* If we are in IPA mode (i.e., current_function_decl is NULL), call function CALLBACK for every function in the call graph. Otherwise, - call CALLBACK on the current function. */ - -static void + call CALLBACK on the current function. + This function is global so that plugins can use it. */ +void do_per_function_toporder (void (*callback) (void *data), void *data) { int i; @@ -1317,8 +1321,9 @@ verify_curr_properties (void *data) #endif /* Initialize pass dump file. */ +/* This is non-static so that the plugins can use it. */ -static bool +bool pass_init_dump_file (struct opt_pass *pass) { /* If a dump file name is present, open it if enabled. */ @@ -1347,8 +1352,9 @@ pass_init_dump_file (struct opt_pass *pass) } /* Flush PASS dump file. */ +/* This is non-static so that plugins can use it. */ -static void +void pass_fini_dump_file (struct opt_pass *pass) { /* Flush and close dump file. */ @@ -1476,12 +1482,14 @@ execute_all_ipa_transforms (void) /* Execute PASS. */ -static bool +bool execute_one_pass (struct opt_pass *pass) { bool initializing_dump; unsigned int todo_after = 0; + bool gate_status; + /* IPA passes are executed on whole program, so cfun should be NULL. Other passes need function context set. */ if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS) @@ -1491,9 +1499,22 @@ execute_one_pass (struct opt_pass *pass) current_pass = pass; - /* See if we're supposed to run this pass. */ - if (pass->gate && !pass->gate ()) - return false; + /* Check whether gate check should be avoided. + User controls the value of the gate through the parameter "gate_status". */ + gate_status = (pass->gate == NULL) ? true : pass->gate(); + + /* Override gate with plugin. */ + invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE, &gate_status); + + if (!gate_status) + { + current_pass = NULL; + return false; + } + + /* Pass execution event trigger: useful to identify passes being + executed. */ + invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass); if (!quiet_flag && !cfun) fprintf (stderr, " <%s>", pass->name ? pass->name : ""); @@ -1756,8 +1777,12 @@ execute_ipa_pass_list (struct opt_pass *pass) if (execute_one_pass (pass) && pass->sub) { if (pass->sub->type == GIMPLE_PASS) - do_per_function_toporder ((void (*)(void *))execute_pass_list, - pass->sub); + { + invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START, NULL); + do_per_function_toporder ((void (*)(void *))execute_pass_list, + pass->sub); + invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END, NULL); + } else if (pass->sub->type == SIMPLE_IPA_PASS || pass->sub->type == IPA_PASS) execute_ipa_pass_list (pass->sub); |