diff options
author | Prasad Ghangal <prasad.ghangal@gmail.com> | 2016-11-14 13:51:48 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-11-14 13:51:48 +0000 |
commit | 1ee62b926411dda2bffbca8019b494481183ee15 (patch) | |
tree | 8d83980f6ddcd52182f277bc95f6bdd8c523ebf2 /gcc/gimple-pretty-print.c | |
parent | 4d2098539a53d9e2dddd6233fb68820715d95862 (diff) | |
download | gcc-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/gimple-pretty-print.c')
-rw-r--r-- | gcc/gimple-pretty-print.c | 106 |
1 files changed, 77 insertions, 29 deletions
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index f588f5e..8286326 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -893,7 +893,10 @@ dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc, { pp_string (buffer, "switch ("); dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true); - pp_string (buffer, ") <"); + if (flags & TDF_GIMPLE) + pp_string (buffer, ") {"); + else + pp_string (buffer, ") <"); } for (i = 0; i < gimple_switch_num_labels (gs); i++) @@ -904,9 +907,17 @@ dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc, pp_space (buffer); dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false); if (i < gimple_switch_num_labels (gs) - 1) - pp_string (buffer, ", "); + { + if (flags & TDF_GIMPLE) + pp_string (buffer, "; "); + else + pp_string (buffer, ", "); + } } - pp_greater (buffer); + if (flags & TDF_GIMPLE) + pp_string (buffer, "; }"); + else + pp_greater (buffer); } @@ -962,12 +973,14 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags) { tree label = gimple_label_label (gs); if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label); + dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label); else { dump_generic_node (buffer, label, spc, flags, false); pp_colon (buffer); } + if (flags & TDF_GIMPLE) + return; if (DECL_NONLOCAL (label)) pp_string (buffer, " [non-local]"); if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label)) @@ -2039,21 +2052,44 @@ dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment, else { dump_generic_node (buffer, lhs, spc, flags, false); - pp_string (buffer, " = PHI <"); + if (flags & TDF_GIMPLE) + pp_string (buffer, " = __PHI ("); + else + pp_string (buffer, " = PHI <"); } for (i = 0; i < gimple_phi_num_args (phi); i++) { if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i)) dump_location (buffer, gimple_phi_arg_location (phi, i)); + if (flags & TDF_GIMPLE) + { + basic_block src = gimple_phi_arg_edge (phi, i)->src; + gimple *stmt = first_stmt (src); + if (!stmt || gimple_code (stmt) != GIMPLE_LABEL) + { + pp_string (buffer, "bb_"); + pp_decimal_int (buffer, src->index); + } + else + dump_generic_node (buffer, gimple_label_label (as_a <glabel *> (stmt)), 0, flags, + false); + pp_string (buffer, ": "); + } dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags, false); - pp_left_paren (buffer); - pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index); - pp_right_paren (buffer); + if (! (flags & TDF_GIMPLE)) + { + pp_left_paren (buffer); + pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index); + pp_right_paren (buffer); + } if (i < gimple_phi_num_args (phi) - 1) pp_string (buffer, ", "); } - pp_greater (buffer); + if (flags & TDF_GIMPLE) + pp_string (buffer, ");"); + else + pp_greater (buffer); } @@ -2502,7 +2538,12 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags) { gimple *stmt = first_stmt (bb); if (!stmt || gimple_code (stmt) != GIMPLE_LABEL) - fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index); + { + if (flags & TDF_GIMPLE) + fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index); + else + fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index); + } } } @@ -2535,7 +2576,8 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags) if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS)) { INDENT (indent); - dump_gimple_phi (buffer, phi, indent, true, flags); + dump_gimple_phi (buffer, phi, indent, + (flags & TDF_GIMPLE) ? false : true, flags); pp_newline (buffer); } } @@ -2546,26 +2588,32 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags) to BUFFER. */ static void -pp_cfg_jump (pretty_printer *buffer, basic_block bb) +pp_cfg_jump (pretty_printer *buffer, basic_block bb, int flags) { - gimple *stmt; - - stmt = first_stmt (bb); - - pp_string (buffer, "goto <bb "); - pp_decimal_int (buffer, bb->index); - pp_greater (buffer); - if (stmt && gimple_code (stmt) == GIMPLE_LABEL) + if (flags & TDF_GIMPLE) { - pp_string (buffer, " ("); - dump_generic_node (buffer, - gimple_label_label (as_a <glabel *> (stmt)), - 0, 0, false); - pp_right_paren (buffer); + pp_string (buffer, "goto bb_"); + pp_decimal_int (buffer, bb->index); pp_semicolon (buffer); } else - pp_semicolon (buffer); + { + gimple *stmt = first_stmt (bb); + pp_string (buffer, "goto <bb "); + pp_decimal_int (buffer, bb->index); + pp_greater (buffer); + if (stmt && gimple_code (stmt) == GIMPLE_LABEL) + { + pp_string (buffer, " ("); + dump_generic_node (buffer, + gimple_label_label (as_a <glabel *> (stmt)), + 0, 0, false); + pp_right_paren (buffer); + pp_semicolon (buffer); + } + else + pp_semicolon (buffer); + } } @@ -2593,11 +2641,11 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent, extract_true_false_edges_from_block (bb, &true_edge, &false_edge); INDENT (indent + 2); - pp_cfg_jump (buffer, true_edge->dest); + pp_cfg_jump (buffer, true_edge->dest, flags); newline_and_indent (buffer, indent); pp_string (buffer, "else"); newline_and_indent (buffer, indent + 2); - pp_cfg_jump (buffer, false_edge->dest); + pp_cfg_jump (buffer, false_edge->dest, flags); pp_newline (buffer); return; } @@ -2614,7 +2662,7 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent, && e->goto_locus != UNKNOWN_LOCATION) dump_location (buffer, e->goto_locus); - pp_cfg_jump (buffer, e->dest); + pp_cfg_jump (buffer, e->dest, flags); pp_newline (buffer); } } |