From f3258a11356a6d15e915a74f1b67275234eb16b4 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 16 Dec 2013 16:28:56 -0500
Subject: [PATCH 33/88] Introduce gimple_omp_atomic_store

gcc/
	* coretypes.h (gimple_omp_atomic_store): New typedef.
	(const_gimple_omp_atomic_store): New typedef.

	* gimple-pretty-print.c (dump_gimple_omp_atomic_store): Require
	a gimple_omp_atomic_store rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_omp_atomic_store
	within GIMPLE_OMP_ATOMIC_STORE case of switch statement.
	* gimple-walk.c (walk_gimple_op): Likewise.

	* gimple.c (gimple_build_omp_atomic_store): Return a
	gimple_omp_atomic_store rather than a plain gimple.

	* gimple.h (gimple_build_omp_atomic_store): Return a
	gimple_omp_atomic_store rather than a plain gimple.
	(gimple_omp_atomic_store_set_val): Require a gimple_omp_atomic_store
	rather than a plain gimple.
	(gimple_omp_atomic_store_val_ptr): Likewise.
	(gimple_omp_atomic_store_val): Require a
	const_gimple_omp_atomic_store rather than a plain const_gimple.

	* gimplify.c (gimplify_omp_atomic): Strengthen locals "loadstmt" and
	"storestmt" from gimple to gimple_omp_atomic_load loadstmt and
	gimple_omp_atomic_store storestmt respectively.

	* omp-low.c (expand_omp_atomic): Strengthen local "store" from
	gimple to gimple_omp_atomic_store.
---
 gcc/coretypes.h           |  5 +++++
 gcc/gimple-pretty-print.c |  8 +++++---
 gcc/gimple-walk.c         |  5 +++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 20 +++++++-------------
 gcc/gimplify.c            |  3 ++-
 gcc/omp-low.c             |  3 ++-
 7 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 06b3be8..78647b2 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -171,6 +171,11 @@ typedef struct gimple_statement_omp_atomic_load *gimple_omp_atomic_load;
 typedef const struct gimple_statement_omp_atomic_load *
   const_gimple_omp_atomic_load;
 
+struct gimple_statement_omp_atomic_store;
+typedef struct gimple_statement_omp_atomic_store *gimple_omp_atomic_store;
+typedef const struct gimple_statement_omp_atomic_store *
+  const_gimple_omp_atomic_store;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index eafb6cd..62e4bf8 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2000,8 +2000,8 @@ dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple_omp_atomic_load gs,
    in dumpfile.h).  */
 
 static void
-dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
-                             int flags)
+dump_gimple_omp_atomic_store (pretty_printer *buffer,
+			      gimple_omp_atomic_store gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2149,7 +2149,9 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_ATOMIC_STORE:
-      dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
+      dump_gimple_omp_atomic_store (buffer,
+				    as_a <gimple_omp_atomic_store> (gs),
+				    spc, flags);
       break;
 
     case GIMPLE_OMP_FOR:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index af67218..987b856 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -434,8 +434,9 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_ATOMIC_STORE:
-      ret = walk_tree (gimple_omp_atomic_store_val_ptr (stmt), callback_op,
-		       wi, pset);
+      ret = walk_tree (gimple_omp_atomic_store_val_ptr (
+		         as_a <gimple_omp_atomic_store> (stmt)),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 8672b83..1bc176c 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1094,10 +1094,11 @@ gimple_build_omp_atomic_load (tree lhs, tree rhs)
 
    VAL is the value we are storing.  */
 
-gimple
+gimple_omp_atomic_store
 gimple_build_omp_atomic_store (tree val)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0);
+  gimple_omp_atomic_store p =
+    as_a <gimple_omp_atomic_store> (gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0));
   gimple_omp_atomic_store_set_val (p, val);
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index a302529..4513fcb 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1358,7 +1358,7 @@ gimple gimple_build_omp_single (gimple_seq, tree);
 gimple gimple_build_omp_target (gimple_seq, int, tree);
 gimple gimple_build_omp_teams (gimple_seq, tree);
 gimple_omp_atomic_load gimple_build_omp_atomic_load (tree, tree);
-gimple gimple_build_omp_atomic_store (tree);
+gimple_omp_atomic_store gimple_build_omp_atomic_store (tree);
 gimple_transaction gimple_build_transaction (gimple_seq, tree);
 gimple gimple_build_predict (enum br_predictor, enum prediction);
 extern void gimple_seq_add_stmt (gimple_seq *, gimple);
@@ -5367,33 +5367,27 @@ gimple_omp_for_cond (const_gimple gs, size_t i)
 /* Set the value being stored in an atomic store.  */
 
 static inline void
-gimple_omp_atomic_store_set_val (gimple g, tree val)
+gimple_omp_atomic_store_set_val (gimple_omp_atomic_store store_stmt, tree val)
 {
-  gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <gimple_statement_omp_atomic_store *> (g);
-  omp_atomic_store_stmt->val = val;
+  store_stmt->val = val;
 }
 
 
 /* Return the value being stored in an atomic store.  */
 
 static inline tree
-gimple_omp_atomic_store_val (const_gimple g)
+gimple_omp_atomic_store_val (const_gimple_omp_atomic_store store_stmt)
 {
-  const gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <const gimple_statement_omp_atomic_store *> (g);
-  return omp_atomic_store_stmt->val;
+  return store_stmt->val;
 }
 
 
 /* Return a pointer to the value being stored in an atomic store.  */
 
 static inline tree *
-gimple_omp_atomic_store_val_ptr (gimple g)
+gimple_omp_atomic_store_val_ptr (gimple_omp_atomic_store store_stmt)
 {
-  gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <gimple_statement_omp_atomic_store *> (g);
-  return &omp_atomic_store_stmt->val;
+  return &store_stmt->val;
 }
 
 
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 26cc2d0..a969233 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -7308,7 +7308,8 @@ gimplify_omp_atomic (tree *expr_p, gimple_seq *pre_p)
 	     ? NULL : TREE_OPERAND (*expr_p, 1);
   tree type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (addr)));
   tree tmp_load;
-  gimple loadstmt, storestmt;
+  gimple_omp_atomic_load loadstmt;
+  gimple_omp_atomic_store storestmt;
 
   tmp_load = create_tmp_reg (type, NULL);
   if (rhs && goa_stabilize_expr (&rhs, pre_p, addr, tmp_load) < 0)
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 40cba5c..78ec43f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -8188,7 +8188,8 @@ expand_omp_atomic (struct omp_region *region)
   basic_block load_bb = region->entry, store_bb = region->exit;
   gimple_omp_atomic_load load =
     as_a <gimple_omp_atomic_load> (last_stmt (load_bb));
-  gimple store = last_stmt (store_bb);
+  gimple_omp_atomic_store store =
+    as_a <gimple_omp_atomic_store> (last_stmt (store_bb));
   tree loaded_val = gimple_omp_atomic_load_lhs (load);
   tree addr = gimple_omp_atomic_load_rhs (load);
   tree stored_val = gimple_omp_atomic_store_val (store);
-- 
1.8.5.3

