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 03/16] Introduce gimple_bind and use it for accessors.


This updates all of the gimple_bind_* accessors in gimple.h from taking a
plain gimple to taking a gimple_bind (or const_gimple_bind), with the
checking happening at the point of cast.

Various other types are strengthened from gimple to gimple_bind, and from
plain vec<gimple> to vec<gimple_bind>.

gcc/
	* coretypes.h (gimple_bind): New typedef.
	(const_gimple_bind): New typedef.

	* gdbhooks.py (build_pretty_printer): Add gimple_bind
	and its variants, using the gimple printer.

	* gimple-pretty-print.c (dump_gimple_bind): Update type-signature to
	require a gimple_bind rather than just a gimple.

	* gimple.c (gimple_build_bind): Return a gimple_bind rather than
	just a gimple.
	* gimple.h (gimple_build_bind): Likewise.

	* gimple.h (gimple_statement_base::as_a_gimple_bind): New.
	(gimple_statement_base::dyn_cast_gimple_bind): New.
	(gimple_seq_first_stmt_as_a_bind): New.

	* gimple.h (gimple_bind_vars): Update type-signature to
	require a gimple_bind rather than just a gimple, removing
	as_a and hence run-time check.
	(gimple_bind_set_vars): Likewise.
	(gimple_bind_append_vars): Likewise.
	(gimple_bind_body_ptr): Likewise.
	(gimple_bind_body): Likewise.
	(gimple_bind_set_body): Likewise.
	(gimple_bind_add_stmt): Likewise.
	(gimple_bind_add_seq): Likewise.
	(gimple_bind_block): Likewise.
	(gimple_bind_set_block): Likewise.
	* gimplify.c (gimple_push_bind_expr): Likewise.
	(gimple_current_bind_expr): Likewise.
	* tree-inline.c (copy_gimple_bind): Likewise.

	* gimplify.h (gimple_current_bind_expr): Return a gimple_bind
	rather than a plain gimple.
	(gimplify_body): Likewise.
	(gimple_bind_expr_stack): Return a vec<gimple_bind> rather than
	a vec<gimple>.

	* gimplify.c (struct gimplify_ctx): Strengthen field
	"bind_expr_stack" from vec<gimple> to vec<gimple_bind>.
	(gimple_bind_expr_stack): Likewise for type of returned value.

	* gimplify.c (gimplify_body): Strengthen various types from gimple
	to gimple_bind, including the return type.

	* gimplify.c (declare_vars): Introduce "gs" as a generic gimple,
	so that local "scope" can be of type gimple_bind once we've reached
	the region where it must be of code GIMPLE_BIND.

	* gimple-low.c (lower_gimple_bind): Add checked cast to
	gimple_bind, since both callers (lower_function_body and
	lower_stmt) have checked the code for us.

	* gimple.c (gimple_copy): Add checked cast to gimple_bind in
	region guarded by check for code GIMPLE_BIND.
	* gimple-low.c (gimple_stmt_may_fallthru): Likewise.
	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
	* gimple-walk.c (walk_gimple_stmt): Likewise.
	* omp-low.c (scan_omp_1_stmt): Likewise.
	(lower_omp_1): Likewise.
	* tree-cfg.c (verify_gimple_in_seq_2): Likewise.
	(do_warn_unused_result): Likewise.
	* tree-inline.c (remap_gimple_stmt): Likewise.
	(estimate_num_insns): Likewise.
	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.

	* gimplify.c (gimplify_bind_expr): Update local(s) to be a
	gimple_bind rather than just a gimple.
	(gimplify_function_tree): Likewise.
	* omp-low.c (lower_omp_sections): Likewise.
	(lower_omp_single): Likewise.
	(lower_omp_master): Likewise.
	(lower_omp_taskgroup): Likewise.
	(lower_omp_ordered): Likewise.
	(lower_omp_critical): Likewise.
	(lower_omp_taskreg): Likewise.
	(lower_omp_teams): Likewise.
	* omp-low.c (lower_omp_for): Likewise; use
	gimple_seq_first_stmt_as_a_bind to encapsulate the checked cast.
	(lower_omp_target): Likewise.
	* tree-nested.c (finalize_nesting_tree_1): Likewise.

	* gimple.c (empty_stmt_p): Add dyn_cast to a gimple_bind.
	* tree-inline.c (replace_locals_stmt): Add dyn_cast to gimple_bind.

gcc/c-family/
	* c-gimplify.c (add_block_to_enclosing): Strengthen local "stack"
	from being just a vec<gimple> to a vec<gimple_bind>.

gcc/java/
	* java-gimplify.c (java_gimplify_block): Update local to be a
	gimple_bind rather than just a gimple.
---
 gcc/c-family/c-gimplify.c |  4 ++--
 gcc/coretypes.h           |  4 ++++
 gcc/gdbhooks.py           |  4 +++-
 gcc/gimple-low.c          |  5 +++--
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple-walk.c         |  5 +++--
 gcc/gimple.c              | 21 +++++++++++-------
 gcc/gimple.h              | 55 ++++++++++++++++++++++++++++-------------------
 gcc/gimplify.c            | 37 +++++++++++++++----------------
 gcc/gimplify.h            |  6 +++---
 gcc/java/java-gimplify.c  |  2 +-
 gcc/omp-low.c             | 40 +++++++++++++++++++++-------------
 gcc/tree-cfg.c            |  5 +++--
 gcc/tree-inline.c         | 12 ++++++-----
 gcc/tree-nested.c         | 21 ++++++++++--------
 15 files changed, 133 insertions(+), 92 deletions(-)

diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
index 9f79ccb..c9ac07e 100644
--- a/gcc/c-family/c-gimplify.c
+++ b/gcc/c-family/c-gimplify.c
@@ -112,8 +112,8 @@ add_block_to_enclosing (tree block)
 {
   unsigned i;
   tree enclosing;
-  gimple bind;
-  vec<gimple> stack = gimple_bind_expr_stack ();
+  gimple_bind bind;
+  vec<gimple_bind> stack = gimple_bind_expr_stack ();
 
   FOR_EACH_VEC_ELT (stack, i, bind)
     if (gimple_bind_block (bind))
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 250d19f..6bd2e92 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -74,6 +74,10 @@ struct gimple_statement_switch;
 typedef struct gimple_statement_switch *gimple_switch;
 typedef const struct gimple_statement_switch *const_gimple_switch;
 
+struct gimple_statement_bind;
+typedef struct gimple_statement_bind *gimple_bind;
+typedef const struct gimple_statement_bind *const_gimple_bind;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 04f9cde..6330cc3 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -458,7 +458,9 @@ def build_pretty_printer():
 
                               # Keep this in the same order as gimple.def:
                               'gimple_switch', 'const_gimple_switch',
-                              'gimple_statement_switch *'],
+                              'gimple_statement_switch *',
+                              'gimple_bind', 'const_gimple_bind',
+                              'gimple_statement_bind *'],
 
                              'gimple',
                              GimplePrinter)
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 19f2ef8..e35b76e 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -404,7 +404,7 @@ static void
 lower_gimple_bind (gimple_stmt_iterator *gsi, struct lower_data *data)
 {
   tree old_block = data->block;
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_bind stmt = gsi_stmt (*gsi)->as_a_gimple_bind ();
   tree new_block = gimple_bind_block (stmt);
 
   if (new_block)
@@ -598,7 +598,8 @@ gimple_stmt_may_fallthru (gimple stmt)
       return false;
 
     case GIMPLE_BIND:
-      return gimple_seq_may_fallthru (gimple_bind_body (stmt));
+      return gimple_seq_may_fallthru (
+	       gimple_bind_body (stmt->as_a_gimple_bind ()));
 
     case GIMPLE_TRY:
       if (gimple_try_kind (stmt) == GIMPLE_TRY_CATCH)
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index fce6af0..5b4796c 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -889,7 +889,7 @@ dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
    TDF_* in dumpfile.h).  */
 
 static void
-dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_bind (pretty_printer *buffer, gimple_bind gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
@@ -2098,7 +2098,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_BIND:
-      dump_gimple_bind (buffer, gs, spc, flags);
+      dump_gimple_bind (buffer, gs->as_a_gimple_bind (), spc, flags);
       break;
 
     case GIMPLE_CALL:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 4d59ae0..23bce6f 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -541,8 +541,9 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
   switch (gimple_code (stmt))
     {
     case GIMPLE_BIND:
-      ret = walk_gimple_seq_mod (gimple_bind_body_ptr (stmt), callback_stmt,
-				 callback_op, wi);
+      ret =
+	walk_gimple_seq_mod (gimple_bind_body_ptr (stmt->as_a_gimple_bind ()),
+			     callback_stmt, callback_op, wi);
       if (ret)
 	return wi->callback_result;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index c9518e2..206846e 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -513,10 +513,10 @@ gimple_build_nop (void)
    VARS are the variables in BODY.
    BLOCK is the containing block.  */
 
-gimple
+gimple_bind
 gimple_build_bind (tree vars, gimple_seq body, tree block)
 {
-  gimple p = gimple_alloc (GIMPLE_BIND, 0);
+  gimple_bind p = gimple_alloc (GIMPLE_BIND, 0)->as_a_gimple_bind ();
   gimple_bind_set_vars (p, vars);
   if (body)
     gimple_bind_set_body (p, body);
@@ -1248,8 +1248,8 @@ empty_stmt_p (gimple stmt)
 {
   if (gimple_code (stmt) == GIMPLE_NOP)
     return true;
-  if (gimple_code (stmt) == GIMPLE_BIND)
-    return empty_body_p (gimple_bind_body (stmt));
+  if (gimple_bind bind_stmt = stmt->dyn_cast_gimple_bind ())
+    return empty_body_p (gimple_bind_body (bind_stmt));
   return false;
 }
 
@@ -1619,10 +1619,15 @@ gimple_copy (gimple stmt)
       switch (gimple_code (stmt))
 	{
 	case GIMPLE_BIND:
-	  new_seq = gimple_seq_copy (gimple_bind_body (stmt));
-	  gimple_bind_set_body (copy, new_seq);
-	  gimple_bind_set_vars (copy, unshare_expr (gimple_bind_vars (stmt)));
-	  gimple_bind_set_block (copy, gimple_bind_block (stmt));
+	  {
+	    gimple_bind bind_stmt = stmt->as_a_gimple_bind ();
+	    gimple_bind bind_copy = copy->as_a_gimple_bind ();
+	    new_seq = gimple_seq_copy (gimple_bind_body (bind_stmt));
+	    gimple_bind_set_body (bind_copy, new_seq);
+	    gimple_bind_set_vars (bind_copy,
+				  unshare_expr (gimple_bind_vars (bind_stmt)));
+	    gimple_bind_set_block (bind_copy, gimple_bind_block (bind_stmt));
+	  }
 	  break;
 
 	case GIMPLE_CATCH:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index f1f5e8d..60f0d96 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -217,6 +217,12 @@ public:
     return as_a <gimple_statement_switch> (this);
   }
 
+  inline gimple_bind
+  as_a_gimple_bind ()
+  {
+    return as_a <gimple_statement_bind> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -231,6 +237,12 @@ public:
     return dyn_cast <gimple_statement_switch> (this);
   }
 
+  inline gimple_bind
+  dyn_cast_gimple_bind ()
+  {
+    return dyn_cast <gimple_statement_bind> (this);
+  }
+
 };
 
 
@@ -1231,7 +1243,7 @@ void gimple_cond_set_condition_from_tree (gimple, tree);
 gimple gimple_build_label (tree label);
 gimple gimple_build_goto (tree dest);
 gimple gimple_build_nop (void);
-gimple gimple_build_bind (tree, gimple_seq, tree);
+gimple_bind gimple_build_bind (tree, gimple_seq, tree);
 gimple gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
 			     vec<tree, va_gc> *, vec<tree, va_gc> *,
 			     vec<tree, va_gc> *);
@@ -1365,6 +1377,16 @@ gimple_seq_first_stmt (gimple_seq s)
   return n;
 }
 
+/* Return the first statement in GIMPLE sequence S as a gimple_bind,
+   verifying that it has code GIMPLE_BIND in a checked build.  */
+
+static inline gimple_bind
+gimple_seq_first_stmt_as_a_bind (gimple_seq s)
+{
+  gimple_seq_node n = gimple_seq_first (s);
+  return as_a <gimple_statement_bind> (n);
+}
+
 
 /* Return the last node in GIMPLE sequence S.  */
 
@@ -3124,10 +3146,8 @@ gimple_goto_set_dest (gimple gs, tree dest)
 /* Return the variables declared in the GIMPLE_BIND statement GS.  */
 
 static inline tree
-gimple_bind_vars (const_gimple gs)
+gimple_bind_vars (const_gimple_bind bind_stmt)
 {
-  const gimple_statement_bind *bind_stmt =
-    as_a <const gimple_statement_bind> (gs);
   return bind_stmt->vars;
 }
 
@@ -3136,9 +3156,8 @@ gimple_bind_vars (const_gimple gs)
    statement GS.  */
 
 static inline void
-gimple_bind_set_vars (gimple gs, tree vars)
+gimple_bind_set_vars (gimple_bind bind_stmt, tree vars)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   bind_stmt->vars = vars;
 }
 
@@ -3147,24 +3166,22 @@ gimple_bind_set_vars (gimple gs, tree vars)
    statement GS.  */
 
 static inline void
-gimple_bind_append_vars (gimple gs, tree vars)
+gimple_bind_append_vars (gimple_bind bind_stmt, tree vars)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   bind_stmt->vars = chainon (bind_stmt->vars, vars);
 }
 
 
 static inline gimple_seq *
-gimple_bind_body_ptr (gimple gs)
+gimple_bind_body_ptr (gimple_bind bind_stmt)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   return &bind_stmt->body;
 }
 
 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS.  */
 
 static inline gimple_seq
-gimple_bind_body (gimple gs)
+gimple_bind_body (gimple_bind gs)
 {
   return *gimple_bind_body_ptr (gs);
 }
@@ -3174,9 +3191,8 @@ gimple_bind_body (gimple gs)
    statement GS.  */
 
 static inline void
-gimple_bind_set_body (gimple gs, gimple_seq seq)
+gimple_bind_set_body (gimple_bind bind_stmt, gimple_seq seq)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   bind_stmt->body = seq;
 }
 
@@ -3184,9 +3200,8 @@ gimple_bind_set_body (gimple gs, gimple_seq seq)
 /* Append a statement to the end of a GIMPLE_BIND's body.  */
 
 static inline void
-gimple_bind_add_stmt (gimple gs, gimple stmt)
+gimple_bind_add_stmt (gimple_bind bind_stmt, gimple stmt)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   gimple_seq_add_stmt (&bind_stmt->body, stmt);
 }
 
@@ -3194,9 +3209,8 @@ gimple_bind_add_stmt (gimple gs, gimple stmt)
 /* Append a sequence of statements to the end of a GIMPLE_BIND's body.  */
 
 static inline void
-gimple_bind_add_seq (gimple gs, gimple_seq seq)
+gimple_bind_add_seq (gimple_bind bind_stmt, gimple_seq seq)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   gimple_seq_add_seq (&bind_stmt->body, seq);
 }
 
@@ -3205,10 +3219,8 @@ gimple_bind_add_seq (gimple gs, gimple_seq seq)
    GS.  This is analogous to the BIND_EXPR_BLOCK field in trees.  */
 
 static inline tree
-gimple_bind_block (const_gimple gs)
+gimple_bind_block (const_gimple_bind bind_stmt)
 {
-  const gimple_statement_bind *bind_stmt =
-    as_a <const gimple_statement_bind> (gs);
   return bind_stmt->block;
 }
 
@@ -3217,9 +3229,8 @@ gimple_bind_block (const_gimple gs)
    statement GS.  */
 
 static inline void
