From patchwork Thu Oct 31 16:26:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 287557 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 937C42C0374 for ; Fri, 1 Nov 2013 03:28:40 +1100 (EST) 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=SbmTb/hnWAu/NbdaX4fpqmxqsBeKAqhPHVU5FI36RJxcYMEQxZMWS A/tEopp+BUrGq9j56g4/9W2cT81bGxKMZgodtSdTYogBIuhv1o6vrFwBHyG1qzDF 7T8jpvE0C7ObbPHqH/WyPo9qncf6/kB39R7KFP6vhnCt16f8BsKFwc= 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=FAGCLVJs37xmPxqP/jwhB5xIBOc=; b=tEwsL+HKAsNl0mrVtT1R UBKILWRZ8ChzJ6KVLlewd8bI1ySGHABZX0hmlJ4J+HieI96PdySbsXwsjDqINguW k27iWXEc26rNtMTbYgGtksDgDAecMbfbWf2zcnuVeHoRIA1M+jFQMW5g9s8P7g3J Mw716+W/FDZw6ka3A0rBN08= Received: (qmail 32539 invoked by alias); 31 Oct 2013 16:27:29 -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 32418 invoked by uid 89); 31 Oct 2013 16:27:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 31 Oct 2013 16:27:25 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vbv5a-0001s8-40 for gcc-patches@gcc.gnu.org; Thu, 31 Oct 2013 12:27:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13007) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbv5Z-0001ro-Om for gcc-patches@gcc.gnu.org; Thu, 31 Oct 2013 12:27:18 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9VGRG82025099 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 31 Oct 2013 12:27:16 -0400 Received: from surprise.bos.redhat.com ([10.18.25.13]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9VGRCmU021743; Thu, 31 Oct 2013 12:27:16 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org, Andrew MacLeod Cc: David Malcolm Subject: [PATCH 5/6] Port various places from union access to subclass access. Date: Thu, 31 Oct 2013 12:26:40 -0400 Message-Id: <1383236801-13234-6-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1383236801-13234-1-git-send-email-dmalcolm@redhat.com> References: <5271CBF9.2070005@redhat.com> <1383236801-13234-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-IsSubscribed: yes * gimple-streamer-in.c (input_gimple_stmt): Port from union access to use of as_a. * gimple.c (gimple_build_asm_1): Likewise. (gimple_build_try): Likewise. Also, return a specific subclass rather than just gimple. (gimple_build_resx): Port from union access to use of as_a. (gimple_build_eh_dispatch): Likewise. (gimple_build_omp_for): Likewise. Also, convert allocation of iter now that gengtype no longer provides a typed allocator function. (gimple_copy): Likewise. * gimple.h (gimple_build_try): Return a specific subclass rather than just gimple. * gimplify.c (gimplify_cleanup_point_expr): Replace union access with subclass access by making use of new return type of gimple_build_try. * tree-phinodes.c: (allocate_phi_node): Return a "gimple_statement_phi *" rather than just a gimple. (resize_phi_node): Likewise. (make_phi_node): Replace union access with subclass access by making use of new return type of allocate_phi_node. (reserve_phi_args_for_new_edge): Replace union access with as_a. (remove_phi_arg_num): Accept a "gimple_statement_phi *" rather than just a gimple. (remove_phi_args): Update for change to remove_phi_arg_num. --- gcc/gimple-streamer-in.c | 11 ++++----- gcc/gimple.c | 58 ++++++++++++++++++++++++++++++------------------ gcc/gimple.h | 3 ++- gcc/gimplify.c | 4 ++-- gcc/tree-phinodes.c | 37 ++++++++++++++++-------------- 5 files changed, 66 insertions(+), 47 deletions(-) diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c index 4f31b83..2555dbe 100644 --- a/gcc/gimple-streamer-in.c +++ b/gcc/gimple-streamer-in.c @@ -129,13 +129,14 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in, case GIMPLE_ASM: { /* FIXME lto. Move most of this into a new gimple_asm_set_string(). */ + gimple_statement_asm *asm_stmt = as_a (stmt); tree str; - stmt->gimple_asm.ni = streamer_read_uhwi (ib); - stmt->gimple_asm.no = streamer_read_uhwi (ib); - stmt->gimple_asm.nc = streamer_read_uhwi (ib); - stmt->gimple_asm.nl = streamer_read_uhwi (ib); + asm_stmt->ni = streamer_read_uhwi (ib); + asm_stmt->no = streamer_read_uhwi (ib); + asm_stmt->nc = streamer_read_uhwi (ib); + asm_stmt->nl = streamer_read_uhwi (ib); str = streamer_read_string_cst (data_in, ib); - stmt->gimple_asm.string = TREE_STRING_POINTER (str); + asm_stmt->string = TREE_STRING_POINTER (str); } /* Fallthru */ diff --git a/gcc/gimple.c b/gcc/gimple.c index 9b1337a..e9ef8e0 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -641,21 +641,22 @@ static inline gimple gimple_build_asm_1 (const char *string, unsigned ninputs, unsigned noutputs, unsigned nclobbers, unsigned nlabels) { - gimple p; + gimple_statement_asm *p; int size = strlen (string); /* ASMs with labels cannot have outputs. This should have been enforced by the front end. */ gcc_assert (nlabels == 0 || noutputs == 0); - p = gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK, - ninputs + noutputs + nclobbers + nlabels); + p = as_a ( + gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK, + ninputs + noutputs + nclobbers + nlabels)); - p->gimple_asm.ni = ninputs; - p->gimple_asm.no = noutputs; - p->gimple_asm.nc = nclobbers; - p->gimple_asm.nl = nlabels; - p->gimple_asm.string = ggc_alloc_string (string, size); + p->ni = ninputs; + p->no = noutputs; + p->nc = nclobbers; + p->nl = nlabels; + p->string = ggc_alloc_string (string, size); if (GATHER_STATISTICS) gimple_alloc_sizes[(int) gimple_alloc_kind (GIMPLE_ASM)] += size; @@ -767,14 +768,14 @@ gimple_build_eh_else (gimple_seq n_body, gimple_seq e_body) KIND is either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY depending on whether this is a try/catch or a try/finally respectively. */ -gimple +gimple_statement_try * gimple_build_try (gimple_seq eval, gimple_seq cleanup, enum gimple_try_flags kind) { - gimple p; + gimple_statement_try *p; gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY); - p = gimple_alloc (GIMPLE_TRY, 0); + p = as_a (gimple_alloc (GIMPLE_TRY, 0)); gimple_set_subcode (p, kind); if (eval) gimple_try_set_eval (p, eval); @@ -804,8 +805,10 @@ gimple_build_wce (gimple_seq cleanup) gimple gimple_build_resx (int region) { - gimple p = gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0); - p->gimple_eh_ctrl.region = region; + gimple_statement_eh_ctrl *p = + as_a ( + gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0)); + p->region = region; return p; } @@ -852,8 +855,10 @@ gimple_build_switch (tree index, tree default_label, vec args) gimple gimple_build_eh_dispatch (int region) { - gimple p = gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0); - p->gimple_eh_ctrl.region = region; + gimple_statement_eh_ctrl *p = + as_a ( + gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0)); + p->region = region; return p; } @@ -927,14 +932,17 @@ gimple gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse, gimple_seq pre_body) { - gimple p = gimple_alloc (GIMPLE_OMP_FOR, 0); + gimple_statement_omp_for *p = + as_a (gimple_alloc (GIMPLE_OMP_FOR, 0)); if (body) gimple_omp_set_body (p, body); gimple_omp_for_set_clauses (p, clauses); gimple_omp_for_set_kind (p, kind); - p->gimple_omp_for.collapse = collapse; - p->gimple_omp_for.iter - = ggc_alloc_cleared_vec_gimple_omp_for_iter (collapse); + p->collapse = collapse; + p->iter = static_cast ( + ggc_internal_cleared_vec_alloc_stat (sizeof (*p->iter), + collapse MEM_STAT_INFO)); + if (pre_body) gimple_omp_for_set_pre_body (p, pre_body); @@ -2311,9 +2319,15 @@ gimple_copy (gimple stmt) gimple_omp_for_set_pre_body (copy, new_seq); t = unshare_expr (gimple_omp_for_clauses (stmt)); gimple_omp_for_set_clauses (copy, t); - copy->gimple_omp_for.iter - = ggc_alloc_vec_gimple_omp_for_iter - (gimple_omp_for_collapse (stmt)); + { + gimple_statement_omp_for *omp_for_copy = + as_a (copy); + omp_for_copy->iter = + static_cast ( + ggc_internal_vec_alloc_stat (sizeof (struct gimple_omp_for_iter), + gimple_omp_for_collapse (stmt) + MEM_STAT_INFO)); + } for (i = 0; i < gimple_omp_for_collapse (stmt); i++) { gimple_omp_for_set_cond (copy, i, diff --git a/gcc/gimple.h b/gcc/gimple.h index 710ce04..35bfa06 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1074,7 +1074,8 @@ gimple gimple_build_catch (tree, gimple_seq); gimple gimple_build_eh_filter (tree, gimple_seq); gimple gimple_build_eh_must_not_throw (tree); gimple gimple_build_eh_else (gimple_seq, gimple_seq); -gimple gimple_build_try (gimple_seq, gimple_seq, enum gimple_try_flags); +gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq, + enum gimple_try_flags); gimple gimple_build_wce (gimple_seq); gimple gimple_build_resx (int); gimple gimple_build_eh_dispatch (int); diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 1f18466..5869441 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -5456,7 +5456,7 @@ gimplify_cleanup_point_expr (tree *expr_p, gimple_seq *pre_p) } else { - gimple gtry; + gimple_statement_try *gtry; gimple_seq seq; enum gimple_try_flags kind; @@ -5470,7 +5470,7 @@ gimplify_cleanup_point_expr (tree *expr_p, gimple_seq *pre_p) /* Do not use gsi_replace here, as it may scan operands. We want to do a simple structural modification only. */ gsi_set_stmt (&iter, gtry); - iter = gsi_start (gtry->gimple_try.eval); + iter = gsi_start (gtry->eval); } } else diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index 65c636c..6e425fe 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -92,10 +92,10 @@ phinodes_print_statistics (void) happens to contain a PHI node with LEN arguments or more, return that one. */ -static inline gimple +static inline gimple_statement_phi * allocate_phi_node (size_t len) { - gimple phi; + gimple_statement_phi *phi; size_t bucket = NUM_BUCKETS - 2; size_t size = sizeof (struct gimple_statement_phi) + (len - 1) * sizeof (struct phi_arg_d); @@ -110,7 +110,7 @@ allocate_phi_node (size_t len) && gimple_phi_capacity ((*free_phinodes[bucket])[0]) >= len) { free_phinode_count--; - phi = free_phinodes[bucket]->pop (); + phi = as_a (free_phinodes[bucket]->pop ()); if (free_phinodes[bucket]->is_empty ()) vec_free (free_phinodes[bucket]); if (GATHER_STATISTICS) @@ -118,7 +118,8 @@ allocate_phi_node (size_t len) } else { - phi = ggc_alloc_gimple_statement_d (size); + phi = static_cast ( + ggc_internal_alloc_stat (size MEM_STAT_INFO)); if (GATHER_STATISTICS) { enum gimple_alloc_kind kind = gimple_alloc_kind (GIMPLE_PHI); @@ -170,7 +171,7 @@ ideal_phi_node_len (int len) static gimple make_phi_node (tree var, int len) { - gimple phi; + gimple_statement_phi *phi; int capacity, i; capacity = ideal_phi_node_len (len); @@ -185,8 +186,8 @@ make_phi_node (tree var, int len) + sizeof (struct phi_arg_d) * len)); phi->code = GIMPLE_PHI; gimple_init_singleton (phi); - phi->gimple_phi.nargs = len; - phi->gimple_phi.capacity = capacity; + phi->nargs = len; + phi->capacity = capacity; if (!var) ; else if (TREE_CODE (var) == SSA_NAME) @@ -235,11 +236,11 @@ release_phi_node (gimple phi) /* Resize an existing PHI node. The only way is up. Return the possibly relocated phi. */ -static gimple -resize_phi_node (gimple phi, size_t len) +static gimple_statement_phi * +resize_phi_node (gimple_statement_phi *phi, size_t len) { size_t old_size, i; - gimple new_phi; + gimple_statement_phi *new_phi; gcc_assert (len > gimple_phi_capacity (phi)); @@ -262,7 +263,7 @@ resize_phi_node (gimple phi, size_t len) relink_imm_use_stmt (imm, old_imm, new_phi); } - new_phi->gimple_phi.capacity = len; + new_phi->capacity = len; for (i = gimple_phi_num_args (new_phi); i < len; i++) { @@ -290,11 +291,12 @@ reserve_phi_args_for_new_edge (basic_block bb) for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple stmt = gsi_stmt (gsi); + gimple_statement_phi *stmt = + as_a (gsi_stmt (gsi)); if (len > gimple_phi_capacity (stmt)) { - gimple new_phi = resize_phi_node (stmt, cap); + gimple_statement_phi *new_phi = resize_phi_node (stmt, cap); /* The result of the PHI is defined by this PHI node. */ SSA_NAME_DEF_STMT (gimple_phi_result (new_phi)) = new_phi; @@ -314,7 +316,7 @@ reserve_phi_args_for_new_edge (basic_block bb) SET_PHI_ARG_DEF (stmt, len - 1, NULL_TREE); gimple_phi_arg_set_location (stmt, len - 1, UNKNOWN_LOCATION); - stmt->gimple_phi.nargs++; + stmt->nargs++; } } @@ -390,7 +392,7 @@ add_phi_arg (gimple phi, tree def, edge e, source_location locus) is consistent with how we remove an edge from the edge vector. */ static void -remove_phi_arg_num (gimple phi, int i) +remove_phi_arg_num (gimple_statement_phi *phi, int i) { int num_elem = gimple_phi_num_args (phi); @@ -417,7 +419,7 @@ remove_phi_arg_num (gimple phi, int i) /* Shrink the vector and return. Note that we do not have to clear PHI_ARG_DEF because the garbage collector will not look at those elements beyond the first PHI_NUM_ARGS elements of the array. */ - phi->gimple_phi.nargs--; + phi->nargs--; } @@ -429,7 +431,8 @@ remove_phi_args (edge e) gimple_stmt_iterator gsi; for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi)) - remove_phi_arg_num (gsi_stmt (gsi), e->dest_idx); + remove_phi_arg_num (as_a (gsi_stmt (gsi)), + e->dest_idx); }