}
}
-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;
-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
* untill we find no further optimizations.
*/
+ proc_p p = vp;
bblock_p b;
bool changes = TRUE;
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;
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);
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);
Cdeleteset(cs1); Cdeleteset(cs2);
}
-cs_machinit(f)
- FILE *f;
+void cs_machinit(void *vp)
{
+ FILE *f = vp;
char s[100];
int time, space;
return TRUE;
}
-bool desirable(avp)
- avail_p avp;
+bool desirable(avail_p avp)
{
register Lindex i, next;
* (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
}
#endif
-il_flags(p) char* p;
+void il_flags(void *vp)
{
+ char *p = vp;
+
switch (*p++)
{
case 's':
#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
(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
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
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;
}
-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;
}
}
-lv_flags(p)
- char *p;
+void lv_flags(void *vp)
{
+ char *p = vp;
+
switch(*p) {
case 'N':
mesgflag = TRUE;
}
-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);
-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 (;;) {
}
-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;
#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:
-offset aoff(ap,n)
- register arg_p ap;
+offset aoff(arg_p ap, int n)
{
while (n>0) {
if (ap != (arg_p) 0)
}
-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 */
-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.
-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 */
}
-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.
}
-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.
#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
-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;
-appnd_line(l1,l2)
- line_p l1,l2;
+void appnd_line(line_p l1, line_p l2)
{
/* Put l1 after l2 */
-line_p last_instr(b)
- bblock_p b;
+line_p last_instr(bblock_p b)
{
/* Determine the last line of a list */
-line_p find_mesreg(off)
- offset off;
+line_p find_mesreg(offset off)
{
/* Find the register message for the local with the given offset */
}
-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;
*/
-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.
-cset Cempty_set(n)
- short n;
+cset Cempty_set(short n)
{
cset s;
}
-bool Cis_elem(x,s)
- Celem_t x;
- cset s;
+bool Cis_elem(Celem_t x, cset s)
{
short n;
int mask;
-Cadd(x,s_p)
- Celem_t x;
- cset *s_p;
+void Cadd(Celem_t x, cset *s_p)
{
cset s;
short n;
}
-Cremove(x,s_p)
- Celem_t x;
- cset *s_p;
+void Cremove(Celem_t x, cset *s_p)
{
cset s;
short n;
* 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;
}
-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.
-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.
}
-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 */
}
-Cclear_set(s_p)
- cset *s_p;
+void Cclear_set(cset *s_p)
{
cset s;
register short i;
}
-Ccopy_set(s1,s2_p)
- cset s1, *s2_p;
+void Ccopy_set(cset s1, cset *s2_p)
{
cset s2;
register short i;
}
-Csubtract(s1,s2_p)
- cset s1, *s2_p;
+void Csubtract(cset s1, cset *s2_p)
{
cset s2;
register short i;
}
-bool Cequal(s1,s2)
- cset s1, s2;
+bool Cequal(cset s1, cset s2)
{
register short i;
return TRUE;
}
-short Cnrelems(s)
- cset s;
+short Cnrelems(cset s)
{
register short n, cnt;
*/
-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);
*/
-#include <stdlib.h>
+#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
#include <em_spec.h>
#include "types.h"
#include "def.h"
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);
#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: ");
}
/* 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 */
/* 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);
/* Valid Data block */
-VD(d) dblock_p d; {
+void VD(dblock_p d) {
byte pseudo;
VA((short *) d);
/* Valid Object */
-VO(o) obj_p o; {
+void VO(obj_p o) {
offset off;
VA((short *) o);
/* Valid Proc */
-VP(p) proc_p p; {
+void VP(proc_p p) {
proc_id pid;
int nrlabs;
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
#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);
return &files;
}
-FILE *openfile(char* name, char* mode)
+FILE *openfile(const char *name, const char *mode)
{
FILE *f;
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.
* appear in the input.
*/
-bblock_p freshblock()
+bblock_p freshblock(void)
{
bblock_p b;
b = newbblock();
}
-lab_id freshlabel()
+lab_id freshlabel(void)
{
curproc->p_nrlabels++;
return ++lastlabid;
#define getmark() getbyte()
-short getshort() {
+short getshort(void) {
register int l_byte, h_byte;
l_byte = getbyte();
}
-offset getoff() {
+offset getoff(void) {
register long l;
register int h_byte;
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
/* 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
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
}
-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.
}
-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.
}
-proc_p getptable(pname)
- char *pname;
+proc_p getptable(const char *pname)
{
short i;
proc_p head, p, *pp;
/* 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),
/* getbblocks */
-STATIC argstring(length,abp)
- short length;
- register argb_p abp;
+STATIC argstring(short length, argb_p abp)
{
while (length--) {
-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.
}
-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).
}
-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
-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.
-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
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,
* 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
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 */
}
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
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");
core_usage();
}
-int no_action() {}
+/* ARGSUSED */
+void no_action(void *vp) {}
void core_usage(void)
{
* 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);
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
*
*/
-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.
*/
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.
-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 */
-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;
}
-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
-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.
-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.
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.
*/
*/
-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 */
}
-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.
}
-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.
*/
-Lindex Lfirst(s)
- lset s;
+Lindex Lfirst(lset s)
{
return ((Lindex) s);
/* Note that an index for long sets is just
/*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
}
-Ldeleteset(s)
- lset s;
+void Ldeleteset(lset s)
{
register elem_p ep, next;
}
-bool Lis_subset(s1,s2)
- lset s1,s2;
+bool Lis_subset(lset s1, lset s2)
{
/* See if s1 is a subset of s2 */
}
-short Lnrelems(s)
- lset s;
+short Lnrelems(lset s)
{
/* Compute the number of elements of a set */
*/
-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);
* 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 */
-STATIC bool uses_arg(class)
- int class;
+STATIC bool uses_arg(int class)
{
/* See if a member of the given class uses
* an argument.
-STATIC bool uses_2args(class)
- int class;
+STATIC bool uses_2args(int class)
{
/* See if a member of the given class uses
* 2 arguments.
}
-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);
-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
-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.
-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.
-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.
* (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
#include "def.h"
#include "map.h"
#include "lset.h"
+#include "cset.h"
#include "alloc.h"
#include "put.h"
/* 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);
-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;
}
-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
}
}
-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.
#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);
-STATIC putvalues(arg)
- register arg_p arg;
+STATIC void putvalues(arg_p arg)
{
while (arg != (arg_p) 0) {
assert(arg->a_type == ARGOFF);
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. */
-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.
-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;
/* 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 {
}
-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.
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;
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);
* 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.
#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 */
-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;
/* 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
#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 (;;) {
}
-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;
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];
}
-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);
}
-STATIC ud_machinit(f)
- FILE *f;
+STATIC void ud_machinit(void *vp)
{
+ FILE *f = vp;
char s[100];
for (;;) {
}
-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;