2 * Copyright (C) 1995-2008 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
26 #ifndef FIRM_BE_BELIVE_T_H
27 #define FIRM_BE_BELIVE_T_H
30 #include "irnodehashmap.h"
32 #include "irlivechk.h"
36 #define be_is_live_in(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_in)
37 #define be_is_live_end(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_end)
38 #define be_is_live_out(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_out)
48 typedef struct be_lv_info_node_t be_lv_info_node_t;
49 struct be_lv_info_node_t {
54 struct be_lv_info_head_t {
60 struct be_lv_info_head_t head;
61 struct be_lv_info_node_t node;
64 be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *block,
67 static inline unsigned _be_is_live_xxx(const be_lv_t *li, const ir_node *block,
68 const ir_node *irn, unsigned flags)
73 be_lv_info_node_t *info = be_lv_get(li, block, irn);
74 res = info != NULL ? (info->flags & flags) != 0 : 0;
76 res = (lv_chk_bl_xxx(li->lvc, block, irn) & flags) != 0;
82 typedef struct lv_iterator_t
88 static inline lv_iterator_t be_lv_iteration_begin(const be_lv_t *lv,
92 res.info = ir_nodehashmap_get(be_lv_info_t, &lv->map, block);
93 res.i = res.info != NULL ? res.info[0].head.n_members : 0;
97 static inline ir_node *be_lv_iteration_next(lv_iterator_t *iterator, be_lv_state_t flags)
99 while (iterator->i != 0) {
100 const be_lv_info_t *info = iterator->info + iterator->i--;
101 if (info->node.flags & flags)
102 return info->node.node;
107 static inline ir_node *be_lv_iteration_cls_next(lv_iterator_t *iterator, be_lv_state_t flags, const arch_register_class_t *cls)
109 while (iterator->i != 0) {
110 const be_lv_info_t *info = iterator->info + iterator->i--;
111 if (!(info->node.flags & flags))
114 ir_node *node = info->node.node;
115 ir_mode *mode = get_irn_mode(node);
116 if (!mode_is_datab(mode))
118 if (!arch_irn_consider_in_reg_alloc(cls, node))
125 #define be_lv_foreach(lv, block, flags, node) \
126 for (bool once = true; once;) \
127 for (lv_iterator_t iter = be_lv_iteration_begin((lv), (block)); once; once = false) \
128 for (ir_node *node; (node = be_lv_iteration_next(&iter, (flags))) != NULL;)
130 #define be_lv_foreach_cls(lv, block, flags, cls, node) \
131 for (bool once = true; once;) \
132 for (lv_iterator_t iter = be_lv_iteration_begin((lv), (block)); once; once = false) \
133 for (ir_node *node; (node = be_lv_iteration_cls_next(&iter, (flags), (cls))) != NULL;)