missing include added
[libfirm] / ir / ana / irloop_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ana/irloop_t.h
4  * Purpose:     Loop datastructure and access functions -- private stuff.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:     7.2002
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2002-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file irloop_t.h
15  * Loop datastructure and access functions -- private stuff.
16  *
17  * @author Goetz Lindenmaier
18  */
19
20 #include "firm_common.h"
21 #include "irgraph_t.h"
22 #include "irloop.h"
23
24 #ifndef _IRLOOP_T_H_
25 #define _IRLOOP_T_H_
26
27 /**
28  * Possible loop flags, can be or'ed.
29  */
30 typedef enum loop_flags {
31   loop_is_count_loop = 0x00000001,  /**< if set it's a counting loop */
32   loop_downto_loop   = 0x00000002,  /**< if set, it's a downto loop, else an upto loop */
33   loop_is_endless    = 0x00000004,  /**< if set, this is an endless loop */
34   loop_is_dead       = 0x00000008,  /**< if set, it's a dead loop ie will never be entered */
35   loop_wrap_around   = 0x00000010,  /**< this loop is NOT endless, because of wrap around */
36   loop_end_false     = 0x00000020,  /**< this loop end can't be computed "from compute_loop_info.c" */
37   do_loop            = 0x00000040,  /**< this is a do loop */
38   once               = 0x00000080,  /**< this is a do loop, with a false condition.It itarate once */
39 } loop_flags_t;
40
41 /** The loops datastructure. */
42 struct ir_loop {
43   firm_kind kind;                   /**< A type tag, set to k_ir_loop. */
44
45   struct ir_loop *outer_loop;       /**< The outer loop */
46   loop_element   *children;         /**< Mixed array: Contains sons and loop_nodes */
47   int depth;                        /**< Nesting depth */
48   int n_sons;                       /**< Number of ir_nodes in array "children" */
49   int n_nodes;                      /**< Number of loop_nodes in array "children" */
50   unsigned flags;                   /**< a set of loop_flags_t */
51   tarval  *loop_iter_start;         /**< counting loop: the start value */
52   tarval  *loop_iter_end;           /**< counting loop: the last value reached */
53   tarval  *loop_iter_increment;     /**< counting loop: the increment */
54   ir_node *loop_iter_variable;      /**< The iteration variable of counting loop.*/
55
56   /*
57   struct state_entry *mem_phis;
58   struct state_entry *states;
59
60   struct obset **oval;
61   struct loop_node *link;
62   */
63 #ifdef DEBUG_libfirm
64   int loop_nr;             /**< a unique node number for each loop node to make output
65                               readable. */
66   void *link;              /**< GL @@@ For debugging the analyses. */
67 #endif
68 };
69
70
71 /** Add a son loop to a father loop. */
72 void add_loop_son(ir_loop *loop, ir_loop *son);
73
74 /** Add a node to a loop. */
75 void add_loop_node(ir_loop *loop, ir_node *n);
76
77 /** Sets the loop a node belonging to. */
78 void set_irn_loop(ir_node *n, ir_loop *loop);
79
80 /* -------- INLINE functions -------- */
81
82 static INLINE int
83 _is_ir_loop(const void *thing) {
84   return (get_kind(thing) == k_ir_loop);
85 }
86
87 static INLINE void
88 _set_irg_loop(ir_graph *irg, ir_loop *loop) {
89   assert(irg);
90   irg->loop = loop;
91 }
92
93 static INLINE ir_loop *
94 _get_irg_loop(ir_graph *irg) {
95   assert(irg);
96   return irg->loop;
97 }
98
99 #define is_ir_loop(thing)         _is_ir_loop(thing)
100 #define set_irg_loop(irg, loop)   _set_irg_loop(irg, loop)
101 #define get_irg_loop(irg)         _get_irg_loop(irg)
102
103 #endif /* _IRLOOP_T_H_ */