beloopana: Remove duplicate comments.
[libfirm] / ir / ana / irlivechk.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 Inria Rhone-Alpes.
4  */
5
6 /**
7  * @file
8  * @author  Sebastian Hack
9  * @date    22.04.2007
10  * @brief
11  *
12  * Live in/end checks whose only precomputation concerns the structure of the CFG.
13  * Hence, nothing has to be updated if the program is modified unless the CFG is touched.
14  * See .c file for more comments.
15  */
16
17 #ifndef FIRM_ANA_IRLIVECHK_H
18 #define FIRM_ANA_IRLIVECHK_H
19
20 #include "irgraph.h"
21 #include "irnode.h"
22 #include <stdbool.h>
23
24 typedef enum {
25         lv_chk_state_in  = 1,
26         lv_chk_state_end = 2,
27         lv_chk_state_out = 4,
28         lv_chk_state_through = lv_chk_state_in | lv_chk_state_out | lv_chk_state_end,
29 } lv_chk_state_t;
30
31 typedef struct lv_chk_t lv_chk_t;
32
33 /**
34  * Filter out some nodes for which we never need liveness.
35  *
36  * @param irn  the node t check
37  * @return 0 if no liveness info is needed, 1 else
38  */
39 static inline bool is_liveness_node(const ir_node *irn)
40 {
41         switch (get_irn_opcode(irn)) {
42         case iro_Block:
43         case iro_Bad:
44         case iro_End:
45         case iro_Anchor:
46         case iro_NoMem:
47                 return 0;
48         default:
49                 return 1;
50         }
51 }
52
53 /**
54  * Make a new liveness check environment.
55  * @param irg The graph.
56  * @return    The environment.
57  */
58 extern lv_chk_t *lv_chk_new(ir_graph *irg);
59
60 /**
61  * Free liveness check information.
62  * @param lv The liveness check information.
63  */
64 extern void lv_chk_free(lv_chk_t *lv);
65
66
67 /**
68  * Return liveness information for a node concerning a block.
69  * @param lv   The liveness environment.
70  * @param bl   The block to investigate.
71  * @param irn  The node to check for.
72  * @return     A bitmask of <code>lv_chk_state_t</code>.
73  */
74 extern unsigned lv_chk_bl_xxx(lv_chk_t *lv, const ir_node *bl, const ir_node *irn);
75
76 #define lv_chk_bl_in(lv, bl, irn)  ((lv_chk_bl_xxx((lv), (bl), (irn)) & lv_chk_state_in)  != 0)
77 #define lv_chk_bl_end(lv, bl, irn) ((lv_chk_bl_xxx((lv), (bl), (irn)) & lv_chk_state_end) != 0)
78 #define lv_chk_bl_out(lv, bl, irn) ((lv_chk_bl_xxx((lv), (bl), (irn)) & lv_chk_state_out) != 0)
79
80 #endif /* FIRM_ANA_IRLIVECHK_H */