xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/run-rtl-passes.c (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
13ad841b2Smrg /* run-rtl-passes.c - Run RTL passes directly from frontend
2*4c3eb207Smrg    Copyright (C) 2016-2020 Free Software Foundation, Inc.
33ad841b2Smrg 
43ad841b2Smrg This file is part of GCC.
53ad841b2Smrg 
63ad841b2Smrg GCC is free software; you can redistribute it and/or modify it under
73ad841b2Smrg the terms of the GNU General Public License as published by the Free
83ad841b2Smrg Software Foundation; either version 3, or (at your option) any later
93ad841b2Smrg version.
103ad841b2Smrg 
113ad841b2Smrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
123ad841b2Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
133ad841b2Smrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
143ad841b2Smrg for more details.
153ad841b2Smrg 
163ad841b2Smrg You should have received a copy of the GNU General Public License
173ad841b2Smrg along with GCC; see the file COPYING3.  If not see
183ad841b2Smrg <http://www.gnu.org/licenses/>.  */
193ad841b2Smrg 
203ad841b2Smrg #include "config.h"
213ad841b2Smrg #include "system.h"
223ad841b2Smrg #include "coretypes.h"
233ad841b2Smrg #include "target.h"
243ad841b2Smrg #include "rtl.h"
253ad841b2Smrg #include "function.h"
263ad841b2Smrg #include "basic-block.h"
273ad841b2Smrg #include "tree-pass.h"
283ad841b2Smrg #include "context.h"
293ad841b2Smrg #include "pass_manager.h"
303ad841b2Smrg #include "bitmap.h"
313ad841b2Smrg #include "df.h"
323ad841b2Smrg #include "regs.h"
33cef8759bSmrg #include "output.h"
34cef8759bSmrg #include "debug.h" /* for debug_hooks.  */
353ad841b2Smrg #include "insn-attr-common.h" /* for INSN_SCHEDULING.  */
363ad841b2Smrg #include "insn-attr.h" /* for init_sched_attrs.  */
373ad841b2Smrg #include "run-rtl-passes.h"
383ad841b2Smrg 
393ad841b2Smrg /* Run the backend passes, starting at the given pass.
403ad841b2Smrg    Take ownership of INITIAL_PASS_NAME.  */
413ad841b2Smrg 
423ad841b2Smrg void
run_rtl_passes(char * initial_pass_name)433ad841b2Smrg run_rtl_passes (char *initial_pass_name)
443ad841b2Smrg {
453ad841b2Smrg   cfun->pass_startwith = initial_pass_name;
463ad841b2Smrg   max_regno = max_reg_num ();
473ad841b2Smrg 
48cef8759bSmrg   /* cgraphunit.c normally handles this.  */
49cef8759bSmrg   switch_to_section (text_section);
50cef8759bSmrg   (*debug_hooks->assembly_start) ();
51cef8759bSmrg 
52*4c3eb207Smrg   if (initial_pass_name)
53*4c3eb207Smrg     {
543ad841b2Smrg       /* Pass "expand" normally sets this up.  */
553ad841b2Smrg #ifdef INSN_SCHEDULING
563ad841b2Smrg       init_sched_attrs ();
573ad841b2Smrg #endif
583ad841b2Smrg       bitmap_obstack_initialize (NULL);
593ad841b2Smrg       bitmap_obstack_initialize (&reg_obstack);
603ad841b2Smrg       opt_pass *rest_of_compilation
613ad841b2Smrg 	= g->get_passes ()->get_rest_of_compilation ();
623ad841b2Smrg       gcc_assert (rest_of_compilation);
633ad841b2Smrg       execute_pass_list (cfun, rest_of_compilation);
643ad841b2Smrg 
653ad841b2Smrg       opt_pass *clean_slate = g->get_passes ()->get_clean_slate ();
663ad841b2Smrg       gcc_assert (clean_slate);
673ad841b2Smrg       execute_pass_list (cfun, clean_slate);
683ad841b2Smrg       bitmap_obstack_release (&reg_obstack);
69*4c3eb207Smrg     }
70*4c3eb207Smrg   else
71*4c3eb207Smrg     {
72*4c3eb207Smrg       opt_pass *clean_slate = g->get_passes ()->get_clean_slate ();
73*4c3eb207Smrg       gcc_assert (clean_slate);
74*4c3eb207Smrg       execute_pass_list (cfun, clean_slate);
75*4c3eb207Smrg     }
763ad841b2Smrg 
773ad841b2Smrg   cfun->curr_properties |= PROP_rtl;
78*4c3eb207Smrg   free (initial_pass_name);
793ad841b2Smrg }
80