summaryrefslogtreecommitdiff
path: root/gcc/cfgloop.h
diff options
context:
space:
mode:
authorrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-10 22:17:15 +0000
committerrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-10 22:17:15 +0000
commit17519ba0dc05161d1dd4fba308eee373e9a9841b (patch)
tree879533af06a5f9434bb047870e2878e104446c23 /gcc/cfgloop.h
parent2d043327e6bf9c316751af014a81548f08284a7b (diff)
downloadgcc-17519ba0dc05161d1dd4fba308eee373e9a9841b.tar.gz
* tree-vrp.c (adjust_range_with_scev): Use get_chrec_loop.
* loop-unswitch.c (unswitch_loops): Use FOR_EACH_LOOP. * tree-loop-linear.c (linear_transform_loops): Ditto. * tree-ssa-loop-im.c (determine_lsm): Ditto. * tree-ssa-loop-niter.c (estimate_numbers_of_iterations, free_numbers_of_iterations_estimates): Ditto. * tree_ssa_unswitch_loops (tree_ssa_unswitch_loops): Ditto. * tree-ssa-loop-ch.c (copy_loop_headers): Ditto. * tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto. * modulo-sched.c (sms_schedule): Ditto. * tree-ssa-loop-ivcanon.c (canonicalize_induction_variables, tree_unroll_loops_completely): Ditto. * predict.c (predict_loops): Ditto. * tree-if-conv.c (main_tree_if_conversion): Ditto. * loop-unroll.c (unroll_and_peel_loops, peel_loops_completely, decide_unrolling_and_peeling): Ditto. * cfgloopmanip.c (unloop): Use delete_loop. (place_new_loop): Access larray vector instead of parray. (create_preheaders, force_single_succ_latches, fix_loop_structure): Use FOR_EACH_LOOP and delete_loop.. * loop-doloop.c (doloop_optimize_loops): Ditto. * loop-invariant.c (move_loop_invariants): Ditto. * tree-cfg.c (replace_uses_by): Ditto. * tree-ssa-loop-prefetch.c (tree_ssa_prefetch_arrays): Ditto. * tree-chrec.h (CHREC_VAR, CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE): Moved to ... * tree.h (CHREC_VAR, CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE): ... here. * tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop, compute_overall_effect_of_inner_loop, chrec_is_positive): Use get_loop and get_chrec_loop. (number_of_iterations_for_all_loops): Use number_of_loops. (scev_initialize, scev_reset, scev_const_prop): Use FOR_EACH_LOOP. * tree-scalar-evolution.h (get_chrec_loop): New inline function. * cfgloopanal.c (mark_irreducible_loops): Use number_of_loops, and FOR_EACH_LOOP. * tree-chrec.c (evolution_function_is_invariant_rec_p, chrec_convert_1): Use get_loop and get_chrec_loop. * loop-init.c (loop_optimizer_init): Use number_of_loops. (loop_optimizer_init): Use FOR_EACH_LOOP. * tree-vectorizer.c (vect_loops_num): Removed. (vectorize_loops): Store number of loops locally. Use FOR_EACH_LOOP and get_loop. * tree-vectorizer.h (vect_loops_num): Removed. * tree-data-ref.c (get_number_of_iters_for_loop): Use get_loop. (find_data_references_in_loop): Do not set parallel_p. * tree-data-ref.h: Do not declare VEC(loop_p). * cfgloop.c (flow_loops_dump, mark_single_exit_loops, verify_loop_structure): Use FOR_EACH_LOOP. (flow_loops_free): Use FOR_EACH_LOOP, free larray vector. (initialize_loops_parallel_p): Removed. (flow_loops_find): Push the loops into a vector. (delete_loop): New function. (cancel_loop): Use delete_loop. * cfgloop.h: Declare VEC(loop_p). (struct loop): Remove parallel_p field. (struct loops): Replace num and parray field by larray vector. Remove shared_headers field. (delete_loop): Declare. (get_loop, get_loops, number_of_loops, fel_next, fel_init, FOR_EACH_LOOP): New. * doc/loop.tex: Document new accessor functions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119713 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgloop.h')
-rw-r--r--gcc/cfgloop.h142
1 files changed, 125 insertions, 17 deletions
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index fa0a456fc56..d523acf001c 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -146,12 +146,6 @@ struct loop
EXIT_BLOCK_PTR do not count. Do not use directly; this field should
only be accessed via single_exit/set_single_exit functions. */
edge single_exit_;
-
- /* True when the loop does not carry data dependences, and
- consequently the iterations can be executed in any order. False
- when the loop carries data dependences, or when the property is
- not decidable. */
- bool parallel_p;
};
/* Flags for state of loop structure. */
@@ -166,26 +160,21 @@ enum
#define LOOPS_NORMAL (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES \
| LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
+typedef struct loop *loop_p;
+DEF_VEC_P (loop_p);
+DEF_VEC_ALLOC_P (loop_p, heap);
+
/* Structure to hold CFG information about natural loops within a function. */
struct loops
{
- /* Number of natural loops in the function. */
- unsigned num;
-
/* State of loops. */
int state;
- /* We store just pointers to loops here.
- Note that a loop in this array may actually be NULL, if the loop
- has been removed and the entire loops structure has not been
- recomputed since that time. */
- struct loop **parray;
+ /* Array of the loops. */
+ VEC (loop_p, heap) *larray;
/* Pointer to root of loop hierarchy tree. */
struct loop *tree_root;
-
- /* Headers shared by multiple loops that should be merged. */
- sbitmap shared_headers;
};
/* Loop recognition. */
@@ -231,6 +220,7 @@ extern void add_bb_to_loop (basic_block, struct loop *);
extern void remove_bb_from_loops (basic_block);
extern void cancel_loop_tree (struct loop *);
+extern void delete_loop (struct loop *);
extern int fix_loop_placement (struct loop *);
@@ -375,6 +365,124 @@ simple_loop_desc (struct loop *loop)
return (struct niter_desc *) loop->aux;
}
+/* Accessors for the loop structures. */
+
+/* Returns the loop with index NUM from current_loops. */
+
+static inline struct loop *
+get_loop (unsigned num)
+{
+ return VEC_index (loop_p, current_loops->larray, num);
+}
+
+/* Returns the list of loops in current_loops. */
+
+static inline VEC (loop_p, heap) *
+get_loops (void)
+{
+ if (!current_loops)
+ return NULL;
+
+ return current_loops->larray;
+}
+
+/* Returns the number of loops in current_loops (including the removed
+ ones and the fake loop that forms the root of the loop tree). */
+
+static inline unsigned
+number_of_loops (void)
+{
+ if (!current_loops)
+ return 0;
+
+ return VEC_length (loop_p, current_loops->larray);
+}
+
+/* Loop iterators. */
+
+/* Flags for loop iteration. */
+
+enum li_flags
+{
+ LI_INCLUDE_ROOT, /* Include the fake root of the loop tree. */
+ LI_FROM_INNERMOST, /* Iterate over the loops in the reverse order,
+ starting from innermost ones. */
+ LI_ONLY_INNERMOST, /* Iterate only over innermost loops. */
+ LI_ONLY_OLD /* Do not traverse the loops created during the
+ traversal (this is the default behavior with
+ LI_FROM_INNERMOST). */
+};
+
+/* The iterator for loops. */
+
+typedef struct
+{
+ int idx; /* Index of the actual loop. */
+ int end; /* Only loops before end should be traversed. */
+} loop_iterator;
+
+static inline void
+fel_next (loop_iterator *li, loop_p *loop, unsigned flags)
+{
+ if (flags & LI_FROM_INNERMOST)
+ {
+ li->idx--;
+ for (; li->idx > li->end; li->idx--)
+ {
+ *loop = VEC_index (loop_p, current_loops->larray, li->idx);
+ if (*loop
+ && (!(flags & LI_ONLY_INNERMOST)
+ || (*loop)->inner == NULL))
+ return;
+ }
+ }
+ else
+ {
+ if (!(flags & LI_ONLY_OLD))
+ li->end = number_of_loops ();
+ li->idx++;
+ for (; li->idx < li->end; li->idx++)
+ {
+ *loop = VEC_index (loop_p, current_loops->larray, li->idx);
+ if (*loop
+ && (!(flags & LI_ONLY_INNERMOST)
+ || (*loop)->inner == NULL))
+ return;
+ }
+ }
+
+ *loop = NULL;
+}
+
+static inline void
+fel_init (loop_iterator *li, loop_p *loop, unsigned flags)
+{
+ if (!current_loops)
+ {
+ li->idx = 0;
+ li->end = 0;
+ *loop = NULL;
+ return;
+ }
+
+ if (flags & LI_FROM_INNERMOST)
+ {
+ li->idx = number_of_loops ();
+ li->end = (flags & LI_INCLUDE_ROOT) ? -1 : 0;
+ }
+ else
+ {
+ li->idx = (flags & LI_INCLUDE_ROOT) ? -1 : 0;
+ li->end = number_of_loops ();
+ }
+ fel_next (li, loop, flags);
+}
+
+#define FOR_EACH_LOOP(LI, LOOP, FLAGS) \
+ for (fel_init (&(LI), &(LOOP), FLAGS); \
+ (LOOP); \
+ fel_next (&(LI), &(LOOP), FLAGS))
+
/* The properties of the target. */
extern unsigned target_avail_regs; /* Number of available registers. */