From 0c1fa876ee31d77155fc024701975ec9fe87d0f3 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 11 Apr 2016 11:06:44 -0400 Subject: [PATCH 54/91] FIXME: hack to run one pass --- gcc/pass_manager.h | 1 + gcc/rtl/rtl-frontend.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/gcc/pass_manager.h b/gcc/pass_manager.h index 6b602a2..04dc7a1 100644 --- a/gcc/pass_manager.h +++ b/gcc/pass_manager.h @@ -99,6 +99,7 @@ private: private: context *m_ctxt; + public: /* References to all of the individual passes. These fields are generated via macro expansion. diff --git a/gcc/rtl/rtl-frontend.c b/gcc/rtl/rtl-frontend.c index c2d1316..91201f6 100644 --- a/gcc/rtl/rtl-frontend.c +++ b/gcc/rtl/rtl-frontend.c @@ -45,6 +45,10 @@ along with GCC; see the file COPYING3. If not see #include "cfgrtl.h" #include "deferred-locations.h" #include "emit-rtl.h" +#include "cgraph.h" +#include "tree-pass.h" +#include "context.h" +#include "pass_manager.h" /* Language-dependent contents of a type. */ @@ -518,7 +522,7 @@ function_reader::add_fixup_reg_expr (file_location loc, rtx insn, void function_reader::create_function () { -#if 1 +#if 0 cfg_layout_rtl_register_cfg_hooks (); #else rtl_register_cfg_hooks (); @@ -585,7 +589,43 @@ function_reader::create_function () /* TODO: create edges. */ + cfun->curr_properties = (PROP_cfg | PROP_rtl); + //pop_cfun (); + + /* Do we need this to force cgraphunit.c to output the function? */ + DECL_EXTERNAL (fndecl) = 0; + DECL_PRESERVE_P (fndecl) = 1; + + #if 0 + DECL_INITIAL (m_inner_fndecl) = m_inner_block; + + /* how to add to function? the following appears to be how to + set the body of a m_inner_fndecl: */ + DECL_SAVED_TREE(m_inner_fndecl) = m_inner_bind_expr; + + /* Ensure that locals appear in the debuginfo. */ + BLOCK_VARS (m_inner_block) = BIND_EXPR_VARS (m_inner_bind_expr); + + //debug_tree (m_inner_fndecl); + + /* Convert to gimple: */ + //printf("about to gimplify_function_tree\n"); + gimplify_function_tree (m_inner_fndecl); + //printf("finished gimplify_function_tree\n"); +#endif + +#if 0 + current_function_decl = fndecl; + + /* Add to cgraph: */ + cgraph_node::finalize_function (fndecl, false); + /* This can trigger a collection, so we need to have the function + visible via a GC root. current_function_decl is a GC-root, + so we should be OK. */ + + current_function_decl = NULL; +#endif } void @@ -624,6 +664,21 @@ rtl_langhook_parse_file (void) FILE *out = fopen ("/tmp/roundtrip.rtl", "w"); print_rtl_with_bb (out, reader.get_first_insn (), 1024); fclose (out); + + /* + Run just one pass e.g. pass_instantiate_virtual_regs + (first after pass_expand). "vregs" + */ + /* TODO: find by name... */ + /* For now, extract directly... (hacking it to be public for now). */ + opt_pass *pass = g->get_passes ()->pass_instantiate_virtual_regs_1; + current_function_decl = cfun->decl; + pass->execute (cfun); + current_function_decl = NULL; + + out = fopen ("/tmp/after-pass.rtl", "w"); + print_rtl_with_bb (out, reader.get_first_insn (), 1024); + fclose (out); } static tree -- 1.8.5.3