Use prototypes in ego/cs, ego/sp.

This commit is contained in:
George Koehler 2018-02-05 16:09:30 -05:00
parent a60738a50d
commit 0a6d3de7fe
25 changed files with 166 additions and 259 deletions

View file

@ -11,8 +11,7 @@
#include "cs.h"
#include "cs_entity.h"
offset array_elemsize(vn)
valnum vn;
offset array_elemsize(valnum vn)
{
/* Vn is the valuenumber of an entity that points to
* an array-descriptor. The third element of this descriptor holds
@ -36,14 +35,12 @@ offset array_elemsize(vn)
return aoff(enp->en_ext->o_dblock->d_values, 2);
}
occur_p occ_elem(i)
Lindex i;
occur_p occ_elem(Lindex i)
{
return (occur_p) Lelem(i);
}
entity_p en_elem(i)
Lindex i;
entity_p en_elem(Lindex i)
{
return (entity_p) Lelem(i);
}
@ -54,14 +51,14 @@ entity_p en_elem(i)
STATIC valnum val_no;
valnum newvalnum()
valnum newvalnum(void)
{
/* Return a completely new value number. */
return ++val_no;
}
start_valnum()
void start_valnum(void)
{
/* Restart value numbering. */

View file

@ -3,28 +3,28 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
extern offset array_elemsize(); /* (valnum vm)
extern offset array_elemsize(valnum vm);
/*
* Returns the size of array-elements,
* if vn is the valuenumber of the
* address of an array-descriptor.
*/
extern occur_p occ_elem(); /* (Lindex i)
extern occur_p occ_elem(Lindex i); /*
* Returns a pointer to the occurrence
* of which i is an index in a set.
*/
extern entity_p en_elem(); /* (Lindex i)
extern entity_p en_elem(Lindex i); /*
* Returns a pointer to the entity
* of which i is an index in a set.
*/
extern valnum newvalnum(); /* ()
extern valnum newvalnum(void); /*
* Returns a completely new
* value number.
*/
extern start_valnum(); /* ()
extern void start_valnum(void); /*
* Restart value numbering.
*/

View file

@ -22,8 +22,7 @@
avail_p avails; /* The list of available expressions. */
STATIC bool commutative(instr)
int instr;
STATIC bool commutative(int instr)
{
/* Is instr a commutative operator? */
@ -37,9 +36,7 @@ STATIC bool commutative(instr)
}
}
STATIC bool same_avail(kind, avp1, avp2)
byte kind;
avail_p avp1, avp2;
STATIC bool same_avail(byte kind, avail_p avp1, avail_p avp2)
{
/* Two expressions are the same if they have the same operator,
* the same size, and their operand(s) have the same value.
@ -75,8 +72,7 @@ STATIC bool same_avail(kind, avp1, avp2)
/* NOTREACHED */
}
STATIC void check_local(avp)
avail_p avp;
STATIC void check_local(avail_p avp)
{
/* Check if the local in which the result of avp was stored,
* still holds this result. Update if not.
@ -89,9 +85,7 @@ STATIC void check_local(avp)
}
}
STATIC entity_p result_local(size, l)
offset size;
line_p l;
STATIC entity_p result_local(offset size, line_p l)
{
/* If the result of an expression of size bytes is stored into a
* local for which a registermessage was generated, return a pointer
@ -114,9 +108,7 @@ STATIC entity_p result_local(size, l)
return (entity_p) 0;
}
STATIC copy_avail(kind, src, dst)
int kind;
avail_p src, dst;
STATIC void copy_avail(int kind, avail_p src, avail_p dst)
{
/* Copy some attributes from src to dst. */
@ -143,10 +135,7 @@ STATIC copy_avail(kind, src, dst)
}
}
avail_p av_enter(avp, ocp, kind)
avail_p avp;
occur_p ocp;
int kind;
avail_p av_enter(avail_p avp, occur_p ocp, int kind)
{
/* Put the available expression avp in the list,
* if it is not already there.
@ -186,7 +175,7 @@ avail_p av_enter(avp, ocp, kind)
return ravp;
}
clr_avails()
void clr_avails(void)
{
/* Throw away the information about the available expressions. */

View file

@ -5,7 +5,8 @@
*/
extern avail_p avails; /* The set of available expressions. */
extern avail_p av_enter(); /* (avail_p avp, occur_p ocp, byte kind)
extern avail_p av_enter(avail_p avp, occur_p ocp, byte kind);
/*
* Puts the available expression in avp
* in the list of available expressions,
* if it is not already there. Add ocp to set of
@ -18,6 +19,7 @@ extern avail_p av_enter(); /* (avail_p avp, occur_p ocp, byte kind)
* Returns a pointer into the list.
*/
extern clr_avails(); /* Release all space occupied by the old list
extern void clr_avails(void);
/* Release all space occupied by the old list
* of available expressions.
*/

View file

@ -17,8 +17,7 @@
extern char em_mnem[]; /* The mnemonics of the EM instructions. */
STATIC void showinstr(lnp)
line_p lnp;
STATIC void showinstr(line_p lnp)
{
/* Makes the instruction in `lnp' human readable. Only lines that
* can occur in expressions that are going to be eliminated are
@ -49,8 +48,7 @@ STATIC void showinstr(lnp)
fprintf(stderr,"\n");
}
SHOWOCCUR(ocp)
occur_p ocp;
SHOWOCCUR(occur_p ocp)
{
/* Shows all instructions in an occurrence. */
@ -69,8 +67,7 @@ SHOWOCCUR(ocp)
#ifdef TRACE
SHOWAVAIL(avp)
avail_p avp;
void SHOWAVAIL(avail_p avp)
{
/* Shows an available expression. */
showinstr(avp->av_found);
@ -79,7 +76,7 @@ SHOWAVAIL(avp)
}
OUTAVAILS()
void OUTAVAILS(void)
{
register avail_p ravp;
@ -110,7 +107,7 @@ STATIC char *enkinds[] = {
"ignore mask"
};
OUTENTITIES()
void OUTENTITIES(void)
{
register Lindex i;

View file

@ -5,7 +5,8 @@
*/
#ifdef VERBOSE
extern SHOWOCCUR(); /* (occur_p ocp)
extern void SHOWOCCUR(occur_p ocp);
/*
* Shows all lines in an occurrence.
*/
@ -17,15 +18,18 @@ extern SHOWOCCUR(); /* (occur_p ocp)
#ifdef TRACE
extern OUTAVAILS(); /* ()
extern void OUTAVAILS(void);
/*
* Prints all available expressions.
*/
extern OUTENTITIES(); /* ()
extern void OUTENTITIES(void);
/*
* Prints all entities.
*/
extern SHOWAVAIL(); /* (avail_p avp)
extern void SHOWAVAIL(avail_p avp);
/*
* Shows an available expression.
*/

View file

@ -20,8 +20,7 @@
#include "cs_partit.h"
#include "cs_debug.h"
STATIC dlink(l1, l2)
line_p l1, l2;
STATIC void dlink(line_p l1, line_p l2)
{
/* Doubly link the lines in l1 and l2. */
@ -31,11 +30,10 @@ STATIC dlink(l1, l2)
l2->l_prev = l1;
}
STATIC remove_lines(first, last)
line_p first, last;
STATIC void remove_lines(line_p first, line_p last)
{
/* Throw away the lines between and including first and last.
* Don't worry about any pointers; the (must) have been taken care of.
* Don't worry about any pointers; they (must) have been taken care of.
*/
register line_p lnp, next;
@ -46,8 +44,7 @@ STATIC remove_lines(first, last)
}
}
STATIC bool contained(ocp1, ocp2)
occur_p ocp1, ocp2;
STATIC bool contained(occur_p ocp1, occur_p ocp2)
{
/* Determine whether ocp1 is contained within ocp2. */
@ -61,9 +58,7 @@ STATIC bool contained(ocp1, ocp2)
return FALSE;
}
STATIC delete(ocp, start)
occur_p ocp;
avail_p start;
STATIC void delete(occur_p ocp, avail_p start)
{
/* Delete all occurrences that are contained within ocp.
* They must have been entered in the list before start:
@ -90,10 +85,7 @@ STATIC delete(ocp, start)
}
}
STATIC complete_aar(lnp, instr, descr_vn)
line_p lnp;
int instr;
valnum descr_vn;
STATIC void complete_aar(line_p lnp, int instr, valnum descr_vn)
{
/* Lnp is an instruction that loads the address of an array-element.
* Instr tells us what effect we should achieve; load (instr is op_lar)
@ -109,10 +101,7 @@ STATIC complete_aar(lnp, instr, descr_vn)
dlink(lnp, lindir);
}
STATIC replace(ocp, tmp, avp)
occur_p ocp;
offset tmp;
avail_p avp;
STATIC void replace(occur_p ocp, offset tmp, avail_p avp)
{
/* Replace the lines in the occurrence in ocp by a load of the
* temporary with offset tmp.
@ -143,9 +132,7 @@ STATIC replace(ocp, tmp, avp)
remove_lines(first, last);
}
STATIC append(avp, tmp)
avail_p avp;
offset tmp;
STATIC void append(avail_p avp, offset tmp)
{
/* Avp->av_found points to a line with an operator in it. This
* routine emits a sequence of instructions that saves the result
@ -177,9 +164,7 @@ STATIC append(avp, tmp)
}
}
STATIC set_replace(avp, tmp)
avail_p avp;
offset tmp;
STATIC void set_replace(avail_p avp, offset tmp)
{
/* Avp->av_occurs is now a set of occurrences, each of which will be
* replaced by a reference to a local.
@ -199,8 +184,7 @@ STATIC set_replace(avp, tmp)
}
}
STATIC int reg_score(enp)
entity_p enp;
STATIC int reg_score(entity_p enp)
{
/* Enp is a local that will go into a register.
* We return its score upto now.
@ -209,10 +193,7 @@ STATIC int reg_score(enp)
return regv_arg(enp->en_loc, 4);
}
STATIC line_p gen_mesreg(off, avp, pp)
offset off;
avail_p avp;
proc_p pp;
STATIC line_p gen_mesreg(offset off, avail_p avp, proc_p pp)
{
/* Generate a register message for the local that will hold the
* result of the expression in avp, at the appropriate place in
@ -226,9 +207,7 @@ STATIC line_p gen_mesreg(off, avp, pp)
return reg;
}
STATIC change_score(mes, score)
line_p mes;
int score;
STATIC void change_score(line_p mes, int score)
{
/* Change the score in the register message in mes to score. */
@ -242,8 +221,7 @@ STATIC change_score(mes, score)
ap->a_a.a_offset = score;
}
eliminate(pp)
proc_p pp;
void eliminate(proc_p pp)
{
/* Eliminate costly common subexpressions within procedure pp.
* We scan the available expressions in - with respect to time found -

View file

@ -3,7 +3,8 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
extern eliminate(); /* (proc_p pp)
extern void eliminate(proc_p pp);
/*
* Eliminate some of the recurrences of expressions
* that were found by the valuenumbering
* algorithm.

View file

@ -18,8 +18,7 @@
lset entities; /* Our pseudo symbol-table. */
entity_p find_entity(vn)
valnum vn;
entity_p find_entity(valnum vn)
{
/* Try to find the entity with valuenumber vn. */
@ -33,8 +32,7 @@ entity_p find_entity(vn)
return (entity_p) 0;
}
STATIC bool same_entity(enp1, enp2)
entity_p enp1, enp2;
STATIC bool same_entity(entity_p enp1, entity_p enp2)
{
if (enp1->en_kind != enp2->en_kind) return FALSE;
if (enp1->en_size != enp2->en_size) return FALSE;
@ -69,8 +67,7 @@ STATIC bool same_entity(enp1, enp2)
}
}
STATIC copy_entity(src, dst)
entity_p src, dst;
STATIC void copy_entity(entity_p src, entity_p dst)
{
dst->en_static = src->en_static;
dst->en_kind = src->en_kind;
@ -111,8 +108,7 @@ STATIC copy_entity(src, dst)
}
}
entity_p en_enter(enp)
register entity_p enp;
entity_p en_enter(entity_p enp)
{
/* Put the entity in enp in the entity set, if it is not already there.
* Return pointer to stored entity.
@ -133,7 +129,7 @@ entity_p en_enter(enp)
return new;
}
clr_entities()
void clr_entities(void)
{
/* Throw away all pseudo-symboltable information. */

View file

@ -5,16 +5,19 @@
*/
extern lset entities; /* The pseudo-symboltable. */
extern entity_p find_entity(); /* (valnum vn)
extern entity_p find_entity(valnum vn);
/*
* Tries to find an entity with value number vn.
*/
extern entity_p en_enter(); /* (entity_p enp)
extern entity_p en_enter(entity_p enp);
/*
* Enter the entity in enp in the set of
* entities if it was not already there.
*/
extern clr_entities(); /* ()
extern void clr_entities(void);
/*
* Release all space occupied by our
* pseudo-symboltable.
*/

View file

@ -67,8 +67,7 @@ STATIC struct inf_entity {
#define ENKIND(ip) ip->inf_used
#define SIZEINF(ip) ip->inf_size
STATIC struct inf_entity *getinf(n)
int n;
STATIC struct inf_entity *getinf(int n)
{
struct inf_entity *ip;
@ -78,8 +77,7 @@ STATIC struct inf_entity *getinf(n)
return (struct inf_entity *) 0;
}
entity_p getentity(lnp, l_out)
line_p lnp, *l_out;
entity_p getentity(line_p lnp, line_p *l_out)
{
/* Build the entities where lnp refers to, and enter them.
* If a token needs to be popped, the first line that pushed

View file

@ -3,7 +3,8 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
extern entity_p getentity(); /* (line_p lnp, *l_out)
extern entity_p getentity(line_p lnp, line_p *l_out);
/*
* Extract the entity lnp refers and enter it
* in the table of entities. The main entity
* lnp refers to is returned; sometimes there

View file

@ -16,9 +16,9 @@
#include "cs_debug.h"
#include "cs_avail.h"
#include "cs_entity.h"
#include "cs_kill.h"
STATIC base_valno(enp)
entity_p enp;
STATIC valnum base_valno(entity_p enp)
{
/* Return the value number of the (base) address of an indirectly
* accessed entity.
@ -37,8 +37,7 @@ STATIC base_valno(enp)
/* NOTREACHED */
}
STATIC entity_p find_base(vn)
valnum vn;
STATIC entity_p find_base(valnum vn)
{
/* Vn is the valuenumber of the (base) address of an indirectly
* accessed entity. Return the entity that holds this address
@ -79,8 +78,7 @@ STATIC entity_p find_base(vn)
return (entity_p) 0;
}
STATIC bool obj_overlap(op1, op2)
obj_p op1, op2;
STATIC bool obj_overlap(obj_p op1, obj_p op2)
{
/* Op1 and op2 point to two objects in the same datablock.
* Obj_overlap returns whether these objects might overlap.
@ -97,8 +95,7 @@ STATIC bool obj_overlap(op1, op2)
#define same_datablock(o1, o2) ((o1)->o_dblock == (o2)->o_dblock)
STATIC bool addr_local(enp)
entity_p enp;
STATIC bool addr_local(entity_p enp)
{
/* Is enp the address of a stack item. */
@ -108,17 +105,14 @@ STATIC bool addr_local(enp)
enp->en_kind == ENAARGBASE;
}
STATIC bool addr_external(enp)
entity_p enp;
STATIC bool addr_external(entity_p enp)
{
/* Is enp the address of an external. */
return enp != (entity_p) 0 && enp->en_kind == ENAEXTERNAL;
}
STATIC kill_external(obp, indir)
obj_p obp;
int indir;
STATIC void kill_external(obj_p obp, int indir)
{
/* A store is done via the object in obp. If this store is direct
* we kill directly accessed entities in the same data block only
@ -164,8 +158,7 @@ STATIC kill_external(obp, indir)
}
}
STATIC bool loc_overlap(enp1, enp2)
entity_p enp1, enp2;
STATIC bool loc_overlap(entity_p enp1, entity_p enp2)
{
/* Enp1 and enp2 point to two locals. Loc_overlap returns whether
* they overlap.
@ -184,9 +177,7 @@ STATIC bool loc_overlap(enp1, enp2)
enp1->en_loc + enp1->en_size > enp2->en_loc;
}
STATIC kill_local(enp, indir)
entity_p enp;
bool indir;
STATIC void kill_local(entity_p enp, bool indir)
{
/* This time a store is done into an ENLOCAL. */
@ -234,7 +225,7 @@ STATIC kill_local(enp, indir)
}
}
STATIC void kill_sim()
STATIC void kill_sim(void)
{
/* A store is done into the ENIGNMASK. */
@ -252,8 +243,7 @@ STATIC void kill_sim()
}
}
kill_direct(enp)
entity_p enp;
void kill_direct(entity_p enp)
{
/* A store will be done into enp. We must forget the values of all the
* entities this one may overlap with.
@ -274,8 +264,7 @@ kill_direct(enp)
}
}
kill_indir(enp)
entity_p enp;
void kill_indir(entity_p enp)
{
/* An indirect store is done, in an ENINDIR,
* an ENOFFSETTED or an ENARRELEM.
@ -306,7 +295,7 @@ kill_indir(enp)
}
}
kill_much()
extern void kill_much(void)
{
/* Kills all killable entities,
* except the locals for which a registermessage was generated.
@ -324,8 +313,7 @@ kill_much()
}
}
STATIC bool bad_procflags(pp)
proc_p pp;
STATIC bool bad_procflags(proc_p pp)
{
/* Return whether the flags about the procedure in pp indicate
* that we have little information about it. It might be that
@ -335,8 +323,7 @@ STATIC bool bad_procflags(pp)
return !(pp->p_flags1 & PF_BODYSEEN) || (pp->p_flags1 & PF_CALUNKNOWN);
}
STATIC kill_globset(s)
cset s;
STATIC void kill_globset(cset s)
{
/* S is a set of global variables that might be changed.
* We act as if a direct store is done into each of them.
@ -349,8 +336,7 @@ STATIC kill_globset(s)
}
}
kill_call(pp)
proc_p pp;
void kill_call(proc_p pp)
{
/* Kill everything that might be destroyed by calling
* the procedure in pp.
@ -367,7 +353,7 @@ kill_call(pp)
}
}
kill_all()
void kill_all(void)
{
/* Kills all entities. */

View file

@ -3,27 +3,32 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
extern kill_call(); /* (proc_p pp)
extern void kill_call(proc_p pp);
/*
* Kill all entities that might have an other value
* after execution of the procedure in pp.
*/
extern kill_much(); /* ()
extern void kill_much(void);
/*
* Kill all killable entities except those for which
* a register message was generated.
* Constants, addresses, etc are not killable.
*/
extern kill_indir(); /* (entity_p enp)
extern void kill_indir(entity_p enp);
/*
* Kill all entities that might have an other value
* after indirect assignment to the entity in enp.
*/
extern kill_direct(); /* (entity_p enp)
extern void kill_direct(entity_p enp);
/*
* Kill all entities that might have an other value
* after direct assignment to the entity in enp.
*/
extern kill_all(); /* ()
extern void kill_all(void);
/*
* Kill all entities.
*/

View file

@ -178,8 +178,7 @@ STATIC struct {
#define AVSIZE(l) (info[INSTR(l)].i_av)
#define REGTYPE(n) (info[n].i_regtype)
int instrgroup(lnp)
line_p lnp;
int instrgroup(line_p lnp)
{
if (INSTR(lnp) == op_lor && SHORT(lnp) == 1) {
/* We can't do anything with the stackpointer. */
@ -192,8 +191,7 @@ int instrgroup(lnp)
return GROUP(INSTR(lnp));
}
bool stack_group(instr)
int instr;
bool stack_group(int instr)
{
/* Is this an instruction that only does something to the top of
* the stack?
@ -211,8 +209,7 @@ bool stack_group(instr)
}
}
STATIC offset argw(lnp)
line_p lnp;
STATIC offset argw(line_p lnp)
{
/* Some EM-instructions have their argument either on the same line,
* or on top of the stack. We give up when the argument is on top of
@ -228,8 +225,7 @@ STATIC offset argw(lnp)
}
}
offset op11size(lnp)
line_p lnp;
offset op11size(line_p lnp)
{
/* Returns the size of the first argument of
* the unary operator in lnp.
@ -248,8 +244,7 @@ offset op11size(lnp)
/* NOTREACHED */
}
offset op12size(lnp)
line_p lnp;
offset op12size(line_p lnp)
{
/* Same for first of binary. */
@ -264,8 +259,7 @@ offset op12size(lnp)
/* NOTREACHED */
}
offset op22size(lnp)
line_p lnp;
offset op22size(line_p lnp)
{
switch (OP2SIZE(lnp)) {
case ARGW:
@ -319,8 +313,7 @@ offset op33size(lnp)
return ws;
}
offset avsize(lnp)
line_p lnp;
offset avsize(line_p lnp)
{
/* Returns the size of the result of the instruction in lnp.
* If the instruction is a conversion this size is given on the stack.
@ -359,8 +352,7 @@ offset avsize(lnp)
/* NOTREACHED */
}
int regtype(instr)
byte instr;
int regtype(byte instr)
{
switch (REGTYPE(instr & BMASK)) {
case ANY:

View file

@ -7,53 +7,63 @@
* "manageable chunks.
*/
extern int instrgroup(); /* (line_p lnp)
extern int instrgroup(line_p lnp);
/*
* Return the group into which the instruction
* in lnp belongs to.
*/
extern bool stack_group(); /* (int instr)
extern bool stack_group(int instr);
/*
* Return whether instr is an instruction that
* only changes the state of the stack, i.e.
* is a "true" operator.
*/
extern offset op11size(); /* (line_p lnp)
extern offset op11size(line_p lnp);
/*
* Return the size of the operand of the unary
* operator in lnp.
*/
extern offset op12size(); /* (line_p lnp)
extern offset op12size(line_p lnp);
/*
* Return the size of the first operand of the
* binary operator in lnp.
*/
extern offset op22size(); /* (line_p lnp)
extern offset op22size(line_p lnp);
/*
* Return the size of the second operand of the
* binary operator in lnp.
*/
extern offset op13size(); /* (line_p lnp)
extern offset op13size(line_p lnp);
/*
* Return the size of the first operand of the
* ternary operator in lnp.
*/
extern offset op23size(); /* (line_p lnp)
extern offset op23size(line_p lnp);
/*
* Return the size of the second operand of the
* ternary operator in lnp.
*/
extern offset op33size(); /* (line_p lnp)
extern offset op33size(line_p lnp);
/*
* Return the size of the third operand of the
* ternary operator in lnp.
*/
extern offset avsize(); /* (line_p lnp)
extern offset avsize(line_p lnp);
/*
* Return the size of the result of the
* operator in lnp.
*/
extern int regtype(); /* (byte instr)
extern int regtype(byte instr);
/*
* Return in what kind of machine-register
* the result of instr should be stored:
* pointer, float, or any.

View file

@ -26,9 +26,7 @@ STATIC cset sli_counts;
STATIC short LX_threshold;
STATIC short AR_limit;
STATIC get_instrs(f, s_p)
FILE *f;
cset *s_p;
STATIC void get_instrs(FILE *f, cset *s_p)
{
/* Read a set of integers from inputfile f into *s_p.
* Such a set must be delimited by a negative number.
@ -42,9 +40,7 @@ STATIC get_instrs(f, s_p)
}
}
STATIC choose_cset(f, s_p, max)
FILE *f;
cset *s_p;
STATIC void choose_cset(FILE *f, cset *s_p, int max)
{
/* Read two compact sets of integers from inputfile f.
* Choose the first if we optimize with respect to time,
@ -115,8 +111,7 @@ void cs_machinit(void *vp)
choose_cset(f, &forbidden, sp_lmnem);
}
STATIC bool sli_no_eliminate(lnp)
line_p lnp;
STATIC bool sli_no_eliminate(line_p lnp)
{
/* Return whether the SLI-instruction in lnp is part of
* an array-index computation, and should not be eliminated.
@ -130,8 +125,7 @@ STATIC bool sli_no_eliminate(lnp)
;
}
STATIC bool gains(avp)
avail_p avp;
STATIC bool gains(avail_p avp)
{
/* Return whether we can gain something, when we eliminate
* an expression such as in avp. We just glue together some
@ -161,9 +155,7 @@ STATIC bool gains(avp)
return TRUE;
}
STATIC bool okay_lines(avp, ocp)
avail_p avp;
occur_p ocp;
STATIC bool okay_lines(avail_p avp, occur_p ocp)
{
register line_p lnp, next;
offset sz;

View file

@ -23,8 +23,7 @@ STATIC token_p free_token;
#define Stack_empty() (free_token == &Stack[0])
#define Top (free_token - 1)
Push(tkp)
token_p tkp;
void Push(token_p tkp)
{
if (tkp->tk_size == UNKNOWN_SIZE) {
Empty_stack(); /* The contents of the Stack is useless. */
@ -39,10 +38,7 @@ Push(tkp)
#define WORD_MULTIPLE(n) ((n / ws) * ws + ( n % ws ? ws : 0 ))
void
Pop(tkp, size)
token_p tkp;
offset size;
void Pop(token_p tkp, offset size)
{
/* Pop a token with given size from the valuenumber stack into tkp. */
@ -85,8 +81,7 @@ Pop(tkp, size)
}
}
Dup(lnp)
line_p lnp;
void Dup(line_p lnp)
{
/* Duplicate top bytes on the Stack. */
@ -132,7 +127,7 @@ Dup(lnp)
}
}
clr_stack()
void clr_stack(void)
{
free_token = &Stack[0];
}

View file

@ -3,21 +3,25 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
extern Push(); /* (token_p tkp)
extern void Push(token_p tkp);
/*
* Push the token in tkp on the fake-stack.
*/
extern Pop(); /* (token_p tkp; offset size)
extern void Pop(token_p tkp, offset size);
/*
* Pop a token of size bytes from the fake-stack
* into tkp. If such a token is not there
* we put a dummy in tkp and adjust the fake-stack.
*/
extern Dup(); /* (line_p lnp)
extern void Dup(line_p lnp);
/*
* Reflect the changes made by the dup-instruction
* in lnp to the EM-stack into the fake-stack.
*/
extern clr_stack(); /* ()
extern void clr_stack(void);
/*
* Clear the fake-stack.
*/

View file

@ -21,9 +21,7 @@
#include "cs_partit.h"
#include "cs_getent.h"
STATIC push_entity(enp, lfirst)
entity_p enp;
line_p lfirst;
STATIC void push_entity(entity_p enp, line_p lfirst)
{
/* Build token and Push it. */
@ -35,10 +33,8 @@ STATIC push_entity(enp, lfirst)
Push(&tk);
}
STATIC put_expensive_load(bp, lnp, lfirst, enp)
bblock_p bp;
line_p lnp, lfirst;
entity_p enp;
STATIC void put_expensive_load(bblock_p bp, line_p lnp, line_p lfirst,
entity_p enp)
{
struct avail av;
occur_p ocp;
@ -52,10 +48,7 @@ STATIC put_expensive_load(bp, lnp, lfirst, enp)
av_enter(&av, ocp, EXPENSIVE_LOAD);
}
STATIC put_aar(bp, lnp, lfirst, enp)
bblock_p bp;
line_p lnp, lfirst;
entity_p enp;
STATIC void put_aar(bblock_p bp, line_p lnp, line_p lfirst, entity_p enp)
{
/* Enp points to an ENARRELEM. We do as if its address was computed. */
@ -74,9 +67,7 @@ STATIC put_aar(bp, lnp, lfirst, enp)
av_enter(&av, ocp, TERNAIR_OP);
}
STATIC push_avail(avp, lfirst)
avail_p avp;
line_p lfirst;
STATIC void push_avail(avail_p avp, line_p lfirst)
{
struct token tk;
@ -86,10 +77,7 @@ STATIC push_avail(avp, lfirst)
Push(&tk);
}
STATIC push_unair_op(bp, lnp, tkp1)
bblock_p bp;
line_p lnp;
token_p tkp1;
STATIC void push_unair_op(bblock_p bp, line_p lnp, token_p tkp1)
{
struct avail av;
occur_p ocp;
@ -103,10 +91,7 @@ STATIC push_unair_op(bp, lnp, tkp1)
push_avail(av_enter(&av, ocp, UNAIR_OP), tkp1->tk_lfirst);
}
STATIC push_binair_op(bp, lnp, tkp1, tkp2)
bblock_p bp;
line_p lnp;
token_p tkp1, tkp2;
STATIC void push_binair_op(bblock_p bp, line_p lnp, token_p tkp1, token_p tkp2)
{
struct avail av;
occur_p ocp;
@ -121,10 +106,8 @@ STATIC push_binair_op(bp, lnp, tkp1, tkp2)
push_avail(av_enter(&av, ocp, BINAIR_OP), tkp1->tk_lfirst);
}
STATIC push_ternair_op(bp, lnp, tkp1, tkp2, tkp3)
bblock_p bp;
line_p lnp;
token_p tkp1, tkp2, tkp3;
STATIC void push_ternair_op(bblock_p bp, line_p lnp, token_p tkp1,
token_p tkp2, token_p tkp3)
{
struct avail av;
occur_p ocp;
@ -140,8 +123,7 @@ STATIC push_ternair_op(bp, lnp, tkp1, tkp2, tkp3)
push_avail(av_enter(&av, ocp, TERNAIR_OP), tkp1->tk_lfirst);
}
STATIC fiddle_stack(lnp)
line_p lnp;
STATIC void fiddle_stack(line_p lnp)
{
/* The instruction in lnp does something to the valuenumber-stack. */
@ -232,8 +214,7 @@ STATIC proc_p find_proc(vn)
return (proc_p) 0;
}
STATIC side_effects(lnp)
line_p lnp;
STATIC void side_effects(line_p lnp)
{
/* Lnp contains a cai or cal instruction. We try to find the callee
* and see what side-effects it has.
@ -255,8 +236,7 @@ STATIC side_effects(lnp)
}
}
hopeless(instr)
int instr;
STATIC void hopeless(int instr)
{
/* The effect of `instr' is too difficult to
* compute. We assume worst case behaviour.
@ -281,8 +261,7 @@ hopeless(instr)
}
}
vnm(bp)
bblock_p bp;
void vnm(bblock_p bp)
{
register line_p lnp;
register entity_p rep;

View file

@ -3,7 +3,8 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
extern vnm(); /* (bblock_p bp)
extern void vnm(bblock_p bp);
/*
* Performs the valuenumbering algorithm on the basic
* block in bp.
*/

View file

@ -102,7 +102,7 @@ register save costs:
17 -> (102,136)
18 -> (108,144)
19 -> (114,152)
20 -> (120,160)
20 -> (120,160)
21 -> (126,168)
22 -> (132,176)
23 -> (138,184)

View file

@ -36,7 +36,7 @@ line_p reg_mes(offset tmp, short size, int typ, int score);
bool dom(bblock_p b1, bblock_p b2);
/*
* See if b1 dominates b2. Note that a
* block always * dominates itself.
* block always dominates itself.
*/
bblock_p common_dom(bblock_p a, bblock_p b);
/*

View file

@ -40,13 +40,13 @@ extern int ws; /* word size */
#define UNKNOWN_SIZE (-1)
extern proc_p curproc; /* current procedure */
extern proc_p curproc; /* current procedure */
extern char *filename; /* name of current input file */
extern char *filename; /* name of current input file */
extern lset mesregs; /* set of MES ms_reg pseudos */
extern short time_space_ratio; /* 0 if optimizing for space only,
extern short time_space_ratio; /* 0 if optimizing for space only,
* 100 if optimizing for time only,
* else something 'in between'.
*/

View file

@ -65,9 +65,8 @@ STATIC void sp_machinit(void *vp)
}
fscanf(f,"%d",&globl_sp_allowed);
}
comb_asps(l1,l2,b)
line_p l1,l2;
bblock_p b;
STATIC void comb_asps(line_p l1, line_p l2, bblock_p b)
{
assert(INSTR(l1) == op_asp);
assert(INSTR(l2) == op_asp);
@ -78,11 +77,7 @@ comb_asps(l1,l2,b)
rm_line(l1,b);
}
stack_pollution(b)
bblock_p b;
STATIC void stack_pollution(bblock_p b)
{
/* For every pair of successive ASP instructions in basic
* block b, try to combine the two into one ASP.
@ -134,8 +129,7 @@ stack_pollution(b)
} while (asp != (line_p) 0);
}
STATIC bool block_save(b)
bblock_p b;
STATIC bool block_save(bblock_p b)
{
register line_p l;
@ -159,10 +153,7 @@ STATIC bool block_save(b)
return stack_diff >= 0;
}
STATIC mark_pred(b)
bblock_p b;
STATIC void mark_pred(bblock_p b)
{
Lindex i;
bblock_p x;
@ -176,12 +167,7 @@ STATIC mark_pred(b)
}
}
STATIC mark_unsave_blocks(p)
proc_p p;
STATIC void mark_unsave_blocks(proc_p p)
{
register bblock_p b;
@ -193,8 +179,7 @@ STATIC mark_unsave_blocks(p)
}
}
void sp_optimize(void *vp)
STATIC void sp_optimize(void *vp)
{
proc_p p = vp;
register bblock_p b;
@ -206,21 +191,13 @@ void sp_optimize(void *vp)
}
}
main(argc,argv)
int argc;
char *argv[];
int main(int argc, char *argv[])
{
go(argc,argv,no_action,sp_optimize,sp_machinit,no_action);
report("stack adjustments deleted",Ssp);
exit(0);
}
/***** DEBUGGING:
debug_stack_pollution(p)