aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorPrasad Ghangal <prasad.ghangal@gmail.com>2016-11-14 13:51:48 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-11-14 13:51:48 +0000
commit1ee62b926411dda2bffbca8019b494481183ee15 (patch)
tree8d83980f6ddcd52182f277bc95f6bdd8c523ebf2 /gcc/tree-cfg.c
parent4d2098539a53d9e2dddd6233fb68820715d95862 (diff)
downloadgcc-1ee62b926411dda2bffbca8019b494481183ee15.zip
gcc-1ee62b926411dda2bffbca8019b494481183ee15.tar.gz
gcc-1ee62b926411dda2bffbca8019b494481183ee15.tar.bz2
Make-lang.in (C_AND_OBJC_OBJS): Add gimple-parser.o.
2016-11-14 Prasad Ghangal <prasad.ghangal@gmail.com> Richard Biener <rguenther@suse.de> c/ * Make-lang.in (C_AND_OBJC_OBJS): Add gimple-parser.o. * config-lang.in (gtfiles): Add c/c-parser.h. * c-tree.h (enum c_declspec_word): Add cdw_gimple. (struct c_declspecs): Add gimple_pass member and gimple_p flag. * c-parser.c (enum c_id_kind, struct c_token, c_parser_next_token_is, c_parser_next_token_is_not, c_parser_next_token_is_keyword, enum c_lookahead_kind, enum c_dtr_syn, enum c_parser_prec): Split out to ... * c-parser.h: ... new header. * c-parser.c: Include c-parser.h and gimple-parser.h. (c_parser_peek_token, c_parser_peek_2nd_token, c_token_starts_typename, c_parser_next_token_starts_declspecs, c_parser_next_tokens_start_declaration, c_parser_consume_token, c_parser_error, c_parser_require, c_parser_skip_until_found, c_parser_declspecs, c_parser_declarator, c_parser_peek_nth_token, c_parser_type_name): Export. (c_parser_tokens_buf): New function. (c_parser_error): Likewise. (c_parser_set_error): Likewise. (c_parser_declspecs): Handle RID_GIMPLE. (c_parser_declaration_or_fndef): Parse __GIMPLE marked body via c_parser_parse_gimple_body. * c-parser.h (c_parser_peek_token, c_parser_peek_2nd_token, c_token_starts_typename, c_parser_next_token_starts_declspecs, c_parser_next_tokens_start_declaration, c_parser_consume_token, c_parser_error, c_parser_require, c_parser_skip_until_found, c_parser_declspecs, c_parser_declarator, c_parser_peek_nth_token, c_parser_type_name): Declare. (struct c_parser): Declare forward. (c_parser_tokens_buf): Declare. (c_parser_error): Likewise. (c_parser_set_error): Likewise. * gimple-parser.c: New file. * gimple-parser.h: Likewise. obj-c/ * config-lang.in (gtfiles): Add c/c-parser.h. c-family/ * c-common.h (c_common_resword): Add RID_GIMPLE, RID_PHI types. * c-common.h (enum rid): Add RID_GIMPLE, RID_PHI. * c.opt (fgimple): New option. * doc/invoke.texi (fgimple): Document. * dumpfile.h (TDF_GIMPLE): Add. * dumpfile.c (dump_options): Add gimple. * gimple-pretty-print.c (dump_gimple_switch): Adjust dump for TDF_GIMPLE. (dump_gimple_label): Likewise. (dump_gimple_phi): Likewise. (dump_gimple_bb_header): Likewise. (dump_phi_nodes): Likewise. (pp_cfg_jump): Likewise. Pass in dump flags. (dump_implicit_edges): Adjust. * passes.c (pass_init_dump_file): Do not dump function header for TDF_GIMPLE. * tree-cfg.c (dump_function_to_file): Dump function return type and __GIMPLE keyword for TDF_GIMPLE. Change guard for dumping GIMPLE stmts. * tree-pretty-print.c (dump_decl_name): Adjust dump for TDF_GIMPLE. (dump_generic_node): Likewise. * function.h (struct function): Add pass_startwith member. * passes.c (execute_one_pass): Implement startwith. * tree-ssanames.c (make_ssa_name_fn): New argument, check for version and assign proper version for parsed ssa names. * tree-ssanames.h (make_ssa_name_fn): Add new argument to the function. * internal-fn.c (expand_PHI): New function. * internal-fn.h (expand_PHI): Declared here. * internal-fn.def: New defination for PHI. * tree-cfg.c (lower_phi_internal_fn): New function. (build_gimple_cfg): Call it. (verify_gimple_call): Condition for passing label as arg in internal function PHI. * tree-into-ssa.c (rewrite_add_phi_arguments): Handle already present PHIs with arguments. testsuite/ * gcc.dg/gimplefe-1.c: New testcase. * gcc.dg/gimplefe-2.c: Likewise. * gcc.dg/gimplefe-3.c: Likewise. * gcc.dg/gimplefe-4.c: Likewise. * gcc.dg/gimplefe-5.c: Likewise. * gcc.dg/gimplefe-6.c: Likewise. * gcc.dg/gimplefe-7.c: Likewise. * gcc.dg/gimplefe-8.c: Likewise. * gcc.dg/gimplefe-9.c: Likewise. * gcc.dg/gimplefe-10.c: Likewise. * gcc.dg/gimplefe-11.c: Likewise. * gcc.dg/gimplefe-12.c: Likewise. * gcc.dg/gimplefe-13.c: Likewise. * gcc.dg/gimplefe-14.c: Likewise. * gcc.dg/gimplefe-15.c: Likewise. * gcc.dg/gimplefe-16.c: Likewise. * gcc.dg/gimplefe-17.c: Likewise. * gcc.dg/gimplefe-18.c: Likewise. Co-Authored-By: Richard Biener <rguenther@suse.de> From-SVN: r242387
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index dfa82aa..e99e102 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -170,6 +170,7 @@ static edge find_taken_edge_computed_goto (basic_block, tree);
static edge find_taken_edge_cond_expr (basic_block, tree);
static edge find_taken_edge_switch_expr (gswitch *, basic_block, tree);
static tree find_case_label_for_value (gswitch *, tree);
+static void lower_phi_internal_fn ();
void
init_empty_tree_cfg_for_function (struct function *fn)
@@ -244,6 +245,7 @@ build_gimple_cfg (gimple_seq seq)
discriminator_per_locus = new hash_table<locus_discrim_hasher> (13);
make_edges ();
assign_discriminators ();
+ lower_phi_internal_fn ();
cleanup_dead_labels ();
delete discriminator_per_locus;
discriminator_per_locus = NULL;
@@ -345,6 +347,49 @@ replace_loop_annotate (void)
}
}
+/* Lower internal PHI function from GIMPLE FE. */
+
+static void
+lower_phi_internal_fn ()
+{
+ basic_block bb, pred = NULL;
+ gimple_stmt_iterator gsi;
+ tree lhs;
+ gphi *phi_node;
+ gimple *stmt;
+
+ /* After edge creation, handle __PHI function from GIMPLE FE. */
+ FOR_EACH_BB_FN (bb, cfun)
+ {
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
+ {
+ stmt = gsi_stmt (gsi);
+ if (! gimple_call_internal_p (stmt, IFN_PHI))
+ {
+ gsi_next (&gsi);
+ continue;
+ }
+
+ lhs = gimple_call_lhs (stmt);
+ phi_node = create_phi_node (lhs, bb);
+
+ /* Add arguments to the PHI node. */
+ for (unsigned i = 0; i < gimple_call_num_args (stmt); ++i)
+ {
+ tree arg = gimple_call_arg (stmt, i);
+ if (TREE_CODE (arg) == LABEL_DECL)
+ pred = label_to_block (arg);
+ else
+ {
+ edge e = find_edge (pred, bb);
+ add_phi_arg (phi_node, arg, e, UNKNOWN_LOCATION);
+ }
+ }
+
+ gsi_remove (&gsi, true);
+ }
+ }
+}
static unsigned int
execute_build_cfg (void)
@@ -3337,6 +3382,11 @@ verify_gimple_call (gcall *stmt)
debug_generic_stmt (fn);
return true;
}
+ /* FIXME : for passing label as arg in internal fn PHI from GIMPLE FE*/
+ else if (gimple_call_internal_fn (stmt) == IFN_PHI)
+ {
+ return false;
+ }
}
else
{
@@ -7497,7 +7547,14 @@ dump_function_to_file (tree fndecl, FILE *file, int flags)
}
current_function_decl = fndecl;
- fprintf (file, "%s %s(", function_name (fun), tmclone ? "[tm-clone] " : "");
+ if (flags & TDF_GIMPLE)
+ {
+ print_generic_expr (file, TREE_TYPE (TREE_TYPE (fndecl)),
+ dump_flags | TDF_SLIM);
+ fprintf (file, " __GIMPLE ()\n%s (", function_name (fun));
+ }
+ else
+ fprintf (file, "%s %s(", function_name (fun), tmclone ? "[tm-clone] " : "");
arg = DECL_ARGUMENTS (fndecl);
while (arg)
@@ -7609,7 +7666,7 @@ dump_function_to_file (tree fndecl, FILE *file, int flags)
fprintf (file, "}\n");
}
- else if (DECL_SAVED_TREE (fndecl) == NULL)
+ else if (fun->curr_properties & PROP_gimple_any)
{
/* The function is now in GIMPLE form but the CFG has not been
built yet. Emit the single sequence of GIMPLE statements