2 * Internal headers for liveness analysis.
3 * @author Sebastian Hack
12 #include "irgraph_t.h"
20 typedef enum _live_state_t {
27 typedef struct _irn_live_t {
31 struct _irn_live_t *next;
34 typedef struct _irg_live_info_t {
38 extern size_t live_irg_data_offset;
40 #define get_irg_live_info(irg) (get_irg_data(irg, irg_live_info_t, live_irg_data_offset))
42 #define HASH_PTR_PAIR(x,y) (HASH_PTR(x) + 37 * HASH_PTR(y))
44 static INLINE irn_live_t *_get_or_set_live(const ir_node *block, const ir_node *irn, int state)
46 irg_live_info_t *live_info = get_irg_live_info(get_irn_irg(block));
47 irn_live_t *live, templ;
54 live = set_insert(live_info->live, &templ, sizeof(templ), HASH_PTR_PAIR(block, irn));
55 if(live->state == -1) {
58 irn_live_t *bl_live = _get_or_set_live(block, block, live_state_block);
59 live->next = bl_live->next;
71 static INLINE int _is_live_in(const ir_node *block, const ir_node *irn)
73 return (_get_or_set_live(block, irn, 0)->state & live_state_in) != 0;
76 static INLINE int _is_live_out(const ir_node *block, const ir_node *irn)
78 return (_get_or_set_live(block, irn, 0)->state & live_state_out) != 0;
81 static INLINE int _is_live_end(const ir_node *block, const ir_node *irn)
83 return (_get_or_set_live(block, irn, 0)->state & live_state_end) != 0;
86 #define live_foreach(block, live_info) \
87 for(live_info = _get_or_set_live(block, block, 0)->next; live_info; live_info = live_info->next)
89 static INLINE void _put_live(const ir_node *block, int state, pset *s)
93 live_foreach(block, live) {
94 if(live->state & state)
95 pset_insert_ptr(s, live->irn);
99 static INLINE pset *_put_live_in(const ir_node *block, pset *s)
101 _put_live(block, live_state_in, s);
105 static INLINE pset *_put_live_out(const ir_node *block, pset *s)
107 _put_live(block, live_state_out, s);
111 static INLINE pset *_put_live_end(const ir_node *block, pset *s)
113 _put_live(block, live_state_end, s);
118 #define is_live_in(bl,irn) _is_live_in(bl, irn)
119 #define is_live_out(bl,irn) _is_live_out(bl, irn)
120 #define is_live_end(bl,irn) _is_live_end(bl, irn)
121 #define put_live_in(bl,s) _put_live_in(bl, s)
122 #define put_live_out(bl,s) _put_live_out(bl, s)
123 #define put_live_end(bl,s) _put_live_end(bl, s)
126 * Initialize the liveness module.
127 * To be called from be_init().
129 void be_liveness_init(void);