Add prototypes, void in util/ego/share

This uncovers a problem in il/il_aux.c: it passes 3 arguments to
getlines(), but the function expects 4 arguments.  I add FALSE as the
4th argument.  TRUE would fill in the list of mesregs.  IL uses
mesregs during phase 1, but this call to getlines() is in phase 2.
TRUE would leak memory unless I added a call to Ldeleteset(mesregs).
So I pass FALSE.

Functions passed to go() now have a `void *` parameter because
no_action() now takes a `void *`.
This commit is contained in:
George Koehler 2017-11-15 16:29:27 -05:00
parent 5bbbaf4919
commit 9037d137f5
39 changed files with 294 additions and 407 deletions

View file

@ -304,10 +304,9 @@ STATIC bo_cleanproc(p)
} }
} }
void void bo_optimize(void *vp)
bo_optimize(p)
proc_p p;
{ {
proc_p p = vp;
bblock_p b; bblock_p b;
if (IS_ENTERED_WITH_GTO(p)) return; if (IS_ENTERED_WITH_GTO(p)) return;

View file

@ -289,9 +289,7 @@ STATIC bool try_pred(b)
void void cj_optimize(void *vp)
cj_optimize(p)
proc_p p;
{ {
/* Perform cross jumping for procedure p. /* Perform cross jumping for procedure p.
* In case cases a cross-jumping optimization which give * In case cases a cross-jumping optimization which give
@ -300,6 +298,7 @@ cj_optimize(p)
* untill we find no further optimizations. * untill we find no further optimizations.
*/ */
proc_p p = vp;
bblock_p b; bblock_p b;
bool changes = TRUE; bool changes = TRUE;

View file

@ -34,11 +34,11 @@ STATIC cs_clear()
start_valnum(); start_valnum();
} }
STATIC void cs_optimize(p) STATIC void cs_optimize(void *vp)
proc_p p;
{ {
/* Optimize all basic blocks of one procedure. */ /* Optimize all basic blocks of one procedure. */
proc_p p = vp;
register bblock_p rbp, bdone; register bblock_p rbp, bdone;
if (IS_ENTERED_WITH_GTO(p)) return; if (IS_ENTERED_WITH_GTO(p)) return;

View file

@ -191,7 +191,7 @@ STATIC set_replace(avp, tmp)
register lset s = avp->av_occurs; register lset s = avp->av_occurs;
for (i = Lfirst(s); i != (Lindex) 0; i = Lnext(i, s)) { for (i = Lfirst(s); i != (Lindex) 0; i = Lnext(i, s)) {
OUTVERBOSE("eliminate duplicate", 0); OUTVERBOSE("eliminate duplicate", 0, 0);
SHOWOCCUR(occ_elem(i)); SHOWOCCUR(occ_elem(i));
Scs++; Scs++;
delete(occ_elem(i), avp->av_before); delete(occ_elem(i), avp->av_before);
@ -275,7 +275,7 @@ eliminate(pp)
if (ravp->av_saveloc != (entity_p) 0) { if (ravp->av_saveloc != (entity_p) 0) {
tmp = ravp->av_saveloc->en_loc; tmp = ravp->av_saveloc->en_loc;
mes = find_mesreg(tmp); mes = find_mesreg(tmp);
OUTVERBOSE("re-using %ld(LB)", tmp); OUTVERBOSE("re-using %ld(LB)", tmp, 0);
} else { } else {
tmp = tmplocal(pp, ravp->av_size); tmp = tmplocal(pp, ravp->av_size);
mes = gen_mesreg(tmp, ravp, pp); mes = gen_mesreg(tmp, ravp, pp);

View file

@ -65,9 +65,9 @@ STATIC choose_cset(f, s_p, max)
Cdeleteset(cs1); Cdeleteset(cs2); Cdeleteset(cs1); Cdeleteset(cs2);
} }
cs_machinit(f) void cs_machinit(void *vp)
FILE *f;
{ {
FILE *f = vp;
char s[100]; char s[100];
int time, space; int time, space;
@ -194,8 +194,7 @@ STATIC bool okay_lines(avp, ocp)
return TRUE; return TRUE;
} }
bool desirable(avp) bool desirable(avail_p avp)
avail_p avp;
{ {
register Lindex i, next; register Lindex i, next;

View file

@ -3,11 +3,11 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
extern cs_machinit(); /* (FILE *f) void cs_machinit(void *vp); /* (FILE *f)
* Read phase-specific information from f. * Read phase-specific information from f.
*/ */
extern bool desirable(); /* (avail_p avp) bool desirable(avail_p avp); /*
* Return whether it is desirable to eliminate * Return whether it is desirable to eliminate
* the recurrences of the expression in avp. * the recurrences of the expression in avp.
* At the same time delete the recurrences * At the same time delete the recurrences

View file

@ -299,8 +299,10 @@ Sdiagnostics()
} }
#endif #endif
il_flags(p) char* p; void il_flags(void *vp)
{ {
char *p = vp;
switch (*p++) switch (*p++)
{ {
case 's': case 's':

View file

@ -26,9 +26,7 @@ STATIC actual_p acts, *app;
#define INIT_ACTS() {acts = (actual_p) 0; app = &acts;} #define INIT_ACTS() {acts = (actual_p) 0; app = &acts;}
#define APPEND_ACTUAL(a) {*app = a; app = &a->ac_next;} #define APPEND_ACTUAL(a) {*app = a; app = &a->ac_next;}
STATIC make_actual(l1,l2,size) STATIC void make_actual(line_p l1, line_p l2, offset size)
line_p l1,l2;
offset size;
{ {
/* Allocate a struct for a new actual parameter /* Allocate a struct for a new actual parameter
* expression, the code of which extends from * expression, the code of which extends from

View file

@ -326,7 +326,7 @@ STATIC bool is_dispensable(callee,ccf)
(complete_program || (callee->p_flags1 & PF_EXTERNAL) == 0) && (complete_program || (callee->p_flags1 & PF_EXTERNAL) == 0) &&
(callee->p_flags1 & PF_LPI) == 0) { (callee->p_flags1 & PF_LPI) == 0) {
DISPENSABLE(callee); DISPENSABLE(callee);
OUTVERBOSE("dispensable: procedure %d can be removed",callee->p_id); OUTVERBOSE("dispensable: procedure %d can be removed",callee->p_id,0);
#ifdef VERBOSE #ifdef VERBOSE
Spremoved++; Spremoved++;
#endif #endif
@ -475,7 +475,7 @@ STATIC singles(cals)
DISPENSABLE(c->cl_proc); DISPENSABLE(c->cl_proc);
CHANGED(c->cl_caller); CHANGED(c->cl_caller);
OUTVERBOSE("singles: procedure %d can be removed", OUTVERBOSE("singles: procedure %d can be removed",
c->cl_proc->p_id); c->cl_proc->p_id, 0);
#ifdef VERBOSE #ifdef VERBOSE
Spremoved++; Spremoved++;
#endif #endif

View file

@ -222,7 +222,7 @@ call_p getcall(cf)
m = getshort(); m = getshort();
act->ac_size = getoff(); act->ac_size = getoff();
act->ac_inl = getbyte(); act->ac_inl = getbyte();
act->ac_exp = getlines(cf,m,&voided); act->ac_exp = getlines(cf,m,&voided,FALSE);
*app = act; *app = act;
app = &act->ac_next; app = &act->ac_next;
} }

View file

@ -447,7 +447,9 @@ STATIC use(l,mesgflag)
STATIC nothing() { } /* No action to be undertaken at level 0 of parser */ /* ARGSUSED */
STATIC void nothing(line_p l1, line_p l2, offset size)
{ } /* No action to be undertaken at level 0 of parser */
STATIC rem_code(l1,l2,b) STATIC rem_code(l1,l2,b)
line_p l1,l2; line_p l1,l2;
@ -580,9 +582,10 @@ STATIC lv_cleanup(p)
} }
} }
lv_flags(p) void lv_flags(void *vp)
char *p;
{ {
char *p = vp;
switch(*p) { switch(*p) {
case 'N': case 'N':
mesgflag = TRUE; mesgflag = TRUE;
@ -591,10 +594,10 @@ lv_flags(p)
} }
void void lv_optimize(void *vp)
lv_optimize(p)
proc_p p;
{ {
proc_p p = vp;
if (IS_ENTERED_WITH_GTO(p)) return; if (IS_ENTERED_WITH_GTO(p)) return;
locals = (local_p *) 0; locals = (local_p *) 0;
lv_extend(p); lv_extend(p);

View file

@ -104,10 +104,10 @@ get_otab(f,tab)
STATIC ra_machinit(f) STATIC void ra_machinit(void *vp)
FILE *f;
{ {
/* Read target machine dependent information for this phase */ /* Read target machine dependent information for this phase */
FILE *f = vp;
char s[100]; char s[100];
for (;;) { for (;;) {
@ -344,16 +344,16 @@ STATIC cleanitems(list)
} }
ra_initialize() /* ARGSUSED */
void ra_initialize(void *null)
{ {
init_replacements(ps,ws); init_replacements(ps,ws);
} }
void void ra_optimize(void *vp)
ra_optimize(p)
proc_p p;
{ {
proc_p p = vp;
item_p itemlist; item_p itemlist;
alloc_p alloclist,packed,unpacked; alloc_p alloclist,packed,unpacked;
offset locls; offset locls;

View file

@ -19,8 +19,7 @@
#include "map.h" #include "map.h"
#include "lset.h" #include "lset.h"
offset off_set(lnp) offset off_set(line_p lnp)
line_p lnp;
{ {
switch(lnp->l_optype) { switch(lnp->l_optype) {
case OPSHORT: case OPSHORT:
@ -36,8 +35,7 @@ offset off_set(lnp)
offset aoff(ap,n) offset aoff(arg_p ap, int n)
register arg_p ap;
{ {
while (n>0) { while (n>0) {
if (ap != (arg_p) 0) if (ap != (arg_p) 0)
@ -52,9 +50,7 @@ offset aoff(ap,n)
} }
offset tmplocal(p,size) offset tmplocal(proc_p p, offset size)
proc_p p;
offset size;
{ {
/* Allocate a new local variable in the stack frame of p */ /* Allocate a new local variable in the stack frame of p */
@ -65,8 +61,7 @@ offset tmplocal(p,size)
line_p int_line(off) line_p int_line(offset off)
offset off;
{ {
/* Allocate a line struct of type OPSHORT or OPOFFSET, /* Allocate a line struct of type OPSHORT or OPOFFSET,
* whichever one fits best. * whichever one fits best.
@ -87,10 +82,7 @@ line_p int_line(off)
line_p reg_mes(tmp,size,typ,score) line_p reg_mes(offset tmp, short size, int typ, int score)
offset tmp;
short size;
int typ,score;
{ {
/* Generate a register message */ /* Generate a register message */
@ -111,8 +103,7 @@ line_p reg_mes(tmp,size,typ,score)
} }
bool dom(b1,b2) bool dom(bblock_p b1, bblock_p b2)
bblock_p b1,b2;
{ {
/* See if b1 dominates b2. Note that a block always /* See if b1 dominates b2. Note that a block always
* dominates itself. * dominates itself.
@ -130,8 +121,7 @@ bool dom(b1,b2)
} }
bblock_p common_dom(a,b) bblock_p common_dom(bblock_p a, bblock_p b)
bblock_p a,b;
{ {
/* find a basic block that dominates a as well as b; /* find a basic block that dominates a as well as b;
* note that a basic block also dominates itself. * note that a basic block also dominates itself.
@ -152,8 +142,7 @@ bblock_p common_dom(a,b)
#define R time_space_ratio #define R time_space_ratio
short add_timespace(time,space) short add_timespace(short time, short space)
short time,space;
{ {
/* Add together a time and space, using the time_space_ratio /* Add together a time and space, using the time_space_ratio
* parameter that may be set by the user, indicating the need * parameter that may be set by the user, indicating the need
@ -165,9 +154,7 @@ short add_timespace(time,space)
rm_line(l,b) void rm_line(line_p l, bblock_p b)
line_p l;
bblock_p b;
{ {
if (b->b_start == l) { if (b->b_start == l) {
b->b_start = l->l_next; b->b_start = l->l_next;
@ -183,8 +170,7 @@ rm_line(l,b)
appnd_line(l1,l2) void appnd_line(line_p l1, line_p l2)
line_p l1,l2;
{ {
/* Put l1 after l2 */ /* Put l1 after l2 */
@ -198,8 +184,7 @@ appnd_line(l1,l2)
line_p last_instr(b) line_p last_instr(bblock_p b)
bblock_p b;
{ {
/* Determine the last line of a list */ /* Determine the last line of a list */
@ -213,8 +198,7 @@ line_p last_instr(b)
line_p find_mesreg(off) line_p find_mesreg(offset off)
offset off;
{ {
/* Find the register message for the local with the given offset */ /* Find the register message for the local with the given offset */
@ -229,17 +213,14 @@ line_p find_mesreg(off)
} }
bool is_regvar(off) bool is_regvar(offset off)
offset off;
{ {
return find_mesreg(off) != (line_p) 0; return find_mesreg(off) != (line_p) 0;
} }
offset regv_arg(off,n) offset regv_arg(offset off, int n)
offset off;
int n;
{ {
/* fetch the n'th argument of the register message of the /* fetch the n'th argument of the register message of the
* local variable at offset off; * local variable at offset off;

View file

@ -10,61 +10,68 @@
*/ */
extern offset off_set(); /* (line_p lnp) offset off_set(line_p lnp); /*
* lnp has a SHORT or OFFSET operand. Return * lnp has a SHORT or OFFSET operand. Return
* the value of this operand as an offset. * the value of this operand as an offset.
*/ */
extern offset aoff(); /* (arg_p list; int n) offset aoff(arg_p list, int n); /*
* Determine the offset field of the * Determine the offset field of the
* n'th argument in the list (this argument * n'th argument in the list (this argument
* must have type ARGOFF). Start counting at 0. * must have type ARGOFF). Start counting at 0.
*/ */
extern offset tmplocal(); /* (proc_p p, offset size) offset tmplocal(proc_p p, offset size);
/*
* Allocate a new local variable in the * Allocate a new local variable in the
* stack frame of p. * stack frame of p.
*/ */
line_p int_line(); /* (offset off) line_p int_line(offset off); /*
* Allocate a line struct of type OPSHORT * Allocate a line struct of type OPSHORT
* or OPOFFSET, whichever one fits best. * or OPOFFSET, whichever one fits best.
*/ */
extern line_p reg_mes(); /* (offset tmp; short size; int typ,score) line_p reg_mes(offset tmp, short size, int typ, int score);
/*
* Generate a register message with the * Generate a register message with the
* given arguments. * given arguments.
*/ */
extern bool dom(); /* (bblock_p b1,b2) bool dom(bblock_p b1, bblock_p b2);
/* See if b1 dominates b2. Note that a /*
* See if b1 dominates b2. Note that a
* block always * dominates itself. * block always * dominates itself.
*/ */
extern bblock_p common_dom(); /* (bblock_p a,b) bblock_p common_dom(bblock_p a, bblock_p b);
* find a basic block that dominates a as /*
* well as b; note that a basic block also * Find a basic block that dominates a as
* well as b; note that a basic block also
* dominates itself. * dominates itself.
*/ */
extern short add_timespace(); /* (short time,space) short add_timespace(short time, short space);
* Add together a time and space, using /*
* the time_space_ratio parameter that * Add together a time and space, using
* the time_space_ratio parameter that
* may be set by the user. * may be set by the user.
*/ */
extern rm_line(); /* ( line_p l; bblock_p b) void rm_line(line_p l, bblock_p b);
/*
* Remove line l from b basic block b. * Remove line l from b basic block b.
*/ */
void appnd_line(line_p l1, line_p l2);
extern appnd_line(); /* ( line_p l1,l2) /*
* Put line l1 after l2. * Put line l1 after l2.
*/ */
extern line_p last_instr(); /* ( bblock_p b) line_p last_instr(bblock_p b); /*
* Determine the last line of a basic block. * Determine the last line of a basic block.
*/ */
extern line_p find_mesreg(); /* (offset off) line_p find_mesreg(offset off); /*
* Find the register message for the local * Find the register message for the local
* with the given offset. * with the given offset.
*/ */
extern bool is_regvar(); /* (offset off) bool is_regvar(offset off); /*
* See if there is a 'register message' * See if there is a 'register message'
* for the local variable with the * for the local variable with the
* given offset. * given offset.
*/ */
extern offset regv_arg(); /* (offset off; int n) offset regv_arg(offset off, int n);
/*
* Fetch the n'th argument of the * Fetch the n'th argument of the
* register message of the local with * register message of the local with
* the given offset. * the given offset.

View file

@ -37,8 +37,7 @@
cset Cempty_set(n) cset Cempty_set(short n)
short n;
{ {
cset s; cset s;
@ -48,9 +47,7 @@ cset Cempty_set(n)
} }
bool Cis_elem(x,s) bool Cis_elem(Celem_t x, cset s)
Celem_t x;
cset s;
{ {
short n; short n;
int mask; int mask;
@ -67,9 +64,7 @@ bool Cis_elem(x,s)
Cadd(x,s_p) void Cadd(Celem_t x, cset *s_p)
Celem_t x;
cset *s_p;
{ {
cset s; cset s;
short n; short n;
@ -83,9 +78,7 @@ Cadd(x,s_p)
} }
Cremove(x,s_p) void Cremove(Celem_t x, cset *s_p)
Celem_t x;
cset *s_p;
{ {
cset s; cset s;
short n; short n;
@ -117,16 +110,13 @@ Cremove(x,s_p)
* be used very often. * be used very often.
*/ */
Cindex Cfirst(s) Cindex Cfirst(cset s)
cset s;
{ {
return Cnext((Cindex) 0,s); return Cnext((Cindex) 0,s);
} }
Cindex Cnext(i,s) Cindex Cnext(Cindex i, cset s)
Cindex i;
cset s;
{ {
register short n; register short n;
@ -139,16 +129,14 @@ Cindex Cnext(i,s)
} }
Celem_t Celem(i) Celem_t Celem(Cindex i)
Cindex i;
{ {
return (Celem_t) i; return (Celem_t) i;
} }
Cjoin(s1,s2_p) void Cjoin(cset s1, cset *s2_p)
cset s1, *s2_p;
{ {
/* Two sets are joined by or-ing their bitvectors, /* Two sets are joined by or-ing their bitvectors,
* word by word. * word by word.
@ -168,8 +156,7 @@ Cjoin(s1,s2_p)
Cintersect(s1,s2_p) void Cintersect(cset s1, cset *s2_p)
cset s1, *s2_p;
{ {
/* Two sets are intersected by and-ing their bitvectors, /* Two sets are intersected by and-ing their bitvectors,
* word by word. * word by word.
@ -188,15 +175,13 @@ Cintersect(s1,s2_p)
} }
Cdeleteset(s) void Cdeleteset(cset s)
cset s;
{ {
oldbitvect(s,DIVWL(s->v_size - 1) + 1); oldbitvect(s,DIVWL(s->v_size - 1) + 1);
} }
bool Cis_subset(s1,s2) bool Cis_subset(cset s1, cset s2)
cset s1,s2;
{ {
/* See if s1 is a subset of s2 */ /* See if s1 is a subset of s2 */
@ -213,8 +198,7 @@ bool Cis_subset(s1,s2)
} }
Cclear_set(s_p) void Cclear_set(cset *s_p)
cset *s_p;
{ {
cset s; cset s;
register short i; register short i;
@ -227,8 +211,7 @@ Cclear_set(s_p)
} }
Ccopy_set(s1,s2_p) void Ccopy_set(cset s1, cset *s2_p)
cset s1, *s2_p;
{ {
cset s2; cset s2;
register short i; register short i;
@ -241,8 +224,7 @@ Ccopy_set(s1,s2_p)
} }
Csubtract(s1,s2_p) void Csubtract(cset s1, cset *s2_p)
cset s1, *s2_p;
{ {
cset s2; cset s2;
register short i; register short i;
@ -255,8 +237,7 @@ Csubtract(s1,s2_p)
} }
bool Cequal(s1,s2) bool Cequal(cset s1, cset s2)
cset s1, s2;
{ {
register short i; register short i;
@ -267,8 +248,7 @@ bool Cequal(s1,s2)
return TRUE; return TRUE;
} }
short Cnrelems(s) short Cnrelems(cset s)
cset s;
{ {
register short n, cnt; register short n, cnt;

View file

@ -8,19 +8,19 @@
*/ */
extern cset Cempty_set(); /* (short) */ cset Cempty_set(short);
extern bool Cis_elem(); /* (Celem, cset) */ bool Cis_elem(Celem_t, cset);
extern Cadd(); /* (Celem, *cset) */ void Cadd(Celem_t, cset *);
extern Cremove(); /* (Celem, *cset) */ void Cremove(Celem_t, cset *);
extern Cindex Cfirst(); /* (cset) */ Cindex Cfirst(cset);
extern Cindex Cnext(); /* (Cindex, cset) */ Cindex Cnext(Cindex, cset);
extern Celem_t Celem(); /* (Cindex) */ Celem_t Celem(Cindex);
extern Cjoin(); /* (cset, *cset) */ void Cjoin(cset, cset *);
extern Cintersect(); /* (cset, *cset) */ void Cintersect(cset, cset *);
extern Cdeleteset(); /* (cset) */ void Cdeleteset(cset);
extern bool Cis_subset(); /* (cset, cset) */ bool Cis_subset(cset, cset);
extern Cclearset(); /* (cset, *cset) */ void Cclearset(cset, cset *);
extern Ccopy_set(); /* (cset, *cset) */ void Ccopy_set(cset, cset *);
extern Csubtract(); /* (cset, *cset) */ void Csubtract(cset, cset *);
extern bool Cequal(); /* (cset, cset) */ bool Cequal(cset, cset);
extern short Cnrelems(); /* (cset) */ short Cnrelems(cset);

View file

@ -9,8 +9,9 @@
*/ */
#include <stdlib.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <em_spec.h> #include <em_spec.h>
#include "types.h" #include "types.h"
#include "def.h" #include "def.h"
@ -23,14 +24,17 @@ int linecount; /* # lines in this file */
bool verbose_flag = FALSE; /* generate verbose output ? */ bool verbose_flag = FALSE; /* generate verbose output ? */
/* VARARGS1 */ /* VARARGS1 */
error(s,a) char *s,*a; { void error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
fprintf(stderr,"error on line %u",linecount); fprintf(stderr,"error on line %u",linecount);
if (filename != (char *) 0) { if (filename != (char *) 0) {
fprintf(stderr," file %s",filename); fprintf(stderr," file %s",filename);
} }
fprintf(stderr,": "); fprintf(stderr,": ");
fprintf(stderr,s,a); vfprintf(stderr,s,ap);
fprintf(stderr,"\n"); fprintf(stderr,"\n");
abort(); abort();
exit(-1); exit(-1);
@ -38,21 +42,17 @@ error(s,a) char *s,*a; {
#ifdef TRACE #ifdef TRACE
/* VARARGS1 */ /* VARARGS1 */
OUTTRACE(s,n) void OUTTRACE(const char *s, int n)
char *s;
int n;
{ {
fprintf(stderr,"> "); fprintf(stderr,"> ");
fprintf(stderr,s,n); vfprintf(stderr,s,n);
fprintf(stderr,"\n"); fprintf(stderr,"\n");
} }
#endif #endif
#ifdef VERBOSE #ifdef VERBOSE
/* VARARGS1 */ /* VARARGS1 */
OUTVERBOSE(s,n1,n2) void OUTVERBOSE(const char *s, int n1, int n2)
char *s;
int n1,n2;
{ {
if (verbose_flag) { if (verbose_flag) {
fprintf(stderr,"optimization: "); fprintf(stderr,"optimization: ");
@ -72,7 +72,7 @@ badassertion(file,line) char *file; unsigned line; {
} }
/* Valid Address */ /* Valid Address */
VA(a) short *a; { void VA(short *a) {
if (a == (short *) 0) error("VA: 0 argument"); if (a == (short *) 0) error("VA: 0 argument");
if ( ((unsigned) a & 01) == 01) { if ( ((unsigned) a & 01) == 01) {
/* MACHINE DEPENDENT TEST */ /* MACHINE DEPENDENT TEST */
@ -83,14 +83,14 @@ VA(a) short *a; {
/* Valid Instruction code */ /* Valid Instruction code */
VI(i) short i; { void VI(short i) {
if (i > ps_last) error("VI: illegal instr: %d", i); if (i > ps_last) error("VI: illegal instr: %d", i);
} }
/* Valid Line */ /* Valid Line */
VL(l) line_p l; { void VL(line_p l) {
byte instr, optype; byte instr, optype;
VA((short *) l); VA((short *) l);
@ -106,7 +106,7 @@ VL(l) line_p l; {
/* Valid Data block */ /* Valid Data block */
VD(d) dblock_p d; { void VD(dblock_p d) {
byte pseudo; byte pseudo;
VA((short *) d); VA((short *) d);
@ -119,7 +119,7 @@ VD(d) dblock_p d; {
/* Valid Object */ /* Valid Object */
VO(o) obj_p o; { void VO(obj_p o) {
offset off; offset off;
VA((short *) o); VA((short *) o);
@ -133,7 +133,7 @@ VO(o) obj_p o; {
/* Valid Proc */ /* Valid Proc */
VP(p) proc_p p; { void VP(proc_p p) {
proc_id pid; proc_id pid;
int nrlabs; int nrlabs;

View file

@ -12,16 +12,16 @@ extern int linecount; /* # lines in this file */
extern bool verbose_flag; /* generate verbose output ? */ extern bool verbose_flag; /* generate verbose output ? */
/* VARARGS 1 */ /* VARARGS 1 */
extern error(); void error(const char *, ...);
#ifdef TRACE #ifdef TRACE
extern OUTTRACE(); void OUTTRACE(const char *, int);
#else #else
#define OUTTRACE(s,n) #define OUTTRACE(s,n)
#endif #endif
#ifdef VERBOSE #ifdef VERBOSE
extern OUTVERBOSE(); void OUTVERBOSE(const char *, int, int);
#else #else
#define OUTVERBOSE(s,n1,n2) #define OUTVERBOSE(s,n1,n2)
#endif #endif
@ -36,12 +36,12 @@ extern OUTVERBOSE();
#define assert(x) if(!(x)) badassertion(__FILE__,__LINE__) #define assert(x) if(!(x)) badassertion(__FILE__,__LINE__)
extern VI(); void VI(short);
extern VL(); void VL(line_p);
extern VD(); void VD(dblock_p);
extern VA(); void VA(short *);
extern VO(); void VO(obj_p);
extern VP(); void VP(proc_p);

View file

@ -47,7 +47,7 @@ struct files* findfiles(int argc, const char** argv)
return &files; return &files;
} }
FILE *openfile(char* name, char* mode) FILE *openfile(const char *name, const char *mode)
{ {
FILE *f; FILE *f;

View file

@ -37,9 +37,10 @@ struct files
int argc; int argc;
}; };
extern struct files* findfiles(int argc, const char** argv); struct files* findfiles(int argc, const char** argv);
extern FILE *openfile(); /* (char *name, *mode) FILE *openfile(const char *name, const char *mode);
/*
* Open a file with the given name * Open a file with the given name
* and mode; aborts if the file * and mode; aborts if the file
* cannot be opened. * cannot be opened.

View file

@ -33,7 +33,7 @@ lab_id lastlabid; /* last label identifier */
* appear in the input. * appear in the input.
*/ */
bblock_p freshblock() bblock_p freshblock(void)
{ {
bblock_p b; bblock_p b;
b = newbblock(); b = newbblock();
@ -42,7 +42,7 @@ bblock_p freshblock()
} }
lab_id freshlabel() lab_id freshlabel(void)
{ {
curproc->p_nrlabels++; curproc->p_nrlabels++;
return ++lastlabid; return ++lastlabid;
@ -51,7 +51,7 @@ lab_id freshlabel()
#define getmark() getbyte() #define getmark() getbyte()
short getshort() { short getshort(void) {
register int l_byte, h_byte; register int l_byte, h_byte;
l_byte = getbyte(); l_byte = getbyte();
@ -61,7 +61,7 @@ short getshort() {
} }
offset getoff() { offset getoff(void) {
register long l; register long l;
register int h_byte; register int h_byte;
@ -73,7 +73,7 @@ offset getoff() {
return l | (h_byte*256L*256*256L) ; return l | (h_byte*256L*256*256L) ;
} }
STATIC int getint() STATIC int getint(void)
{ {
/* Read an integer from the input file. This routine is /* Read an integer from the input file. This routine is
* only used when reading a bitvector-set. We expect an * only used when reading a bitvector-set. We expect an
@ -90,8 +90,7 @@ STATIC int getint()
/* getptable */ /* getptable */
loop_p getloop(id) STATIC void *getloop(loop_id id)
loop_id id;
{ {
/* Map a loop identifier onto a loop struct. /* Map a loop identifier onto a loop struct.
* If no struct was alocated yet for this identifier then * If no struct was alocated yet for this identifier then
@ -107,8 +106,7 @@ loop_p getloop(id)
return (lpmap[id]); return (lpmap[id]);
} }
bblock_p getblock(id) STATIC void *getblock(block_id id)
block_id id;
{ {
/* Map a basic block identifier onto a block struct /* Map a basic block identifier onto a block struct
* If no struct was alocated yet for this identifier then * If no struct was alocated yet for this identifier then
@ -126,8 +124,7 @@ bblock_p getblock(id)
} }
lset getlset(p) STATIC lset getlset(void *(*p)(short))
char *((*p) ());
{ {
/* Read a 'long' set. Such a set is represented externally /* Read a 'long' set. Such a set is represented externally
* as a sequence of identifying numbers terminated by a 0. * as a sequence of identifying numbers terminated by a 0.
@ -146,7 +143,7 @@ lset getlset(p)
} }
cset getcset() STATIC cset getcset()
{ {
/* Read a 'compact' set. Such a set is represented externally /* Read a 'compact' set. Such a set is represented externally
* a row of bytes (its bitvector) preceded by its length. * a row of bytes (its bitvector) preceded by its length.
@ -163,8 +160,7 @@ cset getcset()
} }
proc_p getptable(pname) proc_p getptable(const char *pname)
char *pname;
{ {
short i; short i;
proc_p head, p, *pp; proc_p head, p, *pp;
@ -216,8 +212,7 @@ proc_p getptable(pname)
/* getdtable */ /* getdtable */
dblock_p getdtable(dname) dblock_p getdtable(const char *dname)
char *dname;
{ {
/* Read the data block table. Every data block may /* Read the data block table. Every data block may
* have a list of objects and a list of values (arguments), * have a list of objects and a list of values (arguments),
@ -290,9 +285,7 @@ dblock_p getdtable(dname)
/* getbblocks */ /* getbblocks */
STATIC argstring(length,abp) STATIC argstring(short length, argb_p abp)
short length;
register argb_p abp;
{ {
while (length--) { while (length--) {
@ -304,7 +297,7 @@ STATIC argstring(length,abp)
STATIC arg_p readargs() STATIC arg_p readargs(void)
{ {
/* Read a list of arguments and allocate structures /* Read a list of arguments and allocate structures
* for them. Return a pointer to the head of the list. * for them. Return a pointer to the head of the list.
@ -363,8 +356,7 @@ STATIC arg_p readargs()
} }
line_p read_line(p_out) line_p read_line(proc_p *p_out)
proc_p *p_out;
{ {
/* Read a line of EM code (i.e. one instruction) /* Read a line of EM code (i.e. one instruction)
* and its arguments (if any). * and its arguments (if any).
@ -426,8 +418,7 @@ line_p read_line(p_out)
} }
message(lnp) void message(line_p lnp)
line_p lnp;
{ {
/* See if lnp is some useful message. /* See if lnp is some useful message.
* (e.g. a message telling that a certain local variable * (e.g. a message telling that a certain local variable
@ -456,11 +447,7 @@ message(lnp)
line_p getlines(lf,n,p_out,collect_mes) line_p getlines(FILE *lf, int n, proc_p *p_out, bool collect_mes)
FILE *lf;
int n;
proc_p *p_out;
bool collect_mes;
{ {
/* Read n lines of EM text and doubly link them. /* Read n lines of EM text and doubly link them.
* Also process messages. * Also process messages.
@ -486,13 +473,8 @@ line_p getlines(lf,n,p_out,collect_mes)
bool getunit(gf,lf,kind_out,g_out,l_out,p_out,collect_mes) bool getunit(FILE *gf, FILE *lf, short *kind_out, bblock_p *g_out,
FILE *gf,*lf; line_p *l_out, proc_p *p_out, bool collect_mes)
short *kind_out;
bblock_p *g_out;
line_p *l_out;
proc_p *p_out;
bool collect_mes;
{ {
/* Read control flow graph (gf) and EM text (lf) of the next procedure. /* Read control flow graph (gf) and EM text (lf) of the next procedure.
* A pointer to the proctable entry of the read procedure is * A pointer to the proctable entry of the read procedure is

View file

@ -10,44 +10,44 @@ extern block_id lastbid; /* block identifying number */
extern lab_id lastlabid; /* last label identifier */ extern lab_id lastlabid; /* last label identifier */
#define getbyte() getc(curinp) #define getbyte() getc(curinp)
extern short getshort(); /* () short getshort(void); /*
* Read a short from curinp * Read a short from curinp
*/ */
extern offset getoff(); /* () offset getoff(void); /*
* Read an offset from curinp * Read an offset from curinp
*/ */
extern line_p read_line(); /* ( proc_p *p_out) line_p read_line(proc_p *p_out); /*
* Read a line of EM code (i.e. one * Read a line of EM code (i.e. one
* instruction) and its arguments * instruction) and its arguments
* (if any). If the instruction is a * (if any). If the instruction is a
* 'pro' pseudo, set p_out. * 'pro' pseudo, set p_out.
*/ */
extern line_p getlines(); /* ( FILE *lf; int n; proc_p *p_out; line_p getlines(FILE *lf, int n, proc_p *p_out, bool collect_mes);
* bool collect_mes) /*
* Read n lines of EM text and doubly * Read n lines of EM text and doubly
* link them. Also process messages * link them. Also process messages
* if required. * if required.
*/ */
extern bblock_p freshblock(); /* () bblock_p freshblock(void); /*
* Allocate a bblock struct and assign * Allocate a bblock struct and assign
* it a brand new block_id. * it a brand new block_id.
*/ */
extern lab_id freshlabel(); /* () lab_id freshlabel(void); /*
* Get a brand new lab_id. * Get a brand new lab_id.
*/ */
extern dblock_p getdtable(); /* (char *dname) dblock_p getdtable(const char *dname); /*
* Read the data block table from * Read the data block table from
* the file with the given name. * the file with the given name.
*/ */
extern proc_p getptable(); /* (char *pname) proc_p getptable(const char *pname); /*
* Read the proc table from * Read the proc table from
* the file with the given name. * the file with the given name.
*/ */
extern bool getunit(); /* (FILE *gf,*lf; short kind_out; bool getunit(FILE *gf, FILE *lf, short *kind_out, bblock_p *g_out,
* bblock_p g_out; line_p l_out; line_p *l_out, proc_p *p_out, bool collect_mes);
* proc_p *p_out; bool collect_mes) /*
* Read the control flow graph * Read the control flow graph
* (from file gf) and the EM text * (from file gf) and the EM text
* (from lf). If collect_mes is TRUE, * (from lf). If collect_mes is TRUE,
@ -56,8 +56,8 @@ extern bool getunit(); /* (FILE *gf,*lf; short kind_out;
* variable 'mesregs'. The proc read * variable 'mesregs'. The proc read
* is returned in p_out. * is returned in p_out.
*/ */
extern message(); /* (line_p lnp) void message(line_p lnp); /*
* See if lnp is some useful message. * See if lnp is some useful message.
* (e.g. a message telling that a * (e.g. a message telling that a
* certain local variable will never be * certain local variable will never be
* referenced indirectly, so it may be * referenced indirectly, so it may be

View file

@ -27,7 +27,7 @@ STATIC bool report_flag = FALSE; /* report #optimizations found? */
STATIC bool core_flag = FALSE; /* report core usage? */ STATIC bool core_flag = FALSE; /* report core usage? */
#endif #endif
static mach_init(char* machfile, int (*phase_machinit)()) STATIC void mach_init(char* machfile, void (*phase_machinit)(void *))
{ {
/* Read target machine dependent information */ /* Read target machine dependent information */
@ -43,7 +43,8 @@ static mach_init(char* machfile, int (*phase_machinit)())
} }
void go(int argc, const char** argv, void go(int argc, const char** argv,
int (*initialize)(), int (*optimize)(), int (*phase_machinit)(), int (*proc_flag)()) void (*initialize)(void *), void (*optimize)(void *),
void (*phase_machinit)(void *), void (*proc_flag)(void *))
{ {
struct files* files = findfiles(argc, argv); struct files* files = findfiles(argc, argv);
FILE* f, *gf, *f2, *gf2; /* The EM input and output and FILE* f, *gf, *f2, *gf2; /* The EM input and output and
@ -100,7 +101,7 @@ void go(int argc, const char** argv,
time_space_ratio = (time_opt ? 100 : 0); time_space_ratio = (time_opt ? 100 : 0);
fproc = getptable(files->pname_in); /* proc table */ fproc = getptable(files->pname_in); /* proc table */
fdblock = getdtable(files->dname_in); /* data block table */ fdblock = getdtable(files->dname_in); /* data block table */
(*initialize)(); (*initialize)(NULL);
if (optimize == no_action) if (optimize == no_action)
return; return;
f = openfile(files->lname_in, "r"); f = openfile(files->lname_in, "r");
@ -143,7 +144,8 @@ void go(int argc, const char** argv,
core_usage(); core_usage();
} }
int no_action() {} /* ARGSUSED */
void no_action(void *vp) {}
void core_usage(void) void core_usage(void)
{ {

View file

@ -22,20 +22,22 @@
* and 'optimize' is called with the current procedure * and 'optimize' is called with the current procedure
* as parameter. * as parameter.
*/ */
extern void go(int argc, const char** argv, void go(int argc, const char** argv,
int (*initialize)(), int (*optimize)(), void (*initialize)(void *null),
int (*phase_machinit)(), int (*proc_flag)()); void (*optimize)(void *), /* (proc_p *p) */
void (*phase_machinit)(void *), /* (FILE *f) */
void (*proc_flag)(void *)); /* (char *flag) */
/* /*
* Parameter to be supplied for e.g. 'initialize' if * Parameter to be supplied for e.g. 'initialize' if
* no action is required. * no action is required.
*/ */
extern int no_action(); void no_action(void *);
/* Report core usage, if core_flag is set. */ /* Report core usage, if core_flag is set. */
extern void core_usage(void); void core_usage(void);
/* Report number of optimizations found, if /* Report number of optimizations found, if
* report_flag is set * report_flag is set
*/ */
extern void report(char* s, int n); void report(char* s, int n);

View file

@ -19,7 +19,8 @@
extern short nrglobals; extern short nrglobals;
init_globals() /* ARGSUSED */
void init_globals(void *vp)
{ {
/* Assign a 'global variable number (o_globnr) to /* Assign a 'global variable number (o_globnr) to
* every global variable for which we want to * every global variable for which we want to

View file

@ -10,6 +10,6 @@
* *
*/ */
extern init_globals(); /* Assign a 'global variable number (o_globnr) void init_globals(void *null); /* Assign a 'global variable number (o_globnr)
* to every global variable. * to every global variable.
*/ */

View file

@ -29,12 +29,8 @@ short nrglobals;
short nrlocals; short nrlocals;
local_p *locals; /* dynamic array */ local_p *locals; /* dynamic array */
STATIC void localvar(off,size,locs,reg,score) STATIC void localvar(offset off, short size, local_p *locs, bool reg,
offset off; offset score)
short size;
local_p *locs;
bool reg;
offset score;
{ {
/* process a reference to a local variable. /* process a reference to a local variable.
* A local is characterized by a (offset,size) pair. * A local is characterized by a (offset,size) pair.
@ -72,9 +68,7 @@ STATIC void localvar(off,size,locs,reg,score)
STATIC check_message(l,locs) STATIC check_message(line_p l, local_p *locs)
line_p l;
local_p *locs;
{ {
/* See if l is a register message */ /* See if l is a register message */
@ -90,9 +84,7 @@ STATIC check_message(l,locs)
STATIC void check_local_use(l,locs) STATIC void check_local_use(line_p l, local_p *locs)
line_p l;
local_p *locs;
{ {
short sz; short sz;
@ -126,8 +118,7 @@ STATIC void check_local_use(l,locs)
} }
make_localtab(p) void make_localtab(proc_p p)
proc_p p;
{ {
/* Make a table of local variables. /* Make a table of local variables.
* This table is used to associate a * This table is used to associate a
@ -186,10 +177,7 @@ make_localtab(p)
void find_local(off,nr_out,found_out) void find_local(offset off, short *nr_out, bool *found_out)
offset off;
short *nr_out;
bool *found_out;
{ {
/* Try to find the local variable at the given /* Try to find the local variable at the given
* offset. Return its local-number. * offset. Return its local-number.
@ -211,10 +199,7 @@ void find_local(off,nr_out,found_out)
void var_nr(l,nr_out,found_out) void var_nr(line_p l, short *nr_out, bool *found_out)
line_p l;
short *nr_out;
bool *found_out;
{ {
/* Determine the number of the variable referenced /* Determine the number of the variable referenced
* by EM instruction l. * by EM instruction l.

View file

@ -11,17 +11,19 @@
extern local_p *locals; /* table of locals, index is local-number */ extern local_p *locals; /* table of locals, index is local-number */
extern short nrlocals; /* number of locals for which we keep ud-info */ extern short nrlocals; /* number of locals for which we keep ud-info */
extern make_localtab(); /* (proc_p p) void make_localtab(proc_p p); /*
* Analyse the text of procedure p to determine * Analyse the text of procedure p to determine
* which local variable p has. Make a table of * which local variable p has. Make a table of
* these variables ('locals') and count them * these variables ('locals') and count them
* ('nrlocals'). Also collect register messages. * ('nrlocals'). Also collect register messages.
*/ */
extern void var_nr(); /* (line_p l; short *nr_out;bool *found_out) void var_nr(line_p l, short *nr_out, bool *found_out);
/*
* Compute the 'variable number' of the * Compute the 'variable number' of the
* variable referenced by EM instruction l. * variable referenced by EM instruction l.
*/ */
extern void find_local(); /* (offset off; short *nr_out; bool *found_out) void find_local(offset off, short *nr_out, bool *found_out);
/*
* Try to find the local variable at the given * Try to find the local variable at the given
* offset. Return its local-number. * offset. Return its local-number.
*/ */

View file

@ -30,15 +30,13 @@
*/ */
lset Lempty_set() lset Lempty_set(void)
{ {
return ((lset) 0); return ((lset) 0);
} }
bool Lis_elem(x,s) bool Lis_elem(Lelem_t x, lset s)
register Lelem_t x;
register lset s;
{ {
/* Search the list to see if x is an element of s */ /* Search the list to see if x is an element of s */
@ -52,9 +50,7 @@ bool Lis_elem(x,s)
} }
Ladd(x,s_p) void Ladd(Lelem_t x, lset *s_p)
Lelem_t x;
lset *s_p;
{ {
/* add x to a set. Note that the set is given as in-out /* add x to a set. Note that the set is given as in-out
* parameter, because it may be changed. * parameter, because it may be changed.
@ -71,9 +67,7 @@ Ladd(x,s_p)
} }
Lremove(x,s_p) void Lremove(Lelem_t x, lset *s_p)
Lelem_t x;
lset *s_p;
{ {
/* Remove x from a set. If x was not an element of /* Remove x from a set. If x was not an element of
* the set, nothing happens. * the set, nothing happens.
@ -109,8 +103,7 @@ Lremove(x,s_p)
*/ */
Lindex Lfirst(s) Lindex Lfirst(lset s)
lset s;
{ {
return ((Lindex) s); return ((Lindex) s);
/* Note that an index for long sets is just /* Note that an index for long sets is just
@ -120,25 +113,21 @@ Lindex Lfirst(s)
/*ARGSUSED1*/ /*ARGSUSED1*/
Lindex Lnext(i,s) Lindex Lnext(Lindex i, lset s)
Lindex i;
lset s;
{ {
assert(i != (Lindex) 0); assert(i != (Lindex) 0);
return (i->e_next); return (i->e_next);
} }
Lelem_t Lelem(i) Lelem_t Lelem(Lindex i)
Lindex i;
{ {
return (i->e_elem); return (i->e_elem);
} }
Ljoin(s1,s2_p) void Ljoin(lset s1, lset *s2_p)
lset s1,*s2_p;
{ {
/* Join two sets, assign the result to the second set /* Join two sets, assign the result to the second set
* and delete the first set (i.e. the value of the * and delete the first set (i.e. the value of the
@ -173,8 +162,7 @@ Ljoin(s1,s2_p)
} }
Ldeleteset(s) void Ldeleteset(lset s)
lset s;
{ {
register elem_p ep, next; register elem_p ep, next;
@ -185,8 +173,7 @@ Ldeleteset(s)
} }
bool Lis_subset(s1,s2) bool Lis_subset(lset s1, lset s2)
lset s1,s2;
{ {
/* See if s1 is a subset of s2 */ /* See if s1 is a subset of s2 */
@ -199,8 +186,7 @@ bool Lis_subset(s1,s2)
} }
short Lnrelems(s) short Lnrelems(lset s)
lset s;
{ {
/* Compute the number of elements of a set */ /* Compute the number of elements of a set */

View file

@ -8,14 +8,14 @@
*/ */
extern lset Lempty_set(); /* () */ lset Lempty_set(void);
extern bool Lis_elem(); /* (Lelem_t, lset) */ bool Lis_elem(Lelem_t, lset);
extern Ladd(); /* (Lelem_t, *lset) */ void Ladd(Lelem_t, lset *);
extern Lremove(); /* (Lelem_t, *lset) */ void Lremove(Lelem_t, lset *);
extern Lindex Lfirst(); /* (lset) */ Lindex Lfirst(lset);
extern Lindex Lnext(); /* (Lindex, lset) */ Lindex Lnext(Lindex, lset);
extern Lelem_t Lelem(); /* (Lindex) */ Lelem_t Lelem(Lindex);
extern Ljoin(); /* (lset, *lset) */ void Ljoin(lset, lset *);
extern Ldeleteset(); /* (lset) */ void Ldeleteset(lset);
extern bool Lis_subset(); /* (lset, lset) */ bool Lis_subset(lset, lset);
extern short Lnrelems(); /* (lset) */ short Lnrelems(lset);

View file

@ -41,9 +41,7 @@ typedef struct class *class_p;
* generated automatically from the file classdefs.src. * generated automatically from the file classdefs.src.
*/ */
STATIC bool classes(instr,src_out,res_out) STATIC bool classes(int instr, int *src_out, int *res_out)
int instr;
int *src_out, *res_out;
{ {
/* Determine the classes of the given instruction */ /* Determine the classes of the given instruction */
@ -59,8 +57,7 @@ STATIC bool classes(instr,src_out,res_out)
STATIC bool uses_arg(class) STATIC bool uses_arg(int class)
int class;
{ {
/* See if a member of the given class uses /* See if a member of the given class uses
* an argument. * an argument.
@ -82,8 +79,7 @@ STATIC bool uses_arg(class)
STATIC bool uses_2args(class) STATIC bool uses_2args(int class)
int class;
{ {
/* See if a member of the given class uses /* See if a member of the given class uses
* 2 arguments. * 2 arguments.
@ -93,9 +89,7 @@ STATIC bool uses_2args(class)
} }
STATIC bool parse_locs(l,c1_out,c2_out) STATIC bool parse_locs(line_p l, offset *c1_out, offset *c2_out)
line_p l;
offset *c1_out, *c2_out;
{ {
if (INSTR(l) == op_loc && INSTR(PREV(l)) == op_loc) { if (INSTR(l) == op_loc && INSTR(PREV(l)) == op_loc) {
*c1_out = off_set(l); *c1_out = off_set(l);
@ -107,10 +101,8 @@ STATIC bool parse_locs(l,c1_out,c2_out)
STATIC bool check_args(l,src_class,res_class,arg1_out,arg2_out) STATIC bool check_args(line_p l, int src_class, int res_class,
line_p l; offset *arg1_out, offset *arg2_out)
int src_class,res_class;
offset *arg1_out, *arg2_out;
{ {
/* Several EM instructions have an argument /* Several EM instructions have an argument
* giving the size of the operand(s) of * giving the size of the operand(s) of
@ -144,9 +136,7 @@ STATIC bool check_args(l,src_class,res_class,arg1_out,arg2_out)
STATIC offset nrbytes(class,arg1,arg2) STATIC offset nrbytes(int class, offset arg1, offset arg2)
int class;
offset arg1,arg2;
{ {
/* Determine the number of bytes of the given /* Determine the number of bytes of the given
* arguments and class. * arguments and class.
@ -185,9 +175,8 @@ STATIC offset nrbytes(class,arg1,arg2)
STATIC attrib(l,expect_out,srcb_out,resb_out) STATIC void attrib(line_p l, offset *expect_out, offset *srcb_out,
line_p l; offset *resb_out)
offset *expect_out, *srcb_out, *resb_out;
{ {
/* Determine a number of attributes of an EM /* Determine a number of attributes of an EM
* instruction appearing in an expression. * instruction appearing in an expression.
@ -215,11 +204,8 @@ STATIC attrib(l,expect_out,srcb_out,resb_out)
bool parse(l,nbytes,l_out,level,action0) bool parse(line_p l, offset nbytes, line_p *l_out, int level,
line_p l, *l_out; void (*action0)(line_p, line_p, offset))
offset nbytes;
int level;
int (*action0) ();
{ {
/* This is a recursive descent parser for /* This is a recursive descent parser for
* EM expressions. * EM expressions.

View file

@ -3,8 +3,9 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
bool parse(); /* (line_p l, *l_out; offset nbytes; bool parse(line_p l, offset nbytes, line_p *l_out, int level,
* int level; int (*action0) ()) void (*action0)(line_p l1, line_p l2, offset size));
/*
* This is a recursive descent parser for * This is a recursive descent parser for
* EM expressions. * EM expressions.
* It tries to recognize EM code that loads exactly * It tries to recognize EM code that loads exactly

View file

@ -15,6 +15,7 @@
#include "def.h" #include "def.h"
#include "map.h" #include "map.h"
#include "lset.h" #include "lset.h"
#include "cset.h"
#include "alloc.h" #include "alloc.h"
#include "put.h" #include "put.h"
@ -31,12 +32,11 @@ FILE *curoutp;
/* putlines */ /* putlines */
STATIC putstr(); STATIC void putstr(argb_p);
STATIC outlab(); STATIC void outlab(lab_id);
STATIC outobject(); STATIC void outobject(obj_p);
STATIC putargs(ap) STATIC void putargs(arg_p ap)
register arg_p ap;
{ {
while (ap != (arg_p) 0) { while (ap != (arg_p) 0) {
outbyte((byte) ap->a_type & BMASK); outbyte((byte) ap->a_type & BMASK);
@ -70,9 +70,9 @@ STATIC putargs(ap)
STATIC putstr(abp) register argb_p abp; { STATIC void putstr(argb_p abp) {
register argb_p tbp; argb_p tbp;
register length; int length;
length = 0; length = 0;
tbp = abp; tbp = abp;
@ -89,22 +89,21 @@ STATIC putstr(abp) register argb_p abp; {
} }
outoff(off) offset off; { void outoff(offset off) {
outshort( (short) (off&0177777L) ); outshort( (short) (off&0177777L) );
outshort( (short) (off>>16) ); outshort( (short) (off>>16) );
} }
outshort(i) short i; { void outshort(short i) {
outbyte( (byte) (i&BMASK) ); outbyte( (byte) (i&BMASK) );
outbyte( (byte) (i>>8) ); outbyte( (byte) (i>>8) );
} }
STATIC outint(i) STATIC void outint(int i)
int i;
{ {
/* Write an integer to the output file. This routine is /* Write an integer to the output file. This routine is
* only used when outputting a bitvector-set. We expect an * only used when outputting a bitvector-set. We expect an
@ -119,24 +118,22 @@ STATIC outint(i)
} }
} }
STATIC outlab(lid) lab_id lid; { STATIC void outlab(lab_id lid) {
outshort((short) lid); outshort((short) lid);
} }
STATIC outobject(obj) obj_p obj; { STATIC void outobject(obj_p obj) {
outshort((short) obj->o_id); outshort((short) obj->o_id);
} }
outproc(p) proc_p p; { void outproc(proc_p p) {
outshort((short) p->p_id); outshort((short) p->p_id);
} }
short putlines(l,lf) short putlines(line_p l, FILE *lf)
line_p l;
FILE *lf;
{ {
/* Output the list of em instructions headed by l. /* Output the list of em instructions headed by l.
* Return the number of instruction written. * Return the number of instruction written.
@ -189,8 +186,7 @@ short putlines(l,lf)
#define outmark(m) outbyte((byte) m) #define outmark(m) outbyte((byte) m)
STATIC putobjects(obj) STATIC void putobjects(obj_p obj)
register obj_p obj;
{ {
while (obj != (obj_p) 0) { while (obj != (obj_p) 0) {
outmark(MARK_OBJ); outmark(MARK_OBJ);
@ -203,8 +199,7 @@ STATIC putobjects(obj)
STATIC putvalues(arg) STATIC void putvalues(arg_p arg)
register arg_p arg;
{ {
while (arg != (arg_p) 0) { while (arg != (arg_p) 0) {
assert(arg->a_type == ARGOFF); assert(arg->a_type == ARGOFF);
@ -213,9 +208,7 @@ STATIC putvalues(arg)
arg = arg->a_next; arg = arg->a_next;
} }
} }
putdtable(head,df) void putdtable(dblock_p head, FILE *df)
dblock_p head;
FILE *df;
{ {
/* Write the datablock table to the data block file df. */ /* Write the datablock table to the data block file df. */
@ -257,8 +250,7 @@ putdtable(head,df)
STATIC outcset(s) STATIC void outcset(cset s)
cset s;
{ {
/* A 'compact' set is represented externally as a row of words /* A 'compact' set is represented externally as a row of words
* (its bitvector) preceded by its length. * (its bitvector) preceded by its length.
@ -274,10 +266,7 @@ STATIC outcset(s)
putptable(head,pf,all) void putptable(proc_p head, FILE *pf, bool all)
proc_p head;
FILE *pf;
bool all;
{ {
register proc_p p; register proc_p p;
proc_p next; proc_p next;
@ -328,16 +317,18 @@ putptable(head,pf,all)
/* putunit */ /* putunit */
STATIC outloop(l) STATIC void outloop(void *vp)
loop_p l;
{ {
loop_p l = vp;
outshort((short) l->lp_id); outshort((short) l->lp_id);
} }
STATIC outblock(b) STATIC void outblock(void *vp)
bblock_p b;
{ {
bblock_p b = vp;
if (b == (bblock_p) 0) { if (b == (bblock_p) 0) {
outshort((short) 0); outshort((short) 0);
} else { } else {
@ -346,20 +337,7 @@ STATIC outblock(b)
} }
STATIC outid(e,p) STATIC void outlset(lset s, void (*p)(void *))
Lelem_t e;
int (*p) ();
{
/* Auxiliary routine used by outlset. */
/* NOSTRICT */
(*p) (e);
}
STATIC outlset(s,p)
lset s;
int (*p) ();
{ {
/* A 'long' set is represented externally as a /* A 'long' set is represented externally as a
* a sequence of elements terminated by a 0 word. * a sequence of elements terminated by a 0 word.
@ -370,19 +348,14 @@ STATIC outlset(s,p)
register Lindex i; register Lindex i;
for (i = Lfirst(s); i != (Lindex) 0; i = Lnext(i,s)) { for (i = Lfirst(s); i != (Lindex) 0; i = Lnext(i,s)) {
outid(Lelem(i),p); (*p)(Lelem(i));
} }
outshort((short) 0); outshort((short) 0);
} }
void void putunit(short kind, proc_p p, line_p l, FILE *gf, FILE *lf)
putunit(kind,p,l,gf,lf)
short kind;
proc_p p;
line_p l;
FILE *gf, *lf;
{ {
register bblock_p b; register bblock_p b;
register short n = 0; register short n = 0;

View file

@ -9,27 +9,29 @@
extern FILE *curoutp; /* current output file */ extern FILE *curoutp; /* current output file */
#define outbyte(b) putc(b,curoutp) #define outbyte(b) putc(b,curoutp)
extern outshort(); /* (short i) void outshort(short i); /*
* Write a short to curoutp * Write a short to curoutp
*/ */
extern outoff(); /* (offset off) void outoff(offset off); /*
* Write an offset to curoutp * Write an offset to curoutp
*/ */
extern outproc(); /* (proc_p p) void outproc(proc_p p); /*
* Write a procid to curoutp * Write a procid to curoutp
*/ */
extern putdtable(); /* (dblock_p head, FILE *df) void putdtable(dblock_p head, FILE *df);
/*
* Write the data block table to file df, * Write the data block table to file df,
* preceded by its length. * preceded by its length.
*/ */
extern putptable(); /* (proc_p head, FILE *pf, bool all) void putptable(proc_p head, FILE *pf, bool all);
/*
* Write the proc table to file pf, * Write the proc table to file pf,
* preceded by its length. If all=false, * preceded by its length. If all=false,
* the fields computed by CF will not be * the fields computed by CF will not be
* written (used by the IC phase). * written (used by the IC phase).
*/ */
extern void putunit(); /* (short kind; proc_p p; line_p l; void putunit(short kind, proc_p p, line_p l, FILE *gf, FILE *lf);
* FILE *gf, *lf) /*
* If kind = LTEXT, then write * If kind = LTEXT, then write
* the control flow graph to file gf, * the control flow graph to file gf,
* preceded by its length (#basic blocks); * preceded by its length (#basic blocks);
@ -40,7 +42,8 @@ extern void putunit(); /* (short kind; proc_p p; line_p l;
* list of instructions (data declarations) * list of instructions (data declarations)
* to lf. * to lf.
*/ */
extern short putlines(); /* (line_p l; FILE *lf) short putlines(line_p l, FILE *lf);
/*
* Output the list of em instructions * Output the list of em instructions
* headed by l. Return the number of * headed by l. Return the number of
* instructions written. * instructions written.

View file

@ -17,9 +17,7 @@
#define IS_LOC(l) (l!=(line_p) 0 && INSTR(l)==op_loc && TYPE(l)==OPSHORT) #define IS_LOC(l) (l!=(line_p) 0 && INSTR(l)==op_loc && TYPE(l)==OPSHORT)
int stack_change(l,sign) STATIC int stack_change(line_p l, char sign)
line_p l;
char sign;
{ {
/* Interpret the string in the third column of the em_table file */ /* Interpret the string in the third column of the em_table file */
@ -91,10 +89,7 @@ int stack_change(l,sign)
line_change(l,ok_out,pop_out,push_out) void line_change(line_p l, bool *ok_out, int *pop_out, int *push_out)
line_p l;
bool *ok_out;
int *pop_out,*push_out;
{ {
short pop,push; short pop,push;

View file

@ -6,7 +6,8 @@
/* S T A C K _ C H A N G E . H */ /* S T A C K _ C H A N G E . H */
extern line_change(); /* ( line_p l; bool *ok_out; int *pop_out,*push_out) void line_change(line_p l, bool *ok_out, int *pop_out, int *push_out);
/*
* Try to determine how the stack-height will be * Try to determine how the stack-height will be
* affected by the EM instruction l. 'ok_out' is set * affected by the EM instruction l. 'ok_out' is set
* to false if we fail to do so. pop_out and * to false if we fail to do so. pop_out and

View file

@ -52,10 +52,10 @@ STATIC int globl_sp_allowed;
#define IS_ASP(l) (INSTR(l) == op_asp && TYPE(l) == OPSHORT && SHORT(l) > 0) #define IS_ASP(l) (INSTR(l) == op_asp && TYPE(l) == OPSHORT && SHORT(l) > 0)
STATIC sp_machinit(f) STATIC void sp_machinit(void *vp)
FILE *f;
{ {
/* Read target machine dependent information for this phase */ /* Read target machine dependent information for this phase */
FILE *f = vp;
char s[100]; char s[100];
for (;;) { for (;;) {
@ -194,10 +194,9 @@ STATIC mark_unsave_blocks(p)
} }
void void sp_optimize(void *vp)
sp_optimize(p)
proc_p p;
{ {
proc_p p = vp;
register bblock_p b; register bblock_p b;
if (IS_ENTERED_WITH_GTO(p)) return; if (IS_ENTERED_WITH_GTO(p)) return;

View file

@ -52,10 +52,10 @@ int sli_threshold;
int Ssr; /* #optimizations found */ int Ssr; /* #optimizations found */
sr_machinit(f) void sr_machinit(void *vp)
FILE *f;
{ {
/* Read target machine dependent information */ /* Read target machine dependent information */
FILE *f = vp;
char s[100]; char s[100];
@ -219,10 +219,10 @@ STATIC sr_cleanproc(p)
} }
void void sr_optimize(void *vp)
sr_optimize(p)
proc_p p;
{ {
proc_p p = vp;
if (IS_ENTERED_WITH_GTO(p)) return; if (IS_ENTERED_WITH_GTO(p)) return;
sr_extproc(p); sr_extproc(p);
loopblocks(p); loopblocks(p);

View file

@ -57,9 +57,9 @@ STATIC cond_p getcondtab(f)
} }
STATIC ud_machinit(f) STATIC void ud_machinit(void *vp)
FILE *f;
{ {
FILE *f = vp;
char s[100]; char s[100];
for (;;) { for (;;) {
@ -532,10 +532,10 @@ STATIC ud_cleanup(p)
} }
void void ud_optimize(void *vp)
ud_optimize(p)
proc_p p;
{ {
proc_p p = vp;
if (IS_ENTERED_WITH_GTO(p)) return; if (IS_ENTERED_WITH_GTO(p)) return;
ud_extend(p); ud_extend(p);
locals = (local_p *) 0; locals = (local_p *) 0;