@@ -1,5 +1,58 @@
2014-10-24 David Malcolm <dmalcolm@redhat.com>
+ Introduce gimple_omp_for
+
+ * coretypes.h (gimple_omp_for): New.
+ (const_gimple_omp_for): New.
+
+ * gimple.h (gimple_build_omp_for): Return a gimple_omp_for rather
+ than a plain gimple.
+ (gimple_omp_for_set_kind): Require a gimple_omp_for rather than a
+ plain gimple.
+ (gimple_omp_for_set_combined_p): Likewise.
+ (gimple_omp_for_set_combined_into_p): Likewise.
+
+ * gimple-pretty-print.c (dump_gimple_omp_for): Require a
+ gimple_omp_for rather than a plain gimple.
+ (pp_gimple_stmt_1): Add a checked cast to gimple_omp_for in
+ GIMPLE_OMP_FOR case of switch statement.
+
+ * gimple.c (gimple_build_omp_for): Return a gimple_omp_for rather
+ than a plain gimple.
+ (gimple_copy): Add a checked cast to gimple_omp_for and a new local.
+
+ * gimplify.c (gimplify_omp_for): Strengthen local "gfor" from
+ gimple to gimple_omp_for.
+
+ * omp-low.c (omp_for_data::for_stmt): Strengthen field from gimple
+ to gimple_omp_for.
+ (extract_omp_for_data): Require a gimple_omp_for rather than a
+ plain gimple.
+ (workshare_safe_to_combine_p): Add a checked cast to
+ gimple_omp_for.
+ (get_ws_args_for): Convert check of code against GIMPLE_OMP_FOR
+ with a dyn_cast<gimple_omp_for> and a new local.
+ (scan_omp_parallel): Add a checked cast to gimple_omp_for and a
+ new local.
+ (scan_omp_for): Require a gimple_omp_for rather than a plain
+ gimple.
+ (scan_omp_1_stmt): Add a checked cast to gimple_omp_for in
+ GIMPLE_OMP_FOR case of switch statement.
+ (expand_omp_for): Add a checked cast to gimple_omp_for.
+ (lower_omp_for): Strengthen local "stmt" from gimple to
+ gimple_omp_for.
+
+ * tree-nested.c (walk_gimple_omp_for): Require a gimple_omp_for
+ rather than a plain gimple.
+ (convert_nonlocal_reference_stmt): Add a checked cast to
+ gimple_omp_for in GIMPLE_OMP_FOR case of switch statement.
+ (convert_local_reference_stmt): Likewise.
+
+ * tree-parloops.c (create_parallel_loop): Strengthen local
+ "for_stmt" from gimple to gimple_omp_for.
+
+2014-10-24 David Malcolm <dmalcolm@redhat.com>
+
Introduce gimple_omp_critical
* coretypes.h (gimple_omp_critical): New typedef.
@@ -184,6 +184,10 @@ struct gimple_statement_omp_critical;
typedef struct gimple_statement_omp_critical *gimple_omp_critical;
typedef const struct gimple_statement_omp_critical *const_gimple_omp_critical;
+struct gimple_statement_omp_for;
+typedef struct gimple_statement_omp_for *gimple_omp_for;
+typedef const struct gimple_statement_omp_for *const_gimple_omp_for;
+
union section;
typedef union section section;
struct gcc_options;
@@ -1117,7 +1117,7 @@ dump_gimple_debug (pretty_printer *buffer, gimple_debug gs, int spc, int flags)
/* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */
static void
-dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_omp_for (pretty_printer *buffer, gimple_omp_for gs, int spc, int flags)
{
size_t i;
@@ -2156,7 +2156,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
break;
case GIMPLE_OMP_FOR:
- dump_gimple_omp_for (buffer, gs, spc, flags);
+ dump_gimple_omp_for (buffer, as_a <gimple_omp_for> (gs), spc, flags);
break;
case GIMPLE_OMP_CONTINUE:
@@ -839,12 +839,11 @@ gimple_build_omp_critical (gimple_seq body, tree name)
COLLAPSE is the collapse count.
PRE_BODY is the sequence of statements that are loop invariant. */
-gimple
+gimple_omp_for
gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse,
gimple_seq pre_body)
{
- gimple_statement_omp_for *p =
- as_a <gimple_statement_omp_for *> (gimple_alloc (GIMPLE_OMP_FOR, 0));
+ gimple_omp_for p = as_a <gimple_omp_for> (gimple_alloc (GIMPLE_OMP_FOR, 0));
if (body)
gimple_omp_set_body (p, body);
gimple_omp_for_set_clauses (p, clauses);
@@ -1711,8 +1710,7 @@ gimple_copy (gimple stmt)
t = unshare_expr (gimple_omp_for_clauses (stmt));
gimple_omp_for_set_clauses (copy, t);
{
- gimple_statement_omp_for *omp_for_copy =
- as_a <gimple_statement_omp_for *> (copy);
+ gimple_omp_for omp_for_copy = as_a <gimple_omp_for> (copy);
omp_for_copy->iter = ggc_vec_alloc<gimple_omp_for_iter>
( gimple_omp_for_collapse (stmt));
}
@@ -1343,7 +1343,7 @@ gimple_debug gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DE
#define gimple_build_debug_source_bind(var,val,stmt) \
gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
gimple_omp_critical gimple_build_omp_critical (gimple_seq, tree);
-gimple gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
+gimple_omp_for gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
gimple gimple_build_omp_section (gimple_seq);
@@ -4394,9 +4394,8 @@ gimple_omp_for_kind (const_gimple g)
/* Set the OMP for kind. */
static inline void
-gimple_omp_for_set_kind (gimple g, int kind)
+gimple_omp_for_set_kind (gimple_omp_for g, int kind)
{
- GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
g->subcode = (g->subcode & ~GF_OMP_FOR_KIND_MASK)
| (kind & GF_OMP_FOR_KIND_MASK);
}
@@ -4417,9 +4416,8 @@ gimple_omp_for_combined_p (const_gimple g)
value of COMBINED_P. */
static inline void
-gimple_omp_for_set_combined_p (gimple g, bool combined_p)
+gimple_omp_for_set_combined_p (gimple_omp_for g, bool combined_p)
{
- GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
if (combined_p)
g->subcode |= GF_OMP_FOR_COMBINED;
else
@@ -4442,9 +4440,8 @@ gimple_omp_for_combined_into_p (const_gimple g)
value of COMBINED_P. */
static inline void
-gimple_omp_for_set_combined_into_p (gimple g, bool combined_p)
+gimple_omp_for_set_combined_into_p (gimple_omp_for g, bool combined_p)
{
- GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
if (combined_p)
g->subcode |= GF_OMP_FOR_COMBINED_INTO;
else
@@ -6708,7 +6708,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
tree for_stmt, orig_for_stmt, decl, var, t;
enum gimplify_status ret = GS_ALL_DONE;
enum gimplify_status tret;
- gimple gfor;
+ gimple_omp_for gfor;
gimple_seq for_body, for_pre_body;
int i;
bool simd;
@@ -190,7 +190,7 @@ struct omp_for_data
{
struct omp_for_data_loop loop;
tree chunk_size;
- gimple for_stmt;
+ gimple_omp_for for_stmt;
tree pre, iter_type;
int collapse;
bool have_nowait, have_ordered;
@@ -290,7 +290,7 @@ is_combined_parallel (struct omp_region *region)
them into *FD. */
static void
-extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd,
+extract_omp_for_data (gimple_omp_for for_stmt, struct omp_for_data *fd,
struct omp_for_data_loop *loops)
{
tree t, var, *collapse_iter, *collapse_count;
@@ -638,7 +638,7 @@ workshare_safe_to_combine_p (basic_block ws_entry_bb)
gcc_assert (gimple_code (ws_stmt) == GIMPLE_OMP_FOR);
- extract_omp_for_data (ws_stmt, &fd, NULL);
+ extract_omp_for_data (as_a <gimple_omp_for> (ws_stmt), &fd, NULL);
if (fd.collapse > 1 && TREE_CODE (fd.loop.n2) != INTEGER_CST)
return false;
@@ -671,16 +671,16 @@ get_ws_args_for (gimple par_stmt, gimple ws_stmt)
location_t loc = gimple_location (ws_stmt);
vec<tree, va_gc> *ws_args;
- if (gimple_code (ws_stmt) == GIMPLE_OMP_FOR)
+ if (gimple_omp_for for_stmt = dyn_cast <gimple_omp_for> (ws_stmt))
{
struct omp_for_data fd;
tree n1, n2;
- extract_omp_for_data (ws_stmt, &fd, NULL);
+ extract_omp_for_data (for_stmt, &fd, NULL);
n1 = fd.loop.n1;
n2 = fd.loop.n2;
- if (gimple_omp_for_combined_into_p (ws_stmt))
+ if (gimple_omp_for_combined_into_p (for_stmt))
{
tree innerc
= find_omp_clause (gimple_omp_parallel_clauses (par_stmt),
@@ -2064,16 +2064,15 @@ scan_omp_parallel (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
if (gimple_omp_parallel_combined_p (stmt))
{
- gimple for_stmt;
struct walk_stmt_info wi;
memset (&wi, 0, sizeof (wi));
wi.val_only = true;
walk_gimple_seq (gimple_omp_body (stmt),
find_combined_for, NULL, &wi);
- for_stmt = (gimple) wi.info;
- if (for_stmt)
+ if (wi.info)
{
+ gimple_omp_for for_stmt = as_a <gimple_omp_for> ((gimple) wi.info);
struct omp_for_data fd;
extract_omp_for_data (for_stmt, &fd, NULL);
/* We need two temporaries with fd.loop.v type (istart/iend)
@@ -2273,7 +2272,7 @@ finish_taskreg_scan (omp_context *ctx)
/* Scan an OpenMP loop directive. */
static void
-scan_omp_for (gimple stmt, omp_context *outer_ctx)
+scan_omp_for (gimple_omp_for stmt, omp_context *outer_ctx)
{
omp_context *ctx;
size_t i;
@@ -2811,7 +2810,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
break;
case GIMPLE_OMP_FOR:
- scan_omp_for (stmt, ctx);
+ scan_omp_for (as_a <gimple_omp_for> (stmt), ctx);
break;
case GIMPLE_OMP_SECTIONS:
@@ -7323,7 +7322,8 @@ expand_omp_for (struct omp_region *region, gimple inner_stmt)
= (struct omp_for_data_loop *)
alloca (gimple_omp_for_collapse (last_stmt (region->entry))
* sizeof (struct omp_for_data_loop));
- extract_omp_for_data (last_stmt (region->entry), &fd, loops);
+ extract_omp_for_data (as_a <gimple_omp_for> (last_stmt (region->entry)),
+ &fd, loops);
region->sched_kind = fd.sched_kind;
gcc_assert (EDGE_COUNT (region->entry->succs) == 2);
@@ -9396,7 +9396,7 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
{
tree *rhs_p, block;
struct omp_for_data fd, *fdp = NULL;
- gimple stmt = gsi_stmt (*gsi_p);
+ gimple_omp_for stmt = as_a <gimple_omp_for> (gsi_stmt (*gsi_p));
gimple_bind new_stmt;
gimple_seq omp_for_body, body, dlist;
size_t i;
@@ -613,7 +613,7 @@ walk_function (walk_stmt_fn callback_stmt, walk_tree_fn callback_op,
/* Invoke CALLBACK on a GIMPLE_OMP_FOR's init, cond, incr and pre-body. */
static void
-walk_gimple_omp_for (gimple for_stmt,
+walk_gimple_omp_for (gimple_omp_for for_stmt,
walk_stmt_fn callback_stmt, walk_tree_fn callback_op,
struct nesting_info *info)
{
@@ -1345,7 +1345,8 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
case GIMPLE_OMP_FOR:
save_suppress = info->suppress_expansion;
convert_nonlocal_omp_clauses (gimple_omp_for_clauses_ptr (stmt), wi);
- walk_gimple_omp_for (stmt, convert_nonlocal_reference_stmt,
+ walk_gimple_omp_for (as_a <gimple_omp_for> (stmt),
+ convert_nonlocal_reference_stmt,
convert_nonlocal_reference_op, info);
walk_body (convert_nonlocal_reference_stmt,
convert_nonlocal_reference_op, info, gimple_omp_body_ptr (stmt));
@@ -1913,7 +1914,8 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
case GIMPLE_OMP_FOR:
save_suppress = info->suppress_expansion;
convert_local_omp_clauses (gimple_omp_for_clauses_ptr (stmt), wi);
- walk_gimple_omp_for (stmt, convert_local_reference_stmt,
+ walk_gimple_omp_for (as_a <gimple_omp_for> (stmt),
+ convert_local_reference_stmt,
convert_local_reference_op, info);
walk_body (convert_local_reference_stmt, convert_local_reference_op,
info, gimple_omp_body_ptr (stmt));
@@ -1605,7 +1605,8 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
gimple_stmt_iterator gsi;
basic_block bb, paral_bb, for_bb, ex_bb;
tree t, param;
- gimple stmt, for_stmt, phi, cond_stmt;
+ gimple stmt, phi, cond_stmt;
+ gimple_omp_for for_stmt;
tree cvar, cvar_init, initvar, cvar_next, cvar_base, type;
edge exit, nexit, guard, end, e;