missing include added
[libfirm] / ir / ana / irextbb_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ana/irextbb_t.h
4  * Purpose:     Extended basis block support.
5  * Author:      Michael Beck
6  * Modified by:
7  * Created:     5.2005
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2002-2005 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file irextbb_t.h
15  *
16  *  Computes extended basic blocks.
17  *
18  *  @author Michael Beck
19  */
20 #ifndef _IREXTBB_T_H_
21 #define _IREXTBB_T_H_
22
23 #include "firm_config.h"
24 #include "irgraph_t.h"
25 #include "irextbb.h"
26 #include "irtools.h"
27
28 /**
29  * An extended block.
30  */
31 struct _ir_extblk {
32   firm_kind kind;        /**< k_ir_extblk */
33   unsigned long visited; /**< visited flag */
34   ir_node  **blks;       /**< blocks belonging to this extended block */
35   void *link;            /**< private link field */
36 };
37
38
39 /**
40  * Gets the visited counter of an extended block.
41  * Internal version for libFirm.
42  */
43 static INLINE unsigned long
44 _get_extbb_visited(const ir_extblk *blk) {
45   assert(blk);
46   return blk->visited;
47 }
48
49 /**
50  * Sets the visited counter of an extended block.
51  * Internal version for libFirm.
52  */
53 static INLINE void
54 _set_extbb_visited(ir_extblk *blk, unsigned long visited) {
55   assert(blk);
56   blk->visited = visited;
57 }
58
59 /**
60  * Mark an extended block as visited in a graph.
61  * Internal version for libFirm.
62  */
63 static INLINE void
64 _mark_extbb_visited(ir_extblk *blk) {
65   assert(blk);
66   blk->visited = current_ir_graph->visited;
67 }
68
69 /**
70  * Returns non-zero if an extended was visited.
71  * Internal version for libFirm.
72  */
73 static INLINE int
74 _extbb_visited(const ir_extblk *blk) {
75   assert(blk);
76   return blk->visited >= current_ir_graph->visited;
77 }
78
79 /**
80  * Returns non-zero if an extended block was NOT visited.
81  * Internal version for libFirm.
82  */
83 static INLINE int
84 _extbb_not_visited(const ir_extblk *blk) {
85   assert(blk);
86   return blk->visited < current_ir_graph->visited;
87 }
88
89 /**
90  * Returns the link field of an extended block.
91  * Internal version for libFirm.
92  */
93 static INLINE void *
94 _get_extbb_link(const ir_extblk *blk) {
95   assert(blk);
96   return blk->link;
97 }
98
99 /**
100  * Sets the link field of an extended block.
101  * Internal version for libFirm.
102  */
103 static INLINE void
104 _set_extbb_link(ir_extblk *blk, void *link) {
105   assert(blk);
106   blk->link = link;
107 }
108
109 /**
110  * Return the number of basis blocks of an extended block
111  */
112 static INLINE int
113 _get_extbb_n_blocks(const ir_extblk *blk) {
114   assert(blk);
115   return ARR_LEN(blk->blks);
116 }
117
118 /**
119  * Return the i'th basis block of an extended block
120  */
121 static INLINE ir_node *
122 _get_extbb_block(ir_extblk *blk, int pos)
123 {
124   assert(blk && 0 <= pos && pos < _get_extbb_n_blocks(blk));
125   return blk->blks[pos];
126 }
127
128 /**
129  * Return the leader basis block of an extended block
130  */
131 static INLINE ir_node *
132 _get_extbb_leader(ir_extblk *blk)
133 {
134   return blk->blks[0];
135 }
136
137 #define get_extbb_visited(blk)          _get_extbb_visited(blk)
138 #define set_extbb_visited(blk, v)       _set_extbb_visited(blk, v)
139 #define mark_extbb_visited(blk)   _mark_extbb_visited(blk)
140 #define extbb_visited(blk)        _extbb_visited(blk)
141 #define extbb_not_visited(blk)    _extbb_not_visited(blk)
142 #define get_extbb_link(blk)       _get_extbb_link(blk)
143 #define set_extbb_link(blk, link) _set_extbb_link(blk, link)
144 #define get_extbb_n_blocks(blk)   _get_extbb_n_blocks(blk)
145 #define get_extbb_leader(blk)     _get_extbb_leader(blk)
146
147 #endif /* _IREXTBB_H_ */