[tuples] 2 omp-low.c fixes and GIMPLE_OMP_* dumping
Jakub Jelinek
jakub@redhat.com
Thu May 29 20:32:00 GMT 2008
Hi!
GIMPLE_ASM can't be regimplified by the generic code, and my yesterday's
late patch mistakenly removed else gimplify_expr (...).
The rest is just dumping stuff.
2008-05-29 Jakub Jelinek <jakub@redhat.com>
* omp-low.c (lower_omp_1): Handle regimplification of GIMPLE_ASM.
Fix GIMPLE_ASSIGN regimplification.
* gimple-pretty-print.c (dump_gimple_omp_sections,
dump_gimple_omp_block, dump_gimple_omp_critical): New functions.
(dump_gimple_omp_parallel): Formatting.
(dump_gimple_stmt): Handle remaining GIMPLE_OMP_* statements.
--- gcc/omp-low.c (revision 136181)
+++ gcc/omp-low.c (working copy)
@@ -5107,6 +5107,48 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p
}
}
break;
+ case GIMPLE_ASM:
+ if (ctx && walk_gimple_op (stmt, lower_omp_regimplify_p, NULL))
+ {
+ gimple_seq pre = NULL;
+ size_t i, noutputs = gimple_asm_noutputs (stmt);
+ const char *constraint, **oconstraints;
+ bool allows_mem, allows_reg, is_inout;
+
+ oconstraints
+ = (const char **) alloca ((noutputs) * sizeof (const char *));
+ for (i = 0; i < noutputs; i++)
+ {
+ tree op = gimple_asm_output_op (stmt, i);
+ constraint
+ = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op)));
+ oconstraints[i] = constraint;
+ parse_output_constraint (&constraint, i, 0, 0, &allows_mem,
+ &allows_reg, &is_inout);
+ gimplify_expr (&TREE_VALUE (op), &pre, NULL,
+ is_inout ? is_gimple_min_lval : is_gimple_lvalue,
+ fb_lvalue | fb_mayfail);
+ }
+ for (i = 0; i < gimple_asm_ninputs (stmt); i++)
+ {
+ tree op = gimple_asm_input_op (stmt, i);
+ constraint
+ = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op)));
+ parse_input_constraint (&constraint, 0, 0, noutputs, 0,
+ oconstraints, &allows_mem, &allows_reg);
+ if (TREE_ADDRESSABLE (TREE_TYPE (TREE_VALUE (op))) && allows_mem)
+ allows_reg = 0;
+ if (!allows_reg && allows_mem)
+ gimplify_expr (&TREE_VALUE (op), &pre, NULL,
+ is_gimple_lvalue, fb_lvalue | fb_mayfail);
+ else
+ gimplify_expr (&TREE_VALUE (op), &pre, NULL,
+ is_gimple_asm_val, fb_rvalue);
+ }
+ if (!gimple_seq_empty_p (pre))
+ gsi_insert_seq_before (gsi_p, pre, GSI_SAME_STMT);
+ }
+ break;
default:
if (ctx && walk_gimple_op (stmt, lower_omp_regimplify_p, NULL))
@@ -5140,6 +5182,8 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p
gimplify_expr (&op, &pre, NULL, is_gimple_call_addr,
fb_rvalue);
}
+ else
+ gimplify_expr (&op, &pre, NULL, is_gimple_val, fb_rvalue);
if (!gimple_seq_empty_p (pre))
gsi_insert_seq_before (gsi_p, pre, GSI_SAME_STMT);
gimple_set_op (stmt, i - 1, op);
--- gcc/gimple-pretty-print.c (revision 136181)
+++ gcc/gimple-pretty-print.c (working copy)
@@ -1,5 +1,5 @@
/* Pretty formatting of GIMPLE statements and expressions.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Contributed by Aldy Hernandez <aldyh@redhat.com> and
Diego Novillo <dnovillo@google.com>
@@ -810,6 +810,110 @@ dump_gimple_omp_single (pretty_printer *
}
}
+/* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */
+
+static void
+dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
+ int flags)
+{
+ if (flags & TDF_RAW)
+ {
+ dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
+ gimple_omp_body (gs));
+ dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
+ dump_gimple_fmt (buffer, spc, flags, " >");
+ }
+ else
+ {
+ pp_string (buffer, "#pragma omp sections");
+ if (gimple_omp_sections_control (gs))
+ {
+ pp_string (buffer, " <");
+ dump_generic_node (buffer, gimple_omp_sections_control (gs), spc,
+ flags, false);
+ pp_character (buffer, '>');
+ }
+ dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags);
+ if (!gimple_seq_empty_p (gimple_omp_body (gs)))
+ {
+ newline_and_indent (buffer, spc + 2);
+ pp_character (buffer, '{');
+ pp_newline (buffer);
+ dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
+ INDENT (spc + 2);
+ pp_character (buffer, '}');
+ }
+ }
+}
+
+/* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the pretty_printer
+ BUFFER. */
+
+static void
+dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
+{
+ if (flags & TDF_RAW)
+ dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
+ gimple_omp_body (gs));
+ else
+ {
+ switch (gimple_code (gs))
+ {
+ case GIMPLE_OMP_MASTER:
+ pp_string (buffer, "#pragma omp master");
+ break;
+ case GIMPLE_OMP_ORDERED:
+ pp_string (buffer, "#pragma omp ordered");
+ break;
+ case GIMPLE_OMP_SECTION:
+ pp_string (buffer, "#pragma omp section");
+ break;
+ default:
+ gcc_unreachable ();
+ }
+ if (!gimple_seq_empty_p (gimple_omp_body (gs)))
+ {
+ newline_and_indent (buffer, spc + 2);
+ pp_character (buffer, '{');
+ pp_newline (buffer);
+ dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
+ INDENT (spc + 2);
+ pp_character (buffer, '}');
+ }
+ }
+}
+
+/* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */
+
+static void
+dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
+ int flags)
+{
+ if (flags & TDF_RAW)
+ dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
+ gimple_omp_body (gs));
+ else
+ {
+ pp_string (buffer, "#pragma omp critical");
+ if (gimple_omp_critical_name (gs))
+ {
+ pp_string (buffer, " (");
+ dump_generic_node (buffer, gimple_omp_critical_name (gs), spc,
+ flags, false);
+ pp_character (buffer, ')');
+ }
+ if (!gimple_seq_empty_p (gimple_omp_body (gs)))
+ {
+ newline_and_indent (buffer, spc + 2);
+ pp_character (buffer, '{');
+ pp_newline (buffer);
+ dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
+ INDENT (spc + 2);
+ pp_character (buffer, '}');
+ }
+ }
+}
+
/* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */
static void
@@ -997,6 +1101,7 @@ dump_gimple_omp_parallel (pretty_printer
}
else
{
+ gimple_seq body;
pp_string (buffer, "#pragma omp parallel");
dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags);
if (gimple_omp_parallel_child_fn (gs))
@@ -1012,19 +1117,18 @@ dump_gimple_omp_parallel (pretty_printer
pp_string (buffer, "???");
pp_string (buffer, ")]");
}
- if (gimple_omp_body (gs) &&
- gimple_code
- (gimple_seq_first_stmt (gimple_omp_body (gs))) != GIMPLE_BIND)
+ body = gimple_omp_body (gs);
+ if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND)
{
newline_and_indent (buffer, spc + 2);
pp_character (buffer, '{');
pp_newline (buffer);
- dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
+ dump_gimple_seq (buffer, body, spc + 4, flags);
INDENT (spc + 2);
pp_character (buffer, '}');
}
else
- dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 2, flags);
+ dump_gimple_seq (buffer, body, spc + 2, flags);
}
}
@@ -1247,18 +1351,10 @@ dump_gimple_stmt (pretty_printer *buffer
dump_gimple_goto (buffer, gs, spc, flags);
break;
- case GIMPLE_OMP_MASTER:
- pp_string (buffer, "#pragma omp master");
- break;
-
case GIMPLE_NOP:
pp_string (buffer, "GIMPLE_NOP");
break;
- case GIMPLE_OMP_ORDERED:
- pp_string (buffer, "#pragma omp ordered");
- break;
-
case GIMPLE_RETURN:
dump_gimple_return (buffer, gs, spc, flags);
break;
@@ -1304,6 +1400,24 @@ dump_gimple_stmt (pretty_printer *buffer
dump_gimple_omp_return (buffer, gs, spc, flags);
break;
+ case GIMPLE_OMP_SECTIONS:
+ dump_gimple_omp_sections (buffer, gs, spc, flags);
+ break;
+
+ case GIMPLE_OMP_SECTIONS_SWITCH:
+ pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
+ break;
+
+ case GIMPLE_OMP_MASTER:
+ case GIMPLE_OMP_ORDERED:
+ case GIMPLE_OMP_SECTION:
+ dump_gimple_omp_block (buffer, gs, spc, flags);
+ break;
+
+ case GIMPLE_OMP_CRITICAL:
+ dump_gimple_omp_critical (buffer, gs, spc, flags);
+ break;
+
case GIMPLE_CHANGE_DYNAMIC_TYPE:
dump_gimple_cdt (buffer, gs, spc, flags);
break;
Jakub
More information about the Gcc-patches
mailing list