Moved insert_Perm_after to benode.c
[libfirm] / ir / be / belive_t.h
1 /**
2  * Internal headers for liveness analysis.
3  * @author Sebastian Hack
4  * @date 6.12.2004
5  */
6
7 #ifndef _BELIVE_T_H
8 #define _BELIVE_T_H
9
10 #include "config.h"
11
12 #include "belive.h"
13 #include "pset.h"
14
15 typedef struct _block_live_info_t {
16         pset *in;                               /**< The set of all values live in at that block. */
17         pset *out;                              /**< The set of all values live out. */
18         pset *end;                              /**< The set of all values live at the end
19                                                                                         of the block (contains all live out). */
20 } block_live_info_t;
21
22 typedef struct _node_live_info_t {
23         int is_phi_op;          /**< Marks the node as a phi operand. */
24 } node_live_info_t;
25
26 typedef struct _live_info_t {
27         union {
28                 block_live_info_t block;
29                 node_live_info_t node;
30         } v;
31 } live_info_t;
32
33 extern size_t live_irn_data_offset;
34
35 #define get_irn_live_info(irn) get_irn_data(irn, live_info_t, live_irn_data_offset)
36 #define get_live_info_irn(inf) get_irn_data_base(inf, live_irn_data_offset)
37
38 #define get_block_live_info(irn) (&(get_irn_live_info(irn)->v.block))
39 #define get_node_live_info(irn) (&(get_irn_live_info(irn)->v.node))
40
41 static INLINE int _is_phi_operand(const ir_node *irn)
42 {
43         assert(!is_Block(irn) && "No block node allowed here");
44         return get_node_live_info(irn)->is_phi_op;
45 }
46
47 static INLINE int _is_live_in(const ir_node *block, const ir_node *irn)
48 {
49         block_live_info_t *info = get_block_live_info(block);
50
51         assert(is_Block(block) && "Need a block here");
52         return pset_find_ptr(info->in, irn) != NULL;
53 }
54
55 static INLINE int _is_live_out(const ir_node *block, const ir_node *irn)
56 {
57         block_live_info_t *info = get_block_live_info(block);
58
59         assert(is_Block(block) && "Need a block here");
60         return pset_find_ptr(info->out, irn) != NULL;
61 }
62
63 static INLINE int _is_live_end(const ir_node *block, const ir_node *irn)
64 {
65         block_live_info_t *info = get_block_live_info(block);
66
67         assert(is_Block(block) && "Need a block here");
68         return pset_find_ptr(info->end, irn) != NULL;
69 }
70
71 static INLINE pset *_get_live_in(const ir_node *block)
72 {
73         assert(is_Block(block) && "Need a block here");
74         return get_block_live_info(block)->in;
75 }
76
77 static INLINE pset *_get_live_out(const ir_node *block)
78 {
79         assert(is_Block(block) && "Need a block here");
80         return get_block_live_info(block)->out;
81 }
82
83 static INLINE pset *_get_live_end(const ir_node *block)
84 {
85         assert(is_Block(block) && "Need a block here");
86         return get_block_live_info(block)->end;
87 }
88
89 #define is_phi_operand(irn)                     _is_phi_operand(irn)
90 #define is_live_in(bl,irn)                      _is_live_in(bl, irn)
91 #define is_live_out(bl,irn)             _is_live_out(bl, irn)
92 #define is_live_end(bl,irn)             _is_live_end(bl, irn)
93 #define get_live_in(bl)                                 _get_live_in(bl)
94 #define get_live_out(bl)                                _get_live_out(bl)
95 #define get_live_end(bl)                                _get_live_end(bl)
96
97 /**
98  * Initialize the liveness module.
99  * To be called from be_init().
100  */
101 void be_liveness_init(void);
102
103 #endif