Tested on SPARC/Solaris, applied on the mainline.

2016-10-14  Eric Botcazou  <ebotca...@adacore.com>

        * config/sparc/sparc-passes.def: New file.
        * config/sparc/t-sparc (PASSES_EXTRA): Add sparc-passes.def.
        * config/sparc/sparc-protos.h (make_pass_work_around_errata): New.
        * config/sparc/sparc.c (sparc_option_override): Don't register passes.

-- 
Eric Botcazou
Index: config/sparc/sparc-passes.def
===================================================================
--- config/sparc/sparc-passes.def	(revision 0)
+++ config/sparc/sparc-passes.def	(working copy)
@@ -0,0 +1,27 @@
+/* Description of target passes for SPARC. 
+   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/>.  */
+
+/*
+   Macros that can be used in this file:
+   INSERT_PASS_AFTER (PASS, INSTANCE, TGT_PASS)
+   INSERT_PASS_BEFORE (PASS, INSTANCE, TGT_PASS)
+   REPLACE_PASS (PASS, INSTANCE, TGT_PASS)
+ */
+
+  INSERT_PASS_AFTER (pass_delay_slots, 1, pass_work_around_errata);
Index: config/sparc/sparc-protos.h
===================================================================
--- config/sparc/sparc-protos.h	(revision 241147)
+++ config/sparc/sparc-protos.h	(working copy)
@@ -47,6 +47,7 @@ extern void sparc_profile_hook (int);
 extern void sparc_override_options (void);
 extern void sparc_output_scratch_registers (FILE *);
 extern void sparc_target_macros (void);
+extern void sparc_emit_membar_for_model (enum memmodel, int, int);
 
 #ifdef RTX_CODE
 extern machine_mode select_cc_mode (enum rtx_code, rtx, rtx);
@@ -110,6 +111,6 @@ unsigned int sparc_regmode_natural_size
 bool sparc_modes_tieable_p (machine_mode, machine_mode);
 #endif /* RTX_CODE */
 
-extern void sparc_emit_membar_for_model (enum memmodel, int, int);
+extern rtl_opt_pass *make_pass_work_around_errata (gcc::context *);
 
 #endif /* __SPARC_PROTOS_H__ */
Index: config/sparc/sparc.c
===================================================================
--- config/sparc/sparc.c	(revision 241147)
+++ config/sparc/sparc.c	(working copy)
@@ -883,10 +883,10 @@ mem_ref (rtx x)
 }
 
 /* We use a machine specific pass to enable workarounds for errata.
+
    We need to have the (essentially) final form of the insn stream in order
    to properly detect the various hazards.  Therefore, this machine specific
-   pass runs as late as possible.  The pass is inserted in the pass pipeline
-   at the end of sparc_option_override.  */
+   pass runs as late as possible.  */
 
 static unsigned int
 sparc_do_work_around_errata (void)
@@ -1706,21 +1706,6 @@ sparc_option_override (void)
      pessimizes for double floating-point registers.  */
   if (!global_options_set.x_flag_ira_share_save_slots)
     flag_ira_share_save_slots = 0;
-
-  /* We register a machine specific pass to work around errata, if any.
-     The pass mut be scheduled as late as possible so that we have the
-     (essentially) final form of the insn stream to work on.
-     Registering the pass must be done at start up.  It's convenient to
-     do it here.  */
-  opt_pass *errata_pass = make_pass_work_around_errata (g);
-  struct register_pass_info insert_pass_work_around_errata =
-    {
-      errata_pass,		/* pass */
-      "dbr",			/* reference_pass_name */
-      1,			/* ref_pass_instance_number */
-      PASS_POS_INSERT_AFTER	/* po_op */
-    };
-  register_pass (&insert_pass_work_around_errata);
 }
 
 /* Miscellaneous utilities.  */
Index: config/sparc/t-sparc
===================================================================
--- config/sparc/t-sparc	(revision 241147)
+++ config/sparc/t-sparc	(working copy)
@@ -18,6 +18,8 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
+PASSES_EXTRA += $(srcdir)/config/sparc/sparc-passes.def
+
 sparc-c.o: $(srcdir)/config/sparc/sparc-c.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)

Reply via email to