Run through clang-format.

This commit is contained in:
David Given 2016-08-21 18:51:36 +02:00
parent 03a0b182c4
commit a4f136f999

View file

@ -9,7 +9,6 @@
* *
*/ */
#include <stdio.h> #include <stdio.h>
#include "types.h" #include "types.h"
#include "debug.h" #include "debug.h"
@ -22,54 +21,52 @@
#include "alloc.h" #include "alloc.h"
#include "go.h" #include "go.h"
STATIC bool report_flag = FALSE; /* report #optimizations found? */
STATIC bool report_flag = FALSE; /* report #optimizations found? */
#ifdef DEBUG #ifdef DEBUG
STATIC bool core_flag = FALSE; /* report core usage? */ STATIC bool core_flag = FALSE; /* report core usage? */
#endif #endif
STATIC mach_init(machfile, phase_machinit) char* machfile;
STATIC mach_init(machfile,phase_machinit) int (*phase_machinit)();
char *machfile;
int (*phase_machinit)();
{ {
/* Read target machine dependent information */ /* Read target machine dependent information */
FILE *f; FILE* f;
f = openfile(machfile,"r"); f = openfile(machfile, "r");
fscanf(f,"%d",&ws); fscanf(f, "%d", &ws);
fscanf(f,"%d",&ps); fscanf(f, "%d", &ps);
if (ws != ps && ps != 2*ws) error("illegal pointer size"); if (ws != ps && ps != 2 * ws)
error("illegal pointer size");
(*phase_machinit)(f); (*phase_machinit)(f);
fclose(f); fclose(f);
} }
go(argc, argv, initialize, optimize, phase_machinit, proc_flag) int argc;
char* argv[];
go(argc,argv,initialize,optimize,phase_machinit,proc_flag) int (*initialize)();
int argc; int (*optimize)();
char *argv[]; int (*phase_machinit)();
int (*initialize)(); int (*proc_flag)();
int (*optimize)();
int (*phase_machinit)();
int (*proc_flag)();
{ {
FILE *f, *gf, *f2, *gf2; /* The EM input and output and FILE* f, *gf, *f2, *gf2; /* The EM input and output and
* the basic block graphs input and output * the basic block graphs input and output
*/ */
bblock_p g; bblock_p g;
line_p l; line_p l;
short kind; short kind;
int i; int i;
char *p; char* p;
bool time_opt = TRUE; bool time_opt = TRUE;
linecount = 0; linecount = 0;
for (i = ARGSTART; i < argc; i++) { for (i = ARGSTART; i < argc; i++)
{
p = argv[i]; p = argv[i];
if (*p++ != '-') error("illegal argument"); if (*p++ != '-')
switch(*p) { error("illegal argument");
switch (*p)
{
case 'S': case 'S':
time_opt = FALSE; time_opt = FALSE;
break; break;
@ -78,7 +75,7 @@ go(argc,argv,initialize,optimize,phase_machinit,proc_flag)
break; break;
case 'M': case 'M':
p++; p++;
mach_init(p,phase_machinit); mach_init(p, phase_machinit);
break; break;
case 'C': case 'C':
#ifdef DEBUG #ifdef DEBUG
@ -98,31 +95,34 @@ go(argc,argv,initialize,optimize,phase_machinit,proc_flag)
} }
time_space_ratio = (time_opt ? 100 : 0); time_space_ratio = (time_opt ? 100 : 0);
fproc = getptable(pname); /* proc table */ fproc = getptable(pname); /* proc table */
fdblock = getdtable(dname); /* data block table */ fdblock = getdtable(dname); /* data block table */
(*initialize)(); (*initialize)();
if (optimize == no_action) return; if (optimize == no_action)
f = openfile(lname,"r"); return;
gf = openfile(bname,"r"); f = openfile(lname, "r");
f2 = openfile(lname2,"w"); gf = openfile(bname, "r");
gf2 = openfile(bname2,"w"); f2 = openfile(lname2, "w");
gf2 = openfile(bname2, "w");
mesregs = Lempty_set(); mesregs = Lempty_set();
while (getunit(gf,f,&kind,&g,&l,&curproc,TRUE)) { while (getunit(gf, f, &kind, &g, &l, &curproc, TRUE))
{
/* Read the control flow graph and EM text of /* Read the control flow graph and EM text of
* one procedure and optimize it. * one procedure and optimize it.
*/ */
if (kind == LDATA) { if (kind == LDATA)
putunit(LDATA, (proc_p) 0, l, gf2, f2); {
putunit(LDATA, (proc_p)0, l, gf2, f2);
continue; continue;
} }
OUTTRACE("flow graph of proc %d read",curproc->p_id); OUTTRACE("flow graph of proc %d read", curproc->p_id);
curproc->p_start = g; curproc->p_start = g;
/* The global variable curproc points to the /* The global variable curproc points to the
* current procedure. It is set by getgraph * current procedure. It is set by getgraph
*/ */
(*optimize)(curproc); (*optimize)(curproc);
putunit(LTEXT,curproc,(line_p) 0,gf2,f2); putunit(LTEXT, curproc, (line_p)0, gf2, f2);
/* output control flow graph + text */ /* output control flow graph + text */
OUTTRACE("graph of proc %d outputted",curproc->p_id); OUTTRACE("graph of proc %d outputted", curproc->p_id);
Ldeleteset(mesregs); Ldeleteset(mesregs);
mesregs = Lempty_set(); mesregs = Lempty_set();
} }
@ -130,34 +130,34 @@ go(argc,argv,initialize,optimize,phase_machinit,proc_flag)
fclose(f2); fclose(f2);
fclose(gf); fclose(gf);
fclose(gf2); fclose(gf2);
f = openfile(dname2,"w"); f = openfile(dname2, "w");
putdtable(fdblock,f); putdtable(fdblock, f);
/* fclose(f); done by putdtable */ /* fclose(f); done by putdtable */
f = openfile(pname2,"w"); f = openfile(pname2, "w");
putptable(fproc,f,TRUE); putptable(fproc, f, TRUE);
/* fclose(f); done by putptable */ /* fclose(f); done by putptable */
core_usage(); core_usage();
} }
no_action() {}
no_action() { }
core_usage() core_usage()
{ {
#ifdef DEBUG #ifdef DEBUG
if (core_flag) { if (core_flag)
{
coreusage(); coreusage();
} }
#endif #endif
} }
report(s,n) report(s, n) char* s;
char *s; int n;
int n;
{ {
/* Report number of optimizations found, if report_flag is set */ /* Report number of optimizations found, if report_flag is set */
if (report_flag) { if (report_flag)
fprintf(stderr,"%s: %d\n",s,n); {
fprintf(stderr, "%s: %d\n", s, n);
} }
} }