2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Internal headers for liveness analysis.
23 * @author Sebastian Hack
27 #ifndef FIRM_BE_BELIVE_T_H
28 #define FIRM_BE_BELIVE_T_H
30 #include "irgraph_t.h"
31 #include "irphase_t.h"
43 hook_entry_t hook_info;
46 struct _be_lv_info_node_t {
51 struct _be_lv_info_head_t {
56 struct _be_lv_info_t {
58 struct _be_lv_info_head_t head;
59 struct _be_lv_info_node_t node;
63 static INLINE int _be_lv_next_irn(const struct _be_lv_t *lv, const ir_node *bl, unsigned flags, int i)
65 struct _be_lv_info_t *arr = phase_get_irn_data(&lv->ph, bl);
68 int n_members = (int) arr[0].u.head.n_members;
70 while(i < n_members) {
71 if(arr[i + 1].u.node.flags & flags) {
81 static INLINE ir_node *_be_lv_get_irn(const struct _be_lv_t *lv, const ir_node *bl, int i)
83 struct _be_lv_info_t *arr = phase_get_irn_data(&lv->ph, bl);
84 return get_idx_irn(lv->irg, arr[i + 1].u.node.idx);
87 struct _be_lv_info_node_t *be_lv_get(const struct _be_lv_t *li, const ir_node *bl, const ir_node *irn);
89 static INLINE int _be_is_live_xxx(const struct _be_lv_t *li, const ir_node *block, const ir_node *irn, unsigned flags)
91 struct _be_lv_info_node_t *info = be_lv_get(li, block, irn);
92 return info ? (info->flags & flags) != 0 : 0;
95 #define be_lv_foreach(lv, bl, flags, i) \
96 for (i = _be_lv_next_irn(lv, bl, flags, 0); i >= 0; i = _be_lv_next_irn(lv, bl, flags, i + 1))
99 static INLINE pset *_be_lv_pset_put(const struct _be_lv_t *lv, const ir_node *block, int state, pset *s)
102 be_lv_foreach(lv, block, state, i)
103 pset_insert_ptr(s, _be_lv_get_irn(lv, block, i));
107 #define be_lv_get_irn(lv, bl, i) _be_lv_get_irn(lv, bl, i)
108 #define be_lv_pset_put_in(lv, bl, s) _be_lv_pset_put(lv, bl, be_lv_state_in, s)
109 #define be_lv_pset_put_out(lv, bl, s) _be_lv_pset_put(lv, bl, be_lv_state_out, s)
110 #define be_lv_pset_put_end(lv, bl, s) _be_lv_pset_put(lv, bl, be_lv_state_end, s)
112 #define be_is_live_in(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_in)
113 #define be_is_live_end(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_end)
114 #define be_is_live_out(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_out)
116 #define be_lv_has_info_about(lv, irn) bitset_is_set((lv)->nodes, get_irn_idx(irn))
118 #endif /* FIRM_BE_BELIVE_T_H */