gcc/
        * coretypes.h (gimple_eh_dispatch): New typedef.
        (const_gimple_eh_dispatch): New typedef.

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

        * gimple-streamer-in.c (input_gimple_stmt): Likewise.

        * gimple-streamer-out.c (output_gimple_stmt): Likewise.

        * gimple.c (gimple_build_eh_dispatch): Return a gimple_eh_dispatch
        rather than a plain gimple.

        * gimple.h (gimple_statement_base::as_a_gimple_eh_dispatch): New.
        (gimple_build_eh_dispatch): Return a gimple_eh_dispatch rather
        than a plain gimple.
        (gimple_eh_dispatch_region): Require a const_gimple_eh_dispatch
        rather than a plain const_gimple.
        (gimple_eh_dispatch_set_region): Require a gimple_eh_dispatch
        rather than a plain gimple.

        * tree-cfg.c (make_edges): Add a checked cast to gimple_eh_dispatch
        within GIMPLE_EH_DISPATCH case of switch statement.
        (gimple_verify_flow_info): Likewise.
        (gimple_redirect_edge_and_branch): Likewise.
        (move_stmt_r): Likewise, adding a local.

        * tree-eh.c (emit_eh_dispatch): Convert local from gimple to
        gimple_eh_dispatch.
        (make_eh_dispatch_edges): Require a gimple_eh_dispatch rather than
        a plain gimple.
        (redirect_eh_dispatch_edge): Likewise.
        (lower_eh_dispatch): Likewise.
        (execute_lower_eh_dispatch): Add a checked cast to
        gimple_eh_dispatch.
        (mark_reachable_handlers): Likewise.
        (verify_eh_dispatch_edge): Require a gimple_eh_dispatch rather
        than a plain gimple.

        * tree-eh.h (make_eh_dispatch_edges): Likewise.
        (redirect_eh_dispatch_edge): Likewise.
        (verify_eh_dispatch_edge): Likewise.

        * tree-inline.c (remap_gimple_stmt): Add a checked cast to
        gimple_eh_dispatch within GIMPLE_EH_DISPATCH case of switch
        statement, adding a local.
        (copy_edges_for_bb): Add a checked cast to gimple_eh_dispatch.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  5 +++--
 gcc/gimple-streamer-in.c  |  3 ++-
 gcc/gimple-streamer-out.c |  4 +++-
 gcc/gimple.c              |  8 ++++----
 gcc/gimple.h              | 21 ++++++++++++---------
 gcc/tree-cfg.c            | 12 +++++++-----
 gcc/tree-eh.c             | 17 ++++++++++-------
 gcc/tree-eh.h             |  6 +++---
 gcc/tree-inline.c         |  7 ++++---
 10 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 379ac6a..b997a8d 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -133,6 +133,10 @@ struct gimple_statement_resx;
 typedef struct gimple_statement_resx *gimple_resx;
 typedef const struct gimple_statement_resx *const_gimple_resx;
 
+struct gimple_statement_eh_dispatch;
+typedef struct gimple_statement_eh_dispatch *gimple_eh_dispatch;
+typedef const struct gimple_statement_eh_dispatch *const_gimple_eh_dispatch;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 93ac677..28234cb 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1059,7 +1059,7 @@ dump_gimple_resx (pretty_printer *buffer, gimple_resx gs, 
int spc, int flags)
 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_eh_dispatch (pretty_printer *buffer, gimple_eh_dispatch gs, int 
spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
@@ -2224,7 +2224,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int 
spc, int flags)
       break;
 
     case GIMPLE_EH_DISPATCH:
-      dump_gimple_eh_dispatch (buffer, gs, spc, flags);
+      dump_gimple_eh_dispatch (buffer, gs->as_a_gimple_eh_dispatch (), spc,
+                              flags);
       break;
 
     case GIMPLE_DEBUG:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 4662832..4fb0b41 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -134,7 +134,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct 
data_in *data_in,
       break;
 
     case GIMPLE_EH_DISPATCH:
-      gimple_eh_dispatch_set_region (stmt, streamer_read_hwi (ib));
+      gimple_eh_dispatch_set_region (stmt->as_a_gimple_eh_dispatch (),
+                                    streamer_read_hwi (ib));
       break;
 
     case GIMPLE_ASM:
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 521e789..5d3adf8 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -108,7 +108,9 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
       break;
 
     case GIMPLE_EH_DISPATCH:
-      streamer_write_hwi (ob, gimple_eh_dispatch_region (stmt));
+      streamer_write_hwi (ob,
+                         gimple_eh_dispatch_region (
+                           stmt->as_a_gimple_eh_dispatch ()));
       break;
 
     case GIMPLE_ASM:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 88d9203..e74fad3 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -756,12 +756,12 @@ gimple_build_switch (tree index, tree default_label, 
vec<tree> args)
 
 /* Build a GIMPLE_EH_DISPATCH statement.  */
 
