This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gimple-classes, committed 46/92] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a gimple_phi
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Mon, 27 Oct 2014 16:40:44 -0400
- Subject: [gimple-classes, committed 46/92] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a gimple_phi
- Authentication-results: sourceware.org; auth=none
- References: <1414442490-14841-1-git-send-email-dmalcolm at redhat dot com>
This corresponds to:
[PATCH 48/89] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a gimple_phi
https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01197.html
from the original 89-patch kit
That earlier patch was approved by Jeff:
> OK once prerequisites have gone in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00828.html
gcc/
* gimple.h (gimple_phi_arg_def_ptr): Require a gimple_phi rather
than a plain gimple.
(gimple_phi_arg_has_location): Likewise.
* gimple-streamer-in.c (input_phi): Return a gimple_phi rather
than a plain gimple.
* gimple-streamer-out.c (output_phi): Require a gimple_phi rather
than a plain gimple.
(output_bb): Convert iteration to a gimple_phi_iterator, and local
"phi" to gimple_phi.
* omp-low.c (expand_omp_for_static_chunk): Convert iterator "psi"
to a gimple_phi_iterator; convert locals "phi" and "nphi" to be
gimple_phi.
* tree-cfg.c (gimple_duplicate_sese_tail): Likewise for "psi" and
"phi".
(move_block_to_fn): Introduce new gimple_phi_iterator "psi", using
it in place of "gsi" where necessary. Convert "phi" to be a
gimple_phi.
* tree-cfgcleanup.c (remove_forwarder_block): Likewise.
* tree-vect-loop-manip.c (vect_loop_versioning): Convert "gsi" to
a gimple_phi_iterator, and "orig_phi" and "new_phi" to be
gimple_phi.
* tree.c (find_decls_types_in_node): Introduce new
gimple_phi_iterator "psi", using it in place of "si" where
necessary. Convert "phi" to be a gimple_phi.
---
gcc/ChangeLog.gimple-classes | 35 +++++++++++++++++++++++++++++++++++
gcc/gimple-streamer-in.c | 4 ++--
gcc/gimple-streamer-out.c | 8 +++++---
gcc/gimple.h | 12 ++++++------
gcc/omp-low.c | 8 ++++----
gcc/tree-cfg.c | 15 ++++++++-------
gcc/tree-cfgcleanup.c | 8 ++++----
gcc/tree-vect-loop-manip.c | 7 ++++---
gcc/tree.c | 5 +++--
9 files changed, 71 insertions(+), 31 deletions(-)
diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index b0391f3..b2ca765 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,40 @@
2014-10-24 David Malcolm <dmalcolm@redhat.com>
+ Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a gimple_phi
+
+ * gimple.h (gimple_phi_arg_def_ptr): Require a gimple_phi rather
+ than a plain gimple.
+ (gimple_phi_arg_has_location): Likewise.
+
+ * gimple-streamer-in.c (input_phi): Return a gimple_phi rather
+ than a plain gimple.
+ * gimple-streamer-out.c (output_phi): Require a gimple_phi rather
+ than a plain gimple.
+ (output_bb): Convert iteration to a gimple_phi_iterator, and local
+ "phi" to gimple_phi.
+
+ * omp-low.c (expand_omp_for_static_chunk): Convert iterator "psi"
+ to a gimple_phi_iterator; convert locals "phi" and "nphi" to be
+ gimple_phi.
+
+ * tree-cfg.c (gimple_duplicate_sese_tail): Likewise for "psi" and
+ "phi".
+ (move_block_to_fn): Introduce new gimple_phi_iterator "psi", using
+ it in place of "gsi" where necessary. Convert "phi" to be a
+ gimple_phi.
+
+ * tree-cfgcleanup.c (remove_forwarder_block): Likewise.
+
+ * tree-vect-loop-manip.c (vect_loop_versioning): Convert "gsi" to
+ a gimple_phi_iterator, and "orig_phi" and "new_phi" to be
+ gimple_phi.
+
+ * tree.c (find_decls_types_in_node): Introduce new
+ gimple_phi_iterator "psi", using it in place of "si" where
+ necessary. Convert "phi" to be a gimple_phi.
+
+2014-10-24 David Malcolm <dmalcolm@redhat.com>
+
omp-low.c: Use more concrete types of gimple statement for various locals
* omp-low.c (finalize_task_copyfn): Strengthen local "bind" from
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 202ecac..ae9dcfb 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -44,14 +44,14 @@ along with GCC; see the file COPYING3. If not see
/* Read a PHI function for basic block BB in function FN. DATA_IN is
the file being read. IB is the input block to use for reading. */
-static gimple
+static gimple_phi
input_phi (struct lto_input_block *ib, basic_block bb, struct data_in *data_in,
struct function *fn)
{
unsigned HOST_WIDE_INT ix;
tree phi_result;
int i, len;
- gimple result;
+ gimple_phi result;
ix = streamer_read_uhwi (ib);
phi_result = (*SSANAMES (fn))[ix];
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 2bc605f..71def75 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -41,7 +41,7 @@ along with GCC; see the file COPYING3. If not see
/* Output PHI function PHI to the main stream in OB. */
static void
-output_phi (struct output_block *ob, gimple phi)
+output_phi (struct output_block *ob, gimple_phi phi)
{
unsigned i, len = gimple_phi_num_args (phi);
@@ -238,9 +238,11 @@ output_bb (struct output_block *ob, basic_block bb, struct function *fn)
streamer_write_record_start (ob, LTO_null);
- for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+ for (gimple_phi_iterator psi = gsi_start_phis (bb);
+ !gsi_end_p (psi);
+ gsi_next (&psi))
{
- gimple phi = gsi_stmt (bsi);
+ gimple_phi phi = psi.phi ();
/* Only emit PHIs for gimple registers. PHI nodes for .MEM
will be filled in on reading when the SSA form is
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 4e59777..e4ebcff 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3971,12 +3971,12 @@ gimple_phi_arg_def (gimple gs, size_t index)
}
-/* Return a pointer to the tree operand for argument I of PHI node GS. */
+/* Return a pointer to the tree operand for argument I of phi node PHI. */
static inline tree *
-gimple_phi_arg_def_ptr (gimple gs, size_t index)
+gimple_phi_arg_def_ptr (gimple_phi phi, size_t index)
{
- return &gimple_phi_arg (gs, index)->def;
+ return &gimple_phi_arg (phi, index)->def;
}
/* Return the edge associated with argument I of phi node GS. */
@@ -4011,12 +4011,12 @@ gimple_phi_arg_set_location (gimple gs, size_t i, source_location loc)
gimple_phi_arg (gs, i)->locus = loc;
}
-/* Return TRUE if argument I of phi node GS has a location record. */
+/* Return TRUE if argument I of phi node PHI has a location record. */
static inline bool
-gimple_phi_arg_has_location (gimple gs, size_t i)
+gimple_phi_arg_has_location (gimple_phi phi, size_t i)
{
- return gimple_phi_arg_location (gs, i) != UNKNOWN_LOCATION;
+ return gimple_phi_arg_location (phi, i) != UNKNOWN_LOCATION;
}
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 9946f3f..720a885 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -6732,8 +6732,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
if (gimple_in_ssa_p (cfun))
{
- gimple_stmt_iterator psi;
- gimple phi;
+ gimple_phi_iterator psi;
+ gimple_phi phi;
edge re, ene;
edge_var_map *vm;
size_t i;
@@ -6752,10 +6752,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
for (i = 0; !gsi_end_p (psi) && head->iterate (i, &vm);
gsi_next (&psi), ++i)
{
- gimple nphi;
+ gimple_phi nphi;
source_location locus;
- phi = gsi_stmt (psi);
+ phi = psi.phi ();
t = gimple_phi_result (phi);
gcc_assert (t == redirect_edge_var_map_result (vm));
nphi = create_phi_node (t, iter_part_bb);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 9db1ffd..479989f 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6131,8 +6131,8 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU
gimple cond_stmt;
edge sorig, snew;
basic_block exit_bb;
- gimple_stmt_iterator psi;
- gimple phi;
+ gimple_phi_iterator psi;
+ gimple_phi phi;
tree def;
struct loop *target, *aloop, *cloop;
@@ -6252,7 +6252,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU
!gsi_end_p (psi);
gsi_next (&psi))
{
- phi = gsi_stmt (psi);
+ phi = psi.phi ();
def = PHI_ARG_DEF (phi, nexits[0]->dest_idx);
add_phi_arg (phi, def, e, gimple_phi_arg_location_from_edge (phi, e));
}
@@ -6629,9 +6629,10 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
(*cfg->x_basic_block_info)[bb->index] = bb;
/* Remap the variables in phi nodes. */
- for (si = gsi_start_phis (bb); !gsi_end_p (si); )
+ for (gimple_phi_iterator psi = gsi_start_phis (bb);
+ !gsi_end_p (psi); )
{
- gimple phi = gsi_stmt (si);
+ gimple_phi phi = psi.phi ();
use_operand_p use;
tree op = PHI_RESULT (phi);
ssa_op_iter oi;
@@ -6641,7 +6642,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
{
/* Remove the phi nodes for virtual operands (alias analysis will be
run for the new function, anyway). */
- remove_phi_node (&si, true);
+ remove_phi_node (&psi, true);
continue;
}
@@ -6671,7 +6672,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
}
}
- gsi_next (&si);
+ gsi_next (&psi);
}
for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 3b2a107..f4abe53 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -468,11 +468,11 @@ remove_forwarder_block (basic_block bb)
{
/* Create arguments for the phi nodes, since the edge was not
here before. */
- for (gsi = gsi_start_phis (dest);
- !gsi_end_p (gsi);
- gsi_next (&gsi))
+ for (gimple_phi_iterator psi = gsi_start_phis (dest);
+ !gsi_end_p (psi);
+ gsi_next (&psi))
{
- gimple phi = gsi_stmt (gsi);
+ gimple_phi phi = psi.phi ();
source_location l = gimple_phi_arg_location_from_edge (phi, succ);
tree def = gimple_phi_arg_def (phi, succ->dest_idx);
add_phi_arg (phi, unshare_expr (def), s, l);
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index db565a4..2aa3720 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -2317,11 +2317,12 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
struct loop *scalar_loop = LOOP_VINFO_SCALAR_LOOP (loop_vinfo);
basic_block condition_bb;
- gimple_stmt_iterator gsi, cond_exp_gsi;
+ gimple_phi_iterator gsi;
+ gimple_stmt_iterator cond_exp_gsi;
basic_block merge_bb;
basic_block new_exit_bb;
edge new_exit_e, e;
- gimple orig_phi, new_phi;
+ gimple_phi orig_phi, new_phi;
tree cond_expr = NULL_TREE;
gimple_seq cond_expr_stmt_list = NULL;
tree arg;
@@ -2425,7 +2426,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
for (gsi = gsi_start_phis (merge_bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
tree new_res;
- orig_phi = gsi_stmt (gsi);
+ orig_phi = gsi.phi ();
new_res = copy_ssa_name (PHI_RESULT (orig_phi), NULL);
new_phi = create_phi_node (new_res, new_exit_bb);
arg = PHI_ARG_DEF_FROM_EDGE (orig_phi, e);
diff --git a/gcc/tree.c b/gcc/tree.c
index 2f4d194..72843ca 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5502,12 +5502,13 @@ find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld)
/* Traverse every statement in FN. */
FOR_EACH_BB_FN (bb, fn)
{
+ gimple_phi_iterator psi;
gimple_stmt_iterator si;
unsigned i;
- for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+ for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
{
- gimple phi = gsi_stmt (si);
+ gimple_phi phi = psi.phi ();
for (i = 0; i < gimple_phi_num_args (phi); i++)
{
--
1.8.5.3