This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 29/89] Introduce gimple_resx
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Mon, 21 Apr 2014 12:57:00 -0400
- Subject: [PATCH 29/89] Introduce gimple_resx
- Authentication-results: sourceware.org; auth=none
- References: <1398099480-49147-1-git-send-email-dmalcolm at redhat dot com>
gcc/
* coretypes.h (gimple_resx): New typedef.
(const_gimple_resx): New typedef.
* gimple.h (gimple_statement_base::as_a_gimple_resx): New.
(gimple_build_resx): Return a gimple_resx rather than a plain
gimple.
(gimple_resx_region): Require a const_gimple_resx rather than a
plain const_gimple.
(gimple_resx_set_region): Require a gimple_resx rather than a
plain gimple.
* gimple-pretty-print.c (dump_gimple_resx): Require a gimple_resx
rather than a plain gimple.
(pp_gimple_stmt_1): Add a checked cast to gimple_resx within
GIMPLE_RESX case of switch statement.
* gimple-streamer-in.c (input_gimple_stmt): Likewise.
* gimple-streamer-out.c (output_gimple_stmt): Likewise.
* gimple.c (gimple_build_resx): Return a gimple_resx rather than
a plain gimple.
* tree-cfg.c (move_stmt_r): Add a checked cast to gimple_resx
within GIMPLE_RESX case of switch statement, adding a new local.
* tree-eh.c (emit_post_landing_pad): Convert local from gimple
to gimple_resx.
(lower_resx): Require a gimple_resx rather than a plain gimple.
(execute_lower_resx): Add a checked cast to gimple_resx.
(mark_reachable_handlers): Likewise.
* tree-inline.c (remap_gimple_stmt): Add a checked cast to
gimple_resx within GIMPLE_RESX case of switch statement, adding
a new local.
---
gcc/coretypes.h | 4 ++++
gcc/gimple-pretty-print.c | 4 ++--
gcc/gimple-streamer-in.c | 3 ++-
gcc/gimple-streamer-out.c | 2 +-
gcc/gimple.c | 7 +++----
gcc/gimple.h | 19 +++++++++++--------
gcc/tree-cfg.c | 5 +++--
gcc/tree-eh.c | 10 ++++++----
gcc/tree-inline.c | 5 +++--
9 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 45b157c..379ac6a 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -129,6 +129,10 @@ struct gimple_statement_eh_else;
typedef struct gimple_statement_eh_else *gimple_eh_else;
typedef const struct gimple_statement_eh_else *const_gimple_eh_else;
+struct gimple_statement_resx;
+typedef struct gimple_statement_resx *gimple_resx;
+typedef const struct gimple_statement_resx *const_gimple_resx;
+
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 63443c2..93ac677 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1047,7 +1047,7 @@ dump_gimple_eh_else (pretty_printer *buffer, gimple_eh_else gs, int spc,
dumpfile.h). */
static void
-dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_resx (pretty_printer *buffer, gimple_resx gs, int spc, int flags)
{
if (flags & TDF_RAW)
dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
@@ -2220,7 +2220,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
break;
case GIMPLE_RESX:
- dump_gimple_resx (buffer, gs, spc, flags);
+ dump_gimple_resx (buffer, gs->as_a_gimple_resx (), spc, flags);
break;
case GIMPLE_EH_DISPATCH:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 949e9af..4662832 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -123,7 +123,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
switch (code)
{
case GIMPLE_RESX:
- gimple_resx_set_region (stmt, streamer_read_hwi (ib));
+ gimple_resx_set_region (stmt->as_a_gimple_resx (),
+ streamer_read_hwi (ib));
break;
case GIMPLE_EH_MUST_NOT_THROW:
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 52130ac..521e789 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -97,7 +97,7 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
switch (gimple_code (stmt))
{
case GIMPLE_RESX:
- streamer_write_hwi (ob, gimple_resx_region (stmt));
+ streamer_write_hwi (ob, gimple_resx_region (stmt->as_a_gimple_resx ()));
break;
case GIMPLE_EH_MUST_NOT_THROW:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 9acfcc1..88d9203 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -706,12 +706,11 @@ gimple_build_wce (gimple_seq cleanup)
/* Build a GIMPLE_RESX statement. */
-gimple
+gimple_resx
gimple_build_resx (int region)
{
- gimple_statement_resx *p =
- as_a <gimple_statement_resx> (
- gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0));
+ gimple_resx p =
+ gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0)->as_a_gimple_resx ();
p->region = region;
return p;
}
diff --git a/gcc/gimple.h b/gcc/gimple.h
index a65cdcb..fbbb676 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -312,6 +312,12 @@ public:
return as_a <gimple_statement_eh_else> (this);
}
+ inline gimple_resx
+ as_a_gimple_resx ()
+ {
+ return as_a <gimple_statement_resx> (this);
+ }
+
inline gimple_phi
as_a_gimple_phi ()
{
@@ -1536,7 +1542,7 @@ gimple_eh_else gimple_build_eh_else (gimple_seq, gimple_seq);
gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
enum gimple_try_flags);
gimple gimple_build_wce (gimple_seq);
-gimple gimple_build_resx (int);
+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);
@@ -4190,22 +4196,19 @@ gimple_phi_arg_has_location (gimple gs, size_t i)
}
-/* Return the region number for GIMPLE_RESX GS. */
+/* Return the region number for GIMPLE_RESX RESX_STMT. */
static inline int
-gimple_resx_region (const_gimple gs)
+gimple_resx_region (const_gimple_resx resx_stmt)
{
- const gimple_statement_resx *resx_stmt =
- as_a <const gimple_statement_resx> (gs);
return resx_stmt->region;
}
-/* Set REGION to be the region number for GIMPLE_RESX GS. */
+/* Set REGION to be the region number for GIMPLE_RESX RESX_STMT. */
static inline void
-gimple_resx_set_region (gimple gs, int region)
+gimple_resx_set_region (gimple_resx resx_stmt, int region)
{
- gimple_statement_resx *resx_stmt = as_a <gimple_statement_resx> (gs);
resx_stmt->region = region;
}
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index fcd85e3..a11f4f0 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6460,9 +6460,10 @@ move_stmt_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
case GIMPLE_RESX:
{
- int r = gimple_resx_region (stmt);
+ gimple_resx resx_stmt = stmt->as_a_gimple_resx ();
+ int r = gimple_resx_region (resx_stmt);
r = move_stmt_eh_region_nr (r, p);
- gimple_resx_set_region (stmt, r);
+ gimple_resx_set_region (resx_stmt, r);
}
break;
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 180b195..0f2c77e 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -829,7 +829,7 @@ emit_post_landing_pad (gimple_seq *seq, eh_region region)
static void
emit_resx (gimple_seq *seq, eh_region region)
{
- gimple x = gimple_build_resx (region->index);
+ gimple_resx x = gimple_build_resx (region->index);
gimple_seq_add_stmt (seq, x);
if (region->outer)
record_stmt_eh_region (region->outer, x);
@@ -3186,7 +3186,7 @@ make_pass_refactor_eh (gcc::context *ctxt)
/* At the end of gimple optimization, we can lower RESX. */
static bool
-lower_resx (basic_block bb, gimple stmt, struct pointer_map_t *mnt_map)
+lower_resx (basic_block bb, gimple_resx stmt, struct pointer_map_t *mnt_map)
{
int lp_nr;
eh_region src_r, dst_r;
@@ -3350,7 +3350,8 @@ execute_lower_resx (void)
gimple last = last_stmt (bb);
if (last && is_gimple_resx (last))
{
- dominance_invalidated |= lower_resx (bb, last, mnt_map);
+ dominance_invalidated |= lower_resx (bb, last->as_a_gimple_resx (),
+ mnt_map);
any_rewritten = true;
}
}
@@ -3882,7 +3883,8 @@ mark_reachable_handlers (sbitmap *r_reachablep, sbitmap *lp_reachablep)
switch (gimple_code (stmt))
{
case GIMPLE_RESX:
- bitmap_set_bit (r_reachable, gimple_resx_region (stmt));
+ bitmap_set_bit (r_reachable,
+ gimple_resx_region (stmt->as_a_gimple_resx ()));
break;
case GIMPLE_EH_DISPATCH:
bitmap_set_bit (r_reachable, gimple_eh_dispatch_region (stmt));
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index f516113..49d326c 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1537,9 +1537,10 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
case GIMPLE_RESX:
{
- int r = gimple_resx_region (copy);
+ gimple_resx resx_stmt = copy->as_a_gimple_resx ();
+ int r = gimple_resx_region (resx_stmt);
r = remap_eh_region_nr (r, id);
- gimple_resx_set_region (copy, r);
+ gimple_resx_set_region (resx_stmt, r);
}
break;
--
1.8.5.3