-gimple
+gimple_eh_dispatch
 gimple_build_eh_dispatch (int region)
 {
-  gimple_statement_eh_dispatch *p =
-    as_a <gimple_statement_eh_dispatch> (
-      gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0));
+  gimple_eh_dispatch p =
+    gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0)
+      ->as_a_gimple_eh_dispatch ();
   p->region = region;
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index fbbb676..1ee15e9 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -318,6 +318,12 @@ public:
     return as_a <gimple_statement_resx> (this);
   }
 
+  inline gimple_eh_dispatch
+  as_a_gimple_eh_dispatch ()
+  {
+    return as_a <gimple_statement_eh_dispatch> (this);
+  }
+
   inline gimple_phi
   as_a_gimple_phi ()
   {
@@ -1545,7 +1551,7 @@ gimple gimple_build_wce (gimple_seq);
 gimple_resx gimple_build_resx (int);
 gimple_switch gimple_build_switch_nlabels (unsigned, tree, tree);
 gimple_switch gimple_build_switch (tree, tree, vec<tree> );
-gimple gimple_build_eh_dispatch (int);
+gimple_eh_dispatch gimple_build_eh_dispatch (int);
 gimple_debug gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
 #define gimple_build_debug_bind(var,val,stmt)                  \
   gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
@@ -4212,23 +4218,20 @@ gimple_resx_set_region (gimple_resx resx_stmt, int 
region)
   resx_stmt->region = region;
 }
 
-/* Return the region number for GIMPLE_EH_DISPATCH GS.  */
+/* Return the region number for GIMPLE_EH_DISPATCH EH_DISPATCH_STMT.  */
 
 static inline int
-gimple_eh_dispatch_region (const_gimple gs)
+gimple_eh_dispatch_region (const_gimple_eh_dispatch eh_dispatch_stmt)
 {
-  const gimple_statement_eh_dispatch *eh_dispatch_stmt =
-    as_a <const gimple_statement_eh_dispatch> (gs);
   return eh_dispatch_stmt->region;
 }
 
-/* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS.  */
+/* Set REGION to be the region number for GIMPLE_EH_DISPATCH
+   EH_DISPATCH_STMT.  */
 
 static inline void
-gimple_eh_dispatch_set_region (gimple gs, int region)
+gimple_eh_dispatch_set_region (gimple_eh_dispatch eh_dispatch_stmt, int region)
 {
-  gimple_statement_eh_dispatch *eh_dispatch_stmt =
-    as_a <gimple_statement_eh_dispatch> (gs);
   eh_dispatch_stmt->region = region;
 }
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index a11f4f0..0d3c0d7 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -766,7 +766,8 @@ make_edges (void)
              fallthru = false;
              break;
            case GIMPLE_EH_DISPATCH:
-             fallthru = make_eh_dispatch_edges (last);
+             fallthru =
+               make_eh_dispatch_edges (last->as_a_gimple_eh_dispatch ());
              break;
 
            case GIMPLE_CALL:
@@ -5254,7 +5255,7 @@ gimple_verify_flow_info (void)
          break;
 
        case GIMPLE_EH_DISPATCH:
-         err |= verify_eh_dispatch_edge (stmt);
+         err |= verify_eh_dispatch_edge (stmt->as_a_gimple_eh_dispatch ());
          break;
 
        default:
@@ -5508,7 +5509,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 
     case GIMPLE_EH_DISPATCH:
       if (!(e->flags & EDGE_FALLTHRU))
-       redirect_eh_dispatch_edge (stmt, e, dest);
+       redirect_eh_dispatch_edge (stmt->as_a_gimple_eh_dispatch (), e, dest);
       break;
 
     case GIMPLE_TRANSACTION:
@@ -6469,9 +6470,10 @@ move_stmt_r (gimple_stmt_iterator *gsi_p, bool 
*handled_ops_p,
 
     case GIMPLE_EH_DISPATCH:
       {
-       int r = gimple_eh_dispatch_region (stmt);
+       gimple_eh_dispatch eh_dispatch_stmt = stmt->as_a_gimple_eh_dispatch ();
+       int r = gimple_eh_dispatch_region (eh_dispatch_stmt);
        r = move_stmt_eh_region_nr (r, p);
-       gimple_eh_dispatch_set_region (stmt, r);
+       gimple_eh_dispatch_set_region (eh_dispatch_stmt, r);
       }
       break;
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 0f2c77e..ee810b0 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -840,7 +840,7 @@ emit_resx (gimple_seq *seq, eh_region region)
 static void
 emit_eh_dispatch (gimple_seq *seq, eh_region region)
 {
-  gimple x = gimple_build_eh_dispatch (region->index);
+  gimple_eh_dispatch x = gimple_build_eh_dispatch (region->index);
   gimple_seq_add_stmt (seq, x);
 }
 
@@ -2225,7 +2225,7 @@ make_pass_lower_eh (gcc::context *ctxt)
    no fallthru edge; false if there is.  */
 
 bool
-make_eh_dispatch_edges (gimple stmt)
+make_eh_dispatch_edges (gimple_eh_dispatch stmt)
 {
   eh_region r;
   eh_catch c;
@@ -2383,7 +2383,7 @@ redirect_eh_edge (edge edge_in, basic_block new_bb)
    The actual edge update will happen in the caller.  */
 
 void
-redirect_eh_dispatch_edge (gimple stmt, edge e, basic_block new_bb)
+redirect_eh_dispatch_edge (gimple_eh_dispatch stmt, edge e, basic_block new_bb)
 {
   tree new_lab = gimple_block_label (new_bb);
   bool any_changed = false;
@@ -3598,7 +3598,7 @@ sink_clobbers (basic_block bb)
    we have found some duplicate labels and removed some edges.  */
 
 static bool
-lower_eh_dispatch (basic_block src, gimple stmt)
+lower_eh_dispatch (basic_block src, gimple_eh_dispatch stmt)
 {
   gimple_stmt_iterator gsi;
   int region_nr;
@@ -3759,7 +3759,8 @@ execute_lower_eh_dispatch (void)
        continue;
       if (gimple_code (last) == GIMPLE_EH_DISPATCH)
        {
-         redirected |= lower_eh_dispatch (bb, last);
+         redirected |= lower_eh_dispatch (bb,
+                                          last->as_a_gimple_eh_dispatch ());
          flags |= TODO_update_ssa_only_virtuals;
        }
       else if (gimple_code (last) == GIMPLE_RESX)
@@ -3887,7 +3888,9 @@ mark_reachable_handlers (sbitmap *r_reachablep, sbitmap 
*lp_reachablep)
                              gimple_resx_region (stmt->as_a_gimple_resx ()));
              break;
            case GIMPLE_EH_DISPATCH:
-             bitmap_set_bit (r_reachable, gimple_eh_dispatch_region (stmt));
+             bitmap_set_bit (r_reachable,
+                             gimple_eh_dispatch_region (
+                                stmt->as_a_gimple_eh_dispatch ()));
              break;
            default:
              break;
@@ -4735,7 +4738,7 @@ verify_eh_edges (gimple stmt)
 /* Similarly, but handle GIMPLE_EH_DISPATCH specifically.  */
 
 DEBUG_FUNCTION bool
-verify_eh_dispatch_edge (gimple stmt)
+verify_eh_dispatch_edge (gimple_eh_dispatch stmt)
 {
   eh_region r;
   eh_catch c;
diff --git a/gcc/tree-eh.h b/gcc/tree-eh.h
index cd9b40d..2d985ac 100644
--- a/gcc/tree-eh.h
+++ b/gcc/tree-eh.h
@@ -26,10 +26,10 @@ extern bool remove_stmt_from_eh_lp_fn (struct function *, 
gimple);
 extern bool remove_stmt_from_eh_lp (gimple);
 extern int lookup_stmt_eh_lp_fn (struct function *, gimple);
 extern int lookup_stmt_eh_lp (gimple);
-extern bool make_eh_dispatch_edges (gimple);
+extern bool make_eh_dispatch_edges (gimple_eh_dispatch);
 extern void make_eh_edges (gimple);
 extern edge redirect_eh_edge (edge, basic_block);
-extern void redirect_eh_dispatch_edge (gimple, edge, basic_block);
+extern void redirect_eh_dispatch_edge (gimple_eh_dispatch, edge, basic_block);
 extern bool operation_could_trap_helper_p (enum tree_code, bool, bool, bool,
                                           bool, tree, bool *);
 extern bool operation_could_trap_p (enum tree_code, bool, bool, tree);
@@ -47,6 +47,6 @@ extern bool maybe_duplicate_eh_stmt_fn (struct function *, 
gimple,
 extern bool maybe_duplicate_eh_stmt (gimple, gimple);
 extern void maybe_remove_unreachable_handlers (void);
 extern bool verify_eh_edges (gimple);
-extern bool verify_eh_dispatch_edge (gimple);
+extern bool verify_eh_dispatch_edge (gimple_eh_dispatch);
 
 #endif /* GCC_TREE_EH_H */
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 49d326c..f1d2791 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1546,9 +1546,10 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 
          case GIMPLE_EH_DISPATCH:
            {
-             int r = gimple_eh_dispatch_region (copy);
+             gimple_eh_dispatch eh_dispatch = copy->as_a_gimple_eh_dispatch ();
+             int r = gimple_eh_dispatch_region (eh_dispatch);
              r = remap_eh_region_nr (r, id);
-             gimple_eh_dispatch_set_region (copy, r);
+             gimple_eh_dispatch_set_region (eh_dispatch, r);
            }
            break;
 
@@ -2057,7 +2058,7 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, 
basic_block ret_bb,
        }
 
       if (gimple_code (copy_stmt) == GIMPLE_EH_DISPATCH)
-       make_eh_dispatch_edges (copy_stmt);
+       make_eh_dispatch_edges (copy_stmt->as_a_gimple_eh_dispatch ());
       else if (can_throw)
        make_eh_edges (copy_stmt);
 
-- 
1.8.5.3

Reply via email to