From patchwork Mon Oct 27 20:40:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 403875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C966D140081 for ; Tue, 28 Oct 2014 07:37:52 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=IawGECNYVJTVyBWOf3IGLN9JIJfaa/hy9q5dnWFc0ib5rWAITO7jX BU31/08ImZI+UBwxndQ4t0F0mOHXrUteAjrRGbLA1Jvza8nkzEAspyfjW5tldPvw KvQyPzoPmk1joVBPR6rNPAJ/xebhV5eiI+MxsTaRgSddhAu6az0tjk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=Yd5c2cGXKJwmU+PJD7kkfl1V9vg=; b=c6gMSYQXwIKMbbY828PI SMGKk/+dsk5w2DdT5JTwoiVr9CEnrFxWkm7JXtC76cYGFTsyLShEtbkfx2++7bVZ HajLkadGiwW+HBPMttScuu0fSP9Em/kSEAPHR7dsq1q5i1FxB6Ljmm633S+QfezO 2O72XvX/aW01HBblVzzYWUM= Received: (qmail 2764 invoked by alias); 27 Oct 2014 20:35:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2667 invoked by uid 89); 27 Oct 2014 20:35:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 27 Oct 2014 20:35:09 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9RKZ7aD007292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Oct 2014 16:35:07 -0400 Received: from c64.redhat.com (vpn-236-51.phx2.redhat.com [10.3.236.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9RKYt53021050; Mon, 27 Oct 2014 16:35:07 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 19/92] Introduce gimple_return Date: Mon, 27 Oct 2014 16:40:17 -0400 Message-Id: <1414442490-14841-20-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1414442490-14841-1-git-send-email-dmalcolm@redhat.com> References: <1414442490-14841-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes 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 ::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 + 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 ::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 + 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 (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 (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_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 ::test (gimple gs) template <> template <> inline bool -is_a_helper ::test (gimple gs) +is_a_helper ::test (gimple gs) { - return gs->code == GIMPLE_TRANSACTION; + return gs->code == GIMPLE_RETURN; } template <> @@ -1058,6 +1068,14 @@ is_a_helper ::test (gimple gs) template <> template <> inline bool +is_a_helper ::test (gimple gs) +{ + return gs->code == GIMPLE_TRANSACTION; +} + +template <> +template <> +inline bool is_a_helper ::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 ); 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_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 (stmt)); case GIMPLE_RETURN: - return verify_gimple_return (stmt); + return verify_gimple_return (as_a (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_seq_last_stmt (bb_seq (bb))); gimple_stmt_iterator gsi = gsi_last_bb (bb); gcc_assert (gimple_code (ret_stmt) == GIMPLE_RETURN);