This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 35/89] 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_statement_base::as_a_gimple_omp_atomic_store):
	New.
	(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              | 26 +++++++++++++-------------
 gcc/gimplify.c            |  3 ++-
 gcc/omp-low.c             |  3 ++-
 7 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 2fb510f..34c160e 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -150,6 +150,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 bf0d73c..5cbda7d 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1994,8 +1994,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)
     {
@@ -2155,7 +2155,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,
+				    gs->as_a_gimple_omp_atomic_store (),
+				    spc, flags);
       break;
 
     case GIMPLE_OMP_FOR:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index bbfc20b..f15d1f3 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 (
+		         stmt->as_a_gimple_omp_atomic_store ()),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 797726b..c45cc48 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1093,10 +1093,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 =
+    gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0)->as_a_gimple_omp_atomic_store ();
   gimple_omp_atomic_store_set_val (p, val);
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index f255ff0..b74ff4b 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -342,6 +342,12 @@ public:
     return as_a <gimple_statement_omp_atomic_load> (this);
   }
 
+  inline gimple_omp_atomic_store
+  as_a_gimple_omp_atomic_store ()
+  {
+    return as_a <gimple_statement_omp_atomic_store> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1586,7 +1592,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);
@@ -5562,33 +5568,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 f8c3aff..27058a8 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -7099,7 +7099,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 edcd0ec..22ea34f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -7734,7 +7734,8 @@ expand_omp_atomic (struct omp_region *region)
   basic_block load_bb = region->entry, store_bb = region->exit;
   gimple_omp_atomic_load load =
     last_stmt (load_bb)->as_a_gimple_omp_atomic_load ();
-  gimple store = last_stmt (store_bb);
+  gimple_omp_atomic_store store =
+    last_stmt (store_bb)->as_a_gimple_omp_atomic_store ();
   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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]