@@ -1,5 +1,48 @@
2014-10-24 David Malcolm <dmalcolm@redhat.com>
+ Introduce gimple_return
+
+ * coretypes.h (gimple_return): New typedef.
+ (const_gimple_return): New typedef.
+
+ * gimple.h (gimple_statement_return): New subclass of
+ gimple_statement_with_memory_ops, adding the invariant that
+ stmt->code == GIMPLE_RETURN.
+ (is_a_helper <gimple_statement_return>::test): New.
+ (gimple_build_return): Return a gimple_return rather
+ than a plain gimple.
+
+ * gimple.c (gimple_build_return): Return a gimple_return rather
+ than a plain gimple.
+
+ * cgraphunit.c (expand_thunk): Convert local from a gimple to
+ a gimple_return.
+
+ * gimple-low.c (struct return_statements_t): Convert field "stmt"
+ from a gimple to a gimple_return.
+ (lower_gimple_return): Convert local from a gimple to a
+ gimple_return.
+
+ * gimple-pretty-print.c (dump_gimple_return): Require a
+ gimple_return rather than a plain gimple.
+ (pp_gimple_stmt_1): Add a checked cast to gimple_return within
+ case GIMPLE_RETURN of switch statement.
+
+ * gimplify.c (gimplify_return_expr): Convert locals from
+ gimple to gimple_return.
+
+ * ipa-split.c (split_function): Likewise.
+
+ * tree-cfg.c (verify_gimple_assign): Require a gimple_return
+ rather than a plain gimple.
+ (verify_gimple_stmt): Add checked cast to gimple_return within
+ case GIMPLE_RETURN of switch statement.
+
+ * tree-tailcall.c (adjust_return_value): Convert local from
+ gimple to gimple_return.
+
+2014-10-24 David Malcolm <dmalcolm@redhat.com>
+
Introduce gimple_call
* coretypes.h (gimple_call): New typedef.
@@ -1496,7 +1496,7 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
tree restmp = NULL;
gimple_call call;
- gimple ret;
+ gimple_return ret;
if (in_lto_p)
get_body ();
@@ -114,6 +114,10 @@ struct gimple_statement_call;
typedef struct gimple_statement_call *gimple_call;
typedef const struct gimple_statement_call *const_gimple_call;
+struct gimple_statement_return;
+typedef struct gimple_statement_return *gimple_return;
+typedef const struct gimple_statement_return *const_gimple_return;
+
struct gimple_statement_bind;
typedef struct gimple_statement_bind *gimple_bind;
typedef const struct gimple_statement_bind *const_gimple_bind;
@@ -60,7 +60,7 @@ along with GCC; see the file COPYING3. If not see
struct return_statements_t
{
tree label;
- gimple stmt;
+ gimple_return stmt;
};
typedef struct return_statements_t return_statements_t;
@@ -619,7 +619,7 @@ gimple_seq_may_fallthru (gimple_seq seq)
static void
lower_gimple_return (gimple_stmt_iterator *gsi, struct lower_data *data)
{
- gimple stmt = gsi_stmt (*gsi);
+ gimple_return stmt = as_a <gimple_return> (gsi_stmt (*gsi));
gimple t;
int i;
return_statements_t tmp_rs;
@@ -555,7 +555,7 @@ dump_gimple_assign (pretty_printer *buffer, gimple_assign gs, int spc, int flags
pp_gimple_stmt_1. */
static void
-dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_return (pretty_printer *buffer, gimple_return gs, int spc, int flags)
{
tree t;
@@ -2117,7 +2117,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
break;
case GIMPLE_RETURN:
- dump_gimple_return (buffer, gs, spc, flags);
+ dump_gimple_return (buffer, as_a <gimple_return> (gs), spc, flags);
break;
case GIMPLE_SWITCH:
@@ -177,10 +177,12 @@ gimple_build_with_ops_stat (enum gimple_code code, unsigned subcode,
/* Build a GIMPLE_RETURN statement returning RETVAL. */
-gimple
+gimple_return
gimple_build_return (tree retval)
{
- gimple s = gimple_build_with_ops (GIMPLE_RETURN, ERROR_MARK, 1);
+ gimple_return s =
+ as_a <gimple_return> (gimple_build_with_ops (GIMPLE_RETURN, ERROR_MARK,
+ 1));
if (retval)
gimple_return_set_retval (s, retval);
return s;
@@ -823,6 +823,16 @@ struct GTY((tag("GSS_WITH_MEM_OPS")))
/* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
};
+/* A statement with the invariant that
+ stmt->code == GIMPLE_RETURN
+ i.e. a return statement. */
+
+struct GTY((tag("GSS_WITH_MEM_OPS")))
+ gimple_statement_return : public gimple_statement_with_memory_ops
+{
+ /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
+};
+
template <>
template <>
inline bool
@@ -1042,9 +1052,9 @@ is_a_helper <gimple_statement_phi *>::test (gimple gs)
template <>
template <>
inline bool
-is_a_helper <gimple_statement_transaction *>::test (gimple gs)
+is_a_helper <gimple_statement_return *>::test (gimple gs)
{
- return gs->code == GIMPLE_TRANSACTION;
+ return gs->code == GIMPLE_RETURN;
}
template <>
@@ -1058,6 +1068,14 @@ is_a_helper <gimple_statement_switch *>::test (gimple gs)
template <>
template <>
inline bool
+is_a_helper <gimple_statement_transaction *>::test (gimple gs)
+{
+ return gs->code == GIMPLE_TRANSACTION;
+}
+
+template <>
+template <>
+inline bool
is_a_helper <gimple_statement_try *>::test (gimple gs)
{
return gs->code == GIMPLE_TRY;
@@ -1260,7 +1278,7 @@ extern gimple currently_expanding_gimple_stmt;
#define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
-gimple gimple_build_return (tree);
+gimple_return gimple_build_return (tree);
void gimple_call_reset_alias_info (gimple_call);
gimple_call gimple_build_call_vec (tree, vec<tree> );
gimple_call gimple_build_call (tree, unsigned, ...);
@@ -1191,7 +1191,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
static enum gimplify_status
gimplify_return_expr (tree stmt, gimple_seq *pre_p)
{
- gimple ret;
+ gimple_return ret;
tree ret_expr = TREE_OPERAND (stmt, 0);
tree result_decl, result;
@@ -1211,7 +1211,7 @@ gimplify_return_expr (tree stmt, gimple_seq *pre_p)
|| TREE_CODE (ret_expr) == RESULT_DECL
|| ret_expr == error_mark_node)
{
- gimple ret = gimple_build_return (ret_expr);
+ gimple_return ret = gimple_build_return (ret_expr);
gimple_set_no_warning (ret, TREE_NO_WARNING (stmt));
gimplify_seq_add_stmt (pre_p, ret);
return GS_ALL_DONE;
@@ -1489,7 +1489,7 @@ split_function (struct split_point *split_point)
*/
else
{
- gimple ret;
+ gimple_return ret;
if (split_point->split_part_set_retval
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
{
@@ -9911,7 +9911,8 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
location_t loc = gimple_location (stmt);
clauses = gimple_omp_taskreg_clauses (stmt);
- par_bind = gimple_seq_first_stmt_as_a_bind (gimple_omp_body (stmt));
+ par_bind =
+ as_a <gimple_bind> (gimple_seq_first_stmt (gimple_omp_body (stmt)));
par_body = gimple_bind_body (par_bind);
child_fn = ctx->cb.dst_fn;
if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
@@ -4262,7 +4262,7 @@ verify_gimple_assign (gimple_assign stmt)
is a problem, otherwise false. */
static bool
-verify_gimple_return (gimple stmt)
+verify_gimple_return (gimple_return stmt)
{
tree op = gimple_return_retval (stmt);
tree restype = TREE_TYPE (TREE_TYPE (cfun->decl));
@@ -4510,7 +4510,7 @@ verify_gimple_stmt (gimple stmt)
return verify_gimple_switch (as_a <gimple_switch> (stmt));
case GIMPLE_RETURN:
- return verify_gimple_return (stmt);
+ return verify_gimple_return (as_a <gimple_return> (stmt));
case GIMPLE_ASM:
return false;
@@ -747,7 +747,8 @@ static void
adjust_return_value (basic_block bb, tree m, tree a)
{
tree retval;
- gimple ret_stmt = gimple_seq_last_stmt (bb_seq (bb));
+ gimple_return ret_stmt =
+ as_a <gimple_return> (gimple_seq_last_stmt (bb_seq (bb)));
gimple_stmt_iterator gsi = gsi_last_bb (bb);
gcc_assert (gimple_code (ret_stmt) == GIMPLE_RETURN);