From 80273229bcd752c0d7f549d98c2e2db843dd012f Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 17 Dec 2013 10:44:21 -0500
Subject: [PATCH 39/88] Introduce gimple_omp_task

gcc/
	* coretypes.h (gimple_omp_task): New typedef.
	(const_gimple_omp_task): New typedef.

	* gimple.h (gimple_build_omp_task): Return a gimple_omp_task
	rather than a plain gimple.

	* gimple-pretty-print.c (dump_gimple_omp_task): Require a
	gimple_omp_task rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_omp_task within
	GIMPLE_OMP_TASK case of switch statement.

	* gimple.c (gimple_build_omp_task): Return a gimple_omp_task
	rather than a plain gimple.

	* omp-low.c (finalize_task_copyfn): Require a gimple_omp_task
	rather than a plain gimple.
	(delete_omp_context): Add checked cast to gimple_omp_task.
	(scan_omp_task): Strengthen local "stmt" from gimple to
	gimple_omp_task.
	(expand_task_call): Require a gimple_omp_task rather than a plain
	gimple.
	(expand_omp_taskreg): Add checked cast to gimple_omp_task.
	(create_task_copyfn): Require a gimple_omp_task rather than a
	plain gimple.
	(lower_omp_taskreg): Add checked cast to gimple_omp_task.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              |  3 ++-
 gcc/omp-low.c             | 14 +++++++-------
 5 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 641658f..323e23c 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -192,6 +192,10 @@ struct gimple_statement_omp_parallel;
 typedef struct gimple_statement_omp_parallel *gimple_omp_parallel;
 typedef const struct gimple_statement_omp_parallel *const_gimple_omp_parallel;
 
+struct gimple_statement_omp_task;
+typedef struct gimple_statement_omp_task *gimple_omp_task;
+typedef const struct gimple_statement_omp_task *const_gimple_omp_task;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index ea788c2..2cb6fc8 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1911,7 +1911,7 @@ dump_gimple_omp_parallel (pretty_printer *buffer, gimple_omp_parallel gs,
    dumpfile.h).  */
 
 static void
-dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
+dump_gimple_omp_task (pretty_printer *buffer, gimple_omp_task gs, int spc,
 		      int flags)
 {
   if (flags & TDF_RAW)
@@ -2142,7 +2142,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_TASK:
-      dump_gimple_omp_task (buffer, gs, spc, flags);
+      dump_gimple_omp_task (buffer, as_a <gimple_omp_task> (gs), spc, flags);
       break;
 
     case GIMPLE_OMP_ATOMIC_LOAD:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 26bd509..9510014 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -890,12 +890,13 @@ gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn,
    COPY_FN is the optional function for firstprivate initialization.
    ARG_SIZE and ARG_ALIGN are size and alignment of the data block.  */
 
-gimple
+gimple_omp_task
 gimple_build_omp_task (gimple_seq body, tree clauses, tree child_fn,
 		       tree data_arg, tree copy_fn, tree arg_size,
 		       tree arg_align)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_TASK, 0);
+  gimple_omp_task p =
+    as_a <gimple_omp_task> (gimple_alloc (GIMPLE_OMP_TASK, 0));
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_task_set_clauses (p, clauses);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index cc460499..a9903de 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1345,7 +1345,8 @@ gimple_debug gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DE
 gimple_omp_critical gimple_build_omp_critical (gimple_seq, tree);
 gimple_omp_for gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
 gimple_omp_parallel gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
-gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
+gimple_omp_task gimple_build_omp_task (gimple_seq, tree, tree, tree, tree,
+				       tree, tree);
 gimple gimple_build_omp_section (gimple_seq);
 gimple gimple_build_omp_master (gimple_seq);
 gimple gimple_build_omp_taskgroup (gimple_seq);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 46155d6..c51e6da 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1372,7 +1372,7 @@ static gimple_seq maybe_catch_exception (gimple_seq);
 /* Finalize task copyfn.  */
 
 static void
-finalize_task_copyfn (gimple task_stmt)
+finalize_task_copyfn (gimple_omp_task task_stmt)
 {
   struct function *child_cfun;
   tree child_fn;
@@ -1434,7 +1434,7 @@ delete_omp_context (splay_tree_value value)
     }
 
   if (is_task_ctx (ctx))
-    finalize_task_copyfn (ctx->stmt);
+    finalize_task_copyfn (as_a <gimple_omp_task> (ctx->stmt));
 
   XDELETE (ctx);
 }
@@ -2126,7 +2126,7 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
 {
   omp_context *ctx;
   tree name, t;
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_omp_task stmt = as_a <gimple_omp_task> (gsi_stmt (*gsi));
 
   /* Ignore task directives with empty bodies.  */
   if (optimize > 0
@@ -4566,7 +4566,7 @@ expand_cilk_for_call (basic_block bb, gimple_omp_parallel entry_stmt,
    generate the task operation.  BB is the block where to insert the code.  */
 
 static void
-expand_task_call (basic_block bb, gimple entry_stmt)
+expand_task_call (basic_block bb, gimple_omp_task entry_stmt)
 {
   tree t, t1, t2, t3, flags, cond, c, c2, clauses, depend;
   gimple_stmt_iterator gsi;
@@ -5127,7 +5127,7 @@ expand_omp_taskreg (struct omp_region *region)
     expand_parallel_call (region, new_bb,
 			  as_a <gimple_omp_parallel> (entry_stmt), ws_args);
   else
-    expand_task_call (new_bb, entry_stmt);
+    expand_task_call (new_bb, as_a <gimple_omp_task> (entry_stmt));
   if (gimple_in_ssa_p (cfun))
     update_ssa (TODO_update_ssa_only_virtuals);
 }
@@ -9623,7 +9623,7 @@ task_copyfn_remap_type (struct omp_taskcopy_context *tcctx, tree orig_type)
 /* Create task copyfn.  */
 
 static void
-create_task_copyfn (gimple task_stmt, omp_context *ctx)
+create_task_copyfn (gimple_omp_task task_stmt, omp_context *ctx)
 {
   struct function *child_cfun;
   tree child_fn, t, c, src, dst, f, sf, arg, sarg, decl;
@@ -9954,7 +9954,7 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
     }
 
   if (ctx->srecord_type)
-    create_task_copyfn (stmt, ctx);
+    create_task_copyfn (as_a <gimple_omp_task> (stmt), ctx);
 
   push_gimplify_context ();
 
-- 
1.8.5.3

