[t][TT #1610] Add tests for Parrot_compile_string
[parrot.git] / compilers / imcc / cfg.h
blob4c9221cc362113d9d430f53ef5062d325ef00ce3
1 /*
2 * $Id$
3 * Copyright (C) 2002-2009, Parrot Foundation.
4 */
7 /* Data structures: */
9 /* Two-way linked list of predecessors and successors */
10 #ifndef PARROT_CFG_H_GUARD
11 #define PARROT_CFG_H_GUARD
13 typedef struct _edge {
14 struct _basic_block *from;
15 struct _basic_block *to;
16 struct _edge *pred_next;
17 struct _edge *succ_next;
18 struct _edge *next;
19 } Edge;
21 typedef struct _basic_block {
22 Instruction *start; /* First instruction in basic block */
23 Instruction *end; /* Last instruction in basic block */
24 Edge *pred_list;
25 Edge *succ_list;
26 int loop_depth;
27 unsigned int index; /* on bb_list*/
28 int flag;
29 } Basic_block;
31 enum block_enum_flags_t {
32 BB_IS_SUB = 1 << 0
36 typedef struct _loop_info {
37 Set *loop; /* loop set containing bb's */
38 Set *exits; /* blocks that exit the loop */
39 int depth; /* depth of this loop */
40 unsigned int n_entries; /* nr of entries to this loop */
41 unsigned int header; /* header block of loop */
42 unsigned int preheader; /* preheader block of loop, if 1 entry point */
43 unsigned int size; /* no of blocks in loop */
44 } Loop_info;
47 /* Functions: */
49 /* HEADERIZER BEGIN: compilers/imcc/cfg.c */
50 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
52 PARROT_WARN_UNUSED_RESULT
53 int blocks_are_connected(
54 ARGIN(const Basic_block *from),
55 ARGIN(const Basic_block *to))
56 __attribute__nonnull__(1)
57 __attribute__nonnull__(2);
59 void build_cfg(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
60 __attribute__nonnull__(1)
61 __attribute__nonnull__(2)
62 FUNC_MODIFIES(*unit);
64 void clear_basic_blocks(ARGMOD(IMC_Unit *unit))
65 __attribute__nonnull__(1)
66 FUNC_MODIFIES(*unit);
68 void compute_dominance_frontiers(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
69 __attribute__nonnull__(1)
70 __attribute__nonnull__(2)
71 FUNC_MODIFIES(*unit);
73 void compute_dominators(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
74 __attribute__nonnull__(1)
75 __attribute__nonnull__(2)
76 FUNC_MODIFIES(*unit);
78 PARROT_WARN_UNUSED_RESULT
79 int edge_count(ARGIN(const IMC_Unit *unit))
80 __attribute__nonnull__(1);
82 void find_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int first)
83 __attribute__nonnull__(1)
84 __attribute__nonnull__(2)
85 FUNC_MODIFIES(*unit);
87 void find_loops(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
88 __attribute__nonnull__(1)
89 __attribute__nonnull__(2)
90 FUNC_MODIFIES(*unit);
92 void free_life_info(ARGIN(const IMC_Unit *unit), ARGMOD(SymReg *r))
93 __attribute__nonnull__(1)
94 __attribute__nonnull__(2)
95 FUNC_MODIFIES(*r);
97 void life_analysis(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
98 __attribute__nonnull__(1)
99 __attribute__nonnull__(2);
101 PARROT_MALLOC
102 PARROT_CANNOT_RETURN_NULL
103 Life_range * make_life_range(PARROT_INTERP, ARGMOD(SymReg *r), int idx)
104 __attribute__nonnull__(1)
105 __attribute__nonnull__(2)
106 FUNC_MODIFIES(*r);
108 PARROT_WARN_UNUSED_RESULT
109 int natural_preheader(
110 ARGIN(const IMC_Unit *unit),
111 ARGIN(const Loop_info *loop_info))
112 __attribute__nonnull__(1)
113 __attribute__nonnull__(2);
115 void search_predecessors_not_in(
116 ARGIN(const Basic_block *node),
117 ARGMOD(Set *s))
118 __attribute__nonnull__(1)
119 __attribute__nonnull__(2)
120 FUNC_MODIFIES(*s);
122 #define ASSERT_ARGS_blocks_are_connected __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
123 PARROT_ASSERT_ARG(from) \
124 , PARROT_ASSERT_ARG(to))
125 #define ASSERT_ARGS_build_cfg __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
126 PARROT_ASSERT_ARG(interp) \
127 , PARROT_ASSERT_ARG(unit))
128 #define ASSERT_ARGS_clear_basic_blocks __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
129 PARROT_ASSERT_ARG(unit))
130 #define ASSERT_ARGS_compute_dominance_frontiers __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
131 PARROT_ASSERT_ARG(interp) \
132 , PARROT_ASSERT_ARG(unit))
133 #define ASSERT_ARGS_compute_dominators __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
134 PARROT_ASSERT_ARG(interp) \
135 , PARROT_ASSERT_ARG(unit))
136 #define ASSERT_ARGS_edge_count __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
137 PARROT_ASSERT_ARG(unit))
138 #define ASSERT_ARGS_find_basic_blocks __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
139 PARROT_ASSERT_ARG(interp) \
140 , PARROT_ASSERT_ARG(unit))
141 #define ASSERT_ARGS_find_loops __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
142 PARROT_ASSERT_ARG(interp) \
143 , PARROT_ASSERT_ARG(unit))
144 #define ASSERT_ARGS_free_life_info __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
145 PARROT_ASSERT_ARG(unit) \
146 , PARROT_ASSERT_ARG(r))
147 #define ASSERT_ARGS_life_analysis __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
148 PARROT_ASSERT_ARG(interp) \
149 , PARROT_ASSERT_ARG(unit))
150 #define ASSERT_ARGS_make_life_range __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
151 PARROT_ASSERT_ARG(interp) \
152 , PARROT_ASSERT_ARG(r))
153 #define ASSERT_ARGS_natural_preheader __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
154 PARROT_ASSERT_ARG(unit) \
155 , PARROT_ASSERT_ARG(loop_info))
156 #define ASSERT_ARGS_search_predecessors_not_in __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
157 PARROT_ASSERT_ARG(node) \
158 , PARROT_ASSERT_ARG(s))
159 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
160 /* HEADERIZER END: compilers/imcc/cfg.c */
162 #endif /* PARROT_CFG_H_GUARD */
166 * Local variables:
167 * c-file-style: "parrot"
168 * End:
169 * vim: expandtab shiftwidth=4: