3 * File name: ir/ana/irloop_t.h
4 * Purpose: Loop datastructure and access functions -- private stuff.
5 * Author: Goetz Lindenmaier
9 * Copyright: (c) 2002-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
15 * Loop datastructure and access functions -- private stuff.
17 * @author Goetz Lindenmaier
20 #include "firm_common.h"
21 #include "irgraph_t.h"
29 * Possible loop flags, can be or'ed.
31 typedef enum loop_flags {
32 loop_is_count_loop = 0x00000001, /**< if set it's a counting loop */
33 loop_downto_loop = 0x00000002, /**< if set, it's a downto loop, else an upto loop */
34 loop_is_endless = 0x00000004, /**< if set, this is an endless loop */
35 loop_is_dead = 0x00000008, /**< if set, it's a dead loop ie will never be entered */
36 loop_wrap_around = 0x00000010, /**< this loop is NOT endless, because of wrap around */
37 loop_end_false = 0x00000020, /**< this loop end can't be computed "from compute_loop_info.c" */
38 do_loop = 0x00000040, /**< this is a do loop */
39 once = 0x00000080, /**< this is a do loop, with a false condition.It itarate once */
42 /** The loops datastructure. */
44 firm_kind kind; /**< A type tag, set to k_ir_loop. */
46 struct ir_loop *outer_loop; /**< The outer loop */
47 loop_element *children; /**< Mixed array: Contains sons and loop_nodes */
48 int depth; /**< Nesting depth */
49 int n_sons; /**< Number of ir_nodes in array "children" */
50 int n_nodes; /**< Number of loop_nodes in array "children" */
51 unsigned flags; /**< a set of loop_flags_t */
52 tarval *loop_iter_start; /**< counting loop: the start value */
53 tarval *loop_iter_end; /**< counting loop: the last value reached */
54 tarval *loop_iter_increment; /**< counting loop: the increment */
55 ir_node *loop_iter_variable; /**< The iteration variable of counting loop.*/
58 struct state_entry *mem_phis;
59 struct state_entry *states;
62 struct loop_node *link;
65 long loop_nr; /**< a unique node number for each loop node to make output
67 void *link; /**< GL @@@ For debugging the analyses. */
72 /** Add a son loop to a father loop. */
73 void add_loop_son(ir_loop *loop, ir_loop *son);
75 /** Add a node to a loop. */
76 void add_loop_node(ir_loop *loop, ir_node *n);
78 /** Sets the loop a node belonging to. */
79 void set_irn_loop(ir_node *n, ir_loop *loop);
81 /* -------- INLINE functions -------- */
84 _is_ir_loop(const void *thing) {
85 return (get_kind(thing) == k_ir_loop);
89 _set_irg_loop(ir_graph *irg, ir_loop *loop) {
94 static INLINE ir_loop *
95 _get_irg_loop(ir_graph *irg) {
100 static INLINE ir_loop *
101 _get_loop_outer_loop(const ir_loop *loop) {
102 assert(_is_ir_loop(loop));
103 return loop->outer_loop;
107 _get_loop_depth(const ir_loop *loop) {
108 assert(_is_ir_loop(loop));
113 _get_loop_n_sons(const ir_loop *loop) {
114 assert(_is_ir_loop(loop));
118 /* Uses temporary information to get the loop */
119 static INLINE ir_loop *
120 _get_irn_loop(const ir_node *n) {
125 #define is_ir_loop(thing) _is_ir_loop(thing)
126 #define set_irg_loop(irg, loop) _set_irg_loop(irg, loop)
127 #define get_irg_loop(irg) _get_irg_loop(irg)
128 #define get_loop_outer_loop(loop) _get_loop_outer_loop(loop)
129 #define get_loop_depth(loop) _get_loop_depth(loop)
130 #define get_loop_n_sons(loop) _get_loop_n_sons(loop)
131 #define get_irn_loop(n) _get_irn_loop(n)
133 #endif /* _IRLOOP_T_H_ */