gcc/ * coretypes.h (gimple_phi): New typedef. (const_gimple_phi): New typedef.
* gimple.h (gimple_statement_base::as_a_gimple_phi): New. (gimple_statement_base::dyn_cast_gimple_phi): New. * gdbhooks.py (build_pretty_printer): Add gimple_phi and its variants, using the gimple printer. * gimple.h (gimple_vec): Eliminate thie typedef in the hope of using vecs of more concrete gimple subclasses as appropriate; also the comment is about to become misleading. * gimple.h (gimple_phi_capacity): Use const_gimple_phi typedef rather than spelling out the full type. (gimple_phi_num_args): Likewise. (gimple_phi_result): Likewise. (gimple_phi_result_ptr): Use gimple_phi typedef. (gimple_phi_set_result): Likewise. (gimple_phi_arg): Likewise. (gimple_phi_set_arg): Likewise. * tree-phinodes.c (allocate_phi_node): Likewise. (resize_phi_node): Likewise. (reserve_phi_args_for_new_edge): Likewise. (remove_phi_arg_num): Likewise. * gimple-pretty-print.c (dump_gimple_phi): Require a gimple_phi rather than just a gimple. * tree-into-ssa.c (mark_phi_for_rewrite): Likewise. * tree-phinodes.c (make_phi_node): Return a gimple_phi rather than just a gimple. (create_phi_node): Likewise. * tree-phinodes.h (create_phi_node): Likewise. * trans-mem.c (struct struct tm_log_entry): Replace use of now-removed gimple_vec with a plain vec<gimple>. * tree-into-ssa.c (phis_to_rewrite): Strengthen from a vec<gimple_vec> to a vec< vec<gimple_phi> >. * tree-into-ssa.c (insert_phi_nodes_for): Update local to be a gimple_phi. * tree-into-ssa.c (rewrite_update_phi_arguments): Strengthen local "phis" from a gimple_vec to a vec<gimple_phi>, and local "phi" to a gimple_phi. * tree-into-ssa.c (delete_update_ssa): Strengthen local "phis" from a gimple_vec to a vec<gimple_phi>. * gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to gimple_phi in regions where a stmt is known to have code GIMPLE_PHI. * tree-into-ssa.c (mark_use_interesting): Likewise. --- gcc/coretypes.h | 4 ++++ gcc/gdbhooks.py | 4 +++- gcc/gimple-pretty-print.c | 6 +++--- gcc/gimple.h | 30 +++++++++++++++++++----------- gcc/trans-mem.c | 2 +- gcc/tree-into-ssa.c | 16 ++++++++-------- gcc/tree-phinodes.c | 26 +++++++++++++------------- gcc/tree-phinodes.h | 2 +- 8 files changed, 52 insertions(+), 38 deletions(-) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 57db319..f3945b9 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -94,6 +94,10 @@ struct gimple_statement_bind; typedef struct gimple_statement_bind *gimple_bind; typedef const struct gimple_statement_bind *const_gimple_bind; +struct gimple_statement_phi; +typedef struct gimple_statement_phi *gimple_phi; +typedef const struct gimple_statement_phi *const_gimple_phi; + union section; typedef union section section; struct gcc_options; diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 9f28c4e..ef41bad 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -468,7 +468,9 @@ def build_pretty_printer(): 'gimple_assign', 'const_gimple_assign', 'gimple_statement_assign *', 'gimple_bind', 'const_gimple_bind', - 'gimple_statement_bind *'], + 'gimple_statement_bind *', + 'gimple_phi', 'const_gimple_phi', + 'gimple_statement_phi *'], 'gimple', GimplePrinter) diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index aa7c148..505006a 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1791,7 +1791,7 @@ dump_ssaname_info (pretty_printer *buffer, tree node, int spc) pretty printer. If COMMENT is true, print this after #. */ static void -dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment, +dump_gimple_phi (pretty_printer *buffer, gimple_phi phi, int spc, bool comment, int flags) { size_t i; @@ -2134,7 +2134,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags) break; case GIMPLE_PHI: - dump_gimple_phi (buffer, gs, spc, false, flags); + dump_gimple_phi (buffer, gs->as_a_gimple_phi (), spc, false, flags); break; case GIMPLE_OMP_PARALLEL: @@ -2310,7 +2310,7 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags) if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS)) { INDENT (indent); - dump_gimple_phi (buffer, phi, indent, true, flags); + dump_gimple_phi (buffer, phi->as_a_gimple_phi (), indent, true, flags); pp_newline (buffer); } } diff --git a/gcc/gimple.h b/gcc/gimple.h index f5dcf0c..07d7b64 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -24,10 +24,6 @@ along with GCC; see the file COPYING3. If not see typedef gimple gimple_seq_node; -/* For each block, the PHI nodes that need to be rewritten are stored into - these vectors. */ -typedef vec<gimple> gimple_vec; - enum gimple_code { #define DEFGSCODE(SYM, STRING, STRUCT) SYM, #include "gimple.def" @@ -247,6 +243,12 @@ public: return as_a <gimple_statement_bind> (this); } + inline gimple_phi + as_a_gimple_phi () + { + return as_a <gimple_statement_phi> (this); + } + /* Dynamic casting methods, where the cast returns NULL if the stmt is not of the required kind. @@ -291,6 +293,12 @@ public: return dyn_cast <gimple_statement_bind> (this); } + inline gimple_phi + dyn_cast_gimple_phi () + { + return dyn_cast <gimple_statement_phi> (this); + } + }; @@ -3941,7 +3949,7 @@ gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p) static inline unsigned gimple_phi_capacity (const_gimple gs) { - const gimple_statement_phi *phi_stmt = + const_gimple_phi phi_stmt = as_a <const gimple_statement_phi> (gs); return phi_stmt->capacity; } @@ -3954,7 +3962,7 @@ gimple_phi_capacity (const_gimple gs) static inline unsigned gimple_phi_num_args (const_gimple gs) { - const gimple_statement_phi *phi_stmt = + const_gimple_phi phi_stmt = as_a <const gimple_statement_phi> (gs); return phi_stmt->nargs; } @@ -3965,7 +3973,7 @@ gimple_phi_num_args (const_gimple gs) static inline tree gimple_phi_result (const_gimple gs) { - const gimple_statement_phi *phi_stmt = + const_gimple_phi phi_stmt = as_a <const gimple_statement_phi> (gs); return phi_stmt->result; } @@ -3975,7 +3983,7 @@ gimple_phi_result (const_gimple gs) static inline tree * gimple_phi_result_ptr (gimple gs) { - gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi> (gs); + gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs); return &phi_stmt->result; } @@ -3984,7 +3992,7 @@ gimple_phi_result_ptr (gimple gs) static inline void gimple_phi_set_result (gimple gs, tree result) { - gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi> (gs); + gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs); phi_stmt->result = result; if (result && TREE_CODE (result) == SSA_NAME) SSA_NAME_DEF_STMT (result) = gs; @@ -3997,7 +4005,7 @@ gimple_phi_set_result (gimple gs, tree result) static inline struct phi_arg_d * gimple_phi_arg (gimple gs, unsigned index) { - gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi> (gs); + gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs); gcc_gimple_checking_assert (index <= phi_stmt->capacity); return &(phi_stmt->args[index]); } @@ -4008,7 +4016,7 @@ gimple_phi_arg (gimple gs, unsigned index) static inline void gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg) { - gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi> (gs); + gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs); gcc_gimple_checking_assert (index <= phi_stmt->nargs); phi_stmt->args[index] = *phiarg; } diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index b2adc3d..e1fb7be 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -927,7 +927,7 @@ typedef struct tm_log_entry /* Entry block for the transaction this address occurs in. */ basic_block entry_block; /* Dominating statements the store occurs in. */ - gimple_vec stmts; + vec<gimple> stmts; /* Initially, while we are building the log, we place a nonzero value here to mean that this address *will* be saved with a save/restore sequence. Later, when generating the save sequence diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 0067cfe..beab33e 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -118,7 +118,7 @@ static bitmap names_to_release; /* vec of vec of PHIs to rewrite in a basic block. Element I corresponds the to basic block with index I. Allocated once per compilation, *not* released between different functions. */ -static vec<gimple_vec> phis_to_rewrite; +static vec< vec<gimple_phi> > phis_to_rewrite; /* The bitmap of non-NULL elements of PHIS_TO_REWRITE. */ static bitmap blocks_with_phis_to_rewrite; @@ -948,9 +948,9 @@ find_def_blocks_for (tree var) /* Marks phi node PHI in basic block BB for rewrite. */ static void -mark_phi_for_rewrite (basic_block bb, gimple phi) +mark_phi_for_rewrite (basic_block bb, gimple_phi phi) { - gimple_vec phis; + vec<gimple_phi> phis; unsigned n, idx = bb->index; if (rewrite_uses_p (phi)) @@ -989,7 +989,7 @@ insert_phi_nodes_for (tree var, bitmap phi_insertion_points, bool update_p) { unsigned bb_index; edge e; - gimple phi; + gimple_phi phi; basic_block bb; bitmap_iterator bi; struct def_blocks_d *def_map = find_def_blocks_for (var); @@ -1989,8 +1989,8 @@ rewrite_update_phi_arguments (basic_block bb) FOR_EACH_EDGE (e, ei, bb->succs) { - gimple phi; - gimple_vec phis; + gimple_phi phi; + vec<gimple_phi> phis; if (!bitmap_bit_p (blocks_with_phis_to_rewrite, e->dest->index)) continue; @@ -2455,7 +2455,7 @@ mark_use_interesting (tree var, gimple stmt, basic_block bb, bool insert_phi_p) mark_block_for_update (bb); if (gimple_code (stmt) == GIMPLE_PHI) - mark_phi_for_rewrite (def_bb, stmt); + mark_phi_for_rewrite (def_bb, stmt->as_a_gimple_phi ()); else { set_rewrite_uses (stmt, true); @@ -2815,7 +2815,7 @@ delete_update_ssa (void) if (blocks_with_phis_to_rewrite) EXECUTE_IF_SET_IN_BITMAP (blocks_with_phis_to_rewrite, 0, i, bi) { - gimple_vec phis = phis_to_rewrite[i]; + vec<gimple_phi> phis = phis_to_rewrite[i]; phis.release (); phis_to_rewrite[i].create (0); } diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index b9c5b43..cafd312 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -97,10 +97,10 @@ phinodes_print_statistics (void) happens to contain a PHI node with LEN arguments or more, return that one. */ -static inline gimple_statement_phi * +static inline gimple_phi allocate_phi_node (size_t len) { - gimple_statement_phi *phi; + gimple_phi phi; size_t bucket = NUM_BUCKETS - 2; size_t size = sizeof (struct gimple_statement_phi) + (len - 1) * sizeof (struct phi_arg_d); @@ -123,7 +123,7 @@ allocate_phi_node (size_t len) } else { - phi = static_cast <gimple_statement_phi *> ( + phi = static_cast <gimple_phi> ( ggc_internal_alloc_stat (size MEM_STAT_INFO)); if (GATHER_STATISTICS) { @@ -173,10 +173,10 @@ ideal_phi_node_len (int len) /* Return a PHI node with LEN argument slots for variable VAR. */ -static gimple +static gimple_phi make_phi_node (tree var, int len) { - gimple_statement_phi *phi; + gimple_phi phi; int capacity, i; capacity = ideal_phi_node_len (len); @@ -241,11 +241,11 @@ release_phi_node (gimple phi) /* Resize an existing PHI node. The only way is up. Return the possibly relocated phi. */ -static gimple_statement_phi * -resize_phi_node (gimple_statement_phi *phi, size_t len) +static gimple_phi +resize_phi_node (gimple_phi phi, size_t len) { size_t old_size, i; - gimple_statement_phi *new_phi; + gimple_phi new_phi; gcc_assert (len > gimple_phi_capacity (phi)); @@ -296,12 +296,12 @@ reserve_phi_args_for_new_edge (basic_block bb) for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple_statement_phi *stmt = + gimple_phi stmt = as_a <gimple_statement_phi> (gsi_stmt (gsi)); if (len > gimple_phi_capacity (stmt)) { - gimple_statement_phi *new_phi = resize_phi_node (stmt, cap); + gimple_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; @@ -347,10 +347,10 @@ add_phi_node_to_bb (gimple phi, basic_block bb) /* Create a new PHI node for variable VAR at basic block BB. */ -gimple +gimple_phi create_phi_node (tree var, basic_block bb) { - gimple phi = make_phi_node (var, EDGE_COUNT (bb->preds)); + gimple_phi phi = make_phi_node (var, EDGE_COUNT (bb->preds)); add_phi_node_to_bb (phi, bb); return phi; @@ -397,7 +397,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_statement_phi *phi, int i) +remove_phi_arg_num (gimple_phi phi, int i) { int num_elem = gimple_phi_num_args (phi); diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h index 4dd5e13..e30eca5 100644 --- a/gcc/tree-phinodes.h +++ b/gcc/tree-phinodes.h @@ -24,7 +24,7 @@ extern void phinodes_print_statistics (void); extern void release_phi_node (gimple); extern void reserve_phi_args_for_new_edge (basic_block); extern void add_phi_node_to_bb (gimple phi, basic_block bb); -extern gimple create_phi_node (tree, basic_block); +extern gimple_phi create_phi_node (tree, basic_block); extern void add_phi_arg (gimple, tree, edge, source_location); extern void remove_phi_args (edge); extern void remove_phi_node (gimple_stmt_iterator *, bool); -- 1.7.11.7