This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gimple-classes, committed 19/92] Introduce gimple_return


This corresponds to:
  [PATCH 21/89] Introduce gimple_return
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01180.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK after fixing up the naming/const stuff as discussed for prior
> patches.
> That applies to 22-30. Make sure to take care of
> the pretty printers per Trevor's comments as well. He indicated those
> were missing in a couple of those patches.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00628.html

gcc/
	* 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.
---
 gcc/ChangeLog.gimple-classes | 43 +++++++++++++++++++++++++++++++++++++++++++
 gcc/cgraphunit.c             |  2 +-
 gcc/coretypes.h              |  4 ++++
 gcc/gimple-low.c             |  4 ++--
 gcc/gimple-pretty-print.c    |  4 ++--
 gcc/gimple.c                 |  6 ++++--
 gcc/gimple.h                 | 24 +++++++++++++++++++++---
 gcc/gimplify.c               |  4 ++--
 gcc/ipa-split.c              |  2 +-
 gcc/omp-low.c                |  3 ++-
 gcc/tree-cfg.c               |  4 ++--
 gcc/tree-tailcall.c          |  3 ++-
 12 files changed, 86 insertions(+), 17 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index ba0bde6..5508788 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -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.
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 723ec5e..98d34be 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -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 ();
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 4981e7c..f726053 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -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;
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index ef84c28..04f87e2 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -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;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index a1e1f1f..cfc111c 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -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:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 5f5b33f..e8c0a62 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -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;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index e68cc44..559d281 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -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, ...);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index a20c59d..af64e45 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -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;
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 572467c..9c02f96 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -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))))
 	    {
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 0a4f572..58a958e 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -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
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index c852d7a..ea5bc73 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -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;
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 361f2ea..ff8236d 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -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);
-- 
1.8.5.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]