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