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:
parent
5bbbaf4919
commit
9037d137f5
|
@ -304,10 +304,9 @@ STATIC bo_cleanproc(p)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
bo_optimize(p)
|
||||
proc_p p;
|
||||
void bo_optimize(void *vp)
|
||||
{
|
||||
proc_p p = vp;
|
||||
bblock_p b;
|
||||
|
||||
if (IS_ENTERED_WITH_GTO(p)) return;
|
||||
|
|
|
@ -289,9 +289,7 @@ STATIC bool try_pred(b)
|
|||
|
||||
|
||||
|
||||
void
|
||||
cj_optimize(p)
|
||||
proc_p p;
|
||||
void cj_optimize(void *vp)
|
||||
{
|
||||
/* Perform cross jumping for procedure p.
|
||||
* In case cases a cross-jumping optimization which give
|
||||
|
@ -300,6 +298,7 @@ cj_optimize(p)
|
|||
* untill we find no further optimizations.
|
||||
*/
|
||||
|
||||
proc_p p = vp;
|
||||
bblock_p b;
|
||||
bool changes = TRUE;
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ STATIC cs_clear()
|
|||
start_valnum();
|
||||
}
|
||||
|
||||
STATIC void cs_optimize(p)
|
||||
proc_p p;
|
||||
STATIC void cs_optimize(void *vp)
|
||||
{
|
||||
/* Optimize all basic blocks of one procedure. */
|
||||
|
||||
proc_p p = vp;
|
||||
register bblock_p rbp, bdone;
|
||||
|
||||
if (IS_ENTERED_WITH_GTO(p)) return;
|
||||
|
|
|
@ -191,7 +191,7 @@ STATIC set_replace(avp, tmp)
|
|||
register lset s = avp->av_occurs;
|
||||
|
||||
for (i = Lfirst(s); i != (Lindex) 0; i = Lnext(i, s)) {
|
||||
OUTVERBOSE("eliminate duplicate", 0);
|
||||
OUTVERBOSE("eliminate duplicate", 0, 0);
|
||||
SHOWOCCUR(occ_elem(i));
|
||||
Scs++;
|
||||
delete(occ_elem(i), avp->av_before);
|
||||
|
@ -275,7 +275,7 @@ eliminate(pp)
|
|||
if (ravp->av_saveloc != (entity_p) 0) {
|
||||
tmp = ravp->av_saveloc->en_loc;
|
||||
mes = find_mesreg(tmp);
|
||||
OUTVERBOSE("re-using %ld(LB)", tmp);
|
||||
OUTVERBOSE("re-using %ld(LB)", tmp, 0);
|
||||
} else {
|
||||
tmp = tmplocal(pp, ravp->av_size);
|
||||
mes = gen_mesreg(tmp, ravp, pp);
|
||||
|
|
|
@ -65,9 +65,9 @@ STATIC choose_cset(f, s_p, max)
|
|||
Cdeleteset(cs1); Cdeleteset(cs2);
|
||||
}
|
||||
|
||||
cs_machinit(f)
|
||||
FILE *f;
|
||||
void cs_machinit(void *vp)
|
||||
{
|
||||
FILE *f = vp;
|
||||
char s[100];
|
||||
int time, space;
|
||||
|
||||
|
@ -194,8 +194,7 @@ STATIC bool okay_lines(avp, ocp)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
bool desirable(avp)
|
||||
avail_p avp;
|
||||
bool desirable(avail_p avp)
|
||||
{
|
||||
register Lindex i, next;
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
extern bool desirable(); /* (avail_p avp)
|
||||
bool desirable(avail_p avp); /*
|
||||
* Return whether it is desirable to eliminate
|
||||
* the recurrences of the expression in avp.
|
||||
* At the same time delete the recurrences
|
||||
|
|
|
@ -299,8 +299,10 @@ Sdiagnostics()
|
|||
}
|
||||
#endif
|
||||
|
||||
il_flags(p) char* p;
|
||||
void il_flags(void *vp)
|
||||
{
|
||||
char *p = vp;
|
||||
|
||||
switch (*p++)
|
||||
{
|
||||
case 's':
|
||||
|
|
|
@ -26,9 +26,7 @@ STATIC actual_p acts, *app;
|
|||
#define INIT_ACTS() {acts = (actual_p) 0; app = &acts;}
|
||||
#define APPEND_ACTUAL(a) {*app = a; app = &a->ac_next;}
|
||||
|
||||
STATIC make_actual(l1,l2,size)
|
||||
line_p l1,l2;
|
||||
offset size;
|
||||
STATIC void make_actual(line_p l1, line_p l2, offset size)
|
||||
{
|
||||
/* Allocate a struct for a new actual parameter
|
||||
* expression, the code of which extends from
|
||||
|
|
|
@ -326,7 +326,7 @@ STATIC bool is_dispensable(callee,ccf)
|
|||
(complete_program || (callee->p_flags1 & PF_EXTERNAL) == 0) &&
|
||||
(callee->p_flags1 & PF_LPI) == 0) {
|
||||
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
|
||||
Spremoved++;
|
||||
#endif
|
||||
|
@ -475,7 +475,7 @@ STATIC singles(cals)
|
|||
DISPENSABLE(c->cl_proc);
|
||||
CHANGED(c->cl_caller);
|
||||
OUTVERBOSE("singles: procedure %d can be removed",
|
||||
c->cl_proc->p_id);
|
||||
c->cl_proc->p_id, 0);
|
||||
#ifdef VERBOSE
|
||||
Spremoved++;
|
||||
#endif
|
||||
|
|
|
@ -222,7 +222,7 @@ call_p getcall(cf)
|
|||
m = getshort();
|
||||
act->ac_size = getoff();
|
||||
act->ac_inl = getbyte();
|
||||
act->ac_exp = getlines(cf,m,&voided);
|
||||
act->ac_exp = getlines(cf,m,&voided,FALSE);
|
||||
*app = act;
|
||||
app = &act->ac_next;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
line_p l1,l2;
|
||||
|
@ -580,9 +582,10 @@ STATIC lv_cleanup(p)
|
|||
}
|
||||
}
|
||||
|
||||
lv_flags(p)
|
||||
char *p;
|
||||
void lv_flags(void *vp)
|
||||
{
|
||||
char *p = vp;
|
||||
|
||||
switch(*p) {
|
||||
case 'N':
|
||||
mesgflag = TRUE;
|
||||
|
@ -591,10 +594,10 @@ lv_flags(p)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
lv_optimize(p)
|
||||
proc_p p;
|
||||
void lv_optimize(void *vp)
|
||||
{
|
||||
proc_p p = vp;
|
||||
|
||||
if (IS_ENTERED_WITH_GTO(p)) return;
|
||||
locals = (local_p *) 0;
|
||||
lv_extend(p);
|
||||
|
|
|
@ -104,10 +104,10 @@ get_otab(f,tab)
|
|||
|
||||
|
||||
|
||||
STATIC ra_machinit(f)
|
||||
FILE *f;
|
||||
STATIC void ra_machinit(void *vp)
|
||||
{
|
||||
/* Read target machine dependent information for this phase */
|
||||
FILE *f = vp;
|
||||
char s[100];
|
||||
|
||||
for (;;) {
|
||||
|
@ -344,16 +344,16 @@ STATIC cleanitems(list)
|
|||
}
|
||||
|
||||
|
||||
ra_initialize()
|
||||
/* ARGSUSED */
|
||||
void ra_initialize(void *null)
|
||||
{
|
||||
init_replacements(ps,ws);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ra_optimize(p)
|
||||
proc_p p;
|
||||
void ra_optimize(void *vp)
|
||||
{
|
||||
proc_p p = vp;
|
||||
item_p itemlist;
|
||||
alloc_p alloclist,packed,unpacked;
|
||||
offset locls;
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
#include "map.h"
|
||||
#include "lset.h"
|
||||
|
||||
offset off_set(lnp)
|
||||
line_p lnp;
|
||||
offset off_set(line_p lnp)
|
||||
{
|
||||
switch(lnp->l_optype) {
|
||||
case OPSHORT:
|
||||
|
@ -36,8 +35,7 @@ offset off_set(lnp)
|
|||
|
||||
|
||||
|
||||
offset aoff(ap,n)
|
||||
register arg_p ap;
|
||||
offset aoff(arg_p ap, int n)
|
||||
{
|
||||
while (n>0) {
|
||||
if (ap != (arg_p) 0)
|
||||
|
@ -52,9 +50,7 @@ offset aoff(ap,n)
|
|||
}
|
||||
|
||||
|
||||
offset tmplocal(p,size)
|
||||
proc_p p;
|
||||
offset size;
|
||||
offset tmplocal(proc_p p, offset size)
|
||||
{
|
||||
/* Allocate a new local variable in the stack frame of p */
|
||||
|
||||
|
@ -65,8 +61,7 @@ offset tmplocal(p,size)
|
|||
|
||||
|
||||
|
||||
line_p int_line(off)
|
||||
offset off;
|
||||
line_p int_line(offset off)
|
||||
{
|
||||
/* Allocate a line struct of type OPSHORT or OPOFFSET,
|
||||
* whichever one fits best.
|
||||
|
@ -87,10 +82,7 @@ line_p int_line(off)
|
|||
|
||||
|
||||
|
||||
line_p reg_mes(tmp,size,typ,score)
|
||||
offset tmp;
|
||||
short size;
|
||||
int typ,score;
|
||||
line_p reg_mes(offset tmp, short size, int typ, int score)
|
||||
{
|
||||
/* Generate a register message */
|
||||
|
||||
|
@ -111,8 +103,7 @@ line_p reg_mes(tmp,size,typ,score)
|
|||
}
|
||||
|
||||
|
||||
bool dom(b1,b2)
|
||||
bblock_p b1,b2;
|
||||
bool dom(bblock_p b1, bblock_p b2)
|
||||
{
|
||||
/* See if b1 dominates b2. Note that a block always
|
||||
* dominates itself.
|
||||
|
@ -130,8 +121,7 @@ bool dom(b1,b2)
|
|||
}
|
||||
|
||||
|
||||
bblock_p common_dom(a,b)
|
||||
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 dominates itself.
|
||||
|
@ -152,8 +142,7 @@ bblock_p common_dom(a,b)
|
|||
|
||||
#define R time_space_ratio
|
||||
|
||||
short add_timespace(time,space)
|
||||
short time,space;
|
||||
short add_timespace(short time, short space)
|
||||
{
|
||||
/* Add together a time and space, using the time_space_ratio
|
||||
* parameter that may be set by the user, indicating the need
|
||||
|
@ -165,9 +154,7 @@ short add_timespace(time,space)
|
|||
|
||||
|
||||
|
||||
rm_line(l,b)
|
||||
line_p l;
|
||||
bblock_p b;
|
||||
void rm_line(line_p l, bblock_p b)
|
||||
{
|
||||
if (b->b_start == l) {
|
||||
b->b_start = l->l_next;
|
||||
|
@ -183,8 +170,7 @@ rm_line(l,b)
|
|||
|
||||
|
||||
|
||||
appnd_line(l1,l2)
|
||||
line_p l1,l2;
|
||||
void appnd_line(line_p l1, line_p l2)
|
||||
{
|
||||
/* Put l1 after l2 */
|
||||
|
||||
|
@ -198,8 +184,7 @@ appnd_line(l1,l2)
|
|||
|
||||
|
||||
|
||||
line_p last_instr(b)
|
||||
bblock_p b;
|
||||
line_p last_instr(bblock_p b)
|
||||
{
|
||||
/* Determine the last line of a list */
|
||||
|
||||
|
@ -213,8 +198,7 @@ line_p last_instr(b)
|
|||
|
||||
|
||||
|
||||
line_p find_mesreg(off)
|
||||
offset off;
|
||||
line_p find_mesreg(offset off)
|
||||
{
|
||||
/* Find the register message for the local with the given offset */
|
||||
|
||||
|
@ -229,17 +213,14 @@ line_p find_mesreg(off)
|
|||
}
|
||||
|
||||
|
||||
bool is_regvar(off)
|
||||
offset off;
|
||||
bool is_regvar(offset off)
|
||||
{
|
||||
return find_mesreg(off) != (line_p) 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
offset regv_arg(off,n)
|
||||
offset off;
|
||||
int n;
|
||||
offset regv_arg(offset off, int n)
|
||||
{
|
||||
/* fetch the n'th argument of the register message of the
|
||||
* local variable at offset off;
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* n'th argument in the list (this argument
|
||||
* 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
|
||||
* stack frame of p.
|
||||
*/
|
||||
line_p int_line(); /* (offset off)
|
||||
line_p int_line(offset off); /*
|
||||
* Allocate a line struct of type OPSHORT
|
||||
* 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
|
||||
* given arguments.
|
||||
*/
|
||||
extern bool dom(); /* (bblock_p b1,b2)
|
||||
/* See if b1 dominates b2. Note that a
|
||||
bool dom(bblock_p b1, bblock_p b2);
|
||||
/*
|
||||
* See if b1 dominates b2. Note that a
|
||||
* block always * dominates itself.
|
||||
*/
|
||||
extern bblock_p common_dom(); /* (bblock_p a,b)
|
||||
* find a basic block that dominates a as
|
||||
* well as b; note that a basic block also
|
||||
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
|
||||
* dominates itself.
|
||||
*/
|
||||
extern short add_timespace(); /* (short time,space)
|
||||
* Add together a time and space, using
|
||||
* the time_space_ratio parameter that
|
||||
short add_timespace(short time, short space);
|
||||
/*
|
||||
* Add together a time and space, using
|
||||
* the time_space_ratio parameter that
|
||||
* 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.
|
||||
*/
|
||||
|
||||
extern appnd_line(); /* ( line_p l1,l2)
|
||||
void appnd_line(line_p l1, line_p 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.
|
||||
*/
|
||||
extern line_p find_mesreg(); /* (offset off)
|
||||
* Find the register message for the local
|
||||
line_p find_mesreg(offset off); /*
|
||||
* Find the register message for the local
|
||||
* with the given offset.
|
||||
*/
|
||||
extern bool is_regvar(); /* (offset off)
|
||||
bool is_regvar(offset off); /*
|
||||
* See if there is a 'register message'
|
||||
* for the local variable with the
|
||||
* given offset.
|
||||
*/
|
||||
extern offset regv_arg(); /* (offset off; int n)
|
||||
offset regv_arg(offset off, int n);
|
||||
/*
|
||||
* Fetch the n'th argument of the
|
||||
* register message of the local with
|
||||
* the given offset.
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
|
||||
|
||||
|
||||
cset Cempty_set(n)
|
||||
short n;
|
||||
cset Cempty_set(short n)
|
||||
{
|
||||
cset s;
|
||||
|
||||
|
@ -48,9 +47,7 @@ cset Cempty_set(n)
|
|||
}
|
||||
|
||||
|
||||
bool Cis_elem(x,s)
|
||||
Celem_t x;
|
||||
cset s;
|
||||
bool Cis_elem(Celem_t x, cset s)
|
||||
{
|
||||
short n;
|
||||
int mask;
|
||||
|
@ -67,9 +64,7 @@ bool Cis_elem(x,s)
|
|||
|
||||
|
||||
|
||||
Cadd(x,s_p)
|
||||
Celem_t x;
|
||||
cset *s_p;
|
||||
void Cadd(Celem_t x, cset *s_p)
|
||||
{
|
||||
cset s;
|
||||
short n;
|
||||
|
@ -83,9 +78,7 @@ Cadd(x,s_p)
|
|||
}
|
||||
|
||||
|
||||
Cremove(x,s_p)
|
||||
Celem_t x;
|
||||
cset *s_p;
|
||||
void Cremove(Celem_t x, cset *s_p)
|
||||
{
|
||||
cset s;
|
||||
short n;
|
||||
|
@ -117,16 +110,13 @@ Cremove(x,s_p)
|
|||
* be used very often.
|
||||
*/
|
||||
|
||||
Cindex Cfirst(s)
|
||||
cset s;
|
||||
Cindex Cfirst(cset s)
|
||||
{
|
||||
return Cnext((Cindex) 0,s);
|
||||
}
|
||||
|
||||
|
||||
Cindex Cnext(i,s)
|
||||
Cindex i;
|
||||
cset s;
|
||||
Cindex Cnext(Cindex i, cset s)
|
||||
{
|
||||
register short n;
|
||||
|
||||
|
@ -139,16 +129,14 @@ Cindex Cnext(i,s)
|
|||
}
|
||||
|
||||
|
||||
Celem_t Celem(i)
|
||||
Cindex i;
|
||||
Celem_t Celem(Cindex i)
|
||||
{
|
||||
return (Celem_t) i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Cjoin(s1,s2_p)
|
||||
cset s1, *s2_p;
|
||||
void Cjoin(cset s1, cset *s2_p)
|
||||
{
|
||||
/* Two sets are joined by or-ing their bitvectors,
|
||||
* word by word.
|
||||
|
@ -168,8 +156,7 @@ Cjoin(s1,s2_p)
|
|||
|
||||
|
||||
|
||||
Cintersect(s1,s2_p)
|
||||
cset s1, *s2_p;
|
||||
void Cintersect(cset s1, cset *s2_p)
|
||||
{
|
||||
/* Two sets are intersected by and-ing their bitvectors,
|
||||
* word by word.
|
||||
|
@ -188,15 +175,13 @@ Cintersect(s1,s2_p)
|
|||
}
|
||||
|
||||
|
||||
Cdeleteset(s)
|
||||
cset s;
|
||||
void Cdeleteset(cset s)
|
||||
{
|
||||
oldbitvect(s,DIVWL(s->v_size - 1) + 1);
|
||||
}
|
||||
|
||||
|
||||
bool Cis_subset(s1,s2)
|
||||
cset s1,s2;
|
||||
bool Cis_subset(cset s1, cset s2)
|
||||
{
|
||||
/* See if s1 is a subset of s2 */
|
||||
|
||||
|
@ -213,8 +198,7 @@ bool Cis_subset(s1,s2)
|
|||
}
|
||||
|
||||
|
||||
Cclear_set(s_p)
|
||||
cset *s_p;
|
||||
void Cclear_set(cset *s_p)
|
||||
{
|
||||
cset s;
|
||||
register short i;
|
||||
|
@ -227,8 +211,7 @@ Cclear_set(s_p)
|
|||
}
|
||||
|
||||
|
||||
Ccopy_set(s1,s2_p)
|
||||
cset s1, *s2_p;
|
||||
void Ccopy_set(cset s1, cset *s2_p)
|
||||
{
|
||||
cset s2;
|
||||
register short i;
|
||||
|
@ -241,8 +224,7 @@ Ccopy_set(s1,s2_p)
|
|||
}
|
||||
|
||||
|
||||
Csubtract(s1,s2_p)
|
||||
cset s1, *s2_p;
|
||||
void Csubtract(cset s1, cset *s2_p)
|
||||
{
|
||||
cset s2;
|
||||
register short i;
|
||||
|
@ -255,8 +237,7 @@ Csubtract(s1,s2_p)
|
|||
}
|
||||
|
||||
|
||||
bool Cequal(s1,s2)
|
||||
cset s1, s2;
|
||||
bool Cequal(cset s1, cset s2)
|
||||
{
|
||||
register short i;
|
||||
|
||||
|
@ -267,8 +248,7 @@ bool Cequal(s1,s2)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
short Cnrelems(s)
|
||||
cset s;
|
||||
short Cnrelems(cset s)
|
||||
{
|
||||
register short n, cnt;
|
||||
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
*/
|
||||
|
||||
|
||||
extern cset Cempty_set(); /* (short) */
|
||||
extern bool Cis_elem(); /* (Celem, cset) */
|
||||
extern Cadd(); /* (Celem, *cset) */
|
||||
extern Cremove(); /* (Celem, *cset) */
|
||||
extern Cindex Cfirst(); /* (cset) */
|
||||
extern Cindex Cnext(); /* (Cindex, cset) */
|
||||
extern Celem_t Celem(); /* (Cindex) */
|
||||
extern Cjoin(); /* (cset, *cset) */
|
||||
extern Cintersect(); /* (cset, *cset) */
|
||||
extern Cdeleteset(); /* (cset) */
|
||||
extern bool Cis_subset(); /* (cset, cset) */
|
||||
extern Cclearset(); /* (cset, *cset) */
|
||||
extern Ccopy_set(); /* (cset, *cset) */
|
||||
extern Csubtract(); /* (cset, *cset) */
|
||||
extern bool Cequal(); /* (cset, cset) */
|
||||
extern short Cnrelems(); /* (cset) */
|
||||
cset Cempty_set(short);
|
||||
bool Cis_elem(Celem_t, cset);
|
||||
void Cadd(Celem_t, cset *);
|
||||
void Cremove(Celem_t, cset *);
|
||||
Cindex Cfirst(cset);
|
||||
Cindex Cnext(Cindex, cset);
|
||||
Celem_t Celem(Cindex);
|
||||
void Cjoin(cset, cset *);
|
||||
void Cintersect(cset, cset *);
|
||||
void Cdeleteset(cset);
|
||||
bool Cis_subset(cset, cset);
|
||||
void Cclearset(cset, cset *);
|
||||
void Ccopy_set(cset, cset *);
|
||||
void Csubtract(cset, cset *);
|
||||
bool Cequal(cset, cset);
|
||||
short Cnrelems(cset);
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <em_spec.h>
|
||||
#include "types.h"
|
||||
#include "def.h"
|
||||
|
@ -23,14 +24,17 @@ int linecount; /* # lines in this file */
|
|||
bool verbose_flag = FALSE; /* generate verbose output ? */
|
||||
|
||||
/* 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);
|
||||
if (filename != (char *) 0) {
|
||||
fprintf(stderr," file %s",filename);
|
||||
}
|
||||
fprintf(stderr,": ");
|
||||
fprintf(stderr,s,a);
|
||||
vfprintf(stderr,s,ap);
|
||||
fprintf(stderr,"\n");
|
||||
abort();
|
||||
exit(-1);
|
||||
|
@ -38,21 +42,17 @@ error(s,a) char *s,*a; {
|
|||
|
||||
#ifdef TRACE
|
||||
/* VARARGS1 */
|
||||
OUTTRACE(s,n)
|
||||
char *s;
|
||||
int n;
|
||||
void OUTTRACE(const char *s, int n)
|
||||
{
|
||||
fprintf(stderr,"> ");
|
||||
fprintf(stderr,s,n);
|
||||
vfprintf(stderr,s,n);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
/* VARARGS1 */
|
||||
OUTVERBOSE(s,n1,n2)
|
||||
char *s;
|
||||
int n1,n2;
|
||||
void OUTVERBOSE(const char *s, int n1, int n2)
|
||||
{
|
||||
if (verbose_flag) {
|
||||
fprintf(stderr,"optimization: ");
|
||||
|
@ -72,7 +72,7 @@ badassertion(file,line) char *file; unsigned line; {
|
|||
}
|
||||
/* Valid Address */
|
||||
|
||||
VA(a) short *a; {
|
||||
void VA(short *a) {
|
||||
if (a == (short *) 0) error("VA: 0 argument");
|
||||
if ( ((unsigned) a & 01) == 01) {
|
||||
/* MACHINE DEPENDENT TEST */
|
||||
|
@ -83,14 +83,14 @@ VA(a) short *a; {
|
|||
|
||||
/* Valid Instruction code */
|
||||
|
||||
VI(i) short i; {
|
||||
void VI(short i) {
|
||||
if (i > ps_last) error("VI: illegal instr: %d", i);
|
||||
}
|
||||
|
||||
|
||||
/* Valid Line */
|
||||
|
||||
VL(l) line_p l; {
|
||||
void VL(line_p l) {
|
||||
byte instr, optype;
|
||||
|
||||
VA((short *) l);
|
||||
|
@ -106,7 +106,7 @@ VL(l) line_p l; {
|
|||
|
||||
/* Valid Data block */
|
||||
|
||||
VD(d) dblock_p d; {
|
||||
void VD(dblock_p d) {
|
||||
byte pseudo;
|
||||
|
||||
VA((short *) d);
|
||||
|
@ -119,7 +119,7 @@ VD(d) dblock_p d; {
|
|||
|
||||
/* Valid Object */
|
||||
|
||||
VO(o) obj_p o; {
|
||||
void VO(obj_p o) {
|
||||
offset off;
|
||||
|
||||
VA((short *) o);
|
||||
|
@ -133,7 +133,7 @@ VO(o) obj_p o; {
|
|||
|
||||
/* Valid Proc */
|
||||
|
||||
VP(p) proc_p p; {
|
||||
void VP(proc_p p) {
|
||||
proc_id pid;
|
||||
int nrlabs;
|
||||
|
||||
|
|
|
@ -12,16 +12,16 @@ extern int linecount; /* # lines in this file */
|
|||
extern bool verbose_flag; /* generate verbose output ? */
|
||||
|
||||
/* VARARGS 1 */
|
||||
extern error();
|
||||
void error(const char *, ...);
|
||||
|
||||
|
||||
#ifdef TRACE
|
||||
extern OUTTRACE();
|
||||
void OUTTRACE(const char *, int);
|
||||
#else
|
||||
#define OUTTRACE(s,n)
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
extern OUTVERBOSE();
|
||||
void OUTVERBOSE(const char *, int, int);
|
||||
#else
|
||||
#define OUTVERBOSE(s,n1,n2)
|
||||
#endif
|
||||
|
@ -36,12 +36,12 @@ extern OUTVERBOSE();
|
|||
|
||||
#define assert(x) if(!(x)) badassertion(__FILE__,__LINE__)
|
||||
|
||||
extern VI();
|
||||
extern VL();
|
||||
extern VD();
|
||||
extern VA();
|
||||
extern VO();
|
||||
extern VP();
|
||||
void VI(short);
|
||||
void VL(line_p);
|
||||
void VD(dblock_p);
|
||||
void VA(short *);
|
||||
void VO(obj_p);
|
||||
void VP(proc_p);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ struct files* findfiles(int argc, const char** argv)
|
|||
return &files;
|
||||
}
|
||||
|
||||
FILE *openfile(char* name, char* mode)
|
||||
FILE *openfile(const char *name, const char *mode)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
|
|
|
@ -37,9 +37,10 @@ struct files
|
|||
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
|
||||
* and mode; aborts if the file
|
||||
* cannot be opened.
|
||||
|
|
|
@ -33,7 +33,7 @@ lab_id lastlabid; /* last label identifier */
|
|||
* appear in the input.
|
||||
*/
|
||||
|
||||
bblock_p freshblock()
|
||||
bblock_p freshblock(void)
|
||||
{
|
||||
bblock_p b;
|
||||
b = newbblock();
|
||||
|
@ -42,7 +42,7 @@ bblock_p freshblock()
|
|||
}
|
||||
|
||||
|
||||
lab_id freshlabel()
|
||||
lab_id freshlabel(void)
|
||||
{
|
||||
curproc->p_nrlabels++;
|
||||
return ++lastlabid;
|
||||
|
@ -51,7 +51,7 @@ lab_id freshlabel()
|
|||
|
||||
#define getmark() getbyte()
|
||||
|
||||
short getshort() {
|
||||
short getshort(void) {
|
||||
register int l_byte, h_byte;
|
||||
|
||||
l_byte = getbyte();
|
||||
|
@ -61,7 +61,7 @@ short getshort() {
|
|||
}
|
||||
|
||||
|
||||
offset getoff() {
|
||||
offset getoff(void) {
|
||||
register long l;
|
||||
register int h_byte;
|
||||
|
||||
|
@ -73,7 +73,7 @@ offset getoff() {
|
|||
return l | (h_byte*256L*256*256L) ;
|
||||
}
|
||||
|
||||
STATIC int getint()
|
||||
STATIC int getint(void)
|
||||
{
|
||||
/* Read an integer from the input file. This routine is
|
||||
* only used when reading a bitvector-set. We expect an
|
||||
|
@ -90,8 +90,7 @@ STATIC int getint()
|
|||
|
||||
/* getptable */
|
||||
|
||||
loop_p getloop(id)
|
||||
loop_id id;
|
||||
STATIC void *getloop(loop_id id)
|
||||
{
|
||||
/* Map a loop identifier onto a loop struct.
|
||||
* If no struct was alocated yet for this identifier then
|
||||
|
@ -107,8 +106,7 @@ loop_p getloop(id)
|
|||
return (lpmap[id]);
|
||||
}
|
||||
|
||||
bblock_p getblock(id)
|
||||
block_id id;
|
||||
STATIC void *getblock(block_id id)
|
||||
{
|
||||
/* Map a basic block identifier onto a block struct
|
||||
* If no struct was alocated yet for this identifier then
|
||||
|
@ -126,8 +124,7 @@ bblock_p getblock(id)
|
|||
}
|
||||
|
||||
|
||||
lset getlset(p)
|
||||
char *((*p) ());
|
||||
STATIC lset getlset(void *(*p)(short))
|
||||
{
|
||||
/* Read a 'long' set. Such a set is represented externally
|
||||
* 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
|
||||
* a row of bytes (its bitvector) preceded by its length.
|
||||
|
@ -163,8 +160,7 @@ cset getcset()
|
|||
}
|
||||
|
||||
|
||||
proc_p getptable(pname)
|
||||
char *pname;
|
||||
proc_p getptable(const char *pname)
|
||||
{
|
||||
short i;
|
||||
proc_p head, p, *pp;
|
||||
|
@ -216,8 +212,7 @@ proc_p getptable(pname)
|
|||
|
||||
/* getdtable */
|
||||
|
||||
dblock_p getdtable(dname)
|
||||
char *dname;
|
||||
dblock_p getdtable(const char *dname)
|
||||
{
|
||||
/* Read the data block table. Every data block may
|
||||
* have a list of objects and a list of values (arguments),
|
||||
|
@ -290,9 +285,7 @@ dblock_p getdtable(dname)
|
|||
|
||||
/* getbblocks */
|
||||
|
||||
STATIC argstring(length,abp)
|
||||
short length;
|
||||
register argb_p abp;
|
||||
STATIC argstring(short length, argb_p abp)
|
||||
{
|
||||
|
||||
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
|
||||
* 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)
|
||||
proc_p *p_out;
|
||||
line_p read_line(proc_p *p_out)
|
||||
{
|
||||
/* Read a line of EM code (i.e. one instruction)
|
||||
* and its arguments (if any).
|
||||
|
@ -426,8 +418,7 @@ line_p read_line(p_out)
|
|||
}
|
||||
|
||||
|
||||
message(lnp)
|
||||
line_p lnp;
|
||||
void message(line_p lnp)
|
||||
{
|
||||
/* See if lnp is some useful message.
|
||||
* (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)
|
||||
FILE *lf;
|
||||
int n;
|
||||
proc_p *p_out;
|
||||
bool collect_mes;
|
||||
line_p getlines(FILE *lf, int n, proc_p *p_out, bool collect_mes)
|
||||
{
|
||||
/* Read n lines of EM text and doubly link them.
|
||||
* 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)
|
||||
FILE *gf,*lf;
|
||||
short *kind_out;
|
||||
bblock_p *g_out;
|
||||
line_p *l_out;
|
||||
proc_p *p_out;
|
||||
bool collect_mes;
|
||||
bool getunit(FILE *gf, FILE *lf, 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.
|
||||
* A pointer to the proctable entry of the read procedure is
|
||||
|
|
|
@ -10,44 +10,44 @@ extern block_id lastbid; /* block identifying number */
|
|||
extern lab_id lastlabid; /* last label identifier */
|
||||
|
||||
#define getbyte() getc(curinp)
|
||||
extern short getshort(); /* ()
|
||||
short getshort(void); /*
|
||||
* Read a short from curinp
|
||||
*/
|
||||
extern offset getoff(); /* ()
|
||||
offset getoff(void); /*
|
||||
* 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
|
||||
* instruction) and its arguments
|
||||
* (if any). If the instruction is a
|
||||
* 'pro' pseudo, set p_out.
|
||||
*/
|
||||
|
||||
extern line_p getlines(); /* ( FILE *lf; int n; proc_p *p_out;
|
||||
* bool collect_mes)
|
||||
line_p getlines(FILE *lf, int n, proc_p *p_out, bool collect_mes);
|
||||
/*
|
||||
* Read n lines of EM text and doubly
|
||||
* link them. Also process messages
|
||||
* if required.
|
||||
*/
|
||||
|
||||
extern bblock_p freshblock(); /* ()
|
||||
bblock_p freshblock(void); /*
|
||||
* Allocate a bblock struct and assign
|
||||
* it a brand new block_id.
|
||||
*/
|
||||
extern lab_id freshlabel(); /* ()
|
||||
lab_id freshlabel(void); /*
|
||||
* Get a brand new lab_id.
|
||||
*/
|
||||
extern dblock_p getdtable(); /* (char *dname)
|
||||
dblock_p getdtable(const char *dname); /*
|
||||
* Read the data block table from
|
||||
* the file with the given name.
|
||||
*/
|
||||
extern proc_p getptable(); /* (char *pname)
|
||||
proc_p getptable(const char *pname); /*
|
||||
* Read the proc table from
|
||||
* the file with the given name.
|
||||
*/
|
||||
extern bool getunit(); /* (FILE *gf,*lf; short kind_out;
|
||||
* bblock_p g_out; line_p l_out;
|
||||
* proc_p *p_out; bool collect_mes)
|
||||
bool getunit(FILE *gf, FILE *lf, short *kind_out, bblock_p *g_out,
|
||||
line_p *l_out, proc_p *p_out, bool collect_mes);
|
||||
/*
|
||||
* Read the control flow graph
|
||||
* (from file gf) and the EM text
|
||||
* (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
|
||||
* is returned in p_out.
|
||||
*/
|
||||
extern message(); /* (line_p lnp)
|
||||
* See if lnp is some useful message.
|
||||
void message(line_p lnp); /*
|
||||
* See if lnp is some useful message.
|
||||
* (e.g. a message telling that a
|
||||
* certain local variable will never be
|
||||
* referenced indirectly, so it may be
|
||||
|
|
|
@ -27,7 +27,7 @@ STATIC bool report_flag = FALSE; /* report #optimizations found? */
|
|||
STATIC bool core_flag = FALSE; /* report core usage? */
|
||||
#endif
|
||||
|
||||
static mach_init(char* machfile, int (*phase_machinit)())
|
||||
STATIC void mach_init(char* machfile, void (*phase_machinit)(void *))
|
||||
{
|
||||
/* Read target machine dependent information */
|
||||
|
||||
|
@ -43,7 +43,8 @@ static mach_init(char* machfile, int (*phase_machinit)())
|
|||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
fproc = getptable(files->pname_in); /* proc table */
|
||||
fdblock = getdtable(files->dname_in); /* data block table */
|
||||
(*initialize)();
|
||||
(*initialize)(NULL);
|
||||
if (optimize == no_action)
|
||||
return;
|
||||
f = openfile(files->lname_in, "r");
|
||||
|
@ -143,7 +144,8 @@ void go(int argc, const char** argv,
|
|||
core_usage();
|
||||
}
|
||||
|
||||
int no_action() {}
|
||||
/* ARGSUSED */
|
||||
void no_action(void *vp) {}
|
||||
|
||||
void core_usage(void)
|
||||
{
|
||||
|
|
|
@ -22,20 +22,22 @@
|
|||
* and 'optimize' is called with the current procedure
|
||||
* as parameter.
|
||||
*/
|
||||
extern void go(int argc, const char** argv,
|
||||
int (*initialize)(), int (*optimize)(),
|
||||
int (*phase_machinit)(), int (*proc_flag)());
|
||||
void go(int argc, const char** argv,
|
||||
void (*initialize)(void *null),
|
||||
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
|
||||
* no action is required.
|
||||
*/
|
||||
extern int no_action();
|
||||
void no_action(void *);
|
||||
|
||||
/* Report core usage, if core_flag is set. */
|
||||
extern void core_usage(void);
|
||||
void core_usage(void);
|
||||
|
||||
/* Report number of optimizations found, if
|
||||
* report_flag is set
|
||||
*/
|
||||
extern void report(char* s, int n);
|
||||
void report(char* s, int n);
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
extern short nrglobals;
|
||||
|
||||
init_globals()
|
||||
/* ARGSUSED */
|
||||
void init_globals(void *vp)
|
||||
{
|
||||
/* Assign a 'global variable number (o_globnr) to
|
||||
* every global variable for which we want to
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -29,12 +29,8 @@ short nrglobals;
|
|||
short nrlocals;
|
||||
local_p *locals; /* dynamic array */
|
||||
|
||||
STATIC void localvar(off,size,locs,reg,score)
|
||||
offset off;
|
||||
short size;
|
||||
local_p *locs;
|
||||
bool reg;
|
||||
offset score;
|
||||
STATIC void localvar(offset off, short size, local_p *locs, bool reg,
|
||||
offset score)
|
||||
{
|
||||
/* process a reference to a local variable.
|
||||
* 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)
|
||||
line_p l;
|
||||
local_p *locs;
|
||||
STATIC check_message(line_p l, local_p *locs)
|
||||
{
|
||||
/* See if l is a register message */
|
||||
|
||||
|
@ -90,9 +84,7 @@ STATIC check_message(l,locs)
|
|||
|
||||
|
||||
|
||||
STATIC void check_local_use(l,locs)
|
||||
line_p l;
|
||||
local_p *locs;
|
||||
STATIC void check_local_use(line_p l, local_p *locs)
|
||||
{
|
||||
short sz;
|
||||
|
||||
|
@ -126,8 +118,7 @@ STATIC void check_local_use(l,locs)
|
|||
}
|
||||
|
||||
|
||||
make_localtab(p)
|
||||
proc_p p;
|
||||
void make_localtab(proc_p p)
|
||||
{
|
||||
/* Make a table of local variables.
|
||||
* This table is used to associate a
|
||||
|
@ -186,10 +177,7 @@ make_localtab(p)
|
|||
|
||||
|
||||
|
||||
void find_local(off,nr_out,found_out)
|
||||
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
|
||||
* 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)
|
||||
line_p l;
|
||||
short *nr_out;
|
||||
bool *found_out;
|
||||
void var_nr(line_p l, short *nr_out, bool *found_out)
|
||||
{
|
||||
/* Determine the number of the variable referenced
|
||||
* by EM instruction l.
|
||||
|
|
|
@ -11,17 +11,19 @@
|
|||
extern local_p *locals; /* table of locals, index is local-number */
|
||||
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
|
||||
* which local variable p has. Make a table of
|
||||
* these variables ('locals') and count them
|
||||
* ('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
|
||||
* 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
|
||||
* offset. Return its local-number.
|
||||
*/
|
||||
|
|
|
@ -30,15 +30,13 @@
|
|||
*/
|
||||
|
||||
|
||||
lset Lempty_set()
|
||||
lset Lempty_set(void)
|
||||
{
|
||||
return ((lset) 0);
|
||||
}
|
||||
|
||||
|
||||
bool Lis_elem(x,s)
|
||||
register Lelem_t x;
|
||||
register lset s;
|
||||
bool Lis_elem(Lelem_t x, lset 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)
|
||||
Lelem_t x;
|
||||
lset *s_p;
|
||||
void Ladd(Lelem_t x, lset *s_p)
|
||||
{
|
||||
/* add x to a set. Note that the set is given as in-out
|
||||
* parameter, because it may be changed.
|
||||
|
@ -71,9 +67,7 @@ Ladd(x,s_p)
|
|||
}
|
||||
|
||||
|
||||
Lremove(x,s_p)
|
||||
Lelem_t x;
|
||||
lset *s_p;
|
||||
void Lremove(Lelem_t x, lset *s_p)
|
||||
{
|
||||
/* Remove x from a set. If x was not an element of
|
||||
* the set, nothing happens.
|
||||
|
@ -109,8 +103,7 @@ Lremove(x,s_p)
|
|||
*/
|
||||
|
||||
|
||||
Lindex Lfirst(s)
|
||||
lset s;
|
||||
Lindex Lfirst(lset s)
|
||||
{
|
||||
return ((Lindex) s);
|
||||
/* Note that an index for long sets is just
|
||||
|
@ -120,25 +113,21 @@ Lindex Lfirst(s)
|
|||
|
||||
|
||||
/*ARGSUSED1*/
|
||||
Lindex Lnext(i,s)
|
||||
Lindex i;
|
||||
lset s;
|
||||
Lindex Lnext(Lindex i, lset s)
|
||||
{
|
||||
assert(i != (Lindex) 0);
|
||||
return (i->e_next);
|
||||
}
|
||||
|
||||
|
||||
Lelem_t Lelem(i)
|
||||
Lindex i;
|
||||
Lelem_t Lelem(Lindex i)
|
||||
{
|
||||
return (i->e_elem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ljoin(s1,s2_p)
|
||||
lset s1,*s2_p;
|
||||
void Ljoin(lset s1, lset *s2_p)
|
||||
{
|
||||
/* Join two sets, assign the result to the second set
|
||||
* and delete the first set (i.e. the value of the
|
||||
|
@ -173,8 +162,7 @@ Ljoin(s1,s2_p)
|
|||
}
|
||||
|
||||
|
||||
Ldeleteset(s)
|
||||
lset s;
|
||||
void Ldeleteset(lset s)
|
||||
{
|
||||
register elem_p ep, next;
|
||||
|
||||
|
@ -185,8 +173,7 @@ Ldeleteset(s)
|
|||
}
|
||||
|
||||
|
||||
bool Lis_subset(s1,s2)
|
||||
lset s1,s2;
|
||||
bool Lis_subset(lset s1, lset s2)
|
||||
{
|
||||
/* See if s1 is a subset of s2 */
|
||||
|
||||
|
@ -199,8 +186,7 @@ bool Lis_subset(s1,s2)
|
|||
}
|
||||
|
||||
|
||||
short Lnrelems(s)
|
||||
lset s;
|
||||
short Lnrelems(lset s)
|
||||
{
|
||||
/* Compute the number of elements of a set */
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
*/
|
||||
|
||||
|
||||
extern lset Lempty_set(); /* () */
|
||||
extern bool Lis_elem(); /* (Lelem_t, lset) */
|
||||
extern Ladd(); /* (Lelem_t, *lset) */
|
||||
extern Lremove(); /* (Lelem_t, *lset) */
|
||||
extern Lindex Lfirst(); /* (lset) */
|
||||
extern Lindex Lnext(); /* (Lindex, lset) */
|
||||
extern Lelem_t Lelem(); /* (Lindex) */
|
||||
extern Ljoin(); /* (lset, *lset) */
|
||||
extern Ldeleteset(); /* (lset) */
|
||||
extern bool Lis_subset(); /* (lset, lset) */
|
||||
extern short Lnrelems(); /* (lset) */
|
||||
lset Lempty_set(void);
|
||||
bool Lis_elem(Lelem_t, lset);
|
||||
void Ladd(Lelem_t, lset *);
|
||||
void Lremove(Lelem_t, lset *);
|
||||
Lindex Lfirst(lset);
|
||||
Lindex Lnext(Lindex, lset);
|
||||
Lelem_t Lelem(Lindex);
|
||||
void Ljoin(lset, lset *);
|
||||
void Ldeleteset(lset);
|
||||
bool Lis_subset(lset, lset);
|
||||
short Lnrelems(lset);
|
||||
|
|
|
@ -41,9 +41,7 @@ typedef struct class *class_p;
|
|||
* generated automatically from the file classdefs.src.
|
||||
*/
|
||||
|
||||
STATIC bool classes(instr,src_out,res_out)
|
||||
int instr;
|
||||
int *src_out, *res_out;
|
||||
STATIC bool classes(int instr, int *src_out, int *res_out)
|
||||
{
|
||||
/* Determine the classes of the given instruction */
|
||||
|
||||
|
@ -59,8 +57,7 @@ STATIC bool classes(instr,src_out,res_out)
|
|||
|
||||
|
||||
|
||||
STATIC bool uses_arg(class)
|
||||
int class;
|
||||
STATIC bool uses_arg(int class)
|
||||
{
|
||||
/* See if a member of the given class uses
|
||||
* an argument.
|
||||
|
@ -82,8 +79,7 @@ STATIC bool uses_arg(class)
|
|||
|
||||
|
||||
|
||||
STATIC bool uses_2args(class)
|
||||
int class;
|
||||
STATIC bool uses_2args(int class)
|
||||
{
|
||||
/* See if a member of the given class uses
|
||||
* 2 arguments.
|
||||
|
@ -93,9 +89,7 @@ STATIC bool uses_2args(class)
|
|||
}
|
||||
|
||||
|
||||
STATIC bool parse_locs(l,c1_out,c2_out)
|
||||
line_p l;
|
||||
offset *c1_out, *c2_out;
|
||||
STATIC bool parse_locs(line_p l, offset *c1_out, offset *c2_out)
|
||||
{
|
||||
if (INSTR(l) == op_loc && INSTR(PREV(l)) == op_loc) {
|
||||
*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)
|
||||
line_p l;
|
||||
int src_class,res_class;
|
||||
offset *arg1_out, *arg2_out;
|
||||
STATIC bool check_args(line_p l, int src_class, int res_class,
|
||||
offset *arg1_out, offset *arg2_out)
|
||||
{
|
||||
/* Several EM instructions have an argument
|
||||
* 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)
|
||||
int class;
|
||||
offset arg1,arg2;
|
||||
STATIC offset nrbytes(int class, offset arg1, offset arg2)
|
||||
{
|
||||
/* Determine the number of bytes of the given
|
||||
* arguments and class.
|
||||
|
@ -185,9 +175,8 @@ STATIC offset nrbytes(class,arg1,arg2)
|
|||
|
||||
|
||||
|
||||
STATIC attrib(l,expect_out,srcb_out,resb_out)
|
||||
line_p l;
|
||||
offset *expect_out, *srcb_out, *resb_out;
|
||||
STATIC void attrib(line_p l, offset *expect_out, offset *srcb_out,
|
||||
offset *resb_out)
|
||||
{
|
||||
/* Determine a number of attributes of an EM
|
||||
* 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)
|
||||
line_p l, *l_out;
|
||||
offset nbytes;
|
||||
int level;
|
||||
int (*action0) ();
|
||||
bool parse(line_p l, offset nbytes, line_p *l_out, int level,
|
||||
void (*action0)(line_p, line_p, offset))
|
||||
{
|
||||
/* This is a recursive descent parser for
|
||||
* EM expressions.
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
bool parse(); /* (line_p l, *l_out; offset nbytes;
|
||||
* int level; int (*action0) ())
|
||||
bool parse(line_p l, offset nbytes, line_p *l_out, int level,
|
||||
void (*action0)(line_p l1, line_p l2, offset size));
|
||||
/*
|
||||
* This is a recursive descent parser for
|
||||
* EM expressions.
|
||||
* It tries to recognize EM code that loads exactly
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "def.h"
|
||||
#include "map.h"
|
||||
#include "lset.h"
|
||||
#include "cset.h"
|
||||
#include "alloc.h"
|
||||
#include "put.h"
|
||||
|
||||
|
@ -31,12 +32,11 @@ FILE *curoutp;
|
|||
|
||||
/* putlines */
|
||||
|
||||
STATIC putstr();
|
||||
STATIC outlab();
|
||||
STATIC outobject();
|
||||
STATIC void putstr(argb_p);
|
||||
STATIC void outlab(lab_id);
|
||||
STATIC void outobject(obj_p);
|
||||
|
||||
STATIC putargs(ap)
|
||||
register arg_p ap;
|
||||
STATIC void putargs(arg_p ap)
|
||||
{
|
||||
while (ap != (arg_p) 0) {
|
||||
outbyte((byte) ap->a_type & BMASK);
|
||||
|
@ -70,9 +70,9 @@ STATIC putargs(ap)
|
|||
|
||||
|
||||
|
||||
STATIC putstr(abp) register argb_p abp; {
|
||||
register argb_p tbp;
|
||||
register length;
|
||||
STATIC void putstr(argb_p abp) {
|
||||
argb_p tbp;
|
||||
int length;
|
||||
|
||||
length = 0;
|
||||
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>>16) );
|
||||
}
|
||||
|
||||
|
||||
outshort(i) short i; {
|
||||
void outshort(short i) {
|
||||
|
||||
outbyte( (byte) (i&BMASK) );
|
||||
outbyte( (byte) (i>>8) );
|
||||
}
|
||||
|
||||
|
||||
STATIC outint(i)
|
||||
int i;
|
||||
STATIC void outint(int i)
|
||||
{
|
||||
/* Write an integer to the output file. This routine is
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
STATIC outobject(obj) obj_p obj; {
|
||||
STATIC void outobject(obj_p obj) {
|
||||
outshort((short) obj->o_id);
|
||||
}
|
||||
|
||||
|
||||
outproc(p) proc_p p; {
|
||||
void outproc(proc_p p) {
|
||||
outshort((short) p->p_id);
|
||||
}
|
||||
|
||||
|
||||
short putlines(l,lf)
|
||||
line_p l;
|
||||
FILE *lf;
|
||||
short putlines(line_p l, FILE *lf)
|
||||
{
|
||||
/* Output the list of em instructions headed by l.
|
||||
* Return the number of instruction written.
|
||||
|
@ -189,8 +186,7 @@ short putlines(l,lf)
|
|||
#define outmark(m) outbyte((byte) m)
|
||||
|
||||
|
||||
STATIC putobjects(obj)
|
||||
register obj_p obj;
|
||||
STATIC void putobjects(obj_p obj)
|
||||
{
|
||||
while (obj != (obj_p) 0) {
|
||||
outmark(MARK_OBJ);
|
||||
|
@ -203,8 +199,7 @@ STATIC putobjects(obj)
|
|||
|
||||
|
||||
|
||||
STATIC putvalues(arg)
|
||||
register arg_p arg;
|
||||
STATIC void putvalues(arg_p arg)
|
||||
{
|
||||
while (arg != (arg_p) 0) {
|
||||
assert(arg->a_type == ARGOFF);
|
||||
|
@ -213,9 +208,7 @@ STATIC putvalues(arg)
|
|||
arg = arg->a_next;
|
||||
}
|
||||
}
|
||||
putdtable(head,df)
|
||||
dblock_p head;
|
||||
FILE *df;
|
||||
void putdtable(dblock_p head, FILE *df)
|
||||
{
|
||||
/* Write the datablock table to the data block file df. */
|
||||
|
||||
|
@ -257,8 +250,7 @@ putdtable(head,df)
|
|||
|
||||
|
||||
|
||||
STATIC outcset(s)
|
||||
cset s;
|
||||
STATIC void outcset(cset s)
|
||||
{
|
||||
/* A 'compact' set is represented externally as a row of words
|
||||
* (its bitvector) preceded by its length.
|
||||
|
@ -274,10 +266,7 @@ STATIC outcset(s)
|
|||
|
||||
|
||||
|
||||
putptable(head,pf,all)
|
||||
proc_p head;
|
||||
FILE *pf;
|
||||
bool all;
|
||||
void putptable(proc_p head, FILE *pf, bool all)
|
||||
{
|
||||
register proc_p p;
|
||||
proc_p next;
|
||||
|
@ -328,16 +317,18 @@ putptable(head,pf,all)
|
|||
|
||||
/* putunit */
|
||||
|
||||
STATIC outloop(l)
|
||||
loop_p l;
|
||||
STATIC void outloop(void *vp)
|
||||
{
|
||||
loop_p l = vp;
|
||||
|
||||
outshort((short) l->lp_id);
|
||||
}
|
||||
|
||||
|
||||
STATIC outblock(b)
|
||||
bblock_p b;
|
||||
STATIC void outblock(void *vp)
|
||||
{
|
||||
bblock_p b = vp;
|
||||
|
||||
if (b == (bblock_p) 0) {
|
||||
outshort((short) 0);
|
||||
} else {
|
||||
|
@ -346,20 +337,7 @@ STATIC outblock(b)
|
|||
}
|
||||
|
||||
|
||||
STATIC outid(e,p)
|
||||
Lelem_t e;
|
||||
int (*p) ();
|
||||
{
|
||||
/* Auxiliary routine used by outlset. */
|
||||
|
||||
/* NOSTRICT */
|
||||
(*p) (e);
|
||||
}
|
||||
|
||||
|
||||
STATIC outlset(s,p)
|
||||
lset s;
|
||||
int (*p) ();
|
||||
STATIC void outlset(lset s, void (*p)(void *))
|
||||
{
|
||||
/* A 'long' set is represented externally as a
|
||||
* a sequence of elements terminated by a 0 word.
|
||||
|
@ -370,19 +348,14 @@ STATIC outlset(s,p)
|
|||
register Lindex i;
|
||||
|
||||
for (i = Lfirst(s); i != (Lindex) 0; i = Lnext(i,s)) {
|
||||
outid(Lelem(i),p);
|
||||
(*p)(Lelem(i));
|
||||
}
|
||||
outshort((short) 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
putunit(kind,p,l,gf,lf)
|
||||
short kind;
|
||||
proc_p p;
|
||||
line_p l;
|
||||
FILE *gf, *lf;
|
||||
void putunit(short kind, proc_p p, line_p l, FILE *gf, FILE *lf)
|
||||
{
|
||||
register bblock_p b;
|
||||
register short n = 0;
|
||||
|
|
|
@ -9,27 +9,29 @@
|
|||
extern FILE *curoutp; /* current output file */
|
||||
|
||||
#define outbyte(b) putc(b,curoutp)
|
||||
extern outshort(); /* (short i)
|
||||
void outshort(short i); /*
|
||||
* Write a short to curoutp
|
||||
*/
|
||||
extern outoff(); /* (offset off)
|
||||
void outoff(offset off); /*
|
||||
* Write an offset to curoutp
|
||||
*/
|
||||
extern outproc(); /* (proc_p p)
|
||||
void outproc(proc_p p); /*
|
||||
* 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,
|
||||
* 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,
|
||||
* preceded by its length. If all=false,
|
||||
* the fields computed by CF will not be
|
||||
* written (used by the IC phase).
|
||||
*/
|
||||
extern void putunit(); /* (short kind; proc_p p; line_p l;
|
||||
* FILE *gf, *lf)
|
||||
void putunit(short kind, proc_p p, line_p l, FILE *gf, FILE *lf);
|
||||
/*
|
||||
* If kind = LTEXT, then write
|
||||
* the control flow graph to file gf,
|
||||
* 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)
|
||||
* to lf.
|
||||
*/
|
||||
extern short putlines(); /* (line_p l; FILE *lf)
|
||||
short putlines(line_p l, FILE *lf);
|
||||
/*
|
||||
* Output the list of em instructions
|
||||
* headed by l. Return the number of
|
||||
* instructions written.
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
|
||||
#define IS_LOC(l) (l!=(line_p) 0 && INSTR(l)==op_loc && TYPE(l)==OPSHORT)
|
||||
|
||||
int stack_change(l,sign)
|
||||
line_p l;
|
||||
char sign;
|
||||
STATIC int stack_change(line_p l, char sign)
|
||||
{
|
||||
/* 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)
|
||||
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)
|
||||
{
|
||||
short pop,push;
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
/* 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
|
||||
* affected by the EM instruction l. 'ok_out' is set
|
||||
* to false if we fail to do so. pop_out and
|
||||
|
|
|
@ -52,10 +52,10 @@ STATIC int globl_sp_allowed;
|
|||
#define IS_ASP(l) (INSTR(l) == op_asp && TYPE(l) == OPSHORT && SHORT(l) > 0)
|
||||
|
||||
|
||||
STATIC sp_machinit(f)
|
||||
FILE *f;
|
||||
STATIC void sp_machinit(void *vp)
|
||||
{
|
||||
/* Read target machine dependent information for this phase */
|
||||
FILE *f = vp;
|
||||
char s[100];
|
||||
|
||||
for (;;) {
|
||||
|
@ -194,10 +194,9 @@ STATIC mark_unsave_blocks(p)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
sp_optimize(p)
|
||||
proc_p p;
|
||||
void sp_optimize(void *vp)
|
||||
{
|
||||
proc_p p = vp;
|
||||
register bblock_p b;
|
||||
|
||||
if (IS_ENTERED_WITH_GTO(p)) return;
|
||||
|
|
|
@ -52,10 +52,10 @@ int sli_threshold;
|
|||
|
||||
int Ssr; /* #optimizations found */
|
||||
|
||||
sr_machinit(f)
|
||||
FILE *f;
|
||||
void sr_machinit(void *vp)
|
||||
{
|
||||
/* Read target machine dependent information */
|
||||
FILE *f = vp;
|
||||
char s[100];
|
||||
|
||||
|
||||
|
@ -219,10 +219,10 @@ STATIC sr_cleanproc(p)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
sr_optimize(p)
|
||||
proc_p p;
|
||||
void sr_optimize(void *vp)
|
||||
{
|
||||
proc_p p = vp;
|
||||
|
||||
if (IS_ENTERED_WITH_GTO(p)) return;
|
||||
sr_extproc(p);
|
||||
loopblocks(p);
|
||||
|
|
|
@ -57,9 +57,9 @@ STATIC cond_p getcondtab(f)
|
|||
}
|
||||
|
||||
|
||||
STATIC ud_machinit(f)
|
||||
FILE *f;
|
||||
STATIC void ud_machinit(void *vp)
|
||||
{
|
||||
FILE *f = vp;
|
||||
char s[100];
|
||||
|
||||
for (;;) {
|
||||
|
@ -532,10 +532,10 @@ STATIC ud_cleanup(p)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
ud_optimize(p)
|
||||
proc_p p;
|
||||
void ud_optimize(void *vp)
|
||||
{
|
||||
proc_p p = vp;
|
||||
|
||||
if (IS_ENTERED_WITH_GTO(p)) return;
|
||||
ud_extend(p);
|
||||
locals = (local_p *) 0;
|
||||
|
|
Loading…
Reference in a new issue