-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloop.h
46 lines (39 loc) · 960 Bytes
/
loop.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* -*-Mode: c++;-*-
Copyright (c) 2003-2008 John Plevyak, All Rights Reserved
*/
#ifndef _loop_H_
#define _loop_H_
class FA;
struct LoopNode : public gc {
int index;
void *node;
LoopNode *parent;
Vec<LoopNode *> children;
Vec<LoopNode *> loops;
Vec<LoopNode *> pred;
Vec<LoopNode *> succ;
Vec<LoopNode *> dom_children;
int pre_dfs, post_dfs;
int pre_dom, post_dom;
uint processed : 1;
uint in_worklist : 1;
int dfs_ancestor(LoopNode *);
int dom_ancestor(LoopNode *);
LoopNode(int i, void *n = 0);
};
#define forv_LoopNode(_p, _v) forv_Vec(LoopNode, _p, _v)
struct LoopGraph : public gc {
LoopNode *loops;
LoopNode *entry;
Vec<LoopNode *> nodes;
Vec<Vec<LoopNode *> *> levels;
UnionFind uf;
void unify(LoopNode *n, LoopNode *m);
LoopNode *find(LoopNode *n);
LoopGraph();
};
void find_loops(LoopGraph *g);
void find_local_loops(FA *f);
void find_recursive_loops(FA *f);
void find_all_loops(FA *fa);
#endif