1 /*-
2 * %sccs.include.proprietary.c%
3 */
4
5 #ifndef lint
6 static char sccsid[] = "@(#)2.main.c 8.1 (Berkeley) 06/06/93";
7 #endif /* not lint */
8
9 #include <stdio.h>
10 #include "def.h"
11 #include "2.def.h"
12
13 VERT *after;
14 int *ntobef, *ntoaft;
build()15 build()
16 {
17 VERT v, *dom, *head;
18 int type;
19 struct list **inarc;
20 dfs(START);
21 if (routerr) return;
22 for (v = 0; v < nodenum; ++v)
23 {
24 type = NTYPE(v);
25 if (type == LOOPVX || type == DOVX)
26 FATH(ARC(v,0)) = v;
27 }
28
29 head = challoc(sizeof(*head) * nodenum);
30 if (progress) fprintf(stderr," gethead:\n");
31 gethead(head); /* sets head[v] to ITERVX heading smallest loop containing v or UNDEFINED */
32
33 if (routerr) return;
34 inarc = challoc(nodenum * sizeof(*inarc));
35 if (progress) fprintf(stderr," getinarc:\n");
36 getinarc(inarc,head); /* sets inarc[v] to list of forward arcs entering v */
37
38 dom = challoc(nodenum * sizeof(*dom));
39 if (progress) fprintf(stderr," getdom:\n");
40 getdom(inarc,dom); /* sets dom[v] to immediate dominator of v or UNDEFINED */
41 if (routerr) return;
42 if (progress) fprintf(stderr," gettree:\n");
43 gettree(inarc, dom, head);
44 if (routerr) return;
45
46 chfree(head, nodenum * sizeof(*head)); head = 0;
47 chfree(dom,nodenum * sizeof(*dom)); dom = 0;
48 for (v = 0; v < nodenum; ++v)
49 {
50 freelst(inarc[v]);
51 inarc[v] = 0;
52 }
53 chfree(inarc,sizeof(*inarc) * nodenum); inarc = 0;
54 chfree(ntoaft,sizeof(*ntoaft) * nodenum); ntoaft = 0;
55 chfree(ntobef,sizeof(*ntobef) * nodenum); ntobef = 0;
56 chfree(after, sizeof(*after) * accessnum); after = 0;
57 }
58