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 43/89] Introduce gimple_omp_target


gcc/
	* coretypes.h (gimple_omp_target): New typedef.
	(const_gimple_omp_target): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_target): New.
	(gimple_build_omp_target): Return a gimple_omp_target
	rather than a plain gimple.
	(gimple_omp_target_set_clauses): Require a gimple_omp_target
	rather than a plain gimple.
	(gimple_omp_target_set_kind): Likewise.
	(gimple_omp_target_child_fn_ptr): Likewise.
	(gimple_omp_target_set_child_fn): Likewise.
	(gimple_omp_target_data_arg_ptr): Likewise.
	(gimple_omp_target_set_data_arg): Likewise.
	(gimple_omp_target_child_fn): Require a const_gimple_omp_target
	rather than a plain const_gimple.
	(gimple_omp_target_data_arg): Likewise.

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

	* gimple.c (gimple_build_omp_target): Return a gimple_omp_target
	rather than a plain gimple.

	* gimplify.c (gimplify_omp_target_update): Strengthen local "stmt"
	from gimple to gimple_omp_target.

	* omp-low.c (scan_omp_target): Require a gimple_omp_target rather
	than a plain gimple.
	(scan_omp_1_stmt): Add checked cast to gimple_omp_target within
	GIMPLE_OMP_TARGET case of switch statement.
	(expand_omp_target): Strengthen local "entry_stmt" from gimple to
	gimple_omp_target.
	(lower_omp_target): Likewise for "stmt".
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  6 ++++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 54 +++++++++++++++++++++--------------------------
 gcc/gimplify.c            |  2 +-
 gcc/omp-low.c             | 11 +++++-----
 6 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 6d7bb0f..1ac8765 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -179,6 +179,10 @@ 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;
 
+struct gimple_statement_omp_target;
+typedef struct gimple_statement_omp_target *gimple_omp_target;
+typedef const struct gimple_statement_omp_target *const_gimple_omp_target;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d024730..a5d8706 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1281,7 +1281,8 @@ dump_gimple_omp_single (pretty_printer *buffer, gimple_omp_single gs,
 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_omp_target (pretty_printer *buffer, gimple_omp_target gs,
+			int spc, int flags)
 {
   const char *kind;
   switch (gimple_omp_target_kind (gs))
@@ -2178,7 +2179,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_TARGET:
-      dump_gimple_omp_target (buffer, gs, spc, flags);
+      dump_gimple_omp_target (buffer, gs->as_a_gimple_omp_target (), spc,
+			      flags);
       break;
 
     case GIMPLE_OMP_TEAMS:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index ba9adb8..2ba7c5b 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1051,10 +1051,11 @@ gimple_build_omp_single (gimple_seq body, tree clauses)
    BODY is the sequence of statements that will be executed.
    CLAUSES are any of the OMP target construct's clauses.  */
 
-gimple
+gimple_omp_target
 gimple_build_omp_target (gimple_seq body, int kind, tree clauses)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_TARGET, 0);
+  gimple_omp_target p =
+    gimple_alloc (GIMPLE_OMP_TARGET, 0)->as_a_gimple_omp_target ();
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_target_set_clauses (p, clauses);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 485cec4..d791a28 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -384,6 +384,12 @@ public:
     return as_a <gimple_statement_omp_single> (this);
   }
 
+  inline gimple_omp_target
+  as_a_gimple_omp_target ()
+  {
+    return as_a <gimple_statement_omp_target> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1643,7 +1649,7 @@ gimple gimple_build_omp_return (bool);
 gimple 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 gimple_build_omp_target (gimple_seq, int, tree);
+gimple_omp_target 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_omp_atomic_store gimple_build_omp_atomic_store (tree);
@@ -5367,13 +5373,12 @@ gimple_omp_target_clauses_ptr (gimple gs)
 }
 
 
-/* Set CLAUSES to be the clauses associated with OMP_TARGET GS.  */
+/* Set CLAUSES to be the clauses associated with OMP_TARGET_STMT.  */
 
 static inline void
-gimple_omp_target_set_clauses (gimple gs, tree clauses)
+gimple_omp_target_set_clauses (gimple_omp_target omp_target_stmt,
+			       tree clauses)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   omp_target_stmt->clauses = clauses;
 }
 
@@ -5391,55 +5396,47 @@ gimple_omp_target_kind (const_gimple g)
 /* Set the OMP target kind.  */
 
 static inline void
-gimple_omp_target_set_kind (gimple g, int kind)
+gimple_omp_target_set_kind (gimple_omp_target g, int kind)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
   g->subcode = (g->subcode & ~GF_OMP_TARGET_KIND_MASK)
 		      | (kind & GF_OMP_TARGET_KIND_MASK);
 }
 
 
-/* Return the child function used to hold the body of OMP_TARGET GS.  */
+/* Return the child function used to hold the body of OMP_TARGET_STMT.  */
 
 static inline tree
-gimple_omp_target_child_fn (const_gimple gs)
+gimple_omp_target_child_fn (const_gimple_omp_target omp_target_stmt)
 {
-  const gimple_statement_omp_target *omp_target_stmt =
-    as_a <const gimple_statement_omp_target> (gs);
   return omp_target_stmt->child_fn;
 }
 
 /* Return a pointer to the child function used to hold the body of
-   OMP_TARGET GS.  */
+   OMP_TARGET_STMT.  */
 
 static inline tree *
-gimple_omp_target_child_fn_ptr (gimple gs)
+gimple_omp_target_child_fn_ptr (gimple_omp_target omp_target_stmt)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   return &omp_target_stmt->child_fn;
 }
 
 
-/* Set CHILD_FN to be the child function for OMP_TARGET GS.  */
+/* Set CHILD_FN to be the child function for OMP_TARGET_STMT.  */
 
 static inline void
-gimple_omp_target_set_child_fn (gimple gs, tree child_fn)
+gimple_omp_target_set_child_fn (gimple_omp_target omp_target_stmt,
+				tree child_fn)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   omp_target_stmt->child_fn = child_fn;
 }
 
 
 /* Return the artificial argument used to send variables and values
-   from the parent to the children threads in OMP_TARGET GS.  */
+   from the parent to the children threads in OMP_TARGET_STMT.  */
 
 static inline tree
-gimple_omp_target_data_arg (const_gimple gs)
+gimple_omp_target_data_arg (const_gimple_omp_target omp_target_stmt)
 {
-  const gimple_statement_omp_target *omp_target_stmt =
-    as_a <const gimple_statement_omp_target> (gs);
   return omp_target_stmt->data_arg;
 }
 
@@ -5447,21 +5444,18 @@ gimple_omp_target_data_arg (const_gimple gs)
 /* Return a pointer to the data argument for OMP_TARGET GS.  */
 
 static inline tree *
-gimple_omp_target_data_arg_ptr (gimple gs)
+gimple_omp_target_data_arg_ptr (gimple_omp_target omp_target_stmt)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   return &omp_target_stmt->data_arg;
 }
 
 
-/* Set DATA_ARG to be the data argument for OMP_TARGET GS.  */
+/* Set DATA_ARG to be the data argument for OMP_TARGET_STMT.  */
 
 static inline void
-gimple_omp_target_set_data_arg (gimple gs, tree data_arg)
+gimple_omp_target_set_data_arg (gimple_omp_target omp_target_stmt,
+				tree data_arg)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   omp_target_stmt->data_arg = data_arg;
 }
 
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 763b3c0..1c7481d 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6971,7 +6971,7 @@ static void
 gimplify_omp_target_update (tree *expr_p, gimple_seq *pre_p)
 {
   tree expr = *expr_p;
-  gimple stmt;
+  gimple_omp_target stmt;
 
   gimplify_scan_omp_clauses (&OMP_TARGET_UPDATE_CLAUSES (expr), pre_p,
 			     ORT_WORKSHARE);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index f17226b..9809cf4 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2180,7 +2180,7 @@ scan_omp_single (gimple_omp_single stmt, omp_context *outer_ctx)
 /* Scan an OpenMP target{, data, update} directive.  */
 
 static void
-scan_omp_target (gimple stmt, omp_context *outer_ctx)
+scan_omp_target (gimple_omp_target stmt, omp_context *outer_ctx)
 {
   omp_context *ctx;
   tree name;
@@ -2664,7 +2664,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_TARGET:
-      scan_omp_target (stmt, ctx);
+      scan_omp_target (stmt->as_a_gimple_omp_target (), ctx);
       break;
 
     case GIMPLE_OMP_TEAMS:
@@ -7810,10 +7810,11 @@ expand_omp_target (struct omp_region *region)
   struct function *child_cfun = NULL;
   tree child_fn = NULL_TREE, block, t;
   gimple_stmt_iterator gsi;
-  gimple entry_stmt, stmt;
+  gimple_omp_target entry_stmt;
+  gimple stmt;
   edge e;
 
-  entry_stmt = last_stmt (region->entry);
+  entry_stmt = last_stmt (region->entry)->as_a_gimple_omp_target ();
   new_bb = region->entry;
   int kind = gimple_omp_target_kind (entry_stmt);
   if (kind == GF_OMP_TARGET_KIND_REGION)
@@ -9589,7 +9590,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree clauses;
   tree child_fn, t, c;
-  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_omp_target stmt = gsi_stmt (*gsi_p)->as_a_gimple_omp_target ();
   gimple_bind tgt_bind = NULL, bind;
   gimple_seq tgt_body = NULL, olist, ilist, new_body;
   location_t loc = gimple_location (stmt);
-- 
1.8.5.3


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