@@ -1,5 +1,37 @@
2014-10-24 David Malcolm <dmalcolm@redhat.com>
+ Introduce gimple_label and use it in a few places
+
+ * 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.
+ (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.
+
+2014-10-24 David Malcolm <dmalcolm@redhat.com>
+
Introduce gimple_assign and use it in various places
* coretypes.h (gimple_assign): New typedef.
@@ -94,6 +94,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;
@@ -460,6 +460,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',
@@ -863,7 +863,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)
@@ -2105,7 +2105,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, as_a <gimple_label> (gs), spc, flags);
break;
case GIMPLE_GOTO:
@@ -482,10 +482,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 =
+ as_a <gimple_label> (gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK, 1));
gimple_label_set_label (p, label);
return p;
}
@@ -780,6 +780,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. */
@@ -850,6 +864,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;
@@ -1238,7 +1260,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);
@@ -1531,7 +1531,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
@@ -1540,9 +1540,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;
}
@@ -4429,7 +4429,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;
@@ -4479,7 +4479,7 @@ verify_gimple_stmt (gimple stmt)
return verify_gimple_assign (as_a <gimple_assign> (stmt));
case GIMPLE_LABEL:
- return verify_gimple_label (stmt);
+ return verify_gimple_label (as_a <gimple_label> (stmt));
case GIMPLE_CALL:
return verify_gimple_call (stmt);
@@ -1243,7 +1243,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;
This corresponds to: [PATCH 06/89] Introduce gimple_label and use it in a few places https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01152.html from the original 89-patch kit That earlier patch was approved by Jeff: > Same as prior patches for gimple_cond and gimple_assign. in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00597.html 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. (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/ChangeLog.gimple-classes | 32 ++++++++++++++++++++++++++++++++ gcc/coretypes.h | 4 ++++ gcc/gdbhooks.py | 2 ++ gcc/gimple-pretty-print.c | 4 ++-- gcc/gimple.c | 5 +++-- gcc/gimple.h | 24 +++++++++++++++++++++++- gcc/gimplify.c | 6 +++--- gcc/tree-cfg.c | 4 ++-- gcc/tree-switch-conversion.c | 2 +- 9 files changed, 72 insertions(+), 11 deletions(-)