bring back Carry and Borrow (firm_decomp apparently uses it) and add a note that...
[libfirm] / ir / ana / irextbb_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Extended basis block support -- private header
23  * @author  Michael Beck
24  * @date    5.2005
25  * @version $Id$
26  */
27 #ifndef FIRM_ANA_IREXTBB_T_H
28 #define FIRM_ANA_IREXTBB_T_H
29
30 #include "irgraph_t.h"
31 #include "irextbb.h"
32 #include "irtools.h"
33
34 /**
35  * An extended block.
36  */
37 struct _ir_extblk {
38         firm_kind kind;        /**< k_ir_extblk */
39         ir_visited_t visited;  /**< visited flag */
40         ir_node  **blks;       /**< blocks belonging to this extended block */
41         void *link;            /**< private link field */
42 };
43
44 /**
45  * Checks whether a pointer points to a extended basic block.
46  * Intern version for libFirm.
47  */
48 static inline int _is_ir_extbb(const void *thing)
49 {
50         return (get_kind(thing) == k_ir_extblk);
51 }
52
53 /**
54  * Gets the visited counter of an extended block.
55  * Internal version for libFirm.
56  */
57 static inline ir_visited_t _get_extbb_visited(const ir_extblk *blk)
58 {
59         assert(blk);
60         return blk->visited;
61 }
62
63 /**
64  * Sets the visited counter of an extended block.
65  * Internal version for libFirm.
66  */
67 static inline void _set_extbb_visited(ir_extblk *blk, ir_visited_t visited)
68 {
69         assert(blk);
70         blk->visited = visited;
71 }
72
73 /**
74  * Mark an extended block as visited in a graph.
75  * Internal version for libFirm.
76  */
77 static inline void _mark_extbb_visited(ir_extblk *blk)
78 {
79         assert(blk);
80         blk->visited = current_ir_graph->block_visited;
81 }
82
83 /**
84  * Returns non-zero if an extended was visited.
85  * Internal version for libFirm.
86  */
87 static inline int _extbb_visited(const ir_extblk *blk)
88 {
89         assert(blk);
90         return blk->visited >= current_ir_graph->block_visited;
91 }
92
93 /**
94  * Returns non-zero if an extended block was NOT visited.
95  * Internal version for libFirm.
96  */
97 static inline int _extbb_not_visited(const ir_extblk *blk)
98 {
99         assert(blk);
100         return blk->visited < current_ir_graph->block_visited;
101 }
102
103 /**
104  * Returns the link field of an extended block.
105  * Internal version for libFirm.
106  */
107 static inline void *_get_extbb_link(const ir_extblk *blk)
108 {
109         assert(blk);
110         return blk->link;
111 }
112
113 /**
114  * Sets the link field of an extended block.
115  * Internal version for libFirm.
116  */
117 static inline void _set_extbb_link(ir_extblk *blk, void *link)
118 {
119         assert(blk);
120         blk->link = link;
121 }
122
123 /**
124  * Return the number of basis blocks of an extended block
125  */
126 static inline int _get_extbb_n_blocks(const ir_extblk *blk)
127 {
128         assert(blk);
129         return ARR_LEN(blk->blks);
130 }
131
132 /**
133  * Return the i'th basis block of an extended block
134  */
135 static inline ir_node *_get_extbb_block(const ir_extblk *blk, int pos)
136 {
137         assert(blk && 0 <= pos && pos < _get_extbb_n_blocks(blk));
138         return blk->blks[pos];
139 }
140
141 /**
142  * Return the leader basis block of an extended block
143  */
144 static inline ir_node *_get_extbb_leader(const ir_extblk *blk)
145 {
146         return blk->blks[0];
147 }
148
149 #define is_ir_extbb(thing)        _is_ir_extbb(thing)
150 #define get_extbb_visited(blk)    _get_extbb_visited(blk)
151 #define set_extbb_visited(blk, v) _set_extbb_visited(blk, v)
152 #define mark_extbb_visited(blk)   _mark_extbb_visited(blk)
153 #define extbb_visited(blk)        _extbb_visited(blk)
154 #define extbb_not_visited(blk)    _extbb_not_visited(blk)
155 #define get_extbb_link(blk)       _get_extbb_link(blk)
156 #define set_extbb_link(blk, link) _set_extbb_link(blk, link)
157 #define get_extbb_n_blocks(blk)   _get_extbb_n_blocks(blk)
158 #define get_extbb_leader(blk)     _get_extbb_leader(blk)
159
160 #endif