Run through clang-format.

This commit is contained in:
David Given 2016-08-21 19:38:54 +02:00
parent 1b66b63eae
commit 918f300513

View file

@ -56,8 +56,7 @@ int Sbig_caller,Sdispensable,Schangedcallee,Sbigcallee,Sspace,Szeroratio;
* The call descriptors are put in a file (calfile). * The call descriptors are put in a file (calfile).
*/ */
pass1(lnam,bnam,cnam) pass1(lnam, bnam, cnam) char* lnam, *bnam, *cnam;
char *lnam, *bnam, *cnam;
{ {
FILE* f, *gf, *cf, *ccf; /* The EM input, the basic block graph, FILE* f, *gf, *cf, *ccf; /* The EM input, the basic block graph,
* the call-list file and the calcnt file. * the call-list file and the calcnt file.
@ -76,13 +75,16 @@ pass1(lnam,bnam,cnam)
/* use information from the procedure table to /* use information from the procedure table to
* see which calls certainly cannot be expanded. * see which calls certainly cannot be expanded.
*/ */
while(TRUE) { while (TRUE)
{
laddr = ftell(f); laddr = ftell(f);
if (!getunit(gf,f,&kind,&g,&l,&curproc,TRUE)) break; if (!getunit(gf, f, &kind, &g, &l, &curproc, TRUE))
break;
/* Read the control flow graph and EM text of /* Read the control flow graph and EM text of
* one procedure and analyze it. * one procedure and analyze it.
*/ */
if (kind == LDATA) { if (kind == LDATA)
{
remunit(LDATA, (proc_p)0, l); remunit(LDATA, (proc_p)0, l);
continue; continue;
} }
@ -94,7 +96,8 @@ pass1(lnam,bnam,cnam)
/* address of graph in basic block file */ /* address of graph in basic block file */
curproc->P_SIZE = proclength(curproc); /* #instructions */ curproc->P_SIZE = proclength(curproc); /* #instructions */
total_size += curproc->P_SIZE; total_size += curproc->P_SIZE;
if (BIG_PROC(curproc)) { if (BIG_PROC(curproc))
{
/* curproc is too large to be expanded in line */ /* curproc is too large to be expanded in line */
UNSUITABLE(curproc); UNSUITABLE(curproc);
} }
@ -113,20 +116,15 @@ pass1(lnam,bnam,cnam)
fclose(ccf); fclose(ccf);
} }
/* P A S S 2 /* P A S S 2
* *
* Pass 2 reads the calfile and determines which calls should * Pass 2 reads the calfile and determines which calls should
* be expanded in line. It does not use the EM text. * be expanded in line. It does not use the EM text.
*/ */
STATIC char cname2[128] = TMP_DIR; STATIC char cname2[128] = TMP_DIR;
pass2(cnam,space) pass2(cnam, space) char* cnam;
char *cnam;
long space; long space;
{ {
FILE* cf, *cf2, *ccf; FILE* cf, *cf2, *ccf;
@ -135,9 +133,11 @@ pass2(cnam,space)
cf = openfile(cnam, "r"); cf = openfile(cnam, "r");
cf2 = openfile(cname2, "w"); cf2 = openfile(cname2, "w");
ccf = openfile(ccname, "r"); ccf = openfile(ccname, "r");
while ((c = getcall(cf)) != (call_p) 0) { while ((c = getcall(cf)) != (call_p)0)
{
/* process all calls */ /* process all calls */
if (SUITABLE(c->cl_proc) && anal_params(c)) { if (SUITABLE(c->cl_proc) && anal_params(c))
{
/* called proc. may be put in line */ /* called proc. may be put in line */
/* see which parameters may be put in line */ /* see which parameters may be put in line */
assign_ratio(c); /* assign a rank */ assign_ratio(c); /* assign a rank */
@ -145,23 +145,29 @@ pass2(cnam,space)
append_abstract(a, a->cl_caller); append_abstract(a, a->cl_caller);
/* put it in call-list of calling proc. */ /* put it in call-list of calling proc. */
putcall(c, cf2, (short)0); putcall(c, cf2, (short)0);
} else { }
else
{
rem_call(c); rem_call(c);
} }
} }
select_calls(fproc, ccf, space); select_calls(fproc, ccf, space);
fclose(cf); if (! kp_temps) unlink(cnam); fclose(cf);
if (!kp_temps)
unlink(cnam);
fclose(cf2); fclose(cf2);
fclose(ccf); if (! kp_temps) unlink(ccname); fclose(ccf);
if (!kp_temps)
unlink(ccname);
cf2 = openfile(cname2, "r"); cf2 = openfile(cname2, "r");
add_actuals(fproc, cf2); add_actuals(fproc, cf2);
cleancals(fproc); /* remove calls that were not selected */ cleancals(fproc); /* remove calls that were not selected */
/* add actual parameters to each selected call */ /* add actual parameters to each selected call */
fclose(cf2); if (! kp_temps) unlink(cname2); fclose(cf2);
if (!kp_temps)
unlink(cname2);
} }
/* P A S S 3 /* P A S S 3
* *
* pass 3 reads the substitution file and performs all * pass 3 reads the substitution file and performs all
@ -170,9 +176,7 @@ pass2(cnam,space)
* EM textfile. * EM textfile.
*/ */
pass3(lnam, lnam2) char* lnam, *lnam2;
pass3(lnam,lnam2)
char *lnam,*lnam2;
{ {
bool verbose = TRUE; bool verbose = TRUE;
FILE* lfile, *lfilerand, *lfile2, *sfile; FILE* lfile, *lfilerand, *lfile2, *sfile;
@ -183,23 +187,30 @@ pass3(lnam,lnam2)
lfile = openfile(lnam, "r"); lfile = openfile(lnam, "r");
lfilerand = openfile(lnam, "r"); lfilerand = openfile(lnam, "r");
lfile2 = openfile(lnam2, "w"); lfile2 = openfile(lnam2, "w");
if (verbose) { if (verbose)
{
sfile = openfile(sname, "w"); sfile = openfile(sname, "w");
} }
mesregs = Lempty_set(); mesregs = Lempty_set();
while ((l = get_text(lfile,&curproc)) != (line_p) 0) { while ((l = get_text(lfile, &curproc)) != (line_p)0)
if (curproc == (proc_p) 0) { {
if (curproc == (proc_p)0)
{
/* Just a data-unit; no real instructions */ /* Just a data-unit; no real instructions */
putlines(l->l_next, lfile2); putlines(l->l_next, lfile2);
oldline(l); oldline(l);
continue; continue;
} }
if (IS_DISPENSABLE(curproc)) { if (IS_DISPENSABLE(curproc))
{
liquidate(curproc, l->l_next); liquidate(curproc, l->l_next);
} else { }
else
{
startscan = l->l_next; startscan = l->l_next;
lastcid = 0; lastcid = 0;
for (c = curproc->P_CALS; c != (call_p) 0; c = next) { for (c = curproc->P_CALS; c != (call_p)0; c = next)
{
next = c->cl_cdr; next = c->cl_cdr;
cal = scan_to_cal(startscan, c->cl_id - lastcid); cal = scan_to_cal(startscan, c->cl_id - lastcid);
assert(cal != (line_p)0); assert(cal != (line_p)0);
@ -208,9 +219,12 @@ pass3(lnam,lnam2)
lastcid = c->cl_id; lastcid = c->cl_id;
/* next CAL after current one */ /* next CAL after current one */
substitute(lfilerand, c, cal, l->l_next); substitute(lfilerand, c, cal, l->l_next);
if (verbose) { if (verbose)
{
putcall(c, sfile, 0); putcall(c, sfile, 0);
} else { }
else
{
rem_call(c); rem_call(c);
} }
} }
@ -222,13 +236,14 @@ pass3(lnam,lnam2)
} }
fclose(lfile); fclose(lfile);
fclose(lfile2); fclose(lfile2);
if (verbose) { if (verbose)
{
fclose(sfile); fclose(sfile);
if (! kp_temps) unlink(sname); if (!kp_temps)
unlink(sname);
} }
} }
STATIC il_extptab(ptab) STATIC il_extptab(ptab)
proc_p ptab; proc_p ptab;
{ {
@ -238,7 +253,8 @@ STATIC il_extptab(ptab)
register proc_p p; register proc_p p;
for (p = ptab; p != (proc_p) 0; p = p->p_next) { for (p = ptab; p != (proc_p)0; p = p->p_next)
{
p->p_extend = newilpx(); p->p_extend = newilpx();
p->P_ORGLABELS = p->p_nrlabels; p->P_ORGLABELS = p->p_nrlabels;
p->P_ORGLOCALS = p->p_localbytes; p->P_ORGLOCALS = p->p_localbytes;
@ -252,7 +268,8 @@ STATIC il_cleanptab(ptab)
register proc_p p; register proc_p p;
for (p = ptab; p != (proc_p) 0; p = p->p_next) { for (p = ptab; p != (proc_p)0; p = p->p_next)
{
oldilpx(p->p_extend); oldilpx(p->p_extend);
} }
} }
@ -282,12 +299,13 @@ Sdiagnostics()
} }
#endif #endif
il_flags(p) il_flags(p) char* p;
char *p; {
switch (*p++)
{ {
switch(*p++) {
case 's': case 's':
while (*p != '\0') { while (*p != '\0')
{
space = 10 * space + *p++ - '0'; space = 10 * space + *p++ - '0';
} }
break; break;
@ -304,8 +322,7 @@ il_flags(p)
} }
} }
main(argc,argv) main(argc, argv) int argc;
int argc;
char* argv[]; char* argv[];
{ {
FILE* f; FILE* f;
@ -331,7 +348,8 @@ main(argc,argv)
putptable(fproc, f, FALSE); putptable(fproc, f, FALSE);
report("inline substitutions", Ssubst); report("inline substitutions", Ssubst);
#ifdef VERBOSE #ifdef VERBOSE
if (verbose_flag) { if (verbose_flag)
{
Sdiagnostics(); Sdiagnostics();
} }
#endif #endif