This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 06/89] Introduce gimple_label and use it in a few places
- 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:56:37 -0400
- Subject: [PATCH 06/89] Introduce gimple_label and use it in a few places
- Authentication-results: sourceware.org; auth=none
- References: <1398099480-49147-1-git-send-email-dmalcolm at redhat dot com>
gcc/
* coretypes.h (gimple_label): New typedef.
(const_gimple_label): New typedef.
* gimple.h (struct gimple_statement_label): New subclass of
gimple_statement_with_ops, adding the invariant that
stmt->code == GIMPLE_LABEL.
(gimple_statement_base::as_a_gimple_label): New.
(gimple_statement_base::dyn_cast_gimple_label): New.
(is_a_helper <gimple_statement_label>::test): New.
* gdbhooks.py (build_pretty_printer): Add gimple_label and its
variants, reusing the gimple printer.
* gimple-pretty-print.c (dump_gimple_label): Require a gimple_label
rather than just a gimple.
* tree-cfg.c (verify_gimple_label): Likewise.
* gimple.c (gimple_build_label): Return a gimple_label rather than
just a gimple.
* gimple.h (gimple_build_label): Likewise.
* gimplify.c (gimplify_case_label_expr): Update local to be a
gimple_label.
* tree-switch-conversion.c (gen_inbound_check): Likewise.
* gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to
gimple_label in regions where a stmt is known to have code
GIMPLE_LABEL.
* tree-cfg.c (verify_gimple_stmt): Likewise.
---
gcc/coretypes.h | 4 ++++
gcc/gdbhooks.py | 2 ++
gcc/gimple-pretty-print.c | 4 ++--
gcc/gimple.c | 5 +++--
gcc/gimple.h | 36 +++++++++++++++++++++++++++++++++++-
gcc/gimplify.c | 6 +++---
gcc/tree-cfg.c | 4 ++--
gcc/tree-switch-conversion.c | 2 +-
8 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 375a6b3..cea782e 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -73,6 +73,10 @@ struct gimple_statement_cond;
typedef struct gimple_statement_cond *gimple_cond;
typedef const struct gimple_statement_cond *const_gimple_cond;
+struct gimple_statement_label;
+typedef struct gimple_statement_label *gimple_label;
+typedef const struct gimple_statement_label *const_gimple_label;
+
struct gimple_statement_switch;
typedef struct gimple_statement_switch *gimple_switch;
typedef const struct gimple_statement_switch *const_gimple_switch;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 0ff243c..761141b 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -459,6 +459,8 @@ def build_pretty_printer():
# Keep this in the same order as gimple.def:
'gimple_cond', 'const_gimple_cond',
'gimple_statement_cond *',
+ 'gimple_label', 'const_gimple_label',
+ 'gimple_statement_label *',
'gimple_switch', 'const_gimple_switch',
'gimple_statement_switch *',
'gimple_assign', 'const_gimple_assign',
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 2334d03..7f3a056 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -853,7 +853,7 @@ dump_gimple_cond (pretty_printer *buffer, gimple_cond gs, int spc, int flags)
TDF_* in dumpfils.h). */
static void
-dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_label (pretty_printer *buffer, gimple_label gs, int spc, int flags)
{
tree label = gimple_label_label (gs);
if (flags & TDF_RAW)
@@ -2111,7 +2111,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
break;
case GIMPLE_LABEL:
- dump_gimple_label (buffer, gs, spc, flags);
+ dump_gimple_label (buffer, gs->as_a_gimple_label (), spc, flags);
break;
case GIMPLE_GOTO:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 18130db..7a4a070 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -481,10 +481,11 @@ gimple_cond_set_condition_from_tree (gimple_cond stmt, tree cond)
/* Build a GIMPLE_LABEL statement for LABEL. */
-gimple
+gimple_label
gimple_build_label (tree label)
{
- gimple p = gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK, 1);
+ gimple_label p = gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK,
+ 1)->as_a_gimple_label ();
gimple_label_set_label (p, label);
return p;
}
diff --git a/gcc/gimple.h b/gcc/gimple.h
index cfacebe..8ec8247 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -220,6 +220,12 @@ public:
return as_a <gimple_statement_cond> (this);
}
+ inline gimple_label
+ as_a_gimple_label ()
+ {
+ return as_a <gimple_statement_label> (this);
+ }
+
inline gimple_switch
as_a_gimple_switch ()
{
@@ -252,6 +258,12 @@ public:
return dyn_cast <gimple_statement_cond> (this);
}
+ inline gimple_label
+ dyn_cast_gimple_label ()
+ {
+ return dyn_cast <gimple_statement_label> (this);
+ }
+
inline gimple_switch
dyn_cast_gimple_switch ()
{
@@ -846,6 +858,20 @@ struct GTY((tag("GSS_WITH_OPS")))
};
/* A statement with the invariant that
+ stmt->code == GIMPLE_LABEL
+ i.e. a label statement.
+
+ This type will normally be accessed via the gimple_label and
+ const_gimple_label typedefs (in coretypes.h), which are pointers to
+ this type. */
+
+struct GTY((tag("GSS_WITH_OPS")))
+ gimple_statement_label : public gimple_statement_with_ops
+{
+ /* no additional fields; this uses the layout for GSS_WITH_OPS. */
+};
+
+/* A statement with the invariant that
stmt->code == GIMPLE_SWITCH
i.e. a switch statement. */
@@ -916,6 +942,14 @@ is_a_helper <gimple_statement_cond>::test (gimple gs)
template <>
template <>
inline bool
+is_a_helper <gimple_statement_label>::test (gimple gs)
+{
+ return gs->code == GIMPLE_LABEL;
+}
+
+template <>
+template <>
+inline bool
is_a_helper <gimple_statement_resx>::test (gimple gs)
{
return gs->code == GIMPLE_RESX;
@@ -1304,7 +1338,7 @@ gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
gimple_cond gimple_build_cond (enum tree_code, tree, tree, tree, tree);
gimple_cond gimple_build_cond_from_tree (tree, tree, tree);
void gimple_cond_set_condition_from_tree (gimple_cond, tree);
-gimple gimple_build_label (tree label);
+gimple_label gimple_build_label (tree label);
gimple gimple_build_goto (tree dest);
gimple gimple_build_nop (void);
gimple_bind gimple_build_bind (tree, gimple_seq, tree);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 533766e..46dc786 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1493,7 +1493,7 @@ static enum gimplify_status
gimplify_case_label_expr (tree *expr_p, gimple_seq *pre_p)
{
struct gimplify_ctx *ctxp;
- gimple gimple_label;
+ gimple_label label_stmt;
/* Invalid OpenMP programs can play Duff's Device type games with
#pragma omp parallel. At least in the C front end, we don't
@@ -1502,9 +1502,9 @@ gimplify_case_label_expr (tree *expr_p, gimple_seq *pre_p)
if (ctxp->case_labels.exists ())
break;
- gimple_label = gimple_build_label (CASE_LABEL (*expr_p));
+ label_stmt = gimple_build_label (CASE_LABEL (*expr_p));
ctxp->case_labels.safe_push (*expr_p);
- gimplify_seq_add_stmt (pre_p, gimple_label);
+ gimplify_seq_add_stmt (pre_p, label_stmt);
return GS_ALL_DONE;
}
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 6a67cdc..f42d10b 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4354,7 +4354,7 @@ verify_gimple_debug (gimple stmt ATTRIBUTE_UNUSED)
Returns true if anything is wrong. */
static bool
-verify_gimple_label (gimple stmt)
+verify_gimple_label (gimple_label stmt)
{
tree decl = gimple_label_label (stmt);
int uid;
@@ -4404,7 +4404,7 @@ verify_gimple_stmt (gimple stmt)
return verify_gimple_assign (stmt->as_a_gimple_assign ());
case GIMPLE_LABEL:
- return verify_gimple_label (stmt);
+ return verify_gimple_label (stmt->as_a_gimple_label ());
case GIMPLE_CALL:
return verify_gimple_call (stmt);
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 7e3461c..e88f710 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1217,7 +1217,7 @@ gen_inbound_check (gimple_switch swtch, struct switch_conv_info *info)
tree label_decl1 = create_artificial_label (UNKNOWN_LOCATION);
tree label_decl2 = create_artificial_label (UNKNOWN_LOCATION);
tree label_decl3 = create_artificial_label (UNKNOWN_LOCATION);
- gimple label1, label2, label3;
+ gimple_label label1, label2, label3;
tree utype, tidx;
tree bound;
--
1.8.5.3