-gimple_bind_set_block (gimple gs, tree block)
+gimple_bind_set_block (gimple_bind bind_stmt, tree block)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   gcc_gimple_checking_assert (block == NULL_TREE
 			      || TREE_CODE (block) == BLOCK);
   bind_stmt->block = block;
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 2e8c657..0ff03c7 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -112,7 +112,7 @@ struct gimplify_ctx
 {
   struct gimplify_ctx *prev_context;
 
-  vec<gimple> bind_expr_stack;
+  vec<gimple_bind> bind_expr_stack;
   tree temps;
   gimple_seq conditional_cleanups;
   tree exit_label;
@@ -262,10 +262,10 @@ pop_gimplify_context (gimple body)
 /* Push a GIMPLE_BIND tuple onto the stack of bindings.  */
 
 static void
-gimple_push_bind_expr (gimple gimple_bind)
+gimple_push_bind_expr (gimple_bind bind_stmt)
 {
   gimplify_ctxp->bind_expr_stack.reserve (8);
-  gimplify_ctxp->bind_expr_stack.safe_push (gimple_bind);
+  gimplify_ctxp->bind_expr_stack.safe_push (bind_stmt);
 }
 
 /* Pop the first element off the stack of bindings.  */
@@ -278,7 +278,7 @@ gimple_pop_bind_expr (void)
 
 /* Return the first element of the stack of bindings.  */
 
-gimple
+gimple_bind
 gimple_current_bind_expr (void)
 {
   return gimplify_ctxp->bind_expr_stack.last ();
@@ -286,7 +286,7 @@ gimple_current_bind_expr (void)
 
 /* Return the stack of bindings created during gimplification.  */
 
-vec<gimple> 
+vec<gimple_bind>
 gimple_bind_expr_stack (void)
 {
   return gimplify_ctxp->bind_expr_stack;
@@ -564,14 +564,14 @@ get_initialized_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p)
    generate debug info for them; otherwise don't.  */
 
 void
-declare_vars (tree vars, gimple scope, bool debug_info)
+declare_vars (tree vars, gimple gs, bool debug_info)
 {
   tree last = vars;
   if (last)
     {
       tree temps, block;
 
-      gcc_assert (gimple_code (scope) == GIMPLE_BIND);
+      gimple_bind scope = gs->as_a_gimple_bind ();
 
       temps = nreverse (last);
 
@@ -1024,7 +1024,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
   tree bind_expr = *expr_p;
   bool old_save_stack = gimplify_ctxp->save_stack;
   tree t;
-  gimple gimple_bind;
+  gimple_bind gimple_bind;
   gimple_seq body, cleanup;
   gimple stack_save;
 
@@ -8482,12 +8482,13 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p)
    containing the sequence of corresponding GIMPLE statements.  If DO_PARMS
    is true, also gimplify the parameters.  */
 
-gimple
+gimple_bind
 gimplify_body (tree fndecl, bool do_parms)
 {
   location_t saved_location = input_location;
   gimple_seq parm_stmts, seq;
-  gimple outer_bind;
+  gimple outer_stmt;
+  gimple_bind outer_bind;
   struct cgraph_node *cgn;
 
   timevar_push (TV_TREE_GIMPLIFY);
@@ -8527,18 +8528,18 @@ gimplify_body (tree fndecl, bool do_parms)
   /* Gimplify the function's body.  */
   seq = NULL;
   gimplify_stmt (&DECL_SAVED_TREE (fndecl), &seq);
-  outer_bind = gimple_seq_first_stmt (seq);
-  if (!outer_bind)
+  outer_stmt = gimple_seq_first_stmt (seq);
+  if (!outer_stmt)
     {
-      outer_bind = gimple_build_nop ();
-      gimplify_seq_add_stmt (&seq, outer_bind);
+      outer_stmt = gimple_build_nop ();
+      gimplify_seq_add_stmt (&seq, outer_stmt);
     }
 
   /* The body must contain exactly one statement, a GIMPLE_BIND.  If this is
      not the case, wrap everything in a GIMPLE_BIND to make it so.  */
-  if (gimple_code (outer_bind) == GIMPLE_BIND
+  if (gimple_code (outer_stmt) == GIMPLE_BIND
       && gimple_seq_first (seq) == gimple_seq_last (seq))
-    ;
+    outer_bind = as_a<gimple_statement_bind> (outer_stmt);
   else
     outer_bind = gimple_build_bind (NULL_TREE, seq, NULL);
 
@@ -8652,7 +8653,7 @@ gimplify_function_tree (tree fndecl)
 {
   tree parm, ret;
   gimple_seq seq;
-  gimple bind;
+  gimple_bind bind;
 
   gcc_assert (!gimple_body (fndecl));
 
@@ -8696,7 +8697,7 @@ gimplify_function_tree (tree fndecl)
       && !flag_instrument_functions_exclude_p (fndecl))
     {
       tree x;
-      gimple new_bind;
+      gimple_bind new_bind;
       gimple tf;
       gimple_seq cleanup = NULL, body = NULL;
       tree tmp_var;
diff --git a/gcc/gimplify.h b/gcc/gimplify.h
index 91000d1..c1fa2a2 100644
--- a/gcc/gimplify.h
+++ b/gcc/gimplify.h
@@ -53,8 +53,8 @@ extern void free_gimplify_stack (void);
 extern void push_gimplify_context (bool in_ssa = false,
 				   bool rhs_cond_ok = false);
 extern void pop_gimplify_context (gimple);
-extern gimple gimple_current_bind_expr (void);
-extern vec<gimple> gimple_bind_expr_stack (void);
+extern gimple_bind gimple_current_bind_expr (void);
+extern vec<gimple_bind> gimple_bind_expr_stack (void);
 extern void gimplify_and_add (tree, gimple_seq *);
 extern tree get_formal_tmp_var (tree, gimple_seq *);
 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
@@ -75,7 +75,7 @@ extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
 
 extern void gimplify_type_sizes (tree, gimple_seq *);
 extern void gimplify_one_sizepos (tree *, gimple_seq *);
-extern gimple gimplify_body (tree, bool);
+extern gimple_bind gimplify_body (tree, bool);
 extern void gimplify_function_tree (tree);
 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
 						  gimple_seq *);
diff --git a/gcc/java/java-gimplify.c b/gcc/java/java-gimplify.c
index cf1f970..f8d3c26 100644
--- a/gcc/java/java-gimplify.c
+++ b/gcc/java/java-gimplify.c
@@ -128,7 +128,7 @@ java_gimplify_block (tree java_block)
 {
   tree decls = BLOCK_VARS (java_block);
   tree body = BLOCK_EXPR_BODY (java_block);
-  gimple outer = gimple_current_bind_expr ();
+  gimple_bind outer = gimple_current_bind_expr ();
   tree block;
 
   /* Don't bother with empty blocks.  */
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 13fe3b2..546aff9 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2678,7 +2678,9 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 
 	*handled_ops_p = false;
 	if (ctx)
-	  for (var = gimple_bind_vars (stmt); var ; var = DECL_CHAIN (var))
+	  for (var = gimple_bind_vars (stmt->as_a_gimple_bind ());
+	       var ;
+	       var = DECL_CHAIN (var))
 	    insert_decl_map (&ctx->cb, var, var);
       }
       break;
@@ -8394,7 +8396,8 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block, control;
   gimple_stmt_iterator tgsi;
-  gimple stmt, new_stmt, bind, t;
+  gimple stmt, t;
+  gimple_bind new_stmt, bind;
   gimple_seq ilist, dlist, olist, new_body;
 
   stmt = gsi_stmt (*gsi_p);
@@ -8603,7 +8606,8 @@ static void
 lower_omp_single (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
-  gimple t, bind, single_stmt = gsi_stmt (*gsi_p);
+  gimple t, single_stmt = gsi_stmt (*gsi_p);
+  gimple_bind bind;
   gimple_seq bind_body, bind_body_tail = NULL, dlist;
 
   push_gimplify_context ();
@@ -8661,7 +8665,8 @@ static void
 lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block, lab = NULL, x, bfn_decl;
-  gimple stmt = gsi_stmt (*gsi_p), bind;
+  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_bind bind;
   location_t loc = gimple_location (stmt);
   gimple_seq tseq;
 
@@ -8701,7 +8706,8 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 static void
 lower_omp_taskgroup (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
-  gimple stmt = gsi_stmt (*gsi_p), bind, x;
+  gimple stmt = gsi_stmt (*gsi_p), x;
+  gimple_bind bind;
   tree block = make_node (BLOCK);
 
   bind = gimple_build_bind (NULL, NULL, block);
@@ -8729,7 +8735,8 @@ static void
 lower_omp_ordered (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
-  gimple stmt = gsi_stmt (*gsi_p), bind, x;
+  gimple stmt = gsi_stmt (*gsi_p), x;
+  gimple_bind bind;
 
   push_gimplify_context ();
 
@@ -8772,7 +8779,8 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
   tree name, lock, unlock;
-  gimple stmt = gsi_stmt (*gsi_p), bind;
+  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_bind bind;
   location_t loc = gimple_location (stmt);
   gimple_seq tbody;
 
@@ -8914,7 +8922,8 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree *rhs_p, block;
   struct omp_for_data fd, *fdp = NULL;
-  gimple stmt = gsi_stmt (*gsi_p), new_stmt;
+  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_bind new_stmt;
   gimple_seq omp_for_body, body, dlist;
   size_t i;
 
@@ -8935,7 +8944,8 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   if (!gimple_seq_empty_p (omp_for_body)
       && gimple_code (gimple_seq_first_stmt (omp_for_body)) == GIMPLE_BIND)
     {
-      tree vars = gimple_bind_vars (gimple_seq_first_stmt (omp_for_body));
+      tree vars =
+	gimple_bind_vars (gimple_seq_first_stmt_as_a_bind (omp_for_body));
       gimple_bind_append_vars (new_stmt, vars);
     }
 
@@ -9423,12 +9433,12 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   tree clauses;
   tree child_fn, t;
   gimple stmt = gsi_stmt (*gsi_p);
-  gimple par_bind, bind, dep_bind = NULL;
+  gimple_bind par_bind, bind, dep_bind = NULL;
   gimple_seq par_body, olist, ilist, par_olist, par_rlist, par_ilist, new_body;
   location_t loc = gimple_location (stmt);
 
   clauses = gimple_omp_taskreg_clauses (stmt);
-  par_bind = gimple_seq_first_stmt (gimple_omp_body (stmt));
+  par_bind = gimple_seq_first_stmt_as_a_bind (gimple_omp_body (stmt));
   par_body = gimple_bind_body (par_bind);
   child_fn = ctx->cb.dst_fn;
   if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
@@ -9545,7 +9555,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 tgt_bind = NULL, bind;
+  gimple_bind tgt_bind = NULL, bind;
   gimple_seq tgt_body = NULL, olist, ilist, new_body;
   location_t loc = gimple_location (stmt);
   int kind = gimple_omp_target_kind (stmt);
@@ -9554,7 +9564,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   clauses = gimple_omp_target_clauses (stmt);
   if (kind == GF_OMP_TARGET_KIND_REGION)
     {
-      tgt_bind = gimple_seq_first_stmt (gimple_omp_body (stmt));
+      tgt_bind = gimple_seq_first_stmt_as_a_bind (gimple_omp_body (stmt));
       tgt_body = gimple_bind_body (tgt_bind);
     }
   else if (kind == GF_OMP_TARGET_KIND_DATA)
@@ -9850,7 +9860,7 @@ lower_omp_teams (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   push_gimplify_context ();
 
   tree block = make_node (BLOCK);
-  gimple bind = gimple_build_bind (NULL, NULL, block);
+  gimple_bind bind = gimple_build_bind (NULL, NULL, block);
   gsi_replace (gsi_p, bind, true);
   gimple_seq bind_body = NULL;
   gimple_seq dlist = NULL;
@@ -9979,7 +9989,7 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       lower_omp (gimple_transaction_body_ptr (stmt), ctx);
       break;
     case GIMPLE_BIND:
-      lower_omp (gimple_bind_body_ptr (stmt), ctx);
+      lower_omp (gimple_bind_body_ptr (stmt->as_a_gimple_bind ()), ctx);
       break;
     case GIMPLE_OMP_PARALLEL:
     case GIMPLE_OMP_TASK:
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 290bda1..52ee66e 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4453,7 +4453,8 @@ verify_gimple_in_seq_2 (gimple_seq stmts)
       switch (gimple_code (stmt))
         {
 	case GIMPLE_BIND:
-	  err |= verify_gimple_in_seq_2 (gimple_bind_body (stmt));
+	  err |= verify_gimple_in_seq_2 (
+                   gimple_bind_body (stmt->as_a_gimple_bind ()));
 	  break;
 
 	case GIMPLE_TRY:
@@ -8196,7 +8197,7 @@ do_warn_unused_result (gimple_seq seq)
       switch (gimple_code (g))
 	{
 	case GIMPLE_BIND:
-	  do_warn_unused_result (gimple_bind_body (g));
+	  do_warn_unused_result (gimple_bind_body (g->as_a_gimple_bind ()));
 	  break;
 	case GIMPLE_TRY:
 	  do_warn_unused_result (gimple_try_eval (g));
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index b1682b4..9879d11 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -744,7 +744,7 @@ remap_gimple_seq (gimple_seq body, copy_body_data *id)
    block using the mapping information in ID.  */
 
 static gimple
-copy_gimple_bind (gimple stmt, copy_body_data *id)
+copy_gimple_bind (gimple_bind stmt, copy_body_data *id)
 {
   gimple new_bind;
   tree new_block, new_vars;
@@ -1290,7 +1290,7 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
       switch (gimple_code (stmt))
 	{
 	case GIMPLE_BIND:
-	  copy = copy_gimple_bind (stmt, id);
+	  copy = copy_gimple_bind (stmt->as_a_gimple_bind (), id);
 	  break;
 
 	case GIMPLE_CATCH:
@@ -3884,7 +3884,9 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
       return 10;
 
     case GIMPLE_BIND:
-      return estimate_num_insns_seq (gimple_bind_body (stmt), weights);
+      return estimate_num_insns_seq (
+	       gimple_bind_body (stmt->as_a_gimple_bind ()),
+	       weights);
 
     case GIMPLE_EH_FILTER:
       return estimate_num_insns_seq (gimple_eh_filter_failure (stmt), weights);
@@ -4797,9 +4799,9 @@ replace_locals_stmt (gimple_stmt_iterator *gsip,
 		     struct walk_stmt_info *wi)
 {
   copy_body_data *id = (copy_body_data *) wi->info;
-  gimple stmt = gsi_stmt (*gsip);
+  gimple gs = gsi_stmt (*gsip);
 
-  if (gimple_code (stmt) == GIMPLE_BIND)
+  if (gimple_bind stmt = dyn_cast <gimple_statement_bind> (gs))
     {
       tree block = gimple_bind_block (stmt);
 
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 2d6a56d..ebc7142 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1328,11 +1328,14 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_BIND:
-      if (!optimize && gimple_bind_block (stmt))
-	note_nonlocal_block_vlas (info, gimple_bind_block (stmt));
-
-      *handled_ops_p = false;
-      return NULL_TREE;
+      {
+	gimple_bind bind_stmt = stmt->as_a_gimple_bind ();
+	if (!optimize && gimple_bind_block (bind_stmt))
+	  note_nonlocal_block_vlas (info,
+				    gimple_bind_block (bind_stmt));
+	*handled_ops_p = false;
+	return NULL_TREE;
+      }
 
     case GIMPLE_COND:
       wi->val_only = true;
@@ -2477,9 +2480,9 @@ finalize_nesting_tree_1 (struct nesting_info *root)
   /* If we created initialization statements, insert them.  */
   if (stmt_list)
     {
-      gimple bind;
+      gimple_bind bind;
       annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
-      bind = gimple_seq_first_stmt (gimple_body (context));
+      bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context));
       gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
       gimple_bind_set_body (bind, stmt_list);
     }
@@ -2508,7 +2511,7 @@ finalize_nesting_tree_1 (struct nesting_info *root)
   if (root->debug_var_chain)
     {
       tree debug_var;
-      gimple scope;
+      gimple_bind scope;
 
       remap_vla_decls (DECL_INITIAL (root->context), root);
 
@@ -2563,7 +2566,7 @@ finalize_nesting_tree_1 (struct nesting_info *root)
 	  pointer_map_destroy (id.cb.decl_map);
 	}
 
-      scope = gimple_seq_first_stmt (gimple_body (root->context));
+      scope = gimple_seq_first_stmt_as_a_bind (gimple_body (root->context));
       if (gimple_bind_block (scope))
 	declare_vars (root->debug_var_chain, scope, true);
       else
-- 
1.7.11.7


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