summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog143
-rw-r--r--gcc/Makefile.in1
-rw-r--r--gcc/asan.c1
-rw-r--r--gcc/cfgexpand.c2
-rw-r--r--gcc/cfgloop.c1
-rw-r--r--gcc/cfgloopmanip.c1
-rw-r--r--gcc/cgraph.c1
-rw-r--r--gcc/cgraphbuild.c2
-rw-r--r--gcc/cgraphunit.c1
-rw-r--r--gcc/config/aarch64/aarch64-builtins.c1
-rw-r--r--gcc/config/rs6000/rs6000.c2
-rw-r--r--gcc/gengtype.c6
-rw-r--r--gcc/gimple-fold.c1
-rw-r--r--gcc/gimple-iterator.c1
-rw-r--r--gcc/gimple-iterator.h288
-rw-r--r--gcc/gimple-low.c1
-rw-r--r--gcc/gimple-pretty-print.c1
-rw-r--r--gcc/gimple-ssa-isolate-paths.c2
-rw-r--r--gcc/gimple-ssa-strength-reduction.c1
-rw-r--r--gcc/gimple-streamer-in.c1
-rw-r--r--gcc/gimple-streamer-out.c1
-rw-r--r--gcc/gimple-walk.c871
-rw-r--r--gcc/gimple-walk.h99
-rw-r--r--gcc/gimple.c850
-rw-r--r--gcc/gimple.h357
-rw-r--r--gcc/gimplify.c1
-rw-r--r--gcc/graphite-blocking.c1
-rw-r--r--gcc/graphite-clast-to-gimple.c1
-rw-r--r--gcc/graphite-dependences.c1
-rw-r--r--gcc/graphite-interchange.c1
-rw-r--r--gcc/graphite-optimize-isl.c1
-rw-r--r--gcc/graphite-poly.c1
-rw-r--r--gcc/graphite-scop-detection.c1
-rw-r--r--gcc/graphite-sese-to-poly.c1
-rw-r--r--gcc/graphite.c1
-rw-r--r--gcc/ipa-inline-analysis.c1
-rw-r--r--gcc/ipa-profile.c1
-rw-r--r--gcc/ipa-prop.c2
-rw-r--r--gcc/ipa-pure-const.c2
-rw-r--r--gcc/ipa-split.c2
-rw-r--r--gcc/lto-streamer-in.c1
-rw-r--r--gcc/lto-streamer-out.c1
-rw-r--r--gcc/omp-low.c2
-rw-r--r--gcc/predict.c1
-rw-r--r--gcc/profile.c1
-rw-r--r--gcc/sese.c1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/plugin/selfassign.c1
-rw-r--r--gcc/testsuite/gcc.dg/plugin/selfassign.c1
-rw-r--r--gcc/tracer.c1
-rw-r--r--gcc/trans-mem.c2
-rw-r--r--gcc/tree-call-cdce.c1
-rw-r--r--gcc/tree-cfg.c2
-rw-r--r--gcc/tree-cfgcleanup.c1
-rw-r--r--gcc/tree-complex.c1
-rw-r--r--gcc/tree-data-ref.c1
-rw-r--r--gcc/tree-dfa.c2
-rw-r--r--gcc/tree-eh.c1
-rw-r--r--gcc/tree-emutls.c2
-rw-r--r--gcc/tree-if-conv.c1
-rw-r--r--gcc/tree-inline.c2
-rw-r--r--gcc/tree-into-ssa.c1
-rw-r--r--gcc/tree-loop-distribution.c1
-rw-r--r--gcc/tree-nested.c2
-rw-r--r--gcc/tree-nrv.c2
-rw-r--r--gcc/tree-object-size.c1
-rw-r--r--gcc/tree-outof-ssa.c1
-rw-r--r--gcc/tree-parloops.c2
-rw-r--r--gcc/tree-phinodes.c14
-rw-r--r--gcc/tree-phinodes.h16
-rw-r--r--gcc/tree-predcom.c1
-rw-r--r--gcc/tree-profile.c1
-rw-r--r--gcc/tree-scalar-evolution.c1
-rw-r--r--gcc/tree-sra.c2
-rw-r--r--gcc/tree-ssa-ccp.c1
-rw-r--r--gcc/tree-ssa-coalesce.c1
-rw-r--r--gcc/tree-ssa-copy.c1
-rw-r--r--gcc/tree-ssa-copyrename.c1
-rw-r--r--gcc/tree-ssa-dce.c1
-rw-r--r--gcc/tree-ssa-dom.c1
-rw-r--r--gcc/tree-ssa-dse.c1
-rw-r--r--gcc/tree-ssa-forwprop.c1
-rw-r--r--gcc/tree-ssa-ifcombine.c1
-rw-r--r--gcc/tree-ssa-live.c1
-rw-r--r--gcc/tree-ssa-loop-ch.c1
-rw-r--r--gcc/tree-ssa-loop-im.c1
-rw-r--r--gcc/tree-ssa-loop-ivcanon.c1
-rw-r--r--gcc/tree-ssa-loop-ivopts.c1
-rw-r--r--gcc/tree-ssa-loop-manip.c1
-rw-r--r--gcc/tree-ssa-loop-niter.c1
-rw-r--r--gcc/tree-ssa-loop-prefetch.c1
-rw-r--r--gcc/tree-ssa-loop.c1
-rw-r--r--gcc/tree-ssa-math-opts.c1
-rw-r--r--gcc/tree-ssa-phiopt.c1
-rw-r--r--gcc/tree-ssa-phiprop.c1
-rw-r--r--gcc/tree-ssa-pre.c1
-rw-r--r--gcc/tree-ssa-propagate.c1
-rw-r--r--gcc/tree-ssa-reassoc.c1
-rw-r--r--gcc/tree-ssa-sink.c1
-rw-r--r--gcc/tree-ssa-strlen.c1
-rw-r--r--gcc/tree-ssa-structalias.c1
-rw-r--r--gcc/tree-ssa-tail-merge.c1
-rw-r--r--gcc/tree-ssa-ter.c1
-rw-r--r--gcc/tree-ssa-threadedge.c1
-rw-r--r--gcc/tree-ssa-threadupdate.c1
-rw-r--r--gcc/tree-ssa-uncprop.c1
-rw-r--r--gcc/tree-ssa-uninit.c1
-rw-r--r--gcc/tree-ssa.c2
-rw-r--r--gcc/tree-stdarg.c2
-rw-r--r--gcc/tree-switch-conversion.c1
-rw-r--r--gcc/tree-tailcall.c1
-rw-r--r--gcc/tree-vect-data-refs.c1
-rw-r--r--gcc/tree-vect-generic.c1
-rw-r--r--gcc/tree-vect-loop-manip.c1
-rw-r--r--gcc/tree-vect-loop.c1
-rw-r--r--gcc/tree-vect-patterns.c1
-rw-r--r--gcc/tree-vect-slp.c1
-rw-r--r--gcc/tree-vect-stmts.c1
-rw-r--r--gcc/tree-vectorizer.c2
-rw-r--r--gcc/tree-vrp.c2
-rw-r--r--gcc/tree.c1
-rw-r--r--gcc/tsan.c1
-rw-r--r--gcc/value-prof.c1
-rw-r--r--gcc/vtable-verify.c1
124 files changed, 1571 insertions, 1213 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index adc637c7a42..a8d9c5bd66a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,146 @@
+2013-11-13 Andrew MacLeod <amacleod@redhat,com>
+
+ * gimple-walk.h: New File. Relocate prototypes from gimple.h.
+ (struct walk_stmt_info): Relocate here from gimple.h.
+ * gimple-iterator.h: New File. Relocate prototypes from gimple.h.
+ (struct gimple_stmt_iterator_d): Relocate here from gimple.h.
+ (gsi_start_1, gsi_none, gsi_start_bb, gsi_last_1, gsi_last_bb,
+ gsi_end_p, gsi_one_before_end_p, gsi_next, gsi_prev, gsi_stmt,
+ gsi_after_labels, gsi_next_nondebug, gsi_prev_nondebug,
+ gsi_start_nondebug_bb, gsi_start_nondebug_after_labels_bb,
+ gsi_last_nondebug_bb, gsi_bb, gsi_seq): Relocate here from gimple.h.
+ * gimple.h (struct gimple_stmt_iterator_d): Move to gimple-iterator.h.
+ (gsi_start_1, gsi_none, gsi_start_bb, gsi_last_1, gsi_last_bb,
+ gsi_end_p, gsi_one_before_end_p, gsi_next, gsi_prev, gsi_stmt,
+ gsi_after_labels, gsi_next_nondebug, gsi_prev_nondebug,
+ gsi_start_nondebug_bb, gsi_start_nondebug_after_labels_bb,
+ gsi_last_nondebug_bb, gsi_bb, gsi_seq): Move to gimple-iterator.h.
+ (struct walk_stmt_info): Move to gimple-walk.h.
+ (gimple_seq_set_location): Move to gimple.c
+ * gimple-walk.c: New File.
+ (walk_gimple_seq_mod, walk_gimple_seq, walk_gimple_asm, walk_gimple_op,
+ walk_gimple_stmt, get_base_loadstore, walk_stmt_load_store_addr_ops,
+ walk_stmt_load_store_ops): Relocate here from gimple.c.
+ * gimple-iterator.c: Include gimple-iterator.h.
+ * gimple.c (walk_gimple_seq_mod, walk_gimple_seq, walk_gimple_asm,
+ walk_gimple_op, walk_gimple_stmt, get_base_loadstore,
+ walk_stmt_load_store_addr_ops, walk_stmt_load_store_ops): Move to
+ gimple-walk.c.
+ (gimple_seq_set_location): Relocate from gimple.h.
+ * tree-phinodes.h (set_phi_nodes): Move to tree-phinodes.c.
+ * tree-phinodes.c (set_phi_nodes): Relocate from tree-phinodes.h.
+ * gengtype.c (open_base_files): Add gimple-iterator.h to include list.
+ * Makefile.in (OBJS): Add gimple-walk.o
+ * asan.c: Update Include list as required for gimple-iterator.h and
+ gimple-walk.h.
+ * cfgexpand.c: Likewise.
+ * cfgloop.c: Likewise.
+ * cfgloopmanip.c: Likewise.
+ * cgraph.c: Likewise.
+ * cgraphbuild.c: Likewise.
+ * cgraphunit.c: Likewise.
+ * gimple-fold.c: Likewise.
+ * gimple-low.c: Likewise.
+ * gimple-pretty-print.c: Likewise.
+ * gimple-ssa-isolate-paths.c: Likewise.
+ * gimple-ssa-strength-reduction.c: Likewise.
+ * gimple-streamer-in.c: Likewise.
+ * gimple-streamer-out.c: Likewise.
+ * gimplify.c: Likewise.
+ * graphite-blocking.c: Likewise.
+ * graphite-clast-to-gimple.c: Likewise.
+ * graphite-dependences.c: Likewise.
+ * graphite-interchange.c: Likewise.
+ * graphite-optimize-isl.c: Likewise.
+ * graphite-poly.c: Likewise.
+ * graphite-scop-detection.c: Likewise.
+ * graphite-sese-to-poly.c: Likewise.
+ * graphite.c: Likewise.
+ * ipa-inline-analysis.c: Likewise.
+ * ipa-profile.c: Likewise.
+ * ipa-prop.c: Likewise.
+ * ipa-pure-const.c: Likewise.
+ * ipa-split.c: Likewise.
+ * lto-streamer-in.c: Likewise.
+ * lto-streamer-out.c: Likewise.
+ * omp-low.c: Likewise.
+ * predict.c: Likewise.
+ * profile.c: Likewise.
+ * sese.c: Likewise.
+ * tracer.c: Likewise.
+ * trans-mem.c: Likewise.
+ * tree-call-cdce.c: Likewise.
+ * tree-cfg.c: Likewise.
+ * tree-cfgcleanup.c: Likewise.
+ * tree-complex.c: Likewise.
+ * tree-data-ref.c: Likewise.
+ * tree-dfa.c: Likewise.
+ * tree-eh.c: Likewise.
+ * tree-emutls.c: Likewise.
+ * tree-if-conv.c: Likewise.
+ * tree-inline.c: Likewise.
+ * tree-into-ssa.c: Likewise.
+ * tree-loop-distribution.c: Likewise.
+ * tree-nested.c: Likewise.
+ * tree-nrv.c: Likewise.
+ * tree-object-size.c: Likewise.
+ * tree-outof-ssa.c: Likewise.
+ * tree-parloops.c: Likewise.
+ * tree-predcom.c: Likewise.
+ * tree-profile.c: Likewise.
+ * tree-scalar-evolution.c: Likewise.
+ * tree-sra.c: Likewise.
+ * tree-ssa-ccp.c: Likewise.
+ * tree-ssa-coalesce.c: Likewise.
+ * tree-ssa-copy.c: Likewise.
+ * tree-ssa-copyrename.c: Likewise.
+ * tree-ssa-dce.c: Likewise.
+ * tree-ssa-dom.c: Likewise.
+ * tree-ssa-dse.c: Likewise.
+ * tree-ssa-forwprop.c: Likewise.
+ * tree-ssa-ifcombine.c: Likewise.
+ * tree-ssa-live.c: Likewise.
+ * tree-ssa-loop-ch.c: Likewise.
+ * tree-ssa-loop-im.c: Likewise.
+ * tree-ssa-loop-ivcanon.c: Likewise.
+ * tree-ssa-loop-ivopts.c: Likewise.
+ * tree-ssa-loop-manip.c: Likewise.
+ * tree-ssa-loop-niter.c: Likewise.
+ * tree-ssa-loop-prefetch.c: Likewise.
+ * tree-ssa-loop.c: Likewise.
+ * tree-ssa-math-opts.c: Likewise.
+ * tree-ssa-phiopt.c: Likewise.
+ * tree-ssa-phiprop.c: Likewise.
+ * tree-ssa-pre.c: Likewise.
+ * tree-ssa-propagate.c: Likewise.
+ * tree-ssa-reassoc.c: Likewise.
+ * tree-ssa-sink.c: Likewise.
+ * tree-ssa-strlen.c: Likewise.
+ * tree-ssa-structalias.c: Likewise.
+ * tree-ssa-tail-merge.c: Likewise.
+ * tree-ssa-ter.c: Likewise.
+ * tree-ssa-threadedge.c: Likewise.
+ * tree-ssa-threadupdate.c: Likewise.
+ * tree-ssa-uncprop.c: Likewise.
+ * tree-ssa-uninit.c: Likewise.
+ * tree-ssa.c: Likewise.
+ * tree-stdarg.c: Likewise.
+ * tree-switch-conversion.c: Likewise.
+ * tree-tailcall.c: Likewise.
+ * tree-vect-data-refs.c: Likewise.
+ * tree-vect-generic.c: Likewise.
+ * tree-vect-loop-manip.c: Likewise.
+ * tree-vect-loop.c: Likewise.
+ * tree-vect-patterns.c: Likewise.
+ * tree-vect-slp.c: Likewise.
+ * tree-vect-stmts.c: Likewise.
+ * tree-vectorizer.c: Likewise.
+ * tree-vrp.c: Likewise.
+ * tree.c: Likewise.
+ * tsan.c: Likewise.
+ * value-prof.c: Likewise.
+ * vtable-verify.c: Likewise.
+
2013-11-13 Steven Bosscher <steven@gcc.gnu.org>
* gimple-ssa-isolate-paths.c (pass_isolate_erroneous_paths): Comment
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 031446be5ea..2987506e298 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1240,6 +1240,7 @@ OBJS = \
gimple-ssa-strength-reduction.o \
gimple-streamer-in.o \
gimple-streamer-out.o \
+ gimple-walk.o \
gimplify.o \
godump.o \
graph.o \
diff --git a/gcc/asan.c b/gcc/asan.c
index 59e26397cb1..9b6f96872ec 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "tree-iterator.h"
#include "cgraph.h"
#include "tree-ssanames.h"
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index de7a7b3fb0b..9b480a247bb 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -31,6 +31,8 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h"
#include "bitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 3ff8e841bac..01f250a1519 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "pointer-set.h"
#include "ggc.h"
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 131c2a043dc..6448605823b 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "cfgloop.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "tree-ssa-loop-manip.h"
#include "dumpfile.h"
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index b7ec16655f5..2841055635f 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
#include "cgraph.h"
#include "intl.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "timevar.h"
#include "dumpfile.h"
#include "gimple-ssa.h"
diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index 21ad0ab2ab6..7834b065d52 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -24,6 +24,8 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "langhooks.h"
#include "pointer-set.h"
#include "intl.h"
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 4765e6abb44..51961fc7a79 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -165,6 +165,7 @@ along with GCC; see the file COPYING3. If not see
#include "output.h"
#include "rtl.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-into-ssa.h"
diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index 0df5b3b0d77..2f1a8d03cb1 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -31,6 +31,7 @@
#include "diagnostic-core.h"
#include "optabs.h"
#include "gimple.h"
+#include "gimple-iterator.h"
enum aarch64_simd_builtin_type_mode
{
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 33547c41dd6..c6faa40bf24 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -52,6 +52,8 @@
#include "cfgloop.h"
#include "sched-int.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "intl.h"
#include "params.h"
#include "tm-constrs.h"
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index f35952e5a55..ecf1ef00385 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -1769,9 +1769,9 @@ open_base_files (void)
"tree.h", "rtl.h", "function.h", "insn-config.h", "expr.h",
"hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h",
"optabs.h", "libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
- "gimple.h", "gimple-ssa.h", "tree-cfg.h", "tree-phinodes.h",
- "ssa-iterators.h", "tree-ssanames.h", "tree-ssa-loop.h",
- "tree-ssa-loop-ivopts.h", "tree-ssa-loop-manip.h",
+ "gimple.h", "gimple-iterator.h", "gimple-ssa.h", "tree-cfg.h",
+ "tree-phinodes.h", "ssa-iterators.h", "tree-ssanames.h",
+ "tree-ssa-loop.h", "tree-ssa-loop-ivopts.h", "tree-ssa-loop-manip.h",
"tree-ssa-loop-niter.h", "tree-into-ssa.h", "tree-dfa.h",
"tree-ssa.h", "reload.h", "cpp-id-data.h", "tree-chrec.h",
"except.h", "output.h", "cfgloop.h",
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 1cf8965b7f2..f66d3e79e19 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "dumpfile.h"
#include "bitmap.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-ssanames.h"
#include "tree-into-ssa.h"
diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c
index e430050fcf7..b9453892891 100644
--- a/gcc/gimple-iterator.c
+++ b/gcc/gimple-iterator.c
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
new file mode 100644
index 00000000000..a9360fd14a7
--- /dev/null
+++ b/gcc/gimple-iterator.h
@@ -0,0 +1,288 @@
+/* Header file for gimple iterators.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_GIMPLE_ITERATOR_H
+#define GCC_GIMPLE_ITERATOR_H
+
+/* Iterator object for GIMPLE statement sequences. */
+
+typedef struct gimple_stmt_iterator_d
+{
+ /* Sequence node holding the current statement. */
+ gimple_seq_node ptr;
+
+ /* Sequence and basic block holding the statement. These fields
+ are necessary to handle edge cases such as when statement is
+ added to an empty basic block or when the last statement of a
+ block/sequence is removed. */
+ gimple_seq *seq;
+ basic_block bb;
+} gimple_stmt_iterator;
+
+extern void gsi_insert_seq_before_without_update (gimple_stmt_iterator *,
+ gimple_seq,
+ enum gsi_iterator_update);
+extern void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
+ enum gsi_iterator_update);
+extern void gsi_insert_seq_after_without_update (gimple_stmt_iterator *,
+ gimple_seq,
+ enum gsi_iterator_update);
+extern void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
+ enum gsi_iterator_update);
+extern gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
+extern void gsi_set_stmt (gimple_stmt_iterator *, gimple);
+extern void gsi_split_seq_before (gimple_stmt_iterator *, gimple_seq *);
+extern void gsi_replace (gimple_stmt_iterator *, gimple, bool);
+extern void gsi_replace_with_seq (gimple_stmt_iterator *, gimple_seq, bool);
+extern void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
+ enum gsi_iterator_update);
+extern void gsi_insert_before (gimple_stmt_iterator *, gimple,
+ enum gsi_iterator_update);
+extern void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
+ enum gsi_iterator_update);
+extern void gsi_insert_after (gimple_stmt_iterator *, gimple,
+ enum gsi_iterator_update);
+extern bool gsi_remove (gimple_stmt_iterator *, bool);
+extern gimple_stmt_iterator gsi_for_stmt (gimple);
+extern void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
+extern void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
+extern void gsi_move_to_bb_end (gimple_stmt_iterator *, basic_block);
+extern void gsi_insert_on_edge (edge, gimple);
+extern void gsi_insert_seq_on_edge (edge, gimple_seq);
+extern basic_block gsi_insert_on_edge_immediate (edge, gimple);
+extern basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
+extern void gsi_commit_edge_inserts (void);
+extern void gsi_commit_one_edge_insert (edge, basic_block *);
+extern gimple_stmt_iterator gsi_start_phis (basic_block);
+
+/* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
+
+static inline gimple_stmt_iterator
+gsi_start_1 (gimple_seq *seq)
+{
+ gimple_stmt_iterator i;
+
+ i.ptr = gimple_seq_first (*seq);
+ i.seq = seq;
+ i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
+
+ return i;
+}
+
+#define gsi_start(x) gsi_start_1 (&(x))
+
+static inline gimple_stmt_iterator
+gsi_none (void)
+{
+ gimple_stmt_iterator i;
+ i.ptr = NULL;
+ i.seq = NULL;
+ i.bb = NULL;
+ return i;
+}
+
+/* Return a new iterator pointing to the first statement in basic block BB. */
+
+static inline gimple_stmt_iterator
+gsi_start_bb (basic_block bb)
+{
+ gimple_stmt_iterator i;
+ gimple_seq *seq;
+
+ seq = bb_seq_addr (bb);
+ i.ptr = gimple_seq_first (*seq);
+ i.seq = seq;
+ i.bb = bb;
+
+ return i;
+}
+
+/* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
+
+static inline gimple_stmt_iterator
+gsi_last_1 (gimple_seq *seq)
+{
+ gimple_stmt_iterator i;
+
+ i.ptr = gimple_seq_last (*seq);
+ i.seq = seq;
+ i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
+
+ return i;
+}
+
+#define gsi_last(x) gsi_last_1 (&(x))
+
+/* Return a new iterator pointing to the last statement in basic block BB. */
+
+static inline gimple_stmt_iterator
+gsi_last_bb (basic_block bb)
+{
+ gimple_stmt_iterator i;
+ gimple_seq *seq;
+
+ seq = bb_seq_addr (bb);
+ i.ptr = gimple_seq_last (*seq);
+ i.seq = seq;
+ i.bb = bb;
+
+ return i;
+}
+
+/* Return true if I is at the end of its sequence. */
+
+static inline bool
+gsi_end_p (gimple_stmt_iterator i)
+{
+ return i.ptr == NULL;
+}
+
+/* Return true if I is one statement before the end of its sequence. */
+
+static inline bool
+gsi_one_before_end_p (gimple_stmt_iterator i)
+{
+ return i.ptr != NULL && i.ptr->gsbase.next == NULL;
+}
+
+/* Advance the iterator to the next gimple statement. */
+
+static inline void
+gsi_next (gimple_stmt_iterator *i)
+{
+ i->ptr = i->ptr->gsbase.next;
+}
+
+/* Advance the iterator to the previous gimple statement. */
+
+static inline void
+gsi_prev (gimple_stmt_iterator *i)
+{
+ gimple prev = i->ptr->gsbase.prev;
+ if (prev->gsbase.next)
+ i->ptr = prev;
+ else
+ i->ptr = NULL;
+}
+
+/* Return the current stmt. */
+
+static inline gimple
+gsi_stmt (gimple_stmt_iterator i)
+{
+ return i.ptr;
+}
+
+/* Return a block statement iterator that points to the first non-label
+ statement in block BB. */
+
+static inline gimple_stmt_iterator
+gsi_after_labels (basic_block bb)
+{
+ gimple_stmt_iterator gsi = gsi_start_bb (bb);
+
+ while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
+ gsi_next (&gsi);
+
+ return gsi;
+}
+
+/* Advance the iterator to the next non-debug gimple statement. */
+
+static inline void
+gsi_next_nondebug (gimple_stmt_iterator *i)
+{
+ do
+ {
+ gsi_next (i);
+ }
+ while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
+}
+
+/* Advance the iterator to the next non-debug gimple statement. */
+
+static inline void
+gsi_prev_nondebug (gimple_stmt_iterator *i)
+{
+ do
+ {
+ gsi_prev (i);
+ }
+ while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
+}
+
+/* Return a new iterator pointing to the first non-debug statement in
+ basic block BB. */
+
+static inline gimple_stmt_iterator
+gsi_start_nondebug_bb (basic_block bb)
+{
+ gimple_stmt_iterator i = gsi_start_bb (bb);
+
+ if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
+ gsi_next_nondebug (&i);
+
+ return i;
+}
+
+/* Return a new iterator pointing to the first non-debug non-label statement in
+ basic block BB. */
+
+static inline gimple_stmt_iterator
+gsi_start_nondebug_after_labels_bb (basic_block bb)
+{
+ gimple_stmt_iterator i = gsi_after_labels (bb);
+
+ if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
+ gsi_next_nondebug (&i);
+
+ return i;
+}
+
+/* Return a new iterator pointing to the last non-debug statement in
+ basic block BB. */
+
+static inline gimple_stmt_iterator
+gsi_last_nondebug_bb (basic_block bb)
+{
+ gimple_stmt_iterator i = gsi_last_bb (bb);
+
+ if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
+ gsi_prev_nondebug (&i);
+
+ return i;
+}
+
+/* Return the basic block associated with this iterator. */
+
+static inline basic_block
+gsi_bb (gimple_stmt_iterator i)
+{
+ return i.bb;
+}
+
+/* Return the sequence associated with this iterator. */
+
+static inline gimple_seq
+gsi_seq (gimple_stmt_iterator i)
+{
+ return *i.seq;
+}
+
+#endif /* GCC_GIMPLE_ITERATOR_H */
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index d527d86ab22..519e984da28 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-iterator.h"
#include "tree-inline.h"
#include "flags.h"
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 6842213199a..86c2a55c216 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "hashtab.h"
#include "bitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index ddce01438e6..f9bb249436f 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -27,6 +27,8 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "tree-ssa.h"
#include "tree-ssanames.h"
#include "gimple-ssa.h"
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 41f24cc03e5..35a725054bd 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "basic-block.h"
#include "tree-pass.h"
#include "cfgloop.h"
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 2dae1e43c0c..6f8f51a18ce 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "tree-ssanames.h"
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index e7430a68234..4d0664f3d98 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "data-streamer.h"
#include "gimple-streamer.h"
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
new file mode 100644
index 00000000000..deb4673354a
--- /dev/null
+++ b/gcc/gimple-walk.c
@@ -0,0 +1,871 @@
+/* Gimple walk support.
+
+ Copyright (C) 2007-2013 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tree.h"
+#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
+#include "gimple-walk.h"
+#include "demangle.h"
+
+/* Walk all the statements in the sequence *PSEQ calling walk_gimple_stmt
+ on each one. WI is as in walk_gimple_stmt.
+
+ If walk_gimple_stmt returns non-NULL, the walk is stopped, and the
+ value is stored in WI->CALLBACK_RESULT. Also, the statement that
+ produced the value is returned if this statement has not been
+ removed by a callback (wi->removed_stmt). If the statement has
+ been removed, NULL is returned.
+
+ Otherwise, all the statements are walked and NULL returned. */
+
+gimple
+walk_gimple_seq_mod (gimple_seq *pseq, walk_stmt_fn callback_stmt,
+ walk_tree_fn callback_op, struct walk_stmt_info *wi)
+{
+ gimple_stmt_iterator gsi;
+
+ for (gsi = gsi_start (*pseq); !gsi_end_p (gsi); )
+ {
+ tree ret = walk_gimple_stmt (&gsi, callback_stmt, callback_op, wi);
+ if (ret)
+ {
+ /* If CALLBACK_STMT or CALLBACK_OP return a value, WI must exist
+ to hold it. */
+ gcc_assert (wi);
+ wi->callback_result = ret;
+
+ return wi->removed_stmt ? NULL : gsi_stmt (gsi);
+ }
+
+ if (!wi->removed_stmt)
+ gsi_next (&gsi);
+ }
+
+ if (wi)
+ wi->callback_result = NULL_TREE;
+
+ return NULL;
+}
+
+
+/* Like walk_gimple_seq_mod, but ensure that the head of SEQ isn't
+ changed by the callbacks. */
+
+gimple
+walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt,
+ walk_tree_fn callback_op, struct walk_stmt_info *wi)
+{
+ gimple_seq seq2 = seq;
+ gimple ret = walk_gimple_seq_mod (&seq2, callback_stmt, callback_op, wi);
+ gcc_assert (seq2 == seq);
+ return ret;
+}
+
+
+/* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */
+
+static tree
+walk_gimple_asm (gimple stmt, walk_tree_fn callback_op,
+ struct walk_stmt_info *wi)
+{
+ tree ret, op;
+ unsigned noutputs;
+ const char **oconstraints;
+ unsigned i, n;
+ const char *constraint;
+ bool allows_mem, allows_reg, is_inout;
+
+ noutputs = gimple_asm_noutputs (stmt);
+ oconstraints = (const char **) alloca ((noutputs) * sizeof (const char *));
+
+ if (wi)
+ wi->is_lhs = true;
+
+ for (i = 0; i < noutputs; i++)
+ {
+ op = gimple_asm_output_op (stmt, i);
+ constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op)));
+ oconstraints[i] = constraint;
+ parse_output_constraint (&constraint, i, 0, 0, &allows_mem, &allows_reg,
+ &is_inout);
+ if (wi)
+ wi->val_only = (allows_reg || !allows_mem);
+ ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL);
+ if (ret)
+ return ret;
+ }
+
+ n = gimple_asm_ninputs (stmt);
+ for (i = 0; i < n; i++)
+ {
+ op = gimple_asm_input_op (stmt, i);
+ constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op)));
+ parse_input_constraint (&constraint, 0, 0, noutputs, 0,
+ oconstraints, &allows_mem, &allows_reg);
+ if (wi)
+ {
+ wi->val_only = (allows_reg || !allows_mem);
+ /* Although input "m" is not really a LHS, we need a lvalue. */
+ wi->is_lhs = !wi->val_only;
+ }
+ ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL);
+ if (ret)
+ return ret;
+ }
+
+ if (wi)
+ {
+ wi->is_lhs = false;
+ wi->val_only = true;
+ }
+
+ n = gimple_asm_nlabels (stmt);
+ for (i = 0; i < n; i++)
+ {
+ op = gimple_asm_label_op (stmt, i);
+ ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL);
+ if (ret)
+ return ret;
+ }
+
+ return NULL_TREE;
+}
+
+
+/* Helper function of WALK_GIMPLE_STMT. Walk every tree operand in
+ STMT. CALLBACK_OP and WI are as in WALK_GIMPLE_STMT.
+
+ CALLBACK_OP is called on each operand of STMT via walk_tree.
+ Additional parameters to walk_tree must be stored in WI. For each operand
+ OP, walk_tree is called as:
+
+ walk_tree (&OP, CALLBACK_OP, WI, WI->PSET)
+
+ If CALLBACK_OP returns non-NULL for an operand, the remaining
+ operands are not scanned.
+
+ The return value is that returned by the last call to walk_tree, or
+ NULL_TREE if no CALLBACK_OP is specified. */
+
+tree
+walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
+ struct walk_stmt_info *wi)
+{
+ struct pointer_set_t *pset = (wi) ? wi->pset : NULL;
+ unsigned i;
+ tree ret = NULL_TREE;
+
+ switch (gimple_code (stmt))
+ {
+ case GIMPLE_ASSIGN:
+ /* Walk the RHS operands. If the LHS is of a non-renamable type or
+ is a register variable, we may use a COMPONENT_REF on the RHS. */
+ if (wi)
+ {
+ tree lhs = gimple_assign_lhs (stmt);
+ wi->val_only
+ = (is_gimple_reg_type (TREE_TYPE (lhs)) && !is_gimple_reg (lhs))
+ || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS;
+ }
+
+ for (i = 1; i < gimple_num_ops (stmt); i++)
+ {
+ ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ }
+
+ /* Walk the LHS. If the RHS is appropriate for a memory, we
+ may use a COMPONENT_REF on the LHS. */
+ if (wi)
+ {
+ /* If the RHS is of a non-renamable type or is a register variable,
+ we may use a COMPONENT_REF on the LHS. */
+ tree rhs1 = gimple_assign_rhs1 (stmt);
+ wi->val_only
+ = (is_gimple_reg_type (TREE_TYPE (rhs1)) && !is_gimple_reg (rhs1))
+ || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS;
+ wi->is_lhs = true;
+ }
+
+ ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset);
+ if (ret)
+ return ret;
+
+ if (wi)
+ {
+ wi->val_only = true;
+ wi->is_lhs = false;
+ }
+ break;
+
+ case GIMPLE_CALL:
+ if (wi)
+ {
+ wi->is_lhs = false;
+ wi->val_only = true;
+ }
+
+ ret = walk_tree (gimple_call_chain_ptr (stmt), callback_op, wi, pset);
+ if (ret)
+ return ret;
+
+ ret = walk_tree (gimple_call_fn_ptr (stmt), callback_op, wi, pset);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < gimple_call_num_args (stmt); i++)
+ {
+ if (wi)
+ wi->val_only
+ = is_gimple_reg_type (TREE_TYPE (gimple_call_arg (stmt, i)));
+ ret = walk_tree (gimple_call_arg_ptr (stmt, i), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ }
+
+ if (gimple_call_lhs (stmt))
+ {
+ if (wi)
+ {
+ wi->is_lhs = true;
+ wi->val_only
+ = is_gimple_reg_type (TREE_TYPE (gimple_call_lhs (stmt)));
+ }
+
+ ret = walk_tree (gimple_call_lhs_ptr (stmt), callback_op, wi, pset);
+ if (ret)
+ return ret;
+ }
+
+ if (wi)
+ {
+ wi->is_lhs = false;
+ wi->val_only = true;
+ }
+ break;
+
+ case GIMPLE_CATCH:
+ ret = walk_tree (gimple_catch_types_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_EH_FILTER:
+ ret = walk_tree (gimple_eh_filter_types_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_ASM:
+ ret = walk_gimple_asm (stmt, callback_op, wi);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_CONTINUE:
+ ret = walk_tree (gimple_omp_continue_control_def_ptr (stmt),
+ callback_op, wi, pset);
+ if (ret)
+ return ret;
+
+ ret = walk_tree (gimple_omp_continue_control_use_ptr (stmt),
+ callback_op, wi, pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_CRITICAL:
+ ret = walk_tree (gimple_omp_critical_name_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_FOR:
+ ret = walk_tree (gimple_omp_for_clauses_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
+ {
+ ret = walk_tree (gimple_omp_for_index_ptr (stmt, i), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_for_initial_ptr (stmt, i), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_for_final_ptr (stmt, i), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_for_incr_ptr (stmt, i), callback_op,
+ wi, pset);
+ }
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_PARALLEL:
+ ret = walk_tree (gimple_omp_parallel_clauses_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_parallel_child_fn_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_parallel_data_arg_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_TASK:
+ ret = walk_tree (gimple_omp_task_clauses_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_task_child_fn_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_task_data_arg_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_task_copy_fn_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_task_arg_size_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ ret = walk_tree (gimple_omp_task_arg_align_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_SECTIONS:
+ ret = walk_tree (gimple_omp_sections_clauses_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+
+ ret = walk_tree (gimple_omp_sections_control_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+
+ break;
+
+ case GIMPLE_OMP_SINGLE:
+ ret = walk_tree (gimple_omp_single_clauses_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_TARGET:
+ ret = walk_tree (gimple_omp_target_clauses_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_TEAMS:
+ ret = walk_tree (gimple_omp_teams_clauses_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_ATOMIC_LOAD:
+ ret = walk_tree (gimple_omp_atomic_load_lhs_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+
+ ret = walk_tree (gimple_omp_atomic_load_rhs_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_ATOMIC_STORE:
+ ret = walk_tree (gimple_omp_atomic_store_val_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_TRANSACTION:
+ ret = walk_tree (gimple_transaction_label_ptr (stmt), callback_op,
+ wi, pset);
+ if (ret)
+ return ret;
+ break;
+
+ case GIMPLE_OMP_RETURN:
+ ret = walk_tree (gimple_omp_return_lhs_ptr (stmt), callback_op, wi,
+ pset);
+ if (ret)
+ return ret;
+ break;
+
+ /* Tuples that do not have operands. */
+ case GIMPLE_NOP:
+ case GIMPLE_RESX:
+ case GIMPLE_PREDICT:
+ break;
+
+ default:
+ {
+ enum gimple_statement_structure_enum gss;
+ gss = gimple_statement_structure (stmt);
+ if (gss == GSS_WITH_OPS || gss == GSS_WITH_MEM_OPS)
+ for (i = 0; i < gimple_num_ops (stmt); i++)
+ {
+ ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi, pset);
+ if (ret)
+ return ret;
+ }
+ }
+ break;
+ }
+
+ return NULL_TREE;
+}
+
+
+/* Walk the current statement in GSI (optionally using traversal state
+ stored in WI). If WI is NULL, no state is kept during traversal.
+ The callback CALLBACK_STMT is called. If CALLBACK_STMT indicates
+ that it has handled all the operands of the statement, its return
+ value is returned. Otherwise, the return value from CALLBACK_STMT
+ is discarded and its operands are scanned.
+
+ If CALLBACK_STMT is NULL or it didn't handle the operands,
+ CALLBACK_OP is called on each operand of the statement via
+ walk_gimple_op. If walk_gimple_op returns non-NULL for any
+ operand, the remaining operands are not scanned. In this case, the
+ return value from CALLBACK_OP is returned.
+
+ In any other case, NULL_TREE is returned. */
+
+tree
+walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
+ walk_tree_fn callback_op, struct walk_stmt_info *wi)
+{
+ gimple ret;
+ tree tree_ret;
+ gimple stmt = gsi_stmt (*gsi);
+
+ if (wi)
+ {
+ wi->gsi = *gsi;
+ wi->removed_stmt = false;
+
+ if (wi->want_locations && gimple_has_location (stmt))
+ input_location = gimple_location (stmt);
+ }
+
+ ret = NULL;
+
+ /* Invoke the statement callback. Return if the callback handled
+ all of STMT operands by itself. */
+ if (callback_stmt)
+ {
+ bool handled_ops = false;
+ tree_ret = callback_stmt (gsi, &handled_ops, wi);
+ if (handled_ops)
+ return tree_ret;
+
+ /* If CALLBACK_STMT did not handle operands, it should not have
+ a value to return. */
+ gcc_assert (tree_ret == NULL);
+
+ if (wi && wi->removed_stmt)
+ return NULL;
+
+ /* Re-read stmt in case the callback changed it. */
+ stmt = gsi_stmt (*gsi);
+ }
+
+ /* If CALLBACK_OP is defined, invoke it on every operand of STMT. */
+ if (callback_op)
+ {
+ tree_ret = walk_gimple_op (stmt, callback_op, wi);
+ if (tree_ret)
+ return tree_ret;
+ }
+
+ /* If STMT can have statements inside (e.g. GIMPLE_BIND), walk them. */
+ switch (gimple_code (stmt))
+ {
+ case GIMPLE_BIND:
+ ret = walk_gimple_seq_mod (gimple_bind_body_ptr (stmt), callback_stmt,
+ callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ break;
+
+ case GIMPLE_CATCH:
+ ret = walk_gimple_seq_mod (gimple_catch_handler_ptr (stmt), callback_stmt,
+ callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ break;
+
+ case GIMPLE_EH_FILTER:
+ ret = walk_gimple_seq_mod (gimple_eh_filter_failure_ptr (stmt), callback_stmt,
+ callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ break;
+
+ case GIMPLE_EH_ELSE:
+ ret = walk_gimple_seq_mod (gimple_eh_else_n_body_ptr (stmt),
+ callback_stmt, callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ ret = walk_gimple_seq_mod (gimple_eh_else_e_body_ptr (stmt),
+ callback_stmt, callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ break;
+
+ case GIMPLE_TRY:
+ ret = walk_gimple_seq_mod (gimple_try_eval_ptr (stmt), callback_stmt, callback_op,
+ wi);
+ if (ret)
+ return wi->callback_result;
+
+ ret = walk_gimple_seq_mod (gimple_try_cleanup_ptr (stmt), callback_stmt,
+ callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ break;
+
+ case GIMPLE_OMP_FOR:
+ ret = walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt), callback_stmt,
+ callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+
+ /* FALL THROUGH. */
+ case GIMPLE_OMP_CRITICAL:
+ case GIMPLE_OMP_MASTER:
+ case GIMPLE_OMP_TASKGROUP:
+ case GIMPLE_OMP_ORDERED:
+ case GIMPLE_OMP_SECTION:
+ case GIMPLE_OMP_PARALLEL:
+ case GIMPLE_OMP_TASK:
+ case GIMPLE_OMP_SECTIONS:
+ case GIMPLE_OMP_SINGLE:
+ case GIMPLE_OMP_TARGET:
+ case GIMPLE_OMP_TEAMS:
+ ret = walk_gimple_seq_mod (gimple_omp_body_ptr (stmt), callback_stmt,
+ callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ break;
+
+ case GIMPLE_WITH_CLEANUP_EXPR:
+ ret = walk_gimple_seq_mod (gimple_wce_cleanup_ptr (stmt), callback_stmt,
+ callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ break;
+
+ case GIMPLE_TRANSACTION:
+ ret = walk_gimple_seq_mod (gimple_transaction_body_ptr (stmt),
+ callback_stmt, callback_op, wi);
+ if (ret)
+ return wi->callback_result;
+ break;
+
+ default:
+ gcc_assert (!gimple_has_substatements (stmt));
+ break;
+ }
+
+ return NULL;
+}
+
+/* From a tree operand OP return the base of a load or store operation
+ or NULL_TREE if OP is not a load or a store. */
+
+static tree
+get_base_loadstore (tree op)
+{
+ while (handled_component_p (op))
+ op = TREE_OPERAND (op, 0);
+ if (DECL_P (op)
+ || INDIRECT_REF_P (op)
+ || TREE_CODE (op) == MEM_REF
+ || TREE_CODE (op) == TARGET_MEM_REF)
+ return op;
+ return NULL_TREE;
+}
+
+
+/* For the statement STMT call the callbacks VISIT_LOAD, VISIT_STORE and
+ VISIT_ADDR if non-NULL on loads, store and address-taken operands
+ passing the STMT, the base of the operand and DATA to it. The base
+ will be either a decl, an indirect reference (including TARGET_MEM_REF)
+ or the argument of an address expression.
+ Returns the results of these callbacks or'ed. */
+
+bool
+walk_stmt_load_store_addr_ops (gimple stmt, void *data,
+ bool (*visit_load)(gimple, tree, void *),
+ bool (*visit_store)(gimple, tree, void *),
+ bool (*visit_addr)(gimple, tree, void *))
+{
+ bool ret = false;
+ unsigned i;
+ if (gimple_assign_single_p (stmt))
+ {
+ tree lhs, rhs;
+ if (visit_store)
+ {
+ lhs = get_base_loadstore (gimple_assign_lhs (stmt));
+ if (lhs)
+ ret |= visit_store (stmt, lhs, data);
+ }
+ rhs = gimple_assign_rhs1 (stmt);
+ while (handled_component_p (rhs))
+ rhs = TREE_OPERAND (rhs, 0);
+ if (visit_addr)
+ {
+ if (TREE_CODE (rhs) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data);
+ else if (TREE_CODE (rhs) == TARGET_MEM_REF
+ && TREE_CODE (TMR_BASE (rhs)) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (rhs), 0), data);
+ else if (TREE_CODE (rhs) == OBJ_TYPE_REF
+ && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs)) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs),
+ 0), data);
+ else if (TREE_CODE (rhs) == CONSTRUCTOR)
+ {
+ unsigned int ix;
+ tree val;
+
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), ix, val)
+ if (TREE_CODE (val) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (val, 0), data);
+ else if (TREE_CODE (val) == OBJ_TYPE_REF
+ && TREE_CODE (OBJ_TYPE_REF_OBJECT (val)) == ADDR_EXPR)
+ ret |= visit_addr (stmt,
+ TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val),
+ 0), data);
+ }
+ lhs = gimple_assign_lhs (stmt);
+ if (TREE_CODE (lhs) == TARGET_MEM_REF
+ && TREE_CODE (TMR_BASE (lhs)) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (lhs), 0), data);
+ }
+ if (visit_load)
+ {
+ rhs = get_base_loadstore (rhs);
+ if (rhs)
+ ret |= visit_load (stmt, rhs, data);
+ }
+ }
+ else if (visit_addr
+ && (is_gimple_assign (stmt)
+ || gimple_code (stmt) == GIMPLE_COND))
+ {
+ for (i = 0; i < gimple_num_ops (stmt); ++i)
+ {
+ tree op = gimple_op (stmt, i);
+ if (op == NULL_TREE)
+ ;
+ else if (TREE_CODE (op) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
+ /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison
+ tree with two operands. */
+ else if (i == 1 && COMPARISON_CLASS_P (op))
+ {
+ if (TREE_CODE (TREE_OPERAND (op, 0)) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 0),
+ 0), data);
+ if (TREE_CODE (TREE_OPERAND (op, 1)) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 1),
+ 0), data);
+ }
+ }
+ }
+ else if (is_gimple_call (stmt))
+ {
+ if (visit_store)
+ {
+ tree lhs = gimple_call_lhs (stmt);
+ if (lhs)
+ {
+ lhs = get_base_loadstore (lhs);
+ if (lhs)
+ ret |= visit_store (stmt, lhs, data);
+ }
+ }
+ if (visit_load || visit_addr)
+ for (i = 0; i < gimple_call_num_args (stmt); ++i)
+ {
+ tree rhs = gimple_call_arg (stmt, i);
+ if (visit_addr
+ && TREE_CODE (rhs) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data);
+ else if (visit_load)
+ {
+ rhs = get_base_loadstore (rhs);
+ if (rhs)
+ ret |= visit_load (stmt, rhs, data);
+ }
+ }
+ if (visit_addr
+ && gimple_call_chain (stmt)
+ && TREE_CODE (gimple_call_chain (stmt)) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (gimple_call_chain (stmt), 0),
+ data);
+ if (visit_addr
+ && gimple_call_return_slot_opt_p (stmt)
+ && gimple_call_lhs (stmt) != NULL_TREE
+ && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt))))
+ ret |= visit_addr (stmt, gimple_call_lhs (stmt), data);
+ }
+ else if (gimple_code (stmt) == GIMPLE_ASM)
+ {
+ unsigned noutputs;
+ const char *constraint;
+ const char **oconstraints;
+ bool allows_mem, allows_reg, is_inout;
+ noutputs = gimple_asm_noutputs (stmt);
+ oconstraints = XALLOCAVEC (const char *, noutputs);
+ if (visit_store || visit_addr)
+ for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
+ {
+ tree link = gimple_asm_output_op (stmt, i);
+ tree op = get_base_loadstore (TREE_VALUE (link));
+ if (op && visit_store)
+ ret |= visit_store (stmt, op, data);
+ if (visit_addr)
+ {
+ constraint = TREE_STRING_POINTER
+ (TREE_VALUE (TREE_PURPOSE (link)));
+ oconstraints[i] = constraint;
+ parse_output_constraint (&constraint, i, 0, 0, &allows_mem,
+ &allows_reg, &is_inout);
+ if (op && !allows_reg && allows_mem)
+ ret |= visit_addr (stmt, op, data);
+ }
+ }
+ if (visit_load || visit_addr)
+ for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
+ {
+ tree link = gimple_asm_input_op (stmt, i);
+ tree op = TREE_VALUE (link);
+ if (visit_addr
+ && TREE_CODE (op) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
+ else if (visit_load || visit_addr)
+ {
+ op = get_base_loadstore (op);
+ if (op)
+ {
+ if (visit_load)
+ ret |= visit_load (stmt, op, data);
+ if (visit_addr)
+ {
+ constraint = TREE_STRING_POINTER
+ (TREE_VALUE (TREE_PURPOSE (link)));
+ parse_input_constraint (&constraint, 0, 0, noutputs,
+ 0, oconstraints,
+ &allows_mem, &allows_reg);
+ if (!allows_reg && allows_mem)
+ ret |= visit_addr (stmt, op, data);
+ }
+ }
+ }
+ }
+ }
+ else if (gimple_code (stmt) == GIMPLE_RETURN)
+ {
+ tree op = gimple_return_retval (stmt);
+ if (op)
+ {
+ if (visit_addr
+ && TREE_CODE (op) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
+ else if (visit_load)
+ {
+ op = get_base_loadstore (op);
+ if (op)
+ ret |= visit_load (stmt, op, data);
+ }
+ }
+ }
+ else if (visit_addr
+ && gimple_code (stmt) == GIMPLE_PHI)
+ {
+ for (i = 0; i < gimple_phi_num_args (stmt); ++i)
+ {
+ tree op = gimple_phi_arg_def (stmt, i);
+ if (TREE_CODE (op) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
+ }
+ }
+ else if (visit_addr
+ && gimple_code (stmt) == GIMPLE_GOTO)
+ {
+ tree op = gimple_goto_dest (stmt);
+ if (TREE_CODE (op) == ADDR_EXPR)
+ ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
+ }
+
+ return ret;
+}
+
+/* Like walk_stmt_load_store_addr_ops but with NULL visit_addr. IPA-CP
+ should make a faster clone for this case. */
+
+bool
+walk_stmt_load_store_ops (gimple stmt, void *data,
+ bool (*visit_load)(gimple, tree, void *),
+ bool (*visit_store)(gimple, tree, void *))
+{
+ return walk_stmt_load_store_addr_ops (stmt, data,
+ visit_load, visit_store, NULL);
+}
diff --git a/gcc/gimple-walk.h b/gcc/gimple-walk.h
new file mode 100644
index 00000000000..0b9968a522d
--- /dev/null
+++ b/gcc/gimple-walk.h
@@ -0,0 +1,99 @@
+/* Header file for gimple statement walk support.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_GIMPLE_WALK_H
+#define GCC_GIMPLE_WALK_H
+
+/* Convenience routines to walk all statements of a gimple function.
+ Note that this is useful exclusively before the code is converted
+ into SSA form. Once the program is in SSA form, the standard
+ operand interface should be used to analyze/modify statements. */
+struct walk_stmt_info
+{
+ /* Points to the current statement being walked. */
+ gimple_stmt_iterator gsi;
+
+ /* Additional data that the callback functions may want to carry
+ through the recursion. */
+ void *info;
+
+ /* Pointer map used to mark visited tree nodes when calling
+ walk_tree on each operand. If set to NULL, duplicate tree nodes
+ will be visited more than once. */
+ struct pointer_set_t *pset;
+
+ /* Operand returned by the callbacks. This is set when calling
+ walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
+ returns non-NULL, this field will contain the tree returned by
+ the last callback. */
+ tree callback_result;
+
+ /* Indicates whether the operand being examined may be replaced
+ with something that matches is_gimple_val (if true) or something
+ slightly more complicated (if false). "Something" technically
+ means the common subset of is_gimple_lvalue and is_gimple_rhs,
+ but we never try to form anything more complicated than that, so
+ we don't bother checking.
+
+ Also note that CALLBACK should update this flag while walking the
+ sub-expressions of a statement. For instance, when walking the
+ statement 'foo (&var)', the flag VAL_ONLY will initially be set
+ to true, however, when walking &var, the operand of that
+ ADDR_EXPR does not need to be a GIMPLE value. */
+ BOOL_BITFIELD val_only : 1;
+
+ /* True if we are currently walking the LHS of an assignment. */
+ BOOL_BITFIELD is_lhs : 1;
+
+ /* Optional. Set to true by the callback functions if they made any
+ changes. */
+ BOOL_BITFIELD changed : 1;
+
+ /* True if we're interested in location information. */
+ BOOL_BITFIELD want_locations : 1;
+
+ /* True if we've removed the statement that was processed. */
+ BOOL_BITFIELD removed_stmt : 1;
+};
+
+/* Callback for walk_gimple_stmt. Called for every statement found
+ during traversal. The first argument points to the statement to
+ walk. The second argument is a flag that the callback sets to
+ 'true' if it the callback handled all the operands and
+ sub-statements of the statement (the default value of this flag is
+ 'false'). The third argument is an anonymous pointer to data
+ to be used by the callback. */
+typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
+ struct walk_stmt_info *);
+
+extern gimple walk_gimple_seq_mod (gimple_seq *, walk_stmt_fn, walk_tree_fn,
+ struct walk_stmt_info *);
+extern gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
+ struct walk_stmt_info *);
+extern tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
+extern tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn,
+ walk_tree_fn, struct walk_stmt_info *);
+extern bool walk_stmt_load_store_addr_ops (gimple, void *,
+ bool (*)(gimple, tree, void *),
+ bool (*)(gimple, tree, void *),
+ bool (*)(gimple, tree, void *));
+extern bool walk_stmt_load_store_ops (gimple, void *,
+ bool (*)(gimple, tree, void *),
+ bool (*)(gimple, tree, void *));
+#endif /* GCC_GIMPLE_WALK_H */
diff --git a/gcc/gimple.c b/gcc/gimple.c
index cba3bcedf54..0e073460110 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -29,6 +29,8 @@ along with GCC; see the file COPYING3. If not see
#include "hard-reg-set.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimplify.h"
#include "diagnostic.h"
#include "value-prof.h"
@@ -1297,600 +1299,6 @@ gimple_seq_copy (gimple_seq src)
}
-/* Walk all the statements in the sequence *PSEQ calling walk_gimple_stmt
- on each one. WI is as in walk_gimple_stmt.
-
- If walk_gimple_stmt returns non-NULL, the walk is stopped, and the
- value is stored in WI->CALLBACK_RESULT. Also, the statement that
- produced the value is returned if this statement has not been
- removed by a callback (wi->removed_stmt). If the statement has
- been removed, NULL is returned.
-
- Otherwise, all the statements are walked and NULL returned. */
-
-gimple
-walk_gimple_seq_mod (gimple_seq *pseq, walk_stmt_fn callback_stmt,
- walk_tree_fn callback_op, struct walk_stmt_info *wi)
-{
- gimple_stmt_iterator gsi;
-
- for (gsi = gsi_start (*pseq); !gsi_end_p (gsi); )
- {
- tree ret = walk_gimple_stmt (&gsi, callback_stmt, callback_op, wi);
- if (ret)
- {
- /* If CALLBACK_STMT or CALLBACK_OP return a value, WI must exist
- to hold it. */
- gcc_assert (wi);
- wi->callback_result = ret;
-
- return wi->removed_stmt ? NULL : gsi_stmt (gsi);
- }
-
- if (!wi->removed_stmt)
- gsi_next (&gsi);
- }
-
- if (wi)
- wi->callback_result = NULL_TREE;
-
- return NULL;
-}
-
-
-/* Like walk_gimple_seq_mod, but ensure that the head of SEQ isn't
- changed by the callbacks. */
-
-gimple
-walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt,
- walk_tree_fn callback_op, struct walk_stmt_info *wi)
-{
- gimple_seq seq2 = seq;
- gimple ret = walk_gimple_seq_mod (&seq2, callback_stmt, callback_op, wi);
- gcc_assert (seq2 == seq);
- return ret;
-}
-
-
-/* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */
-
-static tree
-walk_gimple_asm (gimple stmt, walk_tree_fn callback_op,
- struct walk_stmt_info *wi)
-{
- tree ret, op;
- unsigned noutputs;
- const char **oconstraints;
- unsigned i, n;
- const char *constraint;
- bool allows_mem, allows_reg, is_inout;
-
- noutputs = gimple_asm_noutputs (stmt);
- oconstraints = (const char **) alloca ((noutputs) * sizeof (const char *));
-
- if (wi)
- wi->is_lhs = true;
-
- for (i = 0; i < noutputs; i++)
- {
- op = gimple_asm_output_op (stmt, i);
- constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op)));
- oconstraints[i] = constraint;
- parse_output_constraint (&constraint, i, 0, 0, &allows_mem, &allows_reg,
- &is_inout);
- if (wi)
- wi->val_only = (allows_reg || !allows_mem);
- ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL);
- if (ret)
- return ret;
- }
-
- n = gimple_asm_ninputs (stmt);
- for (i = 0; i < n; i++)
- {
- op = gimple_asm_input_op (stmt, i);
- constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op)));
- parse_input_constraint (&constraint, 0, 0, noutputs, 0,
- oconstraints, &allows_mem, &allows_reg);
- if (wi)
- {
- wi->val_only = (allows_reg || !allows_mem);
- /* Although input "m" is not really a LHS, we need a lvalue. */
- wi->is_lhs = !wi->val_only;
- }
- ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL);
- if (ret)
- return ret;
- }
-
- if (wi)
- {
- wi->is_lhs = false;
- wi->val_only = true;
- }
-
- n = gimple_asm_nlabels (stmt);
- for (i = 0; i < n; i++)
- {
- op = gimple_asm_label_op (stmt, i);
- ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL);
- if (ret)
- return ret;
- }
-
- return NULL_TREE;
-}
-
-
-/* Helper function of WALK_GIMPLE_STMT. Walk every tree operand in
- STMT. CALLBACK_OP and WI are as in WALK_GIMPLE_STMT.
-
- CALLBACK_OP is called on each operand of STMT via walk_tree.
- Additional parameters to walk_tree must be stored in WI. For each operand
- OP, walk_tree is called as:
-
- walk_tree (&OP, CALLBACK_OP, WI, WI->PSET)
-
- If CALLBACK_OP returns non-NULL for an operand, the remaining
- operands are not scanned.
-
- The return value is that returned by the last call to walk_tree, or
- NULL_TREE if no CALLBACK_OP is specified. */
-
-tree
-walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
- struct walk_stmt_info *wi)
-{
- struct pointer_set_t *pset = (wi) ? wi->pset : NULL;
- unsigned i;
- tree ret = NULL_TREE;
-
- switch (gimple_code (stmt))
- {
- case GIMPLE_ASSIGN:
- /* Walk the RHS operands. If the LHS is of a non-renamable type or
- is a register variable, we may use a COMPONENT_REF on the RHS. */
- if (wi)
- {
- tree lhs = gimple_assign_lhs (stmt);
- wi->val_only
- = (is_gimple_reg_type (TREE_TYPE (lhs)) && !is_gimple_reg (lhs))
- || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS;
- }
-
- for (i = 1; i < gimple_num_ops (stmt); i++)
- {
- ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi,
- pset);
- if (ret)
- return ret;
- }
-
- /* Walk the LHS. If the RHS is appropriate for a memory, we
- may use a COMPONENT_REF on the LHS. */
- if (wi)
- {
- /* If the RHS is of a non-renamable type or is a register variable,
- we may use a COMPONENT_REF on the LHS. */
- tree rhs1 = gimple_assign_rhs1 (stmt);
- wi->val_only
- = (is_gimple_reg_type (TREE_TYPE (rhs1)) && !is_gimple_reg (rhs1))
- || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS;
- wi->is_lhs = true;
- }
-
- ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset);
- if (ret)
- return ret;
-
- if (wi)
- {
- wi->val_only = true;
- wi->is_lhs = false;
- }
- break;
-
- case GIMPLE_CALL:
- if (wi)
- {
- wi->is_lhs = false;
- wi->val_only = true;
- }
-
- ret = walk_tree (gimple_call_chain_ptr (stmt), callback_op, wi, pset);
- if (ret)
- return ret;
-
- ret = walk_tree (gimple_call_fn_ptr (stmt), callback_op, wi, pset);
- if (ret)
- return ret;
-
- for (i = 0; i < gimple_call_num_args (stmt); i++)
- {
- if (wi)
- wi->val_only
- = is_gimple_reg_type (TREE_TYPE (gimple_call_arg (stmt, i)));
- ret = walk_tree (gimple_call_arg_ptr (stmt, i), callback_op, wi,
- pset);
- if (ret)
- return ret;
- }
-
- if (gimple_call_lhs (stmt))
- {
- if (wi)
- {
- wi->is_lhs = true;
- wi->val_only
- = is_gimple_reg_type (TREE_TYPE (gimple_call_lhs (stmt)));
- }
-
- ret = walk_tree (gimple_call_lhs_ptr (stmt), callback_op, wi, pset);
- if (ret)
- return ret;
- }
-
- if (wi)
- {
- wi->is_lhs = false;
- wi->val_only = true;
- }
- break;
-
- case GIMPLE_CATCH:
- ret = walk_tree (gimple_catch_types_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_EH_FILTER:
- ret = walk_tree (gimple_eh_filter_types_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_ASM:
- ret = walk_gimple_asm (stmt, callback_op, wi);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_CONTINUE:
- ret = walk_tree (gimple_omp_continue_control_def_ptr (stmt),
- callback_op, wi, pset);
- if (ret)
- return ret;
-
- ret = walk_tree (gimple_omp_continue_control_use_ptr (stmt),
- callback_op, wi, pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_CRITICAL:
- ret = walk_tree (gimple_omp_critical_name_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_FOR:
- ret = walk_tree (gimple_omp_for_clauses_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
- {
- ret = walk_tree (gimple_omp_for_index_ptr (stmt, i), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_for_initial_ptr (stmt, i), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_for_final_ptr (stmt, i), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_for_incr_ptr (stmt, i), callback_op,
- wi, pset);
- }
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_PARALLEL:
- ret = walk_tree (gimple_omp_parallel_clauses_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_parallel_child_fn_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_parallel_data_arg_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_TASK:
- ret = walk_tree (gimple_omp_task_clauses_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_task_child_fn_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_task_data_arg_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_task_copy_fn_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_task_arg_size_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- ret = walk_tree (gimple_omp_task_arg_align_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_SECTIONS:
- ret = walk_tree (gimple_omp_sections_clauses_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
-
- ret = walk_tree (gimple_omp_sections_control_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
-
- break;
-
- case GIMPLE_OMP_SINGLE:
- ret = walk_tree (gimple_omp_single_clauses_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_TARGET:
- ret = walk_tree (gimple_omp_target_clauses_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_TEAMS:
- ret = walk_tree (gimple_omp_teams_clauses_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_ATOMIC_LOAD:
- ret = walk_tree (gimple_omp_atomic_load_lhs_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
-
- ret = walk_tree (gimple_omp_atomic_load_rhs_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_ATOMIC_STORE:
- ret = walk_tree (gimple_omp_atomic_store_val_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_TRANSACTION:
- ret = walk_tree (gimple_transaction_label_ptr (stmt), callback_op,
- wi, pset);
- if (ret)
- return ret;
- break;
-
- case GIMPLE_OMP_RETURN:
- ret = walk_tree (gimple_omp_return_lhs_ptr (stmt), callback_op, wi,
- pset);
- if (ret)
- return ret;
- break;
-
- /* Tuples that do not have operands. */
- case GIMPLE_NOP:
- case GIMPLE_RESX:
- case GIMPLE_PREDICT:
- break;
-
- default:
- {
- enum gimple_statement_structure_enum gss;
- gss = gimple_statement_structure (stmt);
- if (gss == GSS_WITH_OPS || gss == GSS_WITH_MEM_OPS)
- for (i = 0; i < gimple_num_ops (stmt); i++)
- {
- ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi, pset);
- if (ret)
- return ret;
- }
- }
- break;
- }
-
- return NULL_TREE;
-}
-
-
-/* Walk the current statement in GSI (optionally using traversal state
- stored in WI). If WI is NULL, no state is kept during traversal.
- The callback CALLBACK_STMT is called. If CALLBACK_STMT indicates
- that it has handled all the operands of the statement, its return
- value is returned. Otherwise, the return value from CALLBACK_STMT
- is discarded and its operands are scanned.
-
- If CALLBACK_STMT is NULL or it didn't handle the operands,
- CALLBACK_OP is called on each operand of the statement via
- walk_gimple_op. If walk_gimple_op returns non-NULL for any
- operand, the remaining operands are not scanned. In this case, the
- return value from CALLBACK_OP is returned.
-
- In any other case, NULL_TREE is returned. */
-
-tree
-walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
- walk_tree_fn callback_op, struct walk_stmt_info *wi)
-{
- gimple ret;
- tree tree_ret;
- gimple stmt = gsi_stmt (*gsi);
-
- if (wi)
- {
- wi->gsi = *gsi;
- wi->removed_stmt = false;
-
- if (wi->want_locations && gimple_has_location (stmt))
- input_location = gimple_location (stmt);
- }
-
- ret = NULL;
-
- /* Invoke the statement callback. Return if the callback handled
- all of STMT operands by itself. */
- if (callback_stmt)
- {
- bool handled_ops = false;
- tree_ret = callback_stmt (gsi, &handled_ops, wi);
- if (handled_ops)
- return tree_ret;
-
- /* If CALLBACK_STMT did not handle operands, it should not have
- a value to return. */
- gcc_assert (tree_ret == NULL);
-
- if (wi && wi->removed_stmt)
- return NULL;
-
- /* Re-read stmt in case the callback changed it. */
- stmt = gsi_stmt (*gsi);
- }
-
- /* If CALLBACK_OP is defined, invoke it on every operand of STMT. */
- if (callback_op)
- {
- tree_ret = walk_gimple_op (stmt, callback_op, wi);
- if (tree_ret)
- return tree_ret;
- }
-
- /* If STMT can have statements inside (e.g. GIMPLE_BIND), walk them. */
- switch (gimple_code (stmt))
- {
- case GIMPLE_BIND:
- ret = walk_gimple_seq_mod (gimple_bind_body_ptr (stmt), callback_stmt,
- callback_op, wi);
- if (ret)
- return wi->callback_result;
- break;
-
- case GIMPLE_CATCH:
- ret = walk_gimple_seq_mod (gimple_catch_handler_ptr (stmt), callback_stmt,
- callback_op, wi);
- if (ret)
- return wi->callback_result;
- break;
-
- case GIMPLE_EH_FILTER:
- ret = walk_gimple_seq_mod (gimple_eh_filter_failure_ptr (stmt), callback_stmt,
- callback_op, wi);
- if (ret)
- return wi->callback_result;
- break;
-
- case GIMPLE_EH_ELSE:
- ret = walk_gimple_seq_mod (gimple_eh_else_n_body_ptr (stmt),
- callback_stmt, callback_op, wi);
- if (ret)
- return wi->callback_result;
- ret = walk_gimple_seq_mod (gimple_eh_else_e_body_ptr (stmt),
- callback_stmt, callback_op, wi);
- if (ret)
- return wi->callback_result;
- break;
-
- case GIMPLE_TRY:
- ret = walk_gimple_seq_mod (gimple_try_eval_ptr (stmt), callback_stmt, callback_op,
- wi);
- if (ret)
- return wi->callback_result;
-
- ret = walk_gimple_seq_mod (gimple_try_cleanup_ptr (stmt), callback_stmt,
- callback_op, wi);
- if (ret)
- return wi->callback_result;
- break;
-
- case GIMPLE_OMP_FOR:
- ret = walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt), callback_stmt,
- callback_op, wi);
- if (ret)
- return wi->callback_result;
-
- /* FALL THROUGH. */
- case GIMPLE_OMP_CRITICAL:
- case GIMPLE_OMP_MASTER:
- case GIMPLE_OMP_TASKGROUP:
- case GIMPLE_OMP_ORDERED:
- case GIMPLE_OMP_SECTION:
- case GIMPLE_OMP_PARALLEL:
- case GIMPLE_OMP_TASK:
- case GIMPLE_OMP_SECTIONS:
- case GIMPLE_OMP_SINGLE:
- case GIMPLE_OMP_TARGET:
- case GIMPLE_OMP_TEAMS:
- ret = walk_gimple_seq_mod (gimple_omp_body_ptr (stmt), callback_stmt,
- callback_op, wi);
- if (ret)
- return wi->callback_result;
- break;
-
- case GIMPLE_WITH_CLEANUP_EXPR:
- ret = walk_gimple_seq_mod (gimple_wce_cleanup_ptr (stmt), callback_stmt,
- callback_op, wi);
- if (ret)
- return wi->callback_result;
- break;
-
- case GIMPLE_TRANSACTION:
- ret = walk_gimple_seq_mod (gimple_transaction_body_ptr (stmt),
- callback_stmt, callback_op, wi);
- if (ret)
- return wi->callback_result;
- break;
-
- default:
- gcc_assert (!gimple_has_substatements (stmt));
- break;
- }
-
- return NULL;
-}
-
/* Return true if calls C1 and C2 are known to go to the same function. */
@@ -2996,251 +2404,6 @@ gimple_get_alias_set (tree t)
}
-/* From a tree operand OP return the base of a load or store operation
- or NULL_TREE if OP is not a load or a store. */
-
-static tree
-get_base_loadstore (tree op)
-{
- while (handled_component_p (op))
- op = TREE_OPERAND (op, 0);
- if (DECL_P (op)
- || INDIRECT_REF_P (op)
- || TREE_CODE (op) == MEM_REF
- || TREE_CODE (op) == TARGET_MEM_REF)
- return op;
- return NULL_TREE;
-}
-
-/* For the statement STMT call the callbacks VISIT_LOAD, VISIT_STORE and
- VISIT_ADDR if non-NULL on loads, store and address-taken operands
- passing the STMT, the base of the operand and DATA to it. The base
- will be either a decl, an indirect reference (including TARGET_MEM_REF)
- or the argument of an address expression.
- Returns the results of these callbacks or'ed. */
-
-bool
-walk_stmt_load_store_addr_ops (gimple stmt, void *data,
- bool (*visit_load)(gimple, tree, void *),
- bool (*visit_store)(gimple, tree, void *),
- bool (*visit_addr)(gimple, tree, void *))
-{
- bool ret = false;
- unsigned i;
- if (gimple_assign_single_p (stmt))
- {
- tree lhs, rhs;
- if (visit_store)
- {
- lhs = get_base_loadstore (gimple_assign_lhs (stmt));
- if (lhs)
- ret |= visit_store (stmt, lhs, data);
- }
- rhs = gimple_assign_rhs1 (stmt);
- while (handled_component_p (rhs))
- rhs = TREE_OPERAND (rhs, 0);
- if (visit_addr)
- {
- if (TREE_CODE (rhs) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data);
- else if (TREE_CODE (rhs) == TARGET_MEM_REF
- && TREE_CODE (TMR_BASE (rhs)) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (rhs), 0), data);
- else if (TREE_CODE (rhs) == OBJ_TYPE_REF
- && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs)) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs),
- 0), data);
- else if (TREE_CODE (rhs) == CONSTRUCTOR)
- {
- unsigned int ix;
- tree val;
-
- FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), ix, val)
- if (TREE_CODE (val) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (val, 0), data);
- else if (TREE_CODE (val) == OBJ_TYPE_REF
- && TREE_CODE (OBJ_TYPE_REF_OBJECT (val)) == ADDR_EXPR)
- ret |= visit_addr (stmt,
- TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val),
- 0), data);
- }
- lhs = gimple_assign_lhs (stmt);
- if (TREE_CODE (lhs) == TARGET_MEM_REF
- && TREE_CODE (TMR_BASE (lhs)) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (lhs), 0), data);
- }
- if (visit_load)
- {
- rhs = get_base_loadstore (rhs);
- if (rhs)
- ret |= visit_load (stmt, rhs, data);
- }
- }
- else if (visit_addr
- && (is_gimple_assign (stmt)
- || gimple_code (stmt) == GIMPLE_COND))
- {
- for (i = 0; i < gimple_num_ops (stmt); ++i)
- {
- tree op = gimple_op (stmt, i);
- if (op == NULL_TREE)
- ;
- else if (TREE_CODE (op) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
- /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison
- tree with two operands. */
- else if (i == 1 && COMPARISON_CLASS_P (op))
- {
- if (TREE_CODE (TREE_OPERAND (op, 0)) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 0),
- 0), data);
- if (TREE_CODE (TREE_OPERAND (op, 1)) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 1),
- 0), data);
- }
- }
- }
- else if (is_gimple_call (stmt))
- {
- if (visit_store)
- {
- tree lhs = gimple_call_lhs (stmt);
- if (lhs)
- {
- lhs = get_base_loadstore (lhs);
- if (lhs)
- ret |= visit_store (stmt, lhs, data);
- }
- }
- if (visit_load || visit_addr)
- for (i = 0; i < gimple_call_num_args (stmt); ++i)
- {
- tree rhs = gimple_call_arg (stmt, i);
- if (visit_addr
- && TREE_CODE (rhs) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data);
- else if (visit_load)
- {
- rhs = get_base_loadstore (rhs);
- if (rhs)
- ret |= visit_load (stmt, rhs, data);
- }
- }
- if (visit_addr
- && gimple_call_chain (stmt)
- && TREE_CODE (gimple_call_chain (stmt)) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (gimple_call_chain (stmt), 0),
- data);
- if (visit_addr
- && gimple_call_return_slot_opt_p (stmt)
- && gimple_call_lhs (stmt) != NULL_TREE
- && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt))))
- ret |= visit_addr (stmt, gimple_call_lhs (stmt), data);
- }
- else if (gimple_code (stmt) == GIMPLE_ASM)
- {
- unsigned noutputs;
- const char *constraint;
- const char **oconstraints;
- bool allows_mem, allows_reg, is_inout;
- noutputs = gimple_asm_noutputs (stmt);
- oconstraints = XALLOCAVEC (const char *, noutputs);
- if (visit_store || visit_addr)
- for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
- {
- tree link = gimple_asm_output_op (stmt, i);
- tree op = get_base_loadstore (TREE_VALUE (link));
- if (op && visit_store)
- ret |= visit_store (stmt, op, data);
- if (visit_addr)
- {
- constraint = TREE_STRING_POINTER
- (TREE_VALUE (TREE_PURPOSE (link)));
- oconstraints[i] = constraint;
- parse_output_constraint (&constraint, i, 0, 0, &allows_mem,
- &allows_reg, &is_inout);
- if (op && !allows_reg && allows_mem)
- ret |= visit_addr (stmt, op, data);
- }
- }
- if (visit_load || visit_addr)
- for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
- {
- tree link = gimple_asm_input_op (stmt, i);
- tree op = TREE_VALUE (link);
- if (visit_addr
- && TREE_CODE (op) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
- else if (visit_load || visit_addr)
- {
- op = get_base_loadstore (op);
- if (op)
- {
- if (visit_load)
- ret |= visit_load (stmt, op, data);
- if (visit_addr)
- {
- constraint = TREE_STRING_POINTER
- (TREE_VALUE (TREE_PURPOSE (link)));
- parse_input_constraint (&constraint, 0, 0, noutputs,
- 0, oconstraints,
- &allows_mem, &allows_reg);
- if (!allows_reg && allows_mem)
- ret |= visit_addr (stmt, op, data);
- }
- }
- }
- }
- }
- else if (gimple_code (stmt) == GIMPLE_RETURN)
- {
- tree op = gimple_return_retval (stmt);
- if (op)
- {
- if (visit_addr
- && TREE_CODE (op) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
- else if (visit_load)
- {
- op = get_base_loadstore (op);
- if (op)
- ret |= visit_load (stmt, op, data);
- }
- }
- }
- else if (visit_addr
- && gimple_code (stmt) == GIMPLE_PHI)
- {
- for (i = 0; i < gimple_phi_num_args (stmt); ++i)
- {
- tree op = gimple_phi_arg_def (stmt, i);
- if (TREE_CODE (op) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
- }
- }
- else if (visit_addr
- && gimple_code (stmt) == GIMPLE_GOTO)
- {
- tree op = gimple_goto_dest (stmt);
- if (TREE_CODE (op) == ADDR_EXPR)
- ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data);
- }
-
- return ret;
-}
-
-/* Like walk_stmt_load_store_addr_ops but with NULL visit_addr. IPA-CP
- should make a faster clone for this case. */
-
-bool
-walk_stmt_load_store_ops (gimple stmt, void *data,
- bool (*visit_load)(gimple, tree, void *),
- bool (*visit_store)(gimple, tree, void *))
-{
- return walk_stmt_load_store_addr_ops (stmt, data,
- visit_load, visit_store, NULL);
-}
-
/* Helper for gimple_ior_addresses_taken_1. */
static bool
@@ -3688,3 +2851,12 @@ preprocess_case_label_vec_for_gimple (vec<tree> labels,
if (default_casep)
*default_casep = default_case;
}
+
+/* Set the location of all statements in SEQ to LOC. */
+
+void
+gimple_seq_set_location (gimple_seq seq, location_t loc)
+{
+ for (gimple_stmt_iterator i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
+ gimple_set_location (gsi_stmt (i), loc);
+}
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 4f34a9eea92..db24800b43a 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -141,21 +141,6 @@ enum plf_mask {
GF_PLF_2 = 1 << 1
};
-/* Iterator object for GIMPLE statement sequences. */
-
-struct gimple_stmt_iterator_d
-{
- /* Sequence node holding the current statement. */
- gimple_seq_node ptr;
-
- /* Sequence and basic block holding the statement. These fields
- are necessary to handle edge cases such as when statement is
- added to an empty basic block or when the last statement of a
- block/sequence is removed. */
- gimple_seq *seq;
- basic_block bb;
-};
-
/* Data structure definitions for GIMPLE tuples. NOTE: word markers
are for 64 bit hosts. */
@@ -847,13 +832,6 @@ extern bool gimple_compare_field_offset (tree, tree);
extern tree gimple_unsigned_type (tree);
extern tree gimple_signed_type (tree);
extern alias_set_type gimple_get_alias_set (tree);
-extern bool walk_stmt_load_store_addr_ops (gimple, void *,
- bool (*)(gimple, tree, void *),
- bool (*)(gimple, tree, void *),
- bool (*)(gimple, tree, void *));
-extern bool walk_stmt_load_store_ops (gimple, void *,
- bool (*)(gimple, tree, void *),
- bool (*)(gimple, tree, void *));
extern bool gimple_ior_addresses_taken (bitmap, gimple);
extern bool gimple_call_builtin_p (gimple, enum built_in_class);
extern bool gimple_call_builtin_p (gimple, enum built_in_function);
@@ -5223,227 +5201,6 @@ gimple_expr_type (const_gimple stmt)
return void_type_node;
}
-/* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
-
-static inline gimple_stmt_iterator
-gsi_start_1 (gimple_seq *seq)
-{
- gimple_stmt_iterator i;
-
- i.ptr = gimple_seq_first (*seq);
- i.seq = seq;
- i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
-
- return i;
-}
-
-#define gsi_start(x) gsi_start_1 (&(x))
-
-static inline gimple_stmt_iterator
-gsi_none (void)
-{
- gimple_stmt_iterator i;
- i.ptr = NULL;
- i.seq = NULL;
- i.bb = NULL;
- return i;
-}
-
-/* Return a new iterator pointing to the first statement in basic block BB. */
-
-static inline gimple_stmt_iterator
-gsi_start_bb (basic_block bb)
-{
- gimple_stmt_iterator i;
- gimple_seq *seq;
-
- seq = bb_seq_addr (bb);
- i.ptr = gimple_seq_first (*seq);
- i.seq = seq;
- i.bb = bb;
-
- return i;
-}
-
-
-/* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
-
-static inline gimple_stmt_iterator
-gsi_last_1 (gimple_seq *seq)
-{
- gimple_stmt_iterator i;
-
- i.ptr = gimple_seq_last (*seq);
- i.seq = seq;
- i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
-
- return i;
-}
-
-#define gsi_last(x) gsi_last_1 (&(x))
-
-/* Return a new iterator pointing to the last statement in basic block BB. */
-
-static inline gimple_stmt_iterator
-gsi_last_bb (basic_block bb)
-{
- gimple_stmt_iterator i;
- gimple_seq *seq;
-
- seq = bb_seq_addr (bb);
- i.ptr = gimple_seq_last (*seq);
- i.seq = seq;
- i.bb = bb;
-
- return i;
-}
-
-
-/* Return true if I is at the end of its sequence. */
-
-static inline bool
-gsi_end_p (gimple_stmt_iterator i)
-{
- return i.ptr == NULL;
-}
-
-
-/* Return true if I is one statement before the end of its sequence. */
-
-static inline bool
-gsi_one_before_end_p (gimple_stmt_iterator i)
-{
- return i.ptr != NULL && i.ptr->gsbase.next == NULL;
-}
-
-
-/* Advance the iterator to the next gimple statement. */
-
-static inline void
-gsi_next (gimple_stmt_iterator *i)
-{
- i->ptr = i->ptr->gsbase.next;
-}
-
-/* Advance the iterator to the previous gimple statement. */
-
-static inline void
-gsi_prev (gimple_stmt_iterator *i)
-{
- gimple prev = i->ptr->gsbase.prev;
- if (prev->gsbase.next)
- i->ptr = prev;
- else
- i->ptr = NULL;
-}
-
-/* Return the current stmt. */
-
-static inline gimple
-gsi_stmt (gimple_stmt_iterator i)
-{
- return i.ptr;
-}
-
-/* Return a block statement iterator that points to the first non-label
- statement in block BB. */
-
-static inline gimple_stmt_iterator
-gsi_after_labels (basic_block bb)
-{
- gimple_stmt_iterator gsi = gsi_start_bb (bb);
-
- while (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
- gsi_next (&gsi);
-
- return gsi;
-}
-
-/* Advance the iterator to the next non-debug gimple statement. */
-
-static inline void
-gsi_next_nondebug (gimple_stmt_iterator *i)
-{
- do
- {
- gsi_next (i);
- }
- while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
-}
-
-/* Advance the iterator to the next non-debug gimple statement. */
-
-static inline void
-gsi_prev_nondebug (gimple_stmt_iterator *i)
-{
- do
- {
- gsi_prev (i);
- }
- while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
-}
-
-/* Return a new iterator pointing to the first non-debug statement in
- basic block BB. */
-
-static inline gimple_stmt_iterator
-gsi_start_nondebug_bb (basic_block bb)
-{
- gimple_stmt_iterator i = gsi_start_bb (bb);
-
- if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
- gsi_next_nondebug (&i);
-
- return i;
-}
-
-/* Return a new iterator pointing to the first non-debug non-label statement in
- basic block BB. */
-
-static inline gimple_stmt_iterator
-gsi_start_nondebug_after_labels_bb (basic_block bb)
-{
- gimple_stmt_iterator i = gsi_after_labels (bb);
-
- if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
- gsi_next_nondebug (&i);
-
- return i;
-}
-
-/* Return a new iterator pointing to the last non-debug statement in
- basic block BB. */
-
-static inline gimple_stmt_iterator
-gsi_last_nondebug_bb (basic_block bb)
-{
- gimple_stmt_iterator i = gsi_last_bb (bb);
-
- if (!gsi_end_p (i) && is_gimple_debug (gsi_stmt (i)))
- gsi_prev_nondebug (&i);
-
- return i;
-}
-
-
-/* Return the basic block associated with this iterator. */
-
-static inline basic_block
-gsi_bb (gimple_stmt_iterator i)
-{
- return i.bb;
-}
-
-
-/* Return the sequence associated with this iterator. */
-
-static inline gimple_seq
-gsi_seq (gimple_stmt_iterator i)
-{
- return *i.seq;
-}
-
-
enum gsi_iterator_update
{
GSI_NEW_STMT, /* Only valid when single statement is added, move
@@ -5454,112 +5211,8 @@ enum gsi_iterator_update
direction. */
};
-/* In gimple-iterator.c */
-gimple_stmt_iterator gsi_start_phis (basic_block);
-gimple_seq gsi_split_seq_after (gimple_stmt_iterator);
-void gsi_split_seq_before (gimple_stmt_iterator *, gimple_seq *);
-void gsi_set_stmt (gimple_stmt_iterator *, gimple);
-void gsi_replace (gimple_stmt_iterator *, gimple, bool);
-void gsi_replace_with_seq (gimple_stmt_iterator *, gimple_seq, bool);
-void gsi_insert_before (gimple_stmt_iterator *, gimple,
- enum gsi_iterator_update);
-void gsi_insert_before_without_update (gimple_stmt_iterator *, gimple,
- enum gsi_iterator_update);
-void gsi_insert_seq_before (gimple_stmt_iterator *, gimple_seq,
- enum gsi_iterator_update);
-void gsi_insert_seq_before_without_update (gimple_stmt_iterator *, gimple_seq,
- enum gsi_iterator_update);
-void gsi_insert_after (gimple_stmt_iterator *, gimple,
- enum gsi_iterator_update);
-void gsi_insert_after_without_update (gimple_stmt_iterator *, gimple,
- enum gsi_iterator_update);
-void gsi_insert_seq_after (gimple_stmt_iterator *, gimple_seq,
- enum gsi_iterator_update);
-void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
- enum gsi_iterator_update);
-bool gsi_remove (gimple_stmt_iterator *, bool);
-gimple_stmt_iterator gsi_for_stmt (gimple);
-void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
-void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
-void gsi_move_to_bb_end (gimple_stmt_iterator *, basic_block);
-void gsi_insert_on_edge (edge, gimple);
-void gsi_insert_seq_on_edge (edge, gimple_seq);
-basic_block gsi_insert_on_edge_immediate (edge, gimple);
-basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
-void gsi_commit_one_edge_insert (edge, basic_block *);
-void gsi_commit_edge_inserts (void);
gimple gimple_call_copy_skip_args (gimple, bitmap);
-/* Convenience routines to walk all statements of a gimple function.
- Note that this is useful exclusively before the code is converted
- into SSA form. Once the program is in SSA form, the standard
- operand interface should be used to analyze/modify statements. */
-struct walk_stmt_info
-{
- /* Points to the current statement being walked. */
- gimple_stmt_iterator gsi;
-
- /* Additional data that the callback functions may want to carry
- through the recursion. */
- void *info;
-
- /* Pointer map used to mark visited tree nodes when calling
- walk_tree on each operand. If set to NULL, duplicate tree nodes
- will be visited more than once. */
- struct pointer_set_t *pset;
-
- /* Operand returned by the callbacks. This is set when calling
- walk_gimple_seq. If the walk_stmt_fn or walk_tree_fn callback
- returns non-NULL, this field will contain the tree returned by
- the last callback. */
- tree callback_result;
-
- /* Indicates whether the operand being examined may be replaced
- with something that matches is_gimple_val (if true) or something
- slightly more complicated (if false). "Something" technically
- means the common subset of is_gimple_lvalue and is_gimple_rhs,
- but we never try to form anything more complicated than that, so
- we don't bother checking.
-
- Also note that CALLBACK should update this flag while walking the
- sub-expressions of a statement. For instance, when walking the
- statement 'foo (&var)', the flag VAL_ONLY will initially be set
- to true, however, when walking &var, the operand of that
- ADDR_EXPR does not need to be a GIMPLE value. */
- BOOL_BITFIELD val_only : 1;
-
- /* True if we are currently walking the LHS of an assignment. */
- BOOL_BITFIELD is_lhs : 1;
-
- /* Optional. Set to true by the callback functions if they made any
- changes. */
- BOOL_BITFIELD changed : 1;
-
- /* True if we're interested in location information. */
- BOOL_BITFIELD want_locations : 1;
-
- /* True if we've removed the statement that was processed. */
- BOOL_BITFIELD removed_stmt : 1;
-};
-
-/* Callback for walk_gimple_stmt. Called for every statement found
- during traversal. The first argument points to the statement to
- walk. The second argument is a flag that the callback sets to
- 'true' if it the callback handled all the operands and
- sub-statements of the statement (the default value of this flag is
- 'false'). The third argument is an anonymous pointer to data
- to be used by the callback. */
-typedef tree (*walk_stmt_fn) (gimple_stmt_iterator *, bool *,
- struct walk_stmt_info *);
-
-gimple walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
- struct walk_stmt_info *);
-gimple walk_gimple_seq_mod (gimple_seq *, walk_stmt_fn, walk_tree_fn,
- struct walk_stmt_info *);
-tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
- struct walk_stmt_info *);
-tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
-
/* Enum and arrays used for allocation stats. Keep in sync with
gimple.c:gimple_alloc_kind_names. */
enum gimple_alloc_kind
@@ -5593,15 +5246,6 @@ gimple_alloc_kind (enum gimple_code code)
extern void dump_gimple_statistics (void);
-/* Set the location of all statements in SEQ to LOC. */
-
-static inline void
-gimple_seq_set_location (gimple_seq seq, location_t loc)
-{
- for (gimple_stmt_iterator i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
- gimple_set_location (gsi_stmt (i), loc);
-}
-
/* Return true if a location should not be emitted for this statement
by annotate_all_with_location. */
@@ -5636,5 +5280,6 @@ gimple_set_do_not_emit_location (gimple g)
extern void sort_case_labels (vec<tree> );
extern void preprocess_case_label_vec_for_gimple (vec<tree> , tree, tree *);
+extern void gimple_seq_set_location (gimple_seq , location_t);
#endif /* GCC_GIMPLE_H */
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 356fc2b91a8..3253f861958 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "tree-iterator.h"
#include "tree-inline.h"
#include "tree-pretty-print.h"
diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c
index 1fff36c53bc..da457d20da1 100644
--- a/gcc/graphite-blocking.c
+++ b/gcc/graphite-blocking.c
@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-ssa-loop.h"
#include "dumpfile.h"
#include "cfgloop.h"
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 207de4f1fe8..38404f4ee40 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic-core.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-ssa-loop-manip.h"
#include "tree-ssa-loop.h"
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index 417ea2cd153..f9f7004cb1d 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-ssa-loop.h"
#include "tree-pass.h"
#include "cfgloop.h"
diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c
index 36e1b55757d..8690313da35 100644
--- a/gcc/graphite-interchange.c
+++ b/gcc/graphite-interchange.c
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-ssa-loop.h"
#include "dumpfile.h"
#include "cfgloop.h"
diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c
index d039c1b74e1..2260c507f86 100644
--- a/gcc/graphite-optimize-isl.c
+++ b/gcc/graphite-optimize-isl.c
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-ssa-loop.h"
#include "dumpfile.h"
#include "cfgloop.h"
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index 2749555c371..d75359e8537 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic-core.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-ssa-loop.h"
#include "dumpfile.h"
#include "gimple-pretty-print.h"
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index e73a349803a..8ac22db553e 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 9ee75b87d07..b10bb46e33e 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/graphite.c b/gcc/graphite.c
index 176c47c980e..5223de959d5 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic-core.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-cfg.h"
#include "tree-ssa-loop.h"
#include "tree-dump.h"
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 445872387d8..2231c77ad66 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -79,6 +79,7 @@ along with GCC; see the file COPYING3. If not see
#include "coverage.h"
#include "ggc.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/ipa-profile.c b/gcc/ipa-profile.c
index 1260069207e..9b8ae3971ea 100644
--- a/gcc/ipa-profile.c
+++ b/gcc/ipa-profile.c
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see
#include "cgraph.h"
#include "tree-pass.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "ggc.h"
#include "flags.h"
#include "target.h"
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index d1d3d71c0af..327bca9e597 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -22,6 +22,8 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "langhooks.h"
#include "ggc.h"
#include "target.h"
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index d775b3178bf..9963b39f461 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -37,6 +37,8 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "tree-cfg.h"
#include "tree-ssa-loop-niter.h"
#include "tree-inline.h"
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index df0a44e7d5f..40b876653a8 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -79,6 +79,8 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "target.h"
#include "ipa-prop.h"
#include "gimple-ssa.h"
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index ebff04f5cdc..449632af38c 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "hashtab.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-ssanames.h"
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 55186234d8c..9a00230d463 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see
#include "hashtab.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-ssanames.h"
#include "tree-pass.h"
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index e383f9a97f9..86f95a1152d 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -28,6 +28,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "rtl.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "tree-iterator.h"
#include "tree-inline.h"
#include "langhooks.h"
diff --git a/gcc/predict.c b/gcc/predict.c
index 3cfa258abed..61cac525991 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see
#include "target.h"
#include "cfgloop.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/profile.c b/gcc/profile.c
index 9e50560830e..5f73b2ca462 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see
#include "value-prof.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-cfg.h"
#include "cfgloop.h"
#include "dumpfile.h"
diff --git a/gcc/sese.c b/gcc/sese.c
index cddd9510e36..169ed9a845d 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "tree-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 36f48fd17f9..93080a8d0b8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-13 Andrew MacLeod <amacleod@redhat.com>
+
+ * testsuite/g++.dg/plugin/selfassign.c: Include gimple-iterator.h.
+ * testsuite/gcc.dg/plugin/selfassign.c: Likewise.
+
2013-11-12 Jeff Law <law@redhat.com>
* PR middle-end/59119
diff --git a/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc/testsuite/g++.dg/plugin/selfassign.c
index 5331f792cb2..2498153a273 100644
--- a/gcc/testsuite/g++.dg/plugin/selfassign.c
+++ b/gcc/testsuite/g++.dg/plugin/selfassign.c
@@ -11,6 +11,7 @@
#include "toplev.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree.h"
#include "tree-pass.h"
#include "intl.h"
diff --git a/gcc/testsuite/gcc.dg/plugin/selfassign.c b/gcc/testsuite/gcc.dg/plugin/selfassign.c
index 5331f792cb2..2498153a273 100644
--- a/gcc/testsuite/gcc.dg/plugin/selfassign.c
+++ b/gcc/testsuite/gcc.dg/plugin/selfassign.c
@@ -11,6 +11,7 @@
#include "toplev.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree.h"
#include "tree-pass.h"
#include "intl.h"
diff --git a/gcc/tracer.c b/gcc/tracer.c
index 86557febab7..71a9201fd09 100644
--- a/gcc/tracer.c
+++ b/gcc/tracer.c
@@ -47,6 +47,7 @@
#include "coverage.h"
#include "tree-pass.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-cfg.h"
#include "tree-ssa.h"
#include "tree-inline.h"
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index e821c99c975..195380bee4d 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -23,6 +23,8 @@
#include "hash-table.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index eec1b0fb739..8e636463dea 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "gimple-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-ssanames.h"
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 601efd65aa8..9cdb1a5b978 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -31,6 +31,8 @@ along with GCC; see the file COPYING3. If not see
#include "ggc.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 3ca84c575bc..fbda06ab745 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "ggc.h"
#include "langhooks.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index b75c732e4f8..188bf1a9336 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "flags.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index ffa4cbf14d7..2aa58363224 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -79,6 +79,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "gimple-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-ssa-loop-niter.h"
#include "tree-ssa-loop.h"
#include "tree-ssa.h"
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index a31a0a28161..91f8c0ef00d 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see
#include "function.h"
#include "tree-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index a489b61c3f2..656ba6f5cb3 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "except.h"
#include "pointer-set.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c
index b5ca407d62e..11337c0c127 100644
--- a/gcc/tree-emutls.c
+++ b/gcc/tree-emutls.c
@@ -22,6 +22,8 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "tree-pass.h"
#include "gimple-ssa.h"
#include "cgraph.h"
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 98cb6ab606f..dc630e2d114 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -89,6 +89,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 5d30caa6f6b..fe5c0cb7367 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -35,6 +35,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree-iterator.h"
#include "intl.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 981e9f4bfb4..e7c5d50da0c 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "function.h"
#include "gimple-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 6adea4d7b34..75d069bbbf3 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 97e4787e3c7..f6baf00042d 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -27,6 +27,8 @@
#include "tree-dump.h"
#include "tree-inline.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "tree-iterator.h"
#include "bitmap.h"
#include "cgraph.h"
diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c
index 1425d195252..b333abf3956 100644
--- a/gcc/tree-nrv.c
+++ b/gcc/tree-nrv.c
@@ -26,6 +26,8 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "tree-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "tree-ssanames.h"
#include "tree-pass.h"
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 576dcb786ed..965dffa4290 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "bitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-ssanames.h"
#include "tree-pass.h"
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 4dc3f9e4a8d..eb11c883fb4 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "bitmap.h"
#include "sbitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index a17085c8692..3a478f916b0 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -24,6 +24,8 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index 2cef1c4ab23..da7bf5be978 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "ggc.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
@@ -504,5 +505,18 @@ degenerate_phi_result (gimple phi)
return (i == gimple_phi_num_args (phi) ? val : NULL);
}
+/* Set PHI nodes of a basic block BB to SEQ. */
+
+void
+set_phi_nodes (basic_block bb, gimple_seq seq)
+{
+ gimple_stmt_iterator i;
+
+ gcc_checking_assert (!(bb->flags & BB_RTL));
+ bb->il.gimple.phi_nodes = seq;
+ if (seq)
+ for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
+ gimple_set_bb (gsi_stmt (i), bb);
+}
#include "gt-tree-phinodes.h"
diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h
index ae6222b336e..4dd5e1362d3 100644
--- a/gcc/tree-phinodes.h
+++ b/gcc/tree-phinodes.h
@@ -30,21 +30,7 @@ extern void remove_phi_args (edge);
extern void remove_phi_node (gimple_stmt_iterator *, bool);
extern void remove_phi_nodes (basic_block);
extern tree degenerate_phi_result (gimple);
-
-/* Set PHI nodes of a basic block BB to SEQ. */
-
-static inline void
-set_phi_nodes (basic_block bb, gimple_seq seq)
-{
- gimple_stmt_iterator i;
-
- gcc_checking_assert (!(bb->flags & BB_RTL));
- bb->il.gimple.phi_nodes = seq;
- if (seq)
- for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
- gimple_set_bb (gsi_stmt (i), bb);
-}
-
+extern void set_phi_nodes (basic_block, gimple_seq);
static inline use_operand_p
gimple_phi_arg_imm_use_ptr (gimple gs, int i)
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 15aadb03eca..e08e9b6c697 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -192,6 +192,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm_p.h"
#include "cfgloop.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 92530590108..428ffc7c464 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see
#include "coverage.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 3702922d001..ffc6d3d09c4 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -260,6 +260,7 @@ along with GCC; see the file COPYING3. If not see
#include "hash-table.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index a4f627f23c1..31fcdfeee3f 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -79,6 +79,8 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "bitmap.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 70b22053be7..c98c742d8b3 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -120,6 +120,7 @@ along with GCC; see the file COPYING3. If not see
#include "function.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index 252fc33a7f0..942602e5fe3 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "bitmap.h"
#include "dumpfile.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c
index 15c6896e945..0f70372c80e 100644
--- a/gcc/tree-ssa-copy.c
+++ b/gcc/tree-ssa-copy.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "function.h"
#include "gimple-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-copyrename.c b/gcc/tree-ssa-copyrename.c
index 30b339def7d..d71802e7a1c 100644
--- a/gcc/tree-ssa-copyrename.c
+++ b/gcc/tree-ssa-copyrename.c
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "flags.h"
#include "basic-block.h"
#include "function.h"
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 7a016f6240d..5da2106b7e7 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "basic-block.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 6a6f027e90c..0ce24df2abe 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "function.h"
#include "gimple-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 202eb3e673b..42e2380a0c8 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "bitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index a6afb47a4db..71c56a050ac 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
index 1786f9c29d3..3fbaba7920b 100644
--- a/gcc/tree-ssa-ifcombine.c
+++ b/gcc/tree-ssa-ifcombine.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "tree-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 17849a21159..1657f6f6ca5 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "bitmap.h"
#include "sbitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c
index b74c56de330..57c1555d28c 100644
--- a/gcc/tree-ssa-loop-ch.c
+++ b/gcc/tree-ssa-loop-ch.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm_p.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-into-ssa.h"
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 34a37633a48..48697c7fa24 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 6f8f04e457e..9fd649e6e09 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 894ff2db521..4eb615f1296 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 123a6e19c98..66c51280152 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm_p.h"
#include "basic-block.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index a6adfc2f1a4..79e7eff98b2 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "intl.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index 85a0b0a6f44..edb49dbde88 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "tree-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-ssa-loop-ivopts.h"
#include "tree-ssa-loop-manip.h"
diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c
index 9bb002868be..20454f2edf4 100644
--- a/gcc/tree-ssa-loop.c
+++ b/gcc/tree-ssa-loop.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm_p.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "tree-ssa-loop-ivopts.h"
#include "tree-ssa-loop-manip.h"
#include "tree-ssa-loop-niter.h"
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 646f8cf1e64..cd654d2502e 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -91,6 +91,7 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h"
#include "tree.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index d79e9575516..caa4925cfb5 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm_p.h"
#include "basic-block.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c
index 61e38d5e385..904d0a432ce 100644
--- a/gcc/tree-ssa-phiprop.c
+++ b/gcc/tree-ssa-phiprop.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 7e83967b072..5b075077d3e 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "tree-inline.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 00780b9a745..b10544836ff 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -31,6 +31,7 @@
#include "dumpfile.h"
#include "sbitmap.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 6e9188457f9..d55c943324b 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "tree-inline.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index a8b149287c9..caf10bb522f 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "tree-inline.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index 0a1c4d40919..565def76ca1 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "hash-table.h"
#include "bitmap.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 6f3a4cee29f..d8dbf05c767 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -30,6 +30,7 @@
#include "basic-block.h"
#include "tree.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-ssanames.h"
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index db95ce1059c..18c15d91107 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -195,6 +195,7 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h"
#include "function.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 6090c5ff5f5..df0c458e019 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "bitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 0c9dcda5ef9..c9b2c697d88 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "timevar.h"
#include "dumpfile.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index ac0d2d3bdd6..e819d65e030 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "function.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "tree-ssa.h"
diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c
index 5255d7fb738..25f9f45b285 100644
--- a/gcc/tree-ssa-uncprop.c
+++ b/gcc/tree-ssa-uncprop.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "function.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 5e376a1df51..a15e37c5151 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "bitmap.h"
#include "pointer-set.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index ae8939e2ba9..c774198e9ab 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -32,6 +32,8 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h"
#include "pointer-set.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index 2c8aac289b6..b0d2dacd8e1 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -29,6 +29,8 @@ along with GCC; see the file COPYING3. If not see
#include "target.h"
#include "bitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 7096b3da3de..e7ffd434888 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -32,6 +32,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "tree.h"
#include "basic-block.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-cfg.h"
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 38acf7bb342..eded4b690ef 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "function.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index c4797755fde..7164684c506 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index 8fca8c14add..a82ecb2cd81 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "langhooks.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-ssanames.h"
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 15227856033..01414ecae91 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 292e7710402..8dd3c430b47 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 51b96e15408..8cca6c67fc3 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 825f73a429a..247bdfd6669 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index b0e0fa99b20..9dfa7bdd88b 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "gimple-pretty-print.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 8e3190fa2c1..9c2cf5d1ce2 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -63,6 +63,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "tree-pretty-print.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 8f8b5ebada7..656e8e1c9bc 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -27,6 +27,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
+#include "gimple-walk.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/tree.c b/gcc/tree.c
index dd0371d0c04..c4484536e82 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h"
#include "bitmap.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "tree-phinodes.h"
diff --git a/gcc/tsan.c b/gcc/tsan.c
index 1d318ea8527..0de971319ad 100644
--- a/gcc/tsan.c
+++ b/gcc/tsan.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm.h"
#include "basic-block.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "function.h"
#include "gimple-ssa.h"
#include "cgraph.h"
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index dda302dde53..6f822f65bd1 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see
#include "regs.h"
#include "ggc.h"
#include "gimplify.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-phinodes.h"
diff --git a/gcc/vtable-verify.c b/gcc/vtable-verify.c
index fb26978d273..ecf1dc25e84 100644
--- a/gcc/vtable-verify.c
+++ b/gcc/vtable-verify.c
@@ -139,6 +139,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree.h"
#include "basic-block.h"
#include "gimple.h"
+#include "gimple-iterator.h"
#include "gimple-ssa.h"
#include "tree-phinodes.h"
#include "ssa-iterators.h"