1 /* $Id: go.c,v 1.9 1994/06/24 10:30:05 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
26 STATIC bool report_flag = FALSE; /* report #optimizations found? */
28 STATIC bool core_flag = FALSE; /* report core usage? */
32 STATIC mach_init(machfile,phase_machinit)
34 int (*phase_machinit)();
36 /* Read target machine dependent information */
40 f = openfile(machfile,"r");
43 if (ws != ps && ps != 2*ws) error("illegal pointer size");
50 go(argc,argv,initialize,optimize,phase_machinit,proc_flag)
55 int (*phase_machinit)();
58 FILE *f, *gf, *f2, *gf2; /* The EM input and output and
59 * the basic block graphs input and output
69 for (i = ARGSTART; i < argc; i++) {
71 if (*p++ != '-') error("illegal argument");
81 mach_init(p,phase_machinit);
99 time_space_ratio = (time_opt ? 100 : 0);
100 fproc = getptable(pname); /* proc table */
101 fdblock = getdtable(dname); /* data block table */
103 if (optimize == no_action) return;
104 f = openfile(lname,"r");
105 gf = openfile(bname,"r");
106 f2 = openfile(lname2,"w");
107 gf2 = openfile(bname2,"w");
108 mesregs = Lempty_set();
109 while (getunit(gf,f,&kind,&g,&l,&curproc,TRUE)) {
110 /* Read the control flow graph and EM text of
111 * one procedure and optimize it.
114 putunit(LDATA, (proc_p) 0, l, gf2, f2);
117 OUTTRACE("flow graph of proc %d read",curproc->p_id);
118 curproc->p_start = g;
119 /* The global variable curproc points to the
120 * current procedure. It is set by getgraph
122 (*optimize)(curproc);
123 putunit(LTEXT,curproc,(line_p) 0,gf2,f2);
124 /* output control flow graph + text */
125 OUTTRACE("graph of proc %d outputted",curproc->p_id);
127 mesregs = Lempty_set();
133 f = openfile(dname2,"w");
134 putdtable(fdblock,f);
135 /* fclose(f); done by putdtable */
136 f = openfile(pname2,"w");
137 putptable(fproc,f,TRUE);
138 /* fclose(f); done by putptable */
158 /* Report number of optimizations found, if report_flag is set */
161 fprintf(stderr,"%s: %d\n",s,n);