fixed output
[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 "irgraph_t.h"
24 #include "irextbb.h"
25 #include "irtools.h"
26
27 /**
28  * An extended block.
29  */
30 struct _ir_extblk {
31   firm_kind kind;        /**< k_ir_extblk */
32   unsigned long visited; /**< visited flag */
33   ir_node  **blks;       /**< blocks belonging to this extended block */
34   void *link;            /**< private link field */
35 };
36
37 /**
38  * Checks whether a pointer points to a extended basic block.
39  * Intern version for libFirm.
40  */
41 static INLINE int
42 _is_ir_extbb (const void *thing) {
43   return (get_kind(thing) == k_ir_extblk);
44 }
45
46 /**
47  * Gets the visited counter of an extended block.
48  * Internal version for libFirm.
49  */
50 static INLINE unsigned long
51 _get_extbb_visited(const ir_extblk *blk) {
52   assert(blk);
53   return blk->visited;
54 }
55
56 /**
57  * Sets the visited counter of an extended block.
58  * Internal version for libFirm.
59  */
60 static INLINE void
61 _set_extbb_visited(ir_extblk *blk, unsigned long visited) {
62   assert(blk);
63   blk->visited = visited;
64 }
65
66 /**
67  * Mark an extended block as visited in a graph.
68  * Internal version for libFirm.
69  */
70 static INLINE void
71 _mark_extbb_visited(ir_extblk *blk) {
72   assert(blk);
73   blk->visited = current_ir_graph->block_visited;
74 }
75
76 /**
77  * Returns non-zero if an extended was visited.
78  * Internal version for libFirm.
79  */
80 static INLINE int
81 _extbb_visited(const ir_extblk *blk) {
82   assert(blk);
83   return blk->visited >= current_ir_graph->block_visited;
84 }
85
86 /**
87  * Returns non-zero if an extended block was NOT visited.
88  * Internal version for libFirm.
89  */
90 static INLINE int
91 _extbb_not_visited(const ir_extblk *blk) {
92   assert(blk);
93   return blk->visited < current_ir_graph->block_visited;
94 }
95
96 /**
97  * Returns the link field of an extended block.
98  * Internal version for libFirm.
99  */
100 static INLINE void *
101 _get_extbb_link(const ir_extblk *blk) {
102   assert(blk);
103   return blk->link;
104 }
105
106 /**
107  * Sets the link field of an extended block.
108  * Internal version for libFirm.
109  */
110 static INLINE void
111 _set_extbb_link(ir_extblk *blk, void *link) {
112   assert(blk);
113   blk->link = link;
114 }
115
116 /**
117  * Return the number of basis blocks of an extended block
118  */
119 static INLINE int
120 _get_extbb_n_blocks(const ir_extblk *blk) {
121   assert(blk);
122   return ARR_LEN(blk->blks);
123 }
124
125 /**
126  * Return the i'th basis block of an extended block
127  */
128 static INLINE ir_node *
129 _get_extbb_block(ir_extblk *blk, int pos)
130 {
131   assert(blk && 0 <= pos && pos < _get_extbb_n_blocks(blk));
132   return blk->blks[pos];
133 }
134
135 /**
136  * Return the leader basis block of an extended block
137  */
138 static INLINE ir_node *
139 _get_extbb_leader(ir_extblk *blk)
140 {
141   return blk->blks[0];
142 }
143
144 #define is_ir_extbb(thing)        _is_ir_extbb(thing)
145 #define get_extbb_visited(blk)    _get_extbb_visited(blk)
146 #define set_extbb_visited(blk, v) _set_extbb_visited(blk, v)
147 #define mark_extbb_visited(blk)   _mark_extbb_visited(blk)
148 #define extbb_visited(blk)        _extbb_visited(blk)
149 #define extbb_not_visited(blk)    _extbb_not_visited(blk)
150 #define get_extbb_link(blk)       _get_extbb_link(blk)
151 #define set_extbb_link(blk, link) _set_extbb_link(blk, link)
152 #define get_extbb_n_blocks(blk)   _get_extbb_n_blocks(blk)
153 #define get_extbb_leader(blk)     _get_extbb_leader(blk)
154
155 #endif /* _IREXTBB_H_ */