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