gccint: Plugins pass
1
1 24.3 Interacting with the pass manager
1 ======================================
1
1 There needs to be a way to add/reorder/remove passes dynamically. This
1 is useful for both analysis plugins (plugging in after a certain pass
1 such as CFG or an IPA pass) and optimization plugins.
1
1 Basic support for inserting new passes or replacing existing passes is
1 provided. A plugin registers a new pass with GCC by calling
1 'register_callback' with the 'PLUGIN_PASS_MANAGER_SETUP' event and a
1 pointer to a 'struct register_pass_info' object defined as follows
1
1 enum pass_positioning_ops
1 {
1 PASS_POS_INSERT_AFTER, // Insert after the reference pass.
1 PASS_POS_INSERT_BEFORE, // Insert before the reference pass.
1 PASS_POS_REPLACE // Replace the reference pass.
1 };
1
1 struct register_pass_info
1 {
1 struct opt_pass *pass; /* New pass provided by the plugin. */
1 const char *reference_pass_name; /* Name of the reference pass for hooking
1 up the new pass. */
1 int ref_pass_instance_number; /* Insert the pass at the specified
1 instance number of the reference pass. */
1 /* Do it for every instance if it is 0. */
1 enum pass_positioning_ops pos_op; /* how to insert the new pass. */
1 };
1
1
1 /* Sample plugin code that registers a new pass. */
1 int
1 plugin_init (struct plugin_name_args *plugin_info,
1 struct plugin_gcc_version *version)
1 {
1 struct register_pass_info pass_info;
1
1 ...
1
1 /* Code to fill in the pass_info object with new pass information. */
1
1 ...
1
1 /* Register the new pass. */
1 register_callback (plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
1
1 ...
1 }
1