diff mbox

[avr] Use avr-passes.def to register passes.

Message ID fb85bbac-7b07-6477-4a55-68ca0b1f6de7@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay Oct. 10, 2016, 1:36 p.m. UTC
This is a code clean-up using the new <target>-passes.def feature in order to 
register avr target passes and to get -fdump-xxx etc. to work for such passes.

Ok for trunk?

Johann

	* config/avr/avr-passes.def: New file.
	* config/avr/t-avr (PASSES_EXTRA): Add avr-passes.def.
	* config/avr/avr-protos.h (gcc::context, rtl_opt_pass): Declare.
	(make_avr_pass_recompute_note): New proto.
	* config/avr/avr.c (make_avr_pass_recompute_notes): New function.
	(avr_pass_recompute_notes): Use anonymous namespace.
	(avr_register_passes): Remove function...
	(avr_option_override): ...and its call.

Comments

Denis Chertykov Oct. 11, 2016, 7:10 a.m. UTC | #1
2016-10-10 16:36 GMT+03:00 Georg-Johann Lay <avr@gjlay.de>:
> This is a code clean-up using the new <target>-passes.def feature in order
> to register avr target passes and to get -fdump-xxx etc. to work for such
> passes.
>
> Ok for trunk?
>
> Johann
>
>         * config/avr/avr-passes.def: New file.
>         * config/avr/t-avr (PASSES_EXTRA): Add avr-passes.def.
>         * config/avr/avr-protos.h (gcc::context, rtl_opt_pass): Declare.
>         (make_avr_pass_recompute_note): New proto.
>         * config/avr/avr.c (make_avr_pass_recompute_notes): New function.
>         (avr_pass_recompute_notes): Use anonymous namespace.
>         (avr_register_passes): Remove function...
>         (avr_option_override): ...and its call.

Please, apply.

Denis.
diff mbox

Patch

Index: config/avr/avr-passes.def
===================================================================
--- config/avr/avr-passes.def	(nonexistent)
+++ config/avr/avr-passes.def	(working copy)
@@ -0,0 +1,28 @@ 
+/* Description of target passes for AVR.
+   Copyright (C) 2016 Free Software Foundation, Inc. */
+
+/* This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 3, or (at your option) any later
+   version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* This avr-specific pass (re)computes insn notes, in particular REG_DEAD
+   notes which are used by `avr.c::reg_unused_after' and branch offset
+   computations.  These notes must be correct, i.e. there must be no
+   dangling REG_DEAD notes; otherwise wrong code might result, cf. PR64331.
+
+   DF needs (correct) CFG, hence right before free_cfg is the last
+   opportunity to rectify notes.  */
+
+INSERT_PASS_BEFORE (pass_free_cfg, 1, avr_pass_recompute_notes);
Index: config/avr/avr-protos.h
===================================================================
--- config/avr/avr-protos.h	(revision 240915)
+++ config/avr/avr-protos.h	(working copy)
@@ -154,6 +154,11 @@  extern void asm_output_float (FILE *file
 
 extern bool avr_have_dimode;
 
+namespace gcc { class context; }
+class rtl_opt_pass;
+
+extern rtl_opt_pass *make_avr_pass_recompute_notes (gcc::context *);
+
 /* From avr-log.c */
 
 #define avr_dump(...) avr_vdump (NULL, __FUNCTION__, __VA_ARGS__)
Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(revision 240915)
+++ config/avr/avr.c	(working copy)
@@ -295,6 +295,7 @@  avr_to_int_mode (rtx x)
     : simplify_gen_subreg (int_mode_for_mode (mode), x, mode, 0);
 }
 
+namespace {
 
 static const pass_data avr_pass_data_recompute_notes =
 {
@@ -328,20 +329,12 @@  public:
   }
 }; // avr_pass_recompute_notes
 
+} // anon namespace
 
-static void
-avr_register_passes (void)
+rtl_opt_pass*
+make_avr_pass_recompute_notes (gcc::context *ctxt)
 {
-  /* This avr-specific pass (re)computes insn notes, in particular REG_DEAD
-     notes which are used by `avr.c::reg_unused_after' and branch offset
-     computations.  These notes must be correct, i.e. there must be no
-     dangling REG_DEAD notes; otherwise wrong code might result, cf. PR64331.
-
-     DF needs (correct) CFG, hence right before free_cfg is the last
-     opportunity to rectify notes.  */
-
-  register_pass (new avr_pass_recompute_notes (g, "avr-notes-free-cfg"),
-                 PASS_POS_INSERT_BEFORE, "*free_cfg", 1);
+  return new avr_pass_recompute_notes (ctxt, "avr-notes-free-cfg");
 }
 
 
@@ -464,11 +457,6 @@  avr_option_override (void)
   init_machine_status = avr_init_machine_status;
 
   avr_log_set_avr_log();
-
-  /* Register some avr-specific pass(es).  There is no canonical place for
-     pass registration.  This function is convenient.  */
-
-  avr_register_passes ();
 }
 
 /* Function to set up the backend function structure.  */
Index: config/avr/t-avr
===================================================================
--- config/avr/t-avr	(revision 240915)
+++ config/avr/t-avr	(working copy)
@@ -16,6 +16,8 @@ 
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
+PASSES_EXTRA += $(srcdir)/config/avr/avr-passes.def
+
 driver-avr.o: $(srcdir)/config/avr/driver-avr.c \
   $(CONFIG_H) $(SYSTEM_H) coretypes.h \
   $(srcdir)/config/avr/avr-arch.h $(TM_H)