From abda7d32e2a4561a0cd4a83daf0dea6de910b295 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 17 Oct 2016 12:14:10 -0400 Subject: [PATCH 16/47] Add run-one-rtl-pass.c/h gcc/ChangeLog: * run-one-rtl-pass.c: New file. * run-one-rtl-pass.h: New file. --- gcc/run-one-rtl-pass.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++ gcc/run-one-rtl-pass.h | 25 +++++++++++ 2 files changed, 145 insertions(+) create mode 100644 gcc/run-one-rtl-pass.c create mode 100644 gcc/run-one-rtl-pass.h diff --git a/gcc/run-one-rtl-pass.c b/gcc/run-one-rtl-pass.c new file mode 100644 index 0000000..ecb7bf0 --- /dev/null +++ b/gcc/run-one-rtl-pass.c @@ -0,0 +1,120 @@ +/* run-one-rtl-pass.c - Run just one RTL pass + 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 +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "target.h" +#include "tree.h" +#include "gimple-expr.h" +#include "diagnostic.h" +#include "opts.h" +#include "fold-const.h" +#include "gimplify.h" +#include "stor-layout.h" +#include "debug.h" +#include "convert.h" +#include "langhooks.h" +#include "langhooks-def.h" +#include "common/common-target.h" +#include "read-md.h" +#include +#include "rtl.h" +#include "cfghooks.h" +#include "stringpool.h" +#include "function.h" +#include "tree-cfg.h" +#include "cfg.h" +#include "basic-block.h" +#include "cfgrtl.h" +#include "memmodel.h" +#include "emit-rtl.h" +#include "cgraph.h" +#include "tree-pass.h" +#include "context.h" +#include "pass_manager.h" +#include "toplev.h" +#include "bitmap.h" +#include "df.h" +#include "regs.h" +#include "varasm.h" +#include "insn-addr.h" + +/* Locate and run PASS_NAME on cfun. */ + +void +run_one_rtl_pass_by_name (const char *pass_name) +{ + opt_pass *pass = g->get_passes ()->get_pass_by_name (pass_name); + if (!pass) + { + error_at (UNKNOWN_LOCATION, "unrecognized pass: %qs", pass_name); + return; + } + + /* Forcibly create the dataflow instance. We'll need to do this on passes + that normally occur after pass_df_initialize/pass_df_initialize_no_opt. */ + /* FIXME: better conditional logic here. */ + if (0 == strcmp (pass_name, "rtl-cse1") + || 0 == strcmp (pass_name, "rtl-fwprop1") + || 0 == strcmp (pass_name, "rtl-combine") + || 0 == strcmp (pass_name, "rtl-ira") + || 0 == strcmp (pass_name, "rtl-reload") + || 0 == strcmp (pass_name, "rtl-pro_and_epilogue")) + { + opt_pass *df_pass = g->get_passes ()->get_pass_by_name ("rtl-dfinit"); + gcc_assert (df_pass); + current_function_decl = cfun->decl; + df_pass->execute (cfun); + + /* The dataflow instance should now exist. */ + gcc_assert (df); + + df_analyze (); + } + + /* Ensure reg_renumber is set up. */ + resize_reg_info (); + + max_regno = max_reg_num (); + + /* Pass "reload" sets the global "reload_completed", and many things + depend on this (e.g. instructions in .md files). */ + /* FIXME: better conditional logic here. */ + if (0 == strcmp (pass_name, "rtl-final")) + reload_completed = 1; + + /* The INSN_ADDRESSES vec is normally set up by shorten_branches; we must + manually set it up for passes that run after this. */ + /* FIXME: better conditional logic here. */ + if (0 == strcmp (pass_name, "rtl-final")) + INSN_ADDRESSES_ALLOC (get_max_uid ()); + + /* Run the user-specified pass. */ + bitmap_obstack_initialize (NULL); + bitmap_obstack_initialize (®_obstack); + pass_init_dump_file (pass); + current_function_decl = cfun->decl; + pass->execute (cfun); + current_function_decl = NULL; + if (dump_file) + print_rtl_with_bb (dump_file, get_insns (), dump_flags); + pass_fini_dump_file (pass); + bitmap_obstack_release (®_obstack); +} diff --git a/gcc/run-one-rtl-pass.h b/gcc/run-one-rtl-pass.h new file mode 100644 index 0000000..40d60ba --- /dev/null +++ b/gcc/run-one-rtl-pass.h @@ -0,0 +1,25 @@ +/* run-one-rtl-pass.h - Run just one RTL pass + 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 +. */ + +#ifndef GCC_RUN_ONE_RTL_PASS_H +#define GCC_RUN_ONE_RTL_PASS_H + +extern void run_one_rtl_pass_by_name (const char *pass_name); + +#endif /* GCC_RUN_ONE_RTL_PASS_H */ -- 1.8.5.3