From e80b9d7e6790d7b0c6e4e4461d4508863ec0db4c Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 17 Dec 2013 12:50:27 -0500
Subject: [PATCH 43/88] Introduce gimple_omp_sections

gcc/
	* coretypes.h (gimple_omp_sections): New typedef.
	(const_gimple_omp_sections): New typedef.

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

	* gimple.c (gimple_build_omp_sections): Return a
	gimple_omp_sections rather than a plain gimple.

	* gimple.h (gimple_build_omp_sections): Return a
	gimple_omp_sections rather than a plain gimple.

	* omp-low.c (scan_omp_sections): Require a gimple_omp_sections
	rather than a plain gimple.
	(scan_omp_1_stmt): Add checked cast to gimple_omp_sections within
	GIMPLE_OMP_SECTIONS case of switch statement.
	(expand_omp_sections): Strengthen local "sections_stmt" from gimple
	to gimple_omp_sections.
	(lower_omp_sections): Likewise for "stmt".
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  7 ++++---
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              |  2 +-
 gcc/omp-low.c             | 14 ++++++++------
 5 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 2cd33e5..b8417bc 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -196,6 +196,10 @@ 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;
 
+struct gimple_statement_omp_sections;
+typedef struct gimple_statement_omp_sections *gimple_omp_sections;
+typedef const struct gimple_statement_omp_sections *const_gimple_omp_sections;
+
 struct gimple_statement_omp_single;
 typedef struct gimple_statement_omp_single *gimple_omp_single;
 typedef const struct gimple_statement_omp_single *const_gimple_omp_single;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d5e3639..a90d2ef 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1388,8 +1388,8 @@ dump_gimple_omp_teams (pretty_printer *buffer, gimple_omp_teams gs, int spc,
 /* 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)
+dump_gimple_omp_sections (pretty_printer *buffer, gimple_omp_sections gs,
+			  int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2188,7 +2188,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_SECTIONS:
-      dump_gimple_omp_sections (buffer, gs, spc, flags);
+      dump_gimple_omp_sections (buffer, as_a <gimple_omp_sections> (gs),
+				spc, flags);
       break;
 
     case GIMPLE_OMP_SECTIONS_SWITCH:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index b4b76f3..c2b4588 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1007,10 +1007,11 @@ gimple_build_omp_return (bool wait_p)
    CLAUSES are any of the OMP sections contsruct's clauses: private,
    firstprivate, lastprivate, reduction, and nowait.  */
 
-gimple
+gimple_omp_sections
 gimple_build_omp_sections (gimple_seq body, tree clauses)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_SECTIONS, 0);
+  gimple_omp_sections p =
+    as_a <gimple_omp_sections> (gimple_alloc (GIMPLE_OMP_SECTIONS, 0));
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_sections_set_clauses (p, clauses);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 462495e..4e59777 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1353,7 +1353,7 @@ gimple gimple_build_omp_taskgroup (gimple_seq);
 gimple_omp_continue gimple_build_omp_continue (tree, tree);
 gimple gimple_build_omp_ordered (gimple_seq);
 gimple gimple_build_omp_return (bool);
-gimple gimple_build_omp_sections (gimple_seq, tree);
+gimple_omp_sections gimple_build_omp_sections (gimple_seq, tree);
 gimple gimple_build_omp_sections_switch (void);
 gimple_omp_single gimple_build_omp_single (gimple_seq, tree);
 gimple_omp_target gimple_build_omp_target (gimple_seq, int, tree);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index ce71618..1edc943 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2295,7 +2295,7 @@ scan_omp_for (gimple_omp_for stmt, omp_context *outer_ctx)
 /* Scan an OpenMP sections directive.  */
 
 static void
-scan_omp_sections (gimple stmt, omp_context *outer_ctx)
+scan_omp_sections (gimple_omp_sections stmt, omp_context *outer_ctx)
 {
   omp_context *ctx;
 
@@ -2814,7 +2814,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_SECTIONS:
-      scan_omp_sections (stmt, ctx);
+      scan_omp_sections (as_a <gimple_omp_sections> (stmt), ctx);
       break;
 
     case GIMPLE_OMP_SINGLE:
@@ -7423,7 +7423,8 @@ expand_omp_sections (struct omp_region *region)
   unsigned len;
   basic_block entry_bb, l0_bb, l1_bb, l2_bb, default_bb;
   gimple_stmt_iterator si, switch_si;
-  gimple sections_stmt, stmt;
+  gimple_omp_sections sections_stmt;
+  gimple stmt;
   gimple_omp_continue cont;
   edge_iterator ei;
   edge e;
@@ -7478,7 +7479,7 @@ expand_omp_sections (struct omp_region *region)
   /* The call to GOMP_sections_start goes in ENTRY_BB, replacing the
      GIMPLE_OMP_SECTIONS statement.  */
   si = gsi_last_bb (entry_bb);
-  sections_stmt = gsi_stmt (si);
+  sections_stmt = as_a <gimple_omp_sections> (gsi_stmt (si));
   gcc_assert (gimple_code (sections_stmt) == GIMPLE_OMP_SECTIONS);
   vin = gimple_omp_sections_control (sections_stmt);
   if (!is_combined_parallel (region))
@@ -8876,11 +8877,12 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block, control;
   gimple_stmt_iterator tgsi;
-  gimple stmt, t;
+  gimple_omp_sections stmt;
+  gimple t;
   gimple_bind new_stmt, bind;
   gimple_seq ilist, dlist, olist, new_body;
 
-  stmt = gsi_stmt (*gsi_p);
+  stmt = as_a <gimple_omp_sections> (gsi_stmt (*gsi_p));
 
   push_gimplify_context ();
 
-- 
1.8.5.3

