2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Internal headers for liveness analysis.
9 * @author Sebastian Hack
12 #ifndef FIRM_BE_BELIVE_T_H
13 #define FIRM_BE_BELIVE_T_H
16 #include "irnodehashmap.h"
18 #include "irlivechk.h"
22 #define be_is_live_in(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_in)
23 #define be_is_live_end(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_end)
24 #define be_is_live_out(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_out)
34 typedef struct be_lv_info_node_t be_lv_info_node_t;
35 struct be_lv_info_node_t {
40 struct be_lv_info_head_t {
46 struct be_lv_info_head_t head;
47 struct be_lv_info_node_t node;
50 be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *block,
53 static inline unsigned _be_is_live_xxx(const be_lv_t *li, const ir_node *block,
54 const ir_node *irn, unsigned flags)
59 be_lv_info_node_t *info = be_lv_get(li, block, irn);
60 res = info != NULL ? (info->flags & flags) != 0 : 0;
62 res = (lv_chk_bl_xxx(li->lvc, block, irn) & flags) != 0;
68 typedef struct lv_iterator_t
74 static inline lv_iterator_t be_lv_iteration_begin(const be_lv_t *lv,
78 res.info = ir_nodehashmap_get(be_lv_info_t, &lv->map, block);
79 res.i = res.info != NULL ? res.info[0].head.n_members : 0;
83 static inline ir_node *be_lv_iteration_next(lv_iterator_t *iterator, be_lv_state_t flags)
85 while (iterator->i != 0) {
86 const be_lv_info_t *info = iterator->info + iterator->i--;
87 if (info->node.flags & flags)
88 return info->node.node;
93 static inline ir_node *be_lv_iteration_cls_next(lv_iterator_t *iterator, be_lv_state_t flags, const arch_register_class_t *cls)
95 while (iterator->i != 0) {
96 const be_lv_info_t *info = iterator->info + iterator->i--;
97 if (!(info->node.flags & flags))
100 ir_node *node = info->node.node;
101 ir_mode *mode = get_irn_mode(node);
102 if (!mode_is_datab(mode))
104 if (!arch_irn_consider_in_reg_alloc(cls, node))
111 #define be_lv_foreach(lv, block, flags, node) \
112 for (bool once = true; once;) \
113 for (lv_iterator_t iter = be_lv_iteration_begin((lv), (block)); once; once = false) \
114 for (ir_node *node; (node = be_lv_iteration_next(&iter, (flags))) != NULL;)
116 #define be_lv_foreach_cls(lv, block, flags, cls, node) \
117 for (bool once = true; once;) \
118 for (lv_iterator_t iter = be_lv_iteration_begin((lv), (block)); once; once = false) \
119 for (ir_node *node; (node = be_lv_iteration_cls_next(&iter, (flags), (cls))) != NULL;)