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 831a8a7..5d69c5d 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -74,6 +74,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 933a7ee..2b29585 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 9f55bcf..515e0b9 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)
@@ -2110,7 +2110,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 e94dd33..cf7613c 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 af01873..e0d2226 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -217,6 +217,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 ()
{
@@ -249,6 +255,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 ()
{
@@ -843,6 +855,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. */
@@ -913,6 +939,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;
@@ -1301,7 +1335,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 0ff03c7..dfd1691 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1486,7 +1486,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
@@ -1495,9 +1495,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 9671407..ba541f0 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4261,7 +4261,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;
@@ -4310,7 +4310,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 2a7976a..b609c17 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.7.11.7