tagged release 0.6.4
[parrot.git] / compilers / imcc / cfg.h
blob4e4051cb0a0e9d411982f983e9ba3354a08f6ff6
1 /*
2 * $Id$
3 * Copyright (C) 2002-2007, The Perl 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 _edge *pred_next;
17 struct _basic_block *to;
18 struct _edge *succ_next;
19 struct _edge *next;
20 } Edge;
23 typedef struct _basic_block {
24 Instruction *start; /* First instruction in basic block */
25 Instruction *end; /* Last instruction in basic block */
26 Edge *pred_list;
27 Edge *succ_list;
28 int loop_depth;
29 int index; /*on bb_list*/
30 int flag;
31 } Basic_block;
33 EXTERN enum block_enum_flags_t {
34 BB_IS_SUB = 1 << 0
35 } block_enum_flags;
38 typedef struct _loop_info {
39 Set * loop; /* loop set containg bb's */
40 Set * exits; /* blocks that exit the loop */
41 int depth; /* depth of this loop */
42 int n_entries; /* nr of entries to this loop */
43 int header; /* header block of loop */
44 int preheader; /* preheader block of loop, if 1 entry point */
45 int size; /* no of blocks in loop */
46 } Loop_info;
49 /* Functions: */
50 struct _IMC_Unit;
52 /* HEADERIZER BEGIN: compilers/imcc/cfg.c */
53 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
55 PARROT_WARN_UNUSED_RESULT
56 int blocks_are_connected(
57 ARGIN(const Basic_block *from),
58 ARGIN(const Basic_block *to))
59 __attribute__nonnull__(1)
60 __attribute__nonnull__(2);
62 void build_cfg(PARROT_INTERP, ARGMOD(struct _IMC_Unit *unit))
63 __attribute__nonnull__(1)
64 __attribute__nonnull__(2)
65 FUNC_MODIFIES(*unit);
67 void clear_basic_blocks(ARGMOD(struct _IMC_Unit *unit))
68 __attribute__nonnull__(1)
69 FUNC_MODIFIES(*unit);
71 void compute_dominance_frontiers(PARROT_INTERP,
72 ARGMOD(struct _IMC_Unit *unit))
73 __attribute__nonnull__(1)
74 __attribute__nonnull__(2)
75 FUNC_MODIFIES(*unit);
77 void compute_dominators(PARROT_INTERP, ARGMOD(struct _IMC_Unit *unit))
78 __attribute__nonnull__(1)
79 __attribute__nonnull__(2)
80 FUNC_MODIFIES(*unit);
82 PARROT_WARN_UNUSED_RESULT
83 int edge_count(ARGIN(const struct _IMC_Unit *unit))
84 __attribute__nonnull__(1);
86 void find_basic_blocks(PARROT_INTERP,
87 ARGMOD(struct _IMC_Unit *unit),
88 int first)
89 __attribute__nonnull__(1)
90 __attribute__nonnull__(2)
91 FUNC_MODIFIES(*unit);
93 void find_loops(PARROT_INTERP, ARGMOD(struct _IMC_Unit *unit))
94 __attribute__nonnull__(1)
95 __attribute__nonnull__(2)
96 FUNC_MODIFIES(*unit);
98 void free_life_info(ARGIN(const struct _IMC_Unit *unit), ARGMOD(SymReg *r))
99 __attribute__nonnull__(1)
100 __attribute__nonnull__(2)
101 FUNC_MODIFIES(*r);
103 void life_analysis(PARROT_INTERP, ARGIN(const struct _IMC_Unit *unit))
104 __attribute__nonnull__(1)
105 __attribute__nonnull__(2);
107 PARROT_MALLOC
108 PARROT_CANNOT_RETURN_NULL
109 Life_range * make_life_range(ARGMOD(SymReg *r), int idx)
110 __attribute__nonnull__(1)
111 FUNC_MODIFIES(*r);
113 PARROT_WARN_UNUSED_RESULT
114 int natural_preheader(
115 ARGIN(const struct _IMC_Unit *unit),
116 ARGIN(const Loop_info* loop_info))
117 __attribute__nonnull__(1)
118 __attribute__nonnull__(2);
120 void search_predecessors_not_in(
121 ARGIN(const Basic_block *node),
122 ARGMOD(Set* s))
123 __attribute__nonnull__(1)
124 __attribute__nonnull__(2)
125 FUNC_MODIFIES(* s);
127 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
128 /* HEADERIZER END: compilers/imcc/cfg.c */
130 #endif /* PARROT_CFG_H_GUARD */
134 * Local variables:
135 * c-file-style: "parrot"
136 * End:
137 * vim: expandtab shiftwidth=4: