This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Add overload for register_pass
- From: Oleg Endo <oleg dot endo at t-online dot de>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Henderson <rth at redhat dot com>, dmalcolm at redhat dot com
- Date: Sat, 24 Aug 2013 23:33:37 +0200
- Subject: Add overload for register_pass
Hi,
I've been working on a SH specific RTL pass and just adapted it to the
new pass handling. One thing that bugged me was pass registration. How
about adding an overload for 'register_pass' as in the attached patch?
Registering a pass is then as simple as:
register_pass (make_new_ifcvt_sh (g, false, "ifcvt1_sh"),
PASS_POS_INSERT_AFTER, "ce1", 1);
Tested with make all-gcc.
Cheers,
Oleg
gcc/ChangeLog:
* passes.c (register_pass): Add overload.
* tree-pass.h (register_pass): Forward declare it.
Add comment.
Index: gcc/tree-pass.h
===================================================================
--- gcc/tree-pass.h (revision 201967)
+++ gcc/tree-pass.h (working copy)
@@ -91,7 +91,8 @@
virtual opt_pass *clone ();
/* If has_gate is set, this pass and all sub-passes are executed only if
- the function returns true. */
+ the function returns true.
+ The default implementation returns true. */
virtual bool gate ();
/* This is the code to run. If has_execute is false, then there should
@@ -330,6 +331,14 @@
enum pass_positioning_ops pos_op; /* how to insert the new pass. */
};
+/* Registers a new pass. Either fill out the register_pass_info or specify
+ the individual parameters. The pass object is expected to have been
+ allocated using operator new and the pass manager takes the ownership of
+ the pass object. */
+extern void register_pass (register_pass_info *);
+extern void register_pass (opt_pass* pass, pass_positioning_ops pos,
+ const char* ref_pass_name, int ref_pass_inst_number);
+
extern gimple_opt_pass *make_pass_mudflap_1 (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_mudflap_2 (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_asan (gcc::context *ctxt);
@@ -594,7 +603,6 @@
extern void ipa_read_optimization_summaries (void);
extern void register_one_dump_file (struct opt_pass *);
extern bool function_called_by_processed_nodes_p (void);
-extern void register_pass (struct register_pass_info *);
/* Set to true if the pass is called the first time during compilation of the
current function. Note that using this information in the optimization
Index: gcc/passes.c
===================================================================
--- gcc/passes.c (revision 201967)
+++ gcc/passes.c (working copy)
@@ -1365,7 +1365,19 @@
register_pass (struct register_pass_info *pass_info)
{
g->get_passes ()->register_pass (pass_info);
+}
+void
+register_pass (opt_pass* pass, pass_positioning_ops pos,
+ const char* ref_pass_name, int ref_pass_inst_number)
+{
+ register_pass_info i;
+ i.pass = pass;
+ i.reference_pass_name = ref_pass_name;
+ i.ref_pass_instance_number = ref_pass_inst_number;
+ i.pos_op = pos;
+
+ g->get_passes ()->register_pass (&i);
}
void