From cTuning.org
Line 9: | Line 9: | ||
=== Joern's new vision of ICI === | === Joern's new vision of ICI === | ||
- | |||
- | |||
(Step-by-step comparison with old one): | (Step-by-step comparison with old one): | ||
Line 16: | Line 14: | ||
In ipa_passes: | In ipa_passes: | ||
- | < | + | <pre> |
+ static int ici_ipa_passes_substitute_status; | + static int ici_ipa_passes_substitute_status; | ||
+ static int ici_all_ipa_passes = 1; | + static int ici_all_ipa_passes = 1; | ||
Line 38: | Line 36: | ||
... | ... | ||
+ unregister_event_parameter ("bypass_gimple_in_ipa"); | + unregister_event_parameter ("bypass_gimple_in_ipa"); | ||
- | </ | + | </pre> |
In do_per_function_toporder: | In do_per_function_toporder: | ||
- | < | + | <pre> |
+ int *bypass | + int *bypass | ||
+ = (int *) get_event_parameter ("bypass_gimple_in_ipa"); | + = (int *) get_event_parameter ("bypass_gimple_in_ipa"); | ||
Line 50: | Line 48: | ||
+ if (bypass) | + if (bypass) | ||
+ *bypass = 1; | + *bypass = 1; | ||
- | </ | + | </pre> |
In execute_ipa_pass_list: | In execute_ipa_pass_list: | ||
- | < | + | <pre> |
+ int *ici_bypass_gimple_in_ipa; | + int *ici_bypass_gimple_in_ipa; | ||
... | ... | ||
Line 60: | Line 58: | ||
+ if (ici_bypass_gimple_in_ipa) | + if (ici_bypass_gimple_in_ipa) | ||
+ *ici_bypass_gimple_in_ipa = 0; | + *ici_bypass_gimple_in_ipa = 0; | ||
- | </ | + | </pre> |
Other parameters of the "pass_execution" event are similarly manipulated all over GCC. | Other parameters of the "pass_execution" event are similarly manipulated all over GCC. | ||
Line 81: | Line 79: | ||
Now you can manipulate the global variable directly when you want to change it, e.g. in do_per_function_toporder: | Now you can manipulate the global variable directly when you want to change it, e.g. in do_per_function_toporder: | ||
- | < | + | <pre> |
/* Reset bypass_gimple_in_ipa to stop recording GIMPLE passes*/ | /* Reset bypass_gimple_in_ipa to stop recording GIMPLE passes*/ | ||
ici_bypass_gimple_in_ipa = 1; | ici_bypass_gimple_in_ipa = 1; | ||
- | </ | + | </pre> |
At the event raising site, the parameters become explicit: | At the event raising site, the parameters become explicit: | ||
- | < | + | <pre> |
invoke_plugin_va_callbacks (PLUGIN_PASS_EXECUTION, | invoke_plugin_va_callbacks (PLUGIN_PASS_EXECUTION, | ||
"_pass_type", EP_INT, &(pass->type), | "_pass_type", EP_INT, &(pass->type), | ||
Line 93: | Line 91: | ||
"all_passes", EP_SILENT, &ici_all_passes, | "all_passes", EP_SILENT, &ici_all_passes, | ||
"bypass_gimple_in_ipa", EP_SILENT, &ici_bypass_gimple_in_ipa); | "bypass_gimple_in_ipa", EP_SILENT, &ici_bypass_gimple_in_ipa); | ||
- | </ | + | </pre> |
Better yet, remove global plugin variables from GCC proper. | Better yet, remove global plugin variables from GCC proper. |
Revision as of 11:16, 13 November 2009
Moving GCC to mainline ...
Separating ICI into:
- manipulating with passes
- calling events by name
Joern's new vision of ICI
(Step-by-step comparison with old one):
current ICI: registered parameters act as global variables throughout GCC.
In ipa_passes:
+ static int ici_ipa_passes_substitute_status; + static int ici_all_ipa_passes = 1; + static int ici_bypass_gimple_in_ipa = 0; set_cfun (NULL); current_function_decl = NULL; gimple_register_cfg_hooks (); bitmap_obstack_initialize (NULL); - execute_ipa_pass_list (all_ipa_passes); + + /* ICI: parameter all_ipa_pass is valid and set to 1 only + when we execute IPA_PASS or SIMPLE_IPA_PASS. */ + register_event_parameter ("all_ipa_passes", + &ici_all_ipa_passes, + EP_SILENT); + /* ICI: parameter bypass_gimple_in_ipa is used to ensure + GIMPLE subpass of IPA passes are record only once. */ + register_event_parameter ("bypass_gimple_in_ipa", + &ici_bypass_gimple_in_ipa, + EP_SILENT); ... + unregister_event_parameter ("bypass_gimple_in_ipa");
In do_per_function_toporder:
+ int *bypass + = (int *) get_event_parameter ("bypass_gimple_in_ipa"); push_cfun (DECL_STRUCT_FUNCTION (node->decl)); current_function_decl = node->decl; callback (data); + /* Reset bypass_gimple_in_ipa to stop recording GIMPLE passes*/ + if (bypass) + *bypass = 1;
In execute_ipa_pass_list:
+ int *ici_bypass_gimple_in_ipa; ... + ici_bypass_gimple_in_ipa + = (int *) get_event_parameter ("bypass_gimple_in_ipa"); + if (ici_bypass_gimple_in_ipa) + *ici_bypass_gimple_in_ipa = 0;
Other parameters of the "pass_execution" event are similarly manipulated all over GCC.
Proposed: events in gcc proper pass all the parameters in the event call to the low-level ICI plugin, which in turn makes them available to high-level plugins via get_event_parameter. The entire hash-table based event parameter handling lives in the low-level ICI plugin, and is thus invisible in GCC proper.
Example of the usage of ICI going to the mainline
If you really need a global variable in gcc proper, declare it in a header file, probably plugin.h:
extern int ici_bypass_gimple_in_ipa;
and define it in one of the files that manipulate it:
int ici_bypass_gimple_in_ipa;
Note: if your system supports common blocks (which is very likely), for purposes of prototyping you can define the global variable in the header file as long as you don't need an explicit initializer; but when a patch is to be contributed to the GCC mainline, you should only have a declaration in the header file.
Now you can manipulate the global variable directly when you want to change it, e.g. in do_per_function_toporder:
/* Reset bypass_gimple_in_ipa to stop recording GIMPLE passes*/ ici_bypass_gimple_in_ipa = 1;
At the event raising site, the parameters become explicit:
invoke_plugin_va_callbacks (PLUGIN_PASS_EXECUTION, "_pass_type", EP_INT, &(pass->type), "all_ipa_passes", EP_SILENT, &ici_all_ipa_passes, "all_passes", EP_SILENT, &ici_all_passes, "bypass_gimple_in_ipa", EP_SILENT, &ici_bypass_gimple_in_ipa);
Better yet, remove global plugin variables from GCC proper. E.g. you have the all_passes_start and all_passes_end hooks, so you could register / unregister the all_passes parameter in these events' callbacks. Likewise for all_ipa_passes.
Instead of the "bypass_gimple_in_ipa" hack, could we have a plugin event in execute_ipa_pass_list before it calls do_per_function_toporder, which can set a flag for record_pass, which can then reset the flag before it returns.