don't call be_spill_phis for phis of other reg classes
[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 "irgraph_t.h"
11 #include "iredges_t.h"
12 #include "irphase_t.h"
13 #include "irhooks.h"
14
15 #include "pset.h"
16 #include "set.h"
17 #include "list.h"
18 #include "hashptr.h"
19 #include "bitset.h"
20
21 #include "belive.h"
22
23 struct _be_lv_t {
24         phase_t ph;
25         ir_graph *irg;
26         bitset_t *nodes;
27         hook_entry_t hook_info;
28 };
29
30 struct _be_lv_info_node_t {
31         unsigned idx;
32         unsigned flags;
33 };
34
35 struct _be_lv_info_head_t {
36         unsigned n_members;
37         unsigned n_size;
38 };
39
40 struct _be_lv_info_t {
41         union {
42                 struct _be_lv_info_head_t head;
43                 struct _be_lv_info_node_t node;
44         } u;
45 };
46
47 static INLINE int _be_lv_next_irn(const struct _be_lv_t *lv, const ir_node *bl, unsigned flags, int i)
48 {
49         struct _be_lv_info_t *arr     = phase_get_irn_data(&lv->ph, bl);
50         if(arr) {
51                 int n_members = (int) arr[0].u.head.n_members;
52
53                 while(i < n_members) {
54                         if(arr[i + 1].u.node.flags & flags) {
55                                 return i;
56                         }
57                         ++i;
58                 }
59         }
60
61         return -1;
62 }
63
64 static INLINE ir_node * _be_lv_get_irn(const struct _be_lv_t *lv, const ir_node *bl, int i)
65 {
66         struct _be_lv_info_t *arr     = phase_get_irn_data(&lv->ph, bl);
67         return get_idx_irn(lv->irg, arr[i + 1].u.node.idx);
68 }
69
70 struct _be_lv_info_node_t *be_lv_get(const struct _be_lv_t *li, const ir_node *bl, const ir_node *irn);
71
72 static INLINE int _be_is_live_xxx(const struct _be_lv_t *li, const ir_node *block, const ir_node *irn, unsigned flags)
73 {
74         struct _be_lv_info_node_t *info = be_lv_get(li, block, irn);
75         return info ? (info->flags & flags) != 0 : 0;
76 }
77
78 #define be_lv_foreach(lv, bl, flags, i) \
79         for(i = _be_lv_next_irn(lv, bl, flags, 0); i >= 0; i = _be_lv_next_irn(lv, bl, flags, i + 1))
80
81
82 static INLINE pset *_be_lv_pset_put(const struct _be_lv_t *lv, const ir_node *block, int state, pset *s)
83 {
84         int i;
85         be_lv_foreach(lv, block, state, i)
86                 pset_insert_ptr(s, _be_lv_get_irn(lv, block, i));
87         return s;
88 }
89
90 #define be_lv_get_irn(lv, bl, i)      _be_lv_get_irn(lv, bl, i)
91 #define be_lv_pset_put_in(lv, bl, s)  _be_lv_pset_put(lv, bl, be_lv_state_in, s)
92 #define be_lv_pset_put_out(lv, bl, s) _be_lv_pset_put(lv, bl, be_lv_state_out, s)
93 #define be_lv_pset_put_end(lv, bl, s) _be_lv_pset_put(lv, bl, be_lv_state_end, s)
94
95 #define be_is_live_in(lv, bl, irn)    _be_is_live_xxx(lv, bl, irn, be_lv_state_in)
96 #define be_is_live_end(lv, bl, irn)   _be_is_live_xxx(lv, bl, irn, be_lv_state_end)
97 #define be_is_live_out(lv, bl, irn)   _be_is_live_xxx(lv, bl, irn, be_lv_state_out)
98
99 #define be_lv_has_info_about(lv, irn) bitset_is_set((lv)->nodes, get_irn_idx(irn))
100
101 #endif