becopyilp: Do not advertise the switch to dump the solution, because this is not...
[libfirm] / ir / ana / irloop_t.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief    Loop datastructure and access functions -- private stuff.
9  * @author   Goetz Lindenmaier
10  * @date     7.2002
11  */
12 #ifndef FIRM_ANA_IRLOOP_T_H
13 #define FIRM_ANA_IRLOOP_T_H
14
15 #include "firm_common.h"
16 #include "irgraph_t.h"
17 #include "irnode_t.h"
18 #include "irloop.h"
19
20 /**
21  * The loops data structure.
22  *
23  * The loops data structure represents circles in the intermediate
24  * representation.  It does not represent loops in the terms of a
25  * source program.
26  * Each ir_graph can contain one outermost loop data structure.
27  * loop is the entry point to the nested loops.
28  * The loop data structure contains a field indicating the depth of
29  * the loop within the nesting.  Further it contains a list of the
30  * loops with nesting depth -1.  Finally it contains a list of all
31  * nodes in the loop.
32  */
33 struct ir_loop {
34         firm_kind       kind;             /**< A type tag, set to k_ir_loop. */
35         unsigned        depth;            /**< Nesting depth */
36         struct ir_loop *outer_loop;       /**< The outer loop */
37         loop_element   *children;         /**< Mixed flexible array: Contains sons and loop_nodes */
38         void *link;                       /**< link field. */
39 #ifdef DEBUG_libfirm
40         long loop_nr;                     /**< A unique node number for each loop node to make output
41                                                readable. */
42 #endif
43 };
44
45 /**
46  * Allocates a new loop as son of father on the given obstack.
47  * If father is equal NULL, a new root loop is created.
48  */
49 ir_loop *alloc_loop(ir_loop *father, struct obstack *obst);
50
51 /** Add a son loop to a father loop. */
52 void add_loop_son(ir_loop *loop, ir_loop *son);
53
54 /** Add a node to a loop. */
55 void add_loop_node(ir_loop *loop, ir_node *n);
56
57 /** Add an IR graph to a loop. */
58 void add_loop_irg(ir_loop *loop, ir_graph *irg);
59
60 /** Sets the loop a node belonging to. */
61 void set_irn_loop(ir_node *n, ir_loop *loop);
62
63 /**
64  * Mature all loops by removing the flexible arrays of a loop tree
65  * and putting them on the given obstack.
66  */
67 void mature_loops(ir_loop *loop, struct obstack *obst);
68
69 /* -------- inline functions -------- */
70
71 static inline int _is_ir_loop(const void *thing)
72 {
73         return get_kind(thing) == k_ir_loop;
74 }
75
76 static inline void _set_irg_loop(ir_graph *irg, ir_loop *loop)
77 {
78         assert(irg);
79         irg->loop = loop;
80 }
81
82 static inline ir_loop *_get_irg_loop(const ir_graph *irg)
83 {
84         assert(irg);
85         return irg->loop;
86 }
87
88 static inline ir_loop *_get_loop_outer_loop(const ir_loop *loop)
89 {
90         assert(_is_ir_loop(loop));
91         return loop->outer_loop;
92 }
93
94 static inline unsigned _get_loop_depth(const ir_loop *loop)
95 {
96         assert(_is_ir_loop(loop));
97         return loop->depth;
98 }
99
100 /* Uses temporary information to get the loop */
101 static inline ir_loop *_get_irn_loop(const ir_node *n)
102 {
103         return n->loop;
104 }
105
106 #define is_ir_loop(thing)         _is_ir_loop(thing)
107 #define set_irg_loop(irg, loop)   _set_irg_loop(irg, loop)
108 #define get_irg_loop(irg)         _get_irg_loop(irg)
109 #define get_loop_outer_loop(loop) _get_loop_outer_loop(loop)
110 #define get_loop_depth(loop)      _get_loop_depth(loop)
111 #define get_irn_loop(n)           _get_irn_loop(n)
112
113 #